From 19d7df69fdb2636856dc8919de72fc1bf8f79598 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Thu, 1 Feb 2018 08:49:23 +0100 Subject: [PATCH 001/942] xfrm: Refuse to insert 32 bit userspace socket policies on 64 bit systems We don't have a compat layer for xfrm, so userspace and kernel structures have different sizes in this case. This results in a broken configuration, so refuse to configure socket policies when trying to insert from 32 bit userspace as we do it already with policies inserted via netlink. Reported-and-tested-by: syzbot+e1a1577ca8bcb47b769a@syzkaller.appspotmail.com Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_state.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 54e21f19d722..f9d2f2233f09 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -2056,6 +2056,11 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen struct xfrm_mgr *km; struct xfrm_policy *pol = NULL; +#ifdef CONFIG_COMPAT + if (in_compat_syscall()) + return -EOPNOTSUPP; +#endif + if (!optval && !optlen) { xfrm_sk_policy_insert(sk, XFRM_POLICY_IN, NULL); xfrm_sk_policy_insert(sk, XFRM_POLICY_OUT, NULL); From 4b20f44e41b421be608756c395ccf4fcb1305824 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 5 Feb 2018 18:05:00 +0100 Subject: [PATCH 002/942] ASoC: samsung: Add the DT binding files entry to MAINTAINERS This patch adds missing DT binding files to the Samsung ASoC drivers entry. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 87a5120d5d47..930fd1e32f12 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11923,6 +11923,7 @@ M: Sylwester Nawrocki L: alsa-devel@alsa-project.org (moderated for non-subscribers) S: Supported F: sound/soc/samsung/ +F: Documentation/devicetree/bindings/sound/samsung* SAMSUNG EXYNOS PSEUDO RANDOM NUMBER GENERATOR (RNG) DRIVER M: Krzysztof Kozlowski From 041e74b71491acadad74b275e8b05add165d92b4 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 5 Feb 2018 18:29:56 +0800 Subject: [PATCH 003/942] ASoC: rt5659: Add the support of Intel HDA Header The patch adds the support of Intel HDA Header. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- include/sound/rt5659.h | 1 + sound/soc/codecs/rt5659.c | 118 ++++++++++++++++++++++++++++++++++++-- sound/soc/codecs/rt5659.h | 3 +- 3 files changed, 117 insertions(+), 5 deletions(-) diff --git a/include/sound/rt5659.h b/include/sound/rt5659.h index 656c4d58948d..9012e2b25360 100644 --- a/include/sound/rt5659.h +++ b/include/sound/rt5659.h @@ -30,6 +30,7 @@ enum rt5659_dmic2_data_pin { enum rt5659_jd_src { RT5659_JD_NULL, RT5659_JD3, + RT5659_JD_HDA_HEADER, }; struct rt5659_platform_data { diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index 07e7757417bc..dbc7dbfe8c6f 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -1461,6 +1461,61 @@ static void rt5659_jack_detect_work(struct work_struct *work) SND_JACK_BTN_2 | SND_JACK_BTN_3); } +static void rt5659_jack_detect_intel_hd_header(struct work_struct *work) +{ + struct rt5659_priv *rt5659 = + container_of(work, struct rt5659_priv, jack_detect_work.work); + unsigned int value; + bool hp_flag, mic_flag; + + if (!rt5659->hs_jack) + return; + + /* headphone jack */ + regmap_read(rt5659->regmap, RT5659_GPIO_STA, &value); + hp_flag = (!(value & 0x8)) ? true : false; + + if (hp_flag != rt5659->hda_hp_plugged) { + rt5659->hda_hp_plugged = hp_flag; + + if (hp_flag) { + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1, + 0x10, 0x0); + rt5659->jack_type |= SND_JACK_HEADPHONE; + } else { + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1, + 0x10, 0x10); + rt5659->jack_type = rt5659->jack_type & + (~SND_JACK_HEADPHONE); + } + + snd_soc_jack_report(rt5659->hs_jack, rt5659->jack_type, + SND_JACK_HEADPHONE); + } + + /* mic jack */ + regmap_read(rt5659->regmap, RT5659_4BTN_IL_CMD_1, &value); + regmap_write(rt5659->regmap, RT5659_4BTN_IL_CMD_1, value); + mic_flag = (value & 0x2000) ? true : false; + + if (mic_flag != rt5659->hda_mic_plugged) { + rt5659->hda_mic_plugged = mic_flag; + if (mic_flag) { + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2, + 0x2, 0x2); + rt5659->jack_type |= SND_JACK_MICROPHONE; + } else { + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2, + 0x2, 0x0); + rt5659->jack_type = rt5659->jack_type + & (~SND_JACK_MICROPHONE); + } + + snd_soc_jack_report(rt5659->hs_jack, rt5659->jack_type, + SND_JACK_MICROPHONE); + } +} + static const struct snd_kcontrol_new rt5659_snd_controls[] = { /* Speaker Output Volume */ SOC_DOUBLE_TLV("Speaker Playback Volume", RT5659_SPO_VOL, @@ -3990,6 +4045,54 @@ static void rt5659_calibrate(struct rt5659_priv *rt5659) regmap_write(rt5659->regmap, RT5659_HP_CHARGE_PUMP_1, 0x0c16); } +void rt5659_intel_hd_header_probe_setup(struct rt5659_priv *rt5659) +{ + int value; + + regmap_read(rt5659->regmap, RT5659_GPIO_STA, &value); + if (!(value & 0x8)) { + rt5659->hda_hp_plugged = true; + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1, + 0x10, 0x0); + } else { + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_1, + 0x10, 0x10); + } + + regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1, + RT5659_PWR_VREF2 | RT5659_PWR_MB, + RT5659_PWR_VREF2 | RT5659_PWR_MB); + msleep(20); + regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_1, + RT5659_PWR_FV2, RT5659_PWR_FV2); + + regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_3, RT5659_PWR_LDO2, + RT5659_PWR_LDO2); + regmap_update_bits(rt5659->regmap, RT5659_PWR_ANLG_2, RT5659_PWR_MB1, + RT5659_PWR_MB1); + regmap_update_bits(rt5659->regmap, RT5659_PWR_VOL, RT5659_PWR_MIC_DET, + RT5659_PWR_MIC_DET); + msleep(20); + + regmap_update_bits(rt5659->regmap, RT5659_4BTN_IL_CMD_2, + RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_EN); + regmap_read(rt5659->regmap, RT5659_4BTN_IL_CMD_1, &value); + regmap_write(rt5659->regmap, RT5659_4BTN_IL_CMD_1, value); + regmap_read(rt5659->regmap, RT5659_4BTN_IL_CMD_1, &value); + + if (value & 0x2000) { + rt5659->hda_mic_plugged = true; + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2, + 0x2, 0x2); + } else { + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2, + 0x2, 0x0); + } + + regmap_update_bits(rt5659->regmap, RT5659_IRQ_CTRL_2, + RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_EN); +} + static int rt5659_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { @@ -4174,16 +4277,23 @@ static int rt5659_i2c_probe(struct i2c_client *i2c, RT5659_PWR_MB, RT5659_PWR_MB); regmap_write(rt5659->regmap, RT5659_PWR_ANLG_2, 0x0001); regmap_write(rt5659->regmap, RT5659_IRQ_CTRL_2, 0x0040); + INIT_DELAYED_WORK(&rt5659->jack_detect_work, + rt5659_jack_detect_work); break; - case RT5659_JD_NULL: + case RT5659_JD_HDA_HEADER: + regmap_write(rt5659->regmap, RT5659_GPIO_CTRL_3, 0x8000); + regmap_write(rt5659->regmap, RT5659_RC_CLK_CTRL, 0x0900); + regmap_write(rt5659->regmap, RT5659_EJD_CTRL_1, 0x70c0); + regmap_write(rt5659->regmap, RT5659_JD_CTRL_1, 0x2000); + regmap_write(rt5659->regmap, RT5659_IRQ_CTRL_1, 0x0040); + INIT_DELAYED_WORK(&rt5659->jack_detect_work, + rt5659_jack_detect_intel_hd_header); + rt5659_intel_hd_header_probe_setup(rt5659); break; default: - dev_warn(&i2c->dev, "Currently, support JD3 only\n"); break; } - INIT_DELAYED_WORK(&rt5659->jack_detect_work, rt5659_jack_detect_work); - if (i2c->irq) { ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, rt5659_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING diff --git a/sound/soc/codecs/rt5659.h b/sound/soc/codecs/rt5659.h index 8f1aeef08489..bea0433c164c 100644 --- a/sound/soc/codecs/rt5659.h +++ b/sound/soc/codecs/rt5659.h @@ -1810,7 +1810,8 @@ struct rt5659_priv { int pll_out; int jack_type; - + bool hda_hp_plugged; + bool hda_mic_plugged; }; int rt5659_set_jack_detect(struct snd_soc_codec *codec, From fc734c244ab5bad427baa57e2e729d2a623b2fa1 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 11 Feb 2018 19:53:18 -0200 Subject: [PATCH 004/942] ASoC: fsl-asoc-card: Use 'snd_pcm_format_t' type when appropriate A better suited type for 'sample_format' and 'asrc_format' is 'snd_pcm_format_t'. Change the type so that the following build warnings with W=1 are gone: sound/soc/fsl/fsl-asoc-card.c:153:29: warning: incorrect type in assignment (different base types) sound/soc/fsl/fsl-asoc-card.c:153:29: expected unsigned int [unsigned] [usertype] sample_format sound/soc/fsl/fsl-asoc-card.c:153:29: got restricted snd_pcm_format_t sound/soc/fsl/fsl-asoc-card.c:258:44: warning: restricted snd_pcm_format_t degrades to integer sound/soc/fsl/fsl-asoc-card.c:525:29: warning: incorrect type in assignment (different base types) sound/soc/fsl/fsl-asoc-card.c:525:29: expected unsigned int [unsigned] [usertype] sample_format sound/soc/fsl/fsl-asoc-card.c:525:29: got restricted snd_pcm_format_t [usertype] sound/soc/fsl/fsl-asoc-card.c:680:43: warning: incorrect type in assignment (different base types) sound/soc/fsl/fsl-asoc-card.c:680:43: expected unsigned int [unsigned] [usertype] asrc_format sound/soc/fsl/fsl-asoc-card.c:680:43: got restricted snd_pcm_format_t [usertype] sound/soc/fsl/fsl-asoc-card.c:682:43: warning: incorrect type in assignment (different base types) sound/soc/fsl/fsl-asoc-card.c:682:43: expected unsigned int [unsigned] [usertype] asrc_format sound/soc/fsl/fsl-asoc-card.c:682:43: got restricted snd_pcm_format_t [usertype] Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl-asoc-card.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c index 989be518c4ed..4a6750aa3637 100644 --- a/sound/soc/fsl/fsl-asoc-card.c +++ b/sound/soc/fsl/fsl-asoc-card.c @@ -91,9 +91,9 @@ struct fsl_asoc_card_priv { struct cpu_priv cpu_priv; struct snd_soc_card card; u32 sample_rate; - u32 sample_format; + snd_pcm_format_t sample_format; u32 asrc_rate; - u32 asrc_format; + snd_pcm_format_t asrc_format; u32 dai_fmt; char name[32]; }; @@ -199,7 +199,7 @@ static int be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); snd_mask_none(mask); - snd_mask_set(mask, priv->asrc_format); + snd_mask_set(mask, (__force int)priv->asrc_format); return 0; } From 0600b3e101b718557c1851c4a3ff456aa18e4956 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 11 Feb 2018 19:53:19 -0200 Subject: [PATCH 005/942] ASoC: fsl_esai: Use 'const _be *' type for iprop The 'iprop' variable is passed as an argument to the be32_to_cpup() function, which expects a 'const _be *' type. Change the iprop variable type so that the following build warnings with W=1 are gone: sound/soc/fsl/fsl_esai.c:860:54: warning: incorrect type in argument 1 (different base types) sound/soc/fsl/fsl_esai.c:860:54: expected restricted __be32 const [usertype] *p sound/soc/fsl/fsl_esai.c:860:54: got unsigned int const [usertype] *[assigned] iprop Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_esai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index cef79a1a620b..40a700493f4c 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c @@ -788,7 +788,7 @@ static int fsl_esai_probe(struct platform_device *pdev) struct device_node *np = pdev->dev.of_node; struct fsl_esai *esai_priv; struct resource *res; - const uint32_t *iprop; + const __be32 *iprop; void __iomem *regs; int irq, ret; From cb3981b6a64e1353b4f8ee70f97583f59c9772d0 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 11 Feb 2018 19:53:20 -0200 Subject: [PATCH 006/942] ASoC: fsl_utils: Use 'const _be *' type for iprop The 'iprop' variable is passed as an argument to the be32_to_cpup() function, which expects a 'const _be *' type. Change the iprop variable type so that the following build warnings with W=1 are gone: sound/soc/fsl/fsl_utils.c:72:40: warning: incorrect type in argument 1 (different base types) sound/soc/fsl/fsl_utils.c:72:40: expected restricted __be32 const [usertype] *p sound/soc/fsl/fsl_utils.c:72:40: got unsigned int const [usertype] *[assigned] iprop sound/soc/fsl/fsl_utils.c:80:32: warning: incorrect type in argument 1 (different base types) sound/soc/fsl/fsl_utils.c:80:32: expected restricted __be32 const [usertype] *p sound/soc/fsl/fsl_utils.c:80:32: got unsigned int const [usertype] *[assigned] iprop Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c index b9e42b503a37..7592b0406370 100644 --- a/sound/soc/fsl/fsl_utils.c +++ b/sound/soc/fsl/fsl_utils.c @@ -36,7 +36,7 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np, { struct resource res; struct device_node *dma_channel_np, *dma_np; - const u32 *iprop; + const __be32 *iprop; int ret; dma_channel_np = of_parse_phandle(ssi_np, name, 0); From da18bcf72291bd4324ba249f881d7d0c205fd00a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sun, 11 Feb 2018 19:53:21 -0200 Subject: [PATCH 007/942] ASoC: fsl_ssi: Use 'const _be *' type for iprop The 'iprop' variable is passed as an argument to the be32_to_cpup() function, which expects a 'const _be *' type. Change the iprop variable type so that the following build warnings with W=1 are gone: sound/soc/fsl/fsl_ssi.c:1463:48: warning: incorrect type in argument 1 (different base types) sound/soc/fsl/fsl_ssi.c:1463:48: expected restricted __be32 const [usertype] *p sound/soc/fsl/fsl_ssi.c:1463:48: got unsigned int const [usertype] *[assigned] iprop Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index aecd00f7929d..24fb672f3c65 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -1377,7 +1377,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; const struct of_device_id *of_id; const char *p, *sprop; - const uint32_t *iprop; + const __be32 *iprop; struct resource *res; void __iomem *iomem; char name[64]; From 29c5b8fd8c07a42b07383c5fac47173d882f74b2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 8 Feb 2018 14:35:30 +0000 Subject: [PATCH 008/942] ASoC: Intel: Skylake: make function skl_clk_round_rate static The function skl_clk_round_rate is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: sound/soc/intel/skylake/skl-ssp-clk.c:250:6: warning: symbol 'skl_clk_round_rate' was not declared. Should it be static? Signed-off-by: Colin Ian King Reviewed-by: Takashi Sakamoto Acked-By: Vinod Koul Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-ssp-clk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl-ssp-clk.c b/sound/soc/intel/skylake/skl-ssp-clk.c index 7fbddf5e3b00..cda1b5fa7436 100644 --- a/sound/soc/intel/skylake/skl-ssp-clk.c +++ b/sound/soc/intel/skylake/skl-ssp-clk.c @@ -247,8 +247,8 @@ static unsigned long skl_clk_recalc_rate(struct clk_hw *hw, } /* Not supported by clk driver. Implemented to satisfy clk fw */ -long skl_clk_round_rate(struct clk_hw *hw, unsigned long rate, - unsigned long *parent_rate) +static long skl_clk_round_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *parent_rate) { return rate; } From 04ff40a983e864b586f189b4c3503b6f61263643 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Mon, 5 Feb 2018 11:38:17 +0000 Subject: [PATCH 009/942] ASoC: wm_adsp: Don't init cache from DSP memory if control is write-only For controls marked write-only don't initialize the cache from the content of the DSP memory. We stil need the cache for any new data that is written to this control, and we need to return something for a read of the ALSA control because most user-side code assumes all ALSA controls are readable. The cache is already created zero- filled so the only change needed is to skip populating it from DSP memory if the control isn't readable. Signed-off-by: Richard Fitzgerald Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 66e32f5d2917..0060aeb63a9f 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1237,9 +1237,16 @@ static int wm_coeff_init_control_caches(struct wm_adsp *dsp) if (ctl->flags & WMFW_CTL_FLAG_VOLATILE) continue; - ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); - if (ret < 0) - return ret; + /* + * For readable controls populate the cache from the DSP memory. + * For non-readable controls the cache was zero-filled when + * created so we don't need to do anything. + */ + if (!ctl->flags || (ctl->flags & WMFW_CTL_FLAG_READABLE)) { + ret = wm_coeff_read_control(ctl, ctl->cache, ctl->len); + if (ret < 0) + return ret; + } } return 0; From b44483eff7fb3b8c96ee763fe4e84c7933882709 Mon Sep 17 00:00:00 2001 From: "oder_chiou@realtek.com" Date: Mon, 5 Feb 2018 18:29:55 +0800 Subject: [PATCH 010/942] ASoC: rt5659: Remove the routing path of the power widget "LDO2" This patch removes the routing path of the power widget "LDO2", and it should be depended on the hardware design. The power widget "LDO2" should add the routing path with the MICBIAS in the machine driver that is reasonable. Signed-off-by: Oder Chiou Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index dbc7dbfe8c6f..c4a704e9a4db 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -2873,11 +2873,6 @@ static const struct snd_soc_dapm_route rt5659_dapm_routes[] = { { "I2S2", NULL, "I2S2 ASRC" }, { "I2S3", NULL, "I2S3 ASRC" }, - { "IN1P", NULL, "LDO2" }, - { "IN2P", NULL, "LDO2" }, - { "IN3P", NULL, "LDO2" }, - { "IN4P", NULL, "LDO2" }, - { "DMIC1", NULL, "DMIC L1" }, { "DMIC1", NULL, "DMIC R1" }, { "DMIC2", NULL, "DMIC L2" }, From 647d04f8e07afc7c3b7a42b3ee01a8b28db29631 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 5 Feb 2018 16:43:56 +0100 Subject: [PATCH 011/942] ASoC: samsung: i2s: Ensure the RCLK rate is properly determined If the RCLK mux clock configuration is specified in DT and no set_sysclk() callback is used in the sound card driver the sclk_srcrate field will remain set to 0, leading to an incorrect PSR divider setting. To fix this the frequency value is retrieved from the CLK_I2S_RCLK_SRC clock, so the actual RCLK mux selection is taken into account. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 233f1c9a4b6c..aeba0ae890ea 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -656,8 +656,12 @@ static int i2s_set_fmt(struct snd_soc_dai *dai, tmp |= mod_slave; break; case SND_SOC_DAIFMT_CBS_CFS: - /* Set default source clock in Master mode */ - if (i2s->rclk_srcrate == 0) + /* + * Set default source clock in Master mode, only when the + * CLK_I2S_RCLK_SRC clock is not exposed so we ensure any + * clock configuration assigned in DT is not overwritten. + */ + if (i2s->rclk_srcrate == 0 && i2s->clk_data.clks == NULL) i2s_set_sysclk(dai, SAMSUNG_I2S_RCLKSRC_0, 0, SND_SOC_CLOCK_IN); break; @@ -881,6 +885,11 @@ static int config_setup(struct i2s_dai *i2s) return 0; if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { + struct clk *rclksrc = i2s->clk_table[CLK_I2S_RCLK_SRC]; + + if (i2s->rclk_srcrate == 0 && rclksrc && !IS_ERR(rclksrc)) + i2s->rclk_srcrate = clk_get_rate(rclksrc); + psr = i2s->rclk_srcrate / i2s->frmclk / rfs; writel(((psr - 1) << 8) | PSR_PSREN, i2s->addr + I2SPSR); dev_dbg(&i2s->pdev->dev, From c95869e5c04fb0000370e7310dc892b417b8128a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:58:25 +0000 Subject: [PATCH 012/942] ASoC: ac97: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 To keep compatibilty, this patch adds snd_soc_xxx_ac97_codec() macro. These will be removed when all codec code was removed. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- include/sound/soc.h | 13 +++++-- sound/soc/codecs/ac97.c | 46 +++++++++++----------- sound/soc/soc-ac97.c | 84 +++++++++++++++++++++-------------------- 3 files changed, 77 insertions(+), 66 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 747fd583b9dc..6a11b0239f74 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -586,10 +586,17 @@ int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned int reg, unsigned int mask, unsigned int value); #ifdef CONFIG_SND_SOC_AC97_BUS -struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec); -struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, +#define snd_soc_alloc_ac97_codec(codec) \ + snd_soc_alloc_ac97_component(&codec->component) +#define snd_soc_new_ac97_codec(codec, id, id_mask) \ + snd_soc_new_ac97_component(&codec->component, id, id_mask) +#define snd_soc_free_ac97_codec(ac97) \ + snd_soc_free_ac97_component(ac97) + +struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component); +struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask); -void snd_soc_free_ac97_codec(struct snd_ac97 *ac97); +void snd_soc_free_ac97_component(struct snd_ac97 *ac97); int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops); int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops, diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index 440b4ce54376..02b4d01adb40 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c @@ -36,8 +36,8 @@ static const struct snd_soc_dapm_route ac97_routes[] = { static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); int reg = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ? AC97_PCM_FRONT_DAC_RATE : AC97_PCM_LR_ADC_RATE; @@ -65,7 +65,7 @@ static struct snd_soc_dai_driver ac97_dai = { .ops = &ac97_dai_ops, }; -static int ac97_soc_probe(struct snd_soc_codec *codec) +static int ac97_soc_probe(struct snd_soc_component *component) { struct snd_ac97 *ac97; struct snd_ac97_bus *ac97_bus; @@ -73,7 +73,7 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) int ret; /* add codec as bus device for standard ac97 */ - ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops, + ret = snd_ac97_bus(component->card->snd_card, 0, soc_ac97_ops, NULL, &ac97_bus); if (ret < 0) return ret; @@ -83,25 +83,25 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) if (ret < 0) return ret; - snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_component_set_drvdata(component, ac97); return 0; } #ifdef CONFIG_PM -static int ac97_soc_suspend(struct snd_soc_codec *codec) +static int ac97_soc_suspend(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); snd_ac97_suspend(ac97); return 0; } -static int ac97_soc_resume(struct snd_soc_codec *codec) +static int ac97_soc_resume(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); snd_ac97_resume(ac97); @@ -112,28 +112,28 @@ static int ac97_soc_resume(struct snd_soc_codec *codec) #define ac97_soc_resume NULL #endif -static const struct snd_soc_codec_driver soc_codec_dev_ac97 = { - .probe = ac97_soc_probe, - .suspend = ac97_soc_suspend, - .resume = ac97_soc_resume, - - .component_driver = { - .dapm_widgets = ac97_widgets, - .num_dapm_widgets = ARRAY_SIZE(ac97_widgets), - .dapm_routes = ac97_routes, - .num_dapm_routes = ARRAY_SIZE(ac97_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ac97 = { + .probe = ac97_soc_probe, + .suspend = ac97_soc_suspend, + .resume = ac97_soc_resume, + .dapm_widgets = ac97_widgets, + .num_dapm_widgets = ARRAY_SIZE(ac97_widgets), + .dapm_routes = ac97_routes, + .num_dapm_routes = ARRAY_SIZE(ac97_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ac97_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ac97, &ac97_dai, 1); + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ac97, &ac97_dai, 1); } static int ac97_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } diff --git a/sound/soc/soc-ac97.c b/sound/soc/soc-ac97.c index 36dae41f65fc..3f424f214bca 100644 --- a/sound/soc/soc-ac97.c +++ b/sound/soc/soc-ac97.c @@ -44,7 +44,7 @@ struct snd_ac97_gpio_priv { struct gpio_chip gpio_chip; #endif unsigned int gpios_set; - struct snd_soc_codec *codec; + struct snd_soc_component *component; }; static struct snd_ac97_bus soc_ac97_bus = { @@ -57,11 +57,11 @@ static void soc_ac97_device_release(struct device *dev) } #ifdef CONFIG_GPIOLIB -static inline struct snd_soc_codec *gpio_to_codec(struct gpio_chip *chip) +static inline struct snd_soc_component *gpio_to_component(struct gpio_chip *chip) { struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); - return gpio_priv->codec; + return gpio_priv->component; } static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) @@ -75,20 +75,22 @@ static int snd_soc_ac97_gpio_request(struct gpio_chip *chip, unsigned offset) static int snd_soc_ac97_gpio_direction_in(struct gpio_chip *chip, unsigned offset) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip); - dev_dbg(codec->dev, "set gpio %d to output\n", offset); - return snd_soc_update_bits(codec, AC97_GPIO_CFG, + dev_dbg(component->dev, "set gpio %d to output\n", offset); + return snd_soc_component_update_bits(component, AC97_GPIO_CFG, 1 << offset, 1 << offset); } static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned offset) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip); int ret; - ret = snd_soc_read(codec, AC97_GPIO_STATUS); - dev_dbg(codec->dev, "get gpio %d : %d\n", offset, + if (snd_soc_component_read(component, AC97_GPIO_STATUS, &ret) < 0) + ret = -1; + + dev_dbg(component->dev, "get gpio %d : %d\n", offset, ret < 0 ? ret : ret & (1 << offset)); return ret < 0 ? ret : !!(ret & (1 << offset)); @@ -98,22 +100,24 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip); gpio_priv->gpios_set &= ~(1 << offset); gpio_priv->gpios_set |= (!!value) << offset; - snd_soc_write(codec, AC97_GPIO_STATUS, gpio_priv->gpios_set); - dev_dbg(codec->dev, "set gpio %d to %d\n", offset, !!value); + snd_soc_component_write(component, AC97_GPIO_STATUS, + gpio_priv->gpios_set); + dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value); } static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { - struct snd_soc_codec *codec = gpio_to_codec(chip); + struct snd_soc_component *component = gpio_to_component(chip); - dev_dbg(codec->dev, "set gpio %d to output\n", offset); + dev_dbg(component->dev, "set gpio %d to output\n", offset); snd_soc_ac97_gpio_set(chip, offset, value); - return snd_soc_update_bits(codec, AC97_GPIO_CFG, 1 << offset, 0); + return snd_soc_component_update_bits(component, AC97_GPIO_CFG, + 1 << offset, 0); } static const struct gpio_chip snd_soc_ac97_gpio_chip = { @@ -128,24 +132,24 @@ static const struct gpio_chip snd_soc_ac97_gpio_chip = { }; static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct snd_ac97_gpio_priv *gpio_priv; int ret; - gpio_priv = devm_kzalloc(codec->dev, sizeof(*gpio_priv), GFP_KERNEL); + gpio_priv = devm_kzalloc(component->dev, sizeof(*gpio_priv), GFP_KERNEL); if (!gpio_priv) return -ENOMEM; ac97->gpio_priv = gpio_priv; - gpio_priv->codec = codec; + gpio_priv->component = component; gpio_priv->gpio_chip = snd_soc_ac97_gpio_chip; gpio_priv->gpio_chip.ngpio = AC97_NUM_GPIOS; - gpio_priv->gpio_chip.parent = codec->dev; + gpio_priv->gpio_chip.parent = component->dev; gpio_priv->gpio_chip.base = -1; ret = gpiochip_add_data(&gpio_priv->gpio_chip, gpio_priv); if (ret != 0) - dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); + dev_err(component->dev, "Failed to add GPIOs: %d\n", ret); return ret; } @@ -155,7 +159,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) } #else static int snd_soc_ac97_init_gpio(struct snd_ac97 *ac97, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { return 0; } @@ -166,8 +170,8 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) #endif /** - * snd_soc_alloc_ac97_codec() - Allocate new a AC'97 device - * @codec: The CODEC for which to create the AC'97 device + * snd_soc_alloc_ac97_component() - Allocate new a AC'97 device + * @component: The COMPONENT for which to create the AC'97 device * * Allocated a new snd_ac97 device and intializes it, but does not yet register * it. The caller is responsible to either call device_add(&ac97->dev) to @@ -175,7 +179,7 @@ static void snd_soc_ac97_free_gpio(struct snd_ac97 *ac97) * * Returns: A snd_ac97 device or a PTR_ERR in case of an error. */ -struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) +struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component) { struct snd_ac97 *ac97; @@ -187,26 +191,26 @@ struct snd_ac97 *snd_soc_alloc_ac97_codec(struct snd_soc_codec *codec) ac97->num = 0; ac97->dev.bus = &ac97_bus_type; - ac97->dev.parent = codec->component.card->dev; + ac97->dev.parent = component->card->dev; ac97->dev.release = soc_ac97_device_release; dev_set_name(&ac97->dev, "%d-%d:%s", - codec->component.card->snd_card->number, 0, - codec->component.name); + component->card->snd_card->number, 0, + component->name); device_initialize(&ac97->dev); return ac97; } -EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); +EXPORT_SYMBOL(snd_soc_alloc_ac97_component); /** - * snd_soc_new_ac97_codec - initailise AC97 device - * @codec: audio codec + * snd_soc_new_ac97_component - initailise AC97 device + * @component: audio component * @id: The expected device ID * @id_mask: Mask that is applied to the device ID before comparing with @id * - * Initialises AC97 codec resources for use by ad-hoc devices only. + * Initialises AC97 component resources for use by ad-hoc devices only. * * If @id is not 0 this function will reset the device, then read the ID from * the device and check if it matches the expected ID. If it doesn't match an @@ -214,20 +218,20 @@ EXPORT_SYMBOL(snd_soc_alloc_ac97_codec); * * Returns: A PTR_ERR() on failure or a valid snd_ac97 struct on success. */ -struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, +struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component, unsigned int id, unsigned int id_mask) { struct snd_ac97 *ac97; int ret; - ac97 = snd_soc_alloc_ac97_codec(codec); + ac97 = snd_soc_alloc_ac97_component(component); if (IS_ERR(ac97)) return ac97; if (id) { ret = snd_ac97_reset(ac97, false, id, id_mask); if (ret < 0) { - dev_err(codec->dev, "Failed to reset AC97 device: %d\n", + dev_err(component->dev, "Failed to reset AC97 device: %d\n", ret); goto err_put_device; } @@ -237,7 +241,7 @@ struct snd_ac97 *snd_soc_new_ac97_codec(struct snd_soc_codec *codec, if (ret) goto err_put_device; - ret = snd_soc_ac97_init_gpio(ac97, codec); + ret = snd_soc_ac97_init_gpio(ac97, component); if (ret) goto err_put_device; @@ -247,22 +251,22 @@ err_put_device: put_device(&ac97->dev); return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(snd_soc_new_ac97_codec); +EXPORT_SYMBOL_GPL(snd_soc_new_ac97_component); /** - * snd_soc_free_ac97_codec - free AC97 codec device + * snd_soc_free_ac97_component - free AC97 component device * @ac97: snd_ac97 device to be freed * - * Frees AC97 codec device resources. + * Frees AC97 component device resources. */ -void snd_soc_free_ac97_codec(struct snd_ac97 *ac97) +void snd_soc_free_ac97_component(struct snd_ac97 *ac97) { snd_soc_ac97_free_gpio(ac97); device_del(&ac97->dev); ac97->bus = NULL; put_device(&ac97->dev); } -EXPORT_SYMBOL_GPL(snd_soc_free_ac97_codec); +EXPORT_SYMBOL_GPL(snd_soc_free_ac97_component); static struct snd_ac97_reset_cfg snd_ac97_rst_cfg; From b5311eede823588b9c33774a1c4dc51843a42a41 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:58:43 +0000 Subject: [PATCH 013/942] ASoC: wm0010: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm0010.c | 179 +++++++++++++++++++------------------- 1 file changed, 88 insertions(+), 91 deletions(-) diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 0147d2fb7b0a..abd2defe7530 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c @@ -90,7 +90,7 @@ enum wm0010_state { }; struct wm0010_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct mutex lock; struct device *dev; @@ -157,9 +157,9 @@ static const char *wm0010_state_to_str(enum wm0010_state state) } /* Called with wm0010->lock held */ -static void wm0010_halt(struct snd_soc_codec *codec) +static void wm0010_halt(struct snd_soc_component *component) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned long flags; enum wm0010_state state; @@ -193,7 +193,7 @@ static void wm0010_halt(struct snd_soc_codec *codec) struct wm0010_boot_xfer { struct list_head list; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct completion *done; struct spi_message m; struct spi_transfer t; @@ -218,13 +218,13 @@ static void wm0010_mark_boot_failure(struct wm0010_priv *wm0010) static void wm0010_boot_xfer_complete(void *data) { struct wm0010_boot_xfer *xfer = data; - struct snd_soc_codec *codec = xfer->codec; - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = xfer->component; + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); u32 *out32 = xfer->t.rx_buf; int i; if (xfer->m.status != 0) { - dev_err(codec->dev, "SPI transfer failed: %d\n", + dev_err(component->dev, "SPI transfer failed: %d\n", xfer->m.status); wm0010_mark_boot_failure(wm0010); if (xfer->done) @@ -233,11 +233,11 @@ static void wm0010_boot_xfer_complete(void *data) } for (i = 0; i < xfer->t.len / 4; i++) { - dev_dbg(codec->dev, "%d: %04x\n", i, out32[i]); + dev_dbg(component->dev, "%d: %04x\n", i, out32[i]); switch (be32_to_cpu(out32[i])) { case 0xe0e0e0e0: - dev_err(codec->dev, + dev_err(component->dev, "%d: ROM error reported in stage 2\n", i); wm0010_mark_boot_failure(wm0010); break; @@ -245,82 +245,82 @@ static void wm0010_boot_xfer_complete(void *data) case 0x55555555: if (wm0010->state < WM0010_STAGE2) break; - dev_err(codec->dev, + dev_err(component->dev, "%d: ROM bootloader running in stage 2\n", i); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0000: - dev_dbg(codec->dev, "Stage2 loader running\n"); + dev_dbg(component->dev, "Stage2 loader running\n"); break; case 0x0fed0007: - dev_dbg(codec->dev, "CODE_HDR packet received\n"); + dev_dbg(component->dev, "CODE_HDR packet received\n"); break; case 0x0fed0008: - dev_dbg(codec->dev, "CODE_DATA packet received\n"); + dev_dbg(component->dev, "CODE_DATA packet received\n"); break; case 0x0fed0009: - dev_dbg(codec->dev, "Download complete\n"); + dev_dbg(component->dev, "Download complete\n"); break; case 0x0fed000c: - dev_dbg(codec->dev, "Application start\n"); + dev_dbg(component->dev, "Application start\n"); break; case 0x0fed000e: - dev_dbg(codec->dev, "PLL packet received\n"); + dev_dbg(component->dev, "PLL packet received\n"); wm0010->pll_running = true; break; case 0x0fed0025: - dev_err(codec->dev, "Device reports image too long\n"); + dev_err(component->dev, "Device reports image too long\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed002c: - dev_err(codec->dev, "Device reports bad SPI packet\n"); + dev_err(component->dev, "Device reports bad SPI packet\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0031: - dev_err(codec->dev, "Device reports SPI read overflow\n"); + dev_err(component->dev, "Device reports SPI read overflow\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0032: - dev_err(codec->dev, "Device reports SPI underclock\n"); + dev_err(component->dev, "Device reports SPI underclock\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0033: - dev_err(codec->dev, "Device reports bad header packet\n"); + dev_err(component->dev, "Device reports bad header packet\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0034: - dev_err(codec->dev, "Device reports invalid packet type\n"); + dev_err(component->dev, "Device reports invalid packet type\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0035: - dev_err(codec->dev, "Device reports data before header error\n"); + dev_err(component->dev, "Device reports data before header error\n"); wm0010_mark_boot_failure(wm0010); break; case 0x0fed0038: - dev_err(codec->dev, "Device reports invalid PLL packet\n"); + dev_err(component->dev, "Device reports invalid PLL packet\n"); break; case 0x0fed003a: - dev_err(codec->dev, "Device reports packet alignment error\n"); + dev_err(component->dev, "Device reports packet alignment error\n"); wm0010_mark_boot_failure(wm0010); break; default: - dev_err(codec->dev, "Unrecognised return 0x%x\n", + dev_err(component->dev, "Unrecognised return 0x%x\n", be32_to_cpu(out32[i])); wm0010_mark_boot_failure(wm0010); break; @@ -342,10 +342,10 @@ static void byte_swap_64(u64 *data_in, u64 *data_out, u32 len) data_out[i] = cpu_to_be64(le64_to_cpu(data_in[i])); } -static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) +static int wm0010_firmware_load(const char *name, struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); struct list_head xfer_list; struct wm0010_boot_xfer *xfer; int ret; @@ -359,9 +359,9 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) INIT_LIST_HEAD(&xfer_list); - ret = request_firmware(&fw, name, codec->dev); + ret = request_firmware(&fw, name, component->dev); if (ret != 0) { - dev_err(codec->dev, "Failed to request application(%s): %d\n", + dev_err(component->dev, "Failed to request application(%s): %d\n", name, ret); return ret; } @@ -377,25 +377,25 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) /* First record should be INFO */ if (rec->command != DFW_CMD_INFO) { - dev_err(codec->dev, "First record not INFO\r\n"); + dev_err(component->dev, "First record not INFO\r\n"); ret = -EINVAL; goto abort; } if (inforec->info_version != INFO_VERSION) { - dev_err(codec->dev, + dev_err(component->dev, "Unsupported version (%02d) of INFO record\r\n", inforec->info_version); ret = -EINVAL; goto abort; } - dev_dbg(codec->dev, "Version v%02d INFO record found\r\n", + dev_dbg(component->dev, "Version v%02d INFO record found\r\n", inforec->info_version); /* Check it's a DSP file */ if (dsp != DEVICE_ID_WM0010) { - dev_err(codec->dev, "Not a WM0010 firmware file.\r\n"); + dev_err(component->dev, "Not a WM0010 firmware file.\r\n"); ret = -EINVAL; goto abort; } @@ -405,7 +405,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) rec = (void *)&rec->data[rec->length]; while (offset < fw->size) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Packet: command %d, data length = 0x%x\r\n", rec->command, rec->length); len = rec->length + 8; @@ -416,7 +416,7 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) goto abort; } - xfer->codec = codec; + xfer->component = component; list_add_tail(&xfer->list, &xfer_list); out = kzalloc(len, GFP_KERNEL | GFP_DMA); @@ -460,18 +460,18 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) rec = (void *)&rec->data[rec->length]; if (offset >= fw->size) { - dev_dbg(codec->dev, "All transfers scheduled\n"); + dev_dbg(component->dev, "All transfers scheduled\n"); xfer->done = &done; } ret = spi_async(spi, &xfer->m); if (ret != 0) { - dev_err(codec->dev, "Write failed: %d\n", ret); + dev_err(component->dev, "Write failed: %d\n", ret); goto abort1; } if (wm0010->boot_failed) { - dev_dbg(codec->dev, "Boot fail!\n"); + dev_dbg(component->dev, "Boot fail!\n"); ret = -EINVAL; goto abort1; } @@ -496,10 +496,10 @@ abort: return ret; } -static int wm0010_stage2_load(struct snd_soc_codec *codec) +static int wm0010_stage2_load(struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); const struct firmware *fw; struct spi_message m; struct spi_transfer t; @@ -508,14 +508,14 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) int i; int ret = 0; - ret = request_firmware(&fw, "wm0010_stage2.bin", codec->dev); + ret = request_firmware(&fw, "wm0010_stage2.bin", component->dev); if (ret != 0) { - dev_err(codec->dev, "Failed to request stage2 loader: %d\n", + dev_err(component->dev, "Failed to request stage2 loader: %d\n", ret); return ret; } - dev_dbg(codec->dev, "Downloading %zu byte stage 2 loader\n", fw->size); + dev_dbg(component->dev, "Downloading %zu byte stage 2 loader\n", fw->size); /* Copy to local buffer first as vmalloc causes problems for dma */ img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); @@ -541,19 +541,19 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) t.speed_hz = wm0010->sysclk / 10; spi_message_add_tail(&t, &m); - dev_dbg(codec->dev, "Starting initial download at %dHz\n", + dev_dbg(component->dev, "Starting initial download at %dHz\n", t.speed_hz); ret = spi_sync(spi, &m); if (ret != 0) { - dev_err(codec->dev, "Initial download failed: %d\n", ret); + dev_err(component->dev, "Initial download failed: %d\n", ret); goto abort; } /* Look for errors from the boot ROM */ for (i = 0; i < fw->size; i++) { if (out[i] != 0x55) { - dev_err(codec->dev, "Boot ROM error: %x in %d\n", + dev_err(component->dev, "Boot ROM error: %x in %d\n", out[i], i); wm0010_mark_boot_failure(wm0010); ret = -EBUSY; @@ -570,10 +570,10 @@ abort2: return ret; } -static int wm0010_boot(struct snd_soc_codec *codec) +static int wm0010_boot(struct snd_soc_component *component) { - struct spi_device *spi = to_spi_device(codec->dev); - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct spi_device *spi = to_spi_device(component->dev); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned long flags; int ret; struct spi_message m; @@ -590,7 +590,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) spin_unlock_irqrestore(&wm0010->irq_lock, flags); if (wm0010->sysclk > 26000000) { - dev_err(codec->dev, "Max DSP clock frequency is 26MHz\n"); + dev_err(component->dev, "Max DSP clock frequency is 26MHz\n"); ret = -ECANCELED; goto err; } @@ -598,7 +598,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) mutex_lock(&wm0010->lock); wm0010->pll_running = false; - dev_dbg(codec->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); + dev_dbg(component->dev, "max_spi_freq: %d\n", wm0010->max_spi_freq); ret = regulator_bulk_enable(ARRAY_SIZE(wm0010->core_supplies), wm0010->core_supplies); @@ -623,19 +623,19 @@ static int wm0010_boot(struct snd_soc_codec *codec) if (!wait_for_completion_timeout(&wm0010->boot_completion, msecs_to_jiffies(20))) - dev_err(codec->dev, "Failed to get interrupt from DSP\n"); + dev_err(component->dev, "Failed to get interrupt from DSP\n"); spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_BOOTROM; spin_unlock_irqrestore(&wm0010->irq_lock, flags); - ret = wm0010_stage2_load(codec); + ret = wm0010_stage2_load(component); if (ret) goto abort; if (!wait_for_completion_timeout(&wm0010->boot_completion, msecs_to_jiffies(20))) - dev_err(codec->dev, "Failed to get interrupt from DSP loader.\n"); + dev_err(component->dev, "Failed to get interrupt from DSP loader.\n"); spin_lock_irqsave(&wm0010->irq_lock, flags); wm0010->state = WM0010_STAGE2; @@ -676,14 +676,14 @@ static int wm0010_boot(struct snd_soc_codec *codec) ret = spi_sync(spi, &m); if (ret) { - dev_err(codec->dev, "First PLL write failed: %d\n", ret); + dev_err(component->dev, "First PLL write failed: %d\n", ret); goto abort_swap; } /* Use a second send of the message to get the return status */ ret = spi_sync(spi, &m); if (ret) { - dev_err(codec->dev, "Second PLL write failed: %d\n", ret); + dev_err(component->dev, "Second PLL write failed: %d\n", ret); goto abort_swap; } @@ -692,7 +692,7 @@ static int wm0010_boot(struct snd_soc_codec *codec) /* Look for PLL active code from the DSP */ for (i = 0; i < len / 4; i++) { if (*p == 0x0e00ed0f) { - dev_dbg(codec->dev, "PLL packet received\n"); + dev_dbg(component->dev, "PLL packet received\n"); wm0010->pll_running = true; break; } @@ -702,9 +702,9 @@ static int wm0010_boot(struct snd_soc_codec *codec) kfree(img_swap); kfree(out); } else - dev_dbg(codec->dev, "Not enabling DSP PLL."); + dev_dbg(component->dev, "Not enabling DSP PLL."); - ret = wm0010_firmware_load("wm0010.dfw", codec); + ret = wm0010_firmware_load("wm0010.dfw", component); if (ret != 0) goto abort; @@ -723,7 +723,7 @@ abort_out: kfree(out); abort: /* Put the chip back into reset */ - wm0010_halt(codec); + wm0010_halt(component); mutex_unlock(&wm0010->lock); return ret; @@ -735,22 +735,22 @@ err: return ret; } -static int wm0010_set_bias_level(struct snd_soc_codec *codec, +static int wm0010_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) - wm0010_boot(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) + wm0010_boot(component); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { mutex_lock(&wm0010->lock); - wm0010_halt(codec); + wm0010_halt(component); mutex_unlock(&wm0010->lock); } break; @@ -761,10 +761,10 @@ static int wm0010_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, +static int wm0010_set_sysclk(struct snd_soc_component *component, int source, int clk_id, unsigned int freq, int dir) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); unsigned int i; wm0010->sysclk = freq; @@ -783,20 +783,19 @@ static int wm0010_set_sysclk(struct snd_soc_codec *codec, int source, return 0; } -static int wm0010_probe(struct snd_soc_codec *codec); +static int wm0010_probe(struct snd_soc_component *component); -static const struct snd_soc_codec_driver soc_codec_dev_wm0010 = { - .probe = wm0010_probe, - .set_bias_level = wm0010_set_bias_level, - .set_sysclk = wm0010_set_sysclk, - .idle_bias_off = true, - - .component_driver = { - .dapm_widgets = wm0010_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), - .dapm_routes = wm0010_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm0010 = { + .probe = wm0010_probe, + .set_bias_level = wm0010_set_bias_level, + .set_sysclk = wm0010_set_sysclk, + .dapm_widgets = wm0010_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm0010_dapm_widgets), + .dapm_routes = wm0010_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm0010_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #define WM0010_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) @@ -860,11 +859,11 @@ static irqreturn_t wm0010_irq(int irq, void *data) return IRQ_NONE; } -static int wm0010_probe(struct snd_soc_codec *codec) +static int wm0010_probe(struct snd_soc_component *component) { - struct wm0010_priv *wm0010 = snd_soc_codec_get_drvdata(codec); + struct wm0010_priv *wm0010 = snd_soc_component_get_drvdata(component); - wm0010->codec = codec; + wm0010->component = component; return 0; } @@ -967,8 +966,8 @@ static int wm0010_spi_probe(struct spi_device *spi) else wm0010->board_max_spi_speed = 0; - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm0010, wm0010_dai, + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm0010, wm0010_dai, ARRAY_SIZE(wm0010_dai)); if (ret < 0) return ret; @@ -980,8 +979,6 @@ static int wm0010_spi_remove(struct spi_device *spi) { struct wm0010_priv *wm0010 = spi_get_drvdata(spi); - snd_soc_unregister_codec(&spi->dev); - gpio_set_value_cansleep(wm0010->gpio_reset, wm0010->gpio_reset_value); From cf73dce9bc4947a777cc07b7fb7b9ff11f1e3b68 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:04:37 +0000 Subject: [PATCH 014/942] ASoC: wm8804: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8804.c | 100 +++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 51 deletions(-) diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index fc69b87443d8..89f13249966e 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c @@ -137,21 +137,21 @@ static const struct snd_soc_dapm_route wm8804_dapm_routes[] = { static int wm8804_aif_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8804_priv *wm8804 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8804_priv *wm8804 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* power up the aif */ if (!wm8804->aif_pwr) - snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0x0); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x10, 0x0); wm8804->aif_pwr++; break; case SND_SOC_DAPM_POST_PMD: /* power down only both paths are disabled */ wm8804->aif_pwr--; if (!wm8804->aif_pwr) - snd_soc_update_bits(codec, WM8804_PWRDN, 0x10, 0x10); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x10, 0x10); break; } @@ -161,8 +161,8 @@ static int wm8804_aif_event(struct snd_soc_dapm_widget *w, static int txsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val = ucontrol->value.enumerated.item[0] << e->shift_l; unsigned int mask = 1 << e->shift_l; @@ -173,18 +173,18 @@ static int txsrc_put(struct snd_kcontrol *kcontrol, snd_soc_dapm_mutex_lock(dapm); - if (snd_soc_test_bits(codec, e->reg, mask, val)) { + if (snd_soc_component_test_bits(component, e->reg, mask, val)) { /* save the current power state of the transmitter */ - txpwr = snd_soc_read(codec, WM8804_PWRDN) & 0x4; + txpwr = snd_soc_component_read32(component, WM8804_PWRDN) & 0x4; /* power down the transmitter */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, 0x4); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, 0x4); /* set the tx source */ - snd_soc_update_bits(codec, e->reg, mask, val); + snd_soc_component_update_bits(component, e->reg, mask, val); /* restore the transmitter's configuration */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x4, txpwr); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x4, txpwr); } snd_soc_dapm_mutex_unlock(dapm); @@ -218,10 +218,10 @@ static int wm8804_soft_reset(struct wm8804_priv *wm8804) static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 format, master, bcp, lrp; - codec = dai->codec; + component = dai->component; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -243,8 +243,8 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* set data format */ - snd_soc_update_bits(codec, WM8804_AIFTX, 0x3, format); - snd_soc_update_bits(codec, WM8804_AIFRX, 0x3, format); + snd_soc_component_update_bits(component, WM8804_AIFTX, 0x3, format); + snd_soc_component_update_bits(component, WM8804_AIFRX, 0x3, format); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -259,7 +259,7 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* set master/slave mode */ - snd_soc_update_bits(codec, WM8804_AIFRX, 0x40, master << 6); + snd_soc_component_update_bits(component, WM8804_AIFRX, 0x40, master << 6); bcp = lrp = 0; switch (fmt & SND_SOC_DAIFMT_INV_MASK) { @@ -280,9 +280,9 @@ static int wm8804_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* set frame inversion */ - snd_soc_update_bits(codec, WM8804_AIFTX, 0x10 | 0x20, + snd_soc_component_update_bits(component, WM8804_AIFTX, 0x10 | 0x20, (bcp << 4) | (lrp << 5)); - snd_soc_update_bits(codec, WM8804_AIFRX, 0x10 | 0x20, + snd_soc_component_update_bits(component, WM8804_AIFRX, 0x10 | 0x20, (bcp << 4) | (lrp << 5)); return 0; } @@ -291,10 +291,10 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 blen; - codec = dai->codec; + component = dai->component; switch (params_width(params)) { case 16: @@ -313,8 +313,8 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream, } /* set word length */ - snd_soc_update_bits(codec, WM8804_AIFTX, 0xc, blen << 2); - snd_soc_update_bits(codec, WM8804_AIFRX, 0xc, blen << 2); + snd_soc_component_update_bits(component, WM8804_AIFTX, 0xc, blen << 2); + snd_soc_component_update_bits(component, WM8804_AIFRX, 0xc, blen << 2); return 0; } @@ -405,8 +405,8 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct wm8804_priv *wm8804 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8804_priv *wm8804 = snd_soc_component_get_drvdata(component); bool change; if (!freq_in || !freq_out) { @@ -431,18 +431,18 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, pm_runtime_get_sync(wm8804->dev); /* set PLLN and PRESCALE */ - snd_soc_update_bits(codec, WM8804_PLL4, 0xf | 0x10, + snd_soc_component_update_bits(component, WM8804_PLL4, 0xf | 0x10, pll_div.n | (pll_div.prescale << 4)); /* set mclkdiv and freqmode */ - snd_soc_update_bits(codec, WM8804_PLL5, 0x3 | 0x8, + snd_soc_component_update_bits(component, WM8804_PLL5, 0x3 | 0x8, pll_div.freqmode | (pll_div.mclkdiv << 3)); /* set PLLK */ - snd_soc_write(codec, WM8804_PLL1, pll_div.k & 0xff); - snd_soc_write(codec, WM8804_PLL2, (pll_div.k >> 8) & 0xff); - snd_soc_write(codec, WM8804_PLL3, pll_div.k >> 16); + snd_soc_component_write(component, WM8804_PLL1, pll_div.k & 0xff); + snd_soc_component_write(component, WM8804_PLL2, (pll_div.k >> 8) & 0xff); + snd_soc_component_write(component, WM8804_PLL3, pll_div.k >> 16); /* power up the PLL */ - snd_soc_update_bits(codec, WM8804_PWRDN, 0x1, 0); + snd_soc_component_update_bits(component, WM8804_PWRDN, 0x1, 0); } return 0; @@ -451,15 +451,15 @@ static int wm8804_set_pll(struct snd_soc_dai *dai, int pll_id, static int wm8804_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; - codec = dai->codec; + component = dai->component; switch (clk_id) { case WM8804_TX_CLKSRC_MCLK: if ((freq >= 10000000 && freq <= 14400000) || (freq >= 16280000 && freq <= 27000000)) - snd_soc_update_bits(codec, WM8804_PLL6, 0x80, 0x80); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x80, 0x80); else { dev_err(dai->dev, "OSCCLOCK is not within the " "recommended range: %uHz\n", freq); @@ -467,13 +467,13 @@ static int wm8804_set_sysclk(struct snd_soc_dai *dai, } break; case WM8804_TX_CLKSRC_PLL: - snd_soc_update_bits(codec, WM8804_PLL6, 0x80, 0); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x80, 0); break; case WM8804_CLKOUT_SRC_CLK1: - snd_soc_update_bits(codec, WM8804_PLL6, 0x8, 0); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x8, 0); break; case WM8804_CLKOUT_SRC_OSCCLK: - snd_soc_update_bits(codec, WM8804_PLL6, 0x8, 0x8); + snd_soc_component_update_bits(component, WM8804_PLL6, 0x8, 0x8); break; default: dev_err(dai->dev, "Unknown clock source: %d\n", clk_id); @@ -486,17 +486,17 @@ static int wm8804_set_sysclk(struct snd_soc_dai *dai, static int wm8804_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8804_priv *wm8804; - codec = dai->codec; + component = dai->component; switch (div_id) { case WM8804_CLKOUT_DIV: - snd_soc_update_bits(codec, WM8804_PLL5, 0x30, + snd_soc_component_update_bits(component, WM8804_PLL5, 0x30, (div & 0x3) << 4); break; case WM8804_MCLK_DIV: - wm8804 = snd_soc_codec_get_drvdata(codec); + wm8804 = snd_soc_component_get_drvdata(component); wm8804->mclk_div = div; break; default: @@ -542,15 +542,14 @@ static struct snd_soc_dai_driver wm8804_dai = { .symmetric_rates = 1 }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8804 = { - .idle_bias_off = true, - - .component_driver = { - .dapm_widgets = wm8804_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8804_dapm_widgets), - .dapm_routes = wm8804_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8804_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8804 = { + .dapm_widgets = wm8804_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8804_dapm_widgets), + .dapm_routes = wm8804_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8804_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; const struct regmap_config wm8804_regmap_config = { @@ -661,7 +660,7 @@ int wm8804_probe(struct device *dev, struct regmap *regmap) } } - ret = snd_soc_register_codec(dev, &soc_codec_dev_wm8804, + ret = devm_snd_soc_register_component(dev, &soc_component_dev_wm8804, &wm8804_dai, 1); if (ret < 0) { dev_err(dev, "Failed to register CODEC: %d\n", ret); @@ -683,7 +682,6 @@ EXPORT_SYMBOL_GPL(wm8804_probe); void wm8804_remove(struct device *dev) { pm_runtime_disable(dev); - snd_soc_unregister_codec(dev); } EXPORT_SYMBOL_GPL(wm8804_remove); From cac308fcd767a077e1119901d8bdd69e31189f67 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:50:28 +0000 Subject: [PATCH 015/942] ASoC: cs4271: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs4271-i2c.c | 7 --- sound/soc/codecs/cs4271-spi.c | 7 --- sound/soc/codecs/cs4271.c | 105 +++++++++++++++++----------------- 3 files changed, 52 insertions(+), 67 deletions(-) diff --git a/sound/soc/codecs/cs4271-i2c.c b/sound/soc/codecs/cs4271-i2c.c index dcb3223d7d8f..ff737304d50b 100644 --- a/sound/soc/codecs/cs4271-i2c.c +++ b/sound/soc/codecs/cs4271-i2c.c @@ -33,12 +33,6 @@ static int cs4271_i2c_probe(struct i2c_client *client, devm_regmap_init_i2c(client, &config)); } -static int cs4271_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id cs4271_i2c_id[] = { { "cs4271", 0 }, { } @@ -51,7 +45,6 @@ static struct i2c_driver cs4271_i2c_driver = { .of_match_table = of_match_ptr(cs4271_dt_ids), }, .probe = cs4271_i2c_probe, - .remove = cs4271_i2c_remove, .id_table = cs4271_i2c_id, }; module_i2c_driver(cs4271_i2c_driver); diff --git a/sound/soc/codecs/cs4271-spi.c b/sound/soc/codecs/cs4271-spi.c index 1ff5f520196a..217f6dc869e5 100644 --- a/sound/soc/codecs/cs4271-spi.c +++ b/sound/soc/codecs/cs4271-spi.c @@ -33,19 +33,12 @@ static int cs4271_spi_probe(struct spi_device *spi) return cs4271_probe(&spi->dev, devm_regmap_init_spi(spi, &config)); } -static int cs4271_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver cs4271_spi_driver = { .driver = { .name = "cs4271", .of_match_table = of_match_ptr(cs4271_dt_ids), }, .probe = cs4271_spi_probe, - .remove = cs4271_spi_remove, }; module_spi_driver(cs4271_spi_driver); diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index 49a80627af12..849fdb2cb260 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c @@ -206,8 +206,8 @@ static const struct snd_soc_dapm_route cs4271_dapm_routes[] = { static int cs4271_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); cs4271->mclk = freq; return 0; @@ -216,8 +216,8 @@ static int cs4271_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int ret; @@ -230,7 +230,7 @@ static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, val |= CS4271_MODE1_MASTER; break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -250,7 +250,7 @@ static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, return ret; break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -263,9 +263,9 @@ static int cs4271_set_dai_fmt(struct snd_soc_dai *codec_dai, static int cs4271_deemph[] = {0, 44100, 48000, 32000}; -static int cs4271_set_deemph(struct snd_soc_codec *codec) +static int cs4271_set_deemph(struct snd_soc_component *component) { - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); int i, ret; int val = CS4271_DACCTL_DEM_DIS; @@ -289,8 +289,8 @@ static int cs4271_set_deemph(struct snd_soc_codec *codec) static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = cs4271->deemph; return 0; @@ -299,11 +299,11 @@ static int cs4271_get_deemph(struct snd_kcontrol *kcontrol, static int cs4271_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); cs4271->deemph = ucontrol->value.integer.value[0]; - return cs4271_set_deemph(codec); + return cs4271_set_deemph(component); } struct cs4271_clk_cfg { @@ -349,8 +349,8 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); int i, ret; unsigned int ratio, val; @@ -399,7 +399,7 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream, break; if (i == CS4171_NR_RATIOS) { - dev_err(codec->dev, "Invalid sample rate\n"); + dev_err(component->dev, "Invalid sample rate\n"); return -EINVAL; } @@ -410,13 +410,13 @@ static int cs4271_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - return cs4271_set_deemph(codec); + return cs4271_set_deemph(component); } static int cs4271_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { - struct snd_soc_codec *codec = dai->codec; - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); int ret; int val_a = 0; int val_b = 0; @@ -493,9 +493,9 @@ static struct snd_soc_dai_driver cs4271_dai = { .symmetric_rates = 1, }; -static int cs4271_reset(struct snd_soc_codec *codec) +static int cs4271_reset(struct snd_soc_component *component) { - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); if (gpio_is_valid(cs4271->gpio_nreset)) { gpio_direction_output(cs4271->gpio_nreset, 0); @@ -508,10 +508,10 @@ static int cs4271_reset(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int cs4271_soc_suspend(struct snd_soc_codec *codec) +static int cs4271_soc_suspend(struct snd_soc_component *component) { int ret; - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); /* Set power-down bit */ ret = regmap_update_bits(cs4271->regmap, CS4271_MODE2, @@ -525,20 +525,20 @@ static int cs4271_soc_suspend(struct snd_soc_codec *codec) return 0; } -static int cs4271_soc_resume(struct snd_soc_codec *codec) +static int cs4271_soc_resume(struct snd_soc_component *component) { int ret; - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); ret = regulator_bulk_enable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); if (ret < 0) { - dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); + dev_err(component->dev, "Failed to enable regulators: %d\n", ret); return ret; } /* Do a proper reset after power up */ - cs4271_reset(codec); + cs4271_reset(component); /* Restore codec state */ ret = regcache_sync(cs4271->regmap); @@ -567,20 +567,20 @@ MODULE_DEVICE_TABLE(of, cs4271_dt_ids); EXPORT_SYMBOL_GPL(cs4271_dt_ids); #endif -static int cs4271_codec_probe(struct snd_soc_codec *codec) +static int cs4271_component_probe(struct snd_soc_component *component) { - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); - struct cs4271_platform_data *cs4271plat = codec->dev->platform_data; + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); + struct cs4271_platform_data *cs4271plat = component->dev->platform_data; int ret; bool amutec_eq_bmutec = false; #ifdef CONFIG_OF - if (of_match_device(cs4271_dt_ids, codec->dev)) { - if (of_get_property(codec->dev->of_node, + if (of_match_device(cs4271_dt_ids, component->dev)) { + if (of_get_property(component->dev->of_node, "cirrus,amutec-eq-bmutec", NULL)) amutec_eq_bmutec = true; - if (of_get_property(codec->dev->of_node, + if (of_get_property(component->dev->of_node, "cirrus,enable-soft-reset", NULL)) cs4271->enable_soft_reset = true; } @@ -589,7 +589,7 @@ static int cs4271_codec_probe(struct snd_soc_codec *codec) ret = regulator_bulk_enable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); if (ret < 0) { - dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); + dev_err(component->dev, "Failed to enable regulators: %d\n", ret); return ret; } @@ -599,7 +599,7 @@ static int cs4271_codec_probe(struct snd_soc_codec *codec) } /* Reset codec */ - cs4271_reset(codec); + cs4271_reset(component); ret = regcache_sync(cs4271->regmap); if (ret < 0) @@ -625,9 +625,9 @@ static int cs4271_codec_probe(struct snd_soc_codec *codec) return 0; } -static int cs4271_codec_remove(struct snd_soc_codec *codec) +static void cs4271_component_remove(struct snd_soc_component *component) { - struct cs4271_private *cs4271 = snd_soc_codec_get_drvdata(codec); + struct cs4271_private *cs4271 = snd_soc_component_get_drvdata(component); if (gpio_is_valid(cs4271->gpio_nreset)) /* Set codec to the reset state */ @@ -635,24 +635,23 @@ static int cs4271_codec_remove(struct snd_soc_codec *codec) regcache_mark_dirty(cs4271->regmap); regulator_bulk_disable(ARRAY_SIZE(cs4271->supplies), cs4271->supplies); - - return 0; }; -static const struct snd_soc_codec_driver soc_codec_dev_cs4271 = { - .probe = cs4271_codec_probe, - .remove = cs4271_codec_remove, +static const struct snd_soc_component_driver soc_component_dev_cs4271 = { + .probe = cs4271_component_probe, + .remove = cs4271_component_remove, .suspend = cs4271_soc_suspend, .resume = cs4271_soc_resume, - - .component_driver = { - .controls = cs4271_snd_controls, - .num_controls = ARRAY_SIZE(cs4271_snd_controls), - .dapm_widgets = cs4271_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs4271_dapm_widgets), - .dapm_routes = cs4271_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(cs4271_dapm_routes), - }, + .controls = cs4271_snd_controls, + .num_controls = ARRAY_SIZE(cs4271_snd_controls), + .dapm_widgets = cs4271_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs4271_dapm_widgets), + .dapm_routes = cs4271_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(cs4271_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int cs4271_common_probe(struct device *dev, @@ -721,8 +720,8 @@ int cs4271_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, cs4271); cs4271->regmap = regmap; - return snd_soc_register_codec(dev, &soc_codec_dev_cs4271, &cs4271_dai, - 1); + return devm_snd_soc_register_component(dev, &soc_component_dev_cs4271, + &cs4271_dai, 1); } EXPORT_SYMBOL_GPL(cs4271_probe); From e5449affbf96cceaa042e33b0d1e5db0bd6ecf3c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:59:05 +0000 Subject: [PATCH 016/942] ASoC: wm2000: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm2000.c | 78 ++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index abfa052c07d8..c5ae07234a00 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -607,8 +607,8 @@ static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); ucontrol->value.integer.value[0] = wm2000->anc_active; @@ -618,8 +618,8 @@ static int wm2000_anc_mode_get(struct snd_kcontrol *kcontrol, static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); unsigned int anc_active = ucontrol->value.integer.value[0]; int ret; @@ -640,8 +640,8 @@ static int wm2000_anc_mode_put(struct snd_kcontrol *kcontrol, static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); ucontrol->value.integer.value[0] = wm2000->spk_ena; @@ -651,8 +651,8 @@ static int wm2000_speaker_get(struct snd_kcontrol *kcontrol, static int wm2000_speaker_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); unsigned int val = ucontrol->value.integer.value[0]; int ret; @@ -683,8 +683,8 @@ static const struct snd_kcontrol_new wm2000_controls[] = { static int wm2000_anc_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); int ret; mutex_lock(&wm2000->lock); @@ -724,16 +724,16 @@ static const struct snd_soc_dapm_route wm2000_audio_map[] = { }; #ifdef CONFIG_PM -static int wm2000_suspend(struct snd_soc_codec *codec) +static int wm2000_suspend(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); return wm2000_anc_transition(wm2000, ANC_OFF); } -static int wm2000_resume(struct snd_soc_codec *codec) +static int wm2000_resume(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); return wm2000_anc_set_mode(wm2000); } @@ -782,9 +782,9 @@ static const struct regmap_config wm2000_regmap = { .readable_reg = wm2000_readable_reg, }; -static int wm2000_probe(struct snd_soc_codec *codec) +static int wm2000_probe(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); /* This will trigger a transition to standby mode by default */ wm2000_anc_set_mode(wm2000); @@ -792,27 +792,28 @@ static int wm2000_probe(struct snd_soc_codec *codec) return 0; } -static int wm2000_remove(struct snd_soc_codec *codec) +static void wm2000_remove(struct snd_soc_component *component) { - struct wm2000_priv *wm2000 = dev_get_drvdata(codec->dev); + struct wm2000_priv *wm2000 = dev_get_drvdata(component->dev); - return wm2000_anc_transition(wm2000, ANC_OFF); + wm2000_anc_transition(wm2000, ANC_OFF); } -static const struct snd_soc_codec_driver soc_codec_dev_wm2000 = { - .probe = wm2000_probe, - .remove = wm2000_remove, - .suspend = wm2000_suspend, - .resume = wm2000_resume, - - .component_driver = { - .controls = wm2000_controls, - .num_controls = ARRAY_SIZE(wm2000_controls), - .dapm_widgets = wm2000_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm2000_dapm_widgets), - .dapm_routes = wm2000_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm2000_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm2000 = { + .probe = wm2000_probe, + .remove = wm2000_remove, + .suspend = wm2000_suspend, + .resume = wm2000_resume, + .controls = wm2000_controls, + .num_controls = ARRAY_SIZE(wm2000_controls), + .dapm_widgets = wm2000_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm2000_dapm_widgets), + .dapm_routes = wm2000_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm2000_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm2000_i2c_probe(struct i2c_client *i2c, @@ -916,7 +917,8 @@ static int wm2000_i2c_probe(struct i2c_client *i2c, wm2000_reset(wm2000); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm2000, NULL, 0); err_supplies: regulator_bulk_disable(WM2000_NUM_SUPPLIES, wm2000->supplies); @@ -926,13 +928,6 @@ out: return ret; } -static int wm2000_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static const struct i2c_device_id wm2000_i2c_id[] = { { "wm2000", 0 }, { } @@ -944,7 +939,6 @@ static struct i2c_driver wm2000_i2c_driver = { .name = "wm2000", }, .probe = wm2000_i2c_probe, - .remove = wm2000_i2c_remove, .id_table = wm2000_i2c_id, }; From 908b530863d4ae570e8005056f408ecae4862494 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:59:19 +0000 Subject: [PATCH 017/942] ASoC: wm2200: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 1 -> .use_pmdown_time = 0 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm2200.c | 157 ++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 81 deletions(-) diff --git a/sound/soc/codecs/wm2200.c b/sound/soc/codecs/wm2200.c index 5c2f5727244d..d5f4bbf27182 100644 --- a/sound/soc/codecs/wm2200.c +++ b/sound/soc/codecs/wm2200.c @@ -87,7 +87,7 @@ struct wm2200_priv { struct wm_adsp dsp[2]; struct regmap *regmap; struct device *dev; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm2200_pdata pdata; struct regulator_bulk_data core_supplies[WM2200_NUM_CORE_SUPPLIES]; @@ -1550,14 +1550,14 @@ static const struct snd_soc_dapm_route wm2200_dapm_routes[] = { WM2200_MIXER_ROUTES("LHPF2", "LHPF2"), }; -static int wm2200_probe(struct snd_soc_codec *codec) +static int wm2200_probe(struct snd_soc_component *component) { - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int ret; - wm2200->codec = codec; + wm2200->component = component; - ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 2); + ret = snd_soc_add_component_controls(component, wm_adsp_fw_controls, 2); if (ret != 0) return ret; @@ -1566,7 +1566,7 @@ static int wm2200_probe(struct snd_soc_codec *codec) static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int lrclk, bclk, fmt_val; lrclk = 0; @@ -1580,7 +1580,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) fmt_val = 2; break; default: - dev_err(codec->dev, "Unsupported DAI format %d\n", + dev_err(component->dev, "Unsupported DAI format %d\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } @@ -1599,7 +1599,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) bclk |= WM2200_AIF1_BCLK_MSTR; break; default: - dev_err(codec->dev, "Unsupported master mode %d\n", + dev_err(component->dev, "Unsupported master mode %d\n", fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; } @@ -1621,15 +1621,15 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR | + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR | WM2200_AIF1_BCLK_INV, bclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2, WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_3, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_3, WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_5, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_5, WM2200_AIF1_FMT_MASK, fmt_val); return 0; @@ -1698,8 +1698,8 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int i, bclk, lrclk, wl, fl, sr_code; int *bclk_rates; @@ -1711,7 +1711,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (fl < 0) return fl; - dev_dbg(codec->dev, "Word length %d bits, frame length %d bits\n", + dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n", wl, fl); /* Target BCLK rate */ @@ -1720,7 +1720,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, return bclk; if (!wm2200->sysclk) { - dev_err(codec->dev, "SYSCLK has no rate set\n"); + dev_err(component->dev, "SYSCLK has no rate set\n"); return -EINVAL; } @@ -1728,13 +1728,13 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (wm2200_sr_code[i] == params_rate(params)) break; if (i == ARRAY_SIZE(wm2200_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", + dev_err(component->dev, "Unsupported sample rate: %dHz\n", params_rate(params)); return -EINVAL; } sr_code = i; - dev_dbg(codec->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n", + dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n", bclk, wm2200->sysclk); if (wm2200->sysclk % 4000) @@ -1746,38 +1746,38 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream, if (bclk_rates[i] >= bclk && (bclk_rates[i] % bclk == 0)) break; if (i == WM2200_NUM_BCLK_RATES) { - dev_err(codec->dev, + dev_err(component->dev, "No valid BCLK for %dHz found from %dHz SYSCLK\n", bclk, wm2200->sysclk); return -EINVAL; } bclk = i; - dev_dbg(codec->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, + dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_DIV_MASK, bclk); lrclk = bclk_rates[bclk] / params_rate(params); - dev_dbg(codec->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); + dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || wm2200->symmetric_rates) - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_7, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_7, WM2200_AIF1RX_BCPF_MASK, lrclk); else - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_6, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_6, WM2200_AIF1TX_BCPF_MASK, lrclk); i = (wl << WM2200_AIF1TX_WL_SHIFT) | wl; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_9, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_9, WM2200_AIF1RX_WL_MASK | WM2200_AIF1RX_SLOT_LEN_MASK, i); else - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_8, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_8, WM2200_AIF1TX_WL_MASK | WM2200_AIF1TX_SLOT_LEN_MASK, i); - snd_soc_update_bits(codec, WM2200_CLOCKING_4, + snd_soc_component_update_bits(component, WM2200_CLOCKING_4, WM2200_SAMPLE_RATE_1_MASK, sr_code); return 0; @@ -1788,10 +1788,10 @@ static const struct snd_soc_dai_ops wm2200_dai_ops = { .hw_params = wm2200_hw_params, }; -static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm2200_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); int fval; switch (clk_id) { @@ -1799,7 +1799,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, break; default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; } @@ -1810,7 +1810,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, case WM2200_CLKSRC_BCLK1: break; default: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; } @@ -1820,7 +1820,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, fval = 2; break; default: - dev_err(codec->dev, "Invalid clock rate: %d\n", freq); + dev_err(component->dev, "Invalid clock rate: %d\n", freq); return -EINVAL; } @@ -1828,7 +1828,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id, * match. */ - snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK | + snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK | WM2200_SYSCLK_SRC_MASK, fval << WM2200_SYSCLK_FREQ_SHIFT | source); @@ -1936,23 +1936,23 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm2200_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); struct _fll_div factors; int ret, i, timeout; unsigned long time_left; if (!Fout) { - dev_dbg(codec->dev, "FLL disabled"); + dev_dbg(component->dev, "FLL disabled"); if (wm2200->fll_fout) - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); wm2200->fll_fout = 0; - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); return 0; } @@ -1963,7 +1963,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, case WM2200_FLL_SRC_BCLK: break; default: - dev_err(codec->dev, "Invalid FLL source %d\n", source); + dev_err(component->dev, "Invalid FLL source %d\n", source); return -EINVAL; } @@ -1972,44 +1972,44 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret; /* Disable the FLL while we reconfigure */ - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_2, WM2200_FLL_OUTDIV_MASK | WM2200_FLL_FRATIO_MASK, (factors.fll_outdiv << WM2200_FLL_OUTDIV_SHIFT) | factors.fll_fratio); if (factors.theta) { - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3, WM2200_FLL_FRACN_ENA, WM2200_FLL_FRACN_ENA); - snd_soc_update_bits(codec, WM2200_FLL_EFS_2, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_2, WM2200_FLL_EFS_ENA, WM2200_FLL_EFS_ENA); } else { - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3, WM2200_FLL_FRACN_ENA, 0); - snd_soc_update_bits(codec, WM2200_FLL_EFS_2, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_2, WM2200_FLL_EFS_ENA, 0); } - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK, factors.theta); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK, factors.n); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_7, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_7, WM2200_FLL_CLK_REF_DIV_MASK | WM2200_FLL_CLK_REF_SRC_MASK, (factors.fll_refclk_div << WM2200_FLL_CLK_REF_DIV_SHIFT) | source); - snd_soc_update_bits(codec, WM2200_FLL_EFS_1, + snd_soc_component_update_bits(component, WM2200_FLL_EFS_1, WM2200_FLL_LAMBDA_MASK, factors.lambda); /* Clear any pending completions */ try_wait_for_completion(&wm2200->fll_lock); - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); - snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, WM2200_FLL_ENA); if (i2c->irq) @@ -2017,7 +2017,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, else timeout = 50; - snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA, + snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA, WM2200_SYSCLK_ENA); /* Poll for the lock; will use the interrupt to exit quickly */ @@ -2032,10 +2032,10 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, msleep(1); } - ret = snd_soc_read(codec, + ret = snd_soc_component_read32(component, WM2200_INTERRUPT_RAW_STATUS_2); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read FLL status: %d\n", ret); continue; @@ -2044,8 +2044,8 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; } if (i == timeout) { - dev_err(codec->dev, "FLL lock timed out\n"); - pm_runtime_put(codec->dev); + dev_err(component->dev, "FLL lock timed out\n"); + pm_runtime_put(component->dev); return -ETIMEDOUT; } @@ -2053,29 +2053,29 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source, wm2200->fll_fref = Fref; wm2200->fll_fout = Fout; - dev_dbg(codec->dev, "FLL running %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL running %dHz->%dHz\n", Fref, Fout); return 0; } static int wm2200_dai_probe(struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int ret; - ret = snd_soc_read(codec, WM2200_GPIO_CTRL_1); + ret = snd_soc_component_read32(component, WM2200_GPIO_CTRL_1); if (ret >= 0) { if ((ret & WM2200_GP1_FN_MASK) != 0) { wm2200->symmetric_rates = true; val = WM2200_AIF1TX_LRCLK_SRC; } } else { - dev_err(codec->dev, "Failed to read GPIO 1 config: %d\n", ret); + dev_err(component->dev, "Failed to read GPIO 1 config: %d\n", ret); } - snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2, + snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2, WM2200_AIF1TX_LRCLK_SRC, val); return 0; @@ -2106,22 +2106,18 @@ static struct snd_soc_dai_driver wm2200_dai = { .ops = &wm2200_dai_ops, }; -static const struct snd_soc_codec_driver soc_codec_wm2200 = { - .probe = wm2200_probe, - - .idle_bias_off = true, - .ignore_pmdown_time = true, - .set_sysclk = wm2200_set_sysclk, - .set_pll = wm2200_set_fll, - - .component_driver = { - .controls = wm2200_snd_controls, - .num_controls = ARRAY_SIZE(wm2200_snd_controls), - .dapm_widgets = wm2200_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm2200_dapm_widgets), - .dapm_routes = wm2200_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm2200_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_wm2200 = { + .probe = wm2200_probe, + .set_sysclk = wm2200_set_sysclk, + .set_pll = wm2200_set_fll, + .controls = wm2200_snd_controls, + .num_controls = ARRAY_SIZE(wm2200_snd_controls), + .dapm_widgets = wm2200_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm2200_dapm_widgets), + .dapm_routes = wm2200_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm2200_dapm_routes), + .endianness = 1, + .non_legacy_dai_naming = 1, }; static irqreturn_t wm2200_irq(int irq, void *data) @@ -2408,7 +2404,7 @@ static int wm2200_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_wm2200, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_wm2200, &wm2200_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -2435,7 +2431,6 @@ static int wm2200_i2c_remove(struct i2c_client *i2c) { struct wm2200_priv *wm2200 = i2c_get_clientdata(i2c); - snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm2200); if (wm2200->pdata.reset) From 6119583847faf8db0a31a0894a537596e564ab9d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:59:35 +0000 Subject: [PATCH 018/942] ASoC: wm5100: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm5100.c | 260 ++++++++++++++++++------------------ sound/soc/codecs/wm5100.h | 2 +- sound/soc/samsung/lowland.c | 12 +- 3 files changed, 134 insertions(+), 140 deletions(-) diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 138a84efdd54..87f9a99ce978 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c @@ -55,7 +55,7 @@ struct wm5100_fll { struct wm5100_priv { struct device *dev; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regulator_bulk_data core_supplies[WM5100_NUM_CORE_SUPPLIES]; @@ -118,16 +118,16 @@ static int wm5100_sr_regs[WM5100_SYNC_SRS] = { WM5100_CLOCKING_6, }; -static int wm5100_alloc_sr(struct snd_soc_codec *codec, int rate) +static int wm5100_alloc_sr(struct snd_soc_component *component, int rate) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int sr_code, sr_free, i; for (i = 0; i < ARRAY_SIZE(wm5100_sr_code); i++) if (wm5100_sr_code[i] == rate) break; if (i == ARRAY_SIZE(wm5100_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", rate); + dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate); return -EINVAL; } sr_code = i; @@ -140,50 +140,50 @@ static int wm5100_alloc_sr(struct snd_soc_codec *codec, int rate) sr_free = i; continue; } - if ((snd_soc_read(codec, wm5100_sr_regs[i]) & + if ((snd_soc_component_read32(component, wm5100_sr_regs[i]) & WM5100_SAMPLE_RATE_1_MASK) == sr_code) break; } if (i < ARRAY_SIZE(wm5100_sr_regs)) { wm5100->sr_ref[i]++; - dev_dbg(codec->dev, "SR %dHz, slot %d, ref %d\n", + dev_dbg(component->dev, "SR %dHz, slot %d, ref %d\n", rate, i, wm5100->sr_ref[i]); return i; } if (sr_free == -1) { - dev_err(codec->dev, "All SR slots already in use\n"); + dev_err(component->dev, "All SR slots already in use\n"); return -EBUSY; } - dev_dbg(codec->dev, "Allocating SR slot %d for %dHz\n", + dev_dbg(component->dev, "Allocating SR slot %d for %dHz\n", sr_free, rate); wm5100->sr_ref[sr_free]++; - snd_soc_update_bits(codec, wm5100_sr_regs[sr_free], + snd_soc_component_update_bits(component, wm5100_sr_regs[sr_free], WM5100_SAMPLE_RATE_1_MASK, sr_code); return sr_free; } else { - dev_err(codec->dev, + dev_err(component->dev, "SR %dHz incompatible with %dHz SYSCLK and %dHz ASYNCCLK\n", rate, wm5100->sysclk, wm5100->asyncclk); return -EINVAL; } } -static void wm5100_free_sr(struct snd_soc_codec *codec, int rate) +static void wm5100_free_sr(struct snd_soc_component *component, int rate) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int i, sr_code; for (i = 0; i < ARRAY_SIZE(wm5100_sr_code); i++) if (wm5100_sr_code[i] == rate) break; if (i == ARRAY_SIZE(wm5100_sr_code)) { - dev_err(codec->dev, "Unsupported sample rate: %dHz\n", rate); + dev_err(component->dev, "Unsupported sample rate: %dHz\n", rate); return; } sr_code = wm5100_sr_code[i]; @@ -192,16 +192,16 @@ static void wm5100_free_sr(struct snd_soc_codec *codec, int rate) if (!wm5100->sr_ref[i]) continue; - if ((snd_soc_read(codec, wm5100_sr_regs[i]) & + if ((snd_soc_component_read32(component, wm5100_sr_regs[i]) & WM5100_SAMPLE_RATE_1_MASK) == sr_code) break; } if (i < ARRAY_SIZE(wm5100_sr_regs)) { wm5100->sr_ref[i]--; - dev_dbg(codec->dev, "Dereference SR %dHz, count now %d\n", + dev_dbg(component->dev, "Dereference SR %dHz, count now %d\n", rate, wm5100->sr_ref[i]); } else { - dev_warn(codec->dev, "Freeing unreferenced sample rate %dHz\n", + dev_warn(component->dev, "Freeing unreferenced sample rate %dHz\n", rate); } } @@ -733,40 +733,39 @@ WM5100_MIXER_CONTROLS("LHPF3", WM5100_HPLP3MIX_INPUT_1_SOURCE), WM5100_MIXER_CONTROLS("LHPF4", WM5100_HPLP4MIX_INPUT_1_SOURCE), }; -static void wm5100_seq_notifier(struct snd_soc_dapm_context *dapm, +static void wm5100_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); u16 val, expect, i; /* Wait for the outputs to flag themselves as enabled */ if (wm5100->out_ena[0]) { - expect = snd_soc_read(codec, WM5100_CHANNEL_ENABLES_1); + expect = snd_soc_component_read32(component, WM5100_CHANNEL_ENABLES_1); for (i = 0; i < 200; i++) { - val = snd_soc_read(codec, WM5100_OUTPUT_STATUS_1); + val = snd_soc_component_read32(component, WM5100_OUTPUT_STATUS_1); if (val == expect) { wm5100->out_ena[0] = false; break; } } if (i == 200) { - dev_err(codec->dev, "Timeout waiting for OUTPUT1 %x\n", + dev_err(component->dev, "Timeout waiting for OUTPUT1 %x\n", expect); } } if (wm5100->out_ena[1]) { - expect = snd_soc_read(codec, WM5100_OUTPUT_ENABLES_2); + expect = snd_soc_component_read32(component, WM5100_OUTPUT_ENABLES_2); for (i = 0; i < 200; i++) { - val = snd_soc_read(codec, WM5100_OUTPUT_STATUS_2); + val = snd_soc_component_read32(component, WM5100_OUTPUT_STATUS_2); if (val == expect) { wm5100->out_ena[1] = false; break; } } if (i == 200) { - dev_err(codec->dev, "Timeout waiting for OUTPUT2 %x\n", + dev_err(component->dev, "Timeout waiting for OUTPUT2 %x\n", expect); } } @@ -776,8 +775,8 @@ static int wm5100_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); switch (w->reg) { case WM5100_CHANNEL_ENABLES_1: @@ -841,17 +840,17 @@ static int wm5100_post_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int ret; - ret = snd_soc_read(codec, WM5100_INTERRUPT_RAW_STATUS_3); + ret = snd_soc_component_read32(component, WM5100_INTERRUPT_RAW_STATUS_3); ret &= WM5100_SPK_SHUTDOWN_WARN_STS | WM5100_SPK_SHUTDOWN_STS | WM5100_CLKGEN_ERR_STS | WM5100_CLKGEN_ERR_ASYNC_STS; wm5100_log_status3(wm5100, ret); - ret = snd_soc_read(codec, WM5100_INTERRUPT_RAW_STATUS_4); + ret = snd_soc_component_read32(component, WM5100_INTERRUPT_RAW_STATUS_4); wm5100_log_status4(wm5100, ret); return 0; @@ -1282,7 +1281,7 @@ static const struct reg_sequence wm5100_reva_patches[] = { static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int lrclk, bclk, mask, base; base = dai->driver->base; @@ -1298,7 +1297,7 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) mask = 2; break; default: - dev_err(codec->dev, "Unsupported DAI format %d\n", + dev_err(component->dev, "Unsupported DAI format %d\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } @@ -1317,7 +1316,7 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) bclk |= WM5100_AIF1_BCLK_MSTR; break; default: - dev_err(codec->dev, "Unsupported master mode %d\n", + dev_err(component->dev, "Unsupported master mode %d\n", fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; } @@ -1339,13 +1338,13 @@ static int wm5100_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, base + 1, WM5100_AIF1_BCLK_MSTR | + snd_soc_component_update_bits(component, base + 1, WM5100_AIF1_BCLK_MSTR | WM5100_AIF1_BCLK_INV, bclk); - snd_soc_update_bits(codec, base + 2, WM5100_AIF1TX_LRCLK_MSTR | + snd_soc_component_update_bits(component, base + 2, WM5100_AIF1TX_LRCLK_MSTR | WM5100_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, base + 3, WM5100_AIF1TX_LRCLK_MSTR | + snd_soc_component_update_bits(component, base + 3, WM5100_AIF1TX_LRCLK_MSTR | WM5100_AIF1TX_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, base + 5, WM5100_AIF1_FMT_MASK, mask); + snd_soc_component_update_bits(component, base + 5, WM5100_AIF1_FMT_MASK, mask); return 0; } @@ -1400,8 +1399,8 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); bool async = wm5100->aif_async[dai->id]; int i, base, bclk, aif_rate, lrclk, wl, fl, sr; int *bclk_rates; @@ -1416,7 +1415,7 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, if (fl < 0) return fl; - dev_dbg(codec->dev, "Word length %d bits, frame length %d bits\n", + dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n", wl, fl); /* Target BCLK rate */ @@ -1427,7 +1426,7 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, /* Root for BCLK depends on SYS/ASYNCCLK */ if (!async) { aif_rate = wm5100->sysclk; - sr = wm5100_alloc_sr(codec, params_rate(params)); + sr = wm5100_alloc_sr(component, params_rate(params)); if (sr < 0) return sr; } else { @@ -1439,23 +1438,23 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, if (params_rate(params) == wm5100_sr_code[i]) break; if (i == ARRAY_SIZE(wm5100_sr_code)) { - dev_err(codec->dev, "Invalid rate %dHzn", + dev_err(component->dev, "Invalid rate %dHzn", params_rate(params)); return -EINVAL; } /* TODO: We should really check for symmetry */ - snd_soc_update_bits(codec, WM5100_CLOCKING_8, + snd_soc_component_update_bits(component, WM5100_CLOCKING_8, WM5100_ASYNC_SAMPLE_RATE_MASK, i); } if (!aif_rate) { - dev_err(codec->dev, "%s has no rate set\n", + dev_err(component->dev, "%s has no rate set\n", async ? "ASYNCCLK" : "SYSCLK"); return -EINVAL; } - dev_dbg(codec->dev, "Target BCLK is %dHz, using %dHz %s\n", + dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz %s\n", bclk, aif_rate, async ? "ASYNCCLK" : "SYSCLK"); if (aif_rate % 4000) @@ -1467,37 +1466,37 @@ static int wm5100_hw_params(struct snd_pcm_substream *substream, if (bclk_rates[i] >= bclk && (bclk_rates[i] % bclk == 0)) break; if (i == WM5100_NUM_BCLK_RATES) { - dev_err(codec->dev, + dev_err(component->dev, "No valid BCLK for %dHz found from %dHz %s\n", bclk, aif_rate, async ? "ASYNCCLK" : "SYSCLK"); return -EINVAL; } bclk = i; - dev_dbg(codec->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); - snd_soc_update_bits(codec, base + 1, WM5100_AIF1_BCLK_FREQ_MASK, bclk); + dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]); + snd_soc_component_update_bits(component, base + 1, WM5100_AIF1_BCLK_FREQ_MASK, bclk); lrclk = bclk_rates[bclk] / params_rate(params); - dev_dbg(codec->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); + dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || wm5100->aif_symmetric[dai->id]) - snd_soc_update_bits(codec, base + 7, + snd_soc_component_update_bits(component, base + 7, WM5100_AIF1RX_BCPF_MASK, lrclk); else - snd_soc_update_bits(codec, base + 6, + snd_soc_component_update_bits(component, base + 6, WM5100_AIF1TX_BCPF_MASK, lrclk); i = (wl << WM5100_AIF1TX_WL_SHIFT) | fl; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - snd_soc_update_bits(codec, base + 9, + snd_soc_component_update_bits(component, base + 9, WM5100_AIF1RX_WL_MASK | WM5100_AIF1RX_SLOT_LEN_MASK, i); else - snd_soc_update_bits(codec, base + 8, + snd_soc_component_update_bits(component, base + 8, WM5100_AIF1TX_WL_MASK | WM5100_AIF1TX_SLOT_LEN_MASK, i); - snd_soc_update_bits(codec, base + 4, WM5100_AIF1_RATE_MASK, sr); + snd_soc_component_update_bits(component, base + 4, WM5100_AIF1_RATE_MASK, sr); return 0; } @@ -1507,10 +1506,10 @@ static const struct snd_soc_dai_ops wm5100_dai_ops = { .hw_params = wm5100_hw_params, }; -static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm5100_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int *rate_store; int fval, audio_rate, ret, reg; @@ -1529,7 +1528,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, case WM5100_CLKSRC_MCLK1: case WM5100_CLKSRC_MCLK2: case WM5100_CLKSRC_SYSCLK: - snd_soc_update_bits(codec, WM5100_CLOCKING_1, + snd_soc_component_update_bits(component, WM5100_CLOCKING_1, WM5100_CLK_32K_SRC_MASK, source); break; @@ -1550,7 +1549,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, wm5100->aif_async[clk_id - 1] = true; break; default: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; } return 0; @@ -1559,35 +1558,35 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, switch (freq) { case 5644800: case 6144000: - snd_soc_update_bits(codec, WM5100_MISC_GPIO_1, + snd_soc_component_update_bits(component, WM5100_MISC_GPIO_1, WM5100_OPCLK_SEL_MASK, 0); break; case 11289600: case 12288000: - snd_soc_update_bits(codec, WM5100_MISC_GPIO_1, + snd_soc_component_update_bits(component, WM5100_MISC_GPIO_1, WM5100_OPCLK_SEL_MASK, 0); break; case 22579200: case 24576000: - snd_soc_update_bits(codec, WM5100_MISC_GPIO_1, + snd_soc_component_update_bits(component, WM5100_MISC_GPIO_1, WM5100_OPCLK_SEL_MASK, 0); break; default: - dev_err(codec->dev, "Unsupported OPCLK %dHz\n", + dev_err(component->dev, "Unsupported OPCLK %dHz\n", freq); return -EINVAL; } return 0; default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; } switch (source) { case WM5100_CLKSRC_SYSCLK: case WM5100_CLKSRC_ASYNCCLK: - dev_err(codec->dev, "Invalid source %d\n", source); + dev_err(component->dev, "Invalid source %d\n", source); return -EINVAL; } @@ -1605,7 +1604,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, fval = 2; break; default: - dev_err(codec->dev, "Invalid clock rate: %d\n", freq); + dev_err(component->dev, "Invalid clock rate: %d\n", freq); return -EINVAL; } @@ -1632,7 +1631,7 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, * match. */ - snd_soc_update_bits(codec, reg, WM5100_SYSCLK_FREQ_MASK | + snd_soc_component_update_bits(component, reg, WM5100_SYSCLK_FREQ_MASK | WM5100_SYSCLK_SRC_MASK, fval << WM5100_SYSCLK_FREQ_SHIFT | source); @@ -1641,13 +1640,13 @@ static int wm5100_set_sysclk(struct snd_soc_codec *codec, int clk_id, * this clock rate. */ if (clk_id == WM5100_CLK_SYSCLK) { - dev_dbg(codec->dev, "Setting primary audio rate to %dHz", + dev_dbg(component->dev, "Setting primary audio rate to %dHz", audio_rate); if (0 && *rate_store) - wm5100_free_sr(codec, audio_rate); - ret = wm5100_alloc_sr(codec, audio_rate); + wm5100_free_sr(component, audio_rate); + ret = wm5100_alloc_sr(component, audio_rate); if (ret != 0) - dev_warn(codec->dev, "Primary audio slot is %d\n", + dev_warn(component->dev, "Primary audio slot is %d\n", ret); } @@ -1755,11 +1754,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm5100_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); struct _fll_div factors; struct wm5100_fll *fll; int ret, base, lock, i, timeout; @@ -1777,16 +1776,16 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, lock = WM5100_FLL2_LOCK_STS; break; default: - dev_err(codec->dev, "Unknown FLL %d\n",fll_id); + dev_err(component->dev, "Unknown FLL %d\n",fll_id); return -EINVAL; } if (!Fout) { - dev_dbg(codec->dev, "FLL%d disabled", fll_id); + dev_dbg(component->dev, "FLL%d disabled", fll_id); if (fll->fout) - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); fll->fout = 0; - snd_soc_update_bits(codec, base + 1, WM5100_FLL1_ENA, 0); + snd_soc_component_update_bits(component, base + 1, WM5100_FLL1_ENA, 0); return 0; } @@ -1800,7 +1799,7 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, case WM5100_FLL_SRC_AIF3BCLK: break; default: - dev_err(codec->dev, "Invalid FLL source %d\n", source); + dev_err(component->dev, "Invalid FLL source %d\n", source); return -EINVAL; } @@ -1809,36 +1808,36 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret; /* Disable the FLL while we reconfigure */ - snd_soc_update_bits(codec, base + 1, WM5100_FLL1_ENA, 0); + snd_soc_component_update_bits(component, base + 1, WM5100_FLL1_ENA, 0); - snd_soc_update_bits(codec, base + 2, + snd_soc_component_update_bits(component, base + 2, WM5100_FLL1_OUTDIV_MASK | WM5100_FLL1_FRATIO_MASK, (factors.fll_outdiv << WM5100_FLL1_OUTDIV_SHIFT) | factors.fll_fratio); - snd_soc_update_bits(codec, base + 3, WM5100_FLL1_THETA_MASK, + snd_soc_component_update_bits(component, base + 3, WM5100_FLL1_THETA_MASK, factors.theta); - snd_soc_update_bits(codec, base + 5, WM5100_FLL1_N_MASK, factors.n); - snd_soc_update_bits(codec, base + 6, + snd_soc_component_update_bits(component, base + 5, WM5100_FLL1_N_MASK, factors.n); + snd_soc_component_update_bits(component, base + 6, WM5100_FLL1_REFCLK_DIV_MASK | WM5100_FLL1_REFCLK_SRC_MASK, (factors.fll_refclk_div << WM5100_FLL1_REFCLK_DIV_SHIFT) | source); - snd_soc_update_bits(codec, base + 7, WM5100_FLL1_LAMBDA_MASK, + snd_soc_component_update_bits(component, base + 7, WM5100_FLL1_LAMBDA_MASK, factors.lambda); /* Clear any pending completions */ try_wait_for_completion(&fll->lock); - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); - snd_soc_update_bits(codec, base + 1, WM5100_FLL1_ENA, WM5100_FLL1_ENA); + snd_soc_component_update_bits(component, base + 1, WM5100_FLL1_ENA, WM5100_FLL1_ENA); if (i2c->irq) timeout = 2; else timeout = 50; - snd_soc_update_bits(codec, WM5100_CLOCKING_3, WM5100_SYSCLK_ENA, + snd_soc_component_update_bits(component, WM5100_CLOCKING_3, WM5100_SYSCLK_ENA, WM5100_SYSCLK_ENA); /* Poll for the lock; will use interrupt when we can test */ @@ -1852,10 +1851,10 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, msleep(1); } - ret = snd_soc_read(codec, + ret = snd_soc_component_read32(component, WM5100_INTERRUPT_RAW_STATUS_3); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read FLL status: %d\n", ret); continue; @@ -1864,8 +1863,8 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; } if (i == timeout) { - dev_err(codec->dev, "FLL%d lock timed out\n", fll_id); - pm_runtime_put(codec->dev); + dev_err(component->dev, "FLL%d lock timed out\n", fll_id); + pm_runtime_put(component->dev); return -ETIMEDOUT; } @@ -1873,7 +1872,7 @@ static int wm5100_set_fll(struct snd_soc_codec *codec, int fll_id, int source, fll->fref = Fref; fll->fout = Fout; - dev_dbg(codec->dev, "FLL%d running %dHz->%dHz\n", fll_id, + dev_dbg(component->dev, "FLL%d running %dHz->%dHz\n", fll_id, Fref, Fout); return 0; @@ -2099,10 +2098,10 @@ static void wm5100_micd_irq(struct wm5100_priv *wm5100) } } -int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int wm5100_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (jack) { wm5100->jack = jack; @@ -2113,7 +2112,7 @@ int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) /* Slowest detection rate, gives debounce for initial * detection */ - snd_soc_update_bits(codec, WM5100_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM5100_MIC_DETECT_1, WM5100_ACCDET_BIAS_STARTTIME_MASK | WM5100_ACCDET_RATE_MASK, (7 << WM5100_ACCDET_BIAS_STARTTIME_SHIFT) | @@ -2132,18 +2131,18 @@ int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) /* We start off just enabling microphone detection - even a * plain headphone will trigger detection. */ - snd_soc_update_bits(codec, WM5100_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM5100_MIC_DETECT_1, WM5100_ACCDET_ENA, WM5100_ACCDET_ENA); - snd_soc_update_bits(codec, WM5100_INTERRUPT_STATUS_3_MASK, + snd_soc_component_update_bits(component, WM5100_INTERRUPT_STATUS_3_MASK, WM5100_IM_ACCDET_EINT, 0); } else { - snd_soc_update_bits(codec, WM5100_INTERRUPT_STATUS_3_MASK, + snd_soc_component_update_bits(component, WM5100_INTERRUPT_STATUS_3_MASK, WM5100_IM_HPDET_EINT | WM5100_IM_ACCDET_EINT, WM5100_IM_HPDET_EINT | WM5100_IM_ACCDET_EINT); - snd_soc_update_bits(codec, WM5100_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM5100_MIC_DETECT_1, WM5100_ACCDET_ENA, 0); wm5100->jack = NULL; } @@ -2330,22 +2329,22 @@ static void wm5100_free_gpio(struct i2c_client *i2c) } #endif -static int wm5100_probe(struct snd_soc_codec *codec) +static int wm5100_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); int ret, i; - wm5100->codec = codec; + wm5100->component = component; for (i = 0; i < ARRAY_SIZE(wm5100_dig_vu); i++) - snd_soc_update_bits(codec, wm5100_dig_vu[i], WM5100_OUT_VU, + snd_soc_component_update_bits(component, wm5100_dig_vu[i], WM5100_OUT_VU, WM5100_OUT_VU); /* Don't debounce interrupts to support use of SYSCLK only */ - snd_soc_write(codec, WM5100_IRQ_DEBOUNCE_1, 0); - snd_soc_write(codec, WM5100_IRQ_DEBOUNCE_2, 0); + snd_soc_component_write(component, WM5100_IRQ_DEBOUNCE_1, 0); + snd_soc_component_write(component, WM5100_IRQ_DEBOUNCE_2, 0); /* TODO: check if we're symmetric */ @@ -2370,34 +2369,30 @@ err_gpio: return ret; } -static int wm5100_remove(struct snd_soc_codec *codec) +static void wm5100_remove(struct snd_soc_component *component) { - struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); + struct wm5100_priv *wm5100 = snd_soc_component_get_drvdata(component); if (wm5100->pdata.hp_pol) { gpio_free(wm5100->pdata.hp_pol); } - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm5100 = { - .probe = wm5100_probe, - .remove = wm5100_remove, - - .set_sysclk = wm5100_set_sysclk, - .set_pll = wm5100_set_fll, - .idle_bias_off = 1, - - .seq_notifier = wm5100_seq_notifier, - .component_driver = { - .controls = wm5100_snd_controls, - .num_controls = ARRAY_SIZE(wm5100_snd_controls), - .dapm_widgets = wm5100_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets), - .dapm_routes = wm5100_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm5100 = { + .probe = wm5100_probe, + .remove = wm5100_remove, + .set_sysclk = wm5100_set_sysclk, + .set_pll = wm5100_set_fll, + .seq_notifier = wm5100_seq_notifier, + .controls = wm5100_snd_controls, + .num_controls = ARRAY_SIZE(wm5100_snd_controls), + .dapm_widgets = wm5100_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm5100_dapm_widgets), + .dapm_routes = wm5100_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm5100_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm5100_regmap = { @@ -2614,8 +2609,8 @@ static int wm5100_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm5100, wm5100_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm5100, wm5100_dai, ARRAY_SIZE(wm5100_dai)); if (ret < 0) { dev_err(&i2c->dev, "Failed to register WM5100: %d\n", ret); @@ -2648,7 +2643,6 @@ static int wm5100_i2c_remove(struct i2c_client *i2c) { struct wm5100_priv *wm5100 = i2c_get_clientdata(i2c); - snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm5100); wm5100_free_gpio(i2c); diff --git a/sound/soc/codecs/wm5100.h b/sound/soc/codecs/wm5100.h index 935a9b7fb274..6076493cfd67 100644 --- a/sound/soc/codecs/wm5100.h +++ b/sound/soc/codecs/wm5100.h @@ -17,7 +17,7 @@ #include #include -int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int wm5100_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #define WM5100_CLK_AIF1 1 #define WM5100_CLK_AIF2 2 diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c index 0d0f58208b75..c9081f42f373 100644 --- a/sound/soc/samsung/lowland.c +++ b/sound/soc/samsung/lowland.c @@ -37,10 +37,10 @@ static struct snd_soc_jack_pin lowland_headset_pins[] = { static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret; - ret = snd_soc_codec_set_sysclk(codec, WM5100_CLK_SYSCLK, + ret = snd_soc_component_set_sysclk(component, WM5100_CLK_SYSCLK, WM5100_CLKSRC_MCLK1, MCLK1_RATE, SND_SOC_CLOCK_IN); if (ret < 0) { @@ -49,7 +49,7 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) } /* Clock OPCLK, used by the other audio components. */ - ret = snd_soc_codec_set_sysclk(codec, WM5100_CLK_OPCLK, 0, + ret = snd_soc_component_set_sysclk(component, WM5100_CLK_OPCLK, 0, CLKOUT_RATE, 0); if (ret < 0) { pr_err("Failed to set OPCLK rate: %d\n", ret); @@ -63,19 +63,19 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - wm5100_detect(codec, &lowland_headset); + wm5100_detect(component, &lowland_headset); return 0; } static int lowland_wm9081_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; snd_soc_dapm_nc_pin(&rtd->card->dapm, "LINEOUT"); /* At any time the WM9081 is active it will have this clock */ - return snd_soc_codec_set_sysclk(codec, WM9081_SYSCLK_MCLK, 0, + return snd_soc_component_set_sysclk(component, WM9081_SYSCLK_MCLK, 0, CLKOUT_RATE, 0); } From 2621a9a4a28b37fa066a1c08aecdd6a44a083e56 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:59:50 +0000 Subject: [PATCH 019/942] ASoC: wm8350: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8350.c | 183 ++++++++++++++++++------------------- sound/soc/codecs/wm8350.h | 4 +- sound/soc/fsl/wm1133-ev1.c | 6 +- 3 files changed, 93 insertions(+), 100 deletions(-) diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index fc79c6725d06..e92ebe52d485 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c @@ -256,8 +256,8 @@ static void wm8350_pga_work(struct work_struct *work) static int pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); struct wm8350_output *out; switch (w->shift) { @@ -299,8 +299,8 @@ static int pga_event(struct snd_soc_dapm_widget *w, static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component); struct wm8350_output *out = NULL; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -334,16 +334,16 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol, return ret; /* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - snd_soc_write(codec, reg, val | WM8350_OUT1_VU); + val = snd_soc_component_read32(component, reg); + snd_soc_component_write(component, reg, val | WM8350_OUT1_VU); return 1; } static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component); struct wm8350_output *out1 = &wm8350_priv->out1; struct wm8350_output *out2 = &wm8350_priv->out2; struct soc_mixer_control *mc = @@ -753,8 +753,8 @@ static const struct snd_soc_dapm_route wm8350_dapm_routes[] = { static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = wm8350_data->wm8350; u16 fll_4; @@ -769,9 +769,9 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, case WM8350_MCLK_SEL_PLL_32K: wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_1, WM8350_MCLK_SEL); - fll_4 = snd_soc_read(codec, WM8350_FLL_CONTROL_4) & + fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) & ~WM8350_FLL_CLK_SRC_MASK; - snd_soc_write(codec, WM8350_FLL_CONTROL_4, fll_4 | clk_id); + snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | clk_id); break; } @@ -788,44 +788,44 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8350_set_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 val; switch (div_id) { case WM8350_ADC_CLKDIV: - val = snd_soc_read(codec, WM8350_ADC_DIVIDER) & + val = snd_soc_component_read32(component, WM8350_ADC_DIVIDER) & ~WM8350_ADC_CLKDIV_MASK; - snd_soc_write(codec, WM8350_ADC_DIVIDER, val | div); + snd_soc_component_write(component, WM8350_ADC_DIVIDER, val | div); break; case WM8350_DAC_CLKDIV: - val = snd_soc_read(codec, WM8350_DAC_CLOCK_CONTROL) & + val = snd_soc_component_read32(component, WM8350_DAC_CLOCK_CONTROL) & ~WM8350_DAC_CLKDIV_MASK; - snd_soc_write(codec, WM8350_DAC_CLOCK_CONTROL, val | div); + snd_soc_component_write(component, WM8350_DAC_CLOCK_CONTROL, val | div); break; case WM8350_BCLK_CLKDIV: - val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) & + val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & ~WM8350_BCLK_DIV_MASK; - snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div); + snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); break; case WM8350_OPCLK_CLKDIV: - val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) & + val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & ~WM8350_OPCLK_DIV_MASK; - snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div); + snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); break; case WM8350_SYS_CLKDIV: - val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) & + val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) & ~WM8350_MCLK_DIV_MASK; - snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div); + snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div); break; case WM8350_DACLR_CLKDIV: - val = snd_soc_read(codec, WM8350_DAC_LR_RATE) & + val = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) & ~WM8350_DACLRC_RATE_MASK; - snd_soc_write(codec, WM8350_DAC_LR_RATE, val | div); + snd_soc_component_write(component, WM8350_DAC_LR_RATE, val | div); break; case WM8350_ADCLR_CLKDIV: - val = snd_soc_read(codec, WM8350_ADC_LR_RATE) & + val = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) & ~WM8350_ADCLRC_RATE_MASK; - snd_soc_write(codec, WM8350_ADC_LR_RATE, val | div); + snd_soc_component_write(component, WM8350_ADC_LR_RATE, val | div); break; default: return -EINVAL; @@ -836,14 +836,14 @@ static int wm8350_set_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8350_AI_FORMATING) & + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) & ~(WM8350_AIF_BCLK_INV | WM8350_AIF_LRCLK_INV | WM8350_AIF_FMT_MASK); - u16 master = snd_soc_read(codec, WM8350_AI_DAC_CONTROL) & + u16 master = snd_soc_component_read32(component, WM8350_AI_DAC_CONTROL) & ~WM8350_BCLK_MSTR; - u16 dac_lrc = snd_soc_read(codec, WM8350_DAC_LR_RATE) & + u16 dac_lrc = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) & ~WM8350_DACLRC_ENA; - u16 adc_lrc = snd_soc_read(codec, WM8350_ADC_LR_RATE) & + u16 adc_lrc = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) & ~WM8350_ADCLRC_ENA; /* set master/slave audio interface */ @@ -896,10 +896,10 @@ static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_write(codec, WM8350_AI_FORMATING, iface); - snd_soc_write(codec, WM8350_AI_DAC_CONTROL, master); - snd_soc_write(codec, WM8350_DAC_LR_RATE, dac_lrc); - snd_soc_write(codec, WM8350_ADC_LR_RATE, adc_lrc); + snd_soc_component_write(component, WM8350_AI_FORMATING, iface); + snd_soc_component_write(component, WM8350_AI_DAC_CONTROL, master); + snd_soc_component_write(component, WM8350_DAC_LR_RATE, dac_lrc); + snd_soc_component_write(component, WM8350_ADC_LR_RATE, adc_lrc); return 0; } @@ -907,10 +907,10 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = wm8350_data->wm8350; - u16 iface = snd_soc_read(codec, WM8350_AI_FORMATING) & + u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) & ~WM8350_AIF_WL_MASK; /* bit size */ @@ -928,7 +928,7 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8350_AI_FORMATING, iface); + snd_soc_component_write(component, WM8350_AI_FORMATING, iface); /* The sloping stopband filter is recommended for use with * lower sample rates to improve performance. @@ -947,7 +947,7 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream, static int wm8350_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val; if (mute) @@ -955,7 +955,7 @@ static int wm8350_mute(struct snd_soc_dai *dai, int mute) else val = 0; - snd_soc_update_bits(codec, WM8350_DAC_MUTE, WM8350_DAC_MUTE_ENA, val); + snd_soc_component_update_bits(component, WM8350_DAC_MUTE, WM8350_DAC_MUTE_ENA, val); return 0; } @@ -1024,8 +1024,8 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; struct _fll_div fll_div; int ret = 0; @@ -1050,17 +1050,17 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, fll_div.ratio); /* set up N.K & dividers */ - fll_1 = snd_soc_read(codec, WM8350_FLL_CONTROL_1) & + fll_1 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_1) & ~(WM8350_FLL_OUTDIV_MASK | WM8350_FLL_RSP_RATE_MASK | 0xc000); - snd_soc_write(codec, WM8350_FLL_CONTROL_1, + snd_soc_component_write(component, WM8350_FLL_CONTROL_1, fll_1 | (fll_div.div << 8) | 0x50); - snd_soc_write(codec, WM8350_FLL_CONTROL_2, + snd_soc_component_write(component, WM8350_FLL_CONTROL_2, (fll_div.ratio << 11) | (fll_div. n & WM8350_FLL_N_MASK)); - snd_soc_write(codec, WM8350_FLL_CONTROL_3, fll_div.k); - fll_4 = snd_soc_read(codec, WM8350_FLL_CONTROL_4) & + snd_soc_component_write(component, WM8350_FLL_CONTROL_3, fll_div.k); + fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) & ~(WM8350_FLL_FRAC | WM8350_FLL_SLOW_LOCK_REF); - snd_soc_write(codec, WM8350_FLL_CONTROL_4, + snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | (fll_div.k ? WM8350_FLL_FRAC : 0) | (fll_div.ratio == 8 ? WM8350_FLL_SLOW_LOCK_REF : 0)); @@ -1074,10 +1074,10 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai, return 0; } -static int wm8350_set_bias_level(struct snd_soc_codec *codec, +static int wm8350_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; struct wm8350_audio_platform_data *platform = wm8350->codec.platform_data; @@ -1101,7 +1101,7 @@ static int wm8350_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret != 0) @@ -1310,7 +1310,7 @@ static irqreturn_t wm8350_hpr_jack_handler(int irq, void *data) /** * wm8350_hp_jack_detect - Enable headphone jack detection. * - * @codec: WM8350 codec + * @component: WM8350 component * @which: left or right jack detect signal * @jack: jack to report detection events on * @report: value to report @@ -1318,10 +1318,10 @@ static irqreturn_t wm8350_hpr_jack_handler(int irq, void *data) * Enables the headphone jack detection of the WM8350. If no report * is specified then detection is disabled. */ -int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, +int wm8350_hp_jack_detect(struct snd_soc_component *component, enum wm8350_jack which, struct snd_soc_jack *jack, int report) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; int ena; @@ -1389,7 +1389,7 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data) /** * wm8350_mic_jack_detect - Enable microphone jack detection. * - * @codec: WM8350 codec + * @component: WM8350 component * @jack: jack to report detection events on * @detect_report: value to report when presence detected * @short_report: value to report when microphone short detected @@ -1397,11 +1397,11 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data) * Enables the microphone jack detection of the WM8350. If both reports * are specified as zero then detection is disabled. */ -int wm8350_mic_jack_detect(struct snd_soc_codec *codec, +int wm8350_mic_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int detect_report, int short_report) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); struct wm8350 *wm8350 = priv->wm8350; priv->mic.jack = jack; @@ -1455,26 +1455,26 @@ static struct snd_soc_dai_driver wm8350_dai = { .ops = &wm8350_dai_ops, }; -static int wm8350_codec_probe(struct snd_soc_codec *codec) +static int wm8350_component_probe(struct snd_soc_component *component) { - struct wm8350 *wm8350 = dev_get_platdata(codec->dev); + struct wm8350 *wm8350 = dev_get_platdata(component->dev); struct wm8350_data *priv; struct wm8350_output *out1; struct wm8350_output *out2; int ret, i; if (wm8350->codec.platform_data == NULL) { - dev_err(codec->dev, "No audio platform data supplied\n"); + dev_err(component->dev, "No audio platform data supplied\n"); return -EINVAL; } - priv = devm_kzalloc(codec->dev, sizeof(struct wm8350_data), + priv = devm_kzalloc(component->dev, sizeof(struct wm8350_data), GFP_KERNEL); if (priv == NULL) return -ENOMEM; - snd_soc_codec_init_regmap(codec, wm8350->regmap); - snd_soc_codec_set_drvdata(codec, priv); + snd_soc_component_init_regmap(component, wm8350->regmap); + snd_soc_component_set_drvdata(component, priv); priv->wm8350 = wm8350; @@ -1497,9 +1497,9 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); /* Enable robust clocking mode in ADC */ - snd_soc_write(codec, WM8350_SECURITY, 0xa7); - snd_soc_write(codec, 0xde, 0x13); - snd_soc_write(codec, WM8350_SECURITY, 0); + snd_soc_component_write(component, WM8350_SECURITY, 0xa7); + snd_soc_component_write(component, 0xde, 0x13); + snd_soc_component_write(component, WM8350_SECURITY, 0); /* read OUT1 & OUT2 volumes */ out1 = &priv->out1; @@ -1552,10 +1552,10 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec) return 0; } -static int wm8350_codec_remove(struct snd_soc_codec *codec) +static void wm8350_component_remove(struct snd_soc_component *component) { - struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); - struct wm8350 *wm8350 = dev_get_platdata(codec->dev); + struct wm8350_data *priv = snd_soc_component_get_drvdata(component); + struct wm8350 *wm8350 = dev_get_platdata(component->dev); wm8350_clear_bits(wm8350, WM8350_JACK_DETECT, WM8350_JDL_ENA | WM8350_JDR_ENA); @@ -1578,44 +1578,37 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec) flush_delayed_work(&priv->pga_work); wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8350 = { - .probe = wm8350_codec_probe, - .remove = wm8350_codec_remove, - .set_bias_level = wm8350_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8350_snd_controls, - .num_controls = ARRAY_SIZE(wm8350_snd_controls), - .dapm_widgets = wm8350_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8350_dapm_widgets), - .dapm_routes = wm8350_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8350_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8350 = { + .probe = wm8350_component_probe, + .remove = wm8350_component_remove, + .set_bias_level = wm8350_set_bias_level, + .controls = wm8350_snd_controls, + .num_controls = ARRAY_SIZE(wm8350_snd_controls), + .dapm_widgets = wm8350_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8350_dapm_widgets), + .dapm_routes = wm8350_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8350_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8350_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8350, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8350, &wm8350_dai, 1); } -static int wm8350_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver wm8350_codec_driver = { .driver = { .name = "wm8350-codec", }, .probe = wm8350_probe, - .remove = wm8350_remove, }; module_platform_driver(wm8350_codec_driver); diff --git a/sound/soc/codecs/wm8350.h b/sound/soc/codecs/wm8350.h index 74108eb82938..1191326c4a61 100644 --- a/sound/soc/codecs/wm8350.h +++ b/sound/soc/codecs/wm8350.h @@ -20,9 +20,9 @@ enum wm8350_jack { WM8350_JDR = 2, }; -int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, +int wm8350_hp_jack_detect(struct snd_soc_component *component, enum wm8350_jack which, struct snd_soc_jack *jack, int report); -int wm8350_mic_jack_detect(struct snd_soc_codec *codec, +int wm8350_mic_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int detect_report, int short_report); diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c index cdaf16367b47..2f80b21b2921 100644 --- a/sound/soc/fsl/wm1133-ev1.c +++ b/sound/soc/fsl/wm1133-ev1.c @@ -201,18 +201,18 @@ static struct snd_soc_jack_pin mic_jack_pins[] = { static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* Headphone jack detection */ snd_soc_card_jack_new(rtd->card, "Headphone", SND_JACK_HEADPHONE, &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins)); - wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); + wm8350_hp_jack_detect(component, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); /* Microphone jack detection */ snd_soc_card_jack_new(rtd->card, "Microphone", SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack, mic_jack_pins, ARRAY_SIZE(mic_jack_pins)); - wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE, + wm8350_mic_jack_detect(component, &mic_jack, SND_JACK_MICROPHONE, SND_JACK_BTN_0); snd_soc_dapm_force_enable_pin(&rtd->card->dapm, "Mic Bias"); From 10dc44c6462db0a4b60efa3add18684205088583 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:00:04 +0000 Subject: [PATCH 020/942] ASoC: wm8400: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 211 ++++++++++++++++++-------------------- 1 file changed, 102 insertions(+), 109 deletions(-) diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index a36adf881bca..c237365d1184 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -65,9 +65,9 @@ struct wm8400_priv { int fll_in, fll_out; }; -static void wm8400_codec_reset(struct snd_soc_codec *codec) +static void wm8400_component_reset(struct snd_soc_component *component) { - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); wm8400_reset_codec_reg_cache(wm8400->wm8400); } @@ -91,7 +91,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -103,8 +103,8 @@ static int wm8400_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, return ret; /* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - return snd_soc_write(codec, reg, val | 0x0100); + val = snd_soc_component_read32(component, reg); + return snd_soc_component_write(component, reg, val | 0x0100); } #define WM8400_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert, tlv_array) \ @@ -324,7 +324,7 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, static int outmixer_event (struct snd_soc_dapm_widget *w, struct snd_kcontrol * kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; u32 reg_shift = mc->shift; @@ -333,7 +333,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, switch (reg_shift) { case WM8400_SPEAKER_MIXER | (WM8400_LDSPK << 8) : - reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER1); if (reg & WM8400_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -341,7 +341,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_SPEAKER_MIXER | (WM8400_RDSPK << 8): - reg = snd_soc_read(codec, WM8400_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8400_OUTPUT_MIXER2); if (reg & WM8400_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -349,7 +349,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_OUTPUT_MIXER1 | (WM8400_LDLO << 8): - reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER); if (reg & WM8400_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -357,7 +357,7 @@ static int outmixer_event (struct snd_soc_dapm_widget *w, } break; case WM8400_OUTPUT_MIXER2 | (WM8400_RDRO << 8): - reg = snd_soc_read(codec, WM8400_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8400_SPEAKER_MIXER); if (reg & WM8400_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); @@ -849,8 +849,8 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { static int wm8400_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); wm8400->sysclk = freq; return 0; @@ -938,8 +938,8 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); struct fll_factors factors; int ret; u16 reg; @@ -962,13 +962,13 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, wm8400->fll_in = freq_in; /* We *must* disable the FLL before any changes */ - reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_2); + reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_2); reg &= ~WM8400_FLL_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_2, reg); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_2, reg); - reg = snd_soc_read(codec, WM8400_FLL_CONTROL_1); + reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_1); reg &= ~WM8400_FLL_OSC_ENA; - snd_soc_write(codec, WM8400_FLL_CONTROL_1, reg); + snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg); if (!freq_out) return 0; @@ -976,15 +976,15 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, reg &= ~(WM8400_FLL_REF_FREQ | WM8400_FLL_FRATIO_MASK); reg |= WM8400_FLL_FRAC | factors.fratio; reg |= factors.freq_ref << WM8400_FLL_REF_FREQ_SHIFT; - snd_soc_write(codec, WM8400_FLL_CONTROL_1, reg); + snd_soc_component_write(component, WM8400_FLL_CONTROL_1, reg); - snd_soc_write(codec, WM8400_FLL_CONTROL_2, factors.k); - snd_soc_write(codec, WM8400_FLL_CONTROL_3, factors.n); + snd_soc_component_write(component, WM8400_FLL_CONTROL_2, factors.k); + snd_soc_component_write(component, WM8400_FLL_CONTROL_3, factors.n); - reg = snd_soc_read(codec, WM8400_FLL_CONTROL_4); + reg = snd_soc_component_read32(component, WM8400_FLL_CONTROL_4); reg &= ~WM8400_FLL_OUTDIV_MASK; reg |= factors.outdiv; - snd_soc_write(codec, WM8400_FLL_CONTROL_4, reg); + snd_soc_component_write(component, WM8400_FLL_CONTROL_4, reg); return 0; } @@ -995,11 +995,11 @@ static int wm8400_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 audio1, audio3; - audio1 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_1); - audio3 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_3); + audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1); + audio3 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_3); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1040,37 +1040,37 @@ static int wm8400_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); - snd_soc_write(codec, WM8400_AUDIO_INTERFACE_3, audio3); + snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_3, audio3); return 0; } static int wm8400_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; switch (div_id) { case WM8400_MCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & ~WM8400_MCLK_DIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); break; case WM8400_DACCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & ~WM8400_DAC_CLKDIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); break; case WM8400_ADCCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_2) & ~WM8400_ADC_CLKDIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_2, reg | div); break; case WM8400_BCLK_DIV: - reg = snd_soc_read(codec, WM8400_CLOCKING_1) & + reg = snd_soc_component_read32(component, WM8400_CLOCKING_1) & ~WM8400_BCLK_DIV_MASK; - snd_soc_write(codec, WM8400_CLOCKING_1, reg | div); + snd_soc_component_write(component, WM8400_CLOCKING_1, reg | div); break; default: return -EINVAL; @@ -1086,8 +1086,8 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 audio1 = snd_soc_read(codec, WM8400_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + u16 audio1 = snd_soc_component_read32(component, WM8400_AUDIO_INTERFACE_1); audio1 &= ~WM8400_AIF_WL_MASK; /* bit size */ @@ -1105,28 +1105,28 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8400_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8400_AUDIO_INTERFACE_1, audio1); return 0; } static int wm8400_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 val = snd_soc_read(codec, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE; + struct snd_soc_component *component = dai->component; + u16 val = snd_soc_component_read32(component, WM8400_DAC_CTRL) & ~WM8400_DAC_MUTE; if (mute) - snd_soc_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); + snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); else - snd_soc_write(codec, WM8400_DAC_CTRL, val); + snd_soc_component_write(component, WM8400_DAC_CTRL, val); return 0; } /* TODO: set bias for best performance at standby */ -static int wm8400_set_bias_level(struct snd_soc_codec *codec, +static int wm8400_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); + struct wm8400_priv *wm8400 = snd_soc_component_get_drvdata(component); u16 val; int ret; @@ -1136,13 +1136,13 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID=2*50k */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) & ~WM8400_VMID_MODE_MASK; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x2); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x2); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(power), &power[0]); if (ret != 0) { @@ -1152,74 +1152,74 @@ static int wm8400_set_bias_level(struct snd_soc_codec *codec, return ret; } - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, WM8400_CODEC_ENA | WM8400_SYSCLK_ENA); /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL); msleep(50); /* Enable VREF & VMID at 2x50k */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); val |= 0x2 | WM8400_VREF_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); /* Enable BUFIOEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL | WM8400_BUFIOEN); /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_BUFIOEN); + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_BUFIOEN); } /* VMID=2*300k */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1) & ~WM8400_VMID_MODE_MASK; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val | 0x4); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val | 0x4); break; case SND_SOC_BIAS_OFF: /* Enable POBCTRL and SOFT_ST */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_POBCTRL | WM8400_BUFIOEN); /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, WM8400_SOFTST | + snd_soc_component_write(component, WM8400_ANTIPOP2, WM8400_SOFTST | WM8400_BUFDCOPEN | WM8400_POBCTRL | WM8400_BUFIOEN); /* mute DAC */ - val = snd_soc_read(codec, WM8400_DAC_CTRL); - snd_soc_write(codec, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); + val = snd_soc_component_read32(component, WM8400_DAC_CTRL); + snd_soc_component_write(component, WM8400_DAC_CTRL, val | WM8400_DAC_MUTE); /* Enable any disabled outputs */ - val = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); + val = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); val |= WM8400_SPK_ENA | WM8400_OUT3_ENA | WM8400_OUT4_ENA | WM8400_LOUT_ENA | WM8400_ROUT_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); /* Disable VMID */ val &= ~WM8400_VMID_MODE_MASK; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); msleep(300); /* Enable all output discharge bits */ - snd_soc_write(codec, WM8400_ANTIPOP1, WM8400_DIS_LLINE | + snd_soc_component_write(component, WM8400_ANTIPOP1, WM8400_DIS_LLINE | WM8400_DIS_RLINE | WM8400_DIS_OUT3 | WM8400_DIS_OUT4 | WM8400_DIS_LOUT | WM8400_DIS_ROUT); /* Disable VREF */ val &= ~WM8400_VREF_ENA; - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, val); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, val); /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8400_ANTIPOP2, 0x0); + snd_soc_component_write(component, WM8400_ANTIPOP2, 0x0); ret = regulator_bulk_disable(ARRAY_SIZE(power), &power[0]); @@ -1273,93 +1273,86 @@ static struct snd_soc_dai_driver wm8400_dai = { .ops = &wm8400_dai_ops, }; -static int wm8400_codec_probe(struct snd_soc_codec *codec) +static int wm8400_component_probe(struct snd_soc_component *component) { - struct wm8400 *wm8400 = dev_get_platdata(codec->dev); + struct wm8400 *wm8400 = dev_get_platdata(component->dev); struct wm8400_priv *priv; int ret; u16 reg; - priv = devm_kzalloc(codec->dev, sizeof(struct wm8400_priv), + priv = devm_kzalloc(component->dev, sizeof(struct wm8400_priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM; - snd_soc_codec_init_regmap(codec, wm8400->regmap); - snd_soc_codec_set_drvdata(codec, priv); + snd_soc_component_init_regmap(component, wm8400->regmap); + snd_soc_component_set_drvdata(component, priv); priv->wm8400 = wm8400; ret = devm_regulator_bulk_get(wm8400->dev, ARRAY_SIZE(power), &power[0]); if (ret != 0) { - dev_err(codec->dev, "Failed to get regulators: %d\n", ret); + dev_err(component->dev, "Failed to get regulators: %d\n", ret); return ret; } - wm8400_codec_reset(codec); + wm8400_component_reset(component); - reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA); + reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, reg | WM8400_CODEC_ENA); /* Latch volume update bits */ - reg = snd_soc_read(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); - snd_soc_write(codec, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, + reg = snd_soc_component_read32(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME); + snd_soc_component_write(component, WM8400_LEFT_LINE_INPUT_1_2_VOLUME, reg & WM8400_IPVU); - reg = snd_soc_read(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); - snd_soc_write(codec, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, + reg = snd_soc_component_read32(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME); + snd_soc_component_write(component, WM8400_RIGHT_LINE_INPUT_1_2_VOLUME, reg & WM8400_IPVU); - snd_soc_write(codec, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); - snd_soc_write(codec, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8400_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8400_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); return 0; } -static int wm8400_codec_remove(struct snd_soc_codec *codec) +static void wm8400_component_remove(struct snd_soc_component *component) { u16 reg; - reg = snd_soc_read(codec, WM8400_POWER_MANAGEMENT_1); - snd_soc_write(codec, WM8400_POWER_MANAGEMENT_1, + reg = snd_soc_component_read32(component, WM8400_POWER_MANAGEMENT_1); + snd_soc_component_write(component, WM8400_POWER_MANAGEMENT_1, reg & (~WM8400_CODEC_ENA)); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8400 = { - .probe = wm8400_codec_probe, - .remove = wm8400_codec_remove, - .set_bias_level = wm8400_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8400_snd_controls, - .num_controls = ARRAY_SIZE(wm8400_snd_controls), - .dapm_widgets = wm8400_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8400_dapm_widgets), - .dapm_routes = wm8400_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8400_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8400 = { + .probe = wm8400_component_probe, + .remove = wm8400_component_remove, + .set_bias_level = wm8400_set_bias_level, + .controls = wm8400_snd_controls, + .num_controls = ARRAY_SIZE(wm8400_snd_controls), + .dapm_widgets = wm8400_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8400_dapm_widgets), + .dapm_routes = wm8400_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8400_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8400_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8400, + return snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8400, &wm8400_dai, 1); } -static int wm8400_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver wm8400_codec_driver = { .driver = { .name = "wm8400-codec", }, .probe = wm8400_probe, - .remove = wm8400_remove, }; module_platform_driver(wm8400_codec_driver); From 8f5a59354c64e7e4305e8029d9f3ba1f0df5d444 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:00:20 +0000 Subject: [PATCH 021/942] ASoC: wm8580: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8580.c | 150 ++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 79 deletions(-) diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 910801dddd64..fa4ad1b093eb 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c @@ -262,8 +262,8 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int ret; @@ -279,8 +279,8 @@ static int wm8580_out_vu(struct snd_kcontrol *kcontrol, return ret; /* Now write again with the volume update bit set */ - snd_soc_update_bits(codec, reg, 0x100, 0x100); - snd_soc_update_bits(codec, reg2, 0x100, 0x100); + snd_soc_component_update_bits(component, reg, 0x100, 0x100); + snd_soc_component_update_bits(component, reg2, 0x100, 0x100); return 0; } @@ -465,8 +465,8 @@ static int wm8580_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { int offset; - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); struct pll_state *state; struct _pll_div pll_div; unsigned int reg; @@ -505,25 +505,25 @@ static int wm8580_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* Always disable the PLL - it is not safe to leave it running * while reprogramming it. */ - snd_soc_update_bits(codec, WM8580_PWRDN2, pwr_mask, pwr_mask); + snd_soc_component_update_bits(component, WM8580_PWRDN2, pwr_mask, pwr_mask); if (!freq_in || !freq_out) return 0; - snd_soc_write(codec, WM8580_PLLA1 + offset, pll_div.k & 0x1ff); - snd_soc_write(codec, WM8580_PLLA2 + offset, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8580_PLLA3 + offset, + snd_soc_component_write(component, WM8580_PLLA1 + offset, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8580_PLLA2 + offset, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8580_PLLA3 + offset, (pll_div.k >> 18 & 0xf) | (pll_div.n << 4)); - reg = snd_soc_read(codec, WM8580_PLLA4 + offset); + reg = snd_soc_component_read32(component, WM8580_PLLA4 + offset); reg &= ~0x1b; reg |= pll_div.prescale | pll_div.postscale << 1 | pll_div.freqmode << 3; - snd_soc_write(codec, WM8580_PLLA4 + offset, reg); + snd_soc_component_write(component, WM8580_PLLA4 + offset, reg); /* All done, turn it on */ - snd_soc_update_bits(codec, WM8580_PWRDN2, pwr_mask, 0); + snd_soc_component_update_bits(component, WM8580_PWRDN2, pwr_mask, 0); return 0; } @@ -539,8 +539,8 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); u16 paifa = 0; u16 paifb = 0; int i, ratio, osr; @@ -572,12 +572,12 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, if (ratio == wm8580_sysclk_ratios[i]) break; if (i == ARRAY_SIZE(wm8580_sysclk_ratios)) { - dev_err(codec->dev, "Invalid clock ratio %d/%d\n", + dev_err(component->dev, "Invalid clock ratio %d/%d\n", wm8580->sysclk[dai->driver->id], params_rate(params)); return -EINVAL; } paifa |= i; - dev_dbg(codec->dev, "Running at %dfs with %dHz clock\n", + dev_dbg(component->dev, "Running at %dfs with %dHz clock\n", wm8580_sysclk_ratios[i], wm8580->sysclk[dai->driver->id]); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { @@ -585,21 +585,21 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, case 128: case 192: osr = WM8580_DACOSR; - dev_dbg(codec->dev, "Selecting 64x OSR\n"); + dev_dbg(component->dev, "Selecting 64x OSR\n"); break; default: osr = 0; - dev_dbg(codec->dev, "Selecting 128x OSR\n"); + dev_dbg(component->dev, "Selecting 128x OSR\n"); break; } - snd_soc_update_bits(codec, WM8580_PAIF3, WM8580_DACOSR, osr); + snd_soc_component_update_bits(component, WM8580_PAIF3, WM8580_DACOSR, osr); } - snd_soc_update_bits(codec, WM8580_PAIF1 + dai->driver->id, + snd_soc_component_update_bits(component, WM8580_PAIF1 + dai->driver->id, WM8580_AIF_RATE_MASK | WM8580_AIF_BCLKSEL_MASK, paifa); - snd_soc_update_bits(codec, WM8580_PAIF3 + dai->driver->id, + snd_soc_component_update_bits(component, WM8580_PAIF3 + dai->driver->id, WM8580_AIF_LENGTH_MASK, paifb); return 0; } @@ -607,13 +607,13 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int aifa; unsigned int aifb; int can_invert_lrclk; - aifa = snd_soc_read(codec, WM8580_PAIF1 + codec_dai->driver->id); - aifb = snd_soc_read(codec, WM8580_PAIF3 + codec_dai->driver->id); + aifa = snd_soc_component_read32(component, WM8580_PAIF1 + codec_dai->driver->id); + aifb = snd_soc_component_read32(component, WM8580_PAIF3 + codec_dai->driver->id); aifb &= ~(WM8580_AIF_FMT_MASK | WM8580_AIF_LRP | WM8580_AIF_BCP); @@ -679,8 +679,8 @@ static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8580_PAIF1 + codec_dai->driver->id, aifa); - snd_soc_write(codec, WM8580_PAIF3 + codec_dai->driver->id, aifb); + snd_soc_component_write(component, WM8580_PAIF1 + codec_dai->driver->id, aifa); + snd_soc_component_write(component, WM8580_PAIF3 + codec_dai->driver->id, aifb); return 0; } @@ -688,12 +688,12 @@ static int wm8580_set_paif_dai_fmt(struct snd_soc_dai *codec_dai, static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg; switch (div_id) { case WM8580_MCLK: - reg = snd_soc_read(codec, WM8580_PLLB4); + reg = snd_soc_component_read32(component, WM8580_PLLB4); reg &= ~WM8580_PLLB4_MCLKOUTSRC_MASK; switch (div) { @@ -715,11 +715,11 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_write(codec, WM8580_PLLB4, reg); + snd_soc_component_write(component, WM8580_PLLB4, reg); break; case WM8580_CLKOUTSRC: - reg = snd_soc_read(codec, WM8580_PLLB4); + reg = snd_soc_component_read32(component, WM8580_PLLB4); reg &= ~WM8580_PLLB4_CLKOUTSRC_MASK; switch (div) { @@ -741,7 +741,7 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_write(codec, WM8580_PLLB4, reg); + snd_soc_component_write(component, WM8580_PLLB4, reg); break; default: @@ -754,8 +754,8 @@ static int wm8580_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); int ret, sel, sel_mask, sel_shift; switch (dai->driver->id) { @@ -790,14 +790,14 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, sel = 3 << sel_shift; break; default: - dev_err(codec->dev, "Unknown clock %d\n", clk_id); + dev_err(component->dev, "Unknown clock %d\n", clk_id); return -EINVAL; } /* We really should validate PLL settings but not yet */ wm8580->sysclk[dai->driver->id] = freq; - ret = snd_soc_update_bits(codec, WM8580_CLKSEL, sel_mask, sel); + ret = snd_soc_component_update_bits(component, WM8580_CLKSEL, sel_mask, sel); if (ret < 0) return ret; @@ -806,22 +806,22 @@ static int wm8580_set_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8580_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg; - reg = snd_soc_read(codec, WM8580_DAC_CONTROL5); + reg = snd_soc_component_read32(component, WM8580_DAC_CONTROL5); if (mute) reg |= WM8580_DAC_CONTROL5_MUTEALL; else reg &= ~WM8580_DAC_CONTROL5_MUTEALL; - snd_soc_write(codec, WM8580_DAC_CONTROL5, reg); + snd_soc_component_write(component, WM8580_DAC_CONTROL5, reg); return 0; } -static int wm8580_set_bias_level(struct snd_soc_codec *codec, +static int wm8580_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -830,20 +830,20 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Power up and get individual control of the DACs */ - snd_soc_update_bits(codec, WM8580_PWRDN1, + snd_soc_component_update_bits(component, WM8580_PWRDN1, WM8580_PWRDN1_PWDN | WM8580_PWRDN1_ALLDACPD, 0); /* Make VMID high impedance */ - snd_soc_update_bits(codec, WM8580_ADC_CONTROL1, + snd_soc_component_update_bits(component, WM8580_ADC_CONTROL1, 0x100, 0); } break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8580_PWRDN1, + snd_soc_component_update_bits(component, WM8580_PWRDN1, WM8580_PWRDN1_PWDN, WM8580_PWRDN1_PWDN); break; } @@ -853,8 +853,8 @@ static int wm8580_set_bias_level(struct snd_soc_codec *codec, static int wm8580_playback_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); return snd_pcm_hw_constraint_minmax(substream->runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 1, wm8580->drvdata->num_dacs * 2); @@ -907,15 +907,15 @@ static struct snd_soc_dai_driver wm8580_dai[] = { }, }; -static int wm8580_probe(struct snd_soc_codec *codec) +static int wm8580_probe(struct snd_soc_component *component) { - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret = 0; switch (wm8580->drvdata->num_dacs) { case 4: - snd_soc_add_codec_controls(codec, wm8581_snd_controls, + snd_soc_add_component_controls(component, wm8581_snd_controls, ARRAY_SIZE(wm8581_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8581_dapm_widgets, ARRAY_SIZE(wm8581_dapm_widgets)); @@ -929,14 +929,14 @@ static int wm8580_probe(struct snd_soc_codec *codec) ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_regulator_get; } /* Get the codec into a known state */ - ret = snd_soc_write(codec, WM8580_RESET, 0); + ret = snd_soc_component_write(component, WM8580_RESET, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to reset codec: %d\n", ret); + dev_err(component->dev, "Failed to reset component: %d\n", ret); goto err_regulator_enable; } @@ -949,28 +949,27 @@ err_regulator_get: } /* power down chip */ -static int wm8580_remove(struct snd_soc_codec *codec) +static void wm8580_remove(struct snd_soc_component *component) { - struct wm8580_priv *wm8580 = snd_soc_codec_get_drvdata(codec); + struct wm8580_priv *wm8580 = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8580 = { - .probe = wm8580_probe, - .remove = wm8580_remove, - .set_bias_level = wm8580_set_bias_level, - - .component_driver = { - .controls = wm8580_snd_controls, - .num_controls = ARRAY_SIZE(wm8580_snd_controls), - .dapm_widgets = wm8580_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8580_dapm_widgets), - .dapm_routes = wm8580_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8580_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8580 = { + .probe = wm8580_probe, + .remove = wm8580_remove, + .set_bias_level = wm8580_set_bias_level, + .controls = wm8580_snd_controls, + .num_controls = ARRAY_SIZE(wm8580_snd_controls), + .dapm_widgets = wm8580_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8580_dapm_widgets), + .dapm_routes = wm8580_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8580_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8580_regmap = { @@ -1037,18 +1036,12 @@ static int wm8580_i2c_probe(struct i2c_client *i2c, return -EINVAL; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai)); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8580, wm8580_dai, ARRAY_SIZE(wm8580_dai)); return ret; } -static int wm8580_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8580_i2c_id[] = { { "wm8580", (kernel_ulong_t)&wm8580_data }, { "wm8581", (kernel_ulong_t)&wm8581_data }, @@ -1062,7 +1055,6 @@ static struct i2c_driver wm8580_i2c_driver = { .of_match_table = wm8580_of_match, }, .probe = wm8580_i2c_probe, - .remove = wm8580_i2c_remove, .id_table = wm8580_i2c_id, }; From 3b60cf1024e0f3c94851ce97baa8a7f31bb73955 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:00:38 +0000 Subject: [PATCH 022/942] ASoC: wm8524: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8524.c | 56 +++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/sound/soc/codecs/wm8524.c b/sound/soc/codecs/wm8524.c index 856a6950a451..fde444d826ca 100644 --- a/sound/soc/codecs/wm8524.c +++ b/sound/soc/codecs/wm8524.c @@ -62,14 +62,14 @@ static const struct { static int wm8524_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component); /* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this. */ if (!wm8524->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL; } @@ -86,8 +86,8 @@ static int wm8524_startup(struct snd_pcm_substream *substream, static void wm8524_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component); gpiod_set_value_cansleep(wm8524->mute, 0); } @@ -95,8 +95,8 @@ static void wm8524_shutdown(struct snd_pcm_substream *substream, static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component); unsigned int val; int i, j = 0; @@ -118,13 +118,13 @@ static int wm8524_set_dai_sysclk(struct snd_soc_dai *codec_dai, case 96000: case 176400: case 192000: - dev_dbg(codec->dev, "Supported sample rate: %dHz\n", + dev_dbg(component->dev, "Supported sample rate: %dHz\n", val); wm8524->rate_constraint_list[j++] = val; wm8524->rate_constraint.count++; break; default: - dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", + dev_dbg(component->dev, "Skipping sample rate: %dHz\n", val); } } @@ -152,7 +152,7 @@ static int wm8524_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int wm8524_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(dai->codec); + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(dai->component); if (wm8524->mute) gpiod_set_value_cansleep(wm8524->mute, mute); @@ -184,9 +184,9 @@ static struct snd_soc_dai_driver wm8524_dai = { .ops = &wm8524_dai_ops, }; -static int wm8524_probe(struct snd_soc_codec *codec) +static int wm8524_probe(struct snd_soc_component *component) { - struct wm8524_priv *wm8524 = snd_soc_codec_get_drvdata(codec); + struct wm8524_priv *wm8524 = snd_soc_component_get_drvdata(component); wm8524->rate_constraint.list = &wm8524->rate_constraint_list[0]; wm8524->rate_constraint.count = @@ -195,15 +195,16 @@ static int wm8524_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8524 = { - .probe = wm8524_probe, - - .component_driver = { - .dapm_widgets = wm8524_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8524_dapm_widgets), - .dapm_routes = wm8524_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8524_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8524 = { + .probe = wm8524_probe, + .dapm_widgets = wm8524_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8524_dapm_widgets), + .dapm_routes = wm8524_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8524_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8524_of_match[] = { @@ -231,23 +232,16 @@ static int wm8524_codec_probe(struct platform_device *pdev) return ret; } - ret = snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm8524, &wm8524_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8524, &wm8524_dai, 1); if (ret < 0) - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret); return ret; } -static int wm8524_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver wm8524_codec_driver = { .probe = wm8524_codec_probe, - .remove = wm8524_codec_remove, .driver = { .name = "wm8524-codec", .of_match_table = wm8524_of_match, From 51bf02cc505fb4bc0c5913e64db12c6b7e464f23 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:00:54 +0000 Subject: [PATCH 023/942] ASoC: wm8510: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8510.c | 149 +++++++++++++++++--------------------- 1 file changed, 68 insertions(+), 81 deletions(-) diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 119ceac684ae..1a2412d73e35 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c @@ -106,7 +106,7 @@ static bool wm8510_volatile(struct device *dev, unsigned int reg) #define WM8510_POWER1_BIASEN 0x08 #define WM8510_POWER1_BUFIOEN 0x10 -#define wm8510_reset(c) snd_soc_write(c, WM8510_RESET, 0) +#define wm8510_reset(c) snd_soc_component_write(c, WM8510_RESET, 0) /* codec private data */ struct wm8510_priv { @@ -316,32 +316,32 @@ static void pll_factors(unsigned int target, unsigned int source) static int wm8510_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; if (freq_in == 0 || freq_out == 0) { /* Clock CODEC directly from MCLK */ - reg = snd_soc_read(codec, WM8510_CLOCK); - snd_soc_write(codec, WM8510_CLOCK, reg & 0x0ff); + reg = snd_soc_component_read32(component, WM8510_CLOCK); + snd_soc_component_write(component, WM8510_CLOCK, reg & 0x0ff); /* Turn off PLL */ - reg = snd_soc_read(codec, WM8510_POWER1); - snd_soc_write(codec, WM8510_POWER1, reg & 0x1df); + reg = snd_soc_component_read32(component, WM8510_POWER1); + snd_soc_component_write(component, WM8510_POWER1, reg & 0x1df); return 0; } pll_factors(freq_out*4, freq_in); - snd_soc_write(codec, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n); - snd_soc_write(codec, WM8510_PLLK1, pll_div.k >> 18); - snd_soc_write(codec, WM8510_PLLK2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8510_PLLK3, pll_div.k & 0x1ff); - reg = snd_soc_read(codec, WM8510_POWER1); - snd_soc_write(codec, WM8510_POWER1, reg | 0x020); + snd_soc_component_write(component, WM8510_PLLN, (pll_div.pre_div << 4) | pll_div.n); + snd_soc_component_write(component, WM8510_PLLK1, pll_div.k >> 18); + snd_soc_component_write(component, WM8510_PLLK2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8510_PLLK3, pll_div.k & 0x1ff); + reg = snd_soc_component_read32(component, WM8510_POWER1); + snd_soc_component_write(component, WM8510_POWER1, reg | 0x020); /* Run CODEC from PLL instead of MCLK */ - reg = snd_soc_read(codec, WM8510_CLOCK); - snd_soc_write(codec, WM8510_CLOCK, reg | 0x100); + reg = snd_soc_component_read32(component, WM8510_CLOCK); + snd_soc_component_write(component, WM8510_CLOCK, reg | 0x100); return 0; } @@ -352,29 +352,29 @@ static int wm8510_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8510_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; switch (div_id) { case WM8510_OPCLKDIV: - reg = snd_soc_read(codec, WM8510_GPIO) & 0x1cf; - snd_soc_write(codec, WM8510_GPIO, reg | div); + reg = snd_soc_component_read32(component, WM8510_GPIO) & 0x1cf; + snd_soc_component_write(component, WM8510_GPIO, reg | div); break; case WM8510_MCLKDIV: - reg = snd_soc_read(codec, WM8510_CLOCK) & 0x11f; - snd_soc_write(codec, WM8510_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8510_CLOCK) & 0x11f; + snd_soc_component_write(component, WM8510_CLOCK, reg | div); break; case WM8510_ADCCLK: - reg = snd_soc_read(codec, WM8510_ADC) & 0x1f7; - snd_soc_write(codec, WM8510_ADC, reg | div); + reg = snd_soc_component_read32(component, WM8510_ADC) & 0x1f7; + snd_soc_component_write(component, WM8510_ADC, reg | div); break; case WM8510_DACCLK: - reg = snd_soc_read(codec, WM8510_DAC) & 0x1f7; - snd_soc_write(codec, WM8510_DAC, reg | div); + reg = snd_soc_component_read32(component, WM8510_DAC) & 0x1f7; + snd_soc_component_write(component, WM8510_DAC, reg | div); break; case WM8510_BCLKDIV: - reg = snd_soc_read(codec, WM8510_CLOCK) & 0x1e3; - snd_soc_write(codec, WM8510_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8510_CLOCK) & 0x1e3; + snd_soc_component_write(component, WM8510_CLOCK, reg | div); break; default: return -EINVAL; @@ -386,9 +386,9 @@ static int wm8510_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8510_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; - u16 clk = snd_soc_read(codec, WM8510_CLOCK) & 0x1fe; + u16 clk = snd_soc_component_read32(component, WM8510_CLOCK) & 0x1fe; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -435,8 +435,8 @@ static int wm8510_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8510_IFACE, iface); - snd_soc_write(codec, WM8510_CLOCK, clk); + snd_soc_component_write(component, WM8510_IFACE, iface); + snd_soc_component_write(component, WM8510_CLOCK, clk); return 0; } @@ -444,9 +444,9 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 iface = snd_soc_read(codec, WM8510_IFACE) & 0x19f; - u16 adn = snd_soc_read(codec, WM8510_ADD) & 0x1f1; + struct snd_soc_component *component = dai->component; + u16 iface = snd_soc_component_read32(component, WM8510_IFACE) & 0x19f; + u16 adn = snd_soc_component_read32(component, WM8510_ADD) & 0x1f1; /* bit size */ switch (params_width(params)) { @@ -485,56 +485,56 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8510_IFACE, iface); - snd_soc_write(codec, WM8510_ADD, adn); + snd_soc_component_write(component, WM8510_IFACE, iface); + snd_soc_component_write(component, WM8510_ADD, adn); return 0; } static int wm8510_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8510_DAC) & 0xffbf; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8510_DAC) & 0xffbf; if (mute) - snd_soc_write(codec, WM8510_DAC, mute_reg | 0x40); + snd_soc_component_write(component, WM8510_DAC, mute_reg | 0x40); else - snd_soc_write(codec, WM8510_DAC, mute_reg); + snd_soc_component_write(component, WM8510_DAC, mute_reg); return 0; } /* liam need to make this lower power with dapm */ -static int wm8510_set_bias_level(struct snd_soc_codec *codec, +static int wm8510_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8510_priv *wm8510 = snd_soc_codec_get_drvdata(codec); - u16 power1 = snd_soc_read(codec, WM8510_POWER1) & ~0x3; + struct wm8510_priv *wm8510 = snd_soc_component_get_drvdata(component); + u16 power1 = snd_soc_component_read32(component, WM8510_POWER1) & ~0x3; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 0x1; /* VMID 50k */ - snd_soc_write(codec, WM8510_POWER1, power1); + snd_soc_component_write(component, WM8510_POWER1, power1); break; case SND_SOC_BIAS_STANDBY: power1 |= WM8510_POWER1_BIASEN | WM8510_POWER1_BUFIOEN; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8510->regmap); /* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8510_POWER1, power1 | 0x3); + snd_soc_component_write(component, WM8510_POWER1, power1 | 0x3); mdelay(100); } power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8510_POWER1, power1); + snd_soc_component_write(component, WM8510_POWER1, power1); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8510_POWER1, 0); - snd_soc_write(codec, WM8510_POWER2, 0); - snd_soc_write(codec, WM8510_POWER3, 0); + snd_soc_component_write(component, WM8510_POWER1, 0); + snd_soc_component_write(component, WM8510_POWER2, 0); + snd_soc_component_write(component, WM8510_POWER3, 0); break; } @@ -574,26 +574,27 @@ static struct snd_soc_dai_driver wm8510_dai = { .symmetric_rates = 1, }; -static int wm8510_probe(struct snd_soc_codec *codec) +static int wm8510_probe(struct snd_soc_component *component) { - wm8510_reset(codec); + wm8510_reset(component); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8510 = { - .probe = wm8510_probe, - .set_bias_level = wm8510_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8510_snd_controls, - .num_controls = ARRAY_SIZE(wm8510_snd_controls), - .dapm_widgets = wm8510_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8510_dapm_widgets), - .dapm_routes = wm8510_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8510_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8510 = { + .probe = wm8510_probe, + .set_bias_level = wm8510_set_bias_level, + .controls = wm8510_snd_controls, + .num_controls = ARRAY_SIZE(wm8510_snd_controls), + .dapm_widgets = wm8510_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8510_dapm_widgets), + .dapm_routes = wm8510_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8510_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8510_of_match[] = { @@ -631,25 +632,18 @@ static int wm8510_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8510); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8510, &wm8510_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8510, &wm8510_dai, 1); return ret; } -static int wm8510_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8510_spi_driver = { .driver = { .name = "wm8510", .of_match_table = wm8510_of_match, }, .probe = wm8510_spi_probe, - .remove = wm8510_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -671,18 +665,12 @@ static int wm8510_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8510); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8510, &wm8510_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8510, &wm8510_dai, 1); return ret; } -static int wm8510_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8510_i2c_id[] = { { "wm8510", 0 }, { } @@ -695,7 +683,6 @@ static struct i2c_driver wm8510_i2c_driver = { .of_match_table = wm8510_of_match, }, .probe = wm8510_i2c_probe, - .remove = wm8510_i2c_remove, .id_table = wm8510_i2c_id, }; #endif From 4bf8ae8356c982847ef5bd5f613b87311f9024ec Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:01:09 +0000 Subject: [PATCH 024/942] ASoC: wm8523: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8523.c | 98 ++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index c7c33e98fbcb..f4a9e25fb334 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c @@ -125,14 +125,14 @@ static const struct { static int wm8523_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); /* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this. */ if (!wm8523->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL; } @@ -148,11 +148,11 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); int i; - u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); - u16 aifctrl2 = snd_soc_read(codec, WM8523_AIF_CTRL2); + u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1); + u16 aifctrl2 = snd_soc_component_read32(component, WM8523_AIF_CTRL2); /* Find a supported LRCLK ratio */ for (i = 0; i < ARRAY_SIZE(lrclk_ratios); i++) { @@ -163,7 +163,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, /* Should never happen, should be handled by constraints */ if (i == ARRAY_SIZE(lrclk_ratios)) { - dev_err(codec->dev, "MCLK/fs ratio %d unsupported\n", + dev_err(component->dev, "MCLK/fs ratio %d unsupported\n", wm8523->sysclk / params_rate(params)); return -EINVAL; } @@ -178,7 +178,7 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, break; if (i == ARRAY_SIZE(bclk_ratios)) { - dev_err(codec->dev, + dev_err(component->dev, "No matching BCLK/fs ratio for word length %d\n", params_width(params)); return -EINVAL; @@ -203,8 +203,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); - snd_soc_write(codec, WM8523_AIF_CTRL2, aifctrl2); + snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1); + snd_soc_component_write(component, WM8523_AIF_CTRL2, aifctrl2); return 0; } @@ -212,8 +212,8 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); unsigned int val; int i; @@ -239,13 +239,13 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, case 96000: case 176400: case 192000: - dev_dbg(codec->dev, "Supported sample rate: %dHz\n", + dev_dbg(component->dev, "Supported sample rate: %dHz\n", val); wm8523->rate_constraint_list[i] = val; wm8523->rate_constraint.count++; break; default: - dev_dbg(codec->dev, "Skipping sample rate: %dHz\n", + dev_dbg(component->dev, "Skipping sample rate: %dHz\n", val); } } @@ -261,8 +261,8 @@ static int wm8523_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 aifctrl1 = snd_soc_read(codec, WM8523_AIF_CTRL1); + struct snd_soc_component *component = codec_dai->component; + u16 aifctrl1 = snd_soc_component_read32(component, WM8523_AIF_CTRL1); aifctrl1 &= ~(WM8523_BCLK_INV_MASK | WM8523_LRCLK_INV_MASK | WM8523_FMT_MASK | WM8523_AIF_MSTR_MASK); @@ -312,15 +312,15 @@ static int wm8523_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8523_AIF_CTRL1, aifctrl1); + snd_soc_component_write(component, WM8523_AIF_CTRL1, aifctrl1); return 0; } -static int wm8523_set_bias_level(struct snd_soc_codec *codec, +static int wm8523_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -329,16 +329,16 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* Full power on */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 3); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8523->supplies), wm8523->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -348,21 +348,21 @@ static int wm8523_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8523->regmap); /* Initial power up */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 1); msleep(100); } /* Power up to mute */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 2); break; case SND_SOC_BIAS_OFF: /* The chip runs through the power down sequence for us. */ - snd_soc_update_bits(codec, WM8523_PSCTRL1, + snd_soc_component_update_bits(component, WM8523_PSCTRL1, WM8523_SYS_ENA_MASK, 0); msleep(100); @@ -397,35 +397,36 @@ static struct snd_soc_dai_driver wm8523_dai = { .ops = &wm8523_dai_ops, }; -static int wm8523_probe(struct snd_soc_codec *codec) +static int wm8523_probe(struct snd_soc_component *component) { - struct wm8523_priv *wm8523 = snd_soc_codec_get_drvdata(codec); + struct wm8523_priv *wm8523 = snd_soc_component_get_drvdata(component); wm8523->rate_constraint.list = &wm8523->rate_constraint_list[0]; wm8523->rate_constraint.count = ARRAY_SIZE(wm8523->rate_constraint_list); /* Change some default settings - latch VU and enable ZC */ - snd_soc_update_bits(codec, WM8523_DAC_GAINR, + snd_soc_component_update_bits(component, WM8523_DAC_GAINR, WM8523_DACR_VU, WM8523_DACR_VU); - snd_soc_update_bits(codec, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC); + snd_soc_component_update_bits(component, WM8523_DAC_CTRL3, WM8523_ZC, WM8523_ZC); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8523 = { - .probe = wm8523_probe, - .set_bias_level = wm8523_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8523_controls, - .num_controls = ARRAY_SIZE(wm8523_controls), - .dapm_widgets = wm8523_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets), - .dapm_routes = wm8523_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8523 = { + .probe = wm8523_probe, + .set_bias_level = wm8523_set_bias_level, + .controls = wm8523_controls, + .num_controls = ARRAY_SIZE(wm8523_controls), + .dapm_widgets = wm8523_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8523_dapm_widgets), + .dapm_routes = wm8523_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8523_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8523_of_match[] = { @@ -511,8 +512,8 @@ static int wm8523_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8523); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8523, &wm8523_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8523, &wm8523_dai, 1); return ret; @@ -521,12 +522,6 @@ err_enable: return ret; } -static int wm8523_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8523_i2c_id[] = { { "wm8523", 0 }, { } @@ -539,7 +534,6 @@ static struct i2c_driver wm8523_i2c_driver = { .of_match_table = wm8523_of_match, }, .probe = wm8523_i2c_probe, - .remove = wm8523_i2c_remove, .id_table = wm8523_i2c_id, }; From 56fc4d2a2a26c39900aca01673f47e06a847e26d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:01:25 +0000 Subject: [PATCH 025/942] ASoC: wm8711: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8711.c | 116 +++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 65 deletions(-) diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c index 2b376c9c99af..1da08d281ae7 100644 --- a/sound/soc/codecs/wm8711.c +++ b/sound/soc/codecs/wm8711.c @@ -58,7 +58,7 @@ static bool wm8711_volatile(struct device *dev, unsigned int reg) } } -#define wm8711_reset(c) snd_soc_write(c, WM8711_RESET, 0) +#define wm8711_reset(c) snd_soc_component_write(c, WM8711_RESET, 0) static const DECLARE_TLV_DB_SCALE(out_tlv, -12100, 100, 1); @@ -159,14 +159,14 @@ static int wm8711_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8711_IFACE) & 0xfff3; + struct snd_soc_component *component = dai->component; + struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8711_IFACE) & 0xfff3; int i = get_coeff(wm8711->sysclk, params_rate(params)); u16 srate = (coeff_div[i].sr << 2) | (coeff_div[i].bosr << 1) | coeff_div[i].usb; - snd_soc_write(codec, WM8711_SRATE, srate); + snd_soc_component_write(component, WM8711_SRATE, srate); /* bit size */ switch (params_width(params)) { @@ -180,17 +180,17 @@ static int wm8711_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8711_IFACE, iface); + snd_soc_component_write(component, WM8711_IFACE, iface); return 0; } static int wm8711_pcm_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; /* set active */ - snd_soc_write(codec, WM8711_ACTIVE, 0x0001); + snd_soc_component_write(component, WM8711_ACTIVE, 0x0001); return 0; } @@ -198,24 +198,24 @@ static int wm8711_pcm_prepare(struct snd_pcm_substream *substream, static void wm8711_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; /* deactivate */ - if (!snd_soc_codec_is_active(codec)) { + if (!snd_soc_component_is_active(component)) { udelay(50); - snd_soc_write(codec, WM8711_ACTIVE, 0x0); + snd_soc_component_write(component, WM8711_ACTIVE, 0x0); } } static int wm8711_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8711_APDIGI) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8711_APDIGI) & 0xfff7; if (mute) - snd_soc_write(codec, WM8711_APDIGI, mute_reg | 0x8); + snd_soc_component_write(component, WM8711_APDIGI, mute_reg | 0x8); else - snd_soc_write(codec, WM8711_APDIGI, mute_reg); + snd_soc_component_write(component, WM8711_APDIGI, mute_reg); return 0; } @@ -223,8 +223,8 @@ static int wm8711_mute(struct snd_soc_dai *dai, int mute) static int wm8711_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component); switch (freq) { case 11289600: @@ -241,8 +241,8 @@ static int wm8711_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8711_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8711_IFACE) & 0x000c; + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8711_IFACE) & 0x000c; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -293,31 +293,31 @@ static int wm8711_set_dai_fmt(struct snd_soc_dai *codec_dai, } /* set iface */ - snd_soc_write(codec, WM8711_IFACE, iface); + snd_soc_component_write(component, WM8711_IFACE, iface); return 0; } -static int wm8711_set_bias_level(struct snd_soc_codec *codec, +static int wm8711_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8711_priv *wm8711 = snd_soc_codec_get_drvdata(codec); - u16 reg = snd_soc_read(codec, WM8711_PWR) & 0xff7f; + struct wm8711_priv *wm8711 = snd_soc_component_get_drvdata(component); + u16 reg = snd_soc_component_read32(component, WM8711_PWR) & 0xff7f; switch (level) { case SND_SOC_BIAS_ON: - snd_soc_write(codec, WM8711_PWR, reg); + snd_soc_component_write(component, WM8711_PWR, reg); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) regcache_sync(wm8711->regmap); - snd_soc_write(codec, WM8711_PWR, reg | 0x0040); + snd_soc_component_write(component, WM8711_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8711_ACTIVE, 0x0); - snd_soc_write(codec, WM8711_PWR, 0xffff); + snd_soc_component_write(component, WM8711_ACTIVE, 0x0); + snd_soc_component_write(component, WM8711_PWR, 0xffff); break; } return 0; @@ -349,37 +349,38 @@ static struct snd_soc_dai_driver wm8711_dai = { .ops = &wm8711_ops, }; -static int wm8711_probe(struct snd_soc_codec *codec) +static int wm8711_probe(struct snd_soc_component *component) { int ret; - ret = wm8711_reset(codec); + ret = wm8711_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; } /* Latch the update bits */ - snd_soc_update_bits(codec, WM8711_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8711_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8711_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8711_ROUT1V, 0x0100, 0x0100); return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8711 = { - .probe = wm8711_probe, - .set_bias_level = wm8711_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8711_snd_controls, - .num_controls = ARRAY_SIZE(wm8711_snd_controls), - .dapm_widgets = wm8711_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8711_dapm_widgets), - .dapm_routes = wm8711_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8711_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8711 = { + .probe = wm8711_probe, + .set_bias_level = wm8711_set_bias_level, + .controls = wm8711_snd_controls, + .num_controls = ARRAY_SIZE(wm8711_snd_controls), + .dapm_widgets = wm8711_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8711_dapm_widgets), + .dapm_routes = wm8711_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8711_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8711_of_match[] = { @@ -417,26 +418,18 @@ static int wm8711_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8711); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8711, &wm8711_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8711, &wm8711_dai, 1); return ret; } -static int wm8711_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - - return 0; -} - static struct spi_driver wm8711_spi_driver = { .driver = { .name = "wm8711", .of_match_table = wm8711_of_match, }, .probe = wm8711_spi_probe, - .remove = wm8711_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -458,18 +451,12 @@ static int wm8711_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, wm8711); - ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_wm8711, &wm8711_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_wm8711, &wm8711_dai, 1); return ret; } -static int wm8711_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8711_i2c_id[] = { { "wm8711", 0 }, { } @@ -482,7 +469,6 @@ static struct i2c_driver wm8711_i2c_driver = { .of_match_table = wm8711_of_match, }, .probe = wm8711_i2c_probe, - .remove = wm8711_i2c_remove, .id_table = wm8711_i2c_id, }; #endif From f081a227aeeb081bf0a886d59d5dd78f35882575 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:01:40 +0000 Subject: [PATCH 026/942] ASoC: wm8750: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8750.c | 115 +++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 64 deletions(-) diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 0da2bbaf06d1..97239bc9d253 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c @@ -86,7 +86,7 @@ struct wm8750_priv { unsigned int sysclk; }; -#define wm8750_reset(c) snd_soc_write(c, WM8750_RESET, 0) +#define wm8750_reset(c) snd_soc_component_write(c, WM8750_RESET, 0) /* * WM8750 Controls @@ -502,8 +502,8 @@ static inline int get_coeff(int mclk, int rate) static int wm8750_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8750_priv *wm8750 = snd_soc_component_get_drvdata(component); switch (freq) { case 11289600: @@ -520,7 +520,7 @@ static int wm8750_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8750_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -571,7 +571,7 @@ static int wm8750_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8750_IFACE, iface); + snd_soc_component_write(component, WM8750_IFACE, iface); return 0; } @@ -579,10 +579,10 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8750_priv *wm8750 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8750_IFACE) & 0x1f3; - u16 srate = snd_soc_read(codec, WM8750_SRATE) & 0x1c0; + struct snd_soc_component *component = dai->component; + struct wm8750_priv *wm8750 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8750_IFACE) & 0x1f3; + u16 srate = snd_soc_component_read32(component, WM8750_SRATE) & 0x1c0; int coeff = get_coeff(wm8750->sysclk, params_rate(params)); /* bit size */ @@ -601,9 +601,9 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream, } /* set iface & srate */ - snd_soc_write(codec, WM8750_IFACE, iface); + snd_soc_component_write(component, WM8750_IFACE, iface); if (coeff >= 0) - snd_soc_write(codec, WM8750_SRATE, srate | + snd_soc_component_write(component, WM8750_SRATE, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); return 0; @@ -611,44 +611,44 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream, static int wm8750_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8750_ADCDAC) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8750_ADCDAC) & 0xfff7; if (mute) - snd_soc_write(codec, WM8750_ADCDAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8750_ADCDAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8750_ADCDAC, mute_reg); + snd_soc_component_write(component, WM8750_ADCDAC, mute_reg); return 0; } -static int wm8750_set_bias_level(struct snd_soc_codec *codec, +static int wm8750_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 pwr_reg = snd_soc_read(codec, WM8750_PWR1) & 0xfe3e; + u16 pwr_reg = snd_soc_component_read32(component, WM8750_PWR1) & 0xfe3e; switch (level) { case SND_SOC_BIAS_ON: /* set vmid to 50k and unmute dac */ - snd_soc_write(codec, WM8750_PWR1, pwr_reg | 0x00c0); + snd_soc_component_write(component, WM8750_PWR1, pwr_reg | 0x00c0); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_cache_sync(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_cache_sync(component); /* Set VMID to 5k */ - snd_soc_write(codec, WM8750_PWR1, pwr_reg | 0x01c1); + snd_soc_component_write(component, WM8750_PWR1, pwr_reg | 0x01c1); /* ...and ramp */ msleep(1000); } /* mute dac and set vmid to 500k, enable VREF */ - snd_soc_write(codec, WM8750_PWR1, pwr_reg | 0x0141); + snd_soc_component_write(component, WM8750_PWR1, pwr_reg | 0x0141); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8750_PWR1, 0x0001); + snd_soc_component_write(component, WM8750_PWR1, 0x0001); break; } return 0; @@ -685,42 +685,43 @@ static struct snd_soc_dai_driver wm8750_dai = { .ops = &wm8750_dai_ops, }; -static int wm8750_probe(struct snd_soc_codec *codec) +static int wm8750_probe(struct snd_soc_component *component) { int ret; - ret = wm8750_reset(codec); + ret = wm8750_reset(component); if (ret < 0) { printk(KERN_ERR "wm8750: failed to reset: %d\n", ret); return ret; } /* set the update bits */ - snd_soc_update_bits(codec, WM8750_LDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_LOUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_LINVOL, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8750_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LOUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_LINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8750_RINVOL, 0x0100, 0x0100); return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8750 = { - .probe = wm8750_probe, - .set_bias_level = wm8750_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8750_snd_controls, - .num_controls = ARRAY_SIZE(wm8750_snd_controls), - .dapm_widgets = wm8750_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), - .dapm_routes = wm8750_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8750_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8750 = { + .probe = wm8750_probe, + .set_bias_level = wm8750_set_bias_level, + .controls = wm8750_snd_controls, + .num_controls = ARRAY_SIZE(wm8750_snd_controls), + .dapm_widgets = wm8750_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), + .dapm_routes = wm8750_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8750_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8750_of_match[] = { @@ -758,17 +759,11 @@ static int wm8750_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8750); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8750, &wm8750_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8750, &wm8750_dai, 1); return ret; } -static int wm8750_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct spi_device_id wm8750_spi_ids[] = { { "wm8750", 0 }, { "wm8987", 0 }, @@ -783,7 +778,6 @@ static struct spi_driver wm8750_spi_driver = { }, .id_table = wm8750_spi_ids, .probe = wm8750_spi_probe, - .remove = wm8750_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -806,17 +800,11 @@ static int wm8750_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8750, &wm8750_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8750, &wm8750_dai, 1); return ret; } -static int wm8750_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8750_i2c_id[] = { { "wm8750", 0 }, { "wm8987", 0 }, @@ -830,7 +818,6 @@ static struct i2c_driver wm8750_i2c_driver = { .of_match_table = wm8750_of_match, }, .probe = wm8750_i2c_probe, - .remove = wm8750_i2c_remove, .id_table = wm8750_i2c_id, }; #endif From 840680dcc29e2d9b49aee0f2910e8e22cfdf0709 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:01:57 +0000 Subject: [PATCH 027/942] ASoC: wm8737: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8737.c | 109 ++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 62 deletions(-) diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c index f0cb1c4afe3c..e9ae821e7609 100644 --- a/sound/soc/codecs/wm8737.c +++ b/sound/soc/codecs/wm8737.c @@ -74,9 +74,9 @@ static bool wm8737_volatile(struct device *dev, unsigned int reg) } } -static int wm8737_reset(struct snd_soc_codec *codec) +static int wm8737_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8737_RESET, 0); + return snd_soc_component_write(component, WM8737_RESET, 0); } static const DECLARE_TLV_DB_RANGE(micboost_tlv, @@ -328,8 +328,8 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int i; u16 clocking = 0; u16 af = 0; @@ -348,7 +348,7 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, } if (i == ARRAY_SIZE(coeff_div)) { - dev_err(codec->dev, "%dHz MCLK can't support %dHz\n", + dev_err(component->dev, "%dHz MCLK can't support %dHz\n", wm8737->mclk, params_rate(params)); return -EINVAL; } @@ -371,8 +371,8 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, WM8737_AUDIO_FORMAT, WM8737_WL_MASK, af); - snd_soc_update_bits(codec, WM8737_CLOCKING, + snd_soc_component_update_bits(component, WM8737_AUDIO_FORMAT, WM8737_WL_MASK, af); + snd_soc_component_update_bits(component, WM8737_CLOCKING, WM8737_USB_MODE | WM8737_CLKDIV2 | WM8737_SR_MASK, clocking); @@ -382,8 +382,8 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, static int wm8737_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { @@ -394,7 +394,7 @@ static int wm8737_set_dai_sysclk(struct snd_soc_dai *codec_dai, } } - dev_err(codec->dev, "MCLK rate %dHz not supported\n", freq); + dev_err(component->dev, "MCLK rate %dHz not supported\n", freq); return -EINVAL; } @@ -403,7 +403,7 @@ static int wm8737_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8737_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 af = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -445,16 +445,16 @@ static int wm8737_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_update_bits(codec, WM8737_AUDIO_FORMAT, + snd_soc_component_update_bits(component, WM8737_AUDIO_FORMAT, WM8737_FORMAT_MASK | WM8737_LRP | WM8737_MS, af); return 0; } -static int wm8737_set_bias_level(struct snd_soc_codec *codec, +static int wm8737_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -463,16 +463,16 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID at 2*75k */ - snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, + snd_soc_component_update_bits(component, WM8737_MISC_BIAS_CONTROL, WM8737_VMIDSEL_MASK, 0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -481,12 +481,12 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8737->regmap); /* Fast VMID ramp at 2*2.5k */ - snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, + snd_soc_component_update_bits(component, WM8737_MISC_BIAS_CONTROL, WM8737_VMIDSEL_MASK, 2 << WM8737_VMIDSEL_SHIFT); /* Bring VMID up */ - snd_soc_update_bits(codec, WM8737_POWER_MANAGEMENT, + snd_soc_component_update_bits(component, WM8737_POWER_MANAGEMENT, WM8737_VMID_MASK | WM8737_VREF_MASK, WM8737_VMID_MASK | @@ -496,14 +496,14 @@ static int wm8737_set_bias_level(struct snd_soc_codec *codec, } /* VMID at 2*300k */ - snd_soc_update_bits(codec, WM8737_MISC_BIAS_CONTROL, + snd_soc_component_update_bits(component, WM8737_MISC_BIAS_CONTROL, WM8737_VMIDSEL_MASK, 1 << WM8737_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8737_POWER_MANAGEMENT, + snd_soc_component_update_bits(component, WM8737_POWER_MANAGEMENT, WM8737_VMID_MASK | WM8737_VREF_MASK, 0); regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), @@ -537,30 +537,30 @@ static struct snd_soc_dai_driver wm8737_dai = { .ops = &wm8737_dai_ops, }; -static int wm8737_probe(struct snd_soc_codec *codec) +static int wm8737_probe(struct snd_soc_component *component) { - struct wm8737_priv *wm8737 = snd_soc_codec_get_drvdata(codec); + struct wm8737_priv *wm8737 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } - ret = wm8737_reset(codec); + ret = wm8737_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); goto err_enable; } - snd_soc_update_bits(codec, WM8737_LEFT_PGA_VOLUME, WM8737_LVU, + snd_soc_component_update_bits(component, WM8737_LEFT_PGA_VOLUME, WM8737_LVU, WM8737_LVU); - snd_soc_update_bits(codec, WM8737_RIGHT_PGA_VOLUME, WM8737_RVU, + snd_soc_component_update_bits(component, WM8737_RIGHT_PGA_VOLUME, WM8737_RVU, WM8737_RVU); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8737->supplies), wm8737->supplies); @@ -573,19 +573,20 @@ err_get: return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8737 = { - .probe = wm8737_probe, - .set_bias_level = wm8737_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8737_snd_controls, - .num_controls = ARRAY_SIZE(wm8737_snd_controls), - .dapm_widgets = wm8737_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8737_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8737 = { + .probe = wm8737_probe, + .set_bias_level = wm8737_set_bias_level, + .controls = wm8737_snd_controls, + .num_controls = ARRAY_SIZE(wm8737_snd_controls), + .dapm_widgets = wm8737_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8737_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8737_of_match[] = { @@ -635,20 +636,13 @@ static int wm8737_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8737); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8737, &wm8737_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8737, &wm8737_dai, 1); return ret; } -static int wm8737_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8737_i2c_id[] = { { "wm8737", 0 }, { } @@ -661,7 +655,6 @@ static struct i2c_driver wm8737_i2c_driver = { .of_match_table = wm8737_of_match, }, .probe = wm8737_i2c_probe, - .remove = wm8737_i2c_remove, .id_table = wm8737_i2c_id, }; #endif @@ -693,26 +686,18 @@ static int wm8737_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8737); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8737, &wm8737_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8737, &wm8737_dai, 1); return ret; } -static int wm8737_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - - return 0; -} - static struct spi_driver wm8737_spi_driver = { .driver = { .name = "wm8737", .of_match_table = wm8737_of_match, }, .probe = wm8737_spi_probe, - .remove = wm8737_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ From 51e42c952e872ebcdbbb2418f652e9c678612072 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:02:13 +0000 Subject: [PATCH 028/942] ASoC: wm8776: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8776.c | 105 +++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/sound/soc/codecs/wm8776.c b/sound/soc/codecs/wm8776.c index ae30480b3976..fb357e23f221 100644 --- a/sound/soc/codecs/wm8776.c +++ b/sound/soc/codecs/wm8776.c @@ -78,9 +78,9 @@ static bool wm8776_volatile(struct device *dev, unsigned int reg) } } -static int wm8776_reset(struct snd_soc_codec *codec) +static int wm8776_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8776_RESET, 0); + return snd_soc_component_write(component, WM8776_RESET, 0); } static const DECLARE_TLV_DB_SCALE(hp_tlv, -12100, 100, 1); @@ -166,7 +166,7 @@ static const struct snd_soc_dapm_route routes[] = { static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg, iface, master; switch (dai->driver->id) { @@ -224,8 +224,8 @@ static int wm8776_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* Finally, write out the values */ - snd_soc_update_bits(codec, reg, 0xf, iface); - snd_soc_update_bits(codec, WM8776_MSTRCTRL, 0x180, master); + snd_soc_component_update_bits(component, reg, 0xf, iface); + snd_soc_component_update_bits(component, WM8776_MSTRCTRL, 0x180, master); return 0; } @@ -243,8 +243,8 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component); int iface_reg, iface; int ratio_shift, master; int i; @@ -279,13 +279,13 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, iface = 0x30; break; default: - dev_err(codec->dev, "Unsupported sample size: %i\n", + dev_err(component->dev, "Unsupported sample size: %i\n", params_width(params)); return -EINVAL; } /* Only need to set MCLK/LRCLK ratio if we're master */ - if (snd_soc_read(codec, WM8776_MSTRCTRL) & master) { + if (snd_soc_component_read32(component, WM8776_MSTRCTRL) & master) { for (i = 0; i < ARRAY_SIZE(mclk_ratios); i++) { if (wm8776->sysclk[dai->driver->id] / params_rate(params) == mclk_ratios[i]) @@ -293,37 +293,37 @@ static int wm8776_hw_params(struct snd_pcm_substream *substream, } if (i == ARRAY_SIZE(mclk_ratios)) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to configure MCLK ratio %d/%d\n", wm8776->sysclk[dai->driver->id], params_rate(params)); return -EINVAL; } - dev_dbg(codec->dev, "MCLK is %dfs\n", mclk_ratios[i]); + dev_dbg(component->dev, "MCLK is %dfs\n", mclk_ratios[i]); - snd_soc_update_bits(codec, WM8776_MSTRCTRL, + snd_soc_component_update_bits(component, WM8776_MSTRCTRL, 0x7 << ratio_shift, i << ratio_shift); } else { - dev_dbg(codec->dev, "DAI in slave mode\n"); + dev_dbg(component->dev, "DAI in slave mode\n"); } - snd_soc_update_bits(codec, iface_reg, 0x30, iface); + snd_soc_component_update_bits(component, iface_reg, 0x30, iface); return 0; } static int wm8776_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - return snd_soc_write(codec, WM8776_DACMUTE, !!mute); + return snd_soc_component_write(component, WM8776_DACMUTE, !!mute); } static int wm8776_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component); if (WARN_ON(dai->driver->id >= ARRAY_SIZE(wm8776->sysclk))) return -EINVAL; @@ -333,10 +333,10 @@ static int wm8776_set_sysclk(struct snd_soc_dai *dai, return 0; } -static int wm8776_set_bias_level(struct snd_soc_codec *codec, +static int wm8776_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8776_priv *wm8776 = snd_soc_codec_get_drvdata(codec); + struct wm8776_priv *wm8776 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -344,16 +344,16 @@ static int wm8776_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8776->regmap); /* Disable the global powerdown; DAPM does the rest */ - snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 0); + snd_soc_component_update_bits(component, WM8776_PWRDOWN, 1, 0); } break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8776_PWRDOWN, 1, 1); + snd_soc_component_update_bits(component, WM8776_PWRDOWN, 1, 1); break; } @@ -407,37 +407,38 @@ static struct snd_soc_dai_driver wm8776_dai[] = { }, }; -static int wm8776_probe(struct snd_soc_codec *codec) +static int wm8776_probe(struct snd_soc_component *component) { int ret = 0; - ret = wm8776_reset(codec); + ret = wm8776_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; } /* Latch the update bits; right channel only since we always * update both. */ - snd_soc_update_bits(codec, WM8776_HPRVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8776_DACRVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8776_HPRVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8776_DACRVOL, 0x100, 0x100); return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8776 = { - .probe = wm8776_probe, - .set_bias_level = wm8776_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8776_snd_controls, - .num_controls = ARRAY_SIZE(wm8776_snd_controls), - .dapm_widgets = wm8776_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets), - .dapm_routes = routes, - .num_dapm_routes = ARRAY_SIZE(routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8776 = { + .probe = wm8776_probe, + .set_bias_level = wm8776_set_bias_level, + .controls = wm8776_snd_controls, + .num_controls = ARRAY_SIZE(wm8776_snd_controls), + .dapm_widgets = wm8776_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8776_dapm_widgets), + .dapm_routes = routes, + .num_dapm_routes = ARRAY_SIZE(routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8776_of_match[] = { @@ -475,25 +476,18 @@ static int wm8776_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8776); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); return ret; } -static int wm8776_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8776_spi_driver = { .driver = { .name = "wm8776", .of_match_table = wm8776_of_match, }, .probe = wm8776_spi_probe, - .remove = wm8776_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -515,18 +509,12 @@ static int wm8776_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8776); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8776, wm8776_dai, ARRAY_SIZE(wm8776_dai)); return ret; } -static int wm8776_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8776_i2c_id[] = { { "wm8775", WM8775 }, { "wm8776", WM8776 }, @@ -540,7 +528,6 @@ static struct i2c_driver wm8776_i2c_driver = { .of_match_table = wm8776_of_match, }, .probe = wm8776_i2c_probe, - .remove = wm8776_i2c_remove, .id_table = wm8776_i2c_id, }; #endif From 502cb3a293be22f95737480902ed3450c06b276a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:02:29 +0000 Subject: [PATCH 029/942] ASoC: wm8770: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8770.c | 131 +++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 67 deletions(-) diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c index d6edcbbdec12..806245c70f8b 100644 --- a/sound/soc/codecs/wm8770.c +++ b/sound/soc/codecs/wm8770.c @@ -84,7 +84,7 @@ struct wm8770_priv { struct regmap *regmap; struct regulator_bulk_data supplies[WM8770_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8770_NUM_SUPPLIES]; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int sysclk; }; @@ -308,14 +308,14 @@ static const struct snd_soc_dapm_route wm8770_intercon[] = { static int vout12supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WM8770_OUTMUX1, 0x180, 0); + snd_soc_component_update_bits(component, WM8770_OUTMUX1, 0x180, 0); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8770_OUTMUX1, 0x180, 0x180); + snd_soc_component_update_bits(component, WM8770_OUTMUX1, 0x180, 0x180); break; } @@ -325,31 +325,31 @@ static int vout12supply_event(struct snd_soc_dapm_widget *w, static int vout34supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, WM8770_OUTMUX2, 0x180, 0); + snd_soc_component_update_bits(component, WM8770_OUTMUX2, 0x180, 0); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8770_OUTMUX2, 0x180, 0x180); + snd_soc_component_update_bits(component, WM8770_OUTMUX2, 0x180, 0x180); break; } return 0; } -static int wm8770_reset(struct snd_soc_codec *codec) +static int wm8770_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8770_RESET, 0); + return snd_soc_component_write(component, WM8770_RESET, 0); } static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int iface, master; - codec = dai->codec; + component = dai->component; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -392,8 +392,8 @@ static int wm8770_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8770_IFACECTRL, 0xf, iface); - snd_soc_update_bits(codec, WM8770_MSTRCTRL, 0x100, master); + snd_soc_component_update_bits(component, WM8770_IFACECTRL, 0xf, iface); + snd_soc_component_update_bits(component, WM8770_MSTRCTRL, 0x100, master); return 0; } @@ -411,15 +411,15 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8770_priv *wm8770; int i; int iface; int shift; int ratio; - codec = dai->codec; - wm8770 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8770 = snd_soc_component_get_drvdata(component); iface = 0; switch (params_width(params)) { @@ -450,7 +450,7 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, } /* Only need to set MCLK/LRCLK ratio if we're master */ - if (snd_soc_read(codec, WM8770_MSTRCTRL) & 0x100) { + if (snd_soc_component_read32(component, WM8770_MSTRCTRL) & 0x100) { for (; i < ARRAY_SIZE(mclk_ratios); ++i) { ratio = wm8770->sysclk / params_rate(params); if (ratio == mclk_ratios[i]) @@ -458,51 +458,51 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, } if (i == ARRAY_SIZE(mclk_ratios)) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to configure MCLK ratio %d/%d\n", wm8770->sysclk, params_rate(params)); return -EINVAL; } - dev_dbg(codec->dev, "MCLK is %dfs\n", mclk_ratios[i]); + dev_dbg(component->dev, "MCLK is %dfs\n", mclk_ratios[i]); - snd_soc_update_bits(codec, WM8770_MSTRCTRL, 0x7 << shift, + snd_soc_component_update_bits(component, WM8770_MSTRCTRL, 0x7 << shift, i << shift); } - snd_soc_update_bits(codec, WM8770_IFACECTRL, 0x30, iface); + snd_soc_component_update_bits(component, WM8770_IFACECTRL, 0x30, iface); return 0; } static int wm8770_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; - codec = dai->codec; - return snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, + component = dai->component; + return snd_soc_component_update_bits(component, WM8770_DACMUTE, 0x10, !!mute << 4); } static int wm8770_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8770_priv *wm8770; - codec = dai->codec; - wm8770 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8770 = snd_soc_component_get_drvdata(component); wm8770->sysclk = freq; return 0; } -static int wm8770_set_bias_level(struct snd_soc_codec *codec, +static int wm8770_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; struct wm8770_priv *wm8770; - wm8770 = snd_soc_codec_get_drvdata(codec); + wm8770 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -510,11 +510,11 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -523,12 +523,12 @@ static int wm8770_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8770->regmap); /* global powerup */ - snd_soc_write(codec, WM8770_PWDNCTRL, 0); + snd_soc_component_write(component, WM8770_PWDNCTRL, 0); } break; case SND_SOC_BIAS_OFF: /* global powerdown */ - snd_soc_write(codec, WM8770_PWDNCTRL, 1); + snd_soc_component_write(component, WM8770_PWDNCTRL, 1); regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); break; @@ -567,60 +567,59 @@ static struct snd_soc_dai_driver wm8770_dai = { .symmetric_rates = 1 }; -static int wm8770_probe(struct snd_soc_codec *codec) +static int wm8770_probe(struct snd_soc_component *component) { struct wm8770_priv *wm8770; int ret; - wm8770 = snd_soc_codec_get_drvdata(codec); - wm8770->codec = codec; + wm8770 = snd_soc_component_get_drvdata(component); + wm8770->component = component; ret = regulator_bulk_enable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } - ret = wm8770_reset(codec); + ret = wm8770_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; } /* latch the volume update bits */ - snd_soc_update_bits(codec, WM8770_MSDIGVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_MSALGVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT1RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT2RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT3RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_VOUT4RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC1RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC2RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC3RVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8770_DAC4RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_MSDIGVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_MSALGVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT1RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT2RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT3RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_VOUT4RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC1RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC2RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC3RVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8770_DAC4RVOL, 0x100, 0x100); /* mute all DACs */ - snd_soc_update_bits(codec, WM8770_DACMUTE, 0x10, 0x10); + snd_soc_component_update_bits(component, WM8770_DACMUTE, 0x10, 0x10); err_reg_enable: regulator_bulk_disable(ARRAY_SIZE(wm8770->supplies), wm8770->supplies); return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8770 = { - .probe = wm8770_probe, - .set_bias_level = wm8770_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = wm8770_snd_controls, - .num_controls = ARRAY_SIZE(wm8770_snd_controls), - .dapm_widgets = wm8770_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets), - .dapm_routes = wm8770_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8770_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8770 = { + .probe = wm8770_probe, + .set_bias_level = wm8770_set_bias_level, + .controls = wm8770_snd_controls, + .num_controls = ARRAY_SIZE(wm8770_snd_controls), + .dapm_widgets = wm8770_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8770_dapm_widgets), + .dapm_routes = wm8770_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8770_intercon), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8770_of_match[] = { @@ -682,8 +681,8 @@ static int wm8770_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8770); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8770, &wm8770_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8770, &wm8770_dai, 1); return ret; } @@ -697,8 +696,6 @@ static int wm8770_spi_remove(struct spi_device *spi) regulator_unregister_notifier(wm8770->supplies[i].consumer, &wm8770->disable_nb[i]); - snd_soc_unregister_codec(&spi->dev); - return 0; } From e5ac140d98b640e3a9c3d6b1a1eb4320d86e60da Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:02:45 +0000 Subject: [PATCH 030/942] ASoC: wm8727: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8727.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/wm8727.c b/sound/soc/codecs/wm8727.c index 7fde077a014b..087ec6db8cd0 100644 --- a/sound/soc/codecs/wm8727.c +++ b/sound/soc/codecs/wm8727.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -41,7 +40,6 @@ static const struct snd_soc_dapm_route wm8727_dapm_routes[] = { SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 |\ SNDRV_PCM_RATE_192000) - static struct snd_soc_dai_driver wm8727_dai = { .name = "wm8727-hifi", .playback = { @@ -53,25 +51,21 @@ static struct snd_soc_dai_driver wm8727_dai = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8727 = { - .component_driver = { - .dapm_widgets = wm8727_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets), - .dapm_routes = wm8727_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8727 = { + .dapm_widgets = wm8727_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8727_dapm_widgets), + .dapm_routes = wm8727_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8727_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8727_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm8727, &wm8727_dai, 1); -} - -static int wm8727_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8727, &wm8727_dai, 1); } static struct platform_driver wm8727_codec_driver = { @@ -80,7 +74,6 @@ static struct platform_driver wm8727_codec_driver = { }, .probe = wm8727_probe, - .remove = wm8727_remove, }; module_platform_driver(wm8727_codec_driver); From cde596c7c07343789e3e0f1c09fc7d3c756c88d0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:03:01 +0000 Subject: [PATCH 031/942] ASoC: wm8731: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8731.c | 101 +++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 4f9a1eb28120..7c8fad865d6b 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c @@ -88,9 +88,9 @@ static SOC_ENUM_SINGLE_DECL(wm8731_insel_enum, static int wm8731_deemph[] = { 0, 32000, 44100, 48000 }; -static int wm8731_set_deemph(struct snd_soc_codec *codec) +static int wm8731_set_deemph(struct snd_soc_component *component) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); int val, i, best; /* If we're using deemphasis select the nearest available sample @@ -110,17 +110,17 @@ static int wm8731_set_deemph(struct snd_soc_codec *codec) val = 0; } - dev_dbg(codec->dev, "Set deemphasis %d (%dHz)\n", + dev_dbg(component->dev, "Set deemphasis %d (%dHz)\n", best, wm8731_deemph[best]); - return snd_soc_update_bits(codec, WM8731_APDIGI, 0x6, val); + return snd_soc_component_update_bits(component, WM8731_APDIGI, 0x6, val); } static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8731->deemph; @@ -130,8 +130,8 @@ static int wm8731_get_deemph(struct snd_kcontrol *kcontrol, static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret = 0; @@ -142,7 +142,7 @@ static int wm8731_put_deemph(struct snd_kcontrol *kcontrol, if (wm8731->deemph != deemph) { wm8731->deemph = deemph; - wm8731_set_deemph(codec); + wm8731_set_deemph(component); ret = 1; } @@ -214,8 +214,8 @@ SND_SOC_DAPM_INPUT("LLINEIN"), static int wm8731_check_osc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); return wm8731->sysclk_type == WM8731_SYSCLK_XTAL; } @@ -337,16 +337,16 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8731_IFACE) & 0xfff3; + struct snd_soc_component *component = dai->component; + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8731_IFACE) & 0xfff3; int i = get_coeff(wm8731->sysclk, params_rate(params)); u16 srate = (coeff_div[i].sr << 2) | (coeff_div[i].bosr << 1) | coeff_div[i].usb; wm8731->playback_fs = params_rate(params); - snd_soc_write(codec, WM8731_SRATE, srate); + snd_soc_component_write(component, WM8731_SRATE, srate); /* bit size */ switch (params_width(params)) { @@ -363,30 +363,30 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, break; } - wm8731_set_deemph(codec); + wm8731_set_deemph(component); - snd_soc_write(codec, WM8731_IFACE, iface); + snd_soc_component_write(component, WM8731_IFACE, iface); return 0; } static int wm8731_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8731_APDIGI) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8731_APDIGI) & 0xfff7; if (mute) - snd_soc_write(codec, WM8731_APDIGI, mute_reg | 0x8); + snd_soc_component_write(component, WM8731_APDIGI, mute_reg | 0x8); else - snd_soc_write(codec, WM8731_APDIGI, mute_reg); + snd_soc_component_write(component, WM8731_APDIGI, mute_reg); return 0; } static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM8731_SYSCLK_XTAL: @@ -429,7 +429,7 @@ static int wm8731_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -481,14 +481,14 @@ static int wm8731_set_dai_fmt(struct snd_soc_dai *codec_dai, } /* set iface */ - snd_soc_write(codec, WM8731_IFACE, iface); + snd_soc_component_write(component, WM8731_IFACE, iface); return 0; } -static int wm8731_set_bias_level(struct snd_soc_codec *codec, +static int wm8731_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(codec); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(component); int ret; u16 reg; @@ -503,7 +503,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); if (ret != 0) @@ -513,13 +513,13 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, } /* Clear PWROFF, gate CLKOUT, everything else as-is */ - reg = snd_soc_read(codec, WM8731_PWR) & 0xff7f; - snd_soc_write(codec, WM8731_PWR, reg | 0x0040); + reg = snd_soc_component_read32(component, WM8731_PWR) & 0xff7f; + snd_soc_component_write(component, WM8731_PWR, reg | 0x0040); break; case SND_SOC_BIAS_OFF: if (wm8731->mclk) clk_disable_unprepare(wm8731->mclk); - snd_soc_write(codec, WM8731_PWR, 0xffff); + snd_soc_component_write(component, WM8731_PWR, 0xffff); regulator_bulk_disable(ARRAY_SIZE(wm8731->supplies), wm8731->supplies); regcache_mark_dirty(wm8731->regmap); @@ -531,7 +531,7 @@ static int wm8731_set_bias_level(struct snd_soc_codec *codec, static int wm8731_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct wm8731_priv *wm8731 = snd_soc_codec_get_drvdata(dai->codec); + struct wm8731_priv *wm8731 = snd_soc_component_get_drvdata(dai->component); if (wm8731->constraints) snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -628,18 +628,19 @@ err_regulator_enable: return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8731 = { - .set_bias_level = wm8731_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8731_snd_controls, - .num_controls = ARRAY_SIZE(wm8731_snd_controls), - .dapm_widgets = wm8731_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), - .dapm_routes = wm8731_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8731_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8731 = { + .set_bias_level = wm8731_set_bias_level, + .controls = wm8731_snd_controls, + .num_controls = ARRAY_SIZE(wm8731_snd_controls), + .dapm_widgets = wm8731_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8731_dapm_widgets), + .dapm_routes = wm8731_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8731_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8731_of_match[] = { @@ -704,8 +705,8 @@ static int wm8731_spi_probe(struct spi_device *spi) if (ret != 0) return ret; - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8731, &wm8731_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8731, &wm8731_dai, 1); if (ret != 0) { dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -716,7 +717,6 @@ static int wm8731_spi_probe(struct spi_device *spi) static int wm8731_spi_remove(struct spi_device *spi) { - snd_soc_unregister_codec(&spi->dev); return 0; } @@ -775,8 +775,8 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, if (ret != 0) return ret; - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8731, &wm8731_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8731, &wm8731_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -787,7 +787,6 @@ static int wm8731_i2c_probe(struct i2c_client *i2c, static int wm8731_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From d6ae5c166ab77245ba5d8c7f57518ce00945d05f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:03:17 +0000 Subject: [PATCH 032/942] ASoC: wm8782: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8782.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/wm8782.c b/sound/soc/codecs/wm8782.c index bcda21018505..7949703f3d04 100644 --- a/sound/soc/codecs/wm8782.c +++ b/sound/soc/codecs/wm8782.c @@ -50,25 +50,21 @@ static struct snd_soc_dai_driver wm8782_dai = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8782 = { - .component_driver = { - .dapm_widgets = wm8782_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8782_dapm_widgets), - .dapm_routes = wm8782_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8782_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8782 = { + .dapm_widgets = wm8782_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8782_dapm_widgets), + .dapm_routes = wm8782_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8782_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8782_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm8782, &wm8782_dai, 1); -} - -static int wm8782_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8782, &wm8782_dai, 1); } static struct platform_driver wm8782_codec_driver = { @@ -76,7 +72,6 @@ static struct platform_driver wm8782_codec_driver = { .name = "wm8782", }, .probe = wm8782_probe, - .remove = wm8782_remove, }; module_platform_driver(wm8782_codec_driver); From 6b41308015b28658d28584bc174aab45e8202fa6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:03:32 +0000 Subject: [PATCH 033/942] ASoC: wm8728: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8728.c | 82 ++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 48 deletions(-) diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index 797cc6e7c70f..839aee35ab56 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c @@ -74,13 +74,13 @@ static const struct snd_soc_dapm_route wm8728_intercon[] = { static int wm8728_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8728_DACCTL); + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8728_DACCTL); if (mute) - snd_soc_write(codec, WM8728_DACCTL, mute_reg | 1); + snd_soc_component_write(component, WM8728_DACCTL, mute_reg | 1); else - snd_soc_write(codec, WM8728_DACCTL, mute_reg & ~1); + snd_soc_component_write(component, WM8728_DACCTL, mute_reg & ~1); return 0; } @@ -89,8 +89,8 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 dac = snd_soc_read(codec, WM8728_DACCTL); + struct snd_soc_component *component = dai->component; + u16 dac = snd_soc_component_read32(component, WM8728_DACCTL); dac &= ~0x18; @@ -107,7 +107,7 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, WM8728_DACCTL, dac); + snd_soc_component_write(component, WM8728_DACCTL, dac); return 0; } @@ -115,8 +115,8 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, static int wm8728_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8728_IFCTL); + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8728_IFCTL); /* Currently only I2S is supported by the driver, though the * hardware is more flexible. @@ -156,24 +156,24 @@ static int wm8728_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8728_IFCTL, iface); + snd_soc_component_write(component, WM8728_IFCTL, iface); return 0; } -static int wm8728_set_bias_level(struct snd_soc_codec *codec, +static int wm8728_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8728_priv *wm8728 = snd_soc_codec_get_drvdata(codec); + struct wm8728_priv *wm8728 = snd_soc_component_get_drvdata(component); u16 reg; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Power everything up... */ - reg = snd_soc_read(codec, WM8728_DACCTL); - snd_soc_write(codec, WM8728_DACCTL, reg & ~0x4); + reg = snd_soc_component_read32(component, WM8728_DACCTL); + snd_soc_component_write(component, WM8728_DACCTL, reg & ~0x4); /* ..then sync in the register cache. */ regcache_sync(wm8728->regmap); @@ -181,8 +181,8 @@ static int wm8728_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - reg = snd_soc_read(codec, WM8728_DACCTL); - snd_soc_write(codec, WM8728_DACCTL, reg | 0x4); + reg = snd_soc_component_read32(component, WM8728_DACCTL); + snd_soc_component_write(component, WM8728_DACCTL, reg | 0x4); break; } return 0; @@ -211,18 +211,19 @@ static struct snd_soc_dai_driver wm8728_dai = { .ops = &wm8728_dai_ops, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8728 = { - .set_bias_level = wm8728_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8728_snd_controls, - .num_controls = ARRAY_SIZE(wm8728_snd_controls), - .dapm_widgets = wm8728_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8728_dapm_widgets), - .dapm_routes = wm8728_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8728_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8728 = { + .set_bias_level = wm8728_set_bias_level, + .controls = wm8728_snd_controls, + .num_controls = ARRAY_SIZE(wm8728_snd_controls), + .dapm_widgets = wm8728_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8728_dapm_widgets), + .dapm_routes = wm8728_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8728_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8728_of_match[] = { @@ -258,26 +259,18 @@ static int wm8728_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8728); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8728, &wm8728_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8728, &wm8728_dai, 1); return ret; } -static int wm8728_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - - return 0; -} - static struct spi_driver wm8728_spi_driver = { .driver = { .name = "wm8728", .of_match_table = wm8728_of_match, }, .probe = wm8728_spi_probe, - .remove = wm8728_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -299,18 +292,12 @@ static int wm8728_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8728); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8728, &wm8728_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8728, &wm8728_dai, 1); return ret; } -static int wm8728_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8728_i2c_id[] = { { "wm8728", 0 }, { } @@ -323,7 +310,6 @@ static struct i2c_driver wm8728_i2c_driver = { .of_match_table = wm8728_of_match, }, .probe = wm8728_i2c_probe, - .remove = wm8728_i2c_remove, .id_table = wm8728_i2c_id, }; #endif From 9b6a00f753ddb6fbc7e7b105bf4b9ddfef92b75c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:04:06 +0000 Subject: [PATCH 034/942] ASoC: wm8741: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8741.c | 133 +++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 74 deletions(-) diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c index a394dbee77aa..1fedf74da705 100644 --- a/sound/soc/codecs/wm8741.c +++ b/sound/soc/codecs/wm8741.c @@ -59,9 +59,9 @@ static const struct reg_default wm8741_reg_defaults[] = { { 32, 0x0002 }, /* R32 - ADDITONAL_CONTROL_1 */ }; -static int wm8741_reset(struct snd_soc_codec *codec) +static int wm8741_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8741_RESET, 0); + return snd_soc_component_write(component, WM8741_RESET, 0); } static const DECLARE_TLV_DB_SCALE(dac_tlv_fine, -12700, 13, 0); @@ -179,8 +179,8 @@ static const struct snd_pcm_hw_constraint_list constraints_36864 = { static int wm8741_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); if (wm8741->sysclk) snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -194,8 +194,8 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); unsigned int iface; int i; @@ -203,7 +203,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, * MCLK supplied to the CODEC - enforce this. */ if (!wm8741->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init or in hw_params\n"); return -EINVAL; } @@ -215,7 +215,7 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, } if (i == wm8741->sysclk_constraints->count) { - dev_err(codec->dev, "LRCLK %d unsupported with MCLK %d\n", + dev_err(component->dev, "LRCLK %d unsupported with MCLK %d\n", params_rate(params), wm8741->sysclk); return -EINVAL; } @@ -235,15 +235,15 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, iface = 0x3; break; default: - dev_dbg(codec->dev, "wm8741_hw_params: Unsupported bit size param = %d", + dev_dbg(component->dev, "wm8741_hw_params: Unsupported bit size param = %d", params_width(params)); return -EINVAL; } - dev_dbg(codec->dev, "wm8741_hw_params: bit size param = %d, rate param = %d", + dev_dbg(component->dev, "wm8741_hw_params: bit size param = %d, rate param = %d", params_width(params), params_rate(params)); - snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK, + snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL, WM8741_IWL_MASK, iface); return 0; @@ -252,10 +252,10 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "wm8741_set_dai_sysclk info: freq=%dHz\n", freq); + dev_dbg(component->dev, "wm8741_set_dai_sysclk info: freq=%dHz\n", freq); switch (freq) { case 0: @@ -297,7 +297,7 @@ static int wm8741_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int iface; /* check master/slave audio interface */ @@ -347,11 +347,11 @@ static int wm8741_set_dai_fmt(struct snd_soc_dai *codec_dai, } - dev_dbg(codec->dev, "wm8741_set_dai_fmt: Format=%x, Clock Inv=%x\n", + dev_dbg(component->dev, "wm8741_set_dai_fmt: Format=%x, Clock Inv=%x\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK, ((fmt & SND_SOC_DAIFMT_INV_MASK))); - snd_soc_update_bits(codec, WM8741_FORMAT_CONTROL, + snd_soc_component_update_bits(component, WM8741_FORMAT_CONTROL, WM8741_BCP_MASK | WM8741_LRP_MASK | WM8741_FMT_MASK, iface); @@ -386,18 +386,18 @@ static struct snd_soc_dai_driver wm8741_dai = { }; #ifdef CONFIG_PM -static int wm8741_resume(struct snd_soc_codec *codec) +static int wm8741_resume(struct snd_soc_component *component) { - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component); return 0; } #else #define wm8741_resume NULL #endif -static int wm8741_configure(struct snd_soc_codec *codec) +static int wm8741_configure(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); /* Configure differential mode */ switch (wm8741->pdata.diff_mode) { @@ -405,7 +405,7 @@ static int wm8741_configure(struct snd_soc_codec *codec) case WM8741_DIFF_MODE_STEREO_REVERSED: case WM8741_DIFF_MODE_MONO_LEFT: case WM8741_DIFF_MODE_MONO_RIGHT: - snd_soc_update_bits(codec, WM8741_MODE_CONTROL_2, + snd_soc_component_update_bits(component, WM8741_MODE_CONTROL_2, WM8741_DIFF_MASK, wm8741->pdata.diff_mode << WM8741_DIFF_SHIFT); break; @@ -414,36 +414,36 @@ static int wm8741_configure(struct snd_soc_codec *codec) } /* Change some default settings - latch VU */ - snd_soc_update_bits(codec, WM8741_DACLLSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACLLSB_ATTENUATION, WM8741_UPDATELL, WM8741_UPDATELL); - snd_soc_update_bits(codec, WM8741_DACLMSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACLMSB_ATTENUATION, WM8741_UPDATELM, WM8741_UPDATELM); - snd_soc_update_bits(codec, WM8741_DACRLSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACRLSB_ATTENUATION, WM8741_UPDATERL, WM8741_UPDATERL); - snd_soc_update_bits(codec, WM8741_DACRMSB_ATTENUATION, + snd_soc_component_update_bits(component, WM8741_DACRMSB_ATTENUATION, WM8741_UPDATERM, WM8741_UPDATERM); return 0; } -static int wm8741_add_controls(struct snd_soc_codec *codec) +static int wm8741_add_controls(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); switch (wm8741->pdata.diff_mode) { case WM8741_DIFF_MODE_STEREO: case WM8741_DIFF_MODE_STEREO_REVERSED: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, wm8741_snd_controls_stereo, ARRAY_SIZE(wm8741_snd_controls_stereo)); break; case WM8741_DIFF_MODE_MONO_LEFT: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, wm8741_snd_controls_mono_left, ARRAY_SIZE(wm8741_snd_controls_mono_left)); break; case WM8741_DIFF_MODE_MONO_RIGHT: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, wm8741_snd_controls_mono_right, ARRAY_SIZE(wm8741_snd_controls_mono_right)); break; @@ -454,37 +454,37 @@ static int wm8741_add_controls(struct snd_soc_codec *codec) return 0; } -static int wm8741_probe(struct snd_soc_codec *codec) +static int wm8741_probe(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); int ret = 0; ret = regulator_bulk_enable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_get; } - ret = wm8741_reset(codec); + ret = wm8741_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); goto err_enable; } - ret = wm8741_configure(codec); + ret = wm8741_configure(component); if (ret < 0) { - dev_err(codec->dev, "Failed to change default settings\n"); + dev_err(component->dev, "Failed to change default settings\n"); goto err_enable; } - ret = wm8741_add_controls(codec); + ret = wm8741_add_controls(component); if (ret < 0) { - dev_err(codec->dev, "Failed to add controls\n"); + dev_err(component->dev, "Failed to add controls\n"); goto err_enable; } - dev_dbg(codec->dev, "Successful registration\n"); + dev_dbg(component->dev, "Successful registration\n"); return ret; err_enable: @@ -493,26 +493,25 @@ err_get: return ret; } -static int wm8741_remove(struct snd_soc_codec *codec) +static void wm8741_remove(struct snd_soc_component *component) { - struct wm8741_priv *wm8741 = snd_soc_codec_get_drvdata(codec); + struct wm8741_priv *wm8741 = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(wm8741->supplies), wm8741->supplies); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8741 = { - .probe = wm8741_probe, - .remove = wm8741_remove, - .resume = wm8741_resume, - - .component_driver = { - .dapm_widgets = wm8741_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets), - .dapm_routes = wm8741_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8741_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8741 = { + .probe = wm8741_probe, + .remove = wm8741_remove, + .resume = wm8741_resume, + .dapm_widgets = wm8741_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8741_dapm_widgets), + .dapm_routes = wm8741_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8741_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8741_of_match[] = { @@ -585,18 +584,12 @@ static int wm8741_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8741); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8741, &wm8741_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8741, &wm8741_dai, 1); return ret; } -static int wm8741_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8741_i2c_id[] = { { "wm8741", 0 }, { } @@ -609,7 +602,6 @@ static struct i2c_driver wm8741_i2c_driver = { .of_match_table = wm8741_of_match, }, .probe = wm8741_i2c_probe, - .remove = wm8741_i2c_remove, .id_table = wm8741_i2c_id, }; #endif @@ -650,24 +642,17 @@ static int wm8741_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8741); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8741, &wm8741_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8741, &wm8741_dai, 1); return ret; } -static int wm8741_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8741_spi_driver = { .driver = { .name = "wm8741", .of_match_table = wm8741_of_match, }, .probe = wm8741_spi_probe, - .remove = wm8741_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ From 22d15fc51ea79e0554cfa1c9ca78af0a8d5cd20b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:04:21 +0000 Subject: [PATCH 035/942] ASoC: wm8753: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8753.c | 289 ++++++++++++++++++-------------------- 1 file changed, 138 insertions(+), 151 deletions(-) diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 0271a5253bd3..1e2823e2a906 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c @@ -55,9 +55,9 @@ static int caps_charge = 2000; module_param(caps_charge, int, 0); MODULE_PARM_DESC(caps_charge, "WM8753 cap charge time (msecs)"); -static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_hifi_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt); -static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_voice_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt); /* @@ -150,7 +150,7 @@ struct wm8753_priv { struct delayed_work charge_work; }; -#define wm8753_reset(c) snd_soc_write(c, WM8753_RESET, 0) +#define wm8753_reset(c) snd_soc_component_write(c, WM8753_RESET, 0) /* * WM8753 Controls @@ -229,8 +229,8 @@ SOC_ENUM_SINGLE(WM8753_OUTCTL, 2, 2, wm8753_rout2_phase), static int wm8753_get_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8753->dai_func; return 0; @@ -239,17 +239,17 @@ static int wm8753_get_dai(struct snd_kcontrol *kcontrol, static int wm8753_set_dai(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); u16 ioctl; if (wm8753->dai_func == ucontrol->value.enumerated.item[0]) return 0; - if (snd_soc_codec_is_active(codec)) + if (snd_soc_component_is_active(component)) return -EBUSY; - ioctl = snd_soc_read(codec, WM8753_IOCTL); + ioctl = snd_soc_component_read32(component, WM8753_IOCTL); wm8753->dai_func = ucontrol->value.enumerated.item[0]; @@ -257,11 +257,11 @@ static int wm8753_set_dai(struct snd_kcontrol *kcontrol, return 1; ioctl = (ioctl & 0x1f3) | (wm8753->dai_func << 2); - snd_soc_write(codec, WM8753_IOCTL, ioctl); + snd_soc_component_write(component, WM8753_IOCTL, ioctl); - wm8753_hifi_write_dai_fmt(codec, wm8753->hifi_fmt); - wm8753_voice_write_dai_fmt(codec, wm8753->voice_fmt); + wm8753_hifi_write_dai_fmt(component, wm8753->hifi_fmt); + wm8753_voice_write_dai_fmt(component, wm8753->voice_fmt); return 1; } @@ -745,7 +745,7 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, { u16 reg, enable; int offset; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; if (pll_id < WM8753_PLL1 || pll_id > WM8753_PLL2) return -ENODEV; @@ -753,17 +753,17 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, if (pll_id == WM8753_PLL1) { offset = 0; enable = 0x10; - reg = snd_soc_read(codec, WM8753_CLOCK) & 0xffef; + reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xffef; } else { offset = 4; enable = 0x8; - reg = snd_soc_read(codec, WM8753_CLOCK) & 0xfff7; + reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfff7; } if (!freq_in || !freq_out) { /* disable PLL */ - snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0026); - snd_soc_write(codec, WM8753_CLOCK, reg); + snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0026); + snd_soc_component_write(component, WM8753_CLOCK, reg); return 0; } else { u16 value = 0; @@ -774,20 +774,20 @@ static int wm8753_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* set up N and K PLL divisor ratios */ /* bits 8:5 = PLL_N, bits 3:0 = PLL_K[21:18] */ value = (pll_div.n << 5) + ((pll_div.k & 0x3c0000) >> 18); - snd_soc_write(codec, WM8753_PLL1CTL2 + offset, value); + snd_soc_component_write(component, WM8753_PLL1CTL2 + offset, value); /* bits 8:0 = PLL_K[17:9] */ value = (pll_div.k & 0x03fe00) >> 9; - snd_soc_write(codec, WM8753_PLL1CTL3 + offset, value); + snd_soc_component_write(component, WM8753_PLL1CTL3 + offset, value); /* bits 8:0 = PLL_K[8:0] */ value = pll_div.k & 0x0001ff; - snd_soc_write(codec, WM8753_PLL1CTL4 + offset, value); + snd_soc_component_write(component, WM8753_PLL1CTL4 + offset, value); /* set PLL as input and enable */ - snd_soc_write(codec, WM8753_PLL1CTL1 + offset, 0x0027 | + snd_soc_component_write(component, WM8753_PLL1CTL1 + offset, 0x0027 | (pll_div.div2 << 3)); - snd_soc_write(codec, WM8753_CLOCK, reg | enable); + snd_soc_component_write(component, WM8753_CLOCK, reg | enable); } return 0; } @@ -866,8 +866,8 @@ static int get_coeff(int mclk, int rate) static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); switch (freq) { case 11289600: @@ -890,10 +890,10 @@ static int wm8753_set_dai_sysclk(struct snd_soc_dai *codec_dai, /* * Set's ADC and Voice DAC format. */ -static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01ec; + u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01ec; /* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -915,7 +915,7 @@ static int wm8753_vdac_adc_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; } - snd_soc_write(codec, WM8753_PCM, voice); + snd_soc_component_write(component, WM8753_PCM, voice); return 0; } @@ -926,10 +926,10 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); - u16 voice = snd_soc_read(codec, WM8753_PCM) & 0x01f3; - u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x017f; + struct snd_soc_component *component = dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + u16 voice = snd_soc_component_read32(component, WM8753_PCM) & 0x01f3; + u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x017f; /* bit size */ switch (params_width(params)) { @@ -949,22 +949,22 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream, /* sample rate */ if (params_rate(params) * 384 == wm8753->pcmclk) srate |= 0x80; - snd_soc_write(codec, WM8753_SRATE1, srate); + snd_soc_component_write(component, WM8753_SRATE1, srate); - snd_soc_write(codec, WM8753_PCM, voice); + snd_soc_component_write(component, WM8753_PCM, voice); return 0; } /* * Set's PCM dai fmt and BCLK. */ -static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_pcm_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 voice, ioctl; - voice = snd_soc_read(codec, WM8753_PCM) & 0x011f; - ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x015d; + voice = snd_soc_component_read32(component, WM8753_PCM) & 0x011f; + ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x015d; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1018,29 +1018,29 @@ static int wm8753_pcm_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; } - snd_soc_write(codec, WM8753_PCM, voice); - snd_soc_write(codec, WM8753_IOCTL, ioctl); + snd_soc_component_write(component, WM8753_PCM, voice); + snd_soc_component_write(component, WM8753_IOCTL, ioctl); return 0; } static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; switch (div_id) { case WM8753_PCMDIV: - reg = snd_soc_read(codec, WM8753_CLOCK) & 0x003f; - snd_soc_write(codec, WM8753_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8753_CLOCK) & 0x003f; + snd_soc_component_write(component, WM8753_CLOCK, reg | div); break; case WM8753_BCLKDIV: - reg = snd_soc_read(codec, WM8753_SRATE2) & 0x01c7; - snd_soc_write(codec, WM8753_SRATE2, reg | div); + reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x01c7; + snd_soc_component_write(component, WM8753_SRATE2, reg | div); break; case WM8753_VXCLKDIV: - reg = snd_soc_read(codec, WM8753_SRATE2) & 0x003f; - snd_soc_write(codec, WM8753_SRATE2, reg | div); + reg = snd_soc_component_read32(component, WM8753_SRATE2) & 0x003f; + snd_soc_component_write(component, WM8753_SRATE2, reg | div); break; default: return -EINVAL; @@ -1051,10 +1051,10 @@ static int wm8753_set_dai_clkdiv(struct snd_soc_dai *codec_dai, /* * Set's HiFi DAC format. */ -static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_hdac_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01e0; + u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01e0; /* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -1076,20 +1076,20 @@ static int wm8753_hdac_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; } - snd_soc_write(codec, WM8753_HIFI, hifi); + snd_soc_component_write(component, WM8753_HIFI, hifi); return 0; } /* * Set's I2S DAI format. */ -static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_i2s_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 ioctl, hifi; - hifi = snd_soc_read(codec, WM8753_HIFI) & 0x013f; - ioctl = snd_soc_read(codec, WM8753_IOCTL) & 0x00ae; + hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x013f; + ioctl = snd_soc_component_read32(component, WM8753_IOCTL) & 0x00ae; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1143,8 +1143,8 @@ static int wm8753_i2s_set_dai_fmt(struct snd_soc_codec *codec, return -EINVAL; } - snd_soc_write(codec, WM8753_HIFI, hifi); - snd_soc_write(codec, WM8753_IOCTL, ioctl); + snd_soc_component_write(component, WM8753_HIFI, hifi); + snd_soc_component_write(component, WM8753_IOCTL, ioctl); return 0; } @@ -1155,10 +1155,10 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); - u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x01c0; - u16 hifi = snd_soc_read(codec, WM8753_HIFI) & 0x01f3; + struct snd_soc_component *component = dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + u16 srate = snd_soc_component_read32(component, WM8753_SRATE1) & 0x01c0; + u16 hifi = snd_soc_component_read32(component, WM8753_HIFI) & 0x01f3; int coeff; /* is digital filter coefficient valid ? */ @@ -1167,7 +1167,7 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, printk(KERN_ERR "wm8753 invalid MCLK or rate\n"); return coeff; } - snd_soc_write(codec, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) | + snd_soc_component_write(component, WM8753_SRATE1, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); /* bit size */ @@ -1185,70 +1185,70 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8753_HIFI, hifi); + snd_soc_component_write(component, WM8753_HIFI, hifi); return 0; } -static int wm8753_mode1v_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode1v_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 clock; /* set clk source as pcmclk */ - clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; - snd_soc_write(codec, WM8753_CLOCK, clock); + clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; + snd_soc_component_write(component, WM8753_CLOCK, clock); - return wm8753_vdac_adc_set_dai_fmt(codec, fmt); + return wm8753_vdac_adc_set_dai_fmt(component, fmt); } -static int wm8753_mode1h_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode1h_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - return wm8753_hdac_set_dai_fmt(codec, fmt); + return wm8753_hdac_set_dai_fmt(component, fmt); } -static int wm8753_mode2_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode2_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 clock; /* set clk source as pcmclk */ - clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; - snd_soc_write(codec, WM8753_CLOCK, clock); + clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; + snd_soc_component_write(component, WM8753_CLOCK, clock); - return wm8753_vdac_adc_set_dai_fmt(codec, fmt); + return wm8753_vdac_adc_set_dai_fmt(component, fmt); } -static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_mode3_4_set_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { u16 clock; /* set clk source as mclk */ - clock = snd_soc_read(codec, WM8753_CLOCK) & 0xfffb; - snd_soc_write(codec, WM8753_CLOCK, clock | 0x4); + clock = snd_soc_component_read32(component, WM8753_CLOCK) & 0xfffb; + snd_soc_component_write(component, WM8753_CLOCK, clock | 0x4); - if (wm8753_hdac_set_dai_fmt(codec, fmt) < 0) + if (wm8753_hdac_set_dai_fmt(component, fmt) < 0) return -EINVAL; - return wm8753_vdac_adc_set_dai_fmt(codec, fmt); + return wm8753_vdac_adc_set_dai_fmt(component, fmt); } -static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_hifi_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); int ret = 0; switch (wm8753->dai_func) { case 0: - ret = wm8753_mode1h_set_dai_fmt(codec, fmt); + ret = wm8753_mode1h_set_dai_fmt(component, fmt); break; case 1: - ret = wm8753_mode2_set_dai_fmt(codec, fmt); + ret = wm8753_mode2_set_dai_fmt(component, fmt); break; case 2: case 3: - ret = wm8753_mode3_4_set_dai_fmt(codec, fmt); + ret = wm8753_mode3_4_set_dai_fmt(component, fmt); break; default: break; @@ -1256,33 +1256,33 @@ static int wm8753_hifi_write_dai_fmt(struct snd_soc_codec *codec, if (ret) return ret; - return wm8753_i2s_set_dai_fmt(codec, fmt); + return wm8753_i2s_set_dai_fmt(component, fmt); } static int wm8753_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); wm8753->hifi_fmt = fmt; - return wm8753_hifi_write_dai_fmt(codec, fmt); + return wm8753_hifi_write_dai_fmt(component, fmt); }; -static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, +static int wm8753_voice_write_dai_fmt(struct snd_soc_component *component, unsigned int fmt) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); int ret = 0; if (wm8753->dai_func != 0) return 0; - ret = wm8753_mode1v_set_dai_fmt(codec, fmt); + ret = wm8753_mode1v_set_dai_fmt(component, fmt); if (ret) return ret; - ret = wm8753_pcm_set_dai_fmt(codec, fmt); + ret = wm8753_pcm_set_dai_fmt(component, fmt); if (ret) return ret; @@ -1292,30 +1292,30 @@ static int wm8753_voice_write_dai_fmt(struct snd_soc_codec *codec, static int wm8753_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); wm8753->voice_fmt = fmt; - return wm8753_voice_write_dai_fmt(codec, fmt); + return wm8753_voice_write_dai_fmt(component, fmt); }; static int wm8753_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8753_DAC) & 0xfff7; - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8753_DAC) & 0xfff7; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); /* the digital mute covers the HiFi and Voice DAC's on the WM8753. * make sure we check if they are not both active when we mute */ if (mute && wm8753->dai_func == 1) { - if (!snd_soc_codec_is_active(codec)) - snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8); + if (!snd_soc_component_is_active(component)) + snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8); } else { if (mute) - snd_soc_write(codec, WM8753_DAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8753_DAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8753_DAC, mute_reg); + snd_soc_component_write(component, WM8753_DAC, mute_reg); } return 0; @@ -1330,35 +1330,35 @@ static void wm8753_charge_work(struct work_struct *work) regmap_update_bits(wm8753->regmap, WM8753_PWR1, 0x0180, 0x0100); } -static int wm8753_set_bias_level(struct snd_soc_codec *codec, +static int wm8753_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); - u16 pwr_reg = snd_soc_read(codec, WM8753_PWR1) & 0xfe3e; + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); + u16 pwr_reg = snd_soc_component_read32(component, WM8753_PWR1) & 0xfe3e; switch (level) { case SND_SOC_BIAS_ON: /* set vmid to 50k and unmute dac */ - snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x00c0); + snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x00c0); break; case SND_SOC_BIAS_PREPARE: /* Wait until fully charged */ flush_delayed_work(&wm8753->charge_work); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* set vmid to 5k for quick power up */ - snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x01c1); + snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x01c1); schedule_delayed_work(&wm8753->charge_work, msecs_to_jiffies(caps_charge)); } else { /* mute dac and set vmid to 500k, enable VREF */ - snd_soc_write(codec, WM8753_PWR1, pwr_reg | 0x0141); + snd_soc_component_write(component, WM8753_PWR1, pwr_reg | 0x0141); } break; case SND_SOC_BIAS_OFF: cancel_delayed_work_sync(&wm8753->charge_work); - snd_soc_write(codec, WM8753_PWR1, 0x0001); + snd_soc_component_write(component, WM8753_PWR1, 0x0001); break; } return 0; @@ -1440,59 +1440,60 @@ static struct snd_soc_dai_driver wm8753_dai[] = { }, }; -static int wm8753_resume(struct snd_soc_codec *codec) +static int wm8753_resume(struct snd_soc_component *component) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); regcache_sync(wm8753->regmap); return 0; } -static int wm8753_probe(struct snd_soc_codec *codec) +static int wm8753_probe(struct snd_soc_component *component) { - struct wm8753_priv *wm8753 = snd_soc_codec_get_drvdata(codec); + struct wm8753_priv *wm8753 = snd_soc_component_get_drvdata(component); int ret; INIT_DELAYED_WORK(&wm8753->charge_work, wm8753_charge_work); - ret = wm8753_reset(codec); + ret = wm8753_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; } wm8753->dai_func = 0; /* set the update bits */ - snd_soc_update_bits(codec, WM8753_LDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LADC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_RADC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LOUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_LINVOL, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8753_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LADC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_RADC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LOUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_LINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8753_RINVOL, 0x0100, 0x0100); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8753 = { - .probe = wm8753_probe, - .resume = wm8753_resume, - .set_bias_level = wm8753_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8753_snd_controls, - .num_controls = ARRAY_SIZE(wm8753_snd_controls), - .dapm_widgets = wm8753_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8753_dapm_widgets), - .dapm_routes = wm8753_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8753_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8753 = { + .probe = wm8753_probe, + .resume = wm8753_resume, + .set_bias_level = wm8753_set_bias_level, + .controls = wm8753_snd_controls, + .num_controls = ARRAY_SIZE(wm8753_snd_controls), + .dapm_widgets = wm8753_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8753_dapm_widgets), + .dapm_routes = wm8753_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8753_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id wm8753_of_match[] = { @@ -1534,7 +1535,7 @@ static int wm8753_spi_probe(struct spi_device *spi) return ret; } - ret = snd_soc_register_codec(&spi->dev, &soc_codec_dev_wm8753, + ret = devm_snd_soc_register_component(&spi->dev, &soc_component_dev_wm8753, wm8753_dai, ARRAY_SIZE(wm8753_dai)); if (ret != 0) dev_err(&spi->dev, "Failed to register CODEC: %d\n", ret); @@ -1542,19 +1543,12 @@ static int wm8753_spi_probe(struct spi_device *spi) return ret; } -static int wm8753_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8753_spi_driver = { .driver = { .name = "wm8753", .of_match_table = wm8753_of_match, }, .probe = wm8753_spi_probe, - .remove = wm8753_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -1580,7 +1574,7 @@ static int wm8753_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm8753, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm8753, wm8753_dai, ARRAY_SIZE(wm8753_dai)); if (ret != 0) dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -1588,12 +1582,6 @@ static int wm8753_i2c_probe(struct i2c_client *i2c, return ret; } -static int wm8753_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8753_i2c_id[] = { { "wm8753", 0 }, { } @@ -1606,7 +1594,6 @@ static struct i2c_driver wm8753_i2c_driver = { .of_match_table = wm8753_of_match, }, .probe = wm8753_i2c_probe, - .remove = wm8753_i2c_remove, .id_table = wm8753_i2c_id, }; #endif From 825a52aa768352920b631208cd03250869609936 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:04:55 +0000 Subject: [PATCH 036/942] ASoC: wm8900: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8900.c | 251 +++++++++++++++++++------------------- 1 file changed, 125 insertions(+), 126 deletions(-) diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index c77b49a29311..1a14e902949d 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c @@ -216,23 +216,23 @@ static bool wm8900_volatile_register(struct device *dev, unsigned int reg) } } -static void wm8900_reset(struct snd_soc_codec *codec) +static void wm8900_reset(struct snd_soc_component *component) { - snd_soc_write(codec, WM8900_REG_RESET, 0); + snd_soc_component_write(component, WM8900_REG_RESET, 0); } static int wm8900_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 hpctl1 = snd_soc_read(codec, WM8900_REG_HPCTL1); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 hpctl1 = snd_soc_component_read32(component, WM8900_REG_HPCTL1); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Clamp headphone outputs */ hpctl1 = WM8900_REG_HPCTL1_HP_CLAMP_IP | WM8900_REG_HPCTL1_HP_CLAMP_OP; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); break; case SND_SOC_DAPM_POST_PMU: @@ -241,41 +241,41 @@ static int wm8900_hp_event(struct snd_soc_dapm_widget *w, hpctl1 |= WM8900_REG_HPCTL1_HP_SHORT | WM8900_REG_HPCTL1_HP_SHORT2 | WM8900_REG_HPCTL1_HP_IPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); msleep(400); /* Enable the output stage */ hpctl1 &= ~WM8900_REG_HPCTL1_HP_CLAMP_OP; hpctl1 |= WM8900_REG_HPCTL1_HP_OPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); /* Remove the shorts */ hpctl1 &= ~WM8900_REG_HPCTL1_HP_SHORT2; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); hpctl1 &= ~WM8900_REG_HPCTL1_HP_SHORT; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); break; case SND_SOC_DAPM_PRE_PMD: /* Short the output */ hpctl1 |= WM8900_REG_HPCTL1_HP_SHORT; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); /* Disable the output stage */ hpctl1 &= ~WM8900_REG_HPCTL1_HP_OPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); /* Clamp the outputs and power down input */ hpctl1 |= WM8900_REG_HPCTL1_HP_CLAMP_IP | WM8900_REG_HPCTL1_HP_CLAMP_OP; hpctl1 &= ~WM8900_REG_HPCTL1_HP_IPSTAGE_ENA; - snd_soc_write(codec, WM8900_REG_HPCTL1, hpctl1); + snd_soc_component_write(component, WM8900_REG_HPCTL1, hpctl1); break; case SND_SOC_DAPM_POST_PMD: /* Disable everything */ - snd_soc_write(codec, WM8900_REG_HPCTL1, 0); + snd_soc_component_write(component, WM8900_REG_HPCTL1, 0); break; default: @@ -635,10 +635,10 @@ static int wm8900_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 reg; - reg = snd_soc_read(codec, WM8900_REG_AUDIO1) & ~0x60; + reg = snd_soc_component_read32(component, WM8900_REG_AUDIO1) & ~0x60; switch (params_width(params)) { case 16: @@ -656,17 +656,17 @@ static int wm8900_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, WM8900_REG_AUDIO1, reg); + snd_soc_component_write(component, WM8900_REG_AUDIO1, reg); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - reg = snd_soc_read(codec, WM8900_REG_DACCTRL); + reg = snd_soc_component_read32(component, WM8900_REG_DACCTRL); if (params_rate(params) <= 24000) reg |= WM8900_REG_DACCTRL_DAC_SB_FILT; else reg &= ~WM8900_REG_DACCTRL_DAC_SB_FILT; - snd_soc_write(codec, WM8900_REG_DACCTRL, reg); + snd_soc_component_write(component, WM8900_REG_DACCTRL, reg); } return 0; @@ -751,24 +751,24 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int wm8900_set_fll(struct snd_soc_codec *codec, +static int wm8900_set_fll(struct snd_soc_component *component, int fll_id, unsigned int freq_in, unsigned int freq_out) { - struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); + struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); struct _fll_div fll_div; if (wm8900->fll_in == freq_in && wm8900->fll_out == freq_out) return 0; /* The digital side should be disabled during any change. */ - snd_soc_update_bits(codec, WM8900_REG_POWER1, + snd_soc_component_update_bits(component, WM8900_REG_POWER1, WM8900_REG_POWER1_FLL_ENA, 0); /* Disable the FLL? */ if (!freq_in || !freq_out) { - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_MCLK_SRC, 0); - snd_soc_update_bits(codec, WM8900_REG_FLLCTL1, + snd_soc_component_update_bits(component, WM8900_REG_FLLCTL1, WM8900_REG_FLLCTL1_OSC_ENA, 0); wm8900->fll_in = freq_in; wm8900->fll_out = freq_out; @@ -784,32 +784,32 @@ static int wm8900_set_fll(struct snd_soc_codec *codec, /* The osclilator *MUST* be enabled before we enable the * digital circuit. */ - snd_soc_write(codec, WM8900_REG_FLLCTL1, + snd_soc_component_write(component, WM8900_REG_FLLCTL1, fll_div.fll_ratio | WM8900_REG_FLLCTL1_OSC_ENA); - snd_soc_write(codec, WM8900_REG_FLLCTL4, fll_div.n >> 5); - snd_soc_write(codec, WM8900_REG_FLLCTL5, + snd_soc_component_write(component, WM8900_REG_FLLCTL4, fll_div.n >> 5); + snd_soc_component_write(component, WM8900_REG_FLLCTL5, (fll_div.fllclk_div << 6) | (fll_div.n & 0x1f)); if (fll_div.k) { - snd_soc_write(codec, WM8900_REG_FLLCTL2, + snd_soc_component_write(component, WM8900_REG_FLLCTL2, (fll_div.k >> 8) | 0x100); - snd_soc_write(codec, WM8900_REG_FLLCTL3, fll_div.k & 0xff); + snd_soc_component_write(component, WM8900_REG_FLLCTL3, fll_div.k & 0xff); } else - snd_soc_write(codec, WM8900_REG_FLLCTL2, 0); + snd_soc_component_write(component, WM8900_REG_FLLCTL2, 0); if (fll_div.fll_slow_lock_ref) - snd_soc_write(codec, WM8900_REG_FLLCTL6, + snd_soc_component_write(component, WM8900_REG_FLLCTL6, WM8900_REG_FLLCTL6_FLL_SLOW_LOCK_REF); else - snd_soc_write(codec, WM8900_REG_FLLCTL6, 0); + snd_soc_component_write(component, WM8900_REG_FLLCTL6, 0); - snd_soc_update_bits(codec, WM8900_REG_POWER1, + snd_soc_component_update_bits(component, WM8900_REG_POWER1, WM8900_REG_POWER1_FLL_ENA, WM8900_REG_POWER1_FLL_ENA); reenable: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_MCLK_SRC, WM8900_REG_CLOCKING1_MCLK_SRC); return 0; @@ -818,41 +818,41 @@ reenable: static int wm8900_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - return wm8900_set_fll(codec_dai->codec, pll_id, freq_in, freq_out); + return wm8900_set_fll(codec_dai->component, pll_id, freq_in, freq_out); } static int wm8900_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; switch (div_id) { case WM8900_BCLK_DIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_BCLK_MASK, div); break; case WM8900_OPCLK_DIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING1, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING1, WM8900_REG_CLOCKING1_OPCLK_MASK, div); break; case WM8900_DAC_LRCLK: - snd_soc_update_bits(codec, WM8900_REG_AUDIO4, + snd_soc_component_update_bits(component, WM8900_REG_AUDIO4, WM8900_LRC_MASK, div); break; case WM8900_ADC_LRCLK: - snd_soc_update_bits(codec, WM8900_REG_AUDIO3, + snd_soc_component_update_bits(component, WM8900_REG_AUDIO3, WM8900_LRC_MASK, div); break; case WM8900_DAC_CLKDIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING2, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING2, WM8900_REG_CLOCKING2_DAC_CLKDIV, div); break; case WM8900_ADC_CLKDIV: - snd_soc_update_bits(codec, WM8900_REG_CLOCKING2, + snd_soc_component_update_bits(component, WM8900_REG_CLOCKING2, WM8900_REG_CLOCKING2_ADC_CLKDIV, div); break; case WM8900_LRCLK_MODE: - snd_soc_update_bits(codec, WM8900_REG_DACCTRL, + snd_soc_component_update_bits(component, WM8900_REG_DACCTRL, WM8900_REG_DACCTRL_AIF_LRCLKRATE, div); break; default: @@ -866,13 +866,13 @@ static int wm8900_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8900_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int clocking1, aif1, aif3, aif4; - clocking1 = snd_soc_read(codec, WM8900_REG_CLOCKING1); - aif1 = snd_soc_read(codec, WM8900_REG_AUDIO1); - aif3 = snd_soc_read(codec, WM8900_REG_AUDIO3); - aif4 = snd_soc_read(codec, WM8900_REG_AUDIO4); + clocking1 = snd_soc_component_read32(component, WM8900_REG_CLOCKING1); + aif1 = snd_soc_component_read32(component, WM8900_REG_AUDIO1); + aif3 = snd_soc_component_read32(component, WM8900_REG_AUDIO3); + aif4 = snd_soc_component_read32(component, WM8900_REG_AUDIO4); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -968,27 +968,27 @@ static int wm8900_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8900_REG_CLOCKING1, clocking1); - snd_soc_write(codec, WM8900_REG_AUDIO1, aif1); - snd_soc_write(codec, WM8900_REG_AUDIO3, aif3); - snd_soc_write(codec, WM8900_REG_AUDIO4, aif4); + snd_soc_component_write(component, WM8900_REG_CLOCKING1, clocking1); + snd_soc_component_write(component, WM8900_REG_AUDIO1, aif1); + snd_soc_component_write(component, WM8900_REG_AUDIO3, aif3); + snd_soc_component_write(component, WM8900_REG_AUDIO4, aif4); return 0; } static int wm8900_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; - reg = snd_soc_read(codec, WM8900_REG_DACCTRL); + reg = snd_soc_component_read32(component, WM8900_REG_DACCTRL); if (mute) reg |= WM8900_REG_DACCTRL_MUTE; else reg &= ~WM8900_REG_DACCTRL_MUTE; - snd_soc_write(codec, WM8900_REG_DACCTRL, reg); + snd_soc_component_write(component, WM8900_REG_DACCTRL, reg); return 0; } @@ -1028,7 +1028,7 @@ static struct snd_soc_dai_driver wm8900_dai = { .ops = &wm8900_dai_ops, }; -static int wm8900_set_bias_level(struct snd_soc_codec *codec, +static int wm8900_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { u16 reg; @@ -1036,10 +1036,10 @@ static int wm8900_set_bias_level(struct snd_soc_codec *codec, switch (level) { case SND_SOC_BIAS_ON: /* Enable thermal shutdown */ - snd_soc_update_bits(codec, WM8900_REG_GPIO, + snd_soc_component_update_bits(component, WM8900_REG_GPIO, WM8900_REG_GPIO_TEMP_ENA, WM8900_REG_GPIO_TEMP_ENA); - snd_soc_update_bits(codec, WM8900_REG_ADDCTL, + snd_soc_component_update_bits(component, WM8900_REG_ADDCTL, WM8900_REG_ADDCTL_TEMP_SD, WM8900_REG_ADDCTL_TEMP_SD); break; @@ -1049,113 +1049,113 @@ static int wm8900_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_STANDBY: /* Charge capacitors if initial power up */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* STARTUP_BIAS_ENA on */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA); /* Startup bias mode */ - snd_soc_write(codec, WM8900_REG_ADDCTL, + snd_soc_component_write(component, WM8900_REG_ADDCTL, WM8900_REG_ADDCTL_BIAS_SRC | WM8900_REG_ADDCTL_VMID_SOFTST); /* VMID 2x50k */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA | 0x1); /* Allow capacitors to charge */ schedule_timeout_interruptible(msecs_to_jiffies(400)); /* Enable bias */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA | WM8900_REG_POWER1_BIAS_ENA | 0x1); - snd_soc_write(codec, WM8900_REG_ADDCTL, 0); + snd_soc_component_write(component, WM8900_REG_ADDCTL, 0); - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_BIAS_ENA | 0x1); } - reg = snd_soc_read(codec, WM8900_REG_POWER1); - snd_soc_write(codec, WM8900_REG_POWER1, + reg = snd_soc_component_read32(component, WM8900_REG_POWER1); + snd_soc_component_write(component, WM8900_REG_POWER1, (reg & WM8900_REG_POWER1_FLL_ENA) | WM8900_REG_POWER1_BIAS_ENA | 0x1); - snd_soc_write(codec, WM8900_REG_POWER2, + snd_soc_component_write(component, WM8900_REG_POWER2, WM8900_REG_POWER2_SYSCLK_ENA); - snd_soc_write(codec, WM8900_REG_POWER3, 0); + snd_soc_component_write(component, WM8900_REG_POWER3, 0); break; case SND_SOC_BIAS_OFF: /* Startup bias enable */ - reg = snd_soc_read(codec, WM8900_REG_POWER1); - snd_soc_write(codec, WM8900_REG_POWER1, + reg = snd_soc_component_read32(component, WM8900_REG_POWER1); + snd_soc_component_write(component, WM8900_REG_POWER1, reg & WM8900_REG_POWER1_STARTUP_BIAS_ENA); - snd_soc_write(codec, WM8900_REG_ADDCTL, + snd_soc_component_write(component, WM8900_REG_ADDCTL, WM8900_REG_ADDCTL_BIAS_SRC | WM8900_REG_ADDCTL_VMID_SOFTST); /* Discharge caps */ - snd_soc_write(codec, WM8900_REG_POWER1, + snd_soc_component_write(component, WM8900_REG_POWER1, WM8900_REG_POWER1_STARTUP_BIAS_ENA); schedule_timeout_interruptible(msecs_to_jiffies(500)); /* Remove clamp */ - snd_soc_write(codec, WM8900_REG_HPCTL1, 0); + snd_soc_component_write(component, WM8900_REG_HPCTL1, 0); /* Power down */ - snd_soc_write(codec, WM8900_REG_ADDCTL, 0); - snd_soc_write(codec, WM8900_REG_POWER1, 0); - snd_soc_write(codec, WM8900_REG_POWER2, 0); - snd_soc_write(codec, WM8900_REG_POWER3, 0); + snd_soc_component_write(component, WM8900_REG_ADDCTL, 0); + snd_soc_component_write(component, WM8900_REG_POWER1, 0); + snd_soc_component_write(component, WM8900_REG_POWER2, 0); + snd_soc_component_write(component, WM8900_REG_POWER3, 0); /* Need to let things settle before stopping the clock * to ensure that restart works, see "Stopping the * master clock" in the datasheet. */ schedule_timeout_interruptible(msecs_to_jiffies(1)); - snd_soc_write(codec, WM8900_REG_POWER2, + snd_soc_component_write(component, WM8900_REG_POWER2, WM8900_REG_POWER2_SYSCLK_ENA); break; } return 0; } -static int wm8900_suspend(struct snd_soc_codec *codec) +static int wm8900_suspend(struct snd_soc_component *component) { - struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); + struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); int fll_out = wm8900->fll_out; int fll_in = wm8900->fll_in; int ret; /* Stop the FLL in an orderly fashion */ - ret = wm8900_set_fll(codec, 0, 0, 0); + ret = wm8900_set_fll(component, 0, 0, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to stop FLL\n"); + dev_err(component->dev, "Failed to stop FLL\n"); return ret; } wm8900->fll_out = fll_out; wm8900->fll_in = fll_in; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); return 0; } -static int wm8900_resume(struct snd_soc_codec *codec) +static int wm8900_resume(struct snd_soc_component *component) { - struct wm8900_priv *wm8900 = snd_soc_codec_get_drvdata(codec); + struct wm8900_priv *wm8900 = snd_soc_component_get_drvdata(component); int ret; - wm8900_reset(codec); + wm8900_reset(component); ret = regcache_sync(wm8900->regmap); if (ret != 0) { - dev_err(codec->dev, "Failed to restore cache: %d\n", ret); + dev_err(component->dev, "Failed to restore cache: %d\n", ret); return ret; } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Restart the FLL? */ if (wm8900->fll_out) { @@ -1165,9 +1165,9 @@ static int wm8900_resume(struct snd_soc_codec *codec) wm8900->fll_in = 0; wm8900->fll_out = 0; - ret = wm8900_set_fll(codec, 0, fll_in, fll_out); + ret = wm8900_set_fll(component, 0, fll_in, fll_out); if (ret != 0) { - dev_err(codec->dev, "Failed to restart FLL\n"); + dev_err(component->dev, "Failed to restart FLL\n"); return ret; } } @@ -1175,53 +1175,54 @@ static int wm8900_resume(struct snd_soc_codec *codec) return 0; } -static int wm8900_probe(struct snd_soc_codec *codec) +static int wm8900_probe(struct snd_soc_component *component) { int reg; - reg = snd_soc_read(codec, WM8900_REG_ID); + reg = snd_soc_component_read32(component, WM8900_REG_ID); if (reg != 0x8900) { - dev_err(codec->dev, "Device is not a WM8900 - ID %x\n", reg); + dev_err(component->dev, "Device is not a WM8900 - ID %x\n", reg); return -ENODEV; } - wm8900_reset(codec); + wm8900_reset(component); /* Turn the chip on */ - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Latch the volume update bits */ - snd_soc_update_bits(codec, WM8900_REG_LINVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_RINVOL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LOUT1CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_ROUT1CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LOUT2CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_ROUT2CTL, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LDAC_DV, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_RDAC_DV, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_LADC_DV, 0x100, 0x100); - snd_soc_update_bits(codec, WM8900_REG_RADC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LINVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_RINVOL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LOUT1CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_ROUT1CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LOUT2CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_ROUT2CTL, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LDAC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_RDAC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_LADC_DV, 0x100, 0x100); + snd_soc_component_update_bits(component, WM8900_REG_RADC_DV, 0x100, 0x100); /* Set the DAC and mixer output bias */ - snd_soc_write(codec, WM8900_REG_OUTBIASCTL, 0x81); + snd_soc_component_write(component, WM8900_REG_OUTBIASCTL, 0x81); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8900 = { - .probe = wm8900_probe, - .suspend = wm8900_suspend, - .resume = wm8900_resume, - .set_bias_level = wm8900_set_bias_level, - - .component_driver = { - .controls = wm8900_snd_controls, - .num_controls = ARRAY_SIZE(wm8900_snd_controls), - .dapm_widgets = wm8900_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8900_dapm_widgets), - .dapm_routes = wm8900_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8900_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8900 = { + .probe = wm8900_probe, + .suspend = wm8900_suspend, + .resume = wm8900_resume, + .set_bias_level = wm8900_set_bias_level, + .controls = wm8900_snd_controls, + .num_controls = ARRAY_SIZE(wm8900_snd_controls), + .dapm_widgets = wm8900_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8900_dapm_widgets), + .dapm_routes = wm8900_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8900_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8900_regmap = { @@ -1253,15 +1254,14 @@ static int wm8900_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8900); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8900, &wm8900_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8900, &wm8900_dai, 1); return ret; } static int wm8900_spi_remove(struct spi_device *spi) { - snd_soc_unregister_codec(&spi->dev); return 0; } @@ -1292,15 +1292,14 @@ static int wm8900_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8900); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8900, &wm8900_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8900, &wm8900_dai, 1); return ret; } static int wm8900_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From 58bd2934923b7339e7320b1cbe87f13287c57c31 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:05:11 +0000 Subject: [PATCH 037/942] ASoC: wm8903: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8903.c | 211 ++++++++++++++++----------------- sound/soc/codecs/wm8903.h | 2 +- sound/soc/tegra/tegra_wm8903.c | 8 +- 3 files changed, 110 insertions(+), 111 deletions(-) diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index cba90f21161f..7b8b6ef2f632 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c @@ -270,15 +270,15 @@ static int wm8903_cp_event(struct snd_soc_dapm_widget *w, static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: wm8903->dcs_pending |= 1 << w->shift; break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8903_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8903_DC_SERVO_0, 1 << w->shift, 0); break; } @@ -289,17 +289,16 @@ static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, #define WM8903_DCS_MODE_WRITE_STOP 0 #define WM8903_DCS_MODE_START_STOP 2 -static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, +static void wm8903_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int dcs_mode = WM8903_DCS_MODE_WRITE_STOP; int i, val; /* Complete any pending DC servo starts */ if (wm8903->dcs_pending) { - dev_dbg(codec->dev, "Starting DC servo for %x\n", + dev_dbg(component->dev, "Starting DC servo for %x\n", wm8903->dcs_pending); /* If we've no cached values then we need to do startup */ @@ -308,14 +307,14 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, continue; if (wm8903->dcs_cache[i]) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Restore DC servo %d value %x\n", 3 - i, wm8903->dcs_cache[i]); - snd_soc_write(codec, WM8903_DC_SERVO_4 + i, + snd_soc_component_write(component, WM8903_DC_SERVO_4 + i, wm8903->dcs_cache[i] & 0xff); } else { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Calibrate DC servo %d\n", 3 - i); dcs_mode = WM8903_DCS_MODE_START_STOP; } @@ -325,10 +324,10 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, if (wm8903->class_w_users) dcs_mode = WM8903_DCS_MODE_START_STOP; - snd_soc_update_bits(codec, WM8903_DC_SERVO_2, + snd_soc_component_update_bits(component, WM8903_DC_SERVO_2, WM8903_DCS_MODE_MASK, dcs_mode); - snd_soc_update_bits(codec, WM8903_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8903_DC_SERVO_0, WM8903_DCS_ENA_MASK, wm8903->dcs_pending); switch (dcs_mode) { @@ -346,9 +345,9 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, if (!(wm8903->dcs_pending & (1 << i))) continue; - val = snd_soc_read(codec, + val = snd_soc_component_read32(component, WM8903_DC_SERVO_READBACK_1 + i); - dev_dbg(codec->dev, "DC servo %d: %x\n", + dev_dbg(component->dev, "DC servo %d: %x\n", 3 - i, val); wm8903->dcs_cache[i] = val; } @@ -374,18 +373,18 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); u16 reg; int ret; - reg = snd_soc_read(codec, WM8903_CLASS_W_0); + reg = snd_soc_component_read32(component, WM8903_CLASS_W_0); /* Turn it off if we're about to enable bypass */ if (ucontrol->value.integer.value[0]) { if (wm8903->class_w_users == 0) { - dev_dbg(codec->dev, "Disabling Class W\n"); - snd_soc_write(codec, WM8903_CLASS_W_0, reg & + dev_dbg(component->dev, "Disabling Class W\n"); + snd_soc_component_write(component, WM8903_CLASS_W_0, reg & ~(WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V)); } wm8903->class_w_users++; @@ -397,14 +396,14 @@ static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, /* If we've just disabled the last bypass path turn Class W on */ if (!ucontrol->value.integer.value[0]) { if (wm8903->class_w_users == 1) { - dev_dbg(codec->dev, "Enabling Class W\n"); - snd_soc_write(codec, WM8903_CLASS_W_0, reg | + dev_dbg(component->dev, "Enabling Class W\n"); + snd_soc_component_write(component, WM8903_CLASS_W_0, reg | WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V); } wm8903->class_w_users--; } - dev_dbg(codec->dev, "Bypass use count now %d\n", + dev_dbg(component->dev, "Bypass use count now %d\n", wm8903->class_w_users); return ret; @@ -417,9 +416,9 @@ static int wm8903_class_w_put(struct snd_kcontrol *kcontrol, static int wm8903_deemph[] = { 0, 32000, 44100, 48000 }; -static int wm8903_set_deemph(struct snd_soc_codec *codec) +static int wm8903_set_deemph(struct snd_soc_component *component) { - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int val, i, best; /* If we're using deemphasis select the nearest available sample @@ -439,18 +438,18 @@ static int wm8903_set_deemph(struct snd_soc_codec *codec) val = 0; } - dev_dbg(codec->dev, "Set deemphasis %d (%dHz)\n", + dev_dbg(component->dev, "Set deemphasis %d (%dHz)\n", best, wm8903_deemph[best]); - return snd_soc_update_bits(codec, WM8903_DAC_DIGITAL_1, + return snd_soc_component_update_bits(component, WM8903_DAC_DIGITAL_1, WM8903_DEEMPH_MASK, val); } static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8903->deemph; @@ -460,8 +459,8 @@ static int wm8903_get_deemph(struct snd_kcontrol *kcontrol, static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret = 0; @@ -472,7 +471,7 @@ static int wm8903_put_deemph(struct snd_kcontrol *kcontrol, if (wm8903->deemph != deemph) { wm8903->deemph = deemph; - wm8903_set_deemph(codec); + wm8903_set_deemph(component); ret = 1; } @@ -1101,7 +1100,7 @@ static const struct snd_soc_dapm_route wm8903_intercon[] = { { "Right Line Output PGA", NULL, "Charge Pump" }, }; -static int wm8903_set_bias_level(struct snd_soc_codec *codec, +static int wm8903_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -1109,14 +1108,14 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_RES_MASK, WM8903_VMID_RES_50K); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_POBCTRL | WM8903_ISEL_MASK | WM8903_STARTUP_BIAS_ENA | WM8903_BIAS_ENA, @@ -1124,22 +1123,22 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, (2 << WM8903_ISEL_SHIFT) | WM8903_STARTUP_BIAS_ENA); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0, WM8903_SPK_DISCHARGE, WM8903_SPK_DISCHARGE); msleep(33); - snd_soc_update_bits(codec, WM8903_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8903_POWER_MANAGEMENT_5, WM8903_SPKL_ENA | WM8903_SPKR_ENA, WM8903_SPKL_ENA | WM8903_SPKR_ENA); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8903_ANALOGUE_SPK_OUTPUT_CONTROL_0, WM8903_SPK_DISCHARGE, 0); - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_TIE_ENA | WM8903_BUFIO_ENA | WM8903_VMID_IO_ENA | @@ -1155,57 +1154,57 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, msleep(129); - snd_soc_update_bits(codec, WM8903_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8903_POWER_MANAGEMENT_5, WM8903_SPKL_ENA | WM8903_SPKR_ENA, 0); - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_SOFT_MASK, 0); - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_RES_MASK, WM8903_VMID_RES_50K); - snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_BIAS_ENA | WM8903_POBCTRL, WM8903_BIAS_ENA); /* By default no bypass paths are enabled so * enable Class W support. */ - dev_dbg(codec->dev, "Enabling Class W\n"); - snd_soc_update_bits(codec, WM8903_CLASS_W_0, + dev_dbg(component->dev, "Enabling Class W\n"); + snd_soc_component_update_bits(component, WM8903_CLASS_W_0, WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V, WM8903_CP_DYN_FREQ | WM8903_CP_DYN_V); } - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_RES_MASK, WM8903_VMID_RES_250K); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_BIAS_ENA, 0); - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_SOFT_MASK, 2 << WM8903_VMID_SOFT_SHIFT); - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_BUF_ENA, 0); msleep(290); - snd_soc_update_bits(codec, WM8903_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_VMID_CONTROL_0, WM8903_VMID_TIE_ENA | WM8903_BUFIO_ENA | WM8903_VMID_IO_ENA | WM8903_VMID_RES_MASK | WM8903_VMID_SOFT_MASK | WM8903_VMID_BUF_ENA, 0); - snd_soc_update_bits(codec, WM8903_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_BIAS_CONTROL_0, WM8903_STARTUP_BIAS_ENA, 0); break; } @@ -1216,8 +1215,8 @@ static int wm8903_set_bias_level(struct snd_soc_codec *codec, static int wm8903_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); wm8903->sysclk = freq; @@ -1227,8 +1226,8 @@ static int wm8903_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8903_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 aif1 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_1); + struct snd_soc_component *component = codec_dai->component; + u16 aif1 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_1); aif1 &= ~(WM8903_LRCLK_DIR | WM8903_BCLK_DIR | WM8903_AIF_FMT_MASK | WM8903_AIF_LRCLK_INV | WM8903_AIF_BCLK_INV); @@ -1306,24 +1305,24 @@ static int wm8903_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_1, aif1); return 0; } static int wm8903_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; - reg = snd_soc_read(codec, WM8903_DAC_DIGITAL_1); + reg = snd_soc_component_read32(component, WM8903_DAC_DIGITAL_1); if (mute) reg |= WM8903_DAC_MUTE; else reg &= ~WM8903_DAC_MUTE; - snd_soc_write(codec, WM8903_DAC_DIGITAL_1, reg); + snd_soc_component_write(component, WM8903_DAC_DIGITAL_1, reg); return 0; } @@ -1443,8 +1442,8 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int fs = params_rate(params); int bclk; int bclk_div; @@ -1455,12 +1454,12 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, int cur_val; int clk_sys; - u16 aif1 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_1); - u16 aif2 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_2); - u16 aif3 = snd_soc_read(codec, WM8903_AUDIO_INTERFACE_3); - u16 clock0 = snd_soc_read(codec, WM8903_CLOCK_RATES_0); - u16 clock1 = snd_soc_read(codec, WM8903_CLOCK_RATES_1); - u16 dac_digital1 = snd_soc_read(codec, WM8903_DAC_DIGITAL_1); + u16 aif1 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_1); + u16 aif2 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_2); + u16 aif3 = snd_soc_component_read32(component, WM8903_AUDIO_INTERFACE_3); + u16 clock0 = snd_soc_component_read32(component, WM8903_CLOCK_RATES_0); + u16 clock1 = snd_soc_component_read32(component, WM8903_CLOCK_RATES_1); + u16 dac_digital1 = snd_soc_component_read32(component, WM8903_DAC_DIGITAL_1); /* Enable sloping stopband filter for low sample rates */ if (fs <= 24000) @@ -1479,7 +1478,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, } } - dev_dbg(codec->dev, "DSP fs = %dHz\n", sample_rates[dsp_config].rate); + dev_dbg(component->dev, "DSP fs = %dHz\n", sample_rates[dsp_config].rate); clock1 &= ~WM8903_SAMPLE_RATE_MASK; clock1 |= sample_rates[dsp_config].value; @@ -1505,7 +1504,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - dev_dbg(codec->dev, "MCLK = %dHz, target sample rate = %dHz\n", + dev_dbg(component->dev, "MCLK = %dHz, target sample rate = %dHz\n", wm8903->sysclk, fs); /* We may not have an MCLK which allows us to generate exactly @@ -1540,12 +1539,12 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, clock1 |= clk_sys_ratios[clk_config].rate << WM8903_CLK_SYS_RATE_SHIFT; clock1 |= clk_sys_ratios[clk_config].mode << WM8903_CLK_SYS_MODE_SHIFT; - dev_dbg(codec->dev, "CLK_SYS_RATE=%x, CLK_SYS_MODE=%x div=%d\n", + dev_dbg(component->dev, "CLK_SYS_RATE=%x, CLK_SYS_MODE=%x div=%d\n", clk_sys_ratios[clk_config].rate, clk_sys_ratios[clk_config].mode, clk_sys_ratios[clk_config].div); - dev_dbg(codec->dev, "Actual CLK_SYS = %dHz\n", clk_sys); + dev_dbg(component->dev, "Actual CLK_SYS = %dHz\n", clk_sys); /* We may not get quite the right frequency if using * approximate clocks so look for the closest match that is @@ -1567,7 +1566,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, aif2 &= ~WM8903_BCLK_DIV_MASK; aif3 &= ~WM8903_LRCLK_RATE_MASK; - dev_dbg(codec->dev, "BCLK ratio %d for %dHz - actual BCLK = %dHz\n", + dev_dbg(component->dev, "BCLK ratio %d for %dHz - actual BCLK = %dHz\n", bclk_divs[bclk_div].ratio / 10, bclk, (clk_sys * 10) / bclk_divs[bclk_div].ratio); @@ -1575,14 +1574,14 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, aif3 |= bclk / fs; wm8903->fs = params_rate(params); - wm8903_set_deemph(codec); + wm8903_set_deemph(component); - snd_soc_write(codec, WM8903_CLOCK_RATES_0, clock0); - snd_soc_write(codec, WM8903_CLOCK_RATES_1, clock1); - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_1, aif1); - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_2, aif2); - snd_soc_write(codec, WM8903_AUDIO_INTERFACE_3, aif3); - snd_soc_write(codec, WM8903_DAC_DIGITAL_1, dac_digital1); + snd_soc_component_write(component, WM8903_CLOCK_RATES_0, clock0); + snd_soc_component_write(component, WM8903_CLOCK_RATES_1, clock1); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_2, aif2); + snd_soc_component_write(component, WM8903_AUDIO_INTERFACE_3, aif3); + snd_soc_component_write(component, WM8903_DAC_DIGITAL_1, dac_digital1); return 0; } @@ -1590,7 +1589,7 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, /** * wm8903_mic_detect - Enable microphone detection via the WM8903 IRQ * - * @codec: WM8903 codec + * @component: WM8903 component * @jack: jack to report detection events on * @det: value to report for presence detection * @shrt: value to report for short detection @@ -1604,13 +1603,13 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, * micdet_cfg in the platform data. Using this function will force on * the microphone bias for the device. */ -int wm8903_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int det, int shrt) { - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); int irq_mask = WM8903_MICDET_EINT | WM8903_MICSHRT_EINT; - dev_dbg(codec->dev, "Enabling microphone detection: %x %x\n", + dev_dbg(component->dev, "Enabling microphone detection: %x %x\n", det, shrt); /* Store the configuration */ @@ -1624,19 +1623,19 @@ int wm8903_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, if (shrt) irq_mask &= ~WM8903_MICSHRT_EINT; - snd_soc_update_bits(codec, WM8903_INTERRUPT_STATUS_1_MASK, + snd_soc_component_update_bits(component, WM8903_INTERRUPT_STATUS_1_MASK, WM8903_MICDET_EINT | WM8903_MICSHRT_EINT, irq_mask); if (det || shrt) { /* Enable mic detection, this may not have been set through * platform data (eg, if the defaults are OK). */ - snd_soc_update_bits(codec, WM8903_WRITE_SEQUENCER_0, + snd_soc_component_update_bits(component, WM8903_WRITE_SEQUENCER_0, WM8903_WSEQ_ENA, WM8903_WSEQ_ENA); - snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_MIC_BIAS_CONTROL_0, WM8903_MICDET_ENA, WM8903_MICDET_ENA); } else { - snd_soc_update_bits(codec, WM8903_MIC_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8903_MIC_BIAS_CONTROL_0, WM8903_MICDET_ENA, 0); } @@ -1766,9 +1765,9 @@ static struct snd_soc_dai_driver wm8903_dai = { .symmetric_rates = 1, }; -static int wm8903_resume(struct snd_soc_codec *codec) +static int wm8903_resume(struct snd_soc_component *component) { - struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); + struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component); regcache_sync(wm8903->regmap); @@ -1884,20 +1883,21 @@ static void wm8903_free_gpio(struct wm8903_priv *wm8903) } #endif -static const struct snd_soc_codec_driver soc_codec_dev_wm8903 = { - .resume = wm8903_resume, - .set_bias_level = wm8903_set_bias_level, - .seq_notifier = wm8903_seq_notifier, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8903_snd_controls, - .num_controls = ARRAY_SIZE(wm8903_snd_controls), - .dapm_widgets = wm8903_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8903_dapm_widgets), - .dapm_routes = wm8903_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8903_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8903 = { + .resume = wm8903_resume, + .set_bias_level = wm8903_set_bias_level, + .seq_notifier = wm8903_seq_notifier, + .controls = wm8903_snd_controls, + .num_controls = ARRAY_SIZE(wm8903_snd_controls), + .dapm_widgets = wm8903_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8903_dapm_widgets), + .dapm_routes = wm8903_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8903_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8903_regmap = { @@ -2176,8 +2176,8 @@ static int wm8903_i2c_probe(struct i2c_client *i2c, WM8903_DAC_MUTEMODE | WM8903_DAC_MUTE, WM8903_DAC_MUTEMODE | WM8903_DAC_MUTE); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8903, &wm8903_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8903, &wm8903_dai, 1); if (ret != 0) goto err; @@ -2197,7 +2197,6 @@ static int wm8903_i2c_remove(struct i2c_client *client) if (client->irq) free_irq(client->irq, wm8903); wm8903_free_gpio(wm8903); - snd_soc_unregister_codec(&client->dev); return 0; } diff --git a/sound/soc/codecs/wm8903.h b/sound/soc/codecs/wm8903.h index 0bb4a647755d..1301aa9dce6f 100644 --- a/sound/soc/codecs/wm8903.h +++ b/sound/soc/codecs/wm8903.h @@ -15,7 +15,7 @@ #include -extern int wm8903_mic_detect(struct snd_soc_codec *codec, +extern int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int det, int shrt); diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 18bdae59a4df..69bc9461974b 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c @@ -170,7 +170,7 @@ static const struct snd_kcontrol_new tegra_wm8903_controls[] = { static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct snd_soc_card *card = rtd->card; struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); @@ -189,7 +189,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) &tegra_wm8903_mic_jack, tegra_wm8903_mic_jack_pins, ARRAY_SIZE(tegra_wm8903_mic_jack_pins)); - wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, + wm8903_mic_detect(component, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, 0); snd_soc_dapm_force_enable_pin(&card->dapm, "MICBIAS"); @@ -202,9 +202,9 @@ static int tegra_wm8903_remove(struct snd_soc_card *card) struct snd_soc_pcm_runtime *rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; - wm8903_mic_detect(codec, NULL, 0, 0); + wm8903_mic_detect(component, NULL, 0, 0); return 0; } From 69b626e68207cf78015ec13f0077af174d710f97 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:05:28 +0000 Subject: [PATCH 038/942] ASoC: wm8955: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8955.c | 189 ++++++++++++++++++-------------------- 1 file changed, 91 insertions(+), 98 deletions(-) diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index 1edc7b1df31d..ba44e3d6c1e0 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c @@ -128,9 +128,9 @@ static bool wm8955_volatile(struct device *dev, unsigned int reg) } } -static int wm8955_reset(struct snd_soc_codec *codec) +static int wm8955_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8955_RESET, 0); + return snd_soc_component_write(component, WM8955_RESET, 0); } struct pll_factors { @@ -242,9 +242,9 @@ static struct { { 11289600, 88200, 0, 31, }, }; -static int wm8955_configure_clocking(struct snd_soc_codec *codec) +static int wm8955_configure_clocking(struct snd_soc_component *component) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int i, ret, val; int clocking = 0; int srate = 0; @@ -267,7 +267,7 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) /* We should never get here with an unsupported sample rate */ if (sr == -1) { - dev_err(codec->dev, "Sample rate %dHz unsupported\n", + dev_err(component->dev, "Sample rate %dHz unsupported\n", wm8955->fs); WARN_ON(sr == -1); return -EINVAL; @@ -282,30 +282,30 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) /* Use the last divider configuration we saw for the * sample rate. */ - ret = wm8995_pll_factors(codec->dev, wm8955->mclk_rate, + ret = wm8995_pll_factors(component->dev, wm8955->mclk_rate, clock_cfgs[sr].mclk, &pll); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to generate %dHz from %dHz MCLK\n", wm8955->fs, wm8955->mclk_rate); return -EINVAL; } - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_1, WM8955_N_MASK | WM8955_K_21_18_MASK, (pll.n << WM8955_N_SHIFT) | pll.k >> 18); - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_2, WM8955_K_17_9_MASK, (pll.k >> 9) & WM8955_K_17_9_MASK); - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_3, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_3, WM8955_K_8_0_MASK, pll.k & WM8955_K_8_0_MASK); if (pll.k) - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_4, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_4, WM8955_KEN, WM8955_KEN); else - snd_soc_update_bits(codec, WM8955_PLL_CONTROL_4, + snd_soc_component_update_bits(component, WM8955_PLL_CONTROL_4, WM8955_KEN, 0); if (pll.outdiv) @@ -314,17 +314,17 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) val = WM8955_PLL_RB; /* Now start the PLL running */ - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLL_RB | WM8955_PLLOUTDIV2, val); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLLEN, WM8955_PLLEN); } srate = clock_cfgs[sr].usb | (clock_cfgs[sr].sr << WM8955_SR_SHIFT); - snd_soc_update_bits(codec, WM8955_SAMPLE_RATE, + snd_soc_component_update_bits(component, WM8955_SAMPLE_RATE, WM8955_USB | WM8955_SR_MASK, srate); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_MCLKSEL, clocking); return 0; @@ -333,22 +333,22 @@ static int wm8955_configure_clocking(struct snd_soc_codec *codec) static int wm8955_sysclk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int ret = 0; /* Always disable the clocks - if we're doing reconfiguration this * avoids misclocking. */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_DIGENB, 0); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLL_RB | WM8955_PLLEN, 0); switch (event) { case SND_SOC_DAPM_POST_PMD: break; case SND_SOC_DAPM_PRE_PMU: - ret = wm8955_configure_clocking(codec); + ret = wm8955_configure_clocking(component); break; default: ret = -EINVAL; @@ -360,9 +360,9 @@ static int wm8955_sysclk(struct snd_soc_dapm_widget *w, static int deemph_settings[] = { 0, 32000, 44100, 48000 }; -static int wm8955_set_deemph(struct snd_soc_codec *codec) +static int wm8955_set_deemph(struct snd_soc_component *component) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int val, i, best; /* If we're using deemphasis select the nearest available sample @@ -381,17 +381,17 @@ static int wm8955_set_deemph(struct snd_soc_codec *codec) val = 0; } - dev_dbg(codec->dev, "Set deemphasis %d\n", val); + dev_dbg(component->dev, "Set deemphasis %d\n", val); - return snd_soc_update_bits(codec, WM8955_DAC_CONTROL, + return snd_soc_component_update_bits(component, WM8955_DAC_CONTROL, WM8955_DEEMPH_MASK, val); } static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8955->deemph; return 0; @@ -400,8 +400,8 @@ static int wm8955_get_deemph(struct snd_kcontrol *kcontrol, static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) @@ -409,7 +409,7 @@ static int wm8955_put_deemph(struct snd_kcontrol *kcontrol, wm8955->deemph = deemph; - return wm8955_set_deemph(codec); + return wm8955_set_deemph(component); } static const char *bass_mode_text[] = { @@ -592,8 +592,8 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int ret; int wl; @@ -613,25 +613,25 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, WM8955_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8955_AUDIO_INTERFACE, WM8955_WL_MASK, wl); wm8955->fs = params_rate(params); - wm8955_set_deemph(codec); + wm8955_set_deemph(component); /* If the chip is clocked then disable the clocks and force a * reconfiguration, otherwise DAPM will power up the * clocks for us later. */ - ret = snd_soc_read(codec, WM8955_POWER_MANAGEMENT_1); + ret = snd_soc_component_read32(component, WM8955_POWER_MANAGEMENT_1); if (ret < 0) return ret; if (ret & WM8955_DIGENB) { - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_DIGENB, 0); - snd_soc_update_bits(codec, WM8955_CLOCKING_PLL, + snd_soc_component_update_bits(component, WM8955_CLOCKING_PLL, WM8955_PLL_RB | WM8955_PLLEN, 0); - wm8955_configure_clocking(codec); + wm8955_configure_clocking(component); } return 0; @@ -641,8 +641,8 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8955_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8955_priv *priv = snd_soc_component_get_drvdata(component); int div; switch (clk_id) { @@ -655,7 +655,7 @@ static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id, div = 0; } - snd_soc_update_bits(codec, WM8955_SAMPLE_RATE, + snd_soc_component_update_bits(component, WM8955_SAMPLE_RATE, WM8955_MCLKDIV2, div); break; @@ -670,7 +670,7 @@ static int wm8955_set_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 aif = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -739,7 +739,7 @@ static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8955_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8955_AUDIO_INTERFACE, WM8955_MS | WM8955_FORMAT_MASK | WM8955_BCLKINV | WM8955_LRP, aif); @@ -749,7 +749,7 @@ static int wm8955_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8955_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int val; if (mute) @@ -757,15 +757,15 @@ static int wm8955_digital_mute(struct snd_soc_dai *codec_dai, int mute) else val = 0; - snd_soc_update_bits(codec, WM8955_DAC_CONTROL, WM8955_DACMU, val); + snd_soc_component_update_bits(component, WM8955_DAC_CONTROL, WM8955_DACMU, val); return 0; } -static int wm8955_set_bias_level(struct snd_soc_codec *codec, +static int wm8955_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -774,22 +774,22 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID resistance 2*50k */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VMIDSEL_MASK, 0x1 << WM8955_VMIDSEL_SHIFT); /* Default bias current */ - snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_1, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_1, WM8955_VSEL_MASK, 0x2 << WM8955_VSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -798,7 +798,7 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8955->regmap); /* Enable VREF and VMID */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VREF | WM8955_VMIDSEL_MASK, WM8955_VREF | @@ -808,29 +808,29 @@ static int wm8955_set_bias_level(struct snd_soc_codec *codec, msleep(500); /* High resistance VROI to maintain outputs */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_3, WM8955_VROI, WM8955_VROI); } /* Maintain VMID with 2*250k */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VMIDSEL_MASK, 0x2 << WM8955_VMIDSEL_SHIFT); /* Minimum bias current */ - snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_1, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_1, WM8955_VSEL_MASK, 0); break; case SND_SOC_BIAS_OFF: /* Low resistance VROI to help discharge */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_3, WM8955_VROI, 0); /* Turn off VMID and VREF */ - snd_soc_update_bits(codec, WM8955_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8955_POWER_MANAGEMENT_1, WM8955_VREF | WM8955_VMIDSEL_MASK, 0); @@ -865,70 +865,70 @@ static struct snd_soc_dai_driver wm8955_dai = { .ops = &wm8955_dai_ops, }; -static int wm8955_probe(struct snd_soc_codec *codec) +static int wm8955_probe(struct snd_soc_component *component) { - struct wm8955_priv *wm8955 = snd_soc_codec_get_drvdata(codec); - struct wm8955_pdata *pdata = dev_get_platdata(codec->dev); + struct wm8955_priv *wm8955 = snd_soc_component_get_drvdata(component); + struct wm8955_pdata *pdata = dev_get_platdata(component->dev); int ret, i; for (i = 0; i < ARRAY_SIZE(wm8955->supplies); i++) wm8955->supplies[i].supply = wm8955_supply_names[i]; - ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8955->supplies), + ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + dev_err(component->dev, "Failed to request supplies: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } - ret = wm8955_reset(codec); + ret = wm8955_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_enable; } /* Change some default settings - latch VU and enable ZC */ - snd_soc_update_bits(codec, WM8955_LEFT_DAC_VOLUME, + snd_soc_component_update_bits(component, WM8955_LEFT_DAC_VOLUME, WM8955_LDVU, WM8955_LDVU); - snd_soc_update_bits(codec, WM8955_RIGHT_DAC_VOLUME, + snd_soc_component_update_bits(component, WM8955_RIGHT_DAC_VOLUME, WM8955_RDVU, WM8955_RDVU); - snd_soc_update_bits(codec, WM8955_LOUT1_VOLUME, + snd_soc_component_update_bits(component, WM8955_LOUT1_VOLUME, WM8955_LO1VU | WM8955_LO1ZC, WM8955_LO1VU | WM8955_LO1ZC); - snd_soc_update_bits(codec, WM8955_ROUT1_VOLUME, + snd_soc_component_update_bits(component, WM8955_ROUT1_VOLUME, WM8955_RO1VU | WM8955_RO1ZC, WM8955_RO1VU | WM8955_RO1ZC); - snd_soc_update_bits(codec, WM8955_LOUT2_VOLUME, + snd_soc_component_update_bits(component, WM8955_LOUT2_VOLUME, WM8955_LO2VU | WM8955_LO2ZC, WM8955_LO2VU | WM8955_LO2ZC); - snd_soc_update_bits(codec, WM8955_ROUT2_VOLUME, + snd_soc_component_update_bits(component, WM8955_ROUT2_VOLUME, WM8955_RO2VU | WM8955_RO2ZC, WM8955_RO2VU | WM8955_RO2ZC); - snd_soc_update_bits(codec, WM8955_MONOOUT_VOLUME, + snd_soc_component_update_bits(component, WM8955_MONOOUT_VOLUME, WM8955_MOZC, WM8955_MOZC); /* Also enable adaptive bass boost by default */ - snd_soc_update_bits(codec, WM8955_BASS_CONTROL, WM8955_BB, WM8955_BB); + snd_soc_component_update_bits(component, WM8955_BASS_CONTROL, WM8955_BB, WM8955_BB); /* Set platform data values */ if (pdata) { if (pdata->out2_speaker) - snd_soc_update_bits(codec, WM8955_ADDITIONAL_CONTROL_2, + snd_soc_component_update_bits(component, WM8955_ADDITIONAL_CONTROL_2, WM8955_ROUT2INV, WM8955_ROUT2INV); if (pdata->monoin_diff) - snd_soc_update_bits(codec, WM8955_MONO_OUT_MIX_1, + snd_soc_component_update_bits(component, WM8955_MONO_OUT_MIX_1, WM8955_DMEN, WM8955_DMEN); } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(wm8955->supplies), wm8955->supplies); @@ -940,19 +940,20 @@ err_enable: return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8955 = { - .probe = wm8955_probe, - .set_bias_level = wm8955_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8955_snd_controls, - .num_controls = ARRAY_SIZE(wm8955_snd_controls), - .dapm_widgets = wm8955_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8955_dapm_widgets), - .dapm_routes = wm8955_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8955_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8955 = { + .probe = wm8955_probe, + .set_bias_level = wm8955_set_bias_level, + .controls = wm8955_snd_controls, + .num_controls = ARRAY_SIZE(wm8955_snd_controls), + .dapm_widgets = wm8955_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8955_dapm_widgets), + .dapm_routes = wm8955_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8955_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8955_regmap = { @@ -989,19 +990,12 @@ static int wm8955_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8955); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8955, &wm8955_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8955, &wm8955_dai, 1); return ret; } -static int wm8955_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8955_i2c_id[] = { { "wm8955", 0 }, { } @@ -1013,7 +1007,6 @@ static struct i2c_driver wm8955_i2c_driver = { .name = "wm8955", }, .probe = wm8955_i2c_probe, - .remove = wm8955_i2c_remove, .id_table = wm8955_i2c_id, }; From e075fc17b70813fede562cc0f7751bc7ca426c49 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:05:45 +0000 Subject: [PATCH 039/942] ASoC: wm8960: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8960.c | 249 +++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 123 deletions(-) diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index 9ed455700954..c30f5aa392c6 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c @@ -49,7 +49,7 @@ #define WM8960_DRES_MASK 0x30 static bool is_pll_freq_available(unsigned int source, unsigned int target); -static int wm8960_set_pll(struct snd_soc_codec *codec, +static int wm8960_set_pll(struct snd_soc_component *component, unsigned int freq_in, unsigned int freq_out); /* * wm8960 register cache @@ -123,7 +123,7 @@ static bool wm8960_volatile(struct device *dev, unsigned int reg) struct wm8960_priv { struct clk *mclk; struct regmap *regmap; - int (*set_bias_level)(struct snd_soc_codec *, + int (*set_bias_level)(struct snd_soc_component *, enum snd_soc_bias_level level); struct snd_soc_dapm_widget *lout1; struct snd_soc_dapm_widget *rout1; @@ -168,9 +168,9 @@ static const struct soc_enum wm8960_enum[] = { static const int deemph_settings[] = { 0, 32000, 44100, 48000 }; -static int wm8960_set_deemph(struct snd_soc_codec *codec) +static int wm8960_set_deemph(struct snd_soc_component *component) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); int val, i, best; /* If we're using deemphasis select the nearest available sample @@ -189,17 +189,17 @@ static int wm8960_set_deemph(struct snd_soc_codec *codec) val = 0; } - dev_dbg(codec->dev, "Set deemphasis %d\n", val); + dev_dbg(component->dev, "Set deemphasis %d\n", val); - return snd_soc_update_bits(codec, WM8960_DACCTL1, + return snd_soc_component_update_bits(component, WM8960_DACCTL1, 0x6, val); } static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8960->deemph; return 0; @@ -208,8 +208,8 @@ static int wm8960_get_deemph(struct snd_kcontrol *kcontrol, static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) @@ -217,7 +217,7 @@ static int wm8960_put_deemph(struct snd_kcontrol *kcontrol, wm8960->deemph = deemph; - return wm8960_set_deemph(codec); + return wm8960_set_deemph(component); } static const DECLARE_TLV_DB_SCALE(adc_tlv, -9750, 50, 1); @@ -470,11 +470,11 @@ static const struct snd_soc_dapm_route audio_paths_capless[] = { { "OUT3 VMID", NULL, "Right Output Mixer" }, }; -static int wm8960_add_widgets(struct snd_soc_codec *codec) +static int wm8960_add_widgets(struct snd_soc_component *component) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); struct wm8960_data *pdata = &wm8960->pdata; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct snd_soc_dapm_widget *w; snd_soc_dapm_new_controls(dapm, wm8960_dapm_widgets, @@ -504,7 +504,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec) * list each time to find the desired power state do so now * and save the result. */ - list_for_each_entry(w, &codec->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (w->dapm != dapm) continue; if (strcmp(w->name, "LOUT1 PGA") == 0) @@ -521,7 +521,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec) static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -573,7 +573,7 @@ static int wm8960_set_dai_fmt(struct snd_soc_dai *codec_dai, } /* set iface */ - snd_soc_write(codec, WM8960_IFACE1, iface); + snd_soc_component_write(component, WM8960_IFACE1, iface); return 0; } @@ -683,7 +683,7 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk, * triplet, we relax the bclk such that bclk is chosen as the * closest available frequency greater than expected bclk. * - * @codec: codec structure + * @component: component structure * @freq_in: input frequency used to derive freq out via PLL * @sysclk_idx: sysclk_divs index for found sysclk * @dac_idx: dac_divs index for found lrclk @@ -695,10 +695,10 @@ int wm8960_configure_sysclk(struct wm8960_priv *wm8960, int mclk, * (@sysclk_idx, @dac_idx, @bclk_idx) dividers */ static -int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, +int wm8960_configure_pll(struct snd_soc_component *component, int freq_in, int *sysclk_idx, int *dac_idx, int *bclk_idx) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); int sysclk, bclk, lrclk, freq_out; int diff, closest, best_freq_out; int i, j, k; @@ -741,22 +741,22 @@ int wm8960_configure_pll(struct snd_soc_codec *codec, int freq_in, return best_freq_out; } -static int wm8960_configure_clocking(struct snd_soc_codec *codec) +static int wm8960_configure_clocking(struct snd_soc_component *component) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); int freq_out, freq_in; - u16 iface1 = snd_soc_read(codec, WM8960_IFACE1); + u16 iface1 = snd_soc_component_read32(component, WM8960_IFACE1); int i, j, k; int ret; if (!(iface1 & (1<<6))) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Codec is slave mode, no need to configure clock\n"); return 0; } if (wm8960->clk_id != WM8960_SYSCLK_MCLK && !wm8960->freq_in) { - dev_err(codec->dev, "No MCLK configured\n"); + dev_err(component->dev, "No MCLK configured\n"); return -EINVAL; } @@ -769,12 +769,12 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec) */ if (wm8960->clk_id == WM8960_SYSCLK_AUTO) { /* disable the PLL and using MCLK to provide sysclk */ - wm8960_set_pll(codec, 0, 0); + wm8960_set_pll(component, 0, 0); freq_out = freq_in; } else if (wm8960->sysclk) { freq_out = wm8960->sysclk; } else { - dev_err(codec->dev, "No SYSCLK configured\n"); + dev_err(component->dev, "No SYSCLK configured\n"); return -EINVAL; } @@ -783,28 +783,28 @@ static int wm8960_configure_clocking(struct snd_soc_codec *codec) if (ret >= 0) { goto configure_clock; } else if (wm8960->clk_id != WM8960_SYSCLK_AUTO) { - dev_err(codec->dev, "failed to configure clock\n"); + dev_err(component->dev, "failed to configure clock\n"); return -EINVAL; } } - freq_out = wm8960_configure_pll(codec, freq_in, &i, &j, &k); + freq_out = wm8960_configure_pll(component, freq_in, &i, &j, &k); if (freq_out < 0) { - dev_err(codec->dev, "failed to configure clock via PLL\n"); + dev_err(component->dev, "failed to configure clock via PLL\n"); return freq_out; } - wm8960_set_pll(codec, freq_in, freq_out); + wm8960_set_pll(component, freq_in, freq_out); configure_clock: /* configure sysclk clock */ - snd_soc_update_bits(codec, WM8960_CLOCK1, 3 << 1, i << 1); + snd_soc_component_update_bits(component, WM8960_CLOCK1, 3 << 1, i << 1); /* configure frame clock */ - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 3, j << 3); - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x7 << 6, j << 6); + snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x7 << 3, j << 3); + snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x7 << 6, j << 6); /* configure bit clock */ - snd_soc_update_bits(codec, WM8960_CLOCK2, 0xf, k); + snd_soc_component_update_bits(component, WM8960_CLOCK2, 0xf, k); return 0; } @@ -813,9 +813,9 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; + struct snd_soc_component *component = dai->component; + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8960_IFACE1) & 0xfff3; bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; int i; @@ -840,7 +840,7 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, break; } default: - dev_err(codec->dev, "unsupported width %d\n", + dev_err(component->dev, "unsupported width %d\n", params_width(params)); return -EINVAL; } @@ -848,23 +848,23 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, wm8960->lrclk = params_rate(params); /* Update filters for the new rate */ if (tx) { - wm8960_set_deemph(codec); + wm8960_set_deemph(component); } else { for (i = 0; i < ARRAY_SIZE(alc_rates); i++) if (alc_rates[i].rate == params_rate(params)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8960_ADDCTL3, 0x7, alc_rates[i].val); } /* set iface */ - snd_soc_write(codec, WM8960_IFACE1, iface); + snd_soc_component_write(component, WM8960_IFACE1, iface); wm8960->is_stream_in_use[tx] = true; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON && + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON && !wm8960->is_stream_in_use[!tx]) - return wm8960_configure_clocking(codec); + return wm8960_configure_clocking(component); return 0; } @@ -872,8 +872,8 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, static int wm8960_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; wm8960->is_stream_in_use[tx] = false; @@ -883,20 +883,20 @@ static int wm8960_hw_free(struct snd_pcm_substream *substream, static int wm8960_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) - snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0x8); + snd_soc_component_update_bits(component, WM8960_DACCTL1, 0x8, 0x8); else - snd_soc_update_bits(codec, WM8960_DACCTL1, 0x8, 0); + snd_soc_component_update_bits(component, WM8960_DACCTL1, 0x8, 0); return 0; } -static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, +static int wm8960_set_bias_level_out3(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - u16 pm2 = snd_soc_read(codec, WM8960_POWER2); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); + u16 pm2 = snd_soc_component_read32(component, WM8960_POWER2); int ret; switch (level) { @@ -904,24 +904,24 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_STANDBY: if (!IS_ERR(wm8960->mclk)) { ret = clk_prepare_enable(wm8960->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable MCLK: %d\n", ret); return ret; } } - ret = wm8960_configure_clocking(codec); + ret = wm8960_configure_clocking(component); if (ret) return ret; /* Set VMID to 2x50k */ - snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x80); + snd_soc_component_update_bits(component, WM8960_POWER1, 0x180, 0x80); break; case SND_SOC_BIAS_ON: @@ -930,7 +930,7 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, * disable the pll */ if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) - wm8960_set_pll(codec, 0, 0); + wm8960_set_pll(component, 0, 0); if (!IS_ERR(wm8960->mclk)) clk_disable_unprepare(wm8960->mclk); @@ -943,38 +943,38 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8960->regmap); /* Enable anti-pop features */ - snd_soc_write(codec, WM8960_APOP1, + snd_soc_component_write(component, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN | WM8960_BUFIOEN); /* Enable & ramp VMID at 2x50k */ - snd_soc_update_bits(codec, WM8960_POWER1, 0x80, 0x80); + snd_soc_component_update_bits(component, WM8960_POWER1, 0x80, 0x80); msleep(100); /* Enable VREF */ - snd_soc_update_bits(codec, WM8960_POWER1, WM8960_VREF, + snd_soc_component_update_bits(component, WM8960_POWER1, WM8960_VREF, WM8960_VREF); /* Disable anti-pop features */ - snd_soc_write(codec, WM8960_APOP1, WM8960_BUFIOEN); + snd_soc_component_write(component, WM8960_APOP1, WM8960_BUFIOEN); } /* Set VMID to 2x250k */ - snd_soc_update_bits(codec, WM8960_POWER1, 0x180, 0x100); + snd_soc_component_update_bits(component, WM8960_POWER1, 0x180, 0x100); break; case SND_SOC_BIAS_OFF: /* Enable anti-pop features */ - snd_soc_write(codec, WM8960_APOP1, + snd_soc_component_write(component, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN | WM8960_BUFIOEN); /* Disable VMID and VREF, let them discharge */ - snd_soc_write(codec, WM8960_POWER1, 0); + snd_soc_component_write(component, WM8960_POWER1, 0); msleep(600); break; } @@ -982,11 +982,11 @@ static int wm8960_set_bias_level_out3(struct snd_soc_codec *codec, return 0; } -static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, +static int wm8960_set_bias_level_capless(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); - u16 pm2 = snd_soc_read(codec, WM8960_POWER2); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); + u16 pm2 = snd_soc_component_read32(component, WM8960_POWER2); int reg, ret; switch (level) { @@ -994,10 +994,10 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_STANDBY: /* Enable anti pop mode */ - snd_soc_update_bits(codec, WM8960_APOP1, + snd_soc_component_update_bits(component, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN, WM8960_POBCTRL | WM8960_SOFT_ST | @@ -1011,20 +1011,20 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, reg |= WM8960_PWR2_ROUT1; if (wm8960->out3 && wm8960->out3->power) reg |= WM8960_PWR2_OUT3; - snd_soc_update_bits(codec, WM8960_POWER2, + snd_soc_component_update_bits(component, WM8960_POWER2, WM8960_PWR2_LOUT1 | WM8960_PWR2_ROUT1 | WM8960_PWR2_OUT3, reg); /* Enable VMID at 2*50k */ - snd_soc_update_bits(codec, WM8960_POWER1, + snd_soc_component_update_bits(component, WM8960_POWER1, WM8960_VMID_MASK, 0x80); /* Ramp */ msleep(100); /* Enable VREF */ - snd_soc_update_bits(codec, WM8960_POWER1, + snd_soc_component_update_bits(component, WM8960_POWER1, WM8960_VREF, WM8960_VREF); msleep(100); @@ -1032,14 +1032,14 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, if (!IS_ERR(wm8960->mclk)) { ret = clk_prepare_enable(wm8960->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable MCLK: %d\n", ret); return ret; } } - ret = wm8960_configure_clocking(codec); + ret = wm8960_configure_clocking(component); if (ret) return ret; @@ -1051,20 +1051,20 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, * disable the pll */ if (wm8960->clk_id == WM8960_SYSCLK_AUTO && (pm2 & 0x1)) - wm8960_set_pll(codec, 0, 0); + wm8960_set_pll(component, 0, 0); if (!IS_ERR(wm8960->mclk)) clk_disable_unprepare(wm8960->mclk); /* Enable anti-pop mode */ - snd_soc_update_bits(codec, WM8960_APOP1, + snd_soc_component_update_bits(component, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN); /* Disable VMID and VREF */ - snd_soc_update_bits(codec, WM8960_POWER1, + snd_soc_component_update_bits(component, WM8960_POWER1, WM8960_VREF | WM8960_VMID_MASK, 0); break; @@ -1077,15 +1077,15 @@ static int wm8960_set_bias_level_capless(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_PREPARE: /* Disable HP discharge */ - snd_soc_update_bits(codec, WM8960_APOP2, + snd_soc_component_update_bits(component, WM8960_APOP2, WM8960_DISOP | WM8960_DRES_MASK, 0); /* Disable anti-pop features */ - snd_soc_update_bits(codec, WM8960_APOP1, + snd_soc_component_update_bits(component, WM8960_APOP1, WM8960_POBCTRL | WM8960_SOFT_ST | WM8960_BUFDCOPEN, WM8960_POBCTRL | WM8960_SOFT_ST | @@ -1184,7 +1184,7 @@ static int pll_factors(unsigned int source, unsigned int target, return 0; } -static int wm8960_set_pll(struct snd_soc_codec *codec, +static int wm8960_set_pll(struct snd_soc_component *component, unsigned int freq_in, unsigned int freq_out) { u16 reg; @@ -1199,29 +1199,29 @@ static int wm8960_set_pll(struct snd_soc_codec *codec, /* Disable the PLL: even if we are changing the frequency the * PLL needs to be disabled while we do so. */ - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0); - snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0); + snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x1, 0); + snd_soc_component_update_bits(component, WM8960_POWER2, 0x1, 0); if (!freq_in || !freq_out) return 0; - reg = snd_soc_read(codec, WM8960_PLL1) & ~0x3f; + reg = snd_soc_component_read32(component, WM8960_PLL1) & ~0x3f; reg |= pll_div.pre_div << 4; reg |= pll_div.n; if (pll_div.k) { reg |= 0x20; - snd_soc_write(codec, WM8960_PLL2, (pll_div.k >> 16) & 0xff); - snd_soc_write(codec, WM8960_PLL3, (pll_div.k >> 8) & 0xff); - snd_soc_write(codec, WM8960_PLL4, pll_div.k & 0xff); + snd_soc_component_write(component, WM8960_PLL2, (pll_div.k >> 16) & 0xff); + snd_soc_component_write(component, WM8960_PLL3, (pll_div.k >> 8) & 0xff); + snd_soc_component_write(component, WM8960_PLL4, pll_div.k & 0xff); } - snd_soc_write(codec, WM8960_PLL1, reg); + snd_soc_component_write(component, WM8960_PLL1, reg); /* Turn it on */ - snd_soc_update_bits(codec, WM8960_POWER2, 0x1, 0x1); + snd_soc_component_update_bits(component, WM8960_POWER2, 0x1, 0x1); msleep(250); - snd_soc_update_bits(codec, WM8960_CLOCK1, 0x1, 0x1); + snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x1, 0x1); return 0; } @@ -1229,43 +1229,43 @@ static int wm8960_set_pll(struct snd_soc_codec *codec, static int wm8960_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); wm8960->freq_in = freq_in; if (pll_id == WM8960_SYSCLK_AUTO) return 0; - return wm8960_set_pll(codec, freq_in, freq_out); + return wm8960_set_pll(component, freq_in, freq_out); } static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; switch (div_id) { case WM8960_SYSCLKDIV: - reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1f9; - snd_soc_write(codec, WM8960_CLOCK1, reg | div); + reg = snd_soc_component_read32(component, WM8960_CLOCK1) & 0x1f9; + snd_soc_component_write(component, WM8960_CLOCK1, reg | div); break; case WM8960_DACDIV: - reg = snd_soc_read(codec, WM8960_CLOCK1) & 0x1c7; - snd_soc_write(codec, WM8960_CLOCK1, reg | div); + reg = snd_soc_component_read32(component, WM8960_CLOCK1) & 0x1c7; + snd_soc_component_write(component, WM8960_CLOCK1, reg | div); break; case WM8960_OPCLKDIV: - reg = snd_soc_read(codec, WM8960_PLL1) & 0x03f; - snd_soc_write(codec, WM8960_PLL1, reg | div); + reg = snd_soc_component_read32(component, WM8960_PLL1) & 0x03f; + snd_soc_component_write(component, WM8960_PLL1, reg | div); break; case WM8960_DCLKDIV: - reg = snd_soc_read(codec, WM8960_CLOCK2) & 0x03f; - snd_soc_write(codec, WM8960_CLOCK2, reg | div); + reg = snd_soc_component_read32(component, WM8960_CLOCK2) & 0x03f; + snd_soc_component_write(component, WM8960_CLOCK2, reg | div); break; case WM8960_TOCLKSEL: - reg = snd_soc_read(codec, WM8960_ADDCTL1) & 0x1fd; - snd_soc_write(codec, WM8960_ADDCTL1, reg | div); + reg = snd_soc_component_read32(component, WM8960_ADDCTL1) & 0x1fd; + snd_soc_component_write(component, WM8960_ADDCTL1, reg | div); break; default: return -EINVAL; @@ -1274,27 +1274,27 @@ static int wm8960_set_dai_clkdiv(struct snd_soc_dai *codec_dai, return 0; } -static int wm8960_set_bias_level(struct snd_soc_codec *codec, +static int wm8960_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); - return wm8960->set_bias_level(codec, level); + return wm8960->set_bias_level(component, level); } static int wm8960_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM8960_SYSCLK_MCLK: - snd_soc_update_bits(codec, WM8960_CLOCK1, + snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x1, WM8960_SYSCLK_MCLK); break; case WM8960_SYSCLK_PLL: - snd_soc_update_bits(codec, WM8960_CLOCK1, + snd_soc_component_update_bits(component, WM8960_CLOCK1, 0x1, WM8960_SYSCLK_PLL); break; case WM8960_SYSCLK_AUTO: @@ -1343,9 +1343,9 @@ static struct snd_soc_dai_driver wm8960_dai = { .symmetric_rates = 1, }; -static int wm8960_probe(struct snd_soc_codec *codec) +static int wm8960_probe(struct snd_soc_component *component) { - struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); + struct wm8960_priv *wm8960 = snd_soc_component_get_drvdata(component); struct wm8960_data *pdata = &wm8960->pdata; if (pdata->capless) @@ -1353,17 +1353,21 @@ static int wm8960_probe(struct snd_soc_codec *codec) else wm8960->set_bias_level = wm8960_set_bias_level_out3; - snd_soc_add_codec_controls(codec, wm8960_snd_controls, + snd_soc_add_component_controls(component, wm8960_snd_controls, ARRAY_SIZE(wm8960_snd_controls)); - wm8960_add_widgets(codec); + wm8960_add_widgets(component); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8960 = { - .probe = wm8960_probe, - .set_bias_level = wm8960_set_bias_level, - .suspend_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm8960 = { + .probe = wm8960_probe, + .set_bias_level = wm8960_set_bias_level, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8960_regmap = { @@ -1447,15 +1451,14 @@ static int wm8960_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8960); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8960, &wm8960_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8960, &wm8960_dai, 1); return ret; } static int wm8960_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From cbc23b742464357c25eef77f63ed86d24a12ff27 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:06:06 +0000 Subject: [PATCH 040/942] ASoC: wm8985: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8985.c | 201 ++++++++++++++++++-------------------- 1 file changed, 94 insertions(+), 107 deletions(-) diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 05344f974ff3..18b342ca4f8e 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c @@ -564,10 +564,10 @@ static const struct snd_soc_dapm_route wm8985_aux_dapm_routes[] = { { "Left Boost Mixer", "AUXL Volume", "AUXL" }, }; -static int wm8985_add_widgets(struct snd_soc_codec *codec) +static int wm8985_add_widgets(struct snd_soc_component *component) { - struct wm8985_priv *wm8985 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8985_priv *wm8985 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); switch (wm8985->dev_type) { case WM8758: @@ -576,7 +576,7 @@ static int wm8985_add_widgets(struct snd_soc_codec *codec) break; case WM8985: - snd_soc_add_codec_controls(codec, wm8985_specific_snd_controls, + snd_soc_add_component_controls(component, wm8985_specific_snd_controls, ARRAY_SIZE(wm8985_specific_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8985_dapm_widgets, @@ -592,10 +592,10 @@ static int wm8985_add_widgets(struct snd_soc_codec *codec) static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg; - reg = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); + reg = snd_soc_component_read32(component, WM8985_EQ1_LOW_SHELF); if (reg & WM8985_EQ3DMODE) ucontrol->value.enumerated.item[0] = 1; else @@ -607,7 +607,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq; @@ -615,7 +615,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, && ucontrol->value.enumerated.item[0] != 1) return -EINVAL; - reg_eq = snd_soc_read(codec, WM8985_EQ1_LOW_SHELF); + reg_eq = snd_soc_component_read32(component, WM8985_EQ1_LOW_SHELF); switch ((reg_eq & WM8985_EQ3DMODE) >> WM8985_EQ3DMODE_SHIFT) { case 0: if (!ucontrol->value.enumerated.item[0]) @@ -627,46 +627,46 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, break; } - regpwr2 = snd_soc_read(codec, WM8985_POWER_MANAGEMENT_2); - regpwr3 = snd_soc_read(codec, WM8985_POWER_MANAGEMENT_3); + regpwr2 = snd_soc_component_read32(component, WM8985_POWER_MANAGEMENT_2); + regpwr3 = snd_soc_component_read32(component, WM8985_POWER_MANAGEMENT_3); /* disable the DACs and ADCs */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_2, WM8985_ADCENR_MASK | WM8985_ADCENL_MASK, 0); - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_3, WM8985_DACENR_MASK | WM8985_DACENL_MASK, 0); - snd_soc_update_bits(codec, WM8985_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8985_ADDITIONAL_CONTROL, WM8985_M128ENB_MASK, WM8985_M128ENB); /* set the desired eqmode */ - snd_soc_update_bits(codec, WM8985_EQ1_LOW_SHELF, + snd_soc_component_update_bits(component, WM8985_EQ1_LOW_SHELF, WM8985_EQ3DMODE_MASK, ucontrol->value.enumerated.item[0] << WM8985_EQ3DMODE_SHIFT); /* restore DAC/ADC configuration */ - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, regpwr2); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_3, regpwr3); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_2, regpwr2); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_3, regpwr3); return 0; } -static int wm8985_reset(struct snd_soc_codec *codec) +static int wm8985_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, WM8985_SOFTWARE_RESET, 0x0); + return snd_soc_component_write(component, WM8985_SOFTWARE_RESET, 0x0); } static int wm8985_dac_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - return snd_soc_update_bits(codec, WM8985_DAC_CONTROL, + return snd_soc_component_update_bits(component, WM8985_DAC_CONTROL, WM8985_SOFTMUTE_MASK, !!mute << WM8985_SOFTMUTE_SHIFT); } static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u16 format, master, bcp, lrp; - codec = dai->codec; + component = dai->component; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -687,7 +687,7 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_FMT_MASK, format << WM8985_FMT_SHIFT); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -702,7 +702,7 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_MS_MASK, master << WM8985_MS_SHIFT); /* frame inversion is not valid for dsp modes */ @@ -739,9 +739,9 @@ static int wm8985_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_LRP_MASK, lrp << WM8985_LRP_SHIFT); - snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_BCP_MASK, bcp << WM8985_BCP_SHIFT); return 0; } @@ -751,14 +751,14 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int i; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8985_priv *wm8985; u16 blen, srate_idx; unsigned int tmp; int srate_best; - codec = dai->codec; - wm8985 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8985 = snd_soc_component_get_drvdata(component); wm8985->bclk = snd_soc_params_to_bclk(params); if ((int)wm8985->bclk < 0) @@ -783,7 +783,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, WM8985_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8985_AUDIO_INTERFACE, WM8985_WL_MASK, blen << WM8985_WL_SHIFT); /* @@ -800,7 +800,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, } dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); - snd_soc_update_bits(codec, WM8985_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8985_ADDITIONAL_CONTROL, WM8985_SR_MASK, srate_idx << WM8985_SR_SHIFT); dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8985->bclk); @@ -819,7 +819,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, } dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_MCLKDIV_MASK, i << WM8985_MCLKDIV_SHIFT); /* select the appropriate bclk divider */ @@ -835,7 +835,7 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, } dev_dbg(dai->dev, "BCLK div = %d\n", i); - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_BCLKDIV_MASK, i << WM8985_BCLKDIV_SHIFT); return 0; } @@ -887,13 +887,13 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id, unsigned int freq_out) { int ret; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct pll_div pll_div; - codec = dai->codec; + component = dai->component; if (!freq_in || !freq_out) { /* disable the PLL */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_PLLEN_MASK, 0); } else { ret = pll_factors(&pll_div, freq_out * 4 * 2, freq_in); @@ -901,18 +901,18 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id, return ret; /* set PLLN and PRESCALE */ - snd_soc_write(codec, WM8985_PLL_N, + snd_soc_component_write(component, WM8985_PLL_N, (pll_div.div2 << WM8985_PLL_PRESCALE_SHIFT) | pll_div.n); /* set PLLK */ - snd_soc_write(codec, WM8985_PLL_K_3, pll_div.k & 0x1ff); - snd_soc_write(codec, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8985_PLL_K_1, (pll_div.k >> 18)); + snd_soc_component_write(component, WM8985_PLL_K_3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8985_PLL_K_2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8985_PLL_K_1, (pll_div.k >> 18)); /* set the source of the clock to be the PLL */ - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_CLKSEL_MASK, WM8985_CLKSEL); /* enable the PLL */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_PLLEN_MASK, WM8985_PLLEN); } return 0; @@ -921,21 +921,21 @@ static int wm8985_set_pll(struct snd_soc_dai *dai, int pll_id, static int wm8985_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8985_priv *wm8985; - codec = dai->codec; - wm8985 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8985 = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM8985_CLKSRC_MCLK: - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_CLKSEL_MASK, 0); - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_PLLEN_MASK, 0); break; case WM8985_CLKSRC_PLL: - snd_soc_update_bits(codec, WM8985_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8985_CLOCK_GEN_CONTROL, WM8985_CLKSEL_MASK, WM8985_CLKSEL); break; default: @@ -947,27 +947,27 @@ static int wm8985_set_sysclk(struct snd_soc_dai *dai, return 0; } -static int wm8985_set_bias_level(struct snd_soc_codec *codec, +static int wm8985_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; struct wm8985_priv *wm8985; - wm8985 = snd_soc_codec_get_drvdata(codec); + wm8985 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: /* VMID at 75k */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK, 1 << WM8985_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -976,45 +976,45 @@ static int wm8985_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8985->regmap); /* enable anti-pop features */ - snd_soc_update_bits(codec, WM8985_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8985_OUT4_TO_ADC, WM8985_POBCTRL_MASK, WM8985_POBCTRL); /* enable thermal shutdown */ - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSDEN_MASK, WM8985_TSDEN); - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSOPCTRL_MASK, WM8985_TSOPCTRL); /* enable BIASEN */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_BIASEN_MASK, WM8985_BIASEN); /* VMID at 75k */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK, 1 << WM8985_VMIDSEL_SHIFT); msleep(500); /* disable anti-pop features */ - snd_soc_update_bits(codec, WM8985_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8985_OUT4_TO_ADC, WM8985_POBCTRL_MASK, 0); } /* VMID at 300k */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK, 2 << WM8985_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_OFF: /* disable thermal shutdown */ - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSOPCTRL_MASK, 0); - snd_soc_update_bits(codec, WM8985_OUTPUT_CTRL0, + snd_soc_component_update_bits(component, WM8985_OUTPUT_CTRL0, WM8985_TSDEN_MASK, 0); /* disable VMIDSEL and BIASEN */ - snd_soc_update_bits(codec, WM8985_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8985_POWER_MANAGEMENT_1, WM8985_VMIDSEL_MASK | WM8985_BIASEN_MASK, 0); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_1, 0); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8985_POWER_MANAGEMENT_3, 0); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8985_POWER_MANAGEMENT_3, 0); regcache_mark_dirty(wm8985->regmap); @@ -1026,46 +1026,46 @@ static int wm8985_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int wm8985_probe(struct snd_soc_codec *codec) +static int wm8985_probe(struct snd_soc_component *component) { size_t i; struct wm8985_priv *wm8985; int ret; - wm8985 = snd_soc_codec_get_drvdata(codec); + wm8985 = snd_soc_component_get_drvdata(component); for (i = 0; i < ARRAY_SIZE(wm8985->supplies); i++) wm8985->supplies[i].supply = wm8985_supply_names[i]; - ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8985->supplies), + ret = devm_regulator_bulk_get(component->dev, ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + dev_err(component->dev, "Failed to request supplies: %d\n", ret); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(wm8985->supplies), wm8985->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } - ret = wm8985_reset(codec); + ret = wm8985_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; } /* latch volume update bits */ for (i = 0; i < ARRAY_SIZE(volume_update_regs); ++i) - snd_soc_update_bits(codec, volume_update_regs[i], + snd_soc_component_update_bits(component, volume_update_regs[i], 0x100, 0x100); /* enable BIASCUT */ - snd_soc_update_bits(codec, WM8985_BIAS_CTRL, WM8985_BIASCUT, + snd_soc_component_update_bits(component, WM8985_BIAS_CTRL, WM8985_BIASCUT, WM8985_BIASCUT); - wm8985_add_widgets(codec); + wm8985_add_widgets(component); return 0; @@ -1105,19 +1105,20 @@ static struct snd_soc_dai_driver wm8985_dai = { .symmetric_rates = 1 }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8985 = { - .probe = wm8985_probe, - .set_bias_level = wm8985_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8985_common_snd_controls, - .num_controls = ARRAY_SIZE(wm8985_common_snd_controls), - .dapm_widgets = wm8985_common_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8985_common_dapm_widgets), - .dapm_routes = wm8985_common_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8985_common_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8985 = { + .probe = wm8985_probe, + .set_bias_level = wm8985_set_bias_level, + .controls = wm8985_common_snd_controls, + .num_controls = ARRAY_SIZE(wm8985_common_snd_controls), + .dapm_widgets = wm8985_common_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8985_common_dapm_widgets), + .dapm_routes = wm8985_common_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8985_common_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8985_regmap = { @@ -1154,23 +1155,16 @@ static int wm8985_spi_probe(struct spi_device *spi) return ret; } - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8985, &wm8985_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8985, &wm8985_dai, 1); return ret; } -static int wm8985_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8985_spi_driver = { .driver = { .name = "wm8985", }, .probe = wm8985_spi_probe, - .remove = wm8985_spi_remove }; #endif @@ -1197,17 +1191,11 @@ static int wm8985_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8985, &wm8985_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8985, &wm8985_dai, 1); return ret; } -static int wm8985_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id wm8985_i2c_id[] = { { "wm8985", WM8985 }, { "wm8758", WM8758 }, @@ -1220,7 +1208,6 @@ static struct i2c_driver wm8985_i2c_driver = { .name = "wm8985", }, .probe = wm8985_i2c_probe, - .remove = wm8985_i2c_remove, .id_table = wm8985_i2c_id }; #endif From 58a6597ea0e6f310e568c0db6224b586a5bf7c7c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:06:22 +0000 Subject: [PATCH 041/942] ASoC: wm8971: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8971.c | 108 ++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 57 deletions(-) diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 887d31cf3945..a79f7a7ab44b 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c @@ -89,7 +89,7 @@ static const struct reg_default wm8971_reg_defaults[] = { { 42, 0x0079 }, }; -#define wm8971_reset(c) snd_soc_write(c, WM8971_RESET, 0) +#define wm8971_reset(c) snd_soc_component_write(c, WM8971_RESET, 0) /* WM8971 Controls */ static const char *wm8971_bass[] = { "Linear Control", "Adaptive Boost" }; @@ -433,8 +433,8 @@ static int get_coeff(int mclk, int rate) static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); switch (freq) { case 11289600: @@ -451,7 +451,7 @@ static int wm8971_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -502,7 +502,7 @@ static int wm8971_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8971_IFACE, iface); + snd_soc_component_write(component, WM8971_IFACE, iface); return 0; } @@ -510,10 +510,10 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8971_IFACE) & 0x1f3; - u16 srate = snd_soc_read(codec, WM8971_SRATE) & 0x1c0; + struct snd_soc_component *component = dai->component; + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8971_IFACE) & 0x1f3; + u16 srate = snd_soc_component_read32(component, WM8971_SRATE) & 0x1c0; int coeff = get_coeff(wm8971->sysclk, params_rate(params)); /* bit size */ @@ -532,9 +532,9 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, } /* set iface & srate */ - snd_soc_write(codec, WM8971_IFACE, iface); + snd_soc_component_write(component, WM8971_IFACE, iface); if (coeff >= 0) - snd_soc_write(codec, WM8971_SRATE, srate | + snd_soc_component_write(component, WM8971_SRATE, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); return 0; @@ -542,13 +542,13 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, static int wm8971_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8971_ADCDAC) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8971_ADCDAC) & 0xfff7; if (mute) - snd_soc_write(codec, WM8971_ADCDAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8971_ADCDAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8971_ADCDAC, mute_reg); + snd_soc_component_write(component, WM8971_ADCDAC, mute_reg); return 0; } @@ -561,37 +561,37 @@ static void wm8971_charge_work(struct work_struct *work) regmap_update_bits(wm8971->regmap, WM8971_PWR1, 0x0180, 0x0100); } -static int wm8971_set_bias_level(struct snd_soc_codec *codec, +static int wm8971_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); - u16 pwr_reg = snd_soc_read(codec, WM8971_PWR1) & 0xfe3e; + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); + u16 pwr_reg = snd_soc_component_read32(component, WM8971_PWR1) & 0xfe3e; switch (level) { case SND_SOC_BIAS_ON: /* set vmid to 50k and unmute dac */ - snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x00c1); + snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x00c1); break; case SND_SOC_BIAS_PREPARE: /* Wait until fully charged */ flush_delayed_work(&wm8971->charge_work); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_cache_sync(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_cache_sync(component); /* charge output caps - set vmid to 5k for quick power up */ - snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x01c0); + snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x01c0); queue_delayed_work(system_power_efficient_wq, &wm8971->charge_work, msecs_to_jiffies(1000)); } else { /* mute dac and set vmid to 500k, enable VREF */ - snd_soc_write(codec, WM8971_PWR1, pwr_reg | 0x0140); + snd_soc_component_write(component, WM8971_PWR1, pwr_reg | 0x0140); } break; case SND_SOC_BIAS_OFF: cancel_delayed_work_sync(&wm8971->charge_work); - snd_soc_write(codec, WM8971_PWR1, 0x0001); + snd_soc_component_write(component, WM8971_PWR1, 0x0001); break; } return 0; @@ -628,40 +628,41 @@ static struct snd_soc_dai_driver wm8971_dai = { .ops = &wm8971_dai_ops, }; -static int wm8971_probe(struct snd_soc_codec *codec) +static int wm8971_probe(struct snd_soc_component *component) { - struct wm8971_priv *wm8971 = snd_soc_codec_get_drvdata(codec); + struct wm8971_priv *wm8971 = snd_soc_component_get_drvdata(component); INIT_DELAYED_WORK(&wm8971->charge_work, wm8971_charge_work); - wm8971_reset(codec); + wm8971_reset(component); /* set the update bits */ - snd_soc_update_bits(codec, WM8971_LDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_LOUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_LOUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_LINVOL, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8971_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LOUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LOUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_LINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8971_RINVOL, 0x0100, 0x0100); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8971 = { - .probe = wm8971_probe, - .set_bias_level = wm8971_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8971_snd_controls, - .num_controls = ARRAY_SIZE(wm8971_snd_controls), - .dapm_widgets = wm8971_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), - .dapm_routes = wm8971_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8971 = { + .probe = wm8971_probe, + .set_bias_level = wm8971_set_bias_level, + .controls = wm8971_snd_controls, + .num_controls = ARRAY_SIZE(wm8971_snd_controls), + .dapm_widgets = wm8971_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8971_dapm_widgets), + .dapm_routes = wm8971_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8971_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8971_regmap = { @@ -691,18 +692,12 @@ static int wm8971_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8971); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8971, &wm8971_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8971, &wm8971_dai, 1); return ret; } -static int wm8971_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8971_i2c_id[] = { { "wm8971", 0 }, { } @@ -714,7 +709,6 @@ static struct i2c_driver wm8971_i2c_driver = { .name = "wm8971", }, .probe = wm8971_i2c_probe, - .remove = wm8971_i2c_remove, .id_table = wm8971_i2c_id, }; From 98020a71c2c135b7c24e8fa8c2b3e947fe465909 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:06:37 +0000 Subject: [PATCH 042/942] ASoC: wm8978: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8978.c | 185 ++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 96 deletions(-) diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index cf761e2d7546..bae4fe89dbf1 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c @@ -408,7 +408,7 @@ struct wm8978_pll_div { #define FIXED_PLL_SIZE (1 << 24) -static void pll_factors(struct snd_soc_codec *codec, +static void pll_factors(struct snd_soc_component *component, struct wm8978_pll_div *pll_div, unsigned int target, unsigned int source) { u64 k_part; @@ -424,7 +424,7 @@ static void pll_factors(struct snd_soc_codec *codec, } if (n_div < 6 || n_div > 12) - dev_warn(codec->dev, + dev_warn(component->dev, "WM8978 N value exceeds recommended range! N = %u\n", n_div); @@ -471,9 +471,9 @@ static int wm8978_enum_mclk(unsigned int f_out, unsigned int f_mclk, * Calculate internal frequencies and dividers, according to Figure 40 * "PLL and Clock Select Circuit" in WM8978 datasheet Rev. 2.6 */ -static int wm8978_configure_pll(struct snd_soc_codec *codec) +static int wm8978_configure_pll(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); struct wm8978_pll_div pll_div; unsigned int f_opclk = wm8978->f_opclk, f_mclk = wm8978->f_mclk, f_256fs = wm8978->f_256fs; @@ -505,9 +505,9 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) else opclk_div = 1; - dev_dbg(codec->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div); + dev_dbg(component->dev, "%s: OPCLKDIV=%d\n", __func__, opclk_div); - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 0x30, + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 0x30, (opclk_div - 1) << 4); wm8978->f_pllout = f_opclk * opclk_div; @@ -533,28 +533,28 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) f2 = wm8978->f_pllout * 4; - dev_dbg(codec->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, + dev_dbg(component->dev, "%s: f_MCLK=%uHz, f_PLLOUT=%uHz\n", __func__, wm8978->f_mclk, wm8978->f_pllout); - pll_factors(codec, &pll_div, f2, wm8978->f_mclk); + pll_factors(component, &pll_div, f2, wm8978->f_mclk); - dev_dbg(codec->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", + dev_dbg(component->dev, "%s: calculated PLL N=0x%x, K=0x%x, div2=%d\n", __func__, pll_div.n, pll_div.k, pll_div.div2); /* Turn PLL off for configuration... */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0); - snd_soc_write(codec, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); - snd_soc_write(codec, WM8978_PLL_K1, pll_div.k >> 18); - snd_soc_write(codec, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8978_PLL_K3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8978_PLL_N, (pll_div.div2 << 4) | pll_div.n); + snd_soc_component_write(component, WM8978_PLL_K1, pll_div.k >> 18); + snd_soc_component_write(component, WM8978_PLL_K2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8978_PLL_K3, pll_div.k & 0x1ff); /* ...and on again */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); if (f_opclk) /* Output PLL (OPCLK) to GPIO1 */ - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 4); + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 4); return 0; } @@ -565,8 +565,8 @@ static int wm8978_configure_pll(struct snd_soc_codec *codec) static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int ret = 0; switch (div_id) { @@ -588,18 +588,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, * find an exact MCLK divider configuration - it will * be equal to or double the OPCLK divisor. */ - ret = wm8978_configure_pll(codec); + ret = wm8978_configure_pll(component); break; case WM8978_BCLKDIV: if (div & ~0x1c) return -EINVAL; - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x1c, div); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x1c, div); break; default: return -EINVAL; } - dev_dbg(codec->dev, "%s: ID %d, value %u\n", __func__, div_id, div); + dev_dbg(component->dev, "%s: ID %d, value %u\n", __func__, div_id, div); return ret; } @@ -610,18 +610,18 @@ static int wm8978_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int ret = 0; - dev_dbg(codec->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq); + dev_dbg(component->dev, "%s: ID %d, freq %u\n", __func__, clk_id, freq); if (freq) { wm8978->f_mclk = freq; /* Even if MCLK is used for system clock, might have to drive OPCLK */ if (wm8978->f_opclk) - ret = wm8978_configure_pll(codec); + ret = wm8978_configure_pll(component); /* Our sysclk is fixed to 256 * fs, will configure in .hw_params() */ @@ -631,13 +631,13 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, if (wm8978->sysclk == WM8978_PLL && (!freq || clk_id == WM8978_MCLK)) { /* Clock CODEC directly from MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0); /* GPIO1 into default mode as input - before configuring PLL */ - snd_soc_update_bits(codec, WM8978_GPIO_CONTROL, 7, 0); + snd_soc_component_update_bits(component, WM8978_GPIO_CONTROL, 7, 0); /* Turn off PLL */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0); wm8978->sysclk = WM8978_MCLK; wm8978->f_pllout = 0; wm8978->f_opclk = 0; @@ -651,15 +651,15 @@ static int wm8978_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, */ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; /* * BCLK polarity mask = 0x100, LRC clock polarity mask = 0x80, * Data Format mask = 0x18: all will be calculated anew */ - u16 iface = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x198; - u16 clk = snd_soc_read(codec, WM8978_CLOCKING); + u16 iface = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x198; + u16 clk = snd_soc_component_read32(component, WM8978_CLOCKING); - dev_dbg(codec->dev, "%s\n", __func__); + dev_dbg(component->dev, "%s\n", __func__); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -707,8 +707,8 @@ static int wm8978_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface); - snd_soc_write(codec, WM8978_CLOCKING, clk); + snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface); + snd_soc_component_write(component, WM8978_CLOCKING, clk); return 0; } @@ -720,13 +720,13 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); /* Word length mask = 0x60 */ - u16 iface_ctl = snd_soc_read(codec, WM8978_AUDIO_INTERFACE) & ~0x60; + u16 iface_ctl = snd_soc_component_read32(component, WM8978_AUDIO_INTERFACE) & ~0x60; /* Sampling rate mask = 0xe (for filters) */ - u16 add_ctl = snd_soc_read(codec, WM8978_ADDITIONAL_CONTROL) & ~0xe; - u16 clking = snd_soc_read(codec, WM8978_CLOCKING); + u16 add_ctl = snd_soc_component_read32(component, WM8978_ADDITIONAL_CONTROL) & ~0xe; + u16 clking = snd_soc_component_read32(component, WM8978_CLOCKING); enum wm8978_sysclk_src current_clk_id = clking & 0x100 ? WM8978_PLL : WM8978_MCLK; unsigned int f_sel, diff, diff_best = INT_MAX; @@ -781,7 +781,7 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, } else { if (!wm8978->f_opclk) { /* We only enter here, if OPCLK is not used */ - int ret = wm8978_configure_pll(codec); + int ret = wm8978_configure_pll(component); if (ret < 0) return ret; } @@ -812,28 +812,28 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, } if (diff) - dev_warn(codec->dev, "Imprecise sampling rate: %uHz%s\n", + dev_warn(component->dev, "Imprecise sampling rate: %uHz%s\n", f_sel * mclk_denominator[best] / mclk_numerator[best] / 256, wm8978->sysclk == WM8978_MCLK ? ", consider using PLL" : ""); - dev_dbg(codec->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, + dev_dbg(component->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, params_width(params), params_rate(params), best); /* MCLK divisor mask = 0xe0 */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0xe0, best << 5); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0xe0, best << 5); - snd_soc_write(codec, WM8978_AUDIO_INTERFACE, iface_ctl); - snd_soc_write(codec, WM8978_ADDITIONAL_CONTROL, add_ctl); + snd_soc_component_write(component, WM8978_AUDIO_INTERFACE, iface_ctl); + snd_soc_component_write(component, WM8978_ADDITIONAL_CONTROL, add_ctl); if (wm8978->sysclk != current_clk_id) { if (wm8978->sysclk == WM8978_PLL) /* Run CODEC from PLL instead of MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0x100); else /* Clock CODEC directly from MCLK */ - snd_soc_update_bits(codec, WM8978_CLOCKING, 0x100, 0); + snd_soc_component_update_bits(component, WM8978_CLOCKING, 0x100, 0); } return 0; @@ -841,52 +841,52 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, static int wm8978_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s: %d\n", __func__, mute); + dev_dbg(component->dev, "%s: %d\n", __func__, mute); if (mute) - snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0x40); + snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0x40); else - snd_soc_update_bits(codec, WM8978_DAC_CONTROL, 0x40, 0); + snd_soc_component_update_bits(component, WM8978_DAC_CONTROL, 0x40, 0); return 0; } -static int wm8978_set_bias_level(struct snd_soc_codec *codec, +static int wm8978_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 power1 = snd_soc_read(codec, WM8978_POWER_MANAGEMENT_1) & ~3; + u16 power1 = snd_soc_component_read32(component, WM8978_POWER_MANAGEMENT_1) & ~3; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 1; /* VMID 75k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1); break; case SND_SOC_BIAS_STANDBY: /* bit 3: enable bias, bit 2: enable I/O tie off buffer */ power1 |= 0xc; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1 | 0x3); mdelay(100); } power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, power1); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, power1); break; case SND_SOC_BIAS_OFF: /* Preserve PLL - OPCLK may be used by someone */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_3, 0); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, ~0x20, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_3, 0); break; } - dev_dbg(codec->dev, "%s: %d, %x\n", __func__, level, power1); + dev_dbg(component->dev, "%s: %d, %x\n", __func__, level, power1); return 0; } @@ -923,31 +923,31 @@ static struct snd_soc_dai_driver wm8978_dai = { .symmetric_rates = 1, }; -static int wm8978_suspend(struct snd_soc_codec *codec) +static int wm8978_suspend(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); /* Also switch PLL off */ - snd_soc_write(codec, WM8978_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8978_POWER_MANAGEMENT_1, 0); regcache_mark_dirty(wm8978->regmap); return 0; } -static int wm8978_resume(struct snd_soc_codec *codec) +static int wm8978_resume(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); /* Sync reg_cache with the hardware */ regcache_sync(wm8978->regmap); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); if (wm8978->f_pllout) /* Switch PLL on */ - snd_soc_update_bits(codec, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); + snd_soc_component_update_bits(component, WM8978_POWER_MANAGEMENT_1, 0x20, 0x20); return 0; } @@ -971,9 +971,9 @@ static const int update_reg[] = { WM8978_ROUT2_SPK_CONTROL, }; -static int wm8978_probe(struct snd_soc_codec *codec) +static int wm8978_probe(struct snd_soc_component *component) { - struct wm8978_priv *wm8978 = snd_soc_codec_get_drvdata(codec); + struct wm8978_priv *wm8978 = snd_soc_component_get_drvdata(component); int i; /* @@ -988,25 +988,26 @@ static int wm8978_probe(struct snd_soc_codec *codec) * written. */ for (i = 0; i < ARRAY_SIZE(update_reg); i++) - snd_soc_update_bits(codec, update_reg[i], 0x100, 0x100); + snd_soc_component_update_bits(component, update_reg[i], 0x100, 0x100); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8978 = { - .probe = wm8978_probe, - .suspend = wm8978_suspend, - .resume = wm8978_resume, - .set_bias_level = wm8978_set_bias_level, - - .component_driver = { - .controls = wm8978_snd_controls, - .num_controls = ARRAY_SIZE(wm8978_snd_controls), - .dapm_widgets = wm8978_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), - .dapm_routes = wm8978_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8978 = { + .probe = wm8978_probe, + .suspend = wm8978_suspend, + .resume = wm8978_resume, + .set_bias_level = wm8978_set_bias_level, + .controls = wm8978_snd_controls, + .num_controls = ARRAY_SIZE(wm8978_snd_controls), + .dapm_widgets = wm8978_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8978_dapm_widgets), + .dapm_routes = wm8978_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8978_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8978_regmap_config = { @@ -1048,8 +1049,8 @@ static int wm8978_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8978, &wm8978_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8978, &wm8978_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -1058,13 +1059,6 @@ static int wm8978_i2c_probe(struct i2c_client *i2c, return 0; } -static int wm8978_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8978_i2c_id[] = { { "wm8978", 0 }, { } @@ -1083,7 +1077,6 @@ static struct i2c_driver wm8978_i2c_driver = { .of_match_table = wm8978_of_match, }, .probe = wm8978_i2c_probe, - .remove = wm8978_i2c_remove, .id_table = wm8978_i2c_id, }; From 3e32a3ff800b71c84796a89479a6ea89eee0803e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:06:52 +0000 Subject: [PATCH 043/942] ASoC: wm8974: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8974.c | 143 ++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 75 deletions(-) diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index d414ddd6e197..43edaf8cd276 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c @@ -54,7 +54,7 @@ static const struct reg_default wm8974_reg_defaults[] = { #define WM8974_POWER1_BIASEN 0x08 #define WM8974_POWER1_BUFIOEN 0x04 -#define wm8974_reset(c) snd_soc_write(c, WM8974_RESET, 0) +#define wm8974_reset(c) snd_soc_component_write(c, WM8974_RESET, 0) static const char *wm8974_companding[] = {"Off", "NC", "u-law", "A-law" }; static const char *wm8974_deemp[] = {"None", "32kHz", "44.1kHz", "48kHz" }; @@ -324,33 +324,33 @@ static void pll_factors(struct pll_ *pll_div, static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct pll_ pll_div; u16 reg; if (freq_in == 0 || freq_out == 0) { /* Clock CODEC directly from MCLK */ - reg = snd_soc_read(codec, WM8974_CLOCK); - snd_soc_write(codec, WM8974_CLOCK, reg & 0x0ff); + reg = snd_soc_component_read32(component, WM8974_CLOCK); + snd_soc_component_write(component, WM8974_CLOCK, reg & 0x0ff); /* Turn off PLL */ - reg = snd_soc_read(codec, WM8974_POWER1); - snd_soc_write(codec, WM8974_POWER1, reg & 0x1df); + reg = snd_soc_component_read32(component, WM8974_POWER1); + snd_soc_component_write(component, WM8974_POWER1, reg & 0x1df); return 0; } pll_factors(&pll_div, freq_out, freq_in); - snd_soc_write(codec, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); - snd_soc_write(codec, WM8974_PLLK1, pll_div.k >> 18); - snd_soc_write(codec, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8974_PLLK3, pll_div.k & 0x1ff); - reg = snd_soc_read(codec, WM8974_POWER1); - snd_soc_write(codec, WM8974_POWER1, reg | 0x020); + snd_soc_component_write(component, WM8974_PLLN, (pll_div.pre_div << 4) | pll_div.n); + snd_soc_component_write(component, WM8974_PLLK1, pll_div.k >> 18); + snd_soc_component_write(component, WM8974_PLLK2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8974_PLLK3, pll_div.k & 0x1ff); + reg = snd_soc_component_read32(component, WM8974_POWER1); + snd_soc_component_write(component, WM8974_POWER1, reg | 0x020); /* Run CODEC from PLL instead of MCLK */ - reg = snd_soc_read(codec, WM8974_CLOCK); - snd_soc_write(codec, WM8974_CLOCK, reg | 0x100); + reg = snd_soc_component_read32(component, WM8974_CLOCK); + snd_soc_component_write(component, WM8974_CLOCK, reg | 0x100); return 0; } @@ -361,21 +361,21 @@ static int wm8974_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8974_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; switch (div_id) { case WM8974_OPCLKDIV: - reg = snd_soc_read(codec, WM8974_GPIO) & 0x1cf; - snd_soc_write(codec, WM8974_GPIO, reg | div); + reg = snd_soc_component_read32(component, WM8974_GPIO) & 0x1cf; + snd_soc_component_write(component, WM8974_GPIO, reg | div); break; case WM8974_MCLKDIV: - reg = snd_soc_read(codec, WM8974_CLOCK) & 0x11f; - snd_soc_write(codec, WM8974_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x11f; + snd_soc_component_write(component, WM8974_CLOCK, reg | div); break; case WM8974_BCLKDIV: - reg = snd_soc_read(codec, WM8974_CLOCK) & 0x1e3; - snd_soc_write(codec, WM8974_CLOCK, reg | div); + reg = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1e3; + snd_soc_component_write(component, WM8974_CLOCK, reg | div); break; default: return -EINVAL; @@ -418,8 +418,8 @@ static unsigned int wm8974_get_mclkdiv(unsigned int f_in, unsigned int f_out, static int wm8974_update_clocks(struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); unsigned int fs256; unsigned int fpll = 0; unsigned int f; @@ -446,8 +446,8 @@ static int wm8974_update_clocks(struct snd_soc_dai *dai) static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); if (dir != SND_SOC_CLOCK_IN) return -EINVAL; @@ -460,9 +460,9 @@ static int wm8974_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; - u16 clk = snd_soc_read(codec, WM8974_CLOCK) & 0x1fe; + u16 clk = snd_soc_component_read32(component, WM8974_CLOCK) & 0x1fe; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -509,8 +509,8 @@ static int wm8974_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8974_IFACE, iface); - snd_soc_write(codec, WM8974_CLOCK, clk); + snd_soc_component_write(component, WM8974_IFACE, iface); + snd_soc_component_write(component, WM8974_CLOCK, clk); return 0; } @@ -518,10 +518,10 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8974_priv *priv = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8974_IFACE) & 0x19f; - u16 adn = snd_soc_read(codec, WM8974_ADD) & 0x1f1; + struct snd_soc_component *component = dai->component; + struct wm8974_priv *priv = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8974_IFACE) & 0x19f; + u16 adn = snd_soc_component_read32(component, WM8974_ADD) & 0x1f1; int err; priv->fs = params_rate(params); @@ -566,55 +566,55 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8974_IFACE, iface); - snd_soc_write(codec, WM8974_ADD, adn); + snd_soc_component_write(component, WM8974_IFACE, iface); + snd_soc_component_write(component, WM8974_ADD, adn); return 0; } static int wm8974_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8974_DAC) & 0xffbf; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8974_DAC) & 0xffbf; if (mute) - snd_soc_write(codec, WM8974_DAC, mute_reg | 0x40); + snd_soc_component_write(component, WM8974_DAC, mute_reg | 0x40); else - snd_soc_write(codec, WM8974_DAC, mute_reg); + snd_soc_component_write(component, WM8974_DAC, mute_reg); return 0; } /* liam need to make this lower power with dapm */ -static int wm8974_set_bias_level(struct snd_soc_codec *codec, +static int wm8974_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 power1 = snd_soc_read(codec, WM8974_POWER1) & ~0x3; + u16 power1 = snd_soc_component_read32(component, WM8974_POWER1) & ~0x3; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: power1 |= 0x1; /* VMID 50k */ - snd_soc_write(codec, WM8974_POWER1, power1); + snd_soc_component_write(component, WM8974_POWER1, power1); break; case SND_SOC_BIAS_STANDBY: power1 |= WM8974_POWER1_BIASEN | WM8974_POWER1_BUFIOEN; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - regcache_sync(dev_get_regmap(codec->dev, NULL)); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + regcache_sync(dev_get_regmap(component->dev, NULL)); /* Initial cap charge at VMID 5k */ - snd_soc_write(codec, WM8974_POWER1, power1 | 0x3); + snd_soc_component_write(component, WM8974_POWER1, power1 | 0x3); mdelay(100); } power1 |= 0x2; /* VMID 500k */ - snd_soc_write(codec, WM8974_POWER1, power1); + snd_soc_component_write(component, WM8974_POWER1, power1); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8974_POWER1, 0); - snd_soc_write(codec, WM8974_POWER2, 0); - snd_soc_write(codec, WM8974_POWER3, 0); + snd_soc_component_write(component, WM8974_POWER1, 0); + snd_soc_component_write(component, WM8974_POWER2, 0); + snd_soc_component_write(component, WM8974_POWER3, 0); break; } @@ -663,32 +663,33 @@ static const struct regmap_config wm8974_regmap = { .cache_type = REGCACHE_FLAT, }; -static int wm8974_probe(struct snd_soc_codec *codec) +static int wm8974_probe(struct snd_soc_component *component) { int ret = 0; - ret = wm8974_reset(codec); + ret = wm8974_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; } return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8974 = { - .probe = wm8974_probe, - .set_bias_level = wm8974_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8974_snd_controls, - .num_controls = ARRAY_SIZE(wm8974_snd_controls), - .dapm_widgets = wm8974_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), - .dapm_routes = wm8974_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8974 = { + .probe = wm8974_probe, + .set_bias_level = wm8974_set_bias_level, + .controls = wm8974_snd_controls, + .num_controls = ARRAY_SIZE(wm8974_snd_controls), + .dapm_widgets = wm8974_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8974_dapm_widgets), + .dapm_routes = wm8974_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8974_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8974_i2c_probe(struct i2c_client *i2c, @@ -708,19 +709,12 @@ static int wm8974_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8974, &wm8974_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8974, &wm8974_dai, 1); return ret; } -static int wm8974_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8974_i2c_id[] = { { "wm8974", 0 }, { } @@ -739,7 +733,6 @@ static struct i2c_driver wm8974_i2c_driver = { .of_match_table = wm8974_of_match, }, .probe = wm8974_i2c_probe, - .remove = wm8974_i2c_remove, .id_table = wm8974_i2c_id, }; From 51bef5c65b293152e4a189e0d3d6805ae5db9965 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:07:09 +0000 Subject: [PATCH 044/942] ASoC: wm8990: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8990.c | 179 ++++++++++++++++++-------------------- 1 file changed, 86 insertions(+), 93 deletions(-) diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index a8945001e696..411b9eee88c2 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c @@ -111,7 +111,7 @@ static const struct reg_default wm8990_reg_defaults[] = { { 62, 0x0026 }, /* R62 - PLL3 */ }; -#define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0) +#define wm8990_reset(c) snd_soc_component_write(c, WM8990_RESET, 0) static const DECLARE_TLV_DB_SCALE(rec_mix_tlv, -1500, 600, 0); @@ -132,7 +132,7 @@ static const DECLARE_TLV_DB_SCALE(out_sidetone_tlv, -3600, 0, 0); static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; int reg = mc->reg; @@ -144,8 +144,8 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, return ret; /* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - return snd_soc_write(codec, reg, val | 0x0100); + val = snd_soc_component_read32(component, reg); + return snd_soc_component_write(component, reg, val | 0x0100); } #define SOC_WM899X_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert,\ @@ -374,14 +374,14 @@ SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME, static int outmixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u32 reg_shift = kcontrol->private_value & 0xfff; int ret = 0; u16 reg; switch (reg_shift) { case WM8990_SPEAKER_MIXER | (WM8990_LDSPK_BIT << 8) : - reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8990_OUTPUT_MIXER1); if (reg & WM8990_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -389,7 +389,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_SPEAKER_MIXER | (WM8990_RDSPK_BIT << 8): - reg = snd_soc_read(codec, WM8990_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8990_OUTPUT_MIXER2); if (reg & WM8990_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -397,7 +397,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_OUTPUT_MIXER1 | (WM8990_LDLO_BIT << 8): - reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8990_SPEAKER_MIXER); if (reg & WM8990_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -405,7 +405,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, } break; case WM8990_OUTPUT_MIXER2 | (WM8990_RDRO_BIT << 8): - reg = snd_soc_read(codec, WM8990_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8990_SPEAKER_MIXER); if (reg & WM8990_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); @@ -934,28 +934,28 @@ static void pll_factors(struct _pll_div *pll_div, unsigned int target, static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct _pll_div pll_div; if (freq_in && freq_out) { pll_factors(&pll_div, freq_out * 4, freq_in); /* Turn on PLL */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_2, WM8990_PLL_ENA, WM8990_PLL_ENA); /* sysclk comes from PLL */ - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_SYSCLK_SRC, WM8990_SYSCLK_SRC); /* set up N , fractional mode and pre-divisor if necessary */ - snd_soc_write(codec, WM8990_PLL1, pll_div.n | WM8990_SDM | + snd_soc_component_write(component, WM8990_PLL1, pll_div.n | WM8990_SDM | (pll_div.div2?WM8990_PRESCALE:0)); - snd_soc_write(codec, WM8990_PLL2, (u8)(pll_div.k>>8)); - snd_soc_write(codec, WM8990_PLL3, (u8)(pll_div.k & 0xFF)); + snd_soc_component_write(component, WM8990_PLL2, (u8)(pll_div.k>>8)); + snd_soc_component_write(component, WM8990_PLL3, (u8)(pll_div.k & 0xFF)); } else { /* Turn off PLL */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_2, WM8990_PLL_ENA, 0); } return 0; @@ -967,8 +967,8 @@ static int wm8990_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8990_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8990_priv *wm8990 = snd_soc_component_get_drvdata(component); wm8990->sysclk = freq; return 0; @@ -980,11 +980,11 @@ static int wm8990_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8990_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 audio1, audio3; - audio1 = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_1); - audio3 = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_3); + audio1 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_1); + audio3 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_3); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1025,31 +1025,31 @@ static int wm8990_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8990_AUDIO_INTERFACE_1, audio1); - snd_soc_write(codec, WM8990_AUDIO_INTERFACE_3, audio3); + snd_soc_component_write(component, WM8990_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8990_AUDIO_INTERFACE_3, audio3); return 0; } static int wm8990_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; switch (div_id) { case WM8990_MCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_MCLK_DIV_MASK, div); break; case WM8990_DACCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_DAC_CLKDIV_MASK, div); break; case WM8990_ADCCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_2, + snd_soc_component_update_bits(component, WM8990_CLOCKING_2, WM8990_ADC_CLKDIV_MASK, div); break; case WM8990_BCLK_DIV: - snd_soc_update_bits(codec, WM8990_CLOCKING_1, + snd_soc_component_update_bits(component, WM8990_CLOCKING_1, WM8990_BCLK_DIV_MASK, div); break; default: @@ -1066,8 +1066,8 @@ static int wm8990_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 audio1 = snd_soc_read(codec, WM8990_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + u16 audio1 = snd_soc_component_read32(component, WM8990_AUDIO_INTERFACE_1); audio1 &= ~WM8990_AIF_WL_MASK; /* bit size */ @@ -1085,29 +1085,29 @@ static int wm8990_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8990_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8990_AUDIO_INTERFACE_1, audio1); return 0; } static int wm8990_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 val; - val = snd_soc_read(codec, WM8990_DAC_CTRL) & ~WM8990_DAC_MUTE; + val = snd_soc_component_read32(component, WM8990_DAC_CTRL) & ~WM8990_DAC_MUTE; if (mute) - snd_soc_write(codec, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE); + snd_soc_component_write(component, WM8990_DAC_CTRL, val | WM8990_DAC_MUTE); else - snd_soc_write(codec, WM8990_DAC_CTRL, val); + snd_soc_component_write(component, WM8990_DAC_CTRL, val); return 0; } -static int wm8990_set_bias_level(struct snd_soc_codec *codec, +static int wm8990_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8990_priv *wm8990 = snd_soc_codec_get_drvdata(codec); + struct wm8990_priv *wm8990 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1116,26 +1116,26 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID=2*50k */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_1, WM8990_VMID_MODE_MASK, 0x2); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8990->regmap); if (ret < 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } /* Enable all output discharge bits */ - snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | + snd_soc_component_write(component, WM8990_ANTIPOP1, WM8990_DIS_LLINE | WM8990_DIS_RLINE | WM8990_DIS_OUT3 | WM8990_DIS_OUT4 | WM8990_DIS_LOUT | WM8990_DIS_ROUT); /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL | WM8990_VMIDTOG); @@ -1143,82 +1143,82 @@ static int wm8990_set_bias_level(struct snd_soc_codec *codec, msleep(300); /* Disable VMIDTOG */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL); /* disable all output discharge bits */ - snd_soc_write(codec, WM8990_ANTIPOP1, 0); + snd_soc_component_write(component, WM8990_ANTIPOP1, 0); /* Enable outputs */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1b00); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1b00); msleep(50); /* Enable VMID at 2x50k */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f02); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f02); msleep(100); /* Enable VREF */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f03); msleep(600); /* Enable BUFIOEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL | WM8990_BUFIOEN); /* Disable outputs */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x3); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x3); /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_BUFIOEN); + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_BUFIOEN); /* Enable workaround for ADC clocking issue. */ - snd_soc_write(codec, WM8990_EXT_ACCESS_ENA, 0x2); - snd_soc_write(codec, WM8990_EXT_CTL1, 0xa003); - snd_soc_write(codec, WM8990_EXT_ACCESS_ENA, 0); + snd_soc_component_write(component, WM8990_EXT_ACCESS_ENA, 0x2); + snd_soc_component_write(component, WM8990_EXT_CTL1, 0xa003); + snd_soc_component_write(component, WM8990_EXT_ACCESS_ENA, 0); } /* VMID=2*250k */ - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_1, WM8990_VMID_MODE_MASK, 0x4); break; case SND_SOC_BIAS_OFF: /* Enable POBCTRL and SOFT_ST */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_POBCTRL | WM8990_BUFIOEN); /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, WM8990_SOFTST | + snd_soc_component_write(component, WM8990_ANTIPOP2, WM8990_SOFTST | WM8990_BUFDCOPEN | WM8990_POBCTRL | WM8990_BUFIOEN); /* mute DAC */ - snd_soc_update_bits(codec, WM8990_DAC_CTRL, + snd_soc_component_update_bits(component, WM8990_DAC_CTRL, WM8990_DAC_MUTE, WM8990_DAC_MUTE); /* Enable any disabled outputs */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f03); /* Disable VMID */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x1f01); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x1f01); msleep(300); /* Enable all output discharge bits */ - snd_soc_write(codec, WM8990_ANTIPOP1, WM8990_DIS_LLINE | + snd_soc_component_write(component, WM8990_ANTIPOP1, WM8990_DIS_LLINE | WM8990_DIS_RLINE | WM8990_DIS_OUT3 | WM8990_DIS_OUT4 | WM8990_DIS_LOUT | WM8990_DIS_ROUT); /* Disable VREF */ - snd_soc_write(codec, WM8990_POWER_MANAGEMENT_1, 0x0); + snd_soc_component_write(component, WM8990_POWER_MANAGEMENT_1, 0x0); /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8990_ANTIPOP2, 0x0); + snd_soc_component_write(component, WM8990_ANTIPOP2, 0x0); regcache_mark_dirty(wm8990->regmap); break; @@ -1272,41 +1272,42 @@ static struct snd_soc_dai_driver wm8990_dai = { * initialise the WM8990 driver * register the mixer and dsp interfaces with the kernel */ -static int wm8990_probe(struct snd_soc_codec *codec) +static int wm8990_probe(struct snd_soc_component *component) { - wm8990_reset(codec); + wm8990_reset(component); /* charge output caps */ - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); - snd_soc_update_bits(codec, WM8990_AUDIO_INTERFACE_4, + snd_soc_component_update_bits(component, WM8990_AUDIO_INTERFACE_4, WM8990_ALRCGPIO1, WM8990_ALRCGPIO1); - snd_soc_update_bits(codec, WM8990_GPIO1_GPIO2, + snd_soc_component_update_bits(component, WM8990_GPIO1_GPIO2, WM8990_GPIO1_SEL_MASK, 1); - snd_soc_update_bits(codec, WM8990_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8990_POWER_MANAGEMENT_2, WM8990_OPCLK_ENA, WM8990_OPCLK_ENA); - snd_soc_write(codec, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); - snd_soc_write(codec, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8990_LEFT_OUTPUT_VOLUME, 0x50 | (1<<8)); + snd_soc_component_write(component, WM8990_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8990 = { - .probe = wm8990_probe, - .set_bias_level = wm8990_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8990_snd_controls, - .num_controls = ARRAY_SIZE(wm8990_snd_controls), - .dapm_widgets = wm8990_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8990_dapm_widgets), - .dapm_routes = wm8990_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8990 = { + .probe = wm8990_probe, + .set_bias_level = wm8990_set_bias_level, + .controls = wm8990_snd_controls, + .num_controls = ARRAY_SIZE(wm8990_snd_controls), + .dapm_widgets = wm8990_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8990_dapm_widgets), + .dapm_routes = wm8990_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8990_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8990_regmap = { @@ -1333,19 +1334,12 @@ static int wm8990_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8990); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8990, &wm8990_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8990, &wm8990_dai, 1); return ret; } -static int wm8990_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8990_i2c_id[] = { { "wm8990", 0 }, { } @@ -1357,7 +1351,6 @@ static struct i2c_driver wm8990_i2c_driver = { .name = "wm8990", }, .probe = wm8990_i2c_probe, - .remove = wm8990_i2c_remove, .id_table = wm8990_i2c_id, }; From ab38ff38bc77330c009f918680501b9dc37a9b3e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:07:26 +0000 Subject: [PATCH 045/942] ASoC: wm8988: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8988.c | 127 +++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 70 deletions(-) diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index b0d0219532f2..62200117444b 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c @@ -119,7 +119,7 @@ struct wm8988_priv { const struct snd_pcm_hw_constraint_list *sysclk_constraints; }; -#define wm8988_reset(c) snd_soc_write(c, WM8988_RESET, 0) +#define wm8988_reset(c) snd_soc_component_write(c, WM8988_RESET, 0) /* * WM8988 Controls @@ -244,16 +244,16 @@ SOC_DOUBLE_R_TLV("Output 2 Playback Volume", WM8988_LOUT2V, WM8988_ROUT2V, static int wm8988_lrc_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 adctl2 = snd_soc_read(codec, WM8988_ADCTL2); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 adctl2 = snd_soc_component_read32(component, WM8988_ADCTL2); /* Use the DAC to gate LRC if active, otherwise use ADC */ - if (snd_soc_read(codec, WM8988_PWR2) & 0x180) + if (snd_soc_component_read32(component, WM8988_PWR2) & 0x180) adctl2 &= ~0x4; else adctl2 |= 0x4; - return snd_soc_write(codec, WM8988_ADCTL2, adctl2); + return snd_soc_component_write(component, WM8988_ADCTL2, adctl2); } static const char *wm8988_line_texts[] = { @@ -555,8 +555,8 @@ static const struct snd_pcm_hw_constraint_list constraints_12 = { static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); switch (freq) { case 11289600: @@ -587,7 +587,7 @@ static int wm8988_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -638,21 +638,21 @@ static int wm8988_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8988_IFACE, iface); + snd_soc_component_write(component, WM8988_IFACE, iface); return 0; } static int wm8988_pcm_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); /* The set of sample rates that can be supported depends on the * MCLK supplied to the CODEC - enforce this. */ if (!wm8988->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "No MCLK configured, call set_sysclk() on init\n"); return -EINVAL; } @@ -668,10 +668,10 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); - u16 iface = snd_soc_read(codec, WM8988_IFACE) & 0x1f3; - u16 srate = snd_soc_read(codec, WM8988_SRATE) & 0x180; + struct snd_soc_component *component = dai->component; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); + u16 iface = snd_soc_component_read32(component, WM8988_IFACE) & 0x1f3; + u16 srate = snd_soc_component_read32(component, WM8988_SRATE) & 0x180; int coeff; coeff = get_coeff(wm8988->sysclk, params_rate(params)); @@ -680,7 +680,7 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, srate |= 0x40; } if (coeff < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Unable to configure sample rate %dHz with %dHz MCLK\n", params_rate(params), wm8988->sysclk); return coeff; @@ -702,9 +702,9 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, } /* set iface & srate */ - snd_soc_write(codec, WM8988_IFACE, iface); + snd_soc_component_write(component, WM8988_IFACE, iface); if (coeff >= 0) - snd_soc_write(codec, WM8988_SRATE, srate | + snd_soc_component_write(component, WM8988_SRATE, srate | (coeff_div[coeff].sr << 1) | coeff_div[coeff].usb); return 0; @@ -712,21 +712,21 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, static int wm8988_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8988_ADCDAC) & 0xfff7; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8988_ADCDAC) & 0xfff7; if (mute) - snd_soc_write(codec, WM8988_ADCDAC, mute_reg | 0x8); + snd_soc_component_write(component, WM8988_ADCDAC, mute_reg | 0x8); else - snd_soc_write(codec, WM8988_ADCDAC, mute_reg); + snd_soc_component_write(component, WM8988_ADCDAC, mute_reg); return 0; } -static int wm8988_set_bias_level(struct snd_soc_codec *codec, +static int wm8988_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8988_priv *wm8988 = snd_soc_codec_get_drvdata(codec); - u16 pwr_reg = snd_soc_read(codec, WM8988_PWR1) & ~0x1c1; + struct wm8988_priv *wm8988 = snd_soc_component_get_drvdata(component); + u16 pwr_reg = snd_soc_component_read32(component, WM8988_PWR1) & ~0x1c1; switch (level) { case SND_SOC_BIAS_ON: @@ -734,26 +734,26 @@ static int wm8988_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VREF, VMID=2x50k, digital enabled */ - snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x00c0); + snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x00c0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8988->regmap); /* VREF, VMID=2x5k */ - snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x1c1); + snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x1c1); /* Charge caps */ msleep(100); } /* VREF, VMID=2*500k, digital stopped */ - snd_soc_write(codec, WM8988_PWR1, pwr_reg | 0x0141); + snd_soc_component_write(component, WM8988_PWR1, pwr_reg | 0x0141); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, WM8988_PWR1, 0x0000); + snd_soc_component_write(component, WM8988_PWR1, 0x0000); break; } return 0; @@ -792,39 +792,40 @@ static struct snd_soc_dai_driver wm8988_dai = { .symmetric_rates = 1, }; -static int wm8988_probe(struct snd_soc_codec *codec) +static int wm8988_probe(struct snd_soc_component *component) { int ret = 0; - ret = wm8988_reset(codec); + ret = wm8988_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; } /* set the update bits (we always update left then right) */ - snd_soc_update_bits(codec, WM8988_RADC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_RDAC, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_ROUT1V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_ROUT2V, 0x0100, 0x0100); - snd_soc_update_bits(codec, WM8988_RINVOL, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_RADC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_RDAC, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_ROUT1V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_ROUT2V, 0x0100, 0x0100); + snd_soc_component_update_bits(component, WM8988_RINVOL, 0x0100, 0x0100); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8988 = { - .probe = wm8988_probe, - .set_bias_level = wm8988_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8988_snd_controls, - .num_controls = ARRAY_SIZE(wm8988_snd_controls), - .dapm_widgets = wm8988_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8988_dapm_widgets), - .dapm_routes = wm8988_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8988 = { + .probe = wm8988_probe, + .set_bias_level = wm8988_set_bias_level, + .controls = wm8988_snd_controls, + .num_controls = ARRAY_SIZE(wm8988_snd_controls), + .dapm_widgets = wm8988_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8988_dapm_widgets), + .dapm_routes = wm8988_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8988_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8988_regmap = { @@ -859,23 +860,16 @@ static int wm8988_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8988); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8988, &wm8988_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8988, &wm8988_dai, 1); return ret; } -static int wm8988_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8988_spi_driver = { .driver = { .name = "wm8988", }, .probe = wm8988_spi_probe, - .remove = wm8988_spi_remove, }; #endif /* CONFIG_SPI_MASTER */ @@ -900,17 +894,11 @@ static int wm8988_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8988, &wm8988_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8988, &wm8988_dai, 1); return ret; } -static int wm8988_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8988_i2c_id[] = { { "wm8988", 0 }, { } @@ -922,7 +910,6 @@ static struct i2c_driver wm8988_i2c_driver = { .name = "wm8988", }, .probe = wm8988_i2c_probe, - .remove = wm8988_i2c_remove, .id_table = wm8988_i2c_id, }; #endif From e3a68fd8a8d19454bbff08bc14b959645601a48d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:07:43 +0000 Subject: [PATCH 046/942] ASoC: wm8983: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8983.c | 170 ++++++++++++++++++-------------------- 1 file changed, 79 insertions(+), 91 deletions(-) diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c index bfdbe72ee687..9f35801aa85f 100644 --- a/sound/soc/codecs/wm8983.c +++ b/sound/soc/codecs/wm8983.c @@ -492,10 +492,10 @@ static const struct snd_soc_dapm_route wm8983_audio_map[] = { static int eqmode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg; - reg = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); + reg = snd_soc_component_read32(component, WM8983_EQ1_LOW_SHELF); if (reg & WM8983_EQ3DMODE) ucontrol->value.enumerated.item[0] = 1; else @@ -507,7 +507,7 @@ static int eqmode_get(struct snd_kcontrol *kcontrol, static int eqmode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int regpwr2, regpwr3; unsigned int reg_eq; @@ -515,7 +515,7 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, && ucontrol->value.enumerated.item[0] != 1) return -EINVAL; - reg_eq = snd_soc_read(codec, WM8983_EQ1_LOW_SHELF); + reg_eq = snd_soc_component_read32(component, WM8983_EQ1_LOW_SHELF); switch ((reg_eq & WM8983_EQ3DMODE) >> WM8983_EQ3DMODE_SHIFT) { case 0: if (!ucontrol->value.enumerated.item[0]) @@ -527,21 +527,21 @@ static int eqmode_put(struct snd_kcontrol *kcontrol, break; } - regpwr2 = snd_soc_read(codec, WM8983_POWER_MANAGEMENT_2); - regpwr3 = snd_soc_read(codec, WM8983_POWER_MANAGEMENT_3); + regpwr2 = snd_soc_component_read32(component, WM8983_POWER_MANAGEMENT_2); + regpwr3 = snd_soc_component_read32(component, WM8983_POWER_MANAGEMENT_3); /* disable the DACs and ADCs */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_2, WM8983_ADCENR_MASK | WM8983_ADCENL_MASK, 0); - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_3, WM8983_DACENR_MASK | WM8983_DACENL_MASK, 0); /* set the desired eqmode */ - snd_soc_update_bits(codec, WM8983_EQ1_LOW_SHELF, + snd_soc_component_update_bits(component, WM8983_EQ1_LOW_SHELF, WM8983_EQ3DMODE_MASK, ucontrol->value.enumerated.item[0] << WM8983_EQ3DMODE_SHIFT); /* restore DAC/ADC configuration */ - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, regpwr2); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_3, regpwr3); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_2, regpwr2); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_3, regpwr3); return 0; } @@ -562,16 +562,16 @@ static bool wm8983_writeable(struct device *dev, unsigned int reg) static int wm8983_dac_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - return snd_soc_update_bits(codec, WM8983_DAC_CONTROL, + return snd_soc_component_update_bits(component, WM8983_DAC_CONTROL, WM8983_SOFTMUTE_MASK, !!mute << WM8983_SOFTMUTE_SHIFT); } static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 format, master, bcp, lrp; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -593,7 +593,7 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_FMT_MASK, format << WM8983_FMT_SHIFT); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -608,7 +608,7 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_MS_MASK, master << WM8983_MS_SHIFT); /* FIXME: We don't currently support DSP A/B modes */ @@ -639,9 +639,9 @@ static int wm8983_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_LRCP_MASK, lrp << WM8983_LRCP_SHIFT); - snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_BCP_MASK, bcp << WM8983_BCP_SHIFT); return 0; } @@ -651,8 +651,8 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int i; - struct snd_soc_codec *codec = dai->codec; - struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component); u16 blen, srate_idx; u32 tmp; int srate_best; @@ -660,7 +660,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, ret = snd_soc_params_to_bclk(params); if (ret < 0) { - dev_err(codec->dev, "Failed to convert params to bclk: %d\n", ret); + dev_err(component->dev, "Failed to convert params to bclk: %d\n", ret); return ret; } @@ -685,7 +685,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, WM8983_AUDIO_INTERFACE, + snd_soc_component_update_bits(component, WM8983_AUDIO_INTERFACE, WM8983_WL_MASK, blen << WM8983_WL_SHIFT); /* @@ -702,7 +702,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, } dev_dbg(dai->dev, "Selected SRATE = %d\n", srates[srate_idx]); - snd_soc_update_bits(codec, WM8983_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8983_ADDITIONAL_CONTROL, WM8983_SR_MASK, srate_idx << WM8983_SR_SHIFT); dev_dbg(dai->dev, "Target BCLK = %uHz\n", wm8983->bclk); @@ -721,7 +721,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, } dev_dbg(dai->dev, "MCLK ratio = %dfs\n", fs_ratios[i].ratio); - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_MCLKDIV_MASK, i << WM8983_MCLKDIV_SHIFT); /* select the appropriate bclk divider */ @@ -737,7 +737,7 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, } dev_dbg(dai->dev, "BCLK div = %d\n", i); - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_BCLKDIV_MASK, i << WM8983_BCLKDIV_SHIFT); return 0; @@ -789,13 +789,13 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id, unsigned int freq_out) { int ret; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct pll_div pll_div; - codec = dai->codec; + component = dai->component; if (!freq_in || !freq_out) { /* disable the PLL */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_PLLEN_MASK, 0); return 0; } else { @@ -804,19 +804,19 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id, return ret; /* disable the PLL before re-programming it */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_PLLEN_MASK, 0); /* set PLLN and PRESCALE */ - snd_soc_write(codec, WM8983_PLL_N, + snd_soc_component_write(component, WM8983_PLL_N, (pll_div.div2 << WM8983_PLL_PRESCALE_SHIFT) | pll_div.n); /* set PLLK */ - snd_soc_write(codec, WM8983_PLL_K_3, pll_div.k & 0x1ff); - snd_soc_write(codec, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8983_PLL_K_1, (pll_div.k >> 18)); + snd_soc_component_write(component, WM8983_PLL_K_3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8983_PLL_K_2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8983_PLL_K_1, (pll_div.k >> 18)); /* enable the PLL */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_PLLEN_MASK, WM8983_PLLEN); } @@ -826,16 +826,16 @@ static int wm8983_set_pll(struct snd_soc_dai *dai, int pll_id, static int wm8983_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM8983_CLKSRC_MCLK: - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_CLKSEL_MASK, 0); break; case WM8983_CLKSRC_PLL: - snd_soc_update_bits(codec, WM8983_CLOCK_GEN_CONTROL, + snd_soc_component_update_bits(component, WM8983_CLOCK_GEN_CONTROL, WM8983_CLKSEL_MASK, WM8983_CLKSEL); break; default: @@ -847,100 +847,100 @@ static int wm8983_set_sysclk(struct snd_soc_dai *dai, return 0; } -static int wm8983_set_bias_level(struct snd_soc_codec *codec, +static int wm8983_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8983_priv *wm8983 = snd_soc_codec_get_drvdata(codec); + struct wm8983_priv *wm8983 = snd_soc_component_get_drvdata(component); int ret; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: /* VMID at 100k */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK, 1 << WM8983_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8983->regmap); if (ret < 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } /* enable anti-pop features */ - snd_soc_update_bits(codec, WM8983_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8983_OUT4_TO_ADC, WM8983_POBCTRL_MASK | WM8983_DELEN_MASK, WM8983_POBCTRL | WM8983_DELEN); /* enable thermal shutdown */ - snd_soc_update_bits(codec, WM8983_OUTPUT_CTRL, + snd_soc_component_update_bits(component, WM8983_OUTPUT_CTRL, WM8983_TSDEN_MASK, WM8983_TSDEN); /* enable BIASEN */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_BIASEN_MASK, WM8983_BIASEN); /* VMID at 100k */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK, 1 << WM8983_VMIDSEL_SHIFT); msleep(250); /* disable anti-pop features */ - snd_soc_update_bits(codec, WM8983_OUT4_TO_ADC, + snd_soc_component_update_bits(component, WM8983_OUT4_TO_ADC, WM8983_POBCTRL_MASK | WM8983_DELEN_MASK, 0); } /* VMID at 500k */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK, 2 << WM8983_VMIDSEL_SHIFT); break; case SND_SOC_BIAS_OFF: /* disable thermal shutdown */ - snd_soc_update_bits(codec, WM8983_OUTPUT_CTRL, + snd_soc_component_update_bits(component, WM8983_OUTPUT_CTRL, WM8983_TSDEN_MASK, 0); /* disable VMIDSEL and BIASEN */ - snd_soc_update_bits(codec, WM8983_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8983_POWER_MANAGEMENT_1, WM8983_VMIDSEL_MASK | WM8983_BIASEN_MASK, 0); /* wait for VMID to discharge */ msleep(100); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_1, 0); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_2, 0); - snd_soc_write(codec, WM8983_POWER_MANAGEMENT_3, 0); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_1, 0); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_2, 0); + snd_soc_component_write(component, WM8983_POWER_MANAGEMENT_3, 0); break; } return 0; } -static int wm8983_probe(struct snd_soc_codec *codec) +static int wm8983_probe(struct snd_soc_component *component) { int ret; int i; - ret = snd_soc_write(codec, WM8983_SOFTWARE_RESET, 0); + ret = snd_soc_component_write(component, WM8983_SOFTWARE_RESET, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; } /* set the vol/gain update bits */ for (i = 0; i < ARRAY_SIZE(vol_update_regs); ++i) - snd_soc_update_bits(codec, vol_update_regs[i], + snd_soc_component_update_bits(component, vol_update_regs[i], 0x100, 0x100); /* mute all outputs and set PGAs to minimum gain */ for (i = WM8983_LOUT1_HP_VOLUME_CTRL; i <= WM8983_OUT4_MONO_MIX_CTRL; ++i) - snd_soc_update_bits(codec, i, 0x40, 0x40); + snd_soc_component_update_bits(component, i, 0x40, 0x40); /* enable soft mute */ - snd_soc_update_bits(codec, WM8983_DAC_CONTROL, + snd_soc_component_update_bits(component, WM8983_DAC_CONTROL, WM8983_SOFTMUTE_MASK, WM8983_SOFTMUTE); /* enable BIASCUT */ - snd_soc_update_bits(codec, WM8983_BIAS_CTRL, + snd_soc_component_update_bits(component, WM8983_BIAS_CTRL, WM8983_BIASCUT, WM8983_BIASCUT); return 0; } @@ -976,18 +976,20 @@ static struct snd_soc_dai_driver wm8983_dai = { .symmetric_rates = 1 }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8983 = { - .probe = wm8983_probe, - .set_bias_level = wm8983_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = wm8983_snd_controls, - .num_controls = ARRAY_SIZE(wm8983_snd_controls), - .dapm_widgets = wm8983_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets), - .dapm_routes = wm8983_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8983 = { + .probe = wm8983_probe, + .set_bias_level = wm8983_set_bias_level, + .controls = wm8983_snd_controls, + .num_controls = ARRAY_SIZE(wm8983_snd_controls), + .dapm_widgets = wm8983_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8983_dapm_widgets), + .dapm_routes = wm8983_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm8983_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8983_regmap = { @@ -1021,23 +1023,16 @@ static int wm8983_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, wm8983); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8983, &wm8983_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8983, &wm8983_dai, 1); return ret; } -static int wm8983_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8983_spi_driver = { .driver = { .name = "wm8983", }, .probe = wm8983_spi_probe, - .remove = wm8983_spi_remove }; #endif @@ -1061,18 +1056,12 @@ static int wm8983_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8983); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8983, &wm8983_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8983, &wm8983_dai, 1); return ret; } -static int wm8983_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8983_i2c_id[] = { { "wm8983", 0 }, { } @@ -1084,7 +1073,6 @@ static struct i2c_driver wm8983_i2c_driver = { .name = "wm8983", }, .probe = wm8983_i2c_probe, - .remove = wm8983_i2c_remove, .id_table = wm8983_i2c_id }; #endif From f4ee271709f05ed62e752557ef2f032aea8258bc Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:07:59 +0000 Subject: [PATCH 047/942] ASoC: wm8962: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8962.c | 397 +++++++++++++++++----------------- sound/soc/codecs/wm8962.h | 2 +- sound/soc/samsung/tobermory.c | 6 +- 3 files changed, 202 insertions(+), 203 deletions(-) diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index fd2731d171dd..a11e9d6bf950 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -55,7 +55,7 @@ static const char *wm8962_supply_names[WM8962_NUM_SUPPLIES] = { struct wm8962_priv { struct wm8962_pdata pdata; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int sysclk; int sysclk_rate; @@ -1475,55 +1475,55 @@ static const DECLARE_TLV_DB_RANGE(classd_tlv, ); static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0); -static int wm8962_dsp2_write_config(struct snd_soc_codec *codec) +static int wm8962_dsp2_write_config(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); return regcache_sync_region(wm8962->regmap, WM8962_HDBASS_AI_1, WM8962_MAX_REGISTER); } -static int wm8962_dsp2_set_enable(struct snd_soc_codec *codec, u16 val) +static int wm8962_dsp2_set_enable(struct snd_soc_component *component, u16 val) { - u16 adcl = snd_soc_read(codec, WM8962_LEFT_ADC_VOLUME); - u16 adcr = snd_soc_read(codec, WM8962_RIGHT_ADC_VOLUME); - u16 dac = snd_soc_read(codec, WM8962_ADC_DAC_CONTROL_1); + u16 adcl = snd_soc_component_read32(component, WM8962_LEFT_ADC_VOLUME); + u16 adcr = snd_soc_component_read32(component, WM8962_RIGHT_ADC_VOLUME); + u16 dac = snd_soc_component_read32(component, WM8962_ADC_DAC_CONTROL_1); /* Mute the ADCs and DACs */ - snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, 0); - snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); - snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, + snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, 0); + snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, WM8962_ADC_VU); + snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1, WM8962_DAC_MUTE, WM8962_DAC_MUTE); - snd_soc_write(codec, WM8962_SOUNDSTAGE_ENABLES_0, val); + snd_soc_component_write(component, WM8962_SOUNDSTAGE_ENABLES_0, val); /* Restore the ADCs and DACs */ - snd_soc_write(codec, WM8962_LEFT_ADC_VOLUME, adcl); - snd_soc_write(codec, WM8962_RIGHT_ADC_VOLUME, adcr); - snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, + snd_soc_component_write(component, WM8962_LEFT_ADC_VOLUME, adcl); + snd_soc_component_write(component, WM8962_RIGHT_ADC_VOLUME, adcr); + snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1, WM8962_DAC_MUTE, dac); return 0; } -static int wm8962_dsp2_start(struct snd_soc_codec *codec) +static int wm8962_dsp2_start(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); - wm8962_dsp2_write_config(codec); + wm8962_dsp2_write_config(component); - snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR); + snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_RUNR); - wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); + wm8962_dsp2_set_enable(component, wm8962->dsp2_ena); return 0; } -static int wm8962_dsp2_stop(struct snd_soc_codec *codec) +static int wm8962_dsp2_stop(struct snd_soc_component *component) { - wm8962_dsp2_set_enable(codec, 0); + wm8962_dsp2_set_enable(component, 0); - snd_soc_write(codec, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP); + snd_soc_component_write(component, WM8962_DSP2_EXECCONTROL, WM8962_DSP2_STOP); return 0; } @@ -1550,8 +1550,8 @@ static int wm8962_dsp2_ena_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = !!(wm8962->dsp2_ena & 1 << shift); @@ -1562,11 +1562,11 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int shift = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int old = wm8962->dsp2_ena; int ret = 0; - int dsp2_running = snd_soc_read(codec, WM8962_DSP2_POWER_MANAGEMENT) & + int dsp2_running = snd_soc_component_read32(component, WM8962_DSP2_POWER_MANAGEMENT) & WM8962_DSP2_ENA; mutex_lock(&wm8962->dsp2_ena_lock); @@ -1583,9 +1583,9 @@ static int wm8962_dsp2_ena_put(struct snd_kcontrol *kcontrol, if (dsp2_running) { if (wm8962->dsp2_ena) - wm8962_dsp2_set_enable(codec, wm8962->dsp2_ena); + wm8962_dsp2_set_enable(component, wm8962->dsp2_ena); else - wm8962_dsp2_stop(codec); + wm8962_dsp2_stop(component); } out: @@ -1600,7 +1600,7 @@ out: static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret; /* Apply the update (if any) */ @@ -1609,17 +1609,17 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, return 0; /* If the left PGA is enabled hit that VU bit... */ - ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); + ret = snd_soc_component_read32(component, WM8962_PWR_MGMT_2); if (ret & WM8962_HPOUTL_PGA_ENA) { - snd_soc_write(codec, WM8962_HPOUTL_VOLUME, - snd_soc_read(codec, WM8962_HPOUTL_VOLUME)); + snd_soc_component_write(component, WM8962_HPOUTL_VOLUME, + snd_soc_component_read32(component, WM8962_HPOUTL_VOLUME)); return 1; } /* ...otherwise the right. The VU is stereo. */ if (ret & WM8962_HPOUTR_PGA_ENA) - snd_soc_write(codec, WM8962_HPOUTR_VOLUME, - snd_soc_read(codec, WM8962_HPOUTR_VOLUME)); + snd_soc_component_write(component, WM8962_HPOUTR_VOLUME, + snd_soc_component_read32(component, WM8962_HPOUTR_VOLUME)); return 1; } @@ -1630,7 +1630,7 @@ static int wm8962_put_hp_sw(struct snd_kcontrol *kcontrol, static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret; /* Apply the update (if any) */ @@ -1639,17 +1639,17 @@ static int wm8962_put_spk_sw(struct snd_kcontrol *kcontrol, return 0; /* If the left PGA is enabled hit that VU bit... */ - ret = snd_soc_read(codec, WM8962_PWR_MGMT_2); + ret = snd_soc_component_read32(component, WM8962_PWR_MGMT_2); if (ret & WM8962_SPKOUTL_PGA_ENA) { - snd_soc_write(codec, WM8962_SPKOUTL_VOLUME, - snd_soc_read(codec, WM8962_SPKOUTL_VOLUME)); + snd_soc_component_write(component, WM8962_SPKOUTL_VOLUME, + snd_soc_component_read32(component, WM8962_SPKOUTL_VOLUME)); return 1; } /* ...otherwise the right. The VU is stereo. */ if (ret & WM8962_SPKOUTR_PGA_ENA) - snd_soc_write(codec, WM8962_SPKOUTR_VOLUME, - snd_soc_read(codec, WM8962_SPKOUTR_VOLUME)); + snd_soc_component_write(component, WM8962_SPKOUTR_VOLUME, + snd_soc_component_read32(component, WM8962_SPKOUTR_VOLUME)); return 1; } @@ -1863,7 +1863,7 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int timeout; int reg; int expected = (WM8962_DCS_STARTUP_DONE_HP1L | @@ -1871,17 +1871,17 @@ static int hp_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA | WM8962_HP1R_ENA, WM8962_HP1L_ENA | WM8962_HP1R_ENA); udelay(20); - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY, WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY); /* Start the DC servo */ - snd_soc_update_bits(codec, WM8962_DC_SERVO_1, + snd_soc_component_update_bits(component, WM8962_DC_SERVO_1, WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA | WM8962_HP1L_DCS_STARTUP | WM8962_HP1R_DCS_STARTUP, @@ -1893,30 +1893,30 @@ static int hp_event(struct snd_soc_dapm_widget *w, timeout = 0; do { msleep(1); - reg = snd_soc_read(codec, WM8962_DC_SERVO_6); + reg = snd_soc_component_read32(component, WM8962_DC_SERVO_6); if (reg < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read DCS status: %d\n", reg); continue; } - dev_dbg(codec->dev, "DCS status: %x\n", reg); + dev_dbg(component->dev, "DCS status: %x\n", reg); } while (++timeout < 200 && (reg & expected) != expected); if ((reg & expected) != expected) - dev_err(codec->dev, "DC servo timed out\n"); + dev_err(component->dev, "DC servo timed out\n"); else - dev_dbg(codec->dev, "DC servo complete after %dms\n", + dev_dbg(component->dev, "DC servo complete after %dms\n", timeout); - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA_OUTP | WM8962_HP1R_ENA_OUTP, WM8962_HP1L_ENA_OUTP | WM8962_HP1R_ENA_OUTP); udelay(20); - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_RMV_SHORT | WM8962_HP1R_RMV_SHORT, WM8962_HP1L_RMV_SHORT | @@ -1924,19 +1924,19 @@ static int hp_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_RMV_SHORT | WM8962_HP1R_RMV_SHORT, 0); udelay(20); - snd_soc_update_bits(codec, WM8962_DC_SERVO_1, + snd_soc_component_update_bits(component, WM8962_DC_SERVO_1, WM8962_HP1L_DCS_ENA | WM8962_HP1R_DCS_ENA | WM8962_HP1L_DCS_STARTUP | WM8962_HP1R_DCS_STARTUP, 0); - snd_soc_update_bits(codec, WM8962_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8962_ANALOGUE_HP_0, WM8962_HP1L_ENA | WM8962_HP1R_ENA | WM8962_HP1L_ENA_DLY | WM8962_HP1R_ENA_DLY | WM8962_HP1L_ENA_OUTP | @@ -1957,7 +1957,7 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int reg; switch (w->shift) { @@ -1980,7 +1980,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - return snd_soc_write(codec, reg, snd_soc_read(codec, reg)); + return snd_soc_component_write(component, reg, snd_soc_component_read32(component, reg)); default: WARN(1, "Invalid event %d\n", event); return -EINVAL; @@ -1990,18 +1990,18 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, static int dsp2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: if (wm8962->dsp2_ena) - wm8962_dsp2_start(codec); + wm8962_dsp2_start(component); break; case SND_SOC_DAPM_PRE_PMD: if (wm8962->dsp2_ena) - wm8962_dsp2_stop(codec); + wm8962_dsp2_stop(component); break; default: @@ -2354,19 +2354,19 @@ static const struct snd_soc_dapm_route wm8962_spk_stereo_intercon[] = { { "SPKOUTR", NULL, "SPKOUTR Output" }, }; -static int wm8962_add_widgets(struct snd_soc_codec *codec) +static int wm8962_add_widgets(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct wm8962_pdata *pdata = &wm8962->pdata; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - snd_soc_add_codec_controls(codec, wm8962_snd_controls, + snd_soc_add_component_controls(component, wm8962_snd_controls, ARRAY_SIZE(wm8962_snd_controls)); if (pdata->spk_mono) - snd_soc_add_codec_controls(codec, wm8962_spk_mono_controls, + snd_soc_add_component_controls(component, wm8962_spk_mono_controls, ARRAY_SIZE(wm8962_spk_mono_controls)); else - snd_soc_add_codec_controls(codec, wm8962_spk_stereo_controls, + snd_soc_add_component_controls(component, wm8962_spk_stereo_controls, ARRAY_SIZE(wm8962_spk_stereo_controls)); @@ -2403,21 +2403,21 @@ static const int sysclk_rates[] = { 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536, 3072, 6144 }; -static void wm8962_configure_bclk(struct snd_soc_codec *codec) +static void wm8962_configure_bclk(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int dspclk, i; int clocking2 = 0; int clocking4 = 0; int aif2 = 0; if (!wm8962->sysclk_rate) { - dev_dbg(codec->dev, "No SYSCLK configured\n"); + dev_dbg(component->dev, "No SYSCLK configured\n"); return; } if (!wm8962->bclk || !wm8962->lrclk) { - dev_dbg(codec->dev, "No audio clocks configured\n"); + dev_dbg(component->dev, "No audio clocks configured\n"); return; } @@ -2429,32 +2429,32 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) } if (i == ARRAY_SIZE(sysclk_rates)) { - dev_err(codec->dev, "Unsupported sysclk ratio %d\n", + dev_err(component->dev, "Unsupported sysclk ratio %d\n", wm8962->sysclk_rate / wm8962->lrclk); return; } - dev_dbg(codec->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]); + dev_dbg(component->dev, "Selected sysclk ratio %d\n", sysclk_rates[i]); - snd_soc_update_bits(codec, WM8962_CLOCKING_4, + snd_soc_component_update_bits(component, WM8962_CLOCKING_4, WM8962_SYSCLK_RATE_MASK, clocking4); /* DSPCLK_DIV can be only generated correctly after enabling SYSCLK. * So we here provisionally enable it and then disable it afterward * if current bias_level hasn't reached SND_SOC_BIAS_ON. */ - if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) - snd_soc_update_bits(codec, WM8962_CLOCKING2, + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_ENA_MASK, WM8962_SYSCLK_ENA); - dspclk = snd_soc_read(codec, WM8962_CLOCKING1); + dspclk = snd_soc_component_read32(component, WM8962_CLOCKING1); - if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON) - snd_soc_update_bits(codec, WM8962_CLOCKING2, + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON) + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_ENA_MASK, 0); if (dspclk < 0) { - dev_err(codec->dev, "Failed to read DSPCLK: %d\n", dspclk); + dev_err(component->dev, "Failed to read DSPCLK: %d\n", dspclk); return; } @@ -2470,11 +2470,11 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) dspclk = wm8962->sysclk_rate / 4; break; default: - dev_warn(codec->dev, "Unknown DSPCLK divisor read back\n"); + dev_warn(component->dev, "Unknown DSPCLK divisor read back\n"); dspclk = wm8962->sysclk_rate; } - dev_dbg(codec->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); + dev_dbg(component->dev, "DSPCLK is %dHz, BCLK %d\n", dspclk, wm8962->bclk); /* We're expecting an exact match */ for (i = 0; i < ARRAY_SIZE(bclk_divs); i++) { @@ -2482,29 +2482,29 @@ static void wm8962_configure_bclk(struct snd_soc_codec *codec) continue; if (dspclk / bclk_divs[i] == wm8962->bclk) { - dev_dbg(codec->dev, "Selected BCLK_DIV %d for %dHz\n", + dev_dbg(component->dev, "Selected BCLK_DIV %d for %dHz\n", bclk_divs[i], wm8962->bclk); clocking2 |= i; break; } } if (i == ARRAY_SIZE(bclk_divs)) { - dev_err(codec->dev, "Unsupported BCLK ratio %d\n", + dev_err(component->dev, "Unsupported BCLK ratio %d\n", dspclk / wm8962->bclk); return; } aif2 |= wm8962->bclk / wm8962->lrclk; - dev_dbg(codec->dev, "Selected LRCLK divisor %d for %dHz\n", + dev_dbg(component->dev, "Selected LRCLK divisor %d for %dHz\n", wm8962->bclk / wm8962->lrclk, wm8962->lrclk); - snd_soc_update_bits(codec, WM8962_CLOCKING2, + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_BCLK_DIV_MASK, clocking2); - snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_2, + snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_2, WM8962_AIF_RATE_MASK, aif2); } -static int wm8962_set_bias_level(struct snd_soc_codec *codec, +static int wm8962_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -2513,18 +2513,18 @@ static int wm8962_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID 2*50k */ - snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, + snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1, WM8962_VMID_SEL_MASK, 0x80); - wm8962_configure_bclk(codec); + wm8962_configure_bclk(component); break; case SND_SOC_BIAS_STANDBY: /* VMID 2*250k */ - snd_soc_update_bits(codec, WM8962_PWR_MGMT_1, + snd_soc_component_update_bits(component, WM8962_PWR_MGMT_1, WM8962_VMID_SEL_MASK, 0x100); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) msleep(100); break; @@ -2556,8 +2556,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; int aif0 = 0; int adctl3 = 0; @@ -2575,7 +2575,7 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, } } if (i == ARRAY_SIZE(sr_vals)) { - dev_err(codec->dev, "Unsupported rate %dHz\n", wm8962->lrclk); + dev_err(component->dev, "Unsupported rate %dHz\n", wm8962->lrclk); return -EINVAL; } @@ -2598,17 +2598,17 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, + snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0, WM8962_WL_MASK, aif0); - snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_3, + snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_3, WM8962_SAMPLE_RATE_INT_MODE | WM8962_SAMPLE_RATE_MASK, adctl3); - dev_dbg(codec->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", + dev_dbg(component->dev, "hw_params set BCLK %dHz LRCLK %dHz\n", wm8962->bclk, wm8962->lrclk); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) - wm8962_configure_bclk(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) + wm8962_configure_bclk(component); return 0; } @@ -2616,8 +2616,8 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int src; switch (clk_id) { @@ -2633,7 +2633,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, return -EINVAL; } - snd_soc_update_bits(codec, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, + snd_soc_component_update_bits(component, WM8962_CLOCKING2, WM8962_SYSCLK_SRC_MASK, src); wm8962->sysclk_rate = freq; @@ -2643,7 +2643,7 @@ static int wm8962_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int aif0 = 0; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -2699,7 +2699,7 @@ static int wm8962_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8962_AUDIO_INTERFACE_0, + snd_soc_component_update_bits(component, WM8962_AUDIO_INTERFACE_0, WM8962_FMT_MASK | WM8962_BCLK_INV | WM8962_MSTR | WM8962_LRCLK_INV, aif0); @@ -2809,10 +2809,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct _fll_div fll_div; unsigned long timeout; int ret; @@ -2824,15 +2824,15 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return 0; if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n"); wm8962->fll_fref = 0; wm8962->fll_fout = 0; - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return 0; } @@ -2842,7 +2842,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return ret; /* Parameters good, disable so we can reprogram */ - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); switch (fll_id) { case WM8962_FLL_MCLK: @@ -2851,13 +2851,13 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, fll1 |= (fll_id - 1) << WM8962_FLL_REFCLK_SRC_SHIFT; break; case WM8962_FLL_INT: - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_OSC_ENA, WM8962_FLL_OSC_ENA); - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_5, WM8962_FLL_FRC_NCO, WM8962_FLL_FRC_NCO); break; default: - dev_err(codec->dev, "Unknown FLL source %d\n", ret); + dev_err(component->dev, "Unknown FLL source %d\n", ret); return -EINVAL; } @@ -2865,34 +2865,34 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, fll1 |= WM8962_FLL_FRAC; /* Stop the FLL while we reconfigure */ - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_2, WM8962_FLL_OUTDIV_MASK | WM8962_FLL_REFCLK_DIV_MASK, (fll_div.fll_outdiv << WM8962_FLL_OUTDIV_SHIFT) | (fll_div.fll_refclk_div)); - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_3, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_3, WM8962_FLL_FRATIO_MASK, fll_div.fll_fratio); - snd_soc_write(codec, WM8962_FLL_CONTROL_6, fll_div.theta); - snd_soc_write(codec, WM8962_FLL_CONTROL_7, fll_div.lambda); - snd_soc_write(codec, WM8962_FLL_CONTROL_8, fll_div.n); + snd_soc_component_write(component, WM8962_FLL_CONTROL_6, fll_div.theta); + snd_soc_component_write(component, WM8962_FLL_CONTROL_7, fll_div.lambda); + snd_soc_component_write(component, WM8962_FLL_CONTROL_8, fll_div.n); reinit_completion(&wm8962->fll_lock); - ret = pm_runtime_get_sync(codec->dev); + ret = pm_runtime_get_sync(component->dev); if (ret < 0) { - dev_err(codec->dev, "Failed to resume device: %d\n", ret); + dev_err(component->dev, "Failed to resume device: %d\n", ret); return ret; } - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_FRAC | WM8962_FLL_REFCLK_SRC_MASK | WM8962_FLL_ENA, fll1 | WM8962_FLL_ENA); - dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); /* This should be a massive overestimate but go even * higher if we'll error out @@ -2906,10 +2906,10 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, timeout); if (timeout == 0 && wm8962->irq) { - dev_err(codec->dev, "FLL lock timed out"); - snd_soc_update_bits(codec, WM8962_FLL_CONTROL_1, + dev_err(component->dev, "FLL lock timed out"); + snd_soc_component_update_bits(component, WM8962_FLL_CONTROL_1, WM8962_FLL_ENA, 0); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return -ETIMEDOUT; } @@ -2922,7 +2922,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source, static int wm8962_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int val, ret; if (mute) @@ -2934,12 +2934,12 @@ static int wm8962_mute(struct snd_soc_dai *dai, int mute) * The DAC mute bit is mirrored in two registers, update both to keep * the register cache consistent. */ - ret = snd_soc_update_bits(codec, WM8962_CLASS_D_CONTROL_1, + ret = snd_soc_component_update_bits(component, WM8962_CLASS_D_CONTROL_1, WM8962_DAC_MUTE_ALT, val); if (ret < 0) return ret; - return snd_soc_update_bits(codec, WM8962_ADC_DAC_CONTROL_1, + return snd_soc_component_update_bits(component, WM8962_ADC_DAC_CONTROL_1, WM8962_DAC_MUTE, val); } @@ -2981,12 +2981,12 @@ static void wm8962_mic_work(struct work_struct *work) struct wm8962_priv *wm8962 = container_of(work, struct wm8962_priv, mic_work.work); - struct snd_soc_codec *codec = wm8962->codec; + struct snd_soc_component *component = wm8962->component; int status = 0; int irq_pol = 0; int reg; - reg = snd_soc_read(codec, WM8962_ADDITIONAL_CONTROL_4); + reg = snd_soc_component_read32(component, WM8962_ADDITIONAL_CONTROL_4); if (reg & WM8962_MICDET_STS) { status |= SND_JACK_MICROPHONE; @@ -3001,7 +3001,7 @@ static void wm8962_mic_work(struct work_struct *work) snd_soc_jack_report(wm8962->jack, status, SND_JACK_MICROPHONE | SND_JACK_BTN_0); - snd_soc_update_bits(codec, WM8962_MICINT_SOURCE_POL, + snd_soc_component_update_bits(component, WM8962_MICINT_SOURCE_POL, WM8962_MICSCD_IRQ_POL | WM8962_MICD_IRQ_POL, irq_pol); } @@ -3099,7 +3099,7 @@ static irqreturn_t wm8962_irq(int irq, void *data) /** * wm8962_mic_detect - Enable microphone detection via the WM8962 IRQ * - * @codec: WM8962 codec + * @component: WM8962 component * @jack: jack to report detection events on * * Enable microphone detection via IRQ on the WM8962. If GPIOs are @@ -3109,10 +3109,10 @@ static irqreturn_t wm8962_irq(int irq, void *data) * * If no jack is supplied detection will be disabled. */ -int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int irq_mask, enable; wm8962->jack = jack; @@ -3124,9 +3124,9 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) enable = 0; } - snd_soc_update_bits(codec, WM8962_INTERRUPT_STATUS_2_MASK, + snd_soc_component_update_bits(component, WM8962_INTERRUPT_STATUS_2_MASK, WM8962_MICD_EINT | WM8962_MICSCD_EINT, irq_mask); - snd_soc_update_bits(codec, WM8962_ADDITIONAL_CONTROL_4, + snd_soc_component_update_bits(component, WM8962_ADDITIONAL_CONTROL_4, WM8962_MICDET_ENA, enable); /* Send an initial empty report */ @@ -3157,8 +3157,8 @@ static void wm8962_beep_work(struct work_struct *work) { struct wm8962_priv *wm8962 = container_of(work, struct wm8962_priv, beep_work); - struct snd_soc_codec *codec = wm8962->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = wm8962->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int i; int reg = 0; int best = 0; @@ -3170,18 +3170,18 @@ static void wm8962_beep_work(struct work_struct *work) best = i; } - dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", + dev_dbg(component->dev, "Set beep rate %dHz for requested %dHz\n", beep_rates[best], wm8962->beep_rate); reg = WM8962_BEEP_ENA | (best << WM8962_BEEP_RATE_SHIFT); snd_soc_dapm_enable_pin(dapm, "Beep"); } else { - dev_dbg(codec->dev, "Disabling beep\n"); + dev_dbg(component->dev, "Disabling beep\n"); snd_soc_dapm_disable_pin(dapm, "Beep"); } - snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, + snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA | WM8962_BEEP_RATE_MASK, reg); snd_soc_dapm_sync(dapm); @@ -3193,10 +3193,10 @@ static void wm8962_beep_work(struct work_struct *work) static int wm8962_beep_event(struct input_dev *dev, unsigned int type, unsigned int code, int hz) { - struct snd_soc_codec *codec = input_get_drvdata(dev); - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = input_get_drvdata(dev); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); + dev_dbg(component->dev, "Beep event %x %x\n", code, hz); switch (code) { case SND_BELL: @@ -3233,14 +3233,14 @@ static ssize_t wm8962_beep_set(struct device *dev, static DEVICE_ATTR(beep, 0200, NULL, wm8962_beep_set); -static void wm8962_init_beep(struct snd_soc_codec *codec) +static void wm8962_init_beep(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int ret; - wm8962->beep = devm_input_allocate_device(codec->dev); + wm8962->beep = devm_input_allocate_device(component->dev); if (!wm8962->beep) { - dev_err(codec->dev, "Failed to allocate beep device\n"); + dev_err(component->dev, "Failed to allocate beep device\n"); return; } @@ -3248,37 +3248,37 @@ static void wm8962_init_beep(struct snd_soc_codec *codec) wm8962->beep_rate = 0; wm8962->beep->name = "WM8962 Beep Generator"; - wm8962->beep->phys = dev_name(codec->dev); + wm8962->beep->phys = dev_name(component->dev); wm8962->beep->id.bustype = BUS_I2C; wm8962->beep->evbit[0] = BIT_MASK(EV_SND); wm8962->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); wm8962->beep->event = wm8962_beep_event; - wm8962->beep->dev.parent = codec->dev; - input_set_drvdata(wm8962->beep, codec); + wm8962->beep->dev.parent = component->dev; + input_set_drvdata(wm8962->beep, component); ret = input_register_device(wm8962->beep); if (ret != 0) { wm8962->beep = NULL; - dev_err(codec->dev, "Failed to register beep device\n"); + dev_err(component->dev, "Failed to register beep device\n"); } - ret = device_create_file(codec->dev, &dev_attr_beep); + ret = device_create_file(component->dev, &dev_attr_beep); if (ret != 0) { - dev_err(codec->dev, "Failed to create keyclick file: %d\n", + dev_err(component->dev, "Failed to create keyclick file: %d\n", ret); } } -static void wm8962_free_beep(struct snd_soc_codec *codec) +static void wm8962_free_beep(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); - device_remove_file(codec->dev, &dev_attr_beep); + device_remove_file(component->dev, &dev_attr_beep); cancel_work_sync(&wm8962->beep_work); wm8962->beep = NULL; - snd_soc_update_bits(codec, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); + snd_soc_component_update_bits(component, WM8962_BEEP_GENERATOR_1, WM8962_BEEP_ENA,0); } static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio) @@ -3333,9 +3333,9 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset) static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) { struct wm8962_priv *wm8962 = gpiochip_get_data(chip); - struct snd_soc_codec *codec = wm8962->codec; + struct snd_soc_component *component = wm8962->component; - snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, + snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset, WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT); } @@ -3343,13 +3343,13 @@ static int wm8962_gpio_direction_out(struct gpio_chip *chip, unsigned offset, int value) { struct wm8962_priv *wm8962 = gpiochip_get_data(chip); - struct snd_soc_codec *codec = wm8962->codec; + struct snd_soc_component *component = wm8962->component; int ret, val; /* Force function 1 (logic output) */ val = (1 << WM8962_GP2_FN_SHIFT) | (value << WM8962_GP2_LVL_SHIFT); - ret = snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset, + ret = snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset, WM8962_GP2_FN_MASK | WM8962_GP2_LVL, val); if (ret < 0) return ret; @@ -3366,15 +3366,15 @@ static const struct gpio_chip wm8962_template_chip = { .can_sleep = 1, }; -static void wm8962_init_gpio(struct snd_soc_codec *codec) +static void wm8962_init_gpio(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); struct wm8962_pdata *pdata = &wm8962->pdata; int ret; wm8962->gpio_chip = wm8962_template_chip; wm8962->gpio_chip.ngpio = WM8962_MAX_GPIO; - wm8962->gpio_chip.parent = codec->dev; + wm8962->gpio_chip.parent = component->dev; if (pdata->gpio_base) wm8962->gpio_chip.base = pdata->gpio_base; @@ -3383,34 +3383,34 @@ static void wm8962_init_gpio(struct snd_soc_codec *codec) ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962); if (ret != 0) - dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret); + dev_err(component->dev, "Failed to add GPIOs: %d\n", ret); } -static void wm8962_free_gpio(struct snd_soc_codec *codec) +static void wm8962_free_gpio(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); gpiochip_remove(&wm8962->gpio_chip); } #else -static void wm8962_init_gpio(struct snd_soc_codec *codec) +static void wm8962_init_gpio(struct snd_soc_component *component) { } -static void wm8962_free_gpio(struct snd_soc_codec *codec) +static void wm8962_free_gpio(struct snd_soc_component *component) { } #endif -static int wm8962_probe(struct snd_soc_codec *codec) +static int wm8962_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; bool dmicclk, dmicdat; - wm8962->codec = codec; + wm8962->component = component; wm8962->disable_nb[0].notifier_call = wm8962_regulator_event_0; wm8962->disable_nb[1].notifier_call = wm8962_regulator_event_1; @@ -3426,19 +3426,19 @@ static int wm8962_probe(struct snd_soc_codec *codec) ret = regulator_register_notifier(wm8962->supplies[i].consumer, &wm8962->disable_nb[i]); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to register regulator notifier: %d\n", ret); } } - wm8962_add_widgets(codec); + wm8962_add_widgets(component); /* Save boards having to disable DMIC when not in use */ dmicclk = false; dmicdat = false; for (i = 0; i < WM8962_MAX_GPIO; i++) { - switch (snd_soc_read(codec, WM8962_GPIO_BASE + i) + switch (snd_soc_component_read32(component, WM8962_GPIO_BASE + i) & WM8962_GP2_FN_MASK) { case WM8962_GPIO_FN_DMICCLK: dmicclk = true; @@ -3451,40 +3451,40 @@ static int wm8962_probe(struct snd_soc_codec *codec) } } if (!dmicclk || !dmicdat) { - dev_dbg(codec->dev, "DMIC not in use, disabling\n"); + dev_dbg(component->dev, "DMIC not in use, disabling\n"); snd_soc_dapm_nc_pin(dapm, "DMICDAT"); } if (dmicclk != dmicdat) - dev_warn(codec->dev, "DMIC GPIOs partially configured\n"); + dev_warn(component->dev, "DMIC GPIOs partially configured\n"); - wm8962_init_beep(codec); - wm8962_init_gpio(codec); + wm8962_init_beep(component); + wm8962_init_gpio(component); return 0; } -static int wm8962_remove(struct snd_soc_codec *codec) +static void wm8962_remove(struct snd_soc_component *component) { - struct wm8962_priv *wm8962 = snd_soc_codec_get_drvdata(codec); + struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component); int i; cancel_delayed_work_sync(&wm8962->mic_work); - wm8962_free_gpio(codec); - wm8962_free_beep(codec); + wm8962_free_gpio(component); + wm8962_free_beep(component); for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) regulator_unregister_notifier(wm8962->supplies[i].consumer, &wm8962->disable_nb[i]); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8962 = { - .probe = wm8962_probe, - .remove = wm8962_remove, - .set_bias_level = wm8962_set_bias_level, - .set_pll = wm8962_set_fll, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm8962 = { + .probe = wm8962_probe, + .remove = wm8962_remove, + .set_bias_level = wm8962_set_bias_level, + .set_pll = wm8962_set_fll, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* Improve power consumption for IN4 DC measurement mode */ @@ -3751,8 +3751,8 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8962, &wm8962_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8962, &wm8962_dai, 1); if (ret < 0) goto err_pm_runtime; @@ -3773,7 +3773,6 @@ err: static int wm8962_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); pm_runtime_disable(&client->dev); return 0; } diff --git a/sound/soc/codecs/wm8962.h b/sound/soc/codecs/wm8962.h index e63a318a3015..a4a42d269747 100644 --- a/sound/soc/codecs/wm8962.h +++ b/sound/soc/codecs/wm8962.h @@ -3779,6 +3779,6 @@ #define WM8962_VSS_ENA_SHIFT 0 /* VSS_ENA */ #define WM8962_VSS_ENA_WIDTH 1 /* VSS_ENA */ -int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c index 3310eda7cf53..998727cb4c31 100644 --- a/sound/soc/samsung/tobermory.c +++ b/sound/soc/samsung/tobermory.c @@ -179,12 +179,12 @@ static struct snd_soc_jack_pin tobermory_headset_pins[] = { static int tobermory_late_probe(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct snd_soc_dai *codec_dai; int ret; rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec = rtd->codec; + component = rtd->codec_dai->component; codec_dai = rtd->codec_dai; ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK, @@ -199,7 +199,7 @@ static int tobermory_late_probe(struct snd_soc_card *card) if (ret) return ret; - wm8962_mic_detect(codec, &tobermory_headset); + wm8962_mic_detect(component, &tobermory_headset); return 0; } From 5d61ef8b07db82746f61927628730ce0407b8897 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:08:15 +0000 Subject: [PATCH 048/942] ASoC: wm8996: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8996.c | 401 +++++++++++++++++------------------ sound/soc/codecs/wm8996.h | 4 +- sound/soc/samsung/speyside.c | 12 +- 3 files changed, 206 insertions(+), 211 deletions(-) diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 8affa4969120..d9d206046f8c 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c @@ -53,7 +53,7 @@ static const char *wm8996_supply_names[WM8996_NUM_SUPPLIES] = { struct wm8996_priv { struct device *dev; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int ldo1ena; @@ -335,9 +335,9 @@ static SOC_ENUM_SINGLE_DECL(dsp1tx_hpf_cutoff, static SOC_ENUM_SINGLE_DECL(dsp2tx_hpf_cutoff, WM8996_DSP2_TX_FILTERS, 0, hpf_cutoff_text); -static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) +static void wm8996_set_retune_mobile(struct snd_soc_component *component, int block) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata; int base, best, best_val, save, i, cfg, iface; @@ -347,7 +347,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) switch (block) { case 0: base = WM8996_DSP1_RX_EQ_GAINS_1; - if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & + if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) & WM8996_DSP1RX_SRC) iface = 1; else @@ -355,7 +355,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) break; case 1: base = WM8996_DSP1_RX_EQ_GAINS_2; - if (snd_soc_read(codec, WM8996_POWER_MANAGEMENT_8) & + if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) & WM8996_DSP2RX_SRC) iface = 1; else @@ -381,7 +381,7 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) } } - dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", block, pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].rate, @@ -390,14 +390,14 @@ static void wm8996_set_retune_mobile(struct snd_soc_codec *codec, int block) /* The EQ will be disabled while reconfiguring it, remember the * current configuration. */ - save = snd_soc_read(codec, base); + save = snd_soc_component_read32(component, base); save &= WM8996_DSP1RX_EQ_ENA; for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++) - snd_soc_update_bits(codec, base + i, 0xffff, + snd_soc_component_update_bits(component, base + i, 0xffff, pdata->retune_mobile_cfgs[best].regs[i]); - snd_soc_update_bits(codec, base, WM8996_DSP1RX_EQ_ENA, save); + snd_soc_component_update_bits(component, base, WM8996_DSP1RX_EQ_ENA, save); } /* Icky as hell but saves code duplication */ @@ -413,8 +413,8 @@ static int wm8996_get_retune_mobile_block(const char *name) static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata; int block = wm8996_get_retune_mobile_block(kcontrol->id.name); int value = ucontrol->value.enumerated.item[0]; @@ -427,7 +427,7 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, wm8996->retune_mobile_cfg[block] = value; - wm8996_set_retune_mobile(codec, block); + wm8996_set_retune_mobile(component, block); return 0; } @@ -435,8 +435,8 @@ static int wm8996_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8996_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int block = wm8996_get_retune_mobile_block(kcontrol->id.name); if (block < 0) @@ -575,40 +575,40 @@ SOC_SINGLE_TLV("DSP2 EQ B5 Volume", WM8996_DSP2_RX_EQ_GAINS_2, 6, 31, 0, eq_tlv), }; -static void wm8996_bg_enable(struct snd_soc_codec *codec) +static void wm8996_bg_enable(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); wm8996->bg_ena++; if (wm8996->bg_ena == 1) { - snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8996_POWER_MANAGEMENT_1, WM8996_BG_ENA, WM8996_BG_ENA); msleep(2); } } -static void wm8996_bg_disable(struct snd_soc_codec *codec) +static void wm8996_bg_disable(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); wm8996->bg_ena--; if (!wm8996->bg_ena) - snd_soc_update_bits(codec, WM8996_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8996_POWER_MANAGEMENT_1, WM8996_BG_ENA, 0); } static int bg_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int ret = 0; switch (event) { case SND_SOC_DAPM_PRE_PMU: - wm8996_bg_enable(codec); + wm8996_bg_enable(component); break; case SND_SOC_DAPM_POST_PMD: - wm8996_bg_disable(codec); + wm8996_bg_disable(component); break; default: WARN(1, "Invalid event %d\n", event); @@ -635,8 +635,8 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int rmv_short_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); /* Record which outputs we enabled */ switch (event) { @@ -654,14 +654,14 @@ static int rmv_short_event(struct snd_soc_dapm_widget *w, return 0; } -static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) +static void wait_for_dc_servo(struct snd_soc_component *component, u16 mask) { - struct i2c_client *i2c = to_i2c_client(codec->dev); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct i2c_client *i2c = to_i2c_client(component->dev); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int ret; unsigned long timeout = 200; - snd_soc_write(codec, WM8996_DC_SERVO_2, mask); + snd_soc_component_write(component, WM8996_DC_SERVO_2, mask); /* Use the interrupt if possible */ do { @@ -669,44 +669,43 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) timeout = wait_for_completion_timeout(&wm8996->dcs_done, msecs_to_jiffies(200)); if (timeout == 0) - dev_err(codec->dev, "DC servo timed out\n"); + dev_err(component->dev, "DC servo timed out\n"); } else { msleep(1); timeout--; } - ret = snd_soc_read(codec, WM8996_DC_SERVO_2); - dev_dbg(codec->dev, "DC servo state: %x\n", ret); + ret = snd_soc_component_read32(component, WM8996_DC_SERVO_2); + dev_dbg(component->dev, "DC servo state: %x\n", ret); } while (timeout && ret & mask); if (timeout == 0) - dev_err(codec->dev, "DC servo timed out for %x\n", mask); + dev_err(component->dev, "DC servo timed out for %x\n", mask); else - dev_dbg(codec->dev, "DC servo complete for %x\n", mask); + dev_dbg(component->dev, "DC servo complete for %x\n", mask); } -static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, +static void wm8996_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); u16 val, mask; /* Complete any pending DC servo starts */ if (wm8996->dcs_pending) { - dev_dbg(codec->dev, "Starting DC servo for %x\n", + dev_dbg(component->dev, "Starting DC servo for %x\n", wm8996->dcs_pending); /* Trigger a startup sequence */ - wait_for_dc_servo(codec, wm8996->dcs_pending + wait_for_dc_servo(component, wm8996->dcs_pending << WM8996_DCS_TRIG_STARTUP_0_SHIFT); wm8996->dcs_pending = 0; } if (wm8996->hpout_pending != wm8996->hpout_ena) { - dev_dbg(codec->dev, "Applying RMV_SHORTs %x->%x\n", + dev_dbg(component->dev, "Applying RMV_SHORTs %x->%x\n", wm8996->hpout_ena, wm8996->hpout_pending); val = 0; @@ -729,7 +728,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, WM8996_HPOUT1R_DLY; } - snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, mask, val); + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, mask, val); val = 0; mask = 0; @@ -751,7 +750,7 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, WM8996_HPOUT2R_DLY; } - snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_2, mask, val); + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_2, mask, val); wm8996->hpout_ena = wm8996->hpout_pending; } @@ -760,8 +759,8 @@ static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, static int dcs_start(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1533,9 +1532,9 @@ static const int bclk_divs[] = { 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96 }; -static void wm8996_update_bclk(struct snd_soc_codec *codec) +static void wm8996_update_bclk(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int aif, best, cur_val, bclk_rate, bclk_reg, i; /* Don't bother if we're in a low frequency idle mode that @@ -1565,18 +1564,18 @@ static void wm8996_update_bclk(struct snd_soc_codec *codec) best = i; } bclk_rate = wm8996->sysclk / bclk_divs[best]; - dev_dbg(codec->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", + dev_dbg(component->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", bclk_divs[best], bclk_rate); - snd_soc_update_bits(codec, bclk_reg, + snd_soc_component_update_bits(component, bclk_reg, WM8996_AIF1_BCLK_DIV_MASK, best); } } -static int wm8996_set_bias_level(struct snd_soc_codec *codec, +static int wm8996_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1584,18 +1583,18 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: /* Put the MICBIASes into regulating mode */ - snd_soc_update_bits(codec, WM8996_MICBIAS_1, + snd_soc_component_update_bits(component, WM8996_MICBIAS_1, WM8996_MICB1_MODE, 0); - snd_soc_update_bits(codec, WM8996_MICBIAS_2, + snd_soc_component_update_bits(component, WM8996_MICBIAS_2, WM8996_MICB2_MODE, 0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8996->supplies), wm8996->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -1612,9 +1611,9 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, } /* Bypass the MICBIASes for lowest power */ - snd_soc_update_bits(codec, WM8996_MICBIAS_1, + snd_soc_component_update_bits(component, WM8996_MICBIAS_1, WM8996_MICB1_MODE, WM8996_MICB1_MODE); - snd_soc_update_bits(codec, WM8996_MICBIAS_2, + snd_soc_component_update_bits(component, WM8996_MICBIAS_2, WM8996_MICB2_MODE, WM8996_MICB2_MODE); break; @@ -1634,7 +1633,7 @@ static int wm8996_set_bias_level(struct snd_soc_codec *codec, static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int aifctrl = 0; int bclk = 0; int lrclk_tx = 0; @@ -1711,15 +1710,15 @@ static int wm8996_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl); - snd_soc_update_bits(codec, bclk_reg, + snd_soc_component_update_bits(component, aifctrl_reg, WM8996_AIF1_FMT_MASK, aifctrl); + snd_soc_component_update_bits(component, bclk_reg, WM8996_AIF1_BCLK_INV | WM8996_AIF1_BCLK_MSTR, bclk); - snd_soc_update_bits(codec, lrclk_tx_reg, + snd_soc_component_update_bits(component, lrclk_tx_reg, WM8996_AIF1TX_LRCLK_INV | WM8996_AIF1TX_LRCLK_MSTR, lrclk_tx); - snd_soc_update_bits(codec, lrclk_rx_reg, + snd_soc_component_update_bits(component, lrclk_rx_reg, WM8996_AIF1RX_LRCLK_INV | WM8996_AIF1RX_LRCLK_MSTR, lrclk_rx); @@ -1735,8 +1734,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int bits, i, bclk_rate, best; int aifdata = 0; int lrclk = 0; @@ -1746,7 +1745,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, switch (dai->id) { case 0: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || - (snd_soc_read(codec, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { + (snd_soc_component_read32(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) { aifdata_reg = WM8996_AIF1RX_DATA_CONFIGURATION; lrclk_reg = WM8996_AIF1_RX_LRCLK_1; } else { @@ -1757,7 +1756,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, break; case 1: if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || - (snd_soc_read(codec, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { + (snd_soc_component_read32(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) { aifdata_reg = WM8996_AIF2RX_DATA_CONFIGURATION; lrclk_reg = WM8996_AIF2_RX_LRCLK_1; } else { @@ -1773,7 +1772,7 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, bclk_rate = snd_soc_params_to_bclk(params); if (bclk_rate < 0) { - dev_err(codec->dev, "Unsupported BCLK rate: %d\n", bclk_rate); + dev_err(component->dev, "Unsupported BCLK rate: %d\n", bclk_rate); return bclk_rate; } @@ -1794,19 +1793,19 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, } dsp |= i << dsp_shift; - wm8996_update_bclk(codec); + wm8996_update_bclk(component); lrclk = bclk_rate / params_rate(params); dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", lrclk, bclk_rate / lrclk); - snd_soc_update_bits(codec, aifdata_reg, + snd_soc_component_update_bits(component, aifdata_reg, WM8996_AIF1TX_WL_MASK | WM8996_AIF1TX_SLOT_LEN_MASK, aifdata); - snd_soc_update_bits(codec, lrclk_reg, WM8996_AIF1RX_RATE_MASK, + snd_soc_component_update_bits(component, lrclk_reg, WM8996_AIF1RX_RATE_MASK, lrclk); - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_2, + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_2, WM8996_DSP1_DIV_MASK << dsp_shift, dsp); return 0; @@ -1815,8 +1814,8 @@ static int wm8996_hw_params(struct snd_pcm_substream *substream, static int wm8996_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int lfclk = 0; int ratediv = 0; int sync = WM8996_REG_SYNC; @@ -1827,8 +1826,8 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, return 0; /* Disable SYSCLK while we reconfigure */ - old = snd_soc_read(codec, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, + old = snd_soc_component_read32(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA; + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, WM8996_SYSCLK_ENA, 0); switch (clk_id) { @@ -1845,14 +1844,14 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, src = 2; break; default: - dev_err(codec->dev, "Unsupported clock source %d\n", clk_id); + dev_err(component->dev, "Unsupported clock source %d\n", clk_id); return -EINVAL; } switch (wm8996->sysclk) { case 5644800: case 6144000: - snd_soc_update_bits(codec, WM8996_AIF_RATE, + snd_soc_component_update_bits(component, WM8996_AIF_RATE, WM8996_SYSCLK_RATE, 0); break; case 22579200: @@ -1861,7 +1860,7 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, wm8996->sysclk /= 2; case 11289600: case 12288000: - snd_soc_update_bits(codec, WM8996_AIF_RATE, + snd_soc_component_update_bits(component, WM8996_AIF_RATE, WM8996_SYSCLK_RATE, WM8996_SYSCLK_RATE); break; case 32000: @@ -1870,20 +1869,20 @@ static int wm8996_set_sysclk(struct snd_soc_dai *dai, sync = 0; break; default: - dev_warn(codec->dev, "Unsupported clock rate %dHz\n", + dev_warn(component->dev, "Unsupported clock rate %dHz\n", wm8996->sysclk); return -EINVAL; } - wm8996_update_bclk(codec); + wm8996_update_bclk(component); - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, WM8996_SYSCLK_SRC_MASK | WM8996_SYSCLK_DIV_MASK, src << WM8996_SYSCLK_SRC_SHIFT | ratediv); - snd_soc_update_bits(codec, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk); - snd_soc_update_bits(codec, WM8996_CONTROL_INTERFACE_1, + snd_soc_component_update_bits(component, WM8996_CLOCKING_1, WM8996_LFCLK_ENA, lfclk); + snd_soc_component_update_bits(component, WM8996_CONTROL_INTERFACE_1, WM8996_REG_SYNC, sync); - snd_soc_update_bits(codec, WM8996_AIF_CLOCKING_1, + snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1, WM8996_SYSCLK_ENA, old); wm8996->sysclk_src = clk_id; @@ -2002,11 +2001,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm8996_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct i2c_client *i2c = to_i2c_client(component->dev); struct _fll_div fll_div; unsigned long timeout, time_left; int ret, reg, retry; @@ -2017,15 +2016,15 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, return 0; if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n"); wm8996->fll_fref = 0; wm8996->fll_fout = 0; - snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_1, WM8996_FLL_ENA, 0); - wm8996_bg_disable(codec); + wm8996_bg_disable(component); return 0; } @@ -2048,14 +2047,14 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, reg = 3; break; default: - dev_err(codec->dev, "Unknown FLL source %d\n", ret); + dev_err(component->dev, "Unknown FLL source %d\n", ret); return -EINVAL; } reg |= fll_div.fll_refclk_div << WM8996_FLL_REFCLK_DIV_SHIFT; reg |= fll_div.fll_ref_freq << WM8996_FLL_REF_FREQ_SHIFT; - snd_soc_update_bits(codec, WM8996_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_5, WM8996_FLL_REFCLK_DIV_MASK | WM8996_FLL_REF_FREQ | WM8996_FLL_REFCLK_SRC_MASK, reg); @@ -2064,38 +2063,38 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, reg |= WM8996_FLL_EFS_ENA | (3 << WM8996_FLL_LFSR_SEL_SHIFT); else reg |= 1 << WM8996_FLL_LFSR_SEL_SHIFT; - snd_soc_write(codec, WM8996_FLL_EFS_2, reg); + snd_soc_component_write(component, WM8996_FLL_EFS_2, reg); - snd_soc_update_bits(codec, WM8996_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_2, WM8996_FLL_OUTDIV_MASK | WM8996_FLL_FRATIO_MASK, (fll_div.fll_outdiv << WM8996_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio)); - snd_soc_write(codec, WM8996_FLL_CONTROL_3, fll_div.theta); + snd_soc_component_write(component, WM8996_FLL_CONTROL_3, fll_div.theta); - snd_soc_update_bits(codec, WM8996_FLL_CONTROL_4, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_4, WM8996_FLL_N_MASK | WM8996_FLL_LOOP_GAIN_MASK, (fll_div.n << WM8996_FLL_N_SHIFT) | fll_div.fll_loop_gain); - snd_soc_write(codec, WM8996_FLL_EFS_1, fll_div.lambda); + snd_soc_component_write(component, WM8996_FLL_EFS_1, fll_div.lambda); /* Enable the bandgap if it's not already enabled */ - ret = snd_soc_read(codec, WM8996_FLL_CONTROL_1); + ret = snd_soc_component_read32(component, WM8996_FLL_CONTROL_1); if (!(ret & WM8996_FLL_ENA)) - wm8996_bg_enable(codec); + wm8996_bg_enable(component); /* Clear any pending completions (eg, from failed startups) */ try_wait_for_completion(&wm8996->fll_lock); - snd_soc_update_bits(codec, WM8996_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8996_FLL_CONTROL_1, WM8996_FLL_ENA, WM8996_FLL_ENA); /* The FLL supports live reconfiguration - kick that in case we were * already enabled. */ - snd_soc_write(codec, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK); + snd_soc_component_write(component, WM8996_FLL_CONTROL_6, WM8996_FLL_SWITCH_CLK); /* Wait for the FLL to lock, using the interrupt if possible */ if (Fref > 1000000) @@ -2121,16 +2120,16 @@ static int wm8996_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; } - ret = snd_soc_read(codec, WM8996_INTERRUPT_RAW_STATUS_2); + ret = snd_soc_component_read32(component, WM8996_INTERRUPT_RAW_STATUS_2); if (ret & WM8996_FLL_LOCK_STS) break; } if (retry == 10) { - dev_err(codec->dev, "Timed out waiting for FLL\n"); + dev_err(component->dev, "Timed out waiting for FLL\n"); ret = -ETIMEDOUT; } - dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); wm8996->fll_fref = Fref; wm8996->fll_fout = Fout; @@ -2237,11 +2236,11 @@ static void wm8996_free_gpio(struct wm8996_priv *wm8996) * will also detect inverted microphone ground connections and update * the polarity of the connections. */ -int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, wm8996_polarity_fn polarity_cb) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); wm8996->jack = jack; wm8996->detecting = true; @@ -2249,12 +2248,12 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, wm8996->jack_flips = 0; if (wm8996->polarity_cb) - wm8996->polarity_cb(codec, 0); + wm8996->polarity_cb(component, 0); /* Clear discarge to avoid noise during detection */ - snd_soc_update_bits(codec, WM8996_MICBIAS_1, + snd_soc_component_update_bits(component, WM8996_MICBIAS_1, WM8996_MICB1_DISCH, 0); - snd_soc_update_bits(codec, WM8996_MICBIAS_2, + snd_soc_component_update_bits(component, WM8996_MICBIAS_2, WM8996_MICB2_DISCH, 0); /* LDO2 powers the microphones, SYSCLK clocks detection */ @@ -2268,26 +2267,26 @@ int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, /* We start off just enabling microphone detection - even a * plain headphone will trigger detection. */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, WM8996_MICD_ENA); /* Slowest detection rate, gives debounce for initial detection */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK, WM8996_MICD_RATE_MASK); /* Enable interrupts and we're off */ - snd_soc_update_bits(codec, WM8996_INTERRUPT_STATUS_2_MASK, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_STATUS_2_MASK, WM8996_IM_MICD_EINT | WM8996_HP_DONE_EINT, 0); return 0; } EXPORT_SYMBOL_GPL(wm8996_detect); -static void wm8996_hpdet_irq(struct snd_soc_codec *codec) +static void wm8996_hpdet_irq(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int val, reg, report; /* Assume headphone in error conditions; we need to report @@ -2295,20 +2294,20 @@ static void wm8996_hpdet_irq(struct snd_soc_codec *codec) */ report = SND_JACK_HEADPHONE; - reg = snd_soc_read(codec, WM8996_HEADPHONE_DETECT_2); + reg = snd_soc_component_read32(component, WM8996_HEADPHONE_DETECT_2); if (reg < 0) { - dev_err(codec->dev, "Failed to read HPDET status\n"); + dev_err(component->dev, "Failed to read HPDET status\n"); goto out; } if (!(reg & WM8996_HP_DONE)) { - dev_err(codec->dev, "Got HPDET IRQ but HPDET is busy\n"); + dev_err(component->dev, "Got HPDET IRQ but HPDET is busy\n"); goto out; } val = reg & WM8996_HP_LVL_MASK; - dev_dbg(codec->dev, "HPDET measured %d ohms\n", val); + dev_dbg(component->dev, "HPDET measured %d ohms\n", val); /* If we've got high enough impedence then report as line, * otherwise assume headphone. @@ -2328,28 +2327,28 @@ out: wm8996->detecting = false; /* If the output isn't running re-clamp it */ - if (!(snd_soc_read(codec, WM8996_POWER_MANAGEMENT_1) & + if (!(snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_1) & (WM8996_HPOUT1L_ENA | WM8996_HPOUT1R_RMV_SHORT))) - snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1R_RMV_SHORT, 0); /* Go back to looking at the microphone */ - snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, + snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_1, WM8996_JD_MODE_MASK, 0); - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, WM8996_MICD_ENA); snd_soc_dapm_disable_pin(dapm, "Bandgap"); snd_soc_dapm_sync(dapm); } -static void wm8996_hpdet_start(struct snd_soc_codec *codec) +static void wm8996_hpdet_start(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); /* Unclamp the output, we can't measure while we're shorting it */ - snd_soc_update_bits(codec, WM8996_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1, WM8996_HPOUT1L_RMV_SHORT | WM8996_HPOUT1R_RMV_SHORT, WM8996_HPOUT1L_RMV_SHORT | @@ -2360,45 +2359,45 @@ static void wm8996_hpdet_start(struct snd_soc_codec *codec) snd_soc_dapm_sync(dapm); /* Go into headphone detect left mode */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0); - snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_ENA, 0); + snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_1, WM8996_JD_MODE_MASK, 1); /* Trigger a measurement */ - snd_soc_update_bits(codec, WM8996_HEADPHONE_DETECT_1, + snd_soc_component_update_bits(component, WM8996_HEADPHONE_DETECT_1, WM8996_HP_POLL, WM8996_HP_POLL); } -static void wm8996_report_headphone(struct snd_soc_codec *codec) +static void wm8996_report_headphone(struct snd_soc_component *component) { - dev_dbg(codec->dev, "Headphone detected\n"); - wm8996_hpdet_start(codec); + dev_dbg(component->dev, "Headphone detected\n"); + wm8996_hpdet_start(component); /* Increase the detection rate a bit for responsiveness. */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK | WM8996_MICD_BIAS_STARTTIME_MASK, 7 << WM8996_MICD_RATE_SHIFT | 7 << WM8996_MICD_BIAS_STARTTIME_SHIFT); } -static void wm8996_micd(struct snd_soc_codec *codec) +static void wm8996_micd(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int val, reg; - val = snd_soc_read(codec, WM8996_MIC_DETECT_3); + val = snd_soc_component_read32(component, WM8996_MIC_DETECT_3); - dev_dbg(codec->dev, "Microphone event: %x\n", val); + dev_dbg(component->dev, "Microphone event: %x\n", val); if (!(val & WM8996_MICD_VALID)) { - dev_warn(codec->dev, "Microphone detection state invalid\n"); + dev_warn(component->dev, "Microphone detection state invalid\n"); return; } /* No accessory, reset everything and report removal */ if (!(val & WM8996_MICD_STS)) { - dev_dbg(codec->dev, "Jack removal detected\n"); + dev_dbg(component->dev, "Jack removal detected\n"); wm8996->jack_mic = false; wm8996->detecting = true; wm8996->jack_flips = 0; @@ -2406,7 +2405,7 @@ static void wm8996_micd(struct snd_soc_codec *codec) SND_JACK_LINEOUT | SND_JACK_HEADSET | SND_JACK_BTN_0); - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK | WM8996_MICD_BIAS_STARTTIME_MASK, WM8996_MICD_RATE_MASK | @@ -2420,19 +2419,19 @@ static void wm8996_micd(struct snd_soc_codec *codec) */ if (val & 0x400) { if (wm8996->detecting) { - dev_dbg(codec->dev, "Microphone detected\n"); + dev_dbg(component->dev, "Microphone detected\n"); wm8996->jack_mic = true; - wm8996_hpdet_start(codec); + wm8996_hpdet_start(component); /* Increase poll rate to give better responsiveness * for buttons */ - snd_soc_update_bits(codec, WM8996_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8996_MIC_DETECT_1, WM8996_MICD_RATE_MASK | WM8996_MICD_BIAS_STARTTIME_MASK, 5 << WM8996_MICD_RATE_SHIFT | 7 << WM8996_MICD_BIAS_STARTTIME_SHIFT); } else { - dev_dbg(codec->dev, "Mic button up\n"); + dev_dbg(component->dev, "Mic button up\n"); snd_soc_jack_report(wm8996->jack, 0, SND_JACK_BTN_0); } @@ -2449,22 +2448,22 @@ static void wm8996_micd(struct snd_soc_codec *codec) wm8996->jack_flips++; if (wm8996->jack_flips > 1) { - wm8996_report_headphone(codec); + wm8996_report_headphone(component); return; } - reg = snd_soc_read(codec, WM8996_ACCESSORY_DETECT_MODE_2); + reg = snd_soc_component_read32(component, WM8996_ACCESSORY_DETECT_MODE_2); reg ^= WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | WM8996_MICD_BIAS_SRC; - snd_soc_update_bits(codec, WM8996_ACCESSORY_DETECT_MODE_2, + snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_2, WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC | WM8996_MICD_BIAS_SRC, reg); if (wm8996->polarity_cb) - wm8996->polarity_cb(codec, + wm8996->polarity_cb(component, (reg & WM8996_MICD_SRC) != 0); - dev_dbg(codec->dev, "Set microphone polarity to %d\n", + dev_dbg(component->dev, "Set microphone polarity to %d\n", (reg & WM8996_MICD_SRC) != 0); return; @@ -2475,52 +2474,52 @@ static void wm8996_micd(struct snd_soc_codec *codec) */ if (val & 0x3fc) { if (wm8996->jack_mic) { - dev_dbg(codec->dev, "Mic button detected\n"); + dev_dbg(component->dev, "Mic button detected\n"); snd_soc_jack_report(wm8996->jack, SND_JACK_BTN_0, SND_JACK_BTN_0); } else if (wm8996->detecting) { - wm8996_report_headphone(codec); + wm8996_report_headphone(component); } } } static irqreturn_t wm8996_irq(int irq, void *data) { - struct snd_soc_codec *codec = data; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = data; + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); int irq_val; - irq_val = snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2); + irq_val = snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2); if (irq_val < 0) { - dev_err(codec->dev, "Failed to read IRQ status: %d\n", + dev_err(component->dev, "Failed to read IRQ status: %d\n", irq_val); return IRQ_NONE; } - irq_val &= ~snd_soc_read(codec, WM8996_INTERRUPT_STATUS_2_MASK); + irq_val &= ~snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2_MASK); if (!irq_val) return IRQ_NONE; - snd_soc_write(codec, WM8996_INTERRUPT_STATUS_2, irq_val); + snd_soc_component_write(component, WM8996_INTERRUPT_STATUS_2, irq_val); if (irq_val & (WM8996_DCS_DONE_01_EINT | WM8996_DCS_DONE_23_EINT)) { - dev_dbg(codec->dev, "DC servo IRQ\n"); + dev_dbg(component->dev, "DC servo IRQ\n"); complete(&wm8996->dcs_done); } if (irq_val & WM8996_FIFOS_ERR_EINT) - dev_err(codec->dev, "Digital core FIFO error\n"); + dev_err(component->dev, "Digital core FIFO error\n"); if (irq_val & WM8996_FLL_LOCK_EINT) { - dev_dbg(codec->dev, "FLL locked\n"); + dev_dbg(component->dev, "FLL locked\n"); complete(&wm8996->fll_lock); } if (irq_val & WM8996_MICD_EINT) - wm8996_micd(codec); + wm8996_micd(component); if (irq_val & WM8996_HP_DONE_EINT) - wm8996_hpdet_irq(codec); + wm8996_hpdet_irq(component); return IRQ_HANDLED; } @@ -2539,9 +2538,9 @@ static irqreturn_t wm8996_edge_irq(int irq, void *data) return ret; } -static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) +static void wm8996_retune_mobile_pdata(struct snd_soc_component *component) { - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); struct wm8996_pdata *pdata = &wm8996->pdata; struct snd_kcontrol_new controls[] = { @@ -2590,15 +2589,15 @@ static void wm8996_retune_mobile_pdata(struct snd_soc_codec *codec) wm8996->retune_mobile_texts = t; } - dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", + dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", wm8996->num_retune_mobile_texts); wm8996->retune_mobile_enum.items = wm8996->num_retune_mobile_texts; wm8996->retune_mobile_enum.texts = wm8996->retune_mobile_texts; - ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); + ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls)); if (ret != 0) - dev_err(codec->dev, + dev_err(component->dev, "Failed to add ReTune Mobile controls: %d\n", ret); } @@ -2614,22 +2613,22 @@ static const struct regmap_config wm8996_regmap = { .cache_type = REGCACHE_RBTREE, }; -static int wm8996_probe(struct snd_soc_codec *codec) +static int wm8996_probe(struct snd_soc_component *component) { int ret; - struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component); + struct i2c_client *i2c = to_i2c_client(component->dev); int irq_flags; - wm8996->codec = codec; + wm8996->component = component; init_completion(&wm8996->dcs_done); init_completion(&wm8996->fll_lock); if (wm8996->pdata.num_retune_mobile_cfgs) - wm8996_retune_mobile_pdata(codec); + wm8996_retune_mobile_pdata(component); else - snd_soc_add_codec_controls(codec, wm8996_eq_controls, + snd_soc_add_component_controls(component, wm8996_eq_controls, ARRAY_SIZE(wm8996_eq_controls)); if (i2c->irq) { @@ -2643,18 +2642,18 @@ static int wm8996_probe(struct snd_soc_codec *codec) if (irq_flags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING)) ret = request_threaded_irq(i2c->irq, NULL, wm8996_edge_irq, - irq_flags, "wm8996", codec); + irq_flags, "wm8996", component); else ret = request_threaded_irq(i2c->irq, NULL, wm8996_irq, - irq_flags, "wm8996", codec); + irq_flags, "wm8996", component); if (ret == 0) { /* Unmask the interrupt */ - snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_CONTROL, WM8996_IM_IRQ, 0); /* Enable error reporting and DC servo status */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_STATUS_2_MASK, WM8996_IM_DCS_DONE_23_EINT | WM8996_IM_DCS_DONE_01_EINT | @@ -2662,7 +2661,7 @@ static int wm8996_probe(struct snd_soc_codec *codec) WM8996_IM_FIFOS_ERR_EINT, 0); } else { - dev_err(codec->dev, "Failed to request IRQ: %d\n", + dev_err(component->dev, "Failed to request IRQ: %d\n", ret); return ret; } @@ -2671,34 +2670,33 @@ static int wm8996_probe(struct snd_soc_codec *codec) return 0; } -static int wm8996_remove(struct snd_soc_codec *codec) +static void wm8996_remove(struct snd_soc_component *component) { - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct i2c_client *i2c = to_i2c_client(component->dev); - snd_soc_update_bits(codec, WM8996_INTERRUPT_CONTROL, + snd_soc_component_update_bits(component, WM8996_INTERRUPT_CONTROL, WM8996_IM_IRQ, WM8996_IM_IRQ); if (i2c->irq) - free_irq(i2c->irq, codec); - - return 0; + free_irq(i2c->irq, component); } -static const struct snd_soc_codec_driver soc_codec_dev_wm8996 = { - .probe = wm8996_probe, - .remove = wm8996_remove, - .set_bias_level = wm8996_set_bias_level, - .idle_bias_off = true, - .seq_notifier = wm8996_seq_notifier, - .component_driver = { - .controls = wm8996_snd_controls, - .num_controls = ARRAY_SIZE(wm8996_snd_controls), - .dapm_widgets = wm8996_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8996_dapm_widgets), - .dapm_routes = wm8996_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8996_dapm_routes), - }, - .set_pll = wm8996_set_fll, +static const struct snd_soc_component_driver soc_component_dev_wm8996 = { + .probe = wm8996_probe, + .remove = wm8996_remove, + .set_bias_level = wm8996_set_bias_level, + .seq_notifier = wm8996_seq_notifier, + .controls = wm8996_snd_controls, + .num_controls = ARRAY_SIZE(wm8996_snd_controls), + .dapm_widgets = wm8996_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8996_dapm_widgets), + .dapm_routes = wm8996_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8996_dapm_routes), + .set_pll = wm8996_set_fll, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, + }; #define WM8996_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\ @@ -3046,8 +3044,8 @@ static int wm8996_i2c_probe(struct i2c_client *i2c, wm8996_init_gpio(wm8996); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8996, wm8996_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8996, wm8996_dai, ARRAY_SIZE(wm8996_dai)); if (ret < 0) goto err_gpiolib; @@ -3074,7 +3072,6 @@ static int wm8996_i2c_remove(struct i2c_client *client) struct wm8996_priv *wm8996 = i2c_get_clientdata(client); int i; - snd_soc_unregister_codec(&client->dev); wm8996_free_gpio(wm8996); if (wm8996->pdata.ldo_ena > 0) { gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0); diff --git a/sound/soc/codecs/wm8996.h b/sound/soc/codecs/wm8996.h index de9ac3e44aec..b38769958752 100644 --- a/sound/soc/codecs/wm8996.h +++ b/sound/soc/codecs/wm8996.h @@ -22,9 +22,9 @@ #define WM8996_FLL_DACLRCLK1 3 #define WM8996_FLL_BCLK1 4 -typedef void (*wm8996_polarity_fn)(struct snd_soc_codec *codec, int polarity); +typedef void (*wm8996_polarity_fn)(struct snd_soc_component *component, int polarity); -int wm8996_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8996_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, wm8996_polarity_fn polarity_cb); /* diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c index 083ef5e21b17..4b4147d07804 100644 --- a/sound/soc/samsung/speyside.c +++ b/sound/soc/samsung/speyside.c @@ -124,14 +124,14 @@ static int speyside_get_micbias(struct snd_soc_dapm_widget *source, return 0; } -static void speyside_set_polarity(struct snd_soc_codec *codec, +static void speyside_set_polarity(struct snd_soc_component *component, int polarity) { speyside_jack_polarity = !polarity; gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); /* Re-run DAPM to make sure we're using the correct mic bias */ - snd_soc_dapm_sync(snd_soc_codec_get_dapm(codec)); + snd_soc_dapm_sync(snd_soc_component_get_dapm(component)); } static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) @@ -149,7 +149,7 @@ static int speyside_wm0010_init(struct snd_soc_pcm_runtime *rtd) static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *dai = rtd->codec_dai; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = dai->component; int ret; ret = snd_soc_dai_set_sysclk(dai, WM8996_SYSCLK_MCLK2, 32768, 0); @@ -168,7 +168,7 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - wm8996_detect(codec, &speyside_headset, speyside_set_polarity); + wm8996_detect(component, &speyside_headset, speyside_set_polarity); return 0; } @@ -232,10 +232,8 @@ static struct snd_soc_dai_link speyside_dai[] = { static int speyside_wm9081_init(struct snd_soc_component *component) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - /* At any time the WM9081 is active it will have this clock */ - return snd_soc_codec_set_sysclk(codec, WM9081_SYSCLK_MCLK, 0, + return snd_soc_component_set_sysclk(component, WM9081_SYSCLK_MCLK, 0, MCLK_AUDIO_RATE, 0); } From bf338e5b6c00859a259ce3f56b9f04a3f0bb075b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:08:29 +0000 Subject: [PATCH 049/942] ASoC: wm8991: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8991.c | 167 ++++++++++++++++++-------------------- 1 file changed, 80 insertions(+), 87 deletions(-) diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index 802c0694e5c3..76a639df6417 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c @@ -133,7 +133,7 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(out_sidetone_tlv, static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int reg = kcontrol->private_value & 0xff; int ret; u16 val; @@ -143,8 +143,8 @@ static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol *kcontrol, return ret; /* now hit the volume update bits (always bit 8) */ - val = snd_soc_read(codec, reg); - return snd_soc_write(codec, reg, val | 0x0100); + val = snd_soc_component_read32(component, reg); + return snd_soc_component_write(component, reg, val | 0x0100); } static const char *wm8991_digital_sidetone[] = @@ -361,14 +361,14 @@ static const struct snd_kcontrol_new wm8991_snd_controls[] = { static int outmixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u32 reg_shift = kcontrol->private_value & 0xfff; int ret = 0; u16 reg; switch (reg_shift) { case WM8991_SPEAKER_MIXER | (WM8991_LDSPK_BIT << 8): - reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER1); if (reg & WM8991_LDLO) { printk(KERN_WARNING "Cannot set as Output Mixer 1 LDLO Set\n"); @@ -377,7 +377,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break; case WM8991_SPEAKER_MIXER | (WM8991_RDSPK_BIT << 8): - reg = snd_soc_read(codec, WM8991_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8991_OUTPUT_MIXER2); if (reg & WM8991_RDRO) { printk(KERN_WARNING "Cannot set as Output Mixer 2 RDRO Set\n"); @@ -386,7 +386,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break; case WM8991_OUTPUT_MIXER1 | (WM8991_LDLO_BIT << 8): - reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER); if (reg & WM8991_LDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer LDSPK Set\n"); @@ -395,7 +395,7 @@ static int outmixer_event(struct snd_soc_dapm_widget *w, break; case WM8991_OUTPUT_MIXER2 | (WM8991_RDRO_BIT << 8): - reg = snd_soc_read(codec, WM8991_SPEAKER_MIXER); + reg = snd_soc_component_read32(component, WM8991_SPEAKER_MIXER); if (reg & WM8991_RDSPK) { printk(KERN_WARNING "Cannot set as Speaker Mixer RDSPK Set\n"); @@ -927,31 +927,31 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int src, unsigned int freq_in, unsigned int freq_out) { u16 reg; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct _pll_div pll_div; if (freq_in && freq_out) { pll_factors(&pll_div, freq_out * 4, freq_in); /* Turn on PLL */ - reg = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_2); + reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2); reg |= WM8991_PLL_ENA; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_2, reg); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg); /* sysclk comes from PLL */ - reg = snd_soc_read(codec, WM8991_CLOCKING_2); - snd_soc_write(codec, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC); + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | WM8991_SYSCLK_SRC); /* set up N , fractional mode and pre-divisor if necessary */ - snd_soc_write(codec, WM8991_PLL1, pll_div.n | WM8991_SDM | + snd_soc_component_write(component, WM8991_PLL1, pll_div.n | WM8991_SDM | (pll_div.div2 ? WM8991_PRESCALE : 0)); - snd_soc_write(codec, WM8991_PLL2, (u8)(pll_div.k>>8)); - snd_soc_write(codec, WM8991_PLL3, (u8)(pll_div.k & 0xFF)); + snd_soc_component_write(component, WM8991_PLL2, (u8)(pll_div.k>>8)); + snd_soc_component_write(component, WM8991_PLL3, (u8)(pll_div.k & 0xFF)); } else { /* Turn on PLL */ - reg = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_2); + reg = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_2); reg &= ~WM8991_PLL_ENA; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_2, reg); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_2, reg); } return 0; } @@ -962,11 +962,11 @@ static int wm8991_set_dai_pll(struct snd_soc_dai *codec_dai, static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 audio1, audio3; - audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1); - audio3 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_3); + audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1); + audio3 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_3); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1007,37 +1007,37 @@ static int wm8991_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1); - snd_soc_write(codec, WM8991_AUDIO_INTERFACE_3, audio3); + snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_3, audio3); return 0; } static int wm8991_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; switch (div_id) { case WM8991_MCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & ~WM8991_MCLK_DIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); break; case WM8991_DACCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & ~WM8991_DAC_CLKDIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); break; case WM8991_ADCCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_2) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_2) & ~WM8991_ADC_CLKDIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_2, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_2, reg | div); break; case WM8991_BCLK_DIV: - reg = snd_soc_read(codec, WM8991_CLOCKING_1) & + reg = snd_soc_component_read32(component, WM8991_CLOCKING_1) & ~WM8991_BCLK_DIV_MASK; - snd_soc_write(codec, WM8991_CLOCKING_1, reg | div); + snd_soc_component_write(component, WM8991_CLOCKING_1, reg | div); break; default: return -EINVAL; @@ -1053,8 +1053,8 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + u16 audio1 = snd_soc_component_read32(component, WM8991_AUDIO_INTERFACE_1); audio1 &= ~WM8991_AIF_WL_MASK; /* bit size */ @@ -1072,27 +1072,27 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, break; } - snd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1); + snd_soc_component_write(component, WM8991_AUDIO_INTERFACE_1, audio1); return 0; } static int wm8991_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 val; - val = snd_soc_read(codec, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; + val = snd_soc_component_read32(component, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE; if (mute) - snd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); + snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); else - snd_soc_write(codec, WM8991_DAC_CTRL, val); + snd_soc_component_write(component, WM8991_DAC_CTRL, val); return 0; } -static int wm8991_set_bias_level(struct snd_soc_codec *codec, +static int wm8991_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8991_priv *wm8991 = snd_soc_codec_get_drvdata(codec); + struct wm8991_priv *wm8991 = snd_soc_component_get_drvdata(component); u16 val; switch (level) { @@ -1101,22 +1101,22 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID=2*50k */ - val = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) & ~WM8991_VMID_MODE_MASK; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, val | 0x2); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x2); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(wm8991->regmap); /* Enable all output discharge bits */ - snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | + snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE | WM8991_DIS_RLINE | WM8991_DIS_OUT3 | WM8991_DIS_OUT4 | WM8991_DIS_LOUT | WM8991_DIS_ROUT); /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_VMIDTOG); @@ -1124,78 +1124,78 @@ static int wm8991_set_bias_level(struct snd_soc_codec *codec, msleep(300); /* Disable VMIDTOG */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL); /* disable all output discharge bits */ - snd_soc_write(codec, WM8991_ANTIPOP1, 0); + snd_soc_component_write(component, WM8991_ANTIPOP1, 0); /* Enable outputs */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1b00); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1b00); msleep(50); /* Enable VMID at 2x50k */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f02); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f02); msleep(100); /* Enable VREF */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f03); msleep(600); /* Enable BUFIOEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFIOEN); /* Disable outputs */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x3); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x3); /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_BUFIOEN); + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_BUFIOEN); } /* VMID=2*250k */ - val = snd_soc_read(codec, WM8991_POWER_MANAGEMENT_1) & + val = snd_soc_component_read32(component, WM8991_POWER_MANAGEMENT_1) & ~WM8991_VMID_MODE_MASK; - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, val | 0x4); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, val | 0x4); break; case SND_SOC_BIAS_OFF: /* Enable POBCTRL and SOFT_ST */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_POBCTRL | WM8991_BUFIOEN); /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, WM8991_SOFTST | + snd_soc_component_write(component, WM8991_ANTIPOP2, WM8991_SOFTST | WM8991_BUFDCOPEN | WM8991_POBCTRL | WM8991_BUFIOEN); /* mute DAC */ - val = snd_soc_read(codec, WM8991_DAC_CTRL); - snd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); + val = snd_soc_component_read32(component, WM8991_DAC_CTRL); + snd_soc_component_write(component, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE); /* Enable any disabled outputs */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f03); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f03); /* Disable VMID */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x1f01); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x1f01); msleep(300); /* Enable all output discharge bits */ - snd_soc_write(codec, WM8991_ANTIPOP1, WM8991_DIS_LLINE | + snd_soc_component_write(component, WM8991_ANTIPOP1, WM8991_DIS_LLINE | WM8991_DIS_RLINE | WM8991_DIS_OUT3 | WM8991_DIS_OUT4 | WM8991_DIS_LOUT | WM8991_DIS_ROUT); /* Disable VREF */ - snd_soc_write(codec, WM8991_POWER_MANAGEMENT_1, 0x0); + snd_soc_component_write(component, WM8991_POWER_MANAGEMENT_1, 0x0); /* disable POBCTRL, SOFT_ST and BUFDCOPEN */ - snd_soc_write(codec, WM8991_ANTIPOP2, 0x0); + snd_soc_component_write(component, WM8991_ANTIPOP2, 0x0); regcache_mark_dirty(wm8991->regmap); break; } @@ -1242,18 +1242,19 @@ static struct snd_soc_dai_driver wm8991_dai = { .ops = &wm8991_ops }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8991 = { - .set_bias_level = wm8991_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8991_snd_controls, - .num_controls = ARRAY_SIZE(wm8991_snd_controls), - .dapm_widgets = wm8991_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), - .dapm_routes = wm8991_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8991 = { + .set_bias_level = wm8991_set_bias_level, + .controls = wm8991_snd_controls, + .num_controls = ARRAY_SIZE(wm8991_snd_controls), + .dapm_widgets = wm8991_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8991_dapm_widgets), + .dapm_routes = wm8991_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8991_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8991_regmap = { @@ -1319,19 +1320,12 @@ static int wm8991_i2c_probe(struct i2c_client *i2c, regmap_write(wm8991->regmap, WM8991_RIGHT_OUTPUT_VOLUME, 0x50 | (1<<8)); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8991, &wm8991_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8991, &wm8991_dai, 1); return ret; } -static int wm8991_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8991_i2c_id[] = { { "wm8991", 0 }, { } @@ -1343,7 +1337,6 @@ static struct i2c_driver wm8991_i2c_driver = { .name = "wm8991", }, .probe = wm8991_i2c_probe, - .remove = wm8991_i2c_remove, .id_table = wm8991_i2c_id, }; From 708ebb3beb93813c58dc359d00665ad660917b1f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:08:45 +0000 Subject: [PATCH 050/942] ASoC: wm8995: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8995.c | 286 ++++++++++++++++++-------------------- 1 file changed, 135 insertions(+), 151 deletions(-) diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index 19b08a5cae62..60e227832331 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c @@ -385,7 +385,7 @@ struct wm8995_priv { struct fll_config fll[2], fll_suspend[2]; struct regulator_bulk_data supplies[WM8995_NUM_SUPPLIES]; struct notifier_block disable_nb[WM8995_NUM_SUPPLIES]; - struct snd_soc_codec *codec; + struct snd_soc_component *component; }; /* @@ -485,48 +485,48 @@ static const struct snd_kcontrol_new wm8995_snd_controls[] = { WM8995_AIF2_ADC_RIGHT_VOLUME, 0, 96, 0, digital_tlv) }; -static void wm8995_update_class_w(struct snd_soc_codec *codec) +static void wm8995_update_class_w(struct snd_soc_component *component) { int enable = 1; int source = 0; /* GCC flow analysis can't track enable */ int reg, reg_r; /* We also need the same setting for L/R and only one path */ - reg = snd_soc_read(codec, WM8995_DAC1_LEFT_MIXER_ROUTING); + reg = snd_soc_component_read32(component, WM8995_DAC1_LEFT_MIXER_ROUTING); switch (reg) { case WM8995_AIF2DACL_TO_DAC1L: - dev_dbg(codec->dev, "Class W source AIF2DAC\n"); + dev_dbg(component->dev, "Class W source AIF2DAC\n"); source = 2 << WM8995_CP_DYN_SRC_SEL_SHIFT; break; case WM8995_AIF1DAC2L_TO_DAC1L: - dev_dbg(codec->dev, "Class W source AIF1DAC2\n"); + dev_dbg(component->dev, "Class W source AIF1DAC2\n"); source = 1 << WM8995_CP_DYN_SRC_SEL_SHIFT; break; case WM8995_AIF1DAC1L_TO_DAC1L: - dev_dbg(codec->dev, "Class W source AIF1DAC1\n"); + dev_dbg(component->dev, "Class W source AIF1DAC1\n"); source = 0 << WM8995_CP_DYN_SRC_SEL_SHIFT; break; default: - dev_dbg(codec->dev, "DAC mixer setting: %x\n", reg); + dev_dbg(component->dev, "DAC mixer setting: %x\n", reg); enable = 0; break; } - reg_r = snd_soc_read(codec, WM8995_DAC1_RIGHT_MIXER_ROUTING); + reg_r = snd_soc_component_read32(component, WM8995_DAC1_RIGHT_MIXER_ROUTING); if (reg_r != reg) { - dev_dbg(codec->dev, "Left and right DAC mixers different\n"); + dev_dbg(component->dev, "Left and right DAC mixers different\n"); enable = 0; } if (enable) { - dev_dbg(codec->dev, "Class W enabled\n"); - snd_soc_update_bits(codec, WM8995_CLASS_W_1, + dev_dbg(component->dev, "Class W enabled\n"); + snd_soc_component_update_bits(component, WM8995_CLASS_W_1, WM8995_CP_DYN_PWR_MASK | WM8995_CP_DYN_SRC_SEL_MASK, source | WM8995_CP_DYN_PWR); } else { - dev_dbg(codec->dev, "Class W disabled\n"); - snd_soc_update_bits(codec, WM8995_CLASS_W_1, + dev_dbg(component->dev, "Class W disabled\n"); + snd_soc_component_update_bits(component, WM8995_CLASS_W_1, WM8995_CP_DYN_PWR_MASK, 0); } } @@ -534,11 +534,11 @@ static void wm8995_update_class_w(struct snd_soc_codec *codec) static int check_clk_sys(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; const char *clk; - reg = snd_soc_read(codec, WM8995_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8995_CLOCKING_1); /* Check what we're currently using for CLK_SYS */ if (reg & WM8995_SYSCLK_SRC) clk = "AIF2CLK"; @@ -550,37 +550,37 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source, static int wm8995_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); int ret; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); - wm8995_update_class_w(codec); + wm8995_update_class_w(component); return ret; } static int hp_supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable the headphone amp */ - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1L_ENA | WM8995_HPOUT1R_ENA); /* Enable the second stage */ - snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1, WM8995_HPOUT1L_DLY_MASK | WM8995_HPOUT1R_DLY_MASK, WM8995_HPOUT1L_DLY | WM8995_HPOUT1R_DLY); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8995_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM8995_CHARGE_PUMP_1, WM8995_CP_ENA_MASK, 0); break; } @@ -588,41 +588,41 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, return 0; } -static void dc_servo_cmd(struct snd_soc_codec *codec, +static void dc_servo_cmd(struct snd_soc_component *component, unsigned int reg, unsigned int val, unsigned int mask) { int timeout = 10; - dev_dbg(codec->dev, "%s: reg = %#x, val = %#x, mask = %#x\n", + dev_dbg(component->dev, "%s: reg = %#x, val = %#x, mask = %#x\n", __func__, reg, val, mask); - snd_soc_write(codec, reg, val); + snd_soc_component_write(component, reg, val); while (timeout--) { msleep(10); - val = snd_soc_read(codec, WM8995_DC_SERVO_READBACK_0); + val = snd_soc_component_read32(component, WM8995_DC_SERVO_READBACK_0); if ((val & mask) == mask) return; } - dev_err(codec->dev, "Timed out waiting for DC Servo\n"); + dev_err(component->dev, "Timed out waiting for DC Servo\n"); } static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int reg; - reg = snd_soc_read(codec, WM8995_ANALOGUE_HP_1); + reg = snd_soc_component_read32(component, WM8995_ANALOGUE_HP_1); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM8995_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM8995_CHARGE_PUMP_1, WM8995_CP_ENA_MASK, WM8995_CP_ENA); msleep(5); - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1R_ENA_MASK, WM8995_HPOUT1L_ENA | WM8995_HPOUT1R_ENA); @@ -630,12 +630,12 @@ static int hp_event(struct snd_soc_dapm_widget *w, udelay(20); reg |= WM8995_HPOUT1L_DLY | WM8995_HPOUT1R_DLY; - snd_soc_write(codec, WM8995_ANALOGUE_HP_1, reg); + snd_soc_component_write(component, WM8995_ANALOGUE_HP_1, reg); - snd_soc_write(codec, WM8995_DC_SERVO_1, WM8995_DCS_ENA_CHAN_0 | + snd_soc_component_write(component, WM8995_DC_SERVO_1, WM8995_DCS_ENA_CHAN_0 | WM8995_DCS_ENA_CHAN_1); - dc_servo_cmd(codec, WM8995_DC_SERVO_2, + dc_servo_cmd(component, WM8995_DC_SERVO_2, WM8995_DCS_TRIG_STARTUP_0 | WM8995_DCS_TRIG_STARTUP_1, WM8995_DCS_TRIG_DAC_WR_0 | @@ -643,23 +643,23 @@ static int hp_event(struct snd_soc_dapm_widget *w, reg |= WM8995_HPOUT1R_OUTP | WM8995_HPOUT1R_RMV_SHORT | WM8995_HPOUT1L_OUTP | WM8995_HPOUT1L_RMV_SHORT; - snd_soc_write(codec, WM8995_ANALOGUE_HP_1, reg); + snd_soc_component_write(component, WM8995_ANALOGUE_HP_1, reg); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1, WM8995_HPOUT1L_OUTP_MASK | WM8995_HPOUT1R_OUTP_MASK | WM8995_HPOUT1L_RMV_SHORT_MASK | WM8995_HPOUT1R_RMV_SHORT_MASK, 0); - snd_soc_update_bits(codec, WM8995_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8995_ANALOGUE_HP_1, WM8995_HPOUT1L_DLY_MASK | WM8995_HPOUT1R_DLY_MASK, 0); - snd_soc_write(codec, WM8995_DC_SERVO_1, 0); + snd_soc_component_write(component, WM8995_DC_SERVO_1, 0); - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_HPOUT1L_ENA_MASK | WM8995_HPOUT1R_ENA_MASK, 0); @@ -669,14 +669,14 @@ static int hp_event(struct snd_soc_dapm_widget *w, return 0; } -static int configure_aif_clock(struct snd_soc_codec *codec, int aif) +static int configure_aif_clock(struct snd_soc_component *component, int aif) { struct wm8995_priv *wm8995; int rate; int reg1 = 0; int offset; - wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component); if (aif) offset = 4; @@ -707,29 +707,29 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif) rate /= 2; reg1 |= WM8995_AIF1CLK_DIV; - dev_dbg(codec->dev, "Dividing AIF%d clock to %dHz\n", + dev_dbg(component->dev, "Dividing AIF%d clock to %dHz\n", aif + 1, rate); } wm8995->aifclk[aif] = rate; - snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1 + offset, + snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1 + offset, WM8995_AIF1CLK_SRC_MASK | WM8995_AIF1CLK_DIV_MASK, reg1); return 0; } -static int configure_clock(struct snd_soc_codec *codec) +static int configure_clock(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct wm8995_priv *wm8995; int change, new; - wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component); /* Bring up the AIF clocks first */ - configure_aif_clock(codec, 0); - configure_aif_clock(codec, 1); + configure_aif_clock(component, 0); + configure_aif_clock(component, 1); /* * Then switch CLK_SYS over to the higher of them; a change @@ -747,7 +747,7 @@ static int configure_clock(struct snd_soc_codec *codec) else new = 0; - change = snd_soc_update_bits(codec, WM8995_CLOCKING_1, + change = snd_soc_component_update_bits(component, WM8995_CLOCKING_1, WM8995_SYSCLK_SRC_MASK, new); if (!change) return 0; @@ -760,14 +760,14 @@ static int configure_clock(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - return configure_clock(codec); + return configure_clock(component); case SND_SOC_DAPM_POST_PMD: - configure_clock(codec); + configure_clock(component); break; } @@ -1422,7 +1422,7 @@ static bool wm8995_volatile(struct device *dev, unsigned int reg) static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int mute_reg; switch (dai->id) { @@ -1436,18 +1436,18 @@ static int wm8995_aif_mute(struct snd_soc_dai *dai, int mute) return -EINVAL; } - snd_soc_update_bits(codec, mute_reg, WM8995_AIF1DAC1_MUTE_MASK, + snd_soc_component_update_bits(component, mute_reg, WM8995_AIF1DAC1_MUTE_MASK, !!mute << WM8995_AIF1DAC1_MUTE_SHIFT); return 0; } static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int master; int aif; - codec = dai->codec; + component = dai->component; master = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1519,11 +1519,11 @@ static int wm8995_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8995_AIF1_CONTROL_1, + snd_soc_component_update_bits(component, WM8995_AIF1_CONTROL_1, WM8995_AIF1_BCLK_INV_MASK | WM8995_AIF1_LRCLK_INV_MASK | WM8995_AIF1_FMT_MASK, aif); - snd_soc_update_bits(codec, WM8995_AIF1_MASTER_SLAVE, + snd_soc_component_update_bits(component, WM8995_AIF1_MASTER_SLAVE, WM8995_AIF1_MSTR_MASK, master); return 0; } @@ -1546,7 +1546,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8995_priv *wm8995; int aif1_reg; int bclk_reg; @@ -1557,8 +1557,8 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, int lrclk, bclk; int i, rate_val, best, best_val, cur_val; - codec = dai->codec; - wm8995 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8995 = snd_soc_component_get_drvdata(component); switch (dai->id) { case 0: @@ -1570,7 +1570,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, lrclk_reg = WM8995_AIF1DAC_LRCLK; } else { lrclk_reg = WM8995_AIF1ADC_LRCLK; - dev_dbg(codec->dev, "AIF1 using split LRCLK\n"); + dev_dbg(component->dev, "AIF1 using split LRCLK\n"); } break; case 1: @@ -1582,7 +1582,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, lrclk_reg = WM8995_AIF2DAC_LRCLK; } else { lrclk_reg = WM8995_AIF2ADC_LRCLK; - dev_dbg(codec->dev, "AIF2 using split LRCLK\n"); + dev_dbg(component->dev, "AIF2 using split LRCLK\n"); } break; default: @@ -1668,13 +1668,13 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", lrclk, bclk_rate / lrclk); - snd_soc_update_bits(codec, aif1_reg, + snd_soc_component_update_bits(component, aif1_reg, WM8995_AIF1_WL_MASK, aif1); - snd_soc_update_bits(codec, bclk_reg, + snd_soc_component_update_bits(component, bclk_reg, WM8995_AIF1_BCLK_DIV_MASK, bclk); - snd_soc_update_bits(codec, lrclk_reg, + snd_soc_component_update_bits(component, lrclk_reg, WM8995_AIF1DAC_RATE_MASK, lrclk); - snd_soc_update_bits(codec, rate_reg, + snd_soc_component_update_bits(component, rate_reg, WM8995_AIF1_SR_MASK | WM8995_AIF1CLK_RATE_MASK, rate_val); return 0; @@ -1682,7 +1682,7 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int reg, val, mask; switch (codec_dai->id) { @@ -1707,7 +1707,7 @@ static int wm8995_set_tristate(struct snd_soc_dai *codec_dai, int tristate) else val = 0; - return snd_soc_update_bits(codec, reg, mask, val); + return snd_soc_component_update_bits(component, reg, mask, val); } /* The size in bits of the FLL divide multiplied by 10 @@ -1797,19 +1797,19 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, int src, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8995_priv *wm8995; int reg_offset, ret; struct fll_div fll; u16 reg, aif1, aif2; - codec = dai->codec; - wm8995 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8995 = snd_soc_component_get_drvdata(component); - aif1 = snd_soc_read(codec, WM8995_AIF1_CLOCKING_1) + aif1 = snd_soc_component_read32(component, WM8995_AIF1_CLOCKING_1) & WM8995_AIF1CLK_ENA; - aif2 = snd_soc_read(codec, WM8995_AIF2_CLOCKING_1) + aif2 = snd_soc_component_read32(component, WM8995_AIF2_CLOCKING_1) & WM8995_AIF2CLK_ENA; switch (id) { @@ -1858,35 +1858,35 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, return ret; /* Gate the AIF clocks while we reclock */ - snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1, WM8995_AIF1CLK_ENA_MASK, 0); - snd_soc_update_bits(codec, WM8995_AIF2_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF2_CLOCKING_1, WM8995_AIF2CLK_ENA_MASK, 0); /* We always need to disable the FLL while reconfiguring */ - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_1 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_1 + reg_offset, WM8995_FLL1_ENA_MASK, 0); reg = (fll.outdiv << WM8995_FLL1_OUTDIV_SHIFT) | (fll.fll_fratio << WM8995_FLL1_FRATIO_SHIFT); - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_2 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_2 + reg_offset, WM8995_FLL1_OUTDIV_MASK | WM8995_FLL1_FRATIO_MASK, reg); - snd_soc_write(codec, WM8995_FLL1_CONTROL_3 + reg_offset, fll.k); + snd_soc_component_write(component, WM8995_FLL1_CONTROL_3 + reg_offset, fll.k); - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_4 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_4 + reg_offset, WM8995_FLL1_N_MASK, fll.n << WM8995_FLL1_N_SHIFT); - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_5 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_5 + reg_offset, WM8995_FLL1_REFCLK_DIV_MASK | WM8995_FLL1_REFCLK_SRC_MASK, (fll.clk_ref_div << WM8995_FLL1_REFCLK_DIV_SHIFT) | (src - 1)); if (freq_out) - snd_soc_update_bits(codec, WM8995_FLL1_CONTROL_1 + reg_offset, + snd_soc_component_update_bits(component, WM8995_FLL1_CONTROL_1 + reg_offset, WM8995_FLL1_ENA_MASK, WM8995_FLL1_ENA); wm8995->fll[id].in = freq_in; @@ -1894,12 +1894,12 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, wm8995->fll[id].src = src; /* Enable any gated AIF clocks */ - snd_soc_update_bits(codec, WM8995_AIF1_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF1_CLOCKING_1, WM8995_AIF1CLK_ENA_MASK, aif1); - snd_soc_update_bits(codec, WM8995_AIF2_CLOCKING_1, + snd_soc_component_update_bits(component, WM8995_AIF2_CLOCKING_1, WM8995_AIF2CLK_ENA_MASK, aif2); - configure_clock(codec); + configure_clock(component); return 0; } @@ -1907,11 +1907,11 @@ static int wm8995_set_fll(struct snd_soc_dai *dai, int id, static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct wm8995_priv *wm8995; - codec = dai->codec; - wm8995 = snd_soc_codec_get_drvdata(codec); + component = dai->component; + wm8995 = snd_soc_component_get_drvdata(component); switch (dai->id) { case 0: @@ -1949,24 +1949,24 @@ static int wm8995_set_dai_sysclk(struct snd_soc_dai *dai, return -EINVAL; } - configure_clock(codec); + configure_clock(component); return 0; } -static int wm8995_set_bias_level(struct snd_soc_codec *codec, +static int wm8995_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { struct wm8995_priv *wm8995; int ret; - wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) @@ -1974,17 +1974,17 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, ret = regcache_sync(wm8995->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_BG_ENA_MASK, WM8995_BG_ENA); } break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8995_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8995_POWER_MANAGEMENT_1, WM8995_BG_ENA_MASK, 0); regulator_bulk_disable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); @@ -1994,37 +1994,36 @@ static int wm8995_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int wm8995_remove(struct snd_soc_codec *codec) +static void wm8995_remove(struct snd_soc_component *component) { struct wm8995_priv *wm8995; int i; - wm8995 = snd_soc_codec_get_drvdata(codec); + wm8995 = snd_soc_component_get_drvdata(component); for (i = 0; i < ARRAY_SIZE(wm8995->supplies); ++i) regulator_unregister_notifier(wm8995->supplies[i].consumer, &wm8995->disable_nb[i]); regulator_bulk_free(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); - return 0; } -static int wm8995_probe(struct snd_soc_codec *codec) +static int wm8995_probe(struct snd_soc_component *component) { struct wm8995_priv *wm8995; int i; int ret; - wm8995 = snd_soc_codec_get_drvdata(codec); - wm8995->codec = codec; + wm8995 = snd_soc_component_get_drvdata(component); + wm8995->component = component; for (i = 0; i < ARRAY_SIZE(wm8995->supplies); i++) wm8995->supplies[i].supply = wm8995_supply_names[i]; - ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(wm8995->supplies), + ret = regulator_bulk_get(component->dev, ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) { - dev_err(codec->dev, "Failed to request supplies: %d\n", ret); + dev_err(component->dev, "Failed to request supplies: %d\n", ret); return ret; } @@ -2042,7 +2041,7 @@ static int wm8995_probe(struct snd_soc_codec *codec) ret = regulator_register_notifier(wm8995->supplies[i].consumer, &wm8995->disable_nb[i]); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to register regulator notifier: %d\n", ret); } @@ -2051,49 +2050,49 @@ static int wm8995_probe(struct snd_soc_codec *codec) ret = regulator_bulk_enable(ARRAY_SIZE(wm8995->supplies), wm8995->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto err_reg_get; } - ret = snd_soc_read(codec, WM8995_SOFTWARE_RESET); + ret = snd_soc_component_read32(component, WM8995_SOFTWARE_RESET); if (ret < 0) { - dev_err(codec->dev, "Failed to read device ID: %d\n", ret); + dev_err(component->dev, "Failed to read device ID: %d\n", ret); goto err_reg_enable; } if (ret != 0x8995) { - dev_err(codec->dev, "Invalid device ID: %#x\n", ret); + dev_err(component->dev, "Invalid device ID: %#x\n", ret); ret = -EINVAL; goto err_reg_enable; } - ret = snd_soc_write(codec, WM8995_SOFTWARE_RESET, 0); + ret = snd_soc_component_write(component, WM8995_SOFTWARE_RESET, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); goto err_reg_enable; } /* Latch volume updates (right only; we always do left then right). */ - snd_soc_update_bits(codec, WM8995_AIF1_DAC1_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_DAC1_RIGHT_VOLUME, WM8995_AIF1DAC1_VU_MASK, WM8995_AIF1DAC1_VU); - snd_soc_update_bits(codec, WM8995_AIF1_DAC2_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_DAC2_RIGHT_VOLUME, WM8995_AIF1DAC2_VU_MASK, WM8995_AIF1DAC2_VU); - snd_soc_update_bits(codec, WM8995_AIF2_DAC_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF2_DAC_RIGHT_VOLUME, WM8995_AIF2DAC_VU_MASK, WM8995_AIF2DAC_VU); - snd_soc_update_bits(codec, WM8995_AIF1_ADC1_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_ADC1_RIGHT_VOLUME, WM8995_AIF1ADC1_VU_MASK, WM8995_AIF1ADC1_VU); - snd_soc_update_bits(codec, WM8995_AIF1_ADC2_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF1_ADC2_RIGHT_VOLUME, WM8995_AIF1ADC2_VU_MASK, WM8995_AIF1ADC2_VU); - snd_soc_update_bits(codec, WM8995_AIF2_ADC_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_AIF2_ADC_RIGHT_VOLUME, WM8995_AIF2ADC_VU_MASK, WM8995_AIF1ADC2_VU); - snd_soc_update_bits(codec, WM8995_DAC1_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_DAC1_RIGHT_VOLUME, WM8995_DAC1_VU_MASK, WM8995_DAC1_VU); - snd_soc_update_bits(codec, WM8995_DAC2_RIGHT_VOLUME, + snd_soc_component_update_bits(component, WM8995_DAC2_RIGHT_VOLUME, WM8995_DAC2_VU_MASK, WM8995_DAC2_VU); - snd_soc_update_bits(codec, WM8995_RIGHT_LINE_INPUT_1_VOLUME, + snd_soc_component_update_bits(component, WM8995_RIGHT_LINE_INPUT_1_VOLUME, WM8995_IN1_VU_MASK, WM8995_IN1_VU); - wm8995_update_class_w(codec); + wm8995_update_class_w(component); return 0; @@ -2186,20 +2185,19 @@ static struct snd_soc_dai_driver wm8995_dai[] = { } }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8995 = { - .probe = wm8995_probe, - .remove = wm8995_remove, - .set_bias_level = wm8995_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = wm8995_snd_controls, - .num_controls = ARRAY_SIZE(wm8995_snd_controls), - .dapm_widgets = wm8995_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8995_dapm_widgets), - .dapm_routes = wm8995_intercon, - .num_dapm_routes = ARRAY_SIZE(wm8995_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8995 = { + .probe = wm8995_probe, + .remove = wm8995_remove, + .set_bias_level = wm8995_set_bias_level, + .controls = wm8995_snd_controls, + .num_controls = ARRAY_SIZE(wm8995_snd_controls), + .dapm_widgets = wm8995_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8995_dapm_widgets), + .dapm_routes = wm8995_intercon, + .num_dapm_routes = ARRAY_SIZE(wm8995_intercon), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8995_regmap = { @@ -2233,24 +2231,17 @@ static int wm8995_spi_probe(struct spi_device *spi) return ret; } - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_wm8995, wm8995_dai, + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_wm8995, wm8995_dai, ARRAY_SIZE(wm8995_dai)); return ret; } -static int wm8995_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver wm8995_spi_driver = { .driver = { .name = "wm8995", }, .probe = wm8995_spi_probe, - .remove = wm8995_spi_remove }; #endif @@ -2274,8 +2265,8 @@ static int wm8995_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8995, wm8995_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8995, wm8995_dai, ARRAY_SIZE(wm8995_dai)); if (ret < 0) dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -2283,12 +2274,6 @@ static int wm8995_i2c_probe(struct i2c_client *i2c, return ret; } -static int wm8995_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8995_i2c_id[] = { {"wm8995", 0}, {} @@ -2301,7 +2286,6 @@ static struct i2c_driver wm8995_i2c_driver = { .name = "wm8995", }, .probe = wm8995_i2c_probe, - .remove = wm8995_i2c_remove, .id_table = wm8995_i2c_id }; #endif From ce8d1015a2b8d1301c98f7e6b774fb1c28220cea Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:09:02 +0000 Subject: [PATCH 051/942] ASoC: wm8961: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8961.c | 241 ++++++++++++++++++-------------------- 1 file changed, 117 insertions(+), 124 deletions(-) diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index e23ceac76015..f70f563d59f3 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c @@ -194,89 +194,89 @@ static bool wm8961_readable(struct device *dev, unsigned int reg) static int wm8961_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 hp_reg = snd_soc_read(codec, WM8961_ANALOGUE_HP_0); - u16 cp_reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_1); - u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); - u16 dcs_reg = snd_soc_read(codec, WM8961_DC_SERVO_1); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 hp_reg = snd_soc_component_read32(component, WM8961_ANALOGUE_HP_0); + u16 cp_reg = snd_soc_component_read32(component, WM8961_CHARGE_PUMP_1); + u16 pwr_reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_2); + u16 dcs_reg = snd_soc_component_read32(component, WM8961_DC_SERVO_1); int timeout = 500; if (event & SND_SOC_DAPM_POST_PMU) { /* Make sure the output is shorted */ hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Enable the charge pump */ cp_reg |= WM8961_CP_ENA; - snd_soc_write(codec, WM8961_CHARGE_PUMP_1, cp_reg); + snd_soc_component_write(component, WM8961_CHARGE_PUMP_1, cp_reg); mdelay(5); /* Enable the PGA */ pwr_reg |= WM8961_LOUT1_PGA | WM8961_ROUT1_PGA; - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg); /* Enable the amplifier */ hp_reg |= WM8961_HPR_ENA | WM8961_HPL_ENA; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Second stage enable */ hp_reg |= WM8961_HPR_ENA_DLY | WM8961_HPL_ENA_DLY; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Enable the DC servo & trigger startup */ dcs_reg |= WM8961_DCS_ENA_CHAN_HPR | WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_ENA_CHAN_HPL | WM8961_DCS_TRIG_STARTUP_HPL; - dev_dbg(codec->dev, "Enabling DC servo\n"); + dev_dbg(component->dev, "Enabling DC servo\n"); - snd_soc_write(codec, WM8961_DC_SERVO_1, dcs_reg); + snd_soc_component_write(component, WM8961_DC_SERVO_1, dcs_reg); do { msleep(1); - dcs_reg = snd_soc_read(codec, WM8961_DC_SERVO_1); + dcs_reg = snd_soc_component_read32(component, WM8961_DC_SERVO_1); } while (--timeout && dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_TRIG_STARTUP_HPL)); if (dcs_reg & (WM8961_DCS_TRIG_STARTUP_HPR | WM8961_DCS_TRIG_STARTUP_HPL)) - dev_err(codec->dev, "DC servo timed out\n"); + dev_err(component->dev, "DC servo timed out\n"); else - dev_dbg(codec->dev, "DC servo startup complete\n"); + dev_dbg(component->dev, "DC servo startup complete\n"); /* Enable the output stage */ hp_reg |= WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Remove the short on the output stage */ hp_reg |= WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT; - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); } if (event & SND_SOC_DAPM_PRE_PMD) { /* Short the output */ hp_reg &= ~(WM8961_HPR_RMV_SHORT | WM8961_HPL_RMV_SHORT); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Disable the output stage */ hp_reg &= ~(WM8961_HPR_ENA_OUTP | WM8961_HPL_ENA_OUTP); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Disable DC offset cancellation */ dcs_reg &= ~(WM8961_DCS_ENA_CHAN_HPR | WM8961_DCS_ENA_CHAN_HPL); - snd_soc_write(codec, WM8961_DC_SERVO_1, dcs_reg); + snd_soc_component_write(component, WM8961_DC_SERVO_1, dcs_reg); /* Finish up */ hp_reg &= ~(WM8961_HPR_ENA_DLY | WM8961_HPR_ENA | WM8961_HPL_ENA_DLY | WM8961_HPL_ENA); - snd_soc_write(codec, WM8961_ANALOGUE_HP_0, hp_reg); + snd_soc_component_write(component, WM8961_ANALOGUE_HP_0, hp_reg); /* Disable the PGA */ pwr_reg &= ~(WM8961_LOUT1_PGA | WM8961_ROUT1_PGA); - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg); /* Disable the charge pump */ - dev_dbg(codec->dev, "Disabling charge pump\n"); - snd_soc_write(codec, WM8961_CHARGE_PUMP_1, + dev_dbg(component->dev, "Disabling charge pump\n"); + snd_soc_component_write(component, WM8961_CHARGE_PUMP_1, cp_reg & ~WM8961_CP_ENA); } @@ -286,28 +286,28 @@ static int wm8961_hp_event(struct snd_soc_dapm_widget *w, static int wm8961_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 pwr_reg = snd_soc_read(codec, WM8961_PWR_MGMT_2); - u16 spk_reg = snd_soc_read(codec, WM8961_CLASS_D_CONTROL_1); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 pwr_reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_2); + u16 spk_reg = snd_soc_component_read32(component, WM8961_CLASS_D_CONTROL_1); if (event & SND_SOC_DAPM_POST_PMU) { /* Enable the PGA */ pwr_reg |= WM8961_SPKL_PGA | WM8961_SPKR_PGA; - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg); /* Enable the amplifier */ spk_reg |= WM8961_SPKL_ENA | WM8961_SPKR_ENA; - snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg); + snd_soc_component_write(component, WM8961_CLASS_D_CONTROL_1, spk_reg); } if (event & SND_SOC_DAPM_PRE_PMD) { /* Disable the amplifier */ spk_reg &= ~(WM8961_SPKL_ENA | WM8961_SPKR_ENA); - snd_soc_write(codec, WM8961_CLASS_D_CONTROL_1, spk_reg); + snd_soc_component_write(component, WM8961_CLASS_D_CONTROL_1, spk_reg); /* Disable the PGA */ pwr_reg &= ~(WM8961_SPKL_PGA | WM8961_SPKR_PGA); - snd_soc_write(codec, WM8961_PWR_MGMT_2, pwr_reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_2, pwr_reg); } return 0; @@ -505,15 +505,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8961_priv *wm8961 = snd_soc_component_get_drvdata(component); int i, best, target, fs; u16 reg; fs = params_rate(params); if (!wm8961->sysclk) { - dev_err(codec->dev, "MCLK has not been specified\n"); + dev_err(component->dev, "MCLK has not been specified\n"); return -EINVAL; } @@ -524,23 +524,23 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, abs(wm8961_srate[best].rate - fs)) best = i; } - reg = snd_soc_read(codec, WM8961_ADDITIONAL_CONTROL_3); + reg = snd_soc_component_read32(component, WM8961_ADDITIONAL_CONTROL_3); reg &= ~WM8961_SAMPLE_RATE_MASK; reg |= wm8961_srate[best].val; - snd_soc_write(codec, WM8961_ADDITIONAL_CONTROL_3, reg); - dev_dbg(codec->dev, "Selected SRATE %dHz for %dHz\n", + snd_soc_component_write(component, WM8961_ADDITIONAL_CONTROL_3, reg); + dev_dbg(component->dev, "Selected SRATE %dHz for %dHz\n", wm8961_srate[best].rate, fs); /* Select a CLK_SYS/fs ratio equal to or higher than required */ target = wm8961->sysclk / fs; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && target < 64) { - dev_err(codec->dev, + dev_err(component->dev, "SYSCLK must be at least 64*fs for DAC\n"); return -EINVAL; } if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && target < 256) { - dev_err(codec->dev, + dev_err(component->dev, "SYSCLK must be at least 256*fs for ADC\n"); return -EINVAL; } @@ -550,19 +550,19 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, break; } if (i == ARRAY_SIZE(wm8961_clk_sys_ratio)) { - dev_err(codec->dev, "Unable to generate CLK_SYS_RATE\n"); + dev_err(component->dev, "Unable to generate CLK_SYS_RATE\n"); return -EINVAL; } - dev_dbg(codec->dev, "Selected CLK_SYS_RATE of %d for %d/%d=%d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATE of %d for %d/%d=%d\n", wm8961_clk_sys_ratio[i].ratio, wm8961->sysclk, fs, wm8961->sysclk / fs); - reg = snd_soc_read(codec, WM8961_CLOCKING_4); + reg = snd_soc_component_read32(component, WM8961_CLOCKING_4); reg &= ~WM8961_CLK_SYS_RATE_MASK; reg |= wm8961_clk_sys_ratio[i].val << WM8961_CLK_SYS_RATE_SHIFT; - snd_soc_write(codec, WM8961_CLOCKING_4, reg); + snd_soc_component_write(component, WM8961_CLOCKING_4, reg); - reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); + reg = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_0); reg &= ~WM8961_WL_MASK; switch (params_width(params)) { case 16: @@ -579,15 +579,15 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_write(codec, WM8961_AUDIO_INTERFACE_0, reg); + snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_0, reg); /* Sloping stop-band filter is recommended for <= 24kHz */ - reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); + reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_2); if (fs <= 24000) reg |= WM8961_DACSLOPE; else reg &= ~WM8961_DACSLOPE; - snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); + snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_2, reg); return 0; } @@ -596,25 +596,25 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8961_priv *wm8961 = snd_soc_codec_get_drvdata(codec); - u16 reg = snd_soc_read(codec, WM8961_CLOCKING1); + struct snd_soc_component *component = dai->component; + struct wm8961_priv *wm8961 = snd_soc_component_get_drvdata(component); + u16 reg = snd_soc_component_read32(component, WM8961_CLOCKING1); if (freq > 33000000) { - dev_err(codec->dev, "MCLK must be <33MHz\n"); + dev_err(component->dev, "MCLK must be <33MHz\n"); return -EINVAL; } if (freq > 16500000) { - dev_dbg(codec->dev, "Using MCLK/2 for %dHz MCLK\n", freq); + dev_dbg(component->dev, "Using MCLK/2 for %dHz MCLK\n", freq); reg |= WM8961_MCLKDIV; freq /= 2; } else { - dev_dbg(codec->dev, "Using MCLK/1 for %dHz MCLK\n", freq); + dev_dbg(component->dev, "Using MCLK/1 for %dHz MCLK\n", freq); reg &= ~WM8961_MCLKDIV; } - snd_soc_write(codec, WM8961_CLOCKING1, reg); + snd_soc_component_write(component, WM8961_CLOCKING1, reg); wm8961->sysclk = freq; @@ -623,8 +623,8 @@ static int wm8961_set_sysclk(struct snd_soc_dai *dai, int clk_id, static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - u16 aif = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); + struct snd_soc_component *component = dai->component; + u16 aif = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_0); aif &= ~(WM8961_BCLKINV | WM8961_LRP | WM8961_MS | WM8961_FORMAT_MASK); @@ -684,26 +684,26 @@ static int wm8961_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - return snd_soc_write(codec, WM8961_AUDIO_INTERFACE_0, aif); + return snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_0, aif); } static int wm8961_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; - u16 reg = snd_soc_read(codec, WM8961_ADDITIONAL_CONTROL_2); + struct snd_soc_component *component = dai->component; + u16 reg = snd_soc_component_read32(component, WM8961_ADDITIONAL_CONTROL_2); if (tristate) reg |= WM8961_TRIS; else reg &= ~WM8961_TRIS; - return snd_soc_write(codec, WM8961_ADDITIONAL_CONTROL_2, reg); + return snd_soc_component_write(component, WM8961_ADDITIONAL_CONTROL_2, reg); } static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_1); + struct snd_soc_component *component = dai->component; + u16 reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_1); if (mute) reg |= WM8961_DACMU; @@ -712,27 +712,27 @@ static int wm8961_digital_mute(struct snd_soc_dai *dai, int mute) msleep(17); - return snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_1, reg); + return snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_1, reg); } static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 reg; switch (div_id) { case WM8961_BCLK: - reg = snd_soc_read(codec, WM8961_CLOCKING2); + reg = snd_soc_component_read32(component, WM8961_CLOCKING2); reg &= ~WM8961_BCLKDIV_MASK; reg |= div; - snd_soc_write(codec, WM8961_CLOCKING2, reg); + snd_soc_component_write(component, WM8961_CLOCKING2, reg); break; case WM8961_LRCLK: - reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_2); + reg = snd_soc_component_read32(component, WM8961_AUDIO_INTERFACE_2); reg &= ~WM8961_LRCLK_RATE_MASK; reg |= div; - snd_soc_write(codec, WM8961_AUDIO_INTERFACE_2, reg); + snd_soc_component_write(component, WM8961_AUDIO_INTERFACE_2, reg); break; default: @@ -742,7 +742,7 @@ static int wm8961_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div) return 0; } -static int wm8961_set_bias_level(struct snd_soc_codec *codec, +static int wm8961_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { u16 reg; @@ -757,36 +757,36 @@ static int wm8961_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { /* Enable bias generation */ - reg = snd_soc_read(codec, WM8961_ANTI_POP); + reg = snd_soc_component_read32(component, WM8961_ANTI_POP); reg |= WM8961_BUFIOEN | WM8961_BUFDCOPEN; - snd_soc_write(codec, WM8961_ANTI_POP, reg); + snd_soc_component_write(component, WM8961_ANTI_POP, reg); /* VMID=2*50k, VREF */ - reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); + reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VMIDSEL_MASK; reg |= (1 << WM8961_VMIDSEL_SHIFT) | WM8961_VREF; - snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg); } break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { /* VREF off */ - reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); + reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VREF; - snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg); /* Bias generation off */ - reg = snd_soc_read(codec, WM8961_ANTI_POP); + reg = snd_soc_component_read32(component, WM8961_ANTI_POP); reg &= ~(WM8961_BUFIOEN | WM8961_BUFDCOPEN); - snd_soc_write(codec, WM8961_ANTI_POP, reg); + snd_soc_component_write(component, WM8961_ANTI_POP, reg); /* VMID off */ - reg = snd_soc_read(codec, WM8961_PWR_MGMT_1); + reg = snd_soc_component_read32(component, WM8961_PWR_MGMT_1); reg &= ~WM8961_VMIDSEL_MASK; - snd_soc_write(codec, WM8961_PWR_MGMT_1, reg); + snd_soc_component_write(component, WM8961_PWR_MGMT_1, reg); } break; @@ -830,51 +830,51 @@ static struct snd_soc_dai_driver wm8961_dai = { .ops = &wm8961_dai_ops, }; -static int wm8961_probe(struct snd_soc_codec *codec) +static int wm8961_probe(struct snd_soc_component *component) { u16 reg; /* Enable class W */ - reg = snd_soc_read(codec, WM8961_CHARGE_PUMP_B); + reg = snd_soc_component_read32(component, WM8961_CHARGE_PUMP_B); reg |= WM8961_CP_DYN_PWR_MASK; - snd_soc_write(codec, WM8961_CHARGE_PUMP_B, reg); + snd_soc_component_write(component, WM8961_CHARGE_PUMP_B, reg); /* Latch volume update bits (right channel only, we always * write both out) and default ZC on. */ - reg = snd_soc_read(codec, WM8961_ROUT1_VOLUME); - snd_soc_write(codec, WM8961_ROUT1_VOLUME, + reg = snd_soc_component_read32(component, WM8961_ROUT1_VOLUME); + snd_soc_component_write(component, WM8961_ROUT1_VOLUME, reg | WM8961_LO1ZC | WM8961_OUT1VU); - snd_soc_write(codec, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC); - reg = snd_soc_read(codec, WM8961_ROUT2_VOLUME); - snd_soc_write(codec, WM8961_ROUT2_VOLUME, + snd_soc_component_write(component, WM8961_LOUT1_VOLUME, reg | WM8961_LO1ZC); + reg = snd_soc_component_read32(component, WM8961_ROUT2_VOLUME); + snd_soc_component_write(component, WM8961_ROUT2_VOLUME, reg | WM8961_SPKRZC | WM8961_SPKVU); - snd_soc_write(codec, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC); + snd_soc_component_write(component, WM8961_LOUT2_VOLUME, reg | WM8961_SPKLZC); - reg = snd_soc_read(codec, WM8961_RIGHT_ADC_VOLUME); - snd_soc_write(codec, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU); - reg = snd_soc_read(codec, WM8961_RIGHT_INPUT_VOLUME); - snd_soc_write(codec, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU); + reg = snd_soc_component_read32(component, WM8961_RIGHT_ADC_VOLUME); + snd_soc_component_write(component, WM8961_RIGHT_ADC_VOLUME, reg | WM8961_ADCVU); + reg = snd_soc_component_read32(component, WM8961_RIGHT_INPUT_VOLUME); + snd_soc_component_write(component, WM8961_RIGHT_INPUT_VOLUME, reg | WM8961_IPVU); /* Use soft mute by default */ - reg = snd_soc_read(codec, WM8961_ADC_DAC_CONTROL_2); + reg = snd_soc_component_read32(component, WM8961_ADC_DAC_CONTROL_2); reg |= WM8961_DACSMM; - snd_soc_write(codec, WM8961_ADC_DAC_CONTROL_2, reg); + snd_soc_component_write(component, WM8961_ADC_DAC_CONTROL_2, reg); /* Use automatic clocking mode by default; for now this is all * we support. */ - reg = snd_soc_read(codec, WM8961_CLOCKING_3); + reg = snd_soc_component_read32(component, WM8961_CLOCKING_3); reg &= ~WM8961_MANUAL_MODE; - snd_soc_write(codec, WM8961_CLOCKING_3, reg); + snd_soc_component_write(component, WM8961_CLOCKING_3, reg); return 0; } #ifdef CONFIG_PM -static int wm8961_resume(struct snd_soc_codec *codec) +static int wm8961_resume(struct snd_soc_component *component) { - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component); return 0; } @@ -882,20 +882,21 @@ static int wm8961_resume(struct snd_soc_codec *codec) #define wm8961_resume NULL #endif -static const struct snd_soc_codec_driver soc_codec_dev_wm8961 = { - .probe = wm8961_probe, - .resume = wm8961_resume, - .set_bias_level = wm8961_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8961_snd_controls, - .num_controls = ARRAY_SIZE(wm8961_snd_controls), - .dapm_widgets = wm8961_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8961_dapm_widgets), - .dapm_routes = audio_paths, - .num_dapm_routes = ARRAY_SIZE(audio_paths), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8961 = { + .probe = wm8961_probe, + .resume = wm8961_resume, + .set_bias_level = wm8961_set_bias_level, + .controls = wm8961_snd_controls, + .num_controls = ARRAY_SIZE(wm8961_snd_controls), + .dapm_widgets = wm8961_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8961_dapm_widgets), + .dapm_routes = audio_paths, + .num_dapm_routes = ARRAY_SIZE(audio_paths), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8961_regmap = { @@ -961,19 +962,12 @@ static int wm8961_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8961); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8961, &wm8961_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8961, &wm8961_dai, 1); return ret; } -static int wm8961_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8961_i2c_id[] = { { "wm8961", 0 }, { } @@ -985,7 +979,6 @@ static struct i2c_driver wm8961_i2c_driver = { .name = "wm8961", }, .probe = wm8961_i2c_probe, - .remove = wm8961_i2c_remove, .id_table = wm8961_i2c_id, }; From 78e89b825c5a3df34be58b8bbbc5c7e4589a761c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:09:18 +0000 Subject: [PATCH 052/942] ASoC: wm8940: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8940.c | 159 ++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 83 deletions(-) diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index b5935625feeb..be4fce0c7b36 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c @@ -334,14 +334,14 @@ static const struct snd_soc_dapm_route wm8940_dapm_routes[] = { {"ADC", NULL, "Boost Mixer"}, }; -#define wm8940_reset(c) snd_soc_write(c, WM8940_SOFTRESET, 0); +#define wm8940_reset(c) snd_soc_component_write(c, WM8940_SOFTRESET, 0); static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 iface = snd_soc_read(codec, WM8940_IFACE) & 0xFE67; - u16 clk = snd_soc_read(codec, WM8940_CLOCK) & 0x1fe; + struct snd_soc_component *component = codec_dai->component; + u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFE67; + u16 clk = snd_soc_component_read32(component, WM8940_CLOCK) & 0x1fe; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -352,7 +352,7 @@ static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_write(codec, WM8940_CLOCK, clk); + snd_soc_component_write(component, WM8940_CLOCK, clk); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -385,7 +385,7 @@ static int wm8940_set_dai_fmt(struct snd_soc_dai *codec_dai, break; } - snd_soc_write(codec, WM8940_IFACE, iface); + snd_soc_component_write(component, WM8940_IFACE, iface); return 0; } @@ -394,10 +394,10 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 iface = snd_soc_read(codec, WM8940_IFACE) & 0xFD9F; - u16 addcntrl = snd_soc_read(codec, WM8940_ADDCNTRL) & 0xFFF1; - u16 companding = snd_soc_read(codec, + struct snd_soc_component *component = dai->component; + u16 iface = snd_soc_component_read32(component, WM8940_IFACE) & 0xFD9F; + u16 addcntrl = snd_soc_component_read32(component, WM8940_ADDCNTRL) & 0xFFF1; + u16 companding = snd_soc_component_read32(component, WM8940_COMPANDINGCTL) & 0xFFDF; int ret; @@ -426,7 +426,7 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, case 48000: break; } - ret = snd_soc_write(codec, WM8940_ADDCNTRL, addcntrl); + ret = snd_soc_component_write(component, WM8940_ADDCNTRL, addcntrl); if (ret) goto error_ret; @@ -446,10 +446,10 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, iface |= (3 << 5); break; } - ret = snd_soc_write(codec, WM8940_COMPANDINGCTL, companding); + ret = snd_soc_component_write(component, WM8940_COMPANDINGCTL, companding); if (ret) goto error_ret; - ret = snd_soc_write(codec, WM8940_IFACE, iface); + ret = snd_soc_component_write(component, WM8940_IFACE, iface); error_ret: return ret; @@ -457,21 +457,21 @@ error_ret: static int wm8940_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, WM8940_DAC) & 0xffbf; + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, WM8940_DAC) & 0xffbf; if (mute) mute_reg |= 0x40; - return snd_soc_write(codec, WM8940_DAC, mute_reg); + return snd_soc_component_write(component, WM8940_DAC, mute_reg); } -static int wm8940_set_bias_level(struct snd_soc_codec *codec, +static int wm8940_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); + struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); u16 val; - u16 pwr_reg = snd_soc_read(codec, WM8940_POWER1) & 0x1F0; + u16 pwr_reg = snd_soc_component_read32(component, WM8940_POWER1) & 0x1F0; int ret = 0; switch (level) { @@ -479,23 +479,23 @@ static int wm8940_set_bias_level(struct snd_soc_codec *codec, /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); /* Enable thermal shutdown */ - val = snd_soc_read(codec, WM8940_OUTPUTCTL); - ret = snd_soc_write(codec, WM8940_OUTPUTCTL, val | 0x2); + val = snd_soc_component_read32(component, WM8940_OUTPUTCTL); + ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, val | 0x2); if (ret) break; /* set vmid to 75k */ - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg | 0x1); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x1); break; case SND_SOC_BIAS_PREPARE: /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg | 0x1); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x1); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(wm8940->regmap); if (ret < 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } } @@ -503,10 +503,10 @@ static int wm8940_set_bias_level(struct snd_soc_codec *codec, /* ensure bufioen and biasen */ pwr_reg |= (1 << 2) | (1 << 3); /* set vmid to 300k for standby */ - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg | 0x2); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg | 0x2); break; case SND_SOC_BIAS_OFF: - ret = snd_soc_write(codec, WM8940_POWER1, pwr_reg); + ret = snd_soc_component_write(component, WM8940_POWER1, pwr_reg); break; } @@ -576,40 +576,40 @@ static void pll_factors(unsigned int target, unsigned int source) static int wm8940_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; /* Turn off PLL */ - reg = snd_soc_read(codec, WM8940_POWER1); - snd_soc_write(codec, WM8940_POWER1, reg & 0x1df); + reg = snd_soc_component_read32(component, WM8940_POWER1); + snd_soc_component_write(component, WM8940_POWER1, reg & 0x1df); if (freq_in == 0 || freq_out == 0) { /* Clock CODEC directly from MCLK */ - reg = snd_soc_read(codec, WM8940_CLOCK); - snd_soc_write(codec, WM8940_CLOCK, reg & 0x0ff); + reg = snd_soc_component_read32(component, WM8940_CLOCK); + snd_soc_component_write(component, WM8940_CLOCK, reg & 0x0ff); /* Pll power down */ - snd_soc_write(codec, WM8940_PLLN, (1 << 7)); + snd_soc_component_write(component, WM8940_PLLN, (1 << 7)); return 0; } /* Pll is followed by a frequency divide by 4 */ pll_factors(freq_out*4, freq_in); if (pll_div.k) - snd_soc_write(codec, WM8940_PLLN, + snd_soc_component_write(component, WM8940_PLLN, (pll_div.pre_scale << 4) | pll_div.n | (1 << 6)); else /* No factional component */ - snd_soc_write(codec, WM8940_PLLN, + snd_soc_component_write(component, WM8940_PLLN, (pll_div.pre_scale << 4) | pll_div.n); - snd_soc_write(codec, WM8940_PLLK1, pll_div.k >> 18); - snd_soc_write(codec, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff); - snd_soc_write(codec, WM8940_PLLK3, pll_div.k & 0x1ff); + snd_soc_component_write(component, WM8940_PLLK1, pll_div.k >> 18); + snd_soc_component_write(component, WM8940_PLLK2, (pll_div.k >> 9) & 0x1ff); + snd_soc_component_write(component, WM8940_PLLK3, pll_div.k & 0x1ff); /* Enable the PLL */ - reg = snd_soc_read(codec, WM8940_POWER1); - snd_soc_write(codec, WM8940_POWER1, reg | 0x020); + reg = snd_soc_component_read32(component, WM8940_POWER1); + snd_soc_component_write(component, WM8940_POWER1, reg | 0x020); /* Run CODEC from PLL instead of MCLK */ - reg = snd_soc_read(codec, WM8940_CLOCK); - snd_soc_write(codec, WM8940_CLOCK, reg | 0x100); + reg = snd_soc_component_read32(component, WM8940_CLOCK); + snd_soc_component_write(component, WM8940_CLOCK, reg | 0x100); return 0; } @@ -617,8 +617,8 @@ static int wm8940_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm8940_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8940_priv *wm8940 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8940_priv *wm8940 = snd_soc_component_get_drvdata(component); switch (freq) { case 11289600: @@ -635,22 +635,22 @@ static int wm8940_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int wm8940_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 reg; int ret = 0; switch (div_id) { case WM8940_BCLKDIV: - reg = snd_soc_read(codec, WM8940_CLOCK) & 0xFFE3; - ret = snd_soc_write(codec, WM8940_CLOCK, reg | (div << 2)); + reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFFE3; + ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 2)); break; case WM8940_MCLKDIV: - reg = snd_soc_read(codec, WM8940_CLOCK) & 0xFF1F; - ret = snd_soc_write(codec, WM8940_CLOCK, reg | (div << 5)); + reg = snd_soc_component_read32(component, WM8940_CLOCK) & 0xFF1F; + ret = snd_soc_component_write(component, WM8940_CLOCK, reg | (div << 5)); break; case WM8940_OPCLKDIV: - reg = snd_soc_read(codec, WM8940_GPIO) & 0xFFCF; - ret = snd_soc_write(codec, WM8940_GPIO, reg | (div << 4)); + reg = snd_soc_component_read32(component, WM8940_GPIO) & 0xFFCF; + ret = snd_soc_component_write(component, WM8940_GPIO, reg | (div << 4)); break; } return ret; @@ -693,29 +693,29 @@ static struct snd_soc_dai_driver wm8940_dai = { .symmetric_rates = 1, }; -static int wm8940_probe(struct snd_soc_codec *codec) +static int wm8940_probe(struct snd_soc_component *component) { - struct wm8940_setup_data *pdata = codec->dev->platform_data; + struct wm8940_setup_data *pdata = component->dev->platform_data; int ret; u16 reg; - ret = wm8940_reset(codec); + ret = wm8940_reset(component); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset\n"); + dev_err(component->dev, "Failed to issue reset\n"); return ret; } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); - ret = snd_soc_write(codec, WM8940_POWER1, 0x180); + ret = snd_soc_component_write(component, WM8940_POWER1, 0x180); if (ret < 0) return ret; if (!pdata) - dev_warn(codec->dev, "No platform data supplied\n"); + dev_warn(component->dev, "No platform data supplied\n"); else { - reg = snd_soc_read(codec, WM8940_OUTPUTCTL); - ret = snd_soc_write(codec, WM8940_OUTPUTCTL, reg | pdata->vroi); + reg = snd_soc_component_read32(component, WM8940_OUTPUTCTL); + ret = snd_soc_component_write(component, WM8940_OUTPUTCTL, reg | pdata->vroi); if (ret < 0) return ret; } @@ -723,19 +723,20 @@ static int wm8940_probe(struct snd_soc_codec *codec) return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8940 = { - .probe = wm8940_probe, - .set_bias_level = wm8940_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm8940_snd_controls, - .num_controls = ARRAY_SIZE(wm8940_snd_controls), - .dapm_widgets = wm8940_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8940_dapm_widgets), - .dapm_routes = wm8940_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8940_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8940 = { + .probe = wm8940_probe, + .set_bias_level = wm8940_set_bias_level, + .controls = wm8940_snd_controls, + .num_controls = ARRAY_SIZE(wm8940_snd_controls), + .dapm_widgets = wm8940_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8940_dapm_widgets), + .dapm_routes = wm8940_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8940_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8940_regmap = { @@ -768,19 +769,12 @@ static int wm8940_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm8940); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8940, &wm8940_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8940, &wm8940_dai, 1); return ret; } -static int wm8940_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id wm8940_i2c_id[] = { { "wm8940", 0 }, { } @@ -792,7 +786,6 @@ static struct i2c_driver wm8940_i2c_driver = { .name = "wm8940", }, .probe = wm8940_i2c_probe, - .remove = wm8940_i2c_remove, .id_table = wm8940_i2c_id, }; From 46a9100c8a94a01bb2d6780b19c9258e9aec323c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:09:37 +0000 Subject: [PATCH 053/942] ASoC: wm8904: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8904.c | 355 +++++++++++++++++++------------------- 1 file changed, 174 insertions(+), 181 deletions(-) diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index 4fd350e8420d..20fdcae06c6b 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c @@ -316,31 +316,31 @@ static bool wm8904_readable_register(struct device *dev, unsigned int reg) } } -static int wm8904_configure_clocking(struct snd_soc_codec *codec) +static int wm8904_configure_clocking(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); unsigned int clock0, clock2, rate; /* Gate the clock while we're updating to avoid misclocking */ - clock2 = snd_soc_read(codec, WM8904_CLOCK_RATES_2); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + clock2 = snd_soc_component_read32(component, WM8904_CLOCK_RATES_2); + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_SYSCLK_SRC, 0); /* This should be done on init() for bypass paths */ switch (wm8904->sysclk_src) { case WM8904_CLK_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK\n", wm8904->mclk_rate); + dev_dbg(component->dev, "Using %dHz MCLK\n", wm8904->mclk_rate); clock2 &= ~WM8904_SYSCLK_SRC; rate = wm8904->mclk_rate; /* Ensure the FLL is stopped */ - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0); break; case WM8904_CLK_FLL: - dev_dbg(codec->dev, "Using %dHz FLL clock\n", + dev_dbg(component->dev, "Using %dHz FLL clock\n", wm8904->fll_fout); clock2 |= WM8904_SYSCLK_SRC; @@ -348,7 +348,7 @@ static int wm8904_configure_clocking(struct snd_soc_codec *codec) break; default: - dev_err(codec->dev, "System clock not configured\n"); + dev_err(component->dev, "System clock not configured\n"); return -EINVAL; } @@ -361,40 +361,40 @@ static int wm8904_configure_clocking(struct snd_soc_codec *codec) wm8904->sysclk_rate = rate; } - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_0, WM8904_MCLK_DIV, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_0, WM8904_MCLK_DIV, clock0); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA | WM8904_SYSCLK_SRC, clock2); - dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate); + dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate); return 0; } -static void wm8904_set_drc(struct snd_soc_codec *codec) +static void wm8904_set_drc(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int save, i; /* Save any enables; the configuration should clear them. */ - save = snd_soc_read(codec, WM8904_DRC_0); + save = snd_soc_component_read32(component, WM8904_DRC_0); for (i = 0; i < WM8904_DRC_REGS; i++) - snd_soc_update_bits(codec, WM8904_DRC_0 + i, 0xffff, + snd_soc_component_update_bits(component, WM8904_DRC_0 + i, 0xffff, pdata->drc_cfgs[wm8904->drc_cfg].regs[i]); /* Reenable the DRC */ - snd_soc_update_bits(codec, WM8904_DRC_0, + snd_soc_component_update_bits(component, WM8904_DRC_0, WM8904_DRC_ENA | WM8904_DRC_DAC_PATH, save); } static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.enumerated.item[0]; @@ -403,7 +403,7 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, wm8904->drc_cfg = value; - wm8904_set_drc(codec); + wm8904_set_drc(component); return 0; } @@ -411,17 +411,17 @@ static int wm8904_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; return 0; } -static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) +static void wm8904_set_retune_mobile(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int best, best_val, save, i, cfg; @@ -444,7 +444,7 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) } } - dev_dbg(codec->dev, "ReTune Mobile %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "ReTune Mobile %s/%dHz for %dHz sample rate\n", pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].rate, wm8904->fs); @@ -452,20 +452,20 @@ static void wm8904_set_retune_mobile(struct snd_soc_codec *codec) /* The EQ will be disabled while reconfiguring it, remember the * current configuration. */ - save = snd_soc_read(codec, WM8904_EQ1); + save = snd_soc_component_read32(component, WM8904_EQ1); for (i = 0; i < WM8904_EQ_REGS; i++) - snd_soc_update_bits(codec, WM8904_EQ1 + i, 0xffff, + snd_soc_component_update_bits(component, WM8904_EQ1 + i, 0xffff, pdata->retune_mobile_cfgs[best].regs[i]); - snd_soc_update_bits(codec, WM8904_EQ1, WM8904_EQ_ENA, save); + snd_soc_component_update_bits(component, WM8904_EQ1, WM8904_EQ_ENA, save); } static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int value = ucontrol->value.enumerated.item[0]; @@ -474,7 +474,7 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, wm8904->retune_mobile_cfg = value; - wm8904_set_retune_mobile(codec); + wm8904_set_retune_mobile(component); return 0; } @@ -482,8 +482,8 @@ static int wm8904_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; @@ -492,9 +492,9 @@ static int wm8904_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int deemph_settings[] = { 0, 32000, 44100, 48000 }; -static int wm8904_set_deemph(struct snd_soc_codec *codec) +static int wm8904_set_deemph(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int val, i, best; /* If we're using deemphasis select the nearest available sample @@ -513,17 +513,17 @@ static int wm8904_set_deemph(struct snd_soc_codec *codec) val = 0; } - dev_dbg(codec->dev, "Set deemphasis %d\n", val); + dev_dbg(component->dev, "Set deemphasis %d\n", val); - return snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_1, + return snd_soc_component_update_bits(component, WM8904_DAC_DIGITAL_1, WM8904_DEEMPH_MASK, val); } static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8904->deemph; return 0; @@ -532,8 +532,8 @@ static int wm8904_get_deemph(struct snd_kcontrol *kcontrol, static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) @@ -541,7 +541,7 @@ static int wm8904_put_deemph(struct snd_kcontrol *kcontrol, wm8904->deemph = deemph; - return wm8904_set_deemph(codec); + return wm8904_set_deemph(component); } static const DECLARE_TLV_DB_SCALE(dac_boost_tlv, 0, 600, 0); @@ -572,7 +572,7 @@ static SOC_ENUM_SINGLE_DECL(hpf_mode, WM8904_ADC_DIGITAL_0, 5, static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int val; int ret; @@ -585,7 +585,7 @@ static int wm8904_adc_osr_put(struct snd_kcontrol *kcontrol, else val = WM8904_ADC_128_OSR_TST_MODE | WM8904_ADC_BIASX1P5; - snd_soc_update_bits(codec, WM8904_ADC_TEST_0, + snd_soc_component_update_bits(component, WM8904_ADC_TEST_0, WM8904_ADC_128_OSR_TST_MODE | WM8904_ADC_BIASX1P5, val); @@ -673,8 +673,8 @@ static int cp_event(struct snd_soc_dapm_widget *w, static int sysclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -685,11 +685,11 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, */ switch (wm8904->sysclk_src) { case WM8904_CLK_FLL: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA, WM8904_FLL_OSC_ENA); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_ENA, WM8904_FLL_ENA); break; @@ -700,7 +700,7 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0); break; } @@ -711,8 +711,8 @@ static int sysclk_event(struct snd_soc_dapm_widget *w, static int out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int reg, val; int dcs_mask; int dcs_l, dcs_r; @@ -751,43 +751,43 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Power on the PGAs */ - snd_soc_update_bits(codec, pwr_reg, + snd_soc_component_update_bits(component, pwr_reg, WM8904_HPL_PGA_ENA | WM8904_HPR_PGA_ENA, WM8904_HPL_PGA_ENA | WM8904_HPR_PGA_ENA); /* Power on the amplifier */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA | WM8904_HPR_ENA, WM8904_HPL_ENA | WM8904_HPR_ENA); /* Enable the first stage */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA_DLY | WM8904_HPR_ENA_DLY, WM8904_HPL_ENA_DLY | WM8904_HPR_ENA_DLY); /* Power up the DC servo */ - snd_soc_update_bits(codec, WM8904_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8904_DC_SERVO_0, dcs_mask, dcs_mask); /* Either calibrate the DC servo or restore cached state * if we have that. */ if (wm8904->dcs_state[dcs_l] || wm8904->dcs_state[dcs_r]) { - dev_dbg(codec->dev, "Restoring DC servo state\n"); + dev_dbg(component->dev, "Restoring DC servo state\n"); - snd_soc_write(codec, dcs_l_reg, + snd_soc_component_write(component, dcs_l_reg, wm8904->dcs_state[dcs_l]); - snd_soc_write(codec, dcs_r_reg, + snd_soc_component_write(component, dcs_r_reg, wm8904->dcs_state[dcs_r]); - snd_soc_write(codec, WM8904_DC_SERVO_1, dcs_mask); + snd_soc_component_write(component, WM8904_DC_SERVO_1, dcs_mask); timeout = 20; } else { - dev_dbg(codec->dev, "Calibrating DC servo\n"); + dev_dbg(component->dev, "Calibrating DC servo\n"); - snd_soc_write(codec, WM8904_DC_SERVO_1, + snd_soc_component_write(component, WM8904_DC_SERVO_1, dcs_mask << WM8904_DCS_TRIG_STARTUP_0_SHIFT); timeout = 500; @@ -796,7 +796,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, /* Wait for DC servo to complete */ dcs_mask <<= WM8904_DCS_CAL_COMPLETE_SHIFT; do { - val = snd_soc_read(codec, WM8904_DC_SERVO_READBACK_0); + val = snd_soc_component_read32(component, WM8904_DC_SERVO_READBACK_0); if ((val & dcs_mask) == dcs_mask) break; @@ -804,19 +804,19 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, } while (--timeout); if ((val & dcs_mask) != dcs_mask) - dev_warn(codec->dev, "DC servo timed out\n"); + dev_warn(component->dev, "DC servo timed out\n"); else - dev_dbg(codec->dev, "DC servo ready\n"); + dev_dbg(component->dev, "DC servo ready\n"); /* Enable the output stage */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP, WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP); break; case SND_SOC_DAPM_POST_PMU: /* Unshort the output itself */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_RMV_SHORT | WM8904_HPR_RMV_SHORT, WM8904_HPL_RMV_SHORT | @@ -826,7 +826,7 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: /* Short the output */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_RMV_SHORT | WM8904_HPR_RMV_SHORT, 0); break; @@ -834,21 +834,21 @@ static int out_pga_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: /* Cache the DC servo configuration; this will be * invalidated if we change the configuration. */ - wm8904->dcs_state[dcs_l] = snd_soc_read(codec, dcs_l_reg); - wm8904->dcs_state[dcs_r] = snd_soc_read(codec, dcs_r_reg); + wm8904->dcs_state[dcs_l] = snd_soc_component_read32(component, dcs_l_reg); + wm8904->dcs_state[dcs_r] = snd_soc_component_read32(component, dcs_r_reg); - snd_soc_update_bits(codec, WM8904_DC_SERVO_0, + snd_soc_component_update_bits(component, WM8904_DC_SERVO_0, dcs_mask, 0); /* Disable the amplifier input and output stages */ - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, WM8904_HPL_ENA | WM8904_HPR_ENA | WM8904_HPL_ENA_DLY | WM8904_HPR_ENA_DLY | WM8904_HPL_ENA_OUTP | WM8904_HPR_ENA_OUTP, 0); /* PGAs too */ - snd_soc_update_bits(codec, pwr_reg, + snd_soc_component_update_bits(component, pwr_reg, WM8904_HPL_PGA_ENA | WM8904_HPR_PGA_ENA, 0); break; @@ -1165,10 +1165,10 @@ static const struct snd_soc_dapm_route wm8912_intercon[] = { { "LINER PGA", NULL, "DACR" }, }; -static int wm8904_add_widgets(struct snd_soc_codec *codec) +static int wm8904_add_widgets(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); snd_soc_dapm_new_controls(dapm, wm8904_core_dapm_widgets, ARRAY_SIZE(wm8904_core_dapm_widgets)); @@ -1177,11 +1177,11 @@ static int wm8904_add_widgets(struct snd_soc_codec *codec) switch (wm8904->devtype) { case WM8904: - snd_soc_add_codec_controls(codec, wm8904_adc_snd_controls, + snd_soc_add_component_controls(component, wm8904_adc_snd_controls, ARRAY_SIZE(wm8904_adc_snd_controls)); - snd_soc_add_codec_controls(codec, wm8904_dac_snd_controls, + snd_soc_add_component_controls(component, wm8904_dac_snd_controls, ARRAY_SIZE(wm8904_dac_snd_controls)); - snd_soc_add_codec_controls(codec, wm8904_snd_controls, + snd_soc_add_component_controls(component, wm8904_snd_controls, ARRAY_SIZE(wm8904_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8904_adc_dapm_widgets, @@ -1200,7 +1200,7 @@ static int wm8904_add_widgets(struct snd_soc_codec *codec) break; case WM8912: - snd_soc_add_codec_controls(codec, wm8904_dac_snd_controls, + snd_soc_add_component_controls(component, wm8904_dac_snd_controls, ARRAY_SIZE(wm8904_dac_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8904_dac_dapm_widgets, @@ -1278,8 +1278,8 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int ret, i, best, best_val, cur_val; unsigned int aif1 = 0; unsigned int aif2 = 0; @@ -1290,7 +1290,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, /* What BCLK do we need? */ wm8904->fs = params_rate(params); if (wm8904->tdm_slots) { - dev_dbg(codec->dev, "Configuring for %d %d bit TDM slots\n", + dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", wm8904->tdm_slots, wm8904->tdm_width); wm8904->bclk = snd_soc_calc_bclk(wm8904->fs, wm8904->tdm_width, 2, @@ -1316,9 +1316,9 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, } - dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm8904->bclk); + dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8904->bclk); - ret = wm8904_configure_clocking(codec); + ret = wm8904_configure_clocking(component); if (ret != 0) return ret; @@ -1334,7 +1334,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", clk_sys_rates[best].ratio); clock1 |= (clk_sys_rates[best].clk_sys_rate << WM8904_CLK_SYS_RATE_SHIFT); @@ -1350,7 +1350,7 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", + dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", sample_rates[best].rate); clock1 |= (sample_rates[best].sample_rate << WM8904_SAMPLE_RATE_SHIFT); @@ -1373,30 +1373,30 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, } } wm8904->bclk = (wm8904->sysclk_rate * 10) / bclk_divs[best].div; - dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", + dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", bclk_divs[best].div, wm8904->bclk); aif2 |= bclk_divs[best].bclk_div; /* LRCLK is a simple fraction of BCLK */ - dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); + dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); aif3 |= wm8904->bclk / wm8904->fs; /* Apply the settings */ - snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_1, + snd_soc_component_update_bits(component, WM8904_DAC_DIGITAL_1, WM8904_DAC_SB_FILT, dac_digital1); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_1, WM8904_AIF_WL_MASK, aif1); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_2, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_2, WM8904_BCLK_DIV_MASK, aif2); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_3, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_3, WM8904_LRCLK_RATE_MASK, aif3); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_1, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_1, WM8904_SAMPLE_RATE_MASK | WM8904_CLK_SYS_RATE_MASK, clock1); /* Update filters for the new settings */ - wm8904_set_retune_mobile(codec); - wm8904_set_deemph(codec); + wm8904_set_retune_mobile(component); + wm8904_set_deemph(component); return 0; } @@ -1405,8 +1405,8 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, static int wm8904_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *priv = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM8904_CLK_MCLK: @@ -1424,14 +1424,14 @@ static int wm8904_set_sysclk(struct snd_soc_dai *dai, int clk_id, dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq); - wm8904_configure_clocking(codec); + wm8904_configure_clocking(component); return 0; } static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int aif1 = 0; unsigned int aif3 = 0; @@ -1508,10 +1508,10 @@ static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_1, WM8904_AIF_BCLK_INV | WM8904_AIF_LRCLK_INV | WM8904_AIF_FMT_MASK | WM8904_BCLK_DIR, aif1); - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_3, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_3, WM8904_LRCLK_DIR, aif3); return 0; @@ -1521,8 +1521,8 @@ static int wm8904_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int wm8904_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int aif1 = 0; /* Don't need to validate anything if we're turning off TDM */ @@ -1560,7 +1560,7 @@ out: wm8904->tdm_width = slot_width; wm8904->tdm_slots = slots / 2; - snd_soc_update_bits(codec, WM8904_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8904_AUDIO_INTERFACE_1, WM8904_AIFADC_TDM | WM8904_AIFADC_TDM_CHAN | WM8904_AIFDAC_TDM | WM8904_AIFDAC_TDM_CHAN, aif1); @@ -1678,8 +1678,8 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct snd_soc_codec *codec = dai->codec; - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct _fll_div fll_div; int ret, val; int clock2, fll1; @@ -1689,19 +1689,19 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, Fout == wm8904->fll_fout) return 0; - clock2 = snd_soc_read(codec, WM8904_CLOCK_RATES_2); + clock2 = snd_soc_component_read32(component, WM8904_CLOCK_RATES_2); if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n"); wm8904->fll_fref = 0; wm8904->fll_fout = 0; /* Gate SYSCLK to avoid glitches */ - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA, 0); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0); goto out; @@ -1718,7 +1718,7 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, break; case WM8904_FLL_FREE_RUNNING: - dev_dbg(codec->dev, "Using free running FLL\n"); + dev_dbg(component->dev, "Using free running FLL\n"); /* Force 12MHz and output/4 for now */ Fout = 12000000; Fref = 12000000; @@ -1728,20 +1728,20 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, break; default: - dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); + dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); return -EINVAL; } /* Save current state then disable the FLL and SYSCLK to avoid * misclocking */ - fll1 = snd_soc_read(codec, WM8904_FLL_CONTROL_1); - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + fll1 = snd_soc_component_read32(component, WM8904_FLL_CONTROL_1); + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA, 0); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA | WM8904_FLL_ENA, 0); /* Unlock forced oscilator control to switch it on/off */ - snd_soc_update_bits(codec, WM8904_CONTROL_INTERFACE_TEST_1, + snd_soc_component_update_bits(component, WM8904_CONTROL_INTERFACE_TEST_1, WM8904_USER_KEY, WM8904_USER_KEY); if (fll_id == WM8904_FLL_FREE_RUNNING) { @@ -1750,24 +1750,24 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, val = 0; } - snd_soc_update_bits(codec, WM8904_FLL_NCO_TEST_1, WM8904_FLL_FRC_NCO, + snd_soc_component_update_bits(component, WM8904_FLL_NCO_TEST_1, WM8904_FLL_FRC_NCO, val); - snd_soc_update_bits(codec, WM8904_CONTROL_INTERFACE_TEST_1, + snd_soc_component_update_bits(component, WM8904_CONTROL_INTERFACE_TEST_1, WM8904_USER_KEY, 0); switch (fll_id) { case WM8904_FLL_MCLK: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_SRC_MASK, 0); break; case WM8904_FLL_LRCLK: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_SRC_MASK, 1); break; case WM8904_FLL_BCLK: - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_SRC_MASK, 2); break; } @@ -1776,39 +1776,39 @@ static int wm8904_set_fll(struct snd_soc_dai *dai, int fll_id, int source, val = WM8904_FLL_FRACN_ENA; else val = 0; - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_FRACN_ENA, val); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_2, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_2, WM8904_FLL_OUTDIV_MASK | WM8904_FLL_FRATIO_MASK, (fll_div.fll_outdiv << WM8904_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio << WM8904_FLL_FRATIO_SHIFT)); - snd_soc_write(codec, WM8904_FLL_CONTROL_3, fll_div.k); + snd_soc_component_write(component, WM8904_FLL_CONTROL_3, fll_div.k); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_4, WM8904_FLL_N_MASK, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_4, WM8904_FLL_N_MASK, fll_div.n << WM8904_FLL_N_SHIFT); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_5, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_5, WM8904_FLL_CLK_REF_DIV_MASK, fll_div.fll_clk_ref_div << WM8904_FLL_CLK_REF_DIV_SHIFT); - dev_dbg(codec->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); wm8904->fll_fref = Fref; wm8904->fll_fout = Fout; wm8904->fll_src = source; /* Enable the FLL if it was previously active */ - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_OSC_ENA, fll1); - snd_soc_update_bits(codec, WM8904_FLL_CONTROL_1, + snd_soc_component_update_bits(component, WM8904_FLL_CONTROL_1, WM8904_FLL_ENA, fll1); out: /* Reenable SYSCLK if it was previously active */ - snd_soc_update_bits(codec, WM8904_CLOCK_RATES_2, + snd_soc_component_update_bits(component, WM8904_CLOCK_RATES_2, WM8904_CLK_SYS_ENA, clock2); return 0; @@ -1816,7 +1816,7 @@ out: static int wm8904_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int val; if (mute) @@ -1824,15 +1824,15 @@ static int wm8904_digital_mute(struct snd_soc_dai *codec_dai, int mute) else val = 0; - snd_soc_update_bits(codec, WM8904_DAC_DIGITAL_1, WM8904_DAC_MUTE, val); + snd_soc_component_update_bits(component, WM8904_DAC_DIGITAL_1, WM8904_DAC_MUTE, val); return 0; } -static int wm8904_set_bias_level(struct snd_soc_codec *codec, +static int wm8904_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1844,21 +1844,21 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID resistance 2*50k */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_RES_MASK, 0x1 << WM8904_VMID_RES_SHIFT); /* Normal bias current */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_ISEL_MASK, 2 << WM8904_ISEL_SHIFT); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; @@ -1868,11 +1868,11 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, regcache_sync(wm8904->regmap); /* Enable bias */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_BIAS_ENA, WM8904_BIAS_ENA); /* Enable VMID, VMID buffering, 2*5k resistance */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_ENA | WM8904_VMID_RES_MASK, WM8904_VMID_ENA | @@ -1883,22 +1883,22 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, } /* Maintain VMID with 2*250k */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_RES_MASK, 0x2 << WM8904_VMID_RES_SHIFT); /* Bias current *0.5 */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_ISEL_MASK, 0); break; case SND_SOC_BIAS_OFF: /* Turn off VMID */ - snd_soc_update_bits(codec, WM8904_VMID_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_VMID_CONTROL_0, WM8904_VMID_RES_MASK | WM8904_VMID_ENA, 0); /* Stop bias generation */ - snd_soc_update_bits(codec, WM8904_BIAS_CONTROL_0, + snd_soc_component_update_bits(component, WM8904_BIAS_CONTROL_0, WM8904_BIAS_ENA, 0); regcache_cache_only(wm8904->regmap, true); @@ -1946,9 +1946,9 @@ static struct snd_soc_dai_driver wm8904_dai = { .symmetric_rates = 1, }; -static void wm8904_handle_retune_mobile_pdata(struct snd_soc_codec *codec) +static void wm8904_handle_retune_mobile_pdata(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; struct snd_kcontrol_new control = SOC_ENUM_EXT("EQ Mode", @@ -1991,31 +1991,31 @@ static void wm8904_handle_retune_mobile_pdata(struct snd_soc_codec *codec) wm8904->retune_mobile_texts = t; } - dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", + dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", wm8904->num_retune_mobile_texts); wm8904->retune_mobile_enum.items = wm8904->num_retune_mobile_texts; wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts; - ret = snd_soc_add_codec_controls(codec, &control, 1); + ret = snd_soc_add_component_controls(component, &control, 1); if (ret != 0) - dev_err(codec->dev, + dev_err(component->dev, "Failed to add ReTune Mobile control: %d\n", ret); } -static void wm8904_handle_pdata(struct snd_soc_codec *codec) +static void wm8904_handle_pdata(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); struct wm8904_pdata *pdata = wm8904->pdata; int ret, i; if (!pdata) { - snd_soc_add_codec_controls(codec, wm8904_eq_controls, + snd_soc_add_component_controls(component, wm8904_eq_controls, ARRAY_SIZE(wm8904_eq_controls)); return; } - dev_dbg(codec->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); + dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); if (pdata->num_drc_cfgs) { struct snd_kcontrol_new control = @@ -2034,28 +2034,28 @@ static void wm8904_handle_pdata(struct snd_soc_codec *codec) wm8904->drc_enum.items = pdata->num_drc_cfgs; wm8904->drc_enum.texts = wm8904->drc_texts; - ret = snd_soc_add_codec_controls(codec, &control, 1); + ret = snd_soc_add_component_controls(component, &control, 1); if (ret != 0) - dev_err(codec->dev, + dev_err(component->dev, "Failed to add DRC mode control: %d\n", ret); - wm8904_set_drc(codec); + wm8904_set_drc(component); } - dev_dbg(codec->dev, "%d ReTune Mobile configurations\n", + dev_dbg(component->dev, "%d ReTune Mobile configurations\n", pdata->num_retune_mobile_cfgs); if (pdata->num_retune_mobile_cfgs) - wm8904_handle_retune_mobile_pdata(codec); + wm8904_handle_retune_mobile_pdata(component); else - snd_soc_add_codec_controls(codec, wm8904_eq_controls, + snd_soc_add_component_controls(component, wm8904_eq_controls, ARRAY_SIZE(wm8904_eq_controls)); } -static int wm8904_probe(struct snd_soc_codec *codec) +static int wm8904_probe(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); switch (wm8904->devtype) { case WM8904: @@ -2064,33 +2064,33 @@ static int wm8904_probe(struct snd_soc_codec *codec) memset(&wm8904_dai.capture, 0, sizeof(wm8904_dai.capture)); break; default: - dev_err(codec->dev, "Unknown device type %d\n", + dev_err(component->dev, "Unknown device type %d\n", wm8904->devtype); return -EINVAL; } - wm8904_handle_pdata(codec); + wm8904_handle_pdata(component); - wm8904_add_widgets(codec); + wm8904_add_widgets(component); return 0; } -static int wm8904_remove(struct snd_soc_codec *codec) +static void wm8904_remove(struct snd_soc_component *component) { - struct wm8904_priv *wm8904 = snd_soc_codec_get_drvdata(codec); + struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); kfree(wm8904->retune_mobile_texts); kfree(wm8904->drc_texts); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm8904 = { - .probe = wm8904_probe, - .remove = wm8904_remove, - .set_bias_level = wm8904_set_bias_level, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm8904 = { + .probe = wm8904_probe, + .remove = wm8904_remove, + .set_bias_level = wm8904_set_bias_level, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm8904_regmap = { @@ -2265,8 +2265,8 @@ static int wm8904_i2c_probe(struct i2c_client *i2c, regcache_cache_only(wm8904->regmap, true); regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8904, &wm8904_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8904, &wm8904_dai, 1); if (ret != 0) return ret; @@ -2277,12 +2277,6 @@ err_enable: return ret; } -static int wm8904_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id wm8904_i2c_id[] = { { "wm8904", WM8904 }, { "wm8912", WM8912 }, @@ -2297,7 +2291,6 @@ static struct i2c_driver wm8904_i2c_driver = { .of_match_table = of_match_ptr(wm8904_of_match), }, .probe = wm8904_i2c_probe, - .remove = wm8904_i2c_remove, .id_table = wm8904_i2c_id, }; From 48c3387642967d62fc47aff4ad0e3816bf8292e3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:09:52 +0000 Subject: [PATCH 054/942] ASoC: wm9081: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = true -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm9081.c | 228 +++++++++++++++++++------------------- 1 file changed, 112 insertions(+), 116 deletions(-) diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 6febef337dd2..52dd610cd8dc 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -339,10 +339,10 @@ static SOC_ENUM_SINGLE_DECL(speaker_mode, WM9081_ANALOGUE_SPEAKER_2, 6, static int speaker_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg; - reg = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); + reg = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2); if (reg & WM9081_SPK_MODE) ucontrol->value.enumerated.item[0] = 1; else @@ -360,9 +360,9 @@ static int speaker_mode_get(struct snd_kcontrol *kcontrol, static int speaker_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - unsigned int reg_pwr = snd_soc_read(codec, WM9081_POWER_MANAGEMENT); - unsigned int reg2 = snd_soc_read(codec, WM9081_ANALOGUE_SPEAKER_2); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + unsigned int reg_pwr = snd_soc_component_read32(component, WM9081_POWER_MANAGEMENT); + unsigned int reg2 = snd_soc_component_read32(component, WM9081_ANALOGUE_SPEAKER_2); /* Are we changing anything? */ if (ucontrol->value.enumerated.item[0] == @@ -383,7 +383,7 @@ static int speaker_mode_put(struct snd_kcontrol *kcontrol, reg2 &= ~WM9081_SPK_MODE; } - snd_soc_write(codec, WM9081_ANALOGUE_SPEAKER_2, reg2); + snd_soc_component_write(component, WM9081_ANALOGUE_SPEAKER_2, reg2); return 0; } @@ -546,10 +546,10 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, +static int wm9081_set_fll(struct snd_soc_component *component, int fll_id, unsigned int Fref, unsigned int Fout) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); u16 reg1, reg4, reg5; struct _fll_div fll_div; int ret; @@ -561,7 +561,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, /* Disable the FLL */ if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n"); wm9081->fll_fref = 0; wm9081->fll_fout = 0; @@ -572,7 +572,7 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, if (ret != 0) return ret; - reg5 = snd_soc_read(codec, WM9081_FLL_CONTROL_5); + reg5 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_5); reg5 &= ~WM9081_FLL_CLK_SRC_MASK; switch (fll_id) { @@ -581,55 +581,55 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, break; default: - dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); + dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); return -EINVAL; } /* Disable CLK_SYS while we reconfigure */ - clk_sys_reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_3); + clk_sys_reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3); if (clk_sys_reg & WM9081_CLK_SYS_ENA) - snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, clk_sys_reg & ~WM9081_CLK_SYS_ENA); /* Any FLL configuration change requires that the FLL be * disabled first. */ - reg1 = snd_soc_read(codec, WM9081_FLL_CONTROL_1); + reg1 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_1); reg1 &= ~WM9081_FLL_ENA; - snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1); /* Apply the configuration */ if (fll_div.k) reg1 |= WM9081_FLL_FRAC_MASK; else reg1 &= ~WM9081_FLL_FRAC_MASK; - snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1); - snd_soc_write(codec, WM9081_FLL_CONTROL_2, + snd_soc_component_write(component, WM9081_FLL_CONTROL_2, (fll_div.fll_outdiv << WM9081_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio << WM9081_FLL_FRATIO_SHIFT)); - snd_soc_write(codec, WM9081_FLL_CONTROL_3, fll_div.k); + snd_soc_component_write(component, WM9081_FLL_CONTROL_3, fll_div.k); - reg4 = snd_soc_read(codec, WM9081_FLL_CONTROL_4); + reg4 = snd_soc_component_read32(component, WM9081_FLL_CONTROL_4); reg4 &= ~WM9081_FLL_N_MASK; reg4 |= fll_div.n << WM9081_FLL_N_SHIFT; - snd_soc_write(codec, WM9081_FLL_CONTROL_4, reg4); + snd_soc_component_write(component, WM9081_FLL_CONTROL_4, reg4); reg5 &= ~WM9081_FLL_CLK_REF_DIV_MASK; reg5 |= fll_div.fll_clk_ref_div << WM9081_FLL_CLK_REF_DIV_SHIFT; - snd_soc_write(codec, WM9081_FLL_CONTROL_5, reg5); + snd_soc_component_write(component, WM9081_FLL_CONTROL_5, reg5); /* Set gain to the recommended value */ - snd_soc_update_bits(codec, WM9081_FLL_CONTROL_4, + snd_soc_component_update_bits(component, WM9081_FLL_CONTROL_4, WM9081_FLL_GAIN_MASK, 0); /* Enable the FLL */ - snd_soc_write(codec, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA); + snd_soc_component_write(component, WM9081_FLL_CONTROL_1, reg1 | WM9081_FLL_ENA); /* Then bring CLK_SYS up again if it was disabled */ if (clk_sys_reg & WM9081_CLK_SYS_ENA) - snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, clk_sys_reg); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, clk_sys_reg); - dev_dbg(codec->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); wm9081->fll_fref = Fref; wm9081->fll_fout = Fout; @@ -637,9 +637,9 @@ static int wm9081_set_fll(struct snd_soc_codec *codec, int fll_id, return 0; } -static int configure_clock(struct snd_soc_codec *codec) +static int configure_clock(struct snd_soc_component *component) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); int new_sysclk, i, target; unsigned int reg; int ret = 0; @@ -654,7 +654,7 @@ static int configure_clock(struct snd_soc_codec *codec) } else { wm9081->sysclk_rate = wm9081->mclk_rate; } - wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, 0, 0); + wm9081_set_fll(component, WM9081_SYSCLK_FLL_MCLK, 0, 0); break; case WM9081_SYSCLK_FLL_MCLK: @@ -695,7 +695,7 @@ static int configure_clock(struct snd_soc_codec *codec) new_sysclk = 12288000; } - ret = wm9081_set_fll(codec, WM9081_SYSCLK_FLL_MCLK, + ret = wm9081_set_fll(component, WM9081_SYSCLK_FLL_MCLK, wm9081->mclk_rate, new_sysclk); if (ret == 0) { wm9081->sysclk_rate = new_sysclk; @@ -711,21 +711,21 @@ static int configure_clock(struct snd_soc_codec *codec) return -EINVAL; } - reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_1); + reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_1); if (mclkdiv) reg |= WM9081_MCLKDIV2; else reg &= ~WM9081_MCLKDIV2; - snd_soc_write(codec, WM9081_CLOCK_CONTROL_1, reg); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_1, reg); - reg = snd_soc_read(codec, WM9081_CLOCK_CONTROL_3); + reg = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_3); if (fll) reg |= WM9081_CLK_SRC_SEL; else reg &= ~WM9081_CLK_SRC_SEL; - snd_soc_write(codec, WM9081_CLOCK_CONTROL_3, reg); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_3, reg); - dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate); + dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm9081->sysclk_rate); return ret; } @@ -733,31 +733,31 @@ static int configure_clock(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); /* This should be done on init() for bypass paths */ switch (wm9081->sysclk_source) { case WM9081_SYSCLK_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK\n", wm9081->mclk_rate); + dev_dbg(component->dev, "Using %dHz MCLK\n", wm9081->mclk_rate); break; case WM9081_SYSCLK_FLL_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK with FLL\n", + dev_dbg(component->dev, "Using %dHz MCLK with FLL\n", wm9081->mclk_rate); break; default: - dev_err(codec->dev, "System clock not configured\n"); + dev_err(component->dev, "System clock not configured\n"); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - configure_clock(codec); + configure_clock(component); break; case SND_SOC_DAPM_POST_PMD: /* Disable the FLL if it's running */ - wm9081_set_fll(codec, 0, 0, 0); + wm9081_set_fll(component, 0, 0, 0); break; } @@ -816,10 +816,10 @@ static const struct snd_soc_dapm_route wm9081_audio_paths[] = { { "SPKP", NULL, "Speaker" }, }; -static int wm9081_set_bias_level(struct snd_soc_codec *codec, +static int wm9081_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -827,31 +827,31 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VMID=2*40k */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_SEL_MASK, 0x2); /* Normal bias current */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_STBY_BIAS_ENA, 0); break; case SND_SOC_BIAS_STANDBY: /* Initial cold start */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_cache_only(wm9081->regmap, false); regcache_sync(wm9081->regmap); /* Disable LINEOUT discharge */ - snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, + snd_soc_component_update_bits(component, WM9081_ANTI_POP_CONTROL, WM9081_LINEOUT_DISCH, 0); /* Select startup bias source */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_BIAS_SRC | WM9081_BIAS_ENA, WM9081_BIAS_SRC | WM9081_BIAS_ENA); /* VMID 2*4k; Soft VMID ramp enable */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK, WM9081_VMID_RAMP | 0x6); @@ -859,37 +859,37 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, mdelay(100); /* Normal bias enable & soft start off */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_RAMP, 0); /* Standard bias source */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_BIAS_SRC, 0); } /* VMID 2*240k */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_SEL_MASK, 0x04); /* Standby bias current on */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_STBY_BIAS_ENA, WM9081_STBY_BIAS_ENA); break; case SND_SOC_BIAS_OFF: /* Startup bias source and disable bias */ - snd_soc_update_bits(codec, WM9081_BIAS_CONTROL_1, + snd_soc_component_update_bits(component, WM9081_BIAS_CONTROL_1, WM9081_BIAS_SRC | WM9081_BIAS_ENA, WM9081_BIAS_SRC); /* Disable VMID with soft ramping */ - snd_soc_update_bits(codec, WM9081_VMID_CONTROL, + snd_soc_component_update_bits(component, WM9081_VMID_CONTROL, WM9081_VMID_RAMP | WM9081_VMID_SEL_MASK, WM9081_VMID_RAMP); /* Actively discharge LINEOUT */ - snd_soc_update_bits(codec, WM9081_ANTI_POP_CONTROL, + snd_soc_component_update_bits(component, WM9081_ANTI_POP_CONTROL, WM9081_LINEOUT_DISCH, WM9081_LINEOUT_DISCH); @@ -903,9 +903,9 @@ static int wm9081_set_bias_level(struct snd_soc_codec *codec, static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); - unsigned int aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2); + struct snd_soc_component *component = dai->component; + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); + unsigned int aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2); aif2 &= ~(WM9081_AIF_BCLK_INV | WM9081_AIF_LRCLK_INV | WM9081_BCLK_DIR | WM9081_LRCLK_DIR | WM9081_AIF_FMT_MASK); @@ -986,7 +986,7 @@ static int wm9081_set_dai_fmt(struct snd_soc_dai *dai, return -EINVAL; } - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_2, aif2); return 0; } @@ -995,23 +995,23 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); int ret, i, best, best_val, cur_val; unsigned int clk_ctrl2, aif1, aif2, aif3, aif4; - clk_ctrl2 = snd_soc_read(codec, WM9081_CLOCK_CONTROL_2); + clk_ctrl2 = snd_soc_component_read32(component, WM9081_CLOCK_CONTROL_2); clk_ctrl2 &= ~(WM9081_CLK_SYS_RATE_MASK | WM9081_SAMPLE_RATE_MASK); - aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1); + aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1); - aif2 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_2); + aif2 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_2); aif2 &= ~WM9081_AIF_WL_MASK; - aif3 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_3); + aif3 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_3); aif3 &= ~WM9081_BCLK_DIV_MASK; - aif4 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_4); + aif4 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_4); aif4 &= ~WM9081_LRCLK_RATE_MASK; wm9081->fs = params_rate(params); @@ -1047,9 +1047,9 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, } } - dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm9081->bclk); + dev_dbg(component->dev, "Target BCLK is %dHz\n", wm9081->bclk); - ret = configure_clock(codec); + ret = configure_clock(component); if (ret != 0) return ret; @@ -1065,7 +1065,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", clk_sys_rates[best].ratio); clk_ctrl2 |= (clk_sys_rates[best].clk_sys_rate << WM9081_CLK_SYS_RATE_SHIFT); @@ -1081,7 +1081,7 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", + dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", sample_rates[best].rate); clk_ctrl2 |= (sample_rates[best].sample_rate << WM9081_SAMPLE_RATE_SHIFT); @@ -1100,12 +1100,12 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, } } wm9081->bclk = (wm9081->sysclk_rate * 10) / bclk_divs[best].div; - dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", + dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", bclk_divs[best].div, wm9081->bclk); aif3 |= bclk_divs[best].bclk_div; /* LRCLK is a simple fraction of BCLK */ - dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs); + dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm9081->bclk / wm9081->fs); aif4 |= wm9081->bclk / wm9081->fs; /* Apply a ReTune Mobile configuration if it's in use */ @@ -1126,51 +1126,51 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, } s = &pdata->retune_configs[best]; - dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", + dev_dbg(component->dev, "ReTune Mobile %s tuned for %dHz\n", s->name, s->rate); /* If the EQ is enabled then disable it while we write out */ - eq1 = snd_soc_read(codec, WM9081_EQ_1) & WM9081_EQ_ENA; + eq1 = snd_soc_component_read32(component, WM9081_EQ_1) & WM9081_EQ_ENA; if (eq1 & WM9081_EQ_ENA) - snd_soc_write(codec, WM9081_EQ_1, 0); + snd_soc_component_write(component, WM9081_EQ_1, 0); /* Write out the other values */ for (i = 1; i < ARRAY_SIZE(s->config); i++) - snd_soc_write(codec, WM9081_EQ_1 + i, s->config[i]); + snd_soc_component_write(component, WM9081_EQ_1 + i, s->config[i]); eq1 |= (s->config[0] & ~WM9081_EQ_ENA); - snd_soc_write(codec, WM9081_EQ_1, eq1); + snd_soc_component_write(component, WM9081_EQ_1, eq1); } - snd_soc_write(codec, WM9081_CLOCK_CONTROL_2, clk_ctrl2); - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_2, aif2); - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_3, aif3); - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_4, aif4); + snd_soc_component_write(component, WM9081_CLOCK_CONTROL_2, clk_ctrl2); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_2, aif2); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_3, aif3); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_4, aif4); return 0; } static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg; - reg = snd_soc_read(codec, WM9081_DAC_DIGITAL_2); + snd_soc_component_read32(component, WM9081_DAC_DIGITAL_2); if (mute) reg |= WM9081_DAC_MUTE; else reg &= ~WM9081_DAC_MUTE; - snd_soc_write(codec, WM9081_DAC_DIGITAL_2, reg); + snd_soc_component_write(component, WM9081_DAC_DIGITAL_2, reg); return 0; } -static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int wm9081_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM9081_SYSCLK_MCLK: @@ -1189,9 +1189,9 @@ static int wm9081_set_sysclk(struct snd_soc_codec *codec, int clk_id, static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); - unsigned int aif1 = snd_soc_read(codec, WM9081_AUDIO_INTERFACE_1); + struct snd_soc_component *component = dai->component; + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); + unsigned int aif1 = snd_soc_component_read32(component, WM9081_AUDIO_INTERFACE_1); aif1 &= ~(WM9081_AIFDAC_TDM_SLOT_MASK | WM9081_AIFDAC_TDM_MODE_MASK); @@ -1221,7 +1221,7 @@ static int wm9081_set_tdm_slot(struct snd_soc_dai *dai, return -EINVAL; } - snd_soc_write(codec, WM9081_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM9081_AUDIO_INTERFACE_1, aif1); return 0; } @@ -1254,42 +1254,39 @@ static struct snd_soc_dai_driver wm9081_dai = { .ops = &wm9081_dai_ops, }; -static int wm9081_probe(struct snd_soc_codec *codec) +static int wm9081_probe(struct snd_soc_component *component) { - struct wm9081_priv *wm9081 = snd_soc_codec_get_drvdata(codec); + struct wm9081_priv *wm9081 = snd_soc_component_get_drvdata(component); /* Enable zero cross by default */ - snd_soc_update_bits(codec, WM9081_ANALOGUE_LINEOUT, + snd_soc_component_update_bits(component, WM9081_ANALOGUE_LINEOUT, WM9081_LINEOUTZC, WM9081_LINEOUTZC); - snd_soc_update_bits(codec, WM9081_ANALOGUE_SPEAKER_PGA, + snd_soc_component_update_bits(component, WM9081_ANALOGUE_SPEAKER_PGA, WM9081_SPKPGAZC, WM9081_SPKPGAZC); if (!wm9081->pdata.num_retune_configs) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "No ReTune Mobile data, using normal EQ\n"); - snd_soc_add_codec_controls(codec, wm9081_eq_controls, + snd_soc_add_component_controls(component, wm9081_eq_controls, ARRAY_SIZE(wm9081_eq_controls)); } return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm9081 = { - .probe = wm9081_probe, - - .set_sysclk = wm9081_set_sysclk, - .set_bias_level = wm9081_set_bias_level, - - .idle_bias_off = true, - - .component_driver = { - .controls = wm9081_snd_controls, - .num_controls = ARRAY_SIZE(wm9081_snd_controls), - .dapm_widgets = wm9081_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets), - .dapm_routes = wm9081_audio_paths, - .num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9081 = { + .probe = wm9081_probe, + .set_sysclk = wm9081_set_sysclk, + .set_bias_level = wm9081_set_bias_level, + .controls = wm9081_snd_controls, + .num_controls = ARRAY_SIZE(wm9081_snd_controls), + .dapm_widgets = wm9081_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9081_dapm_widgets), + .dapm_routes = wm9081_audio_paths, + .num_dapm_routes = ARRAY_SIZE(wm9081_audio_paths), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm9081_regmap = { @@ -1355,8 +1352,8 @@ static int wm9081_i2c_probe(struct i2c_client *i2c, regcache_cache_only(wm9081->regmap, true); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm9081, &wm9081_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm9081, &wm9081_dai, 1); if (ret < 0) return ret; @@ -1365,7 +1362,6 @@ static int wm9081_i2c_probe(struct i2c_client *i2c, static int wm9081_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From 2822e66bb812489aff9c41f4b265fcc2d8613989 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:10:09 +0000 Subject: [PATCH 055/942] ASoC: wm9090: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm9090.c | 109 ++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 56 deletions(-) diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c index 5a131385cb2f..a9f1a0360a19 100644 --- a/sound/soc/codecs/wm9090.c +++ b/sound/soc/codecs/wm9090.c @@ -143,23 +143,23 @@ static bool wm9090_readable(struct device *dev, unsigned int reg) } } -static void wait_for_dc_servo(struct snd_soc_codec *codec) +static void wait_for_dc_servo(struct snd_soc_component *component) { unsigned int reg; int count = 0; - dev_dbg(codec->dev, "Waiting for DC servo...\n"); + dev_dbg(component->dev, "Waiting for DC servo...\n"); do { count++; msleep(1); - reg = snd_soc_read(codec, WM9090_DC_SERVO_READBACK_0); - dev_dbg(codec->dev, "DC servo status: %x\n", reg); + reg = snd_soc_component_read32(component, WM9090_DC_SERVO_READBACK_0); + dev_dbg(component->dev, "DC servo status: %x\n", reg); } while ((reg & WM9090_DCS_CAL_COMPLETE_MASK) != WM9090_DCS_CAL_COMPLETE_MASK && count < 1000); if ((reg & WM9090_DCS_CAL_COMPLETE_MASK) != WM9090_DCS_CAL_COMPLETE_MASK) - dev_err(codec->dev, "Timed out waiting for DC Servo\n"); + dev_err(component->dev, "Timed out waiting for DC Servo\n"); } static const DECLARE_TLV_DB_RANGE(in_tlv, @@ -251,22 +251,22 @@ SOC_SINGLE_TLV("MIXOUTR IN2B Volume", WM9090_OUTPUT_MIXER4, 0, 3, 1, static int hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - unsigned int reg = snd_soc_read(codec, WM9090_ANALOGUE_HP_0); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + unsigned int reg = snd_soc_component_read32(component, WM9090_ANALOGUE_HP_0); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1, WM9090_CP_ENA, WM9090_CP_ENA); msleep(5); - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA, WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA); reg |= WM9090_HPOUT1L_DLY | WM9090_HPOUT1R_DLY; - snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg); /* Start the DC servo. We don't currently use the * ability to save the state since we don't have full @@ -274,16 +274,16 @@ static int hp_ev(struct snd_soc_dapm_widget *w, * DC offsets; see the WM8904 driver for an example of * doing so. */ - snd_soc_write(codec, WM9090_DC_SERVO_0, + snd_soc_component_write(component, WM9090_DC_SERVO_0, WM9090_DCS_ENA_CHAN_0 | WM9090_DCS_ENA_CHAN_1 | WM9090_DCS_TRIG_STARTUP_1 | WM9090_DCS_TRIG_STARTUP_0); - wait_for_dc_servo(codec); + wait_for_dc_servo(component); reg |= WM9090_HPOUT1R_OUTP | WM9090_HPOUT1R_RMV_SHORT | WM9090_HPOUT1L_OUTP | WM9090_HPOUT1L_RMV_SHORT; - snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg); break; case SND_SOC_DAPM_PRE_PMD: @@ -294,15 +294,15 @@ static int hp_ev(struct snd_soc_dapm_widget *w, WM9090_HPOUT1R_DLY | WM9090_HPOUT1R_OUTP); - snd_soc_write(codec, WM9090_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM9090_ANALOGUE_HP_0, reg); - snd_soc_write(codec, WM9090_DC_SERVO_0, 0); + snd_soc_component_write(component, WM9090_DC_SERVO_0, 0); - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_HPOUT1L_ENA | WM9090_HPOUT1R_ENA, 0); - snd_soc_update_bits(codec, WM9090_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM9090_CHARGE_PUMP_1, WM9090_CP_ENA, 0); break; } @@ -419,10 +419,10 @@ static const struct snd_soc_dapm_route audio_map_in2_diff[] = { { "IN2A PGA", NULL, "IN2-" }, }; -static int wm9090_add_controls(struct snd_soc_codec *codec) +static int wm9090_add_controls(struct snd_soc_component *component) { - struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int i; snd_soc_dapm_new_controls(dapm, wm9090_dapm_widgets, @@ -430,7 +430,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); - snd_soc_add_codec_controls(codec, wm9090_controls, + snd_soc_add_component_controls(component, wm9090_controls, ARRAY_SIZE(wm9090_controls)); if (wm9090->pdata.lin1_diff) { @@ -439,7 +439,7 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) } else { snd_soc_dapm_add_routes(dapm, audio_map_in1_se, ARRAY_SIZE(audio_map_in1_se)); - snd_soc_add_codec_controls(codec, wm9090_in1_se_controls, + snd_soc_add_component_controls(component, wm9090_in1_se_controls, ARRAY_SIZE(wm9090_in1_se_controls)); } @@ -449,18 +449,18 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) } else { snd_soc_dapm_add_routes(dapm, audio_map_in2_se, ARRAY_SIZE(audio_map_in2_se)); - snd_soc_add_codec_controls(codec, wm9090_in2_se_controls, + snd_soc_add_component_controls(component, wm9090_in2_se_controls, ARRAY_SIZE(wm9090_in2_se_controls)); } if (wm9090->pdata.agc_ena) { for (i = 0; i < ARRAY_SIZE(wm9090->pdata.agc); i++) - snd_soc_write(codec, WM9090_AGC_CONTROL_0 + i, + snd_soc_component_write(component, WM9090_AGC_CONTROL_0 + i, wm9090->pdata.agc[i]); - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3, WM9090_AGC_ENA, WM9090_AGC_ENA); } else { - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_3, WM9090_AGC_ENA, 0); } @@ -472,19 +472,19 @@ static int wm9090_add_controls(struct snd_soc_codec *codec) * The machine driver should call this from their set_bias_level; if there * isn't one then this can just be set as the set_bias_level function. */ -static int wm9090_set_bias_level(struct snd_soc_codec *codec, +static int wm9090_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm9090_priv *wm9090 = snd_soc_codec_get_drvdata(codec); + struct wm9090_priv *wm9090 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, WM9090_ANTIPOP2, WM9090_VMID_ENA, + snd_soc_component_update_bits(component, WM9090_ANTIPOP2, WM9090_VMID_ENA, WM9090_VMID_ENA); - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, WM9090_BIAS_ENA | @@ -493,7 +493,7 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Restore the register cache */ regcache_sync(wm9090->regmap); } @@ -502,9 +502,9 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec, * ground referenced outputs and class D speaker mean that * latency is not an issue. */ - snd_soc_update_bits(codec, WM9090_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM9090_POWER_MANAGEMENT_1, WM9090_BIAS_ENA | WM9090_VMID_RES_MASK, 0); - snd_soc_update_bits(codec, WM9090_ANTIPOP2, + snd_soc_component_update_bits(component, WM9090_ANTIPOP2, WM9090_VMID_ENA, 0); break; @@ -515,45 +515,49 @@ static int wm9090_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int wm9090_probe(struct snd_soc_codec *codec) +static int wm9090_probe(struct snd_soc_component *component) { /* Configure some defaults; they will be written out when we * bring the bias up. */ - snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_A_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_A_VOLUME, WM9090_IN1_VU | WM9090_IN1A_ZC, WM9090_IN1_VU | WM9090_IN1A_ZC); - snd_soc_update_bits(codec, WM9090_IN1_LINE_INPUT_B_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN1_LINE_INPUT_B_VOLUME, WM9090_IN1_VU | WM9090_IN1B_ZC, WM9090_IN1_VU | WM9090_IN1B_ZC); - snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_A_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_A_VOLUME, WM9090_IN2_VU | WM9090_IN2A_ZC, WM9090_IN2_VU | WM9090_IN2A_ZC); - snd_soc_update_bits(codec, WM9090_IN2_LINE_INPUT_B_VOLUME, + snd_soc_component_update_bits(component, WM9090_IN2_LINE_INPUT_B_VOLUME, WM9090_IN2_VU | WM9090_IN2B_ZC, WM9090_IN2_VU | WM9090_IN2B_ZC); - snd_soc_update_bits(codec, WM9090_SPEAKER_VOLUME_LEFT, + snd_soc_component_update_bits(component, WM9090_SPEAKER_VOLUME_LEFT, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC, WM9090_SPKOUT_VU | WM9090_SPKOUTL_ZC); - snd_soc_update_bits(codec, WM9090_LEFT_OUTPUT_VOLUME, + snd_soc_component_update_bits(component, WM9090_LEFT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1L_ZC); - snd_soc_update_bits(codec, WM9090_RIGHT_OUTPUT_VOLUME, + snd_soc_component_update_bits(component, WM9090_RIGHT_OUTPUT_VOLUME, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC, WM9090_HPOUT1_VU | WM9090_HPOUT1R_ZC); - snd_soc_update_bits(codec, WM9090_CLOCKING_1, + snd_soc_component_update_bits(component, WM9090_CLOCKING_1, WM9090_TOCLK_ENA, WM9090_TOCLK_ENA); - wm9090_add_controls(codec); + wm9090_add_controls(component); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm9090 = { - .probe = wm9090_probe, - .set_bias_level = wm9090_set_bias_level, - .suspend_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm9090 = { + .probe = wm9090_probe, + .set_bias_level = wm9090_set_bias_level, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config wm9090_regmap = { @@ -607,8 +611,8 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, wm9090); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm9090, NULL, 0); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm9090, NULL, 0); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; @@ -617,12 +621,6 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, return 0; } -static int wm9090_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id wm9090_id[] = { { "wm9090", 0 }, { "wm9093", 0 }, @@ -635,7 +633,6 @@ static struct i2c_driver wm9090_i2c_driver = { .name = "wm9090", }, .probe = wm9090_i2c_probe, - .remove = wm9090_i2c_remove, .id_table = wm9090_id, }; From 91880a6b6ba398c74420b4b0d0ef6fc3005f71ca Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:11:46 +0000 Subject: [PATCH 056/942] ASoC: wm9867: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 65 ++++++++++++++++++-------------------- sound/soc/codecs/max9867.h | 2 +- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2f60924fe919..a4e8fafb7e6d 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -179,8 +179,8 @@ static inline int get_ni_value(int mclk, int rate) static int max9867_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); unsigned int ni_h, ni_l; int value; @@ -227,7 +227,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, bclk_value = MAX9867_IFC1B_PCLK_16; break; default: - dev_err(codec->dev, + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } @@ -239,7 +239,7 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, bclk_value = MAX9867_IFC1B_32BIT; break; default: - dev_err(codec->dev, "unsupported sampling rate\n"); + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } regmap_update_bits(max9867->regmap, MAX9867_IFC1B, @@ -251,8 +251,8 @@ static int max9867_dai_hw_params(struct snd_pcm_substream *substream, static int max9867_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); regmap_update_bits(max9867->regmap, MAX9867_PWRMAN, MAX9867_SHTDOWN_MASK, MAX9867_SHTDOWN_MASK); @@ -261,8 +261,8 @@ static int max9867_prepare(struct snd_pcm_substream *substream, static int max9867_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); if (mute) regmap_update_bits(max9867->regmap, MAX9867_DACLEVEL, @@ -276,8 +276,8 @@ static int max9867_mute(struct snd_soc_dai *dai, int mute) static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); int value = 0; /* Set the prescaler based on the master clock frequency*/ @@ -306,8 +306,8 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); u8 iface1A = 0, iface1B = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -404,25 +404,27 @@ static int max9867_resume(struct device *dev) } #endif -static int max9867_probe(struct snd_soc_codec *codec) +static int max9867_probe(struct snd_soc_component *component) { - struct max9867_priv *max9867 = snd_soc_codec_get_drvdata(codec); + struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "max98090_probe\n"); - max9867->codec = codec; + dev_dbg(component->dev, "max98090_probe\n"); + max9867->component = component; return 0; } -static const struct snd_soc_codec_driver max9867_codec = { - .probe = max9867_probe, - .component_driver = { - .controls = max9867_snd_controls, - .num_controls = ARRAY_SIZE(max9867_snd_controls), - .dapm_routes = max9867_audio_map, - .num_dapm_routes = ARRAY_SIZE(max9867_audio_map), - .dapm_widgets = max9867_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets), - }, +static const struct snd_soc_component_driver max9867_component = { + .probe = max9867_probe, + .controls = max9867_snd_controls, + .num_controls = ARRAY_SIZE(max9867_snd_controls), + .dapm_routes = max9867_audio_map, + .num_dapm_routes = ARRAY_SIZE(max9867_audio_map), + .dapm_widgets = max9867_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9867_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static bool max9867_volatile_register(struct device *dev, unsigned int reg) @@ -497,21 +499,15 @@ static int max9867_i2c_probe(struct i2c_client *i2c, return ret; } dev_info(&i2c->dev, "device revision: %x\n", reg); - ret = snd_soc_register_codec(&i2c->dev, &max9867_codec, + ret = devm_snd_soc_register_component(&i2c->dev, &max9867_component, max9867_dai, ARRAY_SIZE(max9867_dai)); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } return ret; } -static int max9867_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max9867_i2c_id[] = { { "max9867", 0 }, { } @@ -535,7 +531,6 @@ static struct i2c_driver max9867_i2c_driver = { .pm = &max9867_pm_ops, }, .probe = max9867_i2c_probe, - .remove = max9867_i2c_remove, .id_table = max9867_i2c_id, }; diff --git a/sound/soc/codecs/max9867.h b/sound/soc/codecs/max9867.h index 65590b4ad62a..c0aea3d1f2ba 100644 --- a/sound/soc/codecs/max9867.h +++ b/sound/soc/codecs/max9867.h @@ -75,7 +75,7 @@ /* codec private data */ struct max9867_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int sysclk; unsigned int pclk; unsigned int master; From 39506cf83bb1b4df80dee1492f8cebc26cec355e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:12:02 +0000 Subject: [PATCH 057/942] ASoC: wm1250-ev1: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm1250-ev1.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c index cf5f0580df6a..9727eec6d01b 100644 --- a/sound/soc/codecs/wm1250-ev1.c +++ b/sound/soc/codecs/wm1250-ev1.c @@ -32,10 +32,10 @@ struct wm1250_priv { struct gpio gpios[WM1250_EV1_NUM_GPIOS]; }; -static int wm1250_ev1_set_bias_level(struct snd_soc_codec *codec, +static int wm1250_ev1_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm1250_priv *wm1250 = dev_get_drvdata(codec->dev); + struct wm1250_priv *wm1250 = dev_get_drvdata(component->dev); int ena; if (wm1250) @@ -81,7 +81,7 @@ static int wm1250_ev1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct wm1250_priv *wm1250 = snd_soc_codec_get_drvdata(dai->codec); + struct wm1250_priv *wm1250 = snd_soc_component_get_drvdata(dai->component); switch (params_rate(params)) { case 8000: @@ -141,15 +141,15 @@ static struct snd_soc_dai_driver wm1250_ev1_dai = { .ops = &wm1250_ev1_ops, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm1250_ev1 = { - .component_driver = { - .dapm_widgets = wm1250_ev1_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets), - .dapm_routes = wm1250_ev1_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes), - }, - .set_bias_level = wm1250_ev1_set_bias_level, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_wm1250_ev1 = { + .dapm_widgets = wm1250_ev1_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm1250_ev1_dapm_widgets), + .dapm_routes = wm1250_ev1_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm1250_ev1_dapm_routes), + .set_bias_level = wm1250_ev1_set_bias_level, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm1250_ev1_pdata(struct i2c_client *i2c) @@ -224,7 +224,7 @@ static int wm1250_ev1_probe(struct i2c_client *i2c, if (ret != 0) return ret; - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm1250_ev1, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_wm1250_ev1, &wm1250_ev1_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); @@ -237,7 +237,6 @@ static int wm1250_ev1_probe(struct i2c_client *i2c, static int wm1250_ev1_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); wm1250_ev1_free(i2c); return 0; From 9123ea9ff5bcdfdb89f7ad6f8efc56f2ca55a071 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:12:39 +0000 Subject: [PATCH 058/942] ASoC: ak4613: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4613.c | 73 ++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c index 3d1cf4784e87..a7b1e3a1ec58 100644 --- a/sound/soc/codecs/ak4613.c +++ b/sound/soc/codecs/ak4613.c @@ -243,9 +243,9 @@ static const struct snd_soc_dapm_route ak4613_intercon[] = { static void ak4613_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); - struct device *dev = codec->dev; + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); + struct device *dev = component->dev; mutex_lock(&priv->lock); priv->cnt--; @@ -305,8 +305,8 @@ static void ak4613_hw_constraints(struct ak4613_priv *priv, static int ak4613_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); priv->cnt++; @@ -318,8 +318,8 @@ static int ak4613_dai_startup(struct snd_pcm_substream *substream, static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); priv->sysclk = freq; @@ -328,8 +328,8 @@ static int ak4613_dai_set_sysclk(struct snd_soc_dai *codec_dai, static int ak4613_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); fmt &= SND_SOC_DAIFMT_FORMAT_MASK; @@ -366,10 +366,10 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); const struct ak4613_interface *iface; - struct device *dev = codec->dev; + struct device *dev = component->dev; unsigned int width = params_width(params); unsigned int fmt = priv->fmt; unsigned int rate; @@ -434,11 +434,11 @@ static int ak4613_dai_hw_params(struct snd_pcm_substream *substream, fmt_ctrl = AUDIO_IFACE_TO_VAL(iface); - snd_soc_update_bits(codec, CTRL1, FMT_MASK, fmt_ctrl); - snd_soc_update_bits(codec, CTRL2, DFS_MASK, ctrl2); + snd_soc_component_update_bits(component, CTRL1, FMT_MASK, fmt_ctrl); + snd_soc_component_update_bits(component, CTRL2, DFS_MASK, ctrl2); - snd_soc_update_bits(codec, ICTRL, ICTRL_MASK, priv->ic); - snd_soc_update_bits(codec, OCTRL, OCTRL_MASK, priv->oc); + snd_soc_component_update_bits(component, ICTRL, ICTRL_MASK, priv->ic); + snd_soc_component_update_bits(component, OCTRL, OCTRL_MASK, priv->oc); hw_params_end: if (ret < 0) @@ -447,7 +447,7 @@ hw_params_end: return ret; } -static int ak4613_set_bias_level(struct snd_soc_codec *codec, +static int ak4613_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { u8 mgmt1 = 0; @@ -467,7 +467,7 @@ static int ak4613_set_bias_level(struct snd_soc_codec *codec, break; } - snd_soc_write(codec, PW_MGMT1, mgmt1); + snd_soc_component_write(component, PW_MGMT1, mgmt1); return 0; } @@ -504,8 +504,8 @@ static void ak4613_dummy_write(struct work_struct *work) static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4613_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4613_priv *priv = snd_soc_component_get_drvdata(component); /* * FIXME @@ -537,7 +537,7 @@ static int ak4613_dai_trigger(struct snd_pcm_substream *substream, int cmd, if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return 0; - priv->component = &codec->component; + priv->component = component; schedule_work(&priv->dummy_write_work); return 0; @@ -582,35 +582,37 @@ static struct snd_soc_dai_driver ak4613_dai = { .symmetric_rates = 1, }; -static int ak4613_suspend(struct snd_soc_codec *codec) +static int ak4613_suspend(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, true); regcache_mark_dirty(regmap); return 0; } -static int ak4613_resume(struct snd_soc_codec *codec) +static int ak4613_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, false); return regcache_sync(regmap); } -static const struct snd_soc_codec_driver soc_codec_dev_ak4613 = { +static const struct snd_soc_component_driver soc_component_dev_ak4613 = { .suspend = ak4613_suspend, .resume = ak4613_resume, .set_bias_level = ak4613_set_bias_level, - .component_driver = { - .controls = ak4613_snd_controls, - .num_controls = ARRAY_SIZE(ak4613_snd_controls), - .dapm_widgets = ak4613_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4613_dapm_widgets), - .dapm_routes = ak4613_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4613_intercon), - }, + .controls = ak4613_snd_controls, + .num_controls = ARRAY_SIZE(ak4613_snd_controls), + .dapm_widgets = ak4613_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4613_dapm_widgets), + .dapm_routes = ak4613_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4613_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void ak4613_parse_of(struct ak4613_priv *priv, @@ -677,13 +679,12 @@ static int ak4613_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); - return snd_soc_register_codec(dev, &soc_codec_dev_ak4613, + return devm_snd_soc_register_component(dev, &soc_component_dev_ak4613, &ak4613_dai, 1); } static int ak4613_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From 43c5d0f05ec55aa71680744ffcaa1aa6fd8a9bab Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:13:07 +0000 Subject: [PATCH 059/942] ASoC: ak4642: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4642.c | 105 ++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 55 deletions(-) diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 29530c567bd9..9c35e91d412d 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -178,19 +178,19 @@ static const struct snd_kcontrol_new ak4642_lout_mixer_controls[] = { static int ak4642_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_PRE_PMU: /* Power save mode ON */ - snd_soc_update_bits(codec, SG_SL2, LOPS, LOPS); + snd_soc_component_update_bits(component, SG_SL2, LOPS, LOPS); break; case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMD: /* Power save mode OFF */ msleep(300); - snd_soc_update_bits(codec, SG_SL2, LOPS, 0); + snd_soc_component_update_bits(component, SG_SL2, LOPS, 0); break; } @@ -282,7 +282,7 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (is_play) { /* @@ -295,8 +295,8 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p97. */ - snd_soc_write(codec, L_IVC, 0x91); /* volume */ - snd_soc_write(codec, R_IVC, 0x91); /* volume */ + snd_soc_component_write(component, L_IVC, 0x91); /* volume */ + snd_soc_component_write(component, R_IVC, 0x91); /* volume */ } else { /* * start stereo input @@ -311,11 +311,11 @@ static int ak4642_dai_startup(struct snd_pcm_substream *substream, * This operation came from example code of * "ASAHI KASEI AK4642" (japanese) manual p94. */ - snd_soc_update_bits(codec, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); - snd_soc_write(codec, TIMER, ZTM(0x3) | WTM(0x3)); - snd_soc_write(codec, ALC_CTL1, ALC | LMTH0); - snd_soc_update_bits(codec, PW_MGMT1, PMADL, PMADL); - snd_soc_update_bits(codec, PW_MGMT3, PMADR, PMADR); + snd_soc_component_update_bits(component, SG_SL1, PMMP | MGAIN0, PMMP | MGAIN0); + snd_soc_component_write(component, TIMER, ZTM(0x3) | WTM(0x3)); + snd_soc_component_write(component, ALC_CTL1, ALC | LMTH0); + snd_soc_component_update_bits(component, PW_MGMT1, PMADL, PMADL); + snd_soc_component_update_bits(component, PW_MGMT3, PMADR, PMADR); } return 0; @@ -325,22 +325,22 @@ static void ak4642_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int is_play = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (is_play) { } else { /* stop stereo input */ - snd_soc_update_bits(codec, PW_MGMT1, PMADL, 0); - snd_soc_update_bits(codec, PW_MGMT3, PMADR, 0); - snd_soc_update_bits(codec, ALC_CTL1, ALC, 0); + snd_soc_component_update_bits(component, PW_MGMT1, PMADL, 0); + snd_soc_component_update_bits(component, PW_MGMT3, PMADR, 0); + snd_soc_component_update_bits(component, ALC_CTL1, ALC, 0); } } static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); u8 pll; int extended_freq = 0; @@ -382,14 +382,14 @@ static int ak4642_dai_set_sysclk(struct snd_soc_dai *codec_dai, if (extended_freq && !priv->drvdata->extended_frequencies) return -EINVAL; - snd_soc_update_bits(codec, MD_CTL1, PLL_MASK, pll); + snd_soc_component_update_bits(component, MD_CTL1, PLL_MASK, pll); return 0; } static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 data; u8 bcko; @@ -407,8 +407,8 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) default: return -EINVAL; } - snd_soc_update_bits(codec, PW_MGMT2, MS | MCKO | PMPLL, data); - snd_soc_update_bits(codec, MD_CTL1, BCKO_MASK, bcko); + snd_soc_component_update_bits(component, PW_MGMT2, MS | MCKO | PMPLL, data); + snd_soc_component_update_bits(component, MD_CTL1, BCKO_MASK, bcko); /* format type */ data = 0; @@ -425,12 +425,12 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) default: return -EINVAL; } - snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); + snd_soc_component_update_bits(component, MD_CTL1, DIF_MASK, data); return 0; } -static int ak4642_set_mcko(struct snd_soc_codec *codec, +static int ak4642_set_mcko(struct snd_soc_component *component, u32 frequency) { static const u32 fs_list[] = { @@ -458,7 +458,7 @@ static int ak4642_set_mcko(struct snd_soc_codec *codec, for (ps = 0; ps < ARRAY_SIZE(ps_list); ps++) { for (fs = 0; fs < ARRAY_SIZE(fs_list); fs++) { if (frequency == ps_list[ps] * fs_list[fs]) { - snd_soc_write(codec, MD_CTL2, + snd_soc_component_write(component, MD_CTL2, PSs(ps) | FSs(fs)); return 0; } @@ -472,25 +472,25 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); u32 rate = clk_get_rate(priv->mcko); if (!rate) rate = params_rate(params) * 256; - return ak4642_set_mcko(codec, rate); + return ak4642_set_mcko(component, rate); } -static int ak4642_set_bias_level(struct snd_soc_codec *codec, +static int ak4642_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_OFF: - snd_soc_write(codec, PW_MGMT1, 0x00); + snd_soc_component_write(component, PW_MGMT1, 0x00); break; default: - snd_soc_update_bits(codec, PW_MGMT1, PMVCM, PMVCM); + snd_soc_component_update_bits(component, PW_MGMT1, PMVCM, PMVCM); break; } @@ -523,46 +523,48 @@ static struct snd_soc_dai_driver ak4642_dai = { .symmetric_rates = 1, }; -static int ak4642_suspend(struct snd_soc_codec *codec) +static int ak4642_suspend(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, true); regcache_mark_dirty(regmap); return 0; } -static int ak4642_resume(struct snd_soc_codec *codec) +static int ak4642_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); regcache_cache_only(regmap, false); regcache_sync(regmap); return 0; } -static int ak4642_probe(struct snd_soc_codec *codec) +static int ak4642_probe(struct snd_soc_component *component) { - struct ak4642_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ak4642_priv *priv = snd_soc_component_get_drvdata(component); if (priv->mcko) - ak4642_set_mcko(codec, clk_get_rate(priv->mcko)); + ak4642_set_mcko(component, clk_get_rate(priv->mcko)); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_ak4642 = { +static const struct snd_soc_component_driver soc_component_dev_ak4642 = { .probe = ak4642_probe, .suspend = ak4642_suspend, .resume = ak4642_resume, .set_bias_level = ak4642_set_bias_level, - .component_driver = { - .controls = ak4642_snd_controls, - .num_controls = ARRAY_SIZE(ak4642_snd_controls), - .dapm_widgets = ak4642_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), - .dapm_routes = ak4642_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), - }, + .controls = ak4642_snd_controls, + .num_controls = ARRAY_SIZE(ak4642_snd_controls), + .dapm_widgets = ak4642_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4642_dapm_widgets), + .dapm_routes = ak4642_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4642_regmap = { @@ -675,14 +677,8 @@ static int ak4642_i2c_probe(struct i2c_client *i2c, if (IS_ERR(regmap)) return PTR_ERR(regmap); - return snd_soc_register_codec(dev, - &soc_codec_dev_ak4642, &ak4642_dai, 1); -} - -static int ak4642_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; + return devm_snd_soc_register_component(dev, + &soc_component_dev_ak4642, &ak4642_dai, 1); } static const struct of_device_id ak4642_of_match[] = { @@ -707,7 +703,6 @@ static struct i2c_driver ak4642_i2c_driver = { .of_match_table = ak4642_of_match, }, .probe = ak4642_i2c_probe, - .remove = ak4642_i2c_remove, .id_table = ak4642_i2c_id, }; From 12132de654bbcd16f6e4e9c0bf2947356756f773 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:13:23 +0000 Subject: [PATCH 060/942] ASoC: ak5386: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak5386.c | 62 ++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/sound/soc/codecs/ak5386.c b/sound/soc/codecs/ak5386.c index d0e16c03815c..d212960b4dda 100644 --- a/sound/soc/codecs/ak5386.c +++ b/sound/soc/codecs/ak5386.c @@ -38,30 +38,29 @@ static const struct snd_soc_dapm_route ak5386_dapm_routes[] = { { "Capture", NULL, "AINR" }, }; -static int ak5386_soc_probe(struct snd_soc_codec *codec) +static int ak5386_soc_probe(struct snd_soc_component *component) { - struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); } -static int ak5386_soc_remove(struct snd_soc_codec *codec) +static void ak5386_soc_remove(struct snd_soc_component *component) { - struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); - return 0; } #ifdef CONFIG_PM -static int ak5386_soc_suspend(struct snd_soc_codec *codec) +static int ak5386_soc_suspend(struct snd_soc_component *component) { - struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); return 0; } -static int ak5386_soc_resume(struct snd_soc_codec *codec) +static int ak5386_soc_resume(struct snd_soc_component *component) { - struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); } #else @@ -69,28 +68,30 @@ static int ak5386_soc_resume(struct snd_soc_codec *codec) #define ak5386_soc_resume NULL #endif /* CONFIG_PM */ -static const struct snd_soc_codec_driver soc_codec_ak5386 = { - .probe = ak5386_soc_probe, - .remove = ak5386_soc_remove, - .suspend = ak5386_soc_suspend, - .resume = ak5386_soc_resume, - .component_driver = { - .dapm_widgets = ak5386_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets), - .dapm_routes = ak5386_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ak5386_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_ak5386 = { + .probe = ak5386_soc_probe, + .remove = ak5386_soc_remove, + .suspend = ak5386_soc_suspend, + .resume = ak5386_soc_resume, + .dapm_widgets = ak5386_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets), + .dapm_routes = ak5386_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ak5386_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ak5386_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; format &= SND_SOC_DAIFMT_FORMAT_MASK; if (format != SND_SOC_DAIFMT_LEFT_J && format != SND_SOC_DAIFMT_I2S) { - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -101,8 +102,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); /* * From the datasheet: @@ -123,8 +124,8 @@ static int ak5386_hw_params(struct snd_pcm_substream *substream, static int ak5386_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak5386_priv *priv = snd_soc_component_get_drvdata(component); if (gpio_is_valid(priv->reset_gpio)) gpio_set_value(priv->reset_gpio, 0); @@ -192,19 +193,12 @@ static int ak5386_probe(struct platform_device *pdev) "AK5386 Reset")) priv->reset_gpio = -EINVAL; - return snd_soc_register_codec(dev, &soc_codec_ak5386, + return devm_snd_soc_register_component(dev, &soc_component_ak5386, &ak5386_dai, 1); } -static int ak5386_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver ak5386_driver = { .probe = ak5386_probe, - .remove = ak5386_remove, .driver = { .name = "ak5386", .of_match_table = of_match_ptr(ak5386_dt_ids), From 57188d8875894b14f6cdd21c7ee6e96ab66c1f2b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:13:39 +0000 Subject: [PATCH 061/942] ASoC: ak4671: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4671.c | 67 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/ak4671.c b/sound/soc/codecs/ak4671.c index dcfdff56fc5a..7133fd69c641 100644 --- a/sound/soc/codecs/ak4671.c +++ b/sound/soc/codecs/ak4671.c @@ -163,15 +163,15 @@ static const struct snd_kcontrol_new ak4671_snd_controls[] = { static int ak4671_out2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, AK4671_LOUT2_POWER_MANAGERMENT, + snd_soc_component_update_bits(component, AK4671_LOUT2_POWER_MANAGERMENT, AK4671_MUTEN, AK4671_MUTEN); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, AK4671_LOUT2_POWER_MANAGERMENT, + snd_soc_component_update_bits(component, AK4671_LOUT2_POWER_MANAGERMENT, AK4671_MUTEN, 0); break; } @@ -427,10 +427,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 fs; - fs = snd_soc_read(codec, AK4671_PLL_MODE_SELECT0); + fs = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT0); fs &= ~AK4671_FS; switch (params_rate(params)) { @@ -465,7 +465,7 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, AK4671_PLL_MODE_SELECT0, fs); + snd_soc_component_write(component, AK4671_PLL_MODE_SELECT0, fs); return 0; } @@ -473,10 +473,10 @@ static int ak4671_hw_params(struct snd_pcm_substream *substream, static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 pll; - pll = snd_soc_read(codec, AK4671_PLL_MODE_SELECT0); + pll = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT0); pll &= ~AK4671_PLL; switch (freq) { @@ -511,19 +511,19 @@ static int ak4671_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, return -EINVAL; } - snd_soc_write(codec, AK4671_PLL_MODE_SELECT0, pll); + snd_soc_component_write(component, AK4671_PLL_MODE_SELECT0, pll); return 0; } static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 mode; u8 format; /* set master/slave audio interface */ - mode = snd_soc_read(codec, AK4671_PLL_MODE_SELECT1); + mode = snd_soc_component_read32(component, AK4671_PLL_MODE_SELECT1); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -537,7 +537,7 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* interface format */ - format = snd_soc_read(codec, AK4671_FORMAT_SELECT); + format = snd_soc_component_read32(component, AK4671_FORMAT_SELECT); format &= ~AK4671_DIF; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -557,24 +557,24 @@ static int ak4671_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* set mode and format */ - snd_soc_write(codec, AK4671_PLL_MODE_SELECT1, mode); - snd_soc_write(codec, AK4671_FORMAT_SELECT, format); + snd_soc_component_write(component, AK4671_PLL_MODE_SELECT1, mode); + snd_soc_component_write(component, AK4671_FORMAT_SELECT, format); return 0; } -static int ak4671_set_bias_level(struct snd_soc_codec *codec, +static int ak4671_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, AK4671_AD_DA_POWER_MANAGEMENT, + snd_soc_component_update_bits(component, AK4671_AD_DA_POWER_MANAGEMENT, AK4671_PMVCM, AK4671_PMVCM); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); + snd_soc_component_write(component, AK4671_AD_DA_POWER_MANAGEMENT, 0x00); break; } return 0; @@ -610,16 +610,18 @@ static struct snd_soc_dai_driver ak4671_dai = { .ops = &ak4671_dai_ops, }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4671 = { - .set_bias_level = ak4671_set_bias_level, - .component_driver = { - .controls = ak4671_snd_controls, - .num_controls = ARRAY_SIZE(ak4671_snd_controls), - .dapm_widgets = ak4671_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4671_dapm_widgets), - .dapm_routes = ak4671_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4671_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4671 = { + .set_bias_level = ak4671_set_bias_level, + .controls = ak4671_snd_controls, + .num_controls = ARRAY_SIZE(ak4671_snd_controls), + .dapm_widgets = ak4671_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4671_dapm_widgets), + .dapm_routes = ak4671_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4671_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4671_regmap = { @@ -645,17 +647,11 @@ static int ak4671_i2c_probe(struct i2c_client *client, return ret; } - ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_ak4671, &ak4671_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_ak4671, &ak4671_dai, 1); return ret; } -static int ak4671_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id ak4671_i2c_id[] = { { "ak4671", 0 }, { } @@ -667,7 +663,6 @@ static struct i2c_driver ak4671_i2c_driver = { .name = "ak4671-codec", }, .probe = ak4671_i2c_probe, - .remove = ak4671_i2c_remove, .id_table = ak4671_i2c_id, }; From 61feead8d78fe103dd18dba5d9acb3a67dce2567 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:14:01 +0000 Subject: [PATCH 062/942] ASoC: ak4104: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4104.c | 68 +++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index dbb184118f2e..32bc545c19cf 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c @@ -65,8 +65,8 @@ static const struct snd_soc_dapm_route ak4104_dapm_routes[] = { static int ak4104_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4104_private *ak4104 = snd_soc_component_get_drvdata(component); int val = 0; int ret; @@ -81,7 +81,7 @@ static int ak4104_set_dai_fmt(struct snd_soc_dai *codec_dai, val |= AK4104_CONTROL1_DIF0 | AK4104_CONTROL1_DIF1; break; default: - dev_err(codec->dev, "invalid dai format\n"); + dev_err(component->dev, "invalid dai format\n"); return -EINVAL; } @@ -102,8 +102,8 @@ static int ak4104_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4104_private *ak4104 = snd_soc_component_get_drvdata(component); int ret, val = 0; /* set the IEC958 bits: consumer mode, no copyright bit */ @@ -141,7 +141,7 @@ static int ak4104_hw_params(struct snd_pcm_substream *substream, val |= IEC958_AES3_CON_FS_192000; break; default: - dev_err(codec->dev, "unsupported sampling rate\n"); + dev_err(component->dev, "unsupported sampling rate\n"); return -EINVAL; } @@ -174,14 +174,14 @@ static struct snd_soc_dai_driver ak4104_dai = { .ops = &ak4101_dai_ops, }; -static int ak4104_probe(struct snd_soc_codec *codec) +static int ak4104_probe(struct snd_soc_component *component) { - struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); + struct ak4104_private *ak4104 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_enable(ak4104->regulator); if (ret < 0) { - dev_err(codec->dev, "Unable to enable regulator: %d\n", ret); + dev_err(component->dev, "Unable to enable regulator: %d\n", ret); return ret; } @@ -205,30 +205,28 @@ exit_disable_regulator: return ret; } -static int ak4104_remove(struct snd_soc_codec *codec) +static void ak4104_remove(struct snd_soc_component *component) { - struct ak4104_private *ak4104 = snd_soc_codec_get_drvdata(codec); + struct ak4104_private *ak4104 = snd_soc_component_get_drvdata(component); regmap_update_bits(ak4104->regmap, AK4104_REG_CONTROL1, AK4104_CONTROL1_PW | AK4104_CONTROL1_RSTN, 0); regulator_disable(ak4104->regulator); - - return 0; } #ifdef CONFIG_PM -static int ak4104_soc_suspend(struct snd_soc_codec *codec) +static int ak4104_soc_suspend(struct snd_soc_component *component) { - struct ak4104_private *priv = snd_soc_codec_get_drvdata(codec); + struct ak4104_private *priv = snd_soc_component_get_drvdata(component); regulator_disable(priv->regulator); return 0; } -static int ak4104_soc_resume(struct snd_soc_codec *codec) +static int ak4104_soc_resume(struct snd_soc_component *component) { - struct ak4104_private *priv = snd_soc_codec_get_drvdata(codec); + struct ak4104_private *priv = snd_soc_component_get_drvdata(component); int ret; ret = regulator_enable(priv->regulator); @@ -242,18 +240,19 @@ static int ak4104_soc_resume(struct snd_soc_codec *codec) #define ak4104_soc_resume NULL #endif /* CONFIG_PM */ -static const struct snd_soc_codec_driver soc_codec_device_ak4104 = { - .probe = ak4104_probe, - .remove = ak4104_remove, - .suspend = ak4104_soc_suspend, - .resume = ak4104_soc_resume, - - .component_driver = { - .dapm_widgets = ak4104_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4104_dapm_widgets), - .dapm_routes = ak4104_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ak4104_dapm_routes), - } +static const struct snd_soc_component_driver soc_component_device_ak4104 = { + .probe = ak4104_probe, + .remove = ak4104_remove, + .suspend = ak4104_soc_suspend, + .resume = ak4104_soc_resume, + .dapm_widgets = ak4104_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4104_dapm_widgets), + .dapm_routes = ak4104_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ak4104_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4104_regmap = { @@ -323,17 +322,11 @@ static int ak4104_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, ak4104); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_device_ak4104, &ak4104_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_device_ak4104, &ak4104_dai, 1); return ret; } -static int ak4104_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct of_device_id ak4104_of_match[] = { { .compatible = "asahi-kasei,ak4104", }, { } @@ -353,7 +346,6 @@ static struct spi_driver ak4104_spi_driver = { }, .id_table = ak4104_id_table, .probe = ak4104_spi_probe, - .remove = ak4104_spi_remove, }; module_spi_driver(ak4104_spi_driver); From d229c0bedc6117b71419250bfebbcd83c161daa6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:14:17 +0000 Subject: [PATCH 063/942] ASoC: ak4535: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4535.c | 78 ++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/sound/soc/codecs/ak4535.c b/sound/soc/codecs/ak4535.c index e3c157dc88db..31f609910bd6 100644 --- a/sound/soc/codecs/ak4535.c +++ b/sound/soc/codecs/ak4535.c @@ -251,8 +251,8 @@ static const struct snd_soc_dapm_route ak4535_audio_map[] = { static int ak4535_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4535_priv *ak4535 = snd_soc_component_get_drvdata(component); ak4535->sysclk = freq; return 0; @@ -262,9 +262,9 @@ static int ak4535_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4535_priv *ak4535 = snd_soc_codec_get_drvdata(codec); - u8 mode2 = snd_soc_read(codec, AK4535_MODE2) & ~(0x3 << 5); + struct snd_soc_component *component = dai->component; + struct ak4535_priv *ak4535 = snd_soc_component_get_drvdata(component); + u8 mode2 = snd_soc_component_read32(component, AK4535_MODE2) & ~(0x3 << 5); int rate = params_rate(params), fs = 256; if (rate) @@ -283,14 +283,14 @@ static int ak4535_hw_params(struct snd_pcm_substream *substream, } /* set rate */ - snd_soc_write(codec, AK4535_MODE2, mode2); + snd_soc_component_write(component, AK4535_MODE2, mode2); return 0; } static int ak4535_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 mode1 = 0; /* interface format */ @@ -308,37 +308,37 @@ static int ak4535_set_dai_fmt(struct snd_soc_dai *codec_dai, /* use 32 fs for BCLK to save power */ mode1 |= 0x4; - snd_soc_write(codec, AK4535_MODE1, mode1); + snd_soc_component_write(component, AK4535_MODE1, mode1); return 0; } static int ak4535_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u16 mute_reg = snd_soc_read(codec, AK4535_DAC); + struct snd_soc_component *component = dai->component; + u16 mute_reg = snd_soc_component_read32(component, AK4535_DAC); if (!mute) - snd_soc_write(codec, AK4535_DAC, mute_reg & ~0x20); + snd_soc_component_write(component, AK4535_DAC, mute_reg & ~0x20); else - snd_soc_write(codec, AK4535_DAC, mute_reg | 0x20); + snd_soc_component_write(component, AK4535_DAC, mute_reg | 0x20); return 0; } -static int ak4535_set_bias_level(struct snd_soc_codec *codec, +static int ak4535_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, AK4535_DAC, 0x20, 0); + snd_soc_component_update_bits(component, AK4535_DAC, 0x20, 0); break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, AK4535_DAC, 0x20, 0x20); + snd_soc_component_update_bits(component, AK4535_DAC, 0x20, 0x20); break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, AK4535_PM1, 0x80, 0x80); - snd_soc_update_bits(codec, AK4535_PM2, 0x80, 0); + snd_soc_component_update_bits(component, AK4535_PM1, 0x80, 0x80); + snd_soc_component_update_bits(component, AK4535_PM2, 0x80, 0); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, AK4535_PM1, 0x80, 0); + snd_soc_component_update_bits(component, AK4535_PM1, 0x80, 0); break; } return 0; @@ -372,9 +372,9 @@ static struct snd_soc_dai_driver ak4535_dai = { .ops = &ak4535_dai_ops, }; -static int ak4535_resume(struct snd_soc_codec *codec) +static int ak4535_resume(struct snd_soc_component *component) { - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component); return 0; } @@ -390,19 +390,20 @@ static const struct regmap_config ak4535_regmap = { .num_reg_defaults = ARRAY_SIZE(ak4535_reg_defaults), }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4535 = { - .resume = ak4535_resume, - .set_bias_level = ak4535_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = ak4535_snd_controls, - .num_controls = ARRAY_SIZE(ak4535_snd_controls), - .dapm_widgets = ak4535_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4535_dapm_widgets), - .dapm_routes = ak4535_audio_map, - .num_dapm_routes = ARRAY_SIZE(ak4535_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4535 = { + .resume = ak4535_resume, + .set_bias_level = ak4535_set_bias_level, + .controls = ak4535_snd_controls, + .num_controls = ARRAY_SIZE(ak4535_snd_controls), + .dapm_widgets = ak4535_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4535_dapm_widgets), + .dapm_routes = ak4535_audio_map, + .num_dapm_routes = ARRAY_SIZE(ak4535_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ak4535_i2c_probe(struct i2c_client *i2c, @@ -425,18 +426,12 @@ static int ak4535_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, ak4535); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_ak4535, &ak4535_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_ak4535, &ak4535_dai, 1); return ret; } -static int ak4535_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id ak4535_i2c_id[] = { { "ak4535", 0 }, { } @@ -448,7 +443,6 @@ static struct i2c_driver ak4535_i2c_driver = { .name = "ak4535", }, .probe = ak4535_i2c_probe, - .remove = ak4535_i2c_remove, .id_table = ak4535_i2c_id, }; From 2b5c3e43cb0c5d9f6ab66baabb3dc08ee9f23e7b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:14:32 +0000 Subject: [PATCH 064/942] ASoC: ak4641: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4641.c | 91 ++++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/sound/soc/codecs/ak4641.c b/sound/soc/codecs/ak4641.c index 60142ff32d4f..05869beff26e 100644 --- a/sound/soc/codecs/ak4641.c +++ b/sound/soc/codecs/ak4641.c @@ -70,9 +70,9 @@ static const struct reg_default ak4641_reg_defaults[] = { static const int deemph_settings[] = {44100, 0, 48000, 32000}; -static int ak4641_set_deemph(struct snd_soc_codec *codec) +static int ak4641_set_deemph(struct snd_soc_component *component) { - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int i, best = 0; for (i = 0 ; i < ARRAY_SIZE(deemph_settings); i++) { @@ -86,16 +86,16 @@ static int ak4641_set_deemph(struct snd_soc_codec *codec) best = i; } - dev_dbg(codec->dev, "Set deemphasis %d\n", best); + dev_dbg(component->dev, "Set deemphasis %d\n", best); - return snd_soc_update_bits(codec, AK4641_DAC, 0x3, best); + return snd_soc_component_update_bits(component, AK4641_DAC, 0x3, best); } static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) @@ -103,14 +103,14 @@ static int ak4641_put_deemph(struct snd_kcontrol *kcontrol, ak4641->deemph = deemph; - return ak4641_set_deemph(codec); + return ak4641_set_deemph(component); } static int ak4641_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = ak4641->deemph; return 0; @@ -307,8 +307,8 @@ static const struct snd_soc_dapm_route ak4641_audio_map[] = { static int ak4641_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); ak4641->sysclk = freq; return 0; @@ -318,8 +318,8 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); int rate = params_rate(params), fs = 256; u8 mode2; @@ -340,16 +340,16 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, mode2 = (0x0 << 5); break; default: - dev_err(codec->dev, "Error: unsupported fs=%d\n", fs); + dev_err(component->dev, "Error: unsupported fs=%d\n", fs); return -EINVAL; } - snd_soc_update_bits(codec, AK4641_MODE2, (0x3 << 5), mode2); + snd_soc_component_update_bits(component, AK4641_MODE2, (0x3 << 5), mode2); /* Update de-emphasis filter for the new rate */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ak4641->playback_fs = rate; - ak4641_set_deemph(codec); + ak4641_set_deemph(component); } return 0; @@ -358,7 +358,7 @@ static int ak4641_i2s_hw_params(struct snd_pcm_substream *substream, static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 btif; int ret; @@ -380,7 +380,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - ret = snd_soc_update_bits(codec, AK4641_BTIF, (0x3 << 5), btif); + ret = snd_soc_component_update_bits(component, AK4641_BTIF, (0x3 << 5), btif); if (ret < 0) return ret; @@ -390,7 +390,7 @@ static int ak4641_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 mode1 = 0; /* interface format */ @@ -405,34 +405,34 @@ static int ak4641_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - return snd_soc_write(codec, AK4641_MODE1, mode1); + return snd_soc_component_write(component, AK4641_MODE1, mode1); } static int ak4641_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - return snd_soc_update_bits(codec, AK4641_DAC, 0x20, mute ? 0x20 : 0); + return snd_soc_component_update_bits(component, AK4641_DAC, 0x20, mute ? 0x20 : 0); } -static int ak4641_set_bias_level(struct snd_soc_codec *codec, +static int ak4641_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ak4641_priv *ak4641 = snd_soc_codec_get_drvdata(codec); - struct ak4641_platform_data *pdata = codec->dev->platform_data; + struct ak4641_priv *ak4641 = snd_soc_component_get_drvdata(component); + struct ak4641_platform_data *pdata = component->dev->platform_data; int ret; switch (level) { case SND_SOC_BIAS_ON: /* unmute */ - snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0); + snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0); break; case SND_SOC_BIAS_PREPARE: /* mute */ - snd_soc_update_bits(codec, AK4641_DAC, 0x20, 0x20); + snd_soc_component_update_bits(component, AK4641_DAC, 0x20, 0x20); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { if (pdata && gpio_is_valid(pdata->gpio_power)) gpio_set_value(pdata->gpio_power, 1); mdelay(1); @@ -442,16 +442,16 @@ static int ak4641_set_bias_level(struct snd_soc_codec *codec, ret = regcache_sync(ak4641->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } } - snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0x80); - snd_soc_update_bits(codec, AK4641_PM2, 0x80, 0); + snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0x80); + snd_soc_component_update_bits(component, AK4641_PM2, 0x80, 0); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, AK4641_PM1, 0x80, 0); + snd_soc_component_update_bits(component, AK4641_PM1, 0x80, 0); if (pdata && gpio_is_valid(pdata->gpio_npdn)) gpio_set_value(pdata->gpio_npdn, 0); if (pdata && gpio_is_valid(pdata->gpio_power)) @@ -524,17 +524,19 @@ static struct snd_soc_dai_driver ak4641_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4641 = { - .component_driver = { - .controls = ak4641_snd_controls, - .num_controls = ARRAY_SIZE(ak4641_snd_controls), - .dapm_widgets = ak4641_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), - .dapm_routes = ak4641_audio_map, - .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4641 = { + .controls = ak4641_snd_controls, + .num_controls = ARRAY_SIZE(ak4641_snd_controls), + .dapm_widgets = ak4641_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4641_dapm_widgets), + .dapm_routes = ak4641_audio_map, + .num_dapm_routes = ARRAY_SIZE(ak4641_audio_map), .set_bias_level = ak4641_set_bias_level, - .suspend_bias_off = true, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4641_regmap = { @@ -583,7 +585,8 @@ static int ak4641_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, ak4641); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak4641, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_ak4641, ak4641_dai, ARRAY_SIZE(ak4641_dai)); if (ret != 0) goto err_gpio2; @@ -608,8 +611,6 @@ static int ak4641_i2c_remove(struct i2c_client *i2c) { struct ak4641_platform_data *pdata = i2c->dev.platform_data; - snd_soc_unregister_codec(&i2c->dev); - if (pdata) { if (gpio_is_valid(pdata->gpio_power)) { gpio_set_value(pdata->gpio_power, 0); From 5aea27d59f764e346cb93923b0af6a94567cb95b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:14:50 +0000 Subject: [PATCH 065/942] ASoC: ak4554: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4554.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/ak4554.c b/sound/soc/codecs/ak4554.c index 0bb4fe5c122a..b7ee13406d93 100644 --- a/sound/soc/codecs/ak4554.c +++ b/sound/soc/codecs/ak4554.c @@ -64,28 +64,24 @@ static struct snd_soc_dai_driver ak4554_dai = { .symmetric_rates = 1, }; -static const struct snd_soc_codec_driver soc_codec_dev_ak4554 = { - .component_driver = { - .dapm_widgets = ak4554_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), - .dapm_routes = ak4554_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ak4554 = { + .dapm_widgets = ak4554_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4554_dapm_widgets), + .dapm_routes = ak4554_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ak4554_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ak4554_soc_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ak4554, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ak4554, &ak4554_dai, 1); } -static int ak4554_soc_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static const struct of_device_id ak4554_of_match[] = { { .compatible = "asahi-kasei,ak4554" }, {}, @@ -98,7 +94,6 @@ static struct platform_driver ak4554_driver = { .of_match_table = ak4554_of_match, }, .probe = ak4554_soc_probe, - .remove = ak4554_soc_remove, }; module_platform_driver(ak4554_driver); From f548dd4f871b827763479e15654c7f0b935e28ee Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:15:08 +0000 Subject: [PATCH 066/942] ASoC: rt274: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt274.c | 206 +++++++++++++++++++-------------------- 1 file changed, 102 insertions(+), 104 deletions(-) diff --git a/sound/soc/codecs/rt274.c b/sound/soc/codecs/rt274.c index 8f92e5c4dd9d..d88e67341083 100644 --- a/sound/soc/codecs/rt274.c +++ b/sound/soc/codecs/rt274.c @@ -38,7 +38,7 @@ struct rt274_priv { struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct i2c_client *i2c; struct snd_soc_jack *jack; struct delayed_work jack_detect_work; @@ -338,13 +338,13 @@ static bool rt274_readable_register(struct device *dev, unsigned int reg) } #ifdef CONFIG_PM -static void rt274_index_sync(struct snd_soc_codec *codec) +static void rt274_index_sync(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < INDEX_CACHE_SIZE; i++) { - snd_soc_write(codec, rt274->index_cache[i].reg, + snd_soc_component_write(component, rt274->index_cache[i].reg, rt274->index_cache[i].def); } } @@ -357,7 +357,7 @@ static int rt274_jack_detect(struct rt274_priv *rt274, bool *hp, bool *mic) *hp = false; *mic = false; - if (!rt274->codec) + if (!rt274->component) return -EINVAL; regmap_read(rt274->regmap, RT274_GET_HP_SENSE, &buf); @@ -393,10 +393,10 @@ static void rt274_jack_detect_work(struct work_struct *work) static irqreturn_t rt274_irq(int irq, void *data); -static int rt274_mic_detect(struct snd_soc_codec *codec, +static int rt274_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); if (jack == NULL) { /* Disable jack detection */ @@ -609,8 +609,8 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int d_len_code = 0, c_len_code = 0; @@ -620,7 +620,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", + dev_err(component->dev, "Unsupported sample rate %d\n", params_rate(params)); return -EINVAL; } @@ -628,7 +628,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, case 12288000: case 24576000: if (params_rate(params) != 48000) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt274->sys_clk); return -EINVAL; } @@ -636,7 +636,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, case 11289600: case 22579200: if (params_rate(params) != 44100) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt274->sys_clk); return -EINVAL; } @@ -647,7 +647,7 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, /* bit 3:0 Number of Channel */ val |= (params_channels(params) - 1); } else { - dev_err(codec->dev, "Unsupported channels %d\n", + dev_err(component->dev, "Unsupported channels %d\n", params_channels(params)); return -EINVAL; } @@ -685,29 +685,29 @@ static int rt274_hw_params(struct snd_pcm_substream *substream, if (rt274->master) c_len_code = 0x3; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, 0xc018, d_len_code << 3 | c_len_code << 14); - dev_dbg(codec->dev, "format val = 0x%x\n", val); + dev_dbg(component->dev, "format val = 0x%x\n", val); - snd_soc_update_bits(codec, RT274_DAC_FORMAT, 0x407f, val); - snd_soc_update_bits(codec, RT274_ADC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT274_DAC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT274_ADC_FORMAT, 0x407f, val); return 0; } static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_MODE_MASK, RT274_I2S_MODE_M); rt274->master = true; break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_MODE_MASK, RT274_I2S_MODE_S); rt274->master = false; break; @@ -717,27 +717,27 @@ static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_I2S); break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_LJ); break; case SND_SOC_DAIFMT_DSP_A: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_PCMA); break; case SND_SOC_DAIFMT_DSP_B: - snd_soc_update_bits(codec, RT274_I2S_CTRL1, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_I2S_FMT_MASK, RT274_I2S_FMT_PCMB); break; default: return -EINVAL; } /* bit 15 Stream Type 0:PCM 1:Non-PCM */ - snd_soc_update_bits(codec, RT274_DAC_FORMAT, 0x8000, 0); - snd_soc_update_bits(codec, RT274_ADC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT274_DAC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT274_ADC_FORMAT, 0x8000, 0); return 0; } @@ -745,47 +745,47 @@ static int rt274_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt274_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); switch (source) { case RT274_PLL2_S_MCLK: - snd_soc_update_bits(codec, RT274_PLL2_CTRL, + snd_soc_component_update_bits(component, RT274_PLL2_CTRL, RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_MCLK); break; default: - dev_warn(codec->dev, "invalid pll source, use BCLK\n"); + dev_warn(component->dev, "invalid pll source, use BCLK\n"); case RT274_PLL2_S_BCLK: - snd_soc_update_bits(codec, RT274_PLL2_CTRL, + snd_soc_component_update_bits(component, RT274_PLL2_CTRL, RT274_PLL2_SRC_MASK, RT274_PLL2_SRC_BCLK); break; } if (source == RT274_PLL2_S_BCLK) { - snd_soc_update_bits(codec, RT274_MCLK_CTRL, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, (0x3 << 12), (0x3 << 12)); switch (rt274->fs) { case 50: - snd_soc_write(codec, 0x7a, 0xaab6); - snd_soc_write(codec, 0x7b, 0x0301); - snd_soc_write(codec, 0x7c, 0x04fe); + snd_soc_component_write(component, 0x7a, 0xaab6); + snd_soc_component_write(component, 0x7b, 0x0301); + snd_soc_component_write(component, 0x7c, 0x04fe); break; case 64: - snd_soc_write(codec, 0x7a, 0xaa96); - snd_soc_write(codec, 0x7b, 0x8003); - snd_soc_write(codec, 0x7c, 0x081e); + snd_soc_component_write(component, 0x7a, 0xaa96); + snd_soc_component_write(component, 0x7b, 0x8003); + snd_soc_component_write(component, 0x7c, 0x081e); break; case 128: - snd_soc_write(codec, 0x7a, 0xaa96); - snd_soc_write(codec, 0x7b, 0x8003); - snd_soc_write(codec, 0x7c, 0x080e); + snd_soc_component_write(component, 0x7a, 0xaa96); + snd_soc_component_write(component, 0x7b, 0x8003); + snd_soc_component_write(component, 0x7c, 0x080e); break; default: - dev_warn(codec->dev, "invalid freq_in, assume 4.8M\n"); + dev_warn(component->dev, "invalid freq_in, assume 4.8M\n"); case 100: - snd_soc_write(codec, 0x7a, 0xaab6); - snd_soc_write(codec, 0x7b, 0x0301); - snd_soc_write(codec, 0x7c, 0x047e); + snd_soc_component_write(component, 0x7a, 0xaab6); + snd_soc_component_write(component, 0x7b, 0x0301); + snd_soc_component_write(component, 0x7c, 0x047e); break; } } @@ -796,11 +796,11 @@ static int rt274_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); unsigned int clk_src, mclk_en; - dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); switch (clk_id) { case RT274_SCLK_S_MCLK: @@ -818,43 +818,43 @@ static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, default: mclk_en = RT274_MCLK_MODE_DIS; clk_src = RT274_CLK_SRC_MCLK; - dev_warn(codec->dev, "invalid sysclk source, use PLL1\n"); + dev_warn(component->dev, "invalid sysclk source, use PLL1\n"); break; } - snd_soc_update_bits(codec, RT274_MCLK_CTRL, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, RT274_MCLK_MODE_MASK, mclk_en); - snd_soc_update_bits(codec, RT274_CLK_CTRL, + snd_soc_component_update_bits(component, RT274_CLK_CTRL, RT274_CLK_SRC_MASK, clk_src); switch (freq) { case 19200000: if (clk_id == RT274_SCLK_S_MCLK) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL2, 0x40, 0x40); break; case 24000000: if (clk_id == RT274_SCLK_S_MCLK) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL2, 0x40, 0x0); break; case 12288000: case 11289600: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, 0x1fcf, 0x0008); break; case 24576000: case 22579200: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_MCLK_CTRL, 0x1fcf, 0x1543); break; default: - dev_err(codec->dev, "Unsupported system clock\n"); + dev_err(component->dev, "Unsupported system clock\n"); return -EINVAL; } @@ -866,16 +866,16 @@ static int rt274_set_dai_sysclk(struct snd_soc_dai *dai, static int rt274_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); rt274->fs = ratio; if ((ratio / 50) == 0) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, 0x1000, 0x1000); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, 0x1000, 0x0); @@ -886,28 +886,28 @@ static int rt274_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (rx_mask || tx_mask) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_EN, RT274_TDM_EN); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_EN, RT274_TDM_DIS); return 0; } switch (slots) { case 4: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_CH_NUM, RT274_TDM_4CH); break; case 2: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT274_I2S_CTRL1, RT274_TDM_CH_NUM, RT274_TDM_2CH); break; default: - dev_err(codec->dev, + dev_err(component->dev, "Support 2 or 4 slots TDM only\n"); return -EINVAL; } @@ -915,20 +915,20 @@ static int rt274_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return 0; } -static int rt274_set_bias_level(struct snd_soc_codec *codec, +static int rt274_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == - snd_soc_codec_get_bias_level(codec)) { - snd_soc_write(codec, + snd_soc_component_get_bias_level(component)) { + snd_soc_component_write(component, RT274_SET_AUDIO_POWER, AC_PWRST_D0); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, + snd_soc_component_write(component, RT274_SET_AUDIO_POWER, AC_PWRST_D3); break; @@ -968,11 +968,11 @@ static irqreturn_t rt274_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt274_probe(struct snd_soc_codec *codec) +static int rt274_probe(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); - rt274->codec = codec; + rt274->component = component; if (rt274->i2c->irq) { INIT_DELAYED_WORK(&rt274->jack_detect_work, @@ -984,19 +984,17 @@ static int rt274_probe(struct snd_soc_codec *codec) return 0; } -static int rt274_remove(struct snd_soc_codec *codec) +static void rt274_remove(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&rt274->jack_detect_work); - - return 0; } #ifdef CONFIG_PM -static int rt274_suspend(struct snd_soc_codec *codec) +static int rt274_suspend(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt274->regmap, true); regcache_mark_dirty(rt274->regmap); @@ -1004,12 +1002,12 @@ static int rt274_suspend(struct snd_soc_codec *codec) return 0; } -static int rt274_resume(struct snd_soc_codec *codec) +static int rt274_resume(struct snd_soc_component *component) { - struct rt274_priv *rt274 = snd_soc_codec_get_drvdata(codec); + struct rt274_priv *rt274 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt274->regmap, false); - rt274_index_sync(codec); + rt274_index_sync(component); regcache_sync(rt274->regmap); return 0; @@ -1055,22 +1053,22 @@ static struct snd_soc_dai_driver rt274_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt274 = { - .probe = rt274_probe, - .remove = rt274_remove, - .suspend = rt274_suspend, - .resume = rt274_resume, - .set_bias_level = rt274_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt274_snd_controls, - .num_controls = ARRAY_SIZE(rt274_snd_controls), - .dapm_widgets = rt274_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt274_dapm_widgets), - .dapm_routes = rt274_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt274_dapm_routes), - }, - .set_jack = rt274_mic_detect, +static const struct snd_soc_component_driver soc_component_dev_rt274 = { + .probe = rt274_probe, + .remove = rt274_remove, + .suspend = rt274_suspend, + .resume = rt274_resume, + .set_bias_level = rt274_set_bias_level, + .set_jack = rt274_mic_detect, + .controls = rt274_snd_controls, + .num_controls = ARRAY_SIZE(rt274_snd_controls), + .dapm_widgets = rt274_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt274_dapm_widgets), + .dapm_routes = rt274_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt274_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt274_regmap = { @@ -1191,7 +1189,8 @@ static int rt274_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt274, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt274, rt274_dai, ARRAY_SIZE(rt274_dai)); return ret; @@ -1203,7 +1202,6 @@ static int rt274_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt274); - snd_soc_unregister_codec(&i2c->dev); return 0; } From 01f8902fe45173c516da1f5e13e9792e8cbb8230 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:42:18 +0000 Subject: [PATCH 067/942] ASoC: rt5616: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5616.c | 219 +++++++++++++++++++------------------- 1 file changed, 109 insertions(+), 110 deletions(-) diff --git a/sound/soc/codecs/rt5616.c b/sound/soc/codecs/rt5616.c index 0e5f54a9bc7e..3dc795f444ce 100644 --- a/sound/soc/codecs/rt5616.c +++ b/sound/soc/codecs/rt5616.c @@ -142,7 +142,7 @@ static const struct reg_default rt5616_reg[] = { }; struct rt5616_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct delayed_work patch_work; struct regmap *regmap; struct clk *mclk; @@ -351,7 +351,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, { unsigned int val; - val = snd_soc_read(snd_soc_dapm_to_codec(source->dapm), RT5616_GLB_CLK); + val = snd_soc_component_read32(snd_soc_dapm_to_component(source->dapm), RT5616_GLB_CLK); val &= RT5616_SCLK_SRC_MASK; if (val == RT5616_SCLK_SRC_PLL1) return 1; @@ -466,16 +466,16 @@ static const struct snd_kcontrol_new rt5616_lout_mix[] = { static int rt5616_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL, + snd_soc_component_update_bits(component, RT5616_ADC_DIG_VOL, RT5616_L_MUTE | RT5616_R_MUTE, 0); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, RT5616_ADC_DIG_VOL, + snd_soc_component_update_bits(component, RT5616_ADC_DIG_VOL, RT5616_L_MUTE | RT5616_R_MUTE, RT5616_L_MUTE | RT5616_R_MUTE); break; @@ -490,51 +490,51 @@ static int rt5616_adc_event(struct snd_soc_dapm_widget *w, static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: /* depop parameters */ - snd_soc_update_bits(codec, RT5616_DEPOP_M2, + snd_soc_component_update_bits(component, RT5616_DEPOP_M2, RT5616_DEPOP_MASK, RT5616_DEPOP_MAN); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_HP_CP_MASK | RT5616_HP_SG_MASK | RT5616_HP_CB_MASK, RT5616_HP_CP_PU | RT5616_HP_SG_DIS | RT5616_HP_CB_PU); - snd_soc_write(codec, RT5616_PR_BASE + + snd_soc_component_write(component, RT5616_PR_BASE + RT5616_HP_DCC_INT1, 0x9f00); /* headphone amp power on */ - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_FV1 | RT5616_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5616_PWR_VOL, + snd_soc_component_update_bits(component, RT5616_PWR_VOL, RT5616_PWR_HV_L | RT5616_PWR_HV_R, RT5616_PWR_HV_L | RT5616_PWR_HV_R); - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_HP_L | RT5616_PWR_HP_R | RT5616_PWR_HA, RT5616_PWR_HP_L | RT5616_PWR_HP_R | RT5616_PWR_HA); msleep(50); - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_FV1 | RT5616_PWR_FV2, RT5616_PWR_FV1 | RT5616_PWR_FV2); - snd_soc_update_bits(codec, RT5616_CHARGE_PUMP, + snd_soc_component_update_bits(component, RT5616_CHARGE_PUMP, RT5616_PM_HP_MASK, RT5616_PM_HP_HV); - snd_soc_update_bits(codec, RT5616_PR_BASE + + snd_soc_component_update_bits(component, RT5616_PR_BASE + RT5616_CHOP_DAC_ADC, 0x0200, 0x0200); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_HP_CO_MASK | RT5616_HP_SG_MASK, RT5616_HP_CO_EN | RT5616_HP_SG_EN); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5616_PR_BASE + + snd_soc_component_update_bits(component, RT5616_PR_BASE + RT5616_CHOP_DAC_ADC, 0x0200, 0x0); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK | RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS | RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS); /* headphone amp power down */ - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_SMT_TRIG_MASK | RT5616_HP_CD_PD_MASK | RT5616_HP_CO_MASK | RT5616_HP_CP_MASK | RT5616_HP_SG_MASK | @@ -542,7 +542,7 @@ static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w, RT5616_SMT_TRIG_DIS | RT5616_HP_CD_PD_EN | RT5616_HP_CO_DIS | RT5616_HP_CP_PD | RT5616_HP_SG_EN | RT5616_HP_CB_PD); - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_HP_L | RT5616_PWR_HP_R | RT5616_PWR_HA, 0); break; @@ -556,61 +556,61 @@ static int rt5616_charge_pump_event(struct snd_soc_dapm_widget *w, static int rt5616_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: /* headphone unmute sequence */ - snd_soc_update_bits(codec, RT5616_DEPOP_M3, + snd_soc_component_update_bits(component, RT5616_DEPOP_M3, RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK | RT5616_CP_FQ3_MASK, RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ1_SFT | RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT | RT5616_CP_FQ_192_KHZ << RT5616_CP_FQ3_SFT); - snd_soc_write(codec, RT5616_PR_BASE + + snd_soc_component_write(component, RT5616_PR_BASE + RT5616_MAMP_INT_REG2, 0xfc00); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_SMT_TRIG_MASK, RT5616_SMT_TRIG_EN); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_RSTN_MASK, RT5616_RSTN_EN); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_RSTN_MASK | RT5616_HP_L_SMT_MASK | RT5616_HP_R_SMT_MASK, RT5616_RSTN_DIS | RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN); - snd_soc_update_bits(codec, RT5616_HP_VOL, + snd_soc_component_update_bits(component, RT5616_HP_VOL, RT5616_L_MUTE | RT5616_R_MUTE, 0); msleep(100); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_HP_SG_MASK | RT5616_HP_L_SMT_MASK | RT5616_HP_R_SMT_MASK, RT5616_HP_SG_DIS | RT5616_HP_L_SMT_DIS | RT5616_HP_R_SMT_DIS); msleep(20); - snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET, + snd_soc_component_update_bits(component, RT5616_HP_CALIB_AMP_DET, RT5616_HPD_PS_MASK, RT5616_HPD_PS_EN); break; case SND_SOC_DAPM_PRE_PMD: /* headphone mute sequence */ - snd_soc_update_bits(codec, RT5616_DEPOP_M3, + snd_soc_component_update_bits(component, RT5616_DEPOP_M3, RT5616_CP_FQ1_MASK | RT5616_CP_FQ2_MASK | RT5616_CP_FQ3_MASK, RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ1_SFT | RT5616_CP_FQ_12_KHZ << RT5616_CP_FQ2_SFT | RT5616_CP_FQ_96_KHZ << RT5616_CP_FQ3_SFT); - snd_soc_write(codec, RT5616_PR_BASE + + snd_soc_component_write(component, RT5616_PR_BASE + RT5616_MAMP_INT_REG2, 0xfc00); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_HP_SG_MASK, RT5616_HP_SG_EN); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_RSTP_MASK, RT5616_RSTP_EN); - snd_soc_update_bits(codec, RT5616_DEPOP_M1, + snd_soc_component_update_bits(component, RT5616_DEPOP_M1, RT5616_RSTP_MASK | RT5616_HP_L_SMT_MASK | RT5616_HP_R_SMT_MASK, RT5616_RSTP_DIS | RT5616_HP_L_SMT_EN | RT5616_HP_R_SMT_EN); - snd_soc_update_bits(codec, RT5616_HP_CALIB_AMP_DET, + snd_soc_component_update_bits(component, RT5616_HP_CALIB_AMP_DET, RT5616_HPD_PS_MASK, RT5616_HPD_PS_DIS); msleep(90); - snd_soc_update_bits(codec, RT5616_HP_VOL, + snd_soc_component_update_bits(component, RT5616_HP_VOL, RT5616_L_MUTE | RT5616_R_MUTE, RT5616_L_MUTE | RT5616_R_MUTE); msleep(30); @@ -626,21 +626,21 @@ static int rt5616_hp_event(struct snd_soc_dapm_widget *w, static int rt5616_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_LM, RT5616_PWR_LM); - snd_soc_update_bits(codec, RT5616_LOUT_CTRL1, + snd_soc_component_update_bits(component, RT5616_LOUT_CTRL1, RT5616_L_MUTE | RT5616_R_MUTE, 0); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5616_LOUT_CTRL1, + snd_soc_component_update_bits(component, RT5616_LOUT_CTRL1, RT5616_L_MUTE | RT5616_R_MUTE, RT5616_L_MUTE | RT5616_R_MUTE); - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_LM, 0); break; @@ -654,16 +654,16 @@ static int rt5616_lout_event(struct snd_soc_dapm_widget *w, static int rt5616_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5616_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG2, RT5616_PWR_BST1_OP2, RT5616_PWR_BST1_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5616_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG2, RT5616_PWR_BST1_OP2, 0); break; @@ -677,16 +677,16 @@ static int rt5616_bst1_event(struct snd_soc_dapm_widget *w, static int rt5616_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5616_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG2, RT5616_PWR_BST2_OP2, RT5616_PWR_BST2_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5616_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG2, RT5616_PWR_BST2_OP2, 0); break; @@ -960,8 +960,8 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; @@ -970,12 +970,12 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream, pre_div = rl6231_get_clk_info(rt5616->sysclk, rt5616->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting\n"); + dev_err(component->dev, "Unsupported clock setting\n"); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } bclk_ms = frame_size > 32 ? 1 : 0; @@ -1004,17 +1004,17 @@ static int rt5616_hw_params(struct snd_pcm_substream *substream, mask_clk = RT5616_I2S_PD1_MASK; val_clk = pre_div << RT5616_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5616_I2S1_SDP, + snd_soc_component_update_bits(component, RT5616_I2S1_SDP, RT5616_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5616_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5616_ADDA_CLK1, mask_clk, val_clk); return 0; } static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1055,7 +1055,7 @@ static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, RT5616_I2S1_SDP, + snd_soc_component_update_bits(component, RT5616_I2S1_SDP, RT5616_I2S_MS_MASK | RT5616_I2S_BP_MASK | RT5616_I2S_DF_MASK, reg_val); @@ -1065,8 +1065,8 @@ static int rt5616_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5616->sysclk && clk_id == rt5616->sysclk_src) @@ -1080,11 +1080,11 @@ static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai, reg_val |= RT5616_SCLK_SRC_PLL1; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5616_GLB_CLK, + snd_soc_component_update_bits(component, RT5616_GLB_CLK, RT5616_SCLK_SRC_MASK, reg_val); rt5616->sysclk = freq; rt5616->sysclk_src = clk_id; @@ -1097,8 +1097,8 @@ static int rt5616_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -1107,11 +1107,11 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5616->pll_in = 0; rt5616->pll_out = 0; - snd_soc_update_bits(codec, RT5616_GLB_CLK, + snd_soc_component_update_bits(component, RT5616_GLB_CLK, RT5616_SCLK_SRC_MASK, RT5616_SCLK_SRC_MCLK); return 0; @@ -1119,34 +1119,34 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, switch (source) { case RT5616_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5616_GLB_CLK, + snd_soc_component_update_bits(component, RT5616_GLB_CLK, RT5616_PLL1_SRC_MASK, RT5616_PLL1_SRC_MCLK); break; case RT5616_PLL1_S_BCLK1: case RT5616_PLL1_S_BCLK2: - snd_soc_update_bits(codec, RT5616_GLB_CLK, + snd_soc_component_update_bits(component, RT5616_GLB_CLK, RT5616_PLL1_SRC_MASK, RT5616_PLL1_SRC_BCLK1); break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5616_PLL_CTRL1, + snd_soc_component_write(component, RT5616_PLL_CTRL1, pll_code.n_code << RT5616_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5616_PLL_CTRL2, + snd_soc_component_write(component, RT5616_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5616_PLL_M_SFT | pll_code.m_bp << RT5616_PLL_M_BP_SFT); @@ -1158,10 +1158,10 @@ static int rt5616_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; } -static int rt5616_set_bias_level(struct snd_soc_codec *codec, +static int rt5616_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1180,7 +1180,7 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec, if (IS_ERR(rt5616->mclk)) break; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5616->mclk); } else { ret = clk_prepare_enable(rt5616->mclk); @@ -1190,30 +1190,30 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_VREF1 | RT5616_PWR_MB | RT5616_PWR_BG | RT5616_PWR_VREF2, RT5616_PWR_VREF1 | RT5616_PWR_MB | RT5616_PWR_BG | RT5616_PWR_VREF2); mdelay(10); - snd_soc_update_bits(codec, RT5616_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5616_PWR_ANLG1, RT5616_PWR_FV1 | RT5616_PWR_FV2, RT5616_PWR_FV1 | RT5616_PWR_FV2); - snd_soc_update_bits(codec, RT5616_D_MISC, + snd_soc_component_update_bits(component, RT5616_D_MISC, RT5616_D_GATE_EN, RT5616_D_GATE_EN); } break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, RT5616_D_MISC, RT5616_D_GATE_EN, 0); - snd_soc_write(codec, RT5616_PWR_DIG1, 0x0000); - snd_soc_write(codec, RT5616_PWR_DIG2, 0x0000); - snd_soc_write(codec, RT5616_PWR_VOL, 0x0000); - snd_soc_write(codec, RT5616_PWR_MIXER, 0x0000); - snd_soc_write(codec, RT5616_PWR_ANLG1, 0x0000); - snd_soc_write(codec, RT5616_PWR_ANLG2, 0x0000); + snd_soc_component_update_bits(component, RT5616_D_MISC, RT5616_D_GATE_EN, 0); + snd_soc_component_write(component, RT5616_PWR_DIG1, 0x0000); + snd_soc_component_write(component, RT5616_PWR_DIG2, 0x0000); + snd_soc_component_write(component, RT5616_PWR_VOL, 0x0000); + snd_soc_component_write(component, RT5616_PWR_MIXER, 0x0000); + snd_soc_component_write(component, RT5616_PWR_ANLG1, 0x0000); + snd_soc_component_write(component, RT5616_PWR_ANLG2, 0x0000); break; default: @@ -1223,24 +1223,24 @@ static int rt5616_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5616_probe(struct snd_soc_codec *codec) +static int rt5616_probe(struct snd_soc_component *component) { - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); /* Check if MCLK provided */ - rt5616->mclk = devm_clk_get(codec->dev, "mclk"); + rt5616->mclk = devm_clk_get(component->dev, "mclk"); if (PTR_ERR(rt5616->mclk) == -EPROBE_DEFER) return -EPROBE_DEFER; - rt5616->codec = codec; + rt5616->component = component; return 0; } #ifdef CONFIG_PM -static int rt5616_suspend(struct snd_soc_codec *codec) +static int rt5616_suspend(struct snd_soc_component *component) { - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5616->regmap, true); regcache_mark_dirty(rt5616->regmap); @@ -1248,9 +1248,9 @@ static int rt5616_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5616_resume(struct snd_soc_codec *codec) +static int rt5616_resume(struct snd_soc_component *component) { - struct rt5616_priv *rt5616 = snd_soc_codec_get_drvdata(codec); + struct rt5616_priv *rt5616 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5616->regmap, false); regcache_sync(rt5616->regmap); @@ -1294,20 +1294,20 @@ static struct snd_soc_dai_driver rt5616_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5616 = { - .probe = rt5616_probe, - .suspend = rt5616_suspend, - .resume = rt5616_resume, - .set_bias_level = rt5616_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5616_snd_controls, - .num_controls = ARRAY_SIZE(rt5616_snd_controls), - .dapm_widgets = rt5616_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5616_dapm_widgets), - .dapm_routes = rt5616_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5616_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5616 = { + .probe = rt5616_probe, + .suspend = rt5616_suspend, + .resume = rt5616_resume, + .set_bias_level = rt5616_set_bias_level, + .controls = rt5616_snd_controls, + .num_controls = ARRAY_SIZE(rt5616_snd_controls), + .dapm_widgets = rt5616_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5616_dapm_widgets), + .dapm_routes = rt5616_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5616_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5616_regmap = { @@ -1387,14 +1387,13 @@ static int rt5616_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5616->regmap, RT5616_PWR_ANLG1, RT5616_PWR_LDO_DVO_MASK, RT5616_PWR_LDO_DVO_1_2V); - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5616, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5616, rt5616_dai, ARRAY_SIZE(rt5616_dai)); } static int rt5616_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); - return 0; } From d5a41b5d5f883b659e2f5bac13867e0b75837e70 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:42:46 +0000 Subject: [PATCH 068/942] ASoC: rt5640: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5640.c | 260 +++++++++++++------------- sound/soc/codecs/rt5640.h | 6 +- sound/soc/intel/boards/byt-rt5640.c | 4 +- sound/soc/intel/boards/bytcr_rt5640.c | 8 +- 4 files changed, 135 insertions(+), 143 deletions(-) diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index 438fe52a12df..05567426f211 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c @@ -166,9 +166,9 @@ static const struct reg_default rt5640_reg[] = { { 0xff, 0x6231 }, }; -static int rt5640_reset(struct snd_soc_codec *codec) +static int rt5640_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, RT5640_RESET, 0); + return snd_soc_component_write(component, RT5640_RESET, 0); } static bool rt5640_volatile_register(struct device *dev, unsigned int reg) @@ -461,17 +461,17 @@ static const struct snd_kcontrol_new rt5640_specific_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5640->sysclk / rl6231_get_pre_div(rt5640->regmap, RT5640_ADDA_CLK1, RT5640_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else - snd_soc_update_bits(codec, RT5640_DMIC, RT5640_DMIC_CLK_MASK, + snd_soc_component_update_bits(component, RT5640_DMIC, RT5640_DMIC_CLK_MASK, idx << RT5640_DMIC_CLK_SFT); return idx; } @@ -479,10 +479,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int val; - val = snd_soc_read(codec, RT5640_GLB_CLK); + val = snd_soc_component_read32(component, RT5640_GLB_CLK); val &= RT5640_SCLK_SRC_MASK; if (val == RT5640_SCLK_SRC_PLL1) return 1; @@ -493,8 +493,8 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); if (!rt5640->asrc_en) return 0; @@ -930,9 +930,9 @@ static SOC_ENUM_SINGLE_DECL(rt5640_sdi_sel_enum, RT5640_I2S2_SDP, static const struct snd_kcontrol_new rt5640_sdi_mux = SOC_DAPM_ENUM("SDI select", rt5640_sdi_sel_enum); -static void hp_amp_power_on(struct snd_soc_codec *codec) +static void hp_amp_power_on(struct snd_soc_component *component) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); /* depop parameters */ regmap_update_bits(rt5640->regmap, RT5640_PR_BASE + @@ -956,9 +956,9 @@ static void hp_amp_power_on(struct snd_soc_codec *codec) RT5640_PWR_FV1 | RT5640_PWR_FV2); } -static void rt5640_pmu_depop(struct snd_soc_codec *codec) +static void rt5640_pmu_depop(struct snd_soc_component *component) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); regmap_update_bits(rt5640->regmap, RT5640_DEPOP_M2, RT5640_DEPOP_MASK | RT5640_DIG_DP_MASK, @@ -984,12 +984,12 @@ static void rt5640_pmu_depop(struct snd_soc_codec *codec) static int rt5640_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: - rt5640_pmu_depop(codec); + rt5640_pmu_depop(component); rt5640->hp_mute = 0; break; @@ -1008,22 +1008,22 @@ static int rt5640_hp_event(struct snd_soc_dapm_widget *w, static int rt5640_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power_on(codec); - snd_soc_update_bits(codec, RT5640_PWR_ANLG1, + hp_amp_power_on(component); + snd_soc_component_update_bits(component, RT5640_PWR_ANLG1, RT5640_PWR_LM, RT5640_PWR_LM); - snd_soc_update_bits(codec, RT5640_OUTPUT, + snd_soc_component_update_bits(component, RT5640_OUTPUT, RT5640_L_MUTE | RT5640_R_MUTE, 0); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5640_OUTPUT, + snd_soc_component_update_bits(component, RT5640_OUTPUT, RT5640_L_MUTE | RT5640_R_MUTE, RT5640_L_MUTE | RT5640_R_MUTE); - snd_soc_update_bits(codec, RT5640_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5640_PWR_ANLG1, RT5640_PWR_LM, 0); break; @@ -1037,11 +1037,11 @@ static int rt5640_lout_event(struct snd_soc_dapm_widget *w, static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power_on(codec); + hp_amp_power_on(component); break; default: return 0; @@ -1053,8 +1053,8 @@ static int rt5640_hp_power_event(struct snd_soc_dapm_widget *w, static int rt5640_hp_post_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1671,14 +1671,14 @@ static const struct snd_soc_dapm_route rt5639_specific_dapm_routes[] = { {"IF2 DAC R", NULL, "DAC R2 Power"}, }; -static int get_sdp_info(struct snd_soc_codec *codec, int dai_id) +static int get_sdp_info(struct snd_soc_component *component, int dai_id) { int ret = 0, val; - if (codec == NULL) + if (component == NULL) return -EINVAL; - val = snd_soc_read(codec, RT5640_I2S1_SDP); + val = snd_soc_component_read32(component, RT5640_I2S1_SDP); val = (val & RT5640_I2S_IF_MASK) >> RT5640_I2S_IF_SFT; switch (dai_id) { case RT5640_AIF1: @@ -1722,21 +1722,21 @@ static int get_sdp_info(struct snd_soc_codec *codec, int dai_id) static int rt5640_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int dai_sel, pre_div, bclk_ms, frame_size; rt5640->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5640->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return frame_size; } if (frame_size > 32) @@ -1766,26 +1766,26 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - dai_sel = get_sdp_info(codec, dai->id); + dai_sel = get_sdp_info(component, dai->id); if (dai_sel < 0) { - dev_err(codec->dev, "Failed to get sdp info: %d\n", dai_sel); + dev_err(component->dev, "Failed to get sdp info: %d\n", dai_sel); return -EINVAL; } if (dai_sel & RT5640_U_IF1) { mask_clk = RT5640_I2S_BCLK_MS1_MASK | RT5640_I2S_PD1_MASK; val_clk = bclk_ms << RT5640_I2S_BCLK_MS1_SFT | pre_div << RT5640_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5640_I2S1_SDP, + snd_soc_component_update_bits(component, RT5640_I2S1_SDP, RT5640_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5640_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5640_ADDA_CLK1, mask_clk, val_clk); } if (dai_sel & RT5640_U_IF2) { mask_clk = RT5640_I2S_BCLK_MS2_MASK | RT5640_I2S_PD2_MASK; val_clk = bclk_ms << RT5640_I2S_BCLK_MS2_SFT | pre_div << RT5640_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5640_I2S2_SDP, + snd_soc_component_update_bits(component, RT5640_I2S2_SDP, RT5640_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5640_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5640_ADDA_CLK1, mask_clk, val_clk); } return 0; @@ -1793,8 +1793,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; int dai_sel; @@ -1836,18 +1836,18 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - dai_sel = get_sdp_info(codec, dai->id); + dai_sel = get_sdp_info(component, dai->id); if (dai_sel < 0) { - dev_err(codec->dev, "Failed to get sdp info: %d\n", dai_sel); + dev_err(component->dev, "Failed to get sdp info: %d\n", dai_sel); return -EINVAL; } if (dai_sel & RT5640_U_IF1) { - snd_soc_update_bits(codec, RT5640_I2S1_SDP, + snd_soc_component_update_bits(component, RT5640_I2S1_SDP, RT5640_I2S_MS_MASK | RT5640_I2S_BP_MASK | RT5640_I2S_DF_MASK, reg_val); } if (dai_sel & RT5640_U_IF2) { - snd_soc_update_bits(codec, RT5640_I2S2_SDP, + snd_soc_component_update_bits(component, RT5640_I2S2_SDP, RT5640_I2S_MS_MASK | RT5640_I2S_BP_MASK | RT5640_I2S_DF_MASK, reg_val); } @@ -1858,8 +1858,8 @@ static int rt5640_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5640->sysclk && clk_id == rt5640->sysclk_src) @@ -1876,10 +1876,10 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai, reg_val |= RT5640_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5640_GLB_CLK, + snd_soc_component_update_bits(component, RT5640_GLB_CLK, RT5640_SCLK_SRC_MASK, reg_val); rt5640->sysclk = freq; rt5640->sysclk_src = clk_id; @@ -1891,8 +1891,8 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -1901,46 +1901,46 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5640->pll_in = 0; rt5640->pll_out = 0; - snd_soc_update_bits(codec, RT5640_GLB_CLK, + snd_soc_component_update_bits(component, RT5640_GLB_CLK, RT5640_SCLK_SRC_MASK, RT5640_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5640_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5640_GLB_CLK, + snd_soc_component_update_bits(component, RT5640_GLB_CLK, RT5640_PLL1_SRC_MASK, RT5640_PLL1_SRC_MCLK); break; case RT5640_PLL1_S_BCLK1: - snd_soc_update_bits(codec, RT5640_GLB_CLK, + snd_soc_component_update_bits(component, RT5640_GLB_CLK, RT5640_PLL1_SRC_MASK, RT5640_PLL1_SRC_BCLK1); break; case RT5640_PLL1_S_BCLK2: - snd_soc_update_bits(codec, RT5640_GLB_CLK, + snd_soc_component_update_bits(component, RT5640_GLB_CLK, RT5640_PLL1_SRC_MASK, RT5640_PLL1_SRC_BCLK2); break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5640_PLL_CTRL1, + snd_soc_component_write(component, RT5640_PLL_CTRL1, pll_code.n_code << RT5640_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5640_PLL_CTRL2, + snd_soc_component_write(component, RT5640_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5640_PLL_M_SFT | pll_code.m_bp << RT5640_PLL_M_BP_SFT); @@ -1951,10 +1951,10 @@ static int rt5640_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; } -static int rt5640_set_bias_level(struct snd_soc_codec *codec, +static int rt5640_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1972,7 +1972,7 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec, if (IS_ERR(rt5640->mclk)) break; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5640->mclk); } else { ret = clk_prepare_enable(rt5640->mclk); @@ -1982,33 +1982,33 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (SND_SOC_BIAS_OFF == snd_soc_codec_get_bias_level(codec)) { - snd_soc_update_bits(codec, RT5640_PWR_ANLG1, + if (SND_SOC_BIAS_OFF == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5640_PWR_ANLG1, RT5640_PWR_VREF1 | RT5640_PWR_MB | RT5640_PWR_BG | RT5640_PWR_VREF2, RT5640_PWR_VREF1 | RT5640_PWR_MB | RT5640_PWR_BG | RT5640_PWR_VREF2); usleep_range(10000, 15000); - snd_soc_update_bits(codec, RT5640_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5640_PWR_ANLG1, RT5640_PWR_FV1 | RT5640_PWR_FV2, RT5640_PWR_FV1 | RT5640_PWR_FV2); - snd_soc_update_bits(codec, RT5640_DUMMY1, + snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x0301, 0x0301); - snd_soc_update_bits(codec, RT5640_MICBIAS, + snd_soc_component_update_bits(component, RT5640_MICBIAS, 0x0030, 0x0030); } break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, RT5640_DEPOP_M1, 0x0004); - snd_soc_write(codec, RT5640_DEPOP_M2, 0x1100); - snd_soc_update_bits(codec, RT5640_DUMMY1, 0x1, 0); - snd_soc_write(codec, RT5640_PWR_DIG1, 0x0000); - snd_soc_write(codec, RT5640_PWR_DIG2, 0x0000); - snd_soc_write(codec, RT5640_PWR_VOL, 0x0000); - snd_soc_write(codec, RT5640_PWR_MIXER, 0x0000); - snd_soc_write(codec, RT5640_PWR_ANLG1, 0x0000); - snd_soc_write(codec, RT5640_PWR_ANLG2, 0x0000); + snd_soc_component_write(component, RT5640_DEPOP_M1, 0x0004); + snd_soc_component_write(component, RT5640_DEPOP_M2, 0x1100); + snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x1, 0); + snd_soc_component_write(component, RT5640_PWR_DIG1, 0x0000); + snd_soc_component_write(component, RT5640_PWR_DIG2, 0x0000); + snd_soc_component_write(component, RT5640_PWR_VOL, 0x0000); + snd_soc_component_write(component, RT5640_PWR_MIXER, 0x0000); + snd_soc_component_write(component, RT5640_PWR_ANLG1, 0x0000); + snd_soc_component_write(component, RT5640_PWR_ANLG2, 0x0000); break; default: @@ -2018,10 +2018,10 @@ static int rt5640_set_bias_level(struct snd_soc_codec *codec, return 0; } -int rt5640_dmic_enable(struct snd_soc_codec *codec, +int rt5640_dmic_enable(struct snd_soc_component *component, bool dmic1_data_pin, bool dmic2_data_pin) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); regmap_update_bits(rt5640->regmap, RT5640_GPIO_CTRL1, RT5640_GP2_PIN_MASK, RT5640_GP2_PIN_DMIC1_SCL); @@ -2044,10 +2044,10 @@ int rt5640_dmic_enable(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(rt5640_dmic_enable); -int rt5640_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5640_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); unsigned int asrc2_mask = 0; unsigned int asrc2_value = 0; @@ -2099,43 +2099,43 @@ int rt5640_sel_asrc_clk_src(struct snd_soc_codec *codec, | (clk_src << RT5640_MAD_R_M_SFT); } - snd_soc_update_bits(codec, RT5640_ASRC_2, + snd_soc_component_update_bits(component, RT5640_ASRC_2, asrc2_mask, asrc2_value); - if (snd_soc_read(codec, RT5640_ASRC_2)) { + if (snd_soc_component_read32(component, RT5640_ASRC_2)) { rt5640->asrc_en = true; - snd_soc_update_bits(codec, RT5640_JD_CTRL, 0x3, 0x3); + snd_soc_component_update_bits(component, RT5640_JD_CTRL, 0x3, 0x3); } else { rt5640->asrc_en = false; - snd_soc_update_bits(codec, RT5640_JD_CTRL, 0x3, 0x0); + snd_soc_component_update_bits(component, RT5640_JD_CTRL, 0x3, 0x0); } return 0; } EXPORT_SYMBOL_GPL(rt5640_sel_asrc_clk_src); -static int rt5640_probe(struct snd_soc_codec *codec) +static int rt5640_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); /* Check if MCLK provided */ - rt5640->mclk = devm_clk_get(codec->dev, "mclk"); + rt5640->mclk = devm_clk_get(component->dev, "mclk"); if (PTR_ERR(rt5640->mclk) == -EPROBE_DEFER) return -EPROBE_DEFER; - rt5640->codec = codec; + rt5640->component = component; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); - snd_soc_update_bits(codec, RT5640_DUMMY1, 0x0301, 0x0301); - snd_soc_update_bits(codec, RT5640_MICBIAS, 0x0030, 0x0030); - snd_soc_update_bits(codec, RT5640_DSP_PATH2, 0xfc00, 0x0c00); + snd_soc_component_update_bits(component, RT5640_DUMMY1, 0x0301, 0x0301); + snd_soc_component_update_bits(component, RT5640_MICBIAS, 0x0030, 0x0030); + snd_soc_component_update_bits(component, RT5640_DSP_PATH2, 0xfc00, 0x0c00); - switch (snd_soc_read(codec, RT5640_RESET) & RT5640_ID_MASK) { + switch (snd_soc_component_read32(component, RT5640_RESET) & RT5640_ID_MASK) { case RT5640_ID_5640: case RT5640_ID_5642: - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, rt5640_specific_snd_controls, ARRAY_SIZE(rt5640_specific_snd_controls)); snd_soc_dapm_new_controls(dapm, @@ -2154,32 +2154,30 @@ static int rt5640_probe(struct snd_soc_codec *codec) ARRAY_SIZE(rt5639_specific_dapm_routes)); break; default: - dev_err(codec->dev, + dev_err(component->dev, "The driver is for RT5639 RT5640 or RT5642 only\n"); return -ENODEV; } if (rt5640->pdata.dmic_en) - rt5640_dmic_enable(codec, rt5640->pdata.dmic1_data_pin, + rt5640_dmic_enable(component, rt5640->pdata.dmic1_data_pin, rt5640->pdata.dmic2_data_pin); return 0; } -static int rt5640_remove(struct snd_soc_codec *codec) +static void rt5640_remove(struct snd_soc_component *component) { - rt5640_reset(codec); - - return 0; + rt5640_reset(component); } #ifdef CONFIG_PM -static int rt5640_suspend(struct snd_soc_codec *codec) +static int rt5640_suspend(struct snd_soc_component *component) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); - rt5640_reset(codec); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + rt5640_reset(component); regcache_cache_only(rt5640->regmap, true); regcache_mark_dirty(rt5640->regmap); if (gpio_is_valid(rt5640->pdata.ldo1_en)) @@ -2188,9 +2186,9 @@ static int rt5640_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5640_resume(struct snd_soc_codec *codec) +static int rt5640_resume(struct snd_soc_component *component) { - struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); + struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); if (gpio_is_valid(rt5640->pdata.ldo1_en)) { gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1); @@ -2259,21 +2257,22 @@ static struct snd_soc_dai_driver rt5640_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5640 = { - .probe = rt5640_probe, - .remove = rt5640_remove, - .suspend = rt5640_suspend, - .resume = rt5640_resume, - .set_bias_level = rt5640_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5640_snd_controls, - .num_controls = ARRAY_SIZE(rt5640_snd_controls), - .dapm_widgets = rt5640_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5640_dapm_widgets), - .dapm_routes = rt5640_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5640_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5640 = { + .probe = rt5640_probe, + .remove = rt5640_remove, + .suspend = rt5640_suspend, + .resume = rt5640_resume, + .set_bias_level = rt5640_set_bias_level, + .controls = rt5640_snd_controls, + .num_controls = ARRAY_SIZE(rt5640_snd_controls), + .dapm_widgets = rt5640_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5640_dapm_widgets), + .dapm_routes = rt5640_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5640_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, + }; static const struct regmap_config rt5640_regmap = { @@ -2427,17 +2426,11 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, rt5640->hp_mute = 1; - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5640, rt5640_dai, ARRAY_SIZE(rt5640_dai)); } -static int rt5640_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static struct i2c_driver rt5640_i2c_driver = { .driver = { .name = "rt5640", @@ -2445,7 +2438,6 @@ static struct i2c_driver rt5640_i2c_driver = { .of_match_table = of_match_ptr(rt5640_of_match), }, .probe = rt5640_i2c_probe, - .remove = rt5640_i2c_remove, .id_table = rt5640_i2c_id, }; module_i2c_driver(rt5640_i2c_driver); diff --git a/sound/soc/codecs/rt5640.h b/sound/soc/codecs/rt5640.h index b8a811732a52..c473e8ae2eda 100644 --- a/sound/soc/codecs/rt5640.h +++ b/sound/soc/codecs/rt5640.h @@ -2102,7 +2102,7 @@ enum { }; struct rt5640_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5640_platform_data pdata; struct regmap *regmap; struct clk *mclk; @@ -2121,9 +2121,9 @@ struct rt5640_priv { bool asrc_en; }; -int rt5640_dmic_enable(struct snd_soc_codec *codec, +int rt5640_dmic_enable(struct snd_soc_component *component, bool dmic1_data_pin, bool dmic2_data_pin); -int rt5640_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5640_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); #endif diff --git a/sound/soc/intel/boards/byt-rt5640.c b/sound/soc/intel/boards/byt-rt5640.c index de9788a3fd06..df902d82145e 100644 --- a/sound/soc/intel/boards/byt-rt5640.c +++ b/sound/soc/intel/boards/byt-rt5640.c @@ -131,7 +131,7 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) { int ret; - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; struct snd_soc_card *card = runtime->card; const struct snd_soc_dapm_route *custom_map; int num_routes; @@ -165,7 +165,7 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) return ret; if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) { - ret = rt5640_dmic_enable(codec, 0, 0); + ret = rt5640_dmic_enable(component, 0, 0); if (ret) return ret; } diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c index b6a1cfeec830..a8d8bff788e7 100644 --- a/sound/soc/intel/boards/bytcr_rt5640.c +++ b/sound/soc/intel/boards/bytcr_rt5640.c @@ -444,14 +444,14 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; struct byt_rt5640_private *priv = snd_soc_card_get_drvdata(card); - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; const struct snd_soc_dapm_route *custom_map; int num_routes; int ret; card->dapm.idle_bias_off = true; - rt5640_sel_asrc_clk_src(codec, + rt5640_sel_asrc_clk_src(component, RT5640_DA_STEREO_FILTER | RT5640_DA_MONO_L_FILTER | RT5640_DA_MONO_R_FILTER | @@ -522,12 +522,12 @@ static int byt_rt5640_init(struct snd_soc_pcm_runtime *runtime) return ret; if (byt_rt5640_quirk & BYT_RT5640_DIFF_MIC) { - snd_soc_update_bits(codec, RT5640_IN1_IN2, RT5640_IN_DF1, + snd_soc_component_update_bits(component, RT5640_IN1_IN2, RT5640_IN_DF1, RT5640_IN_DF1); } if (byt_rt5640_quirk & BYT_RT5640_DMIC_EN) { - ret = rt5640_dmic_enable(codec, 0, 0); + ret = rt5640_dmic_enable(component, 0, 0); if (ret) return ret; } From 17b52010b50b505fc083ce3b8fb4978e6b543411 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:44:39 +0000 Subject: [PATCH 069/942] ASoC: rt5651: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 220 +++++++++++++------------- sound/soc/codecs/rt5651.h | 4 +- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 113 insertions(+), 113 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 831b297978a4..3a844725684b 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -384,17 +384,17 @@ static const struct snd_kcontrol_new rt5651_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5651->sysclk / rl6231_get_pre_div(rt5651->regmap, RT5651_ADDA_CLK1, RT5651_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else - snd_soc_update_bits(codec, RT5651_DMIC, RT5651_DMIC_CLK_MASK, + snd_soc_component_update_bits(component, RT5651_DMIC, RT5651_DMIC_CLK_MASK, idx << RT5651_DMIC_CLK_SFT); return idx; @@ -403,10 +403,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sysclk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int val; - val = snd_soc_read(codec, RT5651_GLB_CLK); + val = snd_soc_component_read32(component, RT5651_GLB_CLK); val &= RT5651_SCLK_SRC_MASK; if (val == RT5651_SCLK_SRC_PLL1) return 1; @@ -703,8 +703,8 @@ static const struct snd_kcontrol_new rt5651_pdm_r_mux = static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -741,8 +741,8 @@ static int rt5651_amp_power_event(struct snd_soc_dapm_widget *w, static int rt5651_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -786,8 +786,8 @@ static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -806,16 +806,16 @@ static int rt5651_hp_post_event(struct snd_soc_dapm_widget *w, static int rt5651_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST1_OP2, RT5651_PWR_BST1_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST1_OP2, 0); break; @@ -829,16 +829,16 @@ static int rt5651_bst1_event(struct snd_soc_dapm_widget *w, static int rt5651_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST2_OP2, RT5651_PWR_BST2_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST2_OP2, 0); break; @@ -852,16 +852,16 @@ static int rt5651_bst2_event(struct snd_soc_dapm_widget *w, static int rt5651_bst3_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST3_OP2, RT5651_PWR_BST3_OP2); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5651_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_BST3_OP2, 0); break; @@ -1313,8 +1313,8 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { static int rt5651_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; @@ -1322,12 +1322,12 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, pre_div = rl6231_get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting\n"); + dev_err(component->dev, "Unsupported clock setting\n"); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } bclk_ms = frame_size > 32 ? 1 : 0; @@ -1358,19 +1358,19 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, case RT5651_AIF1: mask_clk = RT5651_I2S_PD1_MASK; val_clk = pre_div << RT5651_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5651_I2S1_SDP, + snd_soc_component_update_bits(component, RT5651_I2S1_SDP, RT5651_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5651_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5651_ADDA_CLK1, mask_clk, val_clk); break; case RT5651_AIF2: mask_clk = RT5651_I2S_BCLK_MS2_MASK | RT5651_I2S_PD2_MASK; val_clk = pre_div << RT5651_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5651_I2S2_SDP, + snd_soc_component_update_bits(component, RT5651_I2S2_SDP, RT5651_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5651_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5651_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Wrong dai->id: %d\n", dai->id); + dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); return -EINVAL; } @@ -1379,8 +1379,8 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1423,17 +1423,17 @@ static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5651_AIF1: - snd_soc_update_bits(codec, RT5651_I2S1_SDP, + snd_soc_component_update_bits(component, RT5651_I2S1_SDP, RT5651_I2S_MS_MASK | RT5651_I2S_BP_MASK | RT5651_I2S_DF_MASK, reg_val); break; case RT5651_AIF2: - snd_soc_update_bits(codec, RT5651_I2S2_SDP, + snd_soc_component_update_bits(component, RT5651_I2S2_SDP, RT5651_I2S_MS_MASK | RT5651_I2S_BP_MASK | RT5651_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Wrong dai->id: %d\n", dai->id); + dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); return -EINVAL; } return 0; @@ -1442,8 +1442,8 @@ static int rt5651_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5651->sysclk && clk_id == rt5651->sysclk_src) @@ -1460,10 +1460,10 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, reg_val |= RT5651_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_SCLK_SRC_MASK, reg_val); rt5651->sysclk = freq; rt5651->sysclk_src = clk_id; @@ -1476,8 +1476,8 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -1486,46 +1486,46 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5651->pll_in = 0; rt5651->pll_out = 0; - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_SCLK_SRC_MASK, RT5651_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5651_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_PLL1_SRC_MASK, RT5651_PLL1_SRC_MCLK); break; case RT5651_PLL1_S_BCLK1: - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_PLL1_SRC_MASK, RT5651_PLL1_SRC_BCLK1); break; case RT5651_PLL1_S_BCLK2: - snd_soc_update_bits(codec, RT5651_GLB_CLK, + snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_PLL1_SRC_MASK, RT5651_PLL1_SRC_BCLK2); break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5651_PLL_CTRL1, + snd_soc_component_write(component, RT5651_PLL_CTRL1, pll_code.n_code << RT5651_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5651_PLL_CTRL2, + snd_soc_component_write(component, RT5651_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5651_PLL_M_SFT | pll_code.m_bp << RT5651_PLL_M_BP_SFT); @@ -1536,45 +1536,45 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; } -static int rt5651_set_bias_level(struct snd_soc_codec *codec, +static int rt5651_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2); usleep_range(10000, 15000); - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_FV1 | RT5651_PWR_FV2, RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); - snd_soc_update_bits(codec, RT5651_D_MISC, 0x1, 0x1); - if (snd_soc_read(codec, RT5651_PLL_MODE_1) & 0x9200) - snd_soc_update_bits(codec, RT5651_D_MISC, + snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1); + if (snd_soc_component_read32(component, RT5651_PLL_MODE_1) & 0x9200) + snd_soc_component_update_bits(component, RT5651_D_MISC, 0xc00, 0xc00); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, RT5651_D_MISC, 0x0010); - snd_soc_write(codec, RT5651_PWR_DIG1, 0x0000); - snd_soc_write(codec, RT5651_PWR_DIG2, 0x0000); - snd_soc_write(codec, RT5651_PWR_VOL, 0x0000); - snd_soc_write(codec, RT5651_PWR_MIXER, 0x0000); + snd_soc_component_write(component, RT5651_D_MISC, 0x0010); + snd_soc_component_write(component, RT5651_PWR_DIG1, 0x0000); + snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); + snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); + snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); if (rt5651->pdata.jd_src) { - snd_soc_write(codec, RT5651_PWR_ANLG2, 0x0204); - snd_soc_write(codec, RT5651_PWR_ANLG1, 0x0002); + snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); + snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { - snd_soc_write(codec, RT5651_PWR_ANLG1, 0x0000); - snd_soc_write(codec, RT5651_PWR_ANLG2, 0x0000); + snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0000); + snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0000); } break; @@ -1585,24 +1585,24 @@ static int rt5651_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5651_probe(struct snd_soc_codec *codec) +static int rt5651_probe(struct snd_soc_component *component) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - rt5651->codec = codec; + rt5651->component = component; - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2); usleep_range(10000, 15000); - snd_soc_update_bits(codec, RT5651_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_FV1 | RT5651_PWR_FV2, RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); if (rt5651->pdata.jd_src) { snd_soc_dapm_force_enable_pin(dapm, "JD Power"); @@ -1617,21 +1617,21 @@ static int rt5651_probe(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int rt5651_suspend(struct snd_soc_codec *codec) +static int rt5651_suspend(struct snd_soc_component *component) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5651->regmap, true); regcache_mark_dirty(rt5651->regmap); return 0; } -static int rt5651_resume(struct snd_soc_codec *codec) +static int rt5651_resume(struct snd_soc_component *component) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5651->regmap, false); - snd_soc_cache_sync(codec); + snd_soc_component_cache_sync(component); return 0; } @@ -1692,20 +1692,20 @@ static struct snd_soc_dai_driver rt5651_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5651 = { - .probe = rt5651_probe, - .suspend = rt5651_suspend, - .resume = rt5651_resume, - .set_bias_level = rt5651_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5651_snd_controls, - .num_controls = ARRAY_SIZE(rt5651_snd_controls), - .dapm_widgets = rt5651_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5651_dapm_widgets), - .dapm_routes = rt5651_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5651_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5651 = { + .probe = rt5651_probe, + .suspend = rt5651_suspend, + .resume = rt5651_resume, + .set_bias_level = rt5651_set_bias_level, + .controls = rt5651_snd_controls, + .num_controls = ARRAY_SIZE(rt5651_snd_controls), + .dapm_widgets = rt5651_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5651_dapm_widgets), + .dapm_routes = rt5651_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5651_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5651_regmap = { @@ -1794,16 +1794,16 @@ static irqreturn_t rt5651_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt5651_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int jack_type; if (jack_insert) { snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5651_MICBIAS, + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | RT5651_PWR_CLK12M_MASK | @@ -1813,16 +1813,16 @@ static int rt5651_jack_detect(struct snd_soc_codec *codec, int jack_insert) RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); msleep(100); - if (snd_soc_read(codec, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) + if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) jack_type = SND_JACK_HEADPHONE; else jack_type = SND_JACK_HEADSET; - snd_soc_update_bits(codec, RT5651_IRQ_CTRL2, + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, RT5651_MB1_OC_CLR, 0); } else { /* jack out */ jack_type = 0; - snd_soc_update_bits(codec, RT5651_MICBIAS, + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK, RT5651_MIC1_OVCD_DIS); } @@ -1837,32 +1837,32 @@ static void rt5651_jack_detect_work(struct work_struct *work) int report, val = 0; - if (!rt5651->codec) + if (!rt5651->component) return; switch (rt5651->pdata.jd_src) { case RT5651_JD1_1: - val = snd_soc_read(rt5651->codec, RT5651_INT_IRQ_ST) & 0x1000; + val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; break; case RT5651_JD1_2: - val = snd_soc_read(rt5651->codec, RT5651_INT_IRQ_ST) & 0x2000; + val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x2000; break; case RT5651_JD2: - val = snd_soc_read(rt5651->codec, RT5651_INT_IRQ_ST) & 0x4000; + val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x4000; break; default: break; } - report = rt5651_jack_detect(rt5651->codec, !val); + report = rt5651_jack_detect(rt5651->component, !val); snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } -int rt5651_set_jack_detect(struct snd_soc_codec *codec, +int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack) { - struct rt5651_priv *rt5651 = snd_soc_codec_get_drvdata(codec); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); rt5651->hp_jack = hp_jack; rt5651_irq(0, rt5651); @@ -1979,7 +1979,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5651, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5651, rt5651_dai, ARRAY_SIZE(rt5651_dai)); return ret; @@ -1990,7 +1991,6 @@ static int rt5651_i2c_remove(struct i2c_client *i2c) struct rt5651_priv *rt5651 = i2c_get_clientdata(i2c); cancel_delayed_work_sync(&rt5651->jack_detect_work); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 4f8b202121d7..1ef38429e6a0 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2059,7 +2059,7 @@ struct rt5651_pll_code { }; struct rt5651_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5651_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *hp_jack; @@ -2079,6 +2079,6 @@ struct rt5651_priv { bool hp_mute; }; -int rt5651_set_jack_detect(struct snd_soc_codec *codec, +int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack); #endif /* __RT5651_H__ */ diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 456526a93dd5..b6bf92191b9a 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -296,7 +296,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *codec = runtime->codec_dai->component; struct byt_rt5651_private *priv = snd_soc_card_get_drvdata(card); const struct snd_soc_dapm_route *custom_map; int num_routes; From 04e8262ac8c3f59599ea6dfe5cd1a039828ea4ad Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:45:07 +0000 Subject: [PATCH 070/942] ASoC: rt5514: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 4 +- sound/soc/codecs/rt5514.c | 124 ++++++++++++++++------------------ sound/soc/codecs/rt5514.h | 2 +- 3 files changed, 61 insertions(+), 69 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 2144edca97b0..b677f144462b 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -474,9 +474,9 @@ static int __maybe_unused rt5514_suspend(struct device *dev) static int __maybe_unused rt5514_resume(struct device *dev) { - struct snd_soc_platform *platform = snd_soc_lookup_platform(dev); + struct snd_soc_component *component = snd_soc_lookup_component(dev, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); int irq = to_spi_device(dev)->irq; u8 buf[8]; diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 198df016802f..2d79571098ac 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -327,14 +327,13 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); - struct snd_soc_codec *codec = rt5514->codec; const struct firmware *fw = NULL; u8 buf[8]; if (ucontrol->value.integer.value[0] == rt5514->dsp_enabled) return 0; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { rt5514->dsp_enabled = ucontrol->value.integer.value[0]; if (rt5514->dsp_enabled) { @@ -342,11 +341,11 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, !IS_ERR(rt5514->dsp_calib_clk)) { if (clk_set_rate(rt5514->dsp_calib_clk, rt5514->pdata.dsp_calib_clk_rate)) - dev_err(codec->dev, + dev_err(component->dev, "Can't set rate for mclk"); if (clk_prepare_enable(rt5514->dsp_calib_clk)) - dev_err(codec->dev, + dev_err(component->dev, "Can't enable dsp_calib_clk"); rt5514_calibration(rt5514, true); @@ -357,7 +356,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, RT5514_DSP_MAPPING, (u8 *)&buf, sizeof(buf)); #else - dev_err(codec->dev, "There is no SPI driver for" + dev_err(component->dev, "There is no SPI driver for" " loading the firmware\n"); #endif rt5514->pll3_cal_value = buf[0] | buf[1] << 8 | @@ -369,26 +368,26 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, rt5514_enable_dsp_prepare(rt5514); - request_firmware(&fw, RT5514_FIRMWARE1, codec->dev); + request_firmware(&fw, RT5514_FIRMWARE1, component->dev); if (fw) { #if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) rt5514_spi_burst_write(0x4ff60000, fw->data, ((fw->size/8)+1)*8); #else - dev_err(codec->dev, "There is no SPI driver for" + dev_err(component->dev, "There is no SPI driver for" " loading the firmware\n"); #endif release_firmware(fw); fw = NULL; } - request_firmware(&fw, RT5514_FIRMWARE2, codec->dev); + request_firmware(&fw, RT5514_FIRMWARE2, component->dev); if (fw) { #if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) rt5514_spi_burst_write(0x4ffc0000, fw->data, ((fw->size/8)+1)*8); #else - dev_err(codec->dev, "There is no SPI driver for" + dev_err(component->dev, "There is no SPI driver for" " loading the firmware\n"); #endif release_firmware(fw); @@ -492,7 +491,7 @@ static const struct snd_kcontrol_new rt5514_sto2_dmic_mux = * Choose divider parameter that gives the highest possible DMIC frequency in * 1MHz - 3MHz range. */ -static int rt5514_calc_dmic_clk(struct snd_soc_codec *codec, int rate) +static int rt5514_calc_dmic_clk(struct snd_soc_component *component, int rate) { int div[] = {2, 3, 4, 8, 12, 16, 24, 32}; int i; @@ -508,20 +507,20 @@ static int rt5514_calc_dmic_clk(struct snd_soc_codec *codec, int rate) return i; } - dev_warn(codec->dev, "Base clock rate %d is too high\n", rate); + dev_warn(component->dev, "Base clock rate %d is too high\n", rate); return -EINVAL; } static int rt5514_set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); int idx; - idx = rt5514_calc_dmic_clk(codec, rt5514->sysclk); + idx = rt5514_calc_dmic_clk(component, rt5514->sysclk); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else regmap_update_bits(rt5514->regmap, RT5514_CLK_CTRL1, RT5514_CLK_DMIC_OUT_SEL_MASK, @@ -536,8 +535,8 @@ static int rt5514_set_dmic_clk(struct snd_soc_dapm_widget *w, static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); if (rt5514->sysclk_src == RT5514_SCLK_S_PLL1) return 1; @@ -548,8 +547,8 @@ static int rt5514_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int rt5514_i2s_use_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); return (rt5514->sysclk > rt5514->lrck * 384); } @@ -751,21 +750,21 @@ static const struct snd_soc_dapm_route rt5514_dapm_routes[] = { static int rt5514_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); int pre_div, bclk_ms, frame_size; unsigned int val_len = 0; rt5514->lrck = params_rate(params); pre_div = rl6231_get_clk_info(rt5514->sysclk, rt5514->lrck); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting\n"); + dev_err(component->dev, "Unsupported clock setting\n"); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } @@ -808,8 +807,8 @@ static int rt5514_hw_params(struct snd_pcm_substream *substream, static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_INV_MASK) { @@ -862,8 +861,8 @@ static int rt5514_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5514->sysclk && clk_id == rt5514->sysclk_src) @@ -879,7 +878,7 @@ static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai, break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } @@ -897,13 +896,13 @@ static int rt5514_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5514->pll_in = 0; rt5514->pll_out = 0; @@ -930,17 +929,17 @@ static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); @@ -961,8 +960,8 @@ static int rt5514_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); unsigned int val = 0, val2 = 0; if (rx_mask || tx_mask) @@ -1047,10 +1046,10 @@ static int rt5514_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return 0; } -static int rt5514_set_bias_level(struct snd_soc_codec *codec, +static int rt5514_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1058,7 +1057,7 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec, if (IS_ERR(rt5514->mclk)) break; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5514->mclk); } else { ret = clk_prepare_enable(rt5514->mclk); @@ -1068,7 +1067,7 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* * If the DSP is enabled in start of recording, the DSP * should be disabled, and sync back to normal recording @@ -1092,13 +1091,13 @@ static int rt5514_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5514_probe(struct snd_soc_codec *codec) +static int rt5514_probe(struct snd_soc_component *component) { - struct rt5514_priv *rt5514 = snd_soc_codec_get_drvdata(codec); - struct platform_device *pdev = container_of(codec->dev, + struct rt5514_priv *rt5514 = snd_soc_component_get_drvdata(component); + struct platform_device *pdev = container_of(component->dev, struct platform_device, dev); - rt5514->mclk = devm_clk_get(codec->dev, "mclk"); + rt5514->mclk = devm_clk_get(component->dev, "mclk"); if (PTR_ERR(rt5514->mclk) == -EPROBE_DEFER) return -EPROBE_DEFER; @@ -1109,7 +1108,7 @@ static int rt5514_probe(struct snd_soc_codec *codec) return -EPROBE_DEFER; } - rt5514->codec = codec; + rt5514->component = component; rt5514->pll3_cal_value = 0x0078b000; return 0; @@ -1162,18 +1161,18 @@ static struct snd_soc_dai_driver rt5514_dai[] = { } }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5514 = { - .probe = rt5514_probe, - .idle_bias_off = true, - .set_bias_level = rt5514_set_bias_level, - .component_driver = { - .controls = rt5514_snd_controls, - .num_controls = ARRAY_SIZE(rt5514_snd_controls), - .dapm_widgets = rt5514_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5514_dapm_widgets), - .dapm_routes = rt5514_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5514_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5514 = { + .probe = rt5514_probe, + .set_bias_level = rt5514_set_bias_level, + .controls = rt5514_snd_controls, + .num_controls = ARRAY_SIZE(rt5514_snd_controls), + .dapm_widgets = rt5514_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5514_dapm_widgets), + .dapm_routes = rt5514_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5514_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5514_i2c_regmap = { @@ -1313,17 +1312,11 @@ static int rt5514_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5514, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5514, rt5514_dai, ARRAY_SIZE(rt5514_dai)); } -static int rt5514_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static const struct dev_pm_ops rt5514_i2_pm_ops = { SET_SYSTEM_SLEEP_PM_OPS(NULL, rt5514_i2c_resume) }; @@ -1336,7 +1329,6 @@ static struct i2c_driver rt5514_i2c_driver = { .pm = &rt5514_i2_pm_ops, }, .probe = rt5514_i2c_probe, - .remove = rt5514_i2c_remove, .id_table = rt5514_i2c_id, }; module_i2c_driver(rt5514_i2c_driver); diff --git a/sound/soc/codecs/rt5514.h b/sound/soc/codecs/rt5514.h index f0f3400ce6b1..d1ef0b3f566f 100644 --- a/sound/soc/codecs/rt5514.h +++ b/sound/soc/codecs/rt5514.h @@ -272,7 +272,7 @@ enum { struct rt5514_priv { struct rt5514_platform_data pdata; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *i2c_regmap, *regmap; struct clk *mclk, *dsp_calib_clk; int sysclk; From de86a33253d07675abbb1fa294ffb4f3df6f219e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:45:50 +0000 Subject: [PATCH 071/942] ASoC: rt5659: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.c | 307 ++++++++++++++++++-------------------- sound/soc/codecs/rt5659.h | 4 +- 2 files changed, 151 insertions(+), 160 deletions(-) diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index c4a704e9a4db..ef3a44d6386b 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -1238,26 +1238,26 @@ static SOC_VALUE_ENUM_SINGLE_DECL( static int rt5659_hp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret = snd_soc_put_volsw(kcontrol, ucontrol); - if (snd_soc_read(codec, RT5659_STO_NG2_CTRL_1) & RT5659_NG2_EN) { - snd_soc_update_bits(codec, RT5659_STO_NG2_CTRL_1, + if (snd_soc_component_read32(component, RT5659_STO_NG2_CTRL_1) & RT5659_NG2_EN) { + snd_soc_component_update_bits(component, RT5659_STO_NG2_CTRL_1, RT5659_NG2_EN_MASK, RT5659_NG2_DIS); - snd_soc_update_bits(codec, RT5659_STO_NG2_CTRL_1, + snd_soc_component_update_bits(component, RT5659_STO_NG2_CTRL_1, RT5659_NG2_EN_MASK, RT5659_NG2_EN); } return ret; } -static void rt5659_enable_push_button_irq(struct snd_soc_codec *codec, +static void rt5659_enable_push_button_irq(struct snd_soc_component *component, bool enable) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (enable) { - snd_soc_write(codec, RT5659_4BTN_IL_CMD_1, 0x000b); + snd_soc_component_write(component, RT5659_4BTN_IL_CMD_1, 0x000b); /* MICBIAS1 and Mic Det Power for button detect*/ snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); @@ -1265,19 +1265,19 @@ static void rt5659_enable_push_button_irq(struct snd_soc_codec *codec, "Mic Det Power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5659_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5659_PWR_ANLG_2, RT5659_PWR_MB1, RT5659_PWR_MB1); - snd_soc_update_bits(codec, RT5659_PWR_VOL, + snd_soc_component_update_bits(component, RT5659_PWR_VOL, RT5659_PWR_MIC_DET, RT5659_PWR_MIC_DET); - snd_soc_update_bits(codec, RT5659_IRQ_CTRL_2, + snd_soc_component_update_bits(component, RT5659_IRQ_CTRL_2, RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_EN); - snd_soc_update_bits(codec, RT5659_4BTN_IL_CMD_2, + snd_soc_component_update_bits(component, RT5659_4BTN_IL_CMD_2, RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_EN); } else { - snd_soc_update_bits(codec, RT5659_4BTN_IL_CMD_2, + snd_soc_component_update_bits(component, RT5659_4BTN_IL_CMD_2, RT5659_4BTN_IL_MASK, RT5659_4BTN_IL_DIS); - snd_soc_update_bits(codec, RT5659_IRQ_CTRL_2, + snd_soc_component_update_bits(component, RT5659_IRQ_CTRL_2, RT5659_IL_IRQ_MASK, RT5659_IL_IRQ_DIS); /* MICBIAS1 and Mic Det Power for button detect*/ snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); @@ -1288,7 +1288,7 @@ static void rt5659_enable_push_button_irq(struct snd_soc_codec *codec, /** * rt5659_headset_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. @@ -1296,37 +1296,37 @@ static void rt5659_enable_push_button_irq(struct snd_soc_codec *codec, * Returns detect status. */ -static int rt5659_headset_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5659_headset_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; int reg_63; - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); if (jack_insert) { snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - reg_63 = snd_soc_read(codec, RT5659_PWR_ANLG_1); + reg_63 = snd_soc_component_read32(component, RT5659_PWR_ANLG_1); - snd_soc_update_bits(codec, RT5659_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5659_PWR_ANLG_1, RT5659_PWR_VREF2 | RT5659_PWR_MB, RT5659_PWR_VREF2 | RT5659_PWR_MB); msleep(20); - snd_soc_update_bits(codec, RT5659_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5659_PWR_ANLG_1, RT5659_PWR_FV2, RT5659_PWR_FV2); - snd_soc_write(codec, RT5659_EJD_CTRL_2, 0x4160); - snd_soc_update_bits(codec, RT5659_EJD_CTRL_1, + snd_soc_component_write(component, RT5659_EJD_CTRL_2, 0x4160); + snd_soc_component_update_bits(component, RT5659_EJD_CTRL_1, 0x20, 0x0); msleep(20); - snd_soc_update_bits(codec, RT5659_EJD_CTRL_1, + snd_soc_component_update_bits(component, RT5659_EJD_CTRL_1, 0x20, 0x20); while (i < 5) { msleep(sleep_time[i]); - val = snd_soc_read(codec, RT5659_EJD_CTRL_2) & 0x0003; + val = snd_soc_component_read32(component, RT5659_EJD_CTRL_2) & 0x0003; i++; if (val == 0x1 || val == 0x2 || val == 0x3) break; @@ -1335,10 +1335,10 @@ static int rt5659_headset_detect(struct snd_soc_codec *codec, int jack_insert) switch (val) { case 1: rt5659->jack_type = SND_JACK_HEADSET; - rt5659_enable_push_button_irq(codec, true); + rt5659_enable_push_button_irq(component, true); break; default: - snd_soc_write(codec, RT5659_PWR_ANLG_1, reg_63); + snd_soc_component_write(component, RT5659_PWR_ANLG_1, reg_63); rt5659->jack_type = SND_JACK_HEADPHONE; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); @@ -1348,21 +1348,21 @@ static int rt5659_headset_detect(struct snd_soc_codec *codec, int jack_insert) snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); if (rt5659->jack_type == SND_JACK_HEADSET) - rt5659_enable_push_button_irq(codec, false); + rt5659_enable_push_button_irq(component, false); rt5659->jack_type = 0; } - dev_dbg(codec->dev, "jack_type = %d\n", rt5659->jack_type); + dev_dbg(component->dev, "jack_type = %d\n", rt5659->jack_type); return rt5659->jack_type; } -static int rt5659_button_detect(struct snd_soc_codec *codec) +static int rt5659_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5659_4BTN_IL_CMD_1); + val = snd_soc_component_read32(component, RT5659_4BTN_IL_CMD_1); btn_type = val & 0xfff0; - snd_soc_write(codec, RT5659_4BTN_IL_CMD_1, val); + snd_soc_component_write(component, RT5659_4BTN_IL_CMD_1, val); return btn_type; } @@ -1377,10 +1377,10 @@ static irqreturn_t rt5659_irq(int irq, void *data) return IRQ_HANDLED; } -int rt5659_set_jack_detect(struct snd_soc_codec *codec, +int rt5659_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); rt5659->hs_jack = hs_jack; @@ -1396,19 +1396,19 @@ static void rt5659_jack_detect_work(struct work_struct *work) container_of(work, struct rt5659_priv, jack_detect_work.work); int val, btn_type, report = 0; - if (!rt5659->codec) + if (!rt5659->component) return; - val = snd_soc_read(rt5659->codec, RT5659_INT_ST_1) & 0x0080; + val = snd_soc_component_read32(rt5659->component, RT5659_INT_ST_1) & 0x0080; if (!val) { /* jack in */ if (rt5659->jack_type == 0) { /* jack was out, report jack type */ - report = rt5659_headset_detect(rt5659->codec, 1); + report = rt5659_headset_detect(rt5659->component, 1); } else { /* jack is already in, report button event */ report = SND_JACK_HEADSET; - btn_type = rt5659_button_detect(rt5659->codec); + btn_type = rt5659_button_detect(rt5659->component); /** * rt5659 can report three kinds of button behavior, * one click, double click and hold. However, @@ -1441,7 +1441,7 @@ static void rt5659_jack_detect_work(struct work_struct *work) break; default: btn_type = 0; - dev_err(rt5659->codec->dev, + dev_err(rt5659->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -1453,7 +1453,7 @@ static void rt5659_jack_detect_work(struct work_struct *work) } } else { /* jack out */ - report = rt5659_headset_detect(rt5659->codec, 0); + report = rt5659_headset_detect(rt5659->component, 0); } snd_soc_jack_report(rt5659->hs_jack, report, SND_JACK_HEADSET | @@ -1605,8 +1605,8 @@ static const struct snd_kcontrol_new rt5659_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); int pd, idx = -EINVAL; pd = rl6231_get_pre_div(rt5659->regmap, @@ -1614,9 +1614,9 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, idx = rl6231_calc_dmic_clk(rt5659->sysclk / pd); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else { - snd_soc_update_bits(codec, RT5659_DMIC_CTRL_1, + snd_soc_component_update_bits(component, RT5659_DMIC_CTRL_1, RT5659_DMIC_CLK_MASK, idx << RT5659_DMIC_CLK_SFT); } return idx; @@ -1625,17 +1625,17 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int set_adc_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5659_CHOP_ADC, + snd_soc_component_update_bits(component, RT5659_CHOP_ADC, RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK, RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5659_CHOP_ADC, + snd_soc_component_update_bits(component, RT5659_CHOP_ADC, RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK, 0); break; @@ -1650,15 +1650,15 @@ static int set_adc_clk(struct snd_soc_dapm_widget *w, static int rt5659_charge_pump_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Depop */ - snd_soc_write(codec, RT5659_DEPOP_1, 0x0009); + snd_soc_component_write(component, RT5659_DEPOP_1, 0x0009); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, RT5659_HP_CHARGE_PUMP_1, 0x0c16); + snd_soc_component_write(component, RT5659_HP_CHARGE_PUMP_1, 0x0c16); break; default: return 0; @@ -1671,9 +1671,9 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - val = snd_soc_read(codec, RT5659_GLB_CLK); + val = snd_soc_component_read32(component, RT5659_GLB_CLK); val &= RT5659_SCLK_SRC_MASK; if (val == RT5659_SCLK_SRC_PLL1) return 1; @@ -1685,7 +1685,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int reg, shift, val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (w->shift) { case RT5659_ADC_MONO_R_ASRC_SFT: @@ -1716,13 +1716,13 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w, return 0; } - val = (snd_soc_read(codec, reg) >> shift) & 0xf; + val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; switch (val) { case 1: case 2: case 3: /* I2S_Pre_Div1 should be 1 in asrc mode */ - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, RT5659_I2S_PD1_MASK, RT5659_I2S_PD1_2); return 1; default: @@ -2358,24 +2358,24 @@ static const struct snd_kcontrol_new pdm_r_switch = static int rt5659_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5659_CLASSD_CTRL_1, + snd_soc_component_update_bits(component, RT5659_CLASSD_CTRL_1, RT5659_POW_CLSD_DB_MASK, RT5659_POW_CLSD_DB_EN); - snd_soc_update_bits(codec, RT5659_CLASSD_2, + snd_soc_component_update_bits(component, RT5659_CLASSD_2, RT5659_M_RI_DIG, RT5659_M_RI_DIG); - snd_soc_write(codec, RT5659_CLASSD_1, 0x0803); - snd_soc_write(codec, RT5659_SPK_DC_CAILB_CTRL_3, 0x0000); + snd_soc_component_write(component, RT5659_CLASSD_1, 0x0803); + snd_soc_component_write(component, RT5659_SPK_DC_CAILB_CTRL_3, 0x0000); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, RT5659_CLASSD_1, 0x0011); - snd_soc_update_bits(codec, RT5659_CLASSD_2, + snd_soc_component_write(component, RT5659_CLASSD_1, 0x0011); + snd_soc_component_update_bits(component, RT5659_CLASSD_2, RT5659_M_RI_DIG, 0x0); - snd_soc_write(codec, RT5659_SPK_DC_CAILB_CTRL_3, 0x0003); - snd_soc_update_bits(codec, RT5659_CLASSD_CTRL_1, + snd_soc_component_write(component, RT5659_SPK_DC_CAILB_CTRL_3, 0x0003); + snd_soc_component_update_bits(component, RT5659_CLASSD_CTRL_1, RT5659_POW_CLSD_DB_MASK, RT5659_POW_CLSD_DB_DIS); break; @@ -2390,15 +2390,15 @@ static int rt5659_spk_event(struct snd_soc_dapm_widget *w, static int rt5659_mono_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_write(codec, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e00); + snd_soc_component_write(component, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e00); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e04); + snd_soc_component_write(component, RT5659_MONO_AMP_CALIB_CTRL_1, 0x1e04); break; default: @@ -2412,16 +2412,16 @@ static int rt5659_mono_event(struct snd_soc_dapm_widget *w, static int rt5659_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, RT5659_HP_CHARGE_PUMP_1, 0x0e1e); - snd_soc_update_bits(codec, RT5659_DEPOP_1, 0x0010, 0x0010); + snd_soc_component_write(component, RT5659_HP_CHARGE_PUMP_1, 0x0e1e); + snd_soc_component_update_bits(component, RT5659_DEPOP_1, 0x0010, 0x0010); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT5659_DEPOP_1, 0x0000); + snd_soc_component_write(component, RT5659_DEPOP_1, 0x0000); break; default: @@ -3287,21 +3287,21 @@ static const struct snd_soc_dapm_route rt5659_dapm_routes[] = { static int rt5659_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, frame_size; rt5659->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5659->sysclk, rt5659->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5659->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } @@ -3328,39 +3328,39 @@ static int rt5659_hw_params(struct snd_pcm_substream *substream, case RT5659_AIF1: mask_clk = RT5659_I2S_PD1_MASK; val_clk = pre_div << RT5659_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5659_I2S1_SDP, + snd_soc_component_update_bits(component, RT5659_I2S1_SDP, RT5659_I2S_DL_MASK, val_len); break; case RT5659_AIF2: mask_clk = RT5659_I2S_PD2_MASK; val_clk = pre_div << RT5659_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5659_I2S2_SDP, + snd_soc_component_update_bits(component, RT5659_I2S2_SDP, RT5659_I2S_DL_MASK, val_len); break; case RT5659_AIF3: mask_clk = RT5659_I2S_PD3_MASK; val_clk = pre_div << RT5659_I2S_PD3_SFT; - snd_soc_update_bits(codec, RT5659_I2S3_SDP, + snd_soc_component_update_bits(component, RT5659_I2S3_SDP, RT5659_I2S_DL_MASK, val_len); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, mask_clk, val_clk); switch (rt5659->lrck[dai->id]) { case 192000: - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_32); break; case 96000: - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_64); break; default: - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, RT5659_DAC_OSR_MASK, RT5659_DAC_OSR_128); break; } @@ -3370,8 +3370,8 @@ static int rt5659_hw_params(struct snd_pcm_substream *substream, static int rt5659_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -3414,31 +3414,31 @@ static int rt5659_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5659_AIF1: - snd_soc_update_bits(codec, RT5659_I2S1_SDP, + snd_soc_component_update_bits(component, RT5659_I2S1_SDP, RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK | RT5659_I2S_DF_MASK, reg_val); break; case RT5659_AIF2: - snd_soc_update_bits(codec, RT5659_I2S2_SDP, + snd_soc_component_update_bits(component, RT5659_I2S2_SDP, RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK | RT5659_I2S_DF_MASK, reg_val); break; case RT5659_AIF3: - snd_soc_update_bits(codec, RT5659_I2S3_SDP, + snd_soc_component_update_bits(component, RT5659_I2S3_SDP, RT5659_I2S_MS_MASK | RT5659_I2S_BP_MASK | RT5659_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } return 0; } -static int rt5659_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, +static int rt5659_set_component_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src) @@ -3455,25 +3455,25 @@ static int rt5659_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, reg_val |= RT5659_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5659_GLB_CLK, + snd_soc_component_update_bits(component, RT5659_GLB_CLK, RT5659_SCLK_SRC_MASK, reg_val); rt5659->sysclk = freq; rt5659->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk is %dHz and clock id is %d\n", + dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); return 0; } -static int rt5659_set_codec_pll(struct snd_soc_codec *codec, int pll_id, +static int rt5659_set_component_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -3482,50 +3482,50 @@ static int rt5659_set_codec_pll(struct snd_soc_codec *codec, int pll_id, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5659->pll_in = 0; rt5659->pll_out = 0; - snd_soc_update_bits(codec, RT5659_GLB_CLK, + snd_soc_component_update_bits(component, RT5659_GLB_CLK, RT5659_SCLK_SRC_MASK, RT5659_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5659_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5659_GLB_CLK, + snd_soc_component_update_bits(component, RT5659_GLB_CLK, RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_MCLK); break; case RT5659_PLL1_S_BCLK1: - snd_soc_update_bits(codec, RT5659_GLB_CLK, + snd_soc_component_update_bits(component, RT5659_GLB_CLK, RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK1); break; case RT5659_PLL1_S_BCLK2: - snd_soc_update_bits(codec, RT5659_GLB_CLK, + snd_soc_component_update_bits(component, RT5659_GLB_CLK, RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK2); break; case RT5659_PLL1_S_BCLK3: - snd_soc_update_bits(codec, RT5659_GLB_CLK, + snd_soc_component_update_bits(component, RT5659_GLB_CLK, RT5659_PLL1_SRC_MASK, RT5659_PLL1_SRC_BCLK3); break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5659_PLL_CTRL_1, + snd_soc_component_write(component, RT5659_PLL_CTRL_1, pll_code.n_code << RT5659_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5659_PLL_CTRL_2, + snd_soc_component_write(component, RT5659_PLL_CTRL_2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5659_PLL_M_SFT | pll_code.m_bp << RT5659_PLL_M_BP_SFT); @@ -3539,7 +3539,7 @@ static int rt5659_set_codec_pll(struct snd_soc_codec *codec, int pll_id, static int rt5659_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; if (rx_mask || tx_mask) @@ -3583,29 +3583,29 @@ static int rt5659_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; } - snd_soc_update_bits(codec, RT5659_TDM_CTRL_1, 0x8ff0, val); + snd_soc_component_update_bits(component, RT5659_TDM_CTRL_1, 0x8ff0, val); return 0; } static int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); rt5659->bclk[dai->id] = ratio; if (ratio == 64) { switch (dai->id) { case RT5659_AIF2: - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, RT5659_I2S_BCLK_MS2_MASK, RT5659_I2S_BCLK_MS2_64); break; case RT5659_AIF3: - snd_soc_update_bits(codec, RT5659_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5659_ADDA_CLK_1, RT5659_I2S_BCLK_MS3_MASK, RT5659_I2S_BCLK_MS3_64); break; @@ -3615,11 +3615,11 @@ static int rt5659_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) return 0; } -static int rt5659_set_bias_level(struct snd_soc_codec *codec, +static int rt5659_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -3641,7 +3641,7 @@ static int rt5659_set_bias_level(struct snd_soc_codec *codec, if (dapm->bias_level == SND_SOC_BIAS_OFF) { ret = clk_prepare_enable(rt5659->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "failed to enable MCLK: %d\n", ret); return ret; } @@ -3667,37 +3667,35 @@ static int rt5659_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5659_probe(struct snd_soc_codec *codec) +static int rt5659_probe(struct snd_soc_component *component) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); - rt5659->codec = codec; + rt5659->component = component; return 0; } -static int rt5659_remove(struct snd_soc_codec *codec) +static void rt5659_remove(struct snd_soc_component *component) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); regmap_write(rt5659->regmap, RT5659_RESET, 0); - - return 0; } #ifdef CONFIG_PM -static int rt5659_suspend(struct snd_soc_codec *codec) +static int rt5659_suspend(struct snd_soc_component *component) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5659->regmap, true); regcache_mark_dirty(rt5659->regmap); return 0; } -static int rt5659_resume(struct snd_soc_codec *codec) +static int rt5659_resume(struct snd_soc_component *component) { - struct rt5659_priv *rt5659 = snd_soc_codec_get_drvdata(codec); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5659->regmap, false); regcache_sync(rt5659->regmap); @@ -3780,23 +3778,23 @@ static struct snd_soc_dai_driver rt5659_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5659 = { - .probe = rt5659_probe, - .remove = rt5659_remove, - .suspend = rt5659_suspend, - .resume = rt5659_resume, - .set_bias_level = rt5659_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5659_snd_controls, - .num_controls = ARRAY_SIZE(rt5659_snd_controls), - .dapm_widgets = rt5659_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5659_dapm_widgets), - .dapm_routes = rt5659_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5659_dapm_routes), - }, - .set_sysclk = rt5659_set_codec_sysclk, - .set_pll = rt5659_set_codec_pll, +static const struct snd_soc_component_driver soc_component_dev_rt5659 = { + .probe = rt5659_probe, + .remove = rt5659_remove, + .suspend = rt5659_suspend, + .resume = rt5659_resume, + .set_bias_level = rt5659_set_bias_level, + .controls = rt5659_snd_controls, + .num_controls = ARRAY_SIZE(rt5659_snd_controls), + .dapm_widgets = rt5659_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5659_dapm_widgets), + .dapm_routes = rt5659_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5659_dapm_routes), + .set_sysclk = rt5659_set_component_sysclk, + .set_pll = rt5659_set_component_pll, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; @@ -3899,7 +3897,7 @@ static void rt5659_calibrate(struct rt5659_priv *rt5659) break; if (count > 30) { - dev_err(rt5659->codec->dev, + dev_err(rt5659->component->dev, "HP Calibration 1 Failure\n"); return; } @@ -3924,7 +3922,7 @@ static void rt5659_calibrate(struct rt5659_priv *rt5659) break; if (count > 85) { - dev_err(rt5659->codec->dev, + dev_err(rt5659->component->dev, "HP Calibration 2 Failure\n"); return; } @@ -3972,7 +3970,7 @@ static void rt5659_calibrate(struct rt5659_priv *rt5659) break; if (count > 10) { - dev_err(rt5659->codec->dev, + dev_err(rt5659->component->dev, "SPK Calibration Failure\n"); return; } @@ -4005,7 +4003,7 @@ static void rt5659_calibrate(struct rt5659_priv *rt5659) break; if (count > 35) { - dev_err(rt5659->codec->dev, + dev_err(rt5659->component->dev, "Mono Calibration Failure\n"); return; } @@ -4301,17 +4299,11 @@ static int rt5659_i2c_probe(struct i2c_client *i2c, RT5659_GP1_PIN_MASK, RT5659_GP1_PIN_IRQ); } - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5659, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5659, rt5659_dai, ARRAY_SIZE(rt5659_dai)); } -static int rt5659_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static void rt5659_i2c_shutdown(struct i2c_client *client) { struct rt5659_priv *rt5659 = i2c_get_clientdata(client); @@ -4344,7 +4336,6 @@ static struct i2c_driver rt5659_i2c_driver = { .acpi_match_table = ACPI_PTR(rt5659_acpi_match), }, .probe = rt5659_i2c_probe, - .remove = rt5659_i2c_remove, .shutdown = rt5659_i2c_shutdown, .id_table = rt5659_i2c_id, }; diff --git a/sound/soc/codecs/rt5659.h b/sound/soc/codecs/rt5659.h index bea0433c164c..73969ef5029f 100644 --- a/sound/soc/codecs/rt5659.h +++ b/sound/soc/codecs/rt5659.h @@ -1789,7 +1789,7 @@ struct rt5659_pll_code { }; struct rt5659_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5659_platform_data pdata; struct regmap *regmap; struct gpio_desc *gpiod_ldo1_en; @@ -1814,7 +1814,7 @@ struct rt5659_priv { bool hda_mic_plugged; }; -int rt5659_set_jack_detect(struct snd_soc_codec *codec, +int rt5659_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack); #endif /* __RT5659_H__ */ From 5ba04c66d592d53d889dc29281bb2db9471d3122 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:46:46 +0000 Subject: [PATCH 072/942] ASoC: rt5670: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5670.c | 295 ++++++++++++------------ sound/soc/codecs/rt5670.h | 10 +- sound/soc/intel/boards/cht_bsw_rt5672.c | 18 +- 3 files changed, 160 insertions(+), 163 deletions(-) diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c index c5094b4399e2..dc7df337d5f8 100644 --- a/sound/soc/codecs/rt5670.c +++ b/sound/soc/codecs/rt5670.c @@ -423,7 +423,7 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) /** * rt5670_headset_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. @@ -431,46 +431,46 @@ static bool rt5670_readable_register(struct device *dev, unsigned int reg) * Returns detect status. */ -static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5670_headset_detect(struct snd_soc_component *component, int jack_insert) { int val; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (jack_insert) { snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x0); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x0); + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_DET_MODE | RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); - snd_soc_write(codec, RT5670_GPIO_CTRL2, 0x0004); - snd_soc_update_bits(codec, RT5670_GPIO_CTRL1, + snd_soc_component_write(component, RT5670_GPIO_CTRL2, 0x0004); + snd_soc_component_update_bits(component, RT5670_GPIO_CTRL1, RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ); - snd_soc_update_bits(codec, RT5670_CJ_CTRL1, + snd_soc_component_update_bits(component, RT5670_CJ_CTRL1, RT5670_CBJ_BST1_EN, RT5670_CBJ_BST1_EN); - snd_soc_write(codec, RT5670_JD_CTRL3, 0x00f0); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_write(component, RT5670_JD_CTRL3, 0x00f0); + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_MN_JD, RT5670_CBJ_MN_JD); - snd_soc_update_bits(codec, RT5670_CJ_CTRL2, + snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, RT5670_CBJ_MN_JD, 0); msleep(300); - val = snd_soc_read(codec, RT5670_CJ_CTRL3) & 0x7; + val = snd_soc_component_read32(component, RT5670_CJ_CTRL3) & 0x7; if (val == 0x1 || val == 0x2) { rt5670->jack_type = SND_JACK_HEADSET; /* for push button */ - snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x8); - snd_soc_update_bits(codec, RT5670_IL_CMD, 0x40, 0x40); - snd_soc_read(codec, RT5670_IL_CMD); + snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x8); + snd_soc_component_update_bits(component, RT5670_IL_CMD, 0x40, 0x40); + snd_soc_component_read32(component, RT5670_IL_CMD); } else { - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); rt5670->jack_type = SND_JACK_HEADPHONE; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); } } else { - snd_soc_update_bits(codec, RT5670_INT_IRQ_ST, 0x8, 0x0); - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, 0x4, 0x4); + snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x0); + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); rt5670->jack_type = 0; snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); snd_soc_dapm_sync(dapm); @@ -479,35 +479,35 @@ static int rt5670_headset_detect(struct snd_soc_codec *codec, int jack_insert) return rt5670->jack_type; } -void rt5670_jack_suspend(struct snd_soc_codec *codec) +void rt5670_jack_suspend(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); rt5670->jack_type_saved = rt5670->jack_type; - rt5670_headset_detect(codec, 0); + rt5670_headset_detect(component, 0); } EXPORT_SYMBOL_GPL(rt5670_jack_suspend); -void rt5670_jack_resume(struct snd_soc_codec *codec) +void rt5670_jack_resume(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->jack_type_saved) - rt5670_headset_detect(codec, 1); + rt5670_headset_detect(component, 1); } EXPORT_SYMBOL_GPL(rt5670_jack_resume); -static int rt5670_button_detect(struct snd_soc_codec *codec) +static int rt5670_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5670_IL_CMD); + val = snd_soc_component_read32(component, RT5670_IL_CMD); btn_type = val & 0xff80; - snd_soc_write(codec, RT5670_IL_CMD, val); + snd_soc_component_write(component, RT5670_IL_CMD, val); if (btn_type != 0) { msleep(20); - val = snd_soc_read(codec, RT5670_IL_CMD); - snd_soc_write(codec, RT5670_IL_CMD, val); + val = snd_soc_component_read32(component, RT5670_IL_CMD); + snd_soc_component_write(component, RT5670_IL_CMD, val); } return btn_type; @@ -521,25 +521,25 @@ static int rt5670_irq_detection(void *data) int val, btn_type, report = jack->status; if (rt5670->pdata.jd_mode == 1) /* 2 port */ - val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0070; + val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; else - val = snd_soc_read(rt5670->codec, RT5670_A_JD_CTRL1) & 0x0020; + val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; switch (val) { /* jack in */ case 0x30: /* 2 port */ case 0x0: /* 1 port or 2 port */ if (rt5670->jack_type == 0) { - report = rt5670_headset_detect(rt5670->codec, 1); + report = rt5670_headset_detect(rt5670->component, 1); /* for push button and jack out */ gpio->debounce_time = 25; break; } btn_type = 0; - if (snd_soc_read(rt5670->codec, RT5670_INT_IRQ_ST) & 0x4) { + if (snd_soc_component_read32(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { /* button pressed */ report = SND_JACK_HEADSET; - btn_type = rt5670_button_detect(rt5670->codec); + btn_type = rt5670_button_detect(rt5670->component); switch (btn_type) { case 0x2000: /* up */ report |= SND_JACK_BTN_1; @@ -551,7 +551,7 @@ static int rt5670_irq_detection(void *data) report |= SND_JACK_BTN_2; break; default: - dev_err(rt5670->codec->dev, + dev_err(rt5670->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -566,8 +566,8 @@ static int rt5670_irq_detection(void *data) case 0x10: /* 2 port */ case 0x20: /* 1 port */ report = 0; - snd_soc_update_bits(rt5670->codec, RT5670_INT_IRQ_ST, 0x1, 0x0); - rt5670_headset_detect(rt5670->codec, 0); + snd_soc_component_update_bits(rt5670->component, RT5670_INT_IRQ_ST, 0x1, 0x0); + rt5670_headset_detect(rt5670->component, 0); gpio->debounce_time = 150; /* for jack in */ break; default: @@ -577,14 +577,14 @@ static int rt5670_irq_detection(void *data) return report; } -int rt5670_set_jack_detect(struct snd_soc_codec *codec, +int rt5670_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int ret; rt5670->jack = jack; - rt5670->hp_gpio.gpiod_dev = codec->dev; + rt5670->hp_gpio.gpiod_dev = component->dev; rt5670->hp_gpio.name = "headset"; rt5670->hp_gpio.report = SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2; @@ -596,7 +596,7 @@ int rt5670_set_jack_detect(struct snd_soc_codec *codec, ret = snd_soc_jack_add_gpios(rt5670->jack, 1, &rt5670->hp_gpio); if (ret) { - dev_err(codec->dev, "Adding jack GPIO failed\n"); + dev_err(component->dev, "Adding jack GPIO failed\n"); return ret; } @@ -699,17 +699,17 @@ static const struct snd_kcontrol_new rt5670_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, RT5670_ADDA_CLK1, RT5670_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else - snd_soc_update_bits(codec, RT5670_DMIC_CTRL1, + snd_soc_component_update_bits(component, RT5670_DMIC_CTRL1, RT5670_DMIC_CLK_MASK, idx << RT5670_DMIC_CLK_SFT); return idx; } @@ -717,8 +717,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) return 1; @@ -729,7 +729,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg, shift, val; switch (source->shift) { @@ -765,7 +765,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, return 0; } - val = (snd_soc_read(codec, reg) >> shift) & 0xf; + val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; switch (val) { case 1: case 2: @@ -781,8 +781,8 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, static int can_use_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) return 1; @@ -793,7 +793,7 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, /** * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -805,7 +805,7 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5670_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { unsigned int asrc2_mask = 0, asrc2_value = 0; @@ -863,11 +863,11 @@ int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, } if (asrc2_mask) - snd_soc_update_bits(codec, RT5670_ASRC_2, + snd_soc_component_update_bits(component, RT5670_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5670_ASRC_3, + snd_soc_component_update_bits(component, RT5670_ASRC_3, asrc3_mask, asrc3_value); return 0; } @@ -1421,8 +1421,8 @@ static const struct snd_kcontrol_new rt5670_vad_adc_mux = static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1457,8 +1457,8 @@ static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, static int rt5670_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1507,16 +1507,16 @@ static int rt5670_hp_event(struct snd_soc_dapm_widget *w, static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST1_P, RT5670_PWR_BST1_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST1_P, 0); break; @@ -1530,16 +1530,16 @@ static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, static int rt5670_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST2_P, RT5670_PWR_BST2_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5670_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG2, RT5670_PWR_BST2_P, 0); break; @@ -2322,21 +2322,21 @@ static const struct snd_soc_dapm_route rt5672_specific_dapm_routes[] = { static int rt5670_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; rt5670->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5670->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } bclk_ms = frame_size > 32; @@ -2368,20 +2368,20 @@ static int rt5670_hw_params(struct snd_pcm_substream *substream, mask_clk = RT5670_I2S_BCLK_MS1_MASK | RT5670_I2S_PD1_MASK; val_clk = bclk_ms << RT5670_I2S_BCLK_MS1_SFT | pre_div << RT5670_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5670_I2S1_SDP, + snd_soc_component_update_bits(component, RT5670_I2S1_SDP, RT5670_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); break; case RT5670_AIF2: mask_clk = RT5670_I2S_BCLK_MS2_MASK | RT5670_I2S_PD2_MASK; val_clk = bclk_ms << RT5670_I2S_BCLK_MS2_SFT | pre_div << RT5670_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5670_I2S2_SDP, + snd_soc_component_update_bits(component, RT5670_I2S2_SDP, RT5670_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5670_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } @@ -2390,8 +2390,8 @@ static int rt5670_hw_params(struct snd_pcm_substream *substream, static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -2434,26 +2434,26 @@ static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5670_AIF1: - snd_soc_update_bits(codec, RT5670_I2S1_SDP, + snd_soc_component_update_bits(component, RT5670_I2S1_SDP, RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | RT5670_I2S_DF_MASK, reg_val); break; case RT5670_AIF2: - snd_soc_update_bits(codec, RT5670_I2S2_SDP, + snd_soc_component_update_bits(component, RT5670_I2S2_SDP, RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | RT5670_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } return 0; } -static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, +static int rt5670_set_codec_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (clk_id) { @@ -2467,16 +2467,16 @@ static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, reg_val |= RT5670_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_SCLK_SRC_MASK, reg_val); rt5670->sysclk = freq; if (clk_id != RT5670_SCLK_S_RCCLK) rt5670->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); + dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); return 0; } @@ -2484,8 +2484,8 @@ static int rt5670_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -2494,18 +2494,18 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5670->pll_in = 0; rt5670->pll_out = 0; - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5670_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_MCLK); break; case RT5670_PLL1_S_BCLK1: @@ -2514,36 +2514,36 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, case RT5670_PLL1_S_BCLK4: switch (dai->id) { case RT5670_AIF1: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK1); break; case RT5670_AIF2: - snd_soc_update_bits(codec, RT5670_GLB_CLK, + snd_soc_component_update_bits(component, RT5670_GLB_CLK, RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK2); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5670_PLL_CTRL1, + snd_soc_component_write(component, RT5670_PLL_CTRL1, pll_code.n_code << RT5670_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5670_PLL_CTRL2, + snd_soc_component_write(component, RT5670_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5670_PLL_M_SFT | pll_code.m_bp << RT5670_PLL_M_BP_SFT); @@ -2557,7 +2557,7 @@ static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; if (rx_mask || tx_mask) @@ -2595,75 +2595,75 @@ static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; } - snd_soc_update_bits(codec, RT5670_TDM_CTRL_1, 0x7c00, val); + snd_soc_component_update_bits(component, RT5670_TDM_CTRL_1, 0x7c00, val); return 0; } static int rt5670_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); if (dai->id != RT5670_AIF1) return 0; if ((ratio % 50) == 0) - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_50FS); else - snd_soc_update_bits(codec, RT5670_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, RT5670_TDM_DATA_MODE_SEL, RT5670_TDM_DATA_MODE_NOR); return 0; } -static int rt5670_set_bias_level(struct snd_soc_codec *codec, +static int rt5670_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2); mdelay(10); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_FV1 | RT5670_PWR_FV2, RT5670_PWR_FV1 | RT5670_PWR_FV2); - snd_soc_update_bits(codec, RT5670_CHARGE_PUMP, + snd_soc_component_update_bits(component, RT5670_CHARGE_PUMP, RT5670_OSW_L_MASK | RT5670_OSW_R_MASK, RT5670_OSW_L_DIS | RT5670_OSW_R_DIS); - snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x1); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x1); + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_LDO_SEL_MASK, 0x5); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_LDO_SEL_MASK, 0x3); break; case SND_SOC_BIAS_OFF: if (rt5670->pdata.jd_mode) - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, RT5670_PWR_MB | RT5670_PWR_BG); else - snd_soc_update_bits(codec, RT5670_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, RT5670_PWR_VREF1 | RT5670_PWR_MB | RT5670_PWR_BG | RT5670_PWR_VREF2 | RT5670_PWR_FV1 | RT5670_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x0); + snd_soc_component_update_bits(component, RT5670_DIG_MISC, 0x1, 0x0); break; default: @@ -2673,12 +2673,12 @@ static int rt5670_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5670_probe(struct snd_soc_codec *codec) +static int rt5670_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); - switch (snd_soc_read(codec, RT5670_RESET) & RT5670_ID_MASK) { + switch (snd_soc_component_read32(component, RT5670_RESET) & RT5670_ID_MASK) { case RT5670_ID_5670: case RT5670_ID_5671: snd_soc_dapm_new_controls(dapm, @@ -2697,37 +2697,36 @@ static int rt5670_probe(struct snd_soc_codec *codec) ARRAY_SIZE(rt5672_specific_dapm_routes)); break; default: - dev_err(codec->dev, + dev_err(component->dev, "The driver is for RT5670 RT5671 or RT5672 only\n"); return -ENODEV; } - rt5670->codec = codec; + rt5670->component = component; return 0; } -static int rt5670_remove(struct snd_soc_codec *codec) +static void rt5670_remove(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regmap_write(rt5670->regmap, RT5670_RESET, 0); snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); - return 0; } #ifdef CONFIG_PM -static int rt5670_suspend(struct snd_soc_codec *codec) +static int rt5670_suspend(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5670->regmap, true); regcache_mark_dirty(rt5670->regmap); return 0; } -static int rt5670_resume(struct snd_soc_codec *codec) +static int rt5670_resume(struct snd_soc_component *component) { - struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); + struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5670->regmap, false); regcache_sync(rt5670->regmap); @@ -2794,22 +2793,22 @@ static struct snd_soc_dai_driver rt5670_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5670 = { - .probe = rt5670_probe, - .remove = rt5670_remove, - .suspend = rt5670_suspend, - .resume = rt5670_resume, - .set_bias_level = rt5670_set_bias_level, - .idle_bias_off = true, - .set_sysclk = rt5670_set_codec_sysclk, - .component_driver = { - .controls = rt5670_snd_controls, - .num_controls = ARRAY_SIZE(rt5670_snd_controls), - .dapm_widgets = rt5670_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), - .dapm_routes = rt5670_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5670 = { + .probe = rt5670_probe, + .remove = rt5670_remove, + .suspend = rt5670_suspend, + .resume = rt5670_resume, + .set_bias_level = rt5670_set_bias_level, + .set_sysclk = rt5670_set_codec_sysclk, + .controls = rt5670_snd_controls, + .num_controls = ARRAY_SIZE(rt5670_snd_controls), + .dapm_widgets = rt5670_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), + .dapm_routes = rt5670_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5670_regmap = { @@ -3171,7 +3170,8 @@ static int rt5670_i2c_probe(struct i2c_client *i2c, pm_runtime_enable(&i2c->dev); pm_request_idle(&i2c->dev); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5670, rt5670_dai, ARRAY_SIZE(rt5670_dai)); if (ret < 0) goto err; @@ -3188,7 +3188,6 @@ err: static int rt5670_i2c_remove(struct i2c_client *i2c) { pm_runtime_disable(&i2c->dev); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h index 265df80d504e..97e8eebe63fa 100644 --- a/sound/soc/codecs/rt5670.h +++ b/sound/soc/codecs/rt5670.h @@ -1986,11 +1986,11 @@ enum { RT5670_DOWN_RATE_FILTER = (0x1 << 7), }; -int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5670_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); struct rt5670_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5670_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *jack; @@ -2012,8 +2012,8 @@ struct rt5670_priv { int jack_type_saved; }; -void rt5670_jack_suspend(struct snd_soc_codec *codec); -void rt5670_jack_resume(struct snd_soc_codec *codec); -int rt5670_set_jack_detect(struct snd_soc_codec *codec, +void rt5670_jack_suspend(struct snd_soc_component *component); +void rt5670_jack_resume(struct snd_soc_component *component); +int rt5670_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT5670_H__ */ diff --git a/sound/soc/intel/boards/cht_bsw_rt5672.c b/sound/soc/intel/boards/cht_bsw_rt5672.c index c14a52d2f714..e68ec32720a4 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5672.c +++ b/sound/soc/intel/boards/cht_bsw_rt5672.c @@ -183,10 +183,10 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { int ret; struct snd_soc_dai *codec_dai = runtime->codec_dai; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); - if (devm_acpi_dev_add_driver_gpios(codec->dev, cht_rt5672_gpios)) + if (devm_acpi_dev_add_driver_gpios(component->dev, cht_rt5672_gpios)) dev_warn(runtime->dev, "Unable to add GPIO mapping table\n"); /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ @@ -201,7 +201,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) * be supported by RT5672. Otherwise, ASRC will be disabled and cause * noise. */ - rt5670_sel_asrc_clk_src(codec, + rt5670_sel_asrc_clk_src(component, RT5670_DA_STEREO_FILTER | RT5670_DA_MONO_L_FILTER | RT5670_DA_MONO_R_FILTER @@ -219,7 +219,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) if (ret) return ret; - rt5670_set_jack_detect(codec, &ctx->headset); + rt5670_set_jack_detect(component, &ctx->headset); if (ctx->mclk) { /* * The firmware might enable the clock at @@ -333,10 +333,9 @@ static int cht_suspend_pre(struct snd_soc_card *card) list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strncmp(component->name, ctx->codec_name, sizeof(ctx->codec_name))) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); - rt5670_jack_suspend(codec); + dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); + rt5670_jack_suspend(component); break; } } @@ -351,10 +350,9 @@ static int cht_resume_post(struct snd_soc_card *card) list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strncmp(component->name, ctx->codec_name, sizeof(ctx->codec_name))) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "enabling jack detect for resume.\n"); - rt5670_jack_resume(codec); + dev_dbg(component->dev, "enabling jack detect for resume.\n"); + rt5670_jack_resume(component); break; } } From ca04dd8a9b4d350d473675c0f777ff8c213aa0a9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:47:20 +0000 Subject: [PATCH 073/942] ASoC: rt5660: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5660.c | 145 ++++++++++++++++++-------------------- sound/soc/codecs/rt5660.h | 2 +- 2 files changed, 70 insertions(+), 77 deletions(-) diff --git a/sound/soc/codecs/rt5660.c b/sound/soc/codecs/rt5660.c index d22ef00e0d96..20a755137e63 100644 --- a/sound/soc/codecs/rt5660.c +++ b/sound/soc/codecs/rt5660.c @@ -354,17 +354,17 @@ static const struct snd_kcontrol_new rt5660_snd_controls[] = { static int rt5660_set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5660->sysclk / rl6231_get_pre_div(rt5660->regmap, RT5660_ADDA_CLK1, RT5660_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else - snd_soc_update_bits(codec, RT5660_DMIC_CTRL1, + snd_soc_component_update_bits(component, RT5660_DMIC_CTRL1, RT5660_DMIC_CLK_MASK, idx << RT5660_DMIC_CLK_SFT); return idx; @@ -373,10 +373,10 @@ static int rt5660_set_dmic_clk(struct snd_soc_dapm_widget *w, static int rt5660_is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int val; - val = snd_soc_read(codec, RT5660_GLB_CLK); + val = snd_soc_component_read32(component, RT5660_GLB_CLK); val &= RT5660_SCLK_SRC_MASK; if (val == RT5660_SCLK_SRC_PLL1) return 1; @@ -541,17 +541,17 @@ static const struct snd_kcontrol_new rt5660_if1_adc_swap_mux = static int rt5660_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5660_LOUT_AMP_CTRL, + snd_soc_component_update_bits(component, RT5660_LOUT_AMP_CTRL, RT5660_LOUT_CO_MASK | RT5660_LOUT_CB_MASK, RT5660_LOUT_CO_EN | RT5660_LOUT_CB_PU); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5660_LOUT_AMP_CTRL, + snd_soc_component_update_bits(component, RT5660_LOUT_AMP_CTRL, RT5660_LOUT_CO_MASK | RT5660_LOUT_CB_MASK, RT5660_LOUT_CO_DIS | RT5660_LOUT_CB_PD); break; @@ -838,22 +838,22 @@ static const struct snd_soc_dapm_route rt5660_dapm_routes[] = { static int rt5660_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; rt5660->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5660->sysclk, rt5660->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5660->lrck[dai->id], dai->id); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return frame_size; } @@ -890,13 +890,13 @@ static int rt5660_hw_params(struct snd_pcm_substream *substream, mask_clk = RT5660_I2S_BCLK_MS1_MASK | RT5660_I2S_PD1_MASK; val_clk = bclk_ms << RT5660_I2S_BCLK_MS1_SFT | pre_div << RT5660_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5660_I2S1_SDP, RT5660_I2S_DL_MASK, + snd_soc_component_update_bits(component, RT5660_I2S1_SDP, RT5660_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5660_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5660_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } @@ -905,8 +905,8 @@ static int rt5660_hw_params(struct snd_pcm_substream *substream, static int rt5660_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -957,13 +957,13 @@ static int rt5660_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5660_AIF1: - snd_soc_update_bits(codec, RT5660_I2S1_SDP, + snd_soc_component_update_bits(component, RT5660_I2S1_SDP, RT5660_I2S_MS_MASK | RT5660_I2S_BP_MASK | RT5660_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } @@ -973,8 +973,8 @@ static int rt5660_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5660_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5660->sysclk && clk_id == rt5660->sysclk_src) @@ -994,11 +994,11 @@ static int rt5660_set_dai_sysclk(struct snd_soc_dai *dai, break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5660_GLB_CLK, RT5660_SCLK_SRC_MASK, + snd_soc_component_update_bits(component, RT5660_GLB_CLK, RT5660_SCLK_SRC_MASK, reg_val); rt5660->sysclk = freq; @@ -1012,8 +1012,8 @@ static int rt5660_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5660_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -1022,44 +1022,44 @@ static int rt5660_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5660->pll_in = 0; rt5660->pll_out = 0; - snd_soc_update_bits(codec, RT5660_GLB_CLK, + snd_soc_component_update_bits(component, RT5660_GLB_CLK, RT5660_SCLK_SRC_MASK, RT5660_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5660_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5660_GLB_CLK, + snd_soc_component_update_bits(component, RT5660_GLB_CLK, RT5660_PLL1_SRC_MASK, RT5660_PLL1_SRC_MCLK); break; case RT5660_PLL1_S_BCLK: - snd_soc_update_bits(codec, RT5660_GLB_CLK, + snd_soc_component_update_bits(component, RT5660_GLB_CLK, RT5660_PLL1_SRC_MASK, RT5660_PLL1_SRC_BCLK1); break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5660_PLL_CTRL1, + snd_soc_component_write(component, RT5660_PLL_CTRL1, pll_code.n_code << RT5660_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5660_PLL_CTRL2, + snd_soc_component_write(component, RT5660_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5660_PLL_M_SFT | pll_code.m_bp << RT5660_PLL_M_BP_SFT); @@ -1070,10 +1070,10 @@ static int rt5660_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; } -static int rt5660_set_bias_level(struct snd_soc_codec *codec, +static int rt5660_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1081,13 +1081,13 @@ static int rt5660_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, RT5660_GEN_CTRL1, + snd_soc_component_update_bits(component, RT5660_GEN_CTRL1, RT5660_DIG_GATE_CTRL, RT5660_DIG_GATE_CTRL); if (IS_ERR(rt5660->mclk)) break; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(rt5660->mclk); } else { ret = clk_prepare_enable(rt5660->mclk); @@ -1097,21 +1097,21 @@ static int rt5660_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, RT5660_PWR_ANLG1, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, RT5660_PWR_ANLG1, RT5660_PWR_VREF1 | RT5660_PWR_MB | RT5660_PWR_BG | RT5660_PWR_VREF2, RT5660_PWR_VREF1 | RT5660_PWR_MB | RT5660_PWR_BG | RT5660_PWR_VREF2); usleep_range(10000, 15000); - snd_soc_update_bits(codec, RT5660_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5660_PWR_ANLG1, RT5660_PWR_FV1 | RT5660_PWR_FV2, RT5660_PWR_FV1 | RT5660_PWR_FV2); } break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, RT5660_GEN_CTRL1, + snd_soc_component_update_bits(component, RT5660_GEN_CTRL1, RT5660_DIG_GATE_CTRL, 0); break; @@ -1122,24 +1122,24 @@ static int rt5660_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5660_probe(struct snd_soc_codec *codec) +static int rt5660_probe(struct snd_soc_component *component) { - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); - rt5660->codec = codec; + rt5660->component = component; return 0; } -static int rt5660_remove(struct snd_soc_codec *codec) +static void rt5660_remove(struct snd_soc_component *component) { - return snd_soc_write(codec, RT5660_RESET, 0); + snd_soc_component_write(component, RT5660_RESET, 0); } #ifdef CONFIG_PM -static int rt5660_suspend(struct snd_soc_codec *codec) +static int rt5660_suspend(struct snd_soc_component *component) { - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5660->regmap, true); regcache_mark_dirty(rt5660->regmap); @@ -1147,9 +1147,9 @@ static int rt5660_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5660_resume(struct snd_soc_codec *codec) +static int rt5660_resume(struct snd_soc_component *component) { - struct rt5660_priv *rt5660 = snd_soc_codec_get_drvdata(codec); + struct rt5660_priv *rt5660 = snd_soc_component_get_drvdata(component); if (rt5660->pdata.poweroff_codec_in_suspend) msleep(350); @@ -1197,21 +1197,21 @@ static struct snd_soc_dai_driver rt5660_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5660 = { - .probe = rt5660_probe, - .remove = rt5660_remove, - .suspend = rt5660_suspend, - .resume = rt5660_resume, - .set_bias_level = rt5660_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5660_snd_controls, - .num_controls = ARRAY_SIZE(rt5660_snd_controls), - .dapm_widgets = rt5660_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5660_dapm_widgets), - .dapm_routes = rt5660_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5660_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5660 = { + .probe = rt5660_probe, + .remove = rt5660_remove, + .suspend = rt5660_suspend, + .resume = rt5660_resume, + .set_bias_level = rt5660_set_bias_level, + .controls = rt5660_snd_controls, + .num_controls = ARRAY_SIZE(rt5660_snd_controls), + .dapm_widgets = rt5660_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5660_dapm_widgets), + .dapm_routes = rt5660_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5660_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5660_regmap = { @@ -1329,17 +1329,11 @@ static int rt5660_i2c_probe(struct i2c_client *i2c, RT5660_SEL_DMIC_DATA_IN1P); } - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5660, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5660, rt5660_dai, ARRAY_SIZE(rt5660_dai)); } -static int rt5660_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static struct i2c_driver rt5660_i2c_driver = { .driver = { .name = "rt5660", @@ -1347,7 +1341,6 @@ static struct i2c_driver rt5660_i2c_driver = { .of_match_table = of_match_ptr(rt5660_of_match), }, .probe = rt5660_i2c_probe, - .remove = rt5660_i2c_remove, .id_table = rt5660_i2c_id, }; module_i2c_driver(rt5660_i2c_driver); diff --git a/sound/soc/codecs/rt5660.h b/sound/soc/codecs/rt5660.h index bba18fb66b6f..c65de0a20a49 100644 --- a/sound/soc/codecs/rt5660.h +++ b/sound/soc/codecs/rt5660.h @@ -831,7 +831,7 @@ enum { }; struct rt5660_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5660_platform_data pdata; struct regmap *regmap; struct clk *mclk; From 46295e5e7ae53bf3c508892589b269576cd62bc3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:48:05 +0000 Subject: [PATCH 074/942] ASoC: rt5631: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5631.c | 324 +++++++++++++++++++------------------- 1 file changed, 163 insertions(+), 161 deletions(-) diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index 55b04c55fb4b..cf6dce69eb2a 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c @@ -71,30 +71,30 @@ static const struct reg_default rt5631_reg[] = { /** * rt5631_write_index - write index register of 2nd layer */ -static void rt5631_write_index(struct snd_soc_codec *codec, +static void rt5631_write_index(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - snd_soc_write(codec, RT5631_INDEX_ADD, reg); - snd_soc_write(codec, RT5631_INDEX_DATA, value); + snd_soc_component_write(component, RT5631_INDEX_ADD, reg); + snd_soc_component_write(component, RT5631_INDEX_DATA, value); } /** * rt5631_read_index - read index register of 2nd layer */ -static unsigned int rt5631_read_index(struct snd_soc_codec *codec, +static unsigned int rt5631_read_index(struct snd_soc_component *component, unsigned int reg) { unsigned int value; - snd_soc_write(codec, RT5631_INDEX_ADD, reg); - value = snd_soc_read(codec, RT5631_INDEX_DATA); + snd_soc_component_write(component, RT5631_INDEX_ADD, reg); + value = snd_soc_component_read32(component, RT5631_INDEX_DATA); return value; } -static int rt5631_reset(struct snd_soc_codec *codec) +static int rt5631_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, RT5631_RESET, 0); + return snd_soc_component_write(component, RT5631_RESET, 0); } static bool rt5631_volatile_register(struct device *dev, unsigned int reg) @@ -187,8 +187,8 @@ static const DECLARE_TLV_DB_RANGE(mic_bst_tlv, static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = rt5631->dmic_used_flag; @@ -198,8 +198,8 @@ static int rt5631_dmic_get(struct snd_kcontrol *kcontrol, static int rt5631_dmic_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); rt5631->dmic_used_flag = ucontrol->value.integer.value[0]; return 0; @@ -286,78 +286,78 @@ static const struct snd_kcontrol_new rt5631_snd_controls[] = { static int check_sysclk1_source(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_GLOBAL_CLK_CTRL); + reg = snd_soc_component_read32(component, RT5631_GLOBAL_CLK_CTRL); return reg & RT5631_SYSCLK_SOUR_SEL_PLL; } static int check_dmic_used(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); return rt5631->dmic_used_flag; } static int check_dacl_to_outmixl(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_OUTMIXER_L_CTRL); + reg = snd_soc_component_read32(component, RT5631_OUTMIXER_L_CTRL); return !(reg & RT5631_M_DAC_L_TO_OUTMIXER_L); } static int check_dacr_to_outmixr(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_OUTMIXER_R_CTRL); + reg = snd_soc_component_read32(component, RT5631_OUTMIXER_R_CTRL); return !(reg & RT5631_M_DAC_R_TO_OUTMIXER_R); } static int check_dacl_to_spkmixl(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL); + reg = snd_soc_component_read32(component, RT5631_SPK_MIXER_CTRL); return !(reg & RT5631_M_DAC_L_TO_SPKMIXER_L); } static int check_dacr_to_spkmixr(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_SPK_MIXER_CTRL); + reg = snd_soc_component_read32(component, RT5631_SPK_MIXER_CTRL); return !(reg & RT5631_M_DAC_R_TO_SPKMIXER_R); } static int check_adcl_select(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER); + reg = snd_soc_component_read32(component, RT5631_ADC_REC_MIXER); return !(reg & RT5631_M_MIC1_TO_RECMIXER_L); } static int check_adcr_select(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg; - reg = snd_soc_read(codec, RT5631_ADC_REC_MIXER); + reg = snd_soc_component_read32(component, RT5631_ADC_REC_MIXER); return !(reg & RT5631_M_MIC2_TO_RECMIXER_R); } @@ -367,36 +367,36 @@ static int check_adcr_select(struct snd_soc_dapm_widget *source, * * When power on/off headphone, the depop sequence is done by hardware. */ -static void onebit_depop_power_stage(struct snd_soc_codec *codec, int enable) +static void onebit_depop_power_stage(struct snd_soc_component *component, int enable) { unsigned int soft_vol, hp_zc; /* enable one-bit depop function */ - snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2, + snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2, RT5631_EN_ONE_BIT_DEPOP, 0); /* keep soft volume and zero crossing setting */ - soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL); - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0); - hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); if (enable) { /* config one-bit depop parameter */ - rt5631_write_index(codec, RT5631_TEST_MODE_CTRL, 0x84c0); - rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x309f); - rt5631_write_index(codec, RT5631_CP_INTL_REG2, 0x6530); + rt5631_write_index(component, RT5631_TEST_MODE_CTRL, 0x84c0); + rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x309f); + rt5631_write_index(component, RT5631_CP_INTL_REG2, 0x6530); /* power on capless block */ - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_2, + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_2, RT5631_EN_CAP_FREE_DEPOP); } else { /* power off capless block */ - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_2, 0); + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_2, 0); msleep(100); } /* recover soft volume and zero crossing setting */ - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); } /** @@ -405,36 +405,36 @@ static void onebit_depop_power_stage(struct snd_soc_codec *codec, int enable) * * When mute/unmute headphone, the depop sequence is done by hardware. */ -static void onebit_depop_mute_stage(struct snd_soc_codec *codec, int enable) +static void onebit_depop_mute_stage(struct snd_soc_component *component, int enable) { unsigned int soft_vol, hp_zc; /* enable one-bit depop function */ - snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2, + snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2, RT5631_EN_ONE_BIT_DEPOP, 0); /* keep soft volume and zero crossing setting */ - soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL); - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0); - hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); if (enable) { schedule_timeout_uninterruptible(msecs_to_jiffies(10)); /* config one-bit depop parameter */ - rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x307f); - snd_soc_update_bits(codec, RT5631_HP_OUT_VOL, + rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x307f); + snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL, RT5631_L_MUTE | RT5631_R_MUTE, 0); msleep(300); } else { - snd_soc_update_bits(codec, RT5631_HP_OUT_VOL, + snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL, RT5631_L_MUTE | RT5631_R_MUTE, RT5631_L_MUTE | RT5631_R_MUTE); msleep(100); } /* recover soft volume and zero crossing setting */ - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); } /** @@ -443,70 +443,70 @@ static void onebit_depop_mute_stage(struct snd_soc_codec *codec, int enable) * * When power on/off headphone, the depop sequence is done in step by step. */ -static void depop_seq_power_stage(struct snd_soc_codec *codec, int enable) +static void depop_seq_power_stage(struct snd_soc_component *component, int enable) { unsigned int soft_vol, hp_zc; /* depop control by register */ - snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2, + snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2, RT5631_EN_ONE_BIT_DEPOP, RT5631_EN_ONE_BIT_DEPOP); /* keep soft volume and zero crossing setting */ - soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL); - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0); - hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); if (enable) { /* config depop sequence parameter */ - rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x303e); + rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x303e); /* power on headphone and charge pump */ - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_CHARGE_PUMP | RT5631_PWR_HP_L_AMP | RT5631_PWR_HP_R_AMP, RT5631_PWR_CHARGE_PUMP | RT5631_PWR_HP_L_AMP | RT5631_PWR_HP_R_AMP); /* power on soft generator and depop mode2 */ - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN | RT5631_EN_DEPOP2_FOR_HP); msleep(100); /* stop depop mode */ - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_HP_DEPOP_DIS, RT5631_PWR_HP_DEPOP_DIS); } else { /* config depop sequence parameter */ - rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x303F); - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x303F); + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN | RT5631_EN_MUTE_UNMUTE_DEPOP | RT5631_PD_HPAMP_L_ST_UP | RT5631_PD_HPAMP_R_ST_UP); msleep(75); - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN | RT5631_PD_HPAMP_L_ST_UP | RT5631_PD_HPAMP_R_ST_UP); /* start depop mode */ - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_HP_DEPOP_DIS, 0); /* config depop sequence parameter */ - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN | RT5631_EN_DEPOP2_FOR_HP | RT5631_PD_HPAMP_L_ST_UP | RT5631_PD_HPAMP_R_ST_UP); msleep(80); - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN); /* power down headphone and charge pump */ - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_CHARGE_PUMP | RT5631_PWR_HP_L_AMP | RT5631_PWR_HP_R_AMP, 0); } /* recover soft volume and zero crossing setting */ - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); } /** @@ -515,75 +515,75 @@ static void depop_seq_power_stage(struct snd_soc_codec *codec, int enable) * * When mute/unmute headphone, the depop sequence is done in step by step. */ -static void depop_seq_mute_stage(struct snd_soc_codec *codec, int enable) +static void depop_seq_mute_stage(struct snd_soc_component *component, int enable) { unsigned int soft_vol, hp_zc; /* depop control by register */ - snd_soc_update_bits(codec, RT5631_DEPOP_FUN_CTRL_2, + snd_soc_component_update_bits(component, RT5631_DEPOP_FUN_CTRL_2, RT5631_EN_ONE_BIT_DEPOP, RT5631_EN_ONE_BIT_DEPOP); /* keep soft volume and zero crossing setting */ - soft_vol = snd_soc_read(codec, RT5631_SOFT_VOL_CTRL); - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, 0); - hp_zc = snd_soc_read(codec, RT5631_INT_ST_IRQ_CTRL_2); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); + soft_vol = snd_soc_component_read32(component, RT5631_SOFT_VOL_CTRL); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, 0); + hp_zc = snd_soc_component_read32(component, RT5631_INT_ST_IRQ_CTRL_2); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc & 0xf7ff); if (enable) { schedule_timeout_uninterruptible(msecs_to_jiffies(10)); /* config depop sequence parameter */ - rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x302f); - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x302f); + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN | RT5631_EN_MUTE_UNMUTE_DEPOP | RT5631_EN_HP_R_M_UN_MUTE_DEPOP | RT5631_EN_HP_L_M_UN_MUTE_DEPOP); - snd_soc_update_bits(codec, RT5631_HP_OUT_VOL, + snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL, RT5631_L_MUTE | RT5631_R_MUTE, 0); msleep(160); } else { /* config depop sequence parameter */ - rt5631_write_index(codec, RT5631_SPK_INTL_CTRL, 0x302f); - snd_soc_write(codec, RT5631_DEPOP_FUN_CTRL_1, + rt5631_write_index(component, RT5631_SPK_INTL_CTRL, 0x302f); + snd_soc_component_write(component, RT5631_DEPOP_FUN_CTRL_1, RT5631_POW_ON_SOFT_GEN | RT5631_EN_MUTE_UNMUTE_DEPOP | RT5631_EN_HP_R_M_UN_MUTE_DEPOP | RT5631_EN_HP_L_M_UN_MUTE_DEPOP); - snd_soc_update_bits(codec, RT5631_HP_OUT_VOL, + snd_soc_component_update_bits(component, RT5631_HP_OUT_VOL, RT5631_L_MUTE | RT5631_R_MUTE, RT5631_L_MUTE | RT5631_R_MUTE); msleep(150); } /* recover soft volume and zero crossing setting */ - snd_soc_write(codec, RT5631_SOFT_VOL_CTRL, soft_vol); - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); + snd_soc_component_write(component, RT5631_SOFT_VOL_CTRL, soft_vol); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, hp_zc); } static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMD: if (rt5631->codec_version) { - onebit_depop_mute_stage(codec, 0); - onebit_depop_power_stage(codec, 0); + onebit_depop_mute_stage(component, 0); + onebit_depop_power_stage(component, 0); } else { - depop_seq_mute_stage(codec, 0); - depop_seq_power_stage(codec, 0); + depop_seq_mute_stage(component, 0); + depop_seq_power_stage(component, 0); } break; case SND_SOC_DAPM_POST_PMU: if (rt5631->codec_version) { - onebit_depop_power_stage(codec, 1); - onebit_depop_mute_stage(codec, 1); + onebit_depop_power_stage(component, 1); + onebit_depop_mute_stage(component, 1); } else { - depop_seq_power_stage(codec, 1); - depop_seq_mute_stage(codec, 1); + depop_seq_power_stage(component, 1); + depop_seq_mute_stage(component, 1); } break; @@ -597,20 +597,20 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int set_dmic_params(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); switch (rt5631->rx_rate) { case 44100: case 48000: - snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL, + snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL, RT5631_DMIC_CLK_CTRL_MASK, RT5631_DMIC_CLK_CTRL_TO_32FS); break; case 32000: case 22050: - snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL, + snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL, RT5631_DMIC_CLK_CTRL_MASK, RT5631_DMIC_CLK_CTRL_TO_64FS); break; @@ -618,7 +618,7 @@ static int set_dmic_params(struct snd_soc_dapm_widget *w, case 16000: case 11025: case 8000: - snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL, + snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL, RT5631_DMIC_CLK_CTRL_MASK, RT5631_DMIC_CLK_CTRL_TO_128FS); break; @@ -1352,16 +1352,16 @@ static int get_coeff(int mclk, int rate, int timesofbclk) static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); int timesofbclk = 32, coeff; unsigned int iface = 0; - dev_dbg(codec->dev, "enter %s\n", __func__); + dev_dbg(component->dev, "enter %s\n", __func__); rt5631->bclk_rate = snd_soc_params_to_bclk(params); if (rt5631->bclk_rate < 0) { - dev_err(codec->dev, "Fail to get BCLK rate\n"); + dev_err(component->dev, "Fail to get BCLK rate\n"); return rt5631->bclk_rate; } rt5631->rx_rate = params_rate(params); @@ -1373,7 +1373,7 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream, coeff = get_coeff(rt5631->sysclk, rt5631->rx_rate, timesofbclk); if (coeff < 0) { - dev_err(codec->dev, "Fail to get coeff\n"); + dev_err(component->dev, "Fail to get coeff\n"); return coeff; } @@ -1393,9 +1393,9 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, RT5631_SDP_CTRL, + snd_soc_component_update_bits(component, RT5631_SDP_CTRL, RT5631_SDP_I2S_DL_MASK, iface); - snd_soc_write(codec, RT5631_STEREO_AD_DA_CLK_CTRL, + snd_soc_component_write(component, RT5631_STEREO_AD_DA_CLK_CTRL, coeff_div[coeff].reg_val); return 0; @@ -1404,11 +1404,11 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream, static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); unsigned int iface = 0; - dev_dbg(codec->dev, "enter %s\n", __func__); + dev_dbg(component->dev, "enter %s\n", __func__); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -1448,7 +1448,7 @@ static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_write(codec, RT5631_SDP_CTRL, iface); + snd_soc_component_write(component, RT5631_SDP_CTRL, iface); return 0; } @@ -1456,10 +1456,10 @@ static int rt5631_hifi_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "enter %s, syclk=%d\n", __func__, freq); + dev_dbg(component->dev, "enter %s, syclk=%d\n", __func__, freq); if ((freq >= (256 * 8000)) && (freq <= (512 * 96000))) { rt5631->sysclk = freq; @@ -1472,16 +1472,16 @@ static int rt5631_hifi_codec_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); int i, ret = -EINVAL; - dev_dbg(codec->dev, "enter %s\n", __func__); + dev_dbg(component->dev, "enter %s\n", __func__); if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); - snd_soc_update_bits(codec, RT5631_GLOBAL_CLK_CTRL, + snd_soc_component_update_bits(component, RT5631_GLOBAL_CLK_CTRL, RT5631_SYSCLK_SOUR_SEL_MASK, RT5631_SYSCLK_SOUR_SEL_MCLK); @@ -1492,13 +1492,13 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, for (i = 0; i < ARRAY_SIZE(codec_master_pll_div); i++) if (freq_in == codec_master_pll_div[i].pll_in && freq_out == codec_master_pll_div[i].pll_out) { - dev_info(codec->dev, + dev_info(component->dev, "change PLL in master mode\n"); - snd_soc_write(codec, RT5631_PLL_CTRL, + snd_soc_component_write(component, RT5631_PLL_CTRL, codec_master_pll_div[i].reg_val); schedule_timeout_uninterruptible( msecs_to_jiffies(20)); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT5631_GLOBAL_CLK_CTRL, RT5631_SYSCLK_SOUR_SEL_MASK | RT5631_PLLCLK_SOUR_SEL_MASK, @@ -1511,13 +1511,13 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, for (i = 0; i < ARRAY_SIZE(codec_slave_pll_div); i++) if (freq_in == codec_slave_pll_div[i].pll_in && freq_out == codec_slave_pll_div[i].pll_out) { - dev_info(codec->dev, + dev_info(component->dev, "change PLL in slave mode\n"); - snd_soc_write(codec, RT5631_PLL_CTRL, + snd_soc_component_write(component, RT5631_PLL_CTRL, codec_slave_pll_div[i].reg_val); schedule_timeout_uninterruptible( msecs_to_jiffies(20)); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT5631_GLOBAL_CLK_CTRL, RT5631_SYSCLK_SOUR_SEL_MASK | RT5631_PLLCLK_SOUR_SEL_MASK, @@ -1531,26 +1531,26 @@ static int rt5631_codec_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, return ret; } -static int rt5631_set_bias_level(struct snd_soc_codec *codec, +static int rt5631_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD2, RT5631_PWR_MICBIAS1_VOL | RT5631_PWR_MICBIAS2_VOL, RT5631_PWR_MICBIAS1_VOL | RT5631_PWR_MICBIAS2_VOL); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS, RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS); msleep(80); - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_FAST_VREF_CTRL, RT5631_PWR_FAST_VREF_CTRL); regcache_cache_only(rt5631->regmap, false); @@ -1559,10 +1559,10 @@ static int rt5631_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, RT5631_PWR_MANAG_ADD1, 0x0000); - snd_soc_write(codec, RT5631_PWR_MANAG_ADD2, 0x0000); - snd_soc_write(codec, RT5631_PWR_MANAG_ADD3, 0x0000); - snd_soc_write(codec, RT5631_PWR_MANAG_ADD4, 0x0000); + snd_soc_component_write(component, RT5631_PWR_MANAG_ADD1, 0x0000); + snd_soc_component_write(component, RT5631_PWR_MANAG_ADD2, 0x0000); + snd_soc_component_write(component, RT5631_PWR_MANAG_ADD3, 0x0000); + snd_soc_component_write(component, RT5631_PWR_MANAG_ADD4, 0x0000); break; default: @@ -1572,48 +1572,48 @@ static int rt5631_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5631_probe(struct snd_soc_codec *codec) +static int rt5631_probe(struct snd_soc_component *component) { - struct rt5631_priv *rt5631 = snd_soc_codec_get_drvdata(codec); + struct rt5631_priv *rt5631 = snd_soc_component_get_drvdata(component); unsigned int val; - val = rt5631_read_index(codec, RT5631_ADDA_MIXER_INTL_REG3); + val = rt5631_read_index(component, RT5631_ADDA_MIXER_INTL_REG3); if (val & 0x0002) rt5631->codec_version = 1; else rt5631->codec_version = 0; - rt5631_reset(codec); - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + rt5631_reset(component); + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS, RT5631_PWR_VREF | RT5631_PWR_MAIN_BIAS); msleep(80); - snd_soc_update_bits(codec, RT5631_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, RT5631_PWR_MANAG_ADD3, RT5631_PWR_FAST_VREF_CTRL, RT5631_PWR_FAST_VREF_CTRL); /* enable HP zero cross */ - snd_soc_write(codec, RT5631_INT_ST_IRQ_CTRL_2, 0x0f18); + snd_soc_component_write(component, RT5631_INT_ST_IRQ_CTRL_2, 0x0f18); /* power off ClassD auto Recovery */ if (rt5631->codec_version) - snd_soc_update_bits(codec, RT5631_INT_ST_IRQ_CTRL_2, + snd_soc_component_update_bits(component, RT5631_INT_ST_IRQ_CTRL_2, 0x2000, 0x2000); else - snd_soc_update_bits(codec, RT5631_INT_ST_IRQ_CTRL_2, + snd_soc_component_update_bits(component, RT5631_INT_ST_IRQ_CTRL_2, 0x2000, 0); /* DMIC */ if (rt5631->dmic_used_flag) { - snd_soc_update_bits(codec, RT5631_GPIO_CTRL, + snd_soc_component_update_bits(component, RT5631_GPIO_CTRL, RT5631_GPIO_PIN_FUN_SEL_MASK | RT5631_GPIO_DMIC_FUN_SEL_MASK, RT5631_GPIO_PIN_FUN_SEL_GPIO_DIMC | RT5631_GPIO_DMIC_FUN_SEL_DIMC); - snd_soc_update_bits(codec, RT5631_DIG_MIC_CTRL, + snd_soc_component_update_bits(component, RT5631_DIG_MIC_CTRL, RT5631_DMIC_L_CH_LATCH_MASK | RT5631_DMIC_R_CH_LATCH_MASK, RT5631_DMIC_L_CH_LATCH_FALLING | RT5631_DMIC_R_CH_LATCH_RISING); } - snd_soc_codec_init_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_init_bias_level(component, SND_SOC_BIAS_STANDBY); return 0; } @@ -1653,18 +1653,20 @@ static struct snd_soc_dai_driver rt5631_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5631 = { - .probe = rt5631_probe, - .set_bias_level = rt5631_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = rt5631_snd_controls, - .num_controls = ARRAY_SIZE(rt5631_snd_controls), - .dapm_widgets = rt5631_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5631_dapm_widgets), - .dapm_routes = rt5631_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5631_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5631 = { + .probe = rt5631_probe, + .set_bias_level = rt5631_set_bias_level, + .controls = rt5631_snd_controls, + .num_controls = ARRAY_SIZE(rt5631_snd_controls), + .dapm_widgets = rt5631_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5631_dapm_widgets), + .dapm_routes = rt5631_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5631_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct i2c_device_id rt5631_i2c_id[] = { @@ -1712,14 +1714,14 @@ static int rt5631_i2c_probe(struct i2c_client *i2c, if (IS_ERR(rt5631->regmap)) return PTR_ERR(rt5631->regmap); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5631, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5631, rt5631_dai, ARRAY_SIZE(rt5631_dai)); return ret; } static int rt5631_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From fab70c273d75102a3f2593730b49d94ed3f87cff Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:49:03 +0000 Subject: [PATCH 075/942] ASoC: rt5665: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5665.c | 345 +++++++++++++++++++------------------- sound/soc/codecs/rt5665.h | 2 +- 2 files changed, 169 insertions(+), 178 deletions(-) diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index f05d362c4e23..819df1a32dd4 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -44,7 +44,7 @@ static const char *rt5665_supply_names[RT5665_NUM_SUPPLIES] = { }; struct rt5665_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5665_platform_data pdata; struct regmap *regmap; struct gpio_desc *gpiod_ldo1_en; @@ -1000,13 +1000,13 @@ static const struct snd_kcontrol_new rt5665_if3_adc_swap_mux = static int rt5665_hp_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret = snd_soc_put_volsw(kcontrol, ucontrol); - if (snd_soc_read(codec, RT5665_STO_NG2_CTRL_1) & RT5665_NG2_EN) { - snd_soc_update_bits(codec, RT5665_STO_NG2_CTRL_1, + if (snd_soc_component_read32(component, RT5665_STO_NG2_CTRL_1) & RT5665_NG2_EN) { + snd_soc_component_update_bits(component, RT5665_STO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_DIS); - snd_soc_update_bits(codec, RT5665_STO_NG2_CTRL_1, + snd_soc_component_update_bits(component, RT5665_STO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_EN); } @@ -1016,13 +1016,13 @@ static int rt5665_hp_vol_put(struct snd_kcontrol *kcontrol, static int rt5665_mono_vol_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int ret = snd_soc_put_volsw(kcontrol, ucontrol); - if (snd_soc_read(codec, RT5665_MONO_NG2_CTRL_1) & RT5665_NG2_EN) { - snd_soc_update_bits(codec, RT5665_MONO_NG2_CTRL_1, + if (snd_soc_component_read32(component, RT5665_MONO_NG2_CTRL_1) & RT5665_NG2_EN) { + snd_soc_component_update_bits(component, RT5665_MONO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_DIS); - snd_soc_update_bits(codec, RT5665_MONO_NG2_CTRL_1, + snd_soc_component_update_bits(component, RT5665_MONO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_EN); } @@ -1031,7 +1031,7 @@ static int rt5665_mono_vol_put(struct snd_kcontrol *kcontrol, /** * rt5665_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -1043,7 +1043,7 @@ static int rt5665_mono_vol_put(struct snd_kcontrol *kcontrol, * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5665_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5665_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { unsigned int asrc2_mask = 0; @@ -1114,63 +1114,63 @@ int rt5665_sel_asrc_clk_src(struct snd_soc_codec *codec, } if (asrc2_mask) - snd_soc_update_bits(codec, RT5665_ASRC_2, + snd_soc_component_update_bits(component, RT5665_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5665_ASRC_3, + snd_soc_component_update_bits(component, RT5665_ASRC_3, asrc3_mask, asrc3_value); return 0; } EXPORT_SYMBOL_GPL(rt5665_sel_asrc_clk_src); -static int rt5665_button_detect(struct snd_soc_codec *codec) +static int rt5665_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5665_4BTN_IL_CMD_1); + val = snd_soc_component_read32(component, RT5665_4BTN_IL_CMD_1); btn_type = val & 0xfff0; - snd_soc_write(codec, RT5665_4BTN_IL_CMD_1, val); + snd_soc_component_write(component, RT5665_4BTN_IL_CMD_1, val); return btn_type; } -static void rt5665_enable_push_button_irq(struct snd_soc_codec *codec, +static void rt5665_enable_push_button_irq(struct snd_soc_component *component, bool enable) { if (enable) { - snd_soc_write(codec, RT5665_4BTN_IL_CMD_1, 0x0003); - snd_soc_update_bits(codec, RT5665_SAR_IL_CMD_9, 0x1, 0x1); - snd_soc_write(codec, RT5665_IL_CMD_1, 0x0048); - snd_soc_update_bits(codec, RT5665_4BTN_IL_CMD_2, + snd_soc_component_write(component, RT5665_4BTN_IL_CMD_1, 0x0003); + snd_soc_component_update_bits(component, RT5665_SAR_IL_CMD_9, 0x1, 0x1); + snd_soc_component_write(component, RT5665_IL_CMD_1, 0x0048); + snd_soc_component_update_bits(component, RT5665_4BTN_IL_CMD_2, RT5665_4BTN_IL_MASK | RT5665_4BTN_IL_RST_MASK, RT5665_4BTN_IL_EN | RT5665_4BTN_IL_NOR); - snd_soc_update_bits(codec, RT5665_IRQ_CTRL_3, + snd_soc_component_update_bits(component, RT5665_IRQ_CTRL_3, RT5665_IL_IRQ_MASK, RT5665_IL_IRQ_EN); } else { - snd_soc_update_bits(codec, RT5665_IRQ_CTRL_3, + snd_soc_component_update_bits(component, RT5665_IRQ_CTRL_3, RT5665_IL_IRQ_MASK, RT5665_IL_IRQ_DIS); - snd_soc_update_bits(codec, RT5665_4BTN_IL_CMD_2, + snd_soc_component_update_bits(component, RT5665_4BTN_IL_CMD_2, RT5665_4BTN_IL_MASK, RT5665_4BTN_IL_DIS); - snd_soc_update_bits(codec, RT5665_4BTN_IL_CMD_2, + snd_soc_component_update_bits(component, RT5665_4BTN_IL_CMD_2, RT5665_4BTN_IL_RST_MASK, RT5665_4BTN_IL_RST); } } /** * rt5665_headset_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. * * Returns detect status. */ -static int rt5665_headset_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5665_headset_detect(struct snd_soc_component *component, int jack_insert) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); unsigned int sar_hs_type, val; if (jack_insert) { @@ -1201,7 +1201,7 @@ static int rt5665_headset_detect(struct snd_soc_codec *codec, int jack_insert) usleep_range(10000, 15000); - rt5665->sar_adc_value = snd_soc_read(rt5665->codec, + rt5665->sar_adc_value = snd_soc_component_read32(rt5665->component, RT5665_SAR_IL_CMD_4) & 0x7ff; sar_hs_type = rt5665->pdata.sar_hs_type ? @@ -1209,7 +1209,7 @@ static int rt5665_headset_detect(struct snd_soc_codec *codec, int jack_insert) if (rt5665->sar_adc_value > sar_hs_type) { rt5665->jack_type = SND_JACK_HEADSET; - rt5665_enable_push_button_irq(codec, true); + rt5665_enable_push_button_irq(component, true); } else { rt5665->jack_type = SND_JACK_HEADPHONE; regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, @@ -1225,11 +1225,11 @@ static int rt5665_headset_detect(struct snd_soc_codec *codec, int jack_insert) snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); snd_soc_dapm_sync(dapm); if (rt5665->jack_type == SND_JACK_HEADSET) - rt5665_enable_push_button_irq(codec, false); + rt5665_enable_push_button_irq(component, false); rt5665->jack_type = 0; } - dev_dbg(codec->dev, "jack_type = %d\n", rt5665->jack_type); + dev_dbg(component->dev, "jack_type = %d\n", rt5665->jack_type); return rt5665->jack_type; } @@ -1248,9 +1248,9 @@ static void rt5665_jd_check_handler(struct work_struct *work) struct rt5665_priv *rt5665 = container_of(work, struct rt5665_priv, jd_check_work.work); - if (snd_soc_read(rt5665->codec, RT5665_AJD1_CTRL) & 0x0010) { + if (snd_soc_component_read32(rt5665->component, RT5665_AJD1_CTRL) & 0x0010) { /* jack out */ - rt5665->jack_type = rt5665_headset_detect(rt5665->codec, 0); + rt5665->jack_type = rt5665_headset_detect(rt5665->component, 0); snd_soc_jack_report(rt5665->hs_jack, rt5665->jack_type, SND_JACK_HEADSET | @@ -1261,10 +1261,10 @@ static void rt5665_jd_check_handler(struct work_struct *work) } } -static int rt5665_set_jack_detect(struct snd_soc_codec *codec, +static int rt5665_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack, void *data) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); switch (rt5665->pdata.jd_src) { case RT5665_JD1: @@ -1281,7 +1281,7 @@ static int rt5665_set_jack_detect(struct snd_soc_codec *codec, break; default: - dev_warn(codec->dev, "Wrong JD source\n"); + dev_warn(component->dev, "Wrong JD source\n"); break; } @@ -1296,12 +1296,12 @@ static void rt5665_jack_detect_handler(struct work_struct *work) container_of(work, struct rt5665_priv, jack_detect_work.work); int val, btn_type; - while (!rt5665->codec) { + while (!rt5665->component) { pr_debug("%s codec = null\n", __func__); usleep_range(10000, 15000); } - while (!rt5665->codec->component.card->instantiated) { + while (!rt5665->component->card->instantiated) { pr_debug("%s\n", __func__); usleep_range(10000, 15000); } @@ -1313,17 +1313,17 @@ static void rt5665_jack_detect_handler(struct work_struct *work) mutex_lock(&rt5665->calibrate_mutex); - val = snd_soc_read(rt5665->codec, RT5665_AJD1_CTRL) & 0x0010; + val = snd_soc_component_read32(rt5665->component, RT5665_AJD1_CTRL) & 0x0010; if (!val) { /* jack in */ if (rt5665->jack_type == 0) { /* jack was out, report jack type */ rt5665->jack_type = - rt5665_headset_detect(rt5665->codec, 1); + rt5665_headset_detect(rt5665->component, 1); } else { /* jack is already in, report button event */ rt5665->jack_type = SND_JACK_HEADSET; - btn_type = rt5665_button_detect(rt5665->codec); + btn_type = rt5665_button_detect(rt5665->component); /** * rt5665 can report three kinds of button behavior, * one click, double click and hold. However, @@ -1356,7 +1356,7 @@ static void rt5665_jack_detect_handler(struct work_struct *work) break; default: btn_type = 0; - dev_err(rt5665->codec->dev, + dev_err(rt5665->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -1364,7 +1364,7 @@ static void rt5665_jack_detect_handler(struct work_struct *work) } } else { /* jack out */ - rt5665->jack_type = rt5665_headset_detect(rt5665->codec, 0); + rt5665->jack_type = rt5665_headset_detect(rt5665->component, 0); } snd_soc_jack_report(rt5665->hs_jack, rt5665->jack_type, @@ -1479,8 +1479,8 @@ static const struct snd_kcontrol_new rt5665_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); int pd, idx = -EINVAL; pd = rl6231_get_pre_div(rt5665->regmap, @@ -1488,9 +1488,9 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, idx = rl6231_calc_dmic_clk(rt5665->sysclk / pd); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else { - snd_soc_update_bits(codec, RT5665_DMIC_CTRL_1, + snd_soc_component_update_bits(component, RT5665_DMIC_CTRL_1, RT5665_DMIC_CLK_MASK, idx << RT5665_DMIC_CLK_SFT); } return idx; @@ -1499,16 +1499,16 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int rt5665_charge_pump_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5665_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5665_HP_CHARGE_PUMP_1, RT5665_PM_HP_MASK | RT5665_OSW_L_MASK, RT5665_PM_HP_HV | RT5665_OSW_L_EN); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, RT5665_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5665_HP_CHARGE_PUMP_1, RT5665_PM_HP_MASK | RT5665_OSW_L_MASK, RT5665_PM_HP_LV | RT5665_OSW_L_DIS); break; @@ -1523,9 +1523,9 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - val = snd_soc_read(codec, RT5665_GLB_CLK); + val = snd_soc_component_read32(component, RT5665_GLB_CLK); val &= RT5665_SCLK_SRC_MASK; if (val == RT5665_SCLK_SRC_PLL1) return 1; @@ -1537,7 +1537,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int reg, shift, val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (w->shift) { case RT5665_ADC_MONO_R_ASRC_SFT: @@ -1576,13 +1576,13 @@ static int is_using_asrc(struct snd_soc_dapm_widget *w, return 0; } - val = (snd_soc_read(codec, reg) >> shift) & 0xf; + val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; switch (val) { case RT5665_CLK_SEL_I2S1_ASRC: case RT5665_CLK_SEL_I2S2_ASRC: case RT5665_CLK_SEL_I2S3_ASRC: /* I2S_Pre_Div1 should be 1 in asrc mode */ - snd_soc_update_bits(codec, RT5665_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5665_ADDA_CLK_1, RT5665_I2S_PD1_MASK, RT5665_I2S_PD1_2); return 1; default: @@ -2474,24 +2474,24 @@ static const struct snd_kcontrol_new pdm_r_switch = static int rt5665_mono_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5665_MONO_NG2_CTRL_1, + snd_soc_component_update_bits(component, RT5665_MONO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_EN); - snd_soc_update_bits(codec, RT5665_MONO_AMP_CALIB_CTRL_1, 0x40, + snd_soc_component_update_bits(component, RT5665_MONO_AMP_CALIB_CTRL_1, 0x40, 0x0); - snd_soc_update_bits(codec, RT5665_MONO_OUT, 0x10, 0x10); - snd_soc_update_bits(codec, RT5665_MONO_OUT, 0x20, 0x20); + snd_soc_component_update_bits(component, RT5665_MONO_OUT, 0x10, 0x10); + snd_soc_component_update_bits(component, RT5665_MONO_OUT, 0x20, 0x20); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, RT5665_MONO_OUT, 0x20, 0); - snd_soc_update_bits(codec, RT5665_MONO_OUT, 0x10, 0); - snd_soc_update_bits(codec, RT5665_MONO_AMP_CALIB_CTRL_1, 0x40, + snd_soc_component_update_bits(component, RT5665_MONO_OUT, 0x20, 0); + snd_soc_component_update_bits(component, RT5665_MONO_OUT, 0x10, 0); + snd_soc_component_update_bits(component, RT5665_MONO_AMP_CALIB_CTRL_1, 0x40, 0x40); - snd_soc_update_bits(codec, RT5665_MONO_NG2_CTRL_1, + snd_soc_component_update_bits(component, RT5665_MONO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_DIS); break; @@ -2506,18 +2506,18 @@ static int rt5665_mono_event(struct snd_soc_dapm_widget *w, static int rt5665_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5665_STO_NG2_CTRL_1, + snd_soc_component_update_bits(component, RT5665_STO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_EN); - snd_soc_write(codec, RT5665_HP_LOGIC_CTRL_2, 0x0003); + snd_soc_component_write(component, RT5665_HP_LOGIC_CTRL_2, 0x0003); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, RT5665_HP_LOGIC_CTRL_2, 0x0002); - snd_soc_update_bits(codec, RT5665_STO_NG2_CTRL_1, + snd_soc_component_write(component, RT5665_HP_LOGIC_CTRL_2, 0x0002); + snd_soc_component_update_bits(component, RT5665_STO_NG2_CTRL_1, RT5665_NG2_EN_MASK, RT5665_NG2_DIS); break; @@ -2532,16 +2532,16 @@ static int rt5665_hp_event(struct snd_soc_dapm_widget *w, static int rt5665_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5665_DEPOP_1, + snd_soc_component_update_bits(component, RT5665_DEPOP_1, RT5665_PUMP_EN, RT5665_PUMP_EN); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5665_DEPOP_1, + snd_soc_component_update_bits(component, RT5665_DEPOP_1, RT5665_PUMP_EN, 0); break; @@ -2572,23 +2572,23 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w, static int rt5655_set_verf(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: switch (w->shift) { case RT5665_PWR_VREF1_BIT: - snd_soc_update_bits(codec, RT5665_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5665_PWR_ANLG_1, RT5665_PWR_FV1, 0); break; case RT5665_PWR_VREF2_BIT: - snd_soc_update_bits(codec, RT5665_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5665_PWR_ANLG_1, RT5665_PWR_FV2, 0); break; case RT5665_PWR_VREF3_BIT: - snd_soc_update_bits(codec, RT5665_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5665_PWR_ANLG_1, RT5665_PWR_FV3, 0); break; @@ -2601,17 +2601,17 @@ static int rt5655_set_verf(struct snd_soc_dapm_widget *w, usleep_range(15000, 20000); switch (w->shift) { case RT5665_PWR_VREF1_BIT: - snd_soc_update_bits(codec, RT5665_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5665_PWR_ANLG_1, RT5665_PWR_FV1, RT5665_PWR_FV1); break; case RT5665_PWR_VREF2_BIT: - snd_soc_update_bits(codec, RT5665_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5665_PWR_ANLG_1, RT5665_PWR_FV2, RT5665_PWR_FV2); break; case RT5665_PWR_VREF3_BIT: - snd_soc_update_bits(codec, RT5665_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5665_PWR_ANLG_1, RT5665_PWR_FV3, RT5665_PWR_FV3); break; @@ -2630,7 +2630,7 @@ static int rt5655_set_verf(struct snd_soc_dapm_widget *w, static int rt5665_i2s_pin_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int val1, val2, mask1 = 0, mask2 = 0; switch (w->shift) { @@ -2660,18 +2660,18 @@ static int rt5665_i2s_pin_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: if (mask1) - snd_soc_update_bits(codec, RT5665_GPIO_CTRL_1, + snd_soc_component_update_bits(component, RT5665_GPIO_CTRL_1, mask1, val1); if (mask2) - snd_soc_update_bits(codec, RT5665_GPIO_CTRL_2, + snd_soc_component_update_bits(component, RT5665_GPIO_CTRL_2, mask2, val2); break; case SND_SOC_DAPM_POST_PMD: if (mask1) - snd_soc_update_bits(codec, RT5665_GPIO_CTRL_1, + snd_soc_component_update_bits(component, RT5665_GPIO_CTRL_1, mask1, 0); if (mask2) - snd_soc_update_bits(codec, RT5665_GPIO_CTRL_2, + snd_soc_component_update_bits(component, RT5665_GPIO_CTRL_2, mask2, 0); break; default: @@ -4052,7 +4052,7 @@ static const struct snd_soc_dapm_route rt5665_dapm_routes[] = { static int rt5665_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; if (rx_mask || tx_mask) @@ -4096,7 +4096,7 @@ static int rt5665_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return -EINVAL; } - snd_soc_update_bits(codec, RT5665_TDM_CTRL_1, + snd_soc_component_update_bits(component, RT5665_TDM_CTRL_1, RT5665_I2S1_MODE_MASK | RT5665_TDM_IN_CH_MASK | RT5665_TDM_OUT_CH_MASK | RT5665_TDM_IN_LEN_MASK | RT5665_TDM_OUT_LEN_MASK, val); @@ -4108,24 +4108,24 @@ static int rt5665_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int rt5665_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, reg_clk, mask_clk, val_bits = 0x0100; int pre_div, frame_size; rt5665->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5665->sysclk, rt5665->lrck[dai->id]); if (pre_div < 0) { - dev_warn(codec->dev, "Force using PLL"); - snd_soc_codec_set_pll(codec, 0, RT5665_PLL1_S_MCLK, + dev_warn(component->dev, "Force using PLL"); + snd_soc_component_set_pll(component, 0, RT5665_PLL1_S_MCLK, rt5665->sysclk, rt5665->lrck[dai->id] * 512); - snd_soc_codec_set_sysclk(codec, RT5665_SCLK_S_PLL1, 0, + snd_soc_component_set_sysclk(component, RT5665_SCLK_S_PLL1, 0, rt5665->lrck[dai->id] * 512, 0); pre_div = 1; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } @@ -4160,7 +4160,7 @@ static int rt5665_hw_params(struct snd_pcm_substream *substream, reg_clk = RT5665_ADDA_CLK_1; mask_clk = RT5665_I2S_PD1_MASK; val_clk = pre_div << RT5665_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5665_I2S1_SDP, + snd_soc_component_update_bits(component, RT5665_I2S1_SDP, RT5665_I2S_DL_MASK, val_len); break; case RT5665_AIF2_1: @@ -4168,48 +4168,48 @@ static int rt5665_hw_params(struct snd_pcm_substream *substream, reg_clk = RT5665_ADDA_CLK_2; mask_clk = RT5665_I2S_PD2_MASK; val_clk = pre_div << RT5665_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5665_I2S2_SDP, + snd_soc_component_update_bits(component, RT5665_I2S2_SDP, RT5665_I2S_DL_MASK, val_len); break; case RT5665_AIF3: reg_clk = RT5665_ADDA_CLK_2; mask_clk = RT5665_I2S_PD3_MASK; val_clk = pre_div << RT5665_I2S_PD3_SFT; - snd_soc_update_bits(codec, RT5665_I2S3_SDP, + snd_soc_component_update_bits(component, RT5665_I2S3_SDP, RT5665_I2S_DL_MASK, val_len); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } - snd_soc_update_bits(codec, reg_clk, mask_clk, val_clk); - snd_soc_update_bits(codec, RT5665_STO1_DAC_SIL_DET, 0x3700, val_bits); + snd_soc_component_update_bits(component, reg_clk, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5665_STO1_DAC_SIL_DET, 0x3700, val_bits); switch (rt5665->lrck[dai->id]) { case 192000: - snd_soc_update_bits(codec, RT5665_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5665_ADDA_CLK_1, RT5665_DAC_OSR_MASK | RT5665_ADC_OSR_MASK, RT5665_DAC_OSR_32 | RT5665_ADC_OSR_32); break; case 96000: - snd_soc_update_bits(codec, RT5665_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5665_ADDA_CLK_1, RT5665_DAC_OSR_MASK | RT5665_ADC_OSR_MASK, RT5665_DAC_OSR_64 | RT5665_ADC_OSR_64); break; default: - snd_soc_update_bits(codec, RT5665_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5665_ADDA_CLK_1, RT5665_DAC_OSR_MASK | RT5665_ADC_OSR_MASK, RT5665_DAC_OSR_128 | RT5665_ADC_OSR_128); break; } if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { - snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + snd_soc_component_update_bits(component, RT5665_I2S_M_CLK_CTRL_1, RT5665_I2S2_M_PD_MASK, pre_div << RT5665_I2S2_M_PD_SFT); } if (rt5665->master[RT5665_AIF3]) { - snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + snd_soc_component_update_bits(component, RT5665_I2S_M_CLK_CTRL_1, RT5665_I2S3_M_PD_MASK, pre_div << RT5665_I2S3_M_PD_SFT); } @@ -4218,8 +4218,8 @@ static int rt5665_hw_params(struct snd_pcm_substream *substream, static int rt5665_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -4263,32 +4263,32 @@ static int rt5665_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (dai->id) { case RT5665_AIF1_1: case RT5665_AIF1_2: - snd_soc_update_bits(codec, RT5665_I2S1_SDP, + snd_soc_component_update_bits(component, RT5665_I2S1_SDP, RT5665_I2S_MS_MASK | RT5665_I2S_BP_MASK | RT5665_I2S_DF_MASK, reg_val); break; case RT5665_AIF2_1: case RT5665_AIF2_2: - snd_soc_update_bits(codec, RT5665_I2S2_SDP, + snd_soc_component_update_bits(component, RT5665_I2S2_SDP, RT5665_I2S_MS_MASK | RT5665_I2S_BP_MASK | RT5665_I2S_DF_MASK, reg_val); break; case RT5665_AIF3: - snd_soc_update_bits(codec, RT5665_I2S3_SDP, + snd_soc_component_update_bits(component, RT5665_I2S3_SDP, RT5665_I2S_MS_MASK | RT5665_I2S_BP_MASK | RT5665_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } return 0; } -static int rt5665_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, +static int rt5665_set_component_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0, src = 0; if (freq == rt5665->sysclk && clk_id == rt5665->sysclk_src) @@ -4308,34 +4308,34 @@ static int rt5665_set_codec_sysclk(struct snd_soc_codec *codec, int clk_id, src = RT5665_CLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5665_GLB_CLK, + snd_soc_component_update_bits(component, RT5665_GLB_CLK, RT5665_SCLK_SRC_MASK, reg_val); if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { - snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + snd_soc_component_update_bits(component, RT5665_I2S_M_CLK_CTRL_1, RT5665_I2S2_SRC_MASK, src << RT5665_I2S2_SRC_SFT); } if (rt5665->master[RT5665_AIF3]) { - snd_soc_update_bits(codec, RT5665_I2S_M_CLK_CTRL_1, + snd_soc_component_update_bits(component, RT5665_I2S_M_CLK_CTRL_1, RT5665_I2S3_SRC_MASK, src << RT5665_I2S3_SRC_SFT); } rt5665->sysclk = freq; rt5665->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); + dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); return 0; } -static int rt5665_set_codec_pll(struct snd_soc_codec *codec, int pll_id, +static int rt5665_set_component_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -4344,50 +4344,50 @@ static int rt5665_set_codec_pll(struct snd_soc_codec *codec, int pll_id, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5665->pll_in = 0; rt5665->pll_out = 0; - snd_soc_update_bits(codec, RT5665_GLB_CLK, + snd_soc_component_update_bits(component, RT5665_GLB_CLK, RT5665_SCLK_SRC_MASK, RT5665_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5665_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5665_GLB_CLK, + snd_soc_component_update_bits(component, RT5665_GLB_CLK, RT5665_PLL1_SRC_MASK, RT5665_PLL1_SRC_MCLK); break; case RT5665_PLL1_S_BCLK1: - snd_soc_update_bits(codec, RT5665_GLB_CLK, + snd_soc_component_update_bits(component, RT5665_GLB_CLK, RT5665_PLL1_SRC_MASK, RT5665_PLL1_SRC_BCLK1); break; case RT5665_PLL1_S_BCLK2: - snd_soc_update_bits(codec, RT5665_GLB_CLK, + snd_soc_component_update_bits(component, RT5665_GLB_CLK, RT5665_PLL1_SRC_MASK, RT5665_PLL1_SRC_BCLK2); break; case RT5665_PLL1_S_BCLK3: - snd_soc_update_bits(codec, RT5665_GLB_CLK, + snd_soc_component_update_bits(component, RT5665_GLB_CLK, RT5665_PLL1_SRC_MASK, RT5665_PLL1_SRC_BCLK3); break; default: - dev_err(codec->dev, "Unknown PLL Source %d\n", source); + dev_err(component->dev, "Unknown PLL Source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5665_PLL_CTRL_1, + snd_soc_component_write(component, RT5665_PLL_CTRL_1, pll_code.n_code << RT5665_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5665_PLL_CTRL_2, + snd_soc_component_write(component, RT5665_PLL_CTRL_2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5665_PLL_M_SFT | pll_code.m_bp << RT5665_PLL_M_BP_SFT); @@ -4400,10 +4400,10 @@ static int rt5665_set_codec_pll(struct snd_soc_codec *codec, int pll_id, static int rt5665_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); rt5665->bclk[dai->id] = ratio; @@ -4411,12 +4411,12 @@ static int rt5665_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) switch (dai->id) { case RT5665_AIF2_1: case RT5665_AIF2_2: - snd_soc_update_bits(codec, RT5665_ADDA_CLK_2, + snd_soc_component_update_bits(component, RT5665_ADDA_CLK_2, RT5665_I2S_BCLK_MS2_MASK, RT5665_I2S_BCLK_MS2_64); break; case RT5665_AIF3: - snd_soc_update_bits(codec, RT5665_ADDA_CLK_2, + snd_soc_component_update_bits(component, RT5665_ADDA_CLK_2, RT5665_I2S_BCLK_MS3_MASK, RT5665_I2S_BCLK_MS3_64); break; @@ -4426,10 +4426,10 @@ static int rt5665_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) return 0; } -static int rt5665_set_bias_level(struct snd_soc_codec *codec, +static int rt5665_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: @@ -4459,39 +4459,37 @@ static int rt5665_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5665_probe(struct snd_soc_codec *codec) +static int rt5665_probe(struct snd_soc_component *component) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); - rt5665->codec = codec; + rt5665->component = component; schedule_delayed_work(&rt5665->calibrate_work, msecs_to_jiffies(100)); return 0; } -static int rt5665_remove(struct snd_soc_codec *codec) +static void rt5665_remove(struct snd_soc_component *component) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); regmap_write(rt5665->regmap, RT5665_RESET, 0); - - return 0; } #ifdef CONFIG_PM -static int rt5665_suspend(struct snd_soc_codec *codec) +static int rt5665_suspend(struct snd_soc_component *component) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5665->regmap, true); regcache_mark_dirty(rt5665->regmap); return 0; } -static int rt5665_resume(struct snd_soc_codec *codec) +static int rt5665_resume(struct snd_soc_component *component) { - struct rt5665_priv *rt5665 = snd_soc_codec_get_drvdata(codec); + struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5665->regmap, false); regcache_sync(rt5665->regmap); @@ -4605,24 +4603,24 @@ static struct snd_soc_dai_driver rt5665_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5665 = { - .probe = rt5665_probe, - .remove = rt5665_remove, - .suspend = rt5665_suspend, - .resume = rt5665_resume, - .set_bias_level = rt5665_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5665_snd_controls, - .num_controls = ARRAY_SIZE(rt5665_snd_controls), - .dapm_widgets = rt5665_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5665_dapm_widgets), - .dapm_routes = rt5665_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5665_dapm_routes), - }, - .set_sysclk = rt5665_set_codec_sysclk, - .set_pll = rt5665_set_codec_pll, - .set_jack = rt5665_set_jack_detect, +static const struct snd_soc_component_driver soc_component_dev_rt5665 = { + .probe = rt5665_probe, + .remove = rt5665_remove, + .suspend = rt5665_suspend, + .resume = rt5665_resume, + .set_bias_level = rt5665_set_bias_level, + .controls = rt5665_snd_controls, + .num_controls = ARRAY_SIZE(rt5665_snd_controls), + .dapm_widgets = rt5665_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5665_dapm_widgets), + .dapm_routes = rt5665_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5665_dapm_routes), + .set_sysclk = rt5665_set_component_sysclk, + .set_pll = rt5665_set_component_pll, + .set_jack = rt5665_set_jack_detect, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; @@ -4753,7 +4751,7 @@ static void rt5665_calibrate_handler(struct work_struct *work) struct rt5665_priv *rt5665 = container_of(work, struct rt5665_priv, calibrate_work.work); - while (!rt5665->codec->component.card->instantiated) { + while (!rt5665->component->card->instantiated) { pr_debug("%s\n", __func__); usleep_range(10000, 15000); } @@ -4941,17 +4939,11 @@ static int rt5665_i2c_probe(struct i2c_client *i2c, } - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5665, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5665, rt5665_dai, ARRAY_SIZE(rt5665_dai)); } -static int rt5665_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static void rt5665_i2c_shutdown(struct i2c_client *client) { struct rt5665_priv *rt5665 = i2c_get_clientdata(client); @@ -4986,7 +4978,6 @@ static struct i2c_driver rt5665_i2c_driver = { .acpi_match_table = ACPI_PTR(rt5665_acpi_match), }, .probe = rt5665_i2c_probe, - .remove = rt5665_i2c_remove, .shutdown = rt5665_i2c_shutdown, .id_table = rt5665_i2c_id, }; diff --git a/sound/soc/codecs/rt5665.h b/sound/soc/codecs/rt5665.h index 5ddebd6a4a1b..b528e416b592 100644 --- a/sound/soc/codecs/rt5665.h +++ b/sound/soc/codecs/rt5665.h @@ -2003,7 +2003,7 @@ enum { RT5665_CLK_SEL_SYS4, }; -int rt5665_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5665_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); #endif /* __RT5665_H__ */ From 70c9a803fbcc41cb323ae3bfda9f047eb5f73967 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:51:09 +0000 Subject: [PATCH 076/942] ASoC: cs4270: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs4270.c | 124 +++++++++++++++++--------------------- 1 file changed, 55 insertions(+), 69 deletions(-) diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 84f86745c30e..2a7a4168c072 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c @@ -254,8 +254,8 @@ static bool cs4270_reg_is_volatile(struct device *dev, unsigned int reg) static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); cs4270->mclk = freq; return 0; @@ -277,8 +277,8 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); /* set DAI format */ switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -287,7 +287,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK; break; default: - dev_err(codec->dev, "invalid dai format\n"); + dev_err(component->dev, "invalid dai format\n"); return -EINVAL; } @@ -301,7 +301,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai, break; default: /* all other modes are unsupported by the hardware */ - dev_err(codec->dev, "Unknown master/slave configuration\n"); + dev_err(component->dev, "Unknown master/slave configuration\n"); return -EINVAL; } @@ -326,8 +326,8 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int ret; unsigned int i; unsigned int rate; @@ -346,13 +346,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, if (i == NUM_MCLK_RATIOS) { /* We did not find a matching ratio */ - dev_err(codec->dev, "could not find matching ratio\n"); + dev_err(component->dev, "could not find matching ratio\n"); return -EINVAL; } /* Set the sample rate */ - reg = snd_soc_read(codec, CS4270_MODE); + reg = snd_soc_component_read32(component, CS4270_MODE); reg &= ~(CS4270_MODE_SPEED_MASK | CS4270_MODE_DIV_MASK); reg |= cs4270_mode_ratios[i].mclk; @@ -361,15 +361,15 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, else reg |= cs4270_mode_ratios[i].speed_mode; - ret = snd_soc_write(codec, CS4270_MODE, reg); + ret = snd_soc_component_write(component, CS4270_MODE, reg); if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); + dev_err(component->dev, "i2c write failed\n"); return ret; } /* Set the DAI format */ - reg = snd_soc_read(codec, CS4270_FORMAT); + reg = snd_soc_component_read32(component, CS4270_FORMAT); reg &= ~(CS4270_FORMAT_DAC_MASK | CS4270_FORMAT_ADC_MASK); switch (cs4270->mode) { @@ -380,13 +380,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ; break; default: - dev_err(codec->dev, "unknown dai format\n"); + dev_err(component->dev, "unknown dai format\n"); return -EINVAL; } - ret = snd_soc_write(codec, CS4270_FORMAT, reg); + ret = snd_soc_component_write(component, CS4270_FORMAT, reg); if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); + dev_err(component->dev, "i2c write failed\n"); return ret; } @@ -405,11 +405,11 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream, */ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int reg6; - reg6 = snd_soc_read(codec, CS4270_MUTE); + reg6 = snd_soc_component_read32(component, CS4270_MUTE); if (mute) reg6 |= CS4270_MUTE_DAC_A | CS4270_MUTE_DAC_B; @@ -418,7 +418,7 @@ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute) reg6 |= cs4270->manual_mute; } - return snd_soc_write(codec, CS4270_MUTE, reg6); + return snd_soc_component_write(component, CS4270_MUTE, reg6); } /** @@ -438,8 +438,8 @@ static int cs4270_dai_mute(struct snd_soc_dai *dai, int mute) static int cs4270_soc_put_mute(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int left = !ucontrol->value.integer.value[0]; int right = !ucontrol->value.integer.value[1]; @@ -501,9 +501,9 @@ static struct snd_soc_dai_driver cs4270_dai = { * This function is called when ASoC has all the pieces it needs to * instantiate a sound driver. */ -static int cs4270_probe(struct snd_soc_codec *codec) +static int cs4270_probe(struct snd_soc_component *component) { - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int ret; /* Disable auto-mute. This feature appears to be buggy. In some @@ -511,9 +511,9 @@ static int cs4270_probe(struct snd_soc_codec *codec) * this feature disabled by default. An application (e.g. alsactl) can * re-enabled it by using the controls. */ - ret = snd_soc_update_bits(codec, CS4270_MUTE, CS4270_MUTE_AUTO, 0); + ret = snd_soc_component_update_bits(component, CS4270_MUTE, CS4270_MUTE_AUTO, 0); if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); + dev_err(component->dev, "i2c write failed\n"); return ret; } @@ -522,10 +522,10 @@ static int cs4270_probe(struct snd_soc_codec *codec) * playback has started. An application (e.g. alsactl) can * re-enabled it by using the controls. */ - ret = snd_soc_update_bits(codec, CS4270_TRANS, + ret = snd_soc_component_update_bits(component, CS4270_TRANS, CS4270_TRANS_SOFT | CS4270_TRANS_ZERO, 0); if (ret < 0) { - dev_err(codec->dev, "i2c write failed\n"); + dev_err(component->dev, "i2c write failed\n"); return ret; } @@ -541,13 +541,11 @@ static int cs4270_probe(struct snd_soc_codec *codec) * * This function is the counterpart to cs4270_probe(). */ -static int cs4270_remove(struct snd_soc_codec *codec) +static void cs4270_remove(struct snd_soc_component *component) { - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(cs4270->supplies), cs4270->supplies); - - return 0; }; #ifdef CONFIG_PM @@ -561,16 +559,16 @@ static int cs4270_remove(struct snd_soc_codec *codec) * and all registers are written back to the hardware when resuming. */ -static int cs4270_soc_suspend(struct snd_soc_codec *codec) +static int cs4270_soc_suspend(struct snd_soc_component *component) { - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int reg, ret; - reg = snd_soc_read(codec, CS4270_PWRCTL) | CS4270_PWRCTL_PDN_ALL; + reg = snd_soc_component_read32(component, CS4270_PWRCTL) | CS4270_PWRCTL_PDN_ALL; if (reg < 0) return reg; - ret = snd_soc_write(codec, CS4270_PWRCTL, reg); + ret = snd_soc_component_write(component, CS4270_PWRCTL, reg); if (ret < 0) return ret; @@ -580,9 +578,9 @@ static int cs4270_soc_suspend(struct snd_soc_codec *codec) return 0; } -static int cs4270_soc_resume(struct snd_soc_codec *codec) +static int cs4270_soc_resume(struct snd_soc_component *component) { - struct cs4270_private *cs4270 = snd_soc_codec_get_drvdata(codec); + struct cs4270_private *cs4270 = snd_soc_component_get_drvdata(component); int reg, ret; ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies), @@ -598,10 +596,10 @@ static int cs4270_soc_resume(struct snd_soc_codec *codec) regcache_sync(cs4270->regmap); /* ... then disable the power-down bits */ - reg = snd_soc_read(codec, CS4270_PWRCTL); + reg = snd_soc_component_read32(component, CS4270_PWRCTL); reg &= ~CS4270_PWRCTL_PDN_ALL; - return snd_soc_write(codec, CS4270_PWRCTL, reg); + return snd_soc_component_write(component, CS4270_PWRCTL, reg); } #else #define cs4270_soc_suspend NULL @@ -611,20 +609,21 @@ static int cs4270_soc_resume(struct snd_soc_codec *codec) /* * ASoC codec driver structure */ -static const struct snd_soc_codec_driver soc_codec_device_cs4270 = { - .probe = cs4270_probe, - .remove = cs4270_remove, - .suspend = cs4270_soc_suspend, - .resume = cs4270_soc_resume, - - .component_driver = { - .controls = cs4270_snd_controls, - .num_controls = ARRAY_SIZE(cs4270_snd_controls), - .dapm_widgets = cs4270_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs4270_dapm_widgets), - .dapm_routes = cs4270_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(cs4270_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_device_cs4270 = { + .probe = cs4270_probe, + .remove = cs4270_remove, + .suspend = cs4270_soc_suspend, + .resume = cs4270_soc_resume, + .controls = cs4270_snd_controls, + .num_controls = ARRAY_SIZE(cs4270_snd_controls), + .dapm_widgets = cs4270_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs4270_dapm_widgets), + .dapm_routes = cs4270_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(cs4270_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* @@ -718,23 +717,11 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, i2c_set_clientdata(i2c_client, cs4270); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_device_cs4270, &cs4270_dai, 1); + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_device_cs4270, &cs4270_dai, 1); return ret; } -/** - * cs4270_i2c_remove - remove an I2C device - * @i2c_client: the I2C client object - * - * This function is the counterpart to cs4270_i2c_probe(). - */ -static int cs4270_i2c_remove(struct i2c_client *i2c_client) -{ - snd_soc_unregister_codec(&i2c_client->dev); - return 0; -} - /* * cs4270_id - I2C device IDs supported by this driver */ @@ -757,7 +744,6 @@ static struct i2c_driver cs4270_i2c_driver = { }, .id_table = cs4270_id, .probe = cs4270_i2c_probe, - .remove = cs4270_i2c_remove, }; module_i2c_driver(cs4270_i2c_driver); From 0ec65b677c255204d8a26efea400fd7a37771476 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:53:32 +0000 Subject: [PATCH 077/942] ASoC: cs4349: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs4349.c | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c index 0a749c79ef57..bee0e343723f 100644 --- a/sound/soc/codecs/cs4349.c +++ b/sound/soc/codecs/cs4349.c @@ -74,8 +74,8 @@ static bool cs4349_writeable_register(struct device *dev, unsigned int reg) static int cs4349_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4349_private *cs4349 = snd_soc_component_get_drvdata(component); unsigned int fmt; fmt = format & SND_SOC_DAIFMT_FORMAT_MASK; @@ -97,8 +97,8 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs4349_private *cs4349 = snd_soc_component_get_drvdata(component); int fmt, ret; cs4349->rate = params_rate(params); @@ -126,7 +126,7 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - ret = snd_soc_update_bits(codec, CS4349_MODE, DIF_MASK, + ret = snd_soc_component_update_bits(component, CS4349_MODE, DIF_MASK, MODE_FORMAT(fmt)); if (ret < 0) return ret; @@ -136,14 +136,14 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream, static int cs4349_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg; reg = 0; if (mute) reg = MUTE_AB_MASK; - return snd_soc_update_bits(codec, CS4349_MUTE, MUTE_AB_MASK, reg); + return snd_soc_component_update_bits(component, CS4349_MUTE, MUTE_AB_MASK, reg); } static DECLARE_TLV_DB_SCALE(dig_tlv, -12750, 50, 0); @@ -255,15 +255,17 @@ static struct snd_soc_dai_driver cs4349_dai = { .symmetric_rates = 1, }; -static const struct snd_soc_codec_driver soc_codec_dev_cs4349 = { - .component_driver = { - .controls = cs4349_snd_controls, - .num_controls = ARRAY_SIZE(cs4349_snd_controls), - .dapm_widgets = cs4349_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs4349_dapm_widgets), - .dapm_routes = cs4349_routes, - .num_dapm_routes = ARRAY_SIZE(cs4349_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_cs4349 = { + .controls = cs4349_snd_controls, + .num_controls = ARRAY_SIZE(cs4349_snd_controls), + .dapm_widgets = cs4349_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs4349_dapm_widgets), + .dapm_routes = cs4349_routes, + .num_dapm_routes = ARRAY_SIZE(cs4349_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config cs4349_regmap = { @@ -305,7 +307,8 @@ static int cs4349_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, cs4349); - return snd_soc_register_codec(&client->dev, &soc_codec_dev_cs4349, + return devm_snd_soc_register_component(&client->dev, + &soc_component_dev_cs4349, &cs4349_dai, 1); } @@ -313,8 +316,6 @@ static int cs4349_i2c_remove(struct i2c_client *client) { struct cs4349_private *cs4349 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - /* Hold down reset */ gpiod_set_value_cansleep(cs4349->reset_gpio, 0); From aebbf9cc42d6001dcf8872600e55df6e5bd3d406 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:53:51 +0000 Subject: [PATCH 078/942] ASoC: cs4265: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs4265.c | 98 ++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c index fd966bb851cb..275677de669f 100644 --- a/sound/soc/codecs/cs4265.c +++ b/sound/soc/codecs/cs4265.c @@ -322,12 +322,12 @@ static int cs4265_get_clk_index(int mclk, int rate) static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component); int i; if (clk_id != 0) { - dev_err(codec->dev, "Invalid clk_id %d\n", clk_id); + dev_err(component->dev, "Invalid clk_id %d\n", clk_id); return -EINVAL; } for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) { @@ -337,24 +337,24 @@ static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, } } cs4265->sysclk = 0; - dev_err(codec->dev, "Invalid freq parameter %d\n", freq); + dev_err(component->dev, "Invalid freq parameter %d\n", freq); return -EINVAL; } static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component); u8 iface = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, CS4265_ADC_CTL, + snd_soc_component_update_bits(component, CS4265_ADC_CTL, CS4265_ADC_MASTER, CS4265_ADC_MASTER); break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, CS4265_ADC_CTL, + snd_soc_component_update_bits(component, CS4265_ADC_CTL, CS4265_ADC_MASTER, 0); break; @@ -383,20 +383,20 @@ static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int cs4265_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) { - snd_soc_update_bits(codec, CS4265_DAC_CTL, + snd_soc_component_update_bits(component, CS4265_DAC_CTL, CS4265_DAC_CTL_MUTE, CS4265_DAC_CTL_MUTE); - snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, + snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, CS4265_SPDIF_CTL2_MUTE, CS4265_SPDIF_CTL2_MUTE); } else { - snd_soc_update_bits(codec, CS4265_DAC_CTL, + snd_soc_component_update_bits(component, CS4265_DAC_CTL, CS4265_DAC_CTL_MUTE, 0); - snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, + snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, CS4265_SPDIF_CTL2_MUTE, 0); } @@ -407,8 +407,8 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs4265_private *cs4265 = snd_soc_component_get_drvdata(component); int index; if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && @@ -418,45 +418,45 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); if (index >= 0) { - snd_soc_update_bits(codec, CS4265_ADC_CTL, + snd_soc_component_update_bits(component, CS4265_ADC_CTL, CS4265_ADC_FM, clk_map_table[index].fm_mode << 6); - snd_soc_update_bits(codec, CS4265_MCLK_FREQ, + snd_soc_component_update_bits(component, CS4265_MCLK_FREQ, CS4265_MCLK_FREQ_MASK, clk_map_table[index].mclkdiv << 4); } else { - dev_err(codec->dev, "can't get correct mclk\n"); + dev_err(component->dev, "can't get correct mclk\n"); return -EINVAL; } switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, CS4265_DAC_CTL, + snd_soc_component_update_bits(component, CS4265_DAC_CTL, CS4265_DAC_CTL_DIF, (1 << 4)); - snd_soc_update_bits(codec, CS4265_ADC_CTL, + snd_soc_component_update_bits(component, CS4265_ADC_CTL, CS4265_ADC_DIF, (1 << 4)); - snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, + snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, CS4265_SPDIF_CTL2_DIF, (1 << 6)); break; case SND_SOC_DAIFMT_RIGHT_J: if (params_width(params) == 16) { - snd_soc_update_bits(codec, CS4265_DAC_CTL, + snd_soc_component_update_bits(component, CS4265_DAC_CTL, CS4265_DAC_CTL_DIF, (2 << 4)); - snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, + snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, CS4265_SPDIF_CTL2_DIF, (2 << 6)); } else { - snd_soc_update_bits(codec, CS4265_DAC_CTL, + snd_soc_component_update_bits(component, CS4265_DAC_CTL, CS4265_DAC_CTL_DIF, (3 << 4)); - snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, + snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, CS4265_SPDIF_CTL2_DIF, (3 << 6)); } break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, CS4265_DAC_CTL, + snd_soc_component_update_bits(component, CS4265_DAC_CTL, CS4265_DAC_CTL_DIF, 0); - snd_soc_update_bits(codec, CS4265_ADC_CTL, + snd_soc_component_update_bits(component, CS4265_ADC_CTL, CS4265_ADC_DIF, 0); - snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, + snd_soc_component_update_bits(component, CS4265_SPDIF_CTL2, CS4265_SPDIF_CTL2_DIF, 0); break; @@ -466,23 +466,23 @@ static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, return 0; } -static int cs4265_set_bias_level(struct snd_soc_codec *codec, +static int cs4265_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, CS4265_PWRCTL, + snd_soc_component_update_bits(component, CS4265_PWRCTL, CS4265_PWRCTL_PDN, 0); break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, CS4265_PWRCTL, + snd_soc_component_update_bits(component, CS4265_PWRCTL, CS4265_PWRCTL_PDN, CS4265_PWRCTL_PDN); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, CS4265_PWRCTL, + snd_soc_component_update_bits(component, CS4265_PWRCTL, CS4265_PWRCTL_PDN, CS4265_PWRCTL_PDN); break; @@ -544,17 +544,18 @@ static struct snd_soc_dai_driver cs4265_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_cs4265 = { - .set_bias_level = cs4265_set_bias_level, - - .component_driver = { - .controls = cs4265_snd_controls, - .num_controls = ARRAY_SIZE(cs4265_snd_controls), - .dapm_widgets = cs4265_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets), - .dapm_routes = cs4265_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs4265_audio_map), - }, +static const struct snd_soc_component_driver soc_component_cs4265 = { + .set_bias_level = cs4265_set_bias_level, + .controls = cs4265_snd_controls, + .num_controls = ARRAY_SIZE(cs4265_snd_controls), + .dapm_widgets = cs4265_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets), + .dapm_routes = cs4265_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs4265_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config cs4265_regmap = { @@ -616,18 +617,12 @@ static int cs4265_i2c_probe(struct i2c_client *i2c_client, regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_cs4265, cs4265_dai, + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_cs4265, cs4265_dai, ARRAY_SIZE(cs4265_dai)); return ret; } -static int cs4265_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct of_device_id cs4265_of_match[] = { { .compatible = "cirrus,cs4265", }, { } @@ -647,7 +642,6 @@ static struct i2c_driver cs4265_i2c_driver = { }, .id_table = cs4265_id, .probe = cs4265_i2c_probe, - .remove = cs4265_i2c_remove, }; module_i2c_driver(cs4265_i2c_driver); From fa643703a8776cb8987843ea81c765fdf2419383 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:54:19 +0000 Subject: [PATCH 079/942] ASoC: cs35l32: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l32.c | 45 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/sound/soc/codecs/cs35l32.c b/sound/soc/codecs/cs35l32.c index bc3a72e4c4ed..4297058b6938 100644 --- a/sound/soc/codecs/cs35l32.c +++ b/sound/soc/codecs/cs35l32.c @@ -43,7 +43,7 @@ static const char *const cs35l32_supply_names[CS35L32_NUM_SUPPLIES] = { struct cs35l32_private { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regulator_bulk_data supplies[CS35L32_NUM_SUPPLIES]; struct cs35l32_platform_data pdata; struct gpio_desc *reset_gpio; @@ -154,16 +154,16 @@ static const struct snd_soc_dapm_route cs35l32_audio_map[] = { static int cs35l32_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, CS35L32_ADSP_CTL, + snd_soc_component_update_bits(component, CS35L32_ADSP_CTL, CS35L32_ADSP_MASTER_MASK, CS35L32_ADSP_MASTER_MASK); break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, CS35L32_ADSP_CTL, + snd_soc_component_update_bits(component, CS35L32_ADSP_CTL, CS35L32_ADSP_MASTER_MASK, 0); break; default: @@ -175,9 +175,9 @@ static int cs35l32_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int cs35l32_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - return snd_soc_update_bits(codec, CS35L32_PWRCTL2, + return snd_soc_component_update_bits(component, CS35L32_PWRCTL2, CS35L32_SDOUT_3ST, tristate << 3); } @@ -202,7 +202,7 @@ static struct snd_soc_dai_driver cs35l32_dai[] = { } }; -static int cs35l32_codec_set_sysclk(struct snd_soc_codec *codec, +static int cs35l32_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { unsigned int val; @@ -224,21 +224,22 @@ static int cs35l32_codec_set_sysclk(struct snd_soc_codec *codec, return -EINVAL; } - return snd_soc_update_bits(codec, CS35L32_CLK_CTL, + return snd_soc_component_update_bits(component, CS35L32_CLK_CTL, CS35L32_MCLK_DIV2_MASK | CS35L32_MCLK_RATIO_MASK, val); } -static const struct snd_soc_codec_driver soc_codec_dev_cs35l32 = { - .set_sysclk = cs35l32_codec_set_sysclk, - - .component_driver = { - .controls = cs35l32_snd_controls, - .num_controls = ARRAY_SIZE(cs35l32_snd_controls), - .dapm_widgets = cs35l32_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs35l32_dapm_widgets), - .dapm_routes = cs35l32_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs35l32_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_cs35l32 = { + .set_sysclk = cs35l32_component_set_sysclk, + .controls = cs35l32_snd_controls, + .num_controls = ARRAY_SIZE(cs35l32_snd_controls), + .dapm_widgets = cs35l32_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs35l32_dapm_widgets), + .dapm_routes = cs35l32_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs35l32_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* Current and threshold powerup sequence Pg37 in datasheet */ @@ -483,8 +484,8 @@ static int cs35l32_i2c_probe(struct i2c_client *i2c_client, /* Clear MCLK Error Bit since we don't have the clock yet */ ret = regmap_read(cs35l32->regmap, CS35L32_INT_STATUS_1, ®); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs35l32, cs35l32_dai, + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs35l32, cs35l32_dai, ARRAY_SIZE(cs35l32_dai)); if (ret < 0) goto err_disable; @@ -501,8 +502,6 @@ static int cs35l32_i2c_remove(struct i2c_client *i2c_client) { struct cs35l32_private *cs35l32 = i2c_get_clientdata(i2c_client); - snd_soc_unregister_codec(&i2c_client->dev); - /* Hold down reset */ gpiod_set_value_cansleep(cs35l32->reset_gpio, 0); From cefcf59421fe18d4b6491df635cda08518d32863 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:55:16 +0000 Subject: [PATCH 080/942] ASoC: cs35l33: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l33.c | 186 ++++++++++++++++++------------------- 1 file changed, 91 insertions(+), 95 deletions(-) diff --git a/sound/soc/codecs/cs35l33.c b/sound/soc/codecs/cs35l33.c index 854cf8f27605..668cd3754209 100644 --- a/sound/soc/codecs/cs35l33.c +++ b/sound/soc/codecs/cs35l33.c @@ -42,7 +42,7 @@ #define CS35L33_BOOT_DELAY 50 struct cs35l33_private { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct cs35l33_pdata pdata; struct regmap *regmap; struct gpio_desc *reset_gpio; @@ -201,8 +201,8 @@ static const struct snd_kcontrol_new cs35l33_snd_controls[] = { static int cs35l33_spkrdrv_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -211,15 +211,15 @@ static int cs35l33_spkrdrv_event(struct snd_soc_dapm_widget *w, priv->amp_cal = true; regmap_update_bits(priv->regmap, CS35L33_CLASSD_CTL, CS35L33_AMP_CAL, 0); - dev_dbg(codec->dev, "Amp calibration done\n"); + dev_dbg(component->dev, "Amp calibration done\n"); } - dev_dbg(codec->dev, "Amp turned on\n"); + dev_dbg(component->dev, "Amp turned on\n"); break; case SND_SOC_DAPM_POST_PMD: - dev_dbg(codec->dev, "Amp turned off\n"); + dev_dbg(component->dev, "Amp turned off\n"); break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); break; } @@ -229,8 +229,8 @@ static int cs35l33_spkrdrv_event(struct snd_soc_dapm_widget *w, static int cs35l33_sdin_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); unsigned int val; switch (event) { @@ -240,14 +240,14 @@ static int cs35l33_sdin_event(struct snd_soc_dapm_widget *w, val = priv->is_tdm_mode ? 0 : CS35L33_PDN_TDM; regmap_update_bits(priv->regmap, CS35L33_PWRCTL2, CS35L33_PDN_TDM, val); - dev_dbg(codec->dev, "BST turned on\n"); + dev_dbg(component->dev, "BST turned on\n"); break; case SND_SOC_DAPM_POST_PMU: - dev_dbg(codec->dev, "SDIN turned on\n"); + dev_dbg(component->dev, "SDIN turned on\n"); if (!priv->amp_cal) { regmap_update_bits(priv->regmap, CS35L33_CLASSD_CTL, CS35L33_AMP_CAL, CS35L33_AMP_CAL); - dev_dbg(codec->dev, "Amp calibration started\n"); + dev_dbg(component->dev, "Amp calibration started\n"); usleep_range(10000, 11000); } break; @@ -257,10 +257,10 @@ static int cs35l33_sdin_event(struct snd_soc_dapm_widget *w, usleep_range(4000, 4100); regmap_update_bits(priv->regmap, CS35L33_PWRCTL1, CS35L33_PDN_BST, CS35L33_PDN_BST); - dev_dbg(codec->dev, "BST and SDIN turned off\n"); + dev_dbg(component->dev, "BST and SDIN turned off\n"); break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); } @@ -270,8 +270,8 @@ static int cs35l33_sdin_event(struct snd_soc_dapm_widget *w, static int cs35l33_sdout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); unsigned int mask = CS35L33_SDOUT_3ST_I2S | CS35L33_PDN_TDM; unsigned int mask2 = CS35L33_SDOUT_3ST_TDM; unsigned int val, val2; @@ -289,15 +289,15 @@ static int cs35l33_sdout_event(struct snd_soc_dapm_widget *w, /* set sdout_3st_tdm */ val2 = CS35L33_SDOUT_3ST_TDM; } - dev_dbg(codec->dev, "SDOUT turned on\n"); + dev_dbg(component->dev, "SDOUT turned on\n"); break; case SND_SOC_DAPM_PRE_PMD: val = CS35L33_SDOUT_3ST_I2S | CS35L33_PDN_TDM; val2 = CS35L33_SDOUT_3ST_TDM; - dev_dbg(codec->dev, "SDOUT turned off\n"); + dev_dbg(component->dev, "SDOUT turned off\n"); break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); return 0; } @@ -360,11 +360,11 @@ static const struct snd_soc_dapm_route cs35l33_vp_vbst_mon_route[] = { {"VBSTMON", NULL, "MON"}, }; -static int cs35l33_set_bias_level(struct snd_soc_codec *codec, +static int cs35l33_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { unsigned int val; - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -441,19 +441,19 @@ static int cs35l33_get_mclk_coeff(int mclk, int srate) static int cs35l33_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: regmap_update_bits(priv->regmap, CS35L33_ADSP_CTL, CS35L33_MS_MASK, CS35L33_MS_MASK); - dev_dbg(codec->dev, "Audio port in master mode\n"); + dev_dbg(component->dev, "Audio port in master mode\n"); break; case SND_SOC_DAIFMT_CBS_CFS: regmap_update_bits(priv->regmap, CS35L33_ADSP_CTL, CS35L33_MS_MASK, 0); - dev_dbg(codec->dev, "Audio port in slave mode\n"); + dev_dbg(component->dev, "Audio port in slave mode\n"); break; default: return -EINVAL; @@ -466,11 +466,11 @@ static int cs35l33_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) * closely, it is dsp-a with fsync shifted left by half bclk */ priv->is_tdm_mode = true; - dev_dbg(codec->dev, "Audio port in TDM mode\n"); + dev_dbg(component->dev, "Audio port in TDM mode\n"); break; case SND_SOC_DAIFMT_I2S: priv->is_tdm_mode = false; - dev_dbg(codec->dev, "Audio port in I2S mode\n"); + dev_dbg(component->dev, "Audio port in I2S mode\n"); break; default: return -EINVAL; @@ -483,8 +483,8 @@ static int cs35l33_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); int sample_size = params_width(params); int coeff = cs35l33_get_mclk_coeff(priv->mclk_int, params_rate(params)); @@ -505,7 +505,7 @@ static int cs35l33_pcm_hw_params(struct snd_pcm_substream *substream, sample_size << CS35L33_AUDIN_RX_DEPTH_SHIFT); } - dev_dbg(codec->dev, "sample rate=%d, bits per sample=%d\n", + dev_dbg(component->dev, "sample rate=%d, bits per sample=%d\n", params_rate(params), params_width(params)); return 0; @@ -532,8 +532,8 @@ static int cs35l33_pcm_startup(struct snd_pcm_substream *substream, static int cs35l33_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); if (tristate) { regmap_update_bits(priv->regmap, CS35L33_PWRCTL2, @@ -553,9 +553,9 @@ static int cs35l33_set_tristate(struct snd_soc_dai *dai, int tristate) static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); unsigned int reg, bit_pos, i; int slot, slot_num; @@ -567,7 +567,7 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, if (slot >= 0) { regmap_update_bits(priv->regmap, CS35L33_RX_AUD, CS35L33_X_LOC, slot); - dev_dbg(codec->dev, "Audio starts from slots %d", slot); + dev_dbg(component->dev, "Audio starts from slots %d", slot); } /* @@ -593,7 +593,7 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, if (slot_num == 0) { regmap_update_bits(priv->regmap, CS35L33_TX_VMON, CS35L33_X_STATE | CS35L33_X_LOC, slot); - dev_dbg(codec->dev, "VMON enabled in slots %d-%d", + dev_dbg(component->dev, "VMON enabled in slots %d-%d", slot, slot + 1); } @@ -601,7 +601,7 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, if (slot_num == 3) { regmap_update_bits(priv->regmap, CS35L33_TX_IMON, CS35L33_X_STATE | CS35L33_X_LOC, slot); - dev_dbg(codec->dev, "IMON enabled in slots %d-%d", + dev_dbg(component->dev, "IMON enabled in slots %d-%d", slot, slot + 1); } @@ -611,7 +611,7 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, CS35L33_X_STATE | CS35L33_X_LOC, slot); snd_soc_dapm_add_routes(dapm, &cs35l33_vp_vbst_mon_route[0], 2); - dev_dbg(codec->dev, "VPMON enabled in slots %d", slot); + dev_dbg(component->dev, "VPMON enabled in slots %d", slot); } /* configure VBSTMON_TX_LOC */ @@ -620,7 +620,7 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, CS35L33_X_STATE | CS35L33_X_LOC, slot); snd_soc_dapm_add_routes(dapm, &cs35l33_vp_vbst_mon_route[2], 2); - dev_dbg(codec->dev, + dev_dbg(component->dev, "VBSTMON enabled in slots %d", slot); } @@ -638,10 +638,10 @@ static int cs35l33_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return 0; } -static int cs35l33_codec_set_sysclk(struct snd_soc_codec *codec, +static int cs35l33_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct cs35l33_private *cs35l33 = snd_soc_codec_get_drvdata(codec); + struct cs35l33_private *cs35l33 = snd_soc_component_get_drvdata(component); switch (freq) { case CS35L33_MCLK_5644: @@ -663,7 +663,7 @@ static int cs35l33_codec_set_sysclk(struct snd_soc_codec *codec, return -EINVAL; } - dev_dbg(codec->dev, "external mclk freq=%d, internal mclk freq=%d\n", + dev_dbg(component->dev, "external mclk freq=%d, internal mclk freq=%d\n", freq, cs35l33->mclk_int); return 0; @@ -698,12 +698,12 @@ static struct snd_soc_dai_driver cs35l33_dai = { .symmetric_rates = 1, }; -static int cs35l33_set_hg_data(struct snd_soc_codec *codec, +static int cs35l33_set_hg_data(struct snd_soc_component *component, struct cs35l33_pdata *pdata) { struct cs35l33_hg *hg_config = &pdata->hg_config; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct cs35l33_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct cs35l33_private *priv = snd_soc_component_get_drvdata(component); if (hg_config->enable_hg_algo) { regmap_update_bits(priv->regmap, CS35L33_HG_MEMLDO_CTL, @@ -747,20 +747,20 @@ static int cs35l33_set_hg_data(struct snd_soc_codec *codec, return 0; } -static int cs35l33_set_bst_ipk(struct snd_soc_codec *codec, unsigned int bst) +static int cs35l33_set_bst_ipk(struct snd_soc_component *component, unsigned int bst) { - struct cs35l33_private *cs35l33 = snd_soc_codec_get_drvdata(codec); + struct cs35l33_private *cs35l33 = snd_soc_component_get_drvdata(component); int ret = 0, steps = 0; /* Boost current in uA */ if (bst > 3600000 || bst < 1850000) { - dev_err(codec->dev, "Invalid boost current %d\n", bst); + dev_err(component->dev, "Invalid boost current %d\n", bst); ret = -EINVAL; goto err; } if (bst % 15625) { - dev_err(codec->dev, "Current not a multiple of 15625uA (%d)\n", + dev_err(component->dev, "Current not a multiple of 15625uA (%d)\n", bst); ret = -EINVAL; goto err; @@ -778,12 +778,12 @@ err: return ret; } -static int cs35l33_probe(struct snd_soc_codec *codec) +static int cs35l33_probe(struct snd_soc_component *component) { - struct cs35l33_private *cs35l33 = snd_soc_codec_get_drvdata(codec); + struct cs35l33_private *cs35l33 = snd_soc_component_get_drvdata(component); - cs35l33->codec = codec; - pm_runtime_get_sync(codec->dev); + cs35l33->component = component; + pm_runtime_get_sync(component->dev); regmap_update_bits(cs35l33->regmap, CS35L33_PROTECT_CTL, CS35L33_ALIVE_WD_DIS, 0x8); @@ -799,24 +799,24 @@ static int cs35l33_probe(struct snd_soc_codec *codec) cs35l33->pdata.amp_drv_sel << CS35L33_AMP_DRV_SEL_SHIFT); if (cs35l33->pdata.boost_ipk) - cs35l33_set_bst_ipk(codec, cs35l33->pdata.boost_ipk); + cs35l33_set_bst_ipk(component, cs35l33->pdata.boost_ipk); if (cs35l33->enable_soft_ramp) { - snd_soc_update_bits(codec, CS35L33_DAC_CTL, + snd_soc_component_update_bits(component, CS35L33_DAC_CTL, CS35L33_DIGSFT, CS35L33_DIGSFT); - snd_soc_update_bits(codec, CS35L33_DAC_CTL, + snd_soc_component_update_bits(component, CS35L33_DAC_CTL, CS35L33_DSR_RATE, cs35l33->pdata.ramp_rate); } else { - snd_soc_update_bits(codec, CS35L33_DAC_CTL, + snd_soc_component_update_bits(component, CS35L33_DAC_CTL, CS35L33_DIGSFT, 0); } /* update IMON scaling rate if different from default of 0x8 */ if (cs35l33->pdata.imon_adc_scale != 0x8) - snd_soc_update_bits(codec, CS35L33_ADC_CTL, + snd_soc_component_update_bits(component, CS35L33_ADC_CTL, CS35L33_IMON_SCALE, cs35l33->pdata.imon_adc_scale); - cs35l33_set_hg_data(codec, &(cs35l33->pdata)); + cs35l33_set_hg_data(component, &(cs35l33->pdata)); /* * unmask important interrupts that causes the chip to enter @@ -826,26 +826,24 @@ static int cs35l33_probe(struct snd_soc_codec *codec) CS35L33_M_OTE | CS35L33_M_OTW | CS35L33_M_AMP_SHORT | CS35L33_M_CAL_ERR, 0); - pm_runtime_put_sync(codec->dev); + pm_runtime_put_sync(component->dev); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_cs35l33 = { - .probe = cs35l33_probe, - - .set_bias_level = cs35l33_set_bias_level, - .set_sysclk = cs35l33_codec_set_sysclk, - - .component_driver = { - .controls = cs35l33_snd_controls, - .num_controls = ARRAY_SIZE(cs35l33_snd_controls), - .dapm_widgets = cs35l33_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs35l33_dapm_widgets), - .dapm_routes = cs35l33_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs35l33_audio_map), - }, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_cs35l33 = { + .probe = cs35l33_probe, + .set_bias_level = cs35l33_set_bias_level, + .set_sysclk = cs35l33_component_set_sysclk, + .controls = cs35l33_snd_controls, + .num_controls = ARRAY_SIZE(cs35l33_snd_controls), + .dapm_widgets = cs35l33_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs35l33_dapm_widgets), + .dapm_routes = cs35l33_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs35l33_audio_map), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config cs35l33_regmap = { @@ -967,7 +965,7 @@ static int cs35l33_get_hg_data(const struct device_node *np, static irqreturn_t cs35l33_irq_thread(int irq, void *data) { struct cs35l33_private *cs35l33 = data; - struct snd_soc_codec *codec = cs35l33->codec; + struct snd_soc_component *component = cs35l33->component; unsigned int sticky_val1, sticky_val2, current_val, mask1, mask2; regmap_read(cs35l33->regmap, CS35L33_INT_STATUS_2, @@ -989,9 +987,9 @@ static irqreturn_t cs35l33_irq_thread(int irq, void *data) /* handle the interrupts */ if (sticky_val1 & CS35L33_AMP_SHORT) { - dev_crit(codec->dev, "Amp short error\n"); + dev_crit(component->dev, "Amp short error\n"); if (!(current_val & CS35L33_AMP_SHORT)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Amp short error release\n"); regmap_update_bits(cs35l33->regmap, CS35L33_AMP_CTL, @@ -1007,13 +1005,13 @@ static irqreturn_t cs35l33_irq_thread(int irq, void *data) } if (sticky_val1 & CS35L33_CAL_ERR) { - dev_err(codec->dev, "Cal error\n"); + dev_err(component->dev, "Cal error\n"); /* redo the calibration in next power up */ cs35l33->amp_cal = false; if (!(current_val & CS35L33_CAL_ERR)) { - dev_dbg(codec->dev, "Cal error release\n"); + dev_dbg(component->dev, "Cal error release\n"); regmap_update_bits(cs35l33->regmap, CS35L33_AMP_CTL, CS35L33_CAL_ERR_RLS, 0); @@ -1027,9 +1025,9 @@ static irqreturn_t cs35l33_irq_thread(int irq, void *data) } if (sticky_val1 & CS35L33_OTE) { - dev_crit(codec->dev, "Over temperature error\n"); + dev_crit(component->dev, "Over temperature error\n"); if (!(current_val & CS35L33_OTE)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Over temperature error release\n"); regmap_update_bits(cs35l33->regmap, CS35L33_AMP_CTL, CS35L33_OTE_RLS, 0); @@ -1042,9 +1040,9 @@ static irqreturn_t cs35l33_irq_thread(int irq, void *data) } if (sticky_val1 & CS35L33_OTW) { - dev_err(codec->dev, "Over temperature warning\n"); + dev_err(component->dev, "Over temperature warning\n"); if (!(current_val & CS35L33_OTW)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Over temperature warning release\n"); regmap_update_bits(cs35l33->regmap, CS35L33_AMP_CTL, CS35L33_OTW_RLS, 0); @@ -1056,21 +1054,21 @@ static irqreturn_t cs35l33_irq_thread(int irq, void *data) } } if (CS35L33_ALIVE_ERR & sticky_val1) - dev_err(codec->dev, "ERROR: ADSPCLK Interrupt\n"); + dev_err(component->dev, "ERROR: ADSPCLK Interrupt\n"); if (CS35L33_MCLK_ERR & sticky_val1) - dev_err(codec->dev, "ERROR: MCLK Interrupt\n"); + dev_err(component->dev, "ERROR: MCLK Interrupt\n"); if (CS35L33_VMON_OVFL & sticky_val2) - dev_err(codec->dev, + dev_err(component->dev, "ERROR: VMON Overflow Interrupt\n"); if (CS35L33_IMON_OVFL & sticky_val2) - dev_err(codec->dev, + dev_err(component->dev, "ERROR: IMON Overflow Interrupt\n"); if (CS35L33_VPMON_OVFL & sticky_val2) - dev_err(codec->dev, + dev_err(component->dev, "ERROR: VPMON Overflow Interrupt\n"); return IRQ_HANDLED; @@ -1236,10 +1234,10 @@ static int cs35l33_i2c_probe(struct i2c_client *i2c_client, pm_runtime_set_active(&i2c_client->dev); pm_runtime_enable(&i2c_client->dev); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs35l33, &cs35l33_dai, 1); + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs35l33, &cs35l33_dai, 1); if (ret < 0) { - dev_err(&i2c_client->dev, "%s: Register codec failed\n", + dev_err(&i2c_client->dev, "%s: Register component failed\n", __func__); goto err_enable; } @@ -1257,8 +1255,6 @@ static int cs35l33_i2c_remove(struct i2c_client *client) { struct cs35l33_private *cs35l33 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - gpiod_set_value_cansleep(cs35l33->reset_gpio, 0); pm_runtime_disable(&client->dev); From 86c2eddfba351824cffccdd5182954c1cf0b9a8a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:55:56 +0000 Subject: [PATCH 081/942] ASoC: cs35l35: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l35.c | 104 +++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 56 deletions(-) diff --git a/sound/soc/codecs/cs35l35.c b/sound/soc/codecs/cs35l35.c index 129978d1243e..a4a2cb171bdf 100644 --- a/sound/soc/codecs/cs35l35.c +++ b/sound/soc/codecs/cs35l35.c @@ -194,8 +194,8 @@ static int cs35l35_wait_for_pdn(struct cs35l35_private *cs35l35) static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); int ret = 0; switch (event) { @@ -231,7 +231,7 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w, 1 << CS35L35_AMP_DIGSFT_SHIFT); break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); ret = -EINVAL; } return ret; @@ -240,8 +240,8 @@ static int cs35l35_sdin_event(struct snd_soc_dapm_widget *w, static int cs35l35_main_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); unsigned int reg[4]; int i; @@ -301,7 +301,7 @@ static int cs35l35_main_amp_event(struct snd_soc_dapm_widget *w, break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); } return 0; } @@ -369,8 +369,8 @@ static const struct snd_soc_dapm_route cs35l35_audio_map[] = { static int cs35l35_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -470,8 +470,8 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); struct classh_cfg *classh = &cs35l35->pdata.classh_algo; int srate = params_rate(params); int ret = 0; @@ -482,7 +482,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, int clk_ctl = cs35l35_get_clk_config(cs35l35->sysclk, srate); if (clk_ctl < 0) { - dev_err(codec->dev, "Invalid CLK:Rate %d:%d\n", + dev_err(component->dev, "Invalid CLK:Rate %d:%d\n", cs35l35->sysclk, srate); return -EINVAL; } @@ -490,7 +490,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(cs35l35->regmap, CS35L35_CLK_CTL2, CS35L35_CLK_CTL2_MASK, clk_ctl); if (ret != 0) { - dev_err(codec->dev, "Failed to set port config %d\n", ret); + dev_err(component->dev, "Failed to set port config %d\n", ret); return ret; } @@ -509,7 +509,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, CS35L35_CH_WKFET_DEL_MASK, 0 << CS35L35_CH_WKFET_DEL_SHIFT); if (ret != 0) { - dev_err(codec->dev, "Failed to set fet config %d\n", + dev_err(component->dev, "Failed to set fet config %d\n", ret); return ret; } @@ -531,7 +531,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, audin_format = CS35L35_SDIN_DEPTH_24; break; default: - dev_err(codec->dev, "Unsupported Width %d\n", + dev_err(component->dev, "Unsupported Width %d\n", params_width(params)); return -EINVAL; } @@ -554,7 +554,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, * to configure the CLOCK_CTL3 register correctly */ if ((cs35l35->sclk / srate) % 4) { - dev_err(codec->dev, "Unsupported sclk/fs ratio %d:%d\n", + dev_err(component->dev, "Unsupported sclk/fs ratio %d:%d\n", cs35l35->sclk, srate); return -EINVAL; } @@ -568,7 +568,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, case CS35L35_SP_SCLKS_64FS: break; default: - dev_err(codec->dev, "ratio not supported\n"); + dev_err(component->dev, "ratio not supported\n"); return -EINVAL; } } else { @@ -578,7 +578,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, case CS35L35_SP_SCLKS_64FS: break; default: - dev_err(codec->dev, "ratio not supported\n"); + dev_err(component->dev, "ratio not supported\n"); return -EINVAL; } } @@ -587,7 +587,7 @@ static int cs35l35_hw_params(struct snd_pcm_substream *substream, CS35L35_SP_SCLKS_MASK, sp_sclks << CS35L35_SP_SCLKS_SHIFT); if (ret != 0) { - dev_err(codec->dev, "Failed to set fsclk %d\n", ret); + dev_err(component->dev, "Failed to set fsclk %d\n", ret); return ret; } } @@ -607,8 +607,8 @@ static const struct snd_pcm_hw_constraint_list cs35l35_constraints = { static int cs35l35_pcm_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); if (!substream->runtime) return 0; @@ -635,8 +635,8 @@ static const struct snd_pcm_hw_constraint_list cs35l35_pdm_constraints = { static int cs35l35_pdm_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); if (!substream->runtime) return 0; @@ -655,8 +655,8 @@ static int cs35l35_pdm_startup(struct snd_pcm_substream *substream, static int cs35l35_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); /* Need the SCLK Frequency regardless of sysclk source for I2S */ cs35l35->sclk = freq; @@ -712,11 +712,11 @@ static struct snd_soc_dai_driver cs35l35_dai[] = { }, }; -static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, +static int cs35l35_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); int clksrc; int ret = 0; @@ -731,7 +731,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, clksrc = CS35L35_CLK_SOURCE_PDM; break; default: - dev_err(codec->dev, "Invalid CLK Source\n"); + dev_err(component->dev, "Invalid CLK Source\n"); return -EINVAL; } @@ -749,7 +749,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, cs35l35->sysclk = freq; break; default: - dev_err(codec->dev, "Invalid CLK Frequency Input : %d\n", freq); + dev_err(component->dev, "Invalid CLK Frequency Input : %d\n", freq); return -EINVAL; } @@ -757,7 +757,7 @@ static int cs35l35_codec_set_sysclk(struct snd_soc_codec *codec, CS35L35_CLK_SOURCE_MASK, clksrc << CS35L35_CLK_SOURCE_SHIFT); if (ret != 0) { - dev_err(codec->dev, "Failed to set sysclk %d\n", ret); + dev_err(component->dev, "Failed to set sysclk %d\n", ret); return ret; } @@ -834,9 +834,9 @@ static int cs35l35_boost_inductor(struct cs35l35_private *cs35l35, return 0; } -static int cs35l35_codec_probe(struct snd_soc_codec *codec) +static int cs35l35_component_probe(struct snd_soc_component *component) { - struct cs35l35_private *cs35l35 = snd_soc_codec_get_drvdata(codec); + struct cs35l35_private *cs35l35 = snd_soc_component_get_drvdata(component); struct classh_cfg *classh = &cs35l35->pdata.classh_algo; struct monitor_cfg *monitor_config = &cs35l35->pdata.mon_cfg; int ret; @@ -880,7 +880,7 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec) regmap_update_bits(cs35l35->regmap, CS35L35_CLASS_H_CTL, CS35L35_CH_STEREO_MASK, 1 << CS35L35_CH_STEREO_SHIFT); - ret = snd_soc_add_codec_controls(codec, cs35l35_adv_controls, + ret = snd_soc_add_component_controls(component, cs35l35_adv_controls, ARRAY_SIZE(cs35l35_adv_controls)); if (ret) return ret; @@ -1079,20 +1079,19 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_cs35l35 = { - .probe = cs35l35_codec_probe, - .set_sysclk = cs35l35_codec_set_sysclk, - .component_driver = { - .dapm_widgets = cs35l35_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs35l35_dapm_widgets), - - .dapm_routes = cs35l35_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs35l35_audio_map), - - .controls = cs35l35_aud_controls, - .num_controls = ARRAY_SIZE(cs35l35_aud_controls), - }, - +static const struct snd_soc_component_driver soc_component_dev_cs35l35 = { + .probe = cs35l35_component_probe, + .set_sysclk = cs35l35_component_set_sysclk, + .dapm_widgets = cs35l35_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs35l35_dapm_widgets), + .dapm_routes = cs35l35_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs35l35_audio_map), + .controls = cs35l35_aud_controls, + .num_controls = ARRAY_SIZE(cs35l35_aud_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct regmap_config cs35l35_regmap = { @@ -1617,10 +1616,10 @@ static int cs35l35_i2c_probe(struct i2c_client *i2c_client, regmap_update_bits(cs35l35->regmap, CS35L35_PROTECT_CTL, CS35L35_AMP_MUTE_MASK, 1 << CS35L35_AMP_MUTE_SHIFT); - ret = snd_soc_register_codec(dev, &soc_codec_dev_cs35l35, cs35l35_dai, - ARRAY_SIZE(cs35l35_dai)); + ret = devm_snd_soc_register_component(dev, &soc_component_dev_cs35l35, + cs35l35_dai, ARRAY_SIZE(cs35l35_dai)); if (ret < 0) { - dev_err(dev, "Failed to register codec: %d\n", ret); + dev_err(dev, "Failed to register component: %d\n", ret); goto err; } @@ -1634,12 +1633,6 @@ err: return ret; } -static int cs35l35_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct of_device_id cs35l35_of_match[] = { {.compatible = "cirrus,cs35l35"}, {}, @@ -1660,7 +1653,6 @@ static struct i2c_driver cs35l35_i2c_driver = { }, .id_table = cs35l35_id, .probe = cs35l35_i2c_probe, - .remove = cs35l35_i2c_remove, }; module_i2c_driver(cs35l35_i2c_driver); From 8a6e7dd6f07d7f537b10b0e61165c06d15dcc1f2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:56:25 +0000 Subject: [PATCH 082/942] ASoC: cs35l34: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs35l34.c | 127 ++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/sound/soc/codecs/cs35l34.c b/sound/soc/codecs/cs35l34.c index 0600d5264c4c..5063c05afa27 100644 --- a/sound/soc/codecs/cs35l34.c +++ b/sound/soc/codecs/cs35l34.c @@ -43,7 +43,7 @@ #define CS35L34_START_DELAY 50 struct cs35l34_private { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct cs35l34_platform_data pdata; struct regmap *regmap; struct regulator_bulk_data core_supplies[2]; @@ -237,8 +237,8 @@ static bool cs35l34_precious_register(struct device *dev, unsigned int reg) static int cs35l34_sdin_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l34_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l34_private *priv = snd_soc_component_get_drvdata(component); int ret; switch (event) { @@ -250,7 +250,7 @@ static int cs35l34_sdin_event(struct snd_soc_dapm_widget *w, ret = regmap_update_bits(priv->regmap, CS35L34_PWRCTL1, CS35L34_PDN_ALL, 0); if (ret < 0) { - dev_err(codec->dev, "Cannot set Power bits %d\n", ret); + dev_err(component->dev, "Cannot set Power bits %d\n", ret); return ret; } usleep_range(5000, 5100); @@ -272,8 +272,8 @@ static int cs35l34_sdin_event(struct snd_soc_dapm_widget *w, static int cs35l34_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l34_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l34_private *priv = snd_soc_component_get_drvdata(component); unsigned int reg, bit_pos; int slot, slot_num; @@ -284,7 +284,7 @@ static int cs35l34_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, /* scan rx_mask for aud slot */ slot = ffs(rx_mask) - 1; if (slot >= 0) - snd_soc_update_bits(codec, CS35L34_TDM_RX_CTL_1_AUDIN, + snd_soc_component_update_bits(component, CS35L34_TDM_RX_CTL_1_AUDIN, CS35L34_X_LOC, slot); /* scan tx_mask: vmon(2 slots); imon (2 slots); vpmon (1 slot) @@ -294,10 +294,10 @@ static int cs35l34_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, slot_num = 0; /* disable vpmon/vbstmon: enable later if set in tx_mask */ - snd_soc_update_bits(codec, CS35L34_TDM_TX_CTL_3_VPMON, + snd_soc_component_update_bits(component, CS35L34_TDM_TX_CTL_3_VPMON, CS35L34_X_STATE | CS35L34_X_LOC, CS35L34_X_STATE | CS35L34_X_LOC); - snd_soc_update_bits(codec, CS35L34_TDM_TX_CTL_4_VBSTMON, + snd_soc_component_update_bits(component, CS35L34_TDM_TX_CTL_4_VBSTMON, CS35L34_X_STATE | CS35L34_X_LOC, CS35L34_X_STATE | CS35L34_X_LOC); @@ -305,22 +305,22 @@ static int cs35l34_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, while (slot >= 0) { /* configure VMON_TX_LOC */ if (slot_num == 0) - snd_soc_update_bits(codec, CS35L34_TDM_TX_CTL_1_VMON, + snd_soc_component_update_bits(component, CS35L34_TDM_TX_CTL_1_VMON, CS35L34_X_STATE | CS35L34_X_LOC, slot); /* configure IMON_TX_LOC */ if (slot_num == 4) { - snd_soc_update_bits(codec, CS35L34_TDM_TX_CTL_2_IMON, + snd_soc_component_update_bits(component, CS35L34_TDM_TX_CTL_2_IMON, CS35L34_X_STATE | CS35L34_X_LOC, slot); } /* configure VPMON_TX_LOC */ if (slot_num == 3) { - snd_soc_update_bits(codec, CS35L34_TDM_TX_CTL_3_VPMON, + snd_soc_component_update_bits(component, CS35L34_TDM_TX_CTL_3_VPMON, CS35L34_X_STATE | CS35L34_X_LOC, slot); } /* configure VBSTMON_TX_LOC */ if (slot_num == 7) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS35L34_TDM_TX_CTL_4_VBSTMON, CS35L34_X_STATE | CS35L34_X_LOC, slot); } @@ -328,7 +328,7 @@ static int cs35l34_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, /* Enable the relevant tx slot */ reg = CS35L34_TDM_TX_SLOT_EN_4 - (slot/8); bit_pos = slot - ((slot / 8) * (8)); - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, 1 << bit_pos, 1 << bit_pos); tx_mask &= ~(1 << slot); @@ -342,8 +342,8 @@ static int cs35l34_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int cs35l34_main_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l34_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l34_private *priv = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -382,8 +382,8 @@ static const struct snd_kcontrol_new cs35l34_snd_controls[] = { static int cs35l34_mclk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs35l34_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs35l34_private *priv = snd_soc_component_get_drvdata(component); int ret, i; unsigned int reg; @@ -524,8 +524,8 @@ static int cs35l34_get_mclk_coeff(int mclk, int srate) static int cs35l34_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs35l34_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs35l34_private *priv = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -546,15 +546,15 @@ static int cs35l34_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l34_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l34_private *priv = snd_soc_component_get_drvdata(component); int srate = params_rate(params); int ret; int coeff = cs35l34_get_mclk_coeff(priv->mclk_int, srate); if (coeff < 0) { - dev_err(codec->dev, "ERROR: Invalid mclk %d and/or srate %d\n", + dev_err(component->dev, "ERROR: Invalid mclk %d and/or srate %d\n", priv->mclk_int, srate); return coeff; } @@ -562,7 +562,7 @@ static int cs35l34_pcm_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(priv->regmap, CS35L34_ADSP_CLK_CTL, CS35L34_ADSP_RATE, cs35l34_mclk_coeffs[coeff].adsp_rate); if (ret != 0) - dev_err(codec->dev, "Failed to set clock state %d\n", ret); + dev_err(component->dev, "Failed to set clock state %d\n", ret); return ret; } @@ -590,13 +590,13 @@ static int cs35l34_pcm_startup(struct snd_pcm_substream *substream, static int cs35l34_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (tristate) - snd_soc_update_bits(codec, CS35L34_PWRCTL3, + snd_soc_component_update_bits(component, CS35L34_PWRCTL3, CS35L34_PDN_SDOUT, CS35L34_PDN_SDOUT); else - snd_soc_update_bits(codec, CS35L34_PWRCTL3, + snd_soc_component_update_bits(component, CS35L34_PWRCTL3, CS35L34_PDN_SDOUT, 0); return 0; } @@ -604,8 +604,8 @@ static int cs35l34_set_tristate(struct snd_soc_dai *dai, int tristate) static int cs35l34_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct cs35l34_private *cs35l34 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs35l34_private *cs35l34 = snd_soc_component_get_drvdata(component); unsigned int value; switch (freq) { @@ -634,7 +634,7 @@ static int cs35l34_dai_set_sysclk(struct snd_soc_dai *dai, cs35l34->mclk_int = freq / 2; break; default: - dev_err(codec->dev, "ERROR: Invalid Frequency %d\n", freq); + dev_err(component->dev, "ERROR: Invalid Frequency %d\n", freq); cs35l34->mclk_int = 0; return -EINVAL; } @@ -676,7 +676,7 @@ static struct snd_soc_dai_driver cs35l34_dai = { static int cs35l34_boost_inductor(struct cs35l34_private *cs35l34, unsigned int inductor) { - struct snd_soc_codec *codec = cs35l34->codec; + struct snd_soc_component *component = cs35l34->component; switch (inductor) { case 1000: /* 1 uH */ @@ -708,19 +708,19 @@ static int cs35l34_boost_inductor(struct cs35l34_private *cs35l34, regmap_write(cs35l34->regmap, CS35L34_BST_CONV_SW_FREQ, 3); break; default: - dev_err(codec->dev, "%s Invalid Inductor Value %d uH\n", + dev_err(component->dev, "%s Invalid Inductor Value %d uH\n", __func__, inductor); return -EINVAL; } return 0; } -static int cs35l34_probe(struct snd_soc_codec *codec) +static int cs35l34_probe(struct snd_soc_component *component) { int ret = 0; - struct cs35l34_private *cs35l34 = snd_soc_codec_get_drvdata(codec); + struct cs35l34_private *cs35l34 = snd_soc_component_get_drvdata(component); - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); /* Set over temperature warning attenuation to 6 dB */ regmap_update_bits(cs35l34->regmap, CS35L34_PROTECT_CTL, @@ -773,23 +773,24 @@ static int cs35l34_probe(struct snd_soc_codec *codec) regmap_update_bits(cs35l34->regmap, CS35L34_ADSP_TDM_CTL, 1, 1); - pm_runtime_put_sync(codec->dev); + pm_runtime_put_sync(component->dev); return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_cs35l34 = { - .probe = cs35l34_probe, - - .component_driver = { - .dapm_widgets = cs35l34_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs35l34_dapm_widgets), - .dapm_routes = cs35l34_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs35l34_audio_map), - .controls = cs35l34_snd_controls, - .num_controls = ARRAY_SIZE(cs35l34_snd_controls), - }, +static const struct snd_soc_component_driver soc_component_dev_cs35l34 = { + .probe = cs35l34_probe, + .dapm_widgets = cs35l34_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs35l34_dapm_widgets), + .dapm_routes = cs35l34_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs35l34_audio_map), + .controls = cs35l34_snd_controls, + .num_controls = ARRAY_SIZE(cs35l34_snd_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct regmap_config cs35l34_regmap = { @@ -864,7 +865,7 @@ static int cs35l34_handle_of_data(struct i2c_client *i2c_client, static irqreturn_t cs35l34_irq_thread(int irq, void *data) { struct cs35l34_private *cs35l34 = data; - struct snd_soc_codec *codec = cs35l34->codec; + struct snd_soc_component *component = cs35l34->component; unsigned int sticky1, sticky2, sticky3, sticky4; unsigned int mask1, mask2, mask3, mask4, current1; @@ -887,11 +888,11 @@ static irqreturn_t cs35l34_irq_thread(int irq, void *data) regmap_read(cs35l34->regmap, CS35L34_INT_STATUS_1, ¤t1); if (sticky1 & CS35L34_CAL_ERR) { - dev_err(codec->dev, "Cal error\n"); + dev_err(component->dev, "Cal error\n"); /* error is no longer asserted; safe to reset */ if (!(current1 & CS35L34_CAL_ERR)) { - dev_dbg(codec->dev, "Cal error release\n"); + dev_dbg(component->dev, "Cal error release\n"); regmap_update_bits(cs35l34->regmap, CS35L34_PROT_RELEASE_CTL, CS35L34_CAL_ERR_RLS, 0); @@ -907,14 +908,14 @@ static irqreturn_t cs35l34_irq_thread(int irq, void *data) } if (sticky1 & CS35L34_ALIVE_ERR) - dev_err(codec->dev, "Alive error\n"); + dev_err(component->dev, "Alive error\n"); if (sticky1 & CS35L34_AMP_SHORT) { - dev_crit(codec->dev, "Amp short error\n"); + dev_crit(component->dev, "Amp short error\n"); /* error is no longer asserted; safe to reset */ if (!(current1 & CS35L34_AMP_SHORT)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Amp short error release\n"); regmap_update_bits(cs35l34->regmap, CS35L34_PROT_RELEASE_CTL, @@ -930,11 +931,11 @@ static irqreturn_t cs35l34_irq_thread(int irq, void *data) } if (sticky1 & CS35L34_OTW) { - dev_crit(codec->dev, "Over temperature warning\n"); + dev_crit(component->dev, "Over temperature warning\n"); /* error is no longer asserted; safe to reset */ if (!(current1 & CS35L34_OTW)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Over temperature warning release\n"); regmap_update_bits(cs35l34->regmap, CS35L34_PROT_RELEASE_CTL, @@ -950,11 +951,11 @@ static irqreturn_t cs35l34_irq_thread(int irq, void *data) } if (sticky1 & CS35L34_OTE) { - dev_crit(codec->dev, "Over temperature error\n"); + dev_crit(component->dev, "Over temperature error\n"); /* error is no longer asserted; safe to reset */ if (!(current1 & CS35L34_OTE)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Over temperature error release\n"); regmap_update_bits(cs35l34->regmap, CS35L34_PROT_RELEASE_CTL, @@ -970,7 +971,7 @@ static irqreturn_t cs35l34_irq_thread(int irq, void *data) } if (sticky3 & CS35L34_BST_HIGH) { - dev_crit(codec->dev, "VBST too high error; powering off!\n"); + dev_crit(component->dev, "VBST too high error; powering off!\n"); regmap_update_bits(cs35l34->regmap, CS35L34_PWRCTL2, CS35L34_PDN_AMP, CS35L34_PDN_AMP); regmap_update_bits(cs35l34->regmap, CS35L34_PWRCTL1, @@ -978,7 +979,7 @@ static irqreturn_t cs35l34_irq_thread(int irq, void *data) } if (sticky3 & CS35L34_LBST_SHORT) { - dev_crit(codec->dev, "LBST short error; powering off!\n"); + dev_crit(component->dev, "LBST short error; powering off!\n"); regmap_update_bits(cs35l34->regmap, CS35L34_PWRCTL2, CS35L34_PDN_AMP, CS35L34_PDN_AMP); regmap_update_bits(cs35l34->regmap, CS35L34_PWRCTL1, @@ -1108,11 +1109,11 @@ static int cs35l34_i2c_probe(struct i2c_client *i2c_client, pm_runtime_set_active(&i2c_client->dev); pm_runtime_enable(&i2c_client->dev); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs35l34, &cs35l34_dai, 1); + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs35l34, &cs35l34_dai, 1); if (ret < 0) { dev_err(&i2c_client->dev, - "%s: Register codec failed\n", __func__); + "%s: Register component failed\n", __func__); goto err_regulator; } @@ -1129,8 +1130,6 @@ static int cs35l34_i2c_remove(struct i2c_client *client) { struct cs35l34_private *cs35l34 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - gpiod_set_value_cansleep(cs35l34->reset_gpio, 0); pm_runtime_disable(&client->dev); From 99a9f452093e40f82e51a2f49d95ee3c04ad298b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:56:58 +0000 Subject: [PATCH 083/942] ASoC: cs42xx8: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs42xx8-i2c.c | 1 - sound/soc/codecs/cs42xx8.c | 57 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 30 deletions(-) diff --git a/sound/soc/codecs/cs42xx8-i2c.c b/sound/soc/codecs/cs42xx8-i2c.c index 800c1d549347..0214e3ab9da0 100644 --- a/sound/soc/codecs/cs42xx8-i2c.c +++ b/sound/soc/codecs/cs42xx8-i2c.c @@ -33,7 +33,6 @@ static int cs42xx8_i2c_probe(struct i2c_client *i2c, static int cs42xx8_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); pm_runtime_disable(&i2c->dev); return 0; diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c index c1785bd4ff19..ebb9e0cf8364 100644 --- a/sound/soc/codecs/cs42xx8.c +++ b/sound/soc/codecs/cs42xx8.c @@ -194,8 +194,8 @@ static const struct cs42xx8_ratios cs42xx8_ratios[] = { static int cs42xx8_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42xx8_priv *cs42xx8 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); cs42xx8->sysclk = freq; @@ -205,8 +205,8 @@ static int cs42xx8_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int cs42xx8_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42xx8_priv *cs42xx8 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); u32 val; /* Set DAI format */ @@ -224,7 +224,7 @@ static int cs42xx8_set_dai_fmt(struct snd_soc_dai *codec_dai, val = CS42XX8_INTF_DAC_DIF_TDM | CS42XX8_INTF_ADC_DIF_TDM; break; default: - dev_err(codec->dev, "unsupported dai format\n"); + dev_err(component->dev, "unsupported dai format\n"); return -EINVAL; } @@ -241,7 +241,7 @@ static int cs42xx8_set_dai_fmt(struct snd_soc_dai *codec_dai, cs42xx8->slave_mode = false; break; default: - dev_err(codec->dev, "unsupported master/slave mode\n"); + dev_err(component->dev, "unsupported master/slave mode\n"); return -EINVAL; } @@ -252,8 +252,8 @@ static int cs42xx8_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs42xx8_priv *cs42xx8 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; u32 ratio = cs42xx8->sysclk / params_rate(params); u32 i, fm, val, mask; @@ -267,7 +267,7 @@ static int cs42xx8_hw_params(struct snd_pcm_substream *substream, } if (i == ARRAY_SIZE(cs42xx8_ratios)) { - dev_err(codec->dev, "unsupported sysclk ratio\n"); + dev_err(component->dev, "unsupported sysclk ratio\n"); return -EINVAL; } @@ -285,8 +285,8 @@ static int cs42xx8_hw_params(struct snd_pcm_substream *substream, static int cs42xx8_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct cs42xx8_priv *cs42xx8 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); u8 dac_unmute = cs42xx8->tx_channels ? ~((0x1 << cs42xx8->tx_channels) - 1) : 0; @@ -382,14 +382,14 @@ const struct regmap_config cs42xx8_regmap_config = { }; EXPORT_SYMBOL_GPL(cs42xx8_regmap_config); -static int cs42xx8_codec_probe(struct snd_soc_codec *codec) +static int cs42xx8_component_probe(struct snd_soc_component *component) { - struct cs42xx8_priv *cs42xx8 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct cs42xx8_priv *cs42xx8 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); switch (cs42xx8->drvdata->num_adcs) { case 3: - snd_soc_add_codec_controls(codec, cs42xx8_adc3_snd_controls, + snd_soc_add_component_controls(component, cs42xx8_adc3_snd_controls, ARRAY_SIZE(cs42xx8_adc3_snd_controls)); snd_soc_dapm_new_controls(dapm, cs42xx8_adc3_dapm_widgets, ARRAY_SIZE(cs42xx8_adc3_dapm_widgets)); @@ -406,18 +406,17 @@ static int cs42xx8_codec_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver cs42xx8_driver = { - .probe = cs42xx8_codec_probe, - .idle_bias_off = true, - - .component_driver = { - .controls = cs42xx8_snd_controls, - .num_controls = ARRAY_SIZE(cs42xx8_snd_controls), - .dapm_widgets = cs42xx8_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs42xx8_dapm_widgets), - .dapm_routes = cs42xx8_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(cs42xx8_dapm_routes), - }, +static const struct snd_soc_component_driver cs42xx8_driver = { + .probe = cs42xx8_component_probe, + .controls = cs42xx8_snd_controls, + .num_controls = ARRAY_SIZE(cs42xx8_snd_controls), + .dapm_widgets = cs42xx8_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs42xx8_dapm_widgets), + .dapm_routes = cs42xx8_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(cs42xx8_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; const struct cs42xx8_driver_data cs42448_data = { @@ -520,9 +519,9 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap) /* Each adc supports stereo input */ cs42xx8_dai.capture.channels_max = cs42xx8->drvdata->num_adcs * 2; - ret = snd_soc_register_codec(dev, &cs42xx8_driver, &cs42xx8_dai, 1); + ret = devm_snd_soc_register_component(dev, &cs42xx8_driver, &cs42xx8_dai, 1); if (ret) { - dev_err(dev, "failed to register codec:%d\n", ret); + dev_err(dev, "failed to register component:%d\n", ret); goto err_enable; } From 092631bf863d6c632afc1ec935c3acb7b45a8622 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:57:25 +0000 Subject: [PATCH 084/942] ASoC: cs42l73: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l73.c | 122 ++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 64 deletions(-) diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index aebaa97490b6..36b57ee00a30 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c @@ -490,8 +490,8 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = { static int cs42l73_spklo_spk_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMD: /* 150 ms delay between setting PDN and MCLKDIS */ @@ -506,8 +506,8 @@ static int cs42l73_spklo_spk_amp_event(struct snd_soc_dapm_widget *w, static int cs42l73_ear_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMD: /* 50 ms delay between setting PDN and MCLKDIS */ @@ -524,8 +524,8 @@ static int cs42l73_ear_amp_event(struct snd_soc_dapm_widget *w, static int cs42l73_hp_amp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMD: /* 30 ms delay between setting PDN and MCLKDIS */ @@ -884,8 +884,8 @@ static int cs42l73_get_mclk_coeff(int mclk, int srate) static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); int mclkx_coeff; u32 mclk = 0; @@ -899,14 +899,14 @@ static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq) mclk = cs42l73_mclkx_coeffs[mclkx_coeff].mclkx / cs42l73_mclkx_coeffs[mclkx_coeff].ratio; - dev_dbg(codec->dev, "MCLK%u %u <-> internal MCLK %u\n", + dev_dbg(component->dev, "MCLK%u %u <-> internal MCLK %u\n", priv->mclksel + 1, cs42l73_mclkx_coeffs[mclkx_coeff].mclkx, mclk); dmmcc = (priv->mclksel << 4) | (cs42l73_mclkx_coeffs[mclkx_coeff].mclkdiv << 1); - snd_soc_write(codec, CS42L73_DMMCC, dmmcc); + snd_soc_component_write(component, CS42L73_DMMCC, dmmcc); priv->sysclk = mclkx_coeff; priv->mclk = mclk; @@ -917,8 +917,8 @@ static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq) static int cs42l73_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); switch (clk_id) { case CS42L73_CLKID_MCLK1: @@ -930,7 +930,7 @@ static int cs42l73_set_sysclk(struct snd_soc_dai *dai, } if ((cs42l73_set_mclk(dai, freq)) < 0) { - dev_err(codec->dev, "Unable to set MCLK for dai %s\n", + dev_err(component->dev, "Unable to set MCLK for dai %s\n", dai->name); return -EINVAL; } @@ -942,14 +942,14 @@ static int cs42l73_set_sysclk(struct snd_soc_dai *dai, static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); u8 id = codec_dai->id; unsigned int inv, format; u8 spc, mmcc; - spc = snd_soc_read(codec, CS42L73_SPC(id)); - mmcc = snd_soc_read(codec, CS42L73_MMCC(id)); + spc = snd_soc_component_read32(component, CS42L73_SPC(id)); + mmcc = snd_soc_component_read32(component, CS42L73_MMCC(id)); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -974,12 +974,12 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) case SND_SOC_DAIFMT_DSP_A: case SND_SOC_DAIFMT_DSP_B: if (mmcc & CS42L73_MS_MASTER) { - dev_err(codec->dev, + dev_err(component->dev, "PCM format in slave mode only\n"); return -EINVAL; } if (id == CS42L73_ASP) { - dev_err(codec->dev, + dev_err(component->dev, "PCM format is not supported on ASP port\n"); return -EINVAL; } @@ -1029,7 +1029,7 @@ static unsigned int cs42l73_get_xspfs_coeff(u32 rate) return 0; /* 0 = Don't know */ } -static void cs42l73_update_asrc(struct snd_soc_codec *codec, int id, int srate) +static void cs42l73_update_asrc(struct snd_soc_component *component, int id, int srate) { u8 spfs = 0; @@ -1038,13 +1038,13 @@ static void cs42l73_update_asrc(struct snd_soc_codec *codec, int id, int srate) switch (id) { case CS42L73_XSP: - snd_soc_update_bits(codec, CS42L73_VXSPFS, 0x0f, spfs); + snd_soc_component_update_bits(component, CS42L73_VXSPFS, 0x0f, spfs); break; case CS42L73_ASP: - snd_soc_update_bits(codec, CS42L73_ASPC, 0x3c, spfs << 2); + snd_soc_component_update_bits(component, CS42L73_ASPC, 0x3c, spfs << 2); break; case CS42L73_VSP: - snd_soc_update_bits(codec, CS42L73_VXSPFS, 0xf0, spfs << 4); + snd_soc_component_update_bits(component, CS42L73_VXSPFS, 0xf0, spfs << 4); break; default: break; @@ -1055,8 +1055,8 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l73_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l73_private *priv = snd_soc_component_get_drvdata(component); int id = dai->id; int mclk_coeff; int srate = params_rate(params); @@ -1070,7 +1070,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, if (mclk_coeff < 0) return -EINVAL; - dev_dbg(codec->dev, + dev_dbg(component->dev, "DAI[%d]: MCLK %u, srate %u, MMCC[5:0] = %x\n", id, priv->mclk, srate, cs42l73_mclk_coeffs[mclk_coeff].mmcc); @@ -1091,38 +1091,38 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, /* Update ASRCs */ priv->config[id].srate = srate; - snd_soc_write(codec, CS42L73_SPC(id), priv->config[id].spc); - snd_soc_write(codec, CS42L73_MMCC(id), priv->config[id].mmcc); + snd_soc_component_write(component, CS42L73_SPC(id), priv->config[id].spc); + snd_soc_component_write(component, CS42L73_MMCC(id), priv->config[id].mmcc); - cs42l73_update_asrc(codec, id, srate); + cs42l73_update_asrc(component, id, srate); return 0; } -static int cs42l73_set_bias_level(struct snd_soc_codec *codec, +static int cs42l73_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct cs42l73_private *cs42l73 = snd_soc_codec_get_drvdata(codec); + struct cs42l73_private *cs42l73 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0); - snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0); + snd_soc_component_update_bits(component, CS42L73_DMMCC, CS42L73_MCLKDIS, 0); + snd_soc_component_update_bits(component, CS42L73_PWRCTL1, CS42L73_PDN, 0); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l73->regmap, false); regcache_sync(cs42l73->regmap); } - snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1); + snd_soc_component_update_bits(component, CS42L73_PWRCTL1, CS42L73_PDN, 1); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1); + snd_soc_component_update_bits(component, CS42L73_PWRCTL1, CS42L73_PDN, 1); if (cs42l73->shutdwn_delay > 0) { mdelay(cs42l73->shutdwn_delay); cs42l73->shutdwn_delay = 0; @@ -1131,7 +1131,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, * down. */ } - snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1); + snd_soc_component_update_bits(component, CS42L73_DMMCC, CS42L73_MCLKDIS, 1); break; } return 0; @@ -1139,10 +1139,10 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, static int cs42l73_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int id = dai->id; - return snd_soc_update_bits(codec, CS42L73_SPC(id), CS42L73_SP_3ST, + return snd_soc_component_update_bits(component, CS42L73_SPC(id), CS42L73_SP_3ST, tristate << 7); } @@ -1235,13 +1235,13 @@ static struct snd_soc_dai_driver cs42l73_dai[] = { } }; -static int cs42l73_probe(struct snd_soc_codec *codec) +static int cs42l73_probe(struct snd_soc_component *component) { - struct cs42l73_private *cs42l73 = snd_soc_codec_get_drvdata(codec); + struct cs42l73_private *cs42l73 = snd_soc_component_get_drvdata(component); /* Set Charge Pump Frequency */ if (cs42l73->pdata.chgfreq) - snd_soc_update_bits(codec, CS42L73_CPFCHC, + snd_soc_component_update_bits(component, CS42L73_CPFCHC, CS42L73_CHARGEPUMP_MASK, cs42l73->pdata.chgfreq << 4); @@ -1252,19 +1252,20 @@ static int cs42l73_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_cs42l73 = { - .probe = cs42l73_probe, - .set_bias_level = cs42l73_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = cs42l73_snd_controls, - .num_controls = ARRAY_SIZE(cs42l73_snd_controls), - .dapm_widgets = cs42l73_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs42l73_dapm_widgets), - .dapm_routes = cs42l73_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs42l73_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_cs42l73 = { + .probe = cs42l73_probe, + .set_bias_level = cs42l73_set_bias_level, + .controls = cs42l73_snd_controls, + .num_controls = ARRAY_SIZE(cs42l73_snd_controls), + .dapm_widgets = cs42l73_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs42l73_dapm_widgets), + .dapm_routes = cs42l73_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs42l73_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config cs42l73_regmap = { @@ -1361,20 +1362,14 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, dev_info(&i2c_client->dev, "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs42l73, cs42l73_dai, + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs42l73, cs42l73_dai, ARRAY_SIZE(cs42l73_dai)); if (ret < 0) return ret; return 0; } -static int cs42l73_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct of_device_id cs42l73_of_match[] = { { .compatible = "cirrus,cs42l73", }, {}, @@ -1395,7 +1390,6 @@ static struct i2c_driver cs42l73_i2c_driver = { }, .id_table = cs42l73_id, .probe = cs42l73_i2c_probe, - .remove = cs42l73_i2c_remove, }; From 9665a74944b321d060ca626b9a8bee579466ba29 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:57:55 +0000 Subject: [PATCH 085/942] ASoC: cs42l52: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l52.c | 146 ++++++++++++++++++------------------- 1 file changed, 69 insertions(+), 77 deletions(-) diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c index 9731e5dff291..3d83c1be1292 100644 --- a/sound/soc/codecs/cs42l52.c +++ b/sound/soc/codecs/cs42l52.c @@ -42,7 +42,7 @@ struct sp_config { struct cs42l52_private { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct device *dev; struct sp_config config; struct cs42l52_platform_data pdata; @@ -473,17 +473,17 @@ static const struct snd_kcontrol_new cs42l52_micb_controls[] = { SOC_ENUM("MICB Select", micb_enum), }; -static int cs42l52_add_mic_controls(struct snd_soc_codec *codec) +static int cs42l52_add_mic_controls(struct snd_soc_component *component) { - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); struct cs42l52_platform_data *pdata = &cs42l52->pdata; if (!pdata->mica_diff_cfg) - snd_soc_add_codec_controls(codec, cs42l52_mica_controls, + snd_soc_add_component_controls(component, cs42l52_mica_controls, ARRAY_SIZE(cs42l52_mica_controls)); if (!pdata->micb_diff_cfg) - snd_soc_add_codec_controls(codec, cs42l52_micb_controls, + snd_soc_add_component_controls(component, cs42l52_micb_controls, ARRAY_SIZE(cs42l52_micb_controls)); return 0; @@ -716,13 +716,13 @@ static int cs42l52_get_clk(int mclk, int rate) static int cs42l52_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); if ((freq >= CS42L52_MIN_CLK) && (freq <= CS42L52_MAX_CLK)) { cs42l52->sysclk = freq; } else { - dev_err(codec->dev, "Invalid freq parameter\n"); + dev_err(component->dev, "Invalid freq parameter\n"); return -EINVAL; } return 0; @@ -730,8 +730,8 @@ static int cs42l52_set_sysclk(struct snd_soc_dai *codec_dai, static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); u8 iface = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -783,21 +783,21 @@ static int cs42l52_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } cs42l52->config.format = iface; - snd_soc_write(codec, CS42L52_IFACE_CTL1, cs42l52->config.format); + snd_soc_component_write(component, CS42L52_IFACE_CTL1, cs42l52->config.format); return 0; } static int cs42l52_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) - snd_soc_update_bits(codec, CS42L52_PB_CTL1, + snd_soc_component_update_bits(component, CS42L52_PB_CTL1, CS42L52_PB_CTL1_MUTE_MASK, CS42L52_PB_CTL1_MUTE); else - snd_soc_update_bits(codec, CS42L52_PB_CTL1, + snd_soc_component_update_bits(component, CS42L52_PB_CTL1, CS42L52_PB_CTL1_MUTE_MASK, CS42L52_PB_CTL1_UNMUTE); @@ -808,8 +808,8 @@ static int cs42l52_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); u32 clk = 0; int index; @@ -823,36 +823,36 @@ static int cs42l52_pcm_hw_params(struct snd_pcm_substream *substream, (clk_map_table[index].ratio << CLK_RATIO_SHIFT) | clk_map_table[index].mclkdiv2; - snd_soc_write(codec, CS42L52_CLK_CTL, clk); + snd_soc_component_write(component, CS42L52_CLK_CTL, clk); } else { - dev_err(codec->dev, "can't get correct mclk\n"); + dev_err(component->dev, "can't get correct mclk\n"); return -EINVAL; } return 0; } -static int cs42l52_set_bias_level(struct snd_soc_codec *codec, +static int cs42l52_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, CS42L52_PWRCTL1, + snd_soc_component_update_bits(component, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_CODEC, 0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l52->regmap, false); regcache_sync(cs42l52->regmap); } - snd_soc_write(codec, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL); + snd_soc_component_write(component, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL); break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL); + snd_soc_component_write(component, CS42L52_PWRCTL1, CS42L52_PWRCTL1_PDN_ALL); regcache_cache_only(cs42l52->regmap, true); break; } @@ -902,8 +902,8 @@ static void cs42l52_beep_work(struct work_struct *work) { struct cs42l52_private *cs42l52 = container_of(work, struct cs42l52_private, beep_work); - struct snd_soc_codec *codec = cs42l52->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = cs42l52->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int i; int val = 0; int best = 0; @@ -915,18 +915,18 @@ static void cs42l52_beep_work(struct work_struct *work) best = i; } - dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", + dev_dbg(component->dev, "Set beep rate %dHz for requested %dHz\n", beep_rates[best], cs42l52->beep_rate); val = (best << CS42L52_BEEP_RATE_SHIFT); snd_soc_dapm_enable_pin(dapm, "Beep"); } else { - dev_dbg(codec->dev, "Disabling beep\n"); + dev_dbg(component->dev, "Disabling beep\n"); snd_soc_dapm_disable_pin(dapm, "Beep"); } - snd_soc_update_bits(codec, CS42L52_BEEP_FREQ, + snd_soc_component_update_bits(component, CS42L52_BEEP_FREQ, CS42L52_BEEP_RATE_MASK, val); snd_soc_dapm_sync(dapm); @@ -938,10 +938,10 @@ static void cs42l52_beep_work(struct work_struct *work) static int cs42l52_beep_event(struct input_dev *dev, unsigned int type, unsigned int code, int hz) { - struct snd_soc_codec *codec = input_get_drvdata(dev); - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = input_get_drvdata(dev); + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); + dev_dbg(component->dev, "Beep event %x %x\n", code, hz); switch (code) { case SND_BELL: @@ -978,14 +978,14 @@ static ssize_t cs42l52_beep_set(struct device *dev, static DEVICE_ATTR(beep, 0200, NULL, cs42l52_beep_set); -static void cs42l52_init_beep(struct snd_soc_codec *codec) +static void cs42l52_init_beep(struct snd_soc_component *component) { - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); int ret; - cs42l52->beep = devm_input_allocate_device(codec->dev); + cs42l52->beep = devm_input_allocate_device(component->dev); if (!cs42l52->beep) { - dev_err(codec->dev, "Failed to allocate beep device\n"); + dev_err(component->dev, "Failed to allocate beep device\n"); return; } @@ -993,49 +993,49 @@ static void cs42l52_init_beep(struct snd_soc_codec *codec) cs42l52->beep_rate = 0; cs42l52->beep->name = "CS42L52 Beep Generator"; - cs42l52->beep->phys = dev_name(codec->dev); + cs42l52->beep->phys = dev_name(component->dev); cs42l52->beep->id.bustype = BUS_I2C; cs42l52->beep->evbit[0] = BIT_MASK(EV_SND); cs42l52->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); cs42l52->beep->event = cs42l52_beep_event; - cs42l52->beep->dev.parent = codec->dev; - input_set_drvdata(cs42l52->beep, codec); + cs42l52->beep->dev.parent = component->dev; + input_set_drvdata(cs42l52->beep, component); ret = input_register_device(cs42l52->beep); if (ret != 0) { cs42l52->beep = NULL; - dev_err(codec->dev, "Failed to register beep device\n"); + dev_err(component->dev, "Failed to register beep device\n"); } - ret = device_create_file(codec->dev, &dev_attr_beep); + ret = device_create_file(component->dev, &dev_attr_beep); if (ret != 0) { - dev_err(codec->dev, "Failed to create keyclick file: %d\n", + dev_err(component->dev, "Failed to create keyclick file: %d\n", ret); } } -static void cs42l52_free_beep(struct snd_soc_codec *codec) +static void cs42l52_free_beep(struct snd_soc_component *component) { - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); - device_remove_file(codec->dev, &dev_attr_beep); + device_remove_file(component->dev, &dev_attr_beep); cancel_work_sync(&cs42l52->beep_work); cs42l52->beep = NULL; - snd_soc_update_bits(codec, CS42L52_BEEP_TONE_CTL, + snd_soc_component_update_bits(component, CS42L52_BEEP_TONE_CTL, CS42L52_BEEP_EN_MASK, 0); } -static int cs42l52_probe(struct snd_soc_codec *codec) +static int cs42l52_probe(struct snd_soc_component *component) { - struct cs42l52_private *cs42l52 = snd_soc_codec_get_drvdata(codec); + struct cs42l52_private *cs42l52 = snd_soc_component_get_drvdata(component); regcache_cache_only(cs42l52->regmap, true); - cs42l52_add_mic_controls(codec); + cs42l52_add_mic_controls(component); - cs42l52_init_beep(codec); + cs42l52_init_beep(component); cs42l52->sysclk = CS42L52_DEFAULT_CLK; cs42l52->config.format = CS42L52_DEFAULT_FORMAT; @@ -1043,27 +1043,26 @@ static int cs42l52_probe(struct snd_soc_codec *codec) return 0; } -static int cs42l52_remove(struct snd_soc_codec *codec) +static void cs42l52_remove(struct snd_soc_component *component) { - cs42l52_free_beep(codec); - - return 0; + cs42l52_free_beep(component); } -static const struct snd_soc_codec_driver soc_codec_dev_cs42l52 = { - .probe = cs42l52_probe, - .remove = cs42l52_remove, - .set_bias_level = cs42l52_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = cs42l52_snd_controls, - .num_controls = ARRAY_SIZE(cs42l52_snd_controls), - .dapm_widgets = cs42l52_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs42l52_dapm_widgets), - .dapm_routes = cs42l52_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs42l52_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_cs42l52 = { + .probe = cs42l52_probe, + .remove = cs42l52_remove, + .set_bias_level = cs42l52_set_bias_level, + .controls = cs42l52_snd_controls, + .num_controls = ARRAY_SIZE(cs42l52_snd_controls), + .dapm_widgets = cs42l52_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs42l52_dapm_widgets), + .dapm_routes = cs42l52_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs42l52_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* Current and threshold powerup sequence Pg37 */ @@ -1202,19 +1201,13 @@ static int cs42l52_i2c_probe(struct i2c_client *i2c_client, CS42L52_IFACE_CTL2_BIAS_LVL, cs42l52->pdata.micbias_lvl); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs42l52, &cs42l52_dai, 1); + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs42l52, &cs42l52_dai, 1); if (ret < 0) return ret; return 0; } -static int cs42l52_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct of_device_id cs42l52_of_match[] = { { .compatible = "cirrus,cs42l52", }, {}, @@ -1235,7 +1228,6 @@ static struct i2c_driver cs42l52_i2c_driver = { }, .id_table = cs42l52_id, .probe = cs42l52_i2c_probe, - .remove = cs42l52_i2c_remove, }; module_i2c_driver(cs42l52_i2c_driver); From e48f7466f9d93232da3f33ca722aa23a0a892f9e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:58:25 +0000 Subject: [PATCH 086/942] ASoC: cs42l56: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l56.c | 158 ++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 80 deletions(-) diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index fd7b8d32c2b2..a5c8736fad77 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c @@ -45,7 +45,7 @@ static const char *const cs42l56_supply_names[CS42L56_NUM_SUPPLIES] = { struct cs42l56_private { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct device *dev; struct cs42l56_platform_data pdata; struct regulator_bulk_data supplies[CS42L56_NUM_SUPPLIES]; @@ -726,8 +726,8 @@ static int cs42l56_get_mclk_ratio(int mclk, int rate) static int cs42l56_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); switch (freq) { case CS42L56_MCLK_5P6448MHZ: @@ -753,10 +753,10 @@ static int cs42l56_set_sysclk(struct snd_soc_dai *codec_dai, } cs42l56->mclk = freq; - snd_soc_update_bits(codec, CS42L56_CLKCTL_1, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_1, CS42L56_MCLK_PREDIV_MASK, cs42l56->mclk_prediv); - snd_soc_update_bits(codec, CS42L56_CLKCTL_1, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_1, CS42L56_MCLK_DIV2_MASK, cs42l56->mclk_div2); @@ -765,8 +765,8 @@ static int cs42l56_set_sysclk(struct snd_soc_dai *codec_dai, static int cs42l56_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -803,22 +803,22 @@ static int cs42l56_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, CS42L56_CLKCTL_1, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_1, CS42L56_MS_MODE_MASK, cs42l56->iface); - snd_soc_update_bits(codec, CS42L56_SERIAL_FMT, + snd_soc_component_update_bits(component, CS42L56_SERIAL_FMT, CS42L56_DIG_FMT_MASK, cs42l56->iface_fmt); - snd_soc_update_bits(codec, CS42L56_CLKCTL_1, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_1, CS42L56_SCLK_INV_MASK, cs42l56->iface_inv); return 0; } static int cs42l56_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) { /* Hit the DSP Mixer first */ - snd_soc_update_bits(codec, CS42L56_DSP_MUTE_CTL, + snd_soc_component_update_bits(component, CS42L56_DSP_MUTE_CTL, CS42L56_ADCAMIX_MUTE_MASK | CS42L56_ADCBMIX_MUTE_MASK | CS42L56_PCMAMIX_MUTE_MASK | @@ -827,21 +827,21 @@ static int cs42l56_digital_mute(struct snd_soc_dai *dai, int mute) CS42L56_MSTA_MUTE_MASK, CS42L56_MUTE_ALL); /* Mute ADC's */ - snd_soc_update_bits(codec, CS42L56_MISC_ADC_CTL, + snd_soc_component_update_bits(component, CS42L56_MISC_ADC_CTL, CS42L56_ADCA_MUTE_MASK | CS42L56_ADCB_MUTE_MASK, CS42L56_MUTE_ALL); /* HP And LO */ - snd_soc_update_bits(codec, CS42L56_HPA_VOLUME, + snd_soc_component_update_bits(component, CS42L56_HPA_VOLUME, CS42L56_HP_MUTE_MASK, CS42L56_MUTE_ALL); - snd_soc_update_bits(codec, CS42L56_HPB_VOLUME, + snd_soc_component_update_bits(component, CS42L56_HPB_VOLUME, CS42L56_HP_MUTE_MASK, CS42L56_MUTE_ALL); - snd_soc_update_bits(codec, CS42L56_LOA_VOLUME, + snd_soc_component_update_bits(component, CS42L56_LOA_VOLUME, CS42L56_LO_MUTE_MASK, CS42L56_MUTE_ALL); - snd_soc_update_bits(codec, CS42L56_LOB_VOLUME, + snd_soc_component_update_bits(component, CS42L56_LOB_VOLUME, CS42L56_LO_MUTE_MASK, CS42L56_MUTE_ALL); } else { - snd_soc_update_bits(codec, CS42L56_DSP_MUTE_CTL, + snd_soc_component_update_bits(component, CS42L56_DSP_MUTE_CTL, CS42L56_ADCAMIX_MUTE_MASK | CS42L56_ADCBMIX_MUTE_MASK | CS42L56_PCMAMIX_MUTE_MASK | @@ -850,18 +850,18 @@ static int cs42l56_digital_mute(struct snd_soc_dai *dai, int mute) CS42L56_MSTA_MUTE_MASK, CS42L56_UNMUTE); - snd_soc_update_bits(codec, CS42L56_MISC_ADC_CTL, + snd_soc_component_update_bits(component, CS42L56_MISC_ADC_CTL, CS42L56_ADCA_MUTE_MASK | CS42L56_ADCB_MUTE_MASK, CS42L56_UNMUTE); - snd_soc_update_bits(codec, CS42L56_HPA_VOLUME, + snd_soc_component_update_bits(component, CS42L56_HPA_VOLUME, CS42L56_HP_MUTE_MASK, CS42L56_UNMUTE); - snd_soc_update_bits(codec, CS42L56_HPB_VOLUME, + snd_soc_component_update_bits(component, CS42L56_HPB_VOLUME, CS42L56_HP_MUTE_MASK, CS42L56_UNMUTE); - snd_soc_update_bits(codec, CS42L56_LOA_VOLUME, + snd_soc_component_update_bits(component, CS42L56_LOA_VOLUME, CS42L56_LO_MUTE_MASK, CS42L56_UNMUTE); - snd_soc_update_bits(codec, CS42L56_LOB_VOLUME, + snd_soc_component_update_bits(component, CS42L56_LOB_VOLUME, CS42L56_LO_MUTE_MASK, CS42L56_UNMUTE); } return 0; @@ -871,39 +871,39 @@ static int cs42l56_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); int ratio; ratio = cs42l56_get_mclk_ratio(cs42l56->mclk, params_rate(params)); if (ratio >= 0) { - snd_soc_update_bits(codec, CS42L56_CLKCTL_2, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_2, CS42L56_CLK_RATIO_MASK, ratio); } else { - dev_err(codec->dev, "unsupported mclk/sclk/lrclk ratio\n"); + dev_err(component->dev, "unsupported mclk/sclk/lrclk ratio\n"); return -EINVAL; } return 0; } -static int cs42l56_set_bias_level(struct snd_soc_codec *codec, +static int cs42l56_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); int ret; switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, CS42L56_CLKCTL_1, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_1, CS42L56_MCLK_DIS_MASK, 0); - snd_soc_update_bits(codec, CS42L56_PWRCTL_1, + snd_soc_component_update_bits(component, CS42L56_PWRCTL_1, CS42L56_PDN_ALL_MASK, 0); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l56->regmap, false); regcache_sync(cs42l56->regmap); ret = regulator_bulk_enable(ARRAY_SIZE(cs42l56->supplies), @@ -915,13 +915,13 @@ static int cs42l56_set_bias_level(struct snd_soc_codec *codec, return ret; } } - snd_soc_update_bits(codec, CS42L56_PWRCTL_1, + snd_soc_component_update_bits(component, CS42L56_PWRCTL_1, CS42L56_PDN_ALL_MASK, 1); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, CS42L56_PWRCTL_1, + snd_soc_component_update_bits(component, CS42L56_PWRCTL_1, CS42L56_PDN_ALL_MASK, 1); - snd_soc_update_bits(codec, CS42L56_CLKCTL_1, + snd_soc_component_update_bits(component, CS42L56_CLKCTL_1, CS42L56_MCLK_DIS_MASK, 1); regcache_cache_only(cs42l56->regmap, true); regulator_bulk_disable(ARRAY_SIZE(cs42l56->supplies), @@ -974,8 +974,8 @@ static void cs42l56_beep_work(struct work_struct *work) { struct cs42l56_private *cs42l56 = container_of(work, struct cs42l56_private, beep_work); - struct snd_soc_codec *codec = cs42l56->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = cs42l56->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int i; int val = 0; int best = 0; @@ -987,18 +987,18 @@ static void cs42l56_beep_work(struct work_struct *work) best = i; } - dev_dbg(codec->dev, "Set beep rate %dHz for requested %dHz\n", + dev_dbg(component->dev, "Set beep rate %dHz for requested %dHz\n", beep_freq[best], cs42l56->beep_rate); val = (best << CS42L56_BEEP_RATE_SHIFT); snd_soc_dapm_enable_pin(dapm, "Beep"); } else { - dev_dbg(codec->dev, "Disabling beep\n"); + dev_dbg(component->dev, "Disabling beep\n"); snd_soc_dapm_disable_pin(dapm, "Beep"); } - snd_soc_update_bits(codec, CS42L56_BEEP_FREQ_ONTIME, + snd_soc_component_update_bits(component, CS42L56_BEEP_FREQ_ONTIME, CS42L56_BEEP_FREQ_MASK, val); snd_soc_dapm_sync(dapm); @@ -1010,10 +1010,10 @@ static void cs42l56_beep_work(struct work_struct *work) static int cs42l56_beep_event(struct input_dev *dev, unsigned int type, unsigned int code, int hz) { - struct snd_soc_codec *codec = input_get_drvdata(dev); - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = input_get_drvdata(dev); + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "Beep event %x %x\n", code, hz); + dev_dbg(component->dev, "Beep event %x %x\n", code, hz); switch (code) { case SND_BELL: @@ -1050,14 +1050,14 @@ static ssize_t cs42l56_beep_set(struct device *dev, static DEVICE_ATTR(beep, 0200, NULL, cs42l56_beep_set); -static void cs42l56_init_beep(struct snd_soc_codec *codec) +static void cs42l56_init_beep(struct snd_soc_component *component) { - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); int ret; - cs42l56->beep = devm_input_allocate_device(codec->dev); + cs42l56->beep = devm_input_allocate_device(component->dev); if (!cs42l56->beep) { - dev_err(codec->dev, "Failed to allocate beep device\n"); + dev_err(component->dev, "Failed to allocate beep device\n"); return; } @@ -1065,68 +1065,67 @@ static void cs42l56_init_beep(struct snd_soc_codec *codec) cs42l56->beep_rate = 0; cs42l56->beep->name = "CS42L56 Beep Generator"; - cs42l56->beep->phys = dev_name(codec->dev); + cs42l56->beep->phys = dev_name(component->dev); cs42l56->beep->id.bustype = BUS_I2C; cs42l56->beep->evbit[0] = BIT_MASK(EV_SND); cs42l56->beep->sndbit[0] = BIT_MASK(SND_BELL) | BIT_MASK(SND_TONE); cs42l56->beep->event = cs42l56_beep_event; - cs42l56->beep->dev.parent = codec->dev; - input_set_drvdata(cs42l56->beep, codec); + cs42l56->beep->dev.parent = component->dev; + input_set_drvdata(cs42l56->beep, component); ret = input_register_device(cs42l56->beep); if (ret != 0) { cs42l56->beep = NULL; - dev_err(codec->dev, "Failed to register beep device\n"); + dev_err(component->dev, "Failed to register beep device\n"); } - ret = device_create_file(codec->dev, &dev_attr_beep); + ret = device_create_file(component->dev, &dev_attr_beep); if (ret != 0) { - dev_err(codec->dev, "Failed to create keyclick file: %d\n", + dev_err(component->dev, "Failed to create keyclick file: %d\n", ret); } } -static void cs42l56_free_beep(struct snd_soc_codec *codec) +static void cs42l56_free_beep(struct snd_soc_component *component) { - struct cs42l56_private *cs42l56 = snd_soc_codec_get_drvdata(codec); + struct cs42l56_private *cs42l56 = snd_soc_component_get_drvdata(component); - device_remove_file(codec->dev, &dev_attr_beep); + device_remove_file(component->dev, &dev_attr_beep); cancel_work_sync(&cs42l56->beep_work); cs42l56->beep = NULL; - snd_soc_update_bits(codec, CS42L56_BEEP_TONE_CFG, + snd_soc_component_update_bits(component, CS42L56_BEEP_TONE_CFG, CS42L56_BEEP_EN_MASK, 0); } -static int cs42l56_probe(struct snd_soc_codec *codec) +static int cs42l56_probe(struct snd_soc_component *component) { - cs42l56_init_beep(codec); + cs42l56_init_beep(component); return 0; } -static int cs42l56_remove(struct snd_soc_codec *codec) +static void cs42l56_remove(struct snd_soc_component *component) { - cs42l56_free_beep(codec); - - return 0; + cs42l56_free_beep(component); } -static const struct snd_soc_codec_driver soc_codec_dev_cs42l56 = { - .probe = cs42l56_probe, - .remove = cs42l56_remove, - .set_bias_level = cs42l56_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = cs42l56_snd_controls, - .num_controls = ARRAY_SIZE(cs42l56_snd_controls), - .dapm_widgets = cs42l56_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs42l56_dapm_widgets), - .dapm_routes = cs42l56_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs42l56_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_cs42l56 = { + .probe = cs42l56_probe, + .remove = cs42l56_remove, + .set_bias_level = cs42l56_set_bias_level, + .controls = cs42l56_snd_controls, + .num_controls = ARRAY_SIZE(cs42l56_snd_controls), + .dapm_widgets = cs42l56_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs42l56_dapm_widgets), + .dapm_routes = cs42l56_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs42l56_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config cs42l56_regmap = { @@ -1315,8 +1314,8 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client, CS42L56_ADAPT_PWR_MASK, cs42l56->pdata.adaptive_pwr); - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs42l56, &cs42l56_dai, 1); + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs42l56, &cs42l56_dai, 1); if (ret < 0) return ret; @@ -1332,7 +1331,6 @@ static int cs42l56_i2c_remove(struct i2c_client *client) { struct cs42l56_private *cs42l56 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); regulator_bulk_disable(ARRAY_SIZE(cs42l56->supplies), cs42l56->supplies); return 0; From 1fa49856cbc8f4ada62f62f30c3c96038d08f24c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:59:02 +0000 Subject: [PATCH 087/942] ASoC: cs42l51: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l51-i2c.c | 8 ---- sound/soc/codecs/cs42l51.c | 81 +++++++++++++++++----------------- 2 files changed, 41 insertions(+), 48 deletions(-) diff --git a/sound/soc/codecs/cs42l51-i2c.c b/sound/soc/codecs/cs42l51-i2c.c index 9bad478474fa..4b5731a41876 100644 --- a/sound/soc/codecs/cs42l51-i2c.c +++ b/sound/soc/codecs/cs42l51-i2c.c @@ -35,20 +35,12 @@ static int cs42l51_i2c_probe(struct i2c_client *i2c, return cs42l51_probe(&i2c->dev, devm_regmap_init_i2c(i2c, &config)); } -static int cs42l51_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - - return 0; -} - static struct i2c_driver cs42l51_i2c_driver = { .driver = { .name = "cs42l51", .of_match_table = cs42l51_of_match, }, .probe = cs42l51_i2c_probe, - .remove = cs42l51_i2c_remove, .id_table = cs42l51_i2c_id, }; diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index f8072f1897d4..5080d7a3c279 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c @@ -54,8 +54,8 @@ struct cs42l51_private { static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - unsigned long value = snd_soc_read(codec, CS42L51_PCM_MIXER)&3; + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + unsigned long value = snd_soc_component_read32(component, CS42L51_PCM_MIXER)&3; switch (value) { default: @@ -82,7 +82,7 @@ static int cs42l51_get_chan_mix(struct snd_kcontrol *kcontrol, static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned char val; switch (ucontrol->value.enumerated.item[0]) { @@ -98,7 +98,7 @@ static int cs42l51_set_chan_mix(struct snd_kcontrol *kcontrol, break; } - snd_soc_write(codec, CS42L51_PCM_MIXER, val); + snd_soc_component_write(component, CS42L51_PCM_MIXER, val); return 1; } @@ -153,17 +153,17 @@ static const struct snd_kcontrol_new cs42l51_snd_controls[] = { static int cs42l51_pdn_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, CS42L51_POWER_CTL1, + snd_soc_component_update_bits(component, CS42L51_POWER_CTL1, CS42L51_POWER_CTL1_PDN, CS42L51_POWER_CTL1_PDN); break; default: case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, CS42L51_POWER_CTL1, + snd_soc_component_update_bits(component, CS42L51_POWER_CTL1, CS42L51_POWER_CTL1_PDN, 0); break; } @@ -263,8 +263,8 @@ static const struct snd_soc_dapm_route cs42l51_routes[] = { static int cs42l51_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l51_private *cs42l51 = snd_soc_component_get_drvdata(component); switch (format & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: @@ -273,7 +273,7 @@ static int cs42l51_set_dai_fmt(struct snd_soc_dai *codec_dai, cs42l51->audio_mode = format & SND_SOC_DAIFMT_FORMAT_MASK; break; default: - dev_err(codec->dev, "invalid DAI format\n"); + dev_err(component->dev, "invalid DAI format\n"); return -EINVAL; } @@ -285,7 +285,7 @@ static int cs42l51_set_dai_fmt(struct snd_soc_dai *codec_dai, cs42l51->func = MODE_SLAVE_AUTO; break; default: - dev_err(codec->dev, "Unknown master/slave configuration\n"); + dev_err(component->dev, "Unknown master/slave configuration\n"); return -EINVAL; } @@ -326,8 +326,8 @@ static struct cs42l51_ratios slave_auto_ratios[] = { static int cs42l51_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs42l51_private *cs42l51 = snd_soc_component_get_drvdata(component); cs42l51->mclk = freq; return 0; @@ -337,8 +337,8 @@ static int cs42l51_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l51_private *cs42l51 = snd_soc_component_get_drvdata(component); int ret; unsigned int i; unsigned int rate; @@ -370,12 +370,12 @@ static int cs42l51_hw_params(struct snd_pcm_substream *substream, if (i == nr_ratios) { /* We did not find a matching ratio */ - dev_err(codec->dev, "could not find matching ratio\n"); + dev_err(component->dev, "could not find matching ratio\n"); return -EINVAL; } - intf_ctl = snd_soc_read(codec, CS42L51_INTF_CTL); - power_ctl = snd_soc_read(codec, CS42L51_MIC_POWER_CTL); + intf_ctl = snd_soc_component_read32(component, CS42L51_INTF_CTL); + power_ctl = snd_soc_component_read32(component, CS42L51_MIC_POWER_CTL); intf_ctl &= ~(CS42L51_INTF_CTL_MASTER | CS42L51_INTF_CTL_ADC_I2S | CS42L51_INTF_CTL_DAC_FORMAT(7)); @@ -418,24 +418,24 @@ static int cs42l51_hw_params(struct snd_pcm_substream *substream, fmt = CS42L51_DAC_DIF_RJ24; break; default: - dev_err(codec->dev, "unknown format\n"); + dev_err(component->dev, "unknown format\n"); return -EINVAL; } intf_ctl |= CS42L51_INTF_CTL_DAC_FORMAT(fmt); break; default: - dev_err(codec->dev, "unknown format\n"); + dev_err(component->dev, "unknown format\n"); return -EINVAL; } if (ratios[i].mclk) power_ctl |= CS42L51_MIC_POWER_CTL_MCLK_DIV2; - ret = snd_soc_write(codec, CS42L51_INTF_CTL, intf_ctl); + ret = snd_soc_component_write(component, CS42L51_INTF_CTL, intf_ctl); if (ret < 0) return ret; - ret = snd_soc_write(codec, CS42L51_MIC_POWER_CTL, power_ctl); + ret = snd_soc_component_write(component, CS42L51_MIC_POWER_CTL, power_ctl); if (ret < 0) return ret; @@ -444,18 +444,18 @@ static int cs42l51_hw_params(struct snd_pcm_substream *substream, static int cs42l51_dai_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg; int mask = CS42L51_DAC_OUT_CTL_DACA_MUTE|CS42L51_DAC_OUT_CTL_DACB_MUTE; - reg = snd_soc_read(codec, CS42L51_DAC_OUT_CTL); + reg = snd_soc_component_read32(component, CS42L51_DAC_OUT_CTL); if (mute) reg |= mask; else reg &= ~mask; - return snd_soc_write(codec, CS42L51_DAC_OUT_CTL, reg); + return snd_soc_component_write(component, CS42L51_DAC_OUT_CTL, reg); } static const struct snd_soc_dai_ops cs42l51_dai_ops = { @@ -484,7 +484,7 @@ static struct snd_soc_dai_driver cs42l51_dai = { .ops = &cs42l51_dai_ops, }; -static int cs42l51_codec_probe(struct snd_soc_codec *codec) +static int cs42l51_component_probe(struct snd_soc_component *component) { int ret, reg; @@ -497,24 +497,25 @@ static int cs42l51_codec_probe(struct snd_soc_codec *codec) */ reg = CS42L51_DAC_CTL_DATA_SEL(1) | CS42L51_DAC_CTL_AMUTE | CS42L51_DAC_CTL_DACSZ(0); - ret = snd_soc_write(codec, CS42L51_DAC_CTL, reg); + ret = snd_soc_component_write(component, CS42L51_DAC_CTL, reg); if (ret < 0) return ret; return 0; } -static const struct snd_soc_codec_driver soc_codec_device_cs42l51 = { - .probe = cs42l51_codec_probe, - - .component_driver = { - .controls = cs42l51_snd_controls, - .num_controls = ARRAY_SIZE(cs42l51_snd_controls), - .dapm_widgets = cs42l51_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs42l51_dapm_widgets), - .dapm_routes = cs42l51_routes, - .num_dapm_routes = ARRAY_SIZE(cs42l51_routes), - }, +static const struct snd_soc_component_driver soc_component_device_cs42l51 = { + .probe = cs42l51_component_probe, + .controls = cs42l51_snd_controls, + .num_controls = ARRAY_SIZE(cs42l51_snd_controls), + .dapm_widgets = cs42l51_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs42l51_dapm_widgets), + .dapm_routes = cs42l51_routes, + .num_dapm_routes = ARRAY_SIZE(cs42l51_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; const struct regmap_config cs42l51_regmap = { @@ -555,8 +556,8 @@ int cs42l51_probe(struct device *dev, struct regmap *regmap) dev_info(dev, "Cirrus Logic CS42L51, Revision: %02X\n", val & CS42L51_CHIP_REV_MASK); - ret = snd_soc_register_codec(dev, - &soc_codec_device_cs42l51, &cs42l51_dai, 1); + ret = devm_snd_soc_register_component(dev, + &soc_component_device_cs42l51, &cs42l51_dai, 1); error: return ret; } From c92614022c6d375e7759a0142a985b4bbfd9046b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:59:27 +0000 Subject: [PATCH 088/942] ASoC: cs42l42: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 1 -> .use_pmdown_time = 0 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs42l42.c | 154 ++++++++++++++++++------------------- sound/soc/codecs/cs42l42.h | 2 +- 2 files changed, 76 insertions(+), 80 deletions(-) diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c index a2324a0e72ee..651329bf9743 100644 --- a/sound/soc/codecs/cs42l42.c +++ b/sound/soc/codecs/cs42l42.c @@ -468,33 +468,33 @@ static const struct snd_kcontrol_new cs42l42_snd_controls[] = { static int cs42l42_hpdrv_evt(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); if (event & SND_SOC_DAPM_POST_PMU) { /* Enable the channels */ - snd_soc_update_bits(codec, CS42L42_ASP_RX_DAI0_EN, + snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_EN, CS42L42_ASP_RX0_CH_EN_MASK, (CS42L42_ASP_RX0_CH1_EN | CS42L42_ASP_RX0_CH2_EN) << CS42L42_ASP_RX0_CH_EN_SHIFT); /* Power up */ - snd_soc_update_bits(codec, CS42L42_PWR_CTL1, + snd_soc_component_update_bits(component, CS42L42_PWR_CTL1, CS42L42_ASP_DAI_PDN_MASK | CS42L42_MIXER_PDN_MASK | CS42L42_HP_PDN_MASK, 0); } else if (event & SND_SOC_DAPM_PRE_PMD) { /* Disable the channels */ - snd_soc_update_bits(codec, CS42L42_ASP_RX_DAI0_EN, + snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_EN, CS42L42_ASP_RX0_CH_EN_MASK, 0); /* Power down */ - snd_soc_update_bits(codec, CS42L42_PWR_CTL1, + snd_soc_component_update_bits(component, CS42L42_PWR_CTL1, CS42L42_ASP_DAI_PDN_MASK | CS42L42_MIXER_PDN_MASK | CS42L42_HP_PDN_MASK, CS42L42_ASP_DAI_PDN_MASK | CS42L42_MIXER_PDN_MASK | CS42L42_HP_PDN_MASK); } else { - dev_err(codec->dev, "Invalid event 0x%x\n", event); + dev_err(component->dev, "Invalid event 0x%x\n", event); } return 0; } @@ -515,10 +515,10 @@ static const struct snd_soc_dapm_route cs42l42_audio_map[] = { {"HP", NULL, "HPDRV"} }; -static int cs42l42_set_bias_level(struct snd_soc_codec *codec, +static int cs42l42_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct cs42l42_private *cs42l42 = snd_soc_codec_get_drvdata(codec); + struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -527,14 +527,14 @@ static int cs42l42_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_cache_only(cs42l42->regmap, false); regcache_sync(cs42l42->regmap); ret = regulator_bulk_enable( ARRAY_SIZE(cs42l42->supplies), cs42l42->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable regulators: %d\n", ret); return ret; @@ -552,30 +552,28 @@ static int cs42l42_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int cs42l42_codec_probe(struct snd_soc_codec *codec) +static int cs42l42_component_probe(struct snd_soc_component *component) { struct cs42l42_private *cs42l42 = - (struct cs42l42_private *)snd_soc_codec_get_drvdata(codec); + (struct cs42l42_private *)snd_soc_component_get_drvdata(component); - cs42l42->codec = codec; + cs42l42->component = component; return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_cs42l42 = { - .probe = cs42l42_codec_probe, - .set_bias_level = cs42l42_set_bias_level, - .ignore_pmdown_time = true, - - .component_driver = { - .dapm_widgets = cs42l42_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs42l42_dapm_widgets), - .dapm_routes = cs42l42_audio_map, - .num_dapm_routes = ARRAY_SIZE(cs42l42_audio_map), - - .controls = cs42l42_snd_controls, - .num_controls = ARRAY_SIZE(cs42l42_snd_controls), - }, +static const struct snd_soc_component_driver soc_component_dev_cs42l42 = { + .probe = cs42l42_component_probe, + .set_bias_level = cs42l42_set_bias_level, + .dapm_widgets = cs42l42_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs42l42_dapm_widgets), + .dapm_routes = cs42l42_audio_map, + .num_dapm_routes = ARRAY_SIZE(cs42l42_audio_map), + .controls = cs42l42_snd_controls, + .num_controls = ARRAY_SIZE(cs42l42_snd_controls), + .idle_bias_on = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; struct cs42l42_pll_params { @@ -613,16 +611,16 @@ static const struct cs42l42_pll_params pll_ratio_table[] = { { 24576000, 1, 0, 0, 0, 0, 0, 0, 24576000, 0 } }; -static int cs42l42_pll_config(struct snd_soc_codec *codec) +static int cs42l42_pll_config(struct snd_soc_component *component) { - struct cs42l42_private *cs42l42 = snd_soc_codec_get_drvdata(codec); + struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); int i; u32 fsync; for (i = 0; i < ARRAY_SIZE(pll_ratio_table); i++) { if (pll_ratio_table[i].sclk == cs42l42->sclk) { /* Configure the internal sample rate */ - snd_soc_update_bits(codec, CS42L42_MCLK_CTL, + snd_soc_component_update_bits(component, CS42L42_MCLK_CTL, CS42L42_INTERNAL_FS_MASK, ((pll_ratio_table[i].mclk_int != 12000000) && @@ -632,7 +630,7 @@ static int cs42l42_pll_config(struct snd_soc_codec *codec) /* Set the MCLK src (PLL or SCLK) and the divide * ratio */ - snd_soc_update_bits(codec, CS42L42_MCLK_SRC_SEL, + snd_soc_component_update_bits(component, CS42L42_MCLK_SRC_SEL, CS42L42_MCLK_SRC_SEL_MASK | CS42L42_MCLKDIV_MASK, (pll_ratio_table[i].mclk_src_sel @@ -643,62 +641,62 @@ static int cs42l42_pll_config(struct snd_soc_codec *codec) fsync = cs42l42->sclk / cs42l42->srate; if (((fsync * cs42l42->srate) != cs42l42->sclk) || ((fsync % 2) != 0)) { - dev_err(codec->dev, + dev_err(component->dev, "Unsupported sclk %d/sample rate %d\n", cs42l42->sclk, cs42l42->srate); return -EINVAL; } /* Set the LRCLK period */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_FSYNC_P_LOWER, CS42L42_FSYNC_PERIOD_MASK, CS42L42_FRAC0_VAL(fsync - 1) << CS42L42_FSYNC_PERIOD_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_FSYNC_P_UPPER, CS42L42_FSYNC_PERIOD_MASK, CS42L42_FRAC1_VAL(fsync - 1) << CS42L42_FSYNC_PERIOD_SHIFT); /* Set the LRCLK to 50% duty cycle */ fsync = fsync / 2; - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_FSYNC_PW_LOWER, CS42L42_FSYNC_PULSE_WIDTH_MASK, CS42L42_FRAC0_VAL(fsync - 1) << CS42L42_FSYNC_PULSE_WIDTH_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_FSYNC_PW_UPPER, CS42L42_FSYNC_PULSE_WIDTH_MASK, CS42L42_FRAC1_VAL(fsync - 1) << CS42L42_FSYNC_PULSE_WIDTH_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_ASP_FRM_CFG, CS42L42_ASP_5050_MASK, CS42L42_ASP_5050_MASK); /* Set the frame delay to 1.0 SCLK clocks */ - snd_soc_update_bits(codec, CS42L42_ASP_FRM_CFG, + snd_soc_component_update_bits(component, CS42L42_ASP_FRM_CFG, CS42L42_ASP_FSD_MASK, CS42L42_ASP_FSD_1_0 << CS42L42_ASP_FSD_SHIFT); /* Set the sample rates (96k or lower) */ - snd_soc_update_bits(codec, CS42L42_FS_RATE_EN, + snd_soc_component_update_bits(component, CS42L42_FS_RATE_EN, CS42L42_FS_EN_MASK, (CS42L42_FS_EN_IASRC_96K | CS42L42_FS_EN_OASRC_96K) << CS42L42_FS_EN_SHIFT); /* Set the input/output internal MCLK clock ~12 MHz */ - snd_soc_update_bits(codec, CS42L42_IN_ASRC_CLK, + snd_soc_component_update_bits(component, CS42L42_IN_ASRC_CLK, CS42L42_CLK_IASRC_SEL_MASK, CS42L42_CLK_IASRC_SEL_12 << CS42L42_CLK_IASRC_SEL_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_OUT_ASRC_CLK, CS42L42_CLK_OASRC_SEL_MASK, CS42L42_CLK_OASRC_SEL_12 << CS42L42_CLK_OASRC_SEL_SHIFT); /* channel 1 on low LRCLK, 32 bit */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH1_AP_RES, CS42L42_ASP_RX_CH_AP_MASK | CS42L42_ASP_RX_CH_RES_MASK, @@ -707,7 +705,7 @@ static int cs42l42_pll_config(struct snd_soc_codec *codec) (CS42L42_ASP_RX_CH_RES_32 << CS42L42_ASP_RX_CH_RES_SHIFT)); /* Channel 2 on high LRCLK, 32 bit */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH2_AP_RES, CS42L42_ASP_RX_CH_AP_MASK | CS42L42_ASP_RX_CH_RES_MASK, @@ -717,50 +715,50 @@ static int cs42l42_pll_config(struct snd_soc_codec *codec) CS42L42_ASP_RX_CH_RES_SHIFT)); if (pll_ratio_table[i].mclk_src_sel == 0) { /* Pass the clock straight through */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_CTL1, CS42L42_PLL_START_MASK, 0); } else { /* Configure PLL per table 4-5 */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_DIV_CFG1, CS42L42_SCLK_PREDIV_MASK, pll_ratio_table[i].sclk_prediv << CS42L42_SCLK_PREDIV_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_DIV_INT, CS42L42_PLL_DIV_INT_MASK, pll_ratio_table[i].pll_div_int << CS42L42_PLL_DIV_INT_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_DIV_FRAC0, CS42L42_PLL_DIV_FRAC_MASK, CS42L42_FRAC0_VAL( pll_ratio_table[i].pll_div_frac) << CS42L42_PLL_DIV_FRAC_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_DIV_FRAC1, CS42L42_PLL_DIV_FRAC_MASK, CS42L42_FRAC1_VAL( pll_ratio_table[i].pll_div_frac) << CS42L42_PLL_DIV_FRAC_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_DIV_FRAC2, CS42L42_PLL_DIV_FRAC_MASK, CS42L42_FRAC2_VAL( pll_ratio_table[i].pll_div_frac) << CS42L42_PLL_DIV_FRAC_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_CTL4, CS42L42_PLL_MODE_MASK, pll_ratio_table[i].pll_mode << CS42L42_PLL_MODE_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_CTL3, CS42L42_PLL_DIVOUT_MASK, pll_ratio_table[i].pll_divout << CS42L42_PLL_DIVOUT_SHIFT); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, CS42L42_PLL_CAL_RATIO, CS42L42_PLL_CAL_RATIO_MASK, pll_ratio_table[i].pll_cal_ratio @@ -775,7 +773,7 @@ static int cs42l42_pll_config(struct snd_soc_codec *codec) static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u32 asp_cfg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -820,7 +818,7 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) break; } - snd_soc_update_bits(codec, CS42L42_ASP_CLK_CFG, + snd_soc_component_update_bits(component, CS42L42_ASP_CLK_CFG, CS42L42_ASP_MODE_MASK | CS42L42_ASP_SCPOL_IN_DAC_MASK | CS42L42_ASP_LCPOL_IN_MASK, asp_cfg_val); @@ -832,14 +830,14 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l42_private *cs42l42 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); int retval; cs42l42->srate = params_rate(params); cs42l42->swidth = params_width(params); - retval = cs42l42_pll_config(codec); + retval = cs42l42_pll_config(component); return retval; } @@ -847,8 +845,8 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream, static int cs42l42_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct cs42l42_private *cs42l42 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); cs42l42->sclk = freq; @@ -857,7 +855,7 @@ static int cs42l42_set_sysclk(struct snd_soc_dai *dai, static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int regval; u8 fullScaleVol; @@ -865,25 +863,25 @@ static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) /* Mark SCLK as not present to turn on the internal * oscillator. */ - snd_soc_update_bits(codec, CS42L42_OSC_SWITCH, + snd_soc_component_update_bits(component, CS42L42_OSC_SWITCH, CS42L42_SCLK_PRESENT_MASK, 0); - snd_soc_update_bits(codec, CS42L42_PLL_CTL1, + snd_soc_component_update_bits(component, CS42L42_PLL_CTL1, CS42L42_PLL_START_MASK, 0 << CS42L42_PLL_START_SHIFT); /* Mute the headphone */ - snd_soc_update_bits(codec, CS42L42_HP_CTL, + snd_soc_component_update_bits(component, CS42L42_HP_CTL, CS42L42_HP_ANA_AMUTE_MASK | CS42L42_HP_ANA_BMUTE_MASK, CS42L42_HP_ANA_AMUTE_MASK | CS42L42_HP_ANA_BMUTE_MASK); } else { - snd_soc_update_bits(codec, CS42L42_PLL_CTL1, + snd_soc_component_update_bits(component, CS42L42_PLL_CTL1, CS42L42_PLL_START_MASK, 1 << CS42L42_PLL_START_SHIFT); /* Read the headphone load */ - regval = snd_soc_read(codec, CS42L42_LOAD_DET_RCSTAT); + regval = snd_soc_component_read32(component, CS42L42_LOAD_DET_RCSTAT); if (((regval & CS42L42_RLA_STAT_MASK) >> CS42L42_RLA_STAT_SHIFT) == CS42L42_RLA_STAT_15_OHM) { fullScaleVol = CS42L42_HP_FULL_SCALE_VOL_MASK; @@ -892,13 +890,13 @@ static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) } /* Un-mute the headphone, set the full scale volume flag */ - snd_soc_update_bits(codec, CS42L42_HP_CTL, + snd_soc_component_update_bits(component, CS42L42_HP_CTL, CS42L42_HP_ANA_AMUTE_MASK | CS42L42_HP_ANA_BMUTE_MASK | CS42L42_HP_FULL_SCALE_VOL_MASK, fullScaleVol); /* Mark SCLK as present, turn off internal oscillator */ - snd_soc_update_bits(codec, CS42L42_OSC_SWITCH, + snd_soc_component_update_bits(component, CS42L42_OSC_SWITCH, CS42L42_SCLK_PRESENT_MASK, CS42L42_SCLK_PRESENT_MASK); } @@ -1262,16 +1260,16 @@ static void cs42l42_handle_button_press(struct cs42l42_private *cs42l42) switch (bias_level) { case 1: /* Function C button press */ - dev_dbg(cs42l42->codec->dev, "Function C button press\n"); + dev_dbg(cs42l42->component->dev, "Function C button press\n"); break; case 2: /* Function B button press */ - dev_dbg(cs42l42->codec->dev, "Function B button press\n"); + dev_dbg(cs42l42->component->dev, "Function B button press\n"); break; case 3: /* Function D button press */ - dev_dbg(cs42l42->codec->dev, "Function D button press\n"); + dev_dbg(cs42l42->component->dev, "Function D button press\n"); break; case 4: /* Function A button press */ - dev_dbg(cs42l42->codec->dev, "Function A button press\n"); + dev_dbg(cs42l42->component->dev, "Function A button press\n"); break; } @@ -1340,7 +1338,7 @@ static const struct cs42l42_irq_params irq_params_table[] = { static irqreturn_t cs42l42_irq_thread(int irq, void *data) { struct cs42l42_private *cs42l42 = (struct cs42l42_private *)data; - struct snd_soc_codec *codec = cs42l42->codec; + struct snd_soc_component *component = cs42l42->component; unsigned int stickies[12]; unsigned int masks[12]; unsigned int current_plug_status; @@ -1372,7 +1370,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) if ((~masks[5]) & irq_params_table[5].mask) { if (stickies[5] & CS42L42_HSDET_AUTO_DONE_MASK) { cs42l42_process_hs_type_detect(cs42l42); - dev_dbg(codec->dev, + dev_dbg(component->dev, "Auto detect done (%d)\n", cs42l42->hs_type); } @@ -1392,7 +1390,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) if (cs42l42->plug_state != CS42L42_TS_UNPLUG) { cs42l42->plug_state = CS42L42_TS_UNPLUG; cs42l42_cancel_hs_type_detect(cs42l42); - dev_dbg(codec->dev, + dev_dbg(component->dev, "Unplug event\n"); } break; @@ -1410,7 +1408,7 @@ static irqreturn_t cs42l42_irq_thread(int irq, void *data) if (current_button_status & CS42L42_M_DETECT_TF_MASK) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Button released\n"); } else if (current_button_status & CS42L42_M_DETECT_FT_MASK) { @@ -1879,8 +1877,8 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, cs42l42_set_interrupt_masks(cs42l42); /* Register codec for machine driver */ - ret = snd_soc_register_codec(&i2c_client->dev, - &soc_codec_dev_cs42l42, &cs42l42_dai, 1); + ret = devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_cs42l42, &cs42l42_dai, 1); if (ret < 0) goto err_disable; return 0; @@ -1895,8 +1893,6 @@ static int cs42l42_i2c_remove(struct i2c_client *i2c_client) { struct cs42l42_private *cs42l42 = i2c_get_clientdata(i2c_client); - snd_soc_unregister_codec(&i2c_client->dev); - /* Hold down reset */ gpiod_set_value_cansleep(cs42l42->reset_gpio, 0); diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h index d87a0a5322d5..09b0a93203ef 100644 --- a/sound/soc/codecs/cs42l42.h +++ b/sound/soc/codecs/cs42l42.h @@ -754,7 +754,7 @@ static const char *const cs42l42_supply_names[CS42L42_NUM_SUPPLIES] = { struct cs42l42_private { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regulator_bulk_data supplies[CS42L42_NUM_SUPPLIES]; struct gpio_desc *reset_gpio; struct completion pdn_done; From 97b566066ffc2f35940450b408c5f4afa997e4a7 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:00:02 +0000 Subject: [PATCH 089/942] ASoC: cs43130: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs43130.c | 243 +++++++++++++++++++------------------ sound/soc/codecs/cs43130.h | 2 +- 2 files changed, 123 insertions(+), 122 deletions(-) diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index 5ba0edc19df4..feca0a672976 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -236,12 +236,12 @@ static const struct cs43130_pll_params *cs43130_get_pll_table( return NULL; } -static int cs43130_pll_config(struct snd_soc_codec *codec) +static int cs43130_pll_config(struct snd_soc_component *component) { - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); const struct cs43130_pll_params *pll_entry; - dev_dbg(codec->dev, "cs43130->mclk = %u, cs43130->mclk_int = %u\n", + dev_dbg(component->dev, "cs43130->mclk = %u, cs43130->mclk_int = %u\n", cs43130->mclk, cs43130->mclk_int); pll_entry = cs43130_get_pll_table(cs43130->mclk, cs43130->mclk_int); @@ -286,11 +286,11 @@ static int cs43130_pll_config(struct snd_soc_codec *codec) return 0; } -static int cs43130_set_pll(struct snd_soc_codec *codec, int pll_id, int source, +static int cs43130_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { int ret = 0; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (freq_in) { case 9600000: @@ -306,7 +306,7 @@ static int cs43130_set_pll(struct snd_soc_codec *codec, int pll_id, int source, cs43130->mclk = freq_in; break; default: - dev_err(codec->dev, + dev_err(component->dev, "unsupported pll input reference clock:%d\n", freq_in); return -EINVAL; } @@ -319,21 +319,21 @@ static int cs43130_set_pll(struct snd_soc_codec *codec, int pll_id, int source, cs43130->mclk_int = freq_out; break; default: - dev_err(codec->dev, + dev_err(component->dev, "unsupported pll output ref clock: %u\n", freq_out); return -EINVAL; } - ret = cs43130_pll_config(codec); - dev_dbg(codec->dev, "cs43130->pll_bypass = %d", cs43130->pll_bypass); + ret = cs43130_pll_config(component); + dev_dbg(component->dev, "cs43130->pll_bypass = %d", cs43130->pll_bypass); return ret; } -static int cs43130_change_clksrc(struct snd_soc_codec *codec, +static int cs43130_change_clksrc(struct snd_soc_component *component, enum cs43130_mclk_src_sel src) { int ret; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); int mclk_int_decoded; if (src == cs43130->mclk_int_src) { @@ -349,7 +349,7 @@ static int cs43130_change_clksrc(struct snd_soc_codec *codec, mclk_int_decoded = CS43130_MCLK_24P5; break; default: - dev_err(codec->dev, "Invalid MCLK INT freq: %u\n", cs43130->mclk_int); + dev_err(component->dev, "Invalid MCLK INT freq: %u\n", cs43130->mclk_int); return -EINVAL; } @@ -373,7 +373,7 @@ static int cs43130_change_clksrc(struct snd_soc_codec *codec, CS43130_XTAL_RDY_INT_MASK, 1 << CS43130_XTAL_RDY_INT_SHIFT); if (ret == 0) { - dev_err(codec->dev, "Timeout waiting for XTAL_READY interrupt\n"); + dev_err(component->dev, "Timeout waiting for XTAL_READY interrupt\n"); return -ETIMEDOUT; } } @@ -409,7 +409,7 @@ static int cs43130_change_clksrc(struct snd_soc_codec *codec, CS43130_XTAL_RDY_INT_MASK, 1 << CS43130_XTAL_RDY_INT_SHIFT); if (ret == 0) { - dev_err(codec->dev, "Timeout waiting for XTAL_READY interrupt\n"); + dev_err(component->dev, "Timeout waiting for XTAL_READY interrupt\n"); return -ETIMEDOUT; } } @@ -425,7 +425,7 @@ static int cs43130_change_clksrc(struct snd_soc_codec *codec, CS43130_PLL_RDY_INT_MASK, 1 << CS43130_PLL_RDY_INT_SHIFT); if (ret == 0) { - dev_err(codec->dev, "Timeout waiting for PLL_READY interrupt\n"); + dev_err(component->dev, "Timeout waiting for PLL_READY interrupt\n"); return -ETIMEDOUT; } @@ -456,7 +456,7 @@ static int cs43130_change_clksrc(struct snd_soc_codec *codec, 1 << CS43130_PDN_PLL_SHIFT); break; default: - dev_err(codec->dev, "Invalid MCLK source value\n"); + dev_err(component->dev, "Invalid MCLK source value\n"); return -EINVAL; } @@ -774,8 +774,8 @@ static int cs43130_dsd_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); unsigned int required_clk; u8 dsd_speed; @@ -787,11 +787,11 @@ static int cs43130_dsd_hw_params(struct snd_pcm_substream *substream, else required_clk = CS43130_MCLK_24M; - cs43130_set_pll(codec, 0, 0, cs43130->mclk, required_clk); + cs43130_set_pll(component, 0, 0, cs43130->mclk, required_clk); if (cs43130->pll_bypass) - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_EXT); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_EXT); else - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_PLL); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_PLL); } cs43130->clk_req++; @@ -807,7 +807,7 @@ static int cs43130_dsd_hw_params(struct snd_pcm_substream *substream, dsd_speed = 1; break; default: - dev_err(codec->dev, "Rate(%u) not supported\n", + dev_err(component->dev, "Rate(%u) not supported\n", params_rate(params)); return -EINVAL; } @@ -833,8 +833,8 @@ static int cs43130_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); const struct cs43130_rate_map *rate_map; unsigned int sclk = cs43130->dais[dai->id].sclk; unsigned int bitwidth_sclk; @@ -850,11 +850,11 @@ static int cs43130_hw_params(struct snd_pcm_substream *substream, else required_clk = CS43130_MCLK_24M; - cs43130_set_pll(codec, 0, 0, cs43130->mclk, required_clk); + cs43130_set_pll(component, 0, 0, cs43130->mclk, required_clk); if (cs43130->pll_bypass) - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_EXT); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_EXT); else - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_PLL); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_PLL); } cs43130->clk_req++; @@ -878,7 +878,7 @@ static int cs43130_hw_params(struct snd_pcm_substream *substream, dsd_speed = 1; break; default: - dev_err(codec->dev, "Rate(%u) not supported\n", + dev_err(component->dev, "Rate(%u) not supported\n", params_rate(params)); return -EINVAL; } @@ -895,7 +895,7 @@ static int cs43130_hw_params(struct snd_pcm_substream *substream, regmap_write(cs43130->regmap, CS43130_SP_SRATE, rate_map->val); break; default: - dev_err(codec->dev, "Invalid DAI (%d)\n", dai->id); + dev_err(component->dev, "Invalid DAI (%d)\n", dai->id); return -EINVAL; } @@ -919,21 +919,21 @@ static int cs43130_hw_params(struct snd_pcm_substream *substream, if (!sclk) { /* at this point, SCLK must be set */ - dev_err(codec->dev, "SCLK freq is not set\n"); + dev_err(component->dev, "SCLK freq is not set\n"); return -EINVAL; } bitwidth_sclk = (sclk / params_rate(params)) / params_channels(params); if (bitwidth_sclk < bitwidth_dai) { - dev_err(codec->dev, "Format not supported: SCLK freq is too low\n"); + dev_err(component->dev, "Format not supported: SCLK freq is too low\n"); return -EINVAL; } - dev_dbg(codec->dev, + dev_dbg(component->dev, "sclk = %u, fs = %d, bitwidth_dai = %u\n", sclk, params_rate(params), bitwidth_dai); - dev_dbg(codec->dev, + dev_dbg(component->dev, "bitwidth_sclk = %u, num_ch = %u\n", bitwidth_sclk, params_channels(params)); @@ -946,14 +946,14 @@ static int cs43130_hw_params(struct snd_pcm_substream *substream, static int cs43130_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); mutex_lock(&cs43130->clk_mutex); cs43130->clk_req--; if (!cs43130->clk_req) { /* no DAI is currently using clk */ - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_RCO); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_RCO); cs43130_pcm_dsd_mix(false, cs43130->regmap); } mutex_unlock(&cs43130->clk_mutex); @@ -1023,8 +1023,8 @@ static int cs43130_pcm_ch_put(struct snd_kcontrol *kcontrol, { struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int *item = ucontrol->value.enumerated.item; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); unsigned int val; if (item[0] >= e->items) @@ -1144,8 +1144,8 @@ static const struct reg_sequence unmute_seq[] = { static int cs43130_dsd_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1192,7 +1192,7 @@ static int cs43130_dsd_event(struct snd_soc_dapm_widget *w, } break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); return -EINVAL; } return 0; @@ -1201,8 +1201,8 @@ static int cs43130_dsd_event(struct snd_soc_dapm_widget *w, static int cs43130_pcm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1249,7 +1249,7 @@ static int cs43130_pcm_event(struct snd_soc_dapm_widget *w, } break; default: - dev_err(codec->dev, "Invalid event = 0x%x\n", event); + dev_err(component->dev, "Invalid event = 0x%x\n", event); return -EINVAL; } return 0; @@ -1270,8 +1270,8 @@ static const struct reg_sequence dac_postpmd_seq[] = { static int cs43130_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1325,7 +1325,7 @@ static int cs43130_dac_event(struct snd_soc_dapm_widget *w, } break; default: - dev_err(codec->dev, "Invalid DAC event = 0x%x\n", event); + dev_err(component->dev, "Invalid DAC event = 0x%x\n", event); return -EINVAL; } return 0; @@ -1350,8 +1350,8 @@ static const struct reg_sequence hpin_postpmu_seq[] = { static int cs43130_hpin_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMD: @@ -1363,7 +1363,7 @@ static int cs43130_hpin_event(struct snd_soc_dapm_widget *w, ARRAY_SIZE(hpin_postpmu_seq)); break; default: - dev_err(codec->dev, "Invalid HPIN event = 0x%x\n", event); + dev_err(component->dev, "Invalid HPIN event = 0x%x\n", event); return -EINVAL; } return 0; @@ -1471,8 +1471,8 @@ static int cs43130_dop_startup(struct snd_pcm_substream *substream, static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: @@ -1482,7 +1482,7 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) cs43130->dais[codec_dai->id].dai_mode = SND_SOC_DAIFMT_CBM_CFM; break; default: - dev_err(codec->dev, "unsupported mode\n"); + dev_err(component->dev, "unsupported mode\n"); return -EINVAL; } @@ -1500,12 +1500,12 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) cs43130->dais[codec_dai->id].dai_format = SND_SOC_DAIFMT_DSP_B; break; default: - dev_err(codec->dev, + dev_err(component->dev, "unsupported audio format\n"); return -EINVAL; } - dev_dbg(codec->dev, "dai_id = %d, dai_mode = %u, dai_format = %u\n", + dev_dbg(component->dev, "dai_id = %d, dai_mode = %u, dai_format = %u\n", codec_dai->id, cs43130->dais[codec_dai->id].dai_mode, cs43130->dais[codec_dai->id].dai_format); @@ -1515,8 +1515,8 @@ static int cs43130_pcm_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int cs43130_dsd_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: @@ -1526,11 +1526,11 @@ static int cs43130_dsd_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) cs43130->dais[codec_dai->id].dai_mode = SND_SOC_DAIFMT_CBM_CFM; break; default: - dev_err(codec->dev, "Unsupported DAI format.\n"); + dev_err(component->dev, "Unsupported DAI format.\n"); return -EINVAL; } - dev_dbg(codec->dev, "dai_mode = 0x%x\n", + dev_dbg(component->dev, "dai_mode = 0x%x\n", cs43130->dais[codec_dai->id].dai_mode); return 0; @@ -1539,11 +1539,11 @@ static int cs43130_dsd_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int cs43130_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); cs43130->dais[codec_dai->id].sclk = freq; - dev_dbg(codec->dev, "dai_id = %d, sclk = %u\n", codec_dai->id, + dev_dbg(component->dev, "dai_id = %d, sclk = %u\n", codec_dai->id, cs43130->dais[codec_dai->id].sclk); return 0; @@ -1627,13 +1627,13 @@ static struct snd_soc_dai_driver cs43130_dai[] = { }; -static int cs43130_codec_set_sysclk(struct snd_soc_codec *codec, +static int cs43130_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "clk_id = %d, source = %d, freq = %d, dir = %d\n", + dev_dbg(component->dev, "clk_id = %d, source = %d, freq = %d, dir = %d\n", clk_id, source, freq, dir); switch (freq) { @@ -1642,14 +1642,14 @@ static int cs43130_codec_set_sysclk(struct snd_soc_codec *codec, cs43130->mclk = freq; break; default: - dev_err(codec->dev, "Invalid MCLK INT freq: %u\n", freq); + dev_err(component->dev, "Invalid MCLK INT freq: %u\n", freq); return -EINVAL; } if (source == CS43130_MCLK_SRC_EXT) { cs43130->pll_bypass = true; } else { - dev_err(codec->dev, "Invalid MCLK source\n"); + dev_err(component->dev, "Invalid MCLK source\n"); return -EINVAL; } @@ -1929,7 +1929,7 @@ static int cs43130_update_hpload(unsigned int msk, int ac_idx, unsigned int reg; u32 addr; u16 impedance; - struct snd_soc_codec *codec = cs43130->codec; + struct snd_soc_component *component = cs43130->component; switch (msk) { case CS43130_HPLOAD_DC_INT: @@ -1959,7 +1959,7 @@ static int cs43130_update_hpload(unsigned int msk, int ac_idx, else cs43130->hpload_dc[HP_RIGHT] = impedance; - dev_dbg(codec->dev, "HP DC impedance (Ch %u): %u\n", !left_ch, + dev_dbg(component->dev, "HP DC impedance (Ch %u): %u\n", !left_ch, impedance); } else { if (left_ch) @@ -1967,7 +1967,7 @@ static int cs43130_update_hpload(unsigned int msk, int ac_idx, else cs43130->hpload_ac[ac_idx][HP_RIGHT] = impedance; - dev_dbg(codec->dev, "HP AC (%u Hz) impedance (Ch %u): %u\n", + dev_dbg(component->dev, "HP AC (%u Hz) impedance (Ch %u): %u\n", cs43130->ac_freq[ac_idx], !left_ch, impedance); } @@ -1981,7 +1981,7 @@ static int cs43130_hpload_proc(struct cs43130_private *cs43130, int ret; unsigned int msk; u16 ac_reg_val; - struct snd_soc_codec *codec = cs43130->codec; + struct snd_soc_component *component = cs43130->component; reinit_completion(&cs43130->hpload_evt); @@ -2004,17 +2004,17 @@ static int cs43130_hpload_proc(struct cs43130_private *cs43130, msecs_to_jiffies(1000)); regmap_read(cs43130->regmap, CS43130_INT_MASK_4, &msk); if (!ret) { - dev_err(codec->dev, "Timeout waiting for HPLOAD interrupt\n"); + dev_err(component->dev, "Timeout waiting for HPLOAD interrupt\n"); return -1; } - dev_dbg(codec->dev, "HP load stat: %x, INT_MASK_4: %x\n", + dev_dbg(component->dev, "HP load stat: %x, INT_MASK_4: %x\n", cs43130->hpload_stat, msk); if ((cs43130->hpload_stat & (CS43130_HPLOAD_NO_DC_INT | CS43130_HPLOAD_UNPLUG_INT | CS43130_HPLOAD_OOR_INT)) || !(cs43130->hpload_stat & rslt_msk)) { - dev_dbg(codec->dev, "HP load measure failed\n"); + dev_dbg(component->dev, "HP load measure failed\n"); return -1; } @@ -2056,11 +2056,11 @@ static void cs43130_imp_meas(struct work_struct *wk) unsigned int reg, seq_size; int i, ret, ac_idx; struct cs43130_private *cs43130; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct reg_sequences *hpload_seq; cs43130 = container_of(wk, struct cs43130_private, work); - codec = cs43130->codec; + component = cs43130->component; if (!cs43130->mclk) return; @@ -2070,11 +2070,11 @@ static void cs43130_imp_meas(struct work_struct *wk) mutex_lock(&cs43130->clk_mutex); if (!cs43130->clk_req) { /* clk not in use */ - cs43130_set_pll(codec, 0, 0, cs43130->mclk, CS43130_MCLK_22M); + cs43130_set_pll(component, 0, 0, cs43130->mclk, CS43130_MCLK_22M); if (cs43130->pll_bypass) - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_EXT); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_EXT); else - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_PLL); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_PLL); } cs43130->clk_req++; @@ -2125,9 +2125,9 @@ static void cs43130_imp_meas(struct work_struct *wk) snd_soc_jack_report(&cs43130->jack, CS43130_JACK_HEADPHONE, CS43130_JACK_MASK); - dev_dbg(codec->dev, "Set HP output control. DC threshold\n"); + dev_dbg(component->dev, "Set HP output control. DC threshold\n"); for (i = 0; i < CS43130_DC_THRESHOLD; i++) - dev_dbg(codec->dev, "DC threshold[%d]: %u.\n", i, + dev_dbg(component->dev, "DC threshold[%d]: %u.\n", i, cs43130->dc_threshold[i]); cs43130_set_hv(cs43130->regmap, cs43130->hpload_dc[HP_LEFT], @@ -2154,14 +2154,14 @@ exit: cs43130->clk_req--; /* clk not in use */ if (!cs43130->clk_req) - cs43130_change_clksrc(codec, CS43130_MCLK_SRC_RCO); + cs43130_change_clksrc(component, CS43130_MCLK_SRC_RCO); mutex_unlock(&cs43130->clk_mutex); } static irqreturn_t cs43130_irq_thread(int irq, void *data) { struct cs43130_private *cs43130 = (struct cs43130_private *)data; - struct snd_soc_codec *codec = cs43130->codec; + struct snd_soc_component *component = cs43130->component; unsigned int stickies[CS43130_NUM_INT]; unsigned int irq_occurrence = 0; unsigned int masks[CS43130_NUM_INT]; @@ -2179,7 +2179,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) for (j = 0; j < 8; j++) irq_occurrence += (stickies[i] >> j) & 1; } - dev_dbg(codec->dev, "number of interrupts occurred (%u)\n", + dev_dbg(component->dev, "number of interrupts occurred (%u)\n", irq_occurrence); if (!irq_occurrence) @@ -2197,7 +2197,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_NO_DC_INT) { cs43130->hpload_stat = stickies[3]; - dev_err(codec->dev, + dev_err(component->dev, "DC load has not completed before AC load (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); @@ -2206,7 +2206,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_UNPLUG_INT) { cs43130->hpload_stat = stickies[3]; - dev_err(codec->dev, "HP unplugged during measurement (%x)\n", + dev_err(component->dev, "HP unplugged during measurement (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); return IRQ_HANDLED; @@ -2214,7 +2214,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_OOR_INT) { cs43130->hpload_stat = stickies[3]; - dev_err(codec->dev, "HP load out of range (%x)\n", + dev_err(component->dev, "HP load out of range (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); return IRQ_HANDLED; @@ -2222,7 +2222,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_AC_INT) { cs43130->hpload_stat = stickies[3]; - dev_dbg(codec->dev, "HP AC load measurement done (%x)\n", + dev_dbg(component->dev, "HP AC load measurement done (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); return IRQ_HANDLED; @@ -2230,7 +2230,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_DC_INT) { cs43130->hpload_stat = stickies[3]; - dev_dbg(codec->dev, "HP DC load measurement done (%x)\n", + dev_dbg(component->dev, "HP DC load measurement done (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); return IRQ_HANDLED; @@ -2238,7 +2238,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_ON_INT) { cs43130->hpload_stat = stickies[3]; - dev_dbg(codec->dev, "HP load state machine on done (%x)\n", + dev_dbg(component->dev, "HP load state machine on done (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); return IRQ_HANDLED; @@ -2246,19 +2246,19 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[3] & CS43130_HPLOAD_OFF_INT) { cs43130->hpload_stat = stickies[3]; - dev_dbg(codec->dev, "HP load state machine off done (%x)\n", + dev_dbg(component->dev, "HP load state machine off done (%x)\n", cs43130->hpload_stat); complete(&cs43130->hpload_evt); return IRQ_HANDLED; } if (stickies[0] & CS43130_XTAL_ERR_INT) { - dev_err(codec->dev, "Crystal err: clock is not running\n"); + dev_err(component->dev, "Crystal err: clock is not running\n"); return IRQ_HANDLED; } if (stickies[0] & CS43130_HP_UNPLUG_INT) { - dev_dbg(codec->dev, "HP unplugged\n"); + dev_dbg(component->dev, "HP unplugged\n"); cs43130->hpload_done = false; snd_soc_jack_report(&cs43130->jack, 0, CS43130_JACK_MASK); return IRQ_HANDLED; @@ -2267,7 +2267,7 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) if (stickies[0] & CS43130_HP_PLUG_INT) { if (cs43130->dc_meas && !cs43130->hpload_done && !work_busy(&cs43130->work)) { - dev_dbg(codec->dev, "HP load queue work\n"); + dev_dbg(component->dev, "HP load queue work\n"); queue_work(cs43130->wq, &cs43130->work); } @@ -2279,14 +2279,14 @@ static irqreturn_t cs43130_irq_thread(int irq, void *data) return IRQ_NONE; } -static int cs43130_probe(struct snd_soc_codec *codec) +static int cs43130_probe(struct snd_soc_component *component) { int ret; - struct cs43130_private *cs43130 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_card *card = codec->component.card; + struct cs43130_private *cs43130 = snd_soc_component_get_drvdata(component); + struct snd_soc_card *card = component->card; unsigned int reg; - cs43130->codec = codec; + cs43130->component = component; if (cs43130->xtal_ibias != CS43130_XTAL_UNUSED) { regmap_update_bits(cs43130->regmap, CS43130_CRYSTAL_SET, @@ -2299,25 +2299,25 @@ static int cs43130_probe(struct snd_soc_codec *codec) ret = snd_soc_card_jack_new(card, "Headphone", CS43130_JACK_MASK, &cs43130->jack, NULL, 0); if (ret < 0) { - dev_err(codec->dev, "Cannot create jack\n"); + dev_err(component->dev, "Cannot create jack\n"); return ret; } cs43130->hpload_done = false; if (cs43130->dc_meas) { - ret = device_create_file(codec->dev, &dev_attr_hpload_dc_l); + ret = device_create_file(component->dev, &dev_attr_hpload_dc_l); if (ret < 0) return ret; - ret = device_create_file(codec->dev, &dev_attr_hpload_dc_r); + ret = device_create_file(component->dev, &dev_attr_hpload_dc_r); if (ret < 0) return ret; - ret = device_create_file(codec->dev, &dev_attr_hpload_ac_l); + ret = device_create_file(component->dev, &dev_attr_hpload_ac_l); if (ret < 0) return ret; - ret = device_create_file(codec->dev, &dev_attr_hpload_ac_r); + ret = device_create_file(component->dev, &dev_attr_hpload_ac_r); if (ret < 0) return ret; @@ -2338,14 +2338,16 @@ static int cs43130_probe(struct snd_soc_codec *codec) return 0; } -static struct snd_soc_codec_driver soc_codec_dev_cs43130 = { +static struct snd_soc_component_driver soc_component_dev_cs43130 = { .probe = cs43130_probe, - .component_driver = { - .controls = cs43130_snd_controls, - .num_controls = ARRAY_SIZE(cs43130_snd_controls), - }, - .set_sysclk = cs43130_codec_set_sysclk, + .controls = cs43130_snd_controls, + .num_controls = ARRAY_SIZE(cs43130_snd_controls), + .set_sysclk = cs43130_component_set_sysclk, .set_pll = cs43130_set_pll, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config cs43130_regmap = { @@ -2536,33 +2538,34 @@ static int cs43130_i2c_probe(struct i2c_client *client, memcpy(all_hp_routes + ARRAY_SIZE(digital_hp_routes), analog_hp_routes, sizeof(analog_hp_routes)); - soc_codec_dev_cs43130.component_driver.dapm_widgets = + soc_component_dev_cs43130.dapm_widgets = all_hp_widgets; - soc_codec_dev_cs43130.component_driver.num_dapm_widgets = + soc_component_dev_cs43130.num_dapm_widgets = ARRAY_SIZE(all_hp_widgets); - soc_codec_dev_cs43130.component_driver.dapm_routes = + soc_component_dev_cs43130.dapm_routes = all_hp_routes; - soc_codec_dev_cs43130.component_driver.num_dapm_routes = + soc_component_dev_cs43130.num_dapm_routes = ARRAY_SIZE(all_hp_routes); break; case CS43198_CHIP_ID: case CS4399_CHIP_ID: - soc_codec_dev_cs43130.component_driver.dapm_widgets = + soc_component_dev_cs43130.dapm_widgets = digital_hp_widgets; - soc_codec_dev_cs43130.component_driver.num_dapm_widgets = + soc_component_dev_cs43130.num_dapm_widgets = ARRAY_SIZE(digital_hp_widgets); - soc_codec_dev_cs43130.component_driver.dapm_routes = + soc_component_dev_cs43130.dapm_routes = digital_hp_routes; - soc_codec_dev_cs43130.component_driver.num_dapm_routes = + soc_component_dev_cs43130.num_dapm_routes = ARRAY_SIZE(digital_hp_routes); break; } - ret = snd_soc_register_codec(&client->dev, &soc_codec_dev_cs43130, + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_cs43130, cs43130_dai, ARRAY_SIZE(cs43130_dai)); if (ret < 0) { dev_err(&client->dev, - "snd_soc_register_codec failed with ret = %d\n", ret); + "snd_soc_register_component failed with ret = %d\n", ret); goto err; } @@ -2604,8 +2607,6 @@ static int cs43130_i2c_remove(struct i2c_client *client) pm_runtime_disable(&client->dev); regulator_bulk_disable(CS43130_NUM_SUPPLIES, cs43130->supplies); - snd_soc_unregister_codec(&client->dev); - return 0; } diff --git a/sound/soc/codecs/cs43130.h b/sound/soc/codecs/cs43130.h index 781258418d89..c3c6eef61e87 100644 --- a/sound/soc/codecs/cs43130.h +++ b/sound/soc/codecs/cs43130.h @@ -508,7 +508,7 @@ struct cs43130_dai { }; struct cs43130_private { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *regmap; struct regulator_bulk_data supplies[CS43130_NUM_SUPPLIES]; struct gpio_desc *reset_gpio; From 534cf41c0c09e5c7b7aee706abcd3812ef17ae89 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:00:28 +0000 Subject: [PATCH 090/942] ASoC: cs53l30: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cs53l30.c | 57 ++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/sound/soc/codecs/cs53l30.c b/sound/soc/codecs/cs53l30.c index c7edf2df5e36..8995ea45b4ca 100644 --- a/sound/soc/codecs/cs53l30.c +++ b/sound/soc/codecs/cs53l30.c @@ -549,7 +549,7 @@ static int cs53l30_get_mclk_coeff(int mclk_rate, int srate) static int cs53l30_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); int mclkx_coeff; u32 mclk_rate; @@ -572,7 +572,7 @@ static int cs53l30_set_sysclk(struct snd_soc_dai *dai, static int cs53l30_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); u8 aspcfg = 0, aspctl1 = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -626,7 +626,7 @@ static int cs53l30_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); int srate = params_rate(params); int mclk_coeff; @@ -650,11 +650,11 @@ static int cs53l30_pcm_hw_params(struct snd_pcm_substream *substream, return 0; } -static int cs53l30_set_bias_level(struct snd_soc_codec *codec, +static int cs53l30_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(component); unsigned int reg; int i, inter_max_check, ret; @@ -670,7 +670,7 @@ static int cs53l30_set_bias_level(struct snd_soc_codec *codec, if (dapm->bias_level == SND_SOC_BIAS_OFF) { ret = clk_prepare_enable(priv->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "failed to enable MCLK: %d\n", ret); return ret; } @@ -736,7 +736,7 @@ static int cs53l30_set_bias_level(struct snd_soc_codec *codec, static int cs53l30_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); u8 val = tristate ? CS53L30_ASP_3ST : 0; return regmap_update_bits(priv->regmap, CS53L30_ASP_CTL1, @@ -770,7 +770,7 @@ static int cs53l30_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); unsigned int loc[CS53L30_TDM_SLOT_MAX] = {48, 48, 48, 48}; unsigned int slot_next, slot_step; u64 tx_enable = 0; @@ -840,7 +840,7 @@ static int cs53l30_set_dai_tdm_slot(struct snd_soc_dai *dai, static int cs53l30_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); gpiod_set_value_cansleep(priv->mute_gpio, mute); @@ -876,10 +876,10 @@ static struct snd_soc_dai_driver cs53l30_dai = { .symmetric_rates = 1, }; -static int cs53l30_codec_probe(struct snd_soc_codec *codec) +static int cs53l30_component_probe(struct snd_soc_component *component) { - struct cs53l30_private *priv = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct cs53l30_private *priv = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (priv->use_sdout2) snd_soc_dapm_add_routes(dapm, cs53l30_dapm_routes_sdout2, @@ -891,19 +891,18 @@ static int cs53l30_codec_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver cs53l30_driver = { - .probe = cs53l30_codec_probe, - .set_bias_level = cs53l30_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = cs53l30_snd_controls, - .num_controls = ARRAY_SIZE(cs53l30_snd_controls), - .dapm_widgets = cs53l30_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs53l30_dapm_widgets), - .dapm_routes = cs53l30_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(cs53l30_dapm_routes), - }, +static const struct snd_soc_component_driver cs53l30_driver = { + .probe = cs53l30_component_probe, + .set_bias_level = cs53l30_set_bias_level, + .controls = cs53l30_snd_controls, + .num_controls = ARRAY_SIZE(cs53l30_snd_controls), + .dapm_widgets = cs53l30_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs53l30_dapm_widgets), + .dapm_routes = cs53l30_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(cs53l30_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct regmap_config cs53l30_regmap = { @@ -1033,9 +1032,9 @@ static int cs53l30_i2c_probe(struct i2c_client *client, dev_info(dev, "Cirrus Logic CS53L30, Revision: %02X\n", reg & 0xFF); - ret = snd_soc_register_codec(dev, &cs53l30_driver, &cs53l30_dai, 1); + ret = devm_snd_soc_register_component(dev, &cs53l30_driver, &cs53l30_dai, 1); if (ret) { - dev_err(dev, "failed to register codec: %d\n", ret); + dev_err(dev, "failed to register component: %d\n", ret); goto error; } @@ -1051,8 +1050,6 @@ static int cs53l30_i2c_remove(struct i2c_client *client) { struct cs53l30_private *cs53l30 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); - /* Hold down reset */ gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); From 192ce2fb1a4052b4a2ee01f1cad2f39c0eebeb48 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:00:47 +0000 Subject: [PATCH 091/942] ASoC: da732x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da732x.c | 241 +++++++++++++++++++------------------- 1 file changed, 121 insertions(+), 120 deletions(-) diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c index 83db4d23c90b..de275df8f4ee 100644 --- a/sound/soc/codecs/da732x.c +++ b/sound/soc/codecs/da732x.c @@ -168,7 +168,7 @@ static const struct reg_default da732x_reg_cache[] = { { DA732X_REG_UNLOCK , 0x00 }, }; -static inline int da732x_get_input_div(struct snd_soc_codec *codec, int sysclk) +static inline int da732x_get_input_div(struct snd_soc_component *component, int sysclk) { int val; int ret; @@ -192,28 +192,28 @@ static inline int da732x_get_input_div(struct snd_soc_codec *codec, int sysclk) return -EINVAL; } - snd_soc_write(codec, DA732X_REG_PLL_CTRL, val); + snd_soc_component_write(component, DA732X_REG_PLL_CTRL, val); return ret; } -static void da732x_set_charge_pump(struct snd_soc_codec *codec, int state) +static void da732x_set_charge_pump(struct snd_soc_component *component, int state) { switch (state) { case DA732X_ENABLE_CP: - snd_soc_write(codec, DA732X_REG_CLK_EN2, DA732X_CP_CLK_EN); - snd_soc_write(codec, DA732X_REG_CP_HP2, DA732X_HP_CP_EN | + snd_soc_component_write(component, DA732X_REG_CLK_EN2, DA732X_CP_CLK_EN); + snd_soc_component_write(component, DA732X_REG_CP_HP2, DA732X_HP_CP_EN | DA732X_HP_CP_REG | DA732X_HP_CP_PULSESKIP); - snd_soc_write(codec, DA732X_REG_CP_CTRL1, DA732X_CP_EN | + snd_soc_component_write(component, DA732X_REG_CP_CTRL1, DA732X_CP_EN | DA732X_CP_CTRL_CPVDD1); - snd_soc_write(codec, DA732X_REG_CP_CTRL2, + snd_soc_component_write(component, DA732X_REG_CP_CTRL2, DA732X_CP_MANAGE_MAGNITUDE | DA732X_CP_BOOST); - snd_soc_write(codec, DA732X_REG_CP_CTRL3, DA732X_CP_1MHZ); + snd_soc_component_write(component, DA732X_REG_CP_CTRL3, DA732X_CP_1MHZ); break; case DA732X_DISABLE_CP: - snd_soc_write(codec, DA732X_REG_CLK_EN2, DA732X_CP_CLK_DIS); - snd_soc_write(codec, DA732X_REG_CP_HP2, DA732X_HP_CP_DIS); - snd_soc_write(codec, DA732X_REG_CP_CTRL1, DA723X_CP_DIS); + snd_soc_component_write(component, DA732X_REG_CLK_EN2, DA732X_CP_CLK_DIS); + snd_soc_component_write(component, DA732X_REG_CP_HP2, DA732X_HP_CP_DIS); + snd_soc_component_write(component, DA732X_REG_CP_CTRL1, DA723X_CP_DIS); break; default: pr_err("Wrong charge pump state\n"); @@ -331,7 +331,7 @@ static SOC_ENUM_SINGLE_DECL(da732x_adc2_voice_filter_enum, static int da732x_hpf_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; unsigned int reg = enum_ctrl->reg; unsigned int sel = ucontrol->value.enumerated.item[0]; @@ -351,7 +351,7 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol, return -EINVAL; } - snd_soc_update_bits(codec, reg, DA732X_HPF_MASK, bits); + snd_soc_component_update_bits(component, reg, DA732X_HPF_MASK, bits); return 0; } @@ -359,12 +359,12 @@ static int da732x_hpf_set(struct snd_kcontrol *kcontrol, static int da732x_hpf_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; unsigned int reg = enum_ctrl->reg; int val; - val = snd_soc_read(codec, reg) & DA732X_HPF_MASK; + val = snd_soc_component_read32(component, reg) & DA732X_HPF_MASK; switch (val) { case DA732X_HPF_VOICE_EN: @@ -609,18 +609,18 @@ static const struct snd_kcontrol_new da732x_snd_controls[] = { static int da732x_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: switch (w->reg) { case DA732X_REG_ADC1_PD: - snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, + snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3, DA732X_ADCA_BB_CLK_EN, DA732X_ADCA_BB_CLK_EN); break; case DA732X_REG_ADC2_PD: - snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, + snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3, DA732X_ADCC_BB_CLK_EN, DA732X_ADCC_BB_CLK_EN); break; @@ -628,24 +628,24 @@ static int da732x_adc_event(struct snd_soc_dapm_widget *w, return -EINVAL; } - snd_soc_update_bits(codec, w->reg, DA732X_ADC_RST_MASK, + snd_soc_component_update_bits(component, w->reg, DA732X_ADC_RST_MASK, DA732X_ADC_SET_ACT); - snd_soc_update_bits(codec, w->reg, DA732X_ADC_PD_MASK, + snd_soc_component_update_bits(component, w->reg, DA732X_ADC_PD_MASK, DA732X_ADC_ON); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, w->reg, DA732X_ADC_PD_MASK, + snd_soc_component_update_bits(component, w->reg, DA732X_ADC_PD_MASK, DA732X_ADC_OFF); - snd_soc_update_bits(codec, w->reg, DA732X_ADC_RST_MASK, + snd_soc_component_update_bits(component, w->reg, DA732X_ADC_RST_MASK, DA732X_ADC_SET_RST); switch (w->reg) { case DA732X_REG_ADC1_PD: - snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, + snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3, DA732X_ADCA_BB_CLK_EN, 0); break; case DA732X_REG_ADC2_PD: - snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, + snd_soc_component_update_bits(component, DA732X_REG_CLK_EN3, DA732X_ADCC_BB_CLK_EN, 0); break; default: @@ -663,16 +663,16 @@ static int da732x_adc_event(struct snd_soc_dapm_widget *w, static int da732x_out_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << w->shift) | DA732X_OUT_HIZ_EN, (1 << w->shift) | DA732X_OUT_HIZ_EN); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << w->shift) | DA732X_OUT_HIZ_EN, (1 << w->shift) | DA732X_OUT_HIZ_DIS); break; @@ -949,7 +949,7 @@ static int da732x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u32 aif = 0; u32 reg_aif; u32 fs; @@ -1011,15 +1011,15 @@ static int da732x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, reg_aif, DA732X_AIF_WORD_MASK, aif); - snd_soc_update_bits(codec, DA732X_REG_CLK_CTRL, DA732X_SR1_MASK, fs); + snd_soc_component_update_bits(component, reg_aif, DA732X_AIF_WORD_MASK, aif); + snd_soc_component_update_bits(component, DA732X_REG_CLK_CTRL, DA732X_SR1_MASK, fs); return 0; } static int da732x_set_dai_fmt(struct snd_soc_dai *dai, u32 fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u32 aif_mclk, pc_count; u32 reg_aif1, aif1; u32 reg_aif3, aif3; @@ -1107,29 +1107,29 @@ static int da732x_set_dai_fmt(struct snd_soc_dai *dai, u32 fmt) return -EINVAL; } - snd_soc_write(codec, DA732X_REG_AIF_MCLK, aif_mclk); - snd_soc_update_bits(codec, reg_aif1, DA732X_AIF1_CLK_MASK, aif1); - snd_soc_update_bits(codec, reg_aif3, DA732X_AIF_BCLK_INV | + snd_soc_component_write(component, DA732X_REG_AIF_MCLK, aif_mclk); + snd_soc_component_update_bits(component, reg_aif1, DA732X_AIF1_CLK_MASK, aif1); + snd_soc_component_update_bits(component, reg_aif3, DA732X_AIF_BCLK_INV | DA732X_AIF_WCLK_INV | DA732X_AIF_MODE_MASK, aif3); - snd_soc_write(codec, DA732X_REG_PC_CTRL, pc_count); + snd_soc_component_write(component, DA732X_REG_PC_CTRL, pc_count); return 0; } -static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id, +static int da732x_set_dai_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); + struct da732x_priv *da732x = snd_soc_component_get_drvdata(component); int fref, indiv; u8 div_lo, div_mid, div_hi; u64 frac_div; /* Disable PLL */ if (freq_out == 0) { - snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, + snd_soc_component_update_bits(component, DA732X_REG_PLL_CTRL, DA732X_PLL_EN, 0); da732x->pll_en = false; return 0; @@ -1147,17 +1147,17 @@ static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id, case 24576000: case 45160000: case 49152000: - snd_soc_write(codec, DA732X_REG_PLL_CTRL, + snd_soc_component_write(component, DA732X_REG_PLL_CTRL, DA732X_PLL_BYPASS); return 0; default: - dev_err(codec->dev, + dev_err(component->dev, "Cannot use PLL Bypass, invalid SYSCLK rate\n"); return -EINVAL; } } - indiv = da732x_get_input_div(codec, da732x->sysclk); + indiv = da732x_get_input_div(component, da732x->sysclk); if (indiv < 0) return indiv; @@ -1168,11 +1168,11 @@ static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id, div_mid = (frac_div >> DA732X_1BYTE_SHIFT) & DA732X_U8_MASK; div_lo = (frac_div) & DA732X_U8_MASK; - snd_soc_write(codec, DA732X_REG_PLL_DIV_LO, div_lo); - snd_soc_write(codec, DA732X_REG_PLL_DIV_MID, div_mid); - snd_soc_write(codec, DA732X_REG_PLL_DIV_HI, div_hi); + snd_soc_component_write(component, DA732X_REG_PLL_DIV_LO, div_lo); + snd_soc_component_write(component, DA732X_REG_PLL_DIV_MID, div_mid); + snd_soc_component_write(component, DA732X_REG_PLL_DIV_HI, div_hi); - snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, DA732X_PLL_EN, + snd_soc_component_update_bits(component, DA732X_REG_PLL_CTRL, DA732X_PLL_EN, DA732X_PLL_EN); da732x->pll_en = true; @@ -1183,8 +1183,8 @@ static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id, static int da732x_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct da732x_priv *da732x = snd_soc_component_get_drvdata(component); da732x->sysclk = freq; @@ -1268,21 +1268,21 @@ static const struct regmap_config da732x_regmap = { }; -static void da732x_dac_offset_adjust(struct snd_soc_codec *codec) +static void da732x_dac_offset_adjust(struct snd_soc_component *component) { u8 offset[DA732X_HP_DACS]; u8 sign[DA732X_HP_DACS]; u8 step = DA732X_DAC_OFFSET_STEP; /* Initialize DAC offset calibration circuits and registers */ - snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFFSET, DA732X_HP_DAC_OFFSET_TRIM_VAL); - snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFFSET, DA732X_HP_DAC_OFFSET_TRIM_VAL); - snd_soc_write(codec, DA732X_REG_HPL_DAC_OFF_CNTL, + snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFF_CNTL, DA732X_HP_DAC_OFF_CALIBRATION | DA732X_HP_DAC_OFF_SCALE_STEPS); - snd_soc_write(codec, DA732X_REG_HPR_DAC_OFF_CNTL, + snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFF_CNTL, DA732X_HP_DAC_OFF_CALIBRATION | DA732X_HP_DAC_OFF_SCALE_STEPS); @@ -1290,9 +1290,9 @@ static void da732x_dac_offset_adjust(struct snd_soc_codec *codec) msleep(DA732X_WAIT_FOR_STABILIZATION); /* Check DAC offset sign */ - sign[DA732X_HPL_DAC] = (snd_soc_read(codec, DA732X_REG_HPL_DAC_OFF_CNTL) & + sign[DA732X_HPL_DAC] = (snd_soc_component_read32(component, DA732X_REG_HPL_DAC_OFF_CNTL) & DA732X_HP_DAC_OFF_CNTL_COMPO); - sign[DA732X_HPR_DAC] = (snd_soc_read(codec, DA732X_REG_HPR_DAC_OFF_CNTL) & + sign[DA732X_HPR_DAC] = (snd_soc_component_read32(component, DA732X_REG_HPR_DAC_OFF_CNTL) & DA732X_HP_DAC_OFF_CNTL_COMPO); /* Binary search DAC offset values (both channels at once) */ @@ -1302,17 +1302,17 @@ static void da732x_dac_offset_adjust(struct snd_soc_codec *codec) do { offset[DA732X_HPL_DAC] |= step; offset[DA732X_HPR_DAC] |= step; - snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFFSET, ~offset[DA732X_HPL_DAC] & DA732X_HP_DAC_OFF_MASK); - snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFFSET, ~offset[DA732X_HPR_DAC] & DA732X_HP_DAC_OFF_MASK); msleep(DA732X_WAIT_FOR_STABILIZATION); - if ((snd_soc_read(codec, DA732X_REG_HPL_DAC_OFF_CNTL) & + if ((snd_soc_component_read32(component, DA732X_REG_HPL_DAC_OFF_CNTL) & DA732X_HP_DAC_OFF_CNTL_COMPO) ^ sign[DA732X_HPL_DAC]) offset[DA732X_HPL_DAC] &= ~step; - if ((snd_soc_read(codec, DA732X_REG_HPR_DAC_OFF_CNTL) & + if ((snd_soc_component_read32(component, DA732X_REG_HPR_DAC_OFF_CNTL) & DA732X_HP_DAC_OFF_CNTL_COMPO) ^ sign[DA732X_HPR_DAC]) offset[DA732X_HPR_DAC] &= ~step; @@ -1320,19 +1320,19 @@ static void da732x_dac_offset_adjust(struct snd_soc_codec *codec) } while (step); /* Write final DAC offsets to registers */ - snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFFSET, ~offset[DA732X_HPL_DAC] & DA732X_HP_DAC_OFF_MASK); - snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFFSET, ~offset[DA732X_HPR_DAC] & DA732X_HP_DAC_OFF_MASK); /* End DAC calibration mode */ - snd_soc_write(codec, DA732X_REG_HPL_DAC_OFF_CNTL, + snd_soc_component_write(component, DA732X_REG_HPL_DAC_OFF_CNTL, DA732X_HP_DAC_OFF_SCALE_STEPS); - snd_soc_write(codec, DA732X_REG_HPR_DAC_OFF_CNTL, + snd_soc_component_write(component, DA732X_REG_HPR_DAC_OFF_CNTL, DA732X_HP_DAC_OFF_SCALE_STEPS); } -static void da732x_output_offset_adjust(struct snd_soc_codec *codec) +static void da732x_output_offset_adjust(struct snd_soc_component *component) { u8 offset[DA732X_HP_AMPS]; u8 sign[DA732X_HP_AMPS]; @@ -1342,26 +1342,26 @@ static void da732x_output_offset_adjust(struct snd_soc_codec *codec) offset[DA732X_HPR_AMP] = DA732X_HP_OUT_TRIM_VAL; /* Initialize output offset calibration circuits and registers */ - snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL); - snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL); - snd_soc_write(codec, DA732X_REG_HPL, + snd_soc_component_write(component, DA732X_REG_HPL_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL); + snd_soc_component_write(component, DA732X_REG_HPR_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL); + snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_OUT_COMP | DA732X_HP_OUT_EN); - snd_soc_write(codec, DA732X_REG_HPR, + snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_OUT_COMP | DA732X_HP_OUT_EN); /* Wait for voltage stabilization */ msleep(DA732X_WAIT_FOR_STABILIZATION); /* Check output offset sign */ - sign[DA732X_HPL_AMP] = snd_soc_read(codec, DA732X_REG_HPL) & + sign[DA732X_HPL_AMP] = snd_soc_component_read32(component, DA732X_REG_HPL) & DA732X_HP_OUT_COMPO; - sign[DA732X_HPR_AMP] = snd_soc_read(codec, DA732X_REG_HPR) & + sign[DA732X_HPR_AMP] = snd_soc_component_read32(component, DA732X_REG_HPR) & DA732X_HP_OUT_COMPO; - snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_OUT_COMP | + snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_OUT_COMP | (sign[DA732X_HPL_AMP] >> DA732X_HP_OUT_COMPO_SHIFT) | DA732X_HP_OUT_EN); - snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_OUT_COMP | + snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_OUT_COMP | (sign[DA732X_HPR_AMP] >> DA732X_HP_OUT_COMPO_SHIFT) | DA732X_HP_OUT_EN); @@ -1369,17 +1369,17 @@ static void da732x_output_offset_adjust(struct snd_soc_codec *codec) do { offset[DA732X_HPL_AMP] |= step; offset[DA732X_HPR_AMP] |= step; - snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPL_OUT_OFFSET, offset[DA732X_HPL_AMP]); - snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, + snd_soc_component_write(component, DA732X_REG_HPR_OUT_OFFSET, offset[DA732X_HPR_AMP]); msleep(DA732X_WAIT_FOR_STABILIZATION); - if ((snd_soc_read(codec, DA732X_REG_HPL) & + if ((snd_soc_component_read32(component, DA732X_REG_HPL) & DA732X_HP_OUT_COMPO) ^ sign[DA732X_HPL_AMP]) offset[DA732X_HPL_AMP] &= ~step; - if ((snd_soc_read(codec, DA732X_REG_HPR) & + if ((snd_soc_component_read32(component, DA732X_REG_HPR) & DA732X_HP_OUT_COMPO) ^ sign[DA732X_HPR_AMP]) offset[DA732X_HPR_AMP] &= ~step; @@ -1387,80 +1387,80 @@ static void da732x_output_offset_adjust(struct snd_soc_codec *codec) } while (step); /* Write final DAC offsets to registers */ - snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, offset[DA732X_HPL_AMP]); - snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, offset[DA732X_HPR_AMP]); + snd_soc_component_write(component, DA732X_REG_HPL_OUT_OFFSET, offset[DA732X_HPL_AMP]); + snd_soc_component_write(component, DA732X_REG_HPR_OUT_OFFSET, offset[DA732X_HPR_AMP]); } -static void da732x_hp_dc_offset_cancellation(struct snd_soc_codec *codec) +static void da732x_hp_dc_offset_cancellation(struct snd_soc_component *component) { /* Make sure that we have Soft Mute enabled */ - snd_soc_write(codec, DA732X_REG_DAC1_SOFTMUTE, DA732X_SOFTMUTE_EN | + snd_soc_component_write(component, DA732X_REG_DAC1_SOFTMUTE, DA732X_SOFTMUTE_EN | DA732X_GAIN_RAMPED | DA732X_16_SAMPLES); - snd_soc_write(codec, DA732X_REG_DAC1_SEL, DA732X_DACL_EN | + snd_soc_component_write(component, DA732X_REG_DAC1_SEL, DA732X_DACL_EN | DA732X_DACR_EN | DA732X_DACL_SDM | DA732X_DACR_SDM | DA732X_DACL_MUTE | DA732X_DACR_MUTE); - snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_OUT_DAC_EN | + snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_OUT_DAC_EN | DA732X_HP_OUT_MUTE | DA732X_HP_OUT_EN); - snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_OUT_EN | + snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_OUT_EN | DA732X_HP_OUT_MUTE | DA732X_HP_OUT_DAC_EN); - da732x_dac_offset_adjust(codec); - da732x_output_offset_adjust(codec); + da732x_dac_offset_adjust(component); + da732x_output_offset_adjust(component); - snd_soc_write(codec, DA732X_REG_DAC1_SEL, DA732X_DACS_DIS); - snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_DIS); - snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_DIS); + snd_soc_component_write(component, DA732X_REG_DAC1_SEL, DA732X_DACS_DIS); + snd_soc_component_write(component, DA732X_REG_HPL, DA732X_HP_DIS); + snd_soc_component_write(component, DA732X_REG_HPR, DA732X_HP_DIS); } -static int da732x_set_bias_level(struct snd_soc_codec *codec, +static int da732x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); + struct da732x_priv *da732x = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, + snd_soc_component_update_bits(component, DA732X_REG_BIAS_EN, DA732X_BIAS_BOOST_MASK, DA732X_BIAS_BOOST_100PC); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Init Codec */ - snd_soc_write(codec, DA732X_REG_REF1, + snd_soc_component_write(component, DA732X_REG_REF1, DA732X_VMID_FASTCHG); - snd_soc_write(codec, DA732X_REG_BIAS_EN, + snd_soc_component_write(component, DA732X_REG_BIAS_EN, DA732X_BIAS_EN); mdelay(DA732X_STARTUP_DELAY); /* Disable Fast Charge and enable DAC ref voltage */ - snd_soc_write(codec, DA732X_REG_REF1, + snd_soc_component_write(component, DA732X_REG_REF1, DA732X_REFBUFX2_EN); /* Enable bypass DSP routing */ - snd_soc_write(codec, DA732X_REG_DATA_ROUTE, + snd_soc_component_write(component, DA732X_REG_DATA_ROUTE, DA732X_BYPASS_DSP); /* Enable Digital subsystem */ - snd_soc_write(codec, DA732X_REG_DSP_CTRL, + snd_soc_component_write(component, DA732X_REG_DSP_CTRL, DA732X_DIGITAL_EN); - snd_soc_write(codec, DA732X_REG_SPARE1_OUT, + snd_soc_component_write(component, DA732X_REG_SPARE1_OUT, DA732X_HP_DRIVER_EN | DA732X_HP_GATE_LOW | DA732X_HP_LOOP_GAIN_CTRL); - snd_soc_write(codec, DA732X_REG_HP_LIN1_GNDSEL, + snd_soc_component_write(component, DA732X_REG_HP_LIN1_GNDSEL, DA732X_HP_OUT_GNDSEL); - da732x_set_charge_pump(codec, DA732X_ENABLE_CP); + da732x_set_charge_pump(component, DA732X_ENABLE_CP); - snd_soc_write(codec, DA732X_REG_CLK_EN1, + snd_soc_component_write(component, DA732X_REG_CLK_EN1, DA732X_SYS3_CLK_EN | DA732X_PC_CLK_EN); /* Enable Zero Crossing */ - snd_soc_write(codec, DA732X_REG_INP_ZC_EN, + snd_soc_component_write(component, DA732X_REG_INP_ZC_EN, DA732X_MIC1_PRE_ZC_EN | DA732X_MIC1_ZC_EN | DA732X_MIC2_PRE_ZC_EN | @@ -1469,28 +1469,28 @@ static int da732x_set_bias_level(struct snd_soc_codec *codec, DA732X_AUXR_ZC_EN | DA732X_MIC3_PRE_ZC_EN | DA732X_MIC3_ZC_EN); - snd_soc_write(codec, DA732X_REG_OUT_ZC_EN, + snd_soc_component_write(component, DA732X_REG_OUT_ZC_EN, DA732X_HPL_ZC_EN | DA732X_HPR_ZC_EN | DA732X_LIN2_ZC_EN | DA732X_LIN3_ZC_EN | DA732X_LIN4_ZC_EN); - da732x_hp_dc_offset_cancellation(codec); + da732x_hp_dc_offset_cancellation(component); regcache_cache_only(da732x->regmap, false); regcache_sync(da732x->regmap); } else { - snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, + snd_soc_component_update_bits(component, DA732X_REG_BIAS_EN, DA732X_BIAS_BOOST_MASK, DA732X_BIAS_BOOST_50PC); - snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, + snd_soc_component_update_bits(component, DA732X_REG_PLL_CTRL, DA732X_PLL_EN, 0); da732x->pll_en = false; } break; case SND_SOC_BIAS_OFF: regcache_cache_only(da732x->regmap, true); - da732x_set_charge_pump(codec, DA732X_DISABLE_CP); - snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, DA732X_BIAS_EN, + da732x_set_charge_pump(component, DA732X_DISABLE_CP); + snd_soc_component_update_bits(component, DA732X_REG_BIAS_EN, DA732X_BIAS_EN, DA732X_BIAS_DIS); da732x->pll_en = false; break; @@ -1499,17 +1499,19 @@ static int da732x_set_bias_level(struct snd_soc_codec *codec, return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_da732x = { +static const struct snd_soc_component_driver soc_component_dev_da732x = { .set_bias_level = da732x_set_bias_level, - .component_driver = { - .controls = da732x_snd_controls, - .num_controls = ARRAY_SIZE(da732x_snd_controls), - .dapm_widgets = da732x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da732x_dapm_widgets), - .dapm_routes = da732x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(da732x_dapm_routes), - }, + .controls = da732x_snd_controls, + .num_controls = ARRAY_SIZE(da732x_snd_controls), + .dapm_widgets = da732x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da732x_dapm_widgets), + .dapm_routes = da732x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(da732x_dapm_routes), .set_pll = da732x_set_dai_pll, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int da732x_i2c_probe(struct i2c_client *i2c, @@ -1543,10 +1545,11 @@ static int da732x_i2c_probe(struct i2c_client *i2c, (reg & DA732X_ID_MAJOR_MASK) >> 4, (reg & DA732X_ID_MINOR_MASK)); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da732x, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_da732x, da732x_dai, ARRAY_SIZE(da732x_dai)); if (ret != 0) - dev_err(&i2c->dev, "Failed to register codec.\n"); + dev_err(&i2c->dev, "Failed to register component.\n"); err: return ret; @@ -1554,8 +1557,6 @@ err: static int da732x_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); - return 0; } From d06f33aed85cf73703555879157bf33866f8af05 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:01:06 +0000 Subject: [PATCH 092/942] ASoC: da7210: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da7210.c | 181 ++++++++++++++++++-------------------- 1 file changed, 84 insertions(+), 97 deletions(-) diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 1af443ccbc51..07153be52c52 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -331,12 +331,12 @@ static SOC_ENUM_SINGLE_DECL(da7210_hp_mode_sel, static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); if (ucontrol->value.integer.value[0]) { /* Check if noise suppression is enabled */ - if (snd_soc_read(codec, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { - dev_dbg(codec->dev, + if (snd_soc_component_read32(component, DA7210_CONTROL) & DA7210_NOISE_SUP_EN) { + dev_dbg(component->dev, "Disable noise suppression to enable ALC\n"); return -EINVAL; } @@ -354,32 +354,32 @@ static int da7210_put_alc_sw(struct snd_kcontrol *kcontrol, static int da7210_put_noise_sup_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); u8 val; if (ucontrol->value.integer.value[0]) { /* Check if ALC is enabled */ - if (snd_soc_read(codec, DA7210_ADC) & DA7210_ADC_ALC_EN) + if (snd_soc_component_read32(component, DA7210_ADC) & DA7210_ADC_ALC_EN) goto err; /* Check ZC for HP and AUX1 PGA */ - if ((snd_soc_read(codec, DA7210_ZERO_CROSS) & + if ((snd_soc_component_read32(component, DA7210_ZERO_CROSS) & (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) != (DA7210_AUX1_L_ZC | DA7210_AUX1_R_ZC | DA7210_HP_L_ZC | DA7210_HP_R_ZC)) goto err; /* Check INPGA_L_VOL and INPGA_R_VOL */ - val = snd_soc_read(codec, DA7210_IN_GAIN); + val = snd_soc_component_read32(component, DA7210_IN_GAIN); if (((val & DA7210_INPGA_L_VOL) < DA7210_INPGA_MIN_VOL_NS) || (((val & DA7210_INPGA_R_VOL) >> 4) < DA7210_INPGA_MIN_VOL_NS)) goto err; /* Check AUX1_L_VOL and AUX1_R_VOL */ - if (((snd_soc_read(codec, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < + if (((snd_soc_component_read32(component, DA7210_AUX1_L) & DA7210_AUX1_L_VOL) < DA7210_AUX1_MIN_VOL_NS) || - ((snd_soc_read(codec, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < + ((snd_soc_component_read32(component, DA7210_AUX1_R) & DA7210_AUX1_R_VOL) < DA7210_AUX1_MIN_VOL_NS)) goto err; } @@ -760,19 +760,19 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); u32 dai_cfg1; u32 fs, sysclk; /* set DAI source to Left and Right ADC */ - snd_soc_write(codec, DA7210_DAI_SRC_SEL, + snd_soc_component_write(component, DA7210_DAI_SRC_SEL, DA7210_DAI_OUT_R_SRC | DA7210_DAI_OUT_L_SRC); /* Enable DAI */ - snd_soc_write(codec, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); + snd_soc_component_write(component, DA7210_DAI_CFG3, DA7210_DAI_OE | DA7210_DAI_EN); - dai_cfg1 = 0xFC & snd_soc_read(codec, DA7210_DAI_CFG1); + dai_cfg1 = 0xFC & snd_soc_component_read32(component, DA7210_DAI_CFG1); switch (params_width(params)) { case 16: @@ -791,7 +791,7 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); + snd_soc_component_write(component, DA7210_DAI_CFG1, dai_cfg1); switch (params_rate(params)) { case 8000: @@ -839,17 +839,17 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, } /* Disable active mode */ - snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); + snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); - snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_FS_MASK, fs); + snd_soc_component_update_bits(component, DA7210_PLL, DA7210_PLL_FS_MASK, fs); if (da7210->mclk_rate && (da7210->mclk_rate != sysclk)) { /* PLL mode, disable PLL bypass */ - snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, 0); + snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_BYP, 0); if (!da7210->master) { /* PLL slave mode, also enable SRM */ - snd_soc_update_bits(codec, DA7210_PLL, + snd_soc_component_update_bits(component, DA7210_PLL, (DA7210_MCLK_SRM_EN | DA7210_MCLK_DET_EN), (DA7210_MCLK_SRM_EN | @@ -857,13 +857,13 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, } } else { /* PLL bypass mode, enable PLL bypass and Auto Detection */ - snd_soc_update_bits(codec, DA7210_PLL, DA7210_MCLK_DET_EN, + snd_soc_component_update_bits(component, DA7210_PLL, DA7210_MCLK_DET_EN, DA7210_MCLK_DET_EN); - snd_soc_update_bits(codec, DA7210_PLL_DIV3, DA7210_PLL_BYP, + snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_BYP, DA7210_PLL_BYP); } /* Enable active mode */ - snd_soc_update_bits(codec, DA7210_STARTUP1, + snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, DA7210_SC_MST_EN); return 0; @@ -874,16 +874,16 @@ static int da7210_hw_params(struct snd_pcm_substream *substream, */ static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); u32 dai_cfg1; u32 dai_cfg3; - dai_cfg1 = 0x7f & snd_soc_read(codec, DA7210_DAI_CFG1); - dai_cfg3 = 0xfc & snd_soc_read(codec, DA7210_DAI_CFG3); + dai_cfg1 = 0x7f & snd_soc_component_read32(component, DA7210_DAI_CFG1); + dai_cfg3 = 0xfc & snd_soc_component_read32(component, DA7210_DAI_CFG3); - if ((snd_soc_read(codec, DA7210_PLL) & DA7210_PLL_EN) && - (!(snd_soc_read(codec, DA7210_PLL_DIV3) & DA7210_PLL_BYP))) + if ((snd_soc_component_read32(component, DA7210_PLL) & DA7210_PLL_EN) && + (!(snd_soc_component_read32(component, DA7210_PLL_DIV3) & DA7210_PLL_BYP))) return -EINVAL; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -923,21 +923,21 @@ static int da7210_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) */ dai_cfg1 |= DA7210_DAI_FLEN_64BIT; - snd_soc_write(codec, DA7210_DAI_CFG1, dai_cfg1); - snd_soc_write(codec, DA7210_DAI_CFG3, dai_cfg3); + snd_soc_component_write(component, DA7210_DAI_CFG1, dai_cfg1); + snd_soc_component_write(component, DA7210_DAI_CFG3, dai_cfg3); return 0; } static int da7210_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u8 mute_reg = snd_soc_read(codec, DA7210_DAC_HPF) & 0xFB; + struct snd_soc_component *component = dai->component; + u8 mute_reg = snd_soc_component_read32(component, DA7210_DAC_HPF) & 0xFB; if (mute) - snd_soc_write(codec, DA7210_DAC_HPF, mute_reg | 0x4); + snd_soc_component_write(component, DA7210_DAC_HPF, mute_reg | 0x4); else - snd_soc_write(codec, DA7210_DAC_HPF, mute_reg); + snd_soc_component_write(component, DA7210_DAC_HPF, mute_reg); return 0; } @@ -947,8 +947,8 @@ static int da7210_mute(struct snd_soc_dai *dai, int mute) static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); switch (clk_id) { case DA7210_CLKSRC_MCLK: @@ -988,8 +988,8 @@ static int da7210_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int fref, unsigned int fout) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); u8 pll_div1, pll_div2, pll_div3, cnt; @@ -1014,18 +1014,18 @@ static int da7210_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, goto err; /* Disable active mode */ - snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); + snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, 0); /* Write PLL dividers */ - snd_soc_write(codec, DA7210_PLL_DIV1, pll_div1); - snd_soc_write(codec, DA7210_PLL_DIV2, pll_div2); - snd_soc_update_bits(codec, DA7210_PLL_DIV3, + snd_soc_component_write(component, DA7210_PLL_DIV1, pll_div1); + snd_soc_component_write(component, DA7210_PLL_DIV2, pll_div2); + snd_soc_component_update_bits(component, DA7210_PLL_DIV3, DA7210_PLL_DIV_L_MASK, pll_div3); /* Enable PLL */ - snd_soc_update_bits(codec, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); + snd_soc_component_update_bits(component, DA7210_PLL, DA7210_PLL_EN, DA7210_PLL_EN); /* Enable active mode */ - snd_soc_update_bits(codec, DA7210_STARTUP1, DA7210_SC_MST_EN, + snd_soc_component_update_bits(component, DA7210_STARTUP1, DA7210_SC_MST_EN, DA7210_SC_MST_EN); return 0; err: @@ -1064,53 +1064,53 @@ static struct snd_soc_dai_driver da7210_dai = { .symmetric_rates = 1, }; -static int da7210_probe(struct snd_soc_codec *codec) +static int da7210_probe(struct snd_soc_component *component) { - struct da7210_priv *da7210 = snd_soc_codec_get_drvdata(codec); + struct da7210_priv *da7210 = snd_soc_component_get_drvdata(component); - dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); + dev_info(component->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); da7210->mclk_rate = 0; /* This will be set from set_sysclk() */ da7210->master = 0; /* This will be set from set_fmt() */ /* Enable internal regulator & bias current */ - snd_soc_write(codec, DA7210_CONTROL, DA7210_REG_EN | DA7210_BIAS_EN); + snd_soc_component_write(component, DA7210_CONTROL, DA7210_REG_EN | DA7210_BIAS_EN); /* * ADC settings */ /* Enable Left & Right MIC PGA and Mic Bias */ - snd_soc_write(codec, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); - snd_soc_write(codec, DA7210_MIC_R, DA7210_MIC_R_EN); + snd_soc_component_write(component, DA7210_MIC_L, DA7210_MIC_L_EN | DA7210_MICBIAS_EN); + snd_soc_component_write(component, DA7210_MIC_R, DA7210_MIC_R_EN); /* Enable Left and Right input PGA */ - snd_soc_write(codec, DA7210_INMIX_L, DA7210_IN_L_EN); - snd_soc_write(codec, DA7210_INMIX_R, DA7210_IN_R_EN); + snd_soc_component_write(component, DA7210_INMIX_L, DA7210_IN_L_EN); + snd_soc_component_write(component, DA7210_INMIX_R, DA7210_IN_R_EN); /* Enable Left and Right ADC */ - snd_soc_write(codec, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); + snd_soc_component_write(component, DA7210_ADC, DA7210_ADC_L_EN | DA7210_ADC_R_EN); /* * DAC settings */ /* Enable Left and Right DAC */ - snd_soc_write(codec, DA7210_DAC_SEL, + snd_soc_component_write(component, DA7210_DAC_SEL, DA7210_DAC_L_SRC_DAI_L | DA7210_DAC_L_EN | DA7210_DAC_R_SRC_DAI_R | DA7210_DAC_R_EN); /* Enable Left and Right out PGA */ - snd_soc_write(codec, DA7210_OUTMIX_L, DA7210_OUT_L_EN); - snd_soc_write(codec, DA7210_OUTMIX_R, DA7210_OUT_R_EN); + snd_soc_component_write(component, DA7210_OUTMIX_L, DA7210_OUT_L_EN); + snd_soc_component_write(component, DA7210_OUTMIX_R, DA7210_OUT_R_EN); /* Enable Left and Right HeadPhone PGA */ - snd_soc_write(codec, DA7210_HP_CFG, + snd_soc_component_write(component, DA7210_HP_CFG, DA7210_HP_2CAP_MODE | DA7210_HP_SENSE_EN | DA7210_HP_L_EN | DA7210_HP_MODE | DA7210_HP_R_EN); /* Enable ramp mode for DAC gain update */ - snd_soc_write(codec, DA7210_SOFTMUTE, DA7210_RAMP_EN); + snd_soc_component_write(component, DA7210_SOFTMUTE, DA7210_RAMP_EN); /* * For DA7210 codec, there are two ways to enable/disable analog IOs @@ -1138,43 +1138,44 @@ static int da7210_probe(struct snd_soc_codec *codec) */ /* Enable Line out amplifiers */ - snd_soc_write(codec, DA7210_OUT1_L, DA7210_OUT1_L_EN); - snd_soc_write(codec, DA7210_OUT1_R, DA7210_OUT1_R_EN); - snd_soc_write(codec, DA7210_OUT2, DA7210_OUT2_EN | + snd_soc_component_write(component, DA7210_OUT1_L, DA7210_OUT1_L_EN); + snd_soc_component_write(component, DA7210_OUT1_R, DA7210_OUT1_R_EN); + snd_soc_component_write(component, DA7210_OUT2, DA7210_OUT2_EN | DA7210_OUT2_OUTMIX_L | DA7210_OUT2_OUTMIX_R); /* Enable Aux1 */ - snd_soc_write(codec, DA7210_AUX1_L, DA7210_AUX1_L_EN); - snd_soc_write(codec, DA7210_AUX1_R, DA7210_AUX1_R_EN); + snd_soc_component_write(component, DA7210_AUX1_L, DA7210_AUX1_L_EN); + snd_soc_component_write(component, DA7210_AUX1_R, DA7210_AUX1_R_EN); /* Enable Aux2 */ - snd_soc_write(codec, DA7210_AUX2, DA7210_AUX2_EN); + snd_soc_component_write(component, DA7210_AUX2, DA7210_AUX2_EN); /* Set PLL Master clock range 10-20 MHz, enable PLL bypass */ - snd_soc_write(codec, DA7210_PLL_DIV3, DA7210_MCLK_RANGE_10_20_MHZ | + snd_soc_component_write(component, DA7210_PLL_DIV3, DA7210_MCLK_RANGE_10_20_MHZ | DA7210_PLL_BYP); /* Diable PLL and bypass it */ - snd_soc_write(codec, DA7210_PLL, DA7210_PLL_FS_48000); + snd_soc_component_write(component, DA7210_PLL, DA7210_PLL_FS_48000); /* Activate all enabled subsystem */ - snd_soc_write(codec, DA7210_STARTUP1, DA7210_SC_MST_EN); + snd_soc_component_write(component, DA7210_STARTUP1, DA7210_SC_MST_EN); - dev_info(codec->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); + dev_info(component->dev, "DA7210 Audio Codec %s\n", DA7210_VERSION); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_da7210 = { +static const struct snd_soc_component_driver soc_component_dev_da7210 = { .probe = da7210_probe, - - .component_driver = { - .controls = da7210_snd_controls, - .num_controls = ARRAY_SIZE(da7210_snd_controls), - .dapm_widgets = da7210_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), - .dapm_routes = da7210_audio_map, - .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), - }, + .controls = da7210_snd_controls, + .num_controls = ARRAY_SIZE(da7210_snd_controls), + .dapm_widgets = da7210_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da7210_dapm_widgets), + .dapm_routes = da7210_audio_map, + .num_dapm_routes = ARRAY_SIZE(da7210_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #if IS_ENABLED(CONFIG_I2C) @@ -1232,20 +1233,14 @@ static int da7210_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_da7210, &da7210_dai, 1); + ret = snd_soc_register_component(&i2c->dev, + &soc_component_dev_da7210, &da7210_dai, 1); if (ret < 0) - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } -static int da7210_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id da7210_i2c_id[] = { { "da7210", 0 }, { } @@ -1258,7 +1253,6 @@ static struct i2c_driver da7210_i2c_driver = { .name = "da7210", }, .probe = da7210_i2c_probe, - .remove = da7210_i2c_remove, .id_table = da7210_i2c_id, }; #endif @@ -1325,24 +1319,17 @@ static int da7210_spi_probe(struct spi_device *spi) if (ret != 0) dev_warn(&spi->dev, "Failed to apply regmap patch: %d\n", ret); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_da7210, &da7210_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_da7210, &da7210_dai, 1); return ret; } -static int da7210_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver da7210_spi_driver = { .driver = { .name = "da7210", }, .probe = da7210_spi_probe, - .remove = da7210_spi_remove }; #endif From bc596c4256507040743d9bbbf2b78fc82ec45893 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:01:46 +0000 Subject: [PATCH 093/942] ASoC: da7218: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da7218.c | 498 +++++++++++++++++++------------------- sound/soc/codecs/da7218.h | 2 +- 2 files changed, 246 insertions(+), 254 deletions(-) diff --git a/sound/soc/codecs/da7218.c b/sound/soc/codecs/da7218.c index 96c644a15b11..ddc90ac0b19f 100644 --- a/sound/soc/codecs/da7218.c +++ b/sound/soc/codecs/da7218.c @@ -291,7 +291,7 @@ static const struct soc_enum da7218_cp_tau_delay = */ /* ALC */ -static void da7218_alc_calib(struct snd_soc_codec *codec) +static void da7218_alc_calib(struct snd_soc_component *component) { u8 mic_1_ctrl, mic_2_ctrl; u8 mixin_1_ctrl, mixin_2_ctrl; @@ -302,59 +302,59 @@ static void da7218_alc_calib(struct snd_soc_codec *codec) bool calibrated = false; /* Save current state of MIC control registers */ - mic_1_ctrl = snd_soc_read(codec, DA7218_MIC_1_CTRL); - mic_2_ctrl = snd_soc_read(codec, DA7218_MIC_2_CTRL); + mic_1_ctrl = snd_soc_component_read32(component, DA7218_MIC_1_CTRL); + mic_2_ctrl = snd_soc_component_read32(component, DA7218_MIC_2_CTRL); /* Save current state of input mixer control registers */ - mixin_1_ctrl = snd_soc_read(codec, DA7218_MIXIN_1_CTRL); - mixin_2_ctrl = snd_soc_read(codec, DA7218_MIXIN_2_CTRL); + mixin_1_ctrl = snd_soc_component_read32(component, DA7218_MIXIN_1_CTRL); + mixin_2_ctrl = snd_soc_component_read32(component, DA7218_MIXIN_2_CTRL); /* Save current state of input filter control registers */ - in_1l_filt_ctrl = snd_soc_read(codec, DA7218_IN_1L_FILTER_CTRL); - in_1r_filt_ctrl = snd_soc_read(codec, DA7218_IN_1R_FILTER_CTRL); - in_2l_filt_ctrl = snd_soc_read(codec, DA7218_IN_2L_FILTER_CTRL); - in_2r_filt_ctrl = snd_soc_read(codec, DA7218_IN_2R_FILTER_CTRL); + in_1l_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_1L_FILTER_CTRL); + in_1r_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_1R_FILTER_CTRL); + in_2l_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_2L_FILTER_CTRL); + in_2r_filt_ctrl = snd_soc_component_read32(component, DA7218_IN_2R_FILTER_CTRL); /* Save current state of input HPF control registers */ - in_1_hpf_ctrl = snd_soc_read(codec, DA7218_IN_1_HPF_FILTER_CTRL); - in_2_hpf_ctrl = snd_soc_read(codec, DA7218_IN_2_HPF_FILTER_CTRL); + in_1_hpf_ctrl = snd_soc_component_read32(component, DA7218_IN_1_HPF_FILTER_CTRL); + in_2_hpf_ctrl = snd_soc_component_read32(component, DA7218_IN_2_HPF_FILTER_CTRL); /* Enable then Mute MIC PGAs */ - snd_soc_update_bits(codec, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_EN_MASK, + snd_soc_component_update_bits(component, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_EN_MASK, DA7218_MIC_1_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_EN_MASK, + snd_soc_component_update_bits(component, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_EN_MASK, DA7218_MIC_2_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_MIC_1_CTRL, + snd_soc_component_update_bits(component, DA7218_MIC_1_CTRL, DA7218_MIC_1_AMP_MUTE_EN_MASK, DA7218_MIC_1_AMP_MUTE_EN_MASK); - snd_soc_update_bits(codec, DA7218_MIC_2_CTRL, + snd_soc_component_update_bits(component, DA7218_MIC_2_CTRL, DA7218_MIC_2_AMP_MUTE_EN_MASK, DA7218_MIC_2_AMP_MUTE_EN_MASK); /* Enable input mixers unmuted */ - snd_soc_update_bits(codec, DA7218_MIXIN_1_CTRL, + snd_soc_component_update_bits(component, DA7218_MIXIN_1_CTRL, DA7218_MIXIN_1_AMP_EN_MASK | DA7218_MIXIN_1_AMP_MUTE_EN_MASK, DA7218_MIXIN_1_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_MIXIN_2_CTRL, + snd_soc_component_update_bits(component, DA7218_MIXIN_2_CTRL, DA7218_MIXIN_2_AMP_EN_MASK | DA7218_MIXIN_2_AMP_MUTE_EN_MASK, DA7218_MIXIN_2_AMP_EN_MASK); /* Enable input filters unmuted */ - snd_soc_update_bits(codec, DA7218_IN_1L_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_1L_FILTER_CTRL, DA7218_IN_1L_FILTER_EN_MASK | DA7218_IN_1L_MUTE_EN_MASK, DA7218_IN_1L_FILTER_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_1R_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_1R_FILTER_CTRL, DA7218_IN_1R_FILTER_EN_MASK | DA7218_IN_1R_MUTE_EN_MASK, DA7218_IN_1R_FILTER_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_2L_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_2L_FILTER_CTRL, DA7218_IN_2L_FILTER_EN_MASK | DA7218_IN_2L_MUTE_EN_MASK, DA7218_IN_2L_FILTER_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_2R_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_2R_FILTER_CTRL, DA7218_IN_2R_FILTER_EN_MASK | DA7218_IN_2R_MUTE_EN_MASK, DA7218_IN_2R_FILTER_EN_MASK); @@ -364,16 +364,16 @@ static void da7218_alc_calib(struct snd_soc_codec *codec) * rates above 32KHz the ADC signals will be stopped and will cause * calibration to lock up. */ - snd_soc_update_bits(codec, DA7218_IN_1_HPF_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_1_HPF_FILTER_CTRL, DA7218_IN_1_VOICE_EN_MASK, 0); - snd_soc_update_bits(codec, DA7218_IN_2_HPF_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_2_HPF_FILTER_CTRL, DA7218_IN_2_VOICE_EN_MASK, 0); /* Perform auto calibration */ - snd_soc_update_bits(codec, DA7218_CALIB_CTRL, DA7218_CALIB_AUTO_EN_MASK, + snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, DA7218_CALIB_AUTO_EN_MASK, DA7218_CALIB_AUTO_EN_MASK); do { - calib_ctrl = snd_soc_read(codec, DA7218_CALIB_CTRL); + calib_ctrl = snd_soc_component_read32(component, DA7218_CALIB_CTRL); if (calib_ctrl & DA7218_CALIB_AUTO_EN_MASK) { ++i; usleep_range(DA7218_ALC_CALIB_DELAY_MIN, @@ -386,51 +386,51 @@ static void da7218_alc_calib(struct snd_soc_codec *codec) /* If auto calibration fails, disable DC offset, hybrid ALC */ if ((!calibrated) || (calib_ctrl & DA7218_CALIB_OVERFLOW_MASK)) { - dev_warn(codec->dev, + dev_warn(component->dev, "ALC auto calibration failed - %s\n", (calibrated) ? "overflow" : "timeout"); - snd_soc_update_bits(codec, DA7218_CALIB_CTRL, + snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, DA7218_CALIB_OFFSET_EN_MASK, 0); - snd_soc_update_bits(codec, DA7218_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7218_ALC_CTRL1, DA7218_ALC_SYNC_MODE_MASK, 0); } else { /* Enable DC offset cancellation */ - snd_soc_update_bits(codec, DA7218_CALIB_CTRL, + snd_soc_component_update_bits(component, DA7218_CALIB_CTRL, DA7218_CALIB_OFFSET_EN_MASK, DA7218_CALIB_OFFSET_EN_MASK); /* Enable ALC hybrid mode */ - snd_soc_update_bits(codec, DA7218_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7218_ALC_CTRL1, DA7218_ALC_SYNC_MODE_MASK, DA7218_ALC_SYNC_MODE_CH1 | DA7218_ALC_SYNC_MODE_CH2); } /* Restore input HPF control registers to original states */ - snd_soc_write(codec, DA7218_IN_1_HPF_FILTER_CTRL, in_1_hpf_ctrl); - snd_soc_write(codec, DA7218_IN_2_HPF_FILTER_CTRL, in_2_hpf_ctrl); + snd_soc_component_write(component, DA7218_IN_1_HPF_FILTER_CTRL, in_1_hpf_ctrl); + snd_soc_component_write(component, DA7218_IN_2_HPF_FILTER_CTRL, in_2_hpf_ctrl); /* Restore input filter control registers to original states */ - snd_soc_write(codec, DA7218_IN_1L_FILTER_CTRL, in_1l_filt_ctrl); - snd_soc_write(codec, DA7218_IN_1R_FILTER_CTRL, in_1r_filt_ctrl); - snd_soc_write(codec, DA7218_IN_2L_FILTER_CTRL, in_2l_filt_ctrl); - snd_soc_write(codec, DA7218_IN_2R_FILTER_CTRL, in_2r_filt_ctrl); + snd_soc_component_write(component, DA7218_IN_1L_FILTER_CTRL, in_1l_filt_ctrl); + snd_soc_component_write(component, DA7218_IN_1R_FILTER_CTRL, in_1r_filt_ctrl); + snd_soc_component_write(component, DA7218_IN_2L_FILTER_CTRL, in_2l_filt_ctrl); + snd_soc_component_write(component, DA7218_IN_2R_FILTER_CTRL, in_2r_filt_ctrl); /* Restore input mixer control registers to original state */ - snd_soc_write(codec, DA7218_MIXIN_1_CTRL, mixin_1_ctrl); - snd_soc_write(codec, DA7218_MIXIN_2_CTRL, mixin_2_ctrl); + snd_soc_component_write(component, DA7218_MIXIN_1_CTRL, mixin_1_ctrl); + snd_soc_component_write(component, DA7218_MIXIN_2_CTRL, mixin_2_ctrl); /* Restore MIC control registers to original states */ - snd_soc_write(codec, DA7218_MIC_1_CTRL, mic_1_ctrl); - snd_soc_write(codec, DA7218_MIC_2_CTRL, mic_2_ctrl); + snd_soc_component_write(component, DA7218_MIC_1_CTRL, mic_1_ctrl); + snd_soc_component_write(component, DA7218_MIC_2_CTRL, mic_2_ctrl); } static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); int ret; ret = snd_soc_put_volsw(kcontrol, ucontrol); @@ -440,7 +440,7 @@ static int da7218_mixin_gain_put(struct snd_kcontrol *kcontrol, * make sure calibrated offsets are updated. */ if ((ret == 1) && (da7218->alc_en)) - da7218_alc_calib(codec); + da7218_alc_calib(component); return ret; } @@ -450,8 +450,8 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *) kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); unsigned int lvalue = ucontrol->value.integer.value[0]; unsigned int rvalue = ucontrol->value.integer.value[1]; unsigned int lshift = mc->shift; @@ -460,7 +460,7 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, /* Force ALC offset calibration if enabling ALC */ if ((lvalue || rvalue) && (!da7218->alc_en)) - da7218_alc_calib(codec); + da7218_alc_calib(component); /* Update bits to detail which channels are enabled/disabled */ da7218->alc_en &= ~mask; @@ -473,8 +473,8 @@ static int da7218_alc_sw_put(struct snd_kcontrol *kcontrol, static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int reg = mixer_ctrl->reg; @@ -497,8 +497,8 @@ static int da7218_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int reg = mixer_ctrl->reg; @@ -517,8 +517,8 @@ static int da7218_tonegen_freq_put(struct snd_kcontrol *kcontrol, static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int lvalue = ucontrol->value.integer.value[0]; @@ -537,15 +537,15 @@ static int da7218_mic_lvl_det_sw_put(struct snd_kcontrol *kcontrol, * power the path (IN_FILTER widget events). This handling avoids * unwanted level detect events. */ - return snd_soc_write(codec, mixer_ctrl->reg, + return snd_soc_component_write(component, mixer_ctrl->reg, (da7218->in_filt_en & da7218->mic_lvl_det_en)); } static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int lshift = mixer_ctrl->shift; @@ -564,8 +564,8 @@ static int da7218_mic_lvl_det_sw_get(struct snd_kcontrol *kcontrol, static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; @@ -589,8 +589,8 @@ static int da7218_biquad_coeff_get(struct snd_kcontrol *kcontrol, static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *bytes_ext = (struct soc_bytes_ext *) kcontrol->private_value; u8 reg, out_filt1l; @@ -617,8 +617,8 @@ static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, } /* Make sure at least out filter1 enabled to allow programming */ - out_filt1l = snd_soc_read(codec, DA7218_OUT_1L_FILTER_CTRL); - snd_soc_write(codec, DA7218_OUT_1L_FILTER_CTRL, + out_filt1l = snd_soc_component_read32(component, DA7218_OUT_1L_FILTER_CTRL); + snd_soc_component_write(component, DA7218_OUT_1L_FILTER_CTRL, out_filt1l | DA7218_OUT_1L_FILTER_EN_MASK); for (i = 0; i < bytes_ext->max; ++i) { @@ -628,7 +628,7 @@ static int da7218_biquad_coeff_put(struct snd_kcontrol *kcontrol, } /* Restore filter to previous setting */ - snd_soc_write(codec, DA7218_OUT_1L_FILTER_CTRL, out_filt1l); + snd_soc_component_write(component, DA7218_OUT_1L_FILTER_CTRL, out_filt1l); return 0; } @@ -1349,8 +1349,8 @@ static const struct snd_kcontrol_new da7218_st_out_filtr_mix_controls[] = { static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); u8 mask; switch (w->reg) { @@ -1389,7 +1389,7 @@ static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, } /* Enable configured level detection paths */ - snd_soc_write(codec, DA7218_LVL_DET_CTRL, + snd_soc_component_write(component, DA7218_LVL_DET_CTRL, (da7218->in_filt_en & da7218->mic_lvl_det_en)); return 0; @@ -1398,8 +1398,8 @@ static int da7218_in_filter_event(struct snd_soc_dapm_widget *w, static int da7218_dai_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, pll_status, refosc_cal; int i; bool success; @@ -1408,14 +1408,14 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: if (da7218->master) /* Enable DAI clks for master mode */ - snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, DA7218_DAI_CLK_EN_MASK, DA7218_DAI_CLK_EN_MASK); /* Tune reference oscillator */ - snd_soc_write(codec, DA7218_PLL_REFOSC_CAL, + snd_soc_component_write(component, DA7218_PLL_REFOSC_CAL, DA7218_PLL_REFOSC_CAL_START_MASK); - snd_soc_write(codec, DA7218_PLL_REFOSC_CAL, + snd_soc_component_write(component, DA7218_PLL_REFOSC_CAL, DA7218_PLL_REFOSC_CAL_START_MASK | DA7218_PLL_REFOSC_CAL_EN_MASK); @@ -1423,7 +1423,7 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, i = 0; success = false; do { - refosc_cal = snd_soc_read(codec, DA7218_PLL_REFOSC_CAL); + refosc_cal = snd_soc_component_read32(component, DA7218_PLL_REFOSC_CAL); if (!(refosc_cal & DA7218_PLL_REFOSC_CAL_START_MASK)) { success = true; } else { @@ -1434,15 +1434,15 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, } while ((i < DA7218_REF_OSC_CHECK_TRIES) && (!success)); if (!success) - dev_warn(codec->dev, + dev_warn(component->dev, "Reference oscillator failed calibration\n"); /* PC synchronised to DAI */ - snd_soc_write(codec, DA7218_PC_COUNT, + snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_RESYNC_AUTO_MASK); /* If SRM not enabled, we don't need to check status */ - pll_ctrl = snd_soc_read(codec, DA7218_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7218_PLL_CTRL); if ((pll_ctrl & DA7218_PLL_MODE_MASK) != DA7218_PLL_MODE_SRM) return 0; @@ -1450,7 +1450,7 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, i = 0; success = false; do { - pll_status = snd_soc_read(codec, DA7218_PLL_STATUS); + pll_status = snd_soc_component_read32(component, DA7218_PLL_STATUS); if (pll_status & DA7218_PLL_SRM_STATUS_SRM_LOCK) { success = true; } else { @@ -1460,16 +1460,16 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, } while ((i < DA7218_SRM_CHECK_TRIES) && (!success)); if (!success) - dev_warn(codec->dev, "SRM failed to lock\n"); + dev_warn(component->dev, "SRM failed to lock\n"); return 0; case SND_SOC_DAPM_POST_PMD: /* PC free-running */ - snd_soc_write(codec, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); + snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); if (da7218->master) /* Disable DAI clks for master mode */ - snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, DA7218_DAI_CLK_EN_MASK, 0); return 0; @@ -1481,8 +1481,8 @@ static int da7218_dai_event(struct snd_soc_dapm_widget *w, static int da7218_cp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); /* * If this is DA7217 and we're using single supply for differential @@ -1493,11 +1493,11 @@ static int da7218_cp_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, DA7218_CP_CTRL, DA7218_CP_EN_MASK, + snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_EN_MASK, DA7218_CP_EN_MASK); return 0; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, DA7218_CP_CTRL, DA7218_CP_EN_MASK, + snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_EN_MASK, 0); return 0; default: @@ -1508,17 +1508,17 @@ static int da7218_cp_event(struct snd_soc_dapm_widget *w, static int da7218_hp_pga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: /* Enable headphone output */ - snd_soc_update_bits(codec, w->reg, DA7218_HP_AMP_OE_MASK, + snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, DA7218_HP_AMP_OE_MASK); return 0; case SND_SOC_DAPM_PRE_PMD: /* Headphone output high impedance */ - snd_soc_update_bits(codec, w->reg, DA7218_HP_AMP_OE_MASK, 0); + snd_soc_component_update_bits(component, w->reg, DA7218_HP_AMP_OE_MASK, 0); return 0; default: return -EINVAL; @@ -1813,8 +1813,8 @@ static const struct snd_soc_dapm_route da7218_audio_map[] = { static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); int ret; if (da7218->mclk_rate == freq) @@ -1828,12 +1828,12 @@ static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, switch (clk_id) { case DA7218_CLKSRC_MCLK_SQR: - snd_soc_update_bits(codec, DA7218_PLL_CTRL, + snd_soc_component_update_bits(component, DA7218_PLL_CTRL, DA7218_PLL_MCLK_SQR_EN_MASK, DA7218_PLL_MCLK_SQR_EN_MASK); break; case DA7218_CLKSRC_MCLK: - snd_soc_update_bits(codec, DA7218_PLL_CTRL, + snd_soc_component_update_bits(component, DA7218_PLL_CTRL, DA7218_PLL_MCLK_SQR_EN_MASK, 0); break; default: @@ -1859,8 +1859,8 @@ static int da7218_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int fref, unsigned int fout) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, indiv_bits, indiv; u8 pll_frac_top, pll_frac_bot, pll_integer; @@ -1869,7 +1869,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ if (da7218->mclk_rate < 2000000) { - dev_err(codec->dev, "PLL input clock %d below valid range\n", + dev_err(component->dev, "PLL input clock %d below valid range\n", da7218->mclk_rate); return -EINVAL; } else if (da7218->mclk_rate <= 4500000) { @@ -1888,7 +1888,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, indiv_bits = DA7218_PLL_INDIV_36_TO_54_MHZ; indiv = DA7218_PLL_INDIV_36_TO_54_MHZ_VAL; } else { - dev_err(codec->dev, "PLL input clock %d above valid range\n", + dev_err(component->dev, "PLL input clock %d above valid range\n", da7218->mclk_rate); return -EINVAL; } @@ -1899,7 +1899,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, switch (source) { case DA7218_SYSCLK_MCLK: pll_ctrl |= DA7218_PLL_MODE_BYPASS; - snd_soc_update_bits(codec, DA7218_PLL_CTRL, + snd_soc_component_update_bits(component, DA7218_PLL_CTRL, DA7218_PLL_INDIV_MASK | DA7218_PLL_MODE_MASK, pll_ctrl); return 0; @@ -1910,7 +1910,7 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, pll_ctrl |= DA7218_PLL_MODE_SRM; break; default: - dev_err(codec->dev, "Invalid PLL config\n"); + dev_err(component->dev, "Invalid PLL config\n"); return -EINVAL; } @@ -1922,10 +1922,10 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, pll_frac_bot = (frac_div) & DA7218_BYTE_MASK; /* Write PLL config & dividers */ - snd_soc_write(codec, DA7218_PLL_FRAC_TOP, pll_frac_top); - snd_soc_write(codec, DA7218_PLL_FRAC_BOT, pll_frac_bot); - snd_soc_write(codec, DA7218_PLL_INTEGER, pll_integer); - snd_soc_update_bits(codec, DA7218_PLL_CTRL, + snd_soc_component_write(component, DA7218_PLL_FRAC_TOP, pll_frac_top); + snd_soc_component_write(component, DA7218_PLL_FRAC_BOT, pll_frac_bot); + snd_soc_component_write(component, DA7218_PLL_INTEGER, pll_integer); + snd_soc_component_update_bits(component, DA7218_PLL_CTRL, DA7218_PLL_MODE_MASK | DA7218_PLL_INDIV_MASK, pll_ctrl); @@ -1934,8 +1934,8 @@ static int da7218_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); u8 dai_clk_mode = 0, dai_ctrl = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -2012,8 +2012,8 @@ static int da7218_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* By default 64 BCLKs per WCLK is supported */ dai_clk_mode |= DA7218_DAI_BCLKS_PER_WCLK_64; - snd_soc_write(codec, DA7218_DAI_CLK_MODE, dai_clk_mode); - snd_soc_update_bits(codec, DA7218_DAI_CTRL, DA7218_DAI_FORMAT_MASK, + snd_soc_component_write(component, DA7218_DAI_CLK_MODE, dai_clk_mode); + snd_soc_component_update_bits(component, DA7218_DAI_CTRL, DA7218_DAI_FORMAT_MASK, dai_ctrl); return 0; @@ -2023,16 +2023,16 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 dai_bclks_per_wclk; u32 frame_size; /* No channels enabled so disable TDM, revert to 64-bit frames */ if (!tx_mask) { - snd_soc_update_bits(codec, DA7218_DAI_TDM_CTRL, + snd_soc_component_update_bits(component, DA7218_DAI_TDM_CTRL, DA7218_DAI_TDM_CH_EN_MASK | DA7218_DAI_TDM_MODE_EN_MASK, 0); - snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, DA7218_DAI_BCLKS_PER_WCLK_MASK, DA7218_DAI_BCLKS_PER_WCLK_64); return 0; @@ -2040,14 +2040,14 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai, /* Check we have valid slots */ if (fls(tx_mask) > DA7218_DAI_TDM_MAX_SLOTS) { - dev_err(codec->dev, "Invalid number of slots, max = %d\n", + dev_err(component->dev, "Invalid number of slots, max = %d\n", DA7218_DAI_TDM_MAX_SLOTS); return -EINVAL; } /* Check we have a valid offset given (first 2 bytes of rx_mask) */ if (rx_mask >> DA7218_2BYTE_SHIFT) { - dev_err(codec->dev, "Invalid slot offset, max = %d\n", + dev_err(component->dev, "Invalid slot offset, max = %d\n", DA7218_2BYTE_MASK); return -EINVAL; } @@ -2068,18 +2068,18 @@ static int da7218_set_dai_tdm_slot(struct snd_soc_dai *dai, dai_bclks_per_wclk = DA7218_DAI_BCLKS_PER_WCLK_256; break; default: - dev_err(codec->dev, "Invalid frame size\n"); + dev_err(component->dev, "Invalid frame size\n"); return -EINVAL; } - snd_soc_update_bits(codec, DA7218_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7218_DAI_CLK_MODE, DA7218_DAI_BCLKS_PER_WCLK_MASK, dai_bclks_per_wclk); - snd_soc_write(codec, DA7218_DAI_OFFSET_LOWER, + snd_soc_component_write(component, DA7218_DAI_OFFSET_LOWER, (rx_mask & DA7218_BYTE_MASK)); - snd_soc_write(codec, DA7218_DAI_OFFSET_UPPER, + snd_soc_component_write(component, DA7218_DAI_OFFSET_UPPER, ((rx_mask >> DA7218_BYTE_SHIFT) & DA7218_BYTE_MASK)); - snd_soc_update_bits(codec, DA7218_DAI_TDM_CTRL, + snd_soc_component_update_bits(component, DA7218_DAI_TDM_CTRL, DA7218_DAI_TDM_CH_EN_MASK | DA7218_DAI_TDM_MODE_EN_MASK, (tx_mask << DA7218_DAI_TDM_CH_EN_SHIFT) | @@ -2092,7 +2092,7 @@ static int da7218_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 dai_ctrl = 0, fs; unsigned int channels; @@ -2115,7 +2115,7 @@ static int da7218_hw_params(struct snd_pcm_substream *substream, channels = params_channels(params); if ((channels < 1) || (channels > DA7218_DAI_CH_NUM_MAX)) { - dev_err(codec->dev, + dev_err(component->dev, "Invalid number of channels, only 1 to %d supported\n", DA7218_DAI_CH_NUM_MAX); return -EINVAL; @@ -2160,11 +2160,11 @@ static int da7218_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, DA7218_DAI_CTRL, + snd_soc_component_update_bits(component, DA7218_DAI_CTRL, DA7218_DAI_WORD_LENGTH_MASK | DA7218_DAI_CH_NUM_MASK, dai_ctrl); /* SRs tied for ADCs and DACs. */ - snd_soc_write(codec, DA7218_SR, + snd_soc_component_write(component, DA7218_SR, (fs << DA7218_SR_DAC_SHIFT) | (fs << DA7218_SR_ADC_SHIFT)); return 0; @@ -2208,15 +2208,15 @@ static struct snd_soc_dai_driver da7218_dai = { * HP Detect */ -int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int da7218_hpldet(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); if (da7218->dev_id == DA7217_DEV_ID) return -EINVAL; da7218->jack = jack; - snd_soc_update_bits(codec, DA7218_HPLDET_JACK, + snd_soc_component_update_bits(component, DA7218_HPLDET_JACK, DA7218_HPLDET_JACK_EN_MASK, jack ? DA7218_HPLDET_JACK_EN_MASK : 0); @@ -2224,23 +2224,23 @@ int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack) } EXPORT_SYMBOL_GPL(da7218_hpldet); -static void da7218_micldet_irq(struct snd_soc_codec *codec) +static void da7218_micldet_irq(struct snd_soc_component *component) { char *envp[] = { "EVENT=MIC_LEVEL_DETECT", NULL, }; - kobject_uevent_env(&codec->dev->kobj, KOBJ_CHANGE, envp); + kobject_uevent_env(&component->dev->kobj, KOBJ_CHANGE, envp); } -static void da7218_hpldet_irq(struct snd_soc_codec *codec) +static void da7218_hpldet_irq(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); u8 jack_status; int report; - jack_status = snd_soc_read(codec, DA7218_EVENT_STATUS); + jack_status = snd_soc_component_read32(component, DA7218_EVENT_STATUS); if (jack_status & DA7218_HPLDET_JACK_STS_MASK) report = SND_JACK_HEADPHONE; @@ -2256,24 +2256,24 @@ static void da7218_hpldet_irq(struct snd_soc_codec *codec) static irqreturn_t da7218_irq_thread(int irq, void *data) { - struct snd_soc_codec *codec = data; + struct snd_soc_component *component = data; u8 status; /* Read IRQ status reg */ - status = snd_soc_read(codec, DA7218_EVENT); + status = snd_soc_component_read32(component, DA7218_EVENT); if (!status) return IRQ_NONE; /* Mic level detect */ if (status & DA7218_LVL_DET_EVENT_MASK) - da7218_micldet_irq(codec); + da7218_micldet_irq(component); /* HP detect */ if (status & DA7218_HPLDET_JACK_EVENT_MASK) - da7218_hpldet_irq(codec); + da7218_hpldet_irq(component); /* Clear interrupts */ - snd_soc_write(codec, DA7218_EVENT, status); + snd_soc_component_write(component, DA7218_EVENT, status); return IRQ_HANDLED; } @@ -2300,7 +2300,7 @@ static inline int da7218_of_get_id(struct device *dev) } static enum da7218_micbias_voltage - da7218_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) + da7218_of_micbias_lvl(struct snd_soc_component *component, u32 val) { switch (val) { case 1200: @@ -2322,13 +2322,13 @@ static enum da7218_micbias_voltage case 3000: return DA7218_MICBIAS_3_0V; default: - dev_warn(codec->dev, "Invalid micbias level"); + dev_warn(component->dev, "Invalid micbias level"); return DA7218_MICBIAS_1_6V; } } static enum da7218_mic_amp_in_sel - da7218_of_mic_amp_in_sel(struct snd_soc_codec *codec, const char *str) + da7218_of_mic_amp_in_sel(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "diff")) { return DA7218_MIC_AMP_IN_SEL_DIFF; @@ -2337,39 +2337,39 @@ static enum da7218_mic_amp_in_sel } else if (!strcmp(str, "se_n")) { return DA7218_MIC_AMP_IN_SEL_SE_N; } else { - dev_warn(codec->dev, "Invalid mic input type selection"); + dev_warn(component->dev, "Invalid mic input type selection"); return DA7218_MIC_AMP_IN_SEL_DIFF; } } static enum da7218_dmic_data_sel - da7218_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) + da7218_of_dmic_data_sel(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "lrise_rfall")) { return DA7218_DMIC_DATA_LRISE_RFALL; } else if (!strcmp(str, "lfall_rrise")) { return DA7218_DMIC_DATA_LFALL_RRISE; } else { - dev_warn(codec->dev, "Invalid DMIC data type selection"); + dev_warn(component->dev, "Invalid DMIC data type selection"); return DA7218_DMIC_DATA_LRISE_RFALL; } } static enum da7218_dmic_samplephase - da7218_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) + da7218_of_dmic_samplephase(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "on_clkedge")) { return DA7218_DMIC_SAMPLE_ON_CLKEDGE; } else if (!strcmp(str, "between_clkedge")) { return DA7218_DMIC_SAMPLE_BETWEEN_CLKEDGE; } else { - dev_warn(codec->dev, "Invalid DMIC sample phase"); + dev_warn(component->dev, "Invalid DMIC sample phase"); return DA7218_DMIC_SAMPLE_ON_CLKEDGE; } } static enum da7218_dmic_clk_rate - da7218_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) + da7218_of_dmic_clkrate(struct snd_soc_component *component, u32 val) { switch (val) { case 1500000: @@ -2377,13 +2377,13 @@ static enum da7218_dmic_clk_rate case 3000000: return DA7218_DMIC_CLK_3_0MHZ; default: - dev_warn(codec->dev, "Invalid DMIC clock rate"); + dev_warn(component->dev, "Invalid DMIC clock rate"); return DA7218_DMIC_CLK_3_0MHZ; } } static enum da7218_hpldet_jack_rate - da7218_of_jack_rate(struct snd_soc_codec *codec, u32 val) + da7218_of_jack_rate(struct snd_soc_component *component, u32 val) { switch (val) { case 5: @@ -2403,13 +2403,13 @@ static enum da7218_hpldet_jack_rate case 640: return DA7218_HPLDET_JACK_RATE_640US; default: - dev_warn(codec->dev, "Invalid jack detect rate"); + dev_warn(component->dev, "Invalid jack detect rate"); return DA7218_HPLDET_JACK_RATE_40US; } } static enum da7218_hpldet_jack_debounce - da7218_of_jack_debounce(struct snd_soc_codec *codec, u32 val) + da7218_of_jack_debounce(struct snd_soc_component *component, u32 val) { switch (val) { case 0: @@ -2421,13 +2421,13 @@ static enum da7218_hpldet_jack_debounce case 4: return DA7218_HPLDET_JACK_DEBOUNCE_4; default: - dev_warn(codec->dev, "Invalid jack debounce"); + dev_warn(component->dev, "Invalid jack debounce"); return DA7218_HPLDET_JACK_DEBOUNCE_2; } } static enum da7218_hpldet_jack_thr - da7218_of_jack_thr(struct snd_soc_codec *codec, u32 val) + da7218_of_jack_thr(struct snd_soc_component *component, u32 val) { switch (val) { case 84: @@ -2439,76 +2439,76 @@ static enum da7218_hpldet_jack_thr case 96: return DA7218_HPLDET_JACK_THR_96PCT; default: - dev_warn(codec->dev, "Invalid jack threshold level"); + dev_warn(component->dev, "Invalid jack threshold level"); return DA7218_HPLDET_JACK_THR_84PCT; } } -static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) +static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); - struct device_node *np = codec->dev->of_node; + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); + struct device_node *np = component->dev->of_node; struct device_node *hpldet_np; struct da7218_pdata *pdata; struct da7218_hpldet_pdata *hpldet_pdata; const char *of_str; u32 of_val32; - pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0) - pdata->micbias1_lvl = da7218_of_micbias_lvl(codec, of_val32); + pdata->micbias1_lvl = da7218_of_micbias_lvl(component, of_val32); else pdata->micbias1_lvl = DA7218_MICBIAS_1_6V; if (of_property_read_u32(np, "dlg,micbias2-lvl-millivolt", &of_val32) >= 0) - pdata->micbias2_lvl = da7218_of_micbias_lvl(codec, of_val32); + pdata->micbias2_lvl = da7218_of_micbias_lvl(component, of_val32); else pdata->micbias2_lvl = DA7218_MICBIAS_1_6V; if (!of_property_read_string(np, "dlg,mic1-amp-in-sel", &of_str)) pdata->mic1_amp_in_sel = - da7218_of_mic_amp_in_sel(codec, of_str); + da7218_of_mic_amp_in_sel(component, of_str); else pdata->mic1_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; if (!of_property_read_string(np, "dlg,mic2-amp-in-sel", &of_str)) pdata->mic2_amp_in_sel = - da7218_of_mic_amp_in_sel(codec, of_str); + da7218_of_mic_amp_in_sel(component, of_str); else pdata->mic2_amp_in_sel = DA7218_MIC_AMP_IN_SEL_DIFF; if (!of_property_read_string(np, "dlg,dmic1-data-sel", &of_str)) - pdata->dmic1_data_sel = da7218_of_dmic_data_sel(codec, of_str); + pdata->dmic1_data_sel = da7218_of_dmic_data_sel(component, of_str); else pdata->dmic1_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; if (!of_property_read_string(np, "dlg,dmic1-samplephase", &of_str)) pdata->dmic1_samplephase = - da7218_of_dmic_samplephase(codec, of_str); + da7218_of_dmic_samplephase(component, of_str); else pdata->dmic1_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; if (of_property_read_u32(np, "dlg,dmic1-clkrate-hz", &of_val32) >= 0) - pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(codec, of_val32); + pdata->dmic1_clk_rate = da7218_of_dmic_clkrate(component, of_val32); else pdata->dmic1_clk_rate = DA7218_DMIC_CLK_3_0MHZ; if (!of_property_read_string(np, "dlg,dmic2-data-sel", &of_str)) - pdata->dmic2_data_sel = da7218_of_dmic_data_sel(codec, of_str); + pdata->dmic2_data_sel = da7218_of_dmic_data_sel(component, of_str); else pdata->dmic2_data_sel = DA7218_DMIC_DATA_LRISE_RFALL; if (!of_property_read_string(np, "dlg,dmic2-samplephase", &of_str)) pdata->dmic2_samplephase = - da7218_of_dmic_samplephase(codec, of_str); + da7218_of_dmic_samplephase(component, of_str); else pdata->dmic2_samplephase = DA7218_DMIC_SAMPLE_ON_CLKEDGE; if (of_property_read_u32(np, "dlg,dmic2-clkrate-hz", &of_val32) >= 0) - pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(codec, of_val32); + pdata->dmic2_clk_rate = da7218_of_dmic_clkrate(component, of_val32); else pdata->dmic2_clk_rate = DA7218_DMIC_CLK_3_0MHZ; @@ -2522,7 +2522,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) if (!hpldet_np) return pdata; - hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata), + hpldet_pdata = devm_kzalloc(component->dev, sizeof(*hpldet_pdata), GFP_KERNEL); if (!hpldet_pdata) { of_node_put(hpldet_np); @@ -2533,14 +2533,14 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us", &of_val32) >= 0) hpldet_pdata->jack_rate = - da7218_of_jack_rate(codec, of_val32); + da7218_of_jack_rate(component, of_val32); else hpldet_pdata->jack_rate = DA7218_HPLDET_JACK_RATE_40US; if (of_property_read_u32(hpldet_np, "dlg,jack-debounce", &of_val32) >= 0) hpldet_pdata->jack_debounce = - da7218_of_jack_debounce(codec, of_val32); + da7218_of_jack_debounce(component, of_val32); else hpldet_pdata->jack_debounce = DA7218_HPLDET_JACK_DEBOUNCE_2; @@ -2548,7 +2548,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) if (of_property_read_u32(hpldet_np, "dlg,jack-threshold-pct", &of_val32) >= 0) hpldet_pdata->jack_thr = - da7218_of_jack_thr(codec, of_val32); + da7218_of_jack_thr(component, of_val32); else hpldet_pdata->jack_thr = DA7218_HPLDET_JACK_THR_84PCT; @@ -2572,10 +2572,10 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec) * Codec driver functions */ -static int da7218_set_bias_level(struct snd_soc_codec *codec, +static int da7218_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -2583,11 +2583,11 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { if (da7218->mclk) { ret = clk_prepare_enable(da7218->mclk); if (ret) { - dev_err(codec->dev, "Failed to enable mclk\n"); + dev_err(component->dev, "Failed to enable mclk\n"); return ret; } } @@ -2595,14 +2595,14 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Master bias */ - snd_soc_update_bits(codec, DA7218_REFERENCES, + snd_soc_component_update_bits(component, DA7218_REFERENCES, DA7218_BIAS_EN_MASK, DA7218_BIAS_EN_MASK); /* Internal LDO */ - snd_soc_update_bits(codec, DA7218_LDO_CTRL, + snd_soc_component_update_bits(component, DA7218_LDO_CTRL, DA7218_LDO_EN_MASK, DA7218_LDO_EN_MASK); } else { @@ -2615,11 +2615,11 @@ static int da7218_set_bias_level(struct snd_soc_codec *codec, /* Only disable if jack detection disabled */ if (!da7218->jack) { /* Internal LDO */ - snd_soc_update_bits(codec, DA7218_LDO_CTRL, + snd_soc_component_update_bits(component, DA7218_LDO_CTRL, DA7218_LDO_EN_MASK, 0); /* Master bias */ - snd_soc_update_bits(codec, DA7218_REFERENCES, + snd_soc_component_update_bits(component, DA7218_REFERENCES, DA7218_BIAS_EN_MASK, 0); } break; @@ -2634,9 +2634,9 @@ static const char *da7218_supply_names[DA7218_NUM_SUPPLIES] = { [DA7218_SUPPLY_VDDIO] = "VDDIO", }; -static int da7218_handle_supplies(struct snd_soc_codec *codec) +static int da7218_handle_supplies(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct regulator *vddio; u8 io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_2_5V_3_6V; int i, ret; @@ -2645,10 +2645,10 @@ static int da7218_handle_supplies(struct snd_soc_codec *codec) for (i = 0; i < DA7218_NUM_SUPPLIES; ++i) da7218->supplies[i].supply = da7218_supply_names[i]; - ret = devm_regulator_bulk_get(codec->dev, DA7218_NUM_SUPPLIES, + ret = devm_regulator_bulk_get(component->dev, DA7218_NUM_SUPPLIES, da7218->supplies); if (ret) { - dev_err(codec->dev, "Failed to get supplies\n"); + dev_err(component->dev, "Failed to get supplies\n"); return ret; } @@ -2656,29 +2656,29 @@ static int da7218_handle_supplies(struct snd_soc_codec *codec) vddio = da7218->supplies[DA7218_SUPPLY_VDDIO].consumer; ret = regulator_get_voltage(vddio); if (ret < 1500000) - dev_warn(codec->dev, "Invalid VDDIO voltage\n"); + dev_warn(component->dev, "Invalid VDDIO voltage\n"); else if (ret < 2500000) io_voltage_lvl = DA7218_IO_VOLTAGE_LEVEL_1_5V_2_5V; /* Enable main supplies */ ret = regulator_bulk_enable(DA7218_NUM_SUPPLIES, da7218->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies\n"); + dev_err(component->dev, "Failed to enable supplies\n"); return ret; } /* Ensure device in active mode */ - snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK); + snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK); /* Update IO voltage level range */ - snd_soc_write(codec, DA7218_IO_CTRL, io_voltage_lvl); + snd_soc_component_write(component, DA7218_IO_CTRL, io_voltage_lvl); return 0; } -static void da7218_handle_pdata(struct snd_soc_codec *codec) +static void da7218_handle_pdata(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); struct da7218_pdata *pdata = da7218->pdata; if (pdata) { @@ -2719,14 +2719,14 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) break; } - snd_soc_write(codec, DA7218_MICBIAS_CTRL, micbias_lvl); + snd_soc_component_write(component, DA7218_MICBIAS_CTRL, micbias_lvl); /* Mic */ switch (pdata->mic1_amp_in_sel) { case DA7218_MIC_AMP_IN_SEL_DIFF: case DA7218_MIC_AMP_IN_SEL_SE_P: case DA7218_MIC_AMP_IN_SEL_SE_N: - snd_soc_write(codec, DA7218_MIC_1_SELECT, + snd_soc_component_write(component, DA7218_MIC_1_SELECT, pdata->mic1_amp_in_sel); break; } @@ -2735,7 +2735,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) case DA7218_MIC_AMP_IN_SEL_DIFF: case DA7218_MIC_AMP_IN_SEL_SE_P: case DA7218_MIC_AMP_IN_SEL_SE_N: - snd_soc_write(codec, DA7218_MIC_2_SELECT, + snd_soc_component_write(component, DA7218_MIC_2_SELECT, pdata->mic2_amp_in_sel); break; } @@ -2765,7 +2765,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) break; } - snd_soc_update_bits(codec, DA7218_DMIC_1_CTRL, + snd_soc_component_update_bits(component, DA7218_DMIC_1_CTRL, DA7218_DMIC_1_DATA_SEL_MASK | DA7218_DMIC_1_SAMPLEPHASE_MASK | DA7218_DMIC_1_CLK_RATE_MASK, dmic_cfg); @@ -2795,7 +2795,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) break; } - snd_soc_update_bits(codec, DA7218_DMIC_2_CTRL, + snd_soc_component_update_bits(component, DA7218_DMIC_2_CTRL, DA7218_DMIC_2_DATA_SEL_MASK | DA7218_DMIC_2_SAMPLEPHASE_MASK | DA7218_DMIC_2_CLK_RATE_MASK, dmic_cfg); @@ -2806,9 +2806,9 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) pdata->hp_diff_single_supply; if (da7218->hp_single_supply) { - snd_soc_write(codec, DA7218_HP_DIFF_UNLOCK, + snd_soc_component_write(component, DA7218_HP_DIFF_UNLOCK, DA7218_HP_DIFF_UNLOCK_VAL); - snd_soc_update_bits(codec, DA7218_HP_DIFF_CTRL, + snd_soc_component_update_bits(component, DA7218_HP_DIFF_CTRL, DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK, DA7218_HP_AMP_SINGLE_SUPPLY_EN_MASK); } @@ -2857,7 +2857,7 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) DA7218_HPLDET_JACK_THR_SHIFT); break; } - snd_soc_update_bits(codec, DA7218_HPLDET_JACK, + snd_soc_component_update_bits(component, DA7218_HPLDET_JACK, DA7218_HPLDET_JACK_RATE_MASK | DA7218_HPLDET_JACK_DEBOUNCE_MASK | DA7218_HPLDET_JACK_THR_MASK, @@ -2873,31 +2873,31 @@ static void da7218_handle_pdata(struct snd_soc_codec *codec) if (hpldet_pdata->discharge) hpldet_cfg |= DA7218_HPLDET_DISCHARGE_EN_MASK; - snd_soc_write(codec, DA7218_HPLDET_CTRL, hpldet_cfg); + snd_soc_component_write(component, DA7218_HPLDET_CTRL, hpldet_cfg); } } } -static int da7218_probe(struct snd_soc_codec *codec) +static int da7218_probe(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); int ret; /* Regulator configuration */ - ret = da7218_handle_supplies(codec); + ret = da7218_handle_supplies(component); if (ret) return ret; /* Handle DT/Platform data */ - if (codec->dev->of_node) - da7218->pdata = da7218_of_to_pdata(codec); + if (component->dev->of_node) + da7218->pdata = da7218_of_to_pdata(component); else - da7218->pdata = dev_get_platdata(codec->dev); + da7218->pdata = dev_get_platdata(component->dev); - da7218_handle_pdata(codec); + da7218_handle_pdata(component); /* Check if MCLK provided, if not the clock is NULL */ - da7218->mclk = devm_clk_get(codec->dev, "mclk"); + da7218->mclk = devm_clk_get(component->dev, "mclk"); if (IS_ERR(da7218->mclk)) { if (PTR_ERR(da7218->mclk) != -ENOENT) { ret = PTR_ERR(da7218->mclk); @@ -2908,74 +2908,74 @@ static int da7218_probe(struct snd_soc_codec *codec) } /* Default PC to free-running */ - snd_soc_write(codec, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); + snd_soc_component_write(component, DA7218_PC_COUNT, DA7218_PC_FREERUN_MASK); /* * Default Output Filter mixers to off otherwise DAPM will power * Mic to HP passthrough paths by default at startup. */ - snd_soc_write(codec, DA7218_DROUTING_OUTFILT_1L, 0); - snd_soc_write(codec, DA7218_DROUTING_OUTFILT_1R, 0); + snd_soc_component_write(component, DA7218_DROUTING_OUTFILT_1L, 0); + snd_soc_component_write(component, DA7218_DROUTING_OUTFILT_1R, 0); /* Default CP to normal load, power mode */ - snd_soc_update_bits(codec, DA7218_CP_CTRL, + snd_soc_component_update_bits(component, DA7218_CP_CTRL, DA7218_CP_SMALL_SWITCH_FREQ_EN_MASK, 0); /* Default gain ramping */ - snd_soc_update_bits(codec, DA7218_MIXIN_1_CTRL, + snd_soc_component_update_bits(component, DA7218_MIXIN_1_CTRL, DA7218_MIXIN_1_AMP_RAMP_EN_MASK, DA7218_MIXIN_1_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_MIXIN_2_CTRL, + snd_soc_component_update_bits(component, DA7218_MIXIN_2_CTRL, DA7218_MIXIN_2_AMP_RAMP_EN_MASK, DA7218_MIXIN_2_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_1L_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_1L_FILTER_CTRL, DA7218_IN_1L_RAMP_EN_MASK, DA7218_IN_1L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_1R_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_1R_FILTER_CTRL, DA7218_IN_1R_RAMP_EN_MASK, DA7218_IN_1R_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_2L_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_2L_FILTER_CTRL, DA7218_IN_2L_RAMP_EN_MASK, DA7218_IN_2L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_IN_2R_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_IN_2R_FILTER_CTRL, DA7218_IN_2R_RAMP_EN_MASK, DA7218_IN_2R_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_DGS_GAIN_CTRL, + snd_soc_component_update_bits(component, DA7218_DGS_GAIN_CTRL, DA7218_DGS_RAMP_EN_MASK, DA7218_DGS_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_OUT_1L_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_OUT_1L_FILTER_CTRL, DA7218_OUT_1L_RAMP_EN_MASK, DA7218_OUT_1L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_OUT_1R_FILTER_CTRL, + snd_soc_component_update_bits(component, DA7218_OUT_1R_FILTER_CTRL, DA7218_OUT_1R_RAMP_EN_MASK, DA7218_OUT_1R_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7218_HP_L_CTRL, DA7218_HP_L_AMP_RAMP_EN_MASK, DA7218_HP_L_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7218_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7218_HP_R_CTRL, DA7218_HP_R_AMP_RAMP_EN_MASK, DA7218_HP_R_AMP_RAMP_EN_MASK); /* Default infinite tone gen, start/stop by Kcontrol */ - snd_soc_write(codec, DA7218_TONE_GEN_CYCLES, DA7218_BEEP_CYCLES_MASK); + snd_soc_component_write(component, DA7218_TONE_GEN_CYCLES, DA7218_BEEP_CYCLES_MASK); /* DA7217 specific config */ if (da7218->dev_id == DA7217_DEV_ID) { - snd_soc_update_bits(codec, DA7218_HP_DIFF_CTRL, + snd_soc_component_update_bits(component, DA7218_HP_DIFF_CTRL, DA7218_HP_AMP_DIFF_MODE_EN_MASK, DA7218_HP_AMP_DIFF_MODE_EN_MASK); /* Only DA7218 supports HP detect, mask off for DA7217 */ - snd_soc_write(codec, DA7218_EVENT_MASK, + snd_soc_component_write(component, DA7218_EVENT_MASK, DA7218_HPLDET_JACK_EVENT_IRQ_MSK_MASK); } if (da7218->irq) { - ret = devm_request_threaded_irq(codec->dev, da7218->irq, NULL, + ret = devm_request_threaded_irq(component->dev, da7218->irq, NULL, da7218_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT, - "da7218", codec); + "da7218", component); if (ret != 0) { - dev_err(codec->dev, "Failed to request IRQ %d: %d\n", + dev_err(component->dev, "Failed to request IRQ %d: %d\n", da7218->irq, ret); goto err_disable_reg; } @@ -2990,39 +2990,37 @@ err_disable_reg: return ret; } -static int da7218_remove(struct snd_soc_codec *codec) +static void da7218_remove(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); regulator_bulk_disable(DA7218_NUM_SUPPLIES, da7218->supplies); - - return 0; } #ifdef CONFIG_PM -static int da7218_suspend(struct snd_soc_codec *codec) +static int da7218_suspend(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); - da7218_set_bias_level(codec, SND_SOC_BIAS_OFF); + da7218_set_bias_level(component, SND_SOC_BIAS_OFF); /* Put device into standby mode if jack detection disabled */ if (!da7218->jack) - snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, 0); + snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, 0); return 0; } -static int da7218_resume(struct snd_soc_codec *codec) +static int da7218_resume(struct snd_soc_component *component) { - struct da7218_priv *da7218 = snd_soc_codec_get_drvdata(codec); + struct da7218_priv *da7218 = snd_soc_component_get_drvdata(component); /* Put device into active mode if previously moved to standby */ if (!da7218->jack) - snd_soc_write(codec, DA7218_SYSTEM_ACTIVE, + snd_soc_component_write(component, DA7218_SYSTEM_ACTIVE, DA7218_SYSTEM_ACTIVE_MASK); - da7218_set_bias_level(codec, SND_SOC_BIAS_STANDBY); + da7218_set_bias_level(component, SND_SOC_BIAS_STANDBY); return 0; } @@ -3031,21 +3029,22 @@ static int da7218_resume(struct snd_soc_codec *codec) #define da7218_resume NULL #endif -static const struct snd_soc_codec_driver soc_codec_dev_da7218 = { +static const struct snd_soc_component_driver soc_component_dev_da7218 = { .probe = da7218_probe, .remove = da7218_remove, .suspend = da7218_suspend, .resume = da7218_resume, .set_bias_level = da7218_set_bias_level, - - .component_driver = { - .controls = da7218_snd_controls, - .num_controls = ARRAY_SIZE(da7218_snd_controls), - .dapm_widgets = da7218_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da7218_dapm_widgets), - .dapm_routes = da7218_audio_map, - .num_dapm_routes = ARRAY_SIZE(da7218_audio_map), - }, + .controls = da7218_snd_controls, + .num_controls = ARRAY_SIZE(da7218_snd_controls), + .dapm_widgets = da7218_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da7218_dapm_widgets), + .dapm_routes = da7218_audio_map, + .num_dapm_routes = ARRAY_SIZE(da7218_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; @@ -3295,21 +3294,15 @@ static int da7218_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_da7218, &da7218_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_da7218, &da7218_dai, 1); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register da7218 codec: %d\n", + dev_err(&i2c->dev, "Failed to register da7218 component: %d\n", ret); } return ret; } -static int da7218_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id da7218_i2c_id[] = { { "da7217", DA7217_DEV_ID }, { "da7218", DA7218_DEV_ID }, @@ -3323,7 +3316,6 @@ static struct i2c_driver da7218_i2c_driver = { .of_match_table = of_match_ptr(da7218_of_match), }, .probe = da7218_i2c_probe, - .remove = da7218_i2c_remove, .id_table = da7218_i2c_id, }; diff --git a/sound/soc/codecs/da7218.h b/sound/soc/codecs/da7218.h index 4f7ec21069a4..19e6cee2e42e 100644 --- a/sound/soc/codecs/da7218.h +++ b/sound/soc/codecs/da7218.h @@ -1410,6 +1410,6 @@ struct da7218_priv { }; /* HP detect control */ -int da7218_hpldet(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int da7218_hpldet(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* _DA7218_H */ From 2918d9ccc46a408707bc8939ba1777f7211798c3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:03:13 +0000 Subject: [PATCH 094/942] ASoC: da7213: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da7213.c | 328 +++++++++++++++++++------------------- 1 file changed, 161 insertions(+), 167 deletions(-) diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index b2b4e90fc02a..54cb5f24969f 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c @@ -194,7 +194,7 @@ static SOC_ENUM_SINGLE_DECL(da7213_alc_integ_release_rate, * Control Functions */ -static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) +static int da7213_get_alc_data(struct snd_soc_component *component, u8 reg_val) { int mid_data, top_data; int sum = 0; @@ -203,17 +203,17 @@ static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) for (iteration = 0; iteration < DA7213_ALC_AVG_ITERATIONS; iteration++) { /* Select the left or right channel and capture data */ - snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val); + snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val); /* Select middle 8 bits for read back from data register */ - snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, + snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val | DA7213_ALC_DATA_MIDDLE); - mid_data = snd_soc_read(codec, DA7213_ALC_CIC_OP_LVL_DATA); + mid_data = snd_soc_component_read32(component, DA7213_ALC_CIC_OP_LVL_DATA); /* Select top 8 bits for read back from data register */ - snd_soc_write(codec, DA7213_ALC_CIC_OP_LVL_CTRL, + snd_soc_component_write(component, DA7213_ALC_CIC_OP_LVL_CTRL, reg_val | DA7213_ALC_DATA_TOP); - top_data = snd_soc_read(codec, DA7213_ALC_CIC_OP_LVL_DATA); + top_data = snd_soc_component_read32(component, DA7213_ALC_CIC_OP_LVL_DATA); sum += ((mid_data << 8) | (top_data << 16)); } @@ -221,17 +221,17 @@ static int da7213_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) return sum / DA7213_ALC_AVG_ITERATIONS; } -static void da7213_alc_calib_man(struct snd_soc_codec *codec) +static void da7213_alc_calib_man(struct snd_soc_component *component) { u8 reg_val; int avg_left_data, avg_right_data, offset_l, offset_r; /* Calculate average for Left and Right data */ /* Left Data */ - avg_left_data = da7213_get_alc_data(codec, + avg_left_data = da7213_get_alc_data(component, DA7213_ALC_CIC_OP_CHANNEL_LEFT); /* Right Data */ - avg_right_data = da7213_get_alc_data(codec, + avg_right_data = da7213_get_alc_data(component, DA7213_ALC_CIC_OP_CHANNEL_RIGHT); /* Calculate DC offset */ @@ -239,122 +239,122 @@ static void da7213_alc_calib_man(struct snd_soc_codec *codec) offset_r = -avg_right_data; reg_val = (offset_l & DA7213_ALC_OFFSET_15_8) >> 8; - snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_M_L, reg_val); + snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_M_L, reg_val); reg_val = (offset_l & DA7213_ALC_OFFSET_19_16) >> 16; - snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_U_L, reg_val); + snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_U_L, reg_val); reg_val = (offset_r & DA7213_ALC_OFFSET_15_8) >> 8; - snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_M_R, reg_val); + snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_M_R, reg_val); reg_val = (offset_r & DA7213_ALC_OFFSET_19_16) >> 16; - snd_soc_write(codec, DA7213_ALC_OFFSET_MAN_U_R, reg_val); + snd_soc_component_write(component, DA7213_ALC_OFFSET_MAN_U_R, reg_val); /* Enable analog/digital gain mode & offset cancellation */ - snd_soc_update_bits(codec, DA7213_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); } -static void da7213_alc_calib_auto(struct snd_soc_codec *codec) +static void da7213_alc_calib_auto(struct snd_soc_component *component) { u8 alc_ctrl1; /* Begin auto calibration and wait for completion */ - snd_soc_update_bits(codec, DA7213_ALC_CTRL1, DA7213_ALC_AUTO_CALIB_EN, + snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_AUTO_CALIB_EN, DA7213_ALC_AUTO_CALIB_EN); do { - alc_ctrl1 = snd_soc_read(codec, DA7213_ALC_CTRL1); + alc_ctrl1 = snd_soc_component_read32(component, DA7213_ALC_CTRL1); } while (alc_ctrl1 & DA7213_ALC_AUTO_CALIB_EN); /* If auto calibration fails, fall back to digital gain only mode */ if (alc_ctrl1 & DA7213_ALC_CALIB_OVERFLOW) { - dev_warn(codec->dev, + dev_warn(component->dev, "ALC auto calibration failed with overflow\n"); - snd_soc_update_bits(codec, DA7213_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, 0); } else { /* Enable analog/digital gain mode & offset cancellation */ - snd_soc_update_bits(codec, DA7213_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE, DA7213_ALC_OFFSET_EN | DA7213_ALC_SYNC_MODE); } } -static void da7213_alc_calib(struct snd_soc_codec *codec) +static void da7213_alc_calib(struct snd_soc_component *component) { - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); u8 adc_l_ctrl, adc_r_ctrl; u8 mixin_l_sel, mixin_r_sel; u8 mic_1_ctrl, mic_2_ctrl; /* Save current values from ADC control registers */ - adc_l_ctrl = snd_soc_read(codec, DA7213_ADC_L_CTRL); - adc_r_ctrl = snd_soc_read(codec, DA7213_ADC_R_CTRL); + adc_l_ctrl = snd_soc_component_read32(component, DA7213_ADC_L_CTRL); + adc_r_ctrl = snd_soc_component_read32(component, DA7213_ADC_R_CTRL); /* Save current values from MIXIN_L/R_SELECT registers */ - mixin_l_sel = snd_soc_read(codec, DA7213_MIXIN_L_SELECT); - mixin_r_sel = snd_soc_read(codec, DA7213_MIXIN_R_SELECT); + mixin_l_sel = snd_soc_component_read32(component, DA7213_MIXIN_L_SELECT); + mixin_r_sel = snd_soc_component_read32(component, DA7213_MIXIN_R_SELECT); /* Save current values from MIC control registers */ - mic_1_ctrl = snd_soc_read(codec, DA7213_MIC_1_CTRL); - mic_2_ctrl = snd_soc_read(codec, DA7213_MIC_2_CTRL); + mic_1_ctrl = snd_soc_component_read32(component, DA7213_MIC_1_CTRL); + mic_2_ctrl = snd_soc_component_read32(component, DA7213_MIC_2_CTRL); /* Enable ADC Left and Right */ - snd_soc_update_bits(codec, DA7213_ADC_L_CTRL, DA7213_ADC_EN, + snd_soc_component_update_bits(component, DA7213_ADC_L_CTRL, DA7213_ADC_EN, DA7213_ADC_EN); - snd_soc_update_bits(codec, DA7213_ADC_R_CTRL, DA7213_ADC_EN, + snd_soc_component_update_bits(component, DA7213_ADC_R_CTRL, DA7213_ADC_EN, DA7213_ADC_EN); /* Enable MIC paths */ - snd_soc_update_bits(codec, DA7213_MIXIN_L_SELECT, + snd_soc_component_update_bits(component, DA7213_MIXIN_L_SELECT, DA7213_MIXIN_L_MIX_SELECT_MIC_1 | DA7213_MIXIN_L_MIX_SELECT_MIC_2, DA7213_MIXIN_L_MIX_SELECT_MIC_1 | DA7213_MIXIN_L_MIX_SELECT_MIC_2); - snd_soc_update_bits(codec, DA7213_MIXIN_R_SELECT, + snd_soc_component_update_bits(component, DA7213_MIXIN_R_SELECT, DA7213_MIXIN_R_MIX_SELECT_MIC_2 | DA7213_MIXIN_R_MIX_SELECT_MIC_1, DA7213_MIXIN_R_MIX_SELECT_MIC_2 | DA7213_MIXIN_R_MIX_SELECT_MIC_1); /* Mute MIC PGAs */ - snd_soc_update_bits(codec, DA7213_MIC_1_CTRL, DA7213_MUTE_EN, + snd_soc_component_update_bits(component, DA7213_MIC_1_CTRL, DA7213_MUTE_EN, DA7213_MUTE_EN); - snd_soc_update_bits(codec, DA7213_MIC_2_CTRL, DA7213_MUTE_EN, + snd_soc_component_update_bits(component, DA7213_MIC_2_CTRL, DA7213_MUTE_EN, DA7213_MUTE_EN); /* Perform calibration */ if (da7213->alc_calib_auto) - da7213_alc_calib_auto(codec); + da7213_alc_calib_auto(component); else - da7213_alc_calib_man(codec); + da7213_alc_calib_man(component); /* Restore MIXIN_L/R_SELECT registers to their original states */ - snd_soc_write(codec, DA7213_MIXIN_L_SELECT, mixin_l_sel); - snd_soc_write(codec, DA7213_MIXIN_R_SELECT, mixin_r_sel); + snd_soc_component_write(component, DA7213_MIXIN_L_SELECT, mixin_l_sel); + snd_soc_component_write(component, DA7213_MIXIN_R_SELECT, mixin_r_sel); /* Restore ADC control registers to their original states */ - snd_soc_write(codec, DA7213_ADC_L_CTRL, adc_l_ctrl); - snd_soc_write(codec, DA7213_ADC_R_CTRL, adc_r_ctrl); + snd_soc_component_write(component, DA7213_ADC_L_CTRL, adc_l_ctrl); + snd_soc_component_write(component, DA7213_ADC_R_CTRL, adc_r_ctrl); /* Restore original values of MIC control registers */ - snd_soc_write(codec, DA7213_MIC_1_CTRL, mic_1_ctrl); - snd_soc_write(codec, DA7213_MIC_2_CTRL, mic_2_ctrl); + snd_soc_component_write(component, DA7213_MIC_1_CTRL, mic_1_ctrl); + snd_soc_component_write(component, DA7213_MIC_2_CTRL, mic_2_ctrl); } static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; ret = snd_soc_put_volsw_2r(kcontrol, ucontrol); /* If ALC in operation, make sure calibrated offsets are updated */ if ((!ret) && (da7213->alc_en)) - da7213_alc_calib(codec); + da7213_alc_calib(component); return ret; } @@ -362,14 +362,14 @@ static int da7213_put_mixin_gain(struct snd_kcontrol *kcontrol, static int da7213_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); /* Force ALC offset calibration if enabling ALC */ if (ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1]) { if (!da7213->alc_en) { - da7213_alc_calib(codec); + da7213_alc_calib(component); da7213->alc_en = true; } } else { @@ -735,8 +735,8 @@ static const struct snd_kcontrol_new da7213_dapm_mixoutr_controls[] = { static int da7213_dai_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, pll_status; int i = 0; bool srm_lock = false; @@ -745,29 +745,29 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMU: /* Enable DAI clks for master mode */ if (da7213->master) - snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE, DA7213_DAI_CLK_EN_MASK, DA7213_DAI_CLK_EN_MASK); /* PC synchronised to DAI */ - snd_soc_update_bits(codec, DA7213_PC_COUNT, + snd_soc_component_update_bits(component, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, 0); /* If SRM not enabled then nothing more to do */ - pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7213_PLL_CTRL); if (!(pll_ctrl & DA7213_PLL_SRM_EN)) return 0; /* Assist 32KHz mode PLL lock */ if (pll_ctrl & DA7213_PLL_32K_MODE) { - snd_soc_write(codec, 0xF0, 0x8B); - snd_soc_write(codec, 0xF2, 0x03); - snd_soc_write(codec, 0xF0, 0x00); + snd_soc_component_write(component, 0xF0, 0x8B); + snd_soc_component_write(component, 0xF2, 0x03); + snd_soc_component_write(component, 0xF0, 0x00); } /* Check SRM has locked */ do { - pll_status = snd_soc_read(codec, DA7213_PLL_STATUS); + pll_status = snd_soc_component_read32(component, DA7213_PLL_STATUS); if (pll_status & DA7219_PLL_SRM_LOCK) { srm_lock = true; } else { @@ -777,26 +777,26 @@ static int da7213_dai_event(struct snd_soc_dapm_widget *w, } while ((i < DA7213_SRM_CHECK_RETRIES) && (!srm_lock)); if (!srm_lock) - dev_warn(codec->dev, "SRM failed to lock\n"); + dev_warn(component->dev, "SRM failed to lock\n"); return 0; case SND_SOC_DAPM_POST_PMD: /* Revert 32KHz PLL lock udpates if applied previously */ - pll_ctrl = snd_soc_read(codec, DA7213_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7213_PLL_CTRL); if (pll_ctrl & DA7213_PLL_32K_MODE) { - snd_soc_write(codec, 0xF0, 0x8B); - snd_soc_write(codec, 0xF2, 0x01); - snd_soc_write(codec, 0xF0, 0x00); + snd_soc_component_write(component, 0xF0, 0x8B); + snd_soc_component_write(component, 0xF2, 0x01); + snd_soc_component_write(component, 0xF0, 0x00); } /* PC free-running */ - snd_soc_update_bits(codec, DA7213_PC_COUNT, + snd_soc_component_update_bits(component, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, DA7213_PC_FREERUN_MASK); /* Disable DAI clks if in master mode */ if (da7213->master) - snd_soc_update_bits(codec, DA7213_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7213_DAI_CLK_MODE, DA7213_DAI_CLK_EN_MASK, 0); return 0; default: @@ -1150,7 +1150,7 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 dai_ctrl = 0; u8 fs; @@ -1208,17 +1208,17 @@ static int da7213_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, + snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_WORD_LENGTH_MASK, dai_ctrl); - snd_soc_write(codec, DA7213_SR, fs); + snd_soc_component_write(component, DA7213_SR, fs); return 0; } static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); u8 dai_clk_mode = 0, dai_ctrl = 0; u8 dai_offset = 0; @@ -1305,27 +1305,27 @@ static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* By default only 64 BCLK per WCLK is supported */ dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; - snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); - snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, + snd_soc_component_write(component, DA7213_DAI_CLK_MODE, dai_clk_mode); + snd_soc_component_update_bits(component, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, dai_ctrl); - snd_soc_write(codec, DA7213_DAI_OFFSET, dai_offset); + snd_soc_component_write(component, DA7213_DAI_OFFSET, dai_offset); return 0; } static int da7213_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) { - snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL, DA7213_MUTE_EN, DA7213_MUTE_EN); - snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL, DA7213_MUTE_EN, DA7213_MUTE_EN); } else { - snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL, DA7213_MUTE_EN, 0); - snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL, DA7213_MUTE_EN, 0); } @@ -1338,8 +1338,8 @@ static int da7213_mute(struct snd_soc_dai *dai, int mute) static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret = 0; if ((da7213->clk_src == clk_id) && (da7213->mclk_rate == freq)) @@ -1353,11 +1353,11 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, switch (clk_id) { case DA7213_CLKSRC_MCLK: - snd_soc_update_bits(codec, DA7213_PLL_CTRL, + snd_soc_component_update_bits(component, DA7213_PLL_CTRL, DA7213_PLL_MCLK_SQR_EN, 0); break; case DA7213_CLKSRC_MCLK_SQR: - snd_soc_update_bits(codec, DA7213_PLL_CTRL, + snd_soc_component_update_bits(component, DA7213_PLL_CTRL, DA7213_PLL_MCLK_SQR_EN, DA7213_PLL_MCLK_SQR_EN); break; @@ -1387,8 +1387,8 @@ static int da7213_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int fref, unsigned int fout) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, indiv_bits, indiv; u8 pll_frac_top, pll_frac_bot, pll_integer; @@ -1398,7 +1398,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* Workout input divider based on MCLK rate */ if (da7213->mclk_rate == 32768) { if (!da7213->master) { - dev_err(codec->dev, + dev_err(component->dev, "32KHz only valid if codec is clock master\n"); return -EINVAL; } @@ -1411,7 +1411,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, } else { if (da7213->mclk_rate < 5000000) { - dev_err(codec->dev, + dev_err(component->dev, "PLL input clock %d below valid range\n", da7213->mclk_rate); return -EINVAL; @@ -1428,7 +1428,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, indiv_bits = DA7213_PLL_INDIV_36_TO_54_MHZ; indiv = DA7213_PLL_INDIV_36_TO_54_MHZ_VAL; } else { - dev_err(codec->dev, + dev_err(component->dev, "PLL input clock %d above valid range\n", da7213->mclk_rate); return -EINVAL; @@ -1441,7 +1441,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, /* Configure PLL */ switch (source) { case DA7213_SYSCLK_MCLK: - snd_soc_update_bits(codec, DA7213_PLL_CTRL, + snd_soc_component_update_bits(component, DA7213_PLL_CTRL, DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK, pll_ctrl); return 0; @@ -1453,7 +1453,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, break; case DA7213_SYSCLK_PLL_32KHZ: if (da7213->mclk_rate != 32768) { - dev_err(codec->dev, + dev_err(component->dev, "32KHz mode only valid with 32KHz MCLK\n"); return -EINVAL; } @@ -1462,7 +1462,7 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, fout = DA7213_PLL_FREQ_OUT_94310400; break; default: - dev_err(codec->dev, "Invalid PLL config\n"); + dev_err(component->dev, "Invalid PLL config\n"); return -EINVAL; } @@ -1474,22 +1474,22 @@ static int da7213_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, pll_frac_bot = (frac_div) & DA7213_BYTE_MASK; /* Write PLL dividers */ - snd_soc_write(codec, DA7213_PLL_FRAC_TOP, pll_frac_top); - snd_soc_write(codec, DA7213_PLL_FRAC_BOT, pll_frac_bot); - snd_soc_write(codec, DA7213_PLL_INTEGER, pll_integer); + snd_soc_component_write(component, DA7213_PLL_FRAC_TOP, pll_frac_top); + snd_soc_component_write(component, DA7213_PLL_FRAC_BOT, pll_frac_bot); + snd_soc_component_write(component, DA7213_PLL_INTEGER, pll_integer); /* Enable PLL */ pll_ctrl |= DA7213_PLL_EN; - snd_soc_update_bits(codec, DA7213_PLL_CTRL, + snd_soc_component_update_bits(component, DA7213_PLL_CTRL, DA7213_PLL_INDIV_MASK | DA7213_PLL_MODE_MASK, pll_ctrl); /* Assist 32KHz mode PLL lock */ if (source == DA7213_SYSCLK_PLL_32KHZ) { - snd_soc_write(codec, 0xF0, 0x8B); - snd_soc_write(codec, 0xF1, 0x03); - snd_soc_write(codec, 0xF1, 0x01); - snd_soc_write(codec, 0xF0, 0x00); + snd_soc_component_write(component, 0xF0, 0x8B); + snd_soc_component_write(component, 0xF1, 0x03); + snd_soc_component_write(component, 0xF1, 0x01); + snd_soc_component_write(component, 0xF0, 0x00); } return 0; @@ -1526,10 +1526,10 @@ static struct snd_soc_dai_driver da7213_dai = { .symmetric_rates = 1, }; -static int da7213_set_bias_level(struct snd_soc_codec *codec, +static int da7213_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1537,11 +1537,11 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { if (da7213->mclk) { ret = clk_prepare_enable(da7213->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable mclk\n"); return ret; } @@ -1549,9 +1549,9 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, } break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Enable VMID reference & master bias */ - snd_soc_update_bits(codec, DA7213_REFERENCES, + snd_soc_component_update_bits(component, DA7213_REFERENCES, DA7213_VMID_EN | DA7213_BIAS_EN, DA7213_VMID_EN | DA7213_BIAS_EN); } else { @@ -1562,7 +1562,7 @@ static int da7213_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: /* Disable VMID reference & master bias */ - snd_soc_update_bits(codec, DA7213_REFERENCES, + snd_soc_component_update_bits(component, DA7213_REFERENCES, DA7213_VMID_EN | DA7213_BIAS_EN, 0); break; } @@ -1588,7 +1588,7 @@ MODULE_DEVICE_TABLE(acpi, da7213_acpi_match); #endif static enum da7213_micbias_voltage - da7213_of_micbias_lvl(struct snd_soc_codec *codec, u32 val) + da7213_of_micbias_lvl(struct snd_soc_component *component, u32 val) { switch (val) { case 1600: @@ -1600,39 +1600,39 @@ static enum da7213_micbias_voltage case 3000: return DA7213_MICBIAS_3_0V; default: - dev_warn(codec->dev, "Invalid micbias level\n"); + dev_warn(component->dev, "Invalid micbias level\n"); return DA7213_MICBIAS_2_2V; } } static enum da7213_dmic_data_sel - da7213_of_dmic_data_sel(struct snd_soc_codec *codec, const char *str) + da7213_of_dmic_data_sel(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "lrise_rfall")) { return DA7213_DMIC_DATA_LRISE_RFALL; } else if (!strcmp(str, "lfall_rrise")) { return DA7213_DMIC_DATA_LFALL_RRISE; } else { - dev_warn(codec->dev, "Invalid DMIC data select type\n"); + dev_warn(component->dev, "Invalid DMIC data select type\n"); return DA7213_DMIC_DATA_LRISE_RFALL; } } static enum da7213_dmic_samplephase - da7213_of_dmic_samplephase(struct snd_soc_codec *codec, const char *str) + da7213_of_dmic_samplephase(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "on_clkedge")) { return DA7213_DMIC_SAMPLE_ON_CLKEDGE; } else if (!strcmp(str, "between_clkedge")) { return DA7213_DMIC_SAMPLE_BETWEEN_CLKEDGE; } else { - dev_warn(codec->dev, "Invalid DMIC sample phase\n"); + dev_warn(component->dev, "Invalid DMIC sample phase\n"); return DA7213_DMIC_SAMPLE_ON_CLKEDGE; } } static enum da7213_dmic_clk_rate - da7213_of_dmic_clkrate(struct snd_soc_codec *codec, u32 val) + da7213_of_dmic_clkrate(struct snd_soc_component *component, u32 val) { switch (val) { case 1500000: @@ -1640,46 +1640,46 @@ static enum da7213_dmic_clk_rate case 3000000: return DA7213_DMIC_CLK_3_0MHZ; default: - dev_warn(codec->dev, "Invalid DMIC clock rate\n"); + dev_warn(component->dev, "Invalid DMIC clock rate\n"); return DA7213_DMIC_CLK_1_5MHZ; } } static struct da7213_platform_data - *da7213_fw_to_pdata(struct snd_soc_codec *codec) + *da7213_fw_to_pdata(struct snd_soc_component *component) { - struct device *dev = codec->dev; + struct device *dev = component->dev; struct da7213_platform_data *pdata; const char *fw_str; u32 fw_val32; - pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); + pdata = devm_kzalloc(component->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; if (device_property_read_u32(dev, "dlg,micbias1-lvl", &fw_val32) >= 0) - pdata->micbias1_lvl = da7213_of_micbias_lvl(codec, fw_val32); + pdata->micbias1_lvl = da7213_of_micbias_lvl(component, fw_val32); else pdata->micbias1_lvl = DA7213_MICBIAS_2_2V; if (device_property_read_u32(dev, "dlg,micbias2-lvl", &fw_val32) >= 0) - pdata->micbias2_lvl = da7213_of_micbias_lvl(codec, fw_val32); + pdata->micbias2_lvl = da7213_of_micbias_lvl(component, fw_val32); else pdata->micbias2_lvl = DA7213_MICBIAS_2_2V; if (!device_property_read_string(dev, "dlg,dmic-data-sel", &fw_str)) - pdata->dmic_data_sel = da7213_of_dmic_data_sel(codec, fw_str); + pdata->dmic_data_sel = da7213_of_dmic_data_sel(component, fw_str); else pdata->dmic_data_sel = DA7213_DMIC_DATA_LRISE_RFALL; if (!device_property_read_string(dev, "dlg,dmic-samplephase", &fw_str)) pdata->dmic_samplephase = - da7213_of_dmic_samplephase(codec, fw_str); + da7213_of_dmic_samplephase(component, fw_str); else pdata->dmic_samplephase = DA7213_DMIC_SAMPLE_ON_CLKEDGE; if (device_property_read_u32(dev, "dlg,dmic-clkrate", &fw_val32) >= 0) - pdata->dmic_clk_rate = da7213_of_dmic_clkrate(codec, fw_val32); + pdata->dmic_clk_rate = da7213_of_dmic_clkrate(component, fw_val32); else pdata->dmic_clk_rate = DA7213_DMIC_CLK_3_0MHZ; @@ -1687,41 +1687,41 @@ static struct da7213_platform_data } -static int da7213_probe(struct snd_soc_codec *codec) +static int da7213_probe(struct snd_soc_component *component) { - struct da7213_priv *da7213 = snd_soc_codec_get_drvdata(codec); + struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component); /* Default to using ALC auto offset calibration mode. */ - snd_soc_update_bits(codec, DA7213_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7213_ALC_CTRL1, DA7213_ALC_CALIB_MODE_MAN, 0); da7213->alc_calib_auto = true; /* Default PC counter to free-running */ - snd_soc_update_bits(codec, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, + snd_soc_component_update_bits(component, DA7213_PC_COUNT, DA7213_PC_FREERUN_MASK, DA7213_PC_FREERUN_MASK); /* Enable all Gain Ramps */ - snd_soc_update_bits(codec, DA7213_AUX_L_CTRL, + snd_soc_component_update_bits(component, DA7213_AUX_L_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_AUX_R_CTRL, + snd_soc_component_update_bits(component, DA7213_AUX_R_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA7213_MIXIN_L_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_MIXIN_R_CTRL, + snd_soc_component_update_bits(component, DA7213_MIXIN_R_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_ADC_L_CTRL, + snd_soc_component_update_bits(component, DA7213_ADC_L_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_ADC_R_CTRL, + snd_soc_component_update_bits(component, DA7213_ADC_R_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA7213_DAC_L_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA7213_DAC_R_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7213_HP_L_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7213_HP_R_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); - snd_soc_update_bits(codec, DA7213_LINE_CTRL, + snd_soc_component_update_bits(component, DA7213_LINE_CTRL, DA7213_GAIN_RAMP_EN, DA7213_GAIN_RAMP_EN); /* @@ -1732,28 +1732,28 @@ static int da7213_probe(struct snd_soc_codec *codec) * being managed by DAPM while other (non power related) bits are * enabled here */ - snd_soc_update_bits(codec, DA7213_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA7213_MIXIN_L_CTRL, DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); - snd_soc_update_bits(codec, DA7213_MIXIN_R_CTRL, + snd_soc_component_update_bits(component, DA7213_MIXIN_R_CTRL, DA7213_MIXIN_MIX_EN, DA7213_MIXIN_MIX_EN); - snd_soc_update_bits(codec, DA7213_MIXOUT_L_CTRL, + snd_soc_component_update_bits(component, DA7213_MIXOUT_L_CTRL, DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); - snd_soc_update_bits(codec, DA7213_MIXOUT_R_CTRL, + snd_soc_component_update_bits(component, DA7213_MIXOUT_R_CTRL, DA7213_MIXOUT_MIX_EN, DA7213_MIXOUT_MIX_EN); - snd_soc_update_bits(codec, DA7213_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7213_HP_L_CTRL, DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); - snd_soc_update_bits(codec, DA7213_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7213_HP_R_CTRL, DA7213_HP_AMP_OE, DA7213_HP_AMP_OE); - snd_soc_update_bits(codec, DA7213_LINE_CTRL, + snd_soc_component_update_bits(component, DA7213_LINE_CTRL, DA7213_LINE_AMP_OE, DA7213_LINE_AMP_OE); /* Handle DT/Platform data */ - da7213->pdata = dev_get_platdata(codec->dev); + da7213->pdata = dev_get_platdata(component->dev); if (!da7213->pdata) - da7213->pdata = da7213_fw_to_pdata(codec); + da7213->pdata = da7213_fw_to_pdata(component); /* Set platform data values */ if (da7213->pdata) { @@ -1779,7 +1779,7 @@ static int da7213_probe(struct snd_soc_codec *codec) DA7213_MICBIAS2_LEVEL_SHIFT); break; } - snd_soc_update_bits(codec, DA7213_MICBIAS_CTRL, + snd_soc_component_update_bits(component, DA7213_MICBIAS_CTRL, DA7213_MICBIAS1_LEVEL_MASK | DA7213_MICBIAS2_LEVEL_MASK, micbias_lvl); @@ -1805,14 +1805,14 @@ static int da7213_probe(struct snd_soc_codec *codec) DA7213_DMIC_CLK_RATE_SHIFT); break; } - snd_soc_update_bits(codec, DA7213_MIC_CONFIG, + snd_soc_component_update_bits(component, DA7213_MIC_CONFIG, DA7213_DMIC_DATA_SEL_MASK | DA7213_DMIC_SAMPLEPHASE_MASK | DA7213_DMIC_CLK_RATE_MASK, dmic_cfg); } /* Check if MCLK provided */ - da7213->mclk = devm_clk_get(codec->dev, "mclk"); + da7213->mclk = devm_clk_get(component->dev, "mclk"); if (IS_ERR(da7213->mclk)) { if (PTR_ERR(da7213->mclk) != -ENOENT) return PTR_ERR(da7213->mclk); @@ -1823,18 +1823,19 @@ static int da7213_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_da7213 = { +static const struct snd_soc_component_driver soc_component_dev_da7213 = { .probe = da7213_probe, .set_bias_level = da7213_set_bias_level, - - .component_driver = { - .controls = da7213_snd_controls, - .num_controls = ARRAY_SIZE(da7213_snd_controls), - .dapm_widgets = da7213_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da7213_dapm_widgets), - .dapm_routes = da7213_audio_map, - .num_dapm_routes = ARRAY_SIZE(da7213_audio_map), - }, + .controls = da7213_snd_controls, + .num_controls = ARRAY_SIZE(da7213_snd_controls), + .dapm_widgets = da7213_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da7213_dapm_widgets), + .dapm_routes = da7213_audio_map, + .num_dapm_routes = ARRAY_SIZE(da7213_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config da7213_regmap_config = { @@ -1866,21 +1867,15 @@ static int da7213_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_da7213, &da7213_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_da7213, &da7213_dai, 1); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register da7213 codec: %d\n", + dev_err(&i2c->dev, "Failed to register da7213 component: %d\n", ret); } return ret; } -static int da7213_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id da7213_i2c_id[] = { { "da7213", 0 }, { } @@ -1895,7 +1890,6 @@ static struct i2c_driver da7213_i2c_driver = { .acpi_match_table = ACPI_PTR(da7213_acpi_match), }, .probe = da7213_i2c_probe, - .remove = da7213_remove, .id_table = da7213_i2c_id, }; From 35fc975bc7efdc82447f5cc69d401e185779f4b0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:03:34 +0000 Subject: [PATCH 095/942] ASoC: da9055: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da9055.c | 186 ++++++++++++++++++-------------------- 1 file changed, 90 insertions(+), 96 deletions(-) diff --git a/sound/soc/codecs/da9055.c b/sound/soc/codecs/da9055.c index bd7faaee5802..afdf90c78884 100644 --- a/sound/soc/codecs/da9055.c +++ b/sound/soc/codecs/da9055.c @@ -451,7 +451,7 @@ static const char * const da9055_hold_time_txt[] = { static SOC_ENUM_SINGLE_DECL(da9055_hold_time, DA9055_ALC_CTRL3, 0, da9055_hold_time_txt); -static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) +static int da9055_get_alc_data(struct snd_soc_component *component, u8 reg_val) { int mid_data, top_data; int sum = 0; @@ -460,17 +460,17 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) for (iteration = 0; iteration < DA9055_ALC_AVG_ITERATIONS; iteration++) { /* Select the left or right channel and capture data */ - snd_soc_write(codec, DA9055_ALC_CIC_OP_LVL_CTRL, reg_val); + snd_soc_component_write(component, DA9055_ALC_CIC_OP_LVL_CTRL, reg_val); /* Select middle 8 bits for read back from data register */ - snd_soc_write(codec, DA9055_ALC_CIC_OP_LVL_CTRL, + snd_soc_component_write(component, DA9055_ALC_CIC_OP_LVL_CTRL, reg_val | DA9055_ALC_DATA_MIDDLE); - mid_data = snd_soc_read(codec, DA9055_ALC_CIC_OP_LVL_DATA); + mid_data = snd_soc_component_read32(component, DA9055_ALC_CIC_OP_LVL_DATA); /* Select top 8 bits for read back from data register */ - snd_soc_write(codec, DA9055_ALC_CIC_OP_LVL_CTRL, + snd_soc_component_write(component, DA9055_ALC_CIC_OP_LVL_CTRL, reg_val | DA9055_ALC_DATA_TOP); - top_data = snd_soc_read(codec, DA9055_ALC_CIC_OP_LVL_DATA); + top_data = snd_soc_component_read32(component, DA9055_ALC_CIC_OP_LVL_DATA); sum += ((mid_data << 8) | (top_data << 16)); } @@ -481,7 +481,7 @@ static int da9055_get_alc_data(struct snd_soc_codec *codec, u8 reg_val) static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); u8 reg_val, adc_left, adc_right, mic_left, mic_right; int avg_left_data, avg_right_data, offset_l, offset_r; @@ -492,31 +492,31 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, */ /* Save current values from Mic control registers */ - mic_left = snd_soc_read(codec, DA9055_MIC_L_CTRL); - mic_right = snd_soc_read(codec, DA9055_MIC_R_CTRL); + mic_left = snd_soc_component_read32(component, DA9055_MIC_L_CTRL); + mic_right = snd_soc_component_read32(component, DA9055_MIC_R_CTRL); /* Mute Mic PGA Left and Right */ - snd_soc_update_bits(codec, DA9055_MIC_L_CTRL, + snd_soc_component_update_bits(component, DA9055_MIC_L_CTRL, DA9055_MIC_L_MUTE_EN, DA9055_MIC_L_MUTE_EN); - snd_soc_update_bits(codec, DA9055_MIC_R_CTRL, + snd_soc_component_update_bits(component, DA9055_MIC_R_CTRL, DA9055_MIC_R_MUTE_EN, DA9055_MIC_R_MUTE_EN); /* Save current values from ADC control registers */ - adc_left = snd_soc_read(codec, DA9055_ADC_L_CTRL); - adc_right = snd_soc_read(codec, DA9055_ADC_R_CTRL); + adc_left = snd_soc_component_read32(component, DA9055_ADC_L_CTRL); + adc_right = snd_soc_component_read32(component, DA9055_ADC_R_CTRL); /* Enable ADC Left and Right */ - snd_soc_update_bits(codec, DA9055_ADC_L_CTRL, + snd_soc_component_update_bits(component, DA9055_ADC_L_CTRL, DA9055_ADC_L_EN, DA9055_ADC_L_EN); - snd_soc_update_bits(codec, DA9055_ADC_R_CTRL, + snd_soc_component_update_bits(component, DA9055_ADC_R_CTRL, DA9055_ADC_R_EN, DA9055_ADC_R_EN); /* Calculate average for Left and Right data */ /* Left Data */ - avg_left_data = da9055_get_alc_data(codec, + avg_left_data = da9055_get_alc_data(component, DA9055_ALC_CIC_OP_CHANNEL_LEFT); /* Right Data */ - avg_right_data = da9055_get_alc_data(codec, + avg_right_data = da9055_get_alc_data(component, DA9055_ALC_CIC_OP_CHANNEL_RIGHT); /* Calculate DC offset */ @@ -524,22 +524,22 @@ static int da9055_put_alc_sw(struct snd_kcontrol *kcontrol, offset_r = -avg_right_data; reg_val = (offset_l & DA9055_ALC_OFFSET_15_8) >> 8; - snd_soc_write(codec, DA9055_ALC_OFFSET_OP2M_L, reg_val); + snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2M_L, reg_val); reg_val = (offset_l & DA9055_ALC_OFFSET_17_16) >> 16; - snd_soc_write(codec, DA9055_ALC_OFFSET_OP2U_L, reg_val); + snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2U_L, reg_val); reg_val = (offset_r & DA9055_ALC_OFFSET_15_8) >> 8; - snd_soc_write(codec, DA9055_ALC_OFFSET_OP2M_R, reg_val); + snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2M_R, reg_val); reg_val = (offset_r & DA9055_ALC_OFFSET_17_16) >> 16; - snd_soc_write(codec, DA9055_ALC_OFFSET_OP2U_R, reg_val); + snd_soc_component_write(component, DA9055_ALC_OFFSET_OP2U_R, reg_val); /* Restore original values of ADC control registers */ - snd_soc_write(codec, DA9055_ADC_L_CTRL, adc_left); - snd_soc_write(codec, DA9055_ADC_R_CTRL, adc_right); + snd_soc_component_write(component, DA9055_ADC_L_CTRL, adc_left); + snd_soc_component_write(component, DA9055_ADC_R_CTRL, adc_right); /* Restore original values of Mic control registers */ - snd_soc_write(codec, DA9055_MIC_L_CTRL, mic_left); - snd_soc_write(codec, DA9055_MIC_R_CTRL, mic_right); + snd_soc_component_write(component, DA9055_MIC_L_CTRL, mic_left); + snd_soc_component_write(component, DA9055_MIC_R_CTRL, mic_right); } return snd_soc_put_volsw(kcontrol, ucontrol); @@ -1052,8 +1052,8 @@ static int da9055_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component); u8 aif_ctrl, fs; u32 sysclk; @@ -1075,7 +1075,7 @@ static int da9055_hw_params(struct snd_pcm_substream *substream, } /* Set AIF format */ - snd_soc_update_bits(codec, DA9055_AIF_CTRL, DA9055_AIF_WORD_LENGTH_MASK, + snd_soc_component_update_bits(component, DA9055_AIF_CTRL, DA9055_AIF_WORD_LENGTH_MASK, aif_ctrl); switch (params_rate(params)) { @@ -1125,7 +1125,7 @@ static int da9055_hw_params(struct snd_pcm_substream *substream, if (da9055->mclk_rate) { /* PLL Mode, Write actual FS */ - snd_soc_write(codec, DA9055_SR, fs); + snd_soc_component_write(component, DA9055_SR, fs); } else { /* * Non-PLL Mode @@ -1134,24 +1134,24 @@ static int da9055_hw_params(struct snd_pcm_substream *substream, * to derive its sys clk. As sys clk has to be 256 * Fs, we * need to write constant sample rate i.e. 48KHz. */ - snd_soc_write(codec, DA9055_SR, DA9055_SR_48000); + snd_soc_component_write(component, DA9055_SR, DA9055_SR_48000); } if (da9055->mclk_rate && (da9055->mclk_rate != sysclk)) { /* PLL Mode */ if (!da9055->master) { /* PLL slave mode, enable PLL and also SRM */ - snd_soc_update_bits(codec, DA9055_PLL_CTRL, + snd_soc_component_update_bits(component, DA9055_PLL_CTRL, DA9055_PLL_EN | DA9055_PLL_SRM_EN, DA9055_PLL_EN | DA9055_PLL_SRM_EN); } else { /* PLL master mode, only enable PLL */ - snd_soc_update_bits(codec, DA9055_PLL_CTRL, + snd_soc_component_update_bits(component, DA9055_PLL_CTRL, DA9055_PLL_EN, DA9055_PLL_EN); } } else { /* Non PLL Mode, disable PLL */ - snd_soc_update_bits(codec, DA9055_PLL_CTRL, DA9055_PLL_EN, 0); + snd_soc_component_update_bits(component, DA9055_PLL_CTRL, DA9055_PLL_EN, 0); } return 0; @@ -1160,8 +1160,8 @@ static int da9055_hw_params(struct snd_pcm_substream *substream, /* Set DAI mode and Format */ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component); u8 aif_clk_mode, aif_ctrl, mode; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1180,7 +1180,7 @@ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) } /* Don't allow change of mode if PLL is enabled */ - if ((snd_soc_read(codec, DA9055_PLL_CTRL) & DA9055_PLL_EN) && + if ((snd_soc_component_read32(component, DA9055_PLL_CTRL) & DA9055_PLL_EN) && (da9055->master != mode)) return -EINVAL; @@ -1207,27 +1207,27 @@ static int da9055_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* By default only 32 BCLK per WCLK is supported */ aif_clk_mode |= DA9055_AIF_BCLKS_PER_WCLK_32; - snd_soc_update_bits(codec, DA9055_AIF_CLK_MODE, + snd_soc_component_update_bits(component, DA9055_AIF_CLK_MODE, (DA9055_AIF_CLK_MODE_MASK | DA9055_AIF_BCLK_MASK), aif_clk_mode); - snd_soc_update_bits(codec, DA9055_AIF_CTRL, DA9055_AIF_FORMAT_MASK, + snd_soc_component_update_bits(component, DA9055_AIF_CTRL, DA9055_AIF_FORMAT_MASK, aif_ctrl); return 0; } static int da9055_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) { - snd_soc_update_bits(codec, DA9055_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA9055_DAC_L_CTRL, DA9055_DAC_L_MUTE_EN, DA9055_DAC_L_MUTE_EN); - snd_soc_update_bits(codec, DA9055_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA9055_DAC_R_CTRL, DA9055_DAC_R_MUTE_EN, DA9055_DAC_R_MUTE_EN); } else { - snd_soc_update_bits(codec, DA9055_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA9055_DAC_L_CTRL, DA9055_DAC_L_MUTE_EN, 0); - snd_soc_update_bits(codec, DA9055_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA9055_DAC_R_CTRL, DA9055_DAC_R_MUTE_EN, 0); } @@ -1240,8 +1240,8 @@ static int da9055_mute(struct snd_soc_dai *dai, int mute) static int da9055_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component); switch (clk_id) { case DA9055_CLKSRC_MCLK: @@ -1283,13 +1283,13 @@ static int da9055_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int da9055_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int fref, unsigned int fout) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component); u8 pll_frac_top, pll_frac_bot, pll_integer, cnt; /* Disable PLL before setting the divisors */ - snd_soc_update_bits(codec, DA9055_PLL_CTRL, DA9055_PLL_EN, 0); + snd_soc_component_update_bits(component, DA9055_PLL_CTRL, DA9055_PLL_EN, 0); /* In slave mode, there is only one set of divisors */ if (!da9055->master && (fout != 2822400)) @@ -1312,9 +1312,9 @@ static int da9055_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, goto pll_err; /* Write PLL dividers */ - snd_soc_write(codec, DA9055_PLL_FRAC_TOP, pll_frac_top); - snd_soc_write(codec, DA9055_PLL_FRAC_BOT, pll_frac_bot); - snd_soc_write(codec, DA9055_PLL_INTEGER, pll_integer); + snd_soc_component_write(component, DA9055_PLL_FRAC_TOP, pll_frac_top); + snd_soc_component_write(component, DA9055_PLL_FRAC_BOT, pll_frac_bot); + snd_soc_component_write(component, DA9055_PLL_INTEGER, pll_integer); return 0; pll_err: @@ -1353,7 +1353,7 @@ static struct snd_soc_dai_driver da9055_dai = { .symmetric_rates = 1, }; -static int da9055_set_bias_level(struct snd_soc_codec *codec, +static int da9055_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -1361,48 +1361,48 @@ static int da9055_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Enable VMID reference & master bias */ - snd_soc_update_bits(codec, DA9055_REFERENCES, + snd_soc_component_update_bits(component, DA9055_REFERENCES, DA9055_VMID_EN | DA9055_BIAS_EN, DA9055_VMID_EN | DA9055_BIAS_EN); } break; case SND_SOC_BIAS_OFF: /* Disable VMID reference & master bias */ - snd_soc_update_bits(codec, DA9055_REFERENCES, + snd_soc_component_update_bits(component, DA9055_REFERENCES, DA9055_VMID_EN | DA9055_BIAS_EN, 0); break; } return 0; } -static int da9055_probe(struct snd_soc_codec *codec) +static int da9055_probe(struct snd_soc_component *component) { - struct da9055_priv *da9055 = snd_soc_codec_get_drvdata(codec); + struct da9055_priv *da9055 = snd_soc_component_get_drvdata(component); /* Enable all Gain Ramps */ - snd_soc_update_bits(codec, DA9055_AUX_L_CTRL, + snd_soc_component_update_bits(component, DA9055_AUX_L_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_AUX_R_CTRL, + snd_soc_component_update_bits(component, DA9055_AUX_R_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA9055_MIXIN_L_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_MIXIN_R_CTRL, + snd_soc_component_update_bits(component, DA9055_MIXIN_R_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_ADC_L_CTRL, + snd_soc_component_update_bits(component, DA9055_ADC_L_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_ADC_R_CTRL, + snd_soc_component_update_bits(component, DA9055_ADC_R_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA9055_DAC_L_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA9055_DAC_R_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_HP_L_CTRL, + snd_soc_component_update_bits(component, DA9055_HP_L_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_HP_R_CTRL, + snd_soc_component_update_bits(component, DA9055_HP_R_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); - snd_soc_update_bits(codec, DA9055_LINE_CTRL, + snd_soc_component_update_bits(component, DA9055_LINE_CTRL, DA9055_GAIN_RAMPING_EN, DA9055_GAIN_RAMPING_EN); /* @@ -1412,28 +1412,28 @@ static int da9055_probe(struct snd_soc_codec *codec) * being managed by DAPM while other (non power related) bits are * enabled here */ - snd_soc_update_bits(codec, DA9055_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA9055_MIXIN_L_CTRL, DA9055_MIXIN_L_MIX_EN, DA9055_MIXIN_L_MIX_EN); - snd_soc_update_bits(codec, DA9055_MIXIN_R_CTRL, + snd_soc_component_update_bits(component, DA9055_MIXIN_R_CTRL, DA9055_MIXIN_R_MIX_EN, DA9055_MIXIN_R_MIX_EN); - snd_soc_update_bits(codec, DA9055_MIXOUT_L_CTRL, + snd_soc_component_update_bits(component, DA9055_MIXOUT_L_CTRL, DA9055_MIXOUT_L_MIX_EN, DA9055_MIXOUT_L_MIX_EN); - snd_soc_update_bits(codec, DA9055_MIXOUT_R_CTRL, + snd_soc_component_update_bits(component, DA9055_MIXOUT_R_CTRL, DA9055_MIXOUT_R_MIX_EN, DA9055_MIXOUT_R_MIX_EN); /* Set this as per your system configuration */ - snd_soc_write(codec, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ); + snd_soc_component_write(component, DA9055_PLL_CTRL, DA9055_PLL_INDIV_10_20_MHZ); /* Set platform data values */ if (da9055->pdata) { /* set mic bias source */ if (da9055->pdata->micbias_source) { - snd_soc_update_bits(codec, DA9055_MIXIN_R_SELECT, + snd_soc_component_update_bits(component, DA9055_MIXIN_R_SELECT, DA9055_MICBIAS2_EN, DA9055_MICBIAS2_EN); } else { - snd_soc_update_bits(codec, DA9055_MIXIN_R_SELECT, + snd_soc_component_update_bits(component, DA9055_MIXIN_R_SELECT, DA9055_MICBIAS2_EN, 0); } /* set mic bias voltage */ @@ -1442,7 +1442,7 @@ static int da9055_probe(struct snd_soc_codec *codec) case DA9055_MICBIAS_2_1V: case DA9055_MICBIAS_1_8V: case DA9055_MICBIAS_1_6V: - snd_soc_update_bits(codec, DA9055_MIC_CONFIG, + snd_soc_component_update_bits(component, DA9055_MIC_CONFIG, DA9055_MICBIAS_LEVEL_MASK, (da9055->pdata->micbias) << 4); break; @@ -1451,18 +1451,19 @@ static int da9055_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_da9055 = { +static const struct snd_soc_component_driver soc_component_dev_da9055 = { .probe = da9055_probe, .set_bias_level = da9055_set_bias_level, - - .component_driver = { - .controls = da9055_snd_controls, - .num_controls = ARRAY_SIZE(da9055_snd_controls), - .dapm_widgets = da9055_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da9055_dapm_widgets), - .dapm_routes = da9055_audio_map, - .num_dapm_routes = ARRAY_SIZE(da9055_audio_map), - }, + .controls = da9055_snd_controls, + .num_controls = ARRAY_SIZE(da9055_snd_controls), + .dapm_widgets = da9055_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da9055_dapm_widgets), + .dapm_routes = da9055_audio_map, + .num_dapm_routes = ARRAY_SIZE(da9055_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config da9055_regmap_config = { @@ -1499,21 +1500,15 @@ static int da9055_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_da9055, &da9055_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_da9055, &da9055_dai, 1); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register da9055 codec: %d\n", + dev_err(&i2c->dev, "Failed to register da9055 component: %d\n", ret); } return ret; } -static int da9055_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - /* * DO NOT change the device Ids. The naming is intentionally specific as both * the CODEC and PMIC parts of this chip are instantiated separately as I2C @@ -1540,7 +1535,6 @@ static struct i2c_driver da9055_i2c_driver = { .of_match_table = of_match_ptr(da9055_of_match), }, .probe = da9055_i2c_probe, - .remove = da9055_remove, .id_table = da9055_i2c_id, }; From fbf60d9727d544c5c9676b5e9a1baab0704cc9ed Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:04:07 +0000 Subject: [PATCH 096/942] ASoC: max9860: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max9860.c | 70 ++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/max9860.c b/sound/soc/codecs/max9860.c index a2dc6a47f466..5bbf889ad98e 100644 --- a/sound/soc/codecs/max9860.c +++ b/sound/soc/codecs/max9860.c @@ -261,8 +261,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component); u8 master; u8 ifc1a = 0; u8 ifc1b = 0; @@ -270,7 +270,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, unsigned long n; int ret; - dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", + dev_dbg(component->dev, "hw_params %u Hz, %u channels\n", params_rate(params), params_channels(params)); @@ -306,7 +306,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, break; case SND_SOC_DAIFMT_DSP_A: if (params_width(params) != 16) { - dev_err(codec->dev, + dev_err(component->dev, "DSP_A works for 16 bits per sample only.\n"); return -EINVAL; } @@ -315,7 +315,7 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, break; case SND_SOC_DAIFMT_DSP_B: if (params_width(params) != 16) { - dev_err(codec->dev, + dev_err(component->dev, "DSP_B works for 16 bits per sample only.\n"); return -EINVAL; } @@ -352,16 +352,16 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - dev_dbg(codec->dev, "IFC1A %02x\n", ifc1a); + dev_dbg(component->dev, "IFC1A %02x\n", ifc1a); ret = regmap_write(max9860->regmap, MAX9860_IFC1A, ifc1a); if (ret) { - dev_err(codec->dev, "Failed to set IFC1A: %d\n", ret); + dev_err(component->dev, "Failed to set IFC1A: %d\n", ret); return ret; } - dev_dbg(codec->dev, "IFC1B %02x\n", ifc1b); + dev_dbg(component->dev, "IFC1B %02x\n", ifc1b); ret = regmap_write(max9860->regmap, MAX9860_IFC1B, ifc1b); if (ret) { - dev_err(codec->dev, "Failed to set IFC1B: %d\n", ret); + dev_err(component->dev, "Failed to set IFC1B: %d\n", ret); return ret; } @@ -417,33 +417,33 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, } sysclk |= max9860->psclk; - dev_dbg(codec->dev, "SYSCLK %02x\n", sysclk); + dev_dbg(component->dev, "SYSCLK %02x\n", sysclk); ret = regmap_write(max9860->regmap, MAX9860_SYSCLK, sysclk); if (ret) { - dev_err(codec->dev, "Failed to set SYSCLK: %d\n", ret); + dev_err(component->dev, "Failed to set SYSCLK: %d\n", ret); return ret; } - dev_dbg(codec->dev, "N %lu\n", n); + dev_dbg(component->dev, "N %lu\n", n); ret = regmap_write(max9860->regmap, MAX9860_AUDIOCLKHIGH, n >> 8); if (ret) { - dev_err(codec->dev, "Failed to set NHI: %d\n", ret); + dev_err(component->dev, "Failed to set NHI: %d\n", ret); return ret; } ret = regmap_write(max9860->regmap, MAX9860_AUDIOCLKLOW, n & 0xff); if (ret) { - dev_err(codec->dev, "Failed to set NLO: %d\n", ret); + dev_err(component->dev, "Failed to set NLO: %d\n", ret); return ret; } if (!master) { - dev_dbg(codec->dev, "Enable PLL\n"); + dev_dbg(component->dev, "Enable PLL\n"); ret = regmap_update_bits(max9860->regmap, MAX9860_AUDIOCLKHIGH, MAX9860_PLL, MAX9860_PLL); if (ret) { - dev_err(codec->dev, "Failed to enable PLL: %d\n", ret); + dev_err(component->dev, "Failed to enable PLL: %d\n", ret); return ret; } } @@ -453,8 +453,8 @@ static int max9860_hw_params(struct snd_pcm_substream *substream, static int max9860_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct max9860_priv *max9860 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9860_priv *max9860 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -500,10 +500,10 @@ static struct snd_soc_dai_driver max9860_dai = { .symmetric_rates = 1, }; -static int max9860_set_bias_level(struct snd_soc_codec *codec, +static int max9860_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max9860_priv *max9860 = dev_get_drvdata(codec->dev); + struct max9860_priv *max9860 = dev_get_drvdata(component->dev); int ret; switch (level) { @@ -515,7 +515,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, MAX9860_SHDN, MAX9860_SHDN); if (ret) { - dev_err(codec->dev, "Failed to remove SHDN: %d\n", ret); + dev_err(component->dev, "Failed to remove SHDN: %d\n", ret); return ret; } break; @@ -524,7 +524,7 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, ret = regmap_update_bits(max9860->regmap, MAX9860_PWRMAN, MAX9860_SHDN, 0); if (ret) { - dev_err(codec->dev, "Failed to request SHDN: %d\n", + dev_err(component->dev, "Failed to request SHDN: %d\n", ret); return ret; } @@ -534,18 +534,17 @@ static int max9860_set_bias_level(struct snd_soc_codec *codec, return 0; } -static const struct snd_soc_codec_driver max9860_codec_driver = { - .set_bias_level = max9860_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = max9860_controls, - .num_controls = ARRAY_SIZE(max9860_controls), - .dapm_widgets = max9860_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets), - .dapm_routes = max9860_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes), - }, +static const struct snd_soc_component_driver max9860_component_driver = { + .set_bias_level = max9860_set_bias_level, + .controls = max9860_controls, + .num_controls = ARRAY_SIZE(max9860_controls), + .dapm_widgets = max9860_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9860_dapm_widgets), + .dapm_routes = max9860_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max9860_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #ifdef CONFIG_PM @@ -698,7 +697,7 @@ static int max9860_probe(struct i2c_client *i2c, pm_runtime_enable(dev); pm_runtime_idle(dev); - ret = snd_soc_register_codec(dev, &max9860_codec_driver, + ret = devm_snd_soc_register_component(dev, &max9860_component_driver, &max9860_dai, 1); if (ret) { dev_err(dev, "Failed to register CODEC: %d\n", ret); @@ -719,7 +718,6 @@ static int max9860_remove(struct i2c_client *i2c) struct device *dev = &i2c->dev; struct max9860_priv *max9860 = dev_get_drvdata(dev); - snd_soc_unregister_codec(dev); pm_runtime_disable(dev); regulator_disable(max9860->dvddio); return 0; From 0b3eda289c5cf84b7b1a5245812370accece2f19 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:04:34 +0000 Subject: [PATCH 097/942] ASoC: max9850: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max9850.c | 80 ++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 43 deletions(-) diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index a3dfc918c278..74d7f52c7e73 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c @@ -130,8 +130,8 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); u64 lrclk_div; u8 sf, da; @@ -139,14 +139,14 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, return -EINVAL; /* lrclk_div = 2^22 * rate / iclk with iclk = mclk / sf */ - sf = (snd_soc_read(codec, MAX9850_CLOCK) >> 2) + 1; + sf = (snd_soc_component_read32(component, MAX9850_CLOCK) >> 2) + 1; lrclk_div = (1 << 22); lrclk_div *= params_rate(params); lrclk_div *= sf; do_div(lrclk_div, max9850->sysclk); - snd_soc_write(codec, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); - snd_soc_write(codec, MAX9850_LRCLK_LSB, lrclk_div & 0xff); + snd_soc_component_write(component, MAX9850_LRCLK_MSB, (lrclk_div >> 8) & 0x7f); + snd_soc_component_write(component, MAX9850_LRCLK_LSB, lrclk_div & 0xff); switch (params_width(params)) { case 16: @@ -161,7 +161,7 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, MAX9850_DIGITAL_AUDIO, 0x3, da); + snd_soc_component_update_bits(component, MAX9850_DIGITAL_AUDIO, 0x3, da); return 0; } @@ -169,16 +169,16 @@ static int max9850_hw_params(struct snd_pcm_substream *substream, static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); /* calculate mclk -> iclk divider */ if (freq <= 13000000) - snd_soc_write(codec, MAX9850_CLOCK, 0x0); + snd_soc_component_write(component, MAX9850_CLOCK, 0x0); else if (freq <= 26000000) - snd_soc_write(codec, MAX9850_CLOCK, 0x4); + snd_soc_component_write(component, MAX9850_CLOCK, 0x4); else if (freq <= 40000000) - snd_soc_write(codec, MAX9850_CLOCK, 0x8); + snd_soc_component_write(component, MAX9850_CLOCK, 0x8); else return -EINVAL; @@ -188,7 +188,7 @@ static int max9850_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 da = 0; /* set master/slave audio interface */ @@ -234,15 +234,15 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) } /* set da */ - snd_soc_write(codec, MAX9850_DIGITAL_AUDIO, da); + snd_soc_component_write(component, MAX9850_DIGITAL_AUDIO, da); return 0; } -static int max9850_set_bias_level(struct snd_soc_codec *codec, +static int max9850_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); + struct max9850_priv *max9850 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -251,10 +251,10 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max9850->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } @@ -289,31 +289,32 @@ static struct snd_soc_dai_driver max9850_dai = { .ops = &max9850_dai_ops, }; -static int max9850_probe(struct snd_soc_codec *codec) +static int max9850_probe(struct snd_soc_component *component) { /* enable zero-detect */ - snd_soc_update_bits(codec, MAX9850_GENERAL_PURPOSE, 1, 1); + snd_soc_component_update_bits(component, MAX9850_GENERAL_PURPOSE, 1, 1); /* enable slew-rate control */ - snd_soc_update_bits(codec, MAX9850_VOLUME, 0x40, 0x40); + snd_soc_component_update_bits(component, MAX9850_VOLUME, 0x40, 0x40); /* set slew-rate 125ms */ - snd_soc_update_bits(codec, MAX9850_CHARGE_PUMP, 0xff, 0xc0); + snd_soc_component_update_bits(component, MAX9850_CHARGE_PUMP, 0xff, 0xc0); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max9850 = { - .probe = max9850_probe, - .set_bias_level = max9850_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = max9850_controls, - .num_controls = ARRAY_SIZE(max9850_controls), - .dapm_widgets = max9850_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), - .dapm_routes = max9850_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_max9850 = { + .probe = max9850_probe, + .set_bias_level = max9850_set_bias_level, + .controls = max9850_controls, + .num_controls = ARRAY_SIZE(max9850_controls), + .dapm_widgets = max9850_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9850_dapm_widgets), + .dapm_routes = max9850_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max9850_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int max9850_i2c_probe(struct i2c_client *i2c, @@ -333,17 +334,11 @@ static int max9850_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, max9850); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_max9850, &max9850_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max9850, &max9850_dai, 1); return ret; } -static int max9850_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max9850_i2c_id[] = { { "max9850", 0 }, { } @@ -355,7 +350,6 @@ static struct i2c_driver max9850_i2c_driver = { .name = "max9850", }, .probe = max9850_i2c_probe, - .remove = max9850_i2c_remove, .id_table = max9850_i2c_id, }; From 1ae91ac7f787ee4078d93147d633ce3377ece748 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:05:15 +0000 Subject: [PATCH 098/942] ASoC: max98371: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98371.c | 43 ++++++++++++++++--------------------- sound/soc/codecs/max98371.h | 1 - 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/max98371.c b/sound/soc/codecs/max98371.c index 7bc2a17c1e94..d4ba1392aaf8 100644 --- a/sound/soc/codecs/max98371.c +++ b/sound/soc/codecs/max98371.c @@ -187,15 +187,15 @@ static const struct snd_kcontrol_new max98371_snd_controls[] = { static int max98371_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98371_priv *max98371 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98371_priv *max98371 = snd_soc_component_get_drvdata(component); unsigned int val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: break; default: - dev_err(codec->dev, "DAI clock mode unsupported"); + dev_err(component->dev, "DAI clock mode unsupported"); return -EINVAL; } @@ -210,7 +210,7 @@ static int max98371_dai_set_fmt(struct snd_soc_dai *codec_dai, val |= MAX98371_DAI_LEFT; break; default: - dev_err(codec->dev, "DAI wrong mode unsupported"); + dev_err(component->dev, "DAI wrong mode unsupported"); return -EINVAL; } regmap_update_bits(max98371->regmap, MAX98371_FMT, @@ -222,8 +222,8 @@ static int max98371_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98371_priv *max98371 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98371_priv *max98371 = snd_soc_component_get_drvdata(component); int blr_clk_ratio, ch_size, channels = params_channels(params); int rate = params_rate(params); @@ -348,15 +348,17 @@ static struct snd_soc_dai_driver max98371_dai[] = { } }; -static const struct snd_soc_codec_driver max98371_codec = { - .component_driver = { - .controls = max98371_snd_controls, - .num_controls = ARRAY_SIZE(max98371_snd_controls), - .dapm_routes = max98371_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98371_audio_map), - .dapm_widgets = max98371_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets), - }, +static const struct snd_soc_component_driver max98371_component = { + .controls = max98371_snd_controls, + .num_controls = ARRAY_SIZE(max98371_snd_controls), + .dapm_routes = max98371_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98371_audio_map), + .dapm_widgets = max98371_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98371_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98371_regmap = { @@ -397,21 +399,15 @@ static int max98371_i2c_probe(struct i2c_client *i2c, } dev_info(&i2c->dev, "device version %x\n", reg); - ret = snd_soc_register_codec(&i2c->dev, &max98371_codec, + ret = devm_snd_soc_register_component(&i2c->dev, &max98371_component, max98371_dai, ARRAY_SIZE(max98371_dai)); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } return ret; } -static int max98371_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98371_i2c_id[] = { { "max98371", 0 }, { } @@ -432,7 +428,6 @@ static struct i2c_driver max98371_i2c_driver = { .of_match_table = of_match_ptr(max98371_of_match), }, .probe = max98371_i2c_probe, - .remove = max98371_i2c_remove, .id_table = max98371_i2c_id, }; diff --git a/sound/soc/codecs/max98371.h b/sound/soc/codecs/max98371.h index 9f6330964d98..06e9ba784e0b 100644 --- a/sound/soc/codecs/max98371.h +++ b/sound/soc/codecs/max98371.h @@ -62,6 +62,5 @@ struct max98371_priv { struct regmap *regmap; - struct snd_soc_codec *codec; }; #endif From 2dd1637f5a7c602a2d32d95821b0cef13fff175a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:05:45 +0000 Subject: [PATCH 099/942] ASoC: max98095: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98095.c | 448 ++++++++++++++++++------------------ sound/soc/codecs/max98095.h | 2 +- 2 files changed, 222 insertions(+), 228 deletions(-) diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 5ead87d2ab1d..6bf2d0ba864f 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c @@ -251,7 +251,7 @@ static const struct regmap_config max98095_regmap = { /* * Load equalizer DSP coefficient configurations registers */ -static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai, +static void m98095_eq_band(struct snd_soc_component *component, unsigned int dai, unsigned int band, u16 *coefs) { unsigned int eq_reg; @@ -269,15 +269,15 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai, /* Step through the registers and coefs */ for (i = 0; i < M98095_COEFS_PER_BAND; i++) { - snd_soc_write(codec, eq_reg++, M98095_BYTE1(coefs[i])); - snd_soc_write(codec, eq_reg++, M98095_BYTE0(coefs[i])); + snd_soc_component_write(component, eq_reg++, M98095_BYTE1(coefs[i])); + snd_soc_component_write(component, eq_reg++, M98095_BYTE0(coefs[i])); } } /* * Load biquad filter coefficient configurations registers */ -static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai, +static void m98095_biquad_band(struct snd_soc_component *component, unsigned int dai, unsigned int band, u16 *coefs) { unsigned int bq_reg; @@ -295,8 +295,8 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai, /* Step through the registers and coefs */ for (i = 0; i < M98095_COEFS_PER_BAND; i++) { - snd_soc_write(codec, bq_reg++, M98095_BYTE1(coefs[i])); - snd_soc_write(codec, bq_reg++, M98095_BYTE0(coefs[i])); + snd_soc_component_write(component, bq_reg++, M98095_BYTE1(coefs[i])); + snd_soc_component_write(component, bq_reg++, M98095_BYTE0(coefs[i])); } } @@ -353,12 +353,12 @@ static SOC_ENUM_SINGLE_DECL(max98095_dai3_dac_filter_enum, static int max98095_mic1pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; max98095->mic1pre = sel; - snd_soc_update_bits(codec, M98095_05F_LVL_MIC1, M98095_MICPRE_MASK, + snd_soc_component_update_bits(component, M98095_05F_LVL_MIC1, M98095_MICPRE_MASK, (1+sel)<value.integer.value[0] = max98095->mic1pre; return 0; @@ -377,12 +377,12 @@ static int max98095_mic1pre_get(struct snd_kcontrol *kcontrol, static int max98095_mic2pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; max98095->mic2pre = sel; - snd_soc_update_bits(codec, M98095_060_LVL_MIC2, M98095_MICPRE_MASK, + snd_soc_component_update_bits(component, M98095_060_LVL_MIC2, M98095_MICPRE_MASK, (1+sel)<value.integer.value[0] = max98095->mic2pre; return 0; @@ -598,21 +598,21 @@ static const struct snd_kcontrol_new max98095_right_ADC_mixer_controls[] = { static int max98095_mic_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: if (w->reg == M98095_05F_LVL_MIC1) { - snd_soc_update_bits(codec, w->reg, M98095_MICPRE_MASK, + snd_soc_component_update_bits(component, w->reg, M98095_MICPRE_MASK, (1+max98095->mic1pre)<reg, M98095_MICPRE_MASK, + snd_soc_component_update_bits(component, w->reg, M98095_MICPRE_MASK, (1+max98095->mic2pre)<reg, M98095_MICPRE_MASK, 0); + snd_soc_component_update_bits(component, w->reg, M98095_MICPRE_MASK, 0); break; default: return -EINVAL; @@ -628,8 +628,8 @@ static int max98095_mic_event(struct snd_soc_dapm_widget *w, static int max98095_line_pga(struct snd_soc_dapm_widget *w, int event, u8 channel) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); u8 *state; if (WARN_ON(!(channel == 1 || channel == 2))) @@ -640,13 +640,13 @@ static int max98095_line_pga(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: *state |= channel; - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << w->shift), (1 << w->shift)); break; case SND_SOC_DAPM_POST_PMD: *state &= ~channel; if (*state == 0) { - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << w->shift), 0); } break; @@ -676,15 +676,15 @@ static int max98095_pga_in2_event(struct snd_soc_dapm_widget *w, static int max98095_lineout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << (w->shift+2)), (1 << (w->shift+2))); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << (w->shift+2)), 0); break; default: @@ -942,8 +942,8 @@ static int max98095_dai1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; unsigned long long ni; unsigned int rate; @@ -955,11 +955,11 @@ static int max98095_dai1_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: - snd_soc_update_bits(codec, M98095_02A_DAI1_FORMAT, + snd_soc_component_update_bits(component, M98095_02A_DAI1_FORMAT, M98095_DAI_WS, 0); break; case 24: - snd_soc_update_bits(codec, M98095_02A_DAI1_FORMAT, + snd_soc_component_update_bits(component, M98095_02A_DAI1_FORMAT, M98095_DAI_WS, M98095_DAI_WS); break; default: @@ -969,31 +969,31 @@ static int max98095_dai1_hw_params(struct snd_pcm_substream *substream, if (rate_value(rate, ®val)) return -EINVAL; - snd_soc_update_bits(codec, M98095_027_DAI1_CLKMODE, + snd_soc_component_update_bits(component, M98095_027_DAI1_CLKMODE, M98095_CLKMODE_MASK, regval); cdata->rate = rate; /* Configure NI when operating as master */ - if (snd_soc_read(codec, M98095_02A_DAI1_FORMAT) & M98095_DAI_MAS) { + if (snd_soc_component_read32(component, M98095_02A_DAI1_FORMAT) & M98095_DAI_MAS) { if (max98095->sysclk == 0) { - dev_err(codec->dev, "Invalid system clock frequency\n"); + dev_err(component->dev, "Invalid system clock frequency\n"); return -EINVAL; } ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) * (unsigned long long int)rate; do_div(ni, (unsigned long long int)max98095->sysclk); - snd_soc_write(codec, M98095_028_DAI1_CLKCFG_HI, + snd_soc_component_write(component, M98095_028_DAI1_CLKCFG_HI, (ni >> 8) & 0x7F); - snd_soc_write(codec, M98095_029_DAI1_CLKCFG_LO, + snd_soc_component_write(component, M98095_029_DAI1_CLKCFG_LO, ni & 0xFF); } /* Update sample rate mode */ if (rate < 50000) - snd_soc_update_bits(codec, M98095_02E_DAI1_FILTERS, + snd_soc_component_update_bits(component, M98095_02E_DAI1_FILTERS, M98095_DAI_DHF, 0); else - snd_soc_update_bits(codec, M98095_02E_DAI1_FILTERS, + snd_soc_component_update_bits(component, M98095_02E_DAI1_FILTERS, M98095_DAI_DHF, M98095_DAI_DHF); return 0; @@ -1003,8 +1003,8 @@ static int max98095_dai2_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; unsigned long long ni; unsigned int rate; @@ -1016,11 +1016,11 @@ static int max98095_dai2_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: - snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, + snd_soc_component_update_bits(component, M98095_034_DAI2_FORMAT, M98095_DAI_WS, 0); break; case 24: - snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, + snd_soc_component_update_bits(component, M98095_034_DAI2_FORMAT, M98095_DAI_WS, M98095_DAI_WS); break; default: @@ -1030,31 +1030,31 @@ static int max98095_dai2_hw_params(struct snd_pcm_substream *substream, if (rate_value(rate, ®val)) return -EINVAL; - snd_soc_update_bits(codec, M98095_031_DAI2_CLKMODE, + snd_soc_component_update_bits(component, M98095_031_DAI2_CLKMODE, M98095_CLKMODE_MASK, regval); cdata->rate = rate; /* Configure NI when operating as master */ - if (snd_soc_read(codec, M98095_034_DAI2_FORMAT) & M98095_DAI_MAS) { + if (snd_soc_component_read32(component, M98095_034_DAI2_FORMAT) & M98095_DAI_MAS) { if (max98095->sysclk == 0) { - dev_err(codec->dev, "Invalid system clock frequency\n"); + dev_err(component->dev, "Invalid system clock frequency\n"); return -EINVAL; } ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) * (unsigned long long int)rate; do_div(ni, (unsigned long long int)max98095->sysclk); - snd_soc_write(codec, M98095_032_DAI2_CLKCFG_HI, + snd_soc_component_write(component, M98095_032_DAI2_CLKCFG_HI, (ni >> 8) & 0x7F); - snd_soc_write(codec, M98095_033_DAI2_CLKCFG_LO, + snd_soc_component_write(component, M98095_033_DAI2_CLKCFG_LO, ni & 0xFF); } /* Update sample rate mode */ if (rate < 50000) - snd_soc_update_bits(codec, M98095_038_DAI2_FILTERS, + snd_soc_component_update_bits(component, M98095_038_DAI2_FILTERS, M98095_DAI_DHF, 0); else - snd_soc_update_bits(codec, M98095_038_DAI2_FILTERS, + snd_soc_component_update_bits(component, M98095_038_DAI2_FILTERS, M98095_DAI_DHF, M98095_DAI_DHF); return 0; @@ -1064,8 +1064,8 @@ static int max98095_dai3_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; unsigned long long ni; unsigned int rate; @@ -1077,11 +1077,11 @@ static int max98095_dai3_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: - snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, + snd_soc_component_update_bits(component, M98095_03E_DAI3_FORMAT, M98095_DAI_WS, 0); break; case 24: - snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, + snd_soc_component_update_bits(component, M98095_03E_DAI3_FORMAT, M98095_DAI_WS, M98095_DAI_WS); break; default: @@ -1091,31 +1091,31 @@ static int max98095_dai3_hw_params(struct snd_pcm_substream *substream, if (rate_value(rate, ®val)) return -EINVAL; - snd_soc_update_bits(codec, M98095_03B_DAI3_CLKMODE, + snd_soc_component_update_bits(component, M98095_03B_DAI3_CLKMODE, M98095_CLKMODE_MASK, regval); cdata->rate = rate; /* Configure NI when operating as master */ - if (snd_soc_read(codec, M98095_03E_DAI3_FORMAT) & M98095_DAI_MAS) { + if (snd_soc_component_read32(component, M98095_03E_DAI3_FORMAT) & M98095_DAI_MAS) { if (max98095->sysclk == 0) { - dev_err(codec->dev, "Invalid system clock frequency\n"); + dev_err(component->dev, "Invalid system clock frequency\n"); return -EINVAL; } ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) * (unsigned long long int)rate; do_div(ni, (unsigned long long int)max98095->sysclk); - snd_soc_write(codec, M98095_03C_DAI3_CLKCFG_HI, + snd_soc_component_write(component, M98095_03C_DAI3_CLKCFG_HI, (ni >> 8) & 0x7F); - snd_soc_write(codec, M98095_03D_DAI3_CLKCFG_LO, + snd_soc_component_write(component, M98095_03D_DAI3_CLKCFG_LO, ni & 0xFF); } /* Update sample rate mode */ if (rate < 50000) - snd_soc_update_bits(codec, M98095_042_DAI3_FILTERS, + snd_soc_component_update_bits(component, M98095_042_DAI3_FILTERS, M98095_DAI_DHF, 0); else - snd_soc_update_bits(codec, M98095_042_DAI3_FILTERS, + snd_soc_component_update_bits(component, M98095_042_DAI3_FILTERS, M98095_DAI_DHF, M98095_DAI_DHF); return 0; @@ -1124,8 +1124,8 @@ static int max98095_dai3_hw_params(struct snd_pcm_substream *substream, static int max98095_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); /* Requested clock frequency is already setup */ if (freq == max98095->sysclk) @@ -1142,13 +1142,13 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai, * 0x03 (when master clk is 40MHz to 60MHz).. */ if ((freq >= 10000000) && (freq < 20000000)) { - snd_soc_write(codec, M98095_026_SYS_CLK, 0x10); + snd_soc_component_write(component, M98095_026_SYS_CLK, 0x10); } else if ((freq >= 20000000) && (freq < 40000000)) { - snd_soc_write(codec, M98095_026_SYS_CLK, 0x20); + snd_soc_component_write(component, M98095_026_SYS_CLK, 0x20); } else if ((freq >= 40000000) && (freq < 60000000)) { - snd_soc_write(codec, M98095_026_SYS_CLK, 0x30); + snd_soc_component_write(component, M98095_026_SYS_CLK, 0x30); } else { - dev_err(codec->dev, "Invalid master clock frequency\n"); + dev_err(component->dev, "Invalid master clock frequency\n"); return -EINVAL; } @@ -1161,8 +1161,8 @@ static int max98095_dai_set_sysclk(struct snd_soc_dai *dai, static int max98095_dai1_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; u8 regval = 0; @@ -1174,9 +1174,9 @@ static int max98095_dai1_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave mode PLL */ - snd_soc_write(codec, M98095_028_DAI1_CLKCFG_HI, + snd_soc_component_write(component, M98095_028_DAI1_CLKCFG_HI, 0x80); - snd_soc_write(codec, M98095_029_DAI1_CLKCFG_LO, + snd_soc_component_write(component, M98095_029_DAI1_CLKCFG_LO, 0x00); break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1186,7 +1186,7 @@ static int max98095_dai1_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "Clock mode unsupported"); + dev_err(component->dev, "Clock mode unsupported"); return -EINVAL; } @@ -1216,11 +1216,11 @@ static int max98095_dai1_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_update_bits(codec, M98095_02A_DAI1_FORMAT, + snd_soc_component_update_bits(component, M98095_02A_DAI1_FORMAT, M98095_DAI_MAS | M98095_DAI_DLY | M98095_DAI_BCI | M98095_DAI_WCI, regval); - snd_soc_write(codec, M98095_02B_DAI1_CLOCK, M98095_DAI_BSEL64); + snd_soc_component_write(component, M98095_02B_DAI1_CLOCK, M98095_DAI_BSEL64); } return 0; @@ -1229,8 +1229,8 @@ static int max98095_dai1_set_fmt(struct snd_soc_dai *codec_dai, static int max98095_dai2_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; u8 regval = 0; @@ -1242,9 +1242,9 @@ static int max98095_dai2_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave mode PLL */ - snd_soc_write(codec, M98095_032_DAI2_CLKCFG_HI, + snd_soc_component_write(component, M98095_032_DAI2_CLKCFG_HI, 0x80); - snd_soc_write(codec, M98095_033_DAI2_CLKCFG_LO, + snd_soc_component_write(component, M98095_033_DAI2_CLKCFG_LO, 0x00); break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1254,7 +1254,7 @@ static int max98095_dai2_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "Clock mode unsupported"); + dev_err(component->dev, "Clock mode unsupported"); return -EINVAL; } @@ -1284,11 +1284,11 @@ static int max98095_dai2_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, + snd_soc_component_update_bits(component, M98095_034_DAI2_FORMAT, M98095_DAI_MAS | M98095_DAI_DLY | M98095_DAI_BCI | M98095_DAI_WCI, regval); - snd_soc_write(codec, M98095_035_DAI2_CLOCK, + snd_soc_component_write(component, M98095_035_DAI2_CLOCK, M98095_DAI_BSEL64); } @@ -1298,8 +1298,8 @@ static int max98095_dai2_set_fmt(struct snd_soc_dai *codec_dai, static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; u8 regval = 0; @@ -1311,9 +1311,9 @@ static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave mode PLL */ - snd_soc_write(codec, M98095_03C_DAI3_CLKCFG_HI, + snd_soc_component_write(component, M98095_03C_DAI3_CLKCFG_HI, 0x80); - snd_soc_write(codec, M98095_03D_DAI3_CLKCFG_LO, + snd_soc_component_write(component, M98095_03D_DAI3_CLKCFG_LO, 0x00); break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1323,7 +1323,7 @@ static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "Clock mode unsupported"); + dev_err(component->dev, "Clock mode unsupported"); return -EINVAL; } @@ -1353,21 +1353,21 @@ static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, + snd_soc_component_update_bits(component, M98095_03E_DAI3_FORMAT, M98095_DAI_MAS | M98095_DAI_DLY | M98095_DAI_BCI | M98095_DAI_WCI, regval); - snd_soc_write(codec, M98095_03F_DAI3_CLOCK, + snd_soc_component_write(component, M98095_03F_DAI3_CLOCK, M98095_DAI_BSEL64); } return 0; } -static int max98095_set_bias_level(struct snd_soc_codec *codec, +static int max98095_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1385,7 +1385,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, if (IS_ERR(max98095->mclk)) break; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(max98095->mclk); } else { ret = clk_prepare_enable(max98095->mclk); @@ -1395,21 +1395,21 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max98095->regmap); if (ret != 0) { - dev_err(codec->dev, "Failed to sync cache: %d\n", ret); + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } } - snd_soc_update_bits(codec, M98095_090_PWR_EN_IN, + snd_soc_component_update_bits(component, M98095_090_PWR_EN_IN, M98095_MBEN, M98095_MBEN); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, M98095_090_PWR_EN_IN, + snd_soc_component_update_bits(component, M98095_090_PWR_EN_IN, M98095_MBEN, 0); regcache_mark_dirty(max98095->regmap); break; @@ -1494,8 +1494,8 @@ static int max98095_get_eq_channel(const char *name) static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; int channel = max98095_get_eq_channel(kcontrol->id.name); struct max98095_cdata *cdata; @@ -1528,7 +1528,7 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, } } - dev_dbg(codec->dev, "Selected %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", pdata->eq_cfg[best].name, pdata->eq_cfg[best].rate, fs); @@ -1537,29 +1537,29 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol, regmask = (channel == 0) ? M98095_EQ1EN : M98095_EQ2EN; /* Disable filter while configuring, and save current on/off state */ - regsave = snd_soc_read(codec, M98095_088_CFG_LEVEL); - snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0); + regsave = snd_soc_component_read32(component, M98095_088_CFG_LEVEL); + snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, 0); mutex_lock(&max98095->lock); - snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG); - m98095_eq_band(codec, channel, 0, coef_set->band1); - m98095_eq_band(codec, channel, 1, coef_set->band2); - m98095_eq_band(codec, channel, 2, coef_set->band3); - m98095_eq_band(codec, channel, 3, coef_set->band4); - m98095_eq_band(codec, channel, 4, coef_set->band5); - snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0); + snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG); + m98095_eq_band(component, channel, 0, coef_set->band1); + m98095_eq_band(component, channel, 1, coef_set->band2); + m98095_eq_band(component, channel, 2, coef_set->band3); + m98095_eq_band(component, channel, 3, coef_set->band4); + m98095_eq_band(component, channel, 4, coef_set->band5); + snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, 0); mutex_unlock(&max98095->lock); /* Restore the original on/off state */ - snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, regsave); + snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, regsave); return 0; } static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); int channel = max98095_get_eq_channel(kcontrol->id.name); struct max98095_cdata *cdata; @@ -1569,9 +1569,9 @@ static int max98095_get_eq_enum(struct snd_kcontrol *kcontrol, return 0; } -static void max98095_handle_eq_pdata(struct snd_soc_codec *codec) +static void max98095_handle_eq_pdata(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; struct max98095_eq_cfg *cfg; unsigned int cfgcnt; @@ -1624,14 +1624,14 @@ static void max98095_handle_eq_pdata(struct snd_soc_codec *codec) max98095->eq_enum.texts = max98095->eq_texts; max98095->eq_enum.items = max98095->eq_textcnt; - ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); + ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls)); if (ret != 0) - dev_err(codec->dev, "Failed to add EQ control: %d\n", ret); + dev_err(component->dev, "Failed to add EQ control: %d\n", ret); } static const char *bq_mode_name[] = {"Biquad1 Mode", "Biquad2 Mode"}; -static int max98095_get_bq_channel(struct snd_soc_codec *codec, +static int max98095_get_bq_channel(struct snd_soc_component *component, const char *name) { int i; @@ -1641,17 +1641,17 @@ static int max98095_get_bq_channel(struct snd_soc_codec *codec, return i; /* Shouldn't happen */ - dev_err(codec->dev, "Bad biquad channel name '%s'\n", name); + dev_err(component->dev, "Bad biquad channel name '%s'\n", name); return -EINVAL; } static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; - int channel = max98095_get_bq_channel(codec, kcontrol->id.name); + int channel = max98095_get_bq_channel(component, kcontrol->id.name); struct max98095_cdata *cdata; unsigned int sel = ucontrol->value.enumerated.item[0]; struct max98095_biquad_cfg *coef_set; @@ -1682,7 +1682,7 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, } } - dev_dbg(codec->dev, "Selected %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", pdata->bq_cfg[best].name, pdata->bq_cfg[best].rate, fs); @@ -1691,27 +1691,27 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol, regmask = (channel == 0) ? M98095_BQ1EN : M98095_BQ2EN; /* Disable filter while configuring, and save current on/off state */ - regsave = snd_soc_read(codec, M98095_088_CFG_LEVEL); - snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, 0); + regsave = snd_soc_component_read32(component, M98095_088_CFG_LEVEL); + snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, 0); mutex_lock(&max98095->lock); - snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG); - m98095_biquad_band(codec, channel, 0, coef_set->band1); - m98095_biquad_band(codec, channel, 1, coef_set->band2); - snd_soc_update_bits(codec, M98095_00F_HOST_CFG, M98095_SEG, 0); + snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG); + m98095_biquad_band(component, channel, 0, coef_set->band1); + m98095_biquad_band(component, channel, 1, coef_set->band2); + snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, 0); mutex_unlock(&max98095->lock); /* Restore the original on/off state */ - snd_soc_update_bits(codec, M98095_088_CFG_LEVEL, regmask, regsave); + snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, regsave); return 0; } static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); - int channel = max98095_get_bq_channel(codec, kcontrol->id.name); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); + int channel = max98095_get_bq_channel(component, kcontrol->id.name); struct max98095_cdata *cdata; if (channel < 0) @@ -1723,9 +1723,9 @@ static int max98095_get_bq_enum(struct snd_kcontrol *kcontrol, return 0; } -static void max98095_handle_bq_pdata(struct snd_soc_codec *codec) +static void max98095_handle_bq_pdata(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; struct max98095_biquad_cfg *cfg; unsigned int cfgcnt; @@ -1779,19 +1779,19 @@ static void max98095_handle_bq_pdata(struct snd_soc_codec *codec) max98095->bq_enum.texts = max98095->bq_texts; max98095->bq_enum.items = max98095->bq_textcnt; - ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); + ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls)); if (ret != 0) - dev_err(codec->dev, "Failed to add Biquad control: %d\n", ret); + dev_err(component->dev, "Failed to add Biquad control: %d\n", ret); } -static void max98095_handle_pdata(struct snd_soc_codec *codec) +static void max98095_handle_pdata(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_pdata *pdata = max98095->pdata; u8 regval = 0; if (!pdata) { - dev_dbg(codec->dev, "No platform data\n"); + dev_dbg(component->dev, "No platform data\n"); return; } @@ -1802,27 +1802,27 @@ static void max98095_handle_pdata(struct snd_soc_codec *codec) if (pdata->digmic_right_mode) regval |= M98095_DIGMIC_R; - snd_soc_write(codec, M98095_087_CFG_MIC, regval); + snd_soc_component_write(component, M98095_087_CFG_MIC, regval); /* Configure equalizers */ if (pdata->eq_cfgcnt) - max98095_handle_eq_pdata(codec); + max98095_handle_eq_pdata(component); /* Configure bi-quad filters */ if (pdata->bq_cfgcnt) - max98095_handle_bq_pdata(codec); + max98095_handle_bq_pdata(component); } static irqreturn_t max98095_report_jack(int irq, void *data) { - struct snd_soc_codec *codec = data; - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = data; + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); unsigned int value; int hp_report = 0; int mic_report = 0; /* Read the Jack Status Register */ - value = snd_soc_read(codec, M98095_007_JACK_AUTO_STS); + value = snd_soc_component_read32(component, M98095_007_JACK_AUTO_STS); /* If ddone is not set, then detection isn't finished yet */ if ((value & M98095_DDONE) == 0) @@ -1853,9 +1853,9 @@ static irqreturn_t max98095_report_jack(int irq, void *data) return IRQ_HANDLED; } -static int max98095_jack_detect_enable(struct snd_soc_codec *codec) +static int max98095_jack_detect_enable(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); int ret = 0; int detect_enable = M98095_JDEN; unsigned int slew = M98095_DEFAULT_SLEW_DELAY; @@ -1866,41 +1866,41 @@ static int max98095_jack_detect_enable(struct snd_soc_codec *codec) if (max98095->pdata->jack_detect_delay) slew = max98095->pdata->jack_detect_delay; - ret = snd_soc_write(codec, M98095_08E_JACK_DC_SLEW, slew); + ret = snd_soc_component_write(component, M98095_08E_JACK_DC_SLEW, slew); if (ret < 0) { - dev_err(codec->dev, "Failed to cfg auto detect %d\n", ret); + dev_err(component->dev, "Failed to cfg auto detect %d\n", ret); return ret; } /* configure auto detection to be enabled */ - ret = snd_soc_write(codec, M98095_089_JACK_DET_AUTO, detect_enable); + ret = snd_soc_component_write(component, M98095_089_JACK_DET_AUTO, detect_enable); if (ret < 0) { - dev_err(codec->dev, "Failed to cfg auto detect %d\n", ret); + dev_err(component->dev, "Failed to cfg auto detect %d\n", ret); return ret; } return ret; } -static int max98095_jack_detect_disable(struct snd_soc_codec *codec) +static int max98095_jack_detect_disable(struct snd_soc_component *component) { int ret = 0; /* configure auto detection to be disabled */ - ret = snd_soc_write(codec, M98095_089_JACK_DET_AUTO, 0x0); + ret = snd_soc_component_write(component, M98095_089_JACK_DET_AUTO, 0x0); if (ret < 0) { - dev_err(codec->dev, "Failed to cfg auto detect %d\n", ret); + dev_err(component->dev, "Failed to cfg auto detect %d\n", ret); return ret; } return ret; } -int max98095_jack_detect(struct snd_soc_codec *codec, +int max98095_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *client = to_i2c_client(codec->dev); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); + struct i2c_client *client = to_i2c_client(component->dev); int ret = 0; max98095->headphone_jack = hp_jack; @@ -1910,44 +1910,44 @@ int max98095_jack_detect(struct snd_soc_codec *codec, if (!hp_jack && !mic_jack) return -EINVAL; - max98095_jack_detect_enable(codec); + max98095_jack_detect_enable(component); /* enable interrupts for headphone jack detection */ - ret = snd_soc_update_bits(codec, M98095_013_JACK_INT_EN, + ret = snd_soc_component_update_bits(component, M98095_013_JACK_INT_EN, M98095_IDDONE, M98095_IDDONE); if (ret < 0) { - dev_err(codec->dev, "Failed to cfg jack irqs %d\n", ret); + dev_err(component->dev, "Failed to cfg jack irqs %d\n", ret); return ret; } - max98095_report_jack(client->irq, codec); + max98095_report_jack(client->irq, component); return 0; } EXPORT_SYMBOL_GPL(max98095_jack_detect); #ifdef CONFIG_PM -static int max98095_suspend(struct snd_soc_codec *codec) +static int max98095_suspend(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); if (max98095->headphone_jack || max98095->mic_jack) - max98095_jack_detect_disable(codec); + max98095_jack_detect_disable(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); return 0; } -static int max98095_resume(struct snd_soc_codec *codec) +static int max98095_resume(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *client = to_i2c_client(codec->dev); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); + struct i2c_client *client = to_i2c_client(component->dev); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); if (max98095->headphone_jack || max98095->mic_jack) { - max98095_jack_detect_enable(codec); - max98095_report_jack(client->irq, codec); + max98095_jack_detect_enable(component); + max98095_report_jack(client->irq, component); } return 0; @@ -1957,30 +1957,30 @@ static int max98095_resume(struct snd_soc_codec *codec) #define max98095_resume NULL #endif -static int max98095_reset(struct snd_soc_codec *codec) +static int max98095_reset(struct snd_soc_component *component) { int i, ret; /* Gracefully reset the DSP core and the codec hardware * in a proper sequence */ - ret = snd_soc_write(codec, M98095_00F_HOST_CFG, 0); + ret = snd_soc_component_write(component, M98095_00F_HOST_CFG, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to reset DSP: %d\n", ret); + dev_err(component->dev, "Failed to reset DSP: %d\n", ret); return ret; } - ret = snd_soc_write(codec, M98095_097_PWR_SYS, 0); + ret = snd_soc_component_write(component, M98095_097_PWR_SYS, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to reset codec: %d\n", ret); + dev_err(component->dev, "Failed to reset component: %d\n", ret); return ret; } /* Reset to hardware default for registers, as there is not * a soft reset hardware control register */ for (i = M98095_010_HOST_INT_CFG; i < M98095_REG_MAX_CACHED; i++) { - ret = snd_soc_write(codec, i, snd_soc_read(codec, i)); + ret = snd_soc_component_write(component, i, snd_soc_component_read32(component, i)); if (ret < 0) { - dev_err(codec->dev, "Failed to reset: %d\n", ret); + dev_err(component->dev, "Failed to reset: %d\n", ret); return ret; } } @@ -1988,21 +1988,21 @@ static int max98095_reset(struct snd_soc_codec *codec) return ret; } -static int max98095_probe(struct snd_soc_codec *codec) +static int max98095_probe(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); struct max98095_cdata *cdata; struct i2c_client *client; int ret = 0; - max98095->mclk = devm_clk_get(codec->dev, "mclk"); + max98095->mclk = devm_clk_get(component->dev, "mclk"); if (PTR_ERR(max98095->mclk) == -EPROBE_DEFER) return -EPROBE_DEFER; /* reset the codec, the DSP core, and disable all interrupts */ - max98095_reset(codec); + max98095_reset(component); - client = to_i2c_client(codec->dev); + client = to_i2c_client(component->dev); /* initialize private data */ @@ -2037,85 +2037,85 @@ static int max98095_probe(struct snd_soc_codec *codec) ret = request_threaded_irq(client->irq, NULL, max98095_report_jack, IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | - IRQF_ONESHOT, "max98095", codec); + IRQF_ONESHOT, "max98095", component); if (ret) { - dev_err(codec->dev, "Failed to request IRQ: %d\n", ret); + dev_err(component->dev, "Failed to request IRQ: %d\n", ret); goto err_access; } } - ret = snd_soc_read(codec, M98095_0FF_REV_ID); + ret = snd_soc_component_read32(component, M98095_0FF_REV_ID); if (ret < 0) { - dev_err(codec->dev, "Failure reading hardware revision: %d\n", + dev_err(component->dev, "Failure reading hardware revision: %d\n", ret); goto err_irq; } - dev_info(codec->dev, "Hardware revision: %c\n", ret - 0x40 + 'A'); + dev_info(component->dev, "Hardware revision: %c\n", ret - 0x40 + 'A'); - snd_soc_write(codec, M98095_097_PWR_SYS, M98095_PWRSV); + snd_soc_component_write(component, M98095_097_PWR_SYS, M98095_PWRSV); - snd_soc_write(codec, M98095_048_MIX_DAC_LR, + snd_soc_component_write(component, M98095_048_MIX_DAC_LR, M98095_DAI1L_TO_DACL|M98095_DAI1R_TO_DACR); - snd_soc_write(codec, M98095_049_MIX_DAC_M, + snd_soc_component_write(component, M98095_049_MIX_DAC_M, M98095_DAI2M_TO_DACM|M98095_DAI3M_TO_DACM); - snd_soc_write(codec, M98095_092_PWR_EN_OUT, M98095_SPK_SPREADSPECTRUM); - snd_soc_write(codec, M98095_045_CFG_DSP, M98095_DSPNORMAL); - snd_soc_write(codec, M98095_04E_CFG_HP, M98095_HPNORMAL); + snd_soc_component_write(component, M98095_092_PWR_EN_OUT, M98095_SPK_SPREADSPECTRUM); + snd_soc_component_write(component, M98095_045_CFG_DSP, M98095_DSPNORMAL); + snd_soc_component_write(component, M98095_04E_CFG_HP, M98095_HPNORMAL); - snd_soc_write(codec, M98095_02C_DAI1_IOCFG, + snd_soc_component_write(component, M98095_02C_DAI1_IOCFG, M98095_S1NORMAL|M98095_SDATA); - snd_soc_write(codec, M98095_036_DAI2_IOCFG, + snd_soc_component_write(component, M98095_036_DAI2_IOCFG, M98095_S2NORMAL|M98095_SDATA); - snd_soc_write(codec, M98095_040_DAI3_IOCFG, + snd_soc_component_write(component, M98095_040_DAI3_IOCFG, M98095_S3NORMAL|M98095_SDATA); - max98095_handle_pdata(codec); + max98095_handle_pdata(component); /* take the codec out of the shut down */ - snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_SHDNRUN, + snd_soc_component_update_bits(component, M98095_097_PWR_SYS, M98095_SHDNRUN, M98095_SHDNRUN); return 0; err_irq: if (client->irq) - free_irq(client->irq, codec); + free_irq(client->irq, component); err_access: return ret; } -static int max98095_remove(struct snd_soc_codec *codec) +static void max98095_remove(struct snd_soc_component *component) { - struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *client = to_i2c_client(codec->dev); + struct max98095_priv *max98095 = snd_soc_component_get_drvdata(component); + struct i2c_client *client = to_i2c_client(component->dev); if (max98095->headphone_jack || max98095->mic_jack) - max98095_jack_detect_disable(codec); + max98095_jack_detect_disable(component); if (client->irq) - free_irq(client->irq, codec); - - return 0; + free_irq(client->irq, component); } -static const struct snd_soc_codec_driver soc_codec_dev_max98095 = { - .probe = max98095_probe, - .remove = max98095_remove, - .suspend = max98095_suspend, - .resume = max98095_resume, - .set_bias_level = max98095_set_bias_level, - .component_driver = { - .controls = max98095_snd_controls, - .num_controls = ARRAY_SIZE(max98095_snd_controls), - .dapm_widgets = max98095_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98095_dapm_widgets), - .dapm_routes = max98095_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98095_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_max98095 = { + .probe = max98095_probe, + .remove = max98095_remove, + .suspend = max98095_suspend, + .resume = max98095_resume, + .set_bias_level = max98095_set_bias_level, + .controls = max98095_snd_controls, + .num_controls = ARRAY_SIZE(max98095_snd_controls), + .dapm_widgets = max98095_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98095_dapm_widgets), + .dapm_routes = max98095_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98095_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int max98095_i2c_probe(struct i2c_client *i2c, @@ -2142,17 +2142,12 @@ static int max98095_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, max98095); max98095->pdata = i2c->dev.platform_data; - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98095, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98095, max98095_dai, ARRAY_SIZE(max98095_dai)); return ret; } -static int max98095_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98095_i2c_id[] = { { "max98095", MAX98095 }, { } @@ -2171,7 +2166,6 @@ static struct i2c_driver max98095_i2c_driver = { .of_match_table = of_match_ptr(max98095_of_match), }, .probe = max98095_i2c_probe, - .remove = max98095_i2c_remove, .id_table = max98095_i2c_id, }; diff --git a/sound/soc/codecs/max98095.h b/sound/soc/codecs/max98095.h index 2ebbe4e894bf..67886cacddb2 100644 --- a/sound/soc/codecs/max98095.h +++ b/sound/soc/codecs/max98095.h @@ -315,7 +315,7 @@ /* Default Delay used in Slew Rate Calculation for Jack detection */ #define M98095_DEFAULT_SLEW_DELAY 0x18 -extern int max98095_jack_detect(struct snd_soc_codec *codec, +extern int max98095_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack); #endif From 4c66b9d165e0994b9be1ff3233037e614fae22af Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:05:59 +0000 Subject: [PATCH 100/942] ASoC: max98090: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98090.c | 319 ++++++++++---------- sound/soc/codecs/max98090.h | 4 +- sound/soc/mediatek/mt8173/mt8173-max98090.c | 4 +- 3 files changed, 164 insertions(+), 163 deletions(-) diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f5075d1f79e6..c97f21836c66 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c @@ -284,7 +284,7 @@ static int max98090_reset(struct max98090_priv *max98090) ret = regmap_write(max98090->regmap, M98090_REG_SOFTWARE_RESET, M98090_SWRESET_MASK); if (ret < 0) { - dev_err(max98090->codec->dev, + dev_err(max98090->component->dev, "Failed to reset codec: %d\n", ret); return ret; } @@ -354,12 +354,12 @@ static const DECLARE_TLV_DB_RANGE(max98090_rcv_lout_tlv, static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int mask = (1 << fls(mc->max)) - 1; - unsigned int val = snd_soc_read(codec, mc->reg); + unsigned int val = snd_soc_component_read32(component, mc->reg); unsigned int *select; switch (mc->reg) { @@ -394,13 +394,13 @@ static int max98090_get_enab_tlv(struct snd_kcontrol *kcontrol, static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int mask = (1 << fls(mc->max)) - 1; unsigned int sel = ucontrol->value.integer.value[0]; - unsigned int val = snd_soc_read(codec, mc->reg); + unsigned int val = snd_soc_component_read32(component, mc->reg); unsigned int *select; switch (mc->reg) { @@ -429,7 +429,7 @@ static int max98090_put_enab_tlv(struct snd_kcontrol *kcontrol, sel = val; } - snd_soc_update_bits(codec, mc->reg, + snd_soc_component_update_bits(component, mc->reg, mask << mc->shift, sel << mc->shift); @@ -733,10 +733,10 @@ static const struct snd_kcontrol_new max98091_snd_controls[] = { static int max98090_micinput_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); - unsigned int val = snd_soc_read(codec, w->reg); + unsigned int val = snd_soc_component_read32(component, w->reg); if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) val = (val & M98090_MIC_PA1EN_MASK) >> M98090_MIC_PA1EN_SHIFT; @@ -768,10 +768,10 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w, } if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) - snd_soc_update_bits(codec, w->reg, M98090_MIC_PA1EN_MASK, + snd_soc_component_update_bits(component, w->reg, M98090_MIC_PA1EN_MASK, val << M98090_MIC_PA1EN_SHIFT); else - snd_soc_update_bits(codec, w->reg, M98090_MIC_PA2EN_MASK, + snd_soc_component_update_bits(component, w->reg, M98090_MIC_PA2EN_MASK, val << M98090_MIC_PA2EN_SHIFT); return 0; @@ -780,8 +780,8 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w, static int max98090_shdn_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); if (event & SND_SOC_DAPM_POST_PMU) max98090->shdn_pending = true; @@ -1441,16 +1441,16 @@ static const struct snd_soc_dapm_route max98091_dapm_routes[] = { {"DMIC4", NULL, "AHPF"}, }; -static int max98090_add_widgets(struct snd_soc_codec *codec) +static int max98090_add_widgets(struct snd_soc_component *component) { - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - snd_soc_add_codec_controls(codec, max98090_snd_controls, + snd_soc_add_component_controls(component, max98090_snd_controls, ARRAY_SIZE(max98090_snd_controls)); if (max98090->devtype == MAX98091) { - snd_soc_add_codec_controls(codec, max98091_snd_controls, + snd_soc_add_component_controls(component, max98091_snd_controls, ARRAY_SIZE(max98091_snd_controls)); } @@ -1497,24 +1497,24 @@ static const unsigned long long mi_value[] = { 8125, 1625, 1500, 25 }; -static void max98090_configure_bclk(struct snd_soc_codec *codec) +static void max98090_configure_bclk(struct snd_soc_component *component) { - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); unsigned long long ni; int i; if (!max98090->sysclk) { - dev_err(codec->dev, "No SYSCLK configured\n"); + dev_err(component->dev, "No SYSCLK configured\n"); return; } if (!max98090->bclk || !max98090->lrclk) { - dev_err(codec->dev, "No audio clocks configured\n"); + dev_err(component->dev, "No audio clocks configured\n"); return; } /* Skip configuration when operating as slave */ - if (!(snd_soc_read(codec, M98090_REG_MASTER_MODE) & + if (!(snd_soc_component_read32(component, M98090_REG_MASTER_MODE) & M98090_MAS_MASK)) { return; } @@ -1523,14 +1523,14 @@ static void max98090_configure_bclk(struct snd_soc_codec *codec) for (i = 0; i < ARRAY_SIZE(pclk_rates); i++) { if ((pclk_rates[i] == max98090->sysclk) && (lrclk_rates[i] == max98090->lrclk)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Found supported PCLK to LRCLK rates 0x%x\n", i + 0x8); - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_FREQ_MASK, (i + 0x8) << M98090_FREQ_SHIFT); - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_USE_M1_MASK, 0); return; } @@ -1540,24 +1540,24 @@ static void max98090_configure_bclk(struct snd_soc_codec *codec) for (i = 0; i < ARRAY_SIZE(user_pclk_rates); i++) { if ((user_pclk_rates[i] == max98090->sysclk) && (user_lrclk_rates[i] == max98090->lrclk)) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Found user supported PCLK to LRCLK rates\n"); - dev_dbg(codec->dev, "i %d ni %lld mi %lld\n", + dev_dbg(component->dev, "i %d ni %lld mi %lld\n", i, ni_value[i], mi_value[i]); - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_FREQ_MASK, 0); - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_USE_M1_MASK, 1 << M98090_USE_M1_SHIFT); - snd_soc_write(codec, M98090_REG_CLOCK_RATIO_NI_MSB, + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_MSB, (ni_value[i] >> 8) & 0x7F); - snd_soc_write(codec, M98090_REG_CLOCK_RATIO_NI_LSB, + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_LSB, ni_value[i] & 0xFF); - snd_soc_write(codec, M98090_REG_CLOCK_RATIO_MI_MSB, + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_MI_MSB, (mi_value[i] >> 8) & 0x7F); - snd_soc_write(codec, M98090_REG_CLOCK_RATIO_MI_LSB, + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_MI_LSB, mi_value[i] & 0xFF); return; @@ -1567,9 +1567,9 @@ static void max98090_configure_bclk(struct snd_soc_codec *codec) /* * Calculate based on MI = 65536 (not as good as either method above) */ - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_FREQ_MASK, 0); - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_USE_M1_MASK, 0); /* @@ -1580,18 +1580,18 @@ static void max98090_configure_bclk(struct snd_soc_codec *codec) ni = 65536ULL * (max98090->lrclk < 50000 ? 96ULL : 48ULL) * (unsigned long long int)max98090->lrclk; do_div(ni, (unsigned long long int)max98090->sysclk); - dev_info(codec->dev, "No better method found\n"); - dev_info(codec->dev, "Calculating ni %lld with mi 65536\n", ni); - snd_soc_write(codec, M98090_REG_CLOCK_RATIO_NI_MSB, + dev_info(component->dev, "No better method found\n"); + dev_info(component->dev, "Calculating ni %lld with mi 65536\n", ni); + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_MSB, (ni >> 8) & 0x7F); - snd_soc_write(codec, M98090_REG_CLOCK_RATIO_NI_LSB, ni & 0xFF); + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_LSB, ni & 0xFF); } static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct max98090_cdata *cdata; u8 regval; @@ -1605,11 +1605,11 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Set to slave mode PLL - MAS mode off */ - snd_soc_write(codec, + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_MSB, 0x00); - snd_soc_write(codec, + snd_soc_component_write(component, M98090_REG_CLOCK_RATIO_NI_LSB, 0x00); - snd_soc_update_bits(codec, M98090_REG_CLOCK_MODE, + snd_soc_component_update_bits(component, M98090_REG_CLOCK_MODE, M98090_USE_M1_MASK, 0); max98090->master = false; break; @@ -1633,10 +1633,10 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "DAI clock mode unsupported"); + dev_err(component->dev, "DAI clock mode unsupported"); return -EINVAL; } - snd_soc_write(codec, M98090_REG_MASTER_MODE, regval); + snd_soc_component_write(component, M98090_REG_MASTER_MODE, regval); regval = 0; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -1651,7 +1651,7 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_DSP_A: /* Not supported mode */ default: - dev_err(codec->dev, "DAI format unsupported"); + dev_err(component->dev, "DAI format unsupported"); return -EINVAL; } @@ -1668,7 +1668,7 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, regval |= M98090_BCI_MASK|M98090_WCI_MASK; break; default: - dev_err(codec->dev, "DAI invert mode unsupported"); + dev_err(component->dev, "DAI invert mode unsupported"); return -EINVAL; } @@ -1681,7 +1681,7 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, if (max98090->tdm_slots > 1) regval ^= M98090_BCI_MASK; - snd_soc_write(codec, + snd_soc_component_write(component, M98090_REG_INTERFACE_FORMAT, regval); } @@ -1691,8 +1691,8 @@ static int max98090_dai_set_fmt(struct snd_soc_dai *codec_dai, static int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct max98090_cdata *cdata; cdata = &max98090->dai[0]; @@ -1704,13 +1704,13 @@ static int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai, if (max98090->tdm_slots > 1) { /* SLOTL SLOTR SLOTDLY */ - snd_soc_write(codec, M98090_REG_TDM_FORMAT, + snd_soc_component_write(component, M98090_REG_TDM_FORMAT, 0 << M98090_TDM_SLOTL_SHIFT | 1 << M98090_TDM_SLOTR_SHIFT | 0 << M98090_TDM_SLOTDLY_SHIFT); /* FSW TDM */ - snd_soc_update_bits(codec, M98090_REG_TDM_CONTROL, + snd_soc_component_update_bits(component, M98090_REG_TDM_CONTROL, M98090_TDM_MASK, M98090_TDM_MASK); } @@ -1724,10 +1724,10 @@ static int max98090_set_tdm_slot(struct snd_soc_dai *codec_dai, return 0; } -static int max98090_set_bias_level(struct snd_soc_codec *codec, +static int max98090_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1745,7 +1745,7 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec, if (IS_ERR(max98090->mclk)) break; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_ON) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_ON) { clk_disable_unprepare(max98090->mclk); } else { ret = clk_prepare_enable(max98090->mclk); @@ -1755,10 +1755,10 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regcache_sync(max98090->regmap); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to sync cache: %d\n", ret); return ret; } @@ -1767,7 +1767,7 @@ static int max98090_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_OFF: /* Set internal pull-up to lowest power mode */ - snd_soc_update_bits(codec, M98090_REG_JACK_DETECT, + snd_soc_component_update_bits(component, M98090_REG_JACK_DETECT, M98090_JDWK_MASK, M98090_JDWK_MASK); regcache_mark_dirty(max98090->regmap); break; @@ -1928,8 +1928,8 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct max98090_cdata *cdata; cdata = &max98090->dai[0]; @@ -1941,7 +1941,7 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: - snd_soc_update_bits(codec, M98090_REG_INTERFACE_FORMAT, + snd_soc_component_update_bits(component, M98090_REG_INTERFACE_FORMAT, M98090_WS_MASK, 0); break; default: @@ -1949,24 +1949,24 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, } if (max98090->master) - max98090_configure_bclk(codec); + max98090_configure_bclk(component); cdata->rate = max98090->lrclk; /* Update filter mode */ if (max98090->lrclk < 24000) - snd_soc_update_bits(codec, M98090_REG_FILTER_CONFIG, + snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG, M98090_MODE_MASK, 0); else - snd_soc_update_bits(codec, M98090_REG_FILTER_CONFIG, + snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG, M98090_MODE_MASK, M98090_MODE_MASK); /* Update sample rate mode */ if (max98090->lrclk < 50000) - snd_soc_update_bits(codec, M98090_REG_FILTER_CONFIG, + snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG, M98090_DHF_MASK, 0); else - snd_soc_update_bits(codec, M98090_REG_FILTER_CONFIG, + snd_soc_component_update_bits(component, M98090_REG_FILTER_CONFIG, M98090_DHF_MASK, M98090_DHF_MASK); max98090_configure_dmic(max98090, max98090->dmic_freq, max98090->pclk, @@ -1981,8 +1981,8 @@ static int max98090_dai_hw_params(struct snd_pcm_substream *substream, static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); /* Requested clock frequency is already setup */ if (freq == max98090->sysclk) @@ -1999,19 +1999,19 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, * 0x03 (when master clk is 40MHz to 60MHz).. */ if ((freq >= 10000000) && (freq <= 20000000)) { - snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK, + snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK, M98090_PSCLK_DIV1); max98090->pclk = freq; } else if ((freq > 20000000) && (freq <= 40000000)) { - snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK, + snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK, M98090_PSCLK_DIV2); max98090->pclk = freq >> 1; } else if ((freq > 40000000) && (freq <= 60000000)) { - snd_soc_write(codec, M98090_REG_SYSTEM_CLOCK, + snd_soc_component_write(component, M98090_REG_SYSTEM_CLOCK, M98090_PSCLK_DIV4); max98090->pclk = freq >> 2; } else { - dev_err(codec->dev, "Invalid master clock frequency\n"); + dev_err(component->dev, "Invalid master clock frequency\n"); return -EINVAL; } @@ -2022,11 +2022,11 @@ static int max98090_dai_set_sysclk(struct snd_soc_dai *dai, static int max98090_dai_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int regval; regval = mute ? M98090_DVM_MASK : 0; - snd_soc_update_bits(codec, M98090_REG_DAI_PLAYBACK_LEVEL, + snd_soc_component_update_bits(component, M98090_REG_DAI_PLAYBACK_LEVEL, M98090_DVM_MASK, regval); return 0; @@ -2035,8 +2035,8 @@ static int max98090_dai_digital_mute(struct snd_soc_dai *codec_dai, int mute) static int max98090_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -2065,7 +2065,7 @@ static void max98090_pll_det_enable_work(struct work_struct *work) struct max98090_priv *max98090 = container_of(work, struct max98090_priv, pll_det_enable_work.work); - struct snd_soc_codec *codec = max98090->codec; + struct snd_soc_component *component = max98090->component; unsigned int status, mask; /* @@ -2088,7 +2088,7 @@ static void max98090_pll_det_enable_work(struct work_struct *work) msecs_to_jiffies(100)); /* Enable PLL unlock interrupt */ - snd_soc_update_bits(codec, M98090_REG_INTERRUPT_S, + snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S, M98090_IULK_MASK, 1 << M98090_IULK_SHIFT); } @@ -2097,12 +2097,12 @@ static void max98090_pll_det_disable_work(struct work_struct *work) { struct max98090_priv *max98090 = container_of(work, struct max98090_priv, pll_det_disable_work); - struct snd_soc_codec *codec = max98090->codec; + struct snd_soc_component *component = max98090->component; cancel_delayed_work_sync(&max98090->pll_det_enable_work); /* Disable PLL unlock interrupt */ - snd_soc_update_bits(codec, M98090_REG_INTERRUPT_S, + snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S, M98090_IULK_MASK, 0); } @@ -2110,18 +2110,18 @@ static void max98090_pll_work(struct work_struct *work) { struct max98090_priv *max98090 = container_of(work, struct max98090_priv, pll_work); - struct snd_soc_codec *codec = max98090->codec; + struct snd_soc_component *component = max98090->component; - if (!snd_soc_codec_is_active(codec)) + if (!snd_soc_component_is_active(component)) return; - dev_info_ratelimited(codec->dev, "PLL unlocked\n"); + dev_info_ratelimited(component->dev, "PLL unlocked\n"); /* Toggle shutdown OFF then ON */ - snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN, + snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, 0); msleep(10); - snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN, + snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, M98090_SHDNN_MASK); /* Give PLL time to lock */ @@ -2133,7 +2133,7 @@ static void max98090_jack_work(struct work_struct *work) struct max98090_priv *max98090 = container_of(work, struct max98090_priv, jack_work.work); - struct snd_soc_codec *codec = max98090->codec; + struct snd_soc_component *component = max98090->component; int status = 0; int reg; @@ -2141,25 +2141,25 @@ static void max98090_jack_work(struct work_struct *work) if (max98090->jack_state == M98090_JACK_STATE_NO_HEADSET) { /* Strong pull up allows mic detection */ - snd_soc_update_bits(codec, M98090_REG_JACK_DETECT, + snd_soc_component_update_bits(component, M98090_REG_JACK_DETECT, M98090_JDWK_MASK, 0); msleep(50); - reg = snd_soc_read(codec, M98090_REG_JACK_STATUS); + reg = snd_soc_component_read32(component, M98090_REG_JACK_STATUS); /* Weak pull up allows only insertion detection */ - snd_soc_update_bits(codec, M98090_REG_JACK_DETECT, + snd_soc_component_update_bits(component, M98090_REG_JACK_DETECT, M98090_JDWK_MASK, M98090_JDWK_MASK); } else { - reg = snd_soc_read(codec, M98090_REG_JACK_STATUS); + reg = snd_soc_component_read32(component, M98090_REG_JACK_STATUS); } - reg = snd_soc_read(codec, M98090_REG_JACK_STATUS); + reg = snd_soc_component_read32(component, M98090_REG_JACK_STATUS); switch (reg & (M98090_LSNS_MASK | M98090_JKSNS_MASK)) { case M98090_LSNS_MASK | M98090_JKSNS_MASK: - dev_dbg(codec->dev, "No Headset Detected\n"); + dev_dbg(component->dev, "No Headset Detected\n"); max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; @@ -2171,7 +2171,7 @@ static void max98090_jack_work(struct work_struct *work) if (max98090->jack_state == M98090_JACK_STATE_HEADSET) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Headset Button Down Detected\n"); /* @@ -2188,7 +2188,7 @@ static void max98090_jack_work(struct work_struct *work) /* Line is reported as Headphone */ /* Nokia Headset is reported as Headphone */ /* Mono Headphone is reported as Headphone */ - dev_dbg(codec->dev, "Headphone Detected\n"); + dev_dbg(component->dev, "Headphone Detected\n"); max98090->jack_state = M98090_JACK_STATE_HEADPHONE; @@ -2197,7 +2197,7 @@ static void max98090_jack_work(struct work_struct *work) break; case M98090_JKSNS_MASK: - dev_dbg(codec->dev, "Headset Detected\n"); + dev_dbg(component->dev, "Headset Detected\n"); max98090->jack_state = M98090_JACK_STATE_HEADSET; @@ -2206,7 +2206,7 @@ static void max98090_jack_work(struct work_struct *work) break; default: - dev_dbg(codec->dev, "Unrecognized Jack Status\n"); + dev_dbg(component->dev, "Unrecognized Jack Status\n"); break; } @@ -2217,21 +2217,21 @@ static void max98090_jack_work(struct work_struct *work) static irqreturn_t max98090_interrupt(int irq, void *data) { struct max98090_priv *max98090 = data; - struct snd_soc_codec *codec = max98090->codec; + struct snd_soc_component *component = max98090->component; int ret; unsigned int mask; unsigned int active; /* Treat interrupt before codec is initialized as spurious */ - if (codec == NULL) + if (component == NULL) return IRQ_NONE; - dev_dbg(codec->dev, "***** max98090_interrupt *****\n"); + dev_dbg(component->dev, "***** max98090_interrupt *****\n"); ret = regmap_read(max98090->regmap, M98090_REG_INTERRUPT_S, &mask); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "failed to read M98090_REG_INTERRUPT_S: %d\n", ret); return IRQ_NONE; @@ -2240,13 +2240,13 @@ static irqreturn_t max98090_interrupt(int irq, void *data) ret = regmap_read(max98090->regmap, M98090_REG_DEVICE_STATUS, &active); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "failed to read M98090_REG_DEVICE_STATUS: %d\n", ret); return IRQ_NONE; } - dev_dbg(codec->dev, "active=0x%02x mask=0x%02x -> active=0x%02x\n", + dev_dbg(component->dev, "active=0x%02x mask=0x%02x -> active=0x%02x\n", active, mask, active & mask); active &= mask; @@ -2255,20 +2255,20 @@ static irqreturn_t max98090_interrupt(int irq, void *data) return IRQ_NONE; if (active & M98090_CLD_MASK) - dev_err(codec->dev, "M98090_CLD_MASK\n"); + dev_err(component->dev, "M98090_CLD_MASK\n"); if (active & M98090_SLD_MASK) - dev_dbg(codec->dev, "M98090_SLD_MASK\n"); + dev_dbg(component->dev, "M98090_SLD_MASK\n"); if (active & M98090_ULK_MASK) { - dev_dbg(codec->dev, "M98090_ULK_MASK\n"); + dev_dbg(component->dev, "M98090_ULK_MASK\n"); schedule_work(&max98090->pll_work); } if (active & M98090_JDET_MASK) { - dev_dbg(codec->dev, "M98090_JDET_MASK\n"); + dev_dbg(component->dev, "M98090_JDET_MASK\n"); - pm_wakeup_event(codec->dev, 100); + pm_wakeup_event(component->dev, 100); queue_delayed_work(system_power_efficient_wq, &max98090->jack_work, @@ -2276,10 +2276,10 @@ static irqreturn_t max98090_interrupt(int irq, void *data) } if (active & M98090_DRCACT_MASK) - dev_dbg(codec->dev, "M98090_DRCACT_MASK\n"); + dev_dbg(component->dev, "M98090_DRCACT_MASK\n"); if (active & M98090_DRCCLP_MASK) - dev_err(codec->dev, "M98090_DRCCLP_MASK\n"); + dev_err(component->dev, "M98090_DRCCLP_MASK\n"); return IRQ_HANDLED; } @@ -2287,7 +2287,7 @@ static irqreturn_t max98090_interrupt(int irq, void *data) /** * max98090_mic_detect - Enable microphone detection via the MAX98090 IRQ * - * @codec: MAX98090 codec + * @component: MAX98090 component * @jack: jack to report detection events on * * Enable microphone detection via IRQ on the MAX98090. If GPIOs are @@ -2297,20 +2297,20 @@ static irqreturn_t max98090_interrupt(int irq, void *data) * * If no jack is supplied detection will be disabled. */ -int max98090_mic_detect(struct snd_soc_codec *codec, +int max98090_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "max98090_mic_detect\n"); + dev_dbg(component->dev, "max98090_mic_detect\n"); max98090->jack = jack; if (jack) { - snd_soc_update_bits(codec, M98090_REG_INTERRUPT_S, + snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S, M98090_IJDET_MASK, 1 << M98090_IJDET_SHIFT); } else { - snd_soc_update_bits(codec, M98090_REG_INTERRUPT_S, + snd_soc_component_update_bits(component, M98090_REG_INTERRUPT_S, M98090_IJDET_MASK, 0); } @@ -2360,22 +2360,22 @@ static struct snd_soc_dai_driver max98090_dai[] = { } }; -static int max98090_probe(struct snd_soc_codec *codec) +static int max98090_probe(struct snd_soc_component *component) { - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); struct max98090_cdata *cdata; enum max98090_type devtype; int ret = 0; int err; unsigned int micbias; - dev_dbg(codec->dev, "max98090_probe\n"); + dev_dbg(component->dev, "max98090_probe\n"); - max98090->mclk = devm_clk_get(codec->dev, "mclk"); + max98090->mclk = devm_clk_get(component->dev, "mclk"); if (PTR_ERR(max98090->mclk) == -EPROBE_DEFER) return -EPROBE_DEFER; - max98090->codec = codec; + max98090->component = component; /* Reset the codec, the DSP core, and disable all interrupts */ max98090_reset(max98090); @@ -2394,26 +2394,26 @@ static int max98090_probe(struct snd_soc_codec *codec) max98090->pa1en = 0; max98090->pa2en = 0; - ret = snd_soc_read(codec, M98090_REG_REVISION_ID); + ret = snd_soc_component_read32(component, M98090_REG_REVISION_ID); if (ret < 0) { - dev_err(codec->dev, "Failed to read device revision: %d\n", + dev_err(component->dev, "Failed to read device revision: %d\n", ret); goto err_access; } if ((ret >= M98090_REVA) && (ret <= M98090_REVA + 0x0f)) { devtype = MAX98090; - dev_info(codec->dev, "MAX98090 REVID=0x%02x\n", ret); + dev_info(component->dev, "MAX98090 REVID=0x%02x\n", ret); } else if ((ret >= M98091_REVA) && (ret <= M98091_REVA + 0x0f)) { devtype = MAX98091; - dev_info(codec->dev, "MAX98091 REVID=0x%02x\n", ret); + dev_info(component->dev, "MAX98091 REVID=0x%02x\n", ret); } else { devtype = MAX98090; - dev_err(codec->dev, "Unrecognized revision 0x%02x\n", ret); + dev_err(component->dev, "Unrecognized revision 0x%02x\n", ret); } if (max98090->devtype != devtype) { - dev_warn(codec->dev, "Mismatch in DT specified CODEC type.\n"); + dev_warn(component->dev, "Mismatch in DT specified CODEC type.\n"); max98090->devtype = devtype; } @@ -2427,7 +2427,7 @@ static int max98090_probe(struct snd_soc_codec *codec) INIT_WORK(&max98090->pll_work, max98090_pll_work); /* Enable jack detection */ - snd_soc_write(codec, M98090_REG_JACK_DETECT, + snd_soc_component_write(component, M98090_REG_JACK_DETECT, M98090_JDETEN_MASK | M98090_JDEB_25MS); /* @@ -2435,75 +2435,76 @@ static int max98090_probe(struct snd_soc_codec *codec) * An old interrupt ocurring prior to installing the ISR * can keep a new interrupt from generating a trigger. */ - snd_soc_read(codec, M98090_REG_DEVICE_STATUS); + snd_soc_component_read32(component, M98090_REG_DEVICE_STATUS); /* High Performance is default */ - snd_soc_update_bits(codec, M98090_REG_DAC_CONTROL, + snd_soc_component_update_bits(component, M98090_REG_DAC_CONTROL, M98090_DACHP_MASK, 1 << M98090_DACHP_SHIFT); - snd_soc_update_bits(codec, M98090_REG_DAC_CONTROL, + snd_soc_component_update_bits(component, M98090_REG_DAC_CONTROL, M98090_PERFMODE_MASK, 0 << M98090_PERFMODE_SHIFT); - snd_soc_update_bits(codec, M98090_REG_ADC_CONTROL, + snd_soc_component_update_bits(component, M98090_REG_ADC_CONTROL, M98090_ADCHP_MASK, 1 << M98090_ADCHP_SHIFT); /* Turn on VCM bandgap reference */ - snd_soc_write(codec, M98090_REG_BIAS_CONTROL, + snd_soc_component_write(component, M98090_REG_BIAS_CONTROL, M98090_VCM_MODE_MASK); - err = device_property_read_u32(codec->dev, "maxim,micbias", &micbias); + err = device_property_read_u32(component->dev, "maxim,micbias", &micbias); if (err) { micbias = M98090_MBVSEL_2V8; - dev_info(codec->dev, "use default 2.8v micbias\n"); + dev_info(component->dev, "use default 2.8v micbias\n"); } else if (micbias > M98090_MBVSEL_2V8) { - dev_err(codec->dev, "micbias out of range 0x%x\n", micbias); + dev_err(component->dev, "micbias out of range 0x%x\n", micbias); micbias = M98090_MBVSEL_2V8; } - snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE, + snd_soc_component_update_bits(component, M98090_REG_MIC_BIAS_VOLTAGE, M98090_MBVSEL_MASK, micbias); - max98090_add_widgets(codec); + max98090_add_widgets(component); err_access: return ret; } -static int max98090_remove(struct snd_soc_codec *codec) +static void max98090_remove(struct snd_soc_component *component) { - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&max98090->jack_work); cancel_delayed_work_sync(&max98090->pll_det_enable_work); cancel_work_sync(&max98090->pll_det_disable_work); cancel_work_sync(&max98090->pll_work); - max98090->codec = NULL; - - return 0; + max98090->component = NULL; } -static void max98090_seq_notifier(struct snd_soc_dapm_context *dapm, +static void max98090_seq_notifier(struct snd_soc_component *component, enum snd_soc_dapm_type event, int subseq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); + struct max98090_priv *max98090 = snd_soc_component_get_drvdata(component); if (max98090->shdn_pending) { - snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN, + snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, 0); msleep(40); - snd_soc_update_bits(codec, M98090_REG_DEVICE_SHUTDOWN, + snd_soc_component_update_bits(component, M98090_REG_DEVICE_SHUTDOWN, M98090_SHDNN_MASK, M98090_SHDNN_MASK); max98090->shdn_pending = false; } } -static const struct snd_soc_codec_driver soc_codec_dev_max98090 = { - .probe = max98090_probe, - .remove = max98090_remove, - .seq_notifier = max98090_seq_notifier, - .set_bias_level = max98090_set_bias_level, +static const struct snd_soc_component_driver soc_component_dev_max98090 = { + .probe = max98090_probe, + .remove = max98090_remove, + .seq_notifier = max98090_seq_notifier, + .set_bias_level = max98090_set_bias_level, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98090_regmap = { @@ -2570,8 +2571,8 @@ static int max98090_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_max98090, max98090_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98090, max98090_dai, ARRAY_SIZE(max98090_dai)); err_enable: return ret; @@ -2595,7 +2596,7 @@ static void max98090_i2c_shutdown(struct i2c_client *i2c) static int max98090_i2c_remove(struct i2c_client *client) { max98090_i2c_shutdown(client); - snd_soc_unregister_codec(&client->dev); + return 0; } diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h index bc610d9a9ecb..b1572a2d19da 100644 --- a/sound/soc/codecs/max98090.h +++ b/sound/soc/codecs/max98090.h @@ -1519,7 +1519,7 @@ struct max98090_cdata { struct max98090_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; enum max98090_type devtype; struct max98090_pdata *pdata; struct clk *mclk; @@ -1546,7 +1546,7 @@ struct max98090_priv { bool shdn_pending; }; -int max98090_mic_detect(struct snd_soc_codec *codec, +int max98090_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif diff --git a/sound/soc/mediatek/mt8173/mt8173-max98090.c b/sound/soc/mediatek/mt8173/mt8173-max98090.c index e0c2b23ec711..b49b527a7cf9 100644 --- a/sound/soc/mediatek/mt8173/mt8173-max98090.c +++ b/sound/soc/mediatek/mt8173/mt8173-max98090.c @@ -75,7 +75,7 @@ static int mt8173_max98090_init(struct snd_soc_pcm_runtime *runtime) { int ret; struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; /* enable jack detection */ ret = snd_soc_card_jack_new(card, "Headphone", SND_JACK_HEADPHONE, @@ -87,7 +87,7 @@ static int mt8173_max98090_init(struct snd_soc_pcm_runtime *runtime) return ret; } - return max98090_mic_detect(codec, &mt8173_max98090_jack); + return max98090_mic_detect(component, &mt8173_max98090_jack); } /* Digital audio interface glue - connects codec <---> CPU */ From 6f2b5d0db19a0e428dd7fc3abf326ebbc0726693 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:06:51 +0000 Subject: [PATCH 101/942] ASoC: max98926: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98926.c | 56 +++++++++++++++++-------------------- sound/soc/codecs/max98926.h | 2 +- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/sound/soc/codecs/max98926.c b/sound/soc/codecs/max98926.c index 7b1d1b0fa879..d9b1f68f243d 100644 --- a/sound/soc/codecs/max98926.c +++ b/sound/soc/codecs/max98926.c @@ -336,18 +336,18 @@ static void max98926_set_sense_data(struct max98926_priv *max98926) static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component); unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: max98926_set_sense_data(max98926); break; default: - dev_err(codec->dev, "DAI clock mode unsupported\n"); + dev_err(component->dev, "DAI clock mode unsupported\n"); return -EINVAL; } @@ -364,7 +364,7 @@ static int max98926_dai_set_fmt(struct snd_soc_dai *codec_dai, invert = MAX98926_DAI_BCI_MASK | MAX98926_DAI_WCI_MASK; break; default: - dev_err(codec->dev, "DAI invert mode unsupported\n"); + dev_err(component->dev, "DAI invert mode unsupported\n"); return -EINVAL; } @@ -381,8 +381,8 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, { int dai_sr = -EINVAL; int rate = params_rate(params), i; - struct snd_soc_codec *codec = dai->codec; - struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component); int blr_clk_ratio; switch (params_format(params)) { @@ -408,7 +408,7 @@ static int max98926_dai_hw_params(struct snd_pcm_substream *substream, max98926->ch_size = 32; break; default: - dev_dbg(codec->dev, "format unsupported %d\n", + dev_dbg(component->dev, "format unsupported %d\n", params_format(params)); return -EINVAL; } @@ -485,27 +485,29 @@ static struct snd_soc_dai_driver max98926_dai[] = { } }; -static int max98926_probe(struct snd_soc_codec *codec) +static int max98926_probe(struct snd_soc_component *component) { - struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec); + struct max98926_priv *max98926 = snd_soc_component_get_drvdata(component); - max98926->codec = codec; + max98926->component = component; /* Hi-Z all the slots */ regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG4, 0xF0); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max98926 = { - .probe = max98926_probe, - .component_driver = { - .controls = max98926_snd_controls, - .num_controls = ARRAY_SIZE(max98926_snd_controls), - .dapm_routes = max98926_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98926_audio_map), - .dapm_widgets = max98926_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98926_dapm_widgets), - }, +static const struct snd_soc_component_driver soc_component_dev_max98926 = { + .probe = max98926_probe, + .controls = max98926_snd_controls, + .num_controls = ARRAY_SIZE(max98926_snd_controls), + .dapm_routes = max98926_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98926_audio_map), + .dapm_widgets = max98926_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98926_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98926_regmap = { @@ -563,22 +565,17 @@ static int max98926_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98926, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98926, max98926_dai, ARRAY_SIZE(max98926_dai)); if (ret < 0) dev_err(&i2c->dev, - "Failed to register codec: %d\n", ret); + "Failed to register component: %d\n", ret); dev_info(&i2c->dev, "device version: %x\n", reg); err_out: return ret; } -static int max98926_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98926_i2c_id[] = { { "max98926", 0 }, { } @@ -598,7 +595,6 @@ static struct i2c_driver max98926_i2c_driver = { .pm = NULL, }, .probe = max98926_i2c_probe, - .remove = max98926_i2c_remove, .id_table = max98926_i2c_id, }; diff --git a/sound/soc/codecs/max98926.h b/sound/soc/codecs/max98926.h index 9d7ab6df79ca..ccf2c3f66c07 100644 --- a/sound/soc/codecs/max98926.h +++ b/sound/soc/codecs/max98926.h @@ -838,7 +838,7 @@ struct max98926_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int sysclk; unsigned int v_slot; unsigned int i_slot; From 3f64507697e32c2f491224f9f0656be5ae5d6d15 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:07:45 +0000 Subject: [PATCH 102/942] ASoC: max98088: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98088.c | 314 ++++++++++++++++++------------------ 1 file changed, 153 insertions(+), 161 deletions(-) diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index f0bb830874e5..865f64c40b79 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c @@ -307,7 +307,7 @@ static const struct regmap_config max98088_regmap = { /* * Load equalizer DSP coefficient configurations registers */ -static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai, +static void m98088_eq_band(struct snd_soc_component *component, unsigned int dai, unsigned int band, u16 *coefs) { unsigned int eq_reg; @@ -325,8 +325,8 @@ static void m98088_eq_band(struct snd_soc_codec *codec, unsigned int dai, /* Step through the registers and coefs */ for (i = 0; i < M98088_COEFS_PER_BAND; i++) { - snd_soc_write(codec, eq_reg++, M98088_BYTE1(coefs[i])); - snd_soc_write(codec, eq_reg++, M98088_BYTE0(coefs[i])); + snd_soc_component_write(component, eq_reg++, M98088_BYTE1(coefs[i])); + snd_soc_component_write(component, eq_reg++, M98088_BYTE0(coefs[i])); } } @@ -380,12 +380,12 @@ static SOC_ENUM_SINGLE_DECL(max98088_dai1_adc_filter_enum, static int max98088_mic1pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; max98088->mic1pre = sel; - snd_soc_update_bits(codec, M98088_REG_35_LVL_MIC1, M98088_MICPRE_MASK, + snd_soc_component_update_bits(component, M98088_REG_35_LVL_MIC1, M98088_MICPRE_MASK, (1+sel)<value.integer.value[0] = max98088->mic1pre; return 0; @@ -404,12 +404,12 @@ static int max98088_mic1pre_get(struct snd_kcontrol *kcontrol, static int max98088_mic2pre_set(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); unsigned int sel = ucontrol->value.integer.value[0]; max98088->mic2pre = sel; - snd_soc_update_bits(codec, M98088_REG_36_LVL_MIC2, M98088_MICPRE_MASK, + snd_soc_component_update_bits(component, M98088_REG_36_LVL_MIC2, M98088_MICPRE_MASK, (1+sel)<value.integer.value[0] = max98088->mic2pre; return 0; @@ -617,21 +617,21 @@ static const struct snd_kcontrol_new max98088_right_ADC_mixer_controls[] = { static int max98088_mic_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: if (w->reg == M98088_REG_35_LVL_MIC1) { - snd_soc_update_bits(codec, w->reg, M98088_MICPRE_MASK, + snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, (1+max98088->mic1pre)<reg, M98088_MICPRE_MASK, + snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, (1+max98088->mic2pre)<reg, M98088_MICPRE_MASK, 0); + snd_soc_component_update_bits(component, w->reg, M98088_MICPRE_MASK, 0); break; default: return -EINVAL; @@ -647,8 +647,8 @@ static int max98088_mic_event(struct snd_soc_dapm_widget *w, static int max98088_line_pga(struct snd_soc_dapm_widget *w, int event, int line, u8 channel) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); u8 *state; if (WARN_ON(!(channel == 1 || channel == 2))) @@ -668,13 +668,13 @@ static int max98088_line_pga(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: *state |= channel; - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << w->shift), (1 << w->shift)); break; case SND_SOC_DAPM_POST_PMD: *state &= ~channel; if (*state == 0) { - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, (1 << w->shift), 0); } break; @@ -963,8 +963,8 @@ static int max98088_dai1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_cdata *cdata; unsigned long long ni; unsigned int rate; @@ -976,51 +976,51 @@ static int max98088_dai1_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: - snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT, + snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT, M98088_DAI_WS, 0); break; case 24: - snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT, + snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT, M98088_DAI_WS, M98088_DAI_WS); break; default: return -EINVAL; } - snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); if (rate_value(rate, ®val)) return -EINVAL; - snd_soc_update_bits(codec, M98088_REG_11_DAI1_CLKMODE, + snd_soc_component_update_bits(component, M98088_REG_11_DAI1_CLKMODE, M98088_CLKMODE_MASK, regval); cdata->rate = rate; /* Configure NI when operating as master */ - if (snd_soc_read(codec, M98088_REG_14_DAI1_FORMAT) + if (snd_soc_component_read32(component, M98088_REG_14_DAI1_FORMAT) & M98088_DAI_MAS) { if (max98088->sysclk == 0) { - dev_err(codec->dev, "Invalid system clock frequency\n"); + dev_err(component->dev, "Invalid system clock frequency\n"); return -EINVAL; } ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) * (unsigned long long int)rate; do_div(ni, (unsigned long long int)max98088->sysclk); - snd_soc_write(codec, M98088_REG_12_DAI1_CLKCFG_HI, + snd_soc_component_write(component, M98088_REG_12_DAI1_CLKCFG_HI, (ni >> 8) & 0x7F); - snd_soc_write(codec, M98088_REG_13_DAI1_CLKCFG_LO, + snd_soc_component_write(component, M98088_REG_13_DAI1_CLKCFG_LO, ni & 0xFF); } /* Update sample rate mode */ if (rate < 50000) - snd_soc_update_bits(codec, M98088_REG_18_DAI1_FILTERS, + snd_soc_component_update_bits(component, M98088_REG_18_DAI1_FILTERS, M98088_DAI_DHF, 0); else - snd_soc_update_bits(codec, M98088_REG_18_DAI1_FILTERS, + snd_soc_component_update_bits(component, M98088_REG_18_DAI1_FILTERS, M98088_DAI_DHF, M98088_DAI_DHF); - snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, M98088_SHDNRUN); return 0; @@ -1030,8 +1030,8 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_cdata *cdata; unsigned long long ni; unsigned int rate; @@ -1043,51 +1043,51 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 16: - snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, + snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT, M98088_DAI_WS, 0); break; case 24: - snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, + snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT, M98088_DAI_WS, M98088_DAI_WS); break; default: return -EINVAL; } - snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); if (rate_value(rate, ®val)) return -EINVAL; - snd_soc_update_bits(codec, M98088_REG_19_DAI2_CLKMODE, + snd_soc_component_update_bits(component, M98088_REG_19_DAI2_CLKMODE, M98088_CLKMODE_MASK, regval); cdata->rate = rate; /* Configure NI when operating as master */ - if (snd_soc_read(codec, M98088_REG_1C_DAI2_FORMAT) + if (snd_soc_component_read32(component, M98088_REG_1C_DAI2_FORMAT) & M98088_DAI_MAS) { if (max98088->sysclk == 0) { - dev_err(codec->dev, "Invalid system clock frequency\n"); + dev_err(component->dev, "Invalid system clock frequency\n"); return -EINVAL; } ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) * (unsigned long long int)rate; do_div(ni, (unsigned long long int)max98088->sysclk); - snd_soc_write(codec, M98088_REG_1A_DAI2_CLKCFG_HI, + snd_soc_component_write(component, M98088_REG_1A_DAI2_CLKCFG_HI, (ni >> 8) & 0x7F); - snd_soc_write(codec, M98088_REG_1B_DAI2_CLKCFG_LO, + snd_soc_component_write(component, M98088_REG_1B_DAI2_CLKCFG_LO, ni & 0xFF); } /* Update sample rate mode */ if (rate < 50000) - snd_soc_update_bits(codec, M98088_REG_20_DAI2_FILTERS, + snd_soc_component_update_bits(component, M98088_REG_20_DAI2_FILTERS, M98088_DAI_DHF, 0); else - snd_soc_update_bits(codec, M98088_REG_20_DAI2_FILTERS, + snd_soc_component_update_bits(component, M98088_REG_20_DAI2_FILTERS, M98088_DAI_DHF, M98088_DAI_DHF); - snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, M98088_SHDNRUN); return 0; @@ -1096,8 +1096,8 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, static int max98088_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); /* Requested clock frequency is already setup */ if (freq == max98088->sysclk) @@ -1108,18 +1108,18 @@ static int max98088_dai_set_sysclk(struct snd_soc_dai *dai, * 0x02 (when master clk is 20MHz to 30MHz).. */ if ((freq >= 10000000) && (freq < 20000000)) { - snd_soc_write(codec, M98088_REG_10_SYS_CLK, 0x10); + snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x10); } else if ((freq >= 20000000) && (freq < 30000000)) { - snd_soc_write(codec, M98088_REG_10_SYS_CLK, 0x20); + snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x20); } else { - dev_err(codec->dev, "Invalid master clock frequency\n"); + dev_err(component->dev, "Invalid master clock frequency\n"); return -EINVAL; } - if (snd_soc_read(codec, M98088_REG_51_PWR_SYS) & M98088_SHDNRUN) { - snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, + if (snd_soc_component_read32(component, M98088_REG_51_PWR_SYS) & M98088_SHDNRUN) { + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, 0); - snd_soc_update_bits(codec, M98088_REG_51_PWR_SYS, + snd_soc_component_update_bits(component, M98088_REG_51_PWR_SYS, M98088_SHDNRUN, M98088_SHDNRUN); } @@ -1132,8 +1132,8 @@ static int max98088_dai_set_sysclk(struct snd_soc_dai *dai, static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_cdata *cdata; u8 reg15val; u8 reg14val = 0; @@ -1146,9 +1146,9 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave mode PLL */ - snd_soc_write(codec, M98088_REG_12_DAI1_CLKCFG_HI, + snd_soc_component_write(component, M98088_REG_12_DAI1_CLKCFG_HI, 0x80); - snd_soc_write(codec, M98088_REG_13_DAI1_CLKCFG_LO, + snd_soc_component_write(component, M98088_REG_13_DAI1_CLKCFG_LO, 0x00); break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1158,7 +1158,7 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "Clock mode unsupported"); + dev_err(component->dev, "Clock mode unsupported"); return -EINVAL; } @@ -1188,14 +1188,14 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_update_bits(codec, M98088_REG_14_DAI1_FORMAT, + snd_soc_component_update_bits(component, M98088_REG_14_DAI1_FORMAT, M98088_DAI_MAS | M98088_DAI_DLY | M98088_DAI_BCI | M98088_DAI_WCI, reg14val); reg15val = M98088_DAI_BSEL64; if (max98088->digmic) reg15val |= M98088_DAI_OSR64; - snd_soc_write(codec, M98088_REG_15_DAI1_CLOCK, reg15val); + snd_soc_component_write(component, M98088_REG_15_DAI1_CLOCK, reg15val); } return 0; @@ -1204,8 +1204,8 @@ static int max98088_dai1_set_fmt(struct snd_soc_dai *codec_dai, static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_cdata *cdata; u8 reg1Cval = 0; @@ -1217,9 +1217,9 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai, switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave mode PLL */ - snd_soc_write(codec, M98088_REG_1A_DAI2_CLKCFG_HI, + snd_soc_component_write(component, M98088_REG_1A_DAI2_CLKCFG_HI, 0x80); - snd_soc_write(codec, M98088_REG_1B_DAI2_CLKCFG_LO, + snd_soc_component_write(component, M98088_REG_1B_DAI2_CLKCFG_LO, 0x00); break; case SND_SOC_DAIFMT_CBM_CFM: @@ -1229,7 +1229,7 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "Clock mode unsupported"); + dev_err(component->dev, "Clock mode unsupported"); return -EINVAL; } @@ -1259,11 +1259,11 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, + snd_soc_component_update_bits(component, M98088_REG_1C_DAI2_FORMAT, M98088_DAI_MAS | M98088_DAI_DLY | M98088_DAI_BCI | M98088_DAI_WCI, reg1Cval); - snd_soc_write(codec, M98088_REG_1D_DAI2_CLOCK, + snd_soc_component_write(component, M98088_REG_1D_DAI2_CLOCK, M98088_DAI_BSEL64); } @@ -1272,7 +1272,7 @@ static int max98088_dai2_set_fmt(struct snd_soc_dai *codec_dai, static int max98088_dai1_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int reg; if (mute) @@ -1280,14 +1280,14 @@ static int max98088_dai1_digital_mute(struct snd_soc_dai *codec_dai, int mute) else reg = 0; - snd_soc_update_bits(codec, M98088_REG_2F_LVL_DAI1_PLAY, + snd_soc_component_update_bits(component, M98088_REG_2F_LVL_DAI1_PLAY, M98088_DAI_MUTE_MASK, reg); return 0; } static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int reg; if (mute) @@ -1295,15 +1295,15 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute) else reg = 0; - snd_soc_update_bits(codec, M98088_REG_31_LVL_DAI2_PLAY, + snd_soc_component_update_bits(component, M98088_REG_31_LVL_DAI2_PLAY, M98088_DAI_MUTE_MASK, reg); return 0; } -static int max98088_set_bias_level(struct snd_soc_codec *codec, +static int max98088_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1313,15 +1313,15 @@ static int max98088_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) regcache_sync(max98088->regmap); - snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, + snd_soc_component_update_bits(component, M98088_REG_4C_PWR_EN_IN, M98088_MBEN, M98088_MBEN); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, + snd_soc_component_update_bits(component, M98088_REG_4C_PWR_EN_IN, M98088_MBEN, 0); regcache_mark_dirty(max98088->regmap); break; @@ -1380,7 +1380,7 @@ static struct snd_soc_dai_driver max98088_dai[] = { static const char *eq_mode_name[] = {"EQ1 Mode", "EQ2 Mode"}; -static int max98088_get_channel(struct snd_soc_codec *codec, const char *name) +static int max98088_get_channel(struct snd_soc_component *component, const char *name) { int i; @@ -1389,13 +1389,13 @@ static int max98088_get_channel(struct snd_soc_codec *codec, const char *name) return i; /* Shouldn't happen */ - dev_err(codec->dev, "Bad EQ channel name '%s'\n", name); + dev_err(component->dev, "Bad EQ channel name '%s'\n", name); return -EINVAL; } -static void max98088_setup_eq1(struct snd_soc_codec *codec) +static void max98088_setup_eq1(struct snd_soc_component *component) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_pdata *pdata = max98088->pdata; struct max98088_eq_cfg *coef_set; int best, best_val, save, i, sel, fs; @@ -1420,29 +1420,29 @@ static void max98088_setup_eq1(struct snd_soc_codec *codec) } } - dev_dbg(codec->dev, "Selected %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", pdata->eq_cfg[best].name, pdata->eq_cfg[best].rate, fs); /* Disable EQ while configuring, and save current on/off state */ - save = snd_soc_read(codec, M98088_REG_49_CFG_LEVEL); - snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, 0); + save = snd_soc_component_read32(component, M98088_REG_49_CFG_LEVEL); + snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, 0); coef_set = &pdata->eq_cfg[sel]; - m98088_eq_band(codec, 0, 0, coef_set->band1); - m98088_eq_band(codec, 0, 1, coef_set->band2); - m98088_eq_band(codec, 0, 2, coef_set->band3); - m98088_eq_band(codec, 0, 3, coef_set->band4); - m98088_eq_band(codec, 0, 4, coef_set->band5); + m98088_eq_band(component, 0, 0, coef_set->band1); + m98088_eq_band(component, 0, 1, coef_set->band2); + m98088_eq_band(component, 0, 2, coef_set->band3); + m98088_eq_band(component, 0, 3, coef_set->band4); + m98088_eq_band(component, 0, 4, coef_set->band5); /* Restore the original on/off state */ - snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, save); + snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ1EN, save); } -static void max98088_setup_eq2(struct snd_soc_codec *codec) +static void max98088_setup_eq2(struct snd_soc_component *component) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_pdata *pdata = max98088->pdata; struct max98088_eq_cfg *coef_set; int best, best_val, save, i, sel, fs; @@ -1467,34 +1467,34 @@ static void max98088_setup_eq2(struct snd_soc_codec *codec) } } - dev_dbg(codec->dev, "Selected %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "Selected %s/%dHz for %dHz sample rate\n", pdata->eq_cfg[best].name, pdata->eq_cfg[best].rate, fs); /* Disable EQ while configuring, and save current on/off state */ - save = snd_soc_read(codec, M98088_REG_49_CFG_LEVEL); - snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN, 0); + save = snd_soc_component_read32(component, M98088_REG_49_CFG_LEVEL); + snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN, 0); coef_set = &pdata->eq_cfg[sel]; - m98088_eq_band(codec, 1, 0, coef_set->band1); - m98088_eq_band(codec, 1, 1, coef_set->band2); - m98088_eq_band(codec, 1, 2, coef_set->band3); - m98088_eq_band(codec, 1, 3, coef_set->band4); - m98088_eq_band(codec, 1, 4, coef_set->band5); + m98088_eq_band(component, 1, 0, coef_set->band1); + m98088_eq_band(component, 1, 1, coef_set->band2); + m98088_eq_band(component, 1, 2, coef_set->band3); + m98088_eq_band(component, 1, 3, coef_set->band4); + m98088_eq_band(component, 1, 4, coef_set->band5); /* Restore the original on/off state */ - snd_soc_update_bits(codec, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN, + snd_soc_component_update_bits(component, M98088_REG_49_CFG_LEVEL, M98088_EQ2EN, save); } static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_pdata *pdata = max98088->pdata; - int channel = max98088_get_channel(codec, kcontrol->id.name); + int channel = max98088_get_channel(component, kcontrol->id.name); struct max98088_cdata *cdata; int sel = ucontrol->value.enumerated.item[0]; @@ -1510,10 +1510,10 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, switch (channel) { case 0: - max98088_setup_eq1(codec); + max98088_setup_eq1(component); break; case 1: - max98088_setup_eq2(codec); + max98088_setup_eq2(component); break; } @@ -1523,9 +1523,9 @@ static int max98088_put_eq_enum(struct snd_kcontrol *kcontrol, static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); - int channel = max98088_get_channel(codec, kcontrol->id.name); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); + int channel = max98088_get_channel(component, kcontrol->id.name); struct max98088_cdata *cdata; if (channel < 0) @@ -1536,9 +1536,9 @@ static int max98088_get_eq_enum(struct snd_kcontrol *kcontrol, return 0; } -static void max98088_handle_eq_pdata(struct snd_soc_codec *codec) +static void max98088_handle_eq_pdata(struct snd_soc_component *component) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_pdata *pdata = max98088->pdata; struct max98088_eq_cfg *cfg; unsigned int cfgcnt; @@ -1591,19 +1591,19 @@ static void max98088_handle_eq_pdata(struct snd_soc_codec *codec) max98088->eq_enum.texts = max98088->eq_texts; max98088->eq_enum.items = max98088->eq_textcnt; - ret = snd_soc_add_codec_controls(codec, controls, ARRAY_SIZE(controls)); + ret = snd_soc_add_component_controls(component, controls, ARRAY_SIZE(controls)); if (ret != 0) - dev_err(codec->dev, "Failed to add EQ control: %d\n", ret); + dev_err(component->dev, "Failed to add EQ control: %d\n", ret); } -static void max98088_handle_pdata(struct snd_soc_codec *codec) +static void max98088_handle_pdata(struct snd_soc_component *component) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_pdata *pdata = max98088->pdata; u8 regval = 0; if (!pdata) { - dev_dbg(codec->dev, "No platform data\n"); + dev_dbg(component->dev, "No platform data\n"); return; } @@ -1616,21 +1616,21 @@ static void max98088_handle_pdata(struct snd_soc_codec *codec) max98088->digmic = (regval ? 1 : 0); - snd_soc_write(codec, M98088_REG_48_CFG_MIC, regval); + snd_soc_component_write(component, M98088_REG_48_CFG_MIC, regval); /* Configure receiver output */ regval = ((pdata->receiver_mode) ? M98088_REC_LINEMODE : 0); - snd_soc_update_bits(codec, M98088_REG_2A_MIC_REC_CNTL, + snd_soc_component_update_bits(component, M98088_REG_2A_MIC_REC_CNTL, M98088_REC_LINEMODE_MASK, regval); /* Configure equalizers */ if (pdata->eq_cfgcnt) - max98088_handle_eq_pdata(codec); + max98088_handle_eq_pdata(component); } -static int max98088_probe(struct snd_soc_codec *codec) +static int max98088_probe(struct snd_soc_component *component) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); struct max98088_cdata *cdata; int ret = 0; @@ -1658,60 +1658,59 @@ static int max98088_probe(struct snd_soc_codec *codec) max98088->mic1pre = 0; max98088->mic2pre = 0; - ret = snd_soc_read(codec, M98088_REG_FF_REV_ID); + ret = snd_soc_component_read32(component, M98088_REG_FF_REV_ID); if (ret < 0) { - dev_err(codec->dev, "Failed to read device revision: %d\n", + dev_err(component->dev, "Failed to read device revision: %d\n", ret); goto err_access; } - dev_info(codec->dev, "revision %c\n", ret - 0x40 + 'A'); + dev_info(component->dev, "revision %c\n", ret - 0x40 + 'A'); - snd_soc_write(codec, M98088_REG_51_PWR_SYS, M98088_PWRSV); + snd_soc_component_write(component, M98088_REG_51_PWR_SYS, M98088_PWRSV); - snd_soc_write(codec, M98088_REG_0F_IRQ_ENABLE, 0x00); + snd_soc_component_write(component, M98088_REG_0F_IRQ_ENABLE, 0x00); - snd_soc_write(codec, M98088_REG_22_MIX_DAC, + snd_soc_component_write(component, M98088_REG_22_MIX_DAC, M98088_DAI1L_TO_DACL|M98088_DAI2L_TO_DACL| M98088_DAI1R_TO_DACR|M98088_DAI2R_TO_DACR); - snd_soc_write(codec, M98088_REG_4E_BIAS_CNTL, 0xF0); - snd_soc_write(codec, M98088_REG_50_DAC_BIAS2, 0x0F); + snd_soc_component_write(component, M98088_REG_4E_BIAS_CNTL, 0xF0); + snd_soc_component_write(component, M98088_REG_50_DAC_BIAS2, 0x0F); - snd_soc_write(codec, M98088_REG_16_DAI1_IOCFG, + snd_soc_component_write(component, M98088_REG_16_DAI1_IOCFG, M98088_S1NORMAL|M98088_SDATA); - snd_soc_write(codec, M98088_REG_1E_DAI2_IOCFG, + snd_soc_component_write(component, M98088_REG_1E_DAI2_IOCFG, M98088_S2NORMAL|M98088_SDATA); - max98088_handle_pdata(codec); + max98088_handle_pdata(component); err_access: return ret; } -static int max98088_remove(struct snd_soc_codec *codec) +static void max98088_remove(struct snd_soc_component *component) { - struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); + struct max98088_priv *max98088 = snd_soc_component_get_drvdata(component); kfree(max98088->eq_texts); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max98088 = { - .probe = max98088_probe, - .remove = max98088_remove, - .set_bias_level = max98088_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = max98088_snd_controls, - .num_controls = ARRAY_SIZE(max98088_snd_controls), - .dapm_widgets = max98088_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets), - .dapm_routes = max98088_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98088_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_max98088 = { + .probe = max98088_probe, + .remove = max98088_remove, + .set_bias_level = max98088_set_bias_level, + .controls = max98088_snd_controls, + .num_controls = ARRAY_SIZE(max98088_snd_controls), + .dapm_widgets = max98088_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets), + .dapm_routes = max98088_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98088_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int max98088_i2c_probe(struct i2c_client *i2c, @@ -1734,17 +1733,11 @@ static int max98088_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, max98088); max98088->pdata = i2c->dev.platform_data; - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_max98088, &max98088_dai[0], 2); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98088, &max98088_dai[0], 2); return ret; } -static int max98088_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98088_i2c_id[] = { { "max98088", MAX98088 }, { "max98089", MAX98089 }, @@ -1757,7 +1750,6 @@ static struct i2c_driver max98088_i2c_driver = { .name = "max98088", }, .probe = max98088_i2c_probe, - .remove = max98088_i2c_remove, .id_table = max98088_i2c_id, }; From cf9cb34eeba71acc80f9019aac46b2ffd13081b3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:08:29 +0000 Subject: [PATCH 103/942] ASoC: max98925: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98925.c | 72 ++++++++++++++++++------------------- sound/soc/codecs/max98925.h | 2 +- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/sound/soc/codecs/max98925.c b/sound/soc/codecs/max98925.c index 921f95fc396d..29877730a2b0 100644 --- a/sound/soc/codecs/max98925.c +++ b/sound/soc/codecs/max98925.c @@ -99,8 +99,8 @@ static const struct snd_kcontrol_new max98925_dai_sel_mux = static int max98925_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -256,7 +256,7 @@ static const struct { }, }; -static inline int max98925_rate_value(struct snd_soc_codec *codec, +static inline int max98925_rate_value(struct snd_soc_component *component, int rate, int clock, int *value, int *n, int *m) { int ret = -EINVAL; @@ -297,11 +297,11 @@ static void max98925_set_sense_data(struct max98925_priv *max98925) static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* set DAI to slave mode */ @@ -322,7 +322,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "DAI clock mode unsupported"); + dev_err(component->dev, "DAI clock mode unsupported"); return -EINVAL; } @@ -339,7 +339,7 @@ static int max98925_dai_set_fmt(struct snd_soc_dai *codec_dai, invert = M98925_DAI_BCI_MASK | M98925_DAI_WCI_MASK; break; default: - dev_err(codec->dev, "DAI invert mode unsupported"); + dev_err(component->dev, "DAI invert mode unsupported"); return -EINVAL; } @@ -352,7 +352,7 @@ static int max98925_set_clock(struct max98925_priv *max98925, struct snd_pcm_hw_params *params) { unsigned int dai_sr = 0, clock, mdll, n, m; - struct snd_soc_codec *codec = max98925->codec; + struct snd_soc_component *component = max98925->component; int rate = params_rate(params); /* BCLK/LRCLK ratio calculation */ int blr_clk_ratio = params_channels(params) * max98925->ch_size; @@ -395,12 +395,12 @@ static int max98925_set_clock(struct max98925_priv *max98925, mdll = M98925_MDLL_MULT_MCLKx8; break; default: - dev_info(max98925->codec->dev, "unsupported sysclk %d\n", + dev_info(max98925->component->dev, "unsupported sysclk %d\n", max98925->sysclk); return -EINVAL; } - if (max98925_rate_value(codec, rate, clock, &dai_sr, &n, &m)) + if (max98925_rate_value(component, rate, clock, &dai_sr, &n, &m)) return -EINVAL; /* set DAI_SR to correct LRCLK frequency */ @@ -427,8 +427,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (params_width(params)) { case 16: @@ -454,7 +454,7 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, __func__, params_format(params)); return -EINVAL; } - dev_dbg(codec->dev, "%s: format supported %d", + dev_dbg(component->dev, "%s: format supported %d", __func__, params_format(params)); return max98925_set_clock(max98925, params); } @@ -462,8 +462,8 @@ static int max98925_dai_hw_params(struct snd_pcm_substream *substream, static int max98925_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); switch (clk_id) { case 0: @@ -516,11 +516,11 @@ static struct snd_soc_dai_driver max98925_dai[] = { } }; -static int max98925_probe(struct snd_soc_codec *codec) +static int max98925_probe(struct snd_soc_component *component) { - struct max98925_priv *max98925 = snd_soc_codec_get_drvdata(codec); + struct max98925_priv *max98925 = snd_soc_component_get_drvdata(component); - max98925->codec = codec; + max98925->component = component; regmap_write(max98925->regmap, MAX98925_GLOBAL_ENABLE, 0x00); /* It's not the default but we need to set DAI_DLY */ regmap_write(max98925->regmap, @@ -538,16 +538,18 @@ static int max98925_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_max98925 = { - .probe = max98925_probe, - .component_driver = { - .controls = max98925_snd_controls, - .num_controls = ARRAY_SIZE(max98925_snd_controls), - .dapm_routes = max98925_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98925_audio_map), - .dapm_widgets = max98925_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98925_dapm_widgets), - }, +static const struct snd_soc_component_driver soc_component_dev_max98925 = { + .probe = max98925_probe, + .controls = max98925_snd_controls, + .num_controls = ARRAY_SIZE(max98925_snd_controls), + .dapm_routes = max98925_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98925_audio_map), + .dapm_widgets = max98925_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98925_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98925_regmap = { @@ -612,20 +614,15 @@ static int max98925_i2c_probe(struct i2c_client *i2c, dev_info(&i2c->dev, "device version 0x%02X\n", reg); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98925, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98925, max98925_dai, ARRAY_SIZE(max98925_dai)); if (ret < 0) dev_err(&i2c->dev, - "Failed to register codec: %d\n", ret); + "Failed to register component: %d\n", ret); return ret; } -static int max98925_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98925_i2c_id[] = { { "max98925", 0 }, { } @@ -645,7 +642,6 @@ static struct i2c_driver max98925_i2c_driver = { .pm = NULL, }, .probe = max98925_i2c_probe, - .remove = max98925_i2c_remove, .id_table = max98925_i2c_id, }; diff --git a/sound/soc/codecs/max98925.h b/sound/soc/codecs/max98925.h index 3783248f2780..96f97085328d 100644 --- a/sound/soc/codecs/max98925.h +++ b/sound/soc/codecs/max98925.h @@ -821,7 +821,7 @@ struct max98925_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct max98925_pdata *pdata; unsigned int sysclk; unsigned int v_slot; From ec4bf5acbb32f298029c14283f02b409d7354fb9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:09:04 +0000 Subject: [PATCH 104/942] ASoC: max98927: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98927.c | 82 ++++++++++++++++++------------------- sound/soc/codecs/max98927.h | 2 +- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/sound/soc/codecs/max98927.c b/sound/soc/codecs/max98927.c index f701fdc81175..065303a46535 100644 --- a/sound/soc/codecs/max98927.c +++ b/sound/soc/codecs/max98927.c @@ -142,14 +142,14 @@ static struct reg_default max98927_reg[] = { static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); unsigned int mode = 0; unsigned int format = 0; bool use_pdm = false; unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: @@ -160,7 +160,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) mode = MAX98927_PCM_MASTER_MODE_MASTER; break; default: - dev_err(codec->dev, "DAI clock mode unsupported\n"); + dev_err(component->dev, "DAI clock mode unsupported\n"); return -EINVAL; } @@ -176,7 +176,7 @@ static int max98927_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) invert = MAX98927_PCM_MODE_CFG_PCM_BCLKEDGE; break; default: - dev_err(codec->dev, "DAI invert mode unsupported\n"); + dev_err(component->dev, "DAI invert mode unsupported\n"); return -EINVAL; } @@ -268,7 +268,7 @@ static int max98927_get_bclk_sel(int bclk) static int max98927_set_clock(struct max98927_priv *max98927, struct snd_pcm_hw_params *params) { - struct snd_soc_codec *codec = max98927->codec; + struct snd_soc_component *component = max98927->component; /* BCLK/LRCLK ratio calculation */ int blr_clk_ratio = params_channels(params) * max98927->ch_size; int value; @@ -281,7 +281,7 @@ static int max98927_set_clock(struct max98927_priv *max98927, break; } if (i == ARRAY_SIZE(rate_table)) { - dev_err(codec->dev, "failed to find proper clock rate.\n"); + dev_err(component->dev, "failed to find proper clock rate.\n"); return -EINVAL; } regmap_update_bits(max98927->regmap, @@ -294,7 +294,7 @@ static int max98927_set_clock(struct max98927_priv *max98927, /* BCLK configuration */ value = max98927_get_bclk_sel(blr_clk_ratio); if (!value) { - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", params_format(params)); return -EINVAL; } @@ -311,8 +311,8 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); unsigned int sampling_rate = 0; unsigned int chan_sz = 0; @@ -328,7 +328,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", params_format(params)); goto err; } @@ -339,7 +339,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, MAX98927_R0020_PCM_MODE_CFG, MAX98927_PCM_MODE_CFG_CHANSZ_MASK, chan_sz); - dev_dbg(codec->dev, "format supported %d", + dev_dbg(component->dev, "format supported %d", params_format(params)); /* sampling rate configuration */ @@ -372,7 +372,7 @@ static int max98927_dai_hw_params(struct snd_pcm_substream *substream, sampling_rate = MAX98927_PCM_SR_SET1_SR_48000; break; default: - dev_err(codec->dev, "rate %d not supported\n", + dev_err(component->dev, "rate %d not supported\n", params_rate(params)); goto err; } @@ -407,8 +407,8 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); int bsel = 0; unsigned int chan_sz = 0; @@ -417,7 +417,7 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, /* BCLK configuration */ bsel = max98927_get_bclk_sel(slots * slot_width); if (bsel == 0) { - dev_err(codec->dev, "BCLK %d not supported\n", + dev_err(component->dev, "BCLK %d not supported\n", slots * slot_width); return -EINVAL; } @@ -439,7 +439,7 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, chan_sz = MAX98927_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", slot_width); return -EINVAL; } @@ -483,8 +483,8 @@ static int max98927_dai_tdm_slot(struct snd_soc_dai *dai, static int max98927_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); max98927->sysclk = freq; return 0; @@ -500,8 +500,8 @@ static const struct snd_soc_dai_ops max98927_dai_ops = { static int max98927_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -677,11 +677,11 @@ static struct snd_soc_dai_driver max98927_dai[] = { } }; -static int max98927_probe(struct snd_soc_codec *codec) +static int max98927_probe(struct snd_soc_component *component) { - struct max98927_priv *max98927 = snd_soc_codec_get_drvdata(codec); + struct max98927_priv *max98927 = snd_soc_component_get_drvdata(component); - max98927->codec = codec; + max98927->component = component; /* Software Reset */ regmap_write(max98927->regmap, @@ -823,16 +823,18 @@ static const struct dev_pm_ops max98927_pm = { SET_SYSTEM_SLEEP_PM_OPS(max98927_suspend, max98927_resume) }; -static const struct snd_soc_codec_driver soc_codec_dev_max98927 = { - .probe = max98927_probe, - .component_driver = { - .controls = max98927_snd_controls, - .num_controls = ARRAY_SIZE(max98927_snd_controls), - .dapm_widgets = max98927_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98927_dapm_widgets), - .dapm_routes = max98927_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98927_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_max98927 = { + .probe = max98927_probe, + .controls = max98927_snd_controls, + .num_controls = ARRAY_SIZE(max98927_snd_controls), + .dapm_widgets = max98927_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98927_dapm_widgets), + .dapm_routes = max98927_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98927_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98927_regmap = { @@ -914,20 +916,15 @@ static int max98927_i2c_probe(struct i2c_client *i2c, max98927_slot_config(i2c, max98927); /* codec registeration */ - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98927, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_max98927, max98927_dai, ARRAY_SIZE(max98927_dai)); if (ret < 0) - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } -static int max98927_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98927_i2c_id[] = { { "max98927", 0}, { }, @@ -959,7 +956,6 @@ static struct i2c_driver max98927_i2c_driver = { .pm = &max98927_pm, }, .probe = max98927_i2c_probe, - .remove = max98927_i2c_remove, .id_table = max98927_i2c_id, }; diff --git a/sound/soc/codecs/max98927.h b/sound/soc/codecs/max98927.h index 9ea839735433..42a9a244a9db 100644 --- a/sound/soc/codecs/max98927.h +++ b/sound/soc/codecs/max98927.h @@ -258,7 +258,7 @@ struct max98927_priv { struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct max98927_pdata *pdata; unsigned int spk_gain; unsigned int sysclk; From 4b51e9f1c386dbd7bd7bc5a342a6ac90a6c54904 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:09:20 +0000 Subject: [PATCH 105/942] ASoC: max98357a: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98357a.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/max98357a.c b/sound/soc/codecs/max98357a.c index 426ed2dae6ca..d469576b5a7b 100644 --- a/sound/soc/codecs/max98357a.c +++ b/sound/soc/codecs/max98357a.c @@ -59,27 +59,29 @@ static const struct snd_soc_dapm_route max98357a_dapm_routes[] = { {"Speaker", NULL, "HiFi Playback"}, }; -static int max98357a_codec_probe(struct snd_soc_codec *codec) +static int max98357a_component_probe(struct snd_soc_component *component) { struct gpio_desc *sdmode; - sdmode = devm_gpiod_get_optional(codec->dev, "sdmode", GPIOD_OUT_LOW); + sdmode = devm_gpiod_get_optional(component->dev, "sdmode", GPIOD_OUT_LOW); if (IS_ERR(sdmode)) return PTR_ERR(sdmode); - snd_soc_codec_set_drvdata(codec, sdmode); + snd_soc_component_set_drvdata(component, sdmode); return 0; } -static const struct snd_soc_codec_driver max98357a_codec_driver = { - .probe = max98357a_codec_probe, - .component_driver = { - .dapm_widgets = max98357a_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98357a_dapm_widgets), - .dapm_routes = max98357a_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(max98357a_dapm_routes), - }, +static const struct snd_soc_component_driver max98357a_component_driver = { + .probe = max98357a_component_probe, + .dapm_widgets = max98357a_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98357a_dapm_widgets), + .dapm_routes = max98357a_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max98357a_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct snd_soc_dai_ops max98357a_dai_ops = { @@ -107,14 +109,13 @@ static struct snd_soc_dai_driver max98357a_dai_driver = { static int max98357a_platform_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &max98357a_codec_driver, + return devm_snd_soc_register_component(&pdev->dev, + &max98357a_component_driver, &max98357a_dai_driver, 1); } static int max98357a_platform_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); - return 0; } From 41572b5455be5da603b671a04be267cb4bd8633b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:09:48 +0000 Subject: [PATCH 106/942] ASoC: max98373: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/max98373.c | 75 +++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 41 deletions(-) diff --git a/sound/soc/codecs/max98373.c b/sound/soc/codecs/max98373.c index 562e88765129..a92586106932 100644 --- a/sound/soc/codecs/max98373.c +++ b/sound/soc/codecs/max98373.c @@ -112,12 +112,12 @@ static struct reg_default max98373_reg[] = { static int max98373_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); unsigned int format = 0; unsigned int invert = 0; - dev_dbg(codec->dev, "%s: fmt 0x%08X\n", __func__, fmt); + dev_dbg(component->dev, "%s: fmt 0x%08X\n", __func__, fmt); switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: @@ -126,7 +126,7 @@ static int max98373_dai_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) invert = MAX98373_PCM_MODE_CFG_PCM_BCLKEDGE; break; default: - dev_err(codec->dev, "DAI invert mode unsupported\n"); + dev_err(component->dev, "DAI invert mode unsupported\n"); return -EINVAL; } @@ -177,10 +177,10 @@ static int max98373_get_bclk_sel(int bclk) return 0; } -static int max98373_set_clock(struct snd_soc_codec *codec, +static int max98373_set_clock(struct snd_soc_component *component, struct snd_pcm_hw_params *params) { - struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); + struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); /* BCLK/LRCLK ratio calculation */ int blr_clk_ratio = params_channels(params) * max98373->ch_size; int value; @@ -189,7 +189,7 @@ static int max98373_set_clock(struct snd_soc_codec *codec, /* BCLK configuration */ value = max98373_get_bclk_sel(blr_clk_ratio); if (!value) { - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", params_format(params)); return -EINVAL; } @@ -206,8 +206,8 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); unsigned int sampling_rate = 0; unsigned int chan_sz = 0; @@ -223,7 +223,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", params_format(params)); goto err; } @@ -234,7 +234,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, MAX98373_R2024_PCM_DATA_FMT_CFG, MAX98373_PCM_MODE_CFG_CHANSZ_MASK, chan_sz); - dev_dbg(codec->dev, "format supported %d", + dev_dbg(component->dev, "format supported %d", params_format(params)); /* sampling rate configuration */ @@ -267,7 +267,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, sampling_rate = MAX98373_PCM_SR_SET1_SR_48000; break; default: - dev_err(codec->dev, "rate %d not supported\n", + dev_err(component->dev, "rate %d not supported\n", params_rate(params)); goto err; } @@ -295,7 +295,7 @@ static int max98373_dai_hw_params(struct snd_pcm_substream *substream, MAX98373_PCM_SR_SET2_IVADC_SR_MASK, sampling_rate); - return max98373_set_clock(codec, params); + return max98373_set_clock(component, params); err: return -EINVAL; } @@ -304,8 +304,8 @@ static int max98373_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); int bsel = 0; unsigned int chan_sz = 0; unsigned int mask; @@ -319,7 +319,7 @@ static int max98373_dai_tdm_slot(struct snd_soc_dai *dai, /* BCLK configuration */ bsel = max98373_get_bclk_sel(slots * slot_width); if (bsel == 0) { - dev_err(codec->dev, "BCLK %d not supported\n", + dev_err(component->dev, "BCLK %d not supported\n", slots * slot_width); return -EINVAL; } @@ -341,7 +341,7 @@ static int max98373_dai_tdm_slot(struct snd_soc_dai *dai, chan_sz = MAX98373_PCM_MODE_CFG_CHANSZ_32; break; default: - dev_err(codec->dev, "format unsupported %d\n", + dev_err(component->dev, "format unsupported %d\n", slot_width); return -EINVAL; } @@ -394,8 +394,8 @@ static const struct snd_soc_dai_ops max98373_dai_ops = { static int max98373_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -721,11 +721,9 @@ static struct snd_soc_dai_driver max98373_dai[] = { } }; -static int max98373_probe(struct snd_soc_codec *codec) +static int max98373_probe(struct snd_soc_component *component) { - struct max98373_priv *max98373 = snd_soc_codec_get_drvdata(codec); - - codec->control_data = max98373->regmap; + struct max98373_priv *max98373 = snd_soc_component_get_drvdata(component); /* Software Reset */ regmap_write(max98373->regmap, @@ -828,16 +826,18 @@ static const struct dev_pm_ops max98373_pm = { SET_SYSTEM_SLEEP_PM_OPS(max98373_suspend, max98373_resume) }; -static const struct snd_soc_codec_driver soc_codec_dev_max98373 = { - .probe = max98373_probe, - .component_driver = { - .controls = max98373_snd_controls, - .num_controls = ARRAY_SIZE(max98373_snd_controls), - .dapm_widgets = max98373_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(max98373_dapm_widgets), - .dapm_routes = max98373_audio_map, - .num_dapm_routes = ARRAY_SIZE(max98373_audio_map), - }, +static const struct snd_soc_component_driver soc_codec_dev_max98373 = { + .probe = max98373_probe, + .controls = max98373_snd_controls, + .num_controls = ARRAY_SIZE(max98373_snd_controls), + .dapm_widgets = max98373_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max98373_dapm_widgets), + .dapm_routes = max98373_audio_map, + .num_dapm_routes = ARRAY_SIZE(max98373_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config max98373_regmap = { @@ -920,7 +920,7 @@ static int max98373_i2c_probe(struct i2c_client *i2c, max98373_slot_config(i2c, max98373); /* codec registeration */ - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98373, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_codec_dev_max98373, max98373_dai, ARRAY_SIZE(max98373_dai)); if (ret < 0) dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); @@ -928,12 +928,6 @@ static int max98373_i2c_probe(struct i2c_client *i2c, return ret; } -static int max98373_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id max98373_i2c_id[] = { { "max98373", 0}, { }, @@ -965,7 +959,6 @@ static struct i2c_driver max98373_i2c_driver = { .pm = &max98373_pm, }, .probe = max98373_i2c_probe, - .remove = max98373_i2c_remove, .id_table = max98373_i2c_id, }; From a05655877f8f514431158a3f406ae10b4b6c4af3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:10:06 +0000 Subject: [PATCH 107/942] ASoC: adav80x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/adav801.c | 7 -- sound/soc/codecs/adav803.c | 7 -- sound/soc/codecs/adav80x.c | 130 ++++++++++++++++++------------------- 3 files changed, 65 insertions(+), 79 deletions(-) diff --git a/sound/soc/codecs/adav801.c b/sound/soc/codecs/adav801.c index 055f1228c2b4..d82f79dd1b38 100644 --- a/sound/soc/codecs/adav801.c +++ b/sound/soc/codecs/adav801.c @@ -30,18 +30,11 @@ static int adav80x_spi_probe(struct spi_device *spi) return adav80x_bus_probe(&spi->dev, devm_regmap_init_spi(spi, &config)); } -static int adav80x_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver adav80x_spi_driver = { .driver = { .name = "adav801", }, .probe = adav80x_spi_probe, - .remove = adav80x_spi_remove, .id_table = adav80x_spi_id, }; module_spi_driver(adav80x_spi_driver); diff --git a/sound/soc/codecs/adav803.c b/sound/soc/codecs/adav803.c index 52881faedcf6..deb14bc0f1f7 100644 --- a/sound/soc/codecs/adav803.c +++ b/sound/soc/codecs/adav803.c @@ -27,18 +27,11 @@ static int adav803_probe(struct i2c_client *client, devm_regmap_init_i2c(client, &adav80x_regmap_config)); } -static int adav803_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static struct i2c_driver adav803_driver = { .driver = { .name = "adav803", }, .probe = adav803_probe, - .remove = adav803_remove, .id_table = adav803_id, }; module_i2c_driver(adav803_driver); diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index da7ca81f47cf..db21ecbe0762 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c @@ -212,8 +212,8 @@ static const struct snd_soc_dapm_widget adav80x_dapm_widgets[] = { static int adav80x_dapm_sysclk_check(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); const char *clk; switch (adav80x->clk_src) { @@ -236,8 +236,8 @@ static int adav80x_dapm_sysclk_check(struct snd_soc_dapm_widget *source, static int adav80x_dapm_pll_check(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); return adav80x->pll_src == ADAV80X_PLL_SRC_XTAL; } @@ -281,9 +281,9 @@ static const struct snd_soc_dapm_route adav80x_dapm_routes[] = { { "AIFAUXIN", NULL, "SYSCLK" }, }; -static int adav80x_set_deemph(struct snd_soc_codec *codec) +static int adav80x_set_deemph(struct snd_soc_component *component) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int val; if (adav80x->deemph) { @@ -315,8 +315,8 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec) static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; if (deemph > 1) @@ -324,14 +324,14 @@ static int adav80x_put_deemph(struct snd_kcontrol *kcontrol, adav80x->deemph = deemph; - return adav80x_set_deemph(codec); + return adav80x_set_deemph(component); } static int adav80x_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = adav80x->deemph; return 0; @@ -365,8 +365,8 @@ static unsigned int adav80x_port_ctrl_regs[2][2] = { static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int capture = 0x00; unsigned int playback = 0x00; @@ -415,10 +415,10 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return 0; } -static int adav80x_set_adc_clock(struct snd_soc_codec *codec, +static int adav80x_set_adc_clock(struct snd_soc_component *component, unsigned int sample_rate) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int val; if (sample_rate <= 48000) @@ -432,10 +432,10 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec, return 0; } -static int adav80x_set_dac_clock(struct snd_soc_codec *codec, +static int adav80x_set_dac_clock(struct snd_soc_component *component, unsigned int sample_rate) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int val; if (sample_rate <= 48000) @@ -450,10 +450,10 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec, return 0; } -static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, +static int adav80x_set_capture_pcm_format(struct snd_soc_component *component, struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int val; switch (params_width(params)) { @@ -479,10 +479,10 @@ static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, return 0; } -static int adav80x_set_playback_pcm_format(struct snd_soc_codec *codec, +static int adav80x_set_playback_pcm_format(struct snd_soc_component *component, struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int val; if (adav80x->dai_fmt[dai->id] != SND_SOC_DAIFMT_RIGHT_J) @@ -514,32 +514,32 @@ static int adav80x_set_playback_pcm_format(struct snd_soc_codec *codec, static int adav80x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int rate = params_rate(params); if (rate * 256 != adav80x->sysclk) return -EINVAL; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - adav80x_set_playback_pcm_format(codec, dai, params); - adav80x_set_dac_clock(codec, rate); + adav80x_set_playback_pcm_format(component, dai, params); + adav80x_set_dac_clock(component, rate); } else { - adav80x_set_capture_pcm_format(codec, dai, params); - adav80x_set_adc_clock(codec, rate); + adav80x_set_capture_pcm_format(component, dai, params); + adav80x_set_adc_clock(component, rate); } adav80x->rate = rate; - adav80x_set_deemph(codec); + adav80x_set_deemph(component); return 0; } -static int adav80x_set_sysclk(struct snd_soc_codec *codec, +static int adav80x_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (dir == SND_SOC_CLOCK_IN) { switch (clk_id) { @@ -619,11 +619,11 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec, return 0; } -static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, +static int adav80x_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int pll_ctrl1 = 0; unsigned int pll_ctrl2 = 0; unsigned int pll_src; @@ -694,10 +694,10 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, return 0; } -static int adav80x_set_bias_level(struct snd_soc_codec *codec, +static int adav80x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); unsigned int mask = ADAV80X_DAC_CTRL1_PD; switch (level) { @@ -722,10 +722,10 @@ static int adav80x_set_bias_level(struct snd_soc_codec *codec, static int adav80x_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); - if (!snd_soc_codec_is_active(codec) || !adav80x->rate) + if (!snd_soc_component_is_active(component) || !adav80x->rate) return 0; return snd_pcm_hw_constraint_single(substream->runtime, @@ -735,10 +735,10 @@ static int adav80x_dai_startup(struct snd_pcm_substream *substream, static void adav80x_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); - if (!snd_soc_codec_is_active(codec)) + if (!snd_soc_component_is_active(component)) adav80x->rate = 0; } @@ -799,10 +799,10 @@ static struct snd_soc_dai_driver adav80x_dais[] = { }, }; -static int adav80x_probe(struct snd_soc_codec *codec) +static int adav80x_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); /* Force PLLs on for SYSCLK output */ snd_soc_dapm_force_enable_pin(dapm, "PLL1"); @@ -816,32 +816,32 @@ static int adav80x_probe(struct snd_soc_codec *codec) return 0; } -static int adav80x_resume(struct snd_soc_codec *codec) +static int adav80x_resume(struct snd_soc_component *component) { - struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); + struct adav80x *adav80x = snd_soc_component_get_drvdata(component); regcache_sync(adav80x->regmap); return 0; } -static const struct snd_soc_codec_driver adav80x_codec_driver = { - .probe = adav80x_probe, - .resume = adav80x_resume, - .set_bias_level = adav80x_set_bias_level, - .suspend_bias_off = true, - - .set_pll = adav80x_set_pll, - .set_sysclk = adav80x_set_sysclk, - - .component_driver = { - .controls = adav80x_controls, - .num_controls = ARRAY_SIZE(adav80x_controls), - .dapm_widgets = adav80x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(adav80x_dapm_widgets), - .dapm_routes = adav80x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(adav80x_dapm_routes), - }, +static const struct snd_soc_component_driver adav80x_component_driver = { + .probe = adav80x_probe, + .resume = adav80x_resume, + .set_bias_level = adav80x_set_bias_level, + .set_pll = adav80x_set_pll, + .set_sysclk = adav80x_set_sysclk, + .controls = adav80x_controls, + .num_controls = ARRAY_SIZE(adav80x_controls), + .dapm_widgets = adav80x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(adav80x_dapm_widgets), + .dapm_routes = adav80x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(adav80x_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; int adav80x_bus_probe(struct device *dev, struct regmap *regmap) @@ -858,7 +858,7 @@ int adav80x_bus_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, adav80x); adav80x->regmap = regmap; - return snd_soc_register_codec(dev, &adav80x_codec_driver, + return devm_snd_soc_register_component(dev, &adav80x_component_driver, adav80x_dais, ARRAY_SIZE(adav80x_dais)); } EXPORT_SYMBOL_GPL(adav80x_bus_probe); From 0d12540cd83c111cfa3ed9a17bf981134187d8c3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:10:39 +0000 Subject: [PATCH 108/942] ASoC: adau1373: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/adau1373.c | 84 +++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index a865945d776a..f22ff9f6ab47 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c @@ -549,8 +549,8 @@ static const struct snd_kcontrol_new adau1373_drc_controls[] = { static int adau1373_pll_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); unsigned int pll_id = w->name[3] - '1'; unsigned int val; @@ -821,8 +821,8 @@ static const struct snd_soc_dapm_widget adau1373_dapm_widgets[] = { static int adau1373_check_aif_clk(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); unsigned int dai; const char *clk; @@ -842,8 +842,8 @@ static int adau1373_check_aif_clk(struct snd_soc_dapm_widget *source, static int adau1373_check_src(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); unsigned int dai; dai = sink->name[3] - '1'; @@ -1031,8 +1031,8 @@ static const struct snd_soc_dapm_route adau1373_dapm_routes[] = { static int adau1373_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id]; unsigned int div; unsigned int freq; @@ -1098,8 +1098,8 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream, static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id]; unsigned int ctrl; @@ -1158,7 +1158,7 @@ static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int adau1373_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(dai->component); struct adau1373_dai *adau1373_dai = &adau1373->dais[dai->id]; switch (clk_id) { @@ -1250,10 +1250,10 @@ static struct snd_soc_dai_driver adau1373_dai_driver[] = { }, }; -static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id, +static int adau1373_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); unsigned int dpll_div = 0; uint8_t pll_regs[5]; int ret; @@ -1348,10 +1348,10 @@ static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) return false; } -static int adau1373_probe(struct snd_soc_codec *codec) +static int adau1373_probe(struct snd_soc_component *component) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); - struct adau1373_platform_data *pdata = codec->dev->platform_data; + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); + struct adau1373_platform_data *pdata = component->dev->platform_data; bool lineout_differential = false; unsigned int val; int i; @@ -1369,7 +1369,7 @@ static int adau1373_probe(struct snd_soc_codec *codec) pdata->drc_setting[i]); } - snd_soc_add_codec_controls(codec, adau1373_drc_controls, + snd_soc_add_component_controls(component, adau1373_drc_controls, pdata->num_drc); val = 0; @@ -1394,7 +1394,7 @@ static int adau1373_probe(struct snd_soc_codec *codec) } if (!lineout_differential) { - snd_soc_add_codec_controls(codec, adau1373_lineout2_controls, + snd_soc_add_component_controls(component, adau1373_lineout2_controls, ARRAY_SIZE(adau1373_lineout2_controls)); } @@ -1404,10 +1404,10 @@ static int adau1373_probe(struct snd_soc_codec *codec) return 0; } -static int adau1373_set_bias_level(struct snd_soc_codec *codec, +static int adau1373_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1426,9 +1426,9 @@ static int adau1373_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int adau1373_resume(struct snd_soc_codec *codec) +static int adau1373_resume(struct snd_soc_component *component) { - struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); + struct adau1373 *adau1373 = snd_soc_component_get_drvdata(component); regcache_sync(adau1373->regmap); @@ -1458,22 +1458,20 @@ static const struct regmap_config adau1373_regmap_config = { .num_reg_defaults = ARRAY_SIZE(adau1373_reg_defaults), }; -static const struct snd_soc_codec_driver adau1373_codec_driver = { - .probe = adau1373_probe, - .resume = adau1373_resume, - .set_bias_level = adau1373_set_bias_level, - .idle_bias_off = true, - - .set_pll = adau1373_set_pll, - - .component_driver = { - .controls = adau1373_controls, - .num_controls = ARRAY_SIZE(adau1373_controls), - .dapm_widgets = adau1373_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(adau1373_dapm_widgets), - .dapm_routes = adau1373_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(adau1373_dapm_routes), - }, +static const struct snd_soc_component_driver adau1373_component_driver = { + .probe = adau1373_probe, + .resume = adau1373_resume, + .set_bias_level = adau1373_set_bias_level, + .set_pll = adau1373_set_pll, + .controls = adau1373_controls, + .num_controls = ARRAY_SIZE(adau1373_controls), + .dapm_widgets = adau1373_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(adau1373_dapm_widgets), + .dapm_routes = adau1373_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(adau1373_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int adau1373_i2c_probe(struct i2c_client *client, @@ -1495,17 +1493,12 @@ static int adau1373_i2c_probe(struct i2c_client *client, dev_set_drvdata(&client->dev, adau1373); - ret = snd_soc_register_codec(&client->dev, &adau1373_codec_driver, + ret = devm_snd_soc_register_component(&client->dev, + &adau1373_component_driver, adau1373_dai_driver, ARRAY_SIZE(adau1373_dai_driver)); return ret; } -static int adau1373_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id adau1373_i2c_id[] = { { "adau1373", 0 }, { } @@ -1517,7 +1510,6 @@ static struct i2c_driver adau1373_i2c_driver = { .name = "adau1373", }, .probe = adau1373_i2c_probe, - .remove = adau1373_i2c_remove, .id_table = adau1373_i2c_id, }; From d5bc548469dae9cd83f6553437637b0d0b7d5c5c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:11:10 +0000 Subject: [PATCH 109/942] ASoC: adau7002: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/adau7002.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/adau7002.c b/sound/soc/codecs/adau7002.c index 6384c5491de8..49475e36a4e4 100644 --- a/sound/soc/codecs/adau7002.c +++ b/sound/soc/codecs/adau7002.c @@ -38,24 +38,26 @@ static struct snd_soc_dai_driver adau7002_dai = { }, }; -static const struct snd_soc_codec_driver adau7002_codec_driver = { - .component_driver = { - .dapm_widgets = adau7002_widgets, - .num_dapm_widgets = ARRAY_SIZE(adau7002_widgets), - .dapm_routes = adau7002_routes, - .num_dapm_routes = ARRAY_SIZE(adau7002_routes), - }, +static const struct snd_soc_component_driver adau7002_component_driver = { + .dapm_widgets = adau7002_widgets, + .num_dapm_widgets = ARRAY_SIZE(adau7002_widgets), + .dapm_routes = adau7002_routes, + .num_dapm_routes = ARRAY_SIZE(adau7002_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int adau7002_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &adau7002_codec_driver, + return devm_snd_soc_register_component(&pdev->dev, + &adau7002_component_driver, &adau7002_dai, 1); } static int adau7002_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } From f305fe81ab8f9e21388d416ebe03a901273ad0f2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:11:29 +0000 Subject: [PATCH 110/942] ASoC: adau1977: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/adau1977-i2c.c | 7 ---- sound/soc/codecs/adau1977-spi.c | 7 ---- sound/soc/codecs/adau1977.c | 59 ++++++++++++++++----------------- 3 files changed, 29 insertions(+), 44 deletions(-) diff --git a/sound/soc/codecs/adau1977-i2c.c b/sound/soc/codecs/adau1977-i2c.c index 21e7394a972a..e7fe1ee5cdeb 100644 --- a/sound/soc/codecs/adau1977-i2c.c +++ b/sound/soc/codecs/adau1977-i2c.c @@ -29,12 +29,6 @@ static int adau1977_i2c_probe(struct i2c_client *client, id->driver_data, NULL); } -static int adau1977_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id adau1977_i2c_ids[] = { { "adau1977", ADAU1977 }, { "adau1978", ADAU1978 }, @@ -48,7 +42,6 @@ static struct i2c_driver adau1977_i2c_driver = { .name = "adau1977", }, .probe = adau1977_i2c_probe, - .remove = adau1977_i2c_remove, .id_table = adau1977_i2c_ids, }; module_i2c_driver(adau1977_i2c_driver); diff --git a/sound/soc/codecs/adau1977-spi.c b/sound/soc/codecs/adau1977-spi.c index 0b46d88b481c..84ffbde9583f 100644 --- a/sound/soc/codecs/adau1977-spi.c +++ b/sound/soc/codecs/adau1977-spi.c @@ -46,12 +46,6 @@ static int adau1977_spi_probe(struct spi_device *spi) id->driver_data, adau1977_spi_switch_mode); } -static int adau1977_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct spi_device_id adau1977_spi_ids[] = { { "adau1977", ADAU1977 }, { "adau1978", ADAU1978 }, @@ -65,7 +59,6 @@ static struct spi_driver adau1977_spi_driver = { .name = "adau1977", }, .probe = adau1977_spi_probe, - .remove = adau1977_spi_remove, .id_table = adau1977_spi_ids, }; module_spi_driver(adau1977_spi_driver); diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c index e384f212beb2..116af6a9ce3b 100644 --- a/sound/soc/codecs/adau1977.c +++ b/sound/soc/codecs/adau1977.c @@ -294,8 +294,8 @@ static int adau1977_lookup_mcs(struct adau1977 *adau1977, unsigned int rate, static int adau1977_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); unsigned int rate = params_rate(params); unsigned int slot_width; unsigned int ctrl0, ctrl0_mask; @@ -471,10 +471,10 @@ err_disable_avdd: return ret; } -static int adau1977_set_bias_level(struct snd_soc_codec *codec, +static int adau1977_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); int ret = 0; switch (level) { @@ -483,7 +483,7 @@ static int adau1977_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) ret = adau1977_power_enable(adau1977); break; case SND_SOC_BIAS_OFF: @@ -497,7 +497,7 @@ static int adau1977_set_bias_level(struct snd_soc_codec *codec, static int adau1977_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int width) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); unsigned int ctrl0, ctrl1, drv; unsigned int slot[4]; unsigned int i; @@ -603,7 +603,7 @@ static int adau1977_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int adau1977_mute(struct snd_soc_dai *dai, int mute, int stream) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); unsigned int val; if (mute) @@ -617,7 +617,7 @@ static int adau1977_mute(struct snd_soc_dai *dai, int mute, int stream) static int adau1977_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); unsigned int ctrl0 = 0, ctrl1 = 0, block_power = 0; bool invert_lrclk; int ret; @@ -704,7 +704,7 @@ static int adau1977_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int adau1977_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); u64 formats = 0; if (adau1977->slot_width == 16) @@ -729,7 +729,7 @@ static int adau1977_startup(struct snd_pcm_substream *substream, static int adau1977_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(dai->component); unsigned int val; if (tristate) @@ -790,10 +790,10 @@ static bool adau1977_check_sysclk(unsigned int mclk, unsigned int base_freq) return true; } -static int adau1977_set_sysclk(struct snd_soc_codec *codec, +static int adau1977_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(codec); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); unsigned int mask = 0; unsigned int clk_src; unsigned int ret; @@ -844,10 +844,10 @@ static int adau1977_set_sysclk(struct snd_soc_codec *codec, return 0; } -static int adau1977_codec_probe(struct snd_soc_codec *codec) +static int adau1977_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau1977 *adau1977 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau1977 *adau1977 = snd_soc_component_get_drvdata(component); int ret; switch (adau1977->type) { @@ -865,20 +865,19 @@ static int adau1977_codec_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver adau1977_codec_driver = { - .probe = adau1977_codec_probe, - .set_bias_level = adau1977_set_bias_level, - .set_sysclk = adau1977_set_sysclk, - .idle_bias_off = true, - - .component_driver = { - .controls = adau1977_snd_controls, - .num_controls = ARRAY_SIZE(adau1977_snd_controls), - .dapm_widgets = adau1977_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(adau1977_dapm_widgets), - .dapm_routes = adau1977_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(adau1977_dapm_routes), - }, +static const struct snd_soc_component_driver adau1977_component_driver = { + .probe = adau1977_component_probe, + .set_bias_level = adau1977_set_bias_level, + .set_sysclk = adau1977_set_sysclk, + .controls = adau1977_snd_controls, + .num_controls = ARRAY_SIZE(adau1977_snd_controls), + .dapm_widgets = adau1977_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(adau1977_dapm_widgets), + .dapm_routes = adau1977_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(adau1977_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int adau1977_setup_micbias(struct adau1977 *adau1977) @@ -968,7 +967,7 @@ int adau1977_probe(struct device *dev, struct regmap *regmap, if (ret) return ret; - return snd_soc_register_codec(dev, &adau1977_codec_driver, + return devm_snd_soc_register_component(dev, &adau1977_component_driver, &adau1977_dai, 1); err_poweroff: From dd08102a9ff8aec720946f2b229a076b48bc8cf0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:12:24 +0000 Subject: [PATCH 111/942] ASoC: adau17x1/adau1761/adau1781: replace codec to component Now we can replace Codec to Component. Let's do it. Because there are many drivers which are using adau17x1, we need to update these all related drivers in same time. Otherwise compile error/warning happen adau1761: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 adau1781: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/adau1761.c | 88 +++++++++++++++++++------------------ sound/soc/codecs/adau1781.c | 51 ++++++++++----------- sound/soc/codecs/adau17x1.c | 67 ++++++++++++++-------------- sound/soc/codecs/adau17x1.h | 8 ++-- 4 files changed, 108 insertions(+), 106 deletions(-) diff --git a/sound/soc/codecs/adau1761.c b/sound/soc/codecs/adau1761.c index 3bc3cc559dde..be136e981653 100644 --- a/sound/soc/codecs/adau1761.c +++ b/sound/soc/codecs/adau1761.c @@ -255,8 +255,8 @@ static const struct snd_kcontrol_new adau1761_input_mux_control = static int adau1761_dejitter_fixup(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct adau *adau = snd_soc_component_get_drvdata(component); /* After any power changes have been made the dejitter circuit * has to be reinitialized. */ @@ -445,10 +445,10 @@ static const struct snd_soc_dapm_route adau1761_dapm_routes[] = { { "Digital Clock 1", NULL, "SYSCLK" }, }; -static int adau1761_set_bias_level(struct snd_soc_codec *codec, +static int adau1761_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct adau *adau = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -460,7 +460,7 @@ static int adau1761_set_bias_level(struct snd_soc_codec *codec, regmap_update_bits(adau->regmap, ADAU17X1_CLOCK_CONTROL, ADAU17X1_CLOCK_CONTROL_SYSCLK_EN, ADAU17X1_CLOCK_CONTROL_SYSCLK_EN); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) regcache_sync(adau->regmap); break; case SND_SOC_BIAS_OFF: @@ -474,9 +474,9 @@ static int adau1761_set_bias_level(struct snd_soc_codec *codec, } static enum adau1761_output_mode adau1761_get_lineout_mode( - struct snd_soc_codec *codec) + struct snd_soc_component *component) { - struct adau1761_platform_data *pdata = codec->dev->platform_data; + struct adau1761_platform_data *pdata = component->dev->platform_data; if (pdata) return pdata->lineout_mode; @@ -484,11 +484,11 @@ static enum adau1761_output_mode adau1761_get_lineout_mode( return ADAU1761_OUTPUT_MODE_LINE; } -static int adau1761_setup_digmic_jackdetect(struct snd_soc_codec *codec) +static int adau1761_setup_digmic_jackdetect(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau1761_platform_data *pdata = codec->dev->platform_data; - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau1761_platform_data *pdata = component->dev->platform_data; + struct adau *adau = snd_soc_component_get_drvdata(component); enum adau1761_digmic_jackdet_pin_mode mode; unsigned int val = 0; int ret; @@ -513,7 +513,7 @@ static int adau1761_setup_digmic_jackdetect(struct snd_soc_codec *codec) if (pdata->jackdetect_active_low) val |= ADAU1761_DIGMIC_JACKDETECT_ACTIVE_LOW; - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, adau1761_jack_detect_controls, ARRAY_SIZE(adau1761_jack_detect_controls)); if (ret) @@ -546,11 +546,11 @@ static int adau1761_setup_digmic_jackdetect(struct snd_soc_codec *codec) return 0; } -static int adau1761_setup_headphone_mode(struct snd_soc_codec *codec) +static int adau1761_setup_headphone_mode(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau *adau = snd_soc_codec_get_drvdata(codec); - struct adau1761_platform_data *pdata = codec->dev->platform_data; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau *adau = snd_soc_component_get_drvdata(component); + struct adau1761_platform_data *pdata = component->dev->platform_data; enum adau1761_output_mode mode; int ret; @@ -588,7 +588,7 @@ static int adau1761_setup_headphone_mode(struct snd_soc_codec *codec) adau1761_capless_dapm_routes, ARRAY_SIZE(adau1761_capless_dapm_routes)); } else { - ret = snd_soc_add_codec_controls(codec, adau1761_mono_controls, + ret = snd_soc_add_component_controls(component, adau1761_mono_controls, ARRAY_SIZE(adau1761_mono_controls)); if (ret) return ret; @@ -640,14 +640,14 @@ static bool adau1761_readable_register(struct device *dev, unsigned int reg) return adau17x1_readable_register(dev, reg); } -static int adau1761_codec_probe(struct snd_soc_codec *codec) +static int adau1761_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau1761_platform_data *pdata = codec->dev->platform_data; - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau1761_platform_data *pdata = component->dev->platform_data; + struct adau *adau = snd_soc_component_get_drvdata(component); int ret; - ret = adau17x1_add_widgets(codec); + ret = adau17x1_add_widgets(component); if (ret < 0) return ret; @@ -658,20 +658,20 @@ static int adau1761_codec_probe(struct snd_soc_codec *codec) regmap_update_bits(adau->regmap, ADAU1761_RIGHT_DIFF_INPUT_VOL, ADAU1761_DIFF_INPUT_VOL_LDEN, ADAU1761_DIFF_INPUT_VOL_LDEN); - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, adau1761_differential_mode_controls, ARRAY_SIZE(adau1761_differential_mode_controls)); if (ret) return ret; } else { - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, adau1761_single_mode_controls, ARRAY_SIZE(adau1761_single_mode_controls)); if (ret) return ret; } - switch (adau1761_get_lineout_mode(codec)) { + switch (adau1761_get_lineout_mode(component)) { case ADAU1761_OUTPUT_MODE_LINE: break; case ADAU1761_OUTPUT_MODE_HEADPHONE: @@ -686,11 +686,11 @@ static int adau1761_codec_probe(struct snd_soc_codec *codec) return -EINVAL; } - ret = adau1761_setup_headphone_mode(codec); + ret = adau1761_setup_headphone_mode(component); if (ret) return ret; - ret = adau1761_setup_digmic_jackdetect(codec); + ret = adau1761_setup_digmic_jackdetect(component); if (ret) return ret; @@ -706,27 +706,28 @@ static int adau1761_codec_probe(struct snd_soc_codec *codec) return ret; } - ret = adau17x1_add_routes(codec); + ret = adau17x1_add_routes(component); if (ret < 0) return ret; return 0; } -static const struct snd_soc_codec_driver adau1761_codec_driver = { - .probe = adau1761_codec_probe, - .resume = adau17x1_resume, - .set_bias_level = adau1761_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = adau1761_controls, - .num_controls = ARRAY_SIZE(adau1761_controls), - .dapm_widgets = adau1x61_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(adau1x61_dapm_widgets), - .dapm_routes = adau1x61_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(adau1x61_dapm_routes), - }, +static const struct snd_soc_component_driver adau1761_component_driver = { + .probe = adau1761_component_probe, + .resume = adau17x1_resume, + .set_bias_level = adau1761_set_bias_level, + .controls = adau1761_controls, + .num_controls = ARRAY_SIZE(adau1761_controls), + .dapm_widgets = adau1x61_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(adau1x61_dapm_widgets), + .dapm_routes = adau1x61_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(adau1x61_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #define ADAU1761_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ @@ -793,7 +794,8 @@ int adau1761_probe(struct device *dev, struct regmap *regmap, * reaches standby and the core clock is enabled */ regcache_cache_only(regmap, true); - return snd_soc_register_codec(dev, &adau1761_codec_driver, dai_drv, 1); + return devm_snd_soc_register_component(dev, &adau1761_component_driver, + dai_drv, 1); } EXPORT_SYMBOL_GPL(adau1761_probe); diff --git a/sound/soc/codecs/adau1781.c b/sound/soc/codecs/adau1781.c index 546071c6c0d0..6a6655730cd4 100644 --- a/sound/soc/codecs/adau1781.c +++ b/sound/soc/codecs/adau1781.c @@ -174,8 +174,8 @@ static const struct snd_kcontrol_new adau1781_mono_mixer_controls[] = { static int adau1781_dejitter_fixup(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct adau *adau = snd_soc_component_get_drvdata(component); /* After any power changes have been made the dejitter circuit * has to be reinitialized. */ @@ -314,10 +314,10 @@ static const struct snd_soc_dapm_route adau1781_dmic_dapm_routes[] = { { "Right Decimator", NULL, "DMIC Select" }, }; -static int adau1781_set_bias_level(struct snd_soc_codec *codec, +static int adau1781_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct adau *adau = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -380,14 +380,14 @@ static int adau1781_set_input_mode(struct adau *adau, unsigned int reg, ADAU1781_INPUT_DIFFERNTIAL, val); } -static int adau1781_codec_probe(struct snd_soc_codec *codec) +static int adau1781_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau1781_platform_data *pdata = dev_get_platdata(codec->dev); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau1781_platform_data *pdata = dev_get_platdata(component->dev); + struct adau *adau = snd_soc_component_get_drvdata(component); int ret; - ret = adau17x1_add_widgets(codec); + ret = adau17x1_add_widgets(component); if (ret) return ret; @@ -419,27 +419,28 @@ static int adau1781_codec_probe(struct snd_soc_codec *codec) return ret; } - ret = adau17x1_add_routes(codec); + ret = adau17x1_add_routes(component); if (ret < 0) return ret; return 0; } -static const struct snd_soc_codec_driver adau1781_codec_driver = { - .probe = adau1781_codec_probe, - .resume = adau17x1_resume, - .set_bias_level = adau1781_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = adau1781_controls, - .num_controls = ARRAY_SIZE(adau1781_controls), - .dapm_widgets = adau1781_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(adau1781_dapm_widgets), - .dapm_routes = adau1781_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(adau1781_dapm_routes), - }, +static const struct snd_soc_component_driver adau1781_component_driver = { + .probe = adau1781_component_probe, + .resume = adau17x1_resume, + .set_bias_level = adau1781_set_bias_level, + .controls = adau1781_controls, + .num_controls = ARRAY_SIZE(adau1781_controls), + .dapm_widgets = adau1781_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(adau1781_dapm_widgets), + .dapm_routes = adau1781_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(adau1781_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #define ADAU1781_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \ @@ -498,7 +499,7 @@ int adau1781_probe(struct device *dev, struct regmap *regmap, if (ret) return ret; - return snd_soc_register_codec(dev, &adau1781_codec_driver, + return devm_snd_soc_register_component(dev, &adau1781_component_driver, &adau1781_dai_driver, 1); } EXPORT_SYMBOL_GPL(adau1781_probe); diff --git a/sound/soc/codecs/adau17x1.c b/sound/soc/codecs/adau17x1.c index 6758f789b712..df3434982b43 100644 --- a/sound/soc/codecs/adau17x1.c +++ b/sound/soc/codecs/adau17x1.c @@ -63,8 +63,8 @@ static const struct snd_kcontrol_new adau17x1_controls[] = { static int adau17x1_pll_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct adau *adau = snd_soc_component_get_drvdata(component); if (SND_SOC_DAPM_EVENT_ON(event)) { adau->pll_regs[5] = 1; @@ -93,8 +93,8 @@ static int adau17x1_pll_event(struct snd_soc_dapm_widget *w, static int adau17x1_adc_fixup(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct adau *adau = snd_soc_component_get_drvdata(component); /* * If we are capturing, toggle the ADOSR bit in Converter Control 0 to @@ -177,9 +177,9 @@ static const struct snd_soc_dapm_route adau17x1_dapm_pll_route = { static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau *adau = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; struct snd_soc_dapm_update update = { 0 }; unsigned int stream = e->shift_l; @@ -205,7 +205,7 @@ static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, else reg = ADAU17X1_SERIAL_OUTPUT_ROUTE; - change = snd_soc_test_bits(codec, reg, 0xff, val); + change = snd_soc_component_test_bits(component, reg, 0xff, val); if (change) { update.kcontrol = kcontrol; update.mask = 0xff; @@ -222,8 +222,8 @@ static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, static int adau17x1_dsp_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct adau *adau = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int stream = e->shift_l; unsigned int reg, val; @@ -328,8 +328,8 @@ EXPORT_SYMBOL_GPL(adau17x1_has_dsp); static int adau17x1_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adau *adau = snd_soc_component_get_drvdata(component); int ret; if (freq_in < 8000000 || freq_in > 27000000) @@ -353,8 +353,8 @@ static int adau17x1_set_dai_pll(struct snd_soc_dai *dai, int pll_id, static int adau17x1_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(dai->codec); - struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(dai->component); + struct adau *adau = snd_soc_component_get_drvdata(dai->component); bool is_pll; bool was_pll; @@ -438,8 +438,8 @@ static int adau17x1_auto_pll(struct snd_soc_dai *dai, static int adau17x1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adau *adau = snd_soc_component_get_drvdata(component); unsigned int val, div, dsp_div; unsigned int freq; int ret; @@ -531,7 +531,7 @@ static int adau17x1_hw_params(struct snd_pcm_substream *substream, static int adau17x1_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); + struct adau *adau = snd_soc_component_get_drvdata(dai->component); unsigned int ctrl0, ctrl1; int lrclk_pol; @@ -603,7 +603,7 @@ static int adau17x1_set_dai_fmt(struct snd_soc_dai *dai, static int adau17x1_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); + struct adau *adau = snd_soc_component_get_drvdata(dai->component); unsigned int ser_ctrl0, ser_ctrl1; unsigned int conv_ctrl0, conv_ctrl1; @@ -728,7 +728,7 @@ static int adau17x1_set_dai_tdm_slot(struct snd_soc_dai *dai, static int adau17x1_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct adau *adau = snd_soc_codec_get_drvdata(dai->codec); + struct adau *adau = snd_soc_component_get_drvdata(dai->component); if (adau->sigmadsp) return sigmadsp_restrict_params(adau->sigmadsp, substream); @@ -746,10 +746,10 @@ const struct snd_soc_dai_ops adau17x1_dai_ops = { }; EXPORT_SYMBOL_GPL(adau17x1_dai_ops); -int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec, +int adau17x1_set_micbias_voltage(struct snd_soc_component *component, enum adau17x1_micbias_voltage micbias) { - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct adau *adau = snd_soc_component_get_drvdata(component); switch (micbias) { case ADAU17X1_MICBIAS_0_90_AVDD: @@ -858,13 +858,13 @@ int adau17x1_setup_firmware(struct adau *adau, unsigned int rate) } EXPORT_SYMBOL_GPL(adau17x1_setup_firmware); -int adau17x1_add_widgets(struct snd_soc_codec *codec) +int adau17x1_add_widgets(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau *adau = snd_soc_component_get_drvdata(component); int ret; - ret = snd_soc_add_codec_controls(codec, adau17x1_controls, + ret = snd_soc_add_component_controls(component, adau17x1_controls, ARRAY_SIZE(adau17x1_controls)); if (ret) return ret; @@ -882,9 +882,9 @@ int adau17x1_add_widgets(struct snd_soc_codec *codec) if (!adau->sigmadsp) return 0; - ret = sigmadsp_attach(adau->sigmadsp, &codec->component); + ret = sigmadsp_attach(adau->sigmadsp, component); if (ret) { - dev_err(codec->dev, "Failed to attach firmware: %d\n", + dev_err(component->dev, "Failed to attach firmware: %d\n", ret); return ret; } @@ -894,10 +894,10 @@ int adau17x1_add_widgets(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(adau17x1_add_widgets); -int adau17x1_add_routes(struct snd_soc_codec *codec) +int adau17x1_add_routes(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct adau *adau = snd_soc_component_get_drvdata(component); int ret; ret = snd_soc_dapm_add_routes(dapm, adau17x1_dapm_routes, @@ -920,12 +920,12 @@ int adau17x1_add_routes(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(adau17x1_add_routes); -int adau17x1_resume(struct snd_soc_codec *codec) +int adau17x1_resume(struct snd_soc_component *component) { - struct adau *adau = snd_soc_codec_get_drvdata(codec); + struct adau *adau = snd_soc_component_get_drvdata(component); if (adau->switch_mode) - adau->switch_mode(codec->dev); + adau->switch_mode(component->dev); regcache_sync(adau->regmap); @@ -998,7 +998,6 @@ void adau17x1_remove(struct device *dev) { struct adau *adau = dev_get_drvdata(dev); - snd_soc_unregister_codec(dev); if (adau->mclk) clk_disable_unprepare(adau->mclk); } diff --git a/sound/soc/codecs/adau17x1.h b/sound/soc/codecs/adau17x1.h index eaf8f933bab8..a7b1cb770814 100644 --- a/sound/soc/codecs/adau17x1.h +++ b/sound/soc/codecs/adau17x1.h @@ -53,18 +53,18 @@ struct adau { struct sigmadsp *sigmadsp; }; -int adau17x1_add_widgets(struct snd_soc_codec *codec); -int adau17x1_add_routes(struct snd_soc_codec *codec); +int adau17x1_add_widgets(struct snd_soc_component *component); +int adau17x1_add_routes(struct snd_soc_component *component); int adau17x1_probe(struct device *dev, struct regmap *regmap, enum adau17x1_type type, void (*switch_mode)(struct device *dev), const char *firmware_name); void adau17x1_remove(struct device *dev); -int adau17x1_set_micbias_voltage(struct snd_soc_codec *codec, +int adau17x1_set_micbias_voltage(struct snd_soc_component *component, enum adau17x1_micbias_voltage micbias); bool adau17x1_readable_register(struct device *dev, unsigned int reg); bool adau17x1_volatile_register(struct device *dev, unsigned int reg); bool adau17x1_precious_register(struct device *dev, unsigned int reg); -int adau17x1_resume(struct snd_soc_codec *codec); +int adau17x1_resume(struct snd_soc_component *component); extern const struct snd_soc_dai_ops adau17x1_dai_ops; From ff06ac2a0489cfe913215d424667b52ad6c0fba1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:12:48 +0000 Subject: [PATCH 112/942] ASoC: tlv320aic23: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic23-i2c.c | 7 -- sound/soc/codecs/tlv320aic23-spi.c | 7 -- sound/soc/codecs/tlv320aic23.c | 120 +++++++++++++++-------------- 3 files changed, 61 insertions(+), 73 deletions(-) diff --git a/sound/soc/codecs/tlv320aic23-i2c.c b/sound/soc/codecs/tlv320aic23-i2c.c index 78a94af65518..1d7c117316fb 100644 --- a/sound/soc/codecs/tlv320aic23-i2c.c +++ b/sound/soc/codecs/tlv320aic23-i2c.c @@ -31,12 +31,6 @@ static int tlv320aic23_i2c_probe(struct i2c_client *i2c, return tlv320aic23_probe(&i2c->dev, regmap); } -static int tlv320aic23_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id tlv320aic23_id[] = { {"tlv320aic23", 0}, {} @@ -56,7 +50,6 @@ static struct i2c_driver tlv320aic23_i2c_driver = { .of_match_table = of_match_ptr(tlv320aic23_of_match), }, .probe = tlv320aic23_i2c_probe, - .remove = tlv320aic23_i2c_remove, .id_table = tlv320aic23_id, }; diff --git a/sound/soc/codecs/tlv320aic23-spi.c b/sound/soc/codecs/tlv320aic23-spi.c index f801ae051658..d8c9ec1e9201 100644 --- a/sound/soc/codecs/tlv320aic23-spi.c +++ b/sound/soc/codecs/tlv320aic23-spi.c @@ -34,18 +34,11 @@ static int aic23_spi_probe(struct spi_device *spi) return tlv320aic23_probe(&spi->dev, regmap); } -static int aic23_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver aic23_spi = { .driver = { .name = "tlv320aic23", }, .probe = aic23_spi_probe, - .remove = aic23_spi_remove, }; module_spi_driver(aic23_spi); diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 74909211c608..47480cb4d078 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c @@ -82,7 +82,7 @@ static const DECLARE_TLV_DB_SCALE(sidetone_vol_tlv, -1800, 300, 0); static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); u16 val, reg; val = (ucontrol->value.integer.value[0] & 0x07); @@ -96,8 +96,8 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, */ val = (val >= 4) ? 4 : (3 - val); - reg = snd_soc_read(codec, TLV320AIC23_ANLG) & (~0x1C0); - snd_soc_write(codec, TLV320AIC23_ANLG, reg | (val << 6)); + reg = snd_soc_component_read32(component, TLV320AIC23_ANLG) & (~0x1C0); + snd_soc_component_write(component, TLV320AIC23_ANLG, reg | (val << 6)); return 0; } @@ -105,10 +105,10 @@ static int snd_soc_tlv320aic23_put_volsw(struct snd_kcontrol *kcontrol, static int snd_soc_tlv320aic23_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); u16 val; - val = snd_soc_read(codec, TLV320AIC23_ANLG) & (0x1C0); + val = snd_soc_component_read32(component, TLV320AIC23_ANLG) & (0x1C0); val = val >> 6; val = (val >= 4) ? 4 : (3 - val); ucontrol->value.integer.value[0] = val; @@ -296,10 +296,10 @@ static int find_rate(int mclk, u32 need_adc, u32 need_dac) } #ifdef DEBUG -static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk, +static void get_current_sample_rates(struct snd_soc_component *component, int mclk, u32 *sample_rate_adc, u32 *sample_rate_dac) { - int src = snd_soc_read(codec, TLV320AIC23_SRATE); + int src = snd_soc_component_read32(component, TLV320AIC23_SRATE); int sr = (src >> 2) & 0x0f; int val = (mclk / bosr_usb_divisor_table[src & 3]); int adc = (val * sr_adc_mult_table[sr]) / SR_MULT; @@ -313,7 +313,7 @@ static void get_current_sample_rates(struct snd_soc_codec *codec, int mclk, } #endif -static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk, +static int set_sample_rate_control(struct snd_soc_component *component, int mclk, u32 sample_rate_adc, u32 sample_rate_dac) { /* Search for the right sample rate */ @@ -323,11 +323,11 @@ static int set_sample_rate_control(struct snd_soc_codec *codec, int mclk, __func__, sample_rate_adc, sample_rate_dac); return -EINVAL; } - snd_soc_write(codec, TLV320AIC23_SRATE, data); + snd_soc_component_write(component, TLV320AIC23_SRATE, data); #ifdef DEBUG { u32 adc, dac; - get_current_sample_rates(codec, mclk, &adc, &dac); + get_current_sample_rates(component, mclk, &adc, &dac); printk(KERN_DEBUG "actual samplerate = %u,%u reg=%x\n", adc, dac, data); } @@ -339,10 +339,10 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 iface_reg; int ret; - struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); + struct aic23 *aic23 = snd_soc_component_get_drvdata(component); u32 sample_rate_adc = aic23->requested_adc; u32 sample_rate_dac = aic23->requested_dac; u32 sample_rate = params_rate(params); @@ -356,12 +356,12 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, if (!sample_rate_dac) sample_rate_dac = sample_rate; } - ret = set_sample_rate_control(codec, aic23->mclk, sample_rate_adc, + ret = set_sample_rate_control(component, aic23->mclk, sample_rate_adc, sample_rate_dac); if (ret < 0) return ret; - iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); + iface_reg = snd_soc_component_read32(component, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); switch (params_width(params)) { case 16: @@ -376,7 +376,7 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, iface_reg |= (0x03 << 2); break; } - snd_soc_write(codec, TLV320AIC23_DIGT_FMT, iface_reg); + snd_soc_component_write(component, TLV320AIC23_DIGT_FMT, iface_reg); return 0; } @@ -384,10 +384,10 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; /* set active */ - snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0001); + snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0001); return 0; } @@ -395,13 +395,13 @@ static int tlv320aic23_pcm_prepare(struct snd_pcm_substream *substream, static void tlv320aic23_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct aic23 *aic23 = snd_soc_component_get_drvdata(component); /* deactivate */ - if (!snd_soc_codec_is_active(codec)) { + if (!snd_soc_component_is_active(component)) { udelay(50); - snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0); + snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0); } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) aic23->requested_dac = 0; @@ -411,17 +411,17 @@ static void tlv320aic23_shutdown(struct snd_pcm_substream *substream, static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 reg; - reg = snd_soc_read(codec, TLV320AIC23_DIGT); + reg = snd_soc_component_read32(component, TLV320AIC23_DIGT); if (mute) reg |= TLV320AIC23_DACM_MUTE; else reg &= ~TLV320AIC23_DACM_MUTE; - snd_soc_write(codec, TLV320AIC23_DIGT, reg); + snd_soc_component_write(component, TLV320AIC23_DIGT, reg); return 0; } @@ -429,10 +429,10 @@ static int tlv320aic23_mute(struct snd_soc_dai *dai, int mute) static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface_reg; - iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & (~0x03); + iface_reg = snd_soc_component_read32(component, TLV320AIC23_DIGT_FMT) & (~0x03); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -468,7 +468,7 @@ static int tlv320aic23_set_dai_fmt(struct snd_soc_dai *codec_dai, } - snd_soc_write(codec, TLV320AIC23_DIGT_FMT, iface_reg); + snd_soc_component_write(component, TLV320AIC23_DIGT_FMT, iface_reg); return 0; } @@ -481,29 +481,29 @@ static int tlv320aic23_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } -static int tlv320aic23_set_bias_level(struct snd_soc_codec *codec, +static int tlv320aic23_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - u16 reg = snd_soc_read(codec, TLV320AIC23_PWR) & 0x17f; + u16 reg = snd_soc_component_read32(component, TLV320AIC23_PWR) & 0x17f; switch (level) { case SND_SOC_BIAS_ON: /* vref/mid, osc on, dac unmute */ reg &= ~(TLV320AIC23_DEVICE_PWR_OFF | TLV320AIC23_OSC_OFF | \ TLV320AIC23_DAC_OFF); - snd_soc_write(codec, TLV320AIC23_PWR, reg); + snd_soc_component_write(component, TLV320AIC23_PWR, reg); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: /* everything off except vref/vmid, */ - snd_soc_write(codec, TLV320AIC23_PWR, + snd_soc_component_write(component, TLV320AIC23_PWR, reg | TLV320AIC23_CLK_OFF); break; case SND_SOC_BIAS_OFF: /* everything off, dac mute, inactive */ - snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x0); - snd_soc_write(codec, TLV320AIC23_PWR, 0x1ff); + snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x0); + snd_soc_component_write(component, TLV320AIC23_PWR, 0x1ff); break; } return 0; @@ -539,58 +539,59 @@ static struct snd_soc_dai_driver tlv320aic23_dai = { .ops = &tlv320aic23_dai_ops, }; -static int tlv320aic23_resume(struct snd_soc_codec *codec) +static int tlv320aic23_resume(struct snd_soc_component *component) { - struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); + struct aic23 *aic23 = snd_soc_component_get_drvdata(component); regcache_mark_dirty(aic23->regmap); regcache_sync(aic23->regmap); return 0; } -static int tlv320aic23_codec_probe(struct snd_soc_codec *codec) +static int tlv320aic23_component_probe(struct snd_soc_component *component) { /* Reset codec */ - snd_soc_write(codec, TLV320AIC23_RESET, 0); + snd_soc_component_write(component, TLV320AIC23_RESET, 0); - snd_soc_write(codec, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K); + snd_soc_component_write(component, TLV320AIC23_DIGT, TLV320AIC23_DEEMP_44K); /* Unmute input */ - snd_soc_update_bits(codec, TLV320AIC23_LINVOL, + snd_soc_component_update_bits(component, TLV320AIC23_LINVOL, TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED); - snd_soc_update_bits(codec, TLV320AIC23_RINVOL, + snd_soc_component_update_bits(component, TLV320AIC23_RINVOL, TLV320AIC23_LIM_MUTED, TLV320AIC23_LRS_ENABLED); - snd_soc_update_bits(codec, TLV320AIC23_ANLG, + snd_soc_component_update_bits(component, TLV320AIC23_ANLG, TLV320AIC23_BYPASS_ON | TLV320AIC23_MICM_MUTED, 0); /* Default output volume */ - snd_soc_write(codec, TLV320AIC23_LCHNVOL, + snd_soc_component_write(component, TLV320AIC23_LCHNVOL, TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK); - snd_soc_write(codec, TLV320AIC23_RCHNVOL, + snd_soc_component_write(component, TLV320AIC23_RCHNVOL, TLV320AIC23_DEFAULT_OUT_VOL & TLV320AIC23_OUT_VOL_MASK); - snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1); + snd_soc_component_write(component, TLV320AIC23_ACTIVE, 0x1); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { - .probe = tlv320aic23_codec_probe, - .resume = tlv320aic23_resume, - .set_bias_level = tlv320aic23_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = tlv320aic23_snd_controls, - .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls), - .dapm_widgets = tlv320aic23_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), - .dapm_routes = tlv320aic23_intercon, - .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_tlv320aic23 = { + .probe = tlv320aic23_component_probe, + .resume = tlv320aic23_resume, + .set_bias_level = tlv320aic23_set_bias_level, + .controls = tlv320aic23_snd_controls, + .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls), + .dapm_widgets = tlv320aic23_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), + .dapm_routes = tlv320aic23_intercon, + .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; int tlv320aic23_probe(struct device *dev, struct regmap *regmap) @@ -608,7 +609,8 @@ int tlv320aic23_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, aic23); - return snd_soc_register_codec(dev, &soc_codec_dev_tlv320aic23, + return devm_snd_soc_register_component(dev, + &soc_component_dev_tlv320aic23, &tlv320aic23_dai, 1); } EXPORT_SYMBOL(tlv320aic23_probe); From 1514613a7a4480e40f40a2d41527292fece8b362 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:13:13 +0000 Subject: [PATCH 113/942] ASoC: tlv320aic26: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic26.c | 83 ++++++++++++++++------------------ 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 89421caaeb70..b91b8d5f1ba3 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c @@ -30,7 +30,7 @@ MODULE_LICENSE("GPL"); struct aic26 { struct spi_device *spi; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int master; int datfm; int mclk; @@ -64,8 +64,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct aic26 *aic26 = snd_soc_component_get_drvdata(component); int fsref, divisor, wlen, pval, jval, dval, qval; u16 reg; @@ -112,20 +112,20 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, dev_dbg(&aic26->spi->dev, "Setting PLLM to %d.%04d\n", jval, dval); qval = 0; reg = 0x8000 | qval << 11 | pval << 8 | jval << 2; - snd_soc_write(codec, AIC26_REG_PLL_PROG1, reg); + snd_soc_component_write(component, AIC26_REG_PLL_PROG1, reg); reg = dval << 2; - snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); + snd_soc_component_write(component, AIC26_REG_PLL_PROG2, reg); /* Audio Control 3 (master mode, fsref rate) */ if (aic26->master) reg = 0x0800; if (fsref == 48000) reg = 0x2000; - snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); + snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); /* Audio Control 1 (FSref divisor) */ reg = wlen | aic26->datfm | (divisor << 3) | divisor; - snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); + snd_soc_component_update_bits(component, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); return 0; } @@ -135,8 +135,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, */ static int aic26_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct aic26 *aic26 = snd_soc_component_get_drvdata(component); u16 reg; dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", @@ -146,7 +146,7 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) reg = 0x8080; else reg = 0; - snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg); + snd_soc_component_update_bits(component, AIC26_REG_DAC_GAIN, 0x8000, reg); return 0; } @@ -154,8 +154,8 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic26 *aic26 = snd_soc_component_get_drvdata(component); dev_dbg(&aic26->spi->dev, "aic26_set_sysclk(dai=%p, clk_id==%i," " freq=%i, dir=%i)\n", @@ -171,8 +171,8 @@ static int aic26_set_sysclk(struct snd_soc_dai *codec_dai, static int aic26_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic26 *aic26 = snd_soc_component_get_drvdata(component); dev_dbg(&aic26->spi->dev, "aic26_set_fmt(dai=%p, fmt==%i)\n", codec_dai, fmt); @@ -265,7 +265,7 @@ static ssize_t aic26_keyclick_show(struct device *dev, struct aic26 *aic26 = dev_get_drvdata(dev); int val, amp, freq, len; - val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2); + val = snd_soc_component_read32(aic26->component, AIC26_REG_AUDIO_CTRL2); amp = (val >> 12) & 0x7; freq = (125 << ((val >> 8) & 0x7)) >> 1; len = 2 * (1 + ((val >> 4) & 0xf)); @@ -280,7 +280,7 @@ static ssize_t aic26_keyclick_set(struct device *dev, { struct aic26 *aic26 = dev_get_drvdata(dev); - snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2, + snd_soc_component_update_bits(aic26->component, AIC26_REG_AUDIO_CTRL2, 0x8000, 0x800); return count; @@ -291,44 +291,46 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); /* --------------------------------------------------------------------- * SoC CODEC portion of driver: probe and release routines */ -static int aic26_probe(struct snd_soc_codec *codec) +static int aic26_probe(struct snd_soc_component *component) { - struct aic26 *aic26 = dev_get_drvdata(codec->dev); + struct aic26 *aic26 = dev_get_drvdata(component->dev); int ret, reg; - aic26->codec = codec; + aic26->component = component; /* Reset the codec to power on defaults */ - snd_soc_write(codec, AIC26_REG_RESET, 0xBB00); + snd_soc_component_write(component, AIC26_REG_RESET, 0xBB00); /* Power up CODEC */ - snd_soc_write(codec, AIC26_REG_POWER_CTRL, 0); + snd_soc_component_write(component, AIC26_REG_POWER_CTRL, 0); /* Audio Control 3 (master mode, fsref rate) */ - reg = snd_soc_read(codec, AIC26_REG_AUDIO_CTRL3); + reg = snd_soc_component_read32(component, AIC26_REG_AUDIO_CTRL3); reg &= ~0xf800; reg |= 0x0800; /* set master mode */ - snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); + snd_soc_component_write(component, AIC26_REG_AUDIO_CTRL3, reg); /* Register the sysfs files for debugging */ /* Create SysFS files */ - ret = device_create_file(codec->dev, &dev_attr_keyclick); + ret = device_create_file(component->dev, &dev_attr_keyclick); if (ret) - dev_info(codec->dev, "error creating sysfs files\n"); + dev_info(component->dev, "error creating sysfs files\n"); return 0; } -static const struct snd_soc_codec_driver aic26_soc_codec_dev = { - .probe = aic26_probe, - .component_driver = { - .controls = aic26_snd_controls, - .num_controls = ARRAY_SIZE(aic26_snd_controls), - .dapm_widgets = tlv320aic26_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), - .dapm_routes = tlv320aic26_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), - }, +static const struct snd_soc_component_driver aic26_soc_component_dev = { + .probe = aic26_probe, + .controls = aic26_snd_controls, + .num_controls = ARRAY_SIZE(aic26_snd_controls), + .dapm_widgets = tlv320aic26_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), + .dapm_routes = tlv320aic26_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config aic26_regmap = { @@ -361,23 +363,16 @@ static int aic26_spi_probe(struct spi_device *spi) dev_set_drvdata(&spi->dev, aic26); aic26->master = 1; - ret = snd_soc_register_codec(&spi->dev, - &aic26_soc_codec_dev, &aic26_dai, 1); + ret = devm_snd_soc_register_component(&spi->dev, + &aic26_soc_component_dev, &aic26_dai, 1); return ret; } -static int aic26_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver aic26_spi = { .driver = { .name = "tlv320aic26-codec", }, .probe = aic26_spi_probe, - .remove = aic26_spi_remove, }; module_spi_driver(aic26_spi); From 749ad545e3735270036c65e1199b8f3b8cda09e6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:13:54 +0000 Subject: [PATCH 114/942] ASoC: tlv320aic3x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 293 ++++++++++++++++----------------- 1 file changed, 145 insertions(+), 148 deletions(-) diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index b751cad545da..dbfa0d8f11a3 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -72,7 +72,7 @@ struct aic3x_disable_nb { /* codec private data */ struct aic3x_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *regmap; struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; struct aic3x_disable_nb disable_nb[AIC3X_NUM_SUPPLIES]; @@ -162,8 +162,8 @@ static const struct regmap_config aic3x_regmap = { static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int reg = mc->reg; @@ -189,7 +189,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, mask <<= shift; val <<= shift; - change = snd_soc_test_bits(codec, reg, mask, val); + change = snd_soc_component_test_bits(component, reg, mask, val); if (change) { update.kcontrol = kcontrol; update.reg = reg; @@ -215,19 +215,19 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* change mic bias voltage to user defined */ - snd_soc_update_bits(codec, MICBIAS_CTRL, + snd_soc_component_update_bits(component, MICBIAS_CTRL, MICBIAS_LEVEL_MASK, aic3x->micbias_vg << MICBIAS_LEVEL_SHIFT); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, MICBIAS_CTRL, + snd_soc_component_update_bits(component, MICBIAS_CTRL, MICBIAS_LEVEL_MASK, 0); break; } @@ -993,10 +993,10 @@ static const struct snd_soc_dapm_route intercon_3007[] = { {"SPOM", NULL, "Right Class-D Out"}, }; -static int aic3x_add_widgets(struct snd_soc_codec *codec) +static int aic3x_add_widgets(struct snd_soc_component *component) { - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); switch (aic3x->model) { case AIC3X_MODEL_3X: @@ -1035,8 +1035,8 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); int codec_clk = 0, bypass_pll = 0, fsref, last_clk = 0; u8 data, j, r, p, pll_q, pll_p = 1, pll_r = 1, pll_j = 1; u16 d, pll_d = 1; @@ -1047,7 +1047,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, width = params_width(params); /* select data word length */ - data = snd_soc_read(codec, AIC3X_ASD_INTF_CTRLB) & (~(0x3 << 4)); + data = snd_soc_component_read32(component, AIC3X_ASD_INTF_CTRLB) & (~(0x3 << 4)); switch (width) { case 16: break; @@ -1061,7 +1061,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, data |= (0x03 << 4); break; } - snd_soc_write(codec, AIC3X_ASD_INTF_CTRLB, data); + snd_soc_component_write(component, AIC3X_ASD_INTF_CTRLB, data); /* Fsref can be 44100 or 48000 */ fsref = (params_rate(params) % 11025 == 0) ? 44100 : 48000; @@ -1076,15 +1076,15 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, if (bypass_pll) { pll_q &= 0xf; - snd_soc_write(codec, AIC3X_PLL_PROGA_REG, pll_q << PLLQ_SHIFT); - snd_soc_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_CLKDIV); + snd_soc_component_write(component, AIC3X_PLL_PROGA_REG, pll_q << PLLQ_SHIFT); + snd_soc_component_write(component, AIC3X_GPIOB_REG, CODEC_CLKIN_CLKDIV); /* disable PLL if it is bypassed */ - snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, PLL_ENABLE, 0); + snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, PLL_ENABLE, 0); } else { - snd_soc_write(codec, AIC3X_GPIOB_REG, CODEC_CLKIN_PLLDIV); + snd_soc_component_write(component, AIC3X_GPIOB_REG, CODEC_CLKIN_PLLDIV); /* enable PLL when it is used */ - snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, + snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, PLL_ENABLE, PLL_ENABLE); } @@ -1094,7 +1094,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, data |= (fsref == 44100) ? FSREF_44100 : FSREF_48000; if (params_rate(params) >= 64000) data |= DUAL_RATE_MODE; - snd_soc_write(codec, AIC3X_CODEC_DATAPATH_REG, data); + snd_soc_component_write(component, AIC3X_CODEC_DATAPATH_REG, data); /* codec sample rate select */ data = (fsref * 20) / params_rate(params); @@ -1103,7 +1103,7 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, data /= 5; data -= 2; data |= (data << 4); - snd_soc_write(codec, AIC3X_SAMPLE_RATE_SEL_REG, data); + snd_soc_component_write(component, AIC3X_SAMPLE_RATE_SEL_REG, data); if (bypass_pll) return 0; @@ -1172,13 +1172,13 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, } found: - snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, PLLP_MASK, pll_p); - snd_soc_write(codec, AIC3X_OVRF_STATUS_AND_PLLR_REG, + snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, PLLP_MASK, pll_p); + snd_soc_component_write(component, AIC3X_OVRF_STATUS_AND_PLLR_REG, pll_r << PLLR_SHIFT); - snd_soc_write(codec, AIC3X_PLL_PROGB_REG, pll_j << PLLJ_SHIFT); - snd_soc_write(codec, AIC3X_PLL_PROGC_REG, + snd_soc_component_write(component, AIC3X_PLL_PROGB_REG, pll_j << PLLJ_SHIFT); + snd_soc_component_write(component, AIC3X_PLL_PROGC_REG, (pll_d >> 6) << PLLD_MSB_SHIFT); - snd_soc_write(codec, AIC3X_PLL_PROGD_REG, + snd_soc_component_write(component, AIC3X_PLL_PROGD_REG, (pll_d & 0x3F) << PLLD_LSB_SHIFT); return 0; @@ -1187,8 +1187,8 @@ found: static int aic3x_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); int delay = 0; int width = aic3x->slot_width; @@ -1202,23 +1202,23 @@ static int aic3x_prepare(struct snd_pcm_substream *substream, delay += aic3x->tdm_delay*width; /* Configure data delay */ - snd_soc_write(codec, AIC3X_ASD_INTF_CTRLC, delay); + snd_soc_component_write(component, AIC3X_ASD_INTF_CTRLC, delay); return 0; } static int aic3x_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - u8 ldac_reg = snd_soc_read(codec, LDAC_VOL) & ~MUTE_ON; - u8 rdac_reg = snd_soc_read(codec, RDAC_VOL) & ~MUTE_ON; + struct snd_soc_component *component = dai->component; + u8 ldac_reg = snd_soc_component_read32(component, LDAC_VOL) & ~MUTE_ON; + u8 rdac_reg = snd_soc_component_read32(component, RDAC_VOL) & ~MUTE_ON; if (mute) { - snd_soc_write(codec, LDAC_VOL, ldac_reg | MUTE_ON); - snd_soc_write(codec, RDAC_VOL, rdac_reg | MUTE_ON); + snd_soc_component_write(component, LDAC_VOL, ldac_reg | MUTE_ON); + snd_soc_component_write(component, RDAC_VOL, rdac_reg | MUTE_ON); } else { - snd_soc_write(codec, LDAC_VOL, ldac_reg); - snd_soc_write(codec, RDAC_VOL, rdac_reg); + snd_soc_component_write(component, LDAC_VOL, ldac_reg); + snd_soc_component_write(component, RDAC_VOL, rdac_reg); } return 0; @@ -1227,13 +1227,13 @@ static int aic3x_mute(struct snd_soc_dai *dai, int mute) static int aic3x_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); /* set clock on MCLK or GPIO2 or BCLK */ - snd_soc_update_bits(codec, AIC3X_CLKGEN_CTRL_REG, PLLCLK_IN_MASK, + snd_soc_component_update_bits(component, AIC3X_CLKGEN_CTRL_REG, PLLCLK_IN_MASK, clk_id << PLLCLK_IN_SHIFT); - snd_soc_update_bits(codec, AIC3X_CLKGEN_CTRL_REG, CLKDIV_IN_MASK, + snd_soc_component_update_bits(component, AIC3X_CLKGEN_CTRL_REG, CLKDIV_IN_MASK, clk_id << CLKDIV_IN_SHIFT); aic3x->sysclk = freq; @@ -1243,12 +1243,12 @@ static int aic3x_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int aic3x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); u8 iface_areg, iface_breg; - iface_areg = snd_soc_read(codec, AIC3X_ASD_INTF_CTRLA) & 0x3f; - iface_breg = snd_soc_read(codec, AIC3X_ASD_INTF_CTRLB) & 0x3f; + iface_areg = snd_soc_component_read32(component, AIC3X_ASD_INTF_CTRLA) & 0x3f; + iface_breg = snd_soc_component_read32(component, AIC3X_ASD_INTF_CTRLB) & 0x3f; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1289,8 +1289,8 @@ static int aic3x_set_dai_fmt(struct snd_soc_dai *codec_dai, aic3x->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; /* set iface */ - snd_soc_write(codec, AIC3X_ASD_INTF_CTRLA, iface_areg); - snd_soc_write(codec, AIC3X_ASD_INTF_CTRLB, iface_breg); + snd_soc_component_write(component, AIC3X_ASD_INTF_CTRLA, iface_areg); + snd_soc_component_write(component, AIC3X_ASD_INTF_CTRLB, iface_breg); return 0; } @@ -1299,24 +1299,24 @@ static int aic3x_set_dai_tdm_slot(struct snd_soc_dai *codec_dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); unsigned int lsb; if (tx_mask != rx_mask) { - dev_err(codec->dev, "tx and rx masks must be symmetric\n"); + dev_err(component->dev, "tx and rx masks must be symmetric\n"); return -EINVAL; } if (unlikely(!tx_mask)) { - dev_err(codec->dev, "tx and rx masks need to be non 0\n"); + dev_err(component->dev, "tx and rx masks need to be non 0\n"); return -EINVAL; } /* TDM based on DSP mode requires slots to be adjacent */ lsb = __ffs(tx_mask); if ((lsb + 1) != __fls(tx_mask)) { - dev_err(codec->dev, "Invalid mask, slots must be adjacent\n"); + dev_err(component->dev, "Invalid mask, slots must be adjacent\n"); return -EINVAL; } @@ -1327,7 +1327,7 @@ static int aic3x_set_dai_tdm_slot(struct snd_soc_dai *codec_dai, case 32: break; default: - dev_err(codec->dev, "Unsupported slot width %d\n", slot_width); + dev_err(component->dev, "Unsupported slot width %d\n", slot_width); return -EINVAL; } @@ -1336,7 +1336,7 @@ static int aic3x_set_dai_tdm_slot(struct snd_soc_dai *codec_dai, aic3x->slot_width = slot_width; /* DOUT in high-impedance on inactive bit clocks */ - snd_soc_update_bits(codec, AIC3X_ASD_INTF_CTRLA, + snd_soc_component_update_bits(component, AIC3X_ASD_INTF_CTRLA, DOUT_TRISTATE, DOUT_TRISTATE); return 0; @@ -1362,9 +1362,9 @@ static int aic3x_regulator_event(struct notifier_block *nb, return 0; } -static int aic3x_set_power(struct snd_soc_codec *codec, int power) +static int aic3x_set_power(struct snd_soc_component *component, int power) { - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); unsigned int pll_c, pll_d; int ret; @@ -1388,12 +1388,12 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) * writing one of them and thus caused other one also not * being written */ - pll_c = snd_soc_read(codec, AIC3X_PLL_PROGC_REG); - pll_d = snd_soc_read(codec, AIC3X_PLL_PROGD_REG); + pll_c = snd_soc_component_read32(component, AIC3X_PLL_PROGC_REG); + pll_d = snd_soc_component_read32(component, AIC3X_PLL_PROGD_REG); if (pll_c == aic3x_reg[AIC3X_PLL_PROGC_REG].def || pll_d == aic3x_reg[AIC3X_PLL_PROGD_REG].def) { - snd_soc_write(codec, AIC3X_PLL_PROGC_REG, pll_c); - snd_soc_write(codec, AIC3X_PLL_PROGD_REG, pll_d); + snd_soc_component_write(component, AIC3X_PLL_PROGC_REG, pll_c); + snd_soc_component_write(component, AIC3X_PLL_PROGD_REG, pll_d); } /* @@ -1407,7 +1407,7 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) * possible VDD leakage currents in case the supply regulators * remain on */ - snd_soc_write(codec, AIC3X_RESET, SOFT_RESET); + snd_soc_component_write(component, AIC3X_RESET, SOFT_RESET); regcache_mark_dirty(aic3x->regmap); aic3x->power = 0; /* HW writes are needless when bias is off */ @@ -1419,35 +1419,35 @@ out: return ret; } -static int aic3x_set_bias_level(struct snd_soc_codec *codec, +static int aic3x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY && + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY && aic3x->master) { /* enable pll */ - snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, + snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, PLL_ENABLE, PLL_ENABLE); } break; case SND_SOC_BIAS_STANDBY: if (!aic3x->power) - aic3x_set_power(codec, 1); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE && + aic3x_set_power(component, 1); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE && aic3x->master) { /* disable pll */ - snd_soc_update_bits(codec, AIC3X_PLL_PROGA_REG, + snd_soc_component_update_bits(component, AIC3X_PLL_PROGA_REG, PLL_ENABLE, 0); } break; case SND_SOC_BIAS_OFF: if (aic3x->power) - aic3x_set_power(codec, 0); + aic3x_set_power(component, 0); break; } @@ -1486,96 +1486,96 @@ static struct snd_soc_dai_driver aic3x_dai = { .symmetric_rates = 1, }; -static void aic3x_mono_init(struct snd_soc_codec *codec) +static void aic3x_mono_init(struct snd_soc_component *component) { /* DAC to Mono Line Out default volume and route to Output mixer */ - snd_soc_write(codec, DACL1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); - snd_soc_write(codec, DACR1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACL1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACR1_2_MONOLOPM_VOL, DEFAULT_VOL | ROUTE_ON); /* unmute all outputs */ - snd_soc_update_bits(codec, MONOLOPM_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, MONOLOPM_CTRL, UNMUTE, UNMUTE); /* PGA to Mono Line Out default volume, disconnect from Output Mixer */ - snd_soc_write(codec, PGAL_2_MONOLOPM_VOL, DEFAULT_VOL); - snd_soc_write(codec, PGAR_2_MONOLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAL_2_MONOLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAR_2_MONOLOPM_VOL, DEFAULT_VOL); /* Line2 to Mono Out default volume, disconnect from Output Mixer */ - snd_soc_write(codec, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); - snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2L_2_MONOLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); } /* * initialise the AIC3X driver * register the mixer and dsp interfaces with the kernel */ -static int aic3x_init(struct snd_soc_codec *codec) +static int aic3x_init(struct snd_soc_component *component) { - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); - snd_soc_write(codec, AIC3X_PAGE_SELECT, PAGE0_SELECT); - snd_soc_write(codec, AIC3X_RESET, SOFT_RESET); + snd_soc_component_write(component, AIC3X_PAGE_SELECT, PAGE0_SELECT); + snd_soc_component_write(component, AIC3X_RESET, SOFT_RESET); /* DAC default volume and mute */ - snd_soc_write(codec, LDAC_VOL, DEFAULT_VOL | MUTE_ON); - snd_soc_write(codec, RDAC_VOL, DEFAULT_VOL | MUTE_ON); + snd_soc_component_write(component, LDAC_VOL, DEFAULT_VOL | MUTE_ON); + snd_soc_component_write(component, RDAC_VOL, DEFAULT_VOL | MUTE_ON); /* DAC to HP default volume and route to Output mixer */ - snd_soc_write(codec, DACL1_2_HPLOUT_VOL, DEFAULT_VOL | ROUTE_ON); - snd_soc_write(codec, DACR1_2_HPROUT_VOL, DEFAULT_VOL | ROUTE_ON); - snd_soc_write(codec, DACL1_2_HPLCOM_VOL, DEFAULT_VOL | ROUTE_ON); - snd_soc_write(codec, DACR1_2_HPRCOM_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACL1_2_HPLOUT_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACR1_2_HPROUT_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACL1_2_HPLCOM_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACR1_2_HPRCOM_VOL, DEFAULT_VOL | ROUTE_ON); /* DAC to Line Out default volume and route to Output mixer */ - snd_soc_write(codec, DACL1_2_LLOPM_VOL, DEFAULT_VOL | ROUTE_ON); - snd_soc_write(codec, DACR1_2_RLOPM_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACL1_2_LLOPM_VOL, DEFAULT_VOL | ROUTE_ON); + snd_soc_component_write(component, DACR1_2_RLOPM_VOL, DEFAULT_VOL | ROUTE_ON); /* unmute all outputs */ - snd_soc_update_bits(codec, LLOPM_CTRL, UNMUTE, UNMUTE); - snd_soc_update_bits(codec, RLOPM_CTRL, UNMUTE, UNMUTE); - snd_soc_update_bits(codec, HPLOUT_CTRL, UNMUTE, UNMUTE); - snd_soc_update_bits(codec, HPROUT_CTRL, UNMUTE, UNMUTE); - snd_soc_update_bits(codec, HPLCOM_CTRL, UNMUTE, UNMUTE); - snd_soc_update_bits(codec, HPRCOM_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, LLOPM_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, RLOPM_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, HPLOUT_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, HPROUT_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, HPLCOM_CTRL, UNMUTE, UNMUTE); + snd_soc_component_update_bits(component, HPRCOM_CTRL, UNMUTE, UNMUTE); /* ADC default volume and unmute */ - snd_soc_write(codec, LADC_VOL, DEFAULT_GAIN); - snd_soc_write(codec, RADC_VOL, DEFAULT_GAIN); + snd_soc_component_write(component, LADC_VOL, DEFAULT_GAIN); + snd_soc_component_write(component, RADC_VOL, DEFAULT_GAIN); /* By default route Line1 to ADC PGA mixer */ - snd_soc_write(codec, LINE1L_2_LADC_CTRL, 0x0); - snd_soc_write(codec, LINE1R_2_RADC_CTRL, 0x0); + snd_soc_component_write(component, LINE1L_2_LADC_CTRL, 0x0); + snd_soc_component_write(component, LINE1R_2_RADC_CTRL, 0x0); /* PGA to HP Bypass default volume, disconnect from Output Mixer */ - snd_soc_write(codec, PGAL_2_HPLOUT_VOL, DEFAULT_VOL); - snd_soc_write(codec, PGAR_2_HPROUT_VOL, DEFAULT_VOL); - snd_soc_write(codec, PGAL_2_HPLCOM_VOL, DEFAULT_VOL); - snd_soc_write(codec, PGAR_2_HPRCOM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAL_2_HPLOUT_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAR_2_HPROUT_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAL_2_HPLCOM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAR_2_HPRCOM_VOL, DEFAULT_VOL); /* PGA to Line Out default volume, disconnect from Output Mixer */ - snd_soc_write(codec, PGAL_2_LLOPM_VOL, DEFAULT_VOL); - snd_soc_write(codec, PGAR_2_RLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAL_2_LLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, PGAR_2_RLOPM_VOL, DEFAULT_VOL); /* On tlv320aic3104, these registers are reserved and must not be written */ if (aic3x->model != AIC3X_MODEL_3104) { /* Line2 to HP Bypass default volume, disconnect from Output Mixer */ - snd_soc_write(codec, LINE2L_2_HPLOUT_VOL, DEFAULT_VOL); - snd_soc_write(codec, LINE2R_2_HPROUT_VOL, DEFAULT_VOL); - snd_soc_write(codec, LINE2L_2_HPLCOM_VOL, DEFAULT_VOL); - snd_soc_write(codec, LINE2R_2_HPRCOM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2L_2_HPLOUT_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2R_2_HPROUT_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2L_2_HPLCOM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2R_2_HPRCOM_VOL, DEFAULT_VOL); /* Line2 Line Out default volume, disconnect from Output Mixer */ - snd_soc_write(codec, LINE2L_2_LLOPM_VOL, DEFAULT_VOL); - snd_soc_write(codec, LINE2R_2_RLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2L_2_LLOPM_VOL, DEFAULT_VOL); + snd_soc_component_write(component, LINE2R_2_RLOPM_VOL, DEFAULT_VOL); } switch (aic3x->model) { case AIC3X_MODEL_3X: case AIC3X_MODEL_33: - aic3x_mono_init(codec); + aic3x_mono_init(component); break; case AIC3X_MODEL_3007: - snd_soc_write(codec, CLASSD_CTRL, 0); + snd_soc_component_write(component, CLASSD_CTRL, 0); break; } /* Output common-mode voltage = 1.5 V */ - snd_soc_update_bits(codec, HPOUT_SC, HPOUT_SC_OCMV_MASK, + snd_soc_component_update_bits(component, HPOUT_SC, HPOUT_SC_OCMV_MASK, aic3x->ocmv << HPOUT_SC_OCMV_SHIFT); return 0; @@ -1594,13 +1594,13 @@ static bool aic3x_is_shared_reset(struct aic3x_priv *aic3x) return false; } -static int aic3x_probe(struct snd_soc_codec *codec) +static int aic3x_probe(struct snd_soc_component *component) { - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); int ret, i; INIT_LIST_HEAD(&aic3x->list); - aic3x->codec = codec; + aic3x->component = component; for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; @@ -1608,7 +1608,7 @@ static int aic3x_probe(struct snd_soc_codec *codec) ret = regulator_register_notifier(aic3x->supplies[i].consumer, &aic3x->disable_nb[i].nb); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to request regulator notifier: %d\n", ret); goto err_notif; @@ -1616,32 +1616,32 @@ static int aic3x_probe(struct snd_soc_codec *codec) } regcache_mark_dirty(aic3x->regmap); - aic3x_init(codec); + aic3x_init(component); if (aic3x->setup) { if (aic3x->model != AIC3X_MODEL_3104) { /* setup GPIO functions */ - snd_soc_write(codec, AIC3X_GPIO1_REG, + snd_soc_component_write(component, AIC3X_GPIO1_REG, (aic3x->setup->gpio_func[0] & 0xf) << 4); - snd_soc_write(codec, AIC3X_GPIO2_REG, + snd_soc_component_write(component, AIC3X_GPIO2_REG, (aic3x->setup->gpio_func[1] & 0xf) << 4); } else { - dev_warn(codec->dev, "GPIO functionality is not supported on tlv320aic3104\n"); + dev_warn(component->dev, "GPIO functionality is not supported on tlv320aic3104\n"); } } switch (aic3x->model) { case AIC3X_MODEL_3X: case AIC3X_MODEL_33: - snd_soc_add_codec_controls(codec, aic3x_extra_snd_controls, + snd_soc_add_component_controls(component, aic3x_extra_snd_controls, ARRAY_SIZE(aic3x_extra_snd_controls)); - snd_soc_add_codec_controls(codec, aic3x_mono_controls, + snd_soc_add_component_controls(component, aic3x_mono_controls, ARRAY_SIZE(aic3x_mono_controls)); break; case AIC3X_MODEL_3007: - snd_soc_add_codec_controls(codec, aic3x_extra_snd_controls, + snd_soc_add_component_controls(component, aic3x_extra_snd_controls, ARRAY_SIZE(aic3x_extra_snd_controls)); - snd_soc_add_codec_controls(codec, + snd_soc_add_component_controls(component, &aic3x_classd_amp_gain_ctrl, 1); break; case AIC3X_MODEL_3104: @@ -1653,7 +1653,7 @@ static int aic3x_probe(struct snd_soc_codec *codec) case AIC3X_MICBIAS_2_0V: case AIC3X_MICBIAS_2_5V: case AIC3X_MICBIAS_AVDDV: - snd_soc_update_bits(codec, MICBIAS_CTRL, + snd_soc_component_update_bits(component, MICBIAS_CTRL, MICBIAS_LEVEL_MASK, (aic3x->micbias_vg) << MICBIAS_LEVEL_SHIFT); break; @@ -1666,7 +1666,7 @@ static int aic3x_probe(struct snd_soc_codec *codec) break; } - aic3x_add_widgets(codec); + aic3x_add_widgets(component); return 0; @@ -1677,32 +1677,30 @@ err_notif: return ret; } -static int aic3x_remove(struct snd_soc_codec *codec) +static void aic3x_remove(struct snd_soc_component *component) { - struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); + struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); int i; list_del(&aic3x->list); for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) regulator_unregister_notifier(aic3x->supplies[i].consumer, &aic3x->disable_nb[i].nb); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_aic3x = { - .set_bias_level = aic3x_set_bias_level, - .idle_bias_off = true, - .probe = aic3x_probe, - .remove = aic3x_remove, - .component_driver = { - .controls = aic3x_snd_controls, - .num_controls = ARRAY_SIZE(aic3x_snd_controls), - .dapm_widgets = aic3x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_aic3x = { + .set_bias_level = aic3x_set_bias_level, + .probe = aic3x_probe, + .remove = aic3x_remove, + .controls = aic3x_snd_controls, + .num_controls = ARRAY_SIZE(aic3x_snd_controls), + .dapm_widgets = aic3x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void aic3x_configure_ocmv(struct i2c_client *client) @@ -1876,8 +1874,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, ret); } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_aic3x, &aic3x_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_aic3x, &aic3x_dai, 1); if (ret != 0) goto err_gpio; @@ -1898,7 +1896,6 @@ static int aic3x_i2c_remove(struct i2c_client *client) { struct aic3x_priv *aic3x = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); if (gpio_is_valid(aic3x->gpio_reset) && !aic3x_is_shared_reset(aic3x)) { gpio_set_value(aic3x->gpio_reset, 0); From cd21ac8c161ac2a88422387298b30e33ab29012c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:14:21 +0000 Subject: [PATCH 115/942] ASoC: tlv320dac33: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Acked-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320dac33.c | 396 ++++++++++++++++----------------- 1 file changed, 196 insertions(+), 200 deletions(-) diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index 8c71d2f876ff..a957eaeb7bc1 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c @@ -63,9 +63,9 @@ (((samples)*5000) / (((burstrate)*5000) / ((burstrate) - (playrate)))) static void dac33_calculate_times(struct snd_pcm_substream *substream, - struct snd_soc_codec *codec); + struct snd_soc_component *component); static int dac33_prepare_chip(struct snd_pcm_substream *substream, - struct snd_soc_codec *codec); + struct snd_soc_component *component); enum dac33_state { DAC33_IDLE = 0, @@ -91,7 +91,7 @@ static const char *dac33_supply_names[DAC33_NUM_SUPPLIES] = { struct tlv320dac33_priv { struct mutex mutex; struct work_struct work; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regulator_bulk_data supplies[DAC33_NUM_SUPPLIES]; struct snd_pcm_substream *substream; int power_gpio; @@ -171,10 +171,10 @@ static const u8 dac33_reg[DAC33_CACHEREGNUM] = { }; /* Register read and write */ -static inline unsigned int dac33_read_reg_cache(struct snd_soc_codec *codec, +static inline unsigned int dac33_read_reg_cache(struct snd_soc_component *component, unsigned reg) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); u8 *cache = dac33->reg_cache; if (reg >= DAC33_CACHEREGNUM) return 0; @@ -182,10 +182,10 @@ static inline unsigned int dac33_read_reg_cache(struct snd_soc_codec *codec, return cache[reg]; } -static inline void dac33_write_reg_cache(struct snd_soc_codec *codec, +static inline void dac33_write_reg_cache(struct snd_soc_component *component, u8 reg, u8 value) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); u8 *cache = dac33->reg_cache; if (reg >= DAC33_CACHEREGNUM) return; @@ -193,10 +193,10 @@ static inline void dac33_write_reg_cache(struct snd_soc_codec *codec, cache[reg] = value; } -static int dac33_read(struct snd_soc_codec *codec, unsigned int reg, +static int dac33_read(struct snd_soc_component *component, unsigned int reg, u8 *value) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int val, ret = 0; *value = reg & 0xff; @@ -205,24 +205,24 @@ static int dac33_read(struct snd_soc_codec *codec, unsigned int reg, if (dac33->chip_power) { val = i2c_smbus_read_byte_data(dac33->i2c, value[0]); if (val < 0) { - dev_err(codec->dev, "Read failed (%d)\n", val); - value[0] = dac33_read_reg_cache(codec, reg); + dev_err(component->dev, "Read failed (%d)\n", val); + value[0] = dac33_read_reg_cache(component, reg); ret = val; } else { value[0] = val; - dac33_write_reg_cache(codec, reg, val); + dac33_write_reg_cache(component, reg, val); } } else { - value[0] = dac33_read_reg_cache(codec, reg); + value[0] = dac33_read_reg_cache(component, reg); } return ret; } -static int dac33_write(struct snd_soc_codec *codec, unsigned int reg, +static int dac33_write(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); u8 data[2]; int ret = 0; @@ -234,11 +234,11 @@ static int dac33_write(struct snd_soc_codec *codec, unsigned int reg, data[0] = reg & 0xff; data[1] = value & 0xff; - dac33_write_reg_cache(codec, data[0], data[1]); + dac33_write_reg_cache(component, data[0], data[1]); if (dac33->chip_power) { ret = i2c_master_send(dac33->i2c, data, 2); if (ret != 2) - dev_err(codec->dev, "Write failed (%d)\n", ret); + dev_err(component->dev, "Write failed (%d)\n", ret); else ret = 0; } @@ -246,24 +246,24 @@ static int dac33_write(struct snd_soc_codec *codec, unsigned int reg, return ret; } -static int dac33_write_locked(struct snd_soc_codec *codec, unsigned int reg, +static int dac33_write_locked(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&dac33->mutex); - ret = dac33_write(codec, reg, value); + ret = dac33_write(component, reg, value); mutex_unlock(&dac33->mutex); return ret; } #define DAC33_I2C_ADDR_AUTOINC 0x80 -static int dac33_write16(struct snd_soc_codec *codec, unsigned int reg, +static int dac33_write16(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); u8 data[3]; int ret = 0; @@ -277,15 +277,15 @@ static int dac33_write16(struct snd_soc_codec *codec, unsigned int reg, data[1] = (value >> 8) & 0xff; data[2] = value & 0xff; - dac33_write_reg_cache(codec, data[0], data[1]); - dac33_write_reg_cache(codec, data[0] + 1, data[2]); + dac33_write_reg_cache(component, data[0], data[1]); + dac33_write_reg_cache(component, data[0] + 1, data[2]); if (dac33->chip_power) { /* We need to set autoincrement mode for 16 bit writes */ data[0] |= DAC33_I2C_ADDR_AUTOINC; ret = i2c_master_send(dac33->i2c, data, 3); if (ret != 3) - dev_err(codec->dev, "Write failed (%d)\n", ret); + dev_err(component->dev, "Write failed (%d)\n", ret); else ret = 0; } @@ -293,52 +293,52 @@ static int dac33_write16(struct snd_soc_codec *codec, unsigned int reg, return ret; } -static void dac33_init_chip(struct snd_soc_codec *codec) +static void dac33_init_chip(struct snd_soc_component *component) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); if (unlikely(!dac33->chip_power)) return; /* A : DAC sample rate Fsref/1.5 */ - dac33_write(codec, DAC33_DAC_CTRL_A, DAC33_DACRATE(0)); + dac33_write(component, DAC33_DAC_CTRL_A, DAC33_DACRATE(0)); /* B : DAC src=normal, not muted */ - dac33_write(codec, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT | + dac33_write(component, DAC33_DAC_CTRL_B, DAC33_DACSRCR_RIGHT | DAC33_DACSRCL_LEFT); /* C : (defaults) */ - dac33_write(codec, DAC33_DAC_CTRL_C, 0x00); + dac33_write(component, DAC33_DAC_CTRL_C, 0x00); /* 73 : volume soft stepping control, clock source = internal osc (?) */ - dac33_write(codec, DAC33_ANA_VOL_SOFT_STEP_CTRL, DAC33_VOLCLKEN); + dac33_write(component, DAC33_ANA_VOL_SOFT_STEP_CTRL, DAC33_VOLCLKEN); /* Restore only selected registers (gains mostly) */ - dac33_write(codec, DAC33_LDAC_DIG_VOL_CTRL, - dac33_read_reg_cache(codec, DAC33_LDAC_DIG_VOL_CTRL)); - dac33_write(codec, DAC33_RDAC_DIG_VOL_CTRL, - dac33_read_reg_cache(codec, DAC33_RDAC_DIG_VOL_CTRL)); + dac33_write(component, DAC33_LDAC_DIG_VOL_CTRL, + dac33_read_reg_cache(component, DAC33_LDAC_DIG_VOL_CTRL)); + dac33_write(component, DAC33_RDAC_DIG_VOL_CTRL, + dac33_read_reg_cache(component, DAC33_RDAC_DIG_VOL_CTRL)); - dac33_write(codec, DAC33_LINEL_TO_LLO_VOL, - dac33_read_reg_cache(codec, DAC33_LINEL_TO_LLO_VOL)); - dac33_write(codec, DAC33_LINER_TO_RLO_VOL, - dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL)); + dac33_write(component, DAC33_LINEL_TO_LLO_VOL, + dac33_read_reg_cache(component, DAC33_LINEL_TO_LLO_VOL)); + dac33_write(component, DAC33_LINER_TO_RLO_VOL, + dac33_read_reg_cache(component, DAC33_LINER_TO_RLO_VOL)); - dac33_write(codec, DAC33_OUT_AMP_CTRL, - dac33_read_reg_cache(codec, DAC33_OUT_AMP_CTRL)); + dac33_write(component, DAC33_OUT_AMP_CTRL, + dac33_read_reg_cache(component, DAC33_OUT_AMP_CTRL)); - dac33_write(codec, DAC33_LDAC_PWR_CTRL, - dac33_read_reg_cache(codec, DAC33_LDAC_PWR_CTRL)); - dac33_write(codec, DAC33_RDAC_PWR_CTRL, - dac33_read_reg_cache(codec, DAC33_RDAC_PWR_CTRL)); + dac33_write(component, DAC33_LDAC_PWR_CTRL, + dac33_read_reg_cache(component, DAC33_LDAC_PWR_CTRL)); + dac33_write(component, DAC33_RDAC_PWR_CTRL, + dac33_read_reg_cache(component, DAC33_RDAC_PWR_CTRL)); } -static inline int dac33_read_id(struct snd_soc_codec *codec) +static inline int dac33_read_id(struct snd_soc_component *component) { int i, ret = 0; u8 reg; for (i = 0; i < 3; i++) { - ret = dac33_read(codec, DAC33_DEVICE_ID_MSB + i, ®); + ret = dac33_read(component, DAC33_DEVICE_ID_MSB + i, ®); if (ret < 0) break; } @@ -346,44 +346,44 @@ static inline int dac33_read_id(struct snd_soc_codec *codec) return ret; } -static inline void dac33_soft_power(struct snd_soc_codec *codec, int power) +static inline void dac33_soft_power(struct snd_soc_component *component, int power) { u8 reg; - reg = dac33_read_reg_cache(codec, DAC33_PWR_CTRL); + reg = dac33_read_reg_cache(component, DAC33_PWR_CTRL); if (power) reg |= DAC33_PDNALLB; else reg &= ~(DAC33_PDNALLB | DAC33_OSCPDNB | DAC33_DACRPDNB | DAC33_DACLPDNB); - dac33_write(codec, DAC33_PWR_CTRL, reg); + dac33_write(component, DAC33_PWR_CTRL, reg); } -static inline void dac33_disable_digital(struct snd_soc_codec *codec) +static inline void dac33_disable_digital(struct snd_soc_component *component) { u8 reg; /* Stop the DAI clock */ - reg = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B); + reg = dac33_read_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_B); reg &= ~DAC33_BCLKON; - dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, reg); + dac33_write(component, DAC33_SER_AUDIOIF_CTRL_B, reg); /* Power down the Oscillator, and DACs */ - reg = dac33_read_reg_cache(codec, DAC33_PWR_CTRL); + reg = dac33_read_reg_cache(component, DAC33_PWR_CTRL); reg &= ~(DAC33_OSCPDNB | DAC33_DACRPDNB | DAC33_DACLPDNB); - dac33_write(codec, DAC33_PWR_CTRL, reg); + dac33_write(component, DAC33_PWR_CTRL, reg); } -static int dac33_hard_power(struct snd_soc_codec *codec, int power) +static int dac33_hard_power(struct snd_soc_component *component, int power) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int ret = 0; mutex_lock(&dac33->mutex); /* Safety check */ if (unlikely(power == dac33->chip_power)) { - dev_dbg(codec->dev, "Trying to set the same power state: %s\n", + dev_dbg(component->dev, "Trying to set the same power state: %s\n", power ? "ON" : "OFF"); goto exit; } @@ -392,7 +392,7 @@ static int dac33_hard_power(struct snd_soc_codec *codec, int power) ret = regulator_bulk_enable(ARRAY_SIZE(dac33->supplies), dac33->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); goto exit; } @@ -402,14 +402,14 @@ static int dac33_hard_power(struct snd_soc_codec *codec, int power) dac33->chip_power = 1; } else { - dac33_soft_power(codec, 0); + dac33_soft_power(component, 0); if (dac33->power_gpio >= 0) gpio_set_value(dac33->power_gpio, 0); ret = regulator_bulk_disable(ARRAY_SIZE(dac33->supplies), dac33->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to disable supplies: %d\n", ret); goto exit; } @@ -425,18 +425,18 @@ exit: static int dac33_playback_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (likely(dac33->substream)) { - dac33_calculate_times(dac33->substream, codec); - dac33_prepare_chip(dac33->substream, codec); + dac33_calculate_times(dac33->substream, component); + dac33_prepare_chip(dac33->substream, component); } break; case SND_SOC_DAPM_POST_PMD: - dac33_disable_digital(codec); + dac33_disable_digital(component); break; } return 0; @@ -445,8 +445,8 @@ static int dac33_playback_event(struct snd_soc_dapm_widget *w, static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = dac33->fifo_mode; @@ -456,14 +456,14 @@ static int dac33_get_fifo_mode(struct snd_kcontrol *kcontrol, static int dac33_set_fifo_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int ret = 0; if (dac33->fifo_mode == ucontrol->value.enumerated.item[0]) return 0; /* Do not allow changes while stream is running*/ - if (snd_soc_codec_is_active(codec)) + if (snd_soc_component_is_active(component)) return -EPERM; if (ucontrol->value.enumerated.item[0] >= DAC33_FIFO_LAST_MODE) @@ -623,7 +623,7 @@ static const struct snd_soc_dapm_route audio_map[] = { {"RIGHT_LO", NULL, "Codec Power"}, }; -static int dac33_set_bias_level(struct snd_soc_codec *codec, +static int dac33_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; @@ -634,20 +634,20 @@ static int dac33_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - /* Coming from OFF, switch on the codec */ - ret = dac33_hard_power(codec, 1); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + /* Coming from OFF, switch on the component */ + ret = dac33_hard_power(component, 1); if (ret != 0) return ret; - dac33_init_chip(codec); + dac33_init_chip(component); } break; case SND_SOC_BIAS_OFF: - /* Do not power off, when the codec is already off */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + /* Do not power off, when the component is already off */ + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) return 0; - ret = dac33_hard_power(codec, 0); + ret = dac33_hard_power(component, 0); if (ret != 0) return ret; break; @@ -658,13 +658,13 @@ static int dac33_set_bias_level(struct snd_soc_codec *codec, static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) { - struct snd_soc_codec *codec = dac33->codec; + struct snd_soc_component *component = dac33->component; unsigned int delay; unsigned long flags; switch (dac33->fifo_mode) { case DAC33_FIFO_MODE1: - dac33_write16(codec, DAC33_NSAMPLE_MSB, + dac33_write16(component, DAC33_NSAMPLE_MSB, DAC33_THRREG(dac33->nsample)); /* Take the timestamps */ @@ -673,13 +673,13 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) dac33->t_stamp1 = dac33->t_stamp2; spin_unlock_irqrestore(&dac33->lock, flags); - dac33_write16(codec, DAC33_PREFILL_MSB, + dac33_write16(component, DAC33_PREFILL_MSB, DAC33_THRREG(dac33->alarm_threshold)); /* Enable Alarm Threshold IRQ with a delay */ delay = SAMPLES_TO_US(dac33->burst_rate, dac33->alarm_threshold) + 1000; usleep_range(delay, delay + 500); - dac33_write(codec, DAC33_FIFO_IRQ_MASK, DAC33_MAT); + dac33_write(component, DAC33_FIFO_IRQ_MASK, DAC33_MAT); break; case DAC33_FIFO_MODE7: /* Take the timestamp */ @@ -689,14 +689,14 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) dac33->t_stamp1 -= dac33->mode7_us_to_lthr; spin_unlock_irqrestore(&dac33->lock, flags); - dac33_write16(codec, DAC33_PREFILL_MSB, + dac33_write16(component, DAC33_PREFILL_MSB, DAC33_THRREG(DAC33_MODE7_MARGIN)); /* Enable Upper Threshold IRQ */ - dac33_write(codec, DAC33_FIFO_IRQ_MASK, DAC33_MUT); + dac33_write(component, DAC33_FIFO_IRQ_MASK, DAC33_MUT); break; default: - dev_warn(codec->dev, "Unhandled FIFO mode: %d\n", + dev_warn(component->dev, "Unhandled FIFO mode: %d\n", dac33->fifo_mode); break; } @@ -704,7 +704,7 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) static inline void dac33_playback_handler(struct tlv320dac33_priv *dac33) { - struct snd_soc_codec *codec = dac33->codec; + struct snd_soc_component *component = dac33->component; unsigned long flags; switch (dac33->fifo_mode) { @@ -714,14 +714,14 @@ static inline void dac33_playback_handler(struct tlv320dac33_priv *dac33) dac33->t_stamp2 = ktime_to_us(ktime_get()); spin_unlock_irqrestore(&dac33->lock, flags); - dac33_write16(codec, DAC33_NSAMPLE_MSB, + dac33_write16(component, DAC33_NSAMPLE_MSB, DAC33_THRREG(dac33->nsample)); break; case DAC33_FIFO_MODE7: /* At the moment we are not using interrupts in mode7 */ break; default: - dev_warn(codec->dev, "Unhandled FIFO mode: %d\n", + dev_warn(component->dev, "Unhandled FIFO mode: %d\n", dac33->fifo_mode); break; } @@ -729,12 +729,12 @@ static inline void dac33_playback_handler(struct tlv320dac33_priv *dac33) static void dac33_work(struct work_struct *work) { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct tlv320dac33_priv *dac33; u8 reg; dac33 = container_of(work, struct tlv320dac33_priv, work); - codec = dac33->codec; + component = dac33->component; mutex_lock(&dac33->mutex); switch (dac33->state) { @@ -750,12 +750,12 @@ static void dac33_work(struct work_struct *work) case DAC33_FLUSH: dac33->state = DAC33_IDLE; /* Mask all interrupts from dac33 */ - dac33_write(codec, DAC33_FIFO_IRQ_MASK, 0); + dac33_write(component, DAC33_FIFO_IRQ_MASK, 0); /* flush fifo */ - reg = dac33_read_reg_cache(codec, DAC33_FIFO_CTRL_A); + reg = dac33_read_reg_cache(component, DAC33_FIFO_CTRL_A); reg |= DAC33_FIFOFLUSH; - dac33_write(codec, DAC33_FIFO_CTRL_A, reg); + dac33_write(component, DAC33_FIFO_CTRL_A, reg); break; } mutex_unlock(&dac33->mutex); @@ -763,8 +763,8 @@ static void dac33_work(struct work_struct *work) static irqreturn_t dac33_interrupt_handler(int irq, void *dev) { - struct snd_soc_codec *codec = dev; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dev; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); unsigned long flags; spin_lock_irqsave(&dac33->lock, flags); @@ -778,25 +778,25 @@ static irqreturn_t dac33_interrupt_handler(int irq, void *dev) return IRQ_HANDLED; } -static void dac33_oscwait(struct snd_soc_codec *codec) +static void dac33_oscwait(struct snd_soc_component *component) { int timeout = 60; u8 reg; do { usleep_range(1000, 2000); - dac33_read(codec, DAC33_INT_OSC_STATUS, ®); + dac33_read(component, DAC33_INT_OSC_STATUS, ®); } while (((reg & 0x03) != DAC33_OSCSTATUS_NORMAL) && timeout--); if ((reg & 0x03) != DAC33_OSCSTATUS_NORMAL) - dev_err(codec->dev, + dev_err(component->dev, "internal oscillator calibration failed\n"); } static int dac33_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); /* Stream started, save the substream pointer */ dac33->substream = substream; @@ -807,8 +807,8 @@ static int dac33_startup(struct snd_pcm_substream *substream, static void dac33_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); dac33->substream = NULL; } @@ -819,8 +819,8 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); /* Check parameters for validity */ switch (params_rate(params)) { @@ -828,7 +828,7 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "unsupported rate %d\n", + dev_err(component->dev, "unsupported rate %d\n", params_rate(params)); return -EINVAL; } @@ -843,7 +843,7 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, dac33->burst_rate = CALC_BURST_RATE(dac33->burst_bclkdiv, 64); break; default: - dev_err(codec->dev, "unsupported width %d\n", + dev_err(component->dev, "unsupported width %d\n", params_width(params)); return -EINVAL; } @@ -862,9 +862,9 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, * Use the known, working sequence of register writes to initialize the dac33. */ static int dac33_prepare_chip(struct snd_pcm_substream *substream, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); unsigned int oscset, ratioset, pwr_ctrl, reg_tmp; u8 aictrl_a, aictrl_b, fifoctrl_a; @@ -876,16 +876,16 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, dac33->refclk); break; default: - dev_err(codec->dev, "unsupported rate %d\n", + dev_err(component->dev, "unsupported rate %d\n", substream->runtime->rate); return -EINVAL; } - aictrl_a = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_A); + aictrl_a = dac33_read_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_A); aictrl_a &= ~(DAC33_NCYCL_MASK | DAC33_WLEN_MASK); /* Read FIFO control A, and clear FIFO flush bit */ - fifoctrl_a = dac33_read_reg_cache(codec, DAC33_FIFO_CTRL_A); + fifoctrl_a = dac33_read_reg_cache(component, DAC33_FIFO_CTRL_A); fifoctrl_a &= ~DAC33_FIFOFLUSH; fifoctrl_a &= ~DAC33_WIDTH; @@ -898,7 +898,7 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, aictrl_a |= (DAC33_NCYCL_32 | DAC33_WLEN_24); break; default: - dev_err(codec->dev, "unsupported format %d\n", + dev_err(component->dev, "unsupported format %d\n", substream->runtime->format); return -EINVAL; } @@ -914,57 +914,57 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, return 0; } - dac33_soft_power(codec, 0); - dac33_soft_power(codec, 1); + dac33_soft_power(component, 0); + dac33_soft_power(component, 1); - reg_tmp = dac33_read_reg_cache(codec, DAC33_INT_OSC_CTRL); - dac33_write(codec, DAC33_INT_OSC_CTRL, reg_tmp); + reg_tmp = dac33_read_reg_cache(component, DAC33_INT_OSC_CTRL); + dac33_write(component, DAC33_INT_OSC_CTRL, reg_tmp); /* Write registers 0x08 and 0x09 (MSB, LSB) */ - dac33_write16(codec, DAC33_INT_OSC_FREQ_RAT_A, oscset); + dac33_write16(component, DAC33_INT_OSC_FREQ_RAT_A, oscset); /* OSC calibration time */ - dac33_write(codec, DAC33_CALIB_TIME, 96); + dac33_write(component, DAC33_CALIB_TIME, 96); /* adjustment treshold & step */ - dac33_write(codec, DAC33_INT_OSC_CTRL_B, DAC33_ADJTHRSHLD(2) | + dac33_write(component, DAC33_INT_OSC_CTRL_B, DAC33_ADJTHRSHLD(2) | DAC33_ADJSTEP(1)); /* div=4 / gain=1 / div */ - dac33_write(codec, DAC33_INT_OSC_CTRL_C, DAC33_REFDIV(4)); + dac33_write(component, DAC33_INT_OSC_CTRL_C, DAC33_REFDIV(4)); - pwr_ctrl = dac33_read_reg_cache(codec, DAC33_PWR_CTRL); + pwr_ctrl = dac33_read_reg_cache(component, DAC33_PWR_CTRL); pwr_ctrl |= DAC33_OSCPDNB | DAC33_DACRPDNB | DAC33_DACLPDNB; - dac33_write(codec, DAC33_PWR_CTRL, pwr_ctrl); + dac33_write(component, DAC33_PWR_CTRL, pwr_ctrl); - dac33_oscwait(codec); + dac33_oscwait(component); if (dac33->fifo_mode) { /* Generic for all FIFO modes */ /* 50-51 : ASRC Control registers */ - dac33_write(codec, DAC33_ASRC_CTRL_A, DAC33_SRCLKDIV(1)); - dac33_write(codec, DAC33_ASRC_CTRL_B, 1); /* ??? */ + dac33_write(component, DAC33_ASRC_CTRL_A, DAC33_SRCLKDIV(1)); + dac33_write(component, DAC33_ASRC_CTRL_B, 1); /* ??? */ /* Write registers 0x34 and 0x35 (MSB, LSB) */ - dac33_write16(codec, DAC33_SRC_REF_CLK_RATIO_A, ratioset); + dac33_write16(component, DAC33_SRC_REF_CLK_RATIO_A, ratioset); /* Set interrupts to high active */ - dac33_write(codec, DAC33_INTP_CTRL_A, DAC33_INTPM_AHIGH); + dac33_write(component, DAC33_INTP_CTRL_A, DAC33_INTPM_AHIGH); } else { /* FIFO bypass mode */ /* 50-51 : ASRC Control registers */ - dac33_write(codec, DAC33_ASRC_CTRL_A, DAC33_SRCBYP); - dac33_write(codec, DAC33_ASRC_CTRL_B, 0); /* ??? */ + dac33_write(component, DAC33_ASRC_CTRL_A, DAC33_SRCBYP); + dac33_write(component, DAC33_ASRC_CTRL_B, 0); /* ??? */ } /* Interrupt behaviour configuration */ switch (dac33->fifo_mode) { case DAC33_FIFO_MODE1: - dac33_write(codec, DAC33_FIFO_IRQ_MODE_B, + dac33_write(component, DAC33_FIFO_IRQ_MODE_B, DAC33_ATM(DAC33_FIFO_IRQ_MODE_LEVEL)); break; case DAC33_FIFO_MODE7: - dac33_write(codec, DAC33_FIFO_IRQ_MODE_A, + dac33_write(component, DAC33_FIFO_IRQ_MODE_A, DAC33_UTM(DAC33_FIFO_IRQ_MODE_LEVEL)); break; default: @@ -972,7 +972,7 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, break; } - aictrl_b = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B); + aictrl_b = dac33_read_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_B); switch (dac33->fifo_mode) { case DAC33_FIFO_MODE1: @@ -1014,9 +1014,9 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, break; } - dac33_write(codec, DAC33_FIFO_CTRL_A, fifoctrl_a); - dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a); - dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_B, aictrl_b); + dac33_write(component, DAC33_FIFO_CTRL_A, fifoctrl_a); + dac33_write(component, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a); + dac33_write(component, DAC33_SER_AUDIOIF_CTRL_B, aictrl_b); /* * BCLK divide ratio @@ -1028,17 +1028,17 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, * 255: 255 */ if (dac33->fifo_mode) - dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, + dac33_write(component, DAC33_SER_AUDIOIF_CTRL_C, dac33->burst_bclkdiv); else if (substream->runtime->format == SNDRV_PCM_FORMAT_S16_LE) - dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 32); + dac33_write(component, DAC33_SER_AUDIOIF_CTRL_C, 32); else - dac33_write(codec, DAC33_SER_AUDIOIF_CTRL_C, 16); + dac33_write(component, DAC33_SER_AUDIOIF_CTRL_C, 16); switch (dac33->fifo_mode) { case DAC33_FIFO_MODE1: - dac33_write16(codec, DAC33_ATHR_MSB, + dac33_write16(component, DAC33_ATHR_MSB, DAC33_THRREG(dac33->alarm_threshold)); break; case DAC33_FIFO_MODE7: @@ -1046,8 +1046,8 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, * Configure the threshold levels, and leave 10 sample space * at the bottom, and also at the top of the FIFO */ - dac33_write16(codec, DAC33_UTHR_MSB, DAC33_THRREG(dac33->uthr)); - dac33_write16(codec, DAC33_LTHR_MSB, + dac33_write16(component, DAC33_UTHR_MSB, DAC33_THRREG(dac33->uthr)); + dac33_write16(component, DAC33_LTHR_MSB, DAC33_THRREG(DAC33_MODE7_MARGIN)); break; default: @@ -1060,9 +1060,9 @@ static int dac33_prepare_chip(struct snd_pcm_substream *substream, } static void dac33_calculate_times(struct snd_pcm_substream *substream, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); unsigned int period_size = substream->runtime->period_size; unsigned int rate = substream->runtime->rate; unsigned int nsample_limit; @@ -1119,8 +1119,8 @@ static void dac33_calculate_times(struct snd_pcm_substream *substream, static int dac33_pcm_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int ret = 0; switch (cmd) { @@ -1151,8 +1151,8 @@ static snd_pcm_sframes_t dac33_dai_delay( struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); unsigned long long t0, t1, t_now; unsigned int time_delta, uthr; int samples_out, samples_in, samples; @@ -1284,7 +1284,7 @@ static snd_pcm_sframes_t dac33_dai_delay( } break; default: - dev_warn(codec->dev, "Unhandled FIFO mode: %d\n", + dev_warn(component->dev, "Unhandled FIFO mode: %d\n", dac33->fifo_mode); break; } @@ -1295,12 +1295,12 @@ out: static int dac33_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); u8 ioc_reg, asrcb_reg; - ioc_reg = dac33_read_reg_cache(codec, DAC33_INT_OSC_CTRL); - asrcb_reg = dac33_read_reg_cache(codec, DAC33_ASRC_CTRL_B); + ioc_reg = dac33_read_reg_cache(component, DAC33_INT_OSC_CTRL); + asrcb_reg = dac33_read_reg_cache(component, DAC33_ASRC_CTRL_B); switch (clk_id) { case TLV320DAC33_MCLK: ioc_reg |= DAC33_REFSEL; @@ -1311,13 +1311,13 @@ static int dac33_set_dai_sysclk(struct snd_soc_dai *codec_dai, asrcb_reg &= ~DAC33_SRCREFSEL; break; default: - dev_err(codec->dev, "Invalid clock ID (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock ID (%d)\n", clk_id); break; } dac33->refclk = freq; - dac33_write_reg_cache(codec, DAC33_INT_OSC_CTRL, ioc_reg); - dac33_write_reg_cache(codec, DAC33_ASRC_CTRL_B, asrcb_reg); + dac33_write_reg_cache(component, DAC33_INT_OSC_CTRL, ioc_reg); + dac33_write_reg_cache(component, DAC33_ASRC_CTRL_B, asrcb_reg); return 0; } @@ -1325,12 +1325,12 @@ static int dac33_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int dac33_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); u8 aictrl_a, aictrl_b; - aictrl_a = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_A); - aictrl_b = dac33_read_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B); + aictrl_a = dac33_read_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_A); + aictrl_b = dac33_read_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_B); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -1340,7 +1340,7 @@ static int dac33_set_dai_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFS: /* Codec Slave */ if (dac33->fifo_mode) { - dev_err(codec->dev, "FIFO mode requires master mode\n"); + dev_err(component->dev, "FIFO mode requires master mode\n"); return -EINVAL; } else aictrl_a &= ~(DAC33_MSBCLK | DAC33_MSWCLK); @@ -1366,35 +1366,35 @@ static int dac33_set_dai_fmt(struct snd_soc_dai *codec_dai, aictrl_a |= DAC33_AFMT_LEFT_J; break; default: - dev_err(codec->dev, "Unsupported format (%u)\n", + dev_err(component->dev, "Unsupported format (%u)\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } - dac33_write_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a); - dac33_write_reg_cache(codec, DAC33_SER_AUDIOIF_CTRL_B, aictrl_b); + dac33_write_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_A, aictrl_a); + dac33_write_reg_cache(component, DAC33_SER_AUDIOIF_CTRL_B, aictrl_b); return 0; } -static int dac33_soc_probe(struct snd_soc_codec *codec) +static int dac33_soc_probe(struct snd_soc_component *component) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); int ret = 0; - dac33->codec = codec; + dac33->component = component; /* Read the tlv320dac33 ID registers */ - ret = dac33_hard_power(codec, 1); + ret = dac33_hard_power(component, 1); if (ret != 0) { - dev_err(codec->dev, "Failed to power up codec: %d\n", ret); + dev_err(component->dev, "Failed to power up component: %d\n", ret); goto err_power; } - ret = dac33_read_id(codec); - dac33_hard_power(codec, 0); + ret = dac33_read_id(component); + dac33_hard_power(component, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to read chip ID: %d\n", ret); + dev_err(component->dev, "Failed to read chip ID: %d\n", ret); ret = -ENODEV; goto err_power; } @@ -1403,9 +1403,9 @@ static int dac33_soc_probe(struct snd_soc_codec *codec) if (dac33->irq >= 0) { ret = request_irq(dac33->irq, dac33_interrupt_handler, IRQF_TRIGGER_RISING, - codec->component.name, codec); + component->name, component); if (ret < 0) { - dev_err(codec->dev, "Could not request IRQ%d (%d)\n", + dev_err(component->dev, "Could not request IRQ%d (%d)\n", dac33->irq, ret); dac33->irq = -1; } @@ -1416,41 +1416,38 @@ static int dac33_soc_probe(struct snd_soc_codec *codec) /* Only add the FIFO controls, if we have valid IRQ number */ if (dac33->irq >= 0) - snd_soc_add_codec_controls(codec, dac33_mode_snd_controls, + snd_soc_add_component_controls(component, dac33_mode_snd_controls, ARRAY_SIZE(dac33_mode_snd_controls)); err_power: return ret; } -static int dac33_soc_remove(struct snd_soc_codec *codec) +static void dac33_soc_remove(struct snd_soc_component *component) { - struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); + struct tlv320dac33_priv *dac33 = snd_soc_component_get_drvdata(component); if (dac33->irq >= 0) { - free_irq(dac33->irq, dac33->codec); + free_irq(dac33->irq, dac33->component); flush_work(&dac33->work); } - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_tlv320dac33 = { - .read = dac33_read_reg_cache, - .write = dac33_write_locked, - .set_bias_level = dac33_set_bias_level, - .idle_bias_off = true, - - .probe = dac33_soc_probe, - .remove = dac33_soc_remove, - - .component_driver = { - .controls = dac33_snd_controls, - .num_controls = ARRAY_SIZE(dac33_snd_controls), - .dapm_widgets = dac33_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(dac33_dapm_widgets), - .dapm_routes = audio_map, - .num_dapm_routes = ARRAY_SIZE(audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_tlv320dac33 = { + .read = dac33_read_reg_cache, + .write = dac33_write_locked, + .set_bias_level = dac33_set_bias_level, + .probe = dac33_soc_probe, + .remove = dac33_soc_remove, + .controls = dac33_snd_controls, + .num_controls = ARRAY_SIZE(dac33_snd_controls), + .dapm_widgets = dac33_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(dac33_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; #define DAC33_RATES (SNDRV_PCM_RATE_44100 | \ @@ -1544,8 +1541,8 @@ static int dac33_i2c_probe(struct i2c_client *client, goto err_get; } - ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_tlv320dac33, &dac33_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_tlv320dac33, &dac33_dai, 1); if (ret < 0) goto err_get; @@ -1562,12 +1559,11 @@ static int dac33_i2c_remove(struct i2c_client *client) struct tlv320dac33_priv *dac33 = i2c_get_clientdata(client); if (unlikely(dac33->chip_power)) - dac33_hard_power(dac33->codec, 0); + dac33_hard_power(dac33->component, 0); if (dac33->power_gpio >= 0) gpio_free(dac33->power_gpio); - snd_soc_unregister_codec(&client->dev); return 0; } From b154dc5d7631c0bd32e42992867953cfd05bffd9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:14:49 +0000 Subject: [PATCH 116/942] ASoC: tlv320aic32x4: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic32x4.c | 207 +++++++++++++++---------------- 1 file changed, 103 insertions(+), 104 deletions(-) diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index fea019343c3b..e2b5a11b16d1 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c @@ -82,10 +82,10 @@ struct aic32x4_priv { static int aic32x4_get_mfp1_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; - val = snd_soc_read(codec, AIC32X4_DINCTL); + val = snd_soc_component_read32(component, AIC32X4_DINCTL); ucontrol->value.integer.value[0] = (val & 0x01); @@ -95,11 +95,11 @@ static int aic32x4_get_mfp1_gpio(struct snd_kcontrol *kcontrol, static int aic32x4_set_mfp2_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; u8 gpio_check; - val = snd_soc_read(codec, AIC32X4_DOUTCTL); + val = snd_soc_component_read32(component, AIC32X4_DOUTCTL); gpio_check = (val & AIC32X4_MFP_GPIO_ENABLED); if (gpio_check != AIC32X4_MFP_GPIO_ENABLED) { printk(KERN_ERR "%s: MFP2 is not configure as a GPIO output\n", @@ -115,7 +115,7 @@ static int aic32x4_set_mfp2_gpio(struct snd_kcontrol *kcontrol, else val &= ~AIC32X4_MFP2_GPIO_OUT_HIGH; - snd_soc_write(codec, AIC32X4_DOUTCTL, val); + snd_soc_component_write(component, AIC32X4_DOUTCTL, val); return 0; }; @@ -123,10 +123,10 @@ static int aic32x4_set_mfp2_gpio(struct snd_kcontrol *kcontrol, static int aic32x4_get_mfp3_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; - val = snd_soc_read(codec, AIC32X4_SCLKCTL); + val = snd_soc_component_read32(component, AIC32X4_SCLKCTL); ucontrol->value.integer.value[0] = (val & 0x01); @@ -136,11 +136,11 @@ static int aic32x4_get_mfp3_gpio(struct snd_kcontrol *kcontrol, static int aic32x4_set_mfp4_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; u8 gpio_check; - val = snd_soc_read(codec, AIC32X4_MISOCTL); + val = snd_soc_component_read32(component, AIC32X4_MISOCTL); gpio_check = (val & AIC32X4_MFP_GPIO_ENABLED); if (gpio_check != AIC32X4_MFP_GPIO_ENABLED) { printk(KERN_ERR "%s: MFP4 is not configure as a GPIO output\n", @@ -156,7 +156,7 @@ static int aic32x4_set_mfp4_gpio(struct snd_kcontrol *kcontrol, else val &= ~AIC32X4_MFP5_GPIO_OUT_HIGH; - snd_soc_write(codec, AIC32X4_MISOCTL, val); + snd_soc_component_write(component, AIC32X4_MISOCTL, val); return 0; }; @@ -164,10 +164,10 @@ static int aic32x4_set_mfp4_gpio(struct snd_kcontrol *kcontrol, static int aic32x4_get_mfp5_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; - val = snd_soc_read(codec, AIC32X4_GPIOCTL); + val = snd_soc_component_read32(component, AIC32X4_GPIOCTL); ucontrol->value.integer.value[0] = ((val & 0x2) >> 1); return 0; @@ -176,11 +176,11 @@ static int aic32x4_get_mfp5_gpio(struct snd_kcontrol *kcontrol, static int aic32x4_set_mfp5_gpio(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); u8 val; u8 gpio_check; - val = snd_soc_read(codec, AIC32X4_GPIOCTL); + val = snd_soc_component_read32(component, AIC32X4_GPIOCTL); gpio_check = (val & AIC32X4_MFP5_GPIO_OUTPUT); if (gpio_check != AIC32X4_MFP5_GPIO_OUTPUT) { printk(KERN_ERR "%s: MFP5 is not configure as a GPIO output\n", @@ -196,7 +196,7 @@ static int aic32x4_set_mfp5_gpio(struct snd_kcontrol *kcontrol, else val &= 0xfe; - snd_soc_write(codec, AIC32X4_GPIOCTL, val); + snd_soc_component_write(component, AIC32X4_GPIOCTL, val); return 0; }; @@ -597,8 +597,8 @@ static inline int aic32x4_get_divs(int mclk, int rate) static int aic32x4_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component); switch (freq) { case 12000000: @@ -613,7 +613,7 @@ static int aic32x4_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 iface_reg_1 = 0; u8 iface_reg_2 = 0; u8 iface_reg_3 = 0; @@ -657,12 +657,12 @@ static int aic32x4_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, AIC32X4_IFACE1, + snd_soc_component_update_bits(component, AIC32X4_IFACE1, AIC32X4_IFACE1_DATATYPE_MASK | AIC32X4_IFACE1_MASTER_MASK, iface_reg_1); - snd_soc_update_bits(codec, AIC32X4_IFACE2, + snd_soc_component_update_bits(component, AIC32X4_IFACE2, AIC32X4_DATA_OFFSET_MASK, iface_reg_2); - snd_soc_update_bits(codec, AIC32X4_IFACE3, + snd_soc_component_update_bits(component, AIC32X4_IFACE3, AIC32X4_BCLKINV_MASK, iface_reg_3); return 0; @@ -672,8 +672,8 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component); u8 iface1_reg = 0; u8 dacsetup_reg = 0; int i; @@ -685,54 +685,54 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream, } /* MCLK as PLL_CLKIN */ - snd_soc_update_bits(codec, AIC32X4_CLKMUX, AIC32X4_PLL_CLKIN_MASK, + snd_soc_component_update_bits(component, AIC32X4_CLKMUX, AIC32X4_PLL_CLKIN_MASK, AIC32X4_PLL_CLKIN_MCLK << AIC32X4_PLL_CLKIN_SHIFT); /* PLL as CODEC_CLKIN */ - snd_soc_update_bits(codec, AIC32X4_CLKMUX, AIC32X4_CODEC_CLKIN_MASK, + snd_soc_component_update_bits(component, AIC32X4_CLKMUX, AIC32X4_CODEC_CLKIN_MASK, AIC32X4_CODEC_CLKIN_PLL << AIC32X4_CODEC_CLKIN_SHIFT); /* DAC_MOD_CLK as BDIV_CLKIN */ - snd_soc_update_bits(codec, AIC32X4_IFACE3, AIC32X4_BDIVCLK_MASK, + snd_soc_component_update_bits(component, AIC32X4_IFACE3, AIC32X4_BDIVCLK_MASK, AIC32X4_DACMOD2BCLK << AIC32X4_BDIVCLK_SHIFT); /* We will fix R value to 1 and will make P & J=K.D as variable */ - snd_soc_update_bits(codec, AIC32X4_PLLPR, AIC32X4_PLL_R_MASK, 0x01); + snd_soc_component_update_bits(component, AIC32X4_PLLPR, AIC32X4_PLL_R_MASK, 0x01); /* PLL P value */ - snd_soc_update_bits(codec, AIC32X4_PLLPR, AIC32X4_PLL_P_MASK, + snd_soc_component_update_bits(component, AIC32X4_PLLPR, AIC32X4_PLL_P_MASK, aic32x4_divs[i].p_val << AIC32X4_PLL_P_SHIFT); /* PLL J value */ - snd_soc_write(codec, AIC32X4_PLLJ, aic32x4_divs[i].pll_j); + snd_soc_component_write(component, AIC32X4_PLLJ, aic32x4_divs[i].pll_j); /* PLL D value */ - snd_soc_write(codec, AIC32X4_PLLDMSB, (aic32x4_divs[i].pll_d >> 8)); - snd_soc_write(codec, AIC32X4_PLLDLSB, (aic32x4_divs[i].pll_d & 0xff)); + snd_soc_component_write(component, AIC32X4_PLLDMSB, (aic32x4_divs[i].pll_d >> 8)); + snd_soc_component_write(component, AIC32X4_PLLDLSB, (aic32x4_divs[i].pll_d & 0xff)); /* NDAC divider value */ - snd_soc_update_bits(codec, AIC32X4_NDAC, + snd_soc_component_update_bits(component, AIC32X4_NDAC, AIC32X4_NDAC_MASK, aic32x4_divs[i].ndac); /* MDAC divider value */ - snd_soc_update_bits(codec, AIC32X4_MDAC, + snd_soc_component_update_bits(component, AIC32X4_MDAC, AIC32X4_MDAC_MASK, aic32x4_divs[i].mdac); /* DOSR MSB & LSB values */ - snd_soc_write(codec, AIC32X4_DOSRMSB, aic32x4_divs[i].dosr >> 8); - snd_soc_write(codec, AIC32X4_DOSRLSB, (aic32x4_divs[i].dosr & 0xff)); + snd_soc_component_write(component, AIC32X4_DOSRMSB, aic32x4_divs[i].dosr >> 8); + snd_soc_component_write(component, AIC32X4_DOSRLSB, (aic32x4_divs[i].dosr & 0xff)); /* NADC divider value */ - snd_soc_update_bits(codec, AIC32X4_NADC, + snd_soc_component_update_bits(component, AIC32X4_NADC, AIC32X4_NADC_MASK, aic32x4_divs[i].nadc); /* MADC divider value */ - snd_soc_update_bits(codec, AIC32X4_MADC, + snd_soc_component_update_bits(component, AIC32X4_MADC, AIC32X4_MADC_MASK, aic32x4_divs[i].madc); /* AOSR value */ - snd_soc_write(codec, AIC32X4_AOSR, aic32x4_divs[i].aosr); + snd_soc_component_write(component, AIC32X4_AOSR, aic32x4_divs[i].aosr); /* BCLK N divider */ - snd_soc_update_bits(codec, AIC32X4_BCLKN, + snd_soc_component_update_bits(component, AIC32X4_BCLKN, AIC32X4_BCLK_MASK, aic32x4_divs[i].blck_N); switch (params_width(params)) { @@ -753,7 +753,7 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream, AIC32X4_IFACE1_DATALEN_SHIFT); break; } - snd_soc_update_bits(codec, AIC32X4_IFACE1, + snd_soc_component_update_bits(component, AIC32X4_IFACE1, AIC32X4_IFACE1_DATALEN_MASK, iface1_reg); if (params_channels(params) == 1) { @@ -764,7 +764,7 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream, else dacsetup_reg = AIC32X4_LDAC2LCHN | AIC32X4_RDAC2RCHN; } - snd_soc_update_bits(codec, AIC32X4_DACSETUP, + snd_soc_component_update_bits(component, AIC32X4_DACSETUP, AIC32X4_DAC_CHAN_MASK, dacsetup_reg); return 0; @@ -772,18 +772,18 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream, static int aic32x4_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - snd_soc_update_bits(codec, AIC32X4_DACMUTE, + snd_soc_component_update_bits(component, AIC32X4_DACMUTE, AIC32X4_MUTEON, mute ? AIC32X4_MUTEON : 0); return 0; } -static int aic32x4_set_bias_level(struct snd_soc_codec *codec, +static int aic32x4_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -791,59 +791,59 @@ static int aic32x4_set_bias_level(struct snd_soc_codec *codec, /* Switch on master clock */ ret = clk_prepare_enable(aic32x4->mclk); if (ret) { - dev_err(codec->dev, "Failed to enable master clock\n"); + dev_err(component->dev, "Failed to enable master clock\n"); return ret; } /* Switch on PLL */ - snd_soc_update_bits(codec, AIC32X4_PLLPR, + snd_soc_component_update_bits(component, AIC32X4_PLLPR, AIC32X4_PLLEN, AIC32X4_PLLEN); /* Switch on NDAC Divider */ - snd_soc_update_bits(codec, AIC32X4_NDAC, + snd_soc_component_update_bits(component, AIC32X4_NDAC, AIC32X4_NDACEN, AIC32X4_NDACEN); /* Switch on MDAC Divider */ - snd_soc_update_bits(codec, AIC32X4_MDAC, + snd_soc_component_update_bits(component, AIC32X4_MDAC, AIC32X4_MDACEN, AIC32X4_MDACEN); /* Switch on NADC Divider */ - snd_soc_update_bits(codec, AIC32X4_NADC, + snd_soc_component_update_bits(component, AIC32X4_NADC, AIC32X4_NADCEN, AIC32X4_NADCEN); /* Switch on MADC Divider */ - snd_soc_update_bits(codec, AIC32X4_MADC, + snd_soc_component_update_bits(component, AIC32X4_MADC, AIC32X4_MADCEN, AIC32X4_MADCEN); /* Switch on BCLK_N Divider */ - snd_soc_update_bits(codec, AIC32X4_BCLKN, + snd_soc_component_update_bits(component, AIC32X4_BCLKN, AIC32X4_BCLKEN, AIC32X4_BCLKEN); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: /* Switch off BCLK_N Divider */ - snd_soc_update_bits(codec, AIC32X4_BCLKN, + snd_soc_component_update_bits(component, AIC32X4_BCLKN, AIC32X4_BCLKEN, 0); /* Switch off MADC Divider */ - snd_soc_update_bits(codec, AIC32X4_MADC, + snd_soc_component_update_bits(component, AIC32X4_MADC, AIC32X4_MADCEN, 0); /* Switch off NADC Divider */ - snd_soc_update_bits(codec, AIC32X4_NADC, + snd_soc_component_update_bits(component, AIC32X4_NADC, AIC32X4_NADCEN, 0); /* Switch off MDAC Divider */ - snd_soc_update_bits(codec, AIC32X4_MDAC, + snd_soc_component_update_bits(component, AIC32X4_MDAC, AIC32X4_MDACEN, 0); /* Switch off NDAC Divider */ - snd_soc_update_bits(codec, AIC32X4_NDAC, + snd_soc_component_update_bits(component, AIC32X4_NDAC, AIC32X4_NDACEN, 0); /* Switch off PLL */ - snd_soc_update_bits(codec, AIC32X4_PLLPR, + snd_soc_component_update_bits(component, AIC32X4_PLLPR, AIC32X4_PLLEN, 0); /* Switch off master clock */ @@ -884,55 +884,55 @@ static struct snd_soc_dai_driver aic32x4_dai = { .symmetric_rates = 1, }; -static void aic32x4_setup_gpios(struct snd_soc_codec *codec) +static void aic32x4_setup_gpios(struct snd_soc_component *component) { - struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component); /* setup GPIO functions */ /* MFP1 */ if (aic32x4->setup->gpio_func[0] != AIC32X4_MFPX_DEFAULT_VALUE) { - snd_soc_write(codec, AIC32X4_DINCTL, + snd_soc_component_write(component, AIC32X4_DINCTL, aic32x4->setup->gpio_func[0]); - snd_soc_add_codec_controls(codec, aic32x4_mfp1, + snd_soc_add_component_controls(component, aic32x4_mfp1, ARRAY_SIZE(aic32x4_mfp1)); } /* MFP2 */ if (aic32x4->setup->gpio_func[1] != AIC32X4_MFPX_DEFAULT_VALUE) { - snd_soc_write(codec, AIC32X4_DOUTCTL, + snd_soc_component_write(component, AIC32X4_DOUTCTL, aic32x4->setup->gpio_func[1]); - snd_soc_add_codec_controls(codec, aic32x4_mfp2, + snd_soc_add_component_controls(component, aic32x4_mfp2, ARRAY_SIZE(aic32x4_mfp2)); } /* MFP3 */ if (aic32x4->setup->gpio_func[2] != AIC32X4_MFPX_DEFAULT_VALUE) { - snd_soc_write(codec, AIC32X4_SCLKCTL, + snd_soc_component_write(component, AIC32X4_SCLKCTL, aic32x4->setup->gpio_func[2]); - snd_soc_add_codec_controls(codec, aic32x4_mfp3, + snd_soc_add_component_controls(component, aic32x4_mfp3, ARRAY_SIZE(aic32x4_mfp3)); } /* MFP4 */ if (aic32x4->setup->gpio_func[3] != AIC32X4_MFPX_DEFAULT_VALUE) { - snd_soc_write(codec, AIC32X4_MISOCTL, + snd_soc_component_write(component, AIC32X4_MISOCTL, aic32x4->setup->gpio_func[3]); - snd_soc_add_codec_controls(codec, aic32x4_mfp4, + snd_soc_add_component_controls(component, aic32x4_mfp4, ARRAY_SIZE(aic32x4_mfp4)); } /* MFP5 */ if (aic32x4->setup->gpio_func[4] != AIC32X4_MFPX_DEFAULT_VALUE) { - snd_soc_write(codec, AIC32X4_GPIOCTL, + snd_soc_component_write(component, AIC32X4_GPIOCTL, aic32x4->setup->gpio_func[4]); - snd_soc_add_codec_controls(codec, aic32x4_mfp5, + snd_soc_add_component_controls(component, aic32x4_mfp5, ARRAY_SIZE(aic32x4_mfp5)); } } -static int aic32x4_codec_probe(struct snd_soc_codec *codec) +static int aic32x4_component_probe(struct snd_soc_component *component) { - struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); + struct aic32x4_priv *aic32x4 = snd_soc_component_get_drvdata(component); u32 tmp_reg; if (gpio_is_valid(aic32x4->rstn_gpio)) { @@ -940,42 +940,42 @@ static int aic32x4_codec_probe(struct snd_soc_codec *codec) gpio_set_value(aic32x4->rstn_gpio, 1); } - snd_soc_write(codec, AIC32X4_RESET, 0x01); + snd_soc_component_write(component, AIC32X4_RESET, 0x01); if (aic32x4->setup) - aic32x4_setup_gpios(codec); + aic32x4_setup_gpios(component); /* Power platform configuration */ if (aic32x4->power_cfg & AIC32X4_PWR_MICBIAS_2075_LDOIN) { - snd_soc_write(codec, AIC32X4_MICBIAS, AIC32X4_MICBIAS_LDOIN | + snd_soc_component_write(component, AIC32X4_MICBIAS, AIC32X4_MICBIAS_LDOIN | AIC32X4_MICBIAS_2075V); } if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE) - snd_soc_write(codec, AIC32X4_PWRCFG, AIC32X4_AVDDWEAKDISABLE); + snd_soc_component_write(component, AIC32X4_PWRCFG, AIC32X4_AVDDWEAKDISABLE); tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ? AIC32X4_LDOCTLEN : 0; - snd_soc_write(codec, AIC32X4_LDOCTL, tmp_reg); + snd_soc_component_write(component, AIC32X4_LDOCTL, tmp_reg); - tmp_reg = snd_soc_read(codec, AIC32X4_CMMODE); + tmp_reg = snd_soc_component_read32(component, AIC32X4_CMMODE); if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36) tmp_reg |= AIC32X4_LDOIN_18_36; if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED) tmp_reg |= AIC32X4_LDOIN2HP; - snd_soc_write(codec, AIC32X4_CMMODE, tmp_reg); + snd_soc_component_write(component, AIC32X4_CMMODE, tmp_reg); /* Mic PGA routing */ if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K) - snd_soc_write(codec, AIC32X4_LMICPGANIN, + snd_soc_component_write(component, AIC32X4_LMICPGANIN, AIC32X4_LMICPGANIN_IN2R_10K); else - snd_soc_write(codec, AIC32X4_LMICPGANIN, + snd_soc_component_write(component, AIC32X4_LMICPGANIN, AIC32X4_LMICPGANIN_CM1L_10K); if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K) - snd_soc_write(codec, AIC32X4_RMICPGANIN, + snd_soc_component_write(component, AIC32X4_RMICPGANIN, AIC32X4_RMICPGANIN_IN1L_10K); else - snd_soc_write(codec, AIC32X4_RMICPGANIN, + snd_soc_component_write(component, AIC32X4_RMICPGANIN, AIC32X4_RMICPGANIN_CM1R_10K); /* @@ -983,27 +983,28 @@ static int aic32x4_codec_probe(struct snd_soc_codec *codec) * and down for the first capture to work properly. It seems related to * a HW BUG or some kind of behavior not documented in the datasheet. */ - tmp_reg = snd_soc_read(codec, AIC32X4_ADCSETUP); - snd_soc_write(codec, AIC32X4_ADCSETUP, tmp_reg | + tmp_reg = snd_soc_component_read32(component, AIC32X4_ADCSETUP); + snd_soc_component_write(component, AIC32X4_ADCSETUP, tmp_reg | AIC32X4_LADC_EN | AIC32X4_RADC_EN); - snd_soc_write(codec, AIC32X4_ADCSETUP, tmp_reg); + snd_soc_component_write(component, AIC32X4_ADCSETUP, tmp_reg); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { - .probe = aic32x4_codec_probe, - .set_bias_level = aic32x4_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = aic32x4_snd_controls, - .num_controls = ARRAY_SIZE(aic32x4_snd_controls), - .dapm_widgets = aic32x4_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(aic32x4_dapm_widgets), - .dapm_routes = aic32x4_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(aic32x4_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_aic32x4 = { + .probe = aic32x4_component_probe, + .set_bias_level = aic32x4_set_bias_level, + .controls = aic32x4_snd_controls, + .num_controls = ARRAY_SIZE(aic32x4_snd_controls), + .dapm_widgets = aic32x4_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aic32x4_dapm_widgets), + .dapm_routes = aic32x4_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(aic32x4_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int aic32x4_parse_dt(struct aic32x4_priv *aic32x4, @@ -1181,10 +1182,10 @@ int aic32x4_probe(struct device *dev, struct regmap *regmap) return ret; } - ret = snd_soc_register_codec(dev, - &soc_codec_dev_aic32x4, &aic32x4_dai, 1); + ret = devm_snd_soc_register_component(dev, + &soc_component_dev_aic32x4, &aic32x4_dai, 1); if (ret) { - dev_err(dev, "Failed to register codec\n"); + dev_err(dev, "Failed to register component\n"); aic32x4_disable_regulators(aic32x4); return ret; } @@ -1199,8 +1200,6 @@ int aic32x4_remove(struct device *dev) aic32x4_disable_regulators(aic32x4); - snd_soc_unregister_codec(dev); - return 0; } EXPORT_SYMBOL(aic32x4_remove); From f2e6f95b4b1381fe81cdbdb70d2c50a85b770d8b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:15:27 +0000 Subject: [PATCH 117/942] ASoC: tlv320aic31xx: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 240 +++++++++++++++---------------- 1 file changed, 116 insertions(+), 124 deletions(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 858cb8be445f..d3cd924dc300 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -153,7 +153,7 @@ struct aic31xx_disable_nb { }; struct aic31xx_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; u8 i2c_regs_status; struct device *dev; struct regmap *regmap; @@ -348,8 +348,8 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg, static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); unsigned int reg = AIC31XX_DACFLAG1; unsigned int mask; @@ -377,7 +377,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, reg = AIC31XX_ADCFLAG; break; default: - dev_err(codec->dev, "Unknown widget '%s' calling %s\n", + dev_err(component->dev, "Unknown widget '%s' calling %s\n", w->name, __func__); return -EINVAL; } @@ -388,7 +388,7 @@ static int aic31xx_dapm_power_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMD: return aic31xx_wait_bits(aic31xx, reg, mask, 0, 5000, 100); default: - dev_dbg(codec->dev, + dev_dbg(component->dev, "Unhandled dapm widget event %d from %s\n", event, w->name); } @@ -444,23 +444,23 @@ static const struct snd_kcontrol_new aic31xx_dapm_spr_switch = static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* change mic bias voltage to user defined */ - snd_soc_update_bits(codec, AIC31XX_MICBIAS, + snd_soc_component_update_bits(component, AIC31XX_MICBIAS, AIC31XX_MICBIAS_MASK, aic31xx->micbias_vg << AIC31XX_MICBIAS_SHIFT); - dev_dbg(codec->dev, "%s: turned on\n", __func__); + dev_dbg(component->dev, "%s: turned on\n", __func__); break; case SND_SOC_DAPM_PRE_PMD: /* turn mic bias off */ - snd_soc_update_bits(codec, AIC31XX_MICBIAS, + snd_soc_component_update_bits(component, AIC31XX_MICBIAS, AIC31XX_MICBIAS_MASK, 0); - dev_dbg(codec->dev, "%s: turned off\n", __func__); + dev_dbg(component->dev, "%s: turned off\n", __func__); break; } return 0; @@ -670,34 +670,34 @@ aic310x_audio_map[] = { {"SPK", NULL, "SPK ClassD"}, }; -static int aic31xx_add_controls(struct snd_soc_codec *codec) +static int aic31xx_add_controls(struct snd_soc_component *component) { int ret = 0; - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); if (!(aic31xx->codec_type & DAC31XX_BIT)) - ret = snd_soc_add_codec_controls( - codec, aic31xx_snd_controls, + ret = snd_soc_add_component_controls( + component, aic31xx_snd_controls, ARRAY_SIZE(aic31xx_snd_controls)); if (ret) return ret; if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) - ret = snd_soc_add_codec_controls( - codec, aic311x_snd_controls, + ret = snd_soc_add_component_controls( + component, aic311x_snd_controls, ARRAY_SIZE(aic311x_snd_controls)); else - ret = snd_soc_add_codec_controls( - codec, aic310x_snd_controls, + ret = snd_soc_add_component_controls( + component, aic310x_snd_controls, ARRAY_SIZE(aic310x_snd_controls)); return ret; } -static int aic31xx_add_widgets(struct snd_soc_codec *codec) +static int aic31xx_add_widgets(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int ret = 0; if (aic31xx->codec_type & DAC31XX_BIT) { @@ -751,10 +751,10 @@ static int aic31xx_add_widgets(struct snd_soc_codec *codec) return 0; } -static int aic31xx_setup_pll(struct snd_soc_codec *codec, +static int aic31xx_setup_pll(struct snd_soc_component *component, struct snd_pcm_hw_params *params) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int bclk_score = snd_soc_params_to_frame_size(params); int mclk_p; int bclk_n = 0; @@ -762,15 +762,15 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, int i; if (!aic31xx->sysclk || !aic31xx->p_div) { - dev_err(codec->dev, "Master clock not supplied\n"); + dev_err(component->dev, "Master clock not supplied\n"); return -EINVAL; } mclk_p = aic31xx->sysclk / aic31xx->p_div; /* Use PLL as CODEC_CLKIN and DAC_CLK as BDIV_CLKIN */ - snd_soc_update_bits(codec, AIC31XX_CLKMUX, + snd_soc_component_update_bits(component, AIC31XX_CLKMUX, AIC31XX_CODEC_CLKIN_MASK, AIC31XX_CODEC_CLKIN_PLL); - snd_soc_update_bits(codec, AIC31XX_IFACE2, + snd_soc_component_update_bits(component, AIC31XX_IFACE2, AIC31XX_BDIVCLK_MASK, AIC31XX_DAC2BCLK); for (i = 0; i < ARRAY_SIZE(aic31xx_divs); i++) { @@ -789,14 +789,14 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, } if (match == -1) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Sample rate (%u) and format not supported\n", __func__, params_rate(params)); /* See bellow for details how fix this. */ return -EINVAL; } if (bclk_score != 0) { - dev_warn(codec->dev, "Can not produce exact bitclock"); + dev_warn(component->dev, "Can not produce exact bitclock"); /* This is fine if using dsp format, but if using i2s there may be trouble. To fix the issue edit the aic31xx_divs table for your mclk and sample @@ -808,39 +808,39 @@ static int aic31xx_setup_pll(struct snd_soc_codec *codec, i = match; /* PLL configuration */ - snd_soc_update_bits(codec, AIC31XX_PLLPR, AIC31XX_PLL_MASK, + snd_soc_component_update_bits(component, AIC31XX_PLLPR, AIC31XX_PLL_MASK, (aic31xx->p_div << 4) | 0x01); - snd_soc_write(codec, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); + snd_soc_component_write(component, AIC31XX_PLLJ, aic31xx_divs[i].pll_j); - snd_soc_write(codec, AIC31XX_PLLDMSB, + snd_soc_component_write(component, AIC31XX_PLLDMSB, aic31xx_divs[i].pll_d >> 8); - snd_soc_write(codec, AIC31XX_PLLDLSB, + snd_soc_component_write(component, AIC31XX_PLLDLSB, aic31xx_divs[i].pll_d & 0xff); /* DAC dividers configuration */ - snd_soc_update_bits(codec, AIC31XX_NDAC, AIC31XX_PLL_MASK, + snd_soc_component_update_bits(component, AIC31XX_NDAC, AIC31XX_PLL_MASK, aic31xx_divs[i].ndac); - snd_soc_update_bits(codec, AIC31XX_MDAC, AIC31XX_PLL_MASK, + snd_soc_component_update_bits(component, AIC31XX_MDAC, AIC31XX_PLL_MASK, aic31xx_divs[i].mdac); - snd_soc_write(codec, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8); - snd_soc_write(codec, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff); + snd_soc_component_write(component, AIC31XX_DOSRMSB, aic31xx_divs[i].dosr >> 8); + snd_soc_component_write(component, AIC31XX_DOSRLSB, aic31xx_divs[i].dosr & 0xff); /* ADC dividers configuration. Write reset value 1 if not used. */ - snd_soc_update_bits(codec, AIC31XX_NADC, AIC31XX_PLL_MASK, + snd_soc_component_update_bits(component, AIC31XX_NADC, AIC31XX_PLL_MASK, aic31xx_divs[i].nadc ? aic31xx_divs[i].nadc : 1); - snd_soc_update_bits(codec, AIC31XX_MADC, AIC31XX_PLL_MASK, + snd_soc_component_update_bits(component, AIC31XX_MADC, AIC31XX_PLL_MASK, aic31xx_divs[i].madc ? aic31xx_divs[i].madc : 1); - snd_soc_write(codec, AIC31XX_AOSR, aic31xx_divs[i].aosr); + snd_soc_component_write(component, AIC31XX_AOSR, aic31xx_divs[i].aosr); /* Bit clock divider configuration. */ - snd_soc_update_bits(codec, AIC31XX_BCLKN, + snd_soc_component_update_bits(component, AIC31XX_BCLKN, AIC31XX_PLL_MASK, bclk_n); aic31xx->rate_div_line = i; - dev_dbg(codec->dev, + dev_dbg(component->dev, "pll %d.%04d/%d dosr %d n %d m %d aosr %d n %d m %d bclk_n %d\n", aic31xx_divs[i].pll_j, aic31xx_divs[i].pll_d, @@ -861,10 +861,10 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 data = 0; - dev_dbg(codec->dev, "## %s: width %d rate %d\n", + dev_dbg(component->dev, "## %s: width %d rate %d\n", __func__, params_width(params), params_rate(params)); @@ -884,28 +884,28 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, AIC31XX_IFACE1_DATALEN_SHIFT); break; default: - dev_err(codec->dev, "%s: Unsupported width %d\n", + dev_err(component->dev, "%s: Unsupported width %d\n", __func__, params_width(params)); return -EINVAL; } - snd_soc_update_bits(codec, AIC31XX_IFACE1, + snd_soc_component_update_bits(component, AIC31XX_IFACE1, AIC31XX_IFACE1_DATALEN_MASK, data); - return aic31xx_setup_pll(codec, params); + return aic31xx_setup_pll(component, params); } static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; if (mute) { - snd_soc_update_bits(codec, AIC31XX_DACMUTE, + snd_soc_component_update_bits(component, AIC31XX_DACMUTE, AIC31XX_DACMUTE_MASK, AIC31XX_DACMUTE_MASK); } else { - snd_soc_update_bits(codec, AIC31XX_DACMUTE, + snd_soc_component_update_bits(component, AIC31XX_DACMUTE, AIC31XX_DACMUTE_MASK, 0x0); } @@ -915,12 +915,12 @@ static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 iface_reg1 = 0; u8 iface_reg2 = 0; u8 dsp_a_val = 0; - dev_dbg(codec->dev, "## %s: fmt = 0x%x\n", __func__, fmt); + dev_dbg(component->dev, "## %s: fmt = 0x%x\n", __func__, fmt); /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -936,7 +936,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, case SND_SOC_DAIFMT_CBS_CFS: break; default: - dev_err(codec->dev, "Invalid DAI master/slave interface\n"); + dev_err(component->dev, "Invalid DAI master/slave interface\n"); return -EINVAL; } @@ -948,7 +948,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, iface_reg2 |= AIC31XX_BCLKINV_MASK; break; default: - dev_err(codec->dev, "Invalid DAI clock signal polarity\n"); + dev_err(component->dev, "Invalid DAI clock signal polarity\n"); return -EINVAL; } @@ -977,18 +977,18 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, AIC31XX_IFACE1_DATATYPE_SHIFT); break; default: - dev_err(codec->dev, "Invalid DAI interface format\n"); + dev_err(component->dev, "Invalid DAI interface format\n"); return -EINVAL; } - snd_soc_update_bits(codec, AIC31XX_IFACE1, + snd_soc_component_update_bits(component, AIC31XX_IFACE1, AIC31XX_IFACE1_DATATYPE_MASK | AIC31XX_IFACE1_MASTER_MASK, iface_reg1); - snd_soc_update_bits(codec, AIC31XX_DATA_OFFSET, + snd_soc_component_update_bits(component, AIC31XX_DATA_OFFSET, AIC31XX_DATA_OFFSET_MASK, dsp_a_val); - snd_soc_update_bits(codec, AIC31XX_IFACE2, + snd_soc_component_update_bits(component, AIC31XX_IFACE2, AIC31XX_BCLKINV_MASK, iface_reg2); @@ -998,11 +998,11 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int i; - dev_dbg(codec->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", + dev_dbg(component->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", __func__, clk_id, freq, dir); for (i = 1; i < 8; i++) @@ -1025,7 +1025,7 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, } /* set clock on MCLK, BCLK, or GPIO1 as PLL input */ - snd_soc_update_bits(codec, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, + snd_soc_component_update_bits(component, AIC31XX_CLKMUX, AIC31XX_PLL_CLKIN_MASK, clk_id << AIC31XX_PLL_CLKIN_SHIFT); aic31xx->sysclk = freq; @@ -1071,42 +1071,42 @@ static int aic31xx_reset(struct aic31xx_priv *aic31xx) return ret; } -static void aic31xx_clk_on(struct snd_soc_codec *codec) +static void aic31xx_clk_on(struct snd_soc_component *component) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); u8 mask = AIC31XX_PM_MASK; u8 on = AIC31XX_PM_MASK; - dev_dbg(codec->dev, "codec clock -> on (rate %d)\n", + dev_dbg(component->dev, "codec clock -> on (rate %d)\n", aic31xx_divs[aic31xx->rate_div_line].rate); - snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, on); + snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, on); mdelay(10); - snd_soc_update_bits(codec, AIC31XX_NDAC, mask, on); - snd_soc_update_bits(codec, AIC31XX_MDAC, mask, on); + snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, on); + snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, on); if (aic31xx_divs[aic31xx->rate_div_line].nadc) - snd_soc_update_bits(codec, AIC31XX_NADC, mask, on); + snd_soc_component_update_bits(component, AIC31XX_NADC, mask, on); if (aic31xx_divs[aic31xx->rate_div_line].madc) - snd_soc_update_bits(codec, AIC31XX_MADC, mask, on); - snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, on); + snd_soc_component_update_bits(component, AIC31XX_MADC, mask, on); + snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, on); } -static void aic31xx_clk_off(struct snd_soc_codec *codec) +static void aic31xx_clk_off(struct snd_soc_component *component) { u8 mask = AIC31XX_PM_MASK; u8 off = 0; - dev_dbg(codec->dev, "codec clock -> off\n"); - snd_soc_update_bits(codec, AIC31XX_BCLKN, mask, off); - snd_soc_update_bits(codec, AIC31XX_MADC, mask, off); - snd_soc_update_bits(codec, AIC31XX_NADC, mask, off); - snd_soc_update_bits(codec, AIC31XX_MDAC, mask, off); - snd_soc_update_bits(codec, AIC31XX_NDAC, mask, off); - snd_soc_update_bits(codec, AIC31XX_PLLPR, mask, off); + dev_dbg(component->dev, "codec clock -> off\n"); + snd_soc_component_update_bits(component, AIC31XX_BCLKN, mask, off); + snd_soc_component_update_bits(component, AIC31XX_MADC, mask, off); + snd_soc_component_update_bits(component, AIC31XX_NADC, mask, off); + snd_soc_component_update_bits(component, AIC31XX_MDAC, mask, off); + snd_soc_component_update_bits(component, AIC31XX_NDAC, mask, off); + snd_soc_component_update_bits(component, AIC31XX_PLLPR, mask, off); } -static int aic31xx_power_on(struct snd_soc_codec *codec) +static int aic31xx_power_on(struct snd_soc_component *component) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies), @@ -1123,7 +1123,7 @@ static int aic31xx_power_on(struct snd_soc_codec *codec) ret = regcache_sync(aic31xx->regmap); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to restore cache: %d\n", ret); regcache_cache_only(aic31xx->regmap, true); regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), @@ -1134,57 +1134,57 @@ static int aic31xx_power_on(struct snd_soc_codec *codec) return 0; } -static void aic31xx_power_off(struct snd_soc_codec *codec) +static void aic31xx_power_off(struct snd_soc_component *component) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); regcache_cache_only(aic31xx->regmap, true); regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), aic31xx->supplies); } -static int aic31xx_set_bias_level(struct snd_soc_codec *codec, +static int aic31xx_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - dev_dbg(codec->dev, "## %s: %d -> %d\n", __func__, - snd_soc_codec_get_bias_level(codec), level); + dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, + snd_soc_component_get_bias_level(component), level); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) - aic31xx_clk_on(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + aic31xx_clk_on(component); break; case SND_SOC_BIAS_STANDBY: - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_OFF: - aic31xx_power_on(codec); + aic31xx_power_on(component); break; case SND_SOC_BIAS_PREPARE: - aic31xx_clk_off(codec); + aic31xx_clk_off(component); break; default: BUG(); } break; case SND_SOC_BIAS_OFF: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) - aic31xx_power_off(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + aic31xx_power_off(component); break; } return 0; } -static int aic31xx_codec_probe(struct snd_soc_codec *codec) +static int aic31xx_codec_probe(struct snd_soc_component *component) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int i, ret; dev_dbg(aic31xx->dev, "## %s\n", __func__); - aic31xx->codec = codec; + aic31xx->component = component; for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { aic31xx->disable_nb[i].nb.notifier_call = @@ -1193,7 +1193,7 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec) ret = regulator_register_notifier(aic31xx->supplies[i].consumer, &aic31xx->disable_nb[i].nb); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to request regulator notifier: %d\n", ret); return ret; @@ -1203,43 +1203,42 @@ static int aic31xx_codec_probe(struct snd_soc_codec *codec) regcache_cache_only(aic31xx->regmap, true); regcache_mark_dirty(aic31xx->regmap); - ret = aic31xx_add_controls(codec); + ret = aic31xx_add_controls(component); if (ret) return ret; - ret = aic31xx_add_widgets(codec); + ret = aic31xx_add_widgets(component); if (ret) return ret; return 0; } -static int aic31xx_codec_remove(struct snd_soc_codec *codec) +static void aic31xx_codec_remove(struct snd_soc_component *component) { - struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) regulator_unregister_notifier(aic31xx->supplies[i].consumer, &aic31xx->disable_nb[i].nb); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_driver_aic31xx = { +static const struct snd_soc_component_driver soc_codec_driver_aic31xx = { .probe = aic31xx_codec_probe, .remove = aic31xx_codec_remove, .set_bias_level = aic31xx_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = common31xx_snd_controls, - .num_controls = ARRAY_SIZE(common31xx_snd_controls), - .dapm_widgets = common31xx_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets), - .dapm_routes = common31xx_audio_map, - .num_dapm_routes = ARRAY_SIZE(common31xx_audio_map), - }, + .controls = common31xx_snd_controls, + .num_controls = ARRAY_SIZE(common31xx_snd_controls), + .dapm_widgets = common31xx_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(common31xx_dapm_widgets), + .dapm_routes = common31xx_audio_map, + .num_dapm_routes = ARRAY_SIZE(common31xx_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct snd_soc_dai_ops aic31xx_dai_ops = { @@ -1375,23 +1374,17 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, } if (aic31xx->codec_type & DAC31XX_BIT) - return snd_soc_register_codec(&i2c->dev, + return devm_snd_soc_register_component(&i2c->dev, &soc_codec_driver_aic31xx, dac31xx_dai_driver, ARRAY_SIZE(dac31xx_dai_driver)); else - return snd_soc_register_codec(&i2c->dev, + return devm_snd_soc_register_component(&i2c->dev, &soc_codec_driver_aic31xx, aic31xx_dai_driver, ARRAY_SIZE(aic31xx_dai_driver)); } -static int aic31xx_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id aic31xx_i2c_id[] = { { "tlv320aic310x", AIC3100 }, { "tlv320aic311x", AIC3110 }, @@ -1412,7 +1405,6 @@ static struct i2c_driver aic31xx_i2c_driver = { .acpi_match_table = ACPI_PTR(aic31xx_acpi_match), }, .probe = aic31xx_i2c_probe, - .remove = aic31xx_i2c_remove, .id_table = aic31xx_i2c_id, }; module_i2c_driver(aic31xx_i2c_driver); From d0fdfe34080c64127b2e57525a84e3fb3cc29d87 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:15:57 +0000 Subject: [PATCH 118/942] ASoC: cx20442: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cx20442.c | 89 ++++++++++++++++++-------------------- sound/soc/omap/ams-delta.c | 20 ++++----- 2 files changed, 51 insertions(+), 58 deletions(-) diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c index 95bb10ba80dc..07dd33b09596 100644 --- a/sound/soc/codecs/cx20442.c +++ b/sound/soc/codecs/cx20442.c @@ -89,10 +89,10 @@ static const struct snd_soc_dapm_route cx20442_audio_map[] = { {"ADC", NULL, "Input Mixer"}, }; -static unsigned int cx20442_read_reg_cache(struct snd_soc_codec *codec, +static unsigned int cx20442_read_reg_cache(struct snd_soc_component *component, unsigned int reg) { - struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); + struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); if (reg >= 1) return -EINVAL; @@ -153,10 +153,10 @@ static int cx20442_pm_to_v253_vsp(u8 value) return (value & (1 << CX20442_AGC)) ? -EINVAL : 0; } -static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, +static int cx20442_write(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); + struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); int vls, vsp, old, len; char buf[18]; @@ -193,7 +193,7 @@ static int cx20442_write(struct snd_soc_codec *codec, unsigned int reg, if (unlikely(len > (ARRAY_SIZE(buf) - 1))) return -ENOMEM; - dev_dbg(codec->dev, "%s: %s\n", __func__, buf); + dev_dbg(component->dev, "%s: %s\n", __func__, buf); if (cx20442->tty->ops->write(cx20442->tty, buf, len) != len) return -EIO; @@ -240,19 +240,19 @@ err: /* Line discipline .close() */ static void v253_close(struct tty_struct *tty) { - struct snd_soc_codec *codec = tty->disc_data; + struct snd_soc_component *component = tty->disc_data; struct cx20442_priv *cx20442; tty->disc_data = NULL; - if (!codec) + if (!component) return; - cx20442 = snd_soc_codec_get_drvdata(codec); + cx20442 = snd_soc_component_get_drvdata(component); /* Prevent the codec driver from further accessing the modem */ cx20442->tty = NULL; - codec->component.card->pop_time = 0; + component->card->pop_time = 0; } /* Line discipline .hangup() */ @@ -266,20 +266,20 @@ static int v253_hangup(struct tty_struct *tty) static void v253_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) { - struct snd_soc_codec *codec = tty->disc_data; + struct snd_soc_component *component = tty->disc_data; struct cx20442_priv *cx20442; - if (!codec) + if (!component) return; - cx20442 = snd_soc_codec_get_drvdata(codec); + cx20442 = snd_soc_component_get_drvdata(component); if (!cx20442->tty) { /* First modem response, complete setup procedure */ /* Set up codec driver access to modem controls */ cx20442->tty = tty; - codec->component.card->pop_time = 1; + component->card->pop_time = 1; } } @@ -323,15 +323,15 @@ static struct snd_soc_dai_driver cx20442_dai = { }, }; -static int cx20442_set_bias_level(struct snd_soc_codec *codec, +static int cx20442_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); + struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); int err = 0; switch (level) { case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_STANDBY) + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_STANDBY) break; if (IS_ERR(cx20442->por)) err = PTR_ERR(cx20442->por); @@ -339,7 +339,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec, err = regulator_enable(cx20442->por); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_PREPARE) + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_PREPARE) break; if (IS_ERR(cx20442->por)) err = PTR_ERR(cx20442->por); @@ -353,7 +353,7 @@ static int cx20442_set_bias_level(struct snd_soc_codec *codec, return err; } -static int cx20442_codec_probe(struct snd_soc_codec *codec) +static int cx20442_component_probe(struct snd_soc_component *component) { struct cx20442_priv *cx20442; @@ -361,21 +361,21 @@ static int cx20442_codec_probe(struct snd_soc_codec *codec) if (cx20442 == NULL) return -ENOMEM; - cx20442->por = regulator_get(codec->dev, "POR"); + cx20442->por = regulator_get(component->dev, "POR"); if (IS_ERR(cx20442->por)) - dev_warn(codec->dev, "failed to get the regulator"); + dev_warn(component->dev, "failed to get the regulator"); cx20442->tty = NULL; - snd_soc_codec_set_drvdata(codec, cx20442); - codec->component.card->pop_time = 0; + snd_soc_component_set_drvdata(component, cx20442); + component->card->pop_time = 0; return 0; } /* power down chip */ -static int cx20442_codec_remove(struct snd_soc_codec *codec) +static void cx20442_component_remove(struct snd_soc_component *component) { - struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); + struct cx20442_priv *cx20442 = snd_soc_component_get_drvdata(component); if (cx20442->tty) { struct tty_struct *tty = cx20442->tty; @@ -387,36 +387,30 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec) regulator_put(cx20442->por); } - snd_soc_codec_set_drvdata(codec, NULL); + snd_soc_component_set_drvdata(component, NULL); kfree(cx20442); - return 0; } -static const struct snd_soc_codec_driver cx20442_codec_dev = { - .probe = cx20442_codec_probe, - .remove = cx20442_codec_remove, - .set_bias_level = cx20442_set_bias_level, - .read = cx20442_read_reg_cache, - .write = cx20442_write, - - .component_driver = { - .dapm_widgets = cx20442_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets), - .dapm_routes = cx20442_audio_map, - .num_dapm_routes = ARRAY_SIZE(cx20442_audio_map), - }, +static const struct snd_soc_component_driver cx20442_component_dev = { + .probe = cx20442_component_probe, + .remove = cx20442_component_remove, + .set_bias_level = cx20442_set_bias_level, + .read = cx20442_read_reg_cache, + .write = cx20442_write, + .dapm_widgets = cx20442_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cx20442_dapm_widgets), + .dapm_routes = cx20442_audio_map, + .num_dapm_routes = ARRAY_SIZE(cx20442_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int cx20442_platform_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &cx20442_codec_dev, &cx20442_dai, 1); -} - -static int cx20442_platform_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &cx20442_component_dev, &cx20442_dai, 1); } static struct platform_driver cx20442_platform_driver = { @@ -424,7 +418,6 @@ static struct platform_driver cx20442_platform_driver = { .name = "cx20442-codec", }, .probe = cx20442_platform_probe, - .remove = cx20442_platform_remove, }; module_platform_driver(cx20442_platform_driver); diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index cb72c1e57da0..77a30f0f0c96 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c @@ -93,7 +93,7 @@ static unsigned short ams_delta_audio_agc; * Used for passing a codec structure pointer * from the board initialization code to the tty line discipline. */ -static struct snd_soc_codec *cx20442_codec; +static struct snd_soc_component *cx20442_codec; static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) @@ -105,7 +105,7 @@ static int ams_delta_set_audio_mode(struct snd_kcontrol *kcontrol, int pin, changed = 0; /* Refuse any mode changes if we are not able to control the codec. */ - if (!cx20442_codec->component.card->pop_time) + if (!cx20442_codec->card->pop_time) return -EUNATCH; if (ucontrol->value.enumerated.item[0] >= control->items) @@ -300,15 +300,15 @@ static int cx81801_open(struct tty_struct *tty) /* Line discipline .close() */ static void cx81801_close(struct tty_struct *tty) { - struct snd_soc_codec *codec = tty->disc_data; - struct snd_soc_dapm_context *dapm = &codec->component.card->dapm; + struct snd_soc_component *component = tty->disc_data; + struct snd_soc_dapm_context *dapm = &component->card->dapm; del_timer_sync(&cx81801_timer); /* Prevent the hook switch from further changing the DAPM pins */ INIT_LIST_HEAD(&ams_delta_hook_switch.pins); - if (!codec) + if (!component) return; v253_ops.close(tty); @@ -338,14 +338,14 @@ static int cx81801_hangup(struct tty_struct *tty) static void cx81801_receive(struct tty_struct *tty, const unsigned char *cp, char *fp, int count) { - struct snd_soc_codec *codec = tty->disc_data; + struct snd_soc_component *component = tty->disc_data; const unsigned char *c; int apply, ret; - if (!codec) + if (!component) return; - if (!codec->component.card->pop_time) { + if (!component->card->pop_time) { /* First modem response, complete setup procedure */ /* Initialize timer used for config pulse generation */ @@ -358,7 +358,7 @@ static void cx81801_receive(struct tty_struct *tty, ARRAY_SIZE(ams_delta_hook_switch_pins), ams_delta_hook_switch_pins); if (ret) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to link hook switch to DAPM pins, " "will continue with hook switch unlinked.\n"); @@ -467,7 +467,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) /* Codec is ready, now add/activate board specific controls */ /* Store a pointer to the codec structure for tty ldisc use */ - cx20442_codec = rtd->codec; + cx20442_codec = rtd->codec_dai->component; /* Set up digital mute if not provided by the codec */ if (!codec_dai->driver->ops) { From 4e46c228c793d1a537deb1d26ed31a9b0543a20f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:16:23 +0000 Subject: [PATCH 119/942] ASoC: tscs42xx: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tscs42xx.c | 222 ++++++++++++++++++------------------ 1 file changed, 108 insertions(+), 114 deletions(-) diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c index e7661d0315e6..f4f8c613386a 100644 --- a/sound/soc/codecs/tscs42xx.c +++ b/sound/soc/codecs/tscs42xx.c @@ -91,15 +91,15 @@ static const struct regmap_config tscs42xx_regmap = { }; #define MAX_PLL_LOCK_20MS_WAITS 1 -static bool plls_locked(struct snd_soc_codec *codec) +static bool plls_locked(struct snd_soc_component *component) { int ret; int count = MAX_PLL_LOCK_20MS_WAITS; do { - ret = snd_soc_read(codec, R_PLLCTL0); + ret = snd_soc_component_read32(component, R_PLLCTL0); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read PLL lock status (%d)\n", ret); return false; } else if (ret > 0) { @@ -131,10 +131,10 @@ static int sample_rate_to_pll_freq_out(int sample_rate) } #define DACCRSTAT_MAX_TRYS 10 -static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, +static int write_coeff_ram(struct snd_soc_component *component, u8 *coeff_ram, unsigned int addr, unsigned int coeff_cnt) { - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); int cnt; int trys; int ret; @@ -142,9 +142,9 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, for (cnt = 0; cnt < coeff_cnt; cnt++, addr++) { for (trys = 0; trys < DACCRSTAT_MAX_TRYS; trys++) { - ret = snd_soc_read(codec, R_DACCRSTAT); + ret = snd_soc_component_read32(component, R_DACCRSTAT); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read stat (%d)\n", ret); return ret; } @@ -154,14 +154,14 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, if (trys == DACCRSTAT_MAX_TRYS) { ret = -EIO; - dev_err(codec->dev, + dev_err(component->dev, "dac coefficient write error (%d)\n", ret); return ret; } ret = regmap_write(tscs42xx->regmap, R_DACCRADDR, addr); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to write dac ram address (%d)\n", ret); return ret; } @@ -170,7 +170,7 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, &coeff_ram[addr * COEFF_SIZE], COEFF_SIZE); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to write dac ram (%d)\n", ret); return ret; } @@ -179,9 +179,9 @@ static int write_coeff_ram(struct snd_soc_codec *codec, u8 *coeff_ram, return 0; } -static int power_up_audio_plls(struct snd_soc_codec *codec) +static int power_up_audio_plls(struct snd_soc_component *component) { - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); int freq_out; int ret; unsigned int mask; @@ -199,20 +199,20 @@ static int power_up_audio_plls(struct snd_soc_codec *codec) break; default: ret = -EINVAL; - dev_err(codec->dev, "Unrecognized PLL output freq (%d)\n", ret); + dev_err(component->dev, "Unrecognized PLL output freq (%d)\n", ret); return ret; } mutex_lock(&tscs42xx->pll_lock); - ret = snd_soc_update_bits(codec, R_PLLCTL1C, mask, val); + ret = snd_soc_component_update_bits(component, R_PLLCTL1C, mask, val); if (ret < 0) { - dev_err(codec->dev, "Failed to turn PLL on (%d)\n", ret); + dev_err(component->dev, "Failed to turn PLL on (%d)\n", ret); goto exit; } - if (!plls_locked(codec)) { - dev_err(codec->dev, "Failed to lock plls\n"); + if (!plls_locked(component)) { + dev_err(component->dev, "Failed to lock plls\n"); ret = -ENOMSG; goto exit; } @@ -224,25 +224,25 @@ exit: return ret; } -static int power_down_audio_plls(struct snd_soc_codec *codec) +static int power_down_audio_plls(struct snd_soc_component *component) { - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&tscs42xx->pll_lock); - ret = snd_soc_update_bits(codec, R_PLLCTL1C, + ret = snd_soc_component_update_bits(component, R_PLLCTL1C, RM_PLLCTL1C_PDB_PLL1, RV_PLLCTL1C_PDB_PLL1_DISABLE); if (ret < 0) { - dev_err(codec->dev, "Failed to turn PLL off (%d)\n", ret); + dev_err(component->dev, "Failed to turn PLL off (%d)\n", ret); goto exit; } - ret = snd_soc_update_bits(codec, R_PLLCTL1C, + ret = snd_soc_component_update_bits(component, R_PLLCTL1C, RM_PLLCTL1C_PDB_PLL2, RV_PLLCTL1C_PDB_PLL2_DISABLE); if (ret < 0) { - dev_err(codec->dev, "Failed to turn PLL off (%d)\n", ret); + dev_err(component->dev, "Failed to turn PLL off (%d)\n", ret); goto exit; } @@ -256,8 +256,8 @@ exit: static int coeff_ram_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); struct coeff_ram_ctl *ctl = (struct coeff_ram_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -275,8 +275,8 @@ static int coeff_ram_get(struct snd_kcontrol *kcontrol, static int coeff_ram_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); struct coeff_ram_ctl *ctl = (struct coeff_ram_ctl *)kcontrol->private_value; struct soc_bytes_ext *params = &ctl->bytes_ext; @@ -292,11 +292,11 @@ static int coeff_ram_put(struct snd_kcontrol *kcontrol, mutex_lock(&tscs42xx->pll_lock); - if (plls_locked(codec)) { - ret = write_coeff_ram(codec, tscs42xx->coeff_ram, + if (plls_locked(component)) { + ret = write_coeff_ram(component, tscs42xx->coeff_ram, ctl->addr, coeff_cnt); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to flush coeff ram cache (%d)\n", ret); goto exit; } @@ -358,13 +358,13 @@ static int dapm_micb_event(struct snd_soc_dapm_widget *w, static int pll_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int ret; if (SND_SOC_DAPM_EVENT_ON(event)) - ret = power_up_audio_plls(codec); + ret = power_up_audio_plls(component); else - ret = power_down_audio_plls(codec); + ret = power_down_audio_plls(component); return ret; } @@ -372,14 +372,14 @@ static int pll_event(struct snd_soc_dapm_widget *w, static int dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&tscs42xx->coeff_ram_lock); if (tscs42xx->coeff_ram_synced == false) { - ret = write_coeff_ram(codec, tscs42xx->coeff_ram, 0x00, + ret = write_coeff_ram(component, tscs42xx->coeff_ram, 0x00, COEFF_RAM_COEFF_COUNT); if (ret < 0) goto exit; @@ -790,7 +790,7 @@ static const struct snd_kcontrol_new tscs42xx_snd_controls[] = { R_DACMBCREL3L, 2), }; -static int setup_sample_format(struct snd_soc_codec *codec, +static int setup_sample_format(struct snd_soc_component *component, snd_pcm_format_t format) { unsigned int width; @@ -811,21 +811,21 @@ static int setup_sample_format(struct snd_soc_codec *codec, break; default: ret = -EINVAL; - dev_err(codec->dev, "Unsupported format width (%d)\n", ret); + dev_err(component->dev, "Unsupported format width (%d)\n", ret); return ret; } - ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_WL, width); + ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_WL, width); if (ret < 0) { - dev_err(codec->dev, "Failed to set sample width (%d)\n", ret); + dev_err(component->dev, "Failed to set sample width (%d)\n", ret); return ret; } return 0; } -static int setup_sample_rate(struct snd_soc_codec *codec, unsigned int rate) +static int setup_sample_rate(struct snd_soc_component *component, unsigned int rate) { - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); unsigned int br, bm; int ret; @@ -871,29 +871,29 @@ static int setup_sample_rate(struct snd_soc_codec *codec, unsigned int rate) bm = RV_DACSR_DBM_2; break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", rate); + dev_err(component->dev, "Unsupported sample rate %d\n", rate); return -EINVAL; } /* DAC and ADC share bit and frame clock */ - ret = snd_soc_update_bits(codec, R_DACSR, RM_DACSR_DBR, br); + ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBR, br); if (ret < 0) { - dev_err(codec->dev, "Failed to update register (%d)\n", ret); + dev_err(component->dev, "Failed to update register (%d)\n", ret); return ret; } - ret = snd_soc_update_bits(codec, R_DACSR, RM_DACSR_DBM, bm); + ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBM, bm); if (ret < 0) { - dev_err(codec->dev, "Failed to update register (%d)\n", ret); + dev_err(component->dev, "Failed to update register (%d)\n", ret); return ret; } - ret = snd_soc_update_bits(codec, R_ADCSR, RM_DACSR_DBR, br); + ret = snd_soc_component_update_bits(component, R_ADCSR, RM_DACSR_DBR, br); if (ret < 0) { - dev_err(codec->dev, "Failed to update register (%d)\n", ret); + dev_err(component->dev, "Failed to update register (%d)\n", ret); return ret; } - ret = snd_soc_update_bits(codec, R_ADCSR, RM_DACSR_DBM, bm); + ret = snd_soc_component_update_bits(component, R_ADCSR, RM_DACSR_DBM, bm); if (ret < 0) { - dev_err(codec->dev, "Failed to update register (%d)\n", ret); + dev_err(component->dev, "Failed to update register (%d)\n", ret); return ret; } @@ -1025,7 +1025,7 @@ static const struct pll_ctl *get_pll_ctl(int input_freq) return pll_ctl; } -static int set_pll_ctl_from_input_freq(struct snd_soc_codec *codec, +static int set_pll_ctl_from_input_freq(struct snd_soc_component *component, const int input_freq) { int ret; @@ -1035,18 +1035,18 @@ static int set_pll_ctl_from_input_freq(struct snd_soc_codec *codec, pll_ctl = get_pll_ctl(input_freq); if (!pll_ctl) { ret = -EINVAL; - dev_err(codec->dev, "No PLL input entry for %d (%d)\n", + dev_err(component->dev, "No PLL input entry for %d (%d)\n", input_freq, ret); return ret; } for (i = 0; i < PLL_REG_SETTINGS_COUNT; ++i) { - ret = snd_soc_update_bits(codec, + ret = snd_soc_component_update_bits(component, pll_ctl->settings[i].addr, pll_ctl->settings[i].mask, pll_ctl->settings[i].val); if (ret < 0) { - dev_err(codec->dev, "Failed to set pll ctl (%d)\n", + dev_err(component->dev, "Failed to set pll ctl (%d)\n", ret); return ret; } @@ -1059,33 +1059,33 @@ static int tscs42xx_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int ret; - ret = setup_sample_format(codec, params_format(params)); + ret = setup_sample_format(component, params_format(params)); if (ret < 0) { - dev_err(codec->dev, "Failed to setup sample format (%d)\n", + dev_err(component->dev, "Failed to setup sample format (%d)\n", ret); return ret; } - ret = setup_sample_rate(codec, params_rate(params)); + ret = setup_sample_rate(component, params_rate(params)); if (ret < 0) { - dev_err(codec->dev, "Failed to setup sample rate (%d)\n", ret); + dev_err(component->dev, "Failed to setup sample rate (%d)\n", ret); return ret; } return 0; } -static inline int dac_mute(struct snd_soc_codec *codec) +static inline int dac_mute(struct snd_soc_component *component) { int ret; - ret = snd_soc_update_bits(codec, R_CNVRTR1, RM_CNVRTR1_DACMU, + ret = snd_soc_component_update_bits(component, R_CNVRTR1, RM_CNVRTR1_DACMU, RV_CNVRTR1_DACMU_ENABLE); if (ret < 0) { - dev_err(codec->dev, "Failed to mute DAC (%d)\n", + dev_err(component->dev, "Failed to mute DAC (%d)\n", ret); return ret; } @@ -1093,14 +1093,14 @@ static inline int dac_mute(struct snd_soc_codec *codec) return 0; } -static inline int dac_unmute(struct snd_soc_codec *codec) +static inline int dac_unmute(struct snd_soc_component *component) { int ret; - ret = snd_soc_update_bits(codec, R_CNVRTR1, RM_CNVRTR1_DACMU, + ret = snd_soc_component_update_bits(component, R_CNVRTR1, RM_CNVRTR1_DACMU, RV_CNVRTR1_DACMU_DISABLE); if (ret < 0) { - dev_err(codec->dev, "Failed to unmute DAC (%d)\n", + dev_err(component->dev, "Failed to unmute DAC (%d)\n", ret); return ret; } @@ -1108,14 +1108,14 @@ static inline int dac_unmute(struct snd_soc_codec *codec) return 0; } -static inline int adc_mute(struct snd_soc_codec *codec) +static inline int adc_mute(struct snd_soc_component *component) { int ret; - ret = snd_soc_update_bits(codec, R_CNVRTR0, RM_CNVRTR0_ADCMU, + ret = snd_soc_component_update_bits(component, R_CNVRTR0, RM_CNVRTR0_ADCMU, RV_CNVRTR0_ADCMU_ENABLE); if (ret < 0) { - dev_err(codec->dev, "Failed to mute ADC (%d)\n", + dev_err(component->dev, "Failed to mute ADC (%d)\n", ret); return ret; } @@ -1123,14 +1123,14 @@ static inline int adc_mute(struct snd_soc_codec *codec) return 0; } -static inline int adc_unmute(struct snd_soc_codec *codec) +static inline int adc_unmute(struct snd_soc_component *component) { int ret; - ret = snd_soc_update_bits(codec, R_CNVRTR0, RM_CNVRTR0_ADCMU, + ret = snd_soc_component_update_bits(component, R_CNVRTR0, RM_CNVRTR0_ADCMU, RV_CNVRTR0_ADCMU_DISABLE); if (ret < 0) { - dev_err(codec->dev, "Failed to unmute ADC (%d)\n", + dev_err(component->dev, "Failed to unmute ADC (%d)\n", ret); return ret; } @@ -1140,19 +1140,19 @@ static inline int adc_unmute(struct snd_soc_codec *codec) static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int ret; if (mute) if (stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = dac_mute(codec); + ret = dac_mute(component); else - ret = adc_mute(codec); + ret = adc_mute(component); else if (stream == SNDRV_PCM_STREAM_PLAYBACK) - ret = dac_unmute(codec); + ret = dac_unmute(component); else - ret = adc_unmute(codec); + ret = adc_unmute(component); return ret; } @@ -1160,23 +1160,23 @@ static int tscs42xx_mute_stream(struct snd_soc_dai *dai, int mute, int stream) static int tscs42xx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int ret; /* Slave mode not supported since it needs always-on frame clock */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - ret = snd_soc_update_bits(codec, R_AIC1, RM_AIC1_MS, + ret = snd_soc_component_update_bits(component, R_AIC1, RM_AIC1_MS, RV_AIC1_MS_MASTER); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set codec DAI master (%d)\n", ret); return ret; } break; default: ret = -EINVAL; - dev_err(codec->dev, "Unsupported format (%d)\n", ret); + dev_err(component->dev, "Unsupported format (%d)\n", ret); return ret; } @@ -1186,8 +1186,8 @@ static int tscs42xx_set_dai_fmt(struct snd_soc_dai *codec_dai, static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai, unsigned int ratio) { - struct snd_soc_codec *codec = codec_dai->codec; - struct tscs42xx *tscs42xx = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct tscs42xx *tscs42xx = snd_soc_component_get_drvdata(component); unsigned int value; int ret = 0; @@ -1202,18 +1202,18 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai, value = RV_DACSR_DBCM_64; break; default: - dev_err(codec->dev, "Unsupported bclk ratio (%d)\n", ret); + dev_err(component->dev, "Unsupported bclk ratio (%d)\n", ret); return -EINVAL; } - ret = snd_soc_update_bits(codec, R_DACSR, RM_DACSR_DBCM, value); + ret = snd_soc_component_update_bits(component, R_DACSR, RM_DACSR_DBCM, value); if (ret < 0) { - dev_err(codec->dev, "Failed to set DAC BCLK ratio (%d)\n", ret); + dev_err(component->dev, "Failed to set DAC BCLK ratio (%d)\n", ret); return ret; } - ret = snd_soc_update_bits(codec, R_ADCSR, RM_ADCSR_ABCM, value); + ret = snd_soc_component_update_bits(component, R_ADCSR, RM_ADCSR_ABCM, value); if (ret < 0) { - dev_err(codec->dev, "Failed to set ADC BCLK ratio (%d)\n", ret); + dev_err(component->dev, "Failed to set ADC BCLK ratio (%d)\n", ret); return ret; } @@ -1229,40 +1229,40 @@ static int tscs42xx_set_dai_bclk_ratio(struct snd_soc_dai *codec_dai, static int tscs42xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int ret; switch (clk_id) { case TSCS42XX_PLL_SRC_XTAL: case TSCS42XX_PLL_SRC_MCLK1: - ret = snd_soc_write(codec, R_PLLREFSEL, + ret = snd_soc_component_write(component, R_PLLREFSEL, RV_PLLREFSEL_PLL1_REF_SEL_XTAL_MCLK1 | RV_PLLREFSEL_PLL2_REF_SEL_XTAL_MCLK1); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set pll reference input (%d)\n", ret); return ret; } break; case TSCS42XX_PLL_SRC_MCLK2: - ret = snd_soc_write(codec, R_PLLREFSEL, + ret = snd_soc_component_write(component, R_PLLREFSEL, RV_PLLREFSEL_PLL1_REF_SEL_MCLK2 | RV_PLLREFSEL_PLL2_REF_SEL_MCLK2); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set PLL reference (%d)\n", ret); return ret; } break; default: - dev_err(codec->dev, "pll src is unsupported\n"); + dev_err(component->dev, "pll src is unsupported\n"); return -EINVAL; } - ret = set_pll_ctl_from_input_freq(codec, freq); + ret = set_pll_ctl_from_input_freq(component, freq); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to setup PLL input freq (%d)\n", ret); return ret; } @@ -1304,15 +1304,17 @@ static int part_is_valid(struct tscs42xx *tscs42xx) }; } -static struct snd_soc_codec_driver soc_codec_dev_tscs42xx = { - .component_driver = { - .dapm_widgets = tscs42xx_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tscs42xx_dapm_widgets), - .dapm_routes = tscs42xx_intercon, - .num_dapm_routes = ARRAY_SIZE(tscs42xx_intercon), - .controls = tscs42xx_snd_controls, - .num_controls = ARRAY_SIZE(tscs42xx_snd_controls), - }, +static struct snd_soc_component_driver soc_codec_dev_tscs42xx = { + .dapm_widgets = tscs42xx_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tscs42xx_dapm_widgets), + .dapm_routes = tscs42xx_intercon, + .num_dapm_routes = ARRAY_SIZE(tscs42xx_intercon), + .controls = tscs42xx_snd_controls, + .num_controls = ARRAY_SIZE(tscs42xx_snd_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static inline void init_coeff_ram_cache(struct tscs42xx *tscs42xx) @@ -1407,7 +1409,7 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c, mutex_init(&tscs42xx->coeff_ram_lock); mutex_init(&tscs42xx->pll_lock); - ret = snd_soc_register_codec(tscs42xx->dev, &soc_codec_dev_tscs42xx, + ret = devm_snd_soc_register_component(tscs42xx->dev, &soc_codec_dev_tscs42xx, &tscs42xx_dai, 1); if (ret) { dev_err(tscs42xx->dev, "Failed to register codec (%d)\n", ret); @@ -1417,13 +1419,6 @@ static int tscs42xx_i2c_probe(struct i2c_client *i2c, return 0; } -static int tscs42xx_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id tscs42xx_i2c_id[] = { { "tscs42A1", 0 }, { "tscs42A2", 0 }, @@ -1445,7 +1440,6 @@ static struct i2c_driver tscs42xx_i2c_driver = { .of_match_table = tscs42xx_of_match, }, .probe = tscs42xx_i2c_probe, - .remove = tscs42xx_i2c_remove, .id_table = tscs42xx_i2c_id, }; From db0a11d00220cf84bec2047fe698004813096926 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:16:56 +0000 Subject: [PATCH 120/942] ASoC: pcm179x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Reviewed-by: Michael Trimarchi Signed-off-by: Mark Brown --- sound/soc/codecs/pcm179x-i2c.c | 6 ----- sound/soc/codecs/pcm179x-spi.c | 6 ----- sound/soc/codecs/pcm179x.c | 45 +++++++++++++++------------------- sound/soc/codecs/pcm179x.h | 1 - 4 files changed, 20 insertions(+), 38 deletions(-) diff --git a/sound/soc/codecs/pcm179x-i2c.c b/sound/soc/codecs/pcm179x-i2c.c index 4118106abb8d..03747966c6bc 100644 --- a/sound/soc/codecs/pcm179x-i2c.c +++ b/sound/soc/codecs/pcm179x-i2c.c @@ -39,11 +39,6 @@ static int pcm179x_i2c_probe(struct i2c_client *client, return pcm179x_common_init(&client->dev, regmap); } -static int pcm179x_i2c_remove(struct i2c_client *client) -{ - return pcm179x_common_exit(&client->dev); -} - static const struct of_device_id pcm179x_of_match[] = { { .compatible = "ti,pcm1792a", }, { } @@ -63,7 +58,6 @@ static struct i2c_driver pcm179x_i2c_driver = { }, .id_table = pcm179x_i2c_ids, .probe = pcm179x_i2c_probe, - .remove = pcm179x_i2c_remove, }; module_i2c_driver(pcm179x_i2c_driver); diff --git a/sound/soc/codecs/pcm179x-spi.c b/sound/soc/codecs/pcm179x-spi.c index da924d444083..89ad715676fc 100644 --- a/sound/soc/codecs/pcm179x-spi.c +++ b/sound/soc/codecs/pcm179x-spi.c @@ -38,11 +38,6 @@ static int pcm179x_spi_probe(struct spi_device *spi) return pcm179x_common_init(&spi->dev, regmap); } -static int pcm179x_spi_remove(struct spi_device *spi) -{ - return pcm179x_common_exit(&spi->dev); -} - static const struct of_device_id pcm179x_of_match[] = { { .compatible = "ti,pcm1792a", }, { } @@ -62,7 +57,6 @@ static struct spi_driver pcm179x_spi_driver = { }, .id_table = pcm179x_spi_ids, .probe = pcm179x_spi_probe, - .remove = pcm179x_spi_remove, }; module_spi_driver(pcm179x_spi_driver); diff --git a/sound/soc/codecs/pcm179x.c b/sound/soc/codecs/pcm179x.c index 82a3d9db32cb..4b311c06f97d 100644 --- a/sound/soc/codecs/pcm179x.c +++ b/sound/soc/codecs/pcm179x.c @@ -77,8 +77,8 @@ struct pcm179x_private { static int pcm179x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct pcm179x_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct pcm179x_private *priv = snd_soc_component_get_drvdata(component); priv->format = format; @@ -87,8 +87,8 @@ static int pcm179x_set_dai_fmt(struct snd_soc_dai *codec_dai, static int pcm179x_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct pcm179x_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm179x_private *priv = snd_soc_component_get_drvdata(component); int ret; ret = regmap_update_bits(priv->regmap, PCM179X_SOFT_MUTE, @@ -103,8 +103,8 @@ static int pcm179x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct pcm179x_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm179x_private *priv = snd_soc_component_get_drvdata(component); int val = 0, ret; priv->rate = params_rate(params); @@ -137,7 +137,7 @@ static int pcm179x_hw_params(struct snd_pcm_substream *substream, } break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -205,15 +205,17 @@ const struct regmap_config pcm179x_regmap_config = { }; EXPORT_SYMBOL_GPL(pcm179x_regmap_config); -static const struct snd_soc_codec_driver soc_codec_dev_pcm179x = { - .component_driver = { - .controls = pcm179x_controls, - .num_controls = ARRAY_SIZE(pcm179x_controls), - .dapm_widgets = pcm179x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm179x_dapm_widgets), - .dapm_routes = pcm179x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm179x_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_pcm179x = { + .controls = pcm179x_controls, + .num_controls = ARRAY_SIZE(pcm179x_controls), + .dapm_widgets = pcm179x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm179x_dapm_widgets), + .dapm_routes = pcm179x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm179x_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; int pcm179x_common_init(struct device *dev, struct regmap *regmap) @@ -228,18 +230,11 @@ int pcm179x_common_init(struct device *dev, struct regmap *regmap) pcm179x->regmap = regmap; dev_set_drvdata(dev, pcm179x); - return snd_soc_register_codec(dev, - &soc_codec_dev_pcm179x, &pcm179x_dai, 1); + return devm_snd_soc_register_component(dev, + &soc_component_dev_pcm179x, &pcm179x_dai, 1); } EXPORT_SYMBOL_GPL(pcm179x_common_init); -int pcm179x_common_exit(struct device *dev) -{ - snd_soc_unregister_codec(dev); - return 0; -} -EXPORT_SYMBOL_GPL(pcm179x_common_exit); - MODULE_DESCRIPTION("ASoC PCM179X driver"); MODULE_AUTHOR("Michael Trimarchi "); MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/pcm179x.h b/sound/soc/codecs/pcm179x.h index 11e331268aae..cf8681c9a373 100644 --- a/sound/soc/codecs/pcm179x.h +++ b/sound/soc/codecs/pcm179x.h @@ -23,6 +23,5 @@ extern const struct regmap_config pcm179x_regmap_config; int pcm179x_common_init(struct device *dev, struct regmap *regmap); -int pcm179x_common_exit(struct device *dev); #endif From d66827daf16d8ceb46d985b2dc423f3c3136bce0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:17:53 +0000 Subject: [PATCH 121/942] ASoC: pcm3008: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/pcm3008.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/sound/soc/codecs/pcm3008.c b/sound/soc/codecs/pcm3008.c index e59d8ffb93bd..c6ce9bd77c5e 100644 --- a/sound/soc/codecs/pcm3008.c +++ b/sound/soc/codecs/pcm3008.c @@ -32,8 +32,8 @@ static int pcm3008_dac_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pcm3008_setup_data *setup = codec->dev->platform_data; + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pcm3008_setup_data *setup = component->dev->platform_data; gpio_set_value_cansleep(setup->pdda_pin, SND_SOC_DAPM_EVENT_ON(event)); @@ -45,8 +45,8 @@ static int pcm3008_adc_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pcm3008_setup_data *setup = codec->dev->platform_data; + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pcm3008_setup_data *setup = component->dev->platform_data; gpio_set_value_cansleep(setup->pdad_pin, SND_SOC_DAPM_EVENT_ON(event)); @@ -98,13 +98,15 @@ static struct snd_soc_dai_driver pcm3008_dai = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_pcm3008 = { - .component_driver = { - .dapm_widgets = pcm3008_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm3008_dapm_widgets), - .dapm_routes = pcm3008_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm3008_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_pcm3008 = { + .dapm_widgets = pcm3008_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm3008_dapm_widgets), + .dapm_routes = pcm3008_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm3008_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int pcm3008_codec_probe(struct platform_device *pdev) @@ -146,22 +148,14 @@ static int pcm3008_codec_probe(struct platform_device *pdev) if (ret != 0) return ret; - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_pcm3008, &pcm3008_dai, 1); -} - -static int pcm3008_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_pcm3008, &pcm3008_dai, 1); } MODULE_ALIAS("platform:pcm3008-codec"); static struct platform_driver pcm3008_codec_driver = { .probe = pcm3008_codec_probe, - .remove = pcm3008_codec_remove, .driver = { .name = "pcm3008-codec", }, From 7dbbaa5180cb380ac28f023dda8663d8dd3b8b56 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:18:12 +0000 Subject: [PATCH 122/942] ASoC: pcm1681: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/pcm1681.c | 62 ++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 33 deletions(-) diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index c7e28dd2e815..84777d3fa464 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c @@ -90,9 +90,9 @@ struct pcm1681_private { static const int pcm1681_deemph[] = { 44100, 48000, 32000 }; -static int pcm1681_set_deemph(struct snd_soc_codec *codec) +static int pcm1681_set_deemph(struct snd_soc_component *component) { - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); int i = 0, val = -1, enable = 0; if (priv->deemph) { @@ -120,8 +120,8 @@ static int pcm1681_set_deemph(struct snd_soc_codec *codec) static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = priv->deemph; @@ -131,23 +131,23 @@ static int pcm1681_get_deemph(struct snd_kcontrol *kcontrol, static int pcm1681_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); priv->deemph = ucontrol->value.integer.value[0]; - return pcm1681_set_deemph(codec); + return pcm1681_set_deemph(component); } static int pcm1681_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); /* The PCM1681 can only be slave to all clocks */ if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_err(codec->dev, "Invalid clocking mode\n"); + dev_err(component->dev, "Invalid clocking mode\n"); return -EINVAL; } @@ -158,8 +158,8 @@ static int pcm1681_set_dai_fmt(struct snd_soc_dai *codec_dai, static int pcm1681_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); int val; if (mute) @@ -174,8 +174,8 @@ static int pcm1681_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct pcm1681_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm1681_private *priv = snd_soc_component_get_drvdata(component); int val = 0, ret; priv->rate = params_rate(params); @@ -200,7 +200,7 @@ static int pcm1681_hw_params(struct snd_pcm_substream *substream, val = 0x05; break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -208,7 +208,7 @@ static int pcm1681_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - return pcm1681_set_deemph(codec); + return pcm1681_set_deemph(component); } static const struct snd_soc_dai_ops pcm1681_dai_ops = { @@ -288,15 +288,17 @@ static const struct regmap_config pcm1681_regmap = { .readable_reg = pcm1681_accessible_reg, }; -static const struct snd_soc_codec_driver soc_codec_dev_pcm1681 = { - .component_driver = { - .controls = pcm1681_controls, - .num_controls = ARRAY_SIZE(pcm1681_controls), - .dapm_widgets = pcm1681_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm1681_dapm_widgets), - .dapm_routes = pcm1681_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm1681_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_pcm1681 = { + .controls = pcm1681_controls, + .num_controls = ARRAY_SIZE(pcm1681_controls), + .dapm_widgets = pcm1681_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm1681_dapm_widgets), + .dapm_routes = pcm1681_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm1681_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct i2c_device_id pcm1681_i2c_id[] = { @@ -324,16 +326,11 @@ static int pcm1681_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, priv); - return snd_soc_register_codec(&client->dev, &soc_codec_dev_pcm1681, + return devm_snd_soc_register_component(&client->dev, + &soc_component_dev_pcm1681, &pcm1681_dai, 1); } -static int pcm1681_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static struct i2c_driver pcm1681_i2c_driver = { .driver = { .name = "pcm1681", @@ -341,7 +338,6 @@ static struct i2c_driver pcm1681_i2c_driver = { }, .id_table = pcm1681_i2c_id, .probe = pcm1681_i2c_probe, - .remove = pcm1681_i2c_remove, }; module_i2c_driver(pcm1681_i2c_driver); From 5bdef14a35bb99e792951113487043f95f579a05 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:18:32 +0000 Subject: [PATCH 123/942] ASoC: pcm512x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/pcm512x.c | 162 ++++++++++++++++++------------------- 1 file changed, 80 insertions(+), 82 deletions(-) diff --git a/sound/soc/codecs/pcm512x.c b/sound/soc/codecs/pcm512x.c index e0f3556d3872..f0f2d4fd3769 100644 --- a/sound/soc/codecs/pcm512x.c +++ b/sound/soc/codecs/pcm512x.c @@ -226,8 +226,8 @@ static bool pcm512x_volatile(struct device *dev, unsigned int reg) static int pcm512x_overclock_pll_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = pcm512x->overclock_pll; return 0; @@ -236,10 +236,10 @@ static int pcm512x_overclock_pll_get(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_pll_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_STANDBY: break; @@ -254,8 +254,8 @@ static int pcm512x_overclock_pll_put(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dsp_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = pcm512x->overclock_dsp; return 0; @@ -264,10 +264,10 @@ static int pcm512x_overclock_dsp_get(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dsp_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_STANDBY: break; @@ -282,8 +282,8 @@ static int pcm512x_overclock_dsp_put(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = pcm512x->overclock_dac; return 0; @@ -292,10 +292,10 @@ static int pcm512x_overclock_dac_get(struct snd_kcontrol *kcontrol, static int pcm512x_overclock_dac_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); - switch (snd_soc_codec_get_bias_level(codec)) { + switch (snd_soc_component_get_bias_level(component)) { case SND_SOC_BIAS_OFF: case SND_SOC_BIAS_STANDBY: break; @@ -522,8 +522,8 @@ static int pcm512x_hw_rule_rate(struct snd_pcm_hw_params *params, static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); struct device *dev = dai->dev; struct snd_pcm_hw_constraint_ratnums *constraints_no_pll; struct snd_ratnum *rats_no_pll; @@ -564,8 +564,8 @@ static int pcm512x_dai_startup_master(struct snd_pcm_substream *substream, static int pcm512x_dai_startup_slave(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); struct device *dev = dai->dev; struct regmap *regmap = pcm512x->regmap; @@ -590,8 +590,8 @@ static int pcm512x_dai_startup_slave(struct snd_pcm_substream *substream, static int pcm512x_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); switch (pcm512x->fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: @@ -606,10 +606,10 @@ static int pcm512x_dai_startup(struct snd_pcm_substream *substream, } } -static int pcm512x_set_bias_level(struct snd_soc_codec *codec, +static int pcm512x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct pcm512x_priv *pcm512x = dev_get_drvdata(codec->dev); + struct pcm512x_priv *pcm512x = dev_get_drvdata(component->dev); int ret; switch (level) { @@ -621,7 +621,7 @@ static int pcm512x_set_bias_level(struct snd_soc_codec *codec, ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, PCM512x_RQST, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to remove standby: %d\n", + dev_err(component->dev, "Failed to remove standby: %d\n", ret); return ret; } @@ -631,7 +631,7 @@ static int pcm512x_set_bias_level(struct snd_soc_codec *codec, ret = regmap_update_bits(pcm512x->regmap, PCM512x_POWER, PCM512x_RQST, PCM512x_RQST); if (ret != 0) { - dev_err(codec->dev, "Failed to request standby: %d\n", + dev_err(component->dev, "Failed to request standby: %d\n", ret); return ret; } @@ -645,8 +645,8 @@ static unsigned long pcm512x_find_sck(struct snd_soc_dai *dai, unsigned long bclk_rate) { struct device *dev = dai->dev; - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); unsigned long sck_rate; int pow2; @@ -691,8 +691,8 @@ static int pcm512x_find_pll_coeff(struct snd_soc_dai *dai, unsigned long pll_rate) { struct device *dev = dai->dev; - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); unsigned long common; int R, J, D, P; unsigned long K; /* 10000 * J.D */ @@ -798,8 +798,8 @@ static unsigned long pcm512x_pllin_dac_rate(struct snd_soc_dai *dai, unsigned long osr_rate, unsigned long pllin_rate) { - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); unsigned long dac_rate; if (!pcm512x->pll_out) @@ -829,8 +829,8 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, struct snd_pcm_hw_params *params) { struct device *dev = dai->dev; - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); unsigned long pllin_rate = 0; unsigned long pll_rate; unsigned long sck_rate; @@ -949,7 +949,7 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, PCM512x_SDAC, PCM512x_SDAC_GPIO); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set gpio as dacref: %d\n", ret); return ret; } @@ -958,7 +958,7 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_DACIN, PCM512x_GREF, gpio); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set gpio %d as dacin: %d\n", pcm512x->pll_in, ret); return ret; @@ -987,7 +987,7 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, ret = regmap_update_bits(pcm512x->regmap, PCM512x_DAC_REF, PCM512x_SDAC, PCM512x_SDAC_SCK); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set sck as dacref: %d\n", ret); return ret; } @@ -1082,18 +1082,18 @@ static int pcm512x_set_dividers(struct snd_soc_dai *dai, ret = regmap_update_bits(pcm512x->regmap, PCM512x_FS_SPEED_MODE, PCM512x_FSSP, fssp); if (ret != 0) { - dev_err(codec->dev, "Failed to set fs speed: %d\n", ret); + dev_err(component->dev, "Failed to set fs speed: %d\n", ret); return ret; } - dev_dbg(codec->dev, "DSP divider %d\n", dsp_div); - dev_dbg(codec->dev, "DAC divider %d\n", dac_div); - dev_dbg(codec->dev, "NCP divider %d\n", ncp_div); - dev_dbg(codec->dev, "OSR divider %d\n", osr_div); - dev_dbg(codec->dev, "BCK divider %d\n", bclk_div); - dev_dbg(codec->dev, "LRCK divider %d\n", lrclk_div); - dev_dbg(codec->dev, "IDAC %d\n", idac); - dev_dbg(codec->dev, "1<dev, "DSP divider %d\n", dsp_div); + dev_dbg(component->dev, "DAC divider %d\n", dac_div); + dev_dbg(component->dev, "NCP divider %d\n", ncp_div); + dev_dbg(component->dev, "OSR divider %d\n", osr_div); + dev_dbg(component->dev, "BCK divider %d\n", bclk_div); + dev_dbg(component->dev, "LRCK divider %d\n", lrclk_div); + dev_dbg(component->dev, "IDAC %d\n", idac); + dev_dbg(component->dev, "1<codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); int alen; int gpio; int clock_output; int master_mode; int ret; - dev_dbg(codec->dev, "hw_params %u Hz, %u channels\n", + dev_dbg(component->dev, "hw_params %u Hz, %u channels\n", params_rate(params), params_channels(params)); @@ -1128,7 +1128,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, alen = PCM512x_ALEN_32; break; default: - dev_err(codec->dev, "Bad frame size: %d\n", + dev_err(component->dev, "Bad frame size: %d\n", params_width(params)); return -EINVAL; } @@ -1141,7 +1141,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, | PCM512x_BCKO | PCM512x_LRKO, 0); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable slave mode: %d\n", ret); return ret; } @@ -1149,7 +1149,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_ERROR_DETECT, PCM512x_DCAS, 0); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable clock divider autoset: %d\n", ret); return ret; @@ -1170,20 +1170,20 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_I2S_1, PCM512x_ALEN, alen); if (ret != 0) { - dev_err(codec->dev, "Failed to set frame size: %d\n", ret); + dev_err(component->dev, "Failed to set frame size: %d\n", ret); return ret; } if (pcm512x->pll_out) { ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_A, 0x11); if (ret != 0) { - dev_err(codec->dev, "Failed to set FLEX_A: %d\n", ret); + dev_err(component->dev, "Failed to set FLEX_A: %d\n", ret); return ret; } ret = regmap_write(pcm512x->regmap, PCM512x_FLEX_B, 0xff); if (ret != 0) { - dev_err(codec->dev, "Failed to set FLEX_B: %d\n", ret); + dev_err(component->dev, "Failed to set FLEX_B: %d\n", ret); return ret; } @@ -1196,7 +1196,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, | PCM512x_IDSK | PCM512x_IDCH | PCM512x_DCAS); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to ignore auto-clock failures: %d\n", ret); return ret; @@ -1211,7 +1211,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, | PCM512x_IDSK | PCM512x_IDCH | PCM512x_DCAS | PCM512x_IPLK); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to ignore auto-clock failures: %d\n", ret); return ret; @@ -1220,7 +1220,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, PCM512x_PLLE, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to disable pll: %d\n", ret); + dev_err(component->dev, "Failed to disable pll: %d\n", ret); return ret; } } @@ -1233,7 +1233,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_REF, PCM512x_SREF, PCM512x_SREF_GPIO); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set gpio as pllref: %d\n", ret); return ret; } @@ -1242,7 +1242,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_PLLIN, PCM512x_GREF, gpio); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to set gpio %d as pllin: %d\n", pcm512x->pll_in, ret); return ret; @@ -1251,7 +1251,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_PLL_EN, PCM512x_PLLE, PCM512x_PLLE); if (ret != 0) { - dev_err(codec->dev, "Failed to enable pll: %d\n", ret); + dev_err(component->dev, "Failed to enable pll: %d\n", ret); return ret; } } @@ -1260,7 +1260,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, PCM512x_BCKP | PCM512x_BCKO | PCM512x_LRKO, clock_output); if (ret != 0) { - dev_err(codec->dev, "Failed to enable clock output: %d\n", ret); + dev_err(component->dev, "Failed to enable clock output: %d\n", ret); return ret; } @@ -1268,7 +1268,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, PCM512x_RLRK | PCM512x_RBCK, master_mode); if (ret != 0) { - dev_err(codec->dev, "Failed to enable master mode: %d\n", ret); + dev_err(component->dev, "Failed to enable master mode: %d\n", ret); return ret; } @@ -1277,7 +1277,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_GPIO_EN, gpio, gpio); if (ret != 0) { - dev_err(codec->dev, "Failed to enable gpio %d: %d\n", + dev_err(component->dev, "Failed to enable gpio %d: %d\n", pcm512x->pll_out, ret); return ret; } @@ -1286,7 +1286,7 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, gpio, PCM512x_GxSL, PCM512x_GxSL_PLLCK); if (ret != 0) { - dev_err(codec->dev, "Failed to output pll on %d: %d\n", + dev_err(component->dev, "Failed to output pll on %d: %d\n", ret, pcm512x->pll_out); return ret; } @@ -1295,14 +1295,14 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, PCM512x_RQSY, PCM512x_RQSY_HALT); if (ret != 0) { - dev_err(codec->dev, "Failed to halt clocks: %d\n", ret); + dev_err(component->dev, "Failed to halt clocks: %d\n", ret); return ret; } ret = regmap_update_bits(pcm512x->regmap, PCM512x_SYNCHRONIZE, PCM512x_RQSY, PCM512x_RQSY_RESUME); if (ret != 0) { - dev_err(codec->dev, "Failed to resume clocks: %d\n", ret); + dev_err(component->dev, "Failed to resume clocks: %d\n", ret); return ret; } @@ -1311,8 +1311,8 @@ static int pcm512x_hw_params(struct snd_pcm_substream *substream, static int pcm512x_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct pcm512x_priv *pcm512x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component); pcm512x->fmt = fmt; @@ -1341,18 +1341,17 @@ static struct snd_soc_dai_driver pcm512x_dai = { .ops = &pcm512x_dai_ops, }; -static const struct snd_soc_codec_driver pcm512x_codec_driver = { - .set_bias_level = pcm512x_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = pcm512x_controls, - .num_controls = ARRAY_SIZE(pcm512x_controls), - .dapm_widgets = pcm512x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm512x_dapm_widgets), - .dapm_routes = pcm512x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm512x_dapm_routes), - }, +static const struct snd_soc_component_driver pcm512x_component_driver = { + .set_bias_level = pcm512x_set_bias_level, + .controls = pcm512x_controls, + .num_controls = ARRAY_SIZE(pcm512x_controls), + .dapm_widgets = pcm512x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm512x_dapm_widgets), + .dapm_routes = pcm512x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm512x_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_range_cfg pcm512x_range = { @@ -1498,7 +1497,7 @@ int pcm512x_probe(struct device *dev, struct regmap *regmap) } #endif - ret = snd_soc_register_codec(dev, &pcm512x_codec_driver, + ret = devm_snd_soc_register_component(dev, &pcm512x_component_driver, &pcm512x_dai, 1); if (ret != 0) { dev_err(dev, "Failed to register CODEC: %d\n", ret); @@ -1523,7 +1522,6 @@ void pcm512x_remove(struct device *dev) { struct pcm512x_priv *pcm512x = dev_get_drvdata(dev); - snd_soc_unregister_codec(dev); pm_runtime_disable(dev); if (!IS_ERR(pcm512x->sclk)) clk_disable_unprepare(pcm512x->sclk); From d5e90bad6faa0ea93a14f88aaae62fb58e968a0a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:19:05 +0000 Subject: [PATCH 124/942] ASoC: pcm5102a: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/pcm5102a.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/pcm5102a.c b/sound/soc/codecs/pcm5102a.c index 8ba322a00363..39ac2857a554 100644 --- a/sound/soc/codecs/pcm5102a.c +++ b/sound/soc/codecs/pcm5102a.c @@ -32,20 +32,19 @@ static struct snd_soc_dai_driver pcm5102a_dai = { }, }; -static struct snd_soc_codec_driver soc_codec_dev_pcm5102a; +static struct snd_soc_component_driver soc_component_dev_pcm5102a = { + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; static int pcm5102a_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm5102a, + return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_pcm5102a, &pcm5102a_dai, 1); } -static int pcm5102a_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static const struct of_device_id pcm5102a_of_match[] = { { .compatible = "ti,pcm5102a", }, { } @@ -54,7 +53,6 @@ MODULE_DEVICE_TABLE(of, pcm5102a_of_match); static struct platform_driver pcm5102a_codec_driver = { .probe = pcm5102a_probe, - .remove = pcm5102a_remove, .driver = { .name = "pcm5102a-codec", .of_match_table = pcm5102a_of_match, From 29751c1cdf3098380b44c52d2027dd3ba1baadf0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:19:39 +0000 Subject: [PATCH 125/942] ASoC: pcm3168a: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/pcm3168a.c | 51 ++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/pcm3168a.c b/sound/soc/codecs/pcm3168a.c index b9d1207ccef2..3356c91f55b0 100644 --- a/sound/soc/codecs/pcm3168a.c +++ b/sound/soc/codecs/pcm3168a.c @@ -287,8 +287,8 @@ static int pcm3168a_reset(struct pcm3168a_priv *pcm3168a) static int pcm3168a_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct pcm3168a_priv *pcm3168a = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(component); regmap_write(pcm3168a->regmap, PCM3168A_DAC_MUTE, mute ? 0xff : 0); @@ -298,7 +298,7 @@ static int pcm3168a_digital_mute(struct snd_soc_dai *dai, int mute) static int pcm3168a_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct pcm3168a_priv *pcm3168a = snd_soc_codec_get_drvdata(dai->codec); + struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(dai->component); int ret; if (freq > PCM1368A_MAX_SYSCLK) @@ -316,8 +316,8 @@ static int pcm3168a_set_dai_sysclk(struct snd_soc_dai *dai, static int pcm3168a_set_dai_fmt(struct snd_soc_dai *dai, unsigned int format, bool dac) { - struct snd_soc_codec *codec = dai->codec; - struct pcm3168a_priv *pcm3168a = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(component); u32 fmt, reg, mask, shift; bool master_mode; @@ -338,7 +338,7 @@ static int pcm3168a_set_dai_fmt(struct snd_soc_dai *dai, fmt = PCM3168A_FMT_DSP_B; break; default: - dev_err(codec->dev, "unsupported dai format\n"); + dev_err(component->dev, "unsupported dai format\n"); return -EINVAL; } @@ -350,7 +350,7 @@ static int pcm3168a_set_dai_fmt(struct snd_soc_dai *dai, master_mode = true; break; default: - dev_err(codec->dev, "unsupported master/slave mode\n"); + dev_err(component->dev, "unsupported master/slave mode\n"); return -EINVAL; } @@ -396,8 +396,8 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct pcm3168a_priv *pcm3168a = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm3168a_priv *pcm3168a = snd_soc_component_get_drvdata(component); bool tx, master_mode; u32 val, mask, shift, reg; unsigned int rate, fmt, ratio, max_ratio; @@ -430,7 +430,7 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream, } if (i == max_ratio) { - dev_err(codec->dev, "unsupported sysclk ratio\n"); + dev_err(component->dev, "unsupported sysclk ratio\n"); return -EINVAL; } @@ -438,21 +438,21 @@ static int pcm3168a_hw_params(struct snd_pcm_substream *substream, switch (min_frame_size) { case 32: if (master_mode || (fmt != PCM3168A_FMT_RIGHT_J)) { - dev_err(codec->dev, "32-bit frames are supported only for slave mode using right justified\n"); + dev_err(component->dev, "32-bit frames are supported only for slave mode using right justified\n"); return -EINVAL; } fmt = PCM3168A_FMT_RIGHT_J_16; break; case 48: if (master_mode || (fmt & PCM3168A_FMT_DSP_MASK)) { - dev_err(codec->dev, "48-bit frames not supported in master mode, or slave mode using DSP\n"); + dev_err(component->dev, "48-bit frames not supported in master mode, or slave mode using DSP\n"); return -EINVAL; } break; case 64: break; default: - dev_err(codec->dev, "unsupported frame size: %d\n", min_frame_size); + dev_err(component->dev, "unsupported frame size: %d\n", min_frame_size); return -EINVAL; } @@ -595,16 +595,16 @@ const struct regmap_config pcm3168a_regmap = { }; EXPORT_SYMBOL_GPL(pcm3168a_regmap); -static const struct snd_soc_codec_driver pcm3168a_driver = { - .idle_bias_off = true, - .component_driver = { - .controls = pcm3168a_snd_controls, - .num_controls = ARRAY_SIZE(pcm3168a_snd_controls), - .dapm_widgets = pcm3168a_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm3168a_dapm_widgets), - .dapm_routes = pcm3168a_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm3168a_dapm_routes) - }, +static const struct snd_soc_component_driver pcm3168a_driver = { + .controls = pcm3168a_snd_controls, + .num_controls = ARRAY_SIZE(pcm3168a_snd_controls), + .dapm_widgets = pcm3168a_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm3168a_dapm_widgets), + .dapm_routes = pcm3168a_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm3168a_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; int pcm3168a_probe(struct device *dev, struct regmap *regmap) @@ -669,10 +669,10 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) pm_runtime_enable(dev); pm_runtime_idle(dev); - ret = snd_soc_register_codec(dev, &pcm3168a_driver, pcm3168a_dais, + ret = devm_snd_soc_register_component(dev, &pcm3168a_driver, pcm3168a_dais, ARRAY_SIZE(pcm3168a_dais)); if (ret) { - dev_err(dev, "failed to register codec: %d\n", ret); + dev_err(dev, "failed to register component: %d\n", ret); goto err_regulator; } @@ -692,7 +692,6 @@ void pcm3168a_remove(struct device *dev) { struct pcm3168a_priv *pcm3168a = dev_get_drvdata(dev); - snd_soc_unregister_codec(dev); pm_runtime_disable(dev); regulator_bulk_disable(ARRAY_SIZE(pcm3168a->supplies), pcm3168a->supplies); From 7480389fb0d873ed78619542bf5d2717a7ad7786 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:20:09 +0000 Subject: [PATCH 126/942] ASoC: twl6040: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 1 -> .use_pmdown_time = 0 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 269 +++++++++++++++--------------- sound/soc/codecs/twl6040.h | 10 +- sound/soc/omap/omap-abe-twl6040.c | 8 +- 3 files changed, 139 insertions(+), 148 deletions(-) diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 573a523ed0b3..9bf23f8e7162 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -76,7 +76,7 @@ struct twl6040_data { unsigned int clk_in; unsigned int sysclk; struct twl6040_jack_data hs_jack; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct mutex mutex; }; @@ -106,12 +106,12 @@ static const struct snd_pcm_hw_constraint_list sysclk_constraints[] = { { .count = ARRAY_SIZE(hp_rates), .list = hp_rates, }, }; -#define to_twl6040(codec) dev_get_drvdata((codec)->dev->parent) +#define to_twl6040(component) dev_get_drvdata((component)->dev->parent) -static unsigned int twl6040_read(struct snd_soc_codec *codec, unsigned int reg) +static unsigned int twl6040_read(struct snd_soc_component *component, unsigned int reg) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); - struct twl6040 *twl6040 = to_twl6040(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); + struct twl6040 *twl6040 = to_twl6040(component); u8 value; if (reg >= TWL6040_CACHEREGNUM) @@ -133,10 +133,10 @@ static unsigned int twl6040_read(struct snd_soc_codec *codec, unsigned int reg) return value; } -static bool twl6040_can_write_to_chip(struct snd_soc_codec *codec, +static bool twl6040_can_write_to_chip(struct snd_soc_component *component, unsigned int reg) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); switch (reg) { case TWL6040_REG_HSLCTL: @@ -152,10 +152,10 @@ static bool twl6040_can_write_to_chip(struct snd_soc_codec *codec, } } -static inline void twl6040_update_dl12_cache(struct snd_soc_codec *codec, +static inline void twl6040_update_dl12_cache(struct snd_soc_component *component, u8 reg, u8 value) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); switch (reg) { case TWL6040_REG_HSLCTL: @@ -170,54 +170,54 @@ static inline void twl6040_update_dl12_cache(struct snd_soc_codec *codec, } } -static int twl6040_write(struct snd_soc_codec *codec, +static int twl6040_write(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct twl6040 *twl6040 = to_twl6040(codec); + struct twl6040 *twl6040 = to_twl6040(component); if (reg >= TWL6040_CACHEREGNUM) return -EIO; - twl6040_update_dl12_cache(codec, reg, value); - if (twl6040_can_write_to_chip(codec, reg)) + twl6040_update_dl12_cache(component, reg, value); + if (twl6040_can_write_to_chip(component, reg)) return twl6040_reg_write(twl6040, reg, value); else return 0; } -static void twl6040_init_chip(struct snd_soc_codec *codec) +static void twl6040_init_chip(struct snd_soc_component *component) { - twl6040_read(codec, TWL6040_REG_TRIM1); - twl6040_read(codec, TWL6040_REG_TRIM2); - twl6040_read(codec, TWL6040_REG_TRIM3); - twl6040_read(codec, TWL6040_REG_HSOTRIM); - twl6040_read(codec, TWL6040_REG_HFOTRIM); + twl6040_read(component, TWL6040_REG_TRIM1); + twl6040_read(component, TWL6040_REG_TRIM2); + twl6040_read(component, TWL6040_REG_TRIM3); + twl6040_read(component, TWL6040_REG_HSOTRIM); + twl6040_read(component, TWL6040_REG_HFOTRIM); /* Change chip defaults */ /* No imput selected for microphone amplifiers */ - twl6040_write(codec, TWL6040_REG_MICLCTL, 0x18); - twl6040_write(codec, TWL6040_REG_MICRCTL, 0x18); + twl6040_write(component, TWL6040_REG_MICLCTL, 0x18); + twl6040_write(component, TWL6040_REG_MICRCTL, 0x18); /* * We need to lower the default gain values, so the ramp code * can work correctly for the first playback. * This reduces the pop noise heard at the first playback. */ - twl6040_write(codec, TWL6040_REG_HSGAIN, 0xff); - twl6040_write(codec, TWL6040_REG_EARCTL, 0x1e); - twl6040_write(codec, TWL6040_REG_HFLGAIN, 0x1d); - twl6040_write(codec, TWL6040_REG_HFRGAIN, 0x1d); - twl6040_write(codec, TWL6040_REG_LINEGAIN, 0); + twl6040_write(component, TWL6040_REG_HSGAIN, 0xff); + twl6040_write(component, TWL6040_REG_EARCTL, 0x1e); + twl6040_write(component, TWL6040_REG_HFLGAIN, 0x1d); + twl6040_write(component, TWL6040_REG_HFRGAIN, 0x1d); + twl6040_write(component, TWL6040_REG_LINEGAIN, 0); } /* set headset dac and driver power mode */ -static int headset_power_mode(struct snd_soc_codec *codec, int high_perf) +static int headset_power_mode(struct snd_soc_component *component, int high_perf) { int hslctl, hsrctl; int mask = TWL6040_HSDRVMODE | TWL6040_HSDACMODE; - hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); - hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); + hslctl = twl6040_read(component, TWL6040_REG_HSLCTL); + hsrctl = twl6040_read(component, TWL6040_REG_HSRCTL); if (high_perf) { hslctl &= ~mask; @@ -227,8 +227,8 @@ static int headset_power_mode(struct snd_soc_codec *codec, int high_perf) hsrctl |= mask; } - twl6040_write(codec, TWL6040_REG_HSLCTL, hslctl); - twl6040_write(codec, TWL6040_REG_HSRCTL, hsrctl); + twl6040_write(component, TWL6040_REG_HSLCTL, hslctl); + twl6040_write(component, TWL6040_REG_HSRCTL, hsrctl); return 0; } @@ -236,7 +236,7 @@ static int headset_power_mode(struct snd_soc_codec *codec, int high_perf) static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u8 hslctl, hsrctl; /* @@ -244,8 +244,8 @@ static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, * Both HS DAC need to be turned on (before the HS driver) and off at * the same time. */ - hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); - hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); + hslctl = twl6040_read(component, TWL6040_REG_HSLCTL); + hsrctl = twl6040_read(component, TWL6040_REG_HSRCTL); if (SND_SOC_DAPM_EVENT_ON(event)) { hslctl |= TWL6040_HSDACENA; hsrctl |= TWL6040_HSDACENA; @@ -253,8 +253,8 @@ static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, hslctl &= ~TWL6040_HSDACENA; hsrctl &= ~TWL6040_HSDACENA; } - twl6040_write(codec, TWL6040_REG_HSLCTL, hslctl); - twl6040_write(codec, TWL6040_REG_HSRCTL, hsrctl); + twl6040_write(component, TWL6040_REG_HSLCTL, hslctl); + twl6040_write(component, TWL6040_REG_HSRCTL, hsrctl); msleep(1); return 0; @@ -263,17 +263,17 @@ static int twl6040_hs_dac_event(struct snd_soc_dapm_widget *w, static int twl6040_ep_drv_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int ret = 0; if (SND_SOC_DAPM_EVENT_ON(event)) { /* Earphone doesn't support low power mode */ priv->hs_power_mode_locked = 1; - ret = headset_power_mode(codec, 1); + ret = headset_power_mode(component, 1); } else { priv->hs_power_mode_locked = 0; - ret = headset_power_mode(codec, priv->hs_power_mode); + ret = headset_power_mode(component, priv->hs_power_mode); } msleep(1); @@ -281,16 +281,16 @@ static int twl6040_ep_drv_event(struct snd_soc_dapm_widget *w, return ret; } -static void twl6040_hs_jack_report(struct snd_soc_codec *codec, +static void twl6040_hs_jack_report(struct snd_soc_component *component, struct snd_soc_jack *jack, int report) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int status; mutex_lock(&priv->mutex); /* Sync status */ - status = twl6040_read(codec, TWL6040_REG_STATUS); + status = twl6040_read(component, TWL6040_REG_STATUS); if (status & TWL6040_PLUGCOMP) snd_soc_jack_report(jack, report, report); else @@ -299,16 +299,16 @@ static void twl6040_hs_jack_report(struct snd_soc_codec *codec, mutex_unlock(&priv->mutex); } -void twl6040_hs_jack_detect(struct snd_soc_codec *codec, +void twl6040_hs_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int report) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); struct twl6040_jack_data *hs_jack = &priv->hs_jack; hs_jack->jack = jack; hs_jack->report = report; - twl6040_hs_jack_report(codec, hs_jack->jack, hs_jack->report); + twl6040_hs_jack_report(component, hs_jack->jack, hs_jack->report); } EXPORT_SYMBOL_GPL(twl6040_hs_jack_detect); @@ -316,17 +316,17 @@ static void twl6040_accessory_work(struct work_struct *work) { struct twl6040_data *priv = container_of(work, struct twl6040_data, hs_jack.work.work); - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; struct twl6040_jack_data *hs_jack = &priv->hs_jack; - twl6040_hs_jack_report(codec, hs_jack->jack, hs_jack->report); + twl6040_hs_jack_report(component, hs_jack->jack, hs_jack->report); } /* audio interrupt handler */ static irqreturn_t twl6040_audio_handler(int irq, void *data) { - struct snd_soc_codec *codec = data; - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = data; + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); queue_delayed_work(system_power_efficient_wq, &priv->hs_jack.work, msecs_to_jiffies(200)); @@ -337,12 +337,12 @@ static irqreturn_t twl6040_audio_handler(int irq, void *data) static int twl6040_soc_dapm_put_vibra_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int val; /* Do not allow changes while Input/FF efect is running */ - val = twl6040_read(codec, e->reg); + val = twl6040_read(component, e->reg); if (val & TWL6040_VIBENA && !(val & TWL6040_VIBSEL)) return -EBUSY; @@ -486,8 +486,8 @@ static SOC_ENUM_SINGLE_EXT_DECL(twl6040_power_mode_enum, static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = priv->hs_power_mode; @@ -497,13 +497,13 @@ static int twl6040_headset_power_get_enum(struct snd_kcontrol *kcontrol, static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int high_perf = ucontrol->value.enumerated.item[0]; int ret = 0; if (!priv->hs_power_mode_locked) - ret = headset_power_mode(codec, high_perf); + ret = headset_power_mode(component, high_perf); if (!ret) priv->hs_power_mode = high_perf; @@ -514,8 +514,8 @@ static int twl6040_headset_power_put_enum(struct snd_kcontrol *kcontrol, static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = priv->pll_power_mode; @@ -525,17 +525,17 @@ static int twl6040_pll_get_enum(struct snd_kcontrol *kcontrol, static int twl6040_pll_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); priv->pll_power_mode = ucontrol->value.enumerated.item[0]; return 0; } -int twl6040_get_dl1_gain(struct snd_soc_codec *codec) +int twl6040_get_dl1_gain(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (snd_soc_dapm_get_pin_status(dapm, "EP")) return -1; /* -1dB */ @@ -543,7 +543,7 @@ int twl6040_get_dl1_gain(struct snd_soc_codec *codec) if (snd_soc_dapm_get_pin_status(dapm, "HSOR") || snd_soc_dapm_get_pin_status(dapm, "HSOL")) { - u8 val = twl6040_read(codec, TWL6040_REG_HSLCTL); + u8 val = twl6040_read(component, TWL6040_REG_HSLCTL); if (val & TWL6040_HSDACMODE) /* HSDACL in LP mode */ return -8; /* -8dB */ @@ -555,26 +555,26 @@ int twl6040_get_dl1_gain(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(twl6040_get_dl1_gain); -int twl6040_get_clk_id(struct snd_soc_codec *codec) +int twl6040_get_clk_id(struct snd_soc_component *component) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); return priv->pll_power_mode; } EXPORT_SYMBOL_GPL(twl6040_get_clk_id); -int twl6040_get_trim_value(struct snd_soc_codec *codec, enum twl6040_trim trim) +int twl6040_get_trim_value(struct snd_soc_component *component, enum twl6040_trim trim) { if (unlikely(trim >= TWL6040_TRIM_INVAL)) return -EINVAL; - return twl6040_read(codec, TWL6040_REG_TRIM1 + trim); + return twl6040_read(component, TWL6040_REG_TRIM1 + trim); } EXPORT_SYMBOL_GPL(twl6040_get_trim_value); -int twl6040_get_hs_step_size(struct snd_soc_codec *codec) +int twl6040_get_hs_step_size(struct snd_soc_component *component) { - struct twl6040 *twl6040 = to_twl6040(codec); + struct twl6040 *twl6040 = to_twl6040(component); if (twl6040_get_revid(twl6040) < TWL6040_REV_ES1_3) /* For ES under ES_1.3 HS step is 2 mV */ @@ -829,11 +829,11 @@ static const struct snd_soc_dapm_route intercon[] = { {"VIBRAR", NULL, "Vibra Right Driver"}, }; -static int twl6040_set_bias_level(struct snd_soc_codec *codec, +static int twl6040_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct twl6040 *twl6040 = to_twl6040(codec); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040 *twl6040 = to_twl6040(component); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int ret = 0; switch (level) { @@ -856,7 +856,7 @@ static int twl6040_set_bias_level(struct snd_soc_codec *codec, priv->codec_powered = 1; /* Set external boost GPO */ - twl6040_write(codec, TWL6040_REG_GPOCTL, 0x02); + twl6040_write(component, TWL6040_REG_GPOCTL, 0x02); break; case SND_SOC_BIAS_OFF: if (!priv->codec_powered) @@ -873,8 +873,8 @@ static int twl6040_set_bias_level(struct snd_soc_codec *codec, static int twl6040_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); snd_pcm_hw_constraint_list(substream->runtime, 0, SNDRV_PCM_HW_PARAM_RATE, @@ -887,8 +887,8 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int rate; rate = params_rate(params); @@ -899,7 +899,7 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream, case 88200: /* These rates are not supported when HPPLL is in use */ if (unlikely(priv->pll == TWL6040_SYSCLK_SEL_HPPLL)) { - dev_err(codec->dev, "HPPLL does not support rate %d\n", + dev_err(component->dev, "HPPLL does not support rate %d\n", rate); return -EINVAL; } @@ -913,7 +913,7 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream, priv->sysclk = 19200000; break; default: - dev_err(codec->dev, "unsupported rate %d\n", rate); + dev_err(component->dev, "unsupported rate %d\n", rate); return -EINVAL; } @@ -923,20 +923,20 @@ static int twl6040_hw_params(struct snd_pcm_substream *substream, static int twl6040_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl6040 *twl6040 = to_twl6040(codec); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl6040 *twl6040 = to_twl6040(component); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int ret; if (!priv->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "no mclk configured, call set_sysclk() on init\n"); return -EINVAL; } ret = twl6040_set_pll(twl6040, priv->pll, priv->clk_in, priv->sysclk); if (ret) { - dev_err(codec->dev, "Can not set PLL (%d)\n", ret); + dev_err(component->dev, "Can not set PLL (%d)\n", ret); return -EPERM; } @@ -946,8 +946,8 @@ static int twl6040_prepare(struct snd_pcm_substream *substream, static int twl6040_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); switch (clk_id) { case TWL6040_SYSCLK_SEL_LPPLL: @@ -956,26 +956,26 @@ static int twl6040_set_dai_sysclk(struct snd_soc_dai *codec_dai, priv->clk_in = freq; break; default: - dev_err(codec->dev, "unknown clk_id %d\n", clk_id); + dev_err(component->dev, "unknown clk_id %d\n", clk_id); return -EINVAL; } return 0; } -static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id id, +static void twl6040_mute_path(struct snd_soc_component *component, enum twl6040_dai_id id, int mute) { - struct twl6040 *twl6040 = to_twl6040(codec); - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040 *twl6040 = to_twl6040(component); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); int hslctl, hsrctl, earctl; int hflctl, hfrctl; switch (id) { case TWL6040_DAI_DL1: - hslctl = twl6040_read(codec, TWL6040_REG_HSLCTL); - hsrctl = twl6040_read(codec, TWL6040_REG_HSRCTL); - earctl = twl6040_read(codec, TWL6040_REG_EARCTL); + hslctl = twl6040_read(component, TWL6040_REG_HSLCTL); + hsrctl = twl6040_read(component, TWL6040_REG_HSRCTL); + earctl = twl6040_read(component, TWL6040_REG_EARCTL); if (mute) { /* Power down drivers and DACs */ @@ -991,8 +991,8 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i priv->dl1_unmuted = !mute; break; case TWL6040_DAI_DL2: - hflctl = twl6040_read(codec, TWL6040_REG_HFLCTL); - hfrctl = twl6040_read(codec, TWL6040_REG_HFRCTL); + hflctl = twl6040_read(component, TWL6040_REG_HFLCTL); + hfrctl = twl6040_read(component, TWL6040_REG_HFRCTL); if (mute) { /* Power down drivers and DACs */ @@ -1015,12 +1015,12 @@ static int twl6040_digital_mute(struct snd_soc_dai *dai, int mute) { switch (dai->id) { case TWL6040_DAI_LEGACY: - twl6040_mute_path(dai->codec, TWL6040_DAI_DL1, mute); - twl6040_mute_path(dai->codec, TWL6040_DAI_DL2, mute); + twl6040_mute_path(dai->component, TWL6040_DAI_DL1, mute); + twl6040_mute_path(dai->component, TWL6040_DAI_DL2, mute); break; case TWL6040_DAI_DL1: case TWL6040_DAI_DL2: - twl6040_mute_path(dai->codec, dai->id, mute); + twl6040_mute_path(dai->component, dai->id, mute); break; default: break; @@ -1107,23 +1107,23 @@ static struct snd_soc_dai_driver twl6040_dai[] = { }, }; -static int twl6040_probe(struct snd_soc_codec *codec) +static int twl6040_probe(struct snd_soc_component *component) { struct twl6040_data *priv; - struct platform_device *pdev = to_platform_device(codec->dev); + struct platform_device *pdev = to_platform_device(component->dev); int ret = 0; - priv = devm_kzalloc(codec->dev, sizeof(*priv), GFP_KERNEL); + priv = devm_kzalloc(component->dev, sizeof(*priv), GFP_KERNEL); if (priv == NULL) return -ENOMEM; - snd_soc_codec_set_drvdata(codec, priv); + snd_soc_component_set_drvdata(component, priv); - priv->codec = codec; + priv->component = component; priv->plug_irq = platform_get_irq(pdev, 0); if (priv->plug_irq < 0) { - dev_err(codec->dev, "invalid irq: %d\n", priv->plug_irq); + dev_err(component->dev, "invalid irq: %d\n", priv->plug_irq); return priv->plug_irq; } @@ -1134,64 +1134,55 @@ static int twl6040_probe(struct snd_soc_codec *codec) ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler, IRQF_NO_SUSPEND | IRQF_ONESHOT, - "twl6040_irq_plug", codec); + "twl6040_irq_plug", component); if (ret) { - dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret); + dev_err(component->dev, "PLUG IRQ request failed: %d\n", ret); return ret; } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); - twl6040_init_chip(codec); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); + twl6040_init_chip(component); return 0; } -static int twl6040_remove(struct snd_soc_codec *codec) +static void twl6040_remove(struct snd_soc_component *component) { - struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); + struct twl6040_data *priv = snd_soc_component_get_drvdata(component); - free_irq(priv->plug_irq, codec); - - return 0; + free_irq(priv->plug_irq, component); } -static const struct snd_soc_codec_driver soc_codec_dev_twl6040 = { - .probe = twl6040_probe, - .remove = twl6040_remove, - .read = twl6040_read, - .write = twl6040_write, - .set_bias_level = twl6040_set_bias_level, - .suspend_bias_off = true, - .ignore_pmdown_time = true, - - .component_driver = { - .controls = twl6040_snd_controls, - .num_controls = ARRAY_SIZE(twl6040_snd_controls), - .dapm_widgets = twl6040_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(twl6040_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_twl6040 = { + .probe = twl6040_probe, + .remove = twl6040_remove, + .read = twl6040_read, + .remove = twl6040_remove, + .set_bias_level = twl6040_set_bias_level, + .controls = twl6040_snd_controls, + .num_controls = ARRAY_SIZE(twl6040_snd_controls), + .dapm_widgets = twl6040_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(twl6040_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int twl6040_codec_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl6040, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_twl6040, twl6040_dai, ARRAY_SIZE(twl6040_dai)); } -static int twl6040_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver twl6040_codec_driver = { .driver = { .name = "twl6040-codec", }, .probe = twl6040_codec_probe, - .remove = twl6040_codec_remove, }; module_platform_driver(twl6040_codec_driver); diff --git a/sound/soc/codecs/twl6040.h b/sound/soc/codecs/twl6040.h index 0611406ca7c0..3d9f957077ef 100644 --- a/sound/soc/codecs/twl6040.h +++ b/sound/soc/codecs/twl6040.h @@ -34,11 +34,11 @@ enum twl6040_trim { #define TWL6040_HSF_TRIM_LEFT(x) (x & 0x0f) #define TWL6040_HSF_TRIM_RIGHT(x) ((x >> 4) & 0x0f) -int twl6040_get_dl1_gain(struct snd_soc_codec *codec); -void twl6040_hs_jack_detect(struct snd_soc_codec *codec, +int twl6040_get_dl1_gain(struct snd_soc_component *component); +void twl6040_hs_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int report); -int twl6040_get_clk_id(struct snd_soc_codec *codec); -int twl6040_get_trim_value(struct snd_soc_codec *codec, enum twl6040_trim trim); -int twl6040_get_hs_step_size(struct snd_soc_codec *codec); +int twl6040_get_clk_id(struct snd_soc_component *component); +int twl6040_get_trim_value(struct snd_soc_component *component, enum twl6040_trim trim); +int twl6040_get_hs_step_size(struct snd_soc_component *component); #endif /* End of __TWL6040_H__ */ diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index 614b18d2f631..15ccbf479c96 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c @@ -52,7 +52,7 @@ static int omap_abe_hw_params(struct snd_pcm_substream *substream, int clk_id, freq; int ret; - clk_id = twl6040_get_clk_id(rtd->codec); + clk_id = twl6040_get_clk_id(codec_dai->component); if (clk_id == TWL6040_SYSCLK_SEL_HPPLL) freq = priv->mclk_freq; else if (clk_id == TWL6040_SYSCLK_SEL_LPPLL) @@ -166,7 +166,7 @@ static const struct snd_soc_dapm_route audio_map[] = { static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_card *card = rtd->card; struct abe_twl6040 *priv = snd_soc_card_get_drvdata(card); int hs_trim; @@ -176,7 +176,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) * Configure McPDM offset cancellation based on the HSOTRIM value from * twl6040. */ - hs_trim = twl6040_get_trim_value(codec, TWL6040_TRIM_HSOTRIM); + hs_trim = twl6040_get_trim_value(component, TWL6040_TRIM_HSOTRIM); omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim), TWL6040_HSF_TRIM_RIGHT(hs_trim)); @@ -189,7 +189,7 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); + twl6040_hs_jack_detect(component, &hs_jack, SND_JACK_HEADSET); } return 0; From c68e7f5ba4fad7962e193414ad55749cbc008a17 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:20:49 +0000 Subject: [PATCH 127/942] ASoC: twl4030: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/twl4030.c | 383 ++++++++++++++++++------------------- 1 file changed, 187 insertions(+), 196 deletions(-) diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index e4d7f397d361..25b752caf95e 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -86,9 +86,9 @@ static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030) } } -static unsigned int twl4030_read(struct snd_soc_codec *codec, unsigned int reg) +static unsigned int twl4030_read(struct snd_soc_component *component, unsigned int reg) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 value = 0; if (reg >= TWL4030_CACHEREGNUM) @@ -151,10 +151,10 @@ static bool twl4030_can_write_to_chip(struct twl4030_priv *twl4030, return write_to_reg; } -static int twl4030_write(struct snd_soc_codec *codec, unsigned int reg, +static int twl4030_write(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); /* Update the ctl cache */ switch (reg) { @@ -186,9 +186,9 @@ static inline void twl4030_wait_ms(int time) } } -static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable) +static void twl4030_codec_enable(struct snd_soc_component *component, int enable) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); int mode; if (enable == twl4030->codec_powered) @@ -227,16 +227,16 @@ static void twl4030_setup_pdata_of(struct twl4030_codec_data *pdata, pdata->hs_extmute = 1; } -static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) +static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_component *component) { - struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev); + struct twl4030_codec_data *pdata = dev_get_platdata(component->dev); struct device_node *twl4030_codec_node = NULL; - twl4030_codec_node = of_get_child_by_name(codec->dev->parent->of_node, + twl4030_codec_node = of_get_child_by_name(component->dev->parent->of_node, "codec"); if (!pdata && twl4030_codec_node) { - pdata = devm_kzalloc(codec->dev, + pdata = devm_kzalloc(component->dev, sizeof(struct twl4030_codec_data), GFP_KERNEL); if (!pdata) { @@ -250,28 +250,28 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) return pdata; } -static void twl4030_init_chip(struct snd_soc_codec *codec) +static void twl4030_init_chip(struct snd_soc_component *component) { struct twl4030_codec_data *pdata; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 reg, byte; int i = 0; - pdata = twl4030_get_pdata(codec); + pdata = twl4030_get_pdata(component); if (pdata && pdata->hs_extmute) { if (gpio_is_valid(pdata->hs_extmute_gpio)) { int ret; if (!pdata->hs_extmute_gpio) - dev_warn(codec->dev, + dev_warn(component->dev, "Extmute GPIO is 0 is this correct?\n"); ret = gpio_request_one(pdata->hs_extmute_gpio, GPIOF_OUT_INIT_LOW, "hs_extmute"); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to get hs_extmute GPIO\n"); pdata->hs_extmute_gpio = -1; } @@ -292,16 +292,16 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) tw4030_init_ctl_cache(twl4030); /* anti-pop when changing analog gain */ - reg = twl4030_read(codec, TWL4030_REG_MISC_SET_1); - twl4030_write(codec, TWL4030_REG_MISC_SET_1, + reg = twl4030_read(component, TWL4030_REG_MISC_SET_1); + twl4030_write(component, TWL4030_REG_MISC_SET_1, reg | TWL4030_SMOOTH_ANAVOL_EN); - twl4030_write(codec, TWL4030_REG_OPTION, + twl4030_write(component, TWL4030_REG_OPTION, TWL4030_ATXL1_EN | TWL4030_ATXR1_EN | TWL4030_ARXL2_EN | TWL4030_ARXR2_EN); /* REG_ARXR2_APGA_CTL reset according to the TRM: 0dB, DA_EN */ - twl4030_write(codec, TWL4030_REG_ARXR2_APGA_CTL, 0x32); + twl4030_write(component, TWL4030_REG_ARXR2_APGA_CTL, 0x32); /* Machine dependent setup */ if (!pdata) @@ -309,18 +309,18 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) twl4030->pdata = pdata; - reg = twl4030_read(codec, TWL4030_REG_HS_POPN_SET); + reg = twl4030_read(component, TWL4030_REG_HS_POPN_SET); reg &= ~TWL4030_RAMP_DELAY; reg |= (pdata->ramp_delay_value << 2); - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, reg); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, reg); /* initiate offset cancellation */ - twl4030_codec_enable(codec, 1); + twl4030_codec_enable(component, 1); - reg = twl4030_read(codec, TWL4030_REG_ANAMICL); + reg = twl4030_read(component, TWL4030_REG_ANAMICL); reg &= ~TWL4030_OFFSET_CNCL_SEL; reg |= pdata->offset_cncl_path; - twl4030_write(codec, TWL4030_REG_ANAMICL, + twl4030_write(component, TWL4030_REG_ANAMICL, reg | TWL4030_CNCL_OFFSET_START); /* @@ -339,12 +339,12 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) ((byte & TWL4030_CNCL_OFFSET_START) == TWL4030_CNCL_OFFSET_START)); - twl4030_codec_enable(codec, 0); + twl4030_codec_enable(component, 0); } -static void twl4030_apll_enable(struct snd_soc_codec *codec, int enable) +static void twl4030_apll_enable(struct snd_soc_component *component, int enable) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); if (enable) { twl4030->apll_enabled++; @@ -567,13 +567,13 @@ static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control = static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \ struct snd_kcontrol *kcontrol, int event) \ { \ - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); \ - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); \ + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); \ + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); \ \ switch (event) { \ case SND_SOC_DAPM_POST_PMU: \ twl4030->pin_name##_enabled = 1; \ - twl4030_write(codec, reg, twl4030_read(codec, reg)); \ + twl4030_write(component, reg, twl4030_read(component, reg)); \ break; \ case SND_SOC_DAPM_POST_PMD: \ twl4030->pin_name##_enabled = 0; \ @@ -589,47 +589,47 @@ TWL4030_OUTPUT_PGA(predriver, TWL4030_REG_PREDR_CTL, TWL4030_PREDR_GAIN); TWL4030_OUTPUT_PGA(carkitl, TWL4030_REG_PRECKL_CTL, TWL4030_PRECKL_GAIN); TWL4030_OUTPUT_PGA(carkitr, TWL4030_REG_PRECKR_CTL, TWL4030_PRECKR_GAIN); -static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp) +static void handsfree_ramp(struct snd_soc_component *component, int reg, int ramp) { unsigned char hs_ctl; - hs_ctl = twl4030_read(codec, reg); + hs_ctl = twl4030_read(component, reg); if (ramp) { /* HF ramp-up */ hs_ctl |= TWL4030_HF_CTL_REF_EN; - twl4030_write(codec, reg, hs_ctl); + twl4030_write(component, reg, hs_ctl); udelay(10); hs_ctl |= TWL4030_HF_CTL_RAMP_EN; - twl4030_write(codec, reg, hs_ctl); + twl4030_write(component, reg, hs_ctl); udelay(40); hs_ctl |= TWL4030_HF_CTL_LOOP_EN; hs_ctl |= TWL4030_HF_CTL_HB_EN; - twl4030_write(codec, reg, hs_ctl); + twl4030_write(component, reg, hs_ctl); } else { /* HF ramp-down */ hs_ctl &= ~TWL4030_HF_CTL_LOOP_EN; hs_ctl &= ~TWL4030_HF_CTL_HB_EN; - twl4030_write(codec, reg, hs_ctl); + twl4030_write(component, reg, hs_ctl); hs_ctl &= ~TWL4030_HF_CTL_RAMP_EN; - twl4030_write(codec, reg, hs_ctl); + twl4030_write(component, reg, hs_ctl); udelay(40); hs_ctl &= ~TWL4030_HF_CTL_REF_EN; - twl4030_write(codec, reg, hs_ctl); + twl4030_write(component, reg, hs_ctl); } } static int handsfreelpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 1); + handsfree_ramp(component, TWL4030_REG_HFL_CTL, 1); break; case SND_SOC_DAPM_POST_PMD: - handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 0); + handsfree_ramp(component, TWL4030_REG_HFL_CTL, 0); break; } return 0; @@ -638,14 +638,14 @@ static int handsfreelpga_event(struct snd_soc_dapm_widget *w, static int handsfreerpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 1); + handsfree_ramp(component, TWL4030_REG_HFR_CTL, 1); break; case SND_SOC_DAPM_POST_PMD: - handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 0); + handsfree_ramp(component, TWL4030_REG_HFR_CTL, 0); break; } return 0; @@ -654,23 +654,23 @@ static int handsfreerpga_event(struct snd_soc_dapm_widget *w, static int vibramux_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - twl4030_write(codec, TWL4030_REG_VIBRA_SET, 0xff); + twl4030_write(component, TWL4030_REG_VIBRA_SET, 0xff); return 0; } static int apll_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - twl4030_apll_enable(codec, 1); + twl4030_apll_enable(component, 1); break; case SND_SOC_DAPM_POST_PMD: - twl4030_apll_enable(codec, 0); + twl4030_apll_enable(component, 0); break; } return 0; @@ -679,41 +679,41 @@ static int apll_event(struct snd_soc_dapm_widget *w, static int aif_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u8 audio_if; - audio_if = twl4030_read(codec, TWL4030_REG_AUDIO_IF); + audio_if = twl4030_read(component, TWL4030_REG_AUDIO_IF); switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable AIF */ /* enable the PLL before we use it to clock the DAI */ - twl4030_apll_enable(codec, 1); + twl4030_apll_enable(component, 1); - twl4030_write(codec, TWL4030_REG_AUDIO_IF, + twl4030_write(component, TWL4030_REG_AUDIO_IF, audio_if | TWL4030_AIF_EN); break; case SND_SOC_DAPM_POST_PMD: /* disable the DAI before we stop it's source PLL */ - twl4030_write(codec, TWL4030_REG_AUDIO_IF, + twl4030_write(component, TWL4030_REG_AUDIO_IF, audio_if & ~TWL4030_AIF_EN); - twl4030_apll_enable(codec, 0); + twl4030_apll_enable(component, 0); break; } return 0; } -static void headset_ramp(struct snd_soc_codec *codec, int ramp) +static void headset_ramp(struct snd_soc_component *component, int ramp) { unsigned char hs_gain, hs_pop; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_codec_data *pdata = twl4030->pdata; /* Base values for ramp delay calculation: 2^19 - 2^26 */ unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864}; unsigned int delay; - hs_gain = twl4030_read(codec, TWL4030_REG_HS_GAIN_SET); - hs_pop = twl4030_read(codec, TWL4030_REG_HS_POPN_SET); + hs_gain = twl4030_read(component, TWL4030_REG_HS_GAIN_SET); + hs_pop = twl4030_read(component, TWL4030_REG_HS_POPN_SET); delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] / twl4030->sysclk) + 1; @@ -724,26 +724,26 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) gpio_set_value(pdata->hs_extmute_gpio, 1); } else { hs_pop |= TWL4030_EXTMUTE; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); } } if (ramp) { /* Headset ramp-up according to the TRM */ hs_pop |= TWL4030_VMID_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); /* Actually write to the register */ twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, hs_gain, TWL4030_REG_HS_GAIN_SET); hs_pop |= TWL4030_RAMP_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); /* Wait ramp delay time + 1, so the VMID can settle */ twl4030_wait_ms(delay); } else { /* Headset ramp-down _not_ according to * the TRM, but in a way that it is working */ hs_pop &= ~TWL4030_RAMP_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); /* Wait ramp delay time + 1, so the VMID can settle */ twl4030_wait_ms(delay); /* Bypass the reg_cache to mute the headset */ @@ -751,7 +751,7 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) TWL4030_REG_HS_GAIN_SET); hs_pop &= ~TWL4030_VMID_EN; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); } /* Disable external mute */ @@ -760,7 +760,7 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) gpio_set_value(pdata->hs_extmute_gpio, 0); } else { hs_pop &= ~TWL4030_EXTMUTE; - twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop); + twl4030_write(component, TWL4030_REG_HS_POPN_SET, hs_pop); } } } @@ -768,21 +768,21 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) static int headsetlpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* Do the ramp-up only once */ if (!twl4030->hsr_enabled) - headset_ramp(codec, 1); + headset_ramp(component, 1); twl4030->hsl_enabled = 1; break; case SND_SOC_DAPM_POST_PMD: /* Do the ramp-down only if both headsetL/R is disabled */ if (!twl4030->hsr_enabled) - headset_ramp(codec, 0); + headset_ramp(component, 0); twl4030->hsl_enabled = 0; break; @@ -793,21 +793,21 @@ static int headsetlpga_event(struct snd_soc_dapm_widget *w, static int headsetrpga_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* Do the ramp-up only once */ if (!twl4030->hsl_enabled) - headset_ramp(codec, 1); + headset_ramp(component, 1); twl4030->hsr_enabled = 1; break; case SND_SOC_DAPM_POST_PMD: /* Do the ramp-down only if both headsetL/R is disabled */ if (!twl4030->hsl_enabled) - headset_ramp(codec, 0); + headset_ramp(component, 0); twl4030->hsr_enabled = 0; break; @@ -818,8 +818,8 @@ static int headsetrpga_event(struct snd_soc_dapm_widget *w, static int digimic_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_codec_data *pdata = twl4030->pdata; if (pdata && pdata->digimic_delay) @@ -842,7 +842,7 @@ static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int shift = mc->shift; unsigned int rshift = mc->rshift; @@ -850,14 +850,14 @@ static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol, int mask = (1 << fls(max)) - 1; ucontrol->value.integer.value[0] = - (twl4030_read(codec, reg) >> shift) & mask; + (twl4030_read(component, reg) >> shift) & mask; if (ucontrol->value.integer.value[0]) ucontrol->value.integer.value[0] = max + 1 - ucontrol->value.integer.value[0]; if (shift != rshift) { ucontrol->value.integer.value[1] = - (twl4030_read(codec, reg) >> rshift) & mask; + (twl4030_read(component, reg) >> rshift) & mask; if (ucontrol->value.integer.value[1]) ucontrol->value.integer.value[1] = max + 1 - ucontrol->value.integer.value[1]; @@ -871,7 +871,7 @@ static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int shift = mc->shift; unsigned int rshift = mc->rshift; @@ -892,7 +892,7 @@ static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol, val2 = max + 1 - val2; val |= val2 << rshift; } - return snd_soc_update_bits(codec, reg, val_mask, val); + return snd_soc_component_update_bits(component, reg, val_mask, val); } static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, @@ -900,7 +900,7 @@ static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -908,9 +908,9 @@ static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, int mask = (1<value.integer.value[0] = - (twl4030_read(codec, reg) >> shift) & mask; + (twl4030_read(component, reg) >> shift) & mask; ucontrol->value.integer.value[1] = - (twl4030_read(codec, reg2) >> shift) & mask; + (twl4030_read(component, reg2) >> shift) & mask; if (ucontrol->value.integer.value[0]) ucontrol->value.integer.value[0] = @@ -927,7 +927,7 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -948,11 +948,11 @@ static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol, val = val << shift; val2 = val2 << shift; - err = snd_soc_update_bits(codec, reg, val_mask, val); + err = snd_soc_component_update_bits(component, reg, val_mask, val); if (err < 0) return err; - err = snd_soc_update_bits(codec, reg2, val_mask, val2); + err = snd_soc_component_update_bits(component, reg2, val_mask, val2); return err; } @@ -968,11 +968,11 @@ static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum, static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); if (twl4030->configured) { - dev_err(codec->dev, + dev_err(component->dev, "operation mode cannot be changed on-the-fly\n"); return -EBUSY; } @@ -1579,7 +1579,7 @@ static const struct snd_soc_dapm_route intercon[] = { }; -static int twl4030_set_bias_level(struct snd_soc_codec *codec, +static int twl4030_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -1588,11 +1588,11 @@ static int twl4030_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) - twl4030_codec_enable(codec, 1); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + twl4030_codec_enable(component, 1); break; case SND_SOC_BIAS_OFF: - twl4030_codec_enable(codec, 0); + twl4030_codec_enable(component, 0); break; } @@ -1628,12 +1628,12 @@ static void twl4030_constraints(struct twl4030_priv *twl4030, /* In case of 4 channel mode, the RX1 L/R for playback and the TX2 L/R for * capture has to be enabled/disabled. */ -static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction, +static void twl4030_tdm_enable(struct snd_soc_component *component, int direction, int enable) { u8 reg, mask; - reg = twl4030_read(codec, TWL4030_REG_OPTION); + reg = twl4030_read(component, TWL4030_REG_OPTION); if (direction == SNDRV_PCM_STREAM_PLAYBACK) mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN; @@ -1645,14 +1645,14 @@ static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction, else reg &= ~mask; - twl4030_write(codec, TWL4030_REG_OPTION, reg); + twl4030_write(component, TWL4030_REG_OPTION, reg); } static int twl4030_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); if (twl4030->master_substream) { twl4030->slave_substream = substream; @@ -1662,7 +1662,7 @@ static int twl4030_startup(struct snd_pcm_substream *substream, if (twl4030->configured) twl4030_constraints(twl4030, twl4030->master_substream); } else { - if (!(twl4030_read(codec, TWL4030_REG_CODEC_MODE) & + if (!(twl4030_read(component, TWL4030_REG_CODEC_MODE) & TWL4030_OPTION_1)) { /* In option2 4 channel is not supported, set the * constraint for the first stream for channels, the @@ -1680,8 +1680,8 @@ static int twl4030_startup(struct snd_pcm_substream *substream, static void twl4030_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); if (twl4030->master_substream == substream) twl4030->master_substream = twl4030->slave_substream; @@ -1697,27 +1697,27 @@ static void twl4030_shutdown(struct snd_pcm_substream *substream, /* If the closing substream had 4 channel, do the necessary cleanup */ if (substream->runtime->channels == 4) - twl4030_tdm_enable(codec, substream->stream, 0); + twl4030_tdm_enable(component, substream->stream, 0); } static int twl4030_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 mode, old_mode, format, old_format; /* If the substream has 4 channel, do the necessary setup */ if (params_channels(params) == 4) { - format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); - mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE); + format = twl4030_read(component, TWL4030_REG_AUDIO_IF); + mode = twl4030_read(component, TWL4030_REG_CODEC_MODE); /* Safety check: are we in the correct operating mode and * the interface is in TDM mode? */ if ((mode & TWL4030_OPTION_1) && ((format & TWL4030_AIF_FORMAT) == TWL4030_AIF_FORMAT_TDM)) - twl4030_tdm_enable(codec, substream->stream, 1); + twl4030_tdm_enable(component, substream->stream, 1); else return -EINVAL; } @@ -1727,7 +1727,7 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, return 0; /* bit rate */ - old_mode = twl4030_read(codec, + old_mode = twl4030_read(component, TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; mode = old_mode & ~TWL4030_APLL_RATE; @@ -1763,13 +1763,13 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, mode |= TWL4030_APLL_RATE_96000; break; default: - dev_err(codec->dev, "%s: unknown rate %d\n", __func__, + dev_err(component->dev, "%s: unknown rate %d\n", __func__, params_rate(params)); return -EINVAL; } /* sample size */ - old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); + old_format = twl4030_read(component, TWL4030_REG_AUDIO_IF); format = old_format; format &= ~TWL4030_DATA_WIDTH; switch (params_width(params)) { @@ -1780,7 +1780,7 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, format |= TWL4030_DATA_WIDTH_32S_24W; break; default: - dev_err(codec->dev, "%s: unsupported bits/sample %d\n", + dev_err(component->dev, "%s: unsupported bits/sample %d\n", __func__, params_width(params)); return -EINVAL; } @@ -1791,13 +1791,13 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, * If the codec is powered, than we need to toggle the * codec power. */ - twl4030_codec_enable(codec, 0); - twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); - twl4030_write(codec, TWL4030_REG_AUDIO_IF, format); - twl4030_codec_enable(codec, 1); + twl4030_codec_enable(component, 0); + twl4030_write(component, TWL4030_REG_CODEC_MODE, mode); + twl4030_write(component, TWL4030_REG_AUDIO_IF, format); + twl4030_codec_enable(component, 1); } else { - twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); - twl4030_write(codec, TWL4030_REG_AUDIO_IF, format); + twl4030_write(component, TWL4030_REG_CODEC_MODE, mode); + twl4030_write(component, TWL4030_REG_AUDIO_IF, format); } } @@ -1821,8 +1821,8 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); switch (freq) { case 19200000: @@ -1830,12 +1830,12 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, case 38400000: break; default: - dev_err(codec->dev, "Unsupported HFCLKIN: %u\n", freq); + dev_err(component->dev, "Unsupported HFCLKIN: %u\n", freq); return -EINVAL; } if ((freq / 1000) != twl4030->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "Mismatch in HFCLKIN: %u (configured: %u)\n", freq, twl4030->sysclk * 1000); return -EINVAL; @@ -1846,12 +1846,12 @@ static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 old_format, format; /* get format */ - old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); + old_format = twl4030_read(component, TWL4030_REG_AUDIO_IF); format = old_format; /* set master/slave audio interface */ @@ -1887,11 +1887,11 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) * If the codec is powered, than we need to toggle the * codec power. */ - twl4030_codec_enable(codec, 0); - twl4030_write(codec, TWL4030_REG_AUDIO_IF, format); - twl4030_codec_enable(codec, 1); + twl4030_codec_enable(component, 0); + twl4030_write(component, TWL4030_REG_AUDIO_IF, format); + twl4030_codec_enable(component, 1); } else { - twl4030_write(codec, TWL4030_REG_AUDIO_IF, format); + twl4030_write(component, TWL4030_REG_AUDIO_IF, format); } } @@ -1900,25 +1900,25 @@ static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; - u8 reg = twl4030_read(codec, TWL4030_REG_AUDIO_IF); + struct snd_soc_component *component = dai->component; + u8 reg = twl4030_read(component, TWL4030_REG_AUDIO_IF); if (tristate) reg |= TWL4030_AIF_TRI_EN; else reg &= ~TWL4030_AIF_TRI_EN; - return twl4030_write(codec, TWL4030_REG_AUDIO_IF, reg); + return twl4030_write(component, TWL4030_REG_AUDIO_IF, reg); } /* In case of voice mode, the RX1 L(VRX) for downlink and the TX2 L/R * (VTXL, VTXR) for uplink has to be enabled/disabled. */ -static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction, +static void twl4030_voice_enable(struct snd_soc_component *component, int direction, int enable) { u8 reg, mask; - reg = twl4030_read(codec, TWL4030_REG_OPTION); + reg = twl4030_read(component, TWL4030_REG_OPTION); if (direction == SNDRV_PCM_STREAM_PLAYBACK) mask = TWL4030_ARXL1_VRX_EN; @@ -1930,21 +1930,21 @@ static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction, else reg &= ~mask; - twl4030_write(codec, TWL4030_REG_OPTION, reg); + twl4030_write(component, TWL4030_REG_OPTION, reg); } static int twl4030_voice_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 mode; /* If the system master clock is not 26MHz, the voice PCM interface is * not available. */ if (twl4030->sysclk != 26000) { - dev_err(codec->dev, + dev_err(component->dev, "%s: HFCLKIN is %u KHz, voice interface needs 26MHz\n", __func__, twl4030->sysclk); return -EINVAL; @@ -1953,11 +1953,11 @@ static int twl4030_voice_startup(struct snd_pcm_substream *substream, /* If the codec mode is not option2, the voice PCM interface is not * available. */ - mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE) + mode = twl4030_read(component, TWL4030_REG_CODEC_MODE) & TWL4030_OPT_MODE; if (mode != TWL4030_OPTION_2) { - dev_err(codec->dev, "%s: the codec mode is not option2\n", + dev_err(component->dev, "%s: the codec mode is not option2\n", __func__); return -EINVAL; } @@ -1968,25 +1968,25 @@ static int twl4030_voice_startup(struct snd_pcm_substream *substream, static void twl4030_voice_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; /* Enable voice digital filters */ - twl4030_voice_enable(codec, substream->stream, 0); + twl4030_voice_enable(component, substream->stream, 0); } static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 old_mode, mode; /* Enable voice digital filters */ - twl4030_voice_enable(codec, substream->stream, 1); + twl4030_voice_enable(component, substream->stream, 1); /* bit rate */ - old_mode = twl4030_read(codec, + old_mode = twl4030_read(component, TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ; mode = old_mode; @@ -1998,7 +1998,7 @@ static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, mode |= TWL4030_SEL_16K; break; default: - dev_err(codec->dev, "%s: unknown rate %d\n", __func__, + dev_err(component->dev, "%s: unknown rate %d\n", __func__, params_rate(params)); return -EINVAL; } @@ -2009,11 +2009,11 @@ static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, * If the codec is powered, than we need to toggle the * codec power. */ - twl4030_codec_enable(codec, 0); - twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); - twl4030_codec_enable(codec, 1); + twl4030_codec_enable(component, 0); + twl4030_write(component, TWL4030_REG_CODEC_MODE, mode); + twl4030_codec_enable(component, 1); } else { - twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode); + twl4030_write(component, TWL4030_REG_CODEC_MODE, mode); } } @@ -2023,17 +2023,17 @@ static int twl4030_voice_hw_params(struct snd_pcm_substream *substream, static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); if (freq != 26000000) { - dev_err(codec->dev, + dev_err(component->dev, "%s: HFCLKIN is %u KHz, voice interface needs 26MHz\n", __func__, freq / 1000); return -EINVAL; } if ((freq / 1000) != twl4030->sysclk) { - dev_err(codec->dev, + dev_err(component->dev, "Mismatch in HFCLKIN: %u (configured: %u)\n", freq, twl4030->sysclk * 1000); return -EINVAL; @@ -2044,12 +2044,12 @@ static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); u8 old_format, format; /* get format */ - old_format = twl4030_read(codec, TWL4030_REG_VOICE_IF); + old_format = twl4030_read(component, TWL4030_REG_VOICE_IF); format = old_format; /* set master/slave audio interface */ @@ -2082,11 +2082,11 @@ static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, * If the codec is powered, than we need to toggle the * codec power. */ - twl4030_codec_enable(codec, 0); - twl4030_write(codec, TWL4030_REG_VOICE_IF, format); - twl4030_codec_enable(codec, 1); + twl4030_codec_enable(component, 0); + twl4030_write(component, TWL4030_REG_VOICE_IF, format); + twl4030_codec_enable(component, 1); } else { - twl4030_write(codec, TWL4030_REG_VOICE_IF, format); + twl4030_write(component, TWL4030_REG_VOICE_IF, format); } } @@ -2095,15 +2095,15 @@ static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; - u8 reg = twl4030_read(codec, TWL4030_REG_VOICE_IF); + struct snd_soc_component *component = dai->component; + u8 reg = twl4030_read(component, TWL4030_REG_VOICE_IF); if (tristate) reg |= TWL4030_VIF_TRI_EN; else reg &= ~TWL4030_VIF_TRI_EN; - return twl4030_write(codec, TWL4030_REG_VOICE_IF, reg); + return twl4030_write(component, TWL4030_REG_VOICE_IF, reg); } #define TWL4030_RATES (SNDRV_PCM_RATE_8000_48000) @@ -2164,69 +2164,60 @@ static struct snd_soc_dai_driver twl4030_dai[] = { }, }; -static int twl4030_soc_probe(struct snd_soc_codec *codec) +static int twl4030_soc_probe(struct snd_soc_component *component) { struct twl4030_priv *twl4030; - twl4030 = devm_kzalloc(codec->dev, sizeof(struct twl4030_priv), + twl4030 = devm_kzalloc(component->dev, sizeof(struct twl4030_priv), GFP_KERNEL); if (!twl4030) return -ENOMEM; - snd_soc_codec_set_drvdata(codec, twl4030); + snd_soc_component_set_drvdata(component, twl4030); /* Set the defaults, and power up the codec */ twl4030->sysclk = twl4030_audio_get_mclk() / 1000; - twl4030_init_chip(codec); + twl4030_init_chip(component); return 0; } -static int twl4030_soc_remove(struct snd_soc_codec *codec) +static void twl4030_soc_remove(struct snd_soc_component *component) { - struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); + struct twl4030_priv *twl4030 = snd_soc_component_get_drvdata(component); struct twl4030_codec_data *pdata = twl4030->pdata; if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio)) gpio_free(pdata->hs_extmute_gpio); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_twl4030 = { - .probe = twl4030_soc_probe, - .remove = twl4030_soc_remove, - .read = twl4030_read, - .write = twl4030_write, - .set_bias_level = twl4030_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = twl4030_snd_controls, - .num_controls = ARRAY_SIZE(twl4030_snd_controls), - .dapm_widgets = twl4030_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(twl4030_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_twl4030 = { + .probe = twl4030_soc_probe, + .remove = twl4030_soc_remove, + .read = twl4030_read, + .write = twl4030_write, + .set_bias_level = twl4030_set_bias_level, + .controls = twl4030_snd_controls, + .num_controls = ARRAY_SIZE(twl4030_snd_controls), + .dapm_widgets = twl4030_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(twl4030_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int twl4030_codec_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl4030, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_twl4030, twl4030_dai, ARRAY_SIZE(twl4030_dai)); } -static int twl4030_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - MODULE_ALIAS("platform:twl4030-codec"); static struct platform_driver twl4030_codec_driver = { .probe = twl4030_codec_probe, - .remove = twl4030_codec_remove, .driver = { .name = "twl4030-codec", }, From 732ae454bdebdc2afa133150655277551a77ede4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:21:15 +0000 Subject: [PATCH 128/942] ASoC: msm8916-wcd-analog: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-analog.c | 207 +++++++++++++------------- 1 file changed, 104 insertions(+), 103 deletions(-) diff --git a/sound/soc/codecs/msm8916-wcd-analog.c b/sound/soc/codecs/msm8916-wcd-analog.c index 44062bb7bf2f..12ee83d52405 100644 --- a/sound/soc/codecs/msm8916-wcd-analog.c +++ b/sound/soc/codecs/msm8916-wcd-analog.c @@ -288,7 +288,7 @@ struct pm8916_wcd_analog_priv { int mbhc_btn0_released; bool detect_accessory_type; struct clk *mclk; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; struct snd_soc_jack *jack; bool hphl_jack_type_normally_open; @@ -338,18 +338,18 @@ static const struct snd_kcontrol_new pm8916_wcd_analog_snd_controls[] = { SOC_SINGLE_TLV("ADC3 Volume", CDC_A_TX_3_EN, 3, 8, 0, analog_gain), }; -static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) +static void pm8916_wcd_analog_micbias_enable(struct snd_soc_component *component) { - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, MICB_1_CTL_INT_PRECHARG_BYP_EXT_PRECHRG_SEL | MICB_1_CTL_EXT_PRECHARG_EN_ENABLE); if (wcd->micbias_mv) { - snd_soc_update_bits(codec, CDC_A_MICB_1_VAL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_VAL, MICB_1_VAL_MICB_OUT_VAL_MASK, MICB_VOLTAGE_REGVAL(wcd->micbias_mv)); /* @@ -360,20 +360,20 @@ static void pm8916_wcd_analog_micbias_enable(struct snd_soc_codec *codec) msleep(50); } - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_EXT_PRECHARG_EN_MASK | MICB_1_CTL_INT_PRECHARG_BYP_MASK, 0); } -static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_codec - *codec, int event, +static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_component + *component, int event, int reg, unsigned int cap_mode) { switch (event) { case SND_SOC_DAPM_POST_PMU: - pm8916_wcd_analog_micbias_enable(codec); - snd_soc_update_bits(codec, CDC_A_MICB_1_EN, + pm8916_wcd_analog_micbias_enable(component); + snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_BYP_CAP_MASK, cap_mode); break; } @@ -381,25 +381,25 @@ static int pm8916_wcd_analog_enable_micbias_ext(struct snd_soc_codec return 0; } -static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_codec - *codec, int event, +static int pm8916_wcd_analog_enable_micbias_int(struct snd_soc_component + *component, int event, int reg, u32 cap_mode) { switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, + snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, MICB_1_INT_TX2_INT_RBIAS_EN_MASK, MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); - snd_soc_update_bits(codec, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); - snd_soc_update_bits(codec, CDC_A_MICB_1_EN, + snd_soc_component_update_bits(component, reg, MICB_1_EN_PULL_DOWN_EN_MASK, 0); + snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_OPA_STG2_TAIL_CURR_MASK, MICB_1_EN_OPA_STG2_TAIL_CURR_1_60UA); break; case SND_SOC_DAPM_POST_PMU: - pm8916_wcd_analog_micbias_enable(codec); - snd_soc_update_bits(codec, CDC_A_MICB_1_EN, + pm8916_wcd_analog_micbias_enable(component); + snd_soc_component_update_bits(component, CDC_A_MICB_1_EN, MICB_1_EN_BYP_CAP_MASK, cap_mode); break; } @@ -412,10 +412,10 @@ static int pm8916_wcd_analog_enable_micbias_ext1(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_ext(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, wcd->micbias1_cap_mode); } @@ -424,10 +424,10 @@ static int pm8916_wcd_analog_enable_micbias_ext2(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_ext(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_ext(component, event, w->reg, wcd->micbias2_cap_mode); } @@ -437,35 +437,35 @@ static int pm8916_wcd_analog_enable_micbias_int1(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); - return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, wcd->micbias1_cap_mode); } static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, bool micbias2_enabled) { - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 coarse, fine, reg_val, reg_addr; int *vrefs, i; if (!micbias2_enabled) { /* use internal 100uA Current source */ /* Enable internal 2.2k Internal Rbias Resistor */ - snd_soc_update_bits(codec, CDC_A_MICB_1_INT_RBIAS, + snd_soc_component_update_bits(component, CDC_A_MICB_1_INT_RBIAS, MICB_1_INT_TX2_INT_RBIAS_EN_MASK, MICB_1_INT_TX2_INT_RBIAS_EN_ENABLE); /* Remove pull down on MIC BIAS2 */ - snd_soc_update_bits(codec, CDC_A_MICB_2_EN, + snd_soc_component_update_bits(component, CDC_A_MICB_2_EN, CDC_A_MICB_2_PULL_DOWN_EN_MASK, 0); /* enable 100uA internal current source */ - snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL, CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_MASK, CDC_A_MBHC_FSM_CTL_BTN_ISRC_CTRL_I_100UA); } - snd_soc_update_bits(codec, CDC_A_MBHC_FSM_CTL, + snd_soc_component_update_bits(component, CDC_A_MBHC_FSM_CTL, CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN_MASK, CDC_A_MBHC_FSM_CTL_MBHC_FSM_EN); @@ -482,7 +482,7 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, fine = ((vrefs[i] % 100) / 12); reg_val = (coarse << CDC_A_MBHC_BTN_VREF_COARSE_SHIFT) | (fine << CDC_A_MBHC_BTN_VREF_FINE_SHIFT); - snd_soc_update_bits(codec, reg_addr, + snd_soc_component_update_bits(component, reg_addr, CDC_A_MBHC_BTN_VREF_MASK, reg_val); reg_addr++; @@ -493,12 +493,12 @@ static int pm8916_mbhc_configure_bias(struct pm8916_wcd_analog_priv *priv, static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) { - struct snd_soc_codec *codec = wcd->codec; + struct snd_soc_component *component = wcd->component; bool micbias_enabled = false; u32 plug_type = 0; u32 int_en_mask; - snd_soc_write(codec, CDC_A_MBHC_DET_CTL_1, + snd_soc_component_write(component, CDC_A_MBHC_DET_CTL_1, CDC_A_MBHC_DET_CTL_L_DET_EN | CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_INSERTION | CDC_A_MBHC_DET_CTL_MIC_CLAMP_CTL_AUTO | @@ -510,23 +510,23 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) if (wcd->gnd_jack_type_normally_open) plug_type |= CDC_A_GND_PLUG_TYPE_NO; - snd_soc_write(codec, CDC_A_MBHC_DET_CTL_2, + snd_soc_component_write(component, CDC_A_MBHC_DET_CTL_2, CDC_A_MBHC_DET_CTL_HS_L_DET_PULL_UP_CTRL_I_3P0 | CDC_A_MBHC_DET_CTL_HS_L_DET_COMPA_CTRL_V0P9_VDD | plug_type | CDC_A_MBHC_DET_CTL_HPHL_100K_TO_GND_EN); - snd_soc_write(codec, CDC_A_MBHC_DBNC_TIMER, + snd_soc_component_write(component, CDC_A_MBHC_DBNC_TIMER, CDC_A_MBHC_DBNC_TIMER_INSREM_DBNC_T_256_MS | CDC_A_MBHC_DBNC_TIMER_BTN_DBNC_T_16MS); /* enable MBHC clock */ - snd_soc_update_bits(codec, CDC_D_CDC_DIG_CLK_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_DIG_CLK_CTL, DIG_CLK_CTL_D_MBHC_CLK_EN_MASK, DIG_CLK_CTL_D_MBHC_CLK_EN); - if (snd_soc_read(codec, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) + if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) micbias_enabled = true; pm8916_mbhc_configure_bias(wcd, micbias_enabled); @@ -535,8 +535,8 @@ static void pm8916_wcd_setup_mbhc(struct pm8916_wcd_analog_priv *wcd) if (wcd->mbhc_btn_enabled) int_en_mask |= MBHC_BUTTON_PRESS_DET | MBHC_BUTTON_RELEASE_DET; - snd_soc_update_bits(codec, CDC_D_INT_EN_CLR, int_en_mask, 0); - snd_soc_update_bits(codec, CDC_D_INT_EN_SET, int_en_mask, int_en_mask); + snd_soc_component_update_bits(component, CDC_D_INT_EN_CLR, int_en_mask, 0); + snd_soc_component_update_bits(component, CDC_D_INT_EN_SET, int_en_mask, int_en_mask); wcd->mbhc_btn0_released = false; wcd->detect_accessory_type = true; } @@ -546,8 +546,8 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -558,7 +558,7 @@ static int pm8916_wcd_analog_enable_micbias_int2(struct break; } - return pm8916_wcd_analog_enable_micbias_int(codec, event, w->reg, + return pm8916_wcd_analog_enable_micbias_int(component, event, w->reg, wcd->micbias2_cap_mode); } @@ -566,7 +566,7 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u16 adc_reg = CDC_A_TX_1_2_TEST_CTL_2; u8 init_bit_shift; @@ -578,7 +578,7 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: if (w->reg == CDC_A_TX_2_EN) - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_CFILT_REF_SEL_MASK, MICB_1_CTL_CFILT_REF_SEL_HPF_REF); /* @@ -587,17 +587,17 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, * happen when the input voltage is changing too much. */ usleep_range(10000, 10010); - snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, + snd_soc_component_update_bits(component, adc_reg, 1 << init_bit_shift, 1 << init_bit_shift); switch (w->reg) { case CDC_A_TX_1_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX1_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX1_CTL, CONN_TX1_SERIAL_TX1_MUX, CONN_TX1_SERIAL_TX1_ADC_1); break; case CDC_A_TX_2_EN: case CDC_A_TX_3_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX2_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL, CONN_TX2_SERIAL_TX2_MUX, CONN_TX2_SERIAL_TX2_ADC_2); break; @@ -609,21 +609,21 @@ static int pm8916_wcd_analog_enable_adc(struct snd_soc_dapm_widget *w, * to reduce the tx pop */ usleep_range(12000, 12010); - snd_soc_update_bits(codec, adc_reg, 1 << init_bit_shift, 0x00); + snd_soc_component_update_bits(component, adc_reg, 1 << init_bit_shift, 0x00); break; case SND_SOC_DAPM_POST_PMD: switch (w->reg) { case CDC_A_TX_1_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX1_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX1_CTL, CONN_TX1_SERIAL_TX1_MUX, CONN_TX1_SERIAL_TX1_ZERO); break; case CDC_A_TX_2_EN: - snd_soc_update_bits(codec, CDC_A_MICB_1_CTL, + snd_soc_component_update_bits(component, CDC_A_MICB_1_CTL, MICB_1_CTL_CFILT_REF_SEL_MASK, 0); /* fall through */ case CDC_A_TX_3_EN: - snd_soc_update_bits(codec, CDC_D_CDC_CONN_TX2_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_CONN_TX2_CTL, CONN_TX2_SERIAL_TX2_MUX, CONN_TX2_SERIAL_TX2_ZERO); break; @@ -639,11 +639,11 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, CDC_A_SPKR_PWRSTG_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL, SPKR_PWRSTG_CTL_DAC_EN_MASK | SPKR_PWRSTG_CTL_BBM_MASK | SPKR_PWRSTG_CTL_HBRDGE_EN_MASK | @@ -653,29 +653,29 @@ static int pm8916_wcd_analog_enable_spk_pa(struct snd_soc_dapm_widget *w, SPKR_PWRSTG_CTL_HBRDGE_EN | SPKR_PWRSTG_CTL_CLAMP_EN); - snd_soc_update_bits(codec, CDC_A_RX_EAR_CTL, + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, RX_EAR_CTL_SPK_VBAT_LDO_EN_ENABLE); break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, CDC_A_SPKR_DRV_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_DRV_CTL, SPKR_DRV_CTL_DEF_MASK, SPKR_DRV_CTL_DEF_VAL); - snd_soc_update_bits(codec, w->reg, + snd_soc_component_update_bits(component, w->reg, SPKR_DRV_CLASSD_PA_EN_MASK, SPKR_DRV_CLASSD_PA_EN_ENABLE); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, CDC_A_SPKR_PWRSTG_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_PWRSTG_CTL, SPKR_PWRSTG_CTL_DAC_EN_MASK| SPKR_PWRSTG_CTL_BBM_MASK | SPKR_PWRSTG_CTL_HBRDGE_EN_MASK | SPKR_PWRSTG_CTL_CLAMP_EN_MASK, 0); - snd_soc_update_bits(codec, CDC_A_SPKR_DAC_CTL, + snd_soc_component_update_bits(component, CDC_A_SPKR_DAC_CTL, SPKR_DAC_CTL_DAC_RESET_MASK, SPKR_DAC_CTL_DAC_RESET_NORMAL); - snd_soc_update_bits(codec, CDC_A_RX_EAR_CTL, + snd_soc_component_update_bits(component, CDC_A_RX_EAR_CTL, RX_EAR_CTL_SPK_VBAT_LDO_EN_MASK, 0); break; } @@ -701,36 +701,36 @@ static const struct reg_default wcd_reg_defaults_2_0[] = { {CDC_A_MASTER_BIAS_CTL, 0x30}, }; -static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) +static int pm8916_wcd_analog_probe(struct snd_soc_component *component) { - struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); + struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev); int err, reg; err = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (err != 0) { - dev_err(codec->dev, "failed to enable regulators (%d)\n", err); + dev_err(component->dev, "failed to enable regulators (%d)\n", err); return err; } - snd_soc_codec_init_regmap(codec, - dev_get_regmap(codec->dev->parent, NULL)); - snd_soc_codec_set_drvdata(codec, priv); - priv->pmic_rev = snd_soc_read(codec, CDC_D_REVISION1); - priv->codec_version = snd_soc_read(codec, CDC_D_PERPH_SUBTYPE); + snd_soc_component_init_regmap(component, + dev_get_regmap(component->dev->parent, NULL)); + snd_soc_component_set_drvdata(component, priv); + priv->pmic_rev = snd_soc_component_read32(component, CDC_D_REVISION1); + priv->codec_version = snd_soc_component_read32(component, CDC_D_PERPH_SUBTYPE); - dev_info(codec->dev, "PMIC REV: %d\t CODEC Version: %d\n", + dev_info(component->dev, "PMIC REV: %d\t CODEC Version: %d\n", priv->pmic_rev, priv->codec_version); - snd_soc_write(codec, CDC_D_PERPH_RESET_CTL4, 0x01); - snd_soc_write(codec, CDC_A_PERPH_RESET_CTL4, 0x01); + snd_soc_component_write(component, CDC_D_PERPH_RESET_CTL4, 0x01); + snd_soc_component_write(component, CDC_A_PERPH_RESET_CTL4, 0x01); for (reg = 0; reg < ARRAY_SIZE(wcd_reg_defaults_2_0); reg++) - snd_soc_write(codec, wcd_reg_defaults_2_0[reg].reg, + snd_soc_component_write(component, wcd_reg_defaults_2_0[reg].reg, wcd_reg_defaults_2_0[reg].def); - priv->codec = codec; + priv->component = component; - snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL, RST_CTL_DIG_SW_RST_N_MASK, RST_CTL_DIG_SW_RST_N_REMOVE_RESET); @@ -739,14 +739,14 @@ static int pm8916_wcd_analog_probe(struct snd_soc_codec *codec) return 0; } -static int pm8916_wcd_analog_remove(struct snd_soc_codec *codec) +static void pm8916_wcd_analog_remove(struct snd_soc_component *component) { - struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(codec->dev); + struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(component->dev); - snd_soc_update_bits(codec, CDC_D_CDC_RST_CTL, + snd_soc_component_update_bits(component, CDC_D_CDC_RST_CTL, RST_CTL_DIG_SW_RST_N_MASK, 0); - return regulator_bulk_disable(ARRAY_SIZE(priv->supplies), + regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); } @@ -934,11 +934,11 @@ static const struct snd_soc_dapm_widget pm8916_wcd_analog_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("A_MCLK2", CDC_D_CDC_TOP_CLK_CTL, 3, 0, NULL, 0), }; -static int pm8916_wcd_analog_set_jack(struct snd_soc_codec *codec, +static int pm8916_wcd_analog_set_jack(struct snd_soc_component *component, struct snd_soc_jack *jack, void *data) { - struct pm8916_wcd_analog_priv *wcd = snd_soc_codec_get_drvdata(codec); + struct pm8916_wcd_analog_priv *wcd = snd_soc_component_get_drvdata(component); wcd->jack = jack; @@ -950,8 +950,8 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) struct pm8916_wcd_analog_priv *priv = arg; if (priv->detect_accessory_type) { - struct snd_soc_codec *codec = priv->codec; - u32 val = snd_soc_read(codec, CDC_A_MBHC_RESULT_1); + struct snd_soc_component *component = priv->component; + u32 val = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1); /* check if its BTN0 thats released */ if ((val != -1) && !(val & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK)) @@ -967,10 +967,10 @@ static irqreturn_t mbhc_btn_release_irq_handler(int irq, void *arg) static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) { struct pm8916_wcd_analog_priv *priv = arg; - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; u32 btn_result; - btn_result = snd_soc_read(codec, CDC_A_MBHC_RESULT_1) & + btn_result = snd_soc_component_read32(component, CDC_A_MBHC_RESULT_1) & CDC_A_MBHC_RESULT_1_BTN_RESULT_MASK; switch (btn_result) { @@ -993,7 +993,7 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) SND_JACK_BTN_0, btn_mask); break; default: - dev_err(codec->dev, + dev_err(component->dev, "Unexpected button press result (%x)", btn_result); break; } @@ -1004,15 +1004,15 @@ static irqreturn_t mbhc_btn_press_irq_handler(int irq, void *arg) static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) { struct pm8916_wcd_analog_priv *priv = arg; - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; bool ins = false; - if (snd_soc_read(codec, CDC_A_MBHC_DET_CTL_1) & + if (snd_soc_component_read32(component, CDC_A_MBHC_DET_CTL_1) & CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK) ins = true; /* Set the detection type appropriately */ - snd_soc_update_bits(codec, CDC_A_MBHC_DET_CTL_1, + snd_soc_component_update_bits(component, CDC_A_MBHC_DET_CTL_1, CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_MASK, (!ins << CDC_A_MBHC_DET_CTL_MECH_DET_TYPE_SHIFT)); @@ -1020,7 +1020,7 @@ static irqreturn_t pm8916_mbhc_switch_irq_handler(int irq, void *arg) if (ins) { /* hs insertion */ bool micbias_enabled = false; - if (snd_soc_read(codec, CDC_A_MICB_2_EN) & + if (snd_soc_component_read32(component, CDC_A_MICB_2_EN) & CDC_A_MICB_2_EN_ENABLE) micbias_enabled = true; @@ -1075,18 +1075,20 @@ static struct snd_soc_dai_driver pm8916_wcd_analog_dai[] = { }, }; -static const struct snd_soc_codec_driver pm8916_wcd_analog = { - .probe = pm8916_wcd_analog_probe, - .remove = pm8916_wcd_analog_remove, - .set_jack = pm8916_wcd_analog_set_jack, - .component_driver = { - .controls = pm8916_wcd_analog_snd_controls, - .num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls), - .dapm_widgets = pm8916_wcd_analog_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets), - .dapm_routes = pm8916_wcd_analog_audio_map, - .num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map), - }, +static const struct snd_soc_component_driver pm8916_wcd_analog = { + .probe = pm8916_wcd_analog_probe, + .remove = pm8916_wcd_analog_remove, + .set_jack = pm8916_wcd_analog_set_jack, + .controls = pm8916_wcd_analog_snd_controls, + .num_controls = ARRAY_SIZE(pm8916_wcd_analog_snd_controls), + .dapm_widgets = pm8916_wcd_analog_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pm8916_wcd_analog_dapm_widgets), + .dapm_routes = pm8916_wcd_analog_audio_map, + .num_dapm_routes = ARRAY_SIZE(pm8916_wcd_analog_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int pm8916_wcd_analog_parse_dt(struct device *dev, @@ -1223,7 +1225,7 @@ static int pm8916_wcd_analog_spmi_probe(struct platform_device *pdev) dev_set_drvdata(dev, priv); - return snd_soc_register_codec(dev, &pm8916_wcd_analog, + return devm_snd_soc_register_component(dev, &pm8916_wcd_analog, pm8916_wcd_analog_dai, ARRAY_SIZE(pm8916_wcd_analog_dai)); } @@ -1232,7 +1234,6 @@ static int pm8916_wcd_analog_spmi_remove(struct platform_device *pdev) { struct pm8916_wcd_analog_priv *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); clk_disable_unprepare(priv->mclk); return 0; From 2eec0a15e8d7e2a08acff56701cbd98e24a41097 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:21:38 +0000 Subject: [PATCH 129/942] ASoC: msm8916-wcd-digital: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/msm8916-wcd-digital.c | 115 +++++++++++++------------ 1 file changed, 58 insertions(+), 57 deletions(-) diff --git a/sound/soc/codecs/msm8916-wcd-digital.c b/sound/soc/codecs/msm8916-wcd-digital.c index 13354d6304a8..3063dedd21cf 100644 --- a/sound/soc/codecs/msm8916-wcd-digital.c +++ b/sound/soc/codecs/msm8916-wcd-digital.c @@ -348,14 +348,14 @@ static int msm8916_wcd_digital_enable_interpolator( struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: /* apply the digital gain after the interpolator is enabled */ usleep_range(10000, 10100); - snd_soc_write(codec, rx_gain_reg[w->shift], - snd_soc_read(codec, rx_gain_reg[w->shift])); + snd_soc_component_write(component, rx_gain_reg[w->shift], + snd_soc_component_read32(component, rx_gain_reg[w->shift])); break; } return 0; @@ -365,7 +365,7 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int decimator = w->shift + 1; u16 dec_reset_reg, tx_vol_ctl_reg, tx_mux_ctl_reg; u8 dec_hpf_cut_of_freq; @@ -377,46 +377,46 @@ static int msm8916_wcd_digital_enable_dec(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: /* Enable TX digital mute */ - snd_soc_update_bits(codec, tx_vol_ctl_reg, + snd_soc_component_update_bits(component, tx_vol_ctl_reg, TX_VOL_CTL_CFG_MUTE_EN_MASK, TX_VOL_CTL_CFG_MUTE_EN_ENABLE); - dec_hpf_cut_of_freq = snd_soc_read(codec, tx_mux_ctl_reg) & + dec_hpf_cut_of_freq = snd_soc_component_read32(component, tx_mux_ctl_reg) & TX_MUX_CTL_CUT_OFF_FREQ_MASK; dec_hpf_cut_of_freq >>= TX_MUX_CTL_CUT_OFF_FREQ_SHIFT; if (dec_hpf_cut_of_freq != TX_MUX_CTL_CF_NEG_3DB_150HZ) { /* set cut of freq to CF_MIN_3DB_150HZ (0x1) */ - snd_soc_update_bits(codec, tx_mux_ctl_reg, + snd_soc_component_update_bits(component, tx_mux_ctl_reg, TX_MUX_CTL_CUT_OFF_FREQ_MASK, TX_MUX_CTL_CF_NEG_3DB_150HZ); } break; case SND_SOC_DAPM_POST_PMU: /* enable HPF */ - snd_soc_update_bits(codec, tx_mux_ctl_reg, + snd_soc_component_update_bits(component, tx_mux_ctl_reg, TX_MUX_CTL_HPF_BP_SEL_MASK, TX_MUX_CTL_HPF_BP_SEL_NO_BYPASS); /* apply the digital gain after the decimator is enabled */ - snd_soc_write(codec, tx_gain_reg[w->shift], - snd_soc_read(codec, tx_gain_reg[w->shift])); - snd_soc_update_bits(codec, tx_vol_ctl_reg, + snd_soc_component_write(component, tx_gain_reg[w->shift], + snd_soc_component_read32(component, tx_gain_reg[w->shift])); + snd_soc_component_update_bits(component, tx_vol_ctl_reg, TX_VOL_CTL_CFG_MUTE_EN_MASK, 0); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, tx_vol_ctl_reg, + snd_soc_component_update_bits(component, tx_vol_ctl_reg, TX_VOL_CTL_CFG_MUTE_EN_MASK, TX_VOL_CTL_CFG_MUTE_EN_ENABLE); - snd_soc_update_bits(codec, tx_mux_ctl_reg, + snd_soc_component_update_bits(component, tx_mux_ctl_reg, TX_MUX_CTL_HPF_BP_SEL_MASK, TX_MUX_CTL_HPF_BP_SEL_BYPASS); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, + snd_soc_component_update_bits(component, dec_reset_reg, 1 << w->shift, 1 << w->shift); - snd_soc_update_bits(codec, dec_reset_reg, 1 << w->shift, 0x0); - snd_soc_update_bits(codec, tx_mux_ctl_reg, + snd_soc_component_update_bits(component, dec_reset_reg, 1 << w->shift, 0x0); + snd_soc_component_update_bits(component, tx_mux_ctl_reg, TX_MUX_CTL_HPF_BP_SEL_MASK, TX_MUX_CTL_HPF_BP_SEL_BYPASS); - snd_soc_update_bits(codec, tx_vol_ctl_reg, + snd_soc_component_update_bits(component, tx_vol_ctl_reg, TX_VOL_CTL_CFG_MUTE_EN_MASK, 0); break; } @@ -428,35 +428,35 @@ static int msm8916_wcd_digital_enable_dmic(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int dmic; int ret; /* get dmic number out of widget name */ char *dmic_num = strpbrk(w->name, "12"); if (dmic_num == NULL) { - dev_err(codec->dev, "Invalid DMIC\n"); + dev_err(component->dev, "Invalid DMIC\n"); return -EINVAL; } ret = kstrtouint(dmic_num, 10, &dmic); if (ret < 0 || dmic > 2) { - dev_err(codec->dev, "Invalid DMIC line on the codec\n"); + dev_err(component->dev, "Invalid DMIC line on the component\n"); return -EINVAL; } switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, LPASS_CDC_CLK_DMIC_B1_CTL, + snd_soc_component_update_bits(component, LPASS_CDC_CLK_DMIC_B1_CTL, DMIC_B1_CTL_DMIC0_CLK_SEL_MASK, DMIC_B1_CTL_DMIC0_CLK_SEL_DIV3); switch (dmic) { case 1: - snd_soc_update_bits(codec, LPASS_CDC_TX1_DMIC_CTL, + snd_soc_component_update_bits(component, LPASS_CDC_TX1_DMIC_CTL, TXN_DMIC_CTL_CLK_SEL_MASK, TXN_DMIC_CTL_CLK_SEL_DIV3); break; case 2: - snd_soc_update_bits(codec, LPASS_CDC_TX2_DMIC_CTL, + snd_soc_component_update_bits(component, LPASS_CDC_TX2_DMIC_CTL, TXN_DMIC_CTL_CLK_SEL_MASK, TXN_DMIC_CTL_CLK_SEL_DIV3); break; @@ -575,20 +575,20 @@ static int msm8916_wcd_digital_get_clks(struct platform_device *pdev, return 0; } -static int msm8916_wcd_digital_codec_probe(struct snd_soc_codec *codec) +static int msm8916_wcd_digital_component_probe(struct snd_soc_component *component) { - struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(codec->dev); + struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(component->dev); - snd_soc_codec_set_drvdata(codec, priv); + snd_soc_component_set_drvdata(component, priv); return 0; } -static int msm8916_wcd_digital_codec_set_sysclk(struct snd_soc_codec *codec, +static int msm8916_wcd_digital_component_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct msm8916_wcd_digital_priv *p = dev_get_drvdata(codec->dev); + struct msm8916_wcd_digital_priv *p = dev_get_drvdata(component->dev); return clk_set_rate(p->mclk, freq); } @@ -618,18 +618,18 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, rx_fs_rate = RX_I2S_CTL_RX_I2S_FS_RATE_F_48_KHZ; break; default: - dev_err(dai->codec->dev, "Invalid sampling rate %d\n", + dev_err(dai->component->dev, "Invalid sampling rate %d\n", params_rate(params)); return -EINVAL; } switch (substream->stream) { case SNDRV_PCM_STREAM_CAPTURE: - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_TX_I2S_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL, TX_I2S_CTL_TX_I2S_FS_RATE_MASK, tx_fs_rate); break; case SNDRV_PCM_STREAM_PLAYBACK: - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_RX_I2S_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL, RX_I2S_CTL_RX_I2S_FS_RATE_MASK, rx_fs_rate); break; default: @@ -638,18 +638,19 @@ static int msm8916_wcd_digital_hw_params(struct snd_pcm_substream *substream, switch (params_format(params)) { case SNDRV_PCM_FORMAT_S16_LE: - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_TX_I2S_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL, TX_I2S_CTL_TX_I2S_MODE_MASK, TX_I2S_CTL_TX_I2S_MODE_16); - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_RX_I2S_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL, RX_I2S_CTL_RX_I2S_MODE_MASK, RX_I2S_CTL_RX_I2S_MODE_16); break; + case SNDRV_PCM_FORMAT_S32_LE: - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_TX_I2S_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_TX_I2S_CTL, TX_I2S_CTL_TX_I2S_MODE_MASK, TX_I2S_CTL_TX_I2S_MODE_32); - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_RX_I2S_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_RX_I2S_CTL, RX_I2S_CTL_RX_I2S_MODE_MASK, RX_I2S_CTL_RX_I2S_MODE_32); break; @@ -780,32 +781,32 @@ static const struct snd_soc_dapm_route msm8916_wcd_digital_audio_map[] = { static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct msm8916_wcd_digital_priv *msm8916_wcd; unsigned long mclk_rate; - msm8916_wcd = snd_soc_codec_get_drvdata(codec); - snd_soc_update_bits(codec, LPASS_CDC_CLK_MCLK_CTL, + msm8916_wcd = snd_soc_component_get_drvdata(component); + snd_soc_component_update_bits(component, LPASS_CDC_CLK_MCLK_CTL, MCLK_CTL_MCLK_EN_MASK, MCLK_CTL_MCLK_EN_ENABLE); - snd_soc_update_bits(codec, LPASS_CDC_CLK_PDM_CTL, + snd_soc_component_update_bits(component, LPASS_CDC_CLK_PDM_CTL, LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_FB); mclk_rate = clk_get_rate(msm8916_wcd->mclk); switch (mclk_rate) { case 12288000: - snd_soc_update_bits(codec, LPASS_CDC_TOP_CTL, + snd_soc_component_update_bits(component, LPASS_CDC_TOP_CTL, TOP_CTL_DIG_MCLK_FREQ_MASK, TOP_CTL_DIG_MCLK_FREQ_F_12_288MHZ); break; case 9600000: - snd_soc_update_bits(codec, LPASS_CDC_TOP_CTL, + snd_soc_component_update_bits(component, LPASS_CDC_TOP_CTL, TOP_CTL_DIG_MCLK_FREQ_MASK, TOP_CTL_DIG_MCLK_FREQ_F_9_6MHZ); break; default: - dev_err(codec->dev, "Invalid mclk rate %ld\n", mclk_rate); + dev_err(component->dev, "Invalid mclk rate %ld\n", mclk_rate); break; } return 0; @@ -814,7 +815,7 @@ static int msm8916_wcd_digital_startup(struct snd_pcm_substream *substream, static void msm8916_wcd_digital_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - snd_soc_update_bits(dai->codec, LPASS_CDC_CLK_PDM_CTL, + snd_soc_component_update_bits(dai->component, LPASS_CDC_CLK_PDM_CTL, LPASS_CDC_CLK_PDM_CTL_PDM_CLK_SEL_MASK, 0); } @@ -851,18 +852,19 @@ static struct snd_soc_dai_driver msm8916_wcd_digital_dai[] = { }, }; -static const struct snd_soc_codec_driver msm8916_wcd_digital = { - .probe = msm8916_wcd_digital_codec_probe, - .set_sysclk = msm8916_wcd_digital_codec_set_sysclk, - .component_driver = { - .controls = msm8916_wcd_digital_snd_controls, - .num_controls = ARRAY_SIZE(msm8916_wcd_digital_snd_controls), - .dapm_widgets = msm8916_wcd_digital_dapm_widgets, - .num_dapm_widgets = - ARRAY_SIZE(msm8916_wcd_digital_dapm_widgets), - .dapm_routes = msm8916_wcd_digital_audio_map, - .num_dapm_routes = ARRAY_SIZE(msm8916_wcd_digital_audio_map), - }, +static const struct snd_soc_component_driver msm8916_wcd_digital = { + .probe = msm8916_wcd_digital_component_probe, + .set_sysclk = msm8916_wcd_digital_component_set_sysclk, + .controls = msm8916_wcd_digital_snd_controls, + .num_controls = ARRAY_SIZE(msm8916_wcd_digital_snd_controls), + .dapm_widgets = msm8916_wcd_digital_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(msm8916_wcd_digital_dapm_widgets), + .dapm_routes = msm8916_wcd_digital_audio_map, + .num_dapm_routes = ARRAY_SIZE(msm8916_wcd_digital_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config msm8916_codec_regmap_config = { @@ -915,7 +917,7 @@ static int msm8916_wcd_digital_probe(struct platform_device *pdev) dev_set_drvdata(dev, priv); - return snd_soc_register_codec(dev, &msm8916_wcd_digital, + return devm_snd_soc_register_component(dev, &msm8916_wcd_digital, msm8916_wcd_digital_dai, ARRAY_SIZE(msm8916_wcd_digital_dai)); } @@ -924,7 +926,6 @@ static int msm8916_wcd_digital_remove(struct platform_device *pdev) { struct msm8916_wcd_digital_priv *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); clk_disable_unprepare(priv->mclk); clk_disable_unprepare(priv->ahbclk); From 3860978c5bf48720d1bab68ffa49e153fb9c01e8 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:21:55 +0000 Subject: [PATCH 130/942] ASoC: spdif_transmitter: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/spdif_transmitter.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/spdif_transmitter.c b/sound/soc/codecs/spdif_transmitter.c index 037aa1d45559..b4f7fc4acb39 100644 --- a/sound/soc/codecs/spdif_transmitter.c +++ b/sound/soc/codecs/spdif_transmitter.c @@ -38,13 +38,15 @@ static const struct snd_soc_dapm_route dit_routes[] = { { "spdif-out", NULL, "Playback" }, }; -static struct snd_soc_codec_driver soc_codec_spdif_dit = { - .component_driver = { - .dapm_widgets = dit_widgets, - .num_dapm_widgets = ARRAY_SIZE(dit_widgets), - .dapm_routes = dit_routes, - .num_dapm_routes = ARRAY_SIZE(dit_routes), - }, +static struct snd_soc_component_driver soc_codec_spdif_dit = { + .dapm_widgets = dit_widgets, + .num_dapm_widgets = ARRAY_SIZE(dit_widgets), + .dapm_routes = dit_routes, + .num_dapm_routes = ARRAY_SIZE(dit_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct snd_soc_dai_driver dit_stub_dai = { @@ -60,16 +62,11 @@ static struct snd_soc_dai_driver dit_stub_dai = { static int spdif_dit_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit, + return devm_snd_soc_register_component(&pdev->dev, + &soc_codec_spdif_dit, &dit_stub_dai, 1); } -static int spdif_dit_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id spdif_dit_dt_ids[] = { { .compatible = "linux,spdif-dit", }, @@ -80,7 +77,6 @@ MODULE_DEVICE_TABLE(of, spdif_dit_dt_ids); static struct platform_driver spdif_dit_driver = { .probe = spdif_dit_probe, - .remove = spdif_dit_remove, .driver = { .name = DRV_NAME, .of_match_table = of_match_ptr(spdif_dit_dt_ids), From 8c6086b8b5e7e50519b6d439ec51ac06a956c656 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:22:25 +0000 Subject: [PATCH 131/942] ASoC: spdif_receiver: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/spdif_receiver.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/sound/soc/codecs/spdif_receiver.c b/sound/soc/codecs/spdif_receiver.c index c8fd6367f6c0..ac69d495d121 100644 --- a/sound/soc/codecs/spdif_receiver.c +++ b/sound/soc/codecs/spdif_receiver.c @@ -38,13 +38,15 @@ static const struct snd_soc_dapm_route dir_routes[] = { SNDRV_PCM_FMTBIT_S32_LE | \ SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE) -static struct snd_soc_codec_driver soc_codec_spdif_dir = { - .component_driver = { - .dapm_widgets = dir_widgets, - .num_dapm_widgets = ARRAY_SIZE(dir_widgets), - .dapm_routes = dir_routes, - .num_dapm_routes = ARRAY_SIZE(dir_routes), - }, +static struct snd_soc_component_driver soc_codec_spdif_dir = { + .dapm_widgets = dir_widgets, + .num_dapm_widgets = ARRAY_SIZE(dir_widgets), + .dapm_routes = dir_routes, + .num_dapm_routes = ARRAY_SIZE(dir_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct snd_soc_dai_driver dir_stub_dai = { @@ -60,16 +62,11 @@ static struct snd_soc_dai_driver dir_stub_dai = { static int spdif_dir_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dir, + return devm_snd_soc_register_component(&pdev->dev, + &soc_codec_spdif_dir, &dir_stub_dai, 1); } -static int spdif_dir_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id spdif_dir_dt_ids[] = { { .compatible = "linux,spdif-dir", }, @@ -80,7 +77,6 @@ MODULE_DEVICE_TABLE(of, spdif_dir_dt_ids); static struct platform_driver spdif_dir_driver = { .probe = spdif_dir_probe, - .remove = spdif_dir_remove, .driver = { .name = "spdif-dir", .of_match_table = of_match_ptr(spdif_dir_dt_ids), From a06919f517001a7bc746f4d5922d2cbac2b3d0c0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:23:00 +0000 Subject: [PATCH 132/942] ASoC: tas5720: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tas5720.c | 151 +++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 81 deletions(-) diff --git a/sound/soc/codecs/tas5720.c b/sound/soc/codecs/tas5720.c index f3006f301fe8..ae3d032ac35a 100644 --- a/sound/soc/codecs/tas5720.c +++ b/sound/soc/codecs/tas5720.c @@ -49,7 +49,7 @@ static const char * const tas5720_supply_names[] = { #define TAS5720_NUM_SUPPLIES ARRAY_SIZE(tas5720_supply_names) struct tas5720_data { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *regmap; struct i2c_client *tas5720_client; enum tas572x_type devtype; @@ -62,7 +62,7 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int rate = params_rate(params); bool ssz_ds; int ret; @@ -77,14 +77,14 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream, ssz_ds = true; break; default: - dev_err(codec->dev, "unsupported sample rate: %u\n", rate); + dev_err(component->dev, "unsupported sample rate: %u\n", rate); return -EINVAL; } - ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG, + ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG, TAS5720_SSZ_DS, ssz_ds); if (ret < 0) { - dev_err(codec->dev, "error setting sample rate: %d\n", ret); + dev_err(component->dev, "error setting sample rate: %d\n", ret); return ret; } @@ -93,12 +93,12 @@ static int tas5720_hw_params(struct snd_pcm_substream *substream, static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 serial_format; int ret; if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_vdbg(codec->dev, "DAI Format master is not found\n"); + dev_vdbg(component->dev, "DAI Format master is not found\n"); return -EINVAL; } @@ -132,15 +132,15 @@ static int tas5720_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) serial_format = TAS5720_SAIF_LEFTJ; break; default: - dev_vdbg(codec->dev, "DAI Format is not found\n"); + dev_vdbg(component->dev, "DAI Format is not found\n"); return -EINVAL; } - ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG, + ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG, TAS5720_SAIF_FORMAT_MASK, serial_format); if (ret < 0) { - dev_err(codec->dev, "error setting SAIF format: %d\n", ret); + dev_err(component->dev, "error setting SAIF format: %d\n", ret); return ret; } @@ -151,12 +151,12 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int first_slot; int ret; if (!tx_mask) { - dev_err(codec->dev, "tx masks must not be 0\n"); + dev_err(component->dev, "tx masks must not be 0\n"); return -EINVAL; } @@ -168,39 +168,39 @@ static int tas5720_set_dai_tdm_slot(struct snd_soc_dai *dai, first_slot = __ffs(tx_mask); if (first_slot > 7) { - dev_err(codec->dev, "slot selection out of bounds (%u)\n", + dev_err(component->dev, "slot selection out of bounds (%u)\n", first_slot); return -EINVAL; } /* Enable manual TDM slot selection (instead of I2C ID based) */ - ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL1_REG, + ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL1_REG, TAS5720_TDM_CFG_SRC, TAS5720_TDM_CFG_SRC); if (ret < 0) - goto error_snd_soc_update_bits; + goto error_snd_soc_component_update_bits; /* Configure the TDM slot to process audio from */ - ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG, + ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG, TAS5720_TDM_SLOT_SEL_MASK, first_slot); if (ret < 0) - goto error_snd_soc_update_bits; + goto error_snd_soc_component_update_bits; return 0; -error_snd_soc_update_bits: - dev_err(codec->dev, "error configuring TDM mode: %d\n", ret); +error_snd_soc_component_update_bits: + dev_err(component->dev, "error configuring TDM mode: %d\n", ret); return ret; } static int tas5720_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int ret; - ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG, + ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG, TAS5720_MUTE, mute ? TAS5720_MUTE : 0); if (ret < 0) { - dev_err(codec->dev, "error (un-)muting device: %d\n", ret); + dev_err(component->dev, "error (un-)muting device: %d\n", ret); return ret; } @@ -211,7 +211,7 @@ static void tas5720_fault_check_work(struct work_struct *work) { struct tas5720_data *tas5720 = container_of(work, struct tas5720_data, fault_check_work.work); - struct device *dev = tas5720->codec->dev; + struct device *dev = tas5720->component->dev; unsigned int curr_fault; int ret; @@ -267,18 +267,18 @@ out: msecs_to_jiffies(TAS5720_FAULT_CHECK_INTERVAL)); } -static int tas5720_codec_probe(struct snd_soc_codec *codec) +static int tas5720_codec_probe(struct snd_soc_component *component) { - struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); + struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component); unsigned int device_id, expected_device_id; int ret; - tas5720->codec = codec; + tas5720->component = component; ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies), tas5720->supplies); if (ret != 0) { - dev_err(codec->dev, "failed to enable supplies: %d\n", ret); + dev_err(component->dev, "failed to enable supplies: %d\n", ret); return ret; } @@ -289,7 +289,7 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) */ ret = regmap_read(tas5720->regmap, TAS5720_DEVICE_ID_REG, &device_id); if (ret < 0) { - dev_err(codec->dev, "failed to read device ID register: %d\n", + dev_err(component->dev, "failed to read device ID register: %d\n", ret); goto probe_fail; } @@ -302,19 +302,19 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) expected_device_id = TAS5722_DEVICE_ID; break; default: - dev_err(codec->dev, "unexpected private driver data\n"); + dev_err(component->dev, "unexpected private driver data\n"); return -EINVAL; } if (device_id != expected_device_id) - dev_warn(codec->dev, "wrong device ID. expected: %u read: %u\n", + dev_warn(component->dev, "wrong device ID. expected: %u read: %u\n", expected_device_id, device_id); /* Set device to mute */ - ret = snd_soc_update_bits(codec, TAS5720_DIGITAL_CTRL2_REG, + ret = snd_soc_component_update_bits(component, TAS5720_DIGITAL_CTRL2_REG, TAS5720_MUTE, TAS5720_MUTE); if (ret < 0) - goto error_snd_soc_update_bits; + goto error_snd_soc_component_update_bits; /* * Enter shutdown mode - our default when not playing audio - to @@ -322,17 +322,17 @@ static int tas5720_codec_probe(struct snd_soc_codec *codec) * side doing so as all device registers are preserved and the wakeup * of the codec is rather quick which we do using a dapm widget. */ - ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG, + ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG, TAS5720_SDZ, 0); if (ret < 0) - goto error_snd_soc_update_bits; + goto error_snd_soc_component_update_bits; INIT_DELAYED_WORK(&tas5720->fault_check_work, tas5720_fault_check_work); return 0; -error_snd_soc_update_bits: - dev_err(codec->dev, "error configuring device registers: %d\n", ret); +error_snd_soc_component_update_bits: + dev_err(component->dev, "error configuring device registers: %d\n", ret); probe_fail: regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), @@ -340,9 +340,9 @@ probe_fail: return ret; } -static int tas5720_codec_remove(struct snd_soc_codec *codec) +static void tas5720_codec_remove(struct snd_soc_component *component) { - struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); + struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component); int ret; cancel_delayed_work_sync(&tas5720->fault_check_work); @@ -350,24 +350,22 @@ static int tas5720_codec_remove(struct snd_soc_codec *codec) ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), tas5720->supplies); if (ret < 0) - dev_err(codec->dev, "failed to disable supplies: %d\n", ret); - - return ret; + dev_err(component->dev, "failed to disable supplies: %d\n", ret); }; static int tas5720_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component); int ret; if (event & SND_SOC_DAPM_POST_PMU) { /* Take TAS5720 out of shutdown mode */ - ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG, + ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG, TAS5720_SDZ, TAS5720_SDZ); if (ret < 0) { - dev_err(codec->dev, "error waking codec: %d\n", ret); + dev_err(component->dev, "error waking component: %d\n", ret); return ret; } @@ -390,10 +388,10 @@ static int tas5720_dac_event(struct snd_soc_dapm_widget *w, cancel_delayed_work_sync(&tas5720->fault_check_work); /* Place TAS5720 in shutdown mode to minimize current draw */ - ret = snd_soc_update_bits(codec, TAS5720_POWER_CTRL_REG, + ret = snd_soc_component_update_bits(component, TAS5720_POWER_CTRL_REG, TAS5720_SDZ, 0); if (ret < 0) { - dev_err(codec->dev, "error shutting down codec: %d\n", + dev_err(component->dev, "error shutting down component: %d\n", ret); return ret; } @@ -403,9 +401,9 @@ static int tas5720_dac_event(struct snd_soc_dapm_widget *w, } #ifdef CONFIG_PM -static int tas5720_suspend(struct snd_soc_codec *codec) +static int tas5720_suspend(struct snd_soc_component *component) { - struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); + struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component); int ret; regcache_cache_only(tas5720->regmap, true); @@ -414,20 +412,20 @@ static int tas5720_suspend(struct snd_soc_codec *codec) ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), tas5720->supplies); if (ret < 0) - dev_err(codec->dev, "failed to disable supplies: %d\n", ret); + dev_err(component->dev, "failed to disable supplies: %d\n", ret); return ret; } -static int tas5720_resume(struct snd_soc_codec *codec) +static int tas5720_resume(struct snd_soc_component *component) { - struct tas5720_data *tas5720 = snd_soc_codec_get_drvdata(codec); + struct tas5720_data *tas5720 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies), tas5720->supplies); if (ret < 0) { - dev_err(codec->dev, "failed to enable supplies: %d\n", ret); + dev_err(component->dev, "failed to enable supplies: %d\n", ret); return ret; } @@ -435,7 +433,7 @@ static int tas5720_resume(struct snd_soc_codec *codec) ret = regcache_sync(tas5720->regmap); if (ret < 0) { - dev_err(codec->dev, "failed to sync regcache: %d\n", ret); + dev_err(component->dev, "failed to sync regcache: %d\n", ret); return ret; } @@ -512,20 +510,21 @@ static const struct snd_soc_dapm_route tas5720_audio_map[] = { { "OUT", NULL, "DAC" }, }; -static const struct snd_soc_codec_driver soc_codec_dev_tas5720 = { - .probe = tas5720_codec_probe, - .remove = tas5720_codec_remove, - .suspend = tas5720_suspend, - .resume = tas5720_resume, - - .component_driver = { - .controls = tas5720_snd_controls, - .num_controls = ARRAY_SIZE(tas5720_snd_controls), - .dapm_widgets = tas5720_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets), - .dapm_routes = tas5720_audio_map, - .num_dapm_routes = ARRAY_SIZE(tas5720_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_tas5720 = { + .probe = tas5720_codec_probe, + .remove = tas5720_codec_remove, + .suspend = tas5720_suspend, + .resume = tas5720_resume, + .controls = tas5720_snd_controls, + .num_controls = ARRAY_SIZE(tas5720_snd_controls), + .dapm_widgets = tas5720_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tas5720_dapm_widgets), + .dapm_routes = tas5720_audio_map, + .num_dapm_routes = ARRAY_SIZE(tas5720_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* PCM rates supported by the TAS5720 driver */ @@ -614,26 +613,17 @@ static int tas5720_probe(struct i2c_client *client, dev_set_drvdata(dev, data); - ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_tas5720, + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_tas5720, tas5720_dai, ARRAY_SIZE(tas5720_dai)); if (ret < 0) { - dev_err(dev, "failed to register codec: %d\n", ret); + dev_err(dev, "failed to register component: %d\n", ret); return ret; } return 0; } -static int tas5720_remove(struct i2c_client *client) -{ - struct device *dev = &client->dev; - - snd_soc_unregister_codec(dev); - - return 0; -} - static const struct i2c_device_id tas5720_id[] = { { "tas5720", TAS5720 }, { "tas5722", TAS5722 }, @@ -656,7 +646,6 @@ static struct i2c_driver tas5720_i2c_driver = { .of_match_table = of_match_ptr(tas5720_of_match), }, .probe = tas5720_probe, - .remove = tas5720_remove, .id_table = tas5720_id, }; From 79a4ad1e0f4ae040daac3a7d7c6bddd3332d7baf Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:23:20 +0000 Subject: [PATCH 133/942] ASoC: tas2552: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 1 -> .use_pmdown_time = 0 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tas2552.c | 178 ++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 91 deletions(-) diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c index 87307dd0f12e..355ecafb7c0f 100644 --- a/sound/soc/codecs/tas2552.c +++ b/sound/soc/codecs/tas2552.c @@ -70,7 +70,7 @@ static const char *tas2552_supply_names[TAS2552_NUM_SUPPLIES] = { }; struct tas2552_data { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *regmap; struct i2c_client *tas2552_client; struct regulator_bulk_data supplies[TAS2552_NUM_SUPPLIES]; @@ -88,22 +88,22 @@ struct tas2552_data { static int tas2552_post_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, TAS2552_RESERVED_0D, 0xc0); - snd_soc_update_bits(codec, TAS2552_LIMIT_RATE_HYS, (1 << 5), + snd_soc_component_write(component, TAS2552_RESERVED_0D, 0xc0); + snd_soc_component_update_bits(component, TAS2552_LIMIT_RATE_HYS, (1 << 5), (1 << 5)); - snd_soc_update_bits(codec, TAS2552_CFG_2, 1, 0); - snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_SWS, 0); + snd_soc_component_update_bits(component, TAS2552_CFG_2, 1, 0); + snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_SWS, 0); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_SWS, + snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_SWS, TAS2552_SWS); - snd_soc_update_bits(codec, TAS2552_CFG_2, 1, 1); - snd_soc_update_bits(codec, TAS2552_LIMIT_RATE_HYS, (1 << 5), 0); - snd_soc_write(codec, TAS2552_RESERVED_0D, 0xbe); + snd_soc_component_update_bits(component, TAS2552_CFG_2, 1, 1); + snd_soc_component_update_bits(component, TAS2552_LIMIT_RATE_HYS, (1 << 5), 0); + snd_soc_component_write(component, TAS2552_RESERVED_0D, 0xbe); break; } return 0; @@ -149,21 +149,21 @@ static void tas2552_sw_shutdown(struct tas2552_data *tas2552, int sw_shutdown) { u8 cfg1_reg = 0; - if (!tas2552->codec) + if (!tas2552->component) return; if (sw_shutdown) cfg1_reg = TAS2552_SWS; - snd_soc_update_bits(tas2552->codec, TAS2552_CFG_1, TAS2552_SWS, + snd_soc_component_update_bits(tas2552->component, TAS2552_CFG_1, TAS2552_SWS, cfg1_reg); } #endif -static int tas2552_setup_pll(struct snd_soc_codec *codec, +static int tas2552_setup_pll(struct snd_soc_component *component, struct snd_pcm_hw_params *params) { - struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); + struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); bool bypass_pll = false; unsigned int pll_clk = params_rate(params) * 512; unsigned int pll_clkin = tas2552->pll_clkin; @@ -177,15 +177,15 @@ static int tas2552_setup_pll(struct snd_soc_codec *codec, pll_clkin += tas2552->tdm_delay; } - pll_enable = snd_soc_read(codec, TAS2552_CFG_2) & TAS2552_PLL_ENABLE; - snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); + pll_enable = snd_soc_component_read32(component, TAS2552_CFG_2) & TAS2552_PLL_ENABLE; + snd_soc_component_update_bits(component, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); if (pll_clkin == pll_clk) bypass_pll = true; if (bypass_pll) { /* By pass the PLL configuration */ - snd_soc_update_bits(codec, TAS2552_PLL_CTRL_2, + snd_soc_component_update_bits(component, TAS2552_PLL_CTRL_2, TAS2552_PLL_BYPASS, TAS2552_PLL_BYPASS); } else { /* Fill in the PLL control registers for J & D @@ -195,7 +195,7 @@ static int tas2552_setup_pll(struct snd_soc_codec *codec, unsigned int d, q, t; u8 j; u8 pll_sel = (tas2552->pll_clk_id << 3) & TAS2552_PLL_SRC_MASK; - u8 p = snd_soc_read(codec, TAS2552_PLL_CTRL_1); + u8 p = snd_soc_component_read32(component, TAS2552_PLL_CTRL_1); p = (p >> 7); @@ -221,20 +221,20 @@ recalc: goto recalc; } - snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_PLL_SRC_MASK, + snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_PLL_SRC_MASK, pll_sel); - snd_soc_update_bits(codec, TAS2552_PLL_CTRL_1, + snd_soc_component_update_bits(component, TAS2552_PLL_CTRL_1, TAS2552_PLL_J_MASK, j); /* Will clear the PLL_BYPASS bit */ - snd_soc_write(codec, TAS2552_PLL_CTRL_2, + snd_soc_component_write(component, TAS2552_PLL_CTRL_2, TAS2552_PLL_D_UPPER(d)); - snd_soc_write(codec, TAS2552_PLL_CTRL_3, + snd_soc_component_write(component, TAS2552_PLL_CTRL_3, TAS2552_PLL_D_LOWER(d)); } /* Restore PLL status */ - snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, + snd_soc_component_update_bits(component, TAS2552_CFG_2, TAS2552_PLL_ENABLE, pll_enable); return 0; @@ -244,8 +244,8 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = dai->component; + struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); int cpf; u8 ser_ctrl1_reg, wclk_rate; @@ -267,7 +267,7 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, cpf = 64 + tas2552->tdm_delay; break; default: - dev_err(codec->dev, "Not supported sample size: %d\n", + dev_err(component->dev, "Not supported sample size: %d\n", params_width(params)); return -EINVAL; } @@ -281,7 +281,7 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, else ser_ctrl1_reg |= TAS2552_CLKSPERFRAME_256; - snd_soc_update_bits(codec, TAS2552_SER_CTRL_1, + snd_soc_component_update_bits(component, TAS2552_SER_CTRL_1, TAS2552_WORDLENGTH_MASK | TAS2552_CLKSPERFRAME_MASK, ser_ctrl1_reg); @@ -316,15 +316,15 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, wclk_rate = TAS2552_WCLK_FREQ_176_192KHZ; break; default: - dev_err(codec->dev, "Not supported sample rate: %d\n", + dev_err(component->dev, "Not supported sample rate: %d\n", params_rate(params)); return -EINVAL; } - snd_soc_update_bits(codec, TAS2552_CFG_3, TAS2552_WCLK_FREQ_MASK, + snd_soc_component_update_bits(component, TAS2552_CFG_3, TAS2552_WCLK_FREQ_MASK, wclk_rate); - return tas2552_setup_pll(codec, params); + return tas2552_setup_pll(component, params); } #define TAS2552_DAI_FMT_MASK (TAS2552_BCLKDIR | \ @@ -333,8 +333,8 @@ static int tas2552_hw_params(struct snd_pcm_substream *substream, static int tas2552_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tas2552_data *tas2552 = snd_soc_component_get_drvdata(component); int delay = 0; /* TDM slot selection only valid in DSP_A/_B mode */ @@ -344,15 +344,15 @@ static int tas2552_prepare(struct snd_pcm_substream *substream, delay += tas2552->tdm_delay; /* Configure data delay */ - snd_soc_write(codec, TAS2552_SER_CTRL_2, delay); + snd_soc_component_write(component, TAS2552_SER_CTRL_2, delay); return 0; } static int tas2552_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = dai->component; + struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); u8 serial_format; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -369,7 +369,7 @@ static int tas2552_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) serial_format = (TAS2552_BCLKDIR | TAS2552_WCLKDIR); break; default: - dev_vdbg(codec->dev, "DAI Format master is not found\n"); + dev_vdbg(component->dev, "DAI Format master is not found\n"); return -EINVAL; } @@ -388,12 +388,12 @@ static int tas2552_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) serial_format |= TAS2552_DATAFORMAT_LEFT_J; break; default: - dev_vdbg(codec->dev, "DAI Format is not found\n"); + dev_vdbg(component->dev, "DAI Format is not found\n"); return -EINVAL; } tas2552->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; - snd_soc_update_bits(codec, TAS2552_SER_CTRL_1, TAS2552_DAI_FMT_MASK, + snd_soc_component_update_bits(component, TAS2552_SER_CTRL_1, TAS2552_DAI_FMT_MASK, serial_format); return 0; } @@ -401,8 +401,8 @@ static int tas2552_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int tas2552_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = dai->component; + struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); u8 reg, mask, val; switch (clk_id) { @@ -410,7 +410,7 @@ static int tas2552_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, case TAS2552_PLL_CLKIN_IVCLKIN: if (freq < 512000 || freq > 24576000) { /* out of range PLL_CLKIN, fall back to use BCLK */ - dev_warn(codec->dev, "Out of range PLL_CLKIN: %u\n", + dev_warn(component->dev, "Out of range PLL_CLKIN: %u\n", freq); clk_id = TAS2552_PLL_CLKIN_BCLK; freq = 0; @@ -435,11 +435,11 @@ static int tas2552_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, tas2552->pdm_clk = freq; break; default: - dev_err(codec->dev, "Invalid clk id: %d\n", clk_id); + dev_err(component->dev, "Invalid clk id: %d\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); return 0; } @@ -448,26 +448,26 @@ static int tas2552_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tas2552_data *tas2552 = snd_soc_component_get_drvdata(component); unsigned int lsb; if (unlikely(!tx_mask)) { - dev_err(codec->dev, "tx masks need to be non 0\n"); + dev_err(component->dev, "tx masks need to be non 0\n"); return -EINVAL; } /* TDM based on DSP mode requires slots to be adjacent */ lsb = __ffs(tx_mask); if ((lsb + 1) != __fls(tx_mask)) { - dev_err(codec->dev, "Invalid mask, slots must be adjacent\n"); + dev_err(component->dev, "Invalid mask, slots must be adjacent\n"); return -EINVAL; } tas2552->tdm_delay = lsb * slot_width; /* DOUT in high-impedance on inactive bit clocks */ - snd_soc_update_bits(codec, TAS2552_DOUT, + snd_soc_component_update_bits(component, TAS2552_DOUT, TAS2552_SDOUT_TRISTATE, TAS2552_SDOUT_TRISTATE); return 0; @@ -476,12 +476,12 @@ static int tas2552_set_dai_tdm_slot(struct snd_soc_dai *dai, static int tas2552_mute(struct snd_soc_dai *dai, int mute) { u8 cfg1_reg = 0; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) cfg1_reg |= TAS2552_MUTE; - snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_MUTE, cfg1_reg); + snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_MUTE, cfg1_reg); return 0; } @@ -570,41 +570,41 @@ static const struct snd_kcontrol_new tas2552_snd_controls[] = { SOC_ENUM("DIN source", tas2552_din_source_enum), }; -static int tas2552_codec_probe(struct snd_soc_codec *codec) +static int tas2552_component_probe(struct snd_soc_component *component) { - struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct tas2552_data *tas2552 = snd_soc_component_get_drvdata(component); int ret; - tas2552->codec = codec; + tas2552->component = component; ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), tas2552->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } gpiod_set_value(tas2552->enable_gpio, 1); - ret = pm_runtime_get_sync(codec->dev); + ret = pm_runtime_get_sync(component->dev); if (ret < 0) { - dev_err(codec->dev, "Enabling device failed: %d\n", + dev_err(component->dev, "Enabling device failed: %d\n", ret); goto probe_fail; } - snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_MUTE, TAS2552_MUTE); - snd_soc_write(codec, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL | + snd_soc_component_update_bits(component, TAS2552_CFG_1, TAS2552_MUTE, TAS2552_MUTE); + snd_soc_component_write(component, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL | TAS2552_DIN_SRC_SEL_AVG_L_R); - snd_soc_write(codec, TAS2552_OUTPUT_DATA, + snd_soc_component_write(component, TAS2552_OUTPUT_DATA, TAS2552_PDM_DATA_SEL_V_I | TAS2552_R_DATA_OUT(TAS2552_DATA_OUT_V_DATA)); - snd_soc_write(codec, TAS2552_BOOST_APT_CTRL, TAS2552_APT_DELAY_200 | + snd_soc_component_write(component, TAS2552_BOOST_APT_CTRL, TAS2552_APT_DELAY_200 | TAS2552_APT_THRESH_20_17); - snd_soc_write(codec, TAS2552_CFG_2, TAS2552_BOOST_EN | TAS2552_APT_EN | + snd_soc_component_write(component, TAS2552_CFG_2, TAS2552_BOOST_EN | TAS2552_APT_EN | TAS2552_LIM_EN); return 0; @@ -617,42 +617,40 @@ probe_fail: return ret; } -static int tas2552_codec_remove(struct snd_soc_codec *codec) +static void tas2552_component_remove(struct snd_soc_component *component) { - struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct tas2552_data *tas2552 = snd_soc_component_get_drvdata(component); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); gpiod_set_value(tas2552->enable_gpio, 0); - - return 0; }; #ifdef CONFIG_PM -static int tas2552_suspend(struct snd_soc_codec *codec) +static int tas2552_suspend(struct snd_soc_component *component) { - struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct tas2552_data *tas2552 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), tas2552->supplies); if (ret != 0) - dev_err(codec->dev, "Failed to disable supplies: %d\n", + dev_err(component->dev, "Failed to disable supplies: %d\n", ret); return ret; } -static int tas2552_resume(struct snd_soc_codec *codec) +static int tas2552_resume(struct snd_soc_component *component) { - struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); + struct tas2552_data *tas2552 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), tas2552->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); } @@ -663,21 +661,20 @@ static int tas2552_resume(struct snd_soc_codec *codec) #define tas2552_resume NULL #endif -static const struct snd_soc_codec_driver soc_codec_dev_tas2552 = { - .probe = tas2552_codec_probe, - .remove = tas2552_codec_remove, - .suspend = tas2552_suspend, - .resume = tas2552_resume, - .ignore_pmdown_time = true, - - .component_driver = { - .controls = tas2552_snd_controls, - .num_controls = ARRAY_SIZE(tas2552_snd_controls), - .dapm_widgets = tas2552_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tas2552_dapm_widgets), - .dapm_routes = tas2552_audio_map, - .num_dapm_routes = ARRAY_SIZE(tas2552_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_tas2552 = { + .probe = tas2552_component_probe, + .remove = tas2552_component_remove, + .suspend = tas2552_suspend, + .resume = tas2552_resume, + .controls = tas2552_snd_controls, + .num_controls = ARRAY_SIZE(tas2552_snd_controls), + .dapm_widgets = tas2552_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tas2552_dapm_widgets), + .dapm_routes = tas2552_audio_map, + .num_dapm_routes = ARRAY_SIZE(tas2552_audio_map), + .idle_bias_on = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config tas2552_regmap_config = { @@ -736,18 +733,17 @@ static int tas2552_probe(struct i2c_client *client, dev_set_drvdata(&client->dev, data); - ret = snd_soc_register_codec(&client->dev, - &soc_codec_dev_tas2552, + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_dev_tas2552, tas2552_dai, ARRAY_SIZE(tas2552_dai)); if (ret < 0) - dev_err(&client->dev, "Failed to register codec: %d\n", ret); + dev_err(&client->dev, "Failed to register component: %d\n", ret); return ret; } static int tas2552_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); pm_runtime_disable(&client->dev); return 0; } From 77f4be16e6bf781e05a5ea95b98259c93ccf1fa2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:23:46 +0000 Subject: [PATCH 134/942] ASoC: sun4i: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sunxi/sun4i-codec.c | 71 ++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c index 886281673972..9a3cb7704810 100644 --- a/sound/soc/sunxi/sun4i-codec.c +++ b/sound/soc/sunxi/sun4i-codec.c @@ -792,15 +792,17 @@ static const struct snd_soc_dapm_route sun4i_codec_codec_dapm_routes[] = { { "Mic1", NULL, "VMIC" }, }; -static const struct snd_soc_codec_driver sun4i_codec_codec = { - .component_driver = { - .controls = sun4i_codec_controls, - .num_controls = ARRAY_SIZE(sun4i_codec_controls), - .dapm_widgets = sun4i_codec_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sun4i_codec_codec_dapm_widgets), - .dapm_routes = sun4i_codec_codec_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sun4i_codec_codec_dapm_routes), - }, +static const struct snd_soc_component_driver sun4i_codec_codec = { + .controls = sun4i_codec_controls, + .num_controls = ARRAY_SIZE(sun4i_codec_controls), + .dapm_widgets = sun4i_codec_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sun4i_codec_codec_dapm_widgets), + .dapm_routes = sun4i_codec_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sun4i_codec_codec_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /*** sun6i Codec ***/ @@ -1098,15 +1100,17 @@ static const struct snd_soc_dapm_route sun6i_codec_codec_dapm_routes[] = { { "Right ADC", NULL, "Right ADC Mixer" }, }; -static const struct snd_soc_codec_driver sun6i_codec_codec = { - .component_driver = { - .controls = sun6i_codec_codec_widgets, - .num_controls = ARRAY_SIZE(sun6i_codec_codec_widgets), - .dapm_widgets = sun6i_codec_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sun6i_codec_codec_dapm_widgets), - .dapm_routes = sun6i_codec_codec_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sun6i_codec_codec_dapm_routes), - }, +static const struct snd_soc_component_driver sun6i_codec_codec = { + .controls = sun6i_codec_codec_widgets, + .num_controls = ARRAY_SIZE(sun6i_codec_codec_widgets), + .dapm_widgets = sun6i_codec_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sun6i_codec_codec_dapm_widgets), + .dapm_routes = sun6i_codec_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sun6i_codec_codec_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* sun8i A23 codec */ @@ -1126,13 +1130,15 @@ static const struct snd_soc_dapm_widget sun8i_a23_codec_codec_widgets[] = { }; -static const struct snd_soc_codec_driver sun8i_a23_codec_codec = { - .component_driver = { - .controls = sun8i_a23_codec_codec_controls, - .num_controls = ARRAY_SIZE(sun8i_a23_codec_codec_controls), - .dapm_widgets = sun8i_a23_codec_codec_widgets, - .num_dapm_widgets = ARRAY_SIZE(sun8i_a23_codec_codec_widgets), - }, +static const struct snd_soc_component_driver sun8i_a23_codec_codec = { + .controls = sun8i_a23_codec_codec_controls, + .num_controls = ARRAY_SIZE(sun8i_a23_codec_codec_controls), + .dapm_widgets = sun8i_a23_codec_codec_widgets, + .num_dapm_widgets = ARRAY_SIZE(sun8i_a23_codec_codec_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct snd_soc_component_driver sun4i_codec_component = { @@ -1450,7 +1456,7 @@ static const struct regmap_config sun8i_v3s_codec_regmap_config = { struct sun4i_codec_quirks { const struct regmap_config *regmap_config; - const struct snd_soc_codec_driver *codec; + const struct snd_soc_component_driver *codec; struct snd_soc_card * (*create_card)(struct device *dev); struct reg_field reg_adc_fifoc; /* used for regmap_field */ unsigned int reg_dac_txdata; /* TX FIFO offset for DMA config */ @@ -1657,7 +1663,7 @@ static int sun4i_codec_probe(struct platform_device *pdev) scodec->capture_dma_data.maxburst = 8; scodec->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_2_BYTES; - ret = snd_soc_register_codec(&pdev->dev, quirks->codec, + ret = devm_snd_soc_register_component(&pdev->dev, quirks->codec, &sun4i_codec_dai, 1); if (ret) { dev_err(&pdev->dev, "Failed to register our codec\n"); @@ -1669,20 +1675,20 @@ static int sun4i_codec_probe(struct platform_device *pdev) &dummy_cpu_dai, 1); if (ret) { dev_err(&pdev->dev, "Failed to register our DAI\n"); - goto err_unregister_codec; + goto err_assert_reset; } ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); if (ret) { dev_err(&pdev->dev, "Failed to register against DMAEngine\n"); - goto err_unregister_codec; + goto err_assert_reset; } card = quirks->create_card(&pdev->dev); if (IS_ERR(card)) { ret = PTR_ERR(card); dev_err(&pdev->dev, "Failed to create our card\n"); - goto err_unregister_codec; + goto err_assert_reset; } snd_soc_card_set_drvdata(card, scodec); @@ -1690,13 +1696,11 @@ static int sun4i_codec_probe(struct platform_device *pdev) ret = snd_soc_register_card(card); if (ret) { dev_err(&pdev->dev, "Failed to register our card\n"); - goto err_unregister_codec; + goto err_assert_reset; } return 0; -err_unregister_codec: - snd_soc_unregister_codec(&pdev->dev); err_assert_reset: if (scodec->rst) reset_control_assert(scodec->rst); @@ -1711,7 +1715,6 @@ static int sun4i_codec_remove(struct platform_device *pdev) struct sun4i_codec *scodec = snd_soc_card_get_drvdata(card); snd_soc_unregister_card(card); - snd_soc_unregister_codec(&pdev->dev); if (scodec->rst) reset_control_assert(scodec->rst); clk_disable_unprepare(scodec->clk_apb); From 7ec9b872f975a7ab7a466fdb63da9509bc2c9085 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:24:17 +0000 Subject: [PATCH 135/942] ASoC: sun8i: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sunxi/sun8i-codec.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c index 7a15df924316..fb37dd927e33 100644 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@ -184,7 +184,7 @@ static int sun8i_codec_get_hw_rate(struct snd_pcm_hw_params *params) static int sun8i_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct sun8i_codec *scodec = snd_soc_codec_get_drvdata(dai->codec); + struct sun8i_codec *scodec = snd_soc_component_get_drvdata(dai->component); u32 value; /* clock masters */ @@ -304,7 +304,7 @@ static int sun8i_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct sun8i_codec *scodec = snd_soc_codec_get_drvdata(dai->codec); + struct sun8i_codec *scodec = snd_soc_component_get_drvdata(dai->component); int sample_rate; u8 bclk_div; @@ -500,13 +500,15 @@ static struct snd_soc_dai_driver sun8i_codec_dai = { .ops = &sun8i_codec_dai_ops, }; -static const struct snd_soc_codec_driver sun8i_soc_codec = { - .component_driver = { - .dapm_widgets = sun8i_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sun8i_codec_dapm_widgets), - .dapm_routes = sun8i_codec_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sun8i_codec_dapm_routes), - }, +static const struct snd_soc_component_driver sun8i_soc_component = { + .dapm_widgets = sun8i_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sun8i_codec_dapm_widgets), + .dapm_routes = sun8i_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sun8i_codec_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config sun8i_codec_regmap_config = { @@ -566,7 +568,7 @@ static int sun8i_codec_probe(struct platform_device *pdev) goto err_pm_disable; } - ret = snd_soc_register_codec(&pdev->dev, &sun8i_soc_codec, + ret = devm_snd_soc_register_component(&pdev->dev, &sun8i_soc_component, &sun8i_codec_dai, 1); if (ret) { dev_err(&pdev->dev, "Failed to register codec\n"); @@ -594,7 +596,6 @@ static int sun8i_codec_remove(struct platform_device *pdev) if (!pm_runtime_status_suspended(&pdev->dev)) sun8i_codec_runtime_suspend(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); clk_disable_unprepare(scodec->clk_module); clk_disable_unprepare(scodec->clk_bus); From 9310161754511c212dbb6728860376a5afcbbcc8 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:24:44 +0000 Subject: [PATCH 136/942] ASoC: ads117x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ads117x.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/ads117x.c b/sound/soc/codecs/ads117x.c index b7f0057c0239..bcd45ff5db0c 100644 --- a/sound/soc/codecs/ads117x.c +++ b/sound/soc/codecs/ads117x.c @@ -58,25 +58,21 @@ static struct snd_soc_dai_driver ads117x_dai = { .formats = ADS117X_FORMATS,}, }; -static const struct snd_soc_codec_driver soc_codec_dev_ads117x = { - .component_driver = { - .dapm_widgets = ads117x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets), - .dapm_routes = ads117x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ads117x_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ads117x = { + .dapm_widgets = ads117x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ads117x_dapm_widgets), + .dapm_routes = ads117x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ads117x_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ads117x_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ads117x, &ads117x_dai, 1); -} - -static int ads117x_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ads117x, &ads117x_dai, 1); } #if defined(CONFIG_OF) @@ -95,7 +91,6 @@ static struct platform_driver ads117x_codec_driver = { }, .probe = ads117x_probe, - .remove = ads117x_remove, }; module_platform_driver(ads117x_codec_driver); From aeb90fd2e1cbc17a336c8e76d8e75d57722de932 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:25:12 +0000 Subject: [PATCH 137/942] ASoC: ab8500: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ab8500-codec.c | 295 ++++++++++++++++---------------- 1 file changed, 144 insertions(+), 151 deletions(-) diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 006627b8c3a8..03bbbcd3b6c1 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c @@ -1037,86 +1037,86 @@ static const struct snd_soc_dapm_route ab8500_dapm_routes_mic2_vamicx[] = { }; /* ANC FIR-coefficients configuration sequence */ -static void anc_fir(struct snd_soc_codec *codec, +static void anc_fir(struct snd_soc_component *component, unsigned int bnk, unsigned int par, unsigned int val) { if (par == 0 && bnk == 0) - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ANCFIRUPDATE), BIT(AB8500_ANCCONF1_ANCFIRUPDATE)); - snd_soc_write(codec, AB8500_ANCCONF5, val >> 8 & 0xff); - snd_soc_write(codec, AB8500_ANCCONF6, val & 0xff); + snd_soc_component_write(component, AB8500_ANCCONF5, val >> 8 & 0xff); + snd_soc_component_write(component, AB8500_ANCCONF6, val & 0xff); if (par == AB8500_ANC_FIR_COEFFS - 1 && bnk == 1) - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ANCFIRUPDATE), 0); } /* ANC IIR-coefficients configuration sequence */ -static void anc_iir(struct snd_soc_codec *codec, unsigned int bnk, +static void anc_iir(struct snd_soc_component *component, unsigned int bnk, unsigned int par, unsigned int val) { if (par == 0) { if (bnk == 0) { - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ANCIIRINIT), BIT(AB8500_ANCCONF1_ANCIIRINIT)); usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY); - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ANCIIRINIT), 0); usleep_range(AB8500_ANC_SM_DELAY, AB8500_ANC_SM_DELAY); } else { - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ANCIIRUPDATE), BIT(AB8500_ANCCONF1_ANCIIRUPDATE)); } } else if (par > 3) { - snd_soc_write(codec, AB8500_ANCCONF7, 0); - snd_soc_write(codec, AB8500_ANCCONF8, val >> 16 & 0xff); + snd_soc_component_write(component, AB8500_ANCCONF7, 0); + snd_soc_component_write(component, AB8500_ANCCONF8, val >> 16 & 0xff); } - snd_soc_write(codec, AB8500_ANCCONF7, val >> 8 & 0xff); - snd_soc_write(codec, AB8500_ANCCONF8, val & 0xff); + snd_soc_component_write(component, AB8500_ANCCONF7, val >> 8 & 0xff); + snd_soc_component_write(component, AB8500_ANCCONF8, val & 0xff); if (par == AB8500_ANC_IIR_COEFFS - 1 && bnk == 1) - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ANCIIRUPDATE), 0); } /* ANC IIR-/FIR-coefficients configuration sequence */ -static void anc_configure(struct snd_soc_codec *codec, +static void anc_configure(struct snd_soc_component *component, bool apply_fir, bool apply_iir) { - struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); + struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); unsigned int bnk, par, val; - dev_dbg(codec->dev, "%s: Enter.\n", __func__); + dev_dbg(component->dev, "%s: Enter.\n", __func__); if (apply_fir) - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ENANC), 0); - snd_soc_update_bits(codec, AB8500_ANCCONF1, + snd_soc_component_update_bits(component, AB8500_ANCCONF1, BIT(AB8500_ANCCONF1_ENANC), BIT(AB8500_ANCCONF1_ENANC)); if (apply_fir) for (bnk = 0; bnk < AB8500_NR_OF_ANC_COEFF_BANKS; bnk++) for (par = 0; par < AB8500_ANC_FIR_COEFFS; par++) { - val = snd_soc_read(codec, + val = snd_soc_component_read32(component, drvdata->anc_fir_values[par]); - anc_fir(codec, bnk, par, val); + anc_fir(component, bnk, par, val); } if (apply_iir) for (bnk = 0; bnk < AB8500_NR_OF_ANC_COEFF_BANKS; bnk++) for (par = 0; par < AB8500_ANC_IIR_COEFFS; par++) { - val = snd_soc_read(codec, + val = snd_soc_component_read32(component, drvdata->anc_iir_values[par]); - anc_iir(codec, bnk, par, val); + anc_iir(component, bnk, par, val); } - dev_dbg(codec->dev, "%s: Exit.\n", __func__); + dev_dbg(component->dev, "%s: Exit.\n", __func__); } /* @@ -1126,8 +1126,8 @@ static void anc_configure(struct snd_soc_codec *codec, static int sid_status_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); mutex_lock(&drvdata->ctrl_lock); ucontrol->value.enumerated.item[0] = drvdata->sid_status; @@ -1140,15 +1140,15 @@ static int sid_status_control_get(struct snd_kcontrol *kcontrol, static int sid_status_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); unsigned int param, sidconf, val; int status = 1; - dev_dbg(codec->dev, "%s: Enter\n", __func__); + dev_dbg(component->dev, "%s: Enter\n", __func__); if (ucontrol->value.enumerated.item[0] != SID_APPLY_FIR) { - dev_err(codec->dev, + dev_err(component->dev, "%s: ERROR: This control supports '%s' only!\n", __func__, enum_sid_state[SID_APPLY_FIR]); return -EIO; @@ -1156,10 +1156,10 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, mutex_lock(&drvdata->ctrl_lock); - sidconf = snd_soc_read(codec, AB8500_SIDFIRCONF); + sidconf = snd_soc_component_read32(component, AB8500_SIDFIRCONF); if (((sidconf & BIT(AB8500_SIDFIRCONF_FIRSIDBUSY)) != 0)) { if ((sidconf & BIT(AB8500_SIDFIRCONF_ENFIRSIDS)) == 0) { - dev_err(codec->dev, "%s: Sidetone busy while off!\n", + dev_err(component->dev, "%s: Sidetone busy while off!\n", __func__); status = -EPERM; } else { @@ -1168,18 +1168,18 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, goto out; } - snd_soc_write(codec, AB8500_SIDFIRADR, 0); + snd_soc_component_write(component, AB8500_SIDFIRADR, 0); for (param = 0; param < AB8500_SID_FIR_COEFFS; param++) { - val = snd_soc_read(codec, drvdata->sid_fir_values[param]); - snd_soc_write(codec, AB8500_SIDFIRCOEF1, val >> 8 & 0xff); - snd_soc_write(codec, AB8500_SIDFIRCOEF2, val & 0xff); + val = snd_soc_component_read32(component, drvdata->sid_fir_values[param]); + snd_soc_component_write(component, AB8500_SIDFIRCOEF1, val >> 8 & 0xff); + snd_soc_component_write(component, AB8500_SIDFIRCOEF2, val & 0xff); } - snd_soc_update_bits(codec, AB8500_SIDFIRADR, + snd_soc_component_update_bits(component, AB8500_SIDFIRADR, BIT(AB8500_SIDFIRADR_FIRSIDSET), BIT(AB8500_SIDFIRADR_FIRSIDSET)); - snd_soc_update_bits(codec, AB8500_SIDFIRADR, + snd_soc_component_update_bits(component, AB8500_SIDFIRADR, BIT(AB8500_SIDFIRADR_FIRSIDSET), 0); drvdata->sid_status = SID_FIR_CONFIGURED; @@ -1187,7 +1187,7 @@ static int sid_status_control_put(struct snd_kcontrol *kcontrol, out: mutex_unlock(&drvdata->ctrl_lock); - dev_dbg(codec->dev, "%s: Exit\n", __func__); + dev_dbg(component->dev, "%s: Exit\n", __func__); return status; } @@ -1195,8 +1195,8 @@ out: static int anc_status_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); mutex_lock(&drvdata->ctrl_lock); ucontrol->value.enumerated.item[0] = drvdata->anc_status; @@ -1208,10 +1208,10 @@ static int anc_status_control_get(struct snd_kcontrol *kcontrol, static int anc_status_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(codec->dev); - struct device *dev = codec->dev; + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(component->dev); + struct device *dev = component->dev; bool apply_fir, apply_iir; unsigned int req; int status; @@ -1244,7 +1244,7 @@ static int anc_status_control_put(struct snd_kcontrol *kcontrol, } snd_soc_dapm_sync(dapm); - anc_configure(codec, apply_fir, apply_iir); + anc_configure(component, apply_fir, apply_iir); if (apply_fir) { if (drvdata->anc_status == ANC_IIR_CONFIGURED) @@ -1291,8 +1291,8 @@ static int filter_control_info(struct snd_kcontrol *kcontrol, static int filter_control_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ab8500_codec_drvdata *drvdata = snd_soc_component_get_drvdata(component); struct filter_control *fc = (struct filter_control *)kcontrol->private_value; unsigned int i; @@ -1308,8 +1308,8 @@ static int filter_control_get(struct snd_kcontrol *kcontrol, static int filter_control_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ab8500_codec_drvdata *drvdata = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ab8500_codec_drvdata *drvdata = snd_soc_component_get_drvdata(component); struct filter_control *fc = (struct filter_control *)kcontrol->private_value; unsigned int i; @@ -1926,11 +1926,11 @@ enum ab8500_filter { * Extended interface for codec-driver */ -static int ab8500_audio_init_audioblock(struct snd_soc_codec *codec) +static int ab8500_audio_init_audioblock(struct snd_soc_component *component) { int status; - dev_dbg(codec->dev, "%s: Enter.\n", __func__); + dev_dbg(component->dev, "%s: Enter.\n", __func__); /* Reset audio-registers and disable 32kHz-clock output 2 */ status = ab8500_sysctrl_write(AB8500_STW4500CTRL3, @@ -1943,26 +1943,26 @@ static int ab8500_audio_init_audioblock(struct snd_soc_codec *codec) return 0; } -static int ab8500_audio_setup_mics(struct snd_soc_codec *codec, +static int ab8500_audio_setup_mics(struct snd_soc_component *component, struct amic_settings *amics) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); u8 value8; unsigned int value; int status; const struct snd_soc_dapm_route *route; - dev_dbg(codec->dev, "%s: Enter.\n", __func__); + dev_dbg(component->dev, "%s: Enter.\n", __func__); /* Set DMic-clocks to outputs */ - status = abx500_get_register_interruptible(codec->dev, AB8500_MISC, + status = abx500_get_register_interruptible(component->dev, AB8500_MISC, AB8500_GPIO_DIR4_REG, &value8); if (status < 0) return status; value = value8 | GPIO27_DIR_OUTPUT | GPIO29_DIR_OUTPUT | GPIO31_DIR_OUTPUT; - status = abx500_set_register_interruptible(codec->dev, + status = abx500_set_register_interruptible(component->dev, AB8500_MISC, AB8500_GPIO_DIR4_REG, value); @@ -1970,41 +1970,41 @@ static int ab8500_audio_setup_mics(struct snd_soc_codec *codec, return status; /* Attach regulators to AMic DAPM-paths */ - dev_dbg(codec->dev, "%s: Mic 1a regulator: %s\n", __func__, + dev_dbg(component->dev, "%s: Mic 1a regulator: %s\n", __func__, amic_micbias_str(amics->mic1a_micbias)); route = &ab8500_dapm_routes_mic1a_vamicx[amics->mic1a_micbias]; status = snd_soc_dapm_add_routes(dapm, route, 1); - dev_dbg(codec->dev, "%s: Mic 1b regulator: %s\n", __func__, + dev_dbg(component->dev, "%s: Mic 1b regulator: %s\n", __func__, amic_micbias_str(amics->mic1b_micbias)); route = &ab8500_dapm_routes_mic1b_vamicx[amics->mic1b_micbias]; status |= snd_soc_dapm_add_routes(dapm, route, 1); - dev_dbg(codec->dev, "%s: Mic 2 regulator: %s\n", __func__, + dev_dbg(component->dev, "%s: Mic 2 regulator: %s\n", __func__, amic_micbias_str(amics->mic2_micbias)); route = &ab8500_dapm_routes_mic2_vamicx[amics->mic2_micbias]; status |= snd_soc_dapm_add_routes(dapm, route, 1); if (status < 0) { - dev_err(codec->dev, + dev_err(component->dev, "%s: Failed to add AMic-regulator DAPM-routes (%d).\n", __func__, status); return status; } /* Set AMic-configuration */ - dev_dbg(codec->dev, "%s: Mic 1 mic-type: %s\n", __func__, + dev_dbg(component->dev, "%s: Mic 1 mic-type: %s\n", __func__, amic_type_str(amics->mic1_type)); - snd_soc_update_bits(codec, AB8500_ANAGAIN1, AB8500_ANAGAINX_ENSEMICX, + snd_soc_component_update_bits(component, AB8500_ANAGAIN1, AB8500_ANAGAINX_ENSEMICX, amics->mic1_type == AMIC_TYPE_DIFFERENTIAL ? 0 : AB8500_ANAGAINX_ENSEMICX); - dev_dbg(codec->dev, "%s: Mic 2 mic-type: %s\n", __func__, + dev_dbg(component->dev, "%s: Mic 2 mic-type: %s\n", __func__, amic_type_str(amics->mic2_type)); - snd_soc_update_bits(codec, AB8500_ANAGAIN2, AB8500_ANAGAINX_ENSEMICX, + snd_soc_component_update_bits(component, AB8500_ANAGAIN2, AB8500_ANAGAINX_ENSEMICX, amics->mic2_type == AMIC_TYPE_DIFFERENTIAL ? 0 : AB8500_ANAGAINX_ENSEMICX); return 0; } -static int ab8500_audio_set_ear_cmv(struct snd_soc_codec *codec, +static int ab8500_audio_set_ear_cmv(struct snd_soc_component *component, enum ear_cm_voltage ear_cmv) { char *cmv_str; @@ -2023,14 +2023,14 @@ static int ab8500_audio_set_ear_cmv(struct snd_soc_codec *codec, cmv_str = "1.58V"; break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s: Unknown earpiece CM-voltage (%d)!\n", __func__, (int)ear_cmv); return -EINVAL; } - dev_dbg(codec->dev, "%s: Earpiece CM-voltage: %s\n", __func__, + dev_dbg(component->dev, "%s: Earpiece CM-voltage: %s\n", __func__, cmv_str); - snd_soc_update_bits(codec, AB8500_ANACONF1, AB8500_ANACONF1_EARSELCM, + snd_soc_component_update_bits(component, AB8500_ANACONF1, AB8500_ANACONF1_EARSELCM, ear_cmv); return 0; @@ -2040,7 +2040,7 @@ static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai, unsigned int delay) { unsigned int mask, val; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; mask = BIT(AB8500_DIGIFCONF2_IF0DEL); val = 0; @@ -2052,21 +2052,21 @@ static int ab8500_audio_set_bit_delay(struct snd_soc_dai *dai, val |= BIT(AB8500_DIGIFCONF2_IF0DEL); break; default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupported bit-delay (0x%x)!\n", __func__, delay); return -EINVAL; } - dev_dbg(dai->codec->dev, "%s: IF0 Bit-delay: %d bits.\n", + dev_dbg(dai->component->dev, "%s: IF0 Bit-delay: %d bits.\n", __func__, delay); - snd_soc_update_bits(codec, AB8500_DIGIFCONF2, mask, val); + snd_soc_component_update_bits(component, AB8500_DIGIFCONF2, mask, val); return 0; } /* Gates clocking according format mask */ -static int ab8500_codec_set_dai_clock_gate(struct snd_soc_codec *codec, +static int ab8500_codec_set_dai_clock_gate(struct snd_soc_component *component, unsigned int fmt) { unsigned int mask; @@ -2079,22 +2079,22 @@ static int ab8500_codec_set_dai_clock_gate(struct snd_soc_codec *codec, switch (fmt & SND_SOC_DAIFMT_CLOCK_MASK) { case SND_SOC_DAIFMT_CONT: /* continuous clock */ - dev_dbg(codec->dev, "%s: IF0 Clock is continuous.\n", + dev_dbg(component->dev, "%s: IF0 Clock is continuous.\n", __func__); val |= BIT(AB8500_DIGIFCONF1_ENFSBITCLK0); break; case SND_SOC_DAIFMT_GATED: /* clock is gated */ - dev_dbg(codec->dev, "%s: IF0 Clock is gated.\n", + dev_dbg(component->dev, "%s: IF0 Clock is gated.\n", __func__); break; default: - dev_err(codec->dev, + dev_err(component->dev, "%s: ERROR: Unsupported clock mask (0x%x)!\n", __func__, fmt & SND_SOC_DAIFMT_CLOCK_MASK); return -EINVAL; } - snd_soc_update_bits(codec, AB8500_DIGIFCONF1, mask, val); + snd_soc_component_update_bits(component, AB8500_DIGIFCONF1, mask, val); return 0; } @@ -2103,10 +2103,10 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { unsigned int mask; unsigned int val; - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int status; - dev_dbg(codec->dev, "%s: Enter (fmt = 0x%x)\n", __func__, fmt); + dev_dbg(component->dev, "%s: Enter (fmt = 0x%x)\n", __func__, fmt); mask = BIT(AB8500_DIGIFCONF3_IF1DATOIF0AD) | BIT(AB8500_DIGIFCONF3_IF1CLKTOIF0CLK) | @@ -2116,32 +2116,32 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: /* codec clk & FRM master */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0 Master-mode: AB8500 master.\n", __func__); val |= BIT(AB8500_DIGIFCONF3_IF0MASTER); break; case SND_SOC_DAIFMT_CBS_CFS: /* codec clk & FRM slave */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0 Master-mode: AB8500 slave.\n", __func__); break; case SND_SOC_DAIFMT_CBS_CFM: /* codec clk slave & FRM master */ case SND_SOC_DAIFMT_CBM_CFS: /* codec clk master & frame slave */ - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: The device is either a master or a slave.\n", __func__); default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupporter master mask 0x%x\n", __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; } - snd_soc_update_bits(codec, AB8500_DIGIFCONF3, mask, val); + snd_soc_component_update_bits(component, AB8500_DIGIFCONF3, mask, val); /* Set clock gating */ - status = ab8500_codec_set_dai_clock_gate(codec, fmt); + status = ab8500_codec_set_dai_clock_gate(component, fmt); if (status) { - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Failed to set clock gate (%d).\n", __func__, status); return status; @@ -2157,27 +2157,27 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: /* I2S mode */ - dev_dbg(dai->codec->dev, "%s: IF0 Protocol: I2S\n", __func__); + dev_dbg(dai->component->dev, "%s: IF0 Protocol: I2S\n", __func__); val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT1); ab8500_audio_set_bit_delay(dai, 0); break; case SND_SOC_DAIFMT_DSP_A: /* L data MSB after FRM LRC */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0 Protocol: DSP A (TDM)\n", __func__); val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT0); ab8500_audio_set_bit_delay(dai, 1); break; case SND_SOC_DAIFMT_DSP_B: /* L data MSB during FRM LRC */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0 Protocol: DSP B (TDM)\n", __func__); val |= BIT(AB8500_DIGIFCONF2_IF0FORMAT0); ab8500_audio_set_bit_delay(dai, 0); break; default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupported format (0x%x)!\n", __func__, fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; @@ -2185,37 +2185,37 @@ static int ab8500_codec_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF: /* normal bit clock + frame */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0: Normal bit clock, normal frame\n", __func__); break; case SND_SOC_DAIFMT_NB_IF: /* normal BCLK + inv FRM */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0: Normal bit clock, inverted frame\n", __func__); val |= BIT(AB8500_DIGIFCONF2_FSYNC0P); break; case SND_SOC_DAIFMT_IB_NF: /* invert BCLK + nor FRM */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0: Inverted bit clock, normal frame\n", __func__); val |= BIT(AB8500_DIGIFCONF2_BITCLK0P); break; case SND_SOC_DAIFMT_IB_IF: /* invert BCLK + FRM */ - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: IF0: Inverted bit clock, inverted frame\n", __func__); val |= BIT(AB8500_DIGIFCONF2_FSYNC0P); val |= BIT(AB8500_DIGIFCONF2_BITCLK0P); break; default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupported INV mask 0x%x\n", __func__, fmt & SND_SOC_DAIFMT_INV_MASK); return -EINVAL; } - snd_soc_update_bits(codec, AB8500_DIGIFCONF2, mask, val); + snd_soc_component_update_bits(component, AB8500_DIGIFCONF2, mask, val); return 0; } @@ -2224,7 +2224,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val, mask, slot, slots_active; mask = BIT(AB8500_DIGIFCONF2_IF0WL0) | @@ -2245,17 +2245,17 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, BIT(AB8500_DIGIFCONF2_IF0WL0); break; default: - dev_err(dai->codec->dev, "%s: Unsupported slot-width 0x%x\n", + dev_err(dai->component->dev, "%s: Unsupported slot-width 0x%x\n", __func__, slot_width); return -EINVAL; } - dev_dbg(dai->codec->dev, "%s: IF0 slot-width: %d bits.\n", + dev_dbg(dai->component->dev, "%s: IF0 slot-width: %d bits.\n", __func__, slot_width); - snd_soc_update_bits(codec, AB8500_DIGIFCONF2, mask, val); + snd_soc_component_update_bits(component, AB8500_DIGIFCONF2, mask, val); /* Setup TDM clocking according to slot count */ - dev_dbg(dai->codec->dev, "%s: Slots, total: %d\n", __func__, slots); + dev_dbg(dai->component->dev, "%s: Slots, total: %d\n", __func__, slots); mask = BIT(AB8500_DIGIFCONF1_IF0BITCLKOS0) | BIT(AB8500_DIGIFCONF1_IF0BITCLKOS1); switch (slots) { @@ -2273,12 +2273,12 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, BIT(AB8500_DIGIFCONF1_IF0BITCLKOS1); break; default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupported number of slots (%d)!\n", __func__, slots); return -EINVAL; } - snd_soc_update_bits(codec, AB8500_DIGIFCONF1, mask, val); + snd_soc_component_update_bits(component, AB8500_DIGIFCONF1, mask, val); /* Setup TDM DA according to active tx slots */ @@ -2289,7 +2289,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, tx_mask = tx_mask << AB8500_DA_DATA0_OFFSET; slots_active = hweight32(tx_mask); - dev_dbg(dai->codec->dev, "%s: Slots, active, TX: %d\n", __func__, + dev_dbg(dai->component->dev, "%s: Slots, active, TX: %d\n", __func__, slots_active); switch (slots_active) { @@ -2297,26 +2297,26 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, break; case 1: slot = ffs(tx_mask); - snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); - snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); - snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); - snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF1, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF3, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF2, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF4, mask, slot); break; case 2: slot = ffs(tx_mask); - snd_soc_update_bits(codec, AB8500_DASLOTCONF1, mask, slot); - snd_soc_update_bits(codec, AB8500_DASLOTCONF3, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF1, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF3, mask, slot); slot = fls(tx_mask); - snd_soc_update_bits(codec, AB8500_DASLOTCONF2, mask, slot); - snd_soc_update_bits(codec, AB8500_DASLOTCONF4, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF2, mask, slot); + snd_soc_component_update_bits(component, AB8500_DASLOTCONF4, mask, slot); break; case 8: - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: In 8-channel mode DA-from-slot mapping is set manually.", __func__); break; default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: Unsupported number of active TX-slots (%d)!\n", __func__, slots_active); return -EINVAL; @@ -2330,7 +2330,7 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, rx_mask = rx_mask << AB8500_AD_DATA0_OFFSET; slots_active = hweight32(rx_mask); - dev_dbg(dai->codec->dev, "%s: Slots, active, RX: %d\n", __func__, + dev_dbg(dai->component->dev, "%s: Slots, active, RX: %d\n", __func__, slots_active); switch (slots_active) { @@ -2338,29 +2338,29 @@ static int ab8500_codec_set_dai_tdm_slot(struct snd_soc_dai *dai, break; case 1: slot = ffs(rx_mask); - snd_soc_update_bits(codec, AB8500_ADSLOTSEL(slot), + snd_soc_component_update_bits(component, AB8500_ADSLOTSEL(slot), AB8500_MASK_SLOT(slot), AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); break; case 2: slot = ffs(rx_mask); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AB8500_ADSLOTSEL(slot), AB8500_MASK_SLOT(slot), AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT3, slot)); slot = fls(rx_mask); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, AB8500_ADSLOTSEL(slot), AB8500_MASK_SLOT(slot), AB8500_ADSLOTSELX_AD_OUT_TO_SLOT(AB8500_AD_OUT2, slot)); break; case 8: - dev_dbg(dai->codec->dev, + dev_dbg(dai->component->dev, "%s: In 8-channel mode AD-to-slot mapping is set manually.", __func__); break; default: - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: Unsupported number of active RX-slots (%d)!\n", __func__, slots_active); return -EINVAL; @@ -2458,10 +2458,10 @@ static void ab8500_codec_of_probe(struct device *dev, struct device_node *np, } } -static int ab8500_codec_probe(struct snd_soc_codec *codec) +static int ab8500_codec_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct device *dev = codec->dev; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct device *dev = component->dev; struct device_node *np = dev->of_node; struct ab8500_codec_drvdata *drvdata = dev_get_drvdata(dev); struct ab8500_codec_platform_data codec_pdata; @@ -2472,19 +2472,19 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) ab8500_codec_of_probe(dev, np, &codec_pdata); - status = ab8500_audio_setup_mics(codec, &codec_pdata.amics); + status = ab8500_audio_setup_mics(component, &codec_pdata.amics); if (status < 0) { pr_err("%s: Failed to setup mics (%d)!\n", __func__, status); return status; } - status = ab8500_audio_set_ear_cmv(codec, codec_pdata.ear_cmv); + status = ab8500_audio_set_ear_cmv(component, codec_pdata.ear_cmv); if (status < 0) { pr_err("%s: Failed to set earpiece CM-voltage (%d)!\n", __func__, status); return status; } - status = ab8500_audio_init_audioblock(codec); + status = ab8500_audio_init_audioblock(component); if (status < 0) { dev_err(dev, "%s: failed to init audio-block (%d)!\n", __func__, status); @@ -2492,13 +2492,13 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) } /* Override HW-defaults */ - snd_soc_write(codec, AB8500_ANACONF5, + snd_soc_component_write(component, AB8500_ANACONF5, BIT(AB8500_ANACONF5_HSAUTOEN)); - snd_soc_write(codec, AB8500_SHORTCIRCONF, + snd_soc_component_write(component, AB8500_SHORTCIRCONF, BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); /* Add filter controls */ - status = snd_soc_add_codec_controls(codec, ab8500_filter_controls, + status = snd_soc_add_component_controls(component, ab8500_filter_controls, ARRAY_SIZE(ab8500_filter_controls)); if (status < 0) { dev_err(dev, @@ -2523,16 +2523,18 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) return status; } -static const struct snd_soc_codec_driver ab8500_codec_driver = { - .probe = ab8500_codec_probe, - .component_driver = { - .controls = ab8500_ctrls, - .num_controls = ARRAY_SIZE(ab8500_ctrls), - .dapm_widgets = ab8500_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ab8500_dapm_widgets), - .dapm_routes = ab8500_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ab8500_dapm_routes), - }, +static const struct snd_soc_component_driver ab8500_component_driver = { + .probe = ab8500_codec_probe, + .controls = ab8500_ctrls, + .num_controls = ARRAY_SIZE(ab8500_ctrls), + .dapm_widgets = ab8500_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ab8500_dapm_widgets), + .dapm_routes = ab8500_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ab8500_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ab8500_codec_driver_probe(struct platform_device *pdev) @@ -2561,7 +2563,8 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) } dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); - status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, + status = devm_snd_soc_register_component(&pdev->dev, + &ab8500_component_driver, ab8500_codec_dai, ARRAY_SIZE(ab8500_codec_dai)); if (status < 0) @@ -2572,21 +2575,11 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) return status; } -static int ab8500_codec_driver_remove(struct platform_device *pdev) -{ - dev_dbg(&pdev->dev, "%s Enter.\n", __func__); - - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver ab8500_codec_platform_driver = { .driver = { .name = "ab8500-codec", }, .probe = ab8500_codec_driver_probe, - .remove = ab8500_codec_driver_remove, }; module_platform_driver(ab8500_codec_platform_driver); From 89cea5c9a9f3dc487f39997801ff5191f2375369 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:25:29 +0000 Subject: [PATCH 138/942] ASoC: ad193x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ad193x-i2c.c | 7 ------ sound/soc/codecs/ad193x-spi.c | 7 ------ sound/soc/codecs/ad193x.c | 46 ++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 36 deletions(-) diff --git a/sound/soc/codecs/ad193x-i2c.c b/sound/soc/codecs/ad193x-i2c.c index 171313664bc8..b9551334f6b4 100644 --- a/sound/soc/codecs/ad193x-i2c.c +++ b/sound/soc/codecs/ad193x-i2c.c @@ -35,18 +35,11 @@ static int ad193x_i2c_probe(struct i2c_client *client, (enum ad193x_type)id->driver_data); } -static int ad193x_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static struct i2c_driver ad193x_i2c_driver = { .driver = { .name = "ad193x", }, .probe = ad193x_i2c_probe, - .remove = ad193x_i2c_remove, .id_table = ad193x_id, }; module_i2c_driver(ad193x_i2c_driver); diff --git a/sound/soc/codecs/ad193x-spi.c b/sound/soc/codecs/ad193x-spi.c index 23c28573bdb7..3c1394a803b8 100644 --- a/sound/soc/codecs/ad193x-spi.c +++ b/sound/soc/codecs/ad193x-spi.c @@ -29,12 +29,6 @@ static int ad193x_spi_probe(struct spi_device *spi) (enum ad193x_type)id->driver_data); } -static int ad193x_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct spi_device_id ad193x_spi_id[] = { { "ad193x", AD193X }, { "ad1933", AD1933 }, @@ -51,7 +45,6 @@ static struct spi_driver ad193x_spi_driver = { .name = "ad193x", }, .probe = ad193x_spi_probe, - .remove = ad193x_spi_remove, .id_table = ad193x_spi_id, }; module_spi_driver(ad193x_spi_driver); diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c index d10988eec0c1..4b60ebee491d 100644 --- a/sound/soc/codecs/ad193x.c +++ b/sound/soc/codecs/ad193x.c @@ -130,7 +130,7 @@ static inline bool ad193x_has_adc(const struct ad193x_priv *ad193x) static int ad193x_mute(struct snd_soc_dai *dai, int mute) { - struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); + struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(dai->component); if (mute) regmap_update_bits(ad193x->regmap, AD193X_DAC_CTRL2, @@ -146,7 +146,7 @@ static int ad193x_mute(struct snd_soc_dai *dai, int mute) static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int width) { - struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(dai->codec); + struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(dai->component); unsigned int channels; switch (slots) { @@ -179,7 +179,7 @@ static int ad193x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec_dai->codec); + struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(codec_dai->component); unsigned int adc_serfmt = 0; unsigned int adc_fmt = 0; unsigned int dac_fmt = 0; @@ -257,8 +257,8 @@ static int ad193x_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ad193x_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component); switch (freq) { case 12288000: case 18432000: @@ -275,8 +275,8 @@ static int ad193x_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { int word_len = 0, master_rate = 0; - struct snd_soc_codec *codec = dai->codec; - struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component); /* bit size */ switch (params_width(params)) { @@ -351,10 +351,10 @@ static struct snd_soc_dai_driver ad193x_dai = { .ops = &ad193x_dai_ops, }; -static int ad193x_codec_probe(struct snd_soc_codec *codec) +static int ad193x_component_probe(struct snd_soc_component *component) { - struct ad193x_priv *ad193x = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct ad193x_priv *ad193x = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int num, ret; /* default setting for ad193x */ @@ -382,7 +382,7 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) if (ad193x_has_adc(ad193x)) { /* add adc controls */ num = ARRAY_SIZE(ad193x_adc_snd_controls); - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, ad193x_adc_snd_controls, num); if (ret) @@ -408,16 +408,18 @@ static int ad193x_codec_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_ad193x = { - .probe = ad193x_codec_probe, - .component_driver = { - .controls = ad193x_snd_controls, - .num_controls = ARRAY_SIZE(ad193x_snd_controls), - .dapm_widgets = ad193x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets), - .dapm_routes = audio_paths, - .num_dapm_routes = ARRAY_SIZE(audio_paths), - }, +static const struct snd_soc_component_driver soc_component_dev_ad193x = { + .probe = ad193x_component_probe, + .controls = ad193x_snd_controls, + .num_controls = ARRAY_SIZE(ad193x_snd_controls), + .dapm_widgets = ad193x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad193x_dapm_widgets), + .dapm_routes = audio_paths, + .num_dapm_routes = ARRAY_SIZE(audio_paths), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; const struct regmap_config ad193x_regmap_config = { @@ -442,7 +444,7 @@ int ad193x_probe(struct device *dev, struct regmap *regmap, dev_set_drvdata(dev, ad193x); - return snd_soc_register_codec(dev, &soc_codec_dev_ad193x, + return devm_snd_soc_register_component(dev, &soc_component_dev_ad193x, &ad193x_dai, 1); } EXPORT_SYMBOL_GPL(ad193x_probe); From 683adc821182c148ce973c2cc0a9a508e26545ec Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:25:54 +0000 Subject: [PATCH 139/942] ASoC: ad1836: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ad1836.c | 68 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index d0361caad09e..ada663bf5648 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c @@ -164,7 +164,7 @@ static int ad1836_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(dai->codec); + struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(dai->component); int word_len = 0; /* bit size */ @@ -228,17 +228,17 @@ static struct snd_soc_dai_driver ad183x_dais[] = { }; #ifdef CONFIG_PM -static int ad1836_suspend(struct snd_soc_codec *codec) +static int ad1836_suspend(struct snd_soc_component *component) { - struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); + struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component); /* reset clock control mode */ return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, AD1836_ADC_SERFMT_MASK, 0); } -static int ad1836_resume(struct snd_soc_codec *codec) +static int ad1836_resume(struct snd_soc_component *component) { - struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); + struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component); /* restore clock control mode */ return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, AD1836_ADC_SERFMT_MASK, AD1836_ADC_AUX); @@ -248,10 +248,10 @@ static int ad1836_resume(struct snd_soc_codec *codec) #define ad1836_resume NULL #endif -static int ad1836_probe(struct snd_soc_codec *codec) +static int ad1836_probe(struct snd_soc_component *component) { - struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int num_dacs, num_adcs; int ret = 0; int i; @@ -277,7 +277,7 @@ static int ad1836_probe(struct snd_soc_codec *codec) if (ad1836->type == AD1836) { /* left/right diff:PGA/MUX */ regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x3A); - ret = snd_soc_add_codec_controls(codec, ad1836_controls, + ret = snd_soc_add_component_controls(component, ad1836_controls, ARRAY_SIZE(ad1836_controls)); if (ret) return ret; @@ -285,11 +285,11 @@ static int ad1836_probe(struct snd_soc_codec *codec) regmap_write(ad1836->regmap, AD1836_ADC_CTRL3, 0x00); } - ret = snd_soc_add_codec_controls(codec, ad183x_dac_controls, num_dacs * 2); + ret = snd_soc_add_component_controls(component, ad183x_dac_controls, num_dacs * 2); if (ret) return ret; - ret = snd_soc_add_codec_controls(codec, ad183x_adc_controls, num_adcs); + ret = snd_soc_add_component_controls(component, ad183x_adc_controls, num_adcs); if (ret) return ret; @@ -313,28 +313,29 @@ static int ad1836_probe(struct snd_soc_codec *codec) } /* power down chip */ -static int ad1836_remove(struct snd_soc_codec *codec) +static void ad1836_remove(struct snd_soc_component *component) { - struct ad1836_priv *ad1836 = snd_soc_codec_get_drvdata(codec); + struct ad1836_priv *ad1836 = snd_soc_component_get_drvdata(component); /* reset clock control mode */ - return regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, + regmap_update_bits(ad1836->regmap, AD1836_ADC_CTRL2, AD1836_ADC_SERFMT_MASK, 0); } -static const struct snd_soc_codec_driver soc_codec_dev_ad1836 = { - .probe = ad1836_probe, - .remove = ad1836_remove, - .suspend = ad1836_suspend, - .resume = ad1836_resume, - - .component_driver = { - .controls = ad183x_controls, - .num_controls = ARRAY_SIZE(ad183x_controls), - .dapm_widgets = ad183x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ad183x_dapm_widgets), - .dapm_routes = ad183x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ad1836 = { + .probe = ad1836_probe, + .remove = ad1836_remove, + .suspend = ad1836_suspend, + .resume = ad1836_resume, + .controls = ad183x_controls, + .num_controls = ARRAY_SIZE(ad183x_controls), + .dapm_widgets = ad183x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad183x_dapm_widgets), + .dapm_routes = ad183x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ad183x_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct reg_default ad1836_reg_defaults[] = { @@ -382,17 +383,11 @@ static int ad1836_spi_probe(struct spi_device *spi) spi_set_drvdata(spi, ad1836); - ret = snd_soc_register_codec(&spi->dev, - &soc_codec_dev_ad1836, &ad183x_dais[ad1836->type], 1); + ret = devm_snd_soc_register_component(&spi->dev, + &soc_component_dev_ad1836, &ad183x_dais[ad1836->type], 1); return ret; } -static int ad1836_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct spi_device_id ad1836_ids[] = { { "ad1835", AD1835 }, { "ad1836", AD1836 }, @@ -408,7 +403,6 @@ static struct spi_driver ad1836_spi_driver = { .name = "ad1836", }, .probe = ad1836_spi_probe, - .remove = ad1836_spi_remove, .id_table = ad1836_ids, }; From 463c5f87a3af88ba81ed581860d445137a7ff01c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:26:41 +0000 Subject: [PATCH 140/942] ASoC: ad73311: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ad73311.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c index d8d86a0fea60..03ee571e1b7a 100644 --- a/sound/soc/codecs/ad73311.c +++ b/sound/soc/codecs/ad73311.c @@ -54,25 +54,21 @@ static struct snd_soc_dai_driver ad73311_dai = { .formats = SNDRV_PCM_FMTBIT_S16_LE, }, }; -static const struct snd_soc_codec_driver soc_codec_dev_ad73311 = { - .component_driver = { - .dapm_widgets = ad73311_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), - .dapm_routes = ad73311_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ad73311 = { + .dapm_widgets = ad73311_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), + .dapm_routes = ad73311_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ad73311_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ad73311, &ad73311_dai, 1); -} - -static int ad73311_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ad73311, &ad73311_dai, 1); } static struct platform_driver ad73311_codec_driver = { @@ -81,7 +77,6 @@ static struct platform_driver ad73311_codec_driver = { }, .probe = ad73311_probe, - .remove = ad73311_remove, }; module_platform_driver(ad73311_codec_driver); From b63aecbdbcf393e13c71497edb6c8b772f11c773 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:28:10 +0000 Subject: [PATCH 141/942] ASoC: ssm4567: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ssm4567.c | 44 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/sound/soc/codecs/ssm4567.c b/sound/soc/codecs/ssm4567.c index 4afeddef7728..90119ea00498 100644 --- a/sound/soc/codecs/ssm4567.c +++ b/sound/soc/codecs/ssm4567.c @@ -199,8 +199,8 @@ static const struct snd_soc_dapm_route ssm4567_routes[] = { static int ssm4567_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ssm4567 *ssm4567 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ssm4567 *ssm4567 = snd_soc_component_get_drvdata(component); unsigned int rate = params_rate(params); unsigned int dacfs; @@ -223,7 +223,7 @@ static int ssm4567_hw_params(struct snd_pcm_substream *substream, static int ssm4567_mute(struct snd_soc_dai *dai, int mute) { - struct ssm4567 *ssm4567 = snd_soc_codec_get_drvdata(dai->codec); + struct ssm4567 *ssm4567 = snd_soc_component_get_drvdata(dai->component); unsigned int val; val = mute ? SSM4567_DAC_MUTE : 0; @@ -366,10 +366,10 @@ static int ssm4567_set_power(struct ssm4567 *ssm4567, bool enable) return ret; } -static int ssm4567_set_bias_level(struct snd_soc_codec *codec, +static int ssm4567_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ssm4567 *ssm4567 = snd_soc_codec_get_drvdata(codec); + struct ssm4567 *ssm4567 = snd_soc_component_get_drvdata(component); int ret = 0; switch (level) { @@ -378,7 +378,7 @@ static int ssm4567_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) ret = ssm4567_set_power(ssm4567, true); break; case SND_SOC_BIAS_OFF: @@ -417,18 +417,17 @@ static struct snd_soc_dai_driver ssm4567_dai = { .ops = &ssm4567_dai_ops, }; -static const struct snd_soc_codec_driver ssm4567_codec_driver = { - .set_bias_level = ssm4567_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = ssm4567_snd_controls, - .num_controls = ARRAY_SIZE(ssm4567_snd_controls), - .dapm_widgets = ssm4567_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ssm4567_dapm_widgets), - .dapm_routes = ssm4567_routes, - .num_dapm_routes = ARRAY_SIZE(ssm4567_routes), - }, +static const struct snd_soc_component_driver ssm4567_component_driver = { + .set_bias_level = ssm4567_set_bias_level, + .controls = ssm4567_snd_controls, + .num_controls = ARRAY_SIZE(ssm4567_snd_controls), + .dapm_widgets = ssm4567_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ssm4567_dapm_widgets), + .dapm_routes = ssm4567_routes, + .num_dapm_routes = ARRAY_SIZE(ssm4567_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ssm4567_regmap_config = { @@ -469,16 +468,10 @@ static int ssm4567_i2c_probe(struct i2c_client *i2c, if (ret) return ret; - return snd_soc_register_codec(&i2c->dev, &ssm4567_codec_driver, + return devm_snd_soc_register_component(&i2c->dev, &ssm4567_component_driver, &ssm4567_dai, 1); } -static int ssm4567_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id ssm4567_i2c_ids[] = { { "ssm4567", 0 }, { } @@ -510,7 +503,6 @@ static struct i2c_driver ssm4567_driver = { .acpi_match_table = ACPI_PTR(ssm4567_acpi_match), }, .probe = ssm4567_i2c_probe, - .remove = ssm4567_i2c_remove, .id_table = ssm4567_i2c_ids, }; module_i2c_driver(ssm4567_driver); From ad4771ef9d45b8db72318d2cd85024bd7b5f5e95 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:28:41 +0000 Subject: [PATCH 142/942] ASoC: ssm2602: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ssm2602-i2c.c | 7 ---- sound/soc/codecs/ssm2602-spi.c | 7 ---- sound/soc/codecs/ssm2602.c | 77 +++++++++++++++++----------------- 3 files changed, 39 insertions(+), 52 deletions(-) diff --git a/sound/soc/codecs/ssm2602-i2c.c b/sound/soc/codecs/ssm2602-i2c.c index 173ba85ff59e..f1c2b1a3ada3 100644 --- a/sound/soc/codecs/ssm2602-i2c.c +++ b/sound/soc/codecs/ssm2602-i2c.c @@ -27,12 +27,6 @@ static int ssm2602_i2c_probe(struct i2c_client *client, devm_regmap_init_i2c(client, &ssm2602_regmap_config)); } -static int ssm2602_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id ssm2602_i2c_id[] = { { "ssm2602", SSM2602 }, { "ssm2603", SSM2602 }, @@ -55,7 +49,6 @@ static struct i2c_driver ssm2602_i2c_driver = { .of_match_table = ssm2602_of_match, }, .probe = ssm2602_i2c_probe, - .remove = ssm2602_i2c_remove, .id_table = ssm2602_i2c_id, }; module_i2c_driver(ssm2602_i2c_driver); diff --git a/sound/soc/codecs/ssm2602-spi.c b/sound/soc/codecs/ssm2602-spi.c index 842f373045c6..8848628571a1 100644 --- a/sound/soc/codecs/ssm2602-spi.c +++ b/sound/soc/codecs/ssm2602-spi.c @@ -20,12 +20,6 @@ static int ssm2602_spi_probe(struct spi_device *spi) devm_regmap_init_spi(spi, &ssm2602_regmap_config)); } -static int ssm2602_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static const struct of_device_id ssm2602_of_match[] = { { .compatible = "adi,ssm2602", }, { } @@ -38,7 +32,6 @@ static struct spi_driver ssm2602_spi_driver = { .of_match_table = ssm2602_of_match, }, .probe = ssm2602_spi_probe, - .remove = ssm2602_spi_remove, }; module_spi_driver(ssm2602_spi_driver); diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 9b341c23f62b..031e0eabcc1f 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -273,8 +273,8 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); int srate = ssm2602_get_coeff(ssm2602->sysclk, params_rate(params)); unsigned int iface; @@ -308,8 +308,8 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, static int ssm2602_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); if (ssm2602->sysclk_constraints) { snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -322,7 +322,7 @@ static int ssm2602_startup(struct snd_pcm_substream *substream, static int ssm2602_mute(struct snd_soc_dai *dai, int mute) { - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(dai->codec); + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(dai->component); if (mute) regmap_update_bits(ssm2602->regmap, SSM2602_APDIGI, @@ -337,8 +337,8 @@ static int ssm2602_mute(struct snd_soc_dai *dai, int mute) static int ssm2602_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); if (dir == SND_SOC_CLOCK_IN) { if (clk_id != SSM2602_SYSCLK) @@ -389,7 +389,7 @@ static int ssm2602_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int ssm2602_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec_dai->codec); + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(codec_dai->component); unsigned int iface = 0; /* set master/slave audio interface */ @@ -445,10 +445,10 @@ static int ssm2602_set_dai_fmt(struct snd_soc_dai *codec_dai, return 0; } -static int ssm2602_set_bias_level(struct snd_soc_codec *codec, +static int ssm2602_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -511,19 +511,19 @@ static struct snd_soc_dai_driver ssm2602_dai = { .symmetric_samplebits = 1, }; -static int ssm2602_resume(struct snd_soc_codec *codec) +static int ssm2602_resume(struct snd_soc_component *component) { - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); regcache_sync(ssm2602->regmap); return 0; } -static int ssm2602_codec_probe(struct snd_soc_codec *codec) +static int ssm2602_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); int ret; regmap_update_bits(ssm2602->regmap, SSM2602_LOUT1V, @@ -531,7 +531,7 @@ static int ssm2602_codec_probe(struct snd_soc_codec *codec) regmap_update_bits(ssm2602->regmap, SSM2602_ROUT1V, ROUT1V_RLHP_BOTH, ROUT1V_RLHP_BOTH); - ret = snd_soc_add_codec_controls(codec, ssm2602_snd_controls, + ret = snd_soc_add_component_controls(component, ssm2602_snd_controls, ARRAY_SIZE(ssm2602_snd_controls)); if (ret) return ret; @@ -545,9 +545,9 @@ static int ssm2602_codec_probe(struct snd_soc_codec *codec) ARRAY_SIZE(ssm2602_routes)); } -static int ssm2604_codec_probe(struct snd_soc_codec *codec) +static int ssm2604_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; ret = snd_soc_dapm_new_controls(dapm, ssm2604_dapm_widgets, @@ -559,14 +559,14 @@ static int ssm2604_codec_probe(struct snd_soc_codec *codec) ARRAY_SIZE(ssm2604_routes)); } -static int ssm260x_codec_probe(struct snd_soc_codec *codec) +static int ssm260x_component_probe(struct snd_soc_component *component) { - struct ssm2602_priv *ssm2602 = snd_soc_codec_get_drvdata(codec); + struct ssm2602_priv *ssm2602 = snd_soc_component_get_drvdata(component); int ret; ret = regmap_write(ssm2602->regmap, SSM2602_RESET, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to issue reset: %d\n", ret); + dev_err(component->dev, "Failed to issue reset: %d\n", ret); return ret; } @@ -581,30 +581,31 @@ static int ssm260x_codec_probe(struct snd_soc_codec *codec) switch (ssm2602->type) { case SSM2602: - ret = ssm2602_codec_probe(codec); + ret = ssm2602_component_probe(component); break; case SSM2604: - ret = ssm2604_codec_probe(codec); + ret = ssm2604_component_probe(component); break; } return ret; } -static const struct snd_soc_codec_driver soc_codec_dev_ssm2602 = { - .probe = ssm260x_codec_probe, - .resume = ssm2602_resume, - .set_bias_level = ssm2602_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = ssm260x_snd_controls, - .num_controls = ARRAY_SIZE(ssm260x_snd_controls), - .dapm_widgets = ssm260x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ssm260x_dapm_widgets), - .dapm_routes = ssm260x_routes, - .num_dapm_routes = ARRAY_SIZE(ssm260x_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ssm2602 = { + .probe = ssm260x_component_probe, + .resume = ssm2602_resume, + .set_bias_level = ssm2602_set_bias_level, + .controls = ssm260x_snd_controls, + .num_controls = ARRAY_SIZE(ssm260x_snd_controls), + .dapm_widgets = ssm260x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ssm260x_dapm_widgets), + .dapm_routes = ssm260x_routes, + .num_dapm_routes = ARRAY_SIZE(ssm260x_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static bool ssm2602_register_volatile(struct device *dev, unsigned int reg) @@ -641,7 +642,7 @@ int ssm2602_probe(struct device *dev, enum ssm2602_type type, ssm2602->type = type; ssm2602->regmap = regmap; - return snd_soc_register_codec(dev, &soc_codec_dev_ssm2602, + return devm_snd_soc_register_component(dev, &soc_component_dev_ssm2602, &ssm2602_dai, 1); } EXPORT_SYMBOL_GPL(ssm2602_probe); From 17875fe49216b701fa08f0288ea19e608e3bb787 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:29:08 +0000 Subject: [PATCH 143/942] ASoC: ssm2518: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ssm2518.c | 57 +++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c index 15486fd16269..4a1d42a33030 100644 --- a/sound/soc/codecs/ssm2518.c +++ b/sound/soc/codecs/ssm2518.c @@ -336,8 +336,8 @@ static int ssm2518_lookup_mcs(struct ssm2518 *ssm2518, static int ssm2518_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(component); unsigned int rate = params_rate(params); unsigned int ctrl1, ctrl1_mask; int mcs; @@ -391,7 +391,7 @@ static int ssm2518_hw_params(struct snd_pcm_substream *substream, static int ssm2518_mute(struct snd_soc_dai *dai, int mute) { - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(dai->codec); + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(dai->component); unsigned int val; if (mute) @@ -405,7 +405,7 @@ static int ssm2518_mute(struct snd_soc_dai *dai, int mute) static int ssm2518_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(dai->codec); + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(dai->component); unsigned int ctrl1 = 0, ctrl2 = 0; bool invert_fclk; int ret; @@ -498,10 +498,10 @@ static int ssm2518_set_power(struct ssm2518 *ssm2518, bool enable) return ret; } -static int ssm2518_set_bias_level(struct snd_soc_codec *codec, +static int ssm2518_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(codec); + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(component); int ret = 0; switch (level) { @@ -510,7 +510,7 @@ static int ssm2518_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) ret = ssm2518_set_power(ssm2518, true); break; case SND_SOC_BIAS_OFF: @@ -524,7 +524,7 @@ static int ssm2518_set_bias_level(struct snd_soc_codec *codec, static int ssm2518_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int width) { - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(dai->codec); + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(dai->component); unsigned int ctrl1, ctrl2; int left_slot, right_slot; int ret; @@ -609,7 +609,7 @@ static int ssm2518_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int ssm2518_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(dai->codec); + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(dai->component); if (ssm2518->constraints) snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -641,10 +641,10 @@ static struct snd_soc_dai_driver ssm2518_dai = { .ops = &ssm2518_dai_ops, }; -static int ssm2518_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int ssm2518_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct ssm2518 *ssm2518 = snd_soc_codec_get_drvdata(codec); + struct ssm2518 *ssm2518 = snd_soc_component_get_drvdata(component); unsigned int val; if (clk_id != SSM2518_SYSCLK) @@ -710,19 +710,18 @@ static int ssm2518_set_sysclk(struct snd_soc_codec *codec, int clk_id, SSM2518_POWER1_NO_BCLK, val); } -static const struct snd_soc_codec_driver ssm2518_codec_driver = { - .set_bias_level = ssm2518_set_bias_level, - .set_sysclk = ssm2518_set_sysclk, - .idle_bias_off = true, - - .component_driver = { - .controls = ssm2518_snd_controls, - .num_controls = ARRAY_SIZE(ssm2518_snd_controls), - .dapm_widgets = ssm2518_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ssm2518_dapm_widgets), - .dapm_routes = ssm2518_routes, - .num_dapm_routes = ARRAY_SIZE(ssm2518_routes), - }, +static const struct snd_soc_component_driver ssm2518_component_driver = { + .set_bias_level = ssm2518_set_bias_level, + .set_sysclk = ssm2518_set_sysclk, + .controls = ssm2518_snd_controls, + .num_controls = ARRAY_SIZE(ssm2518_snd_controls), + .dapm_widgets = ssm2518_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ssm2518_dapm_widgets), + .dapm_routes = ssm2518_routes, + .num_dapm_routes = ARRAY_SIZE(ssm2518_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ssm2518_regmap_config = { @@ -792,16 +791,11 @@ static int ssm2518_i2c_probe(struct i2c_client *i2c, if (ret) return ret; - return snd_soc_register_codec(&i2c->dev, &ssm2518_codec_driver, + return devm_snd_soc_register_component(&i2c->dev, + &ssm2518_component_driver, &ssm2518_dai, 1); } -static int ssm2518_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id ssm2518_dt_ids[] = { { .compatible = "adi,ssm2518", }, @@ -822,7 +816,6 @@ static struct i2c_driver ssm2518_driver = { .of_match_table = of_match_ptr(ssm2518_dt_ids), }, .probe = ssm2518_i2c_probe, - .remove = ssm2518_i2c_remove, .id_table = ssm2518_i2c_ids, }; module_i2c_driver(ssm2518_driver); From 1f6440c596fef81acfb1c2d7e64254449ab2e428 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:29:31 +0000 Subject: [PATCH 144/942] ASoC: sta350: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/sta350.c | 117 +++++++++++++++++++------------------- 1 file changed, 58 insertions(+), 59 deletions(-) diff --git a/sound/soc/codecs/sta350.c b/sound/soc/codecs/sta350.c index 9644c20f44e3..0b870319b106 100644 --- a/sound/soc/codecs/sta350.c +++ b/sound/soc/codecs/sta350.c @@ -309,8 +309,8 @@ static int sta350_coefficient_info(struct snd_kcontrol *kcontrol, static int sta350_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud, val; @@ -351,8 +351,8 @@ exit_unlock: static int sta350_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud; @@ -386,9 +386,9 @@ static int sta350_coefficient_put(struct snd_kcontrol *kcontrol, return 0; } -static int sta350_sync_coef_shadow(struct snd_soc_codec *codec) +static int sta350_sync_coef_shadow(struct snd_soc_component *component) { - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); unsigned int cfud; int i; @@ -414,16 +414,16 @@ static int sta350_sync_coef_shadow(struct snd_soc_codec *codec) return 0; } -static int sta350_cache_sync(struct snd_soc_codec *codec) +static int sta350_cache_sync(struct snd_soc_component *component) { - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); unsigned int mute; int rc; /* mute during register sync */ regmap_read(sta350->regmap, STA350_CFUD, &mute); regmap_write(sta350->regmap, STA350_MMUTE, mute | STA350_MMUTE_MMUTE); - sta350_sync_coef_shadow(codec); + sta350_sync_coef_shadow(component); rc = regcache_sync(sta350->regmap); regmap_write(sta350->regmap, STA350_MMUTE, mute); return rc; @@ -613,10 +613,10 @@ static int mcs_ratio_table[3][6] = { static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "mclk=%u\n", freq); + dev_dbg(component->dev, "mclk=%u\n", freq); sta350->mclk = freq; return 0; @@ -633,8 +633,8 @@ static int sta350_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int sta350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); unsigned int confb = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -682,22 +682,22 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); int i, mcs = -EINVAL, ir = -EINVAL; unsigned int confa, confb; unsigned int rate, ratio; int ret; if (!sta350->mclk) { - dev_err(codec->dev, + dev_err(component->dev, "sta350->mclk is unset. Unable to determine ratio\n"); return -EIO; } rate = params_rate(params); ratio = sta350->mclk / rate; - dev_dbg(codec->dev, "rate: %u, ratio: %u\n", rate, ratio); + dev_dbg(component->dev, "rate: %u, ratio: %u\n", rate, ratio); for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { if (interpolation_ratios[i].fs == rate) { @@ -707,7 +707,7 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, } if (ir < 0) { - dev_err(codec->dev, "Unsupported samplerate: %u\n", rate); + dev_err(component->dev, "Unsupported samplerate: %u\n", rate); return -EINVAL; } @@ -719,7 +719,7 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, } if (mcs < 0) { - dev_err(codec->dev, "Unresolvable ratio: %u\n", ratio); + dev_err(component->dev, "Unresolvable ratio: %u\n", ratio); return -EINVAL; } @@ -729,10 +729,10 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 24: - dev_dbg(codec->dev, "24bit\n"); + dev_dbg(component->dev, "24bit\n"); /* fall through */ case 32: - dev_dbg(codec->dev, "24bit or 32bit\n"); + dev_dbg(component->dev, "24bit or 32bit\n"); switch (sta350->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x0; @@ -747,7 +747,7 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, break; case 20: - dev_dbg(codec->dev, "20bit\n"); + dev_dbg(component->dev, "20bit\n"); switch (sta350->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x4; @@ -762,7 +762,7 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, break; case 18: - dev_dbg(codec->dev, "18bit\n"); + dev_dbg(component->dev, "18bit\n"); switch (sta350->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x8; @@ -777,7 +777,7 @@ static int sta350_hw_params(struct snd_pcm_substream *substream, break; case 16: - dev_dbg(codec->dev, "16bit\n"); + dev_dbg(component->dev, "16bit\n"); switch (sta350->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x0; @@ -827,20 +827,20 @@ static int sta350_startup_sequence(struct sta350_priv *sta350) /** * sta350_set_bias_level - DAPM callback - * @codec: the codec device + * @component: the component device * @level: DAPM power level * - * This is called by ALSA to put the codec into low power mode - * or to wake it up. If the codec is powered off completely + * This is called by ALSA to put the component into low power mode + * or to wake it up. If the component is powered off completely * all registers must be restored after power on. */ -static int sta350_set_bias_level(struct snd_soc_codec *codec, +static int sta350_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); int ret; - dev_dbg(codec->dev, "level = %d\n", level); + dev_dbg(component->dev, "level = %d\n", level); switch (level) { case SND_SOC_BIAS_ON: break; @@ -853,18 +853,18 @@ static int sta350_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable( ARRAY_SIZE(sta350->supplies), sta350->supplies); if (ret < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } sta350_startup_sequence(sta350); - sta350_cache_sync(codec); + sta350_cache_sync(component); } /* Power down */ @@ -911,22 +911,22 @@ static struct snd_soc_dai_driver sta350_dai = { .ops = &sta350_dai_ops, }; -static int sta350_probe(struct snd_soc_codec *codec) +static int sta350_probe(struct snd_soc_component *component) { - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); struct sta350_platform_data *pdata = sta350->pdata; int i, ret = 0, thermal = 0; ret = regulator_bulk_enable(ARRAY_SIZE(sta350->supplies), sta350->supplies); if (ret < 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } ret = sta350_startup_sequence(sta350); if (ret < 0) { - dev_err(codec->dev, "Failed to startup device\n"); + dev_err(component->dev, "Failed to startup device\n"); return ret; } @@ -1036,35 +1036,35 @@ static int sta350_probe(struct snd_soc_codec *codec) sta350->coef_shadow[60] = 0x400000; sta350->coef_shadow[61] = 0x400000; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); return 0; } -static int sta350_remove(struct snd_soc_codec *codec) +static void sta350_remove(struct snd_soc_component *component) { - struct sta350_priv *sta350 = snd_soc_codec_get_drvdata(codec); + struct sta350_priv *sta350 = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(sta350->supplies), sta350->supplies); - - return 0; } -static const struct snd_soc_codec_driver sta350_codec = { - .probe = sta350_probe, - .remove = sta350_remove, - .set_bias_level = sta350_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = sta350_snd_controls, - .num_controls = ARRAY_SIZE(sta350_snd_controls), - .dapm_widgets = sta350_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sta350_dapm_widgets), - .dapm_routes = sta350_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sta350_dapm_routes), - }, +static const struct snd_soc_component_driver sta350_component = { + .probe = sta350_probe, + .remove = sta350_remove, + .set_bias_level = sta350_set_bias_level, + .controls = sta350_snd_controls, + .num_controls = ARRAY_SIZE(sta350_snd_controls), + .dapm_widgets = sta350_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sta350_dapm_widgets), + .dapm_routes = sta350_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sta350_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config sta350_regmap = { @@ -1244,16 +1244,15 @@ static int sta350_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, sta350); - ret = snd_soc_register_codec(dev, &sta350_codec, &sta350_dai, 1); + ret = devm_snd_soc_register_component(dev, &sta350_component, &sta350_dai, 1); if (ret < 0) - dev_err(dev, "Failed to register codec (%d)\n", ret); + dev_err(dev, "Failed to register component (%d)\n", ret); return ret; } static int sta350_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From ee18359078d017b066bd99efc6e071a3de782844 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:29:57 +0000 Subject: [PATCH 145/942] ASoC: sta32x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/sta32x.c | 134 ++++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 70 deletions(-) diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 5b888476d9ff..d5035f2f2b2b 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c @@ -143,7 +143,7 @@ static const char *sta32x_supply_names[] = { struct sta32x_priv { struct regmap *regmap; struct regulator_bulk_data supplies[ARRAY_SIZE(sta32x_supply_names)]; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct sta32x_platform_data *pdata; unsigned int mclk; @@ -270,8 +270,8 @@ static int sta32x_coefficient_info(struct snd_kcontrol *kcontrol, static int sta32x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud, val; @@ -312,8 +312,8 @@ exit_unlock: static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; unsigned int cfud; @@ -347,9 +347,9 @@ static int sta32x_coefficient_put(struct snd_kcontrol *kcontrol, return 0; } -static int sta32x_sync_coef_shadow(struct snd_soc_codec *codec) +static int sta32x_sync_coef_shadow(struct snd_soc_component *component) { - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); unsigned int cfud; int i; @@ -375,16 +375,16 @@ static int sta32x_sync_coef_shadow(struct snd_soc_codec *codec) return 0; } -static int sta32x_cache_sync(struct snd_soc_codec *codec) +static int sta32x_cache_sync(struct snd_soc_component *component) { - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); unsigned int mute; int rc; /* mute during register sync */ regmap_read(sta32x->regmap, STA32X_MMUTE, &mute); regmap_write(sta32x->regmap, STA32X_MMUTE, mute | STA32X_MMUTE_MMUTE); - sta32x_sync_coef_shadow(codec); + sta32x_sync_coef_shadow(component); rc = regcache_sync(sta32x->regmap); regmap_write(sta32x->regmap, STA32X_MMUTE, mute); return rc; @@ -395,17 +395,17 @@ static void sta32x_watchdog(struct work_struct *work) { struct sta32x_priv *sta32x = container_of(work, struct sta32x_priv, watchdog_work.work); - struct snd_soc_codec *codec = sta32x->codec; + struct snd_soc_component *component = sta32x->component; unsigned int confa, confa_cached; /* check if sta32x has reset itself */ - confa_cached = snd_soc_read(codec, STA32X_CONFA); + confa_cached = snd_soc_component_read32(component, STA32X_CONFA); regcache_cache_bypass(sta32x->regmap, true); - confa = snd_soc_read(codec, STA32X_CONFA); + confa = snd_soc_component_read32(component, STA32X_CONFA); regcache_cache_bypass(sta32x->regmap, false); if (confa != confa_cached) { regcache_mark_dirty(sta32x->regmap); - sta32x_cache_sync(codec); + sta32x_cache_sync(component); } if (!sta32x->shutdown) @@ -582,10 +582,10 @@ static int mcs_ratio_table[3][7] = { static int sta32x_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "mclk=%u\n", freq); + dev_dbg(component->dev, "mclk=%u\n", freq); sta32x->mclk = freq; return 0; @@ -602,8 +602,8 @@ static int sta32x_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int sta32x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); u8 confb = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -651,22 +651,22 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); int i, mcs = -EINVAL, ir = -EINVAL; unsigned int confa, confb; unsigned int rate, ratio; int ret; if (!sta32x->mclk) { - dev_err(codec->dev, + dev_err(component->dev, "sta32x->mclk is unset. Unable to determine ratio\n"); return -EIO; } rate = params_rate(params); ratio = sta32x->mclk / rate; - dev_dbg(codec->dev, "rate: %u, ratio: %u\n", rate, ratio); + dev_dbg(component->dev, "rate: %u, ratio: %u\n", rate, ratio); for (i = 0; i < ARRAY_SIZE(interpolation_ratios); i++) { if (interpolation_ratios[i].fs == rate) { @@ -676,7 +676,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, } if (ir < 0) { - dev_err(codec->dev, "Unsupported samplerate: %u\n", rate); + dev_err(component->dev, "Unsupported samplerate: %u\n", rate); return -EINVAL; } @@ -688,7 +688,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, } if (mcs < 0) { - dev_err(codec->dev, "Unresolvable ratio: %u\n", ratio); + dev_err(component->dev, "Unresolvable ratio: %u\n", ratio); return -EINVAL; } @@ -698,10 +698,10 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, switch (params_width(params)) { case 24: - dev_dbg(codec->dev, "24bit\n"); + dev_dbg(component->dev, "24bit\n"); /* fall through */ case 32: - dev_dbg(codec->dev, "24bit or 32bit\n"); + dev_dbg(component->dev, "24bit or 32bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x0; @@ -716,7 +716,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, break; case 20: - dev_dbg(codec->dev, "20bit\n"); + dev_dbg(component->dev, "20bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x4; @@ -731,7 +731,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, break; case 18: - dev_dbg(codec->dev, "18bit\n"); + dev_dbg(component->dev, "18bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x8; @@ -746,7 +746,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, break; case 16: - dev_dbg(codec->dev, "16bit\n"); + dev_dbg(component->dev, "16bit\n"); switch (sta32x->format) { case SND_SOC_DAIFMT_I2S: confb |= 0x0; @@ -793,20 +793,20 @@ static int sta32x_startup_sequence(struct sta32x_priv *sta32x) /** * sta32x_set_bias_level - DAPM callback - * @codec: the codec device + * @component: the component device * @level: DAPM power level * - * This is called by ALSA to put the codec into low power mode - * or to wake it up. If the codec is powered off completely + * This is called by ALSA to put the component into low power mode + * or to wake it up. If the component is powered off completely * all registers must be restored after power on. */ -static int sta32x_set_bias_level(struct snd_soc_codec *codec, +static int sta32x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { int ret; - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "level = %d\n", level); + dev_dbg(component->dev, "level = %d\n", level); switch (level) { case SND_SOC_BIAS_ON: break; @@ -819,17 +819,17 @@ static int sta32x_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } sta32x_startup_sequence(sta32x); - sta32x_cache_sync(codec); + sta32x_cache_sync(component); sta32x_watchdog_start(sta32x); } @@ -874,21 +874,21 @@ static struct snd_soc_dai_driver sta32x_dai = { .ops = &sta32x_dai_ops, }; -static int sta32x_probe(struct snd_soc_codec *codec) +static int sta32x_probe(struct snd_soc_component *component) { - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); struct sta32x_platform_data *pdata = sta32x->pdata; int i, ret = 0, thermal = 0; ret = regulator_bulk_enable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); if (ret != 0) { - dev_err(codec->dev, "Failed to enable supplies: %d\n", ret); + dev_err(component->dev, "Failed to enable supplies: %d\n", ret); return ret; } ret = sta32x_startup_sequence(sta32x); if (ret < 0) { - dev_err(codec->dev, "Failed to startup device\n"); + dev_err(component->dev, "Failed to startup device\n"); return ret; } @@ -968,36 +968,36 @@ static int sta32x_probe(struct snd_soc_codec *codec) if (sta32x->pdata->needs_esd_watchdog) INIT_DELAYED_WORK(&sta32x->watchdog_work, sta32x_watchdog); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Bias level configuration will have done an extra enable */ regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); return 0; } -static int sta32x_remove(struct snd_soc_codec *codec) +static void sta32x_remove(struct snd_soc_component *component) { - struct sta32x_priv *sta32x = snd_soc_codec_get_drvdata(codec); + struct sta32x_priv *sta32x = snd_soc_component_get_drvdata(component); sta32x_watchdog_stop(sta32x); regulator_bulk_disable(ARRAY_SIZE(sta32x->supplies), sta32x->supplies); - - return 0; } -static const struct snd_soc_codec_driver sta32x_codec = { - .probe = sta32x_probe, - .remove = sta32x_remove, - .set_bias_level = sta32x_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = sta32x_snd_controls, - .num_controls = ARRAY_SIZE(sta32x_snd_controls), - .dapm_widgets = sta32x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sta32x_dapm_widgets), - .dapm_routes = sta32x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sta32x_dapm_routes), - }, +static const struct snd_soc_component_driver sta32x_component = { + .probe = sta32x_probe, + .remove = sta32x_remove, + .set_bias_level = sta32x_set_bias_level, + .controls = sta32x_snd_controls, + .num_controls = ARRAY_SIZE(sta32x_snd_controls), + .dapm_widgets = sta32x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sta32x_dapm_widgets), + .dapm_routes = sta32x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sta32x_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config sta32x_regmap = { @@ -1121,19 +1121,14 @@ static int sta32x_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, sta32x); - ret = snd_soc_register_codec(dev, &sta32x_codec, &sta32x_dai, 1); + ret = devm_snd_soc_register_component(dev, &sta32x_component, + &sta32x_dai, 1); if (ret < 0) - dev_err(dev, "Failed to register codec (%d)\n", ret); + dev_err(dev, "Failed to register component (%d)\n", ret); return ret; } -static int sta32x_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id sta32x_i2c_id[] = { { "sta326", 0 }, { "sta328", 0 }, @@ -1148,7 +1143,6 @@ static struct i2c_driver sta32x_i2c_driver = { .of_match_table = of_match_ptr(st32x_dt_ids), }, .probe = sta32x_i2c_probe, - .remove = sta32x_i2c_remove, .id_table = sta32x_i2c_id, }; From 895577874dc8340fbc7dca7402870d3f18d92109 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:30:16 +0000 Subject: [PATCH 146/942] ASoC: sta529: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/sta529.c | 69 ++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c index 660734359bf3..2881a0f7bb39 100644 --- a/sound/soc/codecs/sta529.c +++ b/sound/soc/codecs/sta529.c @@ -151,28 +151,28 @@ static const struct snd_kcontrol_new sta529_snd_controls[] = { SOC_ENUM("PWM Select", pwm_src), }; -static int sta529_set_bias_level(struct snd_soc_codec *codec, enum +static int sta529_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct sta529 *sta529 = snd_soc_codec_get_drvdata(codec); + struct sta529 *sta529 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: - snd_soc_update_bits(codec, STA529_FFXCFG0, POWER_CNTLMSAK, + snd_soc_component_update_bits(component, STA529_FFXCFG0, POWER_CNTLMSAK, POWER_UP); - snd_soc_update_bits(codec, STA529_MISC, FFX_CLK_MSK, + snd_soc_component_update_bits(component, STA529_MISC, FFX_CLK_MSK, FFX_CLK_ENB); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) regcache_sync(sta529->regmap); - snd_soc_update_bits(codec, STA529_FFXCFG0, + snd_soc_component_update_bits(component, STA529_FFXCFG0, POWER_CNTLMSAK, POWER_STDBY); /* Making FFX output to zero */ - snd_soc_update_bits(codec, STA529_FFXCFG0, FFX_MASK, + snd_soc_component_update_bits(component, STA529_FFXCFG0, FFX_MASK, FFX_OFF); - snd_soc_update_bits(codec, STA529_MISC, FFX_CLK_MSK, + snd_soc_component_update_bits(component, STA529_MISC, FFX_CLK_MSK, FFX_CLK_DIS); break; case SND_SOC_BIAS_OFF: @@ -187,7 +187,7 @@ static int sta529_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int pdata, play_freq_val, record_freq_val; int bclk_to_fs_ratio; @@ -205,7 +205,7 @@ static int sta529_hw_params(struct snd_pcm_substream *substream, bclk_to_fs_ratio = 2; break; default: - dev_err(codec->dev, "Unsupported format\n"); + dev_err(component->dev, "Unsupported format\n"); return -EINVAL; } @@ -228,23 +228,23 @@ static int sta529_hw_params(struct snd_pcm_substream *substream, record_freq_val = 0; break; default: - dev_err(codec->dev, "Unsupported rate\n"); + dev_err(component->dev, "Unsupported rate\n"); return -EINVAL; } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - snd_soc_update_bits(codec, STA529_S2PCFG1, PDATA_LEN_MSK, + snd_soc_component_update_bits(component, STA529_S2PCFG1, PDATA_LEN_MSK, pdata << 6); - snd_soc_update_bits(codec, STA529_S2PCFG1, BCLK_TO_FS_MSK, + snd_soc_component_update_bits(component, STA529_S2PCFG1, BCLK_TO_FS_MSK, bclk_to_fs_ratio << 4); - snd_soc_update_bits(codec, STA529_MISC, PLAY_FREQ_RANGE_MSK, + snd_soc_component_update_bits(component, STA529_MISC, PLAY_FREQ_RANGE_MSK, play_freq_val << 4); } else { - snd_soc_update_bits(codec, STA529_P2SCFG1, PDATA_LEN_MSK, + snd_soc_component_update_bits(component, STA529_P2SCFG1, PDATA_LEN_MSK, pdata << 6); - snd_soc_update_bits(codec, STA529_P2SCFG1, BCLK_TO_FS_MSK, + snd_soc_component_update_bits(component, STA529_P2SCFG1, BCLK_TO_FS_MSK, bclk_to_fs_ratio << 4); - snd_soc_update_bits(codec, STA529_MISC, CAP_FREQ_RANGE_MSK, + snd_soc_component_update_bits(component, STA529_MISC, CAP_FREQ_RANGE_MSK, record_freq_val << 2); } @@ -258,14 +258,14 @@ static int sta529_mute(struct snd_soc_dai *dai, int mute) if (mute) val |= CODEC_MUTE_VAL; - snd_soc_update_bits(dai->codec, STA529_FFXCFG0, AUDIO_MUTE_MSK, val); + snd_soc_component_update_bits(dai->component, STA529_FFXCFG0, AUDIO_MUTE_MSK, val); return 0; } static int sta529_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 mode = 0; /* interface format */ @@ -283,7 +283,7 @@ static int sta529_set_dai_fmt(struct snd_soc_dai *codec_dai, u32 fmt) return -EINVAL; } - snd_soc_update_bits(codec, STA529_S2PCFG0, DATA_FORMAT_MSK, mode); + snd_soc_component_update_bits(component, STA529_S2PCFG0, DATA_FORMAT_MSK, mode); return 0; } @@ -313,14 +313,15 @@ static struct snd_soc_dai_driver sta529_dai = { .ops = &sta529_dai_ops, }; -static const struct snd_soc_codec_driver sta529_codec_driver = { - .set_bias_level = sta529_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = sta529_snd_controls, - .num_controls = ARRAY_SIZE(sta529_snd_controls), - }, +static const struct snd_soc_component_driver sta529_component_driver = { + .set_bias_level = sta529_set_bias_level, + .controls = sta529_snd_controls, + .num_controls = ARRAY_SIZE(sta529_snd_controls), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config sta529_regmap = { @@ -354,21 +355,14 @@ static int sta529_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, sta529); - ret = snd_soc_register_codec(&i2c->dev, - &sta529_codec_driver, &sta529_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &sta529_component_driver, &sta529_dai, 1); if (ret != 0) dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); return ret; } -static int sta529_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id sta529_i2c_id[] = { { "sta529", 0 }, { } @@ -387,7 +381,6 @@ static struct i2c_driver sta529_i2c_driver = { .of_match_table = sta529_of_match, }, .probe = sta529_i2c_probe, - .remove = sta529_i2c_remove, .id_table = sta529_i2c_id, }; From 459bc024b7f2360f656b03562ec02ee5945bd033 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:30:43 +0000 Subject: [PATCH 147/942] ASoC: tas5086: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tas5086.c | 94 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index 199272d5cb6a..5efc4b7145d4 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c @@ -261,9 +261,9 @@ struct tas5086_private { static int tas5086_deemph[] = { 0, 32000, 44100, 48000 }; -static int tas5086_set_deemph(struct snd_soc_codec *codec) +static int tas5086_set_deemph(struct snd_soc_component *component) { - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); int i, val = 0; if (priv->deemph) { @@ -282,8 +282,8 @@ static int tas5086_set_deemph(struct snd_soc_codec *codec) static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = priv->deemph; @@ -293,20 +293,20 @@ static int tas5086_get_deemph(struct snd_kcontrol *kcontrol, static int tas5086_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); priv->deemph = ucontrol->value.integer.value[0]; - return tas5086_set_deemph(codec); + return tas5086_set_deemph(component); } static int tas5086_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); switch (clk_id) { case TAS5086_CLK_IDX_MCLK: @@ -323,12 +323,12 @@ static int tas5086_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int tas5086_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int format) { - struct snd_soc_codec *codec = codec_dai->codec; - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); /* The TAS5086 can only be slave to all clocks */ if ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_err(codec->dev, "Invalid clocking mode\n"); + dev_err(component->dev, "Invalid clocking mode\n"); return -EINVAL; } @@ -361,8 +361,8 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); int val; int ret; @@ -373,7 +373,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, ARRAY_SIZE(tas5086_sample_rates), priv->rate); if (val < 0) { - dev_err(codec->dev, "Invalid sample rate\n"); + dev_err(component->dev, "Invalid sample rate\n"); return -EINVAL; } @@ -387,7 +387,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, val = index_in_array(tas5086_ratios, ARRAY_SIZE(tas5086_ratios), priv->mclk / priv->rate); if (val < 0) { - dev_err(codec->dev, "Invalid MCLK / Fs ratio\n"); + dev_err(component->dev, "Invalid MCLK / Fs ratio\n"); return -EINVAL; } @@ -424,7 +424,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, val = 0x06; break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } @@ -440,7 +440,7 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, val += 2; break; default: - dev_err(codec->dev, "Invalid bit width\n"); + dev_err(component->dev, "Invalid bit width\n"); return -EINVAL; } @@ -454,13 +454,13 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - return tas5086_set_deemph(codec); + return tas5086_set_deemph(component); } static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) { - struct snd_soc_codec *codec = dai->codec; - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); unsigned int val = 0; if (mute) @@ -773,9 +773,9 @@ static struct snd_soc_dai_driver tas5086_dai = { }; #ifdef CONFIG_PM -static int tas5086_soc_suspend(struct snd_soc_codec *codec) +static int tas5086_soc_suspend(struct snd_soc_component *component) { - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); int ret; /* Shut down all channels */ @@ -788,9 +788,9 @@ static int tas5086_soc_suspend(struct snd_soc_codec *codec) return 0; } -static int tas5086_soc_resume(struct snd_soc_codec *codec) +static int tas5086_soc_resume(struct snd_soc_component *component) { - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); @@ -800,7 +800,7 @@ static int tas5086_soc_resume(struct snd_soc_codec *codec) tas5086_reset(priv); regcache_mark_dirty(priv->regmap); - ret = tas5086_init(codec->dev, priv); + ret = tas5086_init(component->dev, priv); if (ret < 0) return ret; @@ -823,22 +823,22 @@ static const struct of_device_id tas5086_dt_ids[] = { MODULE_DEVICE_TABLE(of, tas5086_dt_ids); #endif -static int tas5086_probe(struct snd_soc_codec *codec) +static int tas5086_probe(struct snd_soc_component *component) { - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); int i, ret; ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret < 0) { - dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); + dev_err(component->dev, "Failed to enable regulators: %d\n", ret); return ret; } priv->pwm_start_mid_z = 0; priv->charge_period = 1300000; /* hardware default is 1300 ms */ - if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { - struct device_node *of_node = codec->dev->of_node; + if (of_match_device(of_match_ptr(tas5086_dt_ids), component->dev)) { + struct device_node *of_node = component->dev->of_node; of_property_read_u32(of_node, "ti,charge-period", &priv->charge_period); @@ -855,7 +855,7 @@ static int tas5086_probe(struct snd_soc_codec *codec) } tas5086_reset(priv); - ret = tas5086_init(codec->dev, priv); + ret = tas5086_init(component->dev, priv); if (ret < 0) goto exit_disable_regulators; @@ -872,32 +872,32 @@ exit_disable_regulators: return ret; } -static int tas5086_remove(struct snd_soc_codec *codec) +static void tas5086_remove(struct snd_soc_component *component) { - struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); + struct tas5086_private *priv = snd_soc_component_get_drvdata(component); if (gpio_is_valid(priv->gpio_nreset)) /* Set codec to the reset state */ gpio_set_value(priv->gpio_nreset, 0); regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); - - return 0; }; -static const struct snd_soc_codec_driver soc_codec_dev_tas5086 = { +static const struct snd_soc_component_driver soc_component_dev_tas5086 = { .probe = tas5086_probe, .remove = tas5086_remove, .suspend = tas5086_soc_suspend, .resume = tas5086_soc_resume, - .component_driver = { - .controls = tas5086_controls, - .num_controls = ARRAY_SIZE(tas5086_controls), - .dapm_widgets = tas5086_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tas5086_dapm_widgets), - .dapm_routes = tas5086_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(tas5086_dapm_routes), - }, + .controls = tas5086_controls, + .num_controls = ARRAY_SIZE(tas5086_controls), + .dapm_widgets = tas5086_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tas5086_dapm_widgets), + .dapm_routes = tas5086_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(tas5086_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct i2c_device_id tas5086_i2c_id[] = { @@ -985,7 +985,8 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); if (ret == 0) - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tas5086, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_tas5086, &tas5086_dai, 1); return ret; @@ -993,7 +994,6 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, static int tas5086_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); return 0; } From 2be04bab74d8c2f6493af9da37098208cb2fc44f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:31:00 +0000 Subject: [PATCH 148/942] ASoC: tas571x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tas571x.c | 55 +++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/sound/soc/codecs/tas571x.c b/sound/soc/codecs/tas571x.c index a09499977be4..52f34c94ec25 100644 --- a/sound/soc/codecs/tas571x.c +++ b/sound/soc/codecs/tas571x.c @@ -51,7 +51,7 @@ struct tas571x_private { unsigned int format; struct gpio_desc *reset_gpio; struct gpio_desc *pdn_gpio; - struct snd_soc_codec_driver codec_driver; + struct snd_soc_component_driver component_driver; }; static int tas571x_register_size(struct tas571x_private *priv, unsigned int reg) @@ -242,8 +242,8 @@ static int tas571x_coefficient_info(struct snd_kcontrol *kcontrol, static int tas571x_coefficient_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct i2c_client *i2c = to_i2c_client(component->dev); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -254,8 +254,8 @@ static int tas571x_coefficient_get(struct snd_kcontrol *kcontrol, static int tas571x_coefficient_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct i2c_client *i2c = to_i2c_client(component->dev); int numcoef = kcontrol->private_value >> 16; int index = kcontrol->private_value & 0xffff; @@ -265,7 +265,7 @@ static int tas571x_coefficient_put(struct snd_kcontrol *kcontrol, static int tas571x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int format) { - struct tas571x_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct tas571x_private *priv = snd_soc_component_get_drvdata(dai->component); priv->format = format; @@ -276,7 +276,7 @@ static int tas571x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct tas571x_private *priv = snd_soc_codec_get_drvdata(dai->codec); + struct tas571x_private *priv = snd_soc_component_get_drvdata(dai->component); u32 val; switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -304,13 +304,13 @@ static int tas571x_hw_params(struct snd_pcm_substream *substream, static int tas571x_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 sysctl2; int ret; sysctl2 = mute ? TAS571X_SYS_CTRL_2_SDN_MASK : 0; - ret = snd_soc_update_bits(codec, + ret = snd_soc_component_update_bits(component, TAS571X_SYS_CTRL_2_REG, TAS571X_SYS_CTRL_2_SDN_MASK, sysctl2); @@ -319,10 +319,10 @@ static int tas571x_mute(struct snd_soc_dai *dai, int mute) return ret; } -static int tas571x_set_bias_level(struct snd_soc_codec *codec, +static int tas571x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct tas571x_private *priv = snd_soc_codec_get_drvdata(codec); + struct tas571x_private *priv = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -331,11 +331,11 @@ static int tas571x_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { if (!IS_ERR(priv->mclk)) { ret = clk_prepare_enable(priv->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable master clock: %d\n", ret); return ret; @@ -643,16 +643,15 @@ static const struct snd_soc_dapm_route tas571x_dapm_routes[] = { { "OUT_D", NULL, "DACR" }, }; -static const struct snd_soc_codec_driver tas571x_codec = { - .set_bias_level = tas571x_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .dapm_widgets = tas571x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tas571x_dapm_widgets), - .dapm_routes = tas571x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(tas571x_dapm_routes), - }, +static const struct snd_soc_component_driver tas571x_component = { + .set_bias_level = tas571x_set_bias_level, + .dapm_widgets = tas571x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tas571x_dapm_widgets), + .dapm_routes = tas571x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(tas571x_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct snd_soc_dai_driver tas571x_dai = { @@ -746,9 +745,9 @@ static int tas571x_i2c_probe(struct i2c_client *client, usleep_range(50000, 60000); - memcpy(&priv->codec_driver, &tas571x_codec, sizeof(priv->codec_driver)); - priv->codec_driver.component_driver.controls = priv->chip->controls; - priv->codec_driver.component_driver.num_controls = priv->chip->num_controls; + memcpy(&priv->component_driver, &tas571x_component, sizeof(priv->component_driver)); + priv->component_driver.controls = priv->chip->controls; + priv->component_driver.num_controls = priv->chip->num_controls; if (priv->chip->vol_reg_size == 2) { /* @@ -761,7 +760,8 @@ static int tas571x_i2c_probe(struct i2c_client *client, return ret; } - return snd_soc_register_codec(&client->dev, &priv->codec_driver, + return devm_snd_soc_register_component(&client->dev, + &priv->component_driver, &tas571x_dai, 1); } @@ -769,7 +769,6 @@ static int tas571x_i2c_remove(struct i2c_client *client) { struct tas571x_private *priv = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); regulator_bulk_disable(priv->chip->num_supply_names, priv->supplies); return 0; From 12a72f91a28eb302e1431ef0bb68b5f83e35a891 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:31:19 +0000 Subject: [PATCH 149/942] ASoC: nau8824: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/nau8824.c | 113 +++++++++++++++++-------------------- sound/soc/codecs/nau8824.h | 2 +- 2 files changed, 54 insertions(+), 61 deletions(-) diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c index 088e0cef4cb8..4d9148a6a080 100644 --- a/sound/soc/codecs/nau8824.c +++ b/sound/soc/codecs/nau8824.c @@ -414,8 +414,8 @@ static const struct snd_kcontrol_new nau8824_snd_controls[] = { static int nau8824_output_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -437,8 +437,8 @@ static int nau8824_output_dac_event(struct snd_soc_dapm_widget *w, static int nau8824_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -461,8 +461,8 @@ static int nau8824_spk_event(struct snd_soc_dapm_widget *w, static int nau8824_pump_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -487,8 +487,8 @@ static int nau8824_pump_event(struct snd_soc_dapm_widget *w, static int system_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); if (SND_SOC_DAPM_EVENT_OFF(event)) { /* Set clock source to disable or internal clock before the @@ -509,8 +509,8 @@ static int system_clock_control(struct snd_soc_dapm_widget *w, static int dmic_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); int src; /* The DMIC clock is gotten from system clock (256fs) divided by @@ -988,8 +988,8 @@ static int nau8824_clock_check(struct nau8824 *nau8824, static int nau8824_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; nau8824_sema_acquire(nau8824, HZ); @@ -1072,8 +1072,8 @@ static int nau8824_hw_params(struct snd_pcm_substream *substream, static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); unsigned int ctrl1_val = 0, ctrl2_val = 0; nau8824_sema_acquire(nau8824, HZ); @@ -1149,8 +1149,8 @@ static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int nau8824_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); unsigned int tslot_l = 0, ctrl_val = 0; if (slots > 4 || ((tx_mask & 0xf0) && (tx_mask & 0xf)) || @@ -1288,10 +1288,10 @@ static void nau8824_fll_apply(struct regmap *regmap, } /* freq_out must be 256*Fs in order to achieve the best performance */ -static int nau8824_set_pll(struct snd_soc_codec *codec, int pll_id, int source, +static int nau8824_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); struct nau8824_fll fll_param; int ret, fs; @@ -1374,10 +1374,10 @@ static int nau8824_config_sysclk(struct nau8824 *nau8824, return 0; } -static int nau8824_set_sysclk(struct snd_soc_codec *codec, +static int nau8824_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); return nau8824_config_sysclk(nau8824, clk_id, freq); } @@ -1403,10 +1403,10 @@ static void nau8824_resume_setup(struct nau8824 *nau8824) } } -static int nau8824_set_bias_level(struct snd_soc_codec *codec, +static int nau8824_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1416,7 +1416,7 @@ static int nau8824_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Setup codec configuration after resume */ nau8824_resume_setup(nau8824); } @@ -1434,23 +1434,23 @@ static int nau8824_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int nau8824_codec_probe(struct snd_soc_codec *codec) +static int nau8824_component_probe(struct snd_soc_component *component) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); nau8824->dapm = dapm; return 0; } -static int __maybe_unused nau8824_suspend(struct snd_soc_codec *codec) +static int __maybe_unused nau8824_suspend(struct snd_soc_component *component) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); if (nau8824->irq) { disable_irq(nau8824->irq); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); } regcache_cache_only(nau8824->regmap, true); regcache_mark_dirty(nau8824->regmap); @@ -1458,9 +1458,9 @@ static int __maybe_unused nau8824_suspend(struct snd_soc_codec *codec) return 0; } -static int __maybe_unused nau8824_resume(struct snd_soc_codec *codec) +static int __maybe_unused nau8824_resume(struct snd_soc_component *component) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); regcache_cache_only(nau8824->regmap, false); regcache_sync(nau8824->regmap); @@ -1475,23 +1475,24 @@ static int __maybe_unused nau8824_resume(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver nau8824_codec_driver = { - .probe = nau8824_codec_probe, - .set_sysclk = nau8824_set_sysclk, - .set_pll = nau8824_set_pll, - .set_bias_level = nau8824_set_bias_level, - .suspend = nau8824_suspend, - .resume = nau8824_resume, - .suspend_bias_off = true, - - .component_driver = { - .controls = nau8824_snd_controls, - .num_controls = ARRAY_SIZE(nau8824_snd_controls), - .dapm_widgets = nau8824_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(nau8824_dapm_widgets), - .dapm_routes = nau8824_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(nau8824_dapm_routes), - }, +static const struct snd_soc_component_driver nau8824_component_driver = { + .probe = nau8824_component_probe, + .set_sysclk = nau8824_set_sysclk, + .set_pll = nau8824_set_pll, + .set_bias_level = nau8824_set_bias_level, + .suspend = nau8824_suspend, + .resume = nau8824_resume, + .controls = nau8824_snd_controls, + .num_controls = ARRAY_SIZE(nau8824_snd_controls), + .dapm_widgets = nau8824_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(nau8824_dapm_widgets), + .dapm_routes = nau8824_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(nau8824_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct snd_soc_dai_ops nau8824_dai_ops = { @@ -1547,10 +1548,10 @@ static const struct regmap_config nau8824_regmap_config = { * events will be routed to the given jack. Jack can be null to stop * reporting. */ -int nau8824_enable_jack_detect(struct snd_soc_codec *codec, +int nau8824_enable_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct nau8824 *nau8824 = snd_soc_codec_get_drvdata(codec); + struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); int ret; nau8824->jack = jack; @@ -1838,15 +1839,8 @@ static int nau8824_i2c_probe(struct i2c_client *i2c, if (i2c->irq) nau8824_setup_irq(nau8824); - return snd_soc_register_codec(dev, - &nau8824_codec_driver, &nau8824_dai, 1); -} - - -static int nau8824_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; + return devm_snd_soc_register_component(dev, + &nau8824_component_driver, &nau8824_dai, 1); } static const struct i2c_device_id nau8824_i2c_ids[] = { @@ -1878,7 +1872,6 @@ static struct i2c_driver nau8824_i2c_driver = { .acpi_match_table = ACPI_PTR(nau8824_acpi_match), }, .probe = nau8824_i2c_probe, - .remove = nau8824_i2c_remove, .id_table = nau8824_i2c_ids, }; module_i2c_driver(nau8824_i2c_driver); diff --git a/sound/soc/codecs/nau8824.h b/sound/soc/codecs/nau8824.h index 21eae2431c83..6184a2b5c941 100644 --- a/sound/soc/codecs/nau8824.h +++ b/sound/soc/codecs/nau8824.h @@ -471,7 +471,7 @@ struct nau8824_osr_attr { }; -int nau8824_enable_jack_detect(struct snd_soc_codec *codec, +int nau8824_enable_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* _NAU8824_H */ From 61cf1c47e479ca0905d5ae54c1aa93065f69bf3e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:31:36 +0000 Subject: [PATCH 150/942] ASoC: nau8810: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/nau8810.c | 73 +++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 40 deletions(-) diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c index c8e2451ae0a3..ca2ba1c7bb9a 100644 --- a/sound/soc/codecs/nau8810.c +++ b/sound/soc/codecs/nau8810.c @@ -167,8 +167,8 @@ static bool nau8810_volatile_reg(struct device *dev, unsigned int reg) static int nau8810_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *params = (void *)kcontrol->private_value; int i, reg, reg_val; u16 *val; @@ -198,8 +198,8 @@ static int nau8810_eq_get(struct snd_kcontrol *kcontrol, static int nau8810_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct soc_bytes_ext *params = (void *)kcontrol->private_value; void *data; u16 *val, value; @@ -219,7 +219,7 @@ static int nau8810_eq_put(struct snd_kcontrol *kcontrol, value = be16_to_cpu(*(val + i)); ret = regmap_write(nau8810->regmap, reg + i, value); if (ret) { - dev_err(codec->dev, "EQ configuration fail, register: %x ret: %d\n", + dev_err(component->dev, "EQ configuration fail, register: %x ret: %d\n", reg + i, ret); kfree(data); return ret; @@ -399,8 +399,8 @@ static const struct snd_kcontrol_new nau8810_loopback = static int check_mclk_select_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); unsigned int value; regmap_read(nau8810->regmap, NAU8810_REG_CLOCK, &value); @@ -485,8 +485,8 @@ static const struct snd_soc_dapm_route nau8810_dapm_routes[] = { static int nau8810_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); nau8810->clk_id = clk_id; nau8810->sysclk = freq; @@ -538,8 +538,8 @@ static int nau88l0_calc_pll(unsigned int pll_in, static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct regmap *map = nau8810->regmap; struct nau8810_pll *pll_param = &nau8810->pll; int ret, fs; @@ -577,8 +577,8 @@ static int nau8810_set_pll(struct snd_soc_dai *codec_dai, int pll_id, static int nau8810_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); u16 ctrl1_val = 0, ctrl2_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -667,8 +667,8 @@ static int nau8810_mclk_clkdiv(struct nau8810 *nau8810, int rate) static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); int val_len = 0, val_rate = 0, ret = 0; switch (params_width(params)) { @@ -723,10 +723,10 @@ static int nau8810_pcm_hw_params(struct snd_pcm_substream *substream, return ret; } -static int nau8810_set_bias_level(struct snd_soc_codec *codec, +static int nau8810_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct nau8810 *nau8810 = snd_soc_codec_get_drvdata(codec); + struct nau8810 *nau8810 = snd_soc_component_get_drvdata(component); struct regmap *map = nau8810->regmap; switch (level) { @@ -741,7 +741,7 @@ static int nau8810_set_bias_level(struct snd_soc_codec *codec, NAU8810_IOBUF_EN | NAU8810_ABIAS_EN, NAU8810_IOBUF_EN | NAU8810_ABIAS_EN); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { regcache_sync(map); regmap_update_bits(map, NAU8810_REG_POWER1, NAU8810_REFIMP_MASK, NAU8810_REFIMP_3K); @@ -808,18 +808,19 @@ static const struct regmap_config nau8810_regmap_config = { .num_reg_defaults = ARRAY_SIZE(nau8810_reg_defaults), }; -static const struct snd_soc_codec_driver nau8810_codec_driver = { - .set_bias_level = nau8810_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = nau8810_snd_controls, - .num_controls = ARRAY_SIZE(nau8810_snd_controls), - .dapm_widgets = nau8810_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(nau8810_dapm_widgets), - .dapm_routes = nau8810_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(nau8810_dapm_routes), - }, +static const struct snd_soc_component_driver nau8810_component_driver = { + .set_bias_level = nau8810_set_bias_level, + .controls = nau8810_snd_controls, + .num_controls = ARRAY_SIZE(nau8810_snd_controls), + .dapm_widgets = nau8810_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(nau8810_dapm_widgets), + .dapm_routes = nau8810_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(nau8810_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int nau8810_i2c_probe(struct i2c_client *i2c, @@ -842,15 +843,8 @@ static int nau8810_i2c_probe(struct i2c_client *i2c, regmap_write(nau8810->regmap, NAU8810_REG_RESET, 0x00); - return snd_soc_register_codec(dev, - &nau8810_codec_driver, &nau8810_dai, 1); -} - -static int nau8810_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; + return devm_snd_soc_register_component(dev, + &nau8810_component_driver, &nau8810_dai, 1); } static const struct i2c_device_id nau8810_i2c_id[] = { @@ -873,7 +867,6 @@ static struct i2c_driver nau8810_i2c_driver = { .of_match_table = of_match_ptr(nau8810_of_match), }, .probe = nau8810_i2c_probe, - .remove = nau8810_i2c_remove, .id_table = nau8810_i2c_id, }; From 415bc3a0bfb26c934daa4a16a8a4f589c018bdaa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:31:51 +0000 Subject: [PATCH 151/942] ASoC: nau8540: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/nau8540.c | 79 +++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 43 deletions(-) diff --git a/sound/soc/codecs/nau8540.c b/sound/soc/codecs/nau8540.c index b08fb7e243c3..17104f8dc1a9 100644 --- a/sound/soc/codecs/nau8540.c +++ b/sound/soc/codecs/nau8540.c @@ -236,8 +236,8 @@ static const struct snd_kcontrol_new digital_ch1_mux = static int adc_power_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); if (SND_SOC_DAPM_EVENT_ON(event)) { msleep(300); @@ -258,8 +258,8 @@ static int adc_power_control(struct snd_soc_dapm_widget *w, static int aiftx_power_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); if (SND_SOC_DAPM_EVENT_OFF(event)) { regmap_write(nau8540->regmap, NAU8540_REG_RST, 0x0001); @@ -379,8 +379,8 @@ static int nau8540_clock_check(struct nau8540 *nau8540, int rate, int osr) static int nau8540_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, osr; /* CLK_ADC = OSR * FS @@ -422,8 +422,8 @@ static int nau8540_hw_params(struct snd_pcm_substream *substream, static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); unsigned int ctrl1_val = 0, ctrl2_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -493,8 +493,8 @@ static int nau8540_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int nau8540_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); unsigned int ctrl2_val = 0, ctrl4_val = 0; if (slots > 4 || ((tx_mask & 0xf0) && (tx_mask & 0xf))) @@ -649,10 +649,10 @@ static void nau8540_fll_apply(struct regmap *regmap, } /* freq_out must be 256*Fs in order to achieve the best performance */ -static int nau8540_set_pll(struct snd_soc_codec *codec, int pll_id, int source, +static int nau8540_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); struct nau8540_fll fll_param; int ret, fs; @@ -702,10 +702,10 @@ static int nau8540_set_pll(struct snd_soc_codec *codec, int pll_id, int source, return 0; } -static int nau8540_set_sysclk(struct snd_soc_codec *codec, +static int nau8540_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); switch (clk_id) { case NAU8540_CLK_DIS: @@ -777,9 +777,9 @@ static void nau8540_init_regs(struct nau8540 *nau8540) NAU8540_I2S_DO34_TRI, NAU8540_I2S_DO34_TRI); } -static int __maybe_unused nau8540_suspend(struct snd_soc_codec *codec) +static int __maybe_unused nau8540_suspend(struct snd_soc_component *component) { - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); regcache_cache_only(nau8540->regmap, true); regcache_mark_dirty(nau8540->regmap); @@ -787,9 +787,9 @@ static int __maybe_unused nau8540_suspend(struct snd_soc_codec *codec) return 0; } -static int __maybe_unused nau8540_resume(struct snd_soc_codec *codec) +static int __maybe_unused nau8540_resume(struct snd_soc_component *component) { - struct nau8540 *nau8540 = snd_soc_codec_get_drvdata(codec); + struct nau8540 *nau8540 = snd_soc_component_get_drvdata(component); regcache_cache_only(nau8540->regmap, false); regcache_sync(nau8540->regmap); @@ -797,21 +797,22 @@ static int __maybe_unused nau8540_resume(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver nau8540_codec_driver = { - .set_sysclk = nau8540_set_sysclk, - .set_pll = nau8540_set_pll, - .suspend = nau8540_suspend, - .resume = nau8540_resume, - .suspend_bias_off = true, - - .component_driver = { - .controls = nau8540_snd_controls, - .num_controls = ARRAY_SIZE(nau8540_snd_controls), - .dapm_widgets = nau8540_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(nau8540_dapm_widgets), - .dapm_routes = nau8540_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(nau8540_dapm_routes), - }, +static const struct snd_soc_component_driver nau8540_component_driver = { + .set_sysclk = nau8540_set_sysclk, + .set_pll = nau8540_set_pll, + .suspend = nau8540_suspend, + .resume = nau8540_resume, + .controls = nau8540_snd_controls, + .num_controls = ARRAY_SIZE(nau8540_snd_controls), + .dapm_widgets = nau8540_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(nau8540_dapm_widgets), + .dapm_routes = nau8540_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(nau8540_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config nau8540_regmap_config = { @@ -856,17 +857,10 @@ static int nau8540_i2c_probe(struct i2c_client *i2c, nau8540_reset_chip(nau8540->regmap); nau8540_init_regs(nau8540); - return snd_soc_register_codec(dev, - &nau8540_codec_driver, &nau8540_dai, 1); + return devm_snd_soc_register_component(dev, + &nau8540_component_driver, &nau8540_dai, 1); } -static int nau8540_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - - static const struct i2c_device_id nau8540_i2c_ids[] = { { "nau8540", 0 }, { } @@ -887,7 +881,6 @@ static struct i2c_driver nau8540_i2c_driver = { .of_match_table = of_match_ptr(nau8540_of_ids), }, .probe = nau8540_i2c_probe, - .remove = nau8540_i2c_remove, .id_table = nau8540_i2c_ids, }; module_i2c_driver(nau8540_i2c_driver); From 2ff52976788bae279d031632ad9c22df0f829fa2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:32:16 +0000 Subject: [PATCH 152/942] ASoC: es8316: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/es8316.c | 80 ++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index da2d353af5ba..e97d12d578b0 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -356,8 +356,8 @@ static const struct snd_soc_dapm_route es8316_dapm_routes[] = { static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); int i; int count = 0; @@ -385,19 +385,19 @@ static int es8316_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int es8316_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u8 serdata1 = 0; u8 serdata2 = 0; u8 clksw; u8 mask; if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_err(codec->dev, "Codec driver only supports slave mode\n"); + dev_err(component->dev, "Codec driver only supports slave mode\n"); return -EINVAL; } if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) != SND_SOC_DAIFMT_I2S) { - dev_err(codec->dev, "Codec driver only supports I2S format\n"); + dev_err(component->dev, "Codec driver only supports I2S format\n"); return -EINVAL; } @@ -420,15 +420,15 @@ static int es8316_set_dai_fmt(struct snd_soc_dai *codec_dai, } mask = ES8316_SERDATA1_MASTER | ES8316_SERDATA1_BCLK_INV; - snd_soc_update_bits(codec, ES8316_SERDATA1, mask, serdata1); + snd_soc_component_update_bits(component, ES8316_SERDATA1, mask, serdata1); mask = ES8316_SERDATA2_FMT_MASK | ES8316_SERDATA2_ADCLRP; - snd_soc_update_bits(codec, ES8316_SERDATA_ADC, mask, serdata2); - snd_soc_update_bits(codec, ES8316_SERDATA_DAC, mask, serdata2); + snd_soc_component_update_bits(component, ES8316_SERDATA_ADC, mask, serdata2); + snd_soc_component_update_bits(component, ES8316_SERDATA_DAC, mask, serdata2); /* Enable BCLK and MCLK inputs in slave mode */ clksw = ES8316_CLKMGR_CLKSW_MCLK_ON | ES8316_CLKMGR_CLKSW_BCLK_ON; - snd_soc_update_bits(codec, ES8316_CLKMGR_CLKSW, clksw, clksw); + snd_soc_component_update_bits(component, ES8316_CLKMGR_CLKSW, clksw, clksw); return 0; } @@ -436,11 +436,11 @@ static int es8316_set_dai_fmt(struct snd_soc_dai *codec_dai, static int es8316_pcm_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); if (es8316->sysclk == 0) { - dev_err(codec->dev, "No sysclk provided\n"); + dev_err(component->dev, "No sysclk provided\n"); return -EINVAL; } @@ -458,13 +458,12 @@ static int es8316_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; - struct es8316_priv *es8316 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component); u8 wordlen = 0; if (!es8316->sysclk) { - dev_err(codec->dev, "No MCLK configured\n"); + dev_err(component->dev, "No MCLK configured\n"); return -EINVAL; } @@ -485,16 +484,16 @@ static int es8316_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, ES8316_SERDATA_DAC, + snd_soc_component_update_bits(component, ES8316_SERDATA_DAC, ES8316_SERDATA2_LEN_MASK, wordlen); - snd_soc_update_bits(codec, ES8316_SERDATA_ADC, + snd_soc_component_update_bits(component, ES8316_SERDATA_ADC, ES8316_SERDATA2_LEN_MASK, wordlen); return 0; } static int es8316_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, ES8316_DAC_SET1, 0x20, + snd_soc_component_update_bits(dai->component, ES8316_DAC_SET1, 0x20, mute ? 0x20 : 0); return 0; } @@ -530,42 +529,41 @@ static struct snd_soc_dai_driver es8316_dai = { .symmetric_rates = 1, }; -static int es8316_probe(struct snd_soc_codec *codec) +static int es8316_probe(struct snd_soc_component *component) { /* Reset codec and enable current state machine */ - snd_soc_write(codec, ES8316_RESET, 0x3f); + snd_soc_component_write(component, ES8316_RESET, 0x3f); usleep_range(5000, 5500); - snd_soc_write(codec, ES8316_RESET, ES8316_RESET_CSM_ON); + snd_soc_component_write(component, ES8316_RESET, ES8316_RESET_CSM_ON); msleep(30); /* * Documentation is unclear, but this value from the vendor driver is * needed otherwise audio output is silent. */ - snd_soc_write(codec, ES8316_SYS_VMIDSEL, 0xff); + snd_soc_component_write(component, ES8316_SYS_VMIDSEL, 0xff); /* * Documentation for this register is unclear and incomplete, * but here is a vendor-provided value that improves volume * and quality for Intel CHT platforms. */ - snd_soc_write(codec, ES8316_CLKMGR_ADCOSR, 0x32); + snd_soc_component_write(component, ES8316_CLKMGR_ADCOSR, 0x32); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_es8316 = { - .probe = es8316_probe, - .idle_bias_off = true, - - .component_driver = { - .controls = es8316_snd_controls, - .num_controls = ARRAY_SIZE(es8316_snd_controls), - .dapm_widgets = es8316_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(es8316_dapm_widgets), - .dapm_routes = es8316_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(es8316_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_es8316 = { + .probe = es8316_probe, + .controls = es8316_snd_controls, + .num_controls = ARRAY_SIZE(es8316_snd_controls), + .dapm_widgets = es8316_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(es8316_dapm_widgets), + .dapm_routes = es8316_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(es8316_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config es8316_regmap = { @@ -592,16 +590,11 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client, if (IS_ERR(regmap)) return PTR_ERR(regmap); - return snd_soc_register_codec(&i2c_client->dev, &soc_codec_dev_es8316, + return devm_snd_soc_register_component(&i2c_client->dev, + &soc_component_dev_es8316, &es8316_dai, 1); } -static int es8316_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id es8316_i2c_id[] = { {"es8316", 0 }, {} @@ -627,7 +620,6 @@ static struct i2c_driver es8316_i2c_driver = { .of_match_table = of_match_ptr(es8316_of_match), }, .probe = es8316_i2c_probe, - .remove = es8316_i2c_remove, .id_table = es8316_i2c_id, }; module_i2c_driver(es8316_i2c_driver); From 02009eea07c8d7f277f12400ba7dc8524dbf9498 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:32:37 +0000 Subject: [PATCH 153/942] ASoC: es7134: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/es7134.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/es7134.c b/sound/soc/codecs/es7134.c index 3869025754d8..58515bb1a303 100644 --- a/sound/soc/codecs/es7134.c +++ b/sound/soc/codecs/es7134.c @@ -69,28 +69,24 @@ static const struct snd_soc_dapm_route es7134_dapm_routes[] = { { "AOUTR", NULL, "DAC" }, }; -static const struct snd_soc_codec_driver es7134_codec_driver = { - .component_driver = { - .dapm_widgets = es7134_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(es7134_dapm_widgets), - .dapm_routes = es7134_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(es7134_dapm_routes), - }, +static const struct snd_soc_component_driver es7134_component_driver = { + .dapm_widgets = es7134_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(es7134_dapm_widgets), + .dapm_routes = es7134_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(es7134_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int es7134_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &es7134_codec_driver, + return devm_snd_soc_register_component(&pdev->dev, + &es7134_component_driver, &es7134_dai, 1); } -static int es7134_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id es7134_ids[] = { { .compatible = "everest,es7134", }, @@ -106,7 +102,6 @@ static struct platform_driver es7134_driver = { .of_match_table = of_match_ptr(es7134_ids), }, .probe = es7134_probe, - .remove = es7134_remove, }; module_platform_driver(es7134_driver); From da4ce5607149ace4bb61af4a4910bab1dcf20a19 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:32:55 +0000 Subject: [PATCH 154/942] ASoC: es8328: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/es8328-i2c.c | 7 -- sound/soc/codecs/es8328-spi.c | 7 -- sound/soc/codecs/es8328.c | 147 +++++++++++++++++----------------- 3 files changed, 73 insertions(+), 88 deletions(-) diff --git a/sound/soc/codecs/es8328-i2c.c b/sound/soc/codecs/es8328-i2c.c index 318ab28c5351..19baa3260f85 100644 --- a/sound/soc/codecs/es8328-i2c.c +++ b/sound/soc/codecs/es8328-i2c.c @@ -39,19 +39,12 @@ static int es8328_i2c_probe(struct i2c_client *i2c, devm_regmap_init_i2c(i2c, &es8328_regmap_config)); } -static int es8328_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static struct i2c_driver es8328_i2c_driver = { .driver = { .name = "es8328", .of_match_table = es8328_of_match, }, .probe = es8328_i2c_probe, - .remove = es8328_i2c_remove, .id_table = es8328_id, }; diff --git a/sound/soc/codecs/es8328-spi.c b/sound/soc/codecs/es8328-spi.c index 8fbd935e1c76..d242bd1f7dcc 100644 --- a/sound/soc/codecs/es8328-spi.c +++ b/sound/soc/codecs/es8328-spi.c @@ -28,19 +28,12 @@ static int es8328_spi_probe(struct spi_device *spi) devm_regmap_init_spi(spi, &es8328_regmap_config)); } -static int es8328_spi_remove(struct spi_device *spi) -{ - snd_soc_unregister_codec(&spi->dev); - return 0; -} - static struct spi_driver es8328_spi_driver = { .driver = { .name = "es8328", .of_match_table = es8328_of_match, }, .probe = es8328_spi_probe, - .remove = es8328_spi_remove, }; module_spi_driver(es8328_spi_driver); diff --git a/sound/soc/codecs/es8328.c b/sound/soc/codecs/es8328.c index bcdb8914ec16..e9fc2fd97d2f 100644 --- a/sound/soc/codecs/es8328.c +++ b/sound/soc/codecs/es8328.c @@ -116,9 +116,9 @@ static const struct { { 48000, ES8328_DACCONTROL6_DEEMPH_48k }, }; -static int es8328_set_deemph(struct snd_soc_codec *codec) +static int es8328_set_deemph(struct snd_soc_component *component) { - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); int val, i, best; /* @@ -138,17 +138,17 @@ static int es8328_set_deemph(struct snd_soc_codec *codec) val = ES8328_DACCONTROL6_DEEMPH_OFF; } - dev_dbg(codec->dev, "Set deemphasis %d\n", val); + dev_dbg(component->dev, "Set deemphasis %d\n", val); - return snd_soc_update_bits(codec, ES8328_DACCONTROL6, + return snd_soc_component_update_bits(component, ES8328_DACCONTROL6, ES8328_DACCONTROL6_DEEMPH_MASK, val); } static int es8328_get_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = es8328->deemph; return 0; @@ -157,15 +157,15 @@ static int es8328_get_deemph(struct snd_kcontrol *kcontrol, static int es8328_put_deemph(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); unsigned int deemph = ucontrol->value.integer.value[0]; int ret; if (deemph > 1) return -EINVAL; - ret = es8328_set_deemph(codec); + ret = es8328_set_deemph(component); if (ret < 0) return ret; @@ -455,7 +455,7 @@ static const struct snd_soc_dapm_route es8328_dapm_routes[] = { static int es8328_mute(struct snd_soc_dai *dai, int mute) { - return snd_soc_update_bits(dai->codec, ES8328_DACCONTROL3, + return snd_soc_component_update_bits(dai->component, ES8328_DACCONTROL3, ES8328_DACCONTROL3_DACMUTE, mute ? ES8328_DACCONTROL3_DACMUTE : 0); } @@ -463,8 +463,8 @@ static int es8328_mute(struct snd_soc_dai *dai, int mute) static int es8328_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); if (es8328->master && es8328->sysclk_constraints) snd_pcm_hw_constraint_list(substream->runtime, 0, @@ -478,8 +478,8 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); int i; int reg; int wl; @@ -492,7 +492,7 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, if (es8328->master) { if (!es8328->sysclk_constraints) { - dev_err(codec->dev, "No MCLK configured\n"); + dev_err(component->dev, "No MCLK configured\n"); return -EINVAL; } @@ -502,7 +502,7 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, break; if (i == es8328->sysclk_constraints->count) { - dev_err(codec->dev, + dev_err(component->dev, "LRCLK %d unsupported with current clock\n", params_rate(params)); return -EINVAL; @@ -513,7 +513,7 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, es8328->mclkdiv2 = 0; } - snd_soc_update_bits(codec, ES8328_MASTERMODE, + snd_soc_component_update_bits(component, ES8328_MASTERMODE, ES8328_MASTERMODE_MCLKDIV2, es8328->mclkdiv2 ? ES8328_MASTERMODE_MCLKDIV2 : 0); @@ -538,25 +538,25 @@ static int es8328_hw_params(struct snd_pcm_substream *substream, } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - snd_soc_update_bits(codec, ES8328_DACCONTROL1, + snd_soc_component_update_bits(component, ES8328_DACCONTROL1, ES8328_DACCONTROL1_DACWL_MASK, wl << ES8328_DACCONTROL1_DACWL_SHIFT); es8328->playback_fs = params_rate(params); - es8328_set_deemph(codec); + es8328_set_deemph(component); } else - snd_soc_update_bits(codec, ES8328_ADCCONTROL4, + snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, ES8328_ADCCONTROL4_ADCWL_MASK, wl << ES8328_ADCCONTROL4_ADCWL_SHIFT); - return snd_soc_update_bits(codec, reg, ES8328_RATEMASK, ratio); + return snd_soc_component_update_bits(component, reg, ES8328_RATEMASK, ratio); } static int es8328_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); int mclkdiv2 = 0; switch (freq) { @@ -589,22 +589,22 @@ static int es8328_set_sysclk(struct snd_soc_dai *codec_dai, static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct es8328_priv *es8328 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct es8328_priv *es8328 = snd_soc_component_get_drvdata(component); u8 dac_mode = 0; u8 adc_mode = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: /* Master serial port mode, with BCLK generated automatically */ - snd_soc_update_bits(codec, ES8328_MASTERMODE, + snd_soc_component_update_bits(component, ES8328_MASTERMODE, ES8328_MASTERMODE_MSC, ES8328_MASTERMODE_MSC); es8328->master = true; break; case SND_SOC_DAIFMT_CBS_CFS: /* Slave serial port mode */ - snd_soc_update_bits(codec, ES8328_MASTERMODE, + snd_soc_component_update_bits(component, ES8328_MASTERMODE, ES8328_MASTERMODE_MSC, 0); es8328->master = false; break; @@ -634,15 +634,15 @@ static int es8328_set_dai_fmt(struct snd_soc_dai *codec_dai, if ((fmt & SND_SOC_DAIFMT_INV_MASK) != SND_SOC_DAIFMT_NB_NF) return -EINVAL; - snd_soc_update_bits(codec, ES8328_DACCONTROL1, + snd_soc_component_update_bits(component, ES8328_DACCONTROL1, ES8328_DACCONTROL1_DACFORMAT_MASK, dac_mode); - snd_soc_update_bits(codec, ES8328_ADCCONTROL4, + snd_soc_component_update_bits(component, ES8328_ADCCONTROL4, ES8328_ADCCONTROL4_ADCFORMAT_MASK, adc_mode); return 0; } -static int es8328_set_bias_level(struct snd_soc_codec *codec, +static int es8328_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -651,8 +651,8 @@ static int es8328_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: /* VREF, VMID=2x50k, digital enabled */ - snd_soc_write(codec, ES8328_CHIPPOWER, 0); - snd_soc_update_bits(codec, ES8328_CONTROL1, + snd_soc_component_write(component, ES8328_CHIPPOWER, 0); + snd_soc_component_update_bits(component, ES8328_CONTROL1, ES8328_CONTROL1_VMIDSEL_MASK | ES8328_CONTROL1_ENREF, ES8328_CONTROL1_VMIDSEL_50k | @@ -660,8 +660,8 @@ static int es8328_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, ES8328_CONTROL1, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, ES8328_CONTROL1, ES8328_CONTROL1_VMIDSEL_MASK | ES8328_CONTROL1_ENREF, ES8328_CONTROL1_VMIDSEL_5k | @@ -671,12 +671,12 @@ static int es8328_set_bias_level(struct snd_soc_codec *codec, msleep(100); } - snd_soc_write(codec, ES8328_CONTROL2, + snd_soc_component_write(component, ES8328_CONTROL2, ES8328_CONTROL2_OVERCURRENT_ON | ES8328_CONTROL2_THERMAL_SHUTDOWN_ON); /* VREF, VMID=2*500k, digital stopped */ - snd_soc_update_bits(codec, ES8328_CONTROL1, + snd_soc_component_update_bits(component, ES8328_CONTROL1, ES8328_CONTROL1_VMIDSEL_MASK | ES8328_CONTROL1_ENREF, ES8328_CONTROL1_VMIDSEL_500k | @@ -684,7 +684,7 @@ static int es8328_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, ES8328_CONTROL1, + snd_soc_component_update_bits(component, ES8328_CONTROL1, ES8328_CONTROL1_VMIDSEL_MASK | ES8328_CONTROL1_ENREF, 0); @@ -721,80 +721,80 @@ static struct snd_soc_dai_driver es8328_dai = { .symmetric_rates = 1, }; -static int es8328_suspend(struct snd_soc_codec *codec) +static int es8328_suspend(struct snd_soc_component *component) { struct es8328_priv *es8328; int ret; - es8328 = snd_soc_codec_get_drvdata(codec); + es8328 = snd_soc_component_get_drvdata(component); clk_disable_unprepare(es8328->clk); ret = regulator_bulk_disable(ARRAY_SIZE(es8328->supplies), es8328->supplies); if (ret) { - dev_err(codec->dev, "unable to disable regulators\n"); + dev_err(component->dev, "unable to disable regulators\n"); return ret; } return 0; } -static int es8328_resume(struct snd_soc_codec *codec) +static int es8328_resume(struct snd_soc_component *component) { - struct regmap *regmap = dev_get_regmap(codec->dev, NULL); + struct regmap *regmap = dev_get_regmap(component->dev, NULL); struct es8328_priv *es8328; int ret; - es8328 = snd_soc_codec_get_drvdata(codec); + es8328 = snd_soc_component_get_drvdata(component); ret = clk_prepare_enable(es8328->clk); if (ret) { - dev_err(codec->dev, "unable to enable clock\n"); + dev_err(component->dev, "unable to enable clock\n"); return ret; } ret = regulator_bulk_enable(ARRAY_SIZE(es8328->supplies), es8328->supplies); if (ret) { - dev_err(codec->dev, "unable to enable regulators\n"); + dev_err(component->dev, "unable to enable regulators\n"); return ret; } regcache_mark_dirty(regmap); ret = regcache_sync(regmap); if (ret) { - dev_err(codec->dev, "unable to sync regcache\n"); + dev_err(component->dev, "unable to sync regcache\n"); return ret; } return 0; } -static int es8328_codec_probe(struct snd_soc_codec *codec) +static int es8328_component_probe(struct snd_soc_component *component) { struct es8328_priv *es8328; int ret; - es8328 = snd_soc_codec_get_drvdata(codec); + es8328 = snd_soc_component_get_drvdata(component); ret = regulator_bulk_enable(ARRAY_SIZE(es8328->supplies), es8328->supplies); if (ret) { - dev_err(codec->dev, "unable to enable regulators\n"); + dev_err(component->dev, "unable to enable regulators\n"); return ret; } /* Setup clocks */ - es8328->clk = devm_clk_get(codec->dev, NULL); + es8328->clk = devm_clk_get(component->dev, NULL); if (IS_ERR(es8328->clk)) { - dev_err(codec->dev, "codec clock missing or invalid\n"); + dev_err(component->dev, "codec clock missing or invalid\n"); ret = PTR_ERR(es8328->clk); goto clk_fail; } ret = clk_prepare_enable(es8328->clk); if (ret) { - dev_err(codec->dev, "unable to prepare codec clk\n"); + dev_err(component->dev, "unable to prepare codec clk\n"); goto clk_fail; } @@ -806,19 +806,17 @@ clk_fail: return ret; } -static int es8328_remove(struct snd_soc_codec *codec) +static void es8328_remove(struct snd_soc_component *component) { struct es8328_priv *es8328; - es8328 = snd_soc_codec_get_drvdata(codec); + es8328 = snd_soc_component_get_drvdata(component); if (es8328->clk) clk_disable_unprepare(es8328->clk); regulator_bulk_disable(ARRAY_SIZE(es8328->supplies), es8328->supplies); - - return 0; } const struct regmap_config es8328_regmap_config = { @@ -830,22 +828,23 @@ const struct regmap_config es8328_regmap_config = { }; EXPORT_SYMBOL_GPL(es8328_regmap_config); -static const struct snd_soc_codec_driver es8328_codec_driver = { - .probe = es8328_codec_probe, - .suspend = es8328_suspend, - .resume = es8328_resume, - .remove = es8328_remove, - .set_bias_level = es8328_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = es8328_snd_controls, - .num_controls = ARRAY_SIZE(es8328_snd_controls), - .dapm_widgets = es8328_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(es8328_dapm_widgets), - .dapm_routes = es8328_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(es8328_dapm_routes), - }, +static const struct snd_soc_component_driver es8328_component_driver = { + .probe = es8328_component_probe, + .remove = es8328_remove, + .suspend = es8328_suspend, + .resume = es8328_resume, + .set_bias_level = es8328_set_bias_level, + .controls = es8328_snd_controls, + .num_controls = ARRAY_SIZE(es8328_snd_controls), + .dapm_widgets = es8328_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(es8328_dapm_widgets), + .dapm_routes = es8328_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(es8328_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; int es8328_probe(struct device *dev, struct regmap *regmap) @@ -875,8 +874,8 @@ int es8328_probe(struct device *dev, struct regmap *regmap) dev_set_drvdata(dev, es8328); - return snd_soc_register_codec(dev, - &es8328_codec_driver, &es8328_dai, 1); + return devm_snd_soc_register_component(dev, + &es8328_component_driver, &es8328_dai, 1); } EXPORT_SYMBOL_GPL(es8328_probe); From c778b7715f66c97f6b41077c72a16ad3553817ff Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:33:31 +0000 Subject: [PATCH 155/942] ASoC: alc5632: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/alc5632.c | 138 ++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 72 deletions(-) diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index adb80d8719bd..08034a6d4c5a 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c @@ -116,20 +116,20 @@ static inline int alc5632_reset(struct regmap *map) static int amp_mixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); /* to power-on/off class-d amp generators/speaker */ /* need to write to 'index-46h' register : */ /* so write index num (here 0x46) to reg 0x6a */ /* and then 0xffff/0 to reg 0x6c */ - snd_soc_write(codec, ALC5632_HID_CTRL_INDEX, 0x46); + snd_soc_component_write(component, ALC5632_HID_CTRL_INDEX, 0x46); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_write(codec, ALC5632_HID_CTRL_DATA, 0xFFFF); + snd_soc_component_write(component, ALC5632_HID_CTRL_DATA, 0xFFFF); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, ALC5632_HID_CTRL_DATA, 0); + snd_soc_component_write(component, ALC5632_HID_CTRL_DATA, 0); break; } @@ -681,7 +681,7 @@ static int alc5632_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { int i; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int gbl_clk = 0, pll_div = 0; u16 reg; @@ -689,15 +689,15 @@ static int alc5632_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, return -EINVAL; /* Disable PLL power */ - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_PWR_ADD2_PLL1, 0); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_PWR_ADD2_PLL2, 0); /* pll is not used in slave mode */ - reg = snd_soc_read(codec, ALC5632_DAI_CONTROL); + reg = snd_soc_component_read32(component, ALC5632_DAI_CONTROL); if (reg & ALC5632_DAI_SDP_SLAVE_MODE) return 0; @@ -745,19 +745,19 @@ static int alc5632_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, return -EINVAL; /* choose MCLK/BCLK/VBCLK */ - snd_soc_write(codec, ALC5632_GPCR2, gbl_clk); + snd_soc_component_write(component, ALC5632_GPCR2, gbl_clk); /* choose PLL1 clock rate */ - snd_soc_write(codec, ALC5632_PLL1_CTRL, pll_div); + snd_soc_component_write(component, ALC5632_PLL1_CTRL, pll_div); /* enable PLL1 */ - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_PWR_ADD2_PLL1, ALC5632_PWR_ADD2_PLL1); /* enable PLL2 */ - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_PWR_ADD2_PLL2, ALC5632_PWR_ADD2_PLL2); /* use PLL1 as main SYSCLK */ - snd_soc_update_bits(codec, ALC5632_GPCR1, + snd_soc_component_update_bits(component, ALC5632_GPCR1, ALC5632_GPCR1_CLK_SYS_SRC_SEL_PLL1, ALC5632_GPCR1_CLK_SYS_SRC_SEL_PLL1); @@ -775,9 +775,9 @@ static const struct _coeff_div coeff_div[] = { {512*1, 0x3075}, }; -static int get_coeff(struct snd_soc_codec *codec, int rate) +static int get_coeff(struct snd_soc_component *component, int rate) { - struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec); + struct alc5632_priv *alc5632 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { @@ -793,8 +793,8 @@ static int get_coeff(struct snd_soc_codec *codec, int rate) static int alc5632_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct alc5632_priv *alc5632 = snd_soc_component_get_drvdata(component); switch (freq) { case 4096000: @@ -815,7 +815,7 @@ static int alc5632_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int alc5632_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -864,17 +864,17 @@ static int alc5632_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - return snd_soc_write(codec, ALC5632_DAI_CONTROL, iface); + return snd_soc_component_write(component, ALC5632_DAI_CONTROL, iface); } static int alc5632_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int coeff, rate; u16 iface; - iface = snd_soc_read(codec, ALC5632_DAI_CONTROL); + iface = snd_soc_component_read32(component, ALC5632_DAI_CONTROL); iface &= ~ALC5632_DAI_I2S_DL_MASK; /* bit size */ @@ -893,29 +893,29 @@ static int alc5632_pcm_hw_params(struct snd_pcm_substream *substream, } /* set iface & srate */ - snd_soc_write(codec, ALC5632_DAI_CONTROL, iface); + snd_soc_component_write(component, ALC5632_DAI_CONTROL, iface); rate = params_rate(params); - coeff = get_coeff(codec, rate); + coeff = get_coeff(component, rate); if (coeff < 0) return -EINVAL; coeff = coeff_div[coeff].regvalue; - snd_soc_write(codec, ALC5632_DAC_CLK_CTRL1, coeff); + snd_soc_component_write(component, ALC5632_DAC_CLK_CTRL1, coeff); return 0; } static int alc5632_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 hp_mute = ALC5632_MISC_HP_DEPOP_MUTE_L |ALC5632_MISC_HP_DEPOP_MUTE_R; - u16 mute_reg = snd_soc_read(codec, ALC5632_MISC_CTRL) & ~hp_mute; + u16 mute_reg = snd_soc_component_read32(component, ALC5632_MISC_CTRL) & ~hp_mute; if (mute) mute_reg |= hp_mute; - return snd_soc_write(codec, ALC5632_MISC_CTRL, mute_reg); + return snd_soc_component_write(component, ALC5632_MISC_CTRL, mute_reg); } #define ALC5632_ADD2_POWER_EN (ALC5632_PWR_ADD2_VREF) @@ -929,73 +929,73 @@ static int alc5632_mute(struct snd_soc_dai *dai, int mute) | ALC5632_PWR_ADD1_HP_OUT_ENH_AMP \ | ALC5632_PWR_ADD1_MAIN_BIAS) -static void enable_power_depop(struct snd_soc_codec *codec) +static void enable_power_depop(struct snd_soc_component *component) { - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD1, ALC5632_PWR_ADD1_SOFTGEN_EN, ALC5632_PWR_ADD1_SOFTGEN_EN); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD3, ALC5632_ADD3_POWER_EN, ALC5632_ADD3_POWER_EN); - snd_soc_update_bits(codec, ALC5632_MISC_CTRL, + snd_soc_component_update_bits(component, ALC5632_MISC_CTRL, ALC5632_MISC_HP_DEPOP_MODE2_EN, ALC5632_MISC_HP_DEPOP_MODE2_EN); /* "normal" mode: 0 @ 26 */ /* set all PR0-7 mixers to 0 */ - snd_soc_update_bits(codec, ALC5632_PWR_DOWN_CTRL_STATUS, + snd_soc_component_update_bits(component, ALC5632_PWR_DOWN_CTRL_STATUS, ALC5632_PWR_DOWN_CTRL_STATUS_MASK, 0); msleep(500); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_ADD2_POWER_EN, ALC5632_ADD2_POWER_EN); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD1, ALC5632_ADD1_POWER_EN, ALC5632_ADD1_POWER_EN); /* disable HP Depop2 */ - snd_soc_update_bits(codec, ALC5632_MISC_CTRL, + snd_soc_component_update_bits(component, ALC5632_MISC_CTRL, ALC5632_MISC_HP_DEPOP_MODE2_EN, 0); } -static int alc5632_set_bias_level(struct snd_soc_codec *codec, +static int alc5632_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: - enable_power_depop(codec); + enable_power_depop(component); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: /* everything off except vref/vmid, */ - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD1, ALC5632_PWR_MANAG_ADD1_MASK, ALC5632_PWR_ADD1_MAIN_BIAS); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_PWR_MANAG_ADD2_MASK, ALC5632_PWR_ADD2_VREF); /* "normal" mode: 0 @ 26 */ - snd_soc_update_bits(codec, ALC5632_PWR_DOWN_CTRL_STATUS, + snd_soc_component_update_bits(component, ALC5632_PWR_DOWN_CTRL_STATUS, ALC5632_PWR_DOWN_CTRL_STATUS_MASK, 0xffff ^ (ALC5632_PWR_VREF_PR3 | ALC5632_PWR_VREF_PR2)); break; case SND_SOC_BIAS_OFF: /* everything off, dac mute, inactive */ - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD2, ALC5632_PWR_MANAG_ADD2_MASK, 0); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD3, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD3, ALC5632_PWR_MANAG_ADD3_MASK, 0); - snd_soc_update_bits(codec, ALC5632_PWR_MANAG_ADD1, + snd_soc_component_update_bits(component, ALC5632_PWR_MANAG_ADD1, ALC5632_PWR_MANAG_ADD1_MASK, 0); break; } @@ -1038,9 +1038,9 @@ static struct snd_soc_dai_driver alc5632_dai = { }; #ifdef CONFIG_PM -static int alc5632_resume(struct snd_soc_codec *codec) +static int alc5632_resume(struct snd_soc_component *component) { - struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec); + struct alc5632_priv *alc5632 = snd_soc_component_get_drvdata(component); regcache_sync(alc5632->regmap); @@ -1050,13 +1050,13 @@ static int alc5632_resume(struct snd_soc_codec *codec) #define alc5632_resume NULL #endif -static int alc5632_probe(struct snd_soc_codec *codec) +static int alc5632_probe(struct snd_soc_component *component) { - struct alc5632_priv *alc5632 = snd_soc_codec_get_drvdata(codec); + struct alc5632_priv *alc5632 = snd_soc_component_get_drvdata(component); switch (alc5632->id) { case 0x5c: - snd_soc_add_codec_controls(codec, alc5632_vol_snd_controls, + snd_soc_add_component_controls(component, alc5632_vol_snd_controls, ARRAY_SIZE(alc5632_vol_snd_controls)); break; default: @@ -1066,20 +1066,21 @@ static int alc5632_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_device_alc5632 = { - .probe = alc5632_probe, - .resume = alc5632_resume, - .set_bias_level = alc5632_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = alc5632_snd_controls, - .num_controls = ARRAY_SIZE(alc5632_snd_controls), - .dapm_widgets = alc5632_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(alc5632_dapm_widgets), - .dapm_routes = alc5632_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_device_alc5632 = { + .probe = alc5632_probe, + .resume = alc5632_resume, + .set_bias_level = alc5632_set_bias_level, + .controls = alc5632_snd_controls, + .num_controls = ARRAY_SIZE(alc5632_snd_controls), + .dapm_widgets = alc5632_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(alc5632_dapm_widgets), + .dapm_routes = alc5632_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(alc5632_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config alc5632_regmap = { @@ -1151,23 +1152,17 @@ static int alc5632_i2c_probe(struct i2c_client *client, return -EINVAL; } - ret = snd_soc_register_codec(&client->dev, - &soc_codec_device_alc5632, &alc5632_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_device_alc5632, &alc5632_dai, 1); if (ret < 0) { - dev_err(&client->dev, "Failed to register codec: %d\n", ret); + dev_err(&client->dev, "Failed to register component: %d\n", ret); return ret; } return ret; } -static int alc5632_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id alc5632_i2c_table[] = { {"alc5632", 0x5c}, {} @@ -1187,7 +1182,6 @@ static struct i2c_driver alc5632_i2c_driver = { .of_match_table = of_match_ptr(alc5632_of_match), }, .probe = alc5632_i2c_probe, - .remove = alc5632_i2c_remove, .id_table = alc5632_i2c_table, }; From fd7c728de88eaea0d740b0d92ef73bbe8527a55d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:34:01 +0000 Subject: [PATCH 156/942] ASoC: alc5623: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/alc5623.c | 147 ++++++++++++++++++------------------- 1 file changed, 72 insertions(+), 75 deletions(-) diff --git a/sound/soc/codecs/alc5623.c b/sound/soc/codecs/alc5623.c index 1db965a93632..981a32973c08 100644 --- a/sound/soc/codecs/alc5623.c +++ b/sound/soc/codecs/alc5623.c @@ -47,28 +47,28 @@ struct alc5623_priv { unsigned int jack_det_ctrl; }; -static inline int alc5623_reset(struct snd_soc_codec *codec) +static inline int alc5623_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, ALC5623_RESET, 0); + return snd_soc_component_write(component, ALC5623_RESET, 0); } static int amp_mixer_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); /* to power-on/off class-d amp generators/speaker */ /* need to write to 'index-46h' register : */ /* so write index num (here 0x46) to reg 0x6a */ /* and then 0xffff/0 to reg 0x6c */ - snd_soc_write(codec, ALC5623_HID_CTRL_INDEX, 0x46); + snd_soc_component_write(component, ALC5623_HID_CTRL_INDEX, 0x46); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0xFFFF); + snd_soc_component_write(component, ALC5623_HID_CTRL_DATA, 0xFFFF); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, ALC5623_HID_CTRL_DATA, 0); + snd_soc_component_write(component, ALC5623_HID_CTRL_DATA, 0); break; } @@ -526,7 +526,7 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { int i; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int gbl_clk = 0, pll_div = 0; u16 reg; @@ -534,12 +534,12 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, return -ENODEV; /* Disable PLL power */ - snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD2, + snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD2, ALC5623_PWR_ADD2_PLL, 0); /* pll is not used in slave mode */ - reg = snd_soc_read(codec, ALC5623_DAI_CONTROL); + reg = snd_soc_component_read32(component, ALC5623_DAI_CONTROL); if (reg & ALC5623_DAI_SDP_SLAVE_MODE) return 0; @@ -575,13 +575,13 @@ static int alc5623_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, if (!pll_div) return -EINVAL; - snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk); - snd_soc_write(codec, ALC5623_PLL_CTRL, pll_div); - snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD2, + snd_soc_component_write(component, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk); + snd_soc_component_write(component, ALC5623_PLL_CTRL, pll_div); + snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD2, ALC5623_PWR_ADD2_PLL, ALC5623_PWR_ADD2_PLL); gbl_clk |= ALC5623_GBL_CLK_SYS_SOUR_SEL_PLL; - snd_soc_write(codec, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk); + snd_soc_component_write(component, ALC5623_GLOBAL_CLK_CTRL_REG, gbl_clk); return 0; } @@ -604,9 +604,9 @@ static const struct _coeff_div coeff_div[] = { {384*1, 0x0c6b}, }; -static int get_coeff(struct snd_soc_codec *codec, int rate) +static int get_coeff(struct snd_soc_component *component, int rate) { - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < ARRAY_SIZE(coeff_div); i++) { @@ -622,8 +622,8 @@ static int get_coeff(struct snd_soc_codec *codec, int rate) static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); switch (freq) { case 8192000: @@ -643,7 +643,7 @@ static int alc5623_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 iface = 0; /* set master/slave audio interface */ @@ -695,18 +695,18 @@ static int alc5623_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - return snd_soc_write(codec, ALC5623_DAI_CONTROL, iface); + return snd_soc_component_write(component, ALC5623_DAI_CONTROL, iface); } static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); int coeff, rate; u16 iface; - iface = snd_soc_read(codec, ALC5623_DAI_CONTROL); + iface = snd_soc_component_read32(component, ALC5623_DAI_CONTROL); iface &= ~ALC5623_DAI_I2S_DL_MASK; /* bit size */ @@ -728,30 +728,30 @@ static int alc5623_pcm_hw_params(struct snd_pcm_substream *substream, } /* set iface & srate */ - snd_soc_write(codec, ALC5623_DAI_CONTROL, iface); + snd_soc_component_write(component, ALC5623_DAI_CONTROL, iface); rate = params_rate(params); - coeff = get_coeff(codec, rate); + coeff = get_coeff(component, rate); if (coeff < 0) return -EINVAL; coeff = coeff_div[coeff].regvalue; - dev_dbg(codec->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n", + dev_dbg(component->dev, "%s: sysclk=%d,rate=%d,coeff=0x%04x\n", __func__, alc5623->sysclk, rate, coeff); - snd_soc_write(codec, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff); + snd_soc_component_write(component, ALC5623_STEREO_AD_DA_CLK_CTRL, coeff); return 0; } static int alc5623_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 hp_mute = ALC5623_MISC_M_DAC_L_INPUT | ALC5623_MISC_M_DAC_R_INPUT; - u16 mute_reg = snd_soc_read(codec, ALC5623_MISC_CTRL) & ~hp_mute; + u16 mute_reg = snd_soc_component_read32(component, ALC5623_MISC_CTRL) & ~hp_mute; if (mute) mute_reg |= hp_mute; - return snd_soc_write(codec, ALC5623_MISC_CTRL, mute_reg); + return snd_soc_component_write(component, ALC5623_MISC_CTRL, mute_reg); } #define ALC5623_ADD2_POWER_EN (ALC5623_PWR_ADD2_VREF \ @@ -769,60 +769,60 @@ static int alc5623_mute(struct snd_soc_dai *dai, int mute) (ALC5623_PWR_ADD1_SHORT_CURR_DET_EN \ | ALC5623_PWR_ADD1_HP_OUT_AMP) -static void enable_power_depop(struct snd_soc_codec *codec) +static void enable_power_depop(struct snd_soc_component *component) { - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); - snd_soc_update_bits(codec, ALC5623_PWR_MANAG_ADD1, + snd_soc_component_update_bits(component, ALC5623_PWR_MANAG_ADD1, ALC5623_PWR_ADD1_SOFTGEN_EN, ALC5623_PWR_ADD1_SOFTGEN_EN); - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, ALC5623_ADD3_POWER_EN); + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, ALC5623_ADD3_POWER_EN); - snd_soc_update_bits(codec, ALC5623_MISC_CTRL, + snd_soc_component_update_bits(component, ALC5623_MISC_CTRL, ALC5623_MISC_HP_DEPOP_MODE2_EN, ALC5623_MISC_HP_DEPOP_MODE2_EN); msleep(500); - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, ALC5623_ADD2_POWER_EN); + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, ALC5623_ADD2_POWER_EN); /* avoid writing '1' into 5622 reserved bits */ if (alc5623->id == 0x22) - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1, ALC5623_ADD1_POWER_EN_5622); else - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1, ALC5623_ADD1_POWER_EN); /* disable HP Depop2 */ - snd_soc_update_bits(codec, ALC5623_MISC_CTRL, + snd_soc_component_update_bits(component, ALC5623_MISC_CTRL, ALC5623_MISC_HP_DEPOP_MODE2_EN, 0); } -static int alc5623_set_bias_level(struct snd_soc_codec *codec, +static int alc5623_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: - enable_power_depop(codec); + enable_power_depop(component); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: /* everything off except vref/vmid, */ - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, ALC5623_PWR_ADD2_VREF); - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, ALC5623_PWR_ADD3_MAIN_BIAS); break; case SND_SOC_BIAS_OFF: /* everything off, dac mute, inactive */ - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD2, 0); - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD3, 0); - snd_soc_write(codec, ALC5623_PWR_MANAG_ADD1, 0); + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD2, 0); + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD3, 0); + snd_soc_component_write(component, ALC5623_PWR_MANAG_ADD1, 0); break; } return 0; @@ -862,25 +862,25 @@ static struct snd_soc_dai_driver alc5623_dai = { .ops = &alc5623_dai_ops, }; -static int alc5623_suspend(struct snd_soc_codec *codec) +static int alc5623_suspend(struct snd_soc_component *component) { - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); regcache_cache_only(alc5623->regmap, true); return 0; } -static int alc5623_resume(struct snd_soc_codec *codec) +static int alc5623_resume(struct snd_soc_component *component) { - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); int ret; /* Sync reg_cache with the hardware */ regcache_cache_only(alc5623->regmap, false); ret = regcache_sync(alc5623->regmap); if (ret != 0) { - dev_err(codec->dev, "Failed to sync register cache: %d\n", + dev_err(component->dev, "Failed to sync register cache: %d\n", ret); regcache_cache_only(alc5623->regmap, true); return ret; @@ -889,41 +889,41 @@ static int alc5623_resume(struct snd_soc_codec *codec) return 0; } -static int alc5623_probe(struct snd_soc_codec *codec) +static int alc5623_probe(struct snd_soc_component *component) { - struct alc5623_priv *alc5623 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct alc5623_priv *alc5623 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - alc5623_reset(codec); + alc5623_reset(component); if (alc5623->add_ctrl) { - snd_soc_write(codec, ALC5623_ADD_CTRL_REG, + snd_soc_component_write(component, ALC5623_ADD_CTRL_REG, alc5623->add_ctrl); } if (alc5623->jack_det_ctrl) { - snd_soc_write(codec, ALC5623_JACK_DET_CTRL, + snd_soc_component_write(component, ALC5623_JACK_DET_CTRL, alc5623->jack_det_ctrl); } switch (alc5623->id) { case 0x21: - snd_soc_add_codec_controls(codec, alc5621_vol_snd_controls, + snd_soc_add_component_controls(component, alc5621_vol_snd_controls, ARRAY_SIZE(alc5621_vol_snd_controls)); break; case 0x22: - snd_soc_add_codec_controls(codec, alc5622_vol_snd_controls, + snd_soc_add_component_controls(component, alc5622_vol_snd_controls, ARRAY_SIZE(alc5622_vol_snd_controls)); break; case 0x23: - snd_soc_add_codec_controls(codec, alc5623_vol_snd_controls, + snd_soc_add_component_controls(component, alc5623_vol_snd_controls, ARRAY_SIZE(alc5623_vol_snd_controls)); break; default: return -EINVAL; } - snd_soc_add_codec_controls(codec, alc5623_snd_controls, + snd_soc_add_component_controls(component, alc5623_snd_controls, ARRAY_SIZE(alc5623_snd_controls)); snd_soc_dapm_new_controls(dapm, alc5623_dapm_widgets, @@ -951,12 +951,16 @@ static int alc5623_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_device_alc5623 = { - .probe = alc5623_probe, - .suspend = alc5623_suspend, - .resume = alc5623_resume, - .set_bias_level = alc5623_set_bias_level, - .suspend_bias_off = true, +static const struct snd_soc_component_driver soc_component_device_alc5623 = { + .probe = alc5623_probe, + .suspend = alc5623_suspend, + .resume = alc5623_resume, + .set_bias_level = alc5623_set_bias_level, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config alc5623_regmap = { @@ -1052,20 +1056,14 @@ static int alc5623_i2c_probe(struct i2c_client *client, i2c_set_clientdata(client, alc5623); - ret = snd_soc_register_codec(&client->dev, - &soc_codec_device_alc5623, &alc5623_dai, 1); + ret = devm_snd_soc_register_component(&client->dev, + &soc_component_device_alc5623, &alc5623_dai, 1); if (ret != 0) dev_err(&client->dev, "Failed to register codec: %d\n", ret); return ret; } -static int alc5623_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id alc5623_i2c_table[] = { {"alc5621", 0x21}, {"alc5622", 0x22}, @@ -1087,7 +1085,6 @@ static struct i2c_driver alc5623_i2c_driver = { .of_match_table = of_match_ptr(alc5623_of_match), }, .probe = alc5623_i2c_probe, - .remove = alc5623_i2c_remove, .id_table = alc5623_i2c_table, }; From d20aa608f4244868139b0a25a8afc89c5a6bf422 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:34:21 +0000 Subject: [PATCH 157/942] ASoC: hdmi-codec: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 5672e516bec3..42df579cb507 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -730,14 +730,16 @@ static int hdmi_of_xlate_dai_id(struct snd_soc_component *component, return ret; } -static const struct snd_soc_codec_driver hdmi_codec = { - .component_driver = { - .dapm_widgets = hdmi_widgets, - .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), - .dapm_routes = hdmi_routes, - .num_dapm_routes = ARRAY_SIZE(hdmi_routes), - .of_xlate_dai_id = hdmi_of_xlate_dai_id, - }, +static const struct snd_soc_component_driver hdmi_driver = { + .dapm_widgets = hdmi_widgets, + .num_dapm_widgets = ARRAY_SIZE(hdmi_widgets), + .dapm_routes = hdmi_routes, + .num_dapm_routes = ARRAY_SIZE(hdmi_routes), + .of_xlate_dai_id = hdmi_of_xlate_dai_id, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int hdmi_codec_probe(struct platform_device *pdev) @@ -784,10 +786,10 @@ static int hdmi_codec_probe(struct platform_device *pdev) if (hcd->spdif) hcp->daidrv[i] = hdmi_spdif_dai; - ret = snd_soc_register_codec(dev, &hdmi_codec, hcp->daidrv, + ret = devm_snd_soc_register_component(dev, &hdmi_driver, hcp->daidrv, dai_count); if (ret) { - dev_err(dev, "%s: snd_soc_register_codec() failed (%d)\n", + dev_err(dev, "%s: snd_soc_register_component() failed (%d)\n", __func__, ret); return ret; } @@ -803,7 +805,6 @@ static int hdmi_codec_remove(struct platform_device *pdev) hcp = dev_get_drvdata(dev); kfree(hcp->chmap_info); - snd_soc_unregister_codec(dev); return 0; } From 90e678d2e1a50b913f23a897851caa3d190690b1 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:34:42 +0000 Subject: [PATCH 158/942] ASoC: bt-sco: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/bt-sco.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/bt-sco.c b/sound/soc/codecs/bt-sco.c index 806191addb44..842204203eb3 100644 --- a/sound/soc/codecs/bt-sco.c +++ b/sound/soc/codecs/bt-sco.c @@ -62,25 +62,26 @@ static struct snd_soc_dai_driver bt_sco_dai[] = { } }; -static const struct snd_soc_codec_driver soc_codec_dev_bt_sco = { - .component_driver = { - .dapm_widgets = bt_sco_widgets, - .num_dapm_widgets = ARRAY_SIZE(bt_sco_widgets), - .dapm_routes = bt_sco_routes, - .num_dapm_routes = ARRAY_SIZE(bt_sco_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_bt_sco = { + .dapm_widgets = bt_sco_widgets, + .num_dapm_widgets = ARRAY_SIZE(bt_sco_widgets), + .dapm_routes = bt_sco_routes, + .num_dapm_routes = ARRAY_SIZE(bt_sco_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int bt_sco_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_bt_sco, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_bt_sco, bt_sco_dai, ARRAY_SIZE(bt_sco_dai)); } static int bt_sco_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); - return 0; } From 635b1c185ee9cae61a740264d09095a7d20c019a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:35:04 +0000 Subject: [PATCH 159/942] ASoC: vc4_hdmi: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- drivers/gpu/drm/vc4/vc4_hdmi.c | 47 +++++++++++----------------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 984501e3f0b0..b92c6603c7a2 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -995,15 +995,17 @@ static const struct snd_soc_dapm_route vc4_hdmi_audio_routes[] = { { "TX", NULL, "Playback" }, }; -static const struct snd_soc_codec_driver vc4_hdmi_audio_codec_drv = { - .component_driver = { - .controls = vc4_hdmi_audio_controls, - .num_controls = ARRAY_SIZE(vc4_hdmi_audio_controls), - .dapm_widgets = vc4_hdmi_audio_widgets, - .num_dapm_widgets = ARRAY_SIZE(vc4_hdmi_audio_widgets), - .dapm_routes = vc4_hdmi_audio_routes, - .num_dapm_routes = ARRAY_SIZE(vc4_hdmi_audio_routes), - }, +static const struct snd_soc_component_driver vc4_hdmi_audio_component_drv = { + .controls = vc4_hdmi_audio_controls, + .num_controls = ARRAY_SIZE(vc4_hdmi_audio_controls), + .dapm_widgets = vc4_hdmi_audio_widgets, + .num_dapm_widgets = ARRAY_SIZE(vc4_hdmi_audio_widgets), + .dapm_routes = vc4_hdmi_audio_routes, + .num_dapm_routes = ARRAY_SIZE(vc4_hdmi_audio_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct snd_soc_dai_ops vc4_hdmi_audio_dai_ops = { @@ -1101,11 +1103,11 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi) return ret; } - /* register codec and codec dai */ - ret = snd_soc_register_codec(dev, &vc4_hdmi_audio_codec_drv, + /* register component and codec dai */ + ret = devm_snd_soc_register_component(dev, &vc4_hdmi_audio_component_drv, &vc4_hdmi_audio_codec_dai_drv, 1); if (ret) { - dev_err(dev, "Could not register codec: %d\n", ret); + dev_err(dev, "Could not register component: %d\n", ret); return ret; } @@ -1130,29 +1132,11 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi) */ snd_soc_card_set_drvdata(card, hdmi); ret = devm_snd_soc_register_card(dev, card); - if (ret) { + if (ret) dev_err(dev, "Could not register sound card: %d\n", ret); - goto unregister_codec; - } - - return 0; - -unregister_codec: - snd_soc_unregister_codec(dev); return ret; -} -static void vc4_hdmi_audio_cleanup(struct vc4_hdmi *hdmi) -{ - struct device *dev = &hdmi->pdev->dev; - - /* - * If drvdata is not set this means the audio card was not - * registered, just skip codec unregistration in this case. - */ - if (dev_get_drvdata(dev)) - snd_soc_unregister_codec(dev); } #ifdef CONFIG_DRM_VC4_HDMI_CEC @@ -1480,7 +1464,6 @@ static void vc4_hdmi_unbind(struct device *dev, struct device *master, struct vc4_dev *vc4 = drm->dev_private; struct vc4_hdmi *hdmi = vc4->hdmi; - vc4_hdmi_audio_cleanup(hdmi); cec_unregister_adapter(hdmi->cec_adap); vc4_hdmi_connector_destroy(hdmi->connector); vc4_hdmi_encoder_destroy(hdmi->encoder); From 755d440bcfdf5ff38a14a326d6dd78126466ef1f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:35:34 +0000 Subject: [PATCH 160/942] ASoC: zx_aud96p22: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/zx_aud96p22.c | 35 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/zx_aud96p22.c b/sound/soc/codecs/zx_aud96p22.c index ca1932d13738..7a2d6eaf1786 100644 --- a/sound/soc/codecs/zx_aud96p22.c +++ b/sound/soc/codecs/zx_aud96p22.c @@ -57,8 +57,8 @@ struct aud96p22_priv { static int aud96p22_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aud96p22_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct aud96p22_priv *priv = snd_soc_component_get_drvdata(component); struct regmap *regmap = priv->regmap; if (event != SND_SOC_DAPM_POST_PMU) @@ -74,8 +74,8 @@ static int aud96p22_adc_event(struct snd_soc_dapm_widget *w, static int aud96p22_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct aud96p22_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct aud96p22_priv *priv = snd_soc_component_get_drvdata(component); struct regmap *regmap = priv->regmap; if (event != SND_SOC_DAPM_POST_PMU) @@ -261,20 +261,22 @@ static const struct snd_soc_dapm_route aud96p22_dapm_routes[] = { { "LINEOUTMN", NULL, "LD2" }, }; -static const struct snd_soc_codec_driver aud96p22_driver = { - .component_driver = { - .controls = aud96p22_snd_controls, - .num_controls = ARRAY_SIZE(aud96p22_snd_controls), - .dapm_widgets = aud96p22_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(aud96p22_dapm_widgets), - .dapm_routes = aud96p22_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(aud96p22_dapm_routes), - }, +static const struct snd_soc_component_driver aud96p22_driver = { + .controls = aud96p22_snd_controls, + .num_controls = ARRAY_SIZE(aud96p22_snd_controls), + .dapm_widgets = aud96p22_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(aud96p22_dapm_widgets), + .dapm_routes = aud96p22_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(aud96p22_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int aud96p22_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct aud96p22_priv *priv = snd_soc_codec_get_drvdata(dai->codec); + struct aud96p22_priv *priv = snd_soc_component_get_drvdata(dai->component); struct regmap *regmap = priv->regmap; unsigned int val; @@ -367,9 +369,9 @@ static int aud96p22_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, priv); - ret = snd_soc_register_codec(dev, &aud96p22_driver, &aud96p22_dai, 1); + ret = devm_snd_soc_register_component(dev, &aud96p22_driver, &aud96p22_dai, 1); if (ret) { - dev_err(dev, "failed to register codec: %d\n", ret); + dev_err(dev, "failed to register component: %d\n", ret); return ret; } @@ -378,7 +380,6 @@ static int aud96p22_i2c_probe(struct i2c_client *i2c, static int aud96p22_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); return 0; } From 559ab3977633e5822712c6f44bd06e7f3200f9fe Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:36:21 +0000 Subject: [PATCH 161/942] ASoC: wl1273: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wl1273.c | 93 +++++++++++++++++++-------------------- sound/soc/codecs/wl1273.h | 2 +- 2 files changed, 47 insertions(+), 48 deletions(-) diff --git a/sound/soc/codecs/wl1273.c b/sound/soc/codecs/wl1273.c index 942f1644973e..929ef1fdbb69 100644 --- a/sound/soc/codecs/wl1273.c +++ b/sound/soc/codecs/wl1273.c @@ -172,8 +172,8 @@ out: static int snd_wl1273_get_audio_route(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wl1273->mode; @@ -190,14 +190,14 @@ static const char * const wl1273_audio_route[] = { "Bt", "FmRx", "FmTx" }; static int snd_wl1273_set_audio_route(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); if (wl1273->mode == ucontrol->value.enumerated.item[0]) return 0; /* Do not allow changes while stream is running */ - if (snd_soc_codec_is_active(codec)) + if (snd_soc_component_is_active(component)) return -EPERM; if (ucontrol->value.enumerated.item[0] >= ARRAY_SIZE(wl1273_audio_route)) @@ -213,10 +213,10 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_enum, wl1273_audio_route); static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: enter.\n", __func__); + dev_dbg(component->dev, "%s: enter.\n", __func__); ucontrol->value.enumerated.item[0] = wl1273->core->audio_mode; @@ -226,11 +226,11 @@ static int snd_wl1273_fm_audio_get(struct snd_kcontrol *kcontrol, static int snd_wl1273_fm_audio_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); int val, r = 0; - dev_dbg(codec->dev, "%s: enter.\n", __func__); + dev_dbg(component->dev, "%s: enter.\n", __func__); val = ucontrol->value.enumerated.item[0]; if (wl1273->core->audio_mode == val) @@ -250,10 +250,10 @@ static SOC_ENUM_SINGLE_EXT_DECL(wl1273_audio_enum, wl1273_audio_strings); static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s: enter.\n", __func__); + dev_dbg(component->dev, "%s: enter.\n", __func__); ucontrol->value.integer.value[0] = wl1273->core->volume; @@ -263,11 +263,11 @@ static int snd_wl1273_fm_volume_get(struct snd_kcontrol *kcontrol, static int snd_wl1273_fm_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); int r; - dev_dbg(codec->dev, "%s: enter.\n", __func__); + dev_dbg(component->dev, "%s: enter.\n", __func__); r = wl1273->core->set_volume(wl1273->core, ucontrol->value.integer.value[0]); @@ -301,8 +301,8 @@ static const struct snd_soc_dapm_route wl1273_dapm_routes[] = { static int wl1273_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); switch (wl1273->mode) { case WL1273_MODE_BT: @@ -335,7 +335,7 @@ static int wl1273_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(dai->codec); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(dai->component); struct wl1273_core *core = wl1273->core; unsigned int rate, width, r; @@ -415,14 +415,14 @@ static struct snd_soc_dai_driver wl1273_dai = { }; /* Audio interface format for the soc_card driver */ -int wl1273_get_format(struct snd_soc_codec *codec, unsigned int *fmt) +int wl1273_get_format(struct snd_soc_component *component, unsigned int *fmt) { struct wl1273_priv *wl1273; - if (codec == NULL || fmt == NULL) + if (component == NULL || fmt == NULL) return -EINVAL; - wl1273 = snd_soc_codec_get_drvdata(codec); + wl1273 = snd_soc_component_get_drvdata(component); switch (wl1273->mode) { case WL1273_MODE_FM_RX: @@ -446,15 +446,15 @@ int wl1273_get_format(struct snd_soc_codec *codec, unsigned int *fmt) } EXPORT_SYMBOL_GPL(wl1273_get_format); -static int wl1273_probe(struct snd_soc_codec *codec) +static int wl1273_probe(struct snd_soc_component *component) { - struct wl1273_core **core = codec->dev->platform_data; + struct wl1273_core **core = component->dev->platform_data; struct wl1273_priv *wl1273; - dev_dbg(codec->dev, "%s.\n", __func__); + dev_dbg(component->dev, "%s.\n", __func__); if (!core) { - dev_err(codec->dev, "Platform data is missing.\n"); + dev_err(component->dev, "Platform data is missing.\n"); return -EINVAL; } @@ -465,44 +465,43 @@ static int wl1273_probe(struct snd_soc_codec *codec) wl1273->mode = WL1273_MODE_BT; wl1273->core = *core; - snd_soc_codec_set_drvdata(codec, wl1273); + snd_soc_component_set_drvdata(component, wl1273); return 0; } -static int wl1273_remove(struct snd_soc_codec *codec) +static void wl1273_remove(struct snd_soc_component *component) { - struct wl1273_priv *wl1273 = snd_soc_codec_get_drvdata(codec); + struct wl1273_priv *wl1273 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s\n", __func__); + dev_dbg(component->dev, "%s\n", __func__); kfree(wl1273); - - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wl1273 = { - .probe = wl1273_probe, - .remove = wl1273_remove, - - .component_driver = { - .controls = wl1273_controls, - .num_controls = ARRAY_SIZE(wl1273_controls), - .dapm_widgets = wl1273_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wl1273_dapm_widgets), - .dapm_routes = wl1273_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wl1273_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wl1273 = { + .probe = wl1273_probe, + .remove = wl1273_remove, + .controls = wl1273_controls, + .num_controls = ARRAY_SIZE(wl1273_controls), + .dapm_widgets = wl1273_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wl1273_dapm_widgets), + .dapm_routes = wl1273_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wl1273_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wl1273_platform_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wl1273, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wl1273, &wl1273_dai, 1); } static int wl1273_platform_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } diff --git a/sound/soc/codecs/wl1273.h b/sound/soc/codecs/wl1273.h index 43ec7e668c51..43a81d5cab4d 100644 --- a/sound/soc/codecs/wl1273.h +++ b/sound/soc/codecs/wl1273.h @@ -25,6 +25,6 @@ #ifndef __WL1273_CODEC_H__ #define __WL1273_CODEC_H__ -int wl1273_get_format(struct snd_soc_codec *codec, unsigned int *fmt); +int wl1273_get_format(struct snd_soc_component *component, unsigned int *fmt); #endif /* End of __WL1273_CODEC_H__ */ From 78c97ec04b108d3fff70526e6bdb5bc2ebebe4bd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:37:36 +0000 Subject: [PATCH 162/942] ASoC: mc13783: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/mc13783.c | 68 ++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index be7a45f05bbf..7b0d2610cd27 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c @@ -107,13 +107,13 @@ static int mc13783_pcm_hw_params_dac(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int rate = params_rate(params); int i; for (i = 0; i < ARRAY_SIZE(mc13783_rates); i++) { if (rate == mc13783_rates[i]) { - snd_soc_update_bits(codec, MC13783_AUDIO_DAC, + snd_soc_component_update_bits(component, MC13783_AUDIO_DAC, 0xf << 17, i << 17); return 0; } @@ -126,7 +126,7 @@ static int mc13783_pcm_hw_params_codec(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int rate = params_rate(params); unsigned int val; @@ -141,7 +141,7 @@ static int mc13783_pcm_hw_params_codec(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, MC13783_AUDIO_CODEC, AUDIO_CODEC_CDCFS8K16K, + snd_soc_component_update_bits(component, MC13783_AUDIO_CODEC, AUDIO_CODEC_CDCFS8K16K, val); return 0; @@ -160,7 +160,7 @@ static int mc13783_pcm_hw_params_sync(struct snd_pcm_substream *substream, static int mc13783_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, unsigned int reg) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; unsigned int mask = AUDIO_CFS(3) | AUDIO_BCL_INV | AUDIO_CFS_INV | AUDIO_CSM | AUDIO_C_CLK_EN | AUDIO_C_RESET; @@ -208,7 +208,7 @@ static int mc13783_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, val |= AUDIO_C_RESET; - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); return 0; } @@ -255,7 +255,7 @@ static int mc13783_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir, unsigned int reg) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int clk; unsigned int val = 0; unsigned int mask = AUDIO_CLK(0x7) | AUDIO_CLK_SEL; @@ -275,7 +275,7 @@ static int mc13783_set_sysclk(struct snd_soc_dai *dai, val |= AUDIO_CLK(clk); - snd_soc_update_bits(codec, reg, mask, val); + snd_soc_component_update_bits(component, reg, mask, val); return 0; } @@ -308,7 +308,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; unsigned int mask = SSI_NETWORK_DAC_SLOT_MASK | SSI_NETWORK_DAC_RXSLOT_MASK; @@ -344,7 +344,7 @@ static int mc13783_set_tdm_slot_dac(struct snd_soc_dai *dai, return -EINVAL; } - snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); + snd_soc_component_update_bits(component, MC13783_SSI_NETWORK, mask, val); return 0; } @@ -353,7 +353,7 @@ static int mc13783_set_tdm_slot_codec(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val = 0; unsigned int mask = 0x3f; @@ -366,7 +366,7 @@ static int mc13783_set_tdm_slot_codec(struct snd_soc_dai *dai, val |= (0x00 << 2); /* primary timeslot RX/TX(?) is 0 */ val |= (0x01 << 4); /* secondary timeslot TX is 1 */ - snd_soc_update_bits(codec, MC13783_SSI_NETWORK, mask, val); + snd_soc_component_update_bits(component, MC13783_SSI_NETWORK, mask, val); return 0; } @@ -606,12 +606,12 @@ static struct snd_kcontrol_new mc13783_control_list[] = { SOC_SINGLE("MC2 Capture Bias Switch", MC13783_AUDIO_TX, 1, 1, 0), }; -static int mc13783_probe(struct snd_soc_codec *codec) +static int mc13783_probe(struct snd_soc_component *component) { - struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + struct mc13783_priv *priv = snd_soc_component_get_drvdata(component); - snd_soc_codec_init_regmap(codec, - dev_get_regmap(codec->dev->parent, NULL)); + snd_soc_component_init_regmap(component, + dev_get_regmap(component->dev->parent, NULL)); /* these are the reset values */ mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); @@ -638,14 +638,12 @@ static int mc13783_probe(struct snd_soc_codec *codec) return 0; } -static int mc13783_remove(struct snd_soc_codec *codec) +static void mc13783_remove(struct snd_soc_component *component) { - struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); + struct mc13783_priv *priv = snd_soc_component_get_drvdata(component); /* Make sure VAUDIOON is off */ mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0); - - return 0; } #define MC13783_RATES_RECORD (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000) @@ -731,17 +729,19 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { } }; -static const struct snd_soc_codec_driver soc_codec_dev_mc13783 = { - .probe = mc13783_probe, - .remove = mc13783_remove, - .component_driver = { - .controls = mc13783_control_list, - .num_controls = ARRAY_SIZE(mc13783_control_list), - .dapm_widgets = mc13783_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(mc13783_dapm_widgets), - .dapm_routes = mc13783_routes, - .num_dapm_routes = ARRAY_SIZE(mc13783_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_mc13783 = { + .probe = mc13783_probe, + .remove = mc13783_remove, + .controls = mc13783_control_list, + .num_controls = ARRAY_SIZE(mc13783_control_list), + .dapm_widgets = mc13783_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(mc13783_dapm_widgets), + .dapm_routes = mc13783_routes, + .num_dapm_routes = ARRAY_SIZE(mc13783_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int __init mc13783_codec_probe(struct platform_device *pdev) @@ -782,10 +782,10 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) priv->mc13xxx = dev_get_drvdata(pdev->dev.parent); if (priv->adc_ssi_port == priv->dac_ssi_port) - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, + ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_mc13783, mc13783_dai_sync, ARRAY_SIZE(mc13783_dai_sync)); else - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, + ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_mc13783, mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async)); return ret; @@ -793,8 +793,6 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) static int mc13783_codec_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); - return 0; } From 2f8b31880008c3c2f8401fe5de51288456db9c1a Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:37:53 +0000 Subject: [PATCH 163/942] ASoC: sgtl5000: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/sgtl5000.c | 173 +++++++++++++++++------------------- 1 file changed, 84 insertions(+), 89 deletions(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index e1ab5537d27a..c26ac224f39c 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -147,19 +147,19 @@ struct sgtl5000_priv { static int mic_bias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: /* change mic bias resistor */ - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, 0); break; } @@ -174,12 +174,12 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, static int power_vag_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP; switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP); msleep(400); break; @@ -190,9 +190,9 @@ static int power_vag_event(struct snd_soc_dapm_widget *w, * operational to prevent inadvertently starving the * other one of them. */ - if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) & + if ((snd_soc_component_read32(component, SGTL5000_CHIP_ANA_POWER) & mask) != mask) { - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_VAG_POWERUP, 0); msleep(400); } @@ -318,12 +318,12 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol, static int dac_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int reg; int l; int r; - reg = snd_soc_read(codec, SGTL5000_CHIP_DAC_VOL); + reg = snd_soc_component_read32(component, SGTL5000_CHIP_DAC_VOL); /* get left channel volume */ l = (reg & SGTL5000_DAC_VOL_LEFT_MASK) >> SGTL5000_DAC_VOL_LEFT_SHIFT; @@ -371,7 +371,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol, static int dac_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int reg; int l; int r; @@ -391,7 +391,7 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol, reg = l << SGTL5000_DAC_VOL_LEFT_SHIFT | r << SGTL5000_DAC_VOL_RIGHT_SHIFT; - snd_soc_write(codec, SGTL5000_CHIP_DAC_VOL, reg); + snd_soc_component_write(component, SGTL5000_CHIP_DAC_VOL, reg); return 0; } @@ -409,9 +409,9 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol, static int avc_get_threshold(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int db, i; - u16 reg = snd_soc_read(codec, SGTL5000_DAP_AVC_THRESHOLD); + u16 reg = snd_soc_component_read32(component, SGTL5000_DAP_AVC_THRESHOLD); /* register value 0 => -96dB */ if (!reg) { @@ -442,7 +442,7 @@ static int avc_get_threshold(struct snd_kcontrol *kcontrol, static int avc_put_threshold(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int db; u16 reg; @@ -450,7 +450,7 @@ static int avc_put_threshold(struct snd_kcontrol *kcontrol, if (db < 0 || db > 96) return -EINVAL; reg = avc_thr_db2reg[db]; - snd_soc_write(codec, SGTL5000_DAP_AVC_THRESHOLD, reg); + snd_soc_component_write(component, SGTL5000_DAP_AVC_THRESHOLD, reg); return 0; } @@ -528,10 +528,10 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = { /* mute the codec used by alsa core */ static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 adcdac_ctrl = SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT; - snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ADCDAC_CTRL, adcdac_ctrl, mute ? adcdac_ctrl : 0); return 0; @@ -540,8 +540,8 @@ static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute) /* set codec format */ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); u16 i2sctl = 0; sgtl5000->master = 0; @@ -599,7 +599,7 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_write(codec, SGTL5000_CHIP_I2S_CTRL, i2sctl); + snd_soc_component_write(component, SGTL5000_CHIP_I2S_CTRL, i2sctl); return 0; } @@ -608,8 +608,8 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); switch (clk_id) { case SGTL5000_SYSCLK: @@ -635,9 +635,9 @@ static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai, * and above. * 3. usage of sys_mclk is preferred over pll to save power. */ -static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) +static int sgtl5000_set_clock(struct snd_soc_component *component, int frame_rate) { - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); int clk_ctl = 0; int sys_fs; /* sample freq */ @@ -690,7 +690,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) clk_ctl |= SGTL5000_SYS_FS_96k << SGTL5000_SYS_FS_SHIFT; break; default: - dev_err(codec->dev, "frame rate %d not supported\n", + dev_err(component->dev, "frame rate %d not supported\n", frame_rate); return -EINVAL; } @@ -719,9 +719,9 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) clk_ctl |= SGTL5000_MCLK_FREQ_PLL << SGTL5000_MCLK_FREQ_SHIFT; } else { - dev_err(codec->dev, + dev_err(component->dev, "PLL not supported in slave mode\n"); - dev_err(codec->dev, "%d ratio is not supported. " + dev_err(component->dev, "%d ratio is not supported. " "SYS_MCLK needs to be 256, 384 or 512 * fs\n", sgtl5000->sysclk / frame_rate); return -EINVAL; @@ -754,31 +754,31 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate) pll_ctl = int_div << SGTL5000_PLL_INT_DIV_SHIFT | frac_div << SGTL5000_PLL_FRAC_DIV_SHIFT; - snd_soc_write(codec, SGTL5000_CHIP_PLL_CTRL, pll_ctl); + snd_soc_component_write(component, SGTL5000_CHIP_PLL_CTRL, pll_ctl); if (div2) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL, SGTL5000_INPUT_FREQ_DIV2, SGTL5000_INPUT_FREQ_DIV2); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL, SGTL5000_INPUT_FREQ_DIV2, 0); /* power up pll */ - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP, SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP); /* if using pll, clk_ctrl must be set after pll power up */ - snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl); + snd_soc_component_write(component, SGTL5000_CHIP_CLK_CTRL, clk_ctl); } else { /* otherwise, clk_ctrl must be set before pll power down */ - snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl); + snd_soc_component_write(component, SGTL5000_CHIP_CLK_CTRL, clk_ctl); /* power down pll */ - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP, 0); } @@ -794,8 +794,8 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); int channels = params_channels(params); int i2s_ctl = 0; int stereo; @@ -803,7 +803,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, /* sysclk should already set */ if (!sgtl5000->sysclk) { - dev_err(codec->dev, "%s: set sysclk first!\n", __func__); + dev_err(component->dev, "%s: set sysclk first!\n", __func__); return -EFAULT; } @@ -813,11 +813,11 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, stereo = SGTL5000_ADC_STEREO; /* set mono to save power */ - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, stereo, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, stereo, channels == 1 ? 0 : stereo); /* set codec clock base on lrclk */ - ret = sgtl5000_set_clock(codec, params_rate(params)); + ret = sgtl5000_set_clock(component, params_rate(params)); if (ret) return ret; @@ -851,7 +851,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, SGTL5000_CHIP_I2S_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_I2S_CTRL, SGTL5000_I2S_DLEN_MASK | SGTL5000_I2S_SCLKFREQ_MASK, i2s_ctl); @@ -868,19 +868,19 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, * stop: * on --> prepare --> standby */ -static int sgtl5000_set_bias_level(struct snd_soc_codec *codec, +static int sgtl5000_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, SGTL5000_REFTOP_POWERUP); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, 0); break; } @@ -1020,7 +1020,7 @@ static const u8 vol_quot_table[] = { * 1. vddd provided by external or not * 2. vdda and vddio voltage value. > 3.1v or not */ -static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) +static int sgtl5000_set_power_regs(struct snd_soc_component *component) { int vddd; int vdda; @@ -1032,7 +1032,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) int vol_quot; int lo_vol; size_t i; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); vdda = regulator_get_voltage(sgtl5000->supplies[VDDA].consumer); vddio = regulator_get_voltage(sgtl5000->supplies[VDDIO].consumer); @@ -1045,14 +1045,14 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) vddd = vddd / 1000; if (vdda <= 0 || vddio <= 0 || vddd < 0) { - dev_err(codec->dev, "regulator voltage not set correctly\n"); + dev_err(component->dev, "regulator voltage not set correctly\n"); return -EINVAL; } /* according to datasheet, maximum voltage of supplies */ if (vdda > 3600 || vddio > 3600 || vddd > 1980) { - dev_err(codec->dev, + dev_err(component->dev, "exceed max voltage vdda %dmV vddio %dmV vddd %dmV\n", vdda, vddio, vddd); @@ -1060,15 +1060,15 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) } /* reset value */ - ana_pwr = snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER); + ana_pwr = snd_soc_component_read32(component, SGTL5000_CHIP_ANA_POWER); ana_pwr |= SGTL5000_DAC_STEREO | SGTL5000_ADC_STEREO | SGTL5000_REFTOP_POWERUP; - lreg_ctrl = snd_soc_read(codec, SGTL5000_CHIP_LINREG_CTRL); + lreg_ctrl = snd_soc_component_read32(component, SGTL5000_CHIP_LINREG_CTRL); if (vddio < 3100 && vdda < 3100) { /* enable internal oscillator used for charge pump */ - snd_soc_update_bits(codec, SGTL5000_CHIP_CLK_TOP_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL, SGTL5000_INT_OSC_EN, SGTL5000_INT_OSC_EN); /* Enable VDDC charge pump */ @@ -1081,9 +1081,9 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) SGTL5000_VDDC_MAN_ASSN_SHIFT; } - snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL, lreg_ctrl); + snd_soc_component_write(component, SGTL5000_CHIP_LINREG_CTRL, lreg_ctrl); - snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, ana_pwr); + snd_soc_component_write(component, SGTL5000_CHIP_ANA_POWER, ana_pwr); /* * set ADC/DAC VAG to vdda / 2, @@ -1098,7 +1098,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) else vag = (vag - SGTL5000_ANA_GND_BASE) / SGTL5000_ANA_GND_STP; - snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_REF_CTRL, SGTL5000_ANA_GND_MASK, vag << SGTL5000_ANA_GND_SHIFT); /* set line out VAG to vddio / 2, in range (0.8v, 1.675v) */ @@ -1112,7 +1112,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) lo_vag = (lo_vag - SGTL5000_LINE_OUT_GND_BASE) / SGTL5000_LINE_OUT_GND_STP; - snd_soc_update_bits(codec, SGTL5000_CHIP_LINE_OUT_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_LINE_OUT_CTRL, SGTL5000_LINE_OUT_CURRENT_MASK | SGTL5000_LINE_OUT_GND_MASK, lo_vag << SGTL5000_LINE_OUT_GND_SHIFT | @@ -1135,7 +1135,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec) break; } - snd_soc_update_bits(codec, SGTL5000_CHIP_LINE_OUT_VOL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_LINE_OUT_VOL, SGTL5000_LINE_OUT_VOL_RIGHT_MASK | SGTL5000_LINE_OUT_VOL_LEFT_MASK, lo_vol << SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT | @@ -1183,51 +1183,51 @@ static int sgtl5000_enable_regulators(struct i2c_client *client) return ret; } -static int sgtl5000_probe(struct snd_soc_codec *codec) +static int sgtl5000_probe(struct snd_soc_component *component) { int ret; u16 reg; - struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec); + struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component); /* power up sgtl5000 */ - ret = sgtl5000_set_power_regs(codec); + ret = sgtl5000_set_power_regs(component); if (ret) goto err; /* enable small pop, introduce 400ms delay in turning off */ - snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_REF_CTRL, SGTL5000_SMALL_POP, 1); /* disable short cut detector */ - snd_soc_write(codec, SGTL5000_CHIP_SHORT_CTRL, 0); + snd_soc_component_write(component, SGTL5000_CHIP_SHORT_CTRL, 0); /* * set i2s as default input of sound switch * TODO: add sound switch to control and dapm widge. */ - snd_soc_write(codec, SGTL5000_CHIP_SSS_CTRL, + snd_soc_component_write(component, SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAC_SEL_I2S_IN << SGTL5000_DAC_SEL_SHIFT); - snd_soc_write(codec, SGTL5000_CHIP_DIG_POWER, + snd_soc_component_write(component, SGTL5000_CHIP_DIG_POWER, SGTL5000_ADC_EN | SGTL5000_DAC_EN); /* enable dac volume ramp by default */ - snd_soc_write(codec, SGTL5000_CHIP_ADCDAC_CTRL, + snd_soc_component_write(component, SGTL5000_CHIP_ADCDAC_CTRL, SGTL5000_DAC_VOL_RAMP_EN | SGTL5000_DAC_MUTE_RIGHT | SGTL5000_DAC_MUTE_LEFT); reg = ((sgtl5000->lrclk_strength) << SGTL5000_PAD_I2S_LRCLK_SHIFT | 0x5f); - snd_soc_write(codec, SGTL5000_CHIP_PAD_STRENGTH, reg); + snd_soc_component_write(component, SGTL5000_CHIP_PAD_STRENGTH, reg); - snd_soc_write(codec, SGTL5000_CHIP_ANA_CTRL, + snd_soc_component_write(component, SGTL5000_CHIP_ANA_CTRL, SGTL5000_HP_ZCD_EN | SGTL5000_ADC_ZCD_EN); - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_R_MASK, sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT); - snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL, + snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL, SGTL5000_BIAS_VOLT_MASK, sgtl5000->micbias_voltage << SGTL5000_BIAS_VOLT_SHIFT); /* @@ -1235,7 +1235,7 @@ static int sgtl5000_probe(struct snd_soc_codec *codec) * TODO: * Enable DAP in kcontrol and dapm. */ - snd_soc_write(codec, SGTL5000_DAP_CTRL, 0); + snd_soc_component_write(component, SGTL5000_DAP_CTRL, 0); return 0; @@ -1243,24 +1243,20 @@ err: return ret; } -static int sgtl5000_remove(struct snd_soc_codec *codec) -{ - return 0; -} - -static const struct snd_soc_codec_driver sgtl5000_driver = { - .probe = sgtl5000_probe, - .remove = sgtl5000_remove, - .set_bias_level = sgtl5000_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = sgtl5000_snd_controls, - .num_controls = ARRAY_SIZE(sgtl5000_snd_controls), - .dapm_widgets = sgtl5000_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sgtl5000_dapm_widgets), - .dapm_routes = sgtl5000_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(sgtl5000_dapm_routes), - }, +static const struct snd_soc_component_driver sgtl5000_driver = { + .probe = sgtl5000_probe, + .set_bias_level = sgtl5000_set_bias_level, + .controls = sgtl5000_snd_controls, + .num_controls = ARRAY_SIZE(sgtl5000_snd_controls), + .dapm_widgets = sgtl5000_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sgtl5000_dapm_widgets), + .dapm_routes = sgtl5000_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(sgtl5000_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config sgtl5000_regmap = { @@ -1459,7 +1455,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, /* Ensure sgtl5000 will start with sane register values */ sgtl5000_fill_defaults(client); - ret = snd_soc_register_codec(&client->dev, + ret = devm_snd_soc_register_component(&client->dev, &sgtl5000_driver, &sgtl5000_dai, 1); if (ret) goto disable_clk; @@ -1480,7 +1476,6 @@ static int sgtl5000_i2c_remove(struct i2c_client *client) { struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); - snd_soc_unregister_codec(&client->dev); clk_disable_unprepare(sgtl5000->mclk); regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies); From 4218bcf3e7572891eebed3389e2a9f004ff6d2b6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:38:39 +0000 Subject: [PATCH 164/942] ASoC: sirf-audio: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/sirf-audio-codec.c | 58 ++++++++++++++--------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index 7ae8c181d1a4..e424499a8450 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c @@ -120,8 +120,8 @@ static int atlas6_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, { #define ATLAS6_CODEC_ENABLE_BITS (1 << 29) #define ATLAS6_CODEC_RESET_BITS (1 << 28) - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct sirf_audio_codec *sirf_audio_codec = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct sirf_audio_codec *sirf_audio_codec = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: enable_and_reset_codec(sirf_audio_codec->regmap, @@ -143,8 +143,8 @@ static int prima2_codec_enable_and_reset_event(struct snd_soc_dapm_widget *w, { #define PRIMA2_CODEC_ENABLE_BITS (1 << 27) #define PRIMA2_CODEC_RESET_BITS (1 << 26) - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct sirf_audio_codec *sirf_audio_codec = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct sirf_audio_codec *sirf_audio_codec = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: enable_and_reset_codec(sirf_audio_codec->regmap, @@ -333,8 +333,8 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct sirf_audio_codec *sirf_audio_codec = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct sirf_audio_codec *sirf_audio_codec = snd_soc_component_get_drvdata(component); int playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; /* @@ -346,7 +346,7 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: if (playback) { - snd_soc_update_bits(codec, AUDIO_IC_CODEC_CTRL0, + snd_soc_component_update_bits(component, AUDIO_IC_CODEC_CTRL0, IC_HSLEN | IC_HSREN, 0); sirf_audio_codec_tx_disable(sirf_audio_codec); } else @@ -357,7 +357,7 @@ static int sirf_audio_codec_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (playback) { sirf_audio_codec_tx_enable(sirf_audio_codec); - snd_soc_update_bits(codec, AUDIO_IC_CODEC_CTRL0, + snd_soc_component_update_bits(component, AUDIO_IC_CODEC_CTRL0, IC_HSLEN | IC_HSREN, IC_HSLEN | IC_HSREN); } else sirf_audio_codec_rx_enable(sirf_audio_codec, @@ -393,29 +393,29 @@ static struct snd_soc_dai_driver sirf_audio_codec_dai = { .ops = &sirf_audio_codec_dai_ops, }; -static int sirf_audio_codec_probe(struct snd_soc_codec *codec) +static int sirf_audio_codec_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - pm_runtime_enable(codec->dev); + pm_runtime_enable(component->dev); - if (of_device_is_compatible(codec->dev->of_node, "sirf,prima2-audio-codec")) { + if (of_device_is_compatible(component->dev->of_node, "sirf,prima2-audio-codec")) { snd_soc_dapm_new_controls(dapm, prima2_output_driver_dapm_widgets, ARRAY_SIZE(prima2_output_driver_dapm_widgets)); snd_soc_dapm_new_controls(dapm, &prima2_codec_clock_dapm_widget, 1); - return snd_soc_add_codec_controls(codec, + return snd_soc_add_component_controls(component, volume_controls_prima2, ARRAY_SIZE(volume_controls_prima2)); } - if (of_device_is_compatible(codec->dev->of_node, "sirf,atlas6-audio-codec")) { + if (of_device_is_compatible(component->dev->of_node, "sirf,atlas6-audio-codec")) { snd_soc_dapm_new_controls(dapm, atlas6_output_driver_dapm_widgets, ARRAY_SIZE(atlas6_output_driver_dapm_widgets)); snd_soc_dapm_new_controls(dapm, &atlas6_codec_clock_dapm_widget, 1); - return snd_soc_add_codec_controls(codec, + return snd_soc_add_component_controls(component, volume_controls_atlas6, ARRAY_SIZE(volume_controls_atlas6)); } @@ -423,22 +423,21 @@ static int sirf_audio_codec_probe(struct snd_soc_codec *codec) return -EINVAL; } -static int sirf_audio_codec_remove(struct snd_soc_codec *codec) +static void sirf_audio_codec_remove(struct snd_soc_component *component) { - pm_runtime_disable(codec->dev); - return 0; + pm_runtime_disable(component->dev); } -static const struct snd_soc_codec_driver soc_codec_device_sirf_audio_codec = { - .probe = sirf_audio_codec_probe, - .remove = sirf_audio_codec_remove, - .component_driver = { - .dapm_widgets = sirf_audio_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(sirf_audio_codec_dapm_widgets), - .dapm_routes = sirf_audio_codec_map, - .num_dapm_routes = ARRAY_SIZE(sirf_audio_codec_map), - }, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_codec_device_sirf_audio_codec = { + .probe = sirf_audio_codec_probe, + .remove = sirf_audio_codec_remove, + .dapm_widgets = sirf_audio_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(sirf_audio_codec_dapm_widgets), + .dapm_routes = sirf_audio_codec_map, + .num_dapm_routes = ARRAY_SIZE(sirf_audio_codec_map), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id sirf_audio_codec_of_match[] = { @@ -495,7 +494,7 @@ static int sirf_audio_codec_driver_probe(struct platform_device *pdev) return ret; } - ret = snd_soc_register_codec(&(pdev->dev), + ret = devm_snd_soc_register_component(&(pdev->dev), &soc_codec_device_sirf_audio_codec, &sirf_audio_codec_dai, 1); if (ret) { @@ -525,7 +524,6 @@ static int sirf_audio_codec_driver_remove(struct platform_device *pdev) struct sirf_audio_codec *sirf_audio_codec = platform_get_drvdata(pdev); clk_disable_unprepare(sirf_audio_codec->clk); - snd_soc_unregister_codec(&(pdev->dev)); return 0; } From 40aa60a2e9ab5242593101bb6270563ee5acdf46 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:39:10 +0000 Subject: [PATCH 165/942] ASoC: inno_rk3036: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/inno_rk3036.c | 70 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/sound/soc/codecs/inno_rk3036.c b/sound/soc/codecs/inno_rk3036.c index 6b59b6f08298..85a336ba75f6 100644 --- a/sound/soc/codecs/inno_rk3036.c +++ b/sound/soc/codecs/inno_rk3036.c @@ -196,10 +196,10 @@ static const struct snd_soc_dapm_route rk3036_codec_dapm_routes[] = { static int rk3036_codec_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int reg01_val = 0, reg02_val = 0, reg03_val = 0; - dev_dbg(codec->dev, "rk3036_codec dai set fmt : %08x\n", fmt); + dev_dbg(component->dev, "rk3036_codec dai set fmt : %08x\n", fmt); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: @@ -211,7 +211,7 @@ static int rk3036_codec_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) INNO_R01_I2SMODE_MASTER; break; default: - dev_err(codec->dev, "invalid fmt\n"); + dev_err(component->dev, "invalid fmt\n"); return -EINVAL; } @@ -229,7 +229,7 @@ static int rk3036_codec_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) reg02_val |= INNO_R02_DACM_LJM; break; default: - dev_err(codec->dev, "set dai format failed\n"); + dev_err(component->dev, "set dai format failed\n"); return -EINVAL; } @@ -251,15 +251,15 @@ static int rk3036_codec_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) reg03_val |= INNO_R03_BCP_REVERSAL; break; default: - dev_err(codec->dev, "set dai format failed\n"); + dev_err(component->dev, "set dai format failed\n"); return -EINVAL; } - snd_soc_update_bits(codec, INNO_R01, INNO_R01_I2SMODE_MSK | + snd_soc_component_update_bits(component, INNO_R01, INNO_R01_I2SMODE_MSK | INNO_R01_PINDIR_MSK, reg01_val); - snd_soc_update_bits(codec, INNO_R02, INNO_R02_LRCP_MSK | + snd_soc_component_update_bits(component, INNO_R02, INNO_R02_LRCP_MSK | INNO_R02_DACM_MSK, reg02_val); - snd_soc_update_bits(codec, INNO_R03, INNO_R03_BCP_MSK, reg03_val); + snd_soc_component_update_bits(component, INNO_R03, INNO_R03_BCP_MSK, reg03_val); return 0; } @@ -268,7 +268,7 @@ static int rk3036_codec_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int reg02_val = 0, reg03_val = 0; switch (params_format(hw_params)) { @@ -291,9 +291,9 @@ static int rk3036_codec_dai_hw_params(struct snd_pcm_substream *substream, reg02_val |= INNO_R02_LRCP_NORMAL; reg03_val |= INNO_R03_FWL_32BIT | INNO_R03_DACR_WORK; - snd_soc_update_bits(codec, INNO_R02, INNO_R02_LRCP_MSK | + snd_soc_component_update_bits(component, INNO_R02, INNO_R02_LRCP_MSK | INNO_R02_VWL_MSK, reg02_val); - snd_soc_update_bits(codec, INNO_R03, INNO_R03_DACR_MSK | + snd_soc_component_update_bits(component, INNO_R03, INNO_R03_DACR_MSK | INNO_R03_FWL_MSK, reg03_val); return 0; } @@ -330,43 +330,42 @@ static struct snd_soc_dai_driver rk3036_codec_dai_driver[] = { }, }; -static void rk3036_codec_reset(struct snd_soc_codec *codec) +static void rk3036_codec_reset(struct snd_soc_component *component) { - snd_soc_write(codec, INNO_R00, + snd_soc_component_write(component, INNO_R00, INNO_R00_CSR_RESET | INNO_R00_CDCR_RESET); - snd_soc_write(codec, INNO_R00, + snd_soc_component_write(component, INNO_R00, INNO_R00_CSR_WORK | INNO_R00_CDCR_WORK); } -static int rk3036_codec_probe(struct snd_soc_codec *codec) +static int rk3036_codec_probe(struct snd_soc_component *component) { - rk3036_codec_reset(codec); + rk3036_codec_reset(component); return 0; } -static int rk3036_codec_remove(struct snd_soc_codec *codec) +static void rk3036_codec_remove(struct snd_soc_component *component) { - rk3036_codec_reset(codec); - return 0; + rk3036_codec_reset(component); } -static int rk3036_codec_set_bias_level(struct snd_soc_codec *codec, +static int rk3036_codec_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_STANDBY: /* set a big current for capacitor charging. */ - snd_soc_write(codec, INNO_R10, INNO_R10_MAX_CUR); + snd_soc_component_write(component, INNO_R10, INNO_R10_MAX_CUR); /* start precharge */ - snd_soc_write(codec, INNO_R06, INNO_R06_DAC_PRECHARGE); + snd_soc_component_write(component, INNO_R06, INNO_R06_DAC_PRECHARGE); break; case SND_SOC_BIAS_OFF: /* set a big current for capacitor discharging. */ - snd_soc_write(codec, INNO_R10, INNO_R10_MAX_CUR); + snd_soc_component_write(component, INNO_R10, INNO_R10_MAX_CUR); /* start discharge. */ - snd_soc_write(codec, INNO_R06, INNO_R06_DAC_DISCHARGE); + snd_soc_component_write(component, INNO_R06, INNO_R06_DAC_DISCHARGE); break; default: @@ -376,18 +375,20 @@ static int rk3036_codec_set_bias_level(struct snd_soc_codec *codec, return 0; } -static const struct snd_soc_codec_driver rk3036_codec_driver = { +static const struct snd_soc_component_driver rk3036_codec_driver = { .probe = rk3036_codec_probe, .remove = rk3036_codec_remove, .set_bias_level = rk3036_codec_set_bias_level, - .component_driver = { - .controls = rk3036_codec_dapm_controls, - .num_controls = ARRAY_SIZE(rk3036_codec_dapm_controls), - .dapm_routes = rk3036_codec_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rk3036_codec_dapm_routes), - .dapm_widgets = rk3036_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rk3036_codec_dapm_widgets), - }, + .controls = rk3036_codec_dapm_controls, + .num_controls = ARRAY_SIZE(rk3036_codec_dapm_controls), + .dapm_routes = rk3036_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rk3036_codec_dapm_routes), + .dapm_widgets = rk3036_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rk3036_codec_dapm_widgets), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rk3036_codec_regmap_config = { @@ -449,7 +450,7 @@ static int rk3036_codec_platform_probe(struct platform_device *pdev) priv->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, priv); - ret = snd_soc_register_codec(&pdev->dev, &rk3036_codec_driver, + ret = devm_snd_soc_register_component(&pdev->dev, &rk3036_codec_driver, rk3036_codec_dai_driver, ARRAY_SIZE(rk3036_codec_dai_driver)); if (ret) { @@ -464,7 +465,6 @@ static int rk3036_codec_platform_remove(struct platform_device *pdev) { struct rk3036_codec_priv *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); clk_disable_unprepare(priv->pclk); return 0; From f572634c90586fb5426d514e7c584b0b6b5028c0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:39:30 +0000 Subject: [PATCH 166/942] ASoC: isabelle: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/isabelle.c | 57 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/sound/soc/codecs/isabelle.c b/sound/soc/codecs/isabelle.c index 5ca99280ae00..166420376e67 100644 --- a/sound/soc/codecs/isabelle.c +++ b/sound/soc/codecs/isabelle.c @@ -867,7 +867,7 @@ static const struct snd_soc_dapm_route isabelle_intercon[] = { static int isabelle_hs_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, ISABELLE_DAC1_SOFTRAMP_REG, + snd_soc_component_update_bits(dai->component, ISABELLE_DAC1_SOFTRAMP_REG, BIT(4), (mute ? BIT(4) : 0)); return 0; @@ -875,7 +875,7 @@ static int isabelle_hs_mute(struct snd_soc_dai *dai, int mute) static int isabelle_hf_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, ISABELLE_DAC2_SOFTRAMP_REG, + snd_soc_component_update_bits(dai->component, ISABELLE_DAC2_SOFTRAMP_REG, BIT(4), (mute ? BIT(4) : 0)); return 0; @@ -883,13 +883,13 @@ static int isabelle_hf_mute(struct snd_soc_dai *dai, int mute) static int isabelle_line_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, ISABELLE_DAC3_SOFTRAMP_REG, + snd_soc_component_update_bits(dai->component, ISABELLE_DAC3_SOFTRAMP_REG, BIT(4), (mute ? BIT(4) : 0)); return 0; } -static int isabelle_set_bias_level(struct snd_soc_codec *codec, +static int isabelle_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -899,12 +899,12 @@ static int isabelle_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, ISABELLE_PWR_EN_REG, + snd_soc_component_update_bits(component, ISABELLE_PWR_EN_REG, ISABELLE_CHIP_EN, BIT(0)); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, ISABELLE_PWR_EN_REG, + snd_soc_component_update_bits(component, ISABELLE_PWR_EN_REG, ISABELLE_CHIP_EN, 0); break; } @@ -916,7 +916,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 aif = 0; unsigned int fs_val = 0; @@ -952,7 +952,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, ISABELLE_FS_RATE_CFG_REG, + snd_soc_component_update_bits(component, ISABELLE_FS_RATE_CFG_REG, ISABELLE_FS_RATE_MASK, fs_val); /* bit size */ @@ -967,7 +967,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, ISABELLE_INTF_CFG_REG, + snd_soc_component_update_bits(component, ISABELLE_INTF_CFG_REG, ISABELLE_AIF_LENGTH_MASK, aif); return 0; @@ -975,7 +975,7 @@ static int isabelle_hw_params(struct snd_pcm_substream *substream, static int isabelle_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int aif_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1003,7 +1003,7 @@ static int isabelle_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, ISABELLE_INTF_CFG_REG, + snd_soc_component_update_bits(component, ISABELLE_INTF_CFG_REG, (ISABELLE_AIF_MS | ISABELLE_AIF_FMT_MASK), aif_val); return 0; @@ -1087,17 +1087,17 @@ static struct snd_soc_dai_driver isabelle_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_isabelle = { - .set_bias_level = isabelle_set_bias_level, - .component_driver = { - .controls = isabelle_snd_controls, - .num_controls = ARRAY_SIZE(isabelle_snd_controls), - .dapm_widgets = isabelle_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(isabelle_dapm_widgets), - .dapm_routes = isabelle_intercon, - .num_dapm_routes = ARRAY_SIZE(isabelle_intercon), - }, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_isabelle = { + .set_bias_level = isabelle_set_bias_level, + .controls = isabelle_snd_controls, + .num_controls = ARRAY_SIZE(isabelle_snd_controls), + .dapm_widgets = isabelle_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(isabelle_dapm_widgets), + .dapm_routes = isabelle_intercon, + .num_dapm_routes = ARRAY_SIZE(isabelle_intercon), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config isabelle_regmap_config = { @@ -1125,23 +1125,17 @@ static int isabelle_i2c_probe(struct i2c_client *i2c, } i2c_set_clientdata(i2c, isabelle_regmap); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_isabelle, isabelle_dai, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_isabelle, isabelle_dai, ARRAY_SIZE(isabelle_dai)); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } return ret; } -static int isabelle_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id isabelle_i2c_id[] = { { "isabelle", 0 }, { } @@ -1153,7 +1147,6 @@ static struct i2c_driver isabelle_i2c_driver = { .name = "isabelle", }, .probe = isabelle_i2c_probe, - .remove = isabelle_i2c_remove, .id_table = isabelle_i2c_id, }; From 064f6682f93898d55e6024a536dc1fad3843fa12 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:39:54 +0000 Subject: [PATCH 167/942] ASoC: tfa9879: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tfa9879.c | 50 +++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/sound/soc/codecs/tfa9879.c b/sound/soc/codecs/tfa9879.c index e7ca764b5729..6d213c6d3920 100644 --- a/sound/soc/codecs/tfa9879.c +++ b/sound/soc/codecs/tfa9879.c @@ -30,8 +30,8 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component); int fs; int i2s_set = 0; @@ -88,11 +88,11 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream, } if (tfa9879->lsb_justified) - snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, + snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, TFA9879_I2S_SET_MASK, i2s_set << TFA9879_I2S_SET_SHIFT); - snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, + snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, TFA9879_I2S_FS_MASK, fs << TFA9879_I2S_FS_SHIFT); return 0; @@ -100,9 +100,9 @@ static int tfa9879_hw_params(struct snd_pcm_substream *substream, static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - snd_soc_update_bits(codec, TFA9879_MISC_CONTROL, + snd_soc_component_update_bits(component, TFA9879_MISC_CONTROL, TFA9879_S_MUTE_MASK, !!mute << TFA9879_S_MUTE_SHIFT); @@ -111,8 +111,8 @@ static int tfa9879_digital_mute(struct snd_soc_dai *dai, int mute) static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct tfa9879_priv *tfa9879 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct tfa9879_priv *tfa9879 = snd_soc_component_get_drvdata(component); int i2s_set; int sck_pol; @@ -151,10 +151,10 @@ static int tfa9879_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, + snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, TFA9879_SCK_POL_MASK, sck_pol << TFA9879_SCK_POL_SHIFT); - snd_soc_update_bits(codec, TFA9879_SERIAL_INTERFACE_1, + snd_soc_component_update_bits(component, TFA9879_SERIAL_INTERFACE_1, TFA9879_I2S_SET_MASK, i2s_set << TFA9879_I2S_SET_SHIFT); return 0; @@ -230,15 +230,17 @@ static const struct snd_soc_dapm_route tfa9879_dapm_routes[] = { { "DAC", NULL, "POWER" }, }; -static const struct snd_soc_codec_driver tfa9879_codec = { - .component_driver = { - .controls = tfa9879_controls, - .num_controls = ARRAY_SIZE(tfa9879_controls), - .dapm_widgets = tfa9879_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tfa9879_dapm_widgets), - .dapm_routes = tfa9879_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(tfa9879_dapm_routes), - }, +static const struct snd_soc_component_driver tfa9879_component = { + .controls = tfa9879_controls, + .num_controls = ARRAY_SIZE(tfa9879_controls), + .dapm_widgets = tfa9879_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tfa9879_dapm_widgets), + .dapm_routes = tfa9879_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(tfa9879_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config tfa9879_regmap = { @@ -295,17 +297,10 @@ static int tfa9879_i2c_probe(struct i2c_client *i2c, regmap_write(tfa9879->regmap, tfa9879_regs[i].reg, tfa9879_regs[i].def); - return snd_soc_register_codec(&i2c->dev, &tfa9879_codec, + return devm_snd_soc_register_component(&i2c->dev, &tfa9879_component, &tfa9879_dai, 1); } -static int tfa9879_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - - return 0; -} - static const struct i2c_device_id tfa9879_i2c_id[] = { { "tfa9879", 0 }, { } @@ -324,7 +319,6 @@ static struct i2c_driver tfa9879_i2c_driver = { .of_match_table = tfa9879_of_match, }, .probe = tfa9879_i2c_probe, - .remove = tfa9879_i2c_remove, .id_table = tfa9879_i2c_id, }; From 6d6c3946d877adf1e73c6292f947bbb687452ed5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:40:29 +0000 Subject: [PATCH 168/942] ASoC: dmic: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/dmic.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index cf83c423394d..32a8f71d51f1 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -71,16 +71,16 @@ static struct snd_soc_dai_driver dmic_dai = { .ops = &dmic_dai_ops, }; -static int dmic_codec_probe(struct snd_soc_codec *codec) +static int dmic_component_probe(struct snd_soc_component *component) { struct gpio_desc *dmic_en; - dmic_en = devm_gpiod_get_optional(codec->dev, + dmic_en = devm_gpiod_get_optional(component->dev, "dmicen", GPIOD_OUT_LOW); if (IS_ERR(dmic_en)) return PTR_ERR(dmic_en); - snd_soc_codec_set_drvdata(codec, dmic_en); + snd_soc_component_set_drvdata(component, dmic_en); return 0; } @@ -95,14 +95,16 @@ static const struct snd_soc_dapm_route intercon[] = { {"DMIC AIF", NULL, "DMic"}, }; -static const struct snd_soc_codec_driver soc_dmic = { - .probe = dmic_codec_probe, - .component_driver = { - .dapm_widgets = dmic_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static const struct snd_soc_component_driver soc_dmic = { + .probe = dmic_component_probe, + .dapm_widgets = dmic_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(dmic_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int dmic_dev_probe(struct platform_device *pdev) @@ -129,16 +131,10 @@ static int dmic_dev_probe(struct platform_device *pdev) } } - return snd_soc_register_codec(&pdev->dev, + return devm_snd_soc_register_component(&pdev->dev, &soc_dmic, dai_drv, 1); } -static int dmic_dev_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - MODULE_ALIAS("platform:dmic-codec"); static const struct of_device_id dmic_dev_match[] = { @@ -152,7 +148,6 @@ static struct platform_driver dmic_driver = { .of_match_table = dmic_dev_match, }, .probe = dmic_dev_probe, - .remove = dmic_dev_remove, }; module_platform_driver(dmic_driver); From 049c1bfc30f3a5c09dcb83f2edb8c3707fdb17fd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:40:56 +0000 Subject: [PATCH 169/942] ASoC: sti-sas: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/sti-sas.c | 84 ++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/sound/soc/codecs/sti-sas.c b/sound/soc/codecs/sti-sas.c index 62c618765224..7316c80b8179 100644 --- a/sound/soc/codecs/sti-sas.c +++ b/sound/soc/codecs/sti-sas.c @@ -106,7 +106,7 @@ static int sti_sas_write_reg(void *context, unsigned int reg, return status; } -static int sti_sas_init_sas_registers(struct snd_soc_codec *codec, +static int sti_sas_init_sas_registers(struct snd_soc_component *component, struct sti_sas_data *data) { int ret; @@ -116,35 +116,35 @@ static int sti_sas_init_sas_registers(struct snd_soc_codec *codec, */ /* Initialise bi-phase formatter to disabled */ - ret = snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL, + ret = snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL, SPDIF_BIPHASE_ENABLE_MASK, 0); if (!ret) /* Initialise bi-phase formatter idle value to 0 */ - ret = snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL, + ret = snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL, SPDIF_BIPHASE_IDLE_MASK, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to update SPDIF registers\n"); + dev_err(component->dev, "Failed to update SPDIF registers\n"); return ret; } /* Init DAC configuration */ /* init configuration */ - ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL, + ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL, STIH407_DAC_STANDBY_MASK, STIH407_DAC_STANDBY_MASK); if (!ret) - ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL, + ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL, STIH407_DAC_STANDBY_ANA_MASK, STIH407_DAC_STANDBY_ANA_MASK); if (!ret) - ret = snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL, + ret = snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL, STIH407_DAC_SOFTMUTE_MASK, STIH407_DAC_SOFTMUTE_MASK); if (ret < 0) { - dev_err(codec->dev, "Failed to update DAC registers\n"); + dev_err(component->dev, "Failed to update DAC registers\n"); return ret; } @@ -158,7 +158,7 @@ static int sti_sas_dac_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { /* Sanity check only */ if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupporter master mask 0x%x\n", __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; @@ -183,14 +183,14 @@ static const struct snd_soc_dapm_route stih407_sas_route[] = { static int stih407_sas_dac_mute(struct snd_soc_dai *dai, int mute, int stream) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; if (mute) { - return snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL, + return snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL, STIH407_DAC_SOFTMUTE_MASK, STIH407_DAC_SOFTMUTE_MASK); } else { - return snd_soc_update_bits(codec, STIH407_AUDIO_DAC_CTRL, + return snd_soc_component_update_bits(component, STIH407_AUDIO_DAC_CTRL, STIH407_DAC_SOFTMUTE_MASK, 0); } @@ -203,7 +203,7 @@ static int sti_sas_spdif_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) { - dev_err(dai->codec->dev, + dev_err(dai->component->dev, "%s: ERROR: Unsupporter master mask 0x%x\n", __func__, fmt & SND_SOC_DAIFMT_MASTER_MASK); return -EINVAL; @@ -221,19 +221,19 @@ static int sti_sas_spdif_set_fmt(struct snd_soc_dai *dai, static int sti_sas_spdif_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - return snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL, + return snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL, SPDIF_BIPHASE_ENABLE_MASK, SPDIF_BIPHASE_ENABLE_MASK); case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: - return snd_soc_update_bits(codec, STIH407_AUDIO_GLUE_CTRL, + return snd_soc_component_update_bits(component, STIH407_AUDIO_GLUE_CTRL, SPDIF_BIPHASE_ENABLE_MASK, 0); default: @@ -260,8 +260,8 @@ static bool sti_sas_volatile_register(struct device *dev, unsigned int reg) static int sti_sas_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = dai->component; + struct sti_sas_data *drvdata = dev_get_drvdata(component->dev); if (dir == SND_SOC_CLOCK_OUT) return 0; @@ -285,20 +285,20 @@ static int sti_sas_set_sysclk(struct snd_soc_dai *dai, int clk_id, static int sti_sas_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev); + struct snd_soc_component *component = dai->component; + struct sti_sas_data *drvdata = dev_get_drvdata(component->dev); struct snd_pcm_runtime *runtime = substream->runtime; switch (dai->id) { case STI_SAS_DAI_SPDIF_OUT: if ((drvdata->spdif.mclk / runtime->rate) != 128) { - dev_err(codec->dev, "unexpected mclk-fs ratio\n"); + dev_err(component->dev, "unexpected mclk-fs ratio\n"); return -EINVAL; } break; case STI_SAS_DAI_ANALOG_OUT: if ((drvdata->dac.mclk / runtime->rate) != 256) { - dev_err(codec->dev, "unexpected mclk-fs ratio\n"); + dev_err(component->dev, "unexpected mclk-fs ratio\n"); return -EINVAL; } break; @@ -375,29 +375,33 @@ static struct snd_soc_dai_driver sti_sas_dai[] = { }; #ifdef CONFIG_PM_SLEEP -static int sti_sas_resume(struct snd_soc_codec *codec) +static int sti_sas_resume(struct snd_soc_component *component) { - struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev); + struct sti_sas_data *drvdata = dev_get_drvdata(component->dev); - return sti_sas_init_sas_registers(codec, drvdata); + return sti_sas_init_sas_registers(component, drvdata); } #else #define sti_sas_resume NULL #endif -static int sti_sas_codec_probe(struct snd_soc_codec *codec) +static int sti_sas_component_probe(struct snd_soc_component *component) { - struct sti_sas_data *drvdata = dev_get_drvdata(codec->dev); + struct sti_sas_data *drvdata = dev_get_drvdata(component->dev); int ret; - ret = sti_sas_init_sas_registers(codec, drvdata); + ret = sti_sas_init_sas_registers(component, drvdata); return ret; } -static struct snd_soc_codec_driver sti_sas_driver = { - .probe = sti_sas_codec_probe, - .resume = sti_sas_resume, +static struct snd_soc_component_driver sti_sas_driver = { + .probe = sti_sas_component_probe, + .resume = sti_sas_resume, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct of_device_id sti_sas_dev_match[] = { @@ -452,34 +456,26 @@ static int sti_sas_driver_probe(struct platform_device *pdev) sti_sas_dai[STI_SAS_DAI_ANALOG_OUT].ops = drvdata->dev_data->dac_ops; /* Set dapms*/ - sti_sas_driver.component_driver.dapm_widgets = drvdata->dev_data->dapm_widgets; - sti_sas_driver.component_driver.num_dapm_widgets = drvdata->dev_data->num_dapm_widgets; + sti_sas_driver.dapm_widgets = drvdata->dev_data->dapm_widgets; + sti_sas_driver.num_dapm_widgets = drvdata->dev_data->num_dapm_widgets; - sti_sas_driver.component_driver.dapm_routes = drvdata->dev_data->dapm_routes; - sti_sas_driver.component_driver.num_dapm_routes = drvdata->dev_data->num_dapm_routes; + sti_sas_driver.dapm_routes = drvdata->dev_data->dapm_routes; + sti_sas_driver.num_dapm_routes = drvdata->dev_data->num_dapm_routes; /* Store context */ dev_set_drvdata(&pdev->dev, drvdata); - return snd_soc_register_codec(&pdev->dev, &sti_sas_driver, + return devm_snd_soc_register_component(&pdev->dev, &sti_sas_driver, sti_sas_dai, ARRAY_SIZE(sti_sas_dai)); } -static int sti_sas_driver_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver sti_sas_platform_driver = { .driver = { .name = "sti-sas-codec", .of_match_table = sti_sas_dev_match, }, .probe = sti_sas_driver_probe, - .remove = sti_sas_driver_remove, }; module_platform_driver(sti_sas_platform_driver); From 993709b83cb1276614974b25f130b8a73215e196 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:41:22 +0000 Subject: [PATCH 170/942] ASoC: gtm601: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/gtm601.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/gtm601.c b/sound/soc/codecs/gtm601.c index 926b1a4e37d4..c11ed60ccefb 100644 --- a/sound/soc/codecs/gtm601.c +++ b/sound/soc/codecs/gtm601.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -51,25 +50,21 @@ static struct snd_soc_dai_driver gtm601_dai = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_gtm601 = { - .component_driver = { - .dapm_widgets = gtm601_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets), - .dapm_routes = gtm601_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_gtm601 = { + .dapm_widgets = gtm601_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(gtm601_dapm_widgets), + .dapm_routes = gtm601_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(gtm601_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int gtm601_platform_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_gtm601, >m601_dai, 1); -} - -static int gtm601_platform_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_gtm601, >m601_dai, 1); } #if defined(CONFIG_OF) @@ -86,7 +81,6 @@ static struct platform_driver gtm601_codec_driver = { .of_match_table = of_match_ptr(gtm601_codec_of_match), }, .probe = gtm601_platform_probe, - .remove = gtm601_platform_remove, }; module_platform_driver(gtm601_codec_driver); From 5783994b9afa8d37e9766b3cfbb594c1ae26087c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:41:42 +0000 Subject: [PATCH 171/942] ASoC: 88pm860x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/88pm860x-codec.c | 166 +++++++++++++++--------------- sound/soc/codecs/88pm860x-codec.h | 4 +- sound/soc/pxa/ttc-dkb.c | 6 +- 3 files changed, 88 insertions(+), 88 deletions(-) diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index be8ea723dff9..3c3ef422853d 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -139,7 +139,7 @@ struct pm860x_priv { unsigned int pcmclk; unsigned int dir; unsigned int filter; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct i2c_client *i2c; struct regmap *regmap; struct pm860x_chip *chip; @@ -272,15 +272,15 @@ static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int val[2], val2[2], i; - val[0] = snd_soc_read(codec, reg) & 0x3f; - val[1] = (snd_soc_read(codec, PM860X_SIDETONE_SHIFT) >> 4) & 0xf; - val2[0] = snd_soc_read(codec, reg2) & 0x3f; - val2[1] = (snd_soc_read(codec, PM860X_SIDETONE_SHIFT)) & 0xf; + val[0] = snd_soc_component_read32(component, reg) & 0x3f; + val[1] = (snd_soc_component_read32(component, PM860X_SIDETONE_SHIFT) >> 4) & 0xf; + val2[0] = snd_soc_component_read32(component, reg2) & 0x3f; + val2[1] = (snd_soc_component_read32(component, PM860X_SIDETONE_SHIFT)) & 0xf; for (i = 0; i < ARRAY_SIZE(st_table); i++) { if ((st_table[i].m == val[0]) && (st_table[i].n == val[1])) @@ -296,7 +296,7 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; int err; @@ -308,18 +308,18 @@ static int snd_soc_put_volsw_2r_st(struct snd_kcontrol *kcontrol, if (val >= ARRAY_SIZE(st_table) || val2 >= ARRAY_SIZE(st_table)) return -EINVAL; - err = snd_soc_update_bits(codec, reg, 0x3f, st_table[val].m); + err = snd_soc_component_update_bits(component, reg, 0x3f, st_table[val].m); if (err < 0) return err; - err = snd_soc_update_bits(codec, PM860X_SIDETONE_SHIFT, 0xf0, + err = snd_soc_component_update_bits(component, PM860X_SIDETONE_SHIFT, 0xf0, st_table[val].n << 4); if (err < 0) return err; - err = snd_soc_update_bits(codec, reg2, 0x3f, st_table[val2].m); + err = snd_soc_component_update_bits(component, reg2, 0x3f, st_table[val2].m); if (err < 0) return err; - err = snd_soc_update_bits(codec, PM860X_SIDETONE_SHIFT, 0x0f, + err = snd_soc_component_update_bits(component, PM860X_SIDETONE_SHIFT, 0x0f, st_table[val2].n); return err; } @@ -329,15 +329,15 @@ static int snd_soc_get_volsw_2r_out(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; int max = mc->max, val, val2; unsigned int mask = (1 << fls(max)) - 1; - val = snd_soc_read(codec, reg) >> shift; - val2 = snd_soc_read(codec, reg2) >> shift; + val = snd_soc_component_read32(component, reg) >> shift; + val2 = snd_soc_component_read32(component, reg2) >> shift; ucontrol->value.integer.value[0] = (max - val) & mask; ucontrol->value.integer.value[1] = (max - val2) & mask; @@ -349,7 +349,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int reg = mc->reg; unsigned int reg2 = mc->rreg; unsigned int shift = mc->shift; @@ -365,11 +365,11 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, val = val << shift; val2 = val2 << shift; - err = snd_soc_update_bits(codec, reg, val_mask, val); + err = snd_soc_component_update_bits(component, reg, val_mask, val); if (err < 0) return err; - err = snd_soc_update_bits(codec, reg2, val_mask, val2); + err = snd_soc_component_update_bits(component, reg2, val_mask, val2); return err; } @@ -382,7 +382,7 @@ static int snd_soc_put_volsw_2r_out(struct snd_kcontrol *kcontrol, static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); /* * In order to avoid current on the load, mute power-on and power-off @@ -390,8 +390,8 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, * Unmute by DAC_MUTE. It should be unmuted when DAPM sequence is * finished. */ - snd_soc_update_bits(codec, PM860X_DAC_OFFSET, DAC_MUTE, 0); - snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, + snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, DAC_MUTE, 0); + snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2, RSYNC_CHANGE, RSYNC_CHANGE); return 0; } @@ -399,7 +399,7 @@ static int pm860x_rsync_event(struct snd_soc_dapm_widget *w, static int pm860x_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int dac = 0; int data; @@ -412,28 +412,28 @@ static int pm860x_dac_event(struct snd_soc_dapm_widget *w, if (dac) { /* Auto mute in power-on sequence. */ dac |= MODULATOR; - snd_soc_update_bits(codec, PM860X_DAC_OFFSET, + snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, DAC_MUTE, DAC_MUTE); - snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, + snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2, RSYNC_CHANGE, RSYNC_CHANGE); /* update dac */ - snd_soc_update_bits(codec, PM860X_DAC_EN_2, + snd_soc_component_update_bits(component, PM860X_DAC_EN_2, dac, dac); } break; case SND_SOC_DAPM_PRE_PMD: if (dac) { /* Auto mute in power-off sequence. */ - snd_soc_update_bits(codec, PM860X_DAC_OFFSET, + snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, DAC_MUTE, DAC_MUTE); - snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, + snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2, RSYNC_CHANGE, RSYNC_CHANGE); /* update dac */ - data = snd_soc_read(codec, PM860X_DAC_EN_2); + data = snd_soc_component_read32(component, PM860X_DAC_EN_2); data &= ~dac; if (!(data & (DAC_LEFT | DAC_RIGHT))) data &= ~MODULATOR; - snd_soc_write(codec, PM860X_DAC_EN_2, data); + snd_soc_component_write(component, PM860X_DAC_EN_2, data); } break; } @@ -922,13 +922,13 @@ static const struct snd_soc_dapm_route pm860x_dapm_routes[] = { */ static int pm860x_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int data = 0, mask = MUTE_LEFT | MUTE_RIGHT; if (mute) data = mask; - snd_soc_update_bits(codec, PM860X_DAC_OFFSET, mask, data); - snd_soc_update_bits(codec, PM860X_EAR_CTRL_2, + snd_soc_component_update_bits(component, PM860X_DAC_OFFSET, mask, data); + snd_soc_component_update_bits(component, PM860X_EAR_CTRL_2, RSYNC_CHANGE, RSYNC_CHANGE); return 0; } @@ -937,7 +937,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned char inf = 0, mask = 0; /* bit size */ @@ -952,7 +952,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } mask |= PCM_INF2_18WL; - snd_soc_update_bits(codec, PM860X_PCM_IFACE_2, mask, inf); + snd_soc_component_update_bits(component, PM860X_PCM_IFACE_2, mask, inf); /* sample rate */ switch (params_rate(params)) { @@ -971,7 +971,7 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, PM860X_PCM_RATE, 0x0f, inf); + snd_soc_component_update_bits(component, PM860X_PCM_RATE, 0x0f, inf); return 0; } @@ -979,8 +979,8 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); unsigned char inf = 0, mask = 0; int ret = -EINVAL; @@ -1012,15 +1012,15 @@ static int pm860x_pcm_set_dai_fmt(struct snd_soc_dai *codec_dai, mask |= PCM_MODE_MASK; if (ret) return ret; - snd_soc_update_bits(codec, PM860X_PCM_IFACE_2, mask, inf); + snd_soc_component_update_bits(component, PM860X_PCM_IFACE_2, mask, inf); return 0; } static int pm860x_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); if (dir == PM860X_CLK_DIR_OUT) pm860x->dir = PM860X_CLK_DIR_OUT; @@ -1034,7 +1034,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned char inf; /* bit size */ @@ -1048,7 +1048,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, PM860X_I2S_IFACE_2, PCM_INF2_18WL, inf); + snd_soc_component_update_bits(component, PM860X_I2S_IFACE_2, PCM_INF2_18WL, inf); /* sample rate */ switch (params_rate(params)) { @@ -1076,7 +1076,7 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, default: return -EINVAL; } - snd_soc_update_bits(codec, PM860X_I2S_IFACE_4, 0xf, inf); + snd_soc_component_update_bits(component, PM860X_I2S_IFACE_4, 0xf, inf); return 0; } @@ -1084,8 +1084,8 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); unsigned char inf = 0, mask = 0; mask |= PCM_INF2_BCLK | PCM_INF2_FS | PCM_INF2_MASTER; @@ -1116,14 +1116,14 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } mask |= PCM_MODE_MASK; - snd_soc_update_bits(codec, PM860X_I2S_IFACE_2, mask, inf); + snd_soc_component_update_bits(component, PM860X_I2S_IFACE_2, mask, inf); return 0; } -static int pm860x_set_bias_level(struct snd_soc_codec *codec, +static int pm860x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); int data; switch (level) { @@ -1134,7 +1134,7 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { /* Enable Audio PLL & Audio section */ data = AUDIO_PLL | AUDIO_SECTION_ON; pm860x_reg_write(pm860x->i2c, REG_MISC2, data); @@ -1216,7 +1216,7 @@ static struct snd_soc_dai_driver pm860x_dai[] = { }, }; -static irqreturn_t pm860x_codec_handler(int irq, void *data) +static irqreturn_t pm860x_component_handler(int irq, void *data) { struct pm860x_priv *pm860x = data; int status, shrt, report = 0, mic_report = 0; @@ -1230,7 +1230,7 @@ static irqreturn_t pm860x_codec_handler(int irq, void *data) #ifndef CONFIG_SND_SOC_88PM860X_MODULE if (status & (HEADSET_STATUS | MIC_STATUS | SHORT_HS1 | SHORT_HS2 | SHORT_LO1 | SHORT_LO2)) - trace_snd_soc_jack_irq(dev_name(pm860x->codec->dev)); + trace_snd_soc_jack_irq(dev_name(pm860x->component->dev)); #endif if ((pm860x->det.hp_det & SND_JACK_HEADPHONE) @@ -1256,17 +1256,17 @@ static irqreturn_t pm860x_codec_handler(int irq, void *data) snd_soc_jack_report(pm860x->det.mic_jack, SND_JACK_MICROPHONE, SND_JACK_MICROPHONE); - dev_dbg(pm860x->codec->dev, "headphone report:0x%x, mask:%x\n", + dev_dbg(pm860x->component->dev, "headphone report:0x%x, mask:%x\n", report, mask); - dev_dbg(pm860x->codec->dev, "microphone report:0x%x\n", mic_report); + dev_dbg(pm860x->component->dev, "microphone report:0x%x\n", mic_report); return IRQ_HANDLED; } -int pm860x_hs_jack_detect(struct snd_soc_codec *codec, +int pm860x_hs_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int det, int hook, int hs_shrt, int lo_shrt) { - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); int data; pm860x->det.hp_jack = jack; @@ -1290,15 +1290,15 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec, } /* sync status */ - pm860x_codec_handler(0, pm860x); + pm860x_component_handler(0, pm860x); return 0; } EXPORT_SYMBOL_GPL(pm860x_hs_jack_detect); -int pm860x_mic_jack_detect(struct snd_soc_codec *codec, +int pm860x_mic_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int det) { - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); pm860x->det.mic_jack = jack; pm860x->det.mic_det = det; @@ -1308,25 +1308,25 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec, MICDET_MASK, MICDET_MASK); /* sync status */ - pm860x_codec_handler(0, pm860x); + pm860x_component_handler(0, pm860x); return 0; } EXPORT_SYMBOL_GPL(pm860x_mic_jack_detect); -static int pm860x_probe(struct snd_soc_codec *codec) +static int pm860x_probe(struct snd_soc_component *component) { - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); int i, ret; - pm860x->codec = codec; - snd_soc_codec_init_regmap(codec, pm860x->regmap); + pm860x->component = component; + snd_soc_component_init_regmap(component, pm860x->regmap); for (i = 0; i < 4; i++) { ret = request_threaded_irq(pm860x->irq[i], NULL, - pm860x_codec_handler, IRQF_ONESHOT, + pm860x_component_handler, IRQF_ONESHOT, pm860x->name[i], pm860x); if (ret < 0) { - dev_err(codec->dev, "Failed to request IRQ!\n"); + dev_err(component->dev, "Failed to request IRQ!\n"); goto out; } } @@ -1339,29 +1339,29 @@ out: return ret; } -static int pm860x_remove(struct snd_soc_codec *codec) +static void pm860x_remove(struct snd_soc_component *component) { - struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); + struct pm860x_priv *pm860x = snd_soc_component_get_drvdata(component); int i; for (i = 3; i >= 0; i--) free_irq(pm860x->irq[i], pm860x); - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_pm860x = { - .probe = pm860x_probe, - .remove = pm860x_remove, - .set_bias_level = pm860x_set_bias_level, - - .component_driver = { - .controls = pm860x_snd_controls, - .num_controls = ARRAY_SIZE(pm860x_snd_controls), - .dapm_widgets = pm860x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pm860x_dapm_widgets), - .dapm_routes = pm860x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pm860x_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_pm860x = { + .probe = pm860x_probe, + .remove = pm860x_remove, + .set_bias_level = pm860x_set_bias_level, + .controls = pm860x_snd_controls, + .num_controls = ARRAY_SIZE(pm860x_snd_controls), + .dapm_widgets = pm860x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pm860x_dapm_widgets), + .dapm_routes = pm860x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pm860x_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int pm860x_codec_probe(struct platform_device *pdev) @@ -1393,10 +1393,11 @@ static int pm860x_codec_probe(struct platform_device *pdev) strncpy(pm860x->name[i], res->name, MAX_NAME_LEN); } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pm860x, + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_pm860x, pm860x_dai, ARRAY_SIZE(pm860x_dai)); if (ret) { - dev_err(&pdev->dev, "Failed to register codec\n"); + dev_err(&pdev->dev, "Failed to register component\n"); return -EINVAL; } return ret; @@ -1404,7 +1405,6 @@ static int pm860x_codec_probe(struct platform_device *pdev) static int pm860x_codec_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } diff --git a/sound/soc/codecs/88pm860x-codec.h b/sound/soc/codecs/88pm860x-codec.h index f7282f4f4a79..33aa9ff3463f 100644 --- a/sound/soc/codecs/88pm860x-codec.h +++ b/sound/soc/codecs/88pm860x-codec.h @@ -88,9 +88,9 @@ #define PM860X_SHORT_LINEOUT (1 << 4) #define PM860X_DET_MASK 0x1F -extern int pm860x_hs_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *, +extern int pm860x_hs_jack_detect(struct snd_soc_component *, struct snd_soc_jack *, int, int, int, int); -extern int pm860x_mic_jack_detect(struct snd_soc_codec *, struct snd_soc_jack *, +extern int pm860x_mic_jack_detect(struct snd_soc_component *, struct snd_soc_jack *, int); #endif /* __88PM860X_H */ diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c index 65c20f779177..5d6e61a4bb7e 100644 --- a/sound/soc/pxa/ttc-dkb.c +++ b/sound/soc/pxa/ttc-dkb.c @@ -75,7 +75,7 @@ static const struct snd_soc_dapm_route ttc_audio_map[] = { static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* Headset jack detection */ snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE | @@ -86,9 +86,9 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) ARRAY_SIZE(mic_jack_pins)); /* headphone, microphone detection & headset short detection */ - pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, + pm860x_hs_jack_detect(component, &hs_jack, SND_JACK_HEADPHONE, SND_JACK_BTN_0, SND_JACK_BTN_1, SND_JACK_BTN_2); - pm860x_mic_jack_detect(codec, &hs_jack, SND_JACK_MICROPHONE); + pm860x_mic_jack_detect(component, &hs_jack, SND_JACK_MICROPHONE); return 0; } From 8dc906d3ae088668ab9c0f4e0fa2314a8cd8fcaa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:42:01 +0000 Subject: [PATCH 172/942] ASoC: pistachio: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/img/pistachio-internal-dac.c | 34 +++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/sound/soc/img/pistachio-internal-dac.c b/sound/soc/img/pistachio-internal-dac.c index 53e11c6d4e22..915b894f99ce 100644 --- a/sound/soc/img/pistachio-internal-dac.c +++ b/sound/soc/img/pistachio-internal-dac.c @@ -122,26 +122,26 @@ static struct snd_soc_dai_driver pistachio_internal_dac_dais[] = { }, }; -static int pistachio_internal_dac_codec_probe(struct snd_soc_codec *codec) +static int pistachio_internal_dac_codec_probe(struct snd_soc_component *component) { - struct pistachio_internal_dac *dac = snd_soc_codec_get_drvdata(codec); + struct pistachio_internal_dac *dac = snd_soc_component_get_drvdata(component); - snd_soc_codec_init_regmap(codec, dac->regmap); + snd_soc_component_init_regmap(component, dac->regmap); return 0; } -static const struct snd_soc_codec_driver pistachio_internal_dac_driver = { - .probe = pistachio_internal_dac_codec_probe, - .idle_bias_off = true, - .component_driver = { - .controls = pistachio_internal_dac_snd_controls, - .num_controls = ARRAY_SIZE(pistachio_internal_dac_snd_controls), - .dapm_widgets = pistachio_internal_dac_widgets, - .num_dapm_widgets = ARRAY_SIZE(pistachio_internal_dac_widgets), - .dapm_routes = pistachio_internal_dac_routes, - .num_dapm_routes = ARRAY_SIZE(pistachio_internal_dac_routes), - }, +static const struct snd_soc_component_driver pistachio_internal_dac_driver = { + .probe = pistachio_internal_dac_codec_probe, + .controls = pistachio_internal_dac_snd_controls, + .num_controls = ARRAY_SIZE(pistachio_internal_dac_snd_controls), + .dapm_widgets = pistachio_internal_dac_widgets, + .num_dapm_widgets = ARRAY_SIZE(pistachio_internal_dac_widgets), + .dapm_routes = pistachio_internal_dac_routes, + .num_dapm_routes = ARRAY_SIZE(pistachio_internal_dac_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int pistachio_internal_dac_probe(struct platform_device *pdev) @@ -202,11 +202,12 @@ static int pistachio_internal_dac_probe(struct platform_device *pdev) pm_runtime_enable(dev); pm_runtime_idle(dev); - ret = snd_soc_register_codec(dev, &pistachio_internal_dac_driver, + ret = devm_snd_soc_register_component(dev, + &pistachio_internal_dac_driver, pistachio_internal_dac_dais, ARRAY_SIZE(pistachio_internal_dac_dais)); if (ret) { - dev_err(dev, "failed to register codec: %d\n", ret); + dev_err(dev, "failed to register component: %d\n", ret); goto err_pwr; } @@ -225,7 +226,6 @@ static int pistachio_internal_dac_remove(struct platform_device *pdev) { struct pistachio_internal_dac *dac = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); pistachio_internal_dac_pwr_off(dac); regulator_disable(dac->supply); From f5d5240e087556991b6f33eca6124f3b8f9da703 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:42:27 +0000 Subject: [PATCH 173/942] ASoC: lm49453: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/lm49453.c | 65 +++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/sound/soc/codecs/lm49453.c b/sound/soc/codecs/lm49453.c index 41e09d1287b8..59a646cc03d4 100644 --- a/sound/soc/codecs/lm49453.c +++ b/sound/soc/codecs/lm49453.c @@ -1110,7 +1110,7 @@ static int lm49453_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 clk_div = 0; /* Setting DAC clock dividers based on substream sample rate. */ @@ -1134,15 +1134,15 @@ static int lm49453_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_write(codec, LM49453_P0_ADC_CLK_DIV_REG, clk_div); - snd_soc_write(codec, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div); + snd_soc_component_write(component, LM49453_P0_ADC_CLK_DIV_REG, clk_div); + snd_soc_component_write(component, LM49453_P0_DAC_HP_CLK_DIV_REG, clk_div); return 0; } static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u16 aif_val; int mode = 0; @@ -1185,11 +1185,11 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, LM49453_P0_AUDIO_PORT1_BASIC_REG, + snd_soc_component_update_bits(component, LM49453_P0_AUDIO_PORT1_BASIC_REG, LM49453_AUDIO_PORT1_BASIC_FMT_MASK|BIT(0)|BIT(5), (aif_val | mode | clk_phase)); - snd_soc_write(codec, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift); + snd_soc_component_write(component, LM49453_P0_AUDIO_PORT1_RX_MSB_REG, clk_shift); return 0; } @@ -1197,7 +1197,7 @@ static int lm49453_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u16 pll_clk = 0; switch (freq) { @@ -1216,50 +1216,50 @@ static int lm49453_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, return -EINVAL; } - snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk); + snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, BIT(4), pll_clk); return 0; } static int lm49453_hp_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(1)|BIT(0), (mute ? (BIT(1)|BIT(0)) : 0)); return 0; } static int lm49453_lo_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(3)|BIT(2), (mute ? (BIT(3)|BIT(2)) : 0)); return 0; } static int lm49453_ls_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(5)|BIT(4), (mute ? (BIT(5)|BIT(4)) : 0)); return 0; } static int lm49453_ep_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(4), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(4), (mute ? BIT(4) : 0)); return 0; } static int lm49453_ha_mute(struct snd_soc_dai *dai, int mute) { - snd_soc_update_bits(dai->codec, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6), + snd_soc_component_update_bits(dai->component, LM49453_P0_DAC_DSP_REG, BIT(7)|BIT(6), (mute ? (BIT(7)|BIT(6)) : 0)); return 0; } -static int lm49453_set_bias_level(struct snd_soc_codec *codec, +static int lm49453_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec); + struct lm49453_priv *lm49453 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -1267,15 +1267,15 @@ static int lm49453_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) regcache_sync(lm49453->regmap); - snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, + snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, LM49453_PMC_SETUP_CHIP_EN, LM49453_CHIP_EN); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG, + snd_soc_component_update_bits(component, LM49453_P0_PMC_SETUP_REG, LM49453_PMC_SETUP_CHIP_EN, 0); break; } @@ -1389,17 +1389,17 @@ static struct snd_soc_dai_driver lm49453_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_lm49453 = { - .set_bias_level = lm49453_set_bias_level, - .component_driver = { - .controls = lm49453_snd_controls, - .num_controls = ARRAY_SIZE(lm49453_snd_controls), - .dapm_widgets = lm49453_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets), - .dapm_routes = lm49453_audio_map, - .num_dapm_routes = ARRAY_SIZE(lm49453_audio_map), - }, - .idle_bias_off = true, +static const struct snd_soc_component_driver soc_component_dev_lm49453 = { + .set_bias_level = lm49453_set_bias_level, + .controls = lm49453_snd_controls, + .num_controls = ARRAY_SIZE(lm49453_snd_controls), + .dapm_widgets = lm49453_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(lm49453_dapm_widgets), + .dapm_routes = lm49453_audio_map, + .num_dapm_routes = ARRAY_SIZE(lm49453_audio_map), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config lm49453_regmap_config = { @@ -1434,18 +1434,17 @@ static int lm49453_i2c_probe(struct i2c_client *i2c, return ret; } - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_lm49453, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_lm49453, lm49453_dai, ARRAY_SIZE(lm49453_dai)); if (ret < 0) - dev_err(&i2c->dev, "Failed to register codec: %d\n", ret); + dev_err(&i2c->dev, "Failed to register component: %d\n", ret); return ret; } static int lm49453_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } From 4f404f38c92b13815722dd6e808dde24cd65eed5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:42:49 +0000 Subject: [PATCH 174/942] ASoC: cq93vc: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cq93vc.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 3bf93652bb31..3301861d3502 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c @@ -45,7 +45,7 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = { static int cq93vc_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 reg; if (mute) @@ -53,7 +53,7 @@ static int cq93vc_mute(struct snd_soc_dai *dai, int mute) else reg = 0; - snd_soc_update_bits(codec, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE, + snd_soc_component_update_bits(component, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE, reg); return 0; @@ -72,23 +72,23 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai, return -EINVAL; } -static int cq93vc_set_bias_level(struct snd_soc_codec *codec, +static int cq93vc_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: - snd_soc_write(codec, DAVINCI_VC_REG12, + snd_soc_component_write(component, DAVINCI_VC_REG12, DAVINCI_VC_REG12_POWER_ALL_ON); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, DAVINCI_VC_REG12, + snd_soc_component_write(component, DAVINCI_VC_REG12, DAVINCI_VC_REG12_POWER_ALL_OFF); break; case SND_SOC_BIAS_OFF: /* force all power off */ - snd_soc_write(codec, DAVINCI_VC_REG12, + snd_soc_component_write(component, DAVINCI_VC_REG12, DAVINCI_VC_REG12_POWER_ALL_OFF); break; } @@ -130,24 +130,25 @@ static int cq93vc_probe(struct snd_soc_component *component) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_cq93vc = { - .set_bias_level = cq93vc_set_bias_level, - .component_driver = { - .probe = cq93vc_probe, - .controls = cq93vc_snd_controls, - .num_controls = ARRAY_SIZE(cq93vc_snd_controls), - }, +static const struct snd_soc_component_driver soc_component_dev_cq93vc = { + .set_bias_level = cq93vc_set_bias_level, + .probe = cq93vc_probe, + .controls = cq93vc_snd_controls, + .num_controls = ARRAY_SIZE(cq93vc_snd_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int cq93vc_platform_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_cq93vc, &cq93vc_dai, 1); + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_cq93vc, &cq93vc_dai, 1); } static int cq93vc_platform_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } From b48e6ef3a1db8527d0c99e578f3dd3ee40a2d573 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:43:36 +0000 Subject: [PATCH 175/942] ASoC: jz4740: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/jz4740.c | 48 +++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 27 deletions(-) diff --git a/sound/soc/codecs/jz4740.c b/sound/soc/codecs/jz4740.c index 6324ccdc8a5c..9395b583432c 100644 --- a/sound/soc/codecs/jz4740.c +++ b/sound/soc/codecs/jz4740.c @@ -157,7 +157,7 @@ static const struct snd_soc_dapm_route jz4740_codec_dapm_routes[] = { static int jz4740_codec_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(dai->codec); + struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(dai->component); uint32_t val; switch (params_rate(params)) { @@ -236,10 +236,10 @@ static void jz4740_codec_wakeup(struct regmap *regmap) regcache_sync(regmap); } -static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec, +static int jz4740_codec_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec); + struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(component); struct regmap *regmap = jz4740_codec->regmap; unsigned int mask; unsigned int value; @@ -257,7 +257,7 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: /* The only way to clear the suspend flag is to reset the codec */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) jz4740_codec_wakeup(regmap); mask = JZ4740_CODEC_1_VREF_DISABLE | @@ -283,9 +283,9 @@ static int jz4740_codec_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int jz4740_codec_dev_probe(struct snd_soc_codec *codec) +static int jz4740_codec_dev_probe(struct snd_soc_component *component) { - struct jz4740_codec *jz4740_codec = snd_soc_codec_get_drvdata(codec); + struct jz4740_codec *jz4740_codec = snd_soc_component_get_drvdata(component); regmap_update_bits(jz4740_codec->regmap, JZ4740_REG_CODEC_1, JZ4740_CODEC_1_SW2_ENABLE, JZ4740_CODEC_1_SW2_ENABLE); @@ -293,19 +293,21 @@ static int jz4740_codec_dev_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_jz4740_codec = { - .probe = jz4740_codec_dev_probe, - .set_bias_level = jz4740_codec_set_bias_level, - .suspend_bias_off = true, +static const struct snd_soc_component_driver soc_codec_dev_jz4740_codec = { + .probe = jz4740_codec_dev_probe, + .set_bias_level = jz4740_codec_set_bias_level, + .controls = jz4740_codec_controls, + .num_controls = ARRAY_SIZE(jz4740_codec_controls), + .dapm_widgets = jz4740_codec_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(jz4740_codec_dapm_widgets), + .dapm_routes = jz4740_codec_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(jz4740_codec_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, - .component_driver = { - .controls = jz4740_codec_controls, - .num_controls = ARRAY_SIZE(jz4740_codec_controls), - .dapm_widgets = jz4740_codec_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(jz4740_codec_dapm_widgets), - .dapm_routes = jz4740_codec_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(jz4740_codec_dapm_routes), - }, }; static const struct regmap_config jz4740_codec_regmap_config = { @@ -343,7 +345,7 @@ static int jz4740_codec_probe(struct platform_device *pdev) platform_set_drvdata(pdev, jz4740_codec); - ret = snd_soc_register_codec(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_dev_jz4740_codec, &jz4740_codec_dai, 1); if (ret) dev_err(&pdev->dev, "Failed to register codec\n"); @@ -351,16 +353,8 @@ static int jz4740_codec_probe(struct platform_device *pdev) return ret; } -static int jz4740_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver jz4740_codec_driver = { .probe = jz4740_codec_probe, - .remove = jz4740_codec_remove, .driver = { .name = "jz4740-codec", }, From b40822d9e8bc7fe43de1c68ab3ea5a485ba6a4fa Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:44:09 +0000 Subject: [PATCH 176/942] ASoC: uda1380: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/uda1380.c | 160 ++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 83 deletions(-) diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c index c73e6a192224..584a032b3cb1 100644 --- a/sound/soc/codecs/uda1380.c +++ b/sound/soc/codecs/uda1380.c @@ -34,7 +34,7 @@ /* codec private data */ struct uda1380_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int dac_clk; struct work_struct work; struct i2c_client *i2c; @@ -61,10 +61,10 @@ static unsigned long uda1380_cache_dirty; /* * read uda1380 register cache */ -static inline unsigned int uda1380_read_reg_cache(struct snd_soc_codec *codec, +static inline unsigned int uda1380_read_reg_cache(struct snd_soc_component *component, unsigned int reg) { - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); u16 *cache = uda1380->reg_cache; if (reg == UDA1380_RESET) @@ -77,10 +77,10 @@ static inline unsigned int uda1380_read_reg_cache(struct snd_soc_codec *codec, /* * write uda1380 register cache */ -static inline void uda1380_write_reg_cache(struct snd_soc_codec *codec, +static inline void uda1380_write_reg_cache(struct snd_soc_component *component, u16 reg, unsigned int value) { - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); u16 *cache = uda1380->reg_cache; if (reg >= UDA1380_CACHEREGNUM) @@ -93,10 +93,10 @@ static inline void uda1380_write_reg_cache(struct snd_soc_codec *codec, /* * write to the UDA1380 register space */ -static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg, +static int uda1380_write(struct snd_soc_component *component, unsigned int reg, unsigned int value) { - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); u8 data[3]; /* data is @@ -108,12 +108,12 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg, data[1] = (value & 0xff00) >> 8; data[2] = value & 0x00ff; - uda1380_write_reg_cache(codec, reg, value); + uda1380_write_reg_cache(component, reg, value); /* the interpolator & decimator regs must only be written when the * codec DAI is active. */ - if (!snd_soc_codec_is_active(codec) && (reg >= UDA1380_MVOL)) + if (!snd_soc_component_is_active(component) && (reg >= UDA1380_MVOL)) return 0; pr_debug("uda1380: hw write %x val %x\n", reg, value); if (i2c_master_send(uda1380->i2c, data, 3) == 3) { @@ -133,9 +133,9 @@ static int uda1380_write(struct snd_soc_codec *codec, unsigned int reg, return -EIO; } -static void uda1380_sync_cache(struct snd_soc_codec *codec) +static void uda1380_sync_cache(struct snd_soc_component *component) { - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); int reg; u8 data[3]; u16 *cache = uda1380->reg_cache; @@ -146,15 +146,15 @@ static void uda1380_sync_cache(struct snd_soc_codec *codec) data[1] = (cache[reg] & 0xff00) >> 8; data[2] = cache[reg] & 0x00ff; if (i2c_master_send(uda1380->i2c, data, 3) != 3) - dev_err(codec->dev, "%s: write to reg 0x%x failed\n", + dev_err(component->dev, "%s: write to reg 0x%x failed\n", __func__, reg); } } -static int uda1380_reset(struct snd_soc_codec *codec) +static int uda1380_reset(struct snd_soc_component *component) { - struct uda1380_platform_data *pdata = codec->dev->platform_data; - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); + struct uda1380_platform_data *pdata = component->dev->platform_data; + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); if (gpio_is_valid(pdata->gpio_reset)) { gpio_set_value(pdata->gpio_reset, 1); @@ -168,7 +168,7 @@ static int uda1380_reset(struct snd_soc_codec *codec) data[2] = 0; if (i2c_master_send(uda1380->i2c, data, 3) != 3) { - dev_err(codec->dev, "%s: failed\n", __func__); + dev_err(component->dev, "%s: failed\n", __func__); return -EIO; } } @@ -179,15 +179,15 @@ static int uda1380_reset(struct snd_soc_codec *codec) static void uda1380_flush_work(struct work_struct *work) { struct uda1380_priv *uda1380 = container_of(work, struct uda1380_priv, work); - struct snd_soc_codec *uda1380_codec = uda1380->codec; + struct snd_soc_component *uda1380_component = uda1380->component; int bit, reg; for_each_set_bit(bit, &uda1380_cache_dirty, UDA1380_CACHEREGNUM - 0x10) { reg = 0x10 + bit; pr_debug("uda1380: flush reg %x val %x:\n", reg, - uda1380_read_reg_cache(uda1380_codec, reg)); - uda1380_write(uda1380_codec, reg, - uda1380_read_reg_cache(uda1380_codec, reg)); + uda1380_read_reg_cache(uda1380_component, reg)); + uda1380_write(uda1380_component, reg, + uda1380_read_reg_cache(uda1380_component, reg)); clear_bit(bit, &uda1380_cache_dirty); } @@ -420,11 +420,11 @@ static const struct snd_soc_dapm_route uda1380_dapm_routes[] = { static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int iface; /* set up DAI based upon fmt */ - iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); + iface = uda1380_read_reg_cache(component, UDA1380_IFACE); iface &= ~(R01_SFORI_MASK | R01_SIM | R01_SFORO_MASK); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -442,7 +442,7 @@ static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) return -EINVAL; - uda1380_write_reg_cache(codec, UDA1380_IFACE, iface); + uda1380_write_reg_cache(component, UDA1380_IFACE, iface); return 0; } @@ -450,11 +450,11 @@ static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int iface; /* set up DAI based upon fmt */ - iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); + iface = uda1380_read_reg_cache(component, UDA1380_IFACE); iface &= ~R01_SFORI_MASK; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -472,7 +472,7 @@ static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai, if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) return -EINVAL; - uda1380_write(codec, UDA1380_IFACE, iface); + uda1380_write(component, UDA1380_IFACE, iface); return 0; } @@ -480,11 +480,11 @@ static int uda1380_set_dai_fmt_playback(struct snd_soc_dai *codec_dai, static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int iface; /* set up DAI based upon fmt */ - iface = uda1380_read_reg_cache(codec, UDA1380_IFACE); + iface = uda1380_read_reg_cache(component, UDA1380_IFACE); iface &= ~(R01_SIM | R01_SFORO_MASK); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -501,7 +501,7 @@ static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai, if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) == SND_SOC_DAIFMT_CBM_CFM) iface |= R01_SIM; - uda1380_write(codec, UDA1380_IFACE, iface); + uda1380_write(component, UDA1380_IFACE, iface); return 0; } @@ -509,20 +509,20 @@ static int uda1380_set_dai_fmt_capture(struct snd_soc_dai *codec_dai, static int uda1380_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); - int mixer = uda1380_read_reg_cache(codec, UDA1380_MIXER); + struct snd_soc_component *component = dai->component; + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); + int mixer = uda1380_read_reg_cache(component, UDA1380_MIXER); switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - uda1380_write_reg_cache(codec, UDA1380_MIXER, + uda1380_write_reg_cache(component, UDA1380_MIXER, mixer & ~R14_SILENCE); schedule_work(&uda1380->work); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - uda1380_write_reg_cache(codec, UDA1380_MIXER, + uda1380_write_reg_cache(component, UDA1380_MIXER, mixer | R14_SILENCE); schedule_work(&uda1380->work); break; @@ -534,13 +534,13 @@ static int uda1380_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); + struct snd_soc_component *component = dai->component; + u16 clk = uda1380_read_reg_cache(component, UDA1380_CLK); /* set WSPLL power and divider if running from this clock */ if (clk & R00_DAC_CLK) { int rate = params_rate(params); - u16 pm = uda1380_read_reg_cache(codec, UDA1380_PM); + u16 pm = uda1380_read_reg_cache(component, UDA1380_PM); clk &= ~0x3; /* clear SEL_LOOP_DIV */ switch (rate) { case 6250 ... 12500: @@ -556,7 +556,7 @@ static int uda1380_pcm_hw_params(struct snd_pcm_substream *substream, clk |= 0x3; break; } - uda1380_write(codec, UDA1380_PM, R02_PON_PLL | pm); + uda1380_write(component, UDA1380_PM, R02_PON_PLL | pm); } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -564,20 +564,20 @@ static int uda1380_pcm_hw_params(struct snd_pcm_substream *substream, else clk |= R00_EN_ADC | R00_EN_DEC; - uda1380_write(codec, UDA1380_CLK, clk); + uda1380_write(component, UDA1380_CLK, clk); return 0; } static void uda1380_pcm_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - u16 clk = uda1380_read_reg_cache(codec, UDA1380_CLK); + struct snd_soc_component *component = dai->component; + u16 clk = uda1380_read_reg_cache(component, UDA1380_CLK); /* shut down WSPLL power if running from this clock */ if (clk & R00_DAC_CLK) { - u16 pm = uda1380_read_reg_cache(codec, UDA1380_PM); - uda1380_write(codec, UDA1380_PM, ~R02_PON_PLL & pm); + u16 pm = uda1380_read_reg_cache(component, UDA1380_PM); + uda1380_write(component, UDA1380_PM, ~R02_PON_PLL & pm); } if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) @@ -585,33 +585,33 @@ static void uda1380_pcm_shutdown(struct snd_pcm_substream *substream, else clk &= ~(R00_EN_ADC | R00_EN_DEC); - uda1380_write(codec, UDA1380_CLK, clk); + uda1380_write(component, UDA1380_CLK, clk); } -static int uda1380_set_bias_level(struct snd_soc_codec *codec, +static int uda1380_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - int pm = uda1380_read_reg_cache(codec, UDA1380_PM); + int pm = uda1380_read_reg_cache(component, UDA1380_PM); int reg; - struct uda1380_platform_data *pdata = codec->dev->platform_data; + struct uda1380_platform_data *pdata = component->dev->platform_data; switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: /* ADC, DAC on */ - uda1380_write(codec, UDA1380_PM, R02_PON_BIAS | pm); + uda1380_write(component, UDA1380_PM, R02_PON_BIAS | pm); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { if (gpio_is_valid(pdata->gpio_power)) { gpio_set_value(pdata->gpio_power, 1); mdelay(1); - uda1380_reset(codec); + uda1380_reset(component); } - uda1380_sync_cache(codec); + uda1380_sync_cache(component); } - uda1380_write(codec, UDA1380_PM, 0x0); + uda1380_write(component, UDA1380_PM, 0x0); break; case SND_SOC_BIAS_OFF: if (!gpio_is_valid(pdata->gpio_power)) @@ -694,16 +694,16 @@ static struct snd_soc_dai_driver uda1380_dai[] = { }, }; -static int uda1380_probe(struct snd_soc_codec *codec) +static int uda1380_probe(struct snd_soc_component *component) { - struct uda1380_platform_data *pdata =codec->dev->platform_data; - struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec); + struct uda1380_platform_data *pdata =component->dev->platform_data; + struct uda1380_priv *uda1380 = snd_soc_component_get_drvdata(component); int ret; - uda1380->codec = codec; + uda1380->component = component; if (!gpio_is_valid(pdata->gpio_power)) { - ret = uda1380_reset(codec); + ret = uda1380_reset(component); if (ret) return ret; } @@ -713,10 +713,10 @@ static int uda1380_probe(struct snd_soc_codec *codec) /* set clock input */ switch (pdata->dac_clk) { case UDA1380_DAC_CLK_SYSCLK: - uda1380_write_reg_cache(codec, UDA1380_CLK, 0); + uda1380_write_reg_cache(component, UDA1380_CLK, 0); break; case UDA1380_DAC_CLK_WSPLL: - uda1380_write_reg_cache(codec, UDA1380_CLK, + uda1380_write_reg_cache(component, UDA1380_CLK, R00_DAC_CLK); break; } @@ -724,21 +724,22 @@ static int uda1380_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_uda1380 = { - .probe = uda1380_probe, - .read = uda1380_read_reg_cache, - .write = uda1380_write, - .set_bias_level = uda1380_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = uda1380_snd_controls, - .num_controls = ARRAY_SIZE(uda1380_snd_controls), - .dapm_widgets = uda1380_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), - .dapm_routes = uda1380_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_uda1380 = { + .probe = uda1380_probe, + .read = uda1380_read_reg_cache, + .write = uda1380_write, + .set_bias_level = uda1380_set_bias_level, + .controls = uda1380_snd_controls, + .num_controls = ARRAY_SIZE(uda1380_snd_controls), + .dapm_widgets = uda1380_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), + .dapm_routes = uda1380_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(uda1380_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int uda1380_i2c_probe(struct i2c_client *i2c, @@ -780,17 +781,11 @@ static int uda1380_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, uda1380); uda1380->i2c = i2c; - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_uda1380, uda1380_dai, ARRAY_SIZE(uda1380_dai)); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_uda1380, uda1380_dai, ARRAY_SIZE(uda1380_dai)); return ret; } -static int uda1380_i2c_remove(struct i2c_client *i2c) -{ - snd_soc_unregister_codec(&i2c->dev); - return 0; -} - static const struct i2c_device_id uda1380_i2c_id[] = { { "uda1380", 0 }, { } @@ -809,7 +804,6 @@ static struct i2c_driver uda1380_i2c_driver = { .of_match_table = uda1380_of_match, }, .probe = uda1380_i2c_probe, - .remove = uda1380_i2c_remove, .id_table = uda1380_i2c_id, }; From a9886cd02af5df2a93af178123194bf638cead03 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:44:35 +0000 Subject: [PATCH 177/942] ASoC: ml26124: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ml26124.c | 103 ++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c index 5cc960d8211e..a5fa490dc145 100644 --- a/sound/soc/codecs/ml26124.c +++ b/sound/soc/codecs/ml26124.c @@ -338,8 +338,8 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); int i = get_coeff(priv->mclk, params_rate(hw_params)); int srate; @@ -351,23 +351,23 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, if (priv->clk_in) { switch (priv->mclk / params_rate(hw_params)) { case 256: - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 1); break; case 512: - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 2); break; case 1024: - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 3); break; default: - dev_err(codec->dev, "Unsupported MCLKI\n"); + dev_err(component->dev, "Unsupported MCLKI\n"); break; } } else { - snd_soc_update_bits(codec, ML26124_CLK_CTL, + snd_soc_component_update_bits(component, ML26124_CLK_CTL, BIT(0) | BIT(1), 0); } @@ -375,35 +375,35 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, if (srate < 0) return srate; - snd_soc_update_bits(codec, ML26124_SMPLING_RATE, 0xf, srate); - snd_soc_update_bits(codec, ML26124_PLLNL, 0xff, coeff_div[i].pllnl); - snd_soc_update_bits(codec, ML26124_PLLNH, 0x1, coeff_div[i].pllnh); - snd_soc_update_bits(codec, ML26124_PLLML, 0xff, coeff_div[i].pllml); - snd_soc_update_bits(codec, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh); - snd_soc_update_bits(codec, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv); + snd_soc_component_update_bits(component, ML26124_SMPLING_RATE, 0xf, srate); + snd_soc_component_update_bits(component, ML26124_PLLNL, 0xff, coeff_div[i].pllnl); + snd_soc_component_update_bits(component, ML26124_PLLNH, 0x1, coeff_div[i].pllnh); + snd_soc_component_update_bits(component, ML26124_PLLML, 0xff, coeff_div[i].pllml); + snd_soc_component_update_bits(component, ML26124_PLLMH, 0x3f, coeff_div[i].pllmh); + snd_soc_component_update_bits(component, ML26124_PLLDIV, 0x1f, coeff_div[i].plldiv); return 0; } static int ml26124_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); switch (priv->substream->stream) { case SNDRV_PCM_STREAM_CAPTURE: - snd_soc_update_bits(codec, ML26124_REC_PLYBAK_RUN, BIT(0), 1); + snd_soc_component_update_bits(component, ML26124_REC_PLYBAK_RUN, BIT(0), 1); break; case SNDRV_PCM_STREAM_PLAYBACK: - snd_soc_update_bits(codec, ML26124_REC_PLYBAK_RUN, BIT(1), 2); + snd_soc_component_update_bits(component, ML26124_REC_PLYBAK_RUN, BIT(1), 2); break; } if (mute) - snd_soc_update_bits(codec, ML26124_DVOL_CTL, BIT(4), + snd_soc_component_update_bits(component, ML26124_DVOL_CTL, BIT(4), DVOL_CTL_DVMUTE_ON); else - snd_soc_update_bits(codec, ML26124_DVOL_CTL, BIT(4), + snd_soc_component_update_bits(component, ML26124_DVOL_CTL, BIT(4), DVOL_CTL_DVMUTE_OFF); return 0; @@ -413,7 +413,7 @@ static int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { unsigned char mode; - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; /* set master/slave audio interface */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -426,7 +426,7 @@ static int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, default: return -EINVAL; } - snd_soc_update_bits(codec, ML26124_SAI_MODE_SEL, BIT(0), mode); + snd_soc_component_update_bits(component, ML26124_SAI_MODE_SEL, BIT(0), mode); /* interface format */ switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -450,8 +450,8 @@ static int ml26124_set_dai_fmt(struct snd_soc_dai *codec_dai, static int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); switch (clk_id) { case ML26124_USE_PLLOUT: @@ -469,17 +469,17 @@ static int ml26124_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } -static int ml26124_set_bias_level(struct snd_soc_codec *codec, +static int ml26124_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); + struct ml26124_priv *priv = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, ML26124_PW_SPAMP_PW_MNG, + snd_soc_component_update_bits(component, ML26124_PW_SPAMP_PW_MNG, ML26124_R26_MASK, ML26124_BLT_PREAMP_ON); msleep(100); - snd_soc_update_bits(codec, ML26124_PW_SPAMP_PW_MNG, + snd_soc_component_update_bits(component, ML26124_PW_SPAMP_PW_MNG, ML26124_R26_MASK, ML26124_MICBEN_ON | ML26124_BLT_ALL_ON); break; @@ -487,8 +487,8 @@ static int ml26124_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: /* VMID ON */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_update_bits(codec, ML26124_PW_REF_PW_MNG, + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, ML26124_VMID, ML26124_VMID); msleep(500); regcache_sync(priv->regmap); @@ -496,7 +496,7 @@ static int ml26124_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: /* VMID OFF */ - snd_soc_update_bits(codec, ML26124_PW_REF_PW_MNG, + snd_soc_component_update_bits(component, ML26124_PW_REF_PW_MNG, ML26124_VMID, 0); break; } @@ -528,27 +528,29 @@ static struct snd_soc_dai_driver ml26124_dai = { .symmetric_rates = 1, }; -static int ml26124_probe(struct snd_soc_codec *codec) +static int ml26124_probe(struct snd_soc_component *component) { /* Software Reset */ - snd_soc_update_bits(codec, ML26124_SW_RST, 0x01, 1); - snd_soc_update_bits(codec, ML26124_SW_RST, 0x01, 0); + snd_soc_component_update_bits(component, ML26124_SW_RST, 0x01, 1); + snd_soc_component_update_bits(component, ML26124_SW_RST, 0x01, 0); return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_ml26124 = { - .probe = ml26124_probe, - .set_bias_level = ml26124_set_bias_level, - .suspend_bias_off = true, - .component_driver = { - .controls = ml26124_snd_controls, - .num_controls = ARRAY_SIZE(ml26124_snd_controls), - .dapm_widgets = ml26124_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ml26124_dapm_widgets), - .dapm_routes = ml26124_intercon, - .num_dapm_routes = ARRAY_SIZE(ml26124_intercon), - }, +static const struct snd_soc_component_driver soc_component_dev_ml26124 = { + .probe = ml26124_probe, + .set_bias_level = ml26124_set_bias_level, + .controls = ml26124_snd_controls, + .num_controls = ARRAY_SIZE(ml26124_snd_controls), + .dapm_widgets = ml26124_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ml26124_dapm_widgets), + .dapm_routes = ml26124_intercon, + .num_dapm_routes = ARRAY_SIZE(ml26124_intercon), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ml26124_i2c_regmap = { @@ -580,14 +582,8 @@ static int ml26124_i2c_probe(struct i2c_client *i2c, return ret; } - return snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_ml26124, &ml26124_dai, 1); -} - -static int ml26124_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_ml26124, &ml26124_dai, 1); } static const struct i2c_device_id ml26124_i2c_id[] = { @@ -601,7 +597,6 @@ static struct i2c_driver ml26124_i2c_driver = { .name = "ml26124", }, .probe = ml26124_i2c_probe, - .remove = ml26124_i2c_remove, .id_table = ml26124_i2c_id, }; From 8fcfe24c2345678000fab25bbd214025becf1154 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:45:14 +0000 Subject: [PATCH 178/942] ASoC: si476x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/si476x.c | 42 ++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 7b91ee267b4e..b779c2855c01 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c @@ -140,14 +140,14 @@ static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, si476x_core_lock(core); - err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, + err = snd_soc_component_update_bits(codec_dai->component, SI476X_DIGITAL_IO_OUTPUT_FORMAT, SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK, format); si476x_core_unlock(core); if (err < 0) { - dev_err(codec_dai->codec->dev, "Failed to set output format\n"); + dev_err(codec_dai->component->dev, "Failed to set output format\n"); return err; } @@ -163,7 +163,7 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, rate = params_rate(params); if (rate < 32000 || rate > 48000) { - dev_err(dai->codec->dev, "Rate: %d is not supported\n", rate); + dev_err(dai->component->dev, "Rate: %d is not supported\n", rate); return -EINVAL; } @@ -186,19 +186,19 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, si476x_core_lock(core); - err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE, + err = snd_soc_component_write(dai->component, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE, rate); if (err < 0) { - dev_err(dai->codec->dev, "Failed to set sample rate\n"); + dev_err(dai->component->dev, "Failed to set sample rate\n"); goto out; } - err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, + err = snd_soc_component_update_bits(dai->component, SI476X_DIGITAL_IO_OUTPUT_FORMAT, SI476X_DIGITAL_IO_OUTPUT_WIDTH_MASK, (width << SI476X_DIGITAL_IO_SLOT_SIZE_SHIFT) | (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT)); if (err < 0) { - dev_err(dai->codec->dev, "Failed to set output width\n"); + dev_err(dai->component->dev, "Failed to set output width\n"); goto out; } @@ -239,28 +239,25 @@ static int si476x_probe(struct snd_soc_component *component) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_si476x = { - .component_driver = { - .probe = si476x_probe, - .dapm_widgets = si476x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), - .dapm_routes = si476x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(si476x_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_si476x = { + .probe = si476x_probe, + .dapm_widgets = si476x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), + .dapm_routes = si476x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(si476x_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int si476x_platform_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_si476x, + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_si476x, &si476x_dai, 1); } -static int si476x_platform_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - MODULE_ALIAS("platform:si476x-codec"); static struct platform_driver si476x_platform_driver = { @@ -268,7 +265,6 @@ static struct platform_driver si476x_platform_driver = { .name = "si476x-codec", }, .probe = si476x_platform_probe, - .remove = si476x_platform_remove, }; module_platform_driver(si476x_platform_driver); From 2ab7fb08fb0bd24841bd05a4e51a44b4672b34f9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:45:43 +0000 Subject: [PATCH 179/942] ASoC: uda134x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/uda134x.c | 78 ++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index 77c9cc4467b8..3c935a941129 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c @@ -110,9 +110,9 @@ static int uda134x_regmap_write(void *context, unsigned int reg, return 0; } -static inline void uda134x_reset(struct snd_soc_codec *codec) +static inline void uda134x_reset(struct snd_soc_component *component) { - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); unsigned int mask = 1<<6; regmap_update_bits(uda134x->regmap, UDA134X_STATUS0, mask, mask); @@ -122,7 +122,7 @@ static inline void uda134x_reset(struct snd_soc_codec *codec) static int uda134x_mute(struct snd_soc_dai *dai, int mute) { - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(dai->codec); + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(dai->component); unsigned int mask = 1<<2; unsigned int val; @@ -139,8 +139,8 @@ static int uda134x_mute(struct snd_soc_dai *dai, int mute) static int uda134x_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *master_runtime; if (uda134x->master_substream) { @@ -168,8 +168,8 @@ static int uda134x_startup(struct snd_pcm_substream *substream, static void uda134x_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); if (uda134x->master_substream == substream) uda134x->master_substream = uda134x->slave_substream; @@ -181,8 +181,8 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); unsigned int hw_params = 0; if (substream == uda134x->slave_substream) { @@ -248,8 +248,8 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, static int uda134x_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); pr_debug("%s clk_id: %d, freq: %u, dir: %d\n", __func__, clk_id, freq, dir); @@ -270,8 +270,8 @@ static int uda134x_set_dai_sysclk(struct snd_soc_dai *codec_dai, static int uda134x_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); pr_debug("%s fmt: %08X\n", __func__, fmt); @@ -294,10 +294,10 @@ static int uda134x_set_dai_fmt(struct snd_soc_dai *codec_dai, return 0; } -static int uda134x_set_bias_level(struct snd_soc_codec *codec, +static int uda134x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); struct uda134x_platform_data *pd = uda134x->pd; pr_debug("%s bias level %d\n", __func__, level); @@ -446,10 +446,10 @@ static struct snd_soc_dai_driver uda134x_dai = { .ops = &uda134x_dai_ops, }; -static int uda134x_soc_probe(struct snd_soc_codec *codec) +static int uda134x_soc_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct uda134x_priv *uda134x = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct uda134x_priv *uda134x = snd_soc_component_get_drvdata(component); struct uda134x_platform_data *pd = uda134x->pd; const struct snd_soc_dapm_widget *widgets; unsigned num_widgets; @@ -473,7 +473,7 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec) if (pd->power) pd->power(1); - uda134x_reset(codec); + uda134x_reset(component); if (pd->model == UDA134X_UDA1341) { widgets = uda1341_dapm_widgets; @@ -493,15 +493,15 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec) switch (pd->model) { case UDA134X_UDA1340: case UDA134X_UDA1344: - ret = snd_soc_add_codec_controls(codec, uda1340_snd_controls, + ret = snd_soc_add_component_controls(component, uda1340_snd_controls, ARRAY_SIZE(uda1340_snd_controls)); break; case UDA134X_UDA1341: - ret = snd_soc_add_codec_controls(codec, uda1341_snd_controls, + ret = snd_soc_add_component_controls(component, uda1341_snd_controls, ARRAY_SIZE(uda1341_snd_controls)); break; case UDA134X_UDA1345: - ret = snd_soc_add_codec_controls(codec, uda1345_snd_controls, + ret = snd_soc_add_component_controls(component, uda1345_snd_controls, ARRAY_SIZE(uda1345_snd_controls)); break; default: @@ -518,17 +518,18 @@ static int uda134x_soc_probe(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_uda134x = { - .probe = uda134x_soc_probe, - .set_bias_level = uda134x_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .dapm_widgets = uda134x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(uda134x_dapm_widgets), - .dapm_routes = uda134x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(uda134x_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_uda134x = { + .probe = uda134x_soc_probe, + .set_bias_level = uda134x_set_bias_level, + .dapm_widgets = uda134x_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(uda134x_dapm_widgets), + .dapm_routes = uda134x_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(uda134x_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config uda134x_regmap_config = { @@ -571,14 +572,8 @@ static int uda134x_codec_probe(struct platform_device *pdev) if (IS_ERR(uda134x->regmap)) return PTR_ERR(uda134x->regmap); - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_uda134x, &uda134x_dai, 1); -} - -static int uda134x_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_uda134x, &uda134x_dai, 1); } static struct platform_driver uda134x_codec_driver = { @@ -586,7 +581,6 @@ static struct platform_driver uda134x_codec_driver = { .name = "uda134x-codec", }, .probe = uda134x_codec_probe, - .remove = uda134x_codec_remove, }; module_platform_driver(uda134x_codec_driver); From 7c8d90592165601fc7f133e72f06d7348d476579 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:46:16 +0000 Subject: [PATCH 180/942] ASoC: ics43432: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ics43432.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/ics43432.c b/sound/soc/codecs/ics43432.c index 651206273f36..148d6d6b2a2b 100644 --- a/sound/soc/codecs/ics43432.c +++ b/sound/soc/codecs/ics43432.c @@ -37,21 +37,20 @@ static struct snd_soc_dai_driver ics43432_dai = { }, }; -static const struct snd_soc_codec_driver ics43432_codec_driver = { +static const struct snd_soc_component_driver ics43432_component_driver = { + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ics43432_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, &ics43432_codec_driver, + return devm_snd_soc_register_component(&pdev->dev, + &ics43432_component_driver, &ics43432_dai, 1); } -static int ics43432_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - #ifdef CONFIG_OF static const struct of_device_id ics43432_ids[] = { { .compatible = "invensense,ics43432", }, @@ -66,7 +65,6 @@ static struct platform_driver ics43432_driver = { .of_match_table = of_match_ptr(ics43432_ids), }, .probe = ics43432_probe, - .remove = ics43432_remove, }; module_platform_driver(ics43432_driver); From f12df6614bee36c11ba0b3fb2d74b7d47b955434 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:47:19 +0000 Subject: [PATCH 181/942] ASoC: uniphier: evea: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/uniphier/evea.c | 67 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/sound/soc/uniphier/evea.c b/sound/soc/uniphier/evea.c index 0cc9efff1d9a..cad7e60de21d 100644 --- a/sound/soc/uniphier/evea.c +++ b/sound/soc/uniphier/evea.c @@ -220,8 +220,8 @@ static void evea_update_switch_all(struct evea_priv *evea) static int evea_get_switch_lin(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = evea->switch_lin; @@ -231,8 +231,8 @@ static int evea_get_switch_lin(struct snd_kcontrol *kcontrol, static int evea_set_switch_lin(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); if (evea->switch_lin == ucontrol->value.integer.value[0]) return 0; @@ -245,8 +245,8 @@ static int evea_set_switch_lin(struct snd_kcontrol *kcontrol, static int evea_get_switch_lo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = evea->switch_lo; @@ -256,8 +256,8 @@ static int evea_get_switch_lo(struct snd_kcontrol *kcontrol, static int evea_set_switch_lo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); if (evea->switch_lo == ucontrol->value.integer.value[0]) return 0; @@ -270,8 +270,8 @@ static int evea_set_switch_lo(struct snd_kcontrol *kcontrol, static int evea_get_switch_hp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = evea->switch_hp; @@ -281,8 +281,8 @@ static int evea_get_switch_hp(struct snd_kcontrol *kcontrol, static int evea_set_switch_hp(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); if (evea->switch_hp == ucontrol->value.integer.value[0]) return 0; @@ -301,9 +301,9 @@ static const struct snd_kcontrol_new eva_controls[] = { evea_get_switch_hp, evea_set_switch_hp), }; -static int evea_codec_probe(struct snd_soc_codec *codec) +static int evea_codec_probe(struct snd_soc_component *component) { - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); evea->switch_lin = 1; evea->switch_lo = 1; @@ -315,9 +315,9 @@ static int evea_codec_probe(struct snd_soc_codec *codec) return 0; } -static int evea_codec_suspend(struct snd_soc_codec *codec) +static int evea_codec_suspend(struct snd_soc_component *component) { - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); evea_set_power_state_off(evea); @@ -331,9 +331,9 @@ static int evea_codec_suspend(struct snd_soc_codec *codec) return 0; } -static int evea_codec_resume(struct snd_soc_codec *codec) +static int evea_codec_resume(struct snd_soc_component *component) { - struct evea_priv *evea = snd_soc_codec_get_drvdata(codec); + struct evea_priv *evea = snd_soc_component_get_drvdata(component); int ret; ret = clk_prepare_enable(evea->clk); @@ -376,19 +376,20 @@ err_out_clock: return ret; } -static struct snd_soc_codec_driver soc_codec_evea = { - .probe = evea_codec_probe, - .suspend = evea_codec_suspend, - .resume = evea_codec_resume, - - .component_driver = { - .dapm_widgets = evea_widgets, - .num_dapm_widgets = ARRAY_SIZE(evea_widgets), - .dapm_routes = evea_routes, - .num_dapm_routes = ARRAY_SIZE(evea_routes), - .controls = eva_controls, - .num_controls = ARRAY_SIZE(eva_controls), - }, +static struct snd_soc_component_driver soc_codec_evea = { + .probe = evea_codec_probe, + .suspend = evea_codec_suspend, + .resume = evea_codec_resume, + .dapm_widgets = evea_widgets, + .num_dapm_widgets = ARRAY_SIZE(evea_widgets), + .dapm_routes = evea_routes, + .num_dapm_routes = ARRAY_SIZE(evea_routes), + .controls = eva_controls, + .num_controls = ARRAY_SIZE(eva_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct snd_soc_dai_driver soc_dai_evea[] = { @@ -505,7 +506,7 @@ static int evea_probe(struct platform_device *pdev) platform_set_drvdata(pdev, evea); - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_evea, + ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_evea, soc_dai_evea, ARRAY_SIZE(soc_dai_evea)); if (ret) goto err_out_reset_adamv; @@ -534,8 +535,6 @@ static int evea_remove(struct platform_device *pdev) { struct evea_priv *evea = platform_get_drvdata(pdev); - snd_soc_unregister_codec(&pdev->dev); - reset_control_assert(evea->rst_adamv); reset_control_assert(evea->rst_exiv); reset_control_assert(evea->rst); From c044cfdaf26866d5d31cb715d24fb75bf93ef703 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:47:46 +0000 Subject: [PATCH 182/942] ASoC: pcm186x: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/pcm186x-i2c.c | 8 -- sound/soc/codecs/pcm186x-spi.c | 8 -- sound/soc/codecs/pcm186x.c | 143 ++++++++++++++++----------------- sound/soc/codecs/pcm186x.h | 1 - 4 files changed, 68 insertions(+), 92 deletions(-) diff --git a/sound/soc/codecs/pcm186x-i2c.c b/sound/soc/codecs/pcm186x-i2c.c index 543621232d60..0214dc6d84d0 100644 --- a/sound/soc/codecs/pcm186x-i2c.c +++ b/sound/soc/codecs/pcm186x-i2c.c @@ -36,13 +36,6 @@ static int pcm186x_i2c_probe(struct i2c_client *i2c, return pcm186x_probe(&i2c->dev, type, irq, regmap); } -static int pcm186x_i2c_remove(struct i2c_client *i2c) -{ - pcm186x_remove(&i2c->dev); - - return 0; -} - static const struct i2c_device_id pcm186x_i2c_id[] = { { "pcm1862", PCM1862 }, { "pcm1863", PCM1863 }, @@ -54,7 +47,6 @@ MODULE_DEVICE_TABLE(i2c, pcm186x_i2c_id); static struct i2c_driver pcm186x_i2c_driver = { .probe = pcm186x_i2c_probe, - .remove = pcm186x_i2c_remove, .id_table = pcm186x_i2c_id, .driver = { .name = "pcm186x", diff --git a/sound/soc/codecs/pcm186x-spi.c b/sound/soc/codecs/pcm186x-spi.c index 2366f8e4d4d4..b56e19827497 100644 --- a/sound/soc/codecs/pcm186x-spi.c +++ b/sound/soc/codecs/pcm186x-spi.c @@ -36,13 +36,6 @@ static int pcm186x_spi_probe(struct spi_device *spi) return pcm186x_probe(&spi->dev, type, irq, regmap); } -static int pcm186x_spi_remove(struct spi_device *spi) -{ - pcm186x_remove(&spi->dev); - - return 0; -} - static const struct spi_device_id pcm186x_spi_id[] = { { "pcm1862", PCM1862 }, { "pcm1863", PCM1863 }, @@ -54,7 +47,6 @@ MODULE_DEVICE_TABLE(spi, pcm186x_spi_id); static struct spi_driver pcm186x_spi_driver = { .probe = pcm186x_spi_probe, - .remove = pcm186x_spi_remove, .id_table = pcm186x_spi_id, .driver = { .name = "pcm186x", diff --git a/sound/soc/codecs/pcm186x.c b/sound/soc/codecs/pcm186x.c index cdb51427facc..88fde70b1e9e 100644 --- a/sound/soc/codecs/pcm186x.c +++ b/sound/soc/codecs/pcm186x.c @@ -262,9 +262,8 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - - struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component); unsigned int rate = params_rate(params); unsigned int format = params_format(params); unsigned int width = params_width(params); @@ -274,7 +273,7 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream, u8 tdm_tx_sel = 0; u8 pcm_cfg = 0; - dev_dbg(codec->dev, "%s() rate=%u format=0x%x width=%u channels=%u\n", + dev_dbg(component->dev, "%s() rate=%u format=0x%x width=%u channels=%u\n", __func__, rate, format, width, channels); switch (width) { @@ -306,7 +305,7 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, PCM186X_PCM_CFG, + snd_soc_component_update_bits(component, PCM186X_PCM_CFG, PCM186X_PCM_CFG_RX_WLEN_MASK | PCM186X_PCM_CFG_TX_WLEN_MASK, pcm_cfg); @@ -329,14 +328,14 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, PCM186X_TDM_TX_SEL, + snd_soc_component_update_bits(component, PCM186X_TDM_TX_SEL, PCM186X_TDM_TX_SEL_MASK, tdm_tx_sel); /* In DSP/TDM mode, the LRCLK divider must be 256 */ div_lrck = 256; /* Configure 1/256 duty cycle for LRCK */ - snd_soc_update_bits(codec, PCM186X_PCM_CFG, + snd_soc_component_update_bits(component, PCM186X_PCM_CFG, PCM186X_PCM_CFG_TDM_LRCK_MODE, PCM186X_PCM_CFG_TDM_LRCK_MODE); } @@ -345,12 +344,12 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream, if (priv->is_master_mode) { div_bck = priv->sysclk / (div_lrck * rate); - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s() master_clk=%u div_bck=%u div_lrck=%u\n", __func__, priv->sysclk, div_bck, div_lrck); - snd_soc_write(codec, PCM186X_BCK_DIV, div_bck - 1); - snd_soc_write(codec, PCM186X_LRK_DIV, div_lrck - 1); + snd_soc_component_write(component, PCM186X_BCK_DIV, div_bck - 1); + snd_soc_component_write(component, PCM186X_LRK_DIV, div_lrck - 1); } return 0; @@ -358,18 +357,18 @@ static int pcm186x_hw_params(struct snd_pcm_substream *substream, static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format) { - struct snd_soc_codec *codec = dai->codec; - struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component); u8 clk_ctrl = 0; u8 pcm_cfg = 0; - dev_dbg(codec->dev, "%s() format=0x%x\n", __func__, format); + dev_dbg(component->dev, "%s() format=0x%x\n", __func__, format); /* set master/slave audio interface */ switch (format & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: if (!priv->sysclk) { - dev_err(codec->dev, "operating in master mode requires sysclock to be configured\n"); + dev_err(component->dev, "operating in master mode requires sysclock to be configured\n"); return -EINVAL; } clk_ctrl |= PCM186X_CLK_CTRL_MST_MODE; @@ -379,7 +378,7 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format) priv->is_master_mode = false; break; default: - dev_err(codec->dev, "Invalid DAI master/slave interface\n"); + dev_err(component->dev, "Invalid DAI master/slave interface\n"); return -EINVAL; } @@ -388,7 +387,7 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format) case SND_SOC_DAIFMT_NB_NF: break; default: - dev_err(codec->dev, "Inverted DAI clocks not supported\n"); + dev_err(component->dev, "Inverted DAI clocks not supported\n"); return -EINVAL; } @@ -410,16 +409,16 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format) pcm_cfg = PCM186X_PCM_CFG_FMT_TDM; break; default: - dev_err(codec->dev, "Invalid DAI format\n"); + dev_err(component->dev, "Invalid DAI format\n"); return -EINVAL; } - snd_soc_update_bits(codec, PCM186X_CLK_CTRL, + snd_soc_component_update_bits(component, PCM186X_CLK_CTRL, PCM186X_CLK_CTRL_MST_MODE, clk_ctrl); - snd_soc_write(codec, PCM186X_TDM_TX_OFFSET, priv->tdm_offset); + snd_soc_component_write(component, PCM186X_TDM_TX_OFFSET, priv->tdm_offset); - snd_soc_update_bits(codec, PCM186X_PCM_CFG, + snd_soc_component_update_bits(component, PCM186X_PCM_CFG, PCM186X_PCM_CFG_FMT_MASK, pcm_cfg); return 0; @@ -428,16 +427,16 @@ static int pcm186x_set_fmt(struct snd_soc_dai *dai, unsigned int format) static int pcm186x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component); unsigned int first_slot, last_slot, tdm_offset; - dev_dbg(codec->dev, + dev_dbg(component->dev, "%s() tx_mask=0x%x rx_mask=0x%x slots=%d slot_width=%d\n", __func__, tx_mask, rx_mask, slots, slot_width); if (!tx_mask) { - dev_err(codec->dev, "tdm tx mask must not be 0\n"); + dev_err(component->dev, "tdm tx mask must not be 0\n"); return -EINVAL; } @@ -445,14 +444,14 @@ static int pcm186x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, last_slot = __fls(tx_mask); if (last_slot - first_slot != hweight32(tx_mask) - 1) { - dev_err(codec->dev, "tdm tx mask must be contiguous\n"); + dev_err(component->dev, "tdm tx mask must be contiguous\n"); return -EINVAL; } tdm_offset = first_slot * slot_width; if (tdm_offset > 255) { - dev_err(codec->dev, "tdm tx slot selection out of bounds\n"); + dev_err(component->dev, "tdm tx slot selection out of bounds\n"); return -EINVAL; } @@ -464,10 +463,10 @@ static int pcm186x_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int pcm186x_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s() clk_id=%d freq=%u dir=%d\n", + dev_dbg(component->dev, "%s() clk_id=%d freq=%u dir=%d\n", __func__, clk_id, freq, dir); priv->sysclk = freq; @@ -506,9 +505,9 @@ static struct snd_soc_dai_driver pcm1865_dai = { .ops = &pcm186x_dai_ops, }; -static int pcm186x_power_on(struct snd_soc_codec *codec) +static int pcm186x_power_on(struct snd_soc_component *component) { - struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); + struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component); int ret = 0; ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), @@ -519,25 +518,25 @@ static int pcm186x_power_on(struct snd_soc_codec *codec) regcache_cache_only(priv->regmap, false); ret = regcache_sync(priv->regmap); if (ret) { - dev_err(codec->dev, "Failed to restore cache\n"); + dev_err(component->dev, "Failed to restore cache\n"); regcache_cache_only(priv->regmap, true); regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); return ret; } - snd_soc_update_bits(codec, PCM186X_POWER_CTRL, + snd_soc_component_update_bits(component, PCM186X_POWER_CTRL, PCM186X_PWR_CTRL_PWRDN, 0); return 0; } -static int pcm186x_power_off(struct snd_soc_codec *codec) +static int pcm186x_power_off(struct snd_soc_component *component) { - struct pcm186x_priv *priv = snd_soc_codec_get_drvdata(codec); + struct pcm186x_priv *priv = snd_soc_component_get_drvdata(component); int ret; - snd_soc_update_bits(codec, PCM186X_POWER_CTRL, + snd_soc_component_update_bits(component, PCM186X_POWER_CTRL, PCM186X_PWR_CTRL_PWRDN, PCM186X_PWR_CTRL_PWRDN); regcache_cache_only(priv->regmap, true); @@ -550,11 +549,11 @@ static int pcm186x_power_off(struct snd_soc_codec *codec) return 0; } -static int pcm186x_set_bias_level(struct snd_soc_codec *codec, +static int pcm186x_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - dev_dbg(codec->dev, "## %s: %d -> %d\n", __func__, - snd_soc_codec_get_bias_level(codec), level); + dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, + snd_soc_component_get_bias_level(component), level); switch (level) { case SND_SOC_BIAS_ON: @@ -562,42 +561,44 @@ static int pcm186x_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) - pcm186x_power_on(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + pcm186x_power_on(component); break; case SND_SOC_BIAS_OFF: - pcm186x_power_off(codec); + pcm186x_power_off(component); break; } return 0; } -static struct snd_soc_codec_driver soc_codec_dev_pcm1863 = { - .set_bias_level = pcm186x_set_bias_level, - - .component_driver = { - .controls = pcm1863_snd_controls, - .num_controls = ARRAY_SIZE(pcm1863_snd_controls), - .dapm_widgets = pcm1863_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm1863_dapm_widgets), - .dapm_routes = pcm1863_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm1863_dapm_routes), - }, +static struct snd_soc_component_driver soc_codec_dev_pcm1863 = { + .set_bias_level = pcm186x_set_bias_level, + .controls = pcm1863_snd_controls, + .num_controls = ARRAY_SIZE(pcm1863_snd_controls), + .dapm_widgets = pcm1863_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm1863_dapm_widgets), + .dapm_routes = pcm1863_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm1863_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; -static struct snd_soc_codec_driver soc_codec_dev_pcm1865 = { - .set_bias_level = pcm186x_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = pcm1865_snd_controls, - .num_controls = ARRAY_SIZE(pcm1865_snd_controls), - .dapm_widgets = pcm1865_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(pcm1865_dapm_widgets), - .dapm_routes = pcm1865_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(pcm1865_dapm_routes), - }, +static struct snd_soc_component_driver soc_codec_dev_pcm1865 = { + .set_bias_level = pcm186x_set_bias_level, + .controls = pcm1865_snd_controls, + .num_controls = ARRAY_SIZE(pcm1865_snd_controls), + .dapm_widgets = pcm1865_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm1865_dapm_widgets), + .dapm_routes = pcm1865_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm1865_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static bool pcm186x_volatile(struct device *dev, unsigned int reg) @@ -687,13 +688,13 @@ int pcm186x_probe(struct device *dev, enum pcm186x_type type, int irq, switch (type) { case PCM1865: case PCM1864: - ret = snd_soc_register_codec(dev, &soc_codec_dev_pcm1865, + ret = devm_snd_soc_register_component(dev, &soc_codec_dev_pcm1865, &pcm1865_dai, 1); break; case PCM1863: case PCM1862: default: - ret = snd_soc_register_codec(dev, &soc_codec_dev_pcm1863, + ret = devm_snd_soc_register_component(dev, &soc_codec_dev_pcm1863, &pcm1863_dai, 1); } if (ret) { @@ -705,14 +706,6 @@ int pcm186x_probe(struct device *dev, enum pcm186x_type type, int irq, } EXPORT_SYMBOL_GPL(pcm186x_probe); -int pcm186x_remove(struct device *dev) -{ - snd_soc_unregister_codec(dev); - - return 0; -} -EXPORT_SYMBOL_GPL(pcm186x_remove); - MODULE_AUTHOR("Andreas Dannenberg "); MODULE_AUTHOR("Andrew F. Davis "); MODULE_DESCRIPTION("PCM186x Universal Audio ADC driver"); diff --git a/sound/soc/codecs/pcm186x.h b/sound/soc/codecs/pcm186x.h index b630111bb3c4..2c6ba55bf394 100644 --- a/sound/soc/codecs/pcm186x.h +++ b/sound/soc/codecs/pcm186x.h @@ -215,6 +215,5 @@ extern const struct regmap_config pcm186x_regmap; int pcm186x_probe(struct device *dev, enum pcm186x_type type, int irq, struct regmap *regmap); -int pcm186x_remove(struct device *dev); #endif /* _PCM186X_H_ */ From fbf3c936d8cfa7d754e5f782e26dd9caa4cba191 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:48:04 +0000 Subject: [PATCH 183/942] ASoC: tas6424: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/tas6424.c | 99 ++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/sound/soc/codecs/tas6424.c b/sound/soc/codecs/tas6424.c index 49b87f6e85bf..4f3a16c520a2 100644 --- a/sound/soc/codecs/tas6424.c +++ b/sound/soc/codecs/tas6424.c @@ -66,10 +66,10 @@ static const struct snd_kcontrol_new tas6424_snd_controls[] = { static int tas6424_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct tas6424_data *tas6424 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct tas6424_data *tas6424 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s() event=0x%0x\n", __func__, event); + dev_dbg(component->dev, "%s() event=0x%0x\n", __func__, event); if (event & SND_SOC_DAPM_POST_PMU) { /* Observe codec shutdown-to-active time */ @@ -105,12 +105,12 @@ static int tas6424_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int rate = params_rate(params); unsigned int width = params_width(params); u8 sap_ctrl = 0; - dev_dbg(codec->dev, "%s() rate=%u width=%u\n", __func__, rate, width); + dev_dbg(component->dev, "%s() rate=%u width=%u\n", __func__, rate, width); switch (rate) { case 44100: @@ -123,7 +123,7 @@ static int tas6424_hw_params(struct snd_pcm_substream *substream, sap_ctrl |= TAS6424_SAP_RATE_96000; break; default: - dev_err(codec->dev, "unsupported sample rate: %u\n", rate); + dev_err(component->dev, "unsupported sample rate: %u\n", rate); return -EINVAL; } @@ -134,11 +134,11 @@ static int tas6424_hw_params(struct snd_pcm_substream *substream, case 24: break; default: - dev_err(codec->dev, "unsupported sample width: %u\n", width); + dev_err(component->dev, "unsupported sample width: %u\n", width); return -EINVAL; } - snd_soc_update_bits(codec, TAS6424_SAP_CTRL, + snd_soc_component_update_bits(component, TAS6424_SAP_CTRL, TAS6424_SAP_RATE_MASK | TAS6424_SAP_TDM_SLOT_SZ_16, sap_ctrl); @@ -148,17 +148,17 @@ static int tas6424_hw_params(struct snd_pcm_substream *substream, static int tas6424_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 serial_format = 0; - dev_dbg(codec->dev, "%s() fmt=0x%0x\n", __func__, fmt); + dev_dbg(component->dev, "%s() fmt=0x%0x\n", __func__, fmt); /* clock masters */ switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: break; default: - dev_err(codec->dev, "Invalid DAI master/slave interface\n"); + dev_err(component->dev, "Invalid DAI master/slave interface\n"); return -EINVAL; } @@ -167,7 +167,7 @@ static int tas6424_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) case SND_SOC_DAIFMT_NB_NF: break; default: - dev_err(codec->dev, "Invalid DAI clock signal polarity\n"); + dev_err(component->dev, "Invalid DAI clock signal polarity\n"); return -EINVAL; } @@ -191,11 +191,11 @@ static int tas6424_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) serial_format |= TAS6424_SAP_LEFTJ; break; default: - dev_err(codec->dev, "Invalid DAI interface format\n"); + dev_err(component->dev, "Invalid DAI interface format\n"); return -EINVAL; } - snd_soc_update_bits(codec, TAS6424_SAP_CTRL, + snd_soc_component_update_bits(component, TAS6424_SAP_CTRL, TAS6424_SAP_FMT_MASK, serial_format); return 0; @@ -205,11 +205,11 @@ static int tas6424_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int first_slot, last_slot; bool sap_tdm_slot_last; - dev_dbg(codec->dev, "%s() tx_mask=%d rx_mask=%d\n", __func__, + dev_dbg(component->dev, "%s() tx_mask=%d rx_mask=%d\n", __func__, tx_mask, rx_mask); if (!tx_mask || !rx_mask) @@ -224,7 +224,7 @@ static int tas6424_set_dai_tdm_slot(struct snd_soc_dai *dai, last_slot = __fls(rx_mask); if (last_slot - first_slot != 4) { - dev_err(codec->dev, "tdm mask must cover 4 contiguous slots\n"); + dev_err(component->dev, "tdm mask must cover 4 contiguous slots\n"); return -EINVAL; } @@ -236,11 +236,11 @@ static int tas6424_set_dai_tdm_slot(struct snd_soc_dai *dai, sap_tdm_slot_last = true; break; default: - dev_err(codec->dev, "tdm mask must start at slot 0 or 4\n"); + dev_err(component->dev, "tdm mask must start at slot 0 or 4\n"); return -EINVAL; } - snd_soc_update_bits(codec, TAS6424_SAP_CTRL, TAS6424_SAP_TDM_SLOT_LAST, + snd_soc_component_update_bits(component, TAS6424_SAP_CTRL, TAS6424_SAP_TDM_SLOT_LAST, sap_tdm_slot_last ? TAS6424_SAP_TDM_SLOT_LAST : 0); return 0; @@ -248,27 +248,27 @@ static int tas6424_set_dai_tdm_slot(struct snd_soc_dai *dai, static int tas6424_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int val; - dev_dbg(codec->dev, "%s() mute=%d\n", __func__, mute); + dev_dbg(component->dev, "%s() mute=%d\n", __func__, mute); if (mute) val = TAS6424_ALL_STATE_MUTE; else val = TAS6424_ALL_STATE_PLAY; - snd_soc_write(codec, TAS6424_CH_STATE_CTRL, val); + snd_soc_component_write(component, TAS6424_CH_STATE_CTRL, val); return 0; } -static int tas6424_power_off(struct snd_soc_codec *codec) +static int tas6424_power_off(struct snd_soc_component *component) { - struct tas6424_data *tas6424 = snd_soc_codec_get_drvdata(codec); + struct tas6424_data *tas6424 = snd_soc_component_get_drvdata(component); int ret; - snd_soc_write(codec, TAS6424_CH_STATE_CTRL, TAS6424_ALL_STATE_HIZ); + snd_soc_component_write(component, TAS6424_CH_STATE_CTRL, TAS6424_ALL_STATE_HIZ); regcache_cache_only(tas6424->regmap, true); regcache_mark_dirty(tas6424->regmap); @@ -276,22 +276,22 @@ static int tas6424_power_off(struct snd_soc_codec *codec) ret = regulator_bulk_disable(ARRAY_SIZE(tas6424->supplies), tas6424->supplies); if (ret < 0) { - dev_err(codec->dev, "failed to disable supplies: %d\n", ret); + dev_err(component->dev, "failed to disable supplies: %d\n", ret); return ret; } return 0; } -static int tas6424_power_on(struct snd_soc_codec *codec) +static int tas6424_power_on(struct snd_soc_component *component) { - struct tas6424_data *tas6424 = snd_soc_codec_get_drvdata(codec); + struct tas6424_data *tas6424 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(tas6424->supplies), tas6424->supplies); if (ret < 0) { - dev_err(codec->dev, "failed to enable supplies: %d\n", ret); + dev_err(component->dev, "failed to enable supplies: %d\n", ret); return ret; } @@ -299,11 +299,11 @@ static int tas6424_power_on(struct snd_soc_codec *codec) ret = regcache_sync(tas6424->regmap); if (ret < 0) { - dev_err(codec->dev, "failed to sync regcache: %d\n", ret); + dev_err(component->dev, "failed to sync regcache: %d\n", ret); return ret; } - snd_soc_write(codec, TAS6424_CH_STATE_CTRL, TAS6424_ALL_STATE_MUTE); + snd_soc_component_write(component, TAS6424_CH_STATE_CTRL, TAS6424_ALL_STATE_MUTE); /* any time we come out of HIZ, the output channels automatically run DC * load diagnostics, wait here until this completes @@ -313,39 +313,38 @@ static int tas6424_power_on(struct snd_soc_codec *codec) return 0; } -static int tas6424_set_bias_level(struct snd_soc_codec *codec, +static int tas6424_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - dev_dbg(codec->dev, "%s() level=%d\n", __func__, level); + dev_dbg(component->dev, "%s() level=%d\n", __func__, level); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) - tas6424_power_on(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + tas6424_power_on(component); break; case SND_SOC_BIAS_OFF: - tas6424_power_off(codec); + tas6424_power_off(component); break; } return 0; } -static struct snd_soc_codec_driver soc_codec_dev_tas6424 = { - .set_bias_level = tas6424_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = tas6424_snd_controls, - .num_controls = ARRAY_SIZE(tas6424_snd_controls), - .dapm_widgets = tas6424_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(tas6424_dapm_widgets), - .dapm_routes = tas6424_audio_map, - .num_dapm_routes = ARRAY_SIZE(tas6424_audio_map), - }, +static struct snd_soc_component_driver soc_codec_dev_tas6424 = { + .set_bias_level = tas6424_set_bias_level, + .controls = tas6424_snd_controls, + .num_controls = ARRAY_SIZE(tas6424_snd_controls), + .dapm_widgets = tas6424_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tas6424_dapm_widgets), + .dapm_routes = tas6424_audio_map, + .num_dapm_routes = ARRAY_SIZE(tas6424_audio_map), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static struct snd_soc_dai_ops tas6424_speaker_dai_ops = { @@ -654,7 +653,7 @@ static int tas6424_i2c_probe(struct i2c_client *client, INIT_DELAYED_WORK(&tas6424->fault_check_work, tas6424_fault_check_work); - ret = snd_soc_register_codec(dev, &soc_codec_dev_tas6424, + ret = devm_snd_soc_register_component(dev, &soc_codec_dev_tas6424, tas6424_dai, ARRAY_SIZE(tas6424_dai)); if (ret < 0) { dev_err(dev, "unable to register codec: %d\n", ret); @@ -670,8 +669,6 @@ static int tas6424_i2c_remove(struct i2c_client *client) struct tas6424_data *tas6424 = dev_get_drvdata(dev); int ret; - snd_soc_unregister_codec(dev); - cancel_delayed_work_sync(&tas6424->fault_check_work); ret = regulator_bulk_disable(ARRAY_SIZE(tas6424->supplies), From 716c5223171e94a4dd28c6e8891b8ed9921c93a7 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:27:08 +0000 Subject: [PATCH 184/942] ASoC: atmel-pdmic: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-pdmic.c | 56 +++++++++++++++++------------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..5f72baa5f5c7 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -288,14 +288,14 @@ static const DECLARE_TLV_DB_RANGE(mic_gain_tlv, static int pdmic_get_mic_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); unsigned int dgain_val, scale_val; int i; - dgain_val = (snd_soc_read(codec, PDMIC_DSPR1) & PDMIC_DSPR1_DGAIN_MASK) + dgain_val = (snd_soc_component_read32(component, PDMIC_DSPR1) & PDMIC_DSPR1_DGAIN_MASK) >> PDMIC_DSPR1_DGAIN_SHIFT; - scale_val = (snd_soc_read(codec, PDMIC_DSPR0) & PDMIC_DSPR0_SCALE_MASK) + scale_val = (snd_soc_component_read32(component, PDMIC_DSPR0) & PDMIC_DSPR0_SCALE_MASK) >> PDMIC_DSPR0_SCALE_SHIFT; for (i = 0; i < ARRAY_SIZE(mic_gain_table); i++) { @@ -312,7 +312,7 @@ static int pdmic_put_mic_volsw(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int max = mc->max; unsigned int val; int ret; @@ -322,12 +322,12 @@ static int pdmic_put_mic_volsw(struct snd_kcontrol *kcontrol, if (val > max) return -EINVAL; - ret = snd_soc_update_bits(codec, PDMIC_DSPR1, PDMIC_DSPR1_DGAIN_MASK, + ret = snd_soc_component_update_bits(component, PDMIC_DSPR1, PDMIC_DSPR1_DGAIN_MASK, mic_gain_table[val].dgain << PDMIC_DSPR1_DGAIN_SHIFT); if (ret < 0) return ret; - ret = snd_soc_update_bits(codec, PDMIC_DSPR0, PDMIC_DSPR0_SCALE_MASK, + ret = snd_soc_component_update_bits(component, PDMIC_DSPR0, PDMIC_DSPR0_SCALE_MASK, mic_gain_table[val].scale << PDMIC_DSPR0_SCALE_SHIFT); if (ret < 0) return ret; @@ -346,23 +346,25 @@ SOC_SINGLE("High Pass Filter Switch", PDMIC_DSPR0, SOC_SINGLE("SINCC Filter Switch", PDMIC_DSPR0, PDMIC_DSPR0_SINBYP_SHIFT, 1, 1), }; -static int atmel_pdmic_codec_probe(struct snd_soc_codec *codec) +static int atmel_pdmic_component_probe(struct snd_soc_component *component) { - struct snd_soc_card *card = snd_soc_codec_get_drvdata(codec); + struct snd_soc_card *card = snd_soc_component_get_drvdata(component); struct atmel_pdmic *dd = snd_soc_card_get_drvdata(card); - snd_soc_update_bits(codec, PDMIC_DSPR1, PDMIC_DSPR1_OFFSET_MASK, + snd_soc_component_update_bits(component, PDMIC_DSPR1, PDMIC_DSPR1_OFFSET_MASK, (u32)(dd->pdata->mic_offset << PDMIC_DSPR1_OFFSET_SHIFT)); return 0; } -static struct snd_soc_codec_driver soc_codec_dev_pdmic = { - .probe = atmel_pdmic_codec_probe, - .component_driver = { - .controls = atmel_pdmic_snd_controls, - .num_controls = ARRAY_SIZE(atmel_pdmic_snd_controls), - }, +static struct snd_soc_component_driver soc_component_dev_pdmic = { + .probe = atmel_pdmic_component_probe, + .controls = atmel_pdmic_snd_controls, + .num_controls = ARRAY_SIZE(atmel_pdmic_snd_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* codec dai component */ @@ -375,7 +377,7 @@ atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct atmel_pdmic *dd = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int rate_min = substream->runtime->hw.rate_min; unsigned int rate_max = substream->runtime->hw.rate_max; int fs = params_rate(params); @@ -385,13 +387,13 @@ atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream, u32 mr_val, dspr0_val, pclk_prescal, gclk_prescal; if (params_channels(params) != 1) { - dev_err(codec->dev, + dev_err(component->dev, "only supports one channel\n"); return -EINVAL; } if ((fs < rate_min) || (fs > rate_max)) { - dev_err(codec->dev, + dev_err(component->dev, "sample rate is %dHz, min rate is %dHz, max rate is %dHz\n", fs, rate_min, rate_max); @@ -436,10 +438,10 @@ atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream, mr_val |= PDMIC_MR_CLKS_PCK << PDMIC_MR_CLKS_SHIFT; } - snd_soc_update_bits(codec, PDMIC_MR, + snd_soc_component_update_bits(component, PDMIC_MR, PDMIC_MR_PRESCAL_MASK | PDMIC_MR_CLKS_MASK, mr_val); - snd_soc_update_bits(codec, PDMIC_DSPR0, + snd_soc_component_update_bits(component, PDMIC_DSPR0, PDMIC_DSPR0_OSR_MASK | PDMIC_DSPR0_SIZE_MASK, dspr0_val); return 0; @@ -448,9 +450,9 @@ atmel_pdmic_codec_dai_hw_params(struct snd_pcm_substream *substream, static int atmel_pdmic_codec_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; - snd_soc_update_bits(codec, PDMIC_CR, PDMIC_CR_ENPDM_MASK, + snd_soc_component_update_bits(component, PDMIC_CR, PDMIC_CR_ENPDM_MASK, PDMIC_CR_ENPDM_DIS << PDMIC_CR_ENPDM_SHIFT); return 0; @@ -459,7 +461,7 @@ static int atmel_pdmic_codec_dai_prepare(struct snd_pcm_substream *substream, static int atmel_pdmic_codec_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u32 val; switch (cmd) { @@ -477,7 +479,7 @@ static int atmel_pdmic_codec_dai_trigger(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, PDMIC_CR, PDMIC_CR_ENPDM_MASK, val); + snd_soc_component_update_bits(component, PDMIC_CR, PDMIC_CR_ENPDM_MASK, val); return 0; } @@ -679,10 +681,10 @@ static int atmel_pdmic_probe(struct platform_device *pdev) /* register codec and codec dai */ atmel_pdmic_codec_dai.capture.rate_min = rate_min; atmel_pdmic_codec_dai.capture.rate_max = rate_max; - ret = snd_soc_register_codec(dev, &soc_codec_dev_pdmic, + ret = devm_snd_soc_register_component(dev, &soc_component_dev_pdmic, &atmel_pdmic_codec_dai, 1); if (ret) { - dev_err(dev, "could not register codec: %d\n", ret); + dev_err(dev, "could not register component: %d\n", ret); return ret; } @@ -710,13 +712,11 @@ static int atmel_pdmic_probe(struct platform_device *pdev) return 0; unregister_codec: - snd_soc_unregister_codec(dev); return ret; } static int atmel_pdmic_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } From 1e8ba922c0fca2586cc43a4884e071f8c5446e49 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:27:39 +0000 Subject: [PATCH 185/942] ASoC: atmel-classd: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-classd.c | 54 +++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..27bb55ca07ae 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -247,9 +247,9 @@ static const char * const pwm_type[] = { "Single ended", "Differential" }; -static int atmel_classd_codec_probe(struct snd_soc_codec *codec) +static int atmel_classd_component_probe(struct snd_soc_component *component) { - struct snd_soc_card *card = snd_soc_codec_get_drvdata(codec); + struct snd_soc_card *card = snd_soc_component_get_drvdata(component); struct atmel_classd *dd = snd_soc_card_get_drvdata(card); const struct atmel_classd_pdata *pdata = dd->pdata; u32 mask, val; @@ -283,16 +283,16 @@ static int atmel_classd_codec_probe(struct snd_soc_codec *codec) default: val |= (CLASSD_MR_NOVR_VAL_10NS << CLASSD_MR_NOVR_VAL_SHIFT); - dev_warn(codec->dev, + dev_warn(component->dev, "non-overlapping value %d is invalid, the default value 10 is specified\n", pdata->non_overlap_time); break; } } - snd_soc_update_bits(codec, CLASSD_MR, mask, val); + snd_soc_component_update_bits(component, CLASSD_MR, mask, val); - dev_info(codec->dev, + dev_info(component->dev, "PWM modulation type is %s, non-overlapping is %s\n", pwm_type[pdata->pwm_type], pdata->non_overlap_enable?"enabled":"disabled"); @@ -300,21 +300,23 @@ static int atmel_classd_codec_probe(struct snd_soc_codec *codec) return 0; } -static int atmel_classd_codec_resume(struct snd_soc_codec *codec) +static int atmel_classd_component_resume(struct snd_soc_component *component) { - struct snd_soc_card *card = snd_soc_codec_get_drvdata(codec); + struct snd_soc_card *card = snd_soc_component_get_drvdata(component); struct atmel_classd *dd = snd_soc_card_get_drvdata(card); return regcache_sync(dd->regmap); } -static struct snd_soc_codec_driver soc_codec_dev_classd = { - .probe = atmel_classd_codec_probe, - .resume = atmel_classd_codec_resume, - .component_driver = { - .controls = atmel_classd_snd_controls, - .num_controls = ARRAY_SIZE(atmel_classd_snd_controls), - }, +static struct snd_soc_component_driver soc_component_dev_classd = { + .probe = atmel_classd_component_probe, + .resume = atmel_classd_component_resume, + .controls = atmel_classd_snd_controls, + .num_controls = ARRAY_SIZE(atmel_classd_snd_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; /* codec dai component */ @@ -330,7 +332,7 @@ static int atmel_classd_codec_dai_startup(struct snd_pcm_substream *substream, static int atmel_classd_codec_dai_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u32 mask, val; mask = CLASSD_MR_LMUTE_MASK | CLASSD_MR_RMUTE_MASK; @@ -340,7 +342,7 @@ static int atmel_classd_codec_dai_digital_mute(struct snd_soc_dai *codec_dai, else val = 0; - snd_soc_update_bits(codec, CLASSD_MR, mask, val); + snd_soc_component_update_bits(component, CLASSD_MR, mask, val); return 0; } @@ -379,7 +381,7 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int fs; int i, best, best_val, cur_val, ret; u32 mask, val; @@ -397,7 +399,7 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, } } - dev_dbg(codec->dev, + dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz, GCLK_RATE of %ldHz\n", sample_rates[best].rate, sample_rates[best].gclk_rate); @@ -411,7 +413,7 @@ atmel_classd_codec_dai_hw_params(struct snd_pcm_substream *substream, val = (sample_rates[best].dsp_clk << CLASSD_INTPMR_DSP_CLK_FREQ_SHIFT) | (sample_rates[best].sample_rate << CLASSD_INTPMR_FRAME_SHIFT); - snd_soc_update_bits(codec, CLASSD_INTPMR, mask, val); + snd_soc_component_update_bits(component, CLASSD_INTPMR, mask, val); return clk_prepare_enable(dd->gclk); } @@ -429,9 +431,9 @@ atmel_classd_codec_dai_shutdown(struct snd_pcm_substream *substream, static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; - snd_soc_update_bits(codec, CLASSD_MR, + snd_soc_component_update_bits(component, CLASSD_MR, CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK, (CLASSD_MR_LEN_DIS << CLASSD_MR_LEN_SHIFT) |(CLASSD_MR_REN_DIS << CLASSD_MR_REN_SHIFT)); @@ -442,7 +444,7 @@ static int atmel_classd_codec_dai_prepare(struct snd_pcm_substream *substream, static int atmel_classd_codec_dai_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *codec_dai) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; u32 mask, val; mask = CLASSD_MR_LEN_MASK | CLASSD_MR_REN_MASK; @@ -463,7 +465,7 @@ static int atmel_classd_codec_dai_trigger(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, CLASSD_MR, mask, val); + snd_soc_component_update_bits(component, CLASSD_MR, mask, val); return 0; } @@ -612,10 +614,10 @@ static int atmel_classd_probe(struct platform_device *pdev) return ret; } - ret = snd_soc_register_codec(dev, &soc_codec_dev_classd, + ret = devm_snd_soc_register_component(dev, &soc_component_dev_classd, &atmel_classd_codec_dai, 1); if (ret) { - dev_err(dev, "could not register codec: %d\n", ret); + dev_err(dev, "could not register component: %d\n", ret); return ret; } @@ -643,13 +645,11 @@ static int atmel_classd_probe(struct platform_device *pdev) return 0; unregister_codec: - snd_soc_unregister_codec(dev); return ret; } static int atmel_classd_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); return 0; } From 4510112217116d97df02121d3e1442858efb4897 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:36:54 +0000 Subject: [PATCH 186/942] ASoC: hdac_hdmi/nau8825/rt286/rt298/rt5663/da7219: replace codec to component Now we can replace Codec to Component. Let's do it. Because intal/rockchip boards are using multi-codecs in 1 driver, we need to update these all related drivers in same time. Otherwise compile error/warning happen Note: hdac_hdmi xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 nau8825 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt286 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt298 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt5663 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 da7219 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/da7219-aad.c | 236 +++---- sound/soc/codecs/da7219-aad.h | 12 +- sound/soc/codecs/da7219.c | 307 ++++----- sound/soc/codecs/da7219.h | 2 +- sound/soc/codecs/hdac_hdmi.c | 47 +- sound/soc/codecs/hdac_hdmi.h | 2 +- sound/soc/codecs/nau8825.c | 107 ++-- sound/soc/codecs/nau8825.h | 2 +- sound/soc/codecs/rt286.c | 198 +++--- sound/soc/codecs/rt286.h | 2 +- sound/soc/codecs/rt298.c | 210 +++--- sound/soc/codecs/rt298.h | 2 +- sound/soc/codecs/rt5663.c | 598 +++++++++--------- sound/soc/codecs/rt5663.h | 4 +- sound/soc/intel/boards/broadwell.c | 14 +- sound/soc/intel/boards/bxt_da7219_max98357a.c | 12 +- sound/soc/intel/boards/bxt_rt298.c | 12 +- sound/soc/intel/boards/kbl_rt5663_max98927.c | 14 +- .../intel/boards/kbl_rt5663_rt5514_max98927.c | 14 +- .../soc/intel/boards/skl_nau88l25_max98357a.c | 12 +- sound/soc/intel/boards/skl_nau88l25_ssm4567.c | 12 +- sound/soc/intel/boards/skl_rt286.c | 12 +- sound/soc/rockchip/rk3399_gru_sound.c | 4 +- 23 files changed, 913 insertions(+), 922 deletions(-) diff --git a/sound/soc/codecs/da7219-aad.c b/sound/soc/codecs/da7219-aad.c index 1d1d10dd92ae..a49ab751a036 100644 --- a/sound/soc/codecs/da7219-aad.c +++ b/sound/soc/codecs/da7219-aad.c @@ -32,9 +32,9 @@ * Detection control */ -void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +void da7219_aad_jack_det(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); da7219->aad->jack = jack; da7219->aad->jack_inserted = false; @@ -43,7 +43,7 @@ void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack) snd_soc_jack_report(jack, 0, DA7219_AAD_REPORT_ALL_MASK); /* Enable/Disable jack detection */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, (jack ? DA7219_ACCDET_EN_MASK : 0)); } @@ -57,17 +57,17 @@ static void da7219_aad_btn_det_work(struct work_struct *work) { struct da7219_aad_priv *da7219_aad = container_of(work, struct da7219_aad_priv, btn_det_work); - struct snd_soc_codec *codec = da7219_aad->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = da7219_aad->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); u8 statusa, micbias_ctrl; bool micbias_up = false; int retries = 0; /* Drive headphones/lineout */ - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, DA7219_HP_L_AMP_OE_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, DA7219_HP_R_AMP_OE_MASK); @@ -76,7 +76,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) snd_soc_dapm_sync(dapm); do { - statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); + statusa = snd_soc_component_read32(component, DA7219_ACCDET_STATUS_A); if (statusa & DA7219_MICBIAS_UP_STS_MASK) micbias_up = true; else if (retries++ < DA7219_AAD_MICBIAS_CHK_RETRIES) @@ -84,7 +84,7 @@ static void da7219_aad_btn_det_work(struct work_struct *work) } while ((!micbias_up) && (retries < DA7219_AAD_MICBIAS_CHK_RETRIES)); if (retries >= DA7219_AAD_MICBIAS_CHK_RETRIES) - dev_warn(codec->dev, "Mic bias status check timed out"); + dev_warn(component->dev, "Mic bias status check timed out"); /* * Mic bias pulse required to enable mic, must be done before enabling @@ -92,16 +92,16 @@ static void da7219_aad_btn_det_work(struct work_struct *work) */ if (da7219_aad->micbias_pulse_lvl && da7219_aad->micbias_pulse_time) { /* Pulse higher level voltage */ - micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); - snd_soc_update_bits(codec, DA7219_MICBIAS_CTRL, + micbias_ctrl = snd_soc_component_read32(component, DA7219_MICBIAS_CTRL); + snd_soc_component_update_bits(component, DA7219_MICBIAS_CTRL, DA7219_MICBIAS1_LEVEL_MASK, da7219_aad->micbias_pulse_lvl); msleep(da7219_aad->micbias_pulse_time); - snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_ctrl); + snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_ctrl); } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_BUTTON_CONFIG_MASK, da7219_aad->btn_cfg); } @@ -110,9 +110,9 @@ static void da7219_aad_hptest_work(struct work_struct *work) { struct da7219_aad_priv *da7219_aad = container_of(work, struct da7219_aad_priv, hptest_work); - struct snd_soc_codec *codec = da7219_aad->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = da7219_aad->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u16 tonegen_freq_hptest; u8 pll_srm_sts, pll_ctrl, gain_ramp_ctrl, accdet_cfg8; @@ -127,7 +127,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) if (da7219->mclk) { ret = clk_prepare_enable(da7219->mclk); if (ret) { - dev_err(codec->dev, "Failed to enable mclk - %d\n", ret); + dev_err(component->dev, "Failed to enable mclk - %d\n", ret); mutex_unlock(&da7219->pll_lock); mutex_unlock(&da7219->ctrl_lock); snd_soc_dapm_mutex_unlock(dapm); @@ -142,90 +142,90 @@ static void da7219_aad_hptest_work(struct work_struct *work) * If MCLK is present, but PLL is not enabled then we enable it here to * ensure a consistent detection procedure. */ - pll_srm_sts = snd_soc_read(codec, DA7219_PLL_SRM_STS); + pll_srm_sts = snd_soc_component_read32(component, DA7219_PLL_SRM_STS); if (pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) { tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ); - pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7219_PLL_CTRL); if ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS) - da7219_set_pll(codec, DA7219_SYSCLK_PLL, + da7219_set_pll(component, DA7219_SYSCLK_PLL, DA7219_PLL_FREQ_OUT_98304); } else { tonegen_freq_hptest = cpu_to_le16(DA7219_AAD_HPTEST_RAMP_FREQ_INT_OSC); } /* Ensure gain ramping at fastest rate */ - gain_ramp_ctrl = snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8); + gain_ramp_ctrl = snd_soc_component_read32(component, DA7219_GAIN_RAMP_CTRL); + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_X8); /* Bypass cache so it saves current settings */ regcache_cache_bypass(da7219->regmap, true); /* Make sure Tone Generator is disabled */ - snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); + snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, 0); /* Enable HPTest block, 1KOhms check */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_8, DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_MASK, DA7219_HPTEST_EN_MASK | DA7219_HPTEST_RES_SEL_1KOHMS); /* Set gains to 0db */ - snd_soc_write(codec, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); - snd_soc_write(codec, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); - snd_soc_write(codec, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB); - snd_soc_write(codec, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB); + snd_soc_component_write(component, DA7219_DAC_L_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); + snd_soc_component_write(component, DA7219_DAC_R_GAIN, DA7219_DAC_DIGITAL_GAIN_0DB); + snd_soc_component_write(component, DA7219_HP_L_GAIN, DA7219_HP_AMP_GAIN_0DB); + snd_soc_component_write(component, DA7219_HP_R_GAIN, DA7219_HP_AMP_GAIN_0DB); /* Disable DAC filters, EQs and soft mute */ - snd_soc_update_bits(codec, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_FILTERS1, DA7219_HPF_MODE_MASK, 0); - snd_soc_update_bits(codec, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_FILTERS4, DA7219_DAC_EQ_EN_MASK, 0); - snd_soc_update_bits(codec, DA7219_DAC_FILTERS5, + snd_soc_component_update_bits(component, DA7219_DAC_FILTERS5, DA7219_DAC_SOFTMUTE_EN_MASK, 0); /* Enable HP left & right paths */ - snd_soc_update_bits(codec, DA7219_CP_CTRL, DA7219_CP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_CP_CTRL, DA7219_CP_EN_MASK, DA7219_CP_EN_MASK); - snd_soc_update_bits(codec, DA7219_DIG_ROUTING_DAC, + snd_soc_component_update_bits(component, DA7219_DIG_ROUTING_DAC, DA7219_DAC_L_SRC_MASK | DA7219_DAC_R_SRC_MASK, DA7219_DAC_L_SRC_TONEGEN | DA7219_DAC_R_SRC_TONEGEN); - snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, + snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_EN_MASK | DA7219_DAC_L_MUTE_EN_MASK, DA7219_DAC_L_EN_MASK); - snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, + snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_EN_MASK | DA7219_DAC_R_MUTE_EN_MASK, DA7219_DAC_R_EN_MASK); - snd_soc_update_bits(codec, DA7219_MIXOUT_L_SELECT, + snd_soc_component_update_bits(component, DA7219_MIXOUT_L_SELECT, DA7219_MIXOUT_L_MIX_SELECT_MASK, DA7219_MIXOUT_L_MIX_SELECT_MASK); - snd_soc_update_bits(codec, DA7219_MIXOUT_R_SELECT, + snd_soc_component_update_bits(component, DA7219_MIXOUT_R_SELECT, DA7219_MIXOUT_R_MIX_SELECT_MASK, DA7219_MIXOUT_R_MIX_SELECT_MASK); - snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1L, + snd_soc_component_update_bits(component, DA7219_DROUTING_ST_OUTFILT_1L, DA7219_OUTFILT_ST_1L_SRC_MASK, DA7219_DMIX_ST_SRC_OUTFILT1L); - snd_soc_update_bits(codec, DA7219_DROUTING_ST_OUTFILT_1R, + snd_soc_component_update_bits(component, DA7219_DROUTING_ST_OUTFILT_1R, DA7219_OUTFILT_ST_1R_SRC_MASK, DA7219_DMIX_ST_SRC_OUTFILT1R); - snd_soc_update_bits(codec, DA7219_MIXOUT_L_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXOUT_L_CTRL, DA7219_MIXOUT_L_AMP_EN_MASK, DA7219_MIXOUT_L_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_MIXOUT_R_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXOUT_R_CTRL, DA7219_MIXOUT_R_AMP_EN_MASK, DA7219_MIXOUT_R_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK, DA7219_HP_L_AMP_OE_MASK | DA7219_HP_L_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK, DA7219_HP_R_AMP_OE_MASK | DA7219_HP_R_AMP_EN_MASK); msleep(DA7219_SETTLING_DELAY); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_MUTE_EN_MASK | DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, 0); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_MUTE_EN_MASK | DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, 0); @@ -237,26 +237,26 @@ static void da7219_aad_hptest_work(struct work_struct *work) msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY); /* Configure & start Tone Generator */ - snd_soc_write(codec, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); + snd_soc_component_write(component, DA7219_TONE_GEN_ON_PER, DA7219_BEEP_ON_PER_MASK); regmap_raw_write(da7219->regmap, DA7219_TONE_GEN_FREQ1_L, &tonegen_freq_hptest, sizeof(tonegen_freq_hptest)); - snd_soc_update_bits(codec, DA7219_TONE_GEN_CFG2, + snd_soc_component_update_bits(component, DA7219_TONE_GEN_CFG2, DA7219_SWG_SEL_MASK | DA7219_TONE_GEN_GAIN_MASK, DA7219_SWG_SEL_SRAMP | DA7219_TONE_GEN_GAIN_MINUS_15DB); - snd_soc_write(codec, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK); + snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, DA7219_START_STOPN_MASK); msleep(DA7219_AAD_HPTEST_PERIOD); /* Grab comparator reading */ - accdet_cfg8 = snd_soc_read(codec, DA7219_ACCDET_CONFIG_8); + accdet_cfg8 = snd_soc_component_read32(component, DA7219_ACCDET_CONFIG_8); if (accdet_cfg8 & DA7219_HPTEST_COMP_MASK) report |= SND_JACK_HEADPHONE; else report |= SND_JACK_LINEOUT; /* Stop tone generator */ - snd_soc_write(codec, DA7219_TONE_GEN_CFG1, 0); + snd_soc_component_write(component, DA7219_TONE_GEN_CFG1, 0); msleep(DA7219_AAD_HPTEST_PERIOD); @@ -294,7 +294,7 @@ static void da7219_aad_hptest_work(struct work_struct *work) regcache_cache_bypass(da7219->regmap, false); /* Disable HPTest block */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_8, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_8, DA7219_HPTEST_EN_MASK, 0); /* @@ -305,18 +305,18 @@ static void da7219_aad_hptest_work(struct work_struct *work) msleep(DA7219_AAD_HPTEST_INT_OSC_PATH_DELAY); /* Restore gain ramping rate */ - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl); + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, gain_ramp_ctrl); /* Drive Headphones/lineout */ - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, DA7219_HP_L_AMP_OE_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, DA7219_HP_R_AMP_OE_MASK); /* Restore PLL to previous configuration, if re-configured */ if ((pll_srm_sts & DA7219_PLL_SRM_STS_MCLK) && ((pll_ctrl & DA7219_PLL_MODE_MASK) == DA7219_PLL_MODE_BYPASS)) - da7219_set_pll(codec, DA7219_SYSCLK_MCLK, 0); + da7219_set_pll(component, DA7219_SYSCLK_MCLK, 0); /* Remove MCLK, if previously enabled */ if (da7219->mclk) @@ -343,9 +343,9 @@ static void da7219_aad_hptest_work(struct work_struct *work) static irqreturn_t da7219_aad_irq_thread(int irq, void *data) { struct da7219_aad_priv *da7219_aad = data; - struct snd_soc_codec *codec = da7219_aad->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = da7219_aad->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 events[DA7219_AAD_IRQ_REG_MAX]; u8 statusa; int i, report = 0, mask = 0; @@ -358,13 +358,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) return IRQ_NONE; /* Read status register for jack insertion & type status */ - statusa = snd_soc_read(codec, DA7219_ACCDET_STATUS_A); + statusa = snd_soc_component_read32(component, DA7219_ACCDET_STATUS_A); /* Clear events */ regmap_bulk_write(da7219->regmap, DA7219_ACCDET_IRQ_EVENT_A, events, DA7219_AAD_IRQ_REG_MAX); - dev_dbg(codec->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", + dev_dbg(component->dev, "IRQ events = 0x%x|0x%x, status = 0x%x\n", events[DA7219_AAD_IRQ_REG_A], events[DA7219_AAD_IRQ_REG_B], statusa); @@ -430,13 +430,13 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) da7219_aad->jack_inserted = false; /* Un-drive headphones/lineout */ - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_OE_MASK, 0); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_OE_MASK, 0); /* Ensure button detection disabled */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_BUTTON_CONFIG_MASK, 0); /* Disable mic bias */ @@ -459,7 +459,7 @@ static irqreturn_t da7219_aad_irq_thread(int irq, void *data) */ static enum da7219_aad_micbias_pulse_lvl - da7219_aad_fw_micbias_pulse_lvl(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_micbias_pulse_lvl(struct snd_soc_component *component, u32 val) { switch (val) { case 2800: @@ -467,13 +467,13 @@ static enum da7219_aad_micbias_pulse_lvl case 2900: return DA7219_AAD_MICBIAS_PULSE_LVL_2_9V; default: - dev_warn(codec->dev, "Invalid micbias pulse level"); + dev_warn(component->dev, "Invalid micbias pulse level"); return DA7219_AAD_MICBIAS_PULSE_LVL_OFF; } } static enum da7219_aad_btn_cfg - da7219_aad_fw_btn_cfg(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_btn_cfg(struct snd_soc_component *component, u32 val) { switch (val) { case 2: @@ -491,13 +491,13 @@ static enum da7219_aad_btn_cfg case 500: return DA7219_AAD_BTN_CFG_500MS; default: - dev_warn(codec->dev, "Invalid button config"); + dev_warn(component->dev, "Invalid button config"); return DA7219_AAD_BTN_CFG_10MS; } } static enum da7219_aad_mic_det_thr - da7219_aad_fw_mic_det_thr(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_mic_det_thr(struct snd_soc_component *component, u32 val) { switch (val) { case 200: @@ -509,13 +509,13 @@ static enum da7219_aad_mic_det_thr case 1000: return DA7219_AAD_MIC_DET_THR_1000_OHMS; default: - dev_warn(codec->dev, "Invalid mic detect threshold"); + dev_warn(component->dev, "Invalid mic detect threshold"); return DA7219_AAD_MIC_DET_THR_500_OHMS; } } static enum da7219_aad_jack_ins_deb - da7219_aad_fw_jack_ins_deb(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_jack_ins_deb(struct snd_soc_component *component, u32 val) { switch (val) { case 5: @@ -535,13 +535,13 @@ static enum da7219_aad_jack_ins_deb case 1000: return DA7219_AAD_JACK_INS_DEB_1S; default: - dev_warn(codec->dev, "Invalid jack insert debounce"); + dev_warn(component->dev, "Invalid jack insert debounce"); return DA7219_AAD_JACK_INS_DEB_20MS; } } static enum da7219_aad_jack_det_rate - da7219_aad_fw_jack_det_rate(struct snd_soc_codec *codec, const char *str) + da7219_aad_fw_jack_det_rate(struct snd_soc_component *component, const char *str) { if (!strcmp(str, "32ms_64ms")) { return DA7219_AAD_JACK_DET_RATE_32_64MS; @@ -552,13 +552,13 @@ static enum da7219_aad_jack_det_rate } else if (!strcmp(str, "256ms_512ms")) { return DA7219_AAD_JACK_DET_RATE_256_512MS; } else { - dev_warn(codec->dev, "Invalid jack detect rate"); + dev_warn(component->dev, "Invalid jack detect rate"); return DA7219_AAD_JACK_DET_RATE_256_512MS; } } static enum da7219_aad_jack_rem_deb - da7219_aad_fw_jack_rem_deb(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_jack_rem_deb(struct snd_soc_component *component, u32 val) { switch (val) { case 1: @@ -570,13 +570,13 @@ static enum da7219_aad_jack_rem_deb case 20: return DA7219_AAD_JACK_REM_DEB_20MS; default: - dev_warn(codec->dev, "Invalid jack removal debounce"); + dev_warn(component->dev, "Invalid jack removal debounce"); return DA7219_AAD_JACK_REM_DEB_1MS; } } static enum da7219_aad_btn_avg - da7219_aad_fw_btn_avg(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_btn_avg(struct snd_soc_component *component, u32 val) { switch (val) { case 1: @@ -588,13 +588,13 @@ static enum da7219_aad_btn_avg case 8: return DA7219_AAD_BTN_AVG_8; default: - dev_warn(codec->dev, "Invalid button average value"); + dev_warn(component->dev, "Invalid button average value"); return DA7219_AAD_BTN_AVG_2; } } static enum da7219_aad_adc_1bit_rpt - da7219_aad_fw_adc_1bit_rpt(struct snd_soc_codec *codec, u32 val) + da7219_aad_fw_adc_1bit_rpt(struct snd_soc_component *component, u32 val) { switch (val) { case 1: @@ -606,14 +606,14 @@ static enum da7219_aad_adc_1bit_rpt case 8: return DA7219_AAD_ADC_1BIT_RPT_8; default: - dev_warn(codec->dev, "Invalid ADC 1-bit repeat value"); + dev_warn(component->dev, "Invalid ADC 1-bit repeat value"); return DA7219_AAD_ADC_1BIT_RPT_1; } } -static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *codec) +static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_component *component) { - struct device *dev = codec->dev; + struct device *dev = component->dev; struct i2c_client *i2c = to_i2c_client(dev); struct fwnode_handle *aad_np; struct da7219_aad_pdata *aad_pdata; @@ -624,7 +624,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod if (!aad_np) return NULL; - aad_pdata = devm_kzalloc(codec->dev, sizeof(*aad_pdata), GFP_KERNEL); + aad_pdata = devm_kzalloc(dev, sizeof(*aad_pdata), GFP_KERNEL); if (!aad_pdata) return NULL; @@ -633,7 +633,7 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod if (fwnode_property_read_u32(aad_np, "dlg,micbias-pulse-lvl", &fw_val32) >= 0) aad_pdata->micbias_pulse_lvl = - da7219_aad_fw_micbias_pulse_lvl(codec, fw_val32); + da7219_aad_fw_micbias_pulse_lvl(component, fw_val32); else aad_pdata->micbias_pulse_lvl = DA7219_AAD_MICBIAS_PULSE_LVL_OFF; @@ -642,31 +642,31 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod aad_pdata->micbias_pulse_time = fw_val32; if (fwnode_property_read_u32(aad_np, "dlg,btn-cfg", &fw_val32) >= 0) - aad_pdata->btn_cfg = da7219_aad_fw_btn_cfg(codec, fw_val32); + aad_pdata->btn_cfg = da7219_aad_fw_btn_cfg(component, fw_val32); else aad_pdata->btn_cfg = DA7219_AAD_BTN_CFG_10MS; if (fwnode_property_read_u32(aad_np, "dlg,mic-det-thr", &fw_val32) >= 0) aad_pdata->mic_det_thr = - da7219_aad_fw_mic_det_thr(codec, fw_val32); + da7219_aad_fw_mic_det_thr(component, fw_val32); else aad_pdata->mic_det_thr = DA7219_AAD_MIC_DET_THR_500_OHMS; if (fwnode_property_read_u32(aad_np, "dlg,jack-ins-deb", &fw_val32) >= 0) aad_pdata->jack_ins_deb = - da7219_aad_fw_jack_ins_deb(codec, fw_val32); + da7219_aad_fw_jack_ins_deb(component, fw_val32); else aad_pdata->jack_ins_deb = DA7219_AAD_JACK_INS_DEB_20MS; if (!fwnode_property_read_string(aad_np, "dlg,jack-det-rate", &fw_str)) aad_pdata->jack_det_rate = - da7219_aad_fw_jack_det_rate(codec, fw_str); + da7219_aad_fw_jack_det_rate(component, fw_str); else aad_pdata->jack_det_rate = DA7219_AAD_JACK_DET_RATE_256_512MS; if (fwnode_property_read_u32(aad_np, "dlg,jack-rem-deb", &fw_val32) >= 0) aad_pdata->jack_rem_deb = - da7219_aad_fw_jack_rem_deb(codec, fw_val32); + da7219_aad_fw_jack_rem_deb(component, fw_val32); else aad_pdata->jack_rem_deb = DA7219_AAD_JACK_REM_DEB_1MS; @@ -691,22 +691,22 @@ static struct da7219_aad_pdata *da7219_aad_fw_to_pdata(struct snd_soc_codec *cod aad_pdata->c_mic_btn_thr = 0x3E; if (fwnode_property_read_u32(aad_np, "dlg,btn-avg", &fw_val32) >= 0) - aad_pdata->btn_avg = da7219_aad_fw_btn_avg(codec, fw_val32); + aad_pdata->btn_avg = da7219_aad_fw_btn_avg(component, fw_val32); else aad_pdata->btn_avg = DA7219_AAD_BTN_AVG_2; if (fwnode_property_read_u32(aad_np, "dlg,adc-1bit-rpt", &fw_val32) >= 0) aad_pdata->adc_1bit_rpt = - da7219_aad_fw_adc_1bit_rpt(codec, fw_val32); + da7219_aad_fw_adc_1bit_rpt(component, fw_val32); else aad_pdata->adc_1bit_rpt = DA7219_AAD_ADC_1BIT_RPT_1; return aad_pdata; } -static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) +static void da7219_aad_handle_pdata(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; struct da7219_pdata *pdata = da7219->pdata; @@ -752,7 +752,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) DA7219_MIC_DET_THRESH_SHIFT); mask |= DA7219_MIC_DET_THRESH_MASK; } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, mask, cfg); + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, mask, cfg); cfg = 0; mask = 0; @@ -787,15 +787,15 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) DA7219_JACKDET_REM_DEB_SHIFT); mask |= DA7219_JACKDET_REM_DEB_MASK; } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_2, mask, cfg); + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_2, mask, cfg); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_3, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_3, aad_pdata->a_d_btn_thr); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_4, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_4, aad_pdata->d_b_btn_thr); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_5, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_5, aad_pdata->b_c_btn_thr); - snd_soc_write(codec, DA7219_ACCDET_CONFIG_6, + snd_soc_component_write(component, DA7219_ACCDET_CONFIG_6, aad_pdata->c_mic_btn_thr); cfg = 0; @@ -818,7 +818,7 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) DA7219_ADC_1_BIT_REPEAT_SHIFT); mask |= DA7219_ADC_1_BIT_REPEAT_MASK; } - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_7, mask, cfg); + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_7, mask, cfg); } } @@ -827,16 +827,16 @@ static void da7219_aad_handle_pdata(struct snd_soc_codec *codec) * Suspend/Resume */ -void da7219_aad_suspend(struct snd_soc_codec *codec) +void da7219_aad_suspend(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); u8 micbias_ctrl; if (da7219_aad->jack) { /* Disable jack detection during suspend */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, 0); /* @@ -846,7 +846,7 @@ void da7219_aad_suspend(struct snd_soc_codec *codec) * suspend then this will be dealt with through the IRQ handler. */ if (da7219_aad->jack_inserted) { - micbias_ctrl = snd_soc_read(codec, DA7219_MICBIAS_CTRL); + micbias_ctrl = snd_soc_component_read32(component, DA7219_MICBIAS_CTRL); if (micbias_ctrl & DA7219_MICBIAS1_EN_MASK) { snd_soc_dapm_disable_pin(dapm, "Mic Bias"); snd_soc_dapm_sync(dapm); @@ -856,11 +856,11 @@ void da7219_aad_suspend(struct snd_soc_codec *codec) } } -void da7219_aad_resume(struct snd_soc_codec *codec) +void da7219_aad_resume(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (da7219_aad->jack) { /* Re-enable micbias if previously enabled for 4-pole jack */ @@ -872,7 +872,7 @@ void da7219_aad_resume(struct snd_soc_codec *codec) } /* Re-enable jack detection */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, DA7219_ACCDET_EN_MASK); } @@ -883,28 +883,28 @@ void da7219_aad_resume(struct snd_soc_codec *codec) * Init/Exit */ -int da7219_aad_init(struct snd_soc_codec *codec) +int da7219_aad_init(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad; u8 mask[DA7219_AAD_IRQ_REG_MAX]; int ret; - da7219_aad = devm_kzalloc(codec->dev, sizeof(*da7219_aad), GFP_KERNEL); + da7219_aad = devm_kzalloc(component->dev, sizeof(*da7219_aad), GFP_KERNEL); if (!da7219_aad) return -ENOMEM; da7219->aad = da7219_aad; - da7219_aad->codec = codec; + da7219_aad->component = component; /* Handle any DT/ACPI/platform data */ if (da7219->pdata && !da7219->pdata->aad_pdata) - da7219->pdata->aad_pdata = da7219_aad_fw_to_pdata(codec); + da7219->pdata->aad_pdata = da7219_aad_fw_to_pdata(component); - da7219_aad_handle_pdata(codec); + da7219_aad_handle_pdata(component); /* Disable button detection */ - snd_soc_update_bits(codec, DA7219_ACCDET_CONFIG_1, + snd_soc_component_update_bits(component, DA7219_ACCDET_CONFIG_1, DA7219_BUTTON_CONFIG_MASK, 0); INIT_WORK(&da7219_aad->btn_det_work, da7219_aad_btn_det_work); @@ -915,7 +915,7 @@ int da7219_aad_init(struct snd_soc_codec *codec) IRQF_TRIGGER_LOW | IRQF_ONESHOT, "da7219-aad", da7219_aad); if (ret) { - dev_err(codec->dev, "Failed to request IRQ: %d\n", ret); + dev_err(component->dev, "Failed to request IRQ: %d\n", ret); return ret; } @@ -928,9 +928,9 @@ int da7219_aad_init(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(da7219_aad_init); -void da7219_aad_exit(struct snd_soc_codec *codec) +void da7219_aad_exit(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_aad_priv *da7219_aad = da7219->aad; u8 mask[DA7219_AAD_IRQ_REG_MAX]; diff --git a/sound/soc/codecs/da7219-aad.h b/sound/soc/codecs/da7219-aad.h index 117a3d7ccd31..b9c4a27e8e61 100644 --- a/sound/soc/codecs/da7219-aad.h +++ b/sound/soc/codecs/da7219-aad.h @@ -189,7 +189,7 @@ enum da7219_aad_event_regs { /* Private data */ struct da7219_aad_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; int irq; u8 micbias_pulse_lvl; @@ -206,14 +206,14 @@ struct da7219_aad_priv { }; /* AAD control */ -void da7219_aad_jack_det(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +void da7219_aad_jack_det(struct snd_soc_component *component, struct snd_soc_jack *jack); /* Suspend/Resume */ -void da7219_aad_suspend(struct snd_soc_codec *codec); -void da7219_aad_resume(struct snd_soc_codec *codec); +void da7219_aad_suspend(struct snd_soc_component *component); +void da7219_aad_resume(struct snd_soc_component *component); /* Init/Exit */ -int da7219_aad_init(struct snd_soc_codec *codec); -void da7219_aad_exit(struct snd_soc_codec *codec); +int da7219_aad_init(struct snd_soc_component *component); +void da7219_aad_exit(struct snd_soc_component *component); #endif /* __DA7219_AAD_H */ diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 6f088536df32..5e043d082f4b 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -256,8 +256,8 @@ static const struct soc_enum da7219_cp_track_mode = static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -270,8 +270,8 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol, static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -284,8 +284,8 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -298,8 +298,8 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol, static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->ctrl_lock); @@ -310,55 +310,55 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol, } /* ALC */ -static void da7219_alc_calib(struct snd_soc_codec *codec) +static void da7219_alc_calib(struct snd_soc_component *component) { u8 mic_ctrl, mixin_ctrl, adc_ctrl, calib_ctrl; /* Save current state of mic control register */ - mic_ctrl = snd_soc_read(codec, DA7219_MIC_1_CTRL); + mic_ctrl = snd_soc_component_read32(component, DA7219_MIC_1_CTRL); /* Save current state of input mixer control register */ - mixin_ctrl = snd_soc_read(codec, DA7219_MIXIN_L_CTRL); + mixin_ctrl = snd_soc_component_read32(component, DA7219_MIXIN_L_CTRL); /* Save current state of input ADC control register */ - adc_ctrl = snd_soc_read(codec, DA7219_ADC_L_CTRL); + adc_ctrl = snd_soc_component_read32(component, DA7219_ADC_L_CTRL); /* Enable then Mute MIC PGAs */ - snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_EN_MASK, DA7219_MIC_1_AMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_MIC_1_CTRL, + snd_soc_component_update_bits(component, DA7219_MIC_1_CTRL, DA7219_MIC_1_AMP_MUTE_EN_MASK, DA7219_MIC_1_AMP_MUTE_EN_MASK); /* Enable input mixers unmuted */ - snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL, DA7219_MIXIN_L_AMP_EN_MASK | DA7219_MIXIN_L_AMP_MUTE_EN_MASK, DA7219_MIXIN_L_AMP_EN_MASK); /* Enable input filters unmuted */ - snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, + snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_MUTE_EN_MASK | DA7219_ADC_L_EN_MASK, DA7219_ADC_L_EN_MASK); /* Perform auto calibration */ - snd_soc_update_bits(codec, DA7219_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7219_ALC_CTRL1, DA7219_ALC_AUTO_CALIB_EN_MASK, DA7219_ALC_AUTO_CALIB_EN_MASK); do { - calib_ctrl = snd_soc_read(codec, DA7219_ALC_CTRL1); + calib_ctrl = snd_soc_component_read32(component, DA7219_ALC_CTRL1); } while (calib_ctrl & DA7219_ALC_AUTO_CALIB_EN_MASK); /* If auto calibration fails, disable DC offset, hybrid ALC */ if (calib_ctrl & DA7219_ALC_CALIB_OVERFLOW_MASK) { - dev_warn(codec->dev, + dev_warn(component->dev, "ALC auto calibration failed with overflow\n"); - snd_soc_update_bits(codec, DA7219_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7219_ALC_CTRL1, DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_SYNC_MODE_MASK, 0); } else { /* Enable DC offset cancellation, hybrid mode */ - snd_soc_update_bits(codec, DA7219_ALC_CTRL1, + snd_soc_component_update_bits(component, DA7219_ALC_CTRL1, DA7219_ALC_OFFSET_EN_MASK | DA7219_ALC_SYNC_MODE_MASK, DA7219_ALC_OFFSET_EN_MASK | @@ -366,20 +366,20 @@ static void da7219_alc_calib(struct snd_soc_codec *codec) } /* Restore input filter control register to original state */ - snd_soc_write(codec, DA7219_ADC_L_CTRL, adc_ctrl); + snd_soc_component_write(component, DA7219_ADC_L_CTRL, adc_ctrl); /* Restore input mixer control registers to original state */ - snd_soc_write(codec, DA7219_MIXIN_L_CTRL, mixin_ctrl); + snd_soc_component_write(component, DA7219_MIXIN_L_CTRL, mixin_ctrl); /* Restore MIC control registers to original states */ - snd_soc_write(codec, DA7219_MIC_1_CTRL, mic_ctrl); + snd_soc_component_write(component, DA7219_MIC_1_CTRL, mic_ctrl); } static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; ret = snd_soc_put_volsw(kcontrol, ucontrol); @@ -389,7 +389,7 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, * make sure calibrated offsets are updated. */ if ((ret == 1) && (da7219->alc_en)) - da7219_alc_calib(codec); + da7219_alc_calib(component); return ret; } @@ -397,13 +397,13 @@ static int da7219_mixin_gain_put(struct snd_kcontrol *kcontrol, static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); /* Force ALC offset calibration if enabling ALC */ if ((ucontrol->value.integer.value[0]) && (!da7219->alc_en)) { - da7219_alc_calib(codec); + da7219_alc_calib(component); da7219->alc_en = true; } else { da7219->alc_en = false; @@ -416,8 +416,8 @@ static int da7219_alc_sw_put(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int reg = mixer_ctrl->reg; @@ -443,8 +443,8 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol, static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mixer_ctrl = (struct soc_mixer_control *) kcontrol->private_value; unsigned int reg = mixer_ctrl->reg; @@ -769,8 +769,8 @@ static const struct snd_kcontrol_new da7219_st_out_filtr_mix_controls[] = { static int da7219_dai_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, pll_status; int i = 0; bool srm_lock = false; @@ -779,22 +779,22 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMU: if (da7219->master) /* Enable DAI clks for master mode */ - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_CLK_EN_MASK, DA7219_DAI_CLK_EN_MASK); /* PC synchronised to DAI */ - snd_soc_update_bits(codec, DA7219_PC_COUNT, + snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, 0); /* Slave mode, if SRM not enabled no need for status checks */ - pll_ctrl = snd_soc_read(codec, DA7219_PLL_CTRL); + pll_ctrl = snd_soc_component_read32(component, DA7219_PLL_CTRL); if ((pll_ctrl & DA7219_PLL_MODE_MASK) != DA7219_PLL_MODE_SRM) return 0; /* Check SRM has locked */ do { - pll_status = snd_soc_read(codec, DA7219_PLL_SRM_STS); + pll_status = snd_soc_component_read32(component, DA7219_PLL_SRM_STS); if (pll_status & DA7219_PLL_SRM_STS_SRM_LOCK) { srm_lock = true; } else { @@ -804,18 +804,18 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, } while ((i < DA7219_SRM_CHECK_RETRIES) & (!srm_lock)); if (!srm_lock) - dev_warn(codec->dev, "SRM failed to lock\n"); + dev_warn(component->dev, "SRM failed to lock\n"); return 0; case SND_SOC_DAPM_POST_PMD: /* PC free-running */ - snd_soc_update_bits(codec, DA7219_PC_COUNT, + snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, DA7219_PC_FREERUN_MASK); /* Disable DAI clks if in master mode */ if (da7219->master) - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_CLK_EN_MASK, 0); return 0; default: @@ -841,7 +841,7 @@ static int da7219_settling_event(struct snd_soc_dapm_widget *w, static int da7219_mixout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); u8 hp_ctrl, min_gain_mask; switch (w->reg) { @@ -860,7 +860,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMD: /* Enable minimum gain on HP to avoid pops */ - snd_soc_update_bits(codec, hp_ctrl, min_gain_mask, + snd_soc_component_update_bits(component, hp_ctrl, min_gain_mask, min_gain_mask); msleep(DA7219_MIN_GAIN_DELAY); @@ -868,7 +868,7 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: /* Remove minimum gain on HP */ - snd_soc_update_bits(codec, hp_ctrl, min_gain_mask, 0); + snd_soc_component_update_bits(component, hp_ctrl, min_gain_mask, 0); break; } @@ -879,22 +879,22 @@ static int da7219_mixout_event(struct snd_soc_dapm_widget *w, static int da7219_gain_ramp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMD: /* Ensure nominal gain ramping for DAPM sequence */ da7219->gain_ramp_ctrl = - snd_soc_read(codec, DA7219_GAIN_RAMP_CTRL); - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, + snd_soc_component_read32(component, DA7219_GAIN_RAMP_CTRL); + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, DA7219_GAIN_RAMP_RATE_NOMINAL); break; case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_POST_PMD: /* Restore previous gain ramp settings */ - snd_soc_write(codec, DA7219_GAIN_RAMP_CTRL, + snd_soc_component_write(component, DA7219_GAIN_RAMP_CTRL, da7219->gain_ramp_ctrl); break; } @@ -1116,8 +1116,8 @@ static const struct snd_soc_dapm_route da7219_audio_map[] = { static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret = 0; if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) @@ -1133,12 +1133,12 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, switch (clk_id) { case DA7219_CLKSRC_MCLK_SQR: - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_MCLK_SQR_EN_MASK, DA7219_PLL_MCLK_SQR_EN_MASK); break; case DA7219_CLKSRC_MCLK: - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_MCLK_SQR_EN_MASK, 0); break; default: @@ -1167,9 +1167,9 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai, return 0; } -int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) +int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, indiv_bits, indiv; u8 pll_frac_top, pll_frac_bot, pll_integer; @@ -1178,7 +1178,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) /* Verify 2MHz - 54MHz MCLK provided, and set input divider */ if (da7219->mclk_rate < 2000000) { - dev_err(codec->dev, "PLL input clock %d below valid range\n", + dev_err(component->dev, "PLL input clock %d below valid range\n", da7219->mclk_rate); return -EINVAL; } else if (da7219->mclk_rate <= 4500000) { @@ -1197,7 +1197,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) indiv_bits = DA7219_PLL_INDIV_36_TO_54_MHZ; indiv = DA7219_PLL_INDIV_36_TO_54_MHZ_VAL; } else { - dev_err(codec->dev, "PLL input clock %d above valid range\n", + dev_err(component->dev, "PLL input clock %d above valid range\n", da7219->mclk_rate); return -EINVAL; } @@ -1208,7 +1208,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) switch (source) { case DA7219_SYSCLK_MCLK: pll_ctrl |= DA7219_PLL_MODE_BYPASS; - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK, pll_ctrl); return 0; @@ -1219,7 +1219,7 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) pll_ctrl |= DA7219_PLL_MODE_SRM; break; default: - dev_err(codec->dev, "Invalid PLL config\n"); + dev_err(component->dev, "Invalid PLL config\n"); return -EINVAL; } @@ -1231,10 +1231,10 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) pll_frac_bot = (frac_div) & DA7219_BYTE_MASK; /* Write PLL config & dividers */ - snd_soc_write(codec, DA7219_PLL_FRAC_TOP, pll_frac_top); - snd_soc_write(codec, DA7219_PLL_FRAC_BOT, pll_frac_bot); - snd_soc_write(codec, DA7219_PLL_INTEGER, pll_integer); - snd_soc_update_bits(codec, DA7219_PLL_CTRL, + snd_soc_component_write(component, DA7219_PLL_FRAC_TOP, pll_frac_top); + snd_soc_component_write(component, DA7219_PLL_FRAC_BOT, pll_frac_bot); + snd_soc_component_write(component, DA7219_PLL_INTEGER, pll_integer); + snd_soc_component_update_bits(component, DA7219_PLL_CTRL, DA7219_PLL_INDIV_MASK | DA7219_PLL_MODE_MASK, pll_ctrl); @@ -1244,12 +1244,12 @@ int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout) static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int fref, unsigned int fout) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; mutex_lock(&da7219->pll_lock); - ret = da7219_set_pll(codec, source, fout); + ret = da7219_set_pll(component, source, fout); mutex_unlock(&da7219->pll_lock); return ret; @@ -1257,8 +1257,8 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 dai_clk_mode = 0, dai_ctrl = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1335,11 +1335,11 @@ static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) /* By default 64 BCLKs per WCLK is supported */ dai_clk_mode |= DA7219_DAI_BCLKS_PER_WCLK_64; - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_BCLKS_PER_WCLK_MASK | DA7219_DAI_CLK_POL_MASK | DA7219_DAI_WCLK_POL_MASK, dai_clk_mode); - snd_soc_update_bits(codec, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK, + snd_soc_component_update_bits(component, DA7219_DAI_CTRL, DA7219_DAI_FORMAT_MASK, dai_ctrl); return 0; @@ -1349,18 +1349,18 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 dai_bclks_per_wclk; u16 offset; u32 frame_size; /* No channels enabled so disable TDM, revert to 64-bit frames */ if (!tx_mask) { - snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, + snd_soc_component_update_bits(component, DA7219_DAI_TDM_CTRL, DA7219_DAI_TDM_CH_EN_MASK | DA7219_DAI_TDM_MODE_EN_MASK, 0); - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_BCLKS_PER_WCLK_MASK, DA7219_DAI_BCLKS_PER_WCLK_64); return 0; @@ -1368,14 +1368,14 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, /* Check we have valid slots */ if (fls(tx_mask) > DA7219_DAI_TDM_MAX_SLOTS) { - dev_err(codec->dev, "Invalid number of slots, max = %d\n", + dev_err(component->dev, "Invalid number of slots, max = %d\n", DA7219_DAI_TDM_MAX_SLOTS); return -EINVAL; } /* Check we have a valid offset given */ if (rx_mask > DA7219_DAI_OFFSET_MAX) { - dev_err(codec->dev, "Invalid slot offset, max = %d\n", + dev_err(component->dev, "Invalid slot offset, max = %d\n", DA7219_DAI_OFFSET_MAX); return -EINVAL; } @@ -1396,11 +1396,11 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, dai_bclks_per_wclk = DA7219_DAI_BCLKS_PER_WCLK_256; break; default: - dev_err(codec->dev, "Invalid frame size %d\n", frame_size); + dev_err(component->dev, "Invalid frame size %d\n", frame_size); return -EINVAL; } - snd_soc_update_bits(codec, DA7219_DAI_CLK_MODE, + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, DA7219_DAI_BCLKS_PER_WCLK_MASK, dai_bclks_per_wclk); @@ -1408,7 +1408,7 @@ static int da7219_set_dai_tdm_slot(struct snd_soc_dai *dai, regmap_bulk_write(da7219->regmap, DA7219_DAI_OFFSET_LOWER, &offset, sizeof(offset)); - snd_soc_update_bits(codec, DA7219_DAI_TDM_CTRL, + snd_soc_component_update_bits(component, DA7219_DAI_TDM_CTRL, DA7219_DAI_TDM_CH_EN_MASK | DA7219_DAI_TDM_MODE_EN_MASK, (tx_mask << DA7219_DAI_TDM_CH_EN_SHIFT) | @@ -1421,7 +1421,7 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 dai_ctrl = 0, fs; unsigned int channels; @@ -1444,7 +1444,7 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, channels = params_channels(params); if ((channels < 1) || (channels > DA7219_DAI_CH_NUM_MAX)) { - dev_err(codec->dev, + dev_err(component->dev, "Invalid number of channels, only 1 to %d supported\n", DA7219_DAI_CH_NUM_MAX); return -EINVAL; @@ -1489,11 +1489,11 @@ static int da7219_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, DA7219_DAI_CTRL, + snd_soc_component_update_bits(component, DA7219_DAI_CTRL, DA7219_DAI_WORD_LENGTH_MASK | DA7219_DAI_CH_NUM_MASK, dai_ctrl); - snd_soc_write(codec, DA7219_SR, fs); + snd_soc_component_write(component, DA7219_SR, fs); return 0; } @@ -1585,9 +1585,9 @@ static enum da7219_mic_amp_in_sel } } -static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec) +static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *component) { - struct device *dev = codec->dev; + struct device *dev = component->dev; struct da7219_pdata *pdata; const char *of_str; u32 of_val32; @@ -1616,10 +1616,10 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_codec *codec) * Codec driver functions */ -static int da7219_set_bias_level(struct snd_soc_codec *codec, +static int da7219_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -1627,11 +1627,11 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_PREPARE: /* Enable MCLK for transition to ON state */ - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { if (da7219->mclk) { ret = clk_prepare_enable(da7219->mclk); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to enable mclk\n"); return ret; } @@ -1640,13 +1640,13 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) /* Master bias */ - snd_soc_update_bits(codec, DA7219_REFERENCES, + snd_soc_component_update_bits(component, DA7219_REFERENCES, DA7219_BIAS_EN_MASK, DA7219_BIAS_EN_MASK); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) { /* Remove MCLK */ if (da7219->mclk) clk_disable_unprepare(da7219->mclk); @@ -1655,7 +1655,7 @@ static int da7219_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_OFF: /* Only disable master bias if we're not a wake-up source */ if (!da7219->wakeup_source) - snd_soc_update_bits(codec, DA7219_REFERENCES, + snd_soc_component_update_bits(component, DA7219_REFERENCES, DA7219_BIAS_EN_MASK, 0); break; @@ -1670,9 +1670,9 @@ static const char *da7219_supply_names[DA7219_NUM_SUPPLIES] = { [DA7219_SUPPLY_VDDIO] = "VDDIO", }; -static int da7219_handle_supplies(struct snd_soc_codec *codec) +static int da7219_handle_supplies(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct regulator *vddio; u8 io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_2_5V_3_6V; int i, ret; @@ -1681,10 +1681,10 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec) for (i = 0; i < DA7219_NUM_SUPPLIES; ++i) da7219->supplies[i].supply = da7219_supply_names[i]; - ret = devm_regulator_bulk_get(codec->dev, DA7219_NUM_SUPPLIES, + ret = devm_regulator_bulk_get(component->dev, DA7219_NUM_SUPPLIES, da7219->supplies); if (ret) { - dev_err(codec->dev, "Failed to get supplies"); + dev_err(component->dev, "Failed to get supplies"); return ret; } @@ -1692,29 +1692,29 @@ static int da7219_handle_supplies(struct snd_soc_codec *codec) vddio = da7219->supplies[DA7219_SUPPLY_VDDIO].consumer; ret = regulator_get_voltage(vddio); if (ret < 1200000) - dev_warn(codec->dev, "Invalid VDDIO voltage\n"); + dev_warn(component->dev, "Invalid VDDIO voltage\n"); else if (ret < 2800000) io_voltage_lvl = DA7219_IO_VOLTAGE_LEVEL_1_2V_2_8V; /* Enable main supplies */ ret = regulator_bulk_enable(DA7219_NUM_SUPPLIES, da7219->supplies); if (ret) { - dev_err(codec->dev, "Failed to enable supplies"); + dev_err(component->dev, "Failed to enable supplies"); return ret; } /* Ensure device in active mode */ - snd_soc_write(codec, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK); + snd_soc_component_write(component, DA7219_SYSTEM_ACTIVE, DA7219_SYSTEM_ACTIVE_MASK); /* Update IO voltage level range */ - snd_soc_write(codec, DA7219_IO_CTRL, io_voltage_lvl); + snd_soc_component_write(component, DA7219_IO_CTRL, io_voltage_lvl); return 0; } -static void da7219_handle_pdata(struct snd_soc_codec *codec) +static void da7219_handle_pdata(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); struct da7219_pdata *pdata = da7219->pdata; if (pdata) { @@ -1735,14 +1735,14 @@ static void da7219_handle_pdata(struct snd_soc_codec *codec) break; } - snd_soc_write(codec, DA7219_MICBIAS_CTRL, micbias_lvl); + snd_soc_component_write(component, DA7219_MICBIAS_CTRL, micbias_lvl); /* Mic */ switch (pdata->mic_amp_in_sel) { case DA7219_MIC_AMP_IN_SEL_DIFF: case DA7219_MIC_AMP_IN_SEL_SE_P: case DA7219_MIC_AMP_IN_SEL_SE_N: - snd_soc_write(codec, DA7219_MIC_1_SELECT, + snd_soc_component_write(component, DA7219_MIC_1_SELECT, pdata->mic_amp_in_sel); break; } @@ -1753,9 +1753,9 @@ static struct reg_sequence da7219_rev_aa_patch[] = { { DA7219_REFERENCES, 0x08 }, }; -static int da7219_probe(struct snd_soc_codec *codec) +static int da7219_probe(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); unsigned int rev; int ret; @@ -1763,13 +1763,13 @@ static int da7219_probe(struct snd_soc_codec *codec) mutex_init(&da7219->pll_lock); /* Regulator configuration */ - ret = da7219_handle_supplies(codec); + ret = da7219_handle_supplies(component); if (ret) return ret; ret = regmap_read(da7219->regmap, DA7219_CHIP_REVISION, &rev); if (ret) { - dev_err(codec->dev, "Failed to read chip revision: %d\n", ret); + dev_err(component->dev, "Failed to read chip revision: %d\n", ret); goto err_disable_reg; } @@ -1778,7 +1778,7 @@ static int da7219_probe(struct snd_soc_codec *codec) ret = regmap_register_patch(da7219->regmap, da7219_rev_aa_patch, ARRAY_SIZE(da7219_rev_aa_patch)); if (ret) { - dev_err(codec->dev, "Failed to register AA patch: %d\n", + dev_err(component->dev, "Failed to register AA patch: %d\n", ret); goto err_disable_reg; } @@ -1788,14 +1788,14 @@ static int da7219_probe(struct snd_soc_codec *codec) } /* Handle DT/ACPI/Platform data */ - da7219->pdata = dev_get_platdata(codec->dev); + da7219->pdata = dev_get_platdata(component->dev); if (!da7219->pdata) - da7219->pdata = da7219_fw_to_pdata(codec); + da7219->pdata = da7219_fw_to_pdata(component); - da7219_handle_pdata(codec); + da7219_handle_pdata(component); /* Check if MCLK provided */ - da7219->mclk = devm_clk_get(codec->dev, "mclk"); + da7219->mclk = devm_clk_get(component->dev, "mclk"); if (IS_ERR(da7219->mclk)) { if (PTR_ERR(da7219->mclk) != -ENOENT) { ret = PTR_ERR(da7219->mclk); @@ -1806,39 +1806,39 @@ static int da7219_probe(struct snd_soc_codec *codec) } /* Default PC counter to free-running */ - snd_soc_update_bits(codec, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, + snd_soc_component_update_bits(component, DA7219_PC_COUNT, DA7219_PC_FREERUN_MASK, DA7219_PC_FREERUN_MASK); /* Default gain ramping */ - snd_soc_update_bits(codec, DA7219_MIXIN_L_CTRL, + snd_soc_component_update_bits(component, DA7219_MIXIN_L_CTRL, DA7219_MIXIN_L_AMP_RAMP_EN_MASK, DA7219_MIXIN_L_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_ADC_L_CTRL, DA7219_ADC_L_RAMP_EN_MASK, DA7219_ADC_L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_L_CTRL, DA7219_DAC_L_RAMP_EN_MASK, DA7219_DAC_L_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK, + snd_soc_component_update_bits(component, DA7219_DAC_R_CTRL, DA7219_DAC_R_RAMP_EN_MASK, DA7219_DAC_R_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_RAMP_EN_MASK, DA7219_HP_L_AMP_RAMP_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_RAMP_EN_MASK, DA7219_HP_R_AMP_RAMP_EN_MASK); /* Default minimum gain on HP to avoid pops during DAPM sequencing */ - snd_soc_update_bits(codec, DA7219_HP_L_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_L_CTRL, DA7219_HP_L_AMP_MIN_GAIN_EN_MASK, DA7219_HP_L_AMP_MIN_GAIN_EN_MASK); - snd_soc_update_bits(codec, DA7219_HP_R_CTRL, + snd_soc_component_update_bits(component, DA7219_HP_R_CTRL, DA7219_HP_R_AMP_MIN_GAIN_EN_MASK, DA7219_HP_R_AMP_MIN_GAIN_EN_MASK); /* Default infinite tone gen, start/stop by Kcontrol */ - snd_soc_write(codec, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK); + snd_soc_component_write(component, DA7219_TONE_GEN_CYCLES, DA7219_BEEP_CYCLES_MASK); /* Initialise AAD block */ - ret = da7219_aad_init(codec); + ret = da7219_aad_init(component); if (ret) goto err_disable_reg; @@ -1850,39 +1850,39 @@ err_disable_reg: return ret; } -static int da7219_remove(struct snd_soc_codec *codec) +static void da7219_remove(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); - da7219_aad_exit(codec); + da7219_aad_exit(component); /* Supplies */ - return regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); + regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); } #ifdef CONFIG_PM -static int da7219_suspend(struct snd_soc_codec *codec) +static int da7219_suspend(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); /* Suspend AAD if we're not a wake-up source */ if (!da7219->wakeup_source) - da7219_aad_suspend(codec); + da7219_aad_suspend(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); return 0; } -static int da7219_resume(struct snd_soc_codec *codec) +static int da7219_resume(struct snd_soc_component *component) { - struct da7219_priv *da7219 = snd_soc_codec_get_drvdata(codec); + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Resume AAD if previously suspended */ if (!da7219->wakeup_source) - da7219_aad_resume(codec); + da7219_aad_resume(component); return 0; } @@ -1891,21 +1891,22 @@ static int da7219_resume(struct snd_soc_codec *codec) #define da7219_resume NULL #endif -static const struct snd_soc_codec_driver soc_codec_dev_da7219 = { +static const struct snd_soc_component_driver soc_component_dev_da7219 = { .probe = da7219_probe, .remove = da7219_remove, .suspend = da7219_suspend, .resume = da7219_resume, .set_bias_level = da7219_set_bias_level, - - .component_driver = { - .controls = da7219_snd_controls, - .num_controls = ARRAY_SIZE(da7219_snd_controls), - .dapm_widgets = da7219_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets), - .dapm_routes = da7219_audio_map, - .num_dapm_routes = ARRAY_SIZE(da7219_audio_map), - }, + .controls = da7219_snd_controls, + .num_controls = ARRAY_SIZE(da7219_snd_controls), + .dapm_widgets = da7219_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(da7219_dapm_widgets), + .dapm_routes = da7219_audio_map, + .num_dapm_routes = ARRAY_SIZE(da7219_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; @@ -2090,7 +2091,7 @@ static int da7219_i2c_probe(struct i2c_client *i2c, } } - /* Soft reset codec */ + /* Soft reset component */ regmap_write_bits(da7219->regmap, DA7219_ACCDET_CONFIG_1, DA7219_ACCDET_EN_MASK, 0); regmap_write_bits(da7219->regmap, DA7219_CIF_CTRL, @@ -2101,10 +2102,11 @@ static int da7219_i2c_probe(struct i2c_client *i2c, regcache_cache_bypass(da7219->regmap, false); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da7219, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_da7219, &da7219_dai, 1); if (ret < 0) { - dev_err(&i2c->dev, "Failed to register da7219 codec: %d\n", + dev_err(&i2c->dev, "Failed to register da7219 component: %d\n", ret); } return ret; @@ -2112,7 +2114,6 @@ static int da7219_i2c_probe(struct i2c_client *i2c, static int da7219_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h index 8d6c3c8c8026..1acb34cd12ad 100644 --- a/sound/soc/codecs/da7219.h +++ b/sound/soc/codecs/da7219.h @@ -822,6 +822,6 @@ struct da7219_priv { u8 gain_ramp_ctrl; }; -int da7219_set_pll(struct snd_soc_codec *codec, int source, unsigned int fout); +int da7219_set_pll(struct snd_soc_component *component, int source, unsigned int fout); #endif /* __DA7219_H */ diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index dba6f4c5074a..0758927d1e06 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -1536,7 +1536,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_pin *pin = NULL; struct hdac_hdmi_port *hport = NULL; - struct snd_soc_codec *codec = edev->scodec; + struct snd_soc_component *component = edev->scodec; int i; /* Don't know how this mapping is derived */ @@ -1551,7 +1551,7 @@ static void hdac_hdmi_eld_notify_cb(void *aptr, int port, int pipe) * connection states are updated in anyway at the end of the resume, * we can skip it when received during PM process. */ - if (snd_power_get_state(codec->component.card->snd_card) != + if (snd_power_get_state(component->card->snd_card) != SNDRV_CTL_POWER_D0) return; @@ -1609,10 +1609,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, char kc_name[NAME_SIZE], xname[NAME_SIZE]; char *name; int i = 0, j; - struct snd_soc_codec *codec = edev->scodec; + struct snd_soc_component *component = edev->scodec; struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); - kc = devm_kcalloc(codec->dev, hdmi->num_ports, + kc = devm_kcalloc(component->dev, hdmi->num_ports, sizeof(*kc), GFP_KERNEL); if (!kc) @@ -1622,11 +1622,11 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, for (j = 0; j < pin->num_ports; j++) { snprintf(xname, sizeof(xname), "hif%d-%d Jack", pin->nid, pin->ports[j].id); - name = devm_kstrdup(codec->dev, xname, GFP_KERNEL); + name = devm_kstrdup(component->dev, xname, GFP_KERNEL); if (!name) return -ENOMEM; snprintf(kc_name, sizeof(kc_name), "%s Switch", xname); - kc[i].name = devm_kstrdup(codec->dev, kc_name, + kc[i].name = devm_kstrdup(component->dev, kc_name, GFP_KERNEL); if (!kc[i].name) return -ENOMEM; @@ -1644,10 +1644,10 @@ static int create_fill_jack_kcontrols(struct snd_soc_card *card, return snd_soc_add_card_controls(card, kc, i); } -int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec, +int hdac_hdmi_jack_port_init(struct snd_soc_component *component, struct snd_soc_dapm_context *dapm) { - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_pin *pin; struct snd_soc_dapm_widget *widgets; @@ -1722,8 +1722,8 @@ EXPORT_SYMBOL_GPL(hdac_hdmi_jack_port_init); int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int device, struct snd_soc_jack *jack) { - struct snd_soc_codec *codec = dai->codec; - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct hdac_hdmi_pcm *pcm; struct snd_pcm *snd_pcm; @@ -1784,16 +1784,16 @@ static void hdac_hdmi_present_sense_all_pins(struct hdac_ext_device *edev, } } -static int hdmi_codec_probe(struct snd_soc_codec *codec) +static int hdmi_codec_probe(struct snd_soc_component *component) { - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); struct hdac_hdmi_priv *hdmi = hdev_to_hdmi_priv(&edev->hdev); struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&codec->component); + snd_soc_component_get_dapm(component); struct hdac_ext_link *hlink = NULL; int ret; - edev->scodec = codec; + edev->scodec = component; /* * hold the ref while we probe, also no need to drop the ref on @@ -1834,12 +1834,11 @@ static int hdmi_codec_probe(struct snd_soc_codec *codec) return 0; } -static int hdmi_codec_remove(struct snd_soc_codec *codec) +static void hdmi_codec_remove(struct snd_soc_component *component) { - struct hdac_ext_device *edev = snd_soc_codec_get_drvdata(codec); + struct hdac_ext_device *edev = snd_soc_component_get_drvdata(component); pm_runtime_disable(&edev->hdev.dev); - return 0; } #ifdef CONFIG_PM @@ -1891,10 +1890,12 @@ static void hdmi_codec_complete(struct device *dev) #define hdmi_codec_complete NULL #endif -static const struct snd_soc_codec_driver hdmi_hda_codec = { - .probe = hdmi_codec_probe, - .remove = hdmi_codec_remove, - .idle_bias_off = true, +static const struct snd_soc_component_driver hdmi_hda_codec = { + .probe = hdmi_codec_probe, + .remove = hdmi_codec_remove, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void hdac_hdmi_get_chmap(struct hdac_device *hdev, int pcm_idx, @@ -2042,7 +2043,7 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) snd_hdac_refresh_widgets(hdev, true); /* ASoC specific initialization */ - ret = snd_soc_register_codec(&hdev->dev, &hdmi_hda_codec, + ret = devm_snd_soc_register_component(&hdev->dev, &hdmi_hda_codec, hdmi_dais, num_dais); snd_hdac_ext_bus_link_put(edev->ebus, hlink); @@ -2059,8 +2060,6 @@ static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev) struct hdac_hdmi_port *port, *port_next; int i; - snd_soc_unregister_codec(&edev->hdev.dev); - list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) { pcm->cvt = NULL; if (list_empty(&pcm->port_list)) diff --git a/sound/soc/codecs/hdac_hdmi.h b/sound/soc/codecs/hdac_hdmi.h index b5b57a5cbbfd..4fa2fc9ee893 100644 --- a/sound/soc/codecs/hdac_hdmi.h +++ b/sound/soc/codecs/hdac_hdmi.h @@ -5,6 +5,6 @@ int hdac_hdmi_jack_init(struct snd_soc_dai *dai, int pcm, struct snd_soc_jack *jack); -int hdac_hdmi_jack_port_init(struct snd_soc_codec *codec, +int hdac_hdmi_jack_port_init(struct snd_soc_component *component, struct snd_soc_dapm_context *dapm); #endif /* __HDAC_HDMI_H__ */ diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index a1b697b6fb64..dc6ea4987b7d 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c @@ -914,8 +914,8 @@ static bool nau8825_volatile_reg(struct device *dev, unsigned int reg) static int nau8825_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -938,8 +938,8 @@ static int nau8825_adc_event(struct snd_soc_dapm_widget *w, static int nau8825_pump_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -962,8 +962,8 @@ static int nau8825_pump_event(struct snd_soc_dapm_widget *w, static int nau8825_output_dac_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1244,8 +1244,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; nau8825_sema_acquire(nau8825, 3 * HZ); @@ -1329,8 +1329,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); unsigned int ctrl1_val = 0, ctrl2_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -1427,10 +1427,10 @@ static struct snd_soc_dai_driver nau8825_dai = { * events will be routed to the given jack. Jack can be null to stop * reporting. */ -int nau8825_enable_jack_detect(struct snd_soc_codec *codec, +int nau8825_enable_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); struct regmap *regmap = nau8825->regmap; nau8825->jack = jack; @@ -1952,24 +1952,22 @@ static const struct regmap_config nau8825_regmap_config = { .num_reg_defaults = ARRAY_SIZE(nau8825_reg_defaults), }; -static int nau8825_codec_probe(struct snd_soc_codec *codec) +static int nau8825_component_probe(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); nau8825->dapm = dapm; return 0; } -static int nau8825_codec_remove(struct snd_soc_codec *codec) +static void nau8825_component_remove(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); /* Cancel and reset cross tak suppresstion detection funciton */ nau8825_xtalk_cancel(nau8825); - - return 0; } /** @@ -2084,20 +2082,20 @@ static void nau8825_fll_apply(struct nau8825 *nau8825, } /* freq_out must be 256*Fs in order to achieve the best performance */ -static int nau8825_set_pll(struct snd_soc_codec *codec, int pll_id, int source, +static int nau8825_set_pll(struct snd_soc_component *component, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); struct nau8825_fll fll_param; int ret, fs; fs = freq_out / 256; ret = nau8825_calc_fll_param(freq_in, fs, &fll_param); if (ret < 0) { - dev_err(codec->dev, "Unsupported input clock %d\n", freq_in); + dev_err(component->dev, "Unsupported input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n", + dev_dbg(component->dev, "mclk_src=%x ratio=%x fll_frac=%x fll_int=%x clk_ref_div=%x\n", fll_param.mclk_src, fll_param.ratio, fll_param.fll_frac, fll_param.fll_int, fll_param.clk_ref_div); @@ -2298,10 +2296,10 @@ static int nau8825_configure_sysclk(struct nau8825 *nau8825, int clk_id, return 0; } -static int nau8825_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int nau8825_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); return nau8825_configure_sysclk(nau8825, clk_id, freq); } @@ -2331,10 +2329,10 @@ static int nau8825_resume_setup(struct nau8825 *nau8825) return 0; } -static int nau8825_set_bias_level(struct snd_soc_codec *codec, +static int nau8825_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); int ret; switch (level) { @@ -2345,11 +2343,11 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { if (nau8825->mclk_freq) { ret = clk_prepare_enable(nau8825->mclk); if (ret) { - dev_err(nau8825->dev, "Unable to prepare codec mclk\n"); + dev_err(nau8825->dev, "Unable to prepare component mclk\n"); return ret; } } @@ -2383,12 +2381,12 @@ static int nau8825_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) +static int __maybe_unused nau8825_suspend(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); disable_irq(nau8825->irq); - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); /* Power down codec power; don't suppoet button wakeup */ snd_soc_dapm_disable_pin(nau8825->dapm, "SAR"); snd_soc_dapm_disable_pin(nau8825->dapm, "MICBIAS"); @@ -2399,9 +2397,9 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) return 0; } -static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) +static int __maybe_unused nau8825_resume(struct snd_soc_component *component) { - struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); + struct nau8825 *nau8825 = snd_soc_component_get_drvdata(component); int ret; regcache_cache_only(nau8825->regmap, false); @@ -2415,24 +2413,25 @@ static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) return 0; } -static const struct snd_soc_codec_driver nau8825_codec_driver = { - .probe = nau8825_codec_probe, - .remove = nau8825_codec_remove, - .set_sysclk = nau8825_set_sysclk, - .set_pll = nau8825_set_pll, - .set_bias_level = nau8825_set_bias_level, - .suspend_bias_off = true, - .suspend = nau8825_suspend, - .resume = nau8825_resume, - - .component_driver = { - .controls = nau8825_controls, - .num_controls = ARRAY_SIZE(nau8825_controls), - .dapm_widgets = nau8825_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets), - .dapm_routes = nau8825_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes), - }, +static const struct snd_soc_component_driver nau8825_component_driver = { + .probe = nau8825_component_probe, + .remove = nau8825_component_remove, + .set_sysclk = nau8825_set_sysclk, + .set_pll = nau8825_set_pll, + .set_bias_level = nau8825_set_bias_level, + .suspend = nau8825_suspend, + .resume = nau8825_resume, + .controls = nau8825_controls, + .num_controls = ARRAY_SIZE(nau8825_controls), + .dapm_widgets = nau8825_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(nau8825_dapm_widgets), + .dapm_routes = nau8825_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(nau8825_dapm_routes), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static void nau8825_reset_chip(struct regmap *regmap) @@ -2619,13 +2618,13 @@ static int nau8825_i2c_probe(struct i2c_client *i2c, if (i2c->irq) nau8825_setup_irq(nau8825); - return snd_soc_register_codec(&i2c->dev, &nau8825_codec_driver, + return devm_snd_soc_register_component(&i2c->dev, + &nau8825_component_driver, &nau8825_dai, 1); } static int nau8825_i2c_remove(struct i2c_client *client) { - snd_soc_unregister_codec(&client->dev); return 0; } diff --git a/sound/soc/codecs/nau8825.h b/sound/soc/codecs/nau8825.h index f7e732125882..f6074c618569 100644 --- a/sound/soc/codecs/nau8825.h +++ b/sound/soc/codecs/nau8825.h @@ -480,7 +480,7 @@ struct nau8825 { bool xtalk_baktab_initialized; /* True if initialized. */ }; -int nau8825_enable_jack_detect(struct snd_soc_codec *codec, +int nau8825_enable_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index af6325c78292..e1643571d643 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -40,7 +40,7 @@ struct rt286_priv { struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt286_platform_data pdata; struct i2c_client *i2c; struct snd_soc_jack *jack; @@ -187,13 +187,13 @@ static bool rt286_readable_register(struct device *dev, unsigned int reg) } #ifdef CONFIG_PM -static void rt286_index_sync(struct snd_soc_codec *codec) +static void rt286_index_sync(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < INDEX_CACHE_SIZE; i++) { - snd_soc_write(codec, rt286->index_cache[i].reg, + snd_soc_component_write(component, rt286->index_cache[i].reg, rt286->index_cache[i].def); } } @@ -220,10 +220,10 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) *hp = false; *mic = false; - if (!rt286->codec) + if (!rt286->component) return -EINVAL; - dapm = snd_soc_codec_get_dapm(rt286->codec); + dapm = snd_soc_component_get_dapm(rt286->component); if (rt286->pdata.cbj_en) { regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); @@ -305,10 +305,10 @@ static void rt286_jack_detect_work(struct work_struct *work) SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); } -int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); rt286->jack = jack; @@ -334,8 +334,8 @@ EXPORT_SYMBOL_GPL(rt286_mic_detect); static int is_mclk_mode(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); if (rt286->clk_id == RT286_SCLK_S_MCLK) return 1; @@ -434,15 +434,15 @@ SOC_DAPM_ENUM("SPO source", rt286_spo_enum); static int rt286_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, + snd_soc_component_write(component, RT286_SPK_EAPD, RT286_SET_EAPD_HIGH); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, + snd_soc_component_write(component, RT286_SPK_EAPD, RT286_SET_EAPD_LOW); break; @@ -456,14 +456,14 @@ static int rt286_spk_event(struct snd_soc_dapm_widget *w, static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0x20); + snd_soc_component_write(component, RT286_SET_PIN_DMIC1, 0x20); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0); + snd_soc_component_write(component, RT286_SET_PIN_DMIC1, 0); break; default: return 0; @@ -475,14 +475,14 @@ static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x38, 0x08); + snd_soc_component_update_bits(component, RT286_POWER_CTRL2, 0x38, 0x08); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT286_POWER_CTRL2, 0x38, 0x30); + snd_soc_component_update_bits(component, RT286_POWER_CTRL2, 0x38, 0x30); break; default: return 0; @@ -494,19 +494,19 @@ static int rt286_ldo2_event(struct snd_soc_dapm_widget *w, static int rt286_mic1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL3, 0xc000, 0x8000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL2, 0xc000, 0x8000); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL3, 0xc000, 0x0000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_A_BIAS_CTRL2, 0xc000, 0x0000); break; default: @@ -674,8 +674,8 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int d_len_code; @@ -687,7 +687,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", + dev_err(component->dev, "Unsupported sample rate %d\n", params_rate(params)); return -EINVAL; } @@ -695,7 +695,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, case 12288000: case 24576000: if (params_rate(params) != 48000) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt286->sys_clk); return -EINVAL; } @@ -703,7 +703,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, case 11289600: case 22579200: if (params_rate(params) != 44100) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt286->sys_clk); return -EINVAL; } @@ -714,7 +714,7 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, /* bit 3:0 Number of Channel */ val |= (params_channels(params) - 1); } else { - dev_err(codec->dev, "Unsupported channels %d\n", + dev_err(component->dev, "Unsupported channels %d\n", params_channels(params)); return -EINVAL; } @@ -745,27 +745,27 @@ static int rt286_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x0018, d_len_code << 3); - dev_dbg(codec->dev, "format val = 0x%x\n", val); + dev_dbg(component->dev, "format val = 0x%x\n", val); - snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x407f, val); - snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT286_DAC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT286_ADC_FORMAT, 0x407f, val); return 0; } static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x800, 0x800); break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x800, 0x0); break; default: @@ -774,27 +774,27 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x0); break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x1 << 8); break; case SND_SOC_DAIFMT_DSP_A: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x2 << 8); break; case SND_SOC_DAIFMT_DSP_B: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x300, 0x3 << 8); break; default: return -EINVAL; } /* bit 15 Stream Type 0:PCM 1:Non-PCM */ - snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x8000, 0); - snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT286_DAC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT286_ADC_FORMAT, 0x8000, 0); return 0; } @@ -802,58 +802,58 @@ static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); if (RT286_SCLK_S_MCLK == clk_id) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x0100, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_PLL_CTRL1, 0x20, 0x20); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x0100, 0x0100); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_PLL_CTRL, 0x4, 0x4); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_PLL_CTRL1, 0x20, 0x0); } switch (freq) { case 19200000: if (RT286_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x40, 0x40); break; case 24000000: if (RT286_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x40, 0x0); break; case 12288000: case 11289600: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x8, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_CLK_DIV, 0xfc1e, 0x0004); break; case 24576000: case 22579200: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL2, 0x8, 0x8); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_CLK_DIV, 0xfc1e, 0x5406); break; default: - dev_err(codec->dev, "Unsupported system clock\n"); + dev_err(component->dev, "Unsupported system clock\n"); return -EINVAL; } @@ -865,42 +865,42 @@ static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); if (50 == ratio) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x1000, 0x1000); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_I2S_CTRL1, 0x1000, 0x0); return 0; } -static int rt286_set_bias_level(struct snd_soc_codec *codec, +static int rt286_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_write(codec, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_write(component, RT286_SET_AUDIO_POWER, AC_PWRST_D0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_DC_GAIN, 0x200, 0x200); } break; case SND_SOC_BIAS_ON: mdelay(10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT286_DC_GAIN, 0x200, 0x0); break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, + snd_soc_component_write(component, RT286_SET_AUDIO_POWER, AC_PWRST_D3); break; @@ -937,11 +937,11 @@ static irqreturn_t rt286_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt286_probe(struct snd_soc_codec *codec) +static int rt286_probe(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); - rt286->codec = codec; + rt286->component = component; if (rt286->i2c->irq) { regmap_update_bits(rt286->regmap, @@ -956,19 +956,17 @@ static int rt286_probe(struct snd_soc_codec *codec) return 0; } -static int rt286_remove(struct snd_soc_codec *codec) +static void rt286_remove(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&rt286->jack_detect_work); - - return 0; } #ifdef CONFIG_PM -static int rt286_suspend(struct snd_soc_codec *codec) +static int rt286_suspend(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt286->regmap, true); regcache_mark_dirty(rt286->regmap); @@ -976,12 +974,12 @@ static int rt286_suspend(struct snd_soc_codec *codec) return 0; } -static int rt286_resume(struct snd_soc_codec *codec) +static int rt286_resume(struct snd_soc_component *component) { - struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); + struct rt286_priv *rt286 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt286->regmap, false); - rt286_index_sync(codec); + rt286_index_sync(component); regcache_sync(rt286->regmap); return 0; @@ -1046,21 +1044,21 @@ static struct snd_soc_dai_driver rt286_dai[] = { }; -static const struct snd_soc_codec_driver soc_codec_dev_rt286 = { - .probe = rt286_probe, - .remove = rt286_remove, - .suspend = rt286_suspend, - .resume = rt286_resume, - .set_bias_level = rt286_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt286_snd_controls, - .num_controls = ARRAY_SIZE(rt286_snd_controls), - .dapm_widgets = rt286_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets), - .dapm_routes = rt286_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt286 = { + .probe = rt286_probe, + .remove = rt286_remove, + .suspend = rt286_suspend, + .resume = rt286_resume, + .set_bias_level = rt286_set_bias_level, + .controls = rt286_snd_controls, + .num_controls = ARRAY_SIZE(rt286_snd_controls), + .dapm_widgets = rt286_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets), + .dapm_routes = rt286_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt286_regmap = { @@ -1243,7 +1241,8 @@ static int rt286_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt286, rt286_dai, ARRAY_SIZE(rt286_dai)); return ret; @@ -1255,7 +1254,6 @@ static int rt286_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt286); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h index 7130edb152ef..c63d0e79ba86 100644 --- a/sound/soc/codecs/rt286.h +++ b/sound/soc/codecs/rt286.h @@ -199,7 +199,7 @@ enum { RT286_AIFS, }; -int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int rt286_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT286_H__ */ diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c index ce963768449f..7bf4b31bdf55 100644 --- a/sound/soc/codecs/rt298.c +++ b/sound/soc/codecs/rt298.c @@ -39,7 +39,7 @@ struct rt298_priv { struct reg_default *index_cache; int index_cache_size; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt298_platform_data pdata; struct i2c_client *i2c; struct snd_soc_jack *jack; @@ -194,13 +194,13 @@ static bool rt298_readable_register(struct device *dev, unsigned int reg) } #ifdef CONFIG_PM -static void rt298_index_sync(struct snd_soc_codec *codec) +static void rt298_index_sync(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < INDEX_CACHE_SIZE; i++) { - snd_soc_write(codec, rt298->index_cache[i].reg, + snd_soc_component_write(component, rt298->index_cache[i].reg, rt298->index_cache[i].def); } } @@ -227,10 +227,10 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic) *hp = false; *mic = false; - if (!rt298->codec) + if (!rt298->component) return -EINVAL; - dapm = snd_soc_codec_get_dapm(rt298->codec); + dapm = snd_soc_component_get_dapm(rt298->component); if (rt298->pdata.cbj_en) { regmap_read(rt298->regmap, RT298_GET_HP_SENSE, &buf); @@ -323,9 +323,9 @@ static void rt298_jack_detect_work(struct work_struct *work) SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); } -int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) +int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm; bool hp = false; bool mic = false; @@ -334,7 +334,7 @@ int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) /* If jack in NULL, disable HS jack */ if (!jack) { regmap_update_bits(rt298->regmap, RT298_IRQ_CTRL, 0x2, 0x0); - dapm = snd_soc_codec_get_dapm(codec); + dapm = snd_soc_component_get_dapm(component); snd_soc_dapm_disable_pin(dapm, "LDO1"); snd_soc_dapm_sync(dapm); return 0; @@ -360,8 +360,8 @@ EXPORT_SYMBOL_GPL(rt298_mic_detect); static int is_mclk_mode(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); if (rt298->clk_id == RT298_SCLK_S_MCLK) return 1; @@ -458,15 +458,15 @@ SOC_DAPM_ENUM("SPO source", rt298_spo_enum); static int rt298_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, + snd_soc_component_write(component, RT298_SPK_EAPD, RT298_SET_EAPD_HIGH); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, + snd_soc_component_write(component, RT298_SPK_EAPD, RT298_SET_EAPD_LOW); break; @@ -480,14 +480,14 @@ static int rt298_spk_event(struct snd_soc_dapm_widget *w, static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0x20); + snd_soc_component_write(component, RT298_SET_PIN_DMIC1, 0x20); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT298_SET_PIN_DMIC1, 0); + snd_soc_component_write(component, RT298_SET_PIN_DMIC1, 0); break; default: return 0; @@ -499,39 +499,39 @@ static int rt298_set_dmic1_event(struct snd_soc_dapm_widget *w, static int rt298_adc_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int nid; nid = (w->reg >> 20) & 0xff; switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), 0x7080, 0x7000); /* If MCLK doesn't exist, reset AD filter */ - if (!(snd_soc_read(codec, RT298_VAD_CTRL) & 0x200)) { + if (!(snd_soc_component_read32(component, RT298_VAD_CTRL) & 0x200)) { pr_info("NO MCLK\n"); switch (nid) { case RT298_ADC_IN1: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x2, 0x2); mdelay(10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x2, 0x0); break; case RT298_ADC_IN2: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x4, 0x4); mdelay(10); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_D_FILTER_CTRL, 0x4, 0x0); break; } } break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), 0x7080, 0x7080); break; @@ -545,19 +545,19 @@ static int rt298_adc_event(struct snd_soc_dapm_widget *w, static int rt298_mic1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL3, 0xc000, 0x8000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL2, 0xc000, 0x8000); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL3, 0xc000, 0x0000); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_A_BIAS_CTRL2, 0xc000, 0x0000); break; default: @@ -745,8 +745,8 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); unsigned int val = 0; int d_len_code; @@ -756,7 +756,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, case 48000: break; default: - dev_err(codec->dev, "Unsupported sample rate %d\n", + dev_err(component->dev, "Unsupported sample rate %d\n", params_rate(params)); return -EINVAL; } @@ -764,7 +764,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, case 12288000: case 24576000: if (params_rate(params) != 48000) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt298->sys_clk); return -EINVAL; } @@ -772,7 +772,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, case 11289600: case 22579200: if (params_rate(params) != 44100) { - dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", + dev_err(component->dev, "Sys_clk is not matched (%d %d)\n", params_rate(params), rt298->sys_clk); return -EINVAL; } @@ -783,7 +783,7 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, /* bit 3:0 Number of Channel */ val |= (params_channels(params) - 1); } else { - dev_err(codec->dev, "Unsupported channels %d\n", + dev_err(component->dev, "Unsupported channels %d\n", params_channels(params)); return -EINVAL; } @@ -814,27 +814,27 @@ static int rt298_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x0018, d_len_code << 3); - dev_dbg(codec->dev, "format val = 0x%x\n", val); + dev_dbg(component->dev, "format val = 0x%x\n", val); - snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x407f, val); - snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT298_DAC_FORMAT, 0x407f, val); + snd_soc_component_update_bits(component, RT298_ADC_FORMAT, 0x407f, val); return 0; } static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBM_CFM: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x800, 0x800); break; case SND_SOC_DAIFMT_CBS_CFS: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x800, 0x0); break; default: @@ -843,27 +843,27 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x0); break; case SND_SOC_DAIFMT_LEFT_J: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x1 << 8); break; case SND_SOC_DAIFMT_DSP_A: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x2 << 8); break; case SND_SOC_DAIFMT_DSP_B: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x300, 0x3 << 8); break; default: return -EINVAL; } /* bit 15 Stream Type 0:PCM 1:Non-PCM */ - snd_soc_update_bits(codec, RT298_DAC_FORMAT, 0x8000, 0); - snd_soc_update_bits(codec, RT298_ADC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT298_DAC_FORMAT, 0x8000, 0); + snd_soc_component_update_bits(component, RT298_ADC_FORMAT, 0x8000, 0); return 0; } @@ -871,56 +871,56 @@ static int rt298_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt298_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); + dev_dbg(component->dev, "%s freq=%d\n", __func__, freq); if (RT298_SCLK_S_MCLK == clk_id) { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x0100, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_PLL_CTRL1, 0x20, 0x20); } else { - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x0100, 0x0100); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_PLL_CTRL1, 0x20, 0x0); } switch (freq) { case 19200000: if (RT298_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x40, 0x40); break; case 24000000: if (RT298_SCLK_S_MCLK == clk_id) { - dev_err(codec->dev, "Should not use MCLK\n"); + dev_err(component->dev, "Should not use MCLK\n"); return -EINVAL; } - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x40, 0x0); break; case 12288000: case 11289600: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x8, 0x0); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_CLK_DIV, 0xfc1e, 0x0004); break; case 24576000: case 22579200: - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL2, 0x8, 0x8); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_CLK_DIV, 0xfc1e, 0x5406); break; default: - dev_err(codec->dev, "Unsupported system clock\n"); + dev_err(component->dev, "Unsupported system clock\n"); return -EINVAL; } @@ -932,39 +932,39 @@ static int rt298_set_dai_sysclk(struct snd_soc_dai *dai, static int rt298_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; - dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); if (50 == ratio) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x1000, 0x1000); else - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT298_I2S_CTRL1, 0x1000, 0x0); return 0; } -static int rt298_set_bias_level(struct snd_soc_codec *codec, +static int rt298_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == - snd_soc_codec_get_bias_level(codec)) { - snd_soc_write(codec, + snd_soc_component_get_bias_level(component)) { + snd_soc_component_write(component, RT298_SET_AUDIO_POWER, AC_PWRST_D0); - snd_soc_update_bits(codec, 0x0d, 0x200, 0x200); - snd_soc_update_bits(codec, 0x52, 0x80, 0x0); + snd_soc_component_update_bits(component, 0x0d, 0x200, 0x200); + snd_soc_component_update_bits(component, 0x52, 0x80, 0x0); mdelay(20); - snd_soc_update_bits(codec, 0x0d, 0x200, 0x0); - snd_soc_update_bits(codec, 0x52, 0x80, 0x80); + snd_soc_component_update_bits(component, 0x0d, 0x200, 0x0); + snd_soc_component_update_bits(component, 0x52, 0x80, 0x80); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, + snd_soc_component_write(component, RT298_SET_AUDIO_POWER, AC_PWRST_D3); break; @@ -1003,11 +1003,11 @@ static irqreturn_t rt298_irq(int irq, void *data) return IRQ_HANDLED; } -static int rt298_probe(struct snd_soc_codec *codec) +static int rt298_probe(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); - rt298->codec = codec; + rt298->component = component; if (rt298->i2c->irq) { regmap_update_bits(rt298->regmap, @@ -1022,19 +1022,17 @@ static int rt298_probe(struct snd_soc_codec *codec) return 0; } -static int rt298_remove(struct snd_soc_codec *codec) +static void rt298_remove(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); cancel_delayed_work_sync(&rt298->jack_detect_work); - - return 0; } #ifdef CONFIG_PM -static int rt298_suspend(struct snd_soc_codec *codec) +static int rt298_suspend(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); rt298->is_hp_in = -1; regcache_cache_only(rt298->regmap, true); @@ -1043,12 +1041,12 @@ static int rt298_suspend(struct snd_soc_codec *codec) return 0; } -static int rt298_resume(struct snd_soc_codec *codec) +static int rt298_resume(struct snd_soc_component *component) { - struct rt298_priv *rt298 = snd_soc_codec_get_drvdata(codec); + struct rt298_priv *rt298 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt298->regmap, false); - rt298_index_sync(codec); + rt298_index_sync(component); regcache_sync(rt298->regmap); return 0; @@ -1113,21 +1111,21 @@ static struct snd_soc_dai_driver rt298_dai[] = { }; -static const struct snd_soc_codec_driver soc_codec_dev_rt298 = { - .probe = rt298_probe, - .remove = rt298_remove, - .suspend = rt298_suspend, - .resume = rt298_resume, - .set_bias_level = rt298_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt298_snd_controls, - .num_controls = ARRAY_SIZE(rt298_snd_controls), - .dapm_widgets = rt298_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets), - .dapm_routes = rt298_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt298 = { + .probe = rt298_probe, + .remove = rt298_remove, + .suspend = rt298_suspend, + .resume = rt298_resume, + .set_bias_level = rt298_set_bias_level, + .controls = rt298_snd_controls, + .num_controls = ARRAY_SIZE(rt298_snd_controls), + .dapm_widgets = rt298_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt298_dapm_widgets), + .dapm_routes = rt298_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt298_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt298_regmap = { @@ -1288,7 +1286,8 @@ static int rt298_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt298, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt298, rt298_dai, ARRAY_SIZE(rt298_dai)); return ret; @@ -1300,7 +1299,6 @@ static int rt298_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt298); - snd_soc_unregister_codec(&i2c->dev); return 0; } diff --git a/sound/soc/codecs/rt298.h b/sound/soc/codecs/rt298.h index 3638f3d61209..b4db935359fa 100644 --- a/sound/soc/codecs/rt298.h +++ b/sound/soc/codecs/rt298.h @@ -210,7 +210,7 @@ enum { RT298_AIFS, }; -int rt298_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); +int rt298_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack); #endif /* __RT298_H__ */ diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c index d329bf719d80..20c0aeea6ca3 100644 --- a/sound/soc/codecs/rt5663.c +++ b/sound/soc/codecs/rt5663.c @@ -49,7 +49,7 @@ struct impedance_mapping_table { }; struct rt5663_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5663_platform_data pdata; struct regmap *regmap; struct delayed_work jack_detect_work, jd_unplug_work; @@ -1384,57 +1384,57 @@ static const char * const rt5663_if1_adc_data_select[] = { static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2, RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select); -static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, +static void rt5663_enable_push_button_irq(struct snd_soc_component *component, bool enable) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); if (enable) { - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_EN); /* reset in-line command */ - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_RESET); - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_NOR); switch (rt5663->codec_ver) { case CODEC_VER_1: - snd_soc_update_bits(codec, RT5663_IRQ_3, + snd_soc_component_update_bits(component, RT5663_IRQ_3, RT5663_V2_EN_IRQ_INLINE_MASK, RT5663_V2_EN_IRQ_INLINE_NOR); break; case CODEC_VER_0: - snd_soc_update_bits(codec, RT5663_IRQ_2, + snd_soc_component_update_bits(component, RT5663_IRQ_2, RT5663_EN_IRQ_INLINE_MASK, RT5663_EN_IRQ_INLINE_NOR); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } } else { switch (rt5663->codec_ver) { case CODEC_VER_1: - snd_soc_update_bits(codec, RT5663_IRQ_3, + snd_soc_component_update_bits(component, RT5663_IRQ_3, RT5663_V2_EN_IRQ_INLINE_MASK, RT5663_V2_EN_IRQ_INLINE_BYP); break; case CODEC_VER_0: - snd_soc_update_bits(codec, RT5663_IRQ_2, + snd_soc_component_update_bits(component, RT5663_IRQ_2, RT5663_EN_IRQ_INLINE_MASK, RT5663_EN_IRQ_INLINE_BYP); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_EN_4BTN_INL_MASK, RT5663_EN_4BTN_INL_DIS); /* reset in-line command */ - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_RESET); - snd_soc_update_bits(codec, RT5663_IL_CMD_6, + snd_soc_component_update_bits(component, RT5663_IL_CMD_6, RT5663_RESET_4BTN_INL_MASK, RT5663_RESET_4BTN_INL_NOR); } @@ -1442,7 +1442,7 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, /** * rt5663_v2_jack_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. @@ -1450,41 +1450,41 @@ static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec, * Returns detect status. */ -static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5663_v2_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int val, i = 0, sleep_time[5] = {300, 150, 100, 50, 30}; - dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); + dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert); if (jack_insert) { - snd_soc_write(codec, RT5663_CBJ_TYPE_2, 0x8040); - snd_soc_write(codec, RT5663_CBJ_TYPE_3, 0x1484); + snd_soc_component_write(component, RT5663_CBJ_TYPE_2, 0x8040); + snd_soc_component_write(component, RT5663_CBJ_TYPE_3, 0x1484); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS2"); snd_soc_dapm_force_enable_pin(dapm, "Mic Det Power"); snd_soc_dapm_force_enable_pin(dapm, "CBJ Power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5663_RC_CLK, + snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_1M_CLK_MASK, RT5663_DIG_1M_CLK_EN); - snd_soc_update_bits(codec, RT5663_RECMIX, 0x8, 0x8); + snd_soc_component_update_bits(component, RT5663_RECMIX, 0x8, 0x8); while (i < 5) { msleep(sleep_time[i]); - val = snd_soc_read(codec, RT5663_CBJ_TYPE_2) & 0x0003; + val = snd_soc_component_read32(component, RT5663_CBJ_TYPE_2) & 0x0003; if (val == 0x1 || val == 0x2 || val == 0x3) break; - dev_dbg(codec->dev, "%s: MX-0011 val=%x sleep %d\n", + dev_dbg(component->dev, "%s: MX-0011 val=%x sleep %d\n", __func__, val, sleep_time[i]); i++; } - dev_dbg(codec->dev, "%s val = %d\n", __func__, val); + dev_dbg(component->dev, "%s val = %d\n", __func__, val); switch (val) { case 1: case 2: rt5663->jack_type = SND_JACK_HEADSET; - rt5663_enable_push_button_irq(codec, true); + rt5663_enable_push_button_irq(component, true); break; default: snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); @@ -1496,10 +1496,10 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) break; } } else { - snd_soc_update_bits(codec, RT5663_RECMIX, 0x8, 0x0); + snd_soc_component_update_bits(component, RT5663_RECMIX, 0x8, 0x0); if (rt5663->jack_type == SND_JACK_HEADSET) { - rt5663_enable_push_button_irq(codec, false); + rt5663_enable_push_button_irq(component, false); snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); @@ -1509,60 +1509,60 @@ static int rt5663_v2_jack_detect(struct snd_soc_codec *codec, int jack_insert) rt5663->jack_type = 0; } - dev_dbg(codec->dev, "jack_type = %d\n", rt5663->jack_type); + dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type); return rt5663->jack_type; } /** * rt5663_jack_detect - Detect headset. - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @jack_insert: Jack insert or not. * * Detect whether is headset or not when jack inserted. * * Returns detect status. */ -static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5663_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int val, i = 0; - dev_dbg(codec->dev, "%s jack_insert:%d\n", __func__, jack_insert); + dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert); if (jack_insert) { - snd_soc_update_bits(codec, RT5663_DIG_MISC, + snd_soc_component_update_bits(component, RT5663_DIG_MISC, RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_EN); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_SI_HP_MASK | RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK, RT5663_SI_HP_EN | RT5663_OSW_HP_L_DIS | RT5663_OSW_HP_R_DIS); - snd_soc_update_bits(codec, RT5663_DUMMY_1, + snd_soc_component_update_bits(component, RT5663_DUMMY_1, RT5663_EMB_CLK_MASK | RT5663_HPA_CPL_BIAS_MASK | RT5663_HPA_CPR_BIAS_MASK, RT5663_EMB_CLK_EN | RT5663_HPA_CPL_BIAS_1 | RT5663_HPA_CPR_BIAS_1); - snd_soc_update_bits(codec, RT5663_CBJ_1, + snd_soc_component_update_bits(component, RT5663_CBJ_1, RT5663_INBUF_CBJ_BST1_MASK | RT5663_CBJ_SENSE_BST1_MASK, RT5663_INBUF_CBJ_BST1_ON | RT5663_CBJ_SENSE_BST1_L); - snd_soc_update_bits(codec, RT5663_IL_CMD_2, + snd_soc_component_update_bits(component, RT5663_IL_CMD_2, RT5663_PWR_MIC_DET_MASK, RT5663_PWR_MIC_DET_ON); /* BST1 power on for JD */ - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_BST1_MASK, RT5663_PWR_BST1_ON); - snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, + snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1, RT5663_CBJ_DET_MASK | RT5663_EXT_JD_MASK | RT5663_POL_EXT_JD_MASK, RT5663_CBJ_DET_EN | RT5663_EXT_JD_EN | RT5663_POL_EXT_JD_EN); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_MB_MASK | RT5663_LDO1_DVO_MASK | RT5663_AMP_HP_MASK, RT5663_PWR_MB | RT5663_LDO1_DVO_0_9V | RT5663_AMP_HP_3X); - snd_soc_update_bits(codec, RT5663_AUTO_1MRC_CLK, + snd_soc_component_update_bits(component, RT5663_AUTO_1MRC_CLK, RT5663_IRQ_POW_SAV_MASK, RT5663_IRQ_POW_SAV_EN); - snd_soc_update_bits(codec, RT5663_IRQ_1, + snd_soc_component_update_bits(component, RT5663_IRQ_1, RT5663_EN_IRQ_JD1_MASK, RT5663_EN_IRQ_JD1_EN); - snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, + snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1, RT5663_EM_JD_MASK, RT5663_EM_JD_RST); - snd_soc_update_bits(codec, RT5663_EM_JACK_TYPE_1, + snd_soc_component_update_bits(component, RT5663_EM_JACK_TYPE_1, RT5663_EM_JD_MASK, RT5663_EM_JD_NOR); while (true) { @@ -1577,10 +1577,10 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) i++; } - val = snd_soc_read(codec, RT5663_EM_JACK_TYPE_2) & 0x0003; - dev_dbg(codec->dev, "%s val = %d\n", __func__, val); + val = snd_soc_component_read32(component, RT5663_EM_JACK_TYPE_2) & 0x0003; + dev_dbg(component->dev, "%s val = %d\n", __func__, val); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_OSW_HP_L_MASK | RT5663_OSW_HP_R_MASK, RT5663_OSW_HP_L_EN | RT5663_OSW_HP_R_EN); @@ -1588,7 +1588,7 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) case 1: case 2: rt5663->jack_type = SND_JACK_HEADSET; - rt5663_enable_push_button_irq(codec, true); + rt5663_enable_push_button_irq(component, true); if (rt5663->pdata.impedance_sensing_num) break; @@ -1636,17 +1636,17 @@ static int rt5663_jack_detect(struct snd_soc_codec *codec, int jack_insert) } } else { if (rt5663->jack_type == SND_JACK_HEADSET) - rt5663_enable_push_button_irq(codec, false); + rt5663_enable_push_button_irq(component, false); rt5663->jack_type = 0; } - dev_dbg(codec->dev, "jack_type = %d\n", rt5663->jack_type); + dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type); return rt5663->jack_type; } -static int rt5663_impedance_sensing(struct snd_soc_codec *codec) +static int rt5663_impedance_sensing(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int value, i, reg84, reg26, reg2fa, reg91, reg10, reg80; for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { @@ -1655,59 +1655,59 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) } if (rt5663->jack_type == SND_JACK_HEADSET) { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); } else { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual & 0xffff); } - reg84 = snd_soc_read(codec, RT5663_ASRC_2); - reg26 = snd_soc_read(codec, RT5663_STO1_ADC_MIXER); - reg2fa = snd_soc_read(codec, RT5663_DUMMY_1); - reg91 = snd_soc_read(codec, RT5663_HP_CHARGE_PUMP_1); - reg10 = snd_soc_read(codec, RT5663_RECMIX); - reg80 = snd_soc_read(codec, RT5663_GLB_CLK); + reg84 = snd_soc_component_read32(component, RT5663_ASRC_2); + reg26 = snd_soc_component_read32(component, RT5663_STO1_ADC_MIXER); + reg2fa = snd_soc_component_read32(component, RT5663_DUMMY_1); + reg91 = snd_soc_component_read32(component, RT5663_HP_CHARGE_PUMP_1); + reg10 = snd_soc_component_read32(component, RT5663_RECMIX); + reg80 = snd_soc_component_read32(component, RT5663_GLB_CLK); - snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, 0); - snd_soc_write(codec, RT5663_ASRC_2, 0); - snd_soc_write(codec, RT5663_STO1_ADC_MIXER, 0x4040); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_STO_DRE_1, 0x8000, 0); + snd_soc_component_write(component, RT5663_ASRC_2, 0); + snd_soc_component_write(component, RT5663_STO1_ADC_MIXER, 0x4040); + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_VREF1 | RT5663_PWR_VREF2); usleep_range(10000, 10005); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1 | RT5663_PWR_FV2); - snd_soc_update_bits(codec, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, + snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, RT5663_SCLK_SRC_RCCLK); - snd_soc_update_bits(codec, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, + snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, RT5663_DIG_25M_CLK_EN); - snd_soc_update_bits(codec, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, 0); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0xff00); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0xfffc); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_1, 0x1232); - snd_soc_write(codec, RT5663_HP_LOGIC_2, 0x0005); - snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0x0030); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0x0003); - snd_soc_update_bits(codec, RT5663_PWR_DIG_2, + snd_soc_component_update_bits(component, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, 0); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0xff00); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0xfffc); + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_1, 0x1232); + snd_soc_component_write(component, RT5663_HP_LOGIC_2, 0x0005); + snd_soc_component_write(component, RT5663_DEPOP_2, 0x3003); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0x0030); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0x0003); + snd_soc_component_update_bits(component, RT5663_PWR_DIG_2, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F); - snd_soc_update_bits(codec, RT5663_PWR_DIG_1, + snd_soc_component_update_bits(component, RT5663_PWR_DIG_1, RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 | RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 | RT5663_PWR_ADC_R1, @@ -1715,71 +1715,71 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) RT5663_PWR_LDO_DACREF_ON | RT5663_PWR_ADC_L1 | RT5663_PWR_ADC_R1); msleep(40); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2); msleep(30); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); - snd_soc_write(codec, RT5663_STO_DAC_MIXER, 0); - snd_soc_write(codec, RT5663_BYPASS_STO_DAC, 0x000c); - snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); - snd_soc_write(codec, RT5663_CHARGE_PUMP_1, 0x2224); - snd_soc_write(codec, RT5663_HP_OUT_EN, 0x8088); - snd_soc_write(codec, RT5663_CHOP_ADC, 0x3000); - snd_soc_write(codec, RT5663_ADDA_RST, 0xc000); - snd_soc_write(codec, RT5663_STO1_HPF_ADJ1, 0x3320); - snd_soc_write(codec, RT5663_HP_CALIB_2, 0x00c9); - snd_soc_write(codec, RT5663_DUMMY_1, 0x004c); - snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7733); - snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); - snd_soc_write(codec, RT5663_STO_DRE_9, 0x0007); - snd_soc_write(codec, RT5663_STO_DRE_10, 0x0007); - snd_soc_write(codec, RT5663_DUMMY_2, 0x02a4); - snd_soc_write(codec, RT5663_RECMIX, 0x0005); - snd_soc_write(codec, RT5663_HP_IMP_SEN_1, 0x4334); - snd_soc_update_bits(codec, RT5663_IRQ_3, 0x0004, 0x0004); - snd_soc_write(codec, RT5663_HP_LOGIC_1, 0x2200); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x3000); - snd_soc_write(codec, RT5663_HP_LOGIC_1, 0x6200); + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_2, 0x1371); + snd_soc_component_write(component, RT5663_STO_DAC_MIXER, 0); + snd_soc_component_write(component, RT5663_BYPASS_STO_DAC, 0x000c); + snd_soc_component_write(component, RT5663_HP_BIAS, 0xafaa); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_1, 0x2224); + snd_soc_component_write(component, RT5663_HP_OUT_EN, 0x8088); + snd_soc_component_write(component, RT5663_CHOP_ADC, 0x3000); + snd_soc_component_write(component, RT5663_ADDA_RST, 0xc000); + snd_soc_component_write(component, RT5663_STO1_HPF_ADJ1, 0x3320); + snd_soc_component_write(component, RT5663_HP_CALIB_2, 0x00c9); + snd_soc_component_write(component, RT5663_DUMMY_1, 0x004c); + snd_soc_component_write(component, RT5663_ANA_BIAS_CUR_1, 0x7733); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_2, 0x7777); + snd_soc_component_write(component, RT5663_STO_DRE_9, 0x0007); + snd_soc_component_write(component, RT5663_STO_DRE_10, 0x0007); + snd_soc_component_write(component, RT5663_DUMMY_2, 0x02a4); + snd_soc_component_write(component, RT5663_RECMIX, 0x0005); + snd_soc_component_write(component, RT5663_HP_IMP_SEN_1, 0x4334); + snd_soc_component_update_bits(component, RT5663_IRQ_3, 0x0004, 0x0004); + snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0x2200); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x3000); + snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0x6200); for (i = 0; i < 100; i++) { msleep(20); - if (snd_soc_read(codec, RT5663_INT_ST_1) & 0x2) + if (snd_soc_component_read32(component, RT5663_INT_ST_1) & 0x2) break; } - value = snd_soc_read(codec, RT5663_HP_IMP_SEN_4); + value = snd_soc_component_read32(component, RT5663_HP_IMP_SEN_4); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0); - snd_soc_write(codec, RT5663_INT_ST_1, 0); - snd_soc_write(codec, RT5663_HP_LOGIC_1, 0); - snd_soc_update_bits(codec, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0); + snd_soc_component_write(component, RT5663_INT_ST_1, 0); + snd_soc_component_write(component, RT5663_HP_LOGIC_1, 0); + snd_soc_component_update_bits(component, RT5663_RC_CLK, RT5663_DIG_25M_CLK_MASK, RT5663_DIG_25M_CLK_DIS); - snd_soc_write(codec, RT5663_GLB_CLK, reg80); - snd_soc_write(codec, RT5663_RECMIX, reg10); - snd_soc_write(codec, RT5663_DUMMY_2, 0x00a4); - snd_soc_write(codec, RT5663_DUMMY_1, reg2fa); - snd_soc_write(codec, RT5663_HP_CALIB_2, 0x00c8); - snd_soc_write(codec, RT5663_STO1_HPF_ADJ1, 0xb320); - snd_soc_write(codec, RT5663_ADDA_RST, 0xe400); - snd_soc_write(codec, RT5663_CHOP_ADC, 0x2000); - snd_soc_write(codec, RT5663_HP_OUT_EN, 0x0008); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_write(component, RT5663_GLB_CLK, reg80); + snd_soc_component_write(component, RT5663_RECMIX, reg10); + snd_soc_component_write(component, RT5663_DUMMY_2, 0x00a4); + snd_soc_component_write(component, RT5663_DUMMY_1, reg2fa); + snd_soc_component_write(component, RT5663_HP_CALIB_2, 0x00c8); + snd_soc_component_write(component, RT5663_STO1_HPF_ADJ1, 0xb320); + snd_soc_component_write(component, RT5663_ADDA_RST, 0xe400); + snd_soc_component_write(component, RT5663_CHOP_ADC, 0x2000); + snd_soc_component_write(component, RT5663_HP_OUT_EN, 0x0008); + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_RECMIX1 | RT5663_PWR_RECMIX2, 0); - snd_soc_update_bits(codec, RT5663_PWR_DIG_1, + snd_soc_component_update_bits(component, RT5663_PWR_DIG_1, RT5663_PWR_DAC_L1 | RT5663_PWR_DAC_R1 | RT5663_PWR_LDO_DACREF_MASK | RT5663_PWR_ADC_L1 | RT5663_PWR_ADC_R1, 0); - snd_soc_update_bits(codec, RT5663_PWR_DIG_2, + snd_soc_component_update_bits(component, RT5663_PWR_DIG_2, RT5663_PWR_ADC_S1F | RT5663_PWR_DAC_S1F, 0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); - snd_soc_write(codec, RT5663_HP_LOGIC_2, 0); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_1, reg91); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0); + snd_soc_component_write(component, RT5663_HP_LOGIC_2, 0); + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_1, reg91); + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK, 0); - snd_soc_write(codec, RT5663_STO1_ADC_MIXER, reg26); - snd_soc_write(codec, RT5663_ASRC_2, reg84); + snd_soc_component_write(component, RT5663_STO1_ADC_MIXER, reg26); + snd_soc_component_write(component, RT5663_ASRC_2, reg84); for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { if (value >= rt5663->imp_table[i].imp_min && @@ -1787,42 +1787,42 @@ static int rt5663_impedance_sensing(struct snd_soc_codec *codec) break; } - snd_soc_update_bits(codec, RT5663_STO_DRE_9, RT5663_DRE_GAIN_HP_MASK, + snd_soc_component_update_bits(component, RT5663_STO_DRE_9, RT5663_DRE_GAIN_HP_MASK, rt5663->imp_table[i].vol); - snd_soc_update_bits(codec, RT5663_STO_DRE_10, RT5663_DRE_GAIN_HP_MASK, + snd_soc_component_update_bits(component, RT5663_STO_DRE_10, RT5663_DRE_GAIN_HP_MASK, rt5663->imp_table[i].vol); if (rt5663->jack_type == SND_JACK_HEADSET) { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); } else { - snd_soc_write(codec, RT5663_MIC_DECRO_2, + snd_soc_component_write(component, RT5663_MIC_DECRO_2, rt5663->imp_table[i].dc_offset_l_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_3, + snd_soc_component_write(component, RT5663_MIC_DECRO_3, rt5663->imp_table[i].dc_offset_l_manual & 0xffff); - snd_soc_write(codec, RT5663_MIC_DECRO_5, + snd_soc_component_write(component, RT5663_MIC_DECRO_5, rt5663->imp_table[i].dc_offset_r_manual >> 16); - snd_soc_write(codec, RT5663_MIC_DECRO_6, + snd_soc_component_write(component, RT5663_MIC_DECRO_6, rt5663->imp_table[i].dc_offset_r_manual & 0xffff); } return 0; } -static int rt5663_button_detect(struct snd_soc_codec *codec) +static int rt5663_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5663_IL_CMD_5); - dev_dbg(codec->dev, "%s: val=0x%x\n", __func__, val); + val = snd_soc_component_read32(component, RT5663_IL_CMD_5); + dev_dbg(component->dev, "%s: val=0x%x\n", __func__, val); btn_type = val & 0xfff0; - snd_soc_write(codec, RT5663_IL_CMD_5, val); + snd_soc_component_write(component, RT5663_IL_CMD_5, val); return btn_type; } @@ -1840,10 +1840,10 @@ static irqreturn_t rt5663_irq(int irq, void *data) return IRQ_HANDLED; } -int rt5663_set_jack_detect(struct snd_soc_codec *codec, +int rt5663_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); rt5663->hs_jack = hs_jack; @@ -1853,12 +1853,12 @@ int rt5663_set_jack_detect(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(rt5663_set_jack_detect); -static bool rt5663_check_jd_status(struct snd_soc_codec *codec) +static bool rt5663_check_jd_status(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); - int val = snd_soc_read(codec, RT5663_INT_ST_1); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); + int val = snd_soc_component_read32(component, RT5663_INT_ST_1); - dev_dbg(codec->dev, "%s val=%x\n", __func__, val); + dev_dbg(component->dev, "%s val=%x\n", __func__, val); /* JD1 */ switch (rt5663->codec_ver) { @@ -1867,7 +1867,7 @@ static bool rt5663_check_jd_status(struct snd_soc_codec *codec) case CODEC_VER_0: return !(val & 0x1000); default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } return false; @@ -1877,28 +1877,28 @@ static void rt5663_jack_detect_work(struct work_struct *work) { struct rt5663_priv *rt5663 = container_of(work, struct rt5663_priv, jack_detect_work.work); - struct snd_soc_codec *codec = rt5663->codec; + struct snd_soc_component *component = rt5663->component; int btn_type, report = 0; - if (!codec) + if (!component) return; - if (rt5663_check_jd_status(codec)) { + if (rt5663_check_jd_status(component)) { /* jack in */ if (rt5663->jack_type == 0) { /* jack was out, report jack type */ switch (rt5663->codec_ver) { case CODEC_VER_1: report = rt5663_v2_jack_detect( - rt5663->codec, 1); + rt5663->component, 1); break; case CODEC_VER_0: - report = rt5663_jack_detect(rt5663->codec, 1); + report = rt5663_jack_detect(rt5663->component, 1); if (rt5663->pdata.impedance_sensing_num) - rt5663_impedance_sensing(rt5663->codec); + rt5663_impedance_sensing(rt5663->component); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } /* Delay the jack insert report to avoid pop noise */ @@ -1906,7 +1906,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) } else { /* jack is already in, report button event */ report = SND_JACK_HEADSET; - btn_type = rt5663_button_detect(rt5663->codec); + btn_type = rt5663_button_detect(rt5663->component); /** * rt5663 can report three kinds of button behavior, * one click, double click and hold. However, @@ -1939,7 +1939,7 @@ static void rt5663_jack_detect_work(struct work_struct *work) break; default: btn_type = 0; - dev_err(rt5663->codec->dev, + dev_err(rt5663->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -1959,16 +1959,16 @@ static void rt5663_jack_detect_work(struct work_struct *work) /* jack out */ switch (rt5663->codec_ver) { case CODEC_VER_1: - report = rt5663_v2_jack_detect(rt5663->codec, 0); + report = rt5663_v2_jack_detect(rt5663->component, 0); break; case CODEC_VER_0: - report = rt5663_jack_detect(rt5663->codec, 0); + report = rt5663_jack_detect(rt5663->component, 0); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } } - dev_dbg(codec->dev, "%s jack report: 0x%04x\n", __func__, report); + dev_dbg(component->dev, "%s jack report: 0x%04x\n", __func__, report); snd_soc_jack_report(rt5663->hs_jack, report, SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3); @@ -1978,22 +1978,22 @@ static void rt5663_jd_unplug_work(struct work_struct *work) { struct rt5663_priv *rt5663 = container_of(work, struct rt5663_priv, jd_unplug_work.work); - struct snd_soc_codec *codec = rt5663->codec; + struct snd_soc_component *component = rt5663->component; - if (!codec) + if (!component) return; - if (!rt5663_check_jd_status(codec)) { + if (!rt5663_check_jd_status(component)) { /* jack out */ switch (rt5663->codec_ver) { case CODEC_VER_1: - rt5663_v2_jack_detect(rt5663->codec, 0); + rt5663_v2_jack_detect(rt5663->component, 0); break; case CODEC_VER_0: - rt5663_jack_detect(rt5663->codec, 0); + rt5663_jack_detect(rt5663->component, 0); break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } snd_soc_jack_report(rt5663->hs_jack, 0, SND_JACK_HEADSET | @@ -2047,9 +2047,9 @@ static int rt5663_is_sys_clk_from_pll(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); - val = snd_soc_read(codec, RT5663_GLB_CLK); + val = snd_soc_component_read32(component, RT5663_GLB_CLK); val &= RT5663_SCLK_SRC_MASK; if (val == RT5663_SCLK_SRC_PLL1) return 1; @@ -2061,8 +2061,8 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, struct snd_soc_dapm_widget *sink) { unsigned int reg, shift, val; - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); if (rt5663->codec_ver == CODEC_VER_1) { switch (w->shift) { @@ -2092,7 +2092,7 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, } } - val = (snd_soc_read(codec, reg) >> shift) & 0x7; + val = (snd_soc_component_read32(component, reg) >> shift) & 0x7; if (val) return 1; @@ -2103,23 +2103,23 @@ static int rt5663_is_using_asrc(struct snd_soc_dapm_widget *w, static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); int da_asrc_en, ad_asrc_en; - da_asrc_en = (snd_soc_read(codec, RT5663_ASRC_2) & + da_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_2) & RT5663_DA_STO1_TRACK_MASK) ? 1 : 0; switch (rt5663->codec_ver) { case CODEC_VER_1: - ad_asrc_en = (snd_soc_read(codec, RT5663_ASRC_3) & + ad_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_3) & RT5663_V2_AD_STO1_TRACK_MASK) ? 1 : 0; break; case CODEC_VER_0: - ad_asrc_en = (snd_soc_read(codec, RT5663_ASRC_2) & + ad_asrc_en = (snd_soc_component_read32(component, RT5663_ASRC_2) & RT5663_AD_STO1_TRACK_MASK) ? 1 : 0; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); return 1; } @@ -2127,14 +2127,14 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, if (rt5663->sysclk > rt5663->lrck * 384) return 1; - dev_err(codec->dev, "sysclk < 384 x fs, disable i2s asrc\n"); + dev_err(component->dev, "sysclk < 384 x fs, disable i2s asrc\n"); return 0; } /** * rt5663_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -2146,10 +2146,10 @@ static int rt5663_i2s_use_asrc(struct snd_soc_dapm_widget *source, * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5663_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int asrc2_mask = 0; unsigned int asrc2_value = 0; unsigned int asrc3_mask = 0; @@ -2180,16 +2180,16 @@ int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, asrc2_value |= clk_src << RT5663_AD_STO1_TRACK_SHIFT; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); } } if (asrc2_mask) - snd_soc_update_bits(codec, RT5663_ASRC_2, asrc2_mask, + snd_soc_component_update_bits(component, RT5663_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5663_ASRC_3, asrc3_mask, + snd_soc_component_update_bits(component, RT5663_ASRC_3, asrc3_mask, asrc3_value); return 0; @@ -2295,42 +2295,42 @@ static const struct snd_kcontrol_new rt5663_alg_dacr_mux = static int rt5663_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_SEL_PM_HP_SHIFT, RT5663_SEL_PM_HP_HIGH); - snd_soc_update_bits(codec, RT5663_HP_LOGIC_2, + snd_soc_component_update_bits(component, RT5663_HP_LOGIC_2, RT5663_HP_SIG_SRC1_MASK, RT5663_HP_SIG_SRC1_SILENCE); } else { - snd_soc_write(codec, RT5663_DEPOP_2, 0x3003); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_write(component, RT5663_DEPOP_2, 0x3003); + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_DIS); - snd_soc_write(codec, RT5663_HP_CHARGE_PUMP_2, 0x1371); - snd_soc_write(codec, RT5663_HP_BIAS, 0xabba); - snd_soc_write(codec, RT5663_CHARGE_PUMP_1, 0x2224); - snd_soc_write(codec, RT5663_ANA_BIAS_CUR_1, 0x7766); - snd_soc_write(codec, RT5663_HP_BIAS, 0xafaa); - snd_soc_write(codec, RT5663_CHARGE_PUMP_2, 0x7777); - snd_soc_update_bits(codec, RT5663_STO_DRE_1, 0x8000, + snd_soc_component_write(component, RT5663_HP_CHARGE_PUMP_2, 0x1371); + snd_soc_component_write(component, RT5663_HP_BIAS, 0xabba); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_1, 0x2224); + snd_soc_component_write(component, RT5663_ANA_BIAS_CUR_1, 0x7766); + snd_soc_component_write(component, RT5663_HP_BIAS, 0xafaa); + snd_soc_component_write(component, RT5663_CHARGE_PUMP_2, 0x7777); + snd_soc_component_update_bits(component, RT5663_STO_DRE_1, 0x8000, 0x8000); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x3000); } break; case SND_SOC_DAPM_PRE_PMD: if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_HP_LOGIC_2, + snd_soc_component_update_bits(component, RT5663_HP_LOGIC_2, RT5663_HP_SIG_SRC1_MASK, RT5663_HP_SIG_SRC1_REG); } else { - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x3000, 0x0); - snd_soc_update_bits(codec, RT5663_HP_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x3000, 0x0); + snd_soc_component_update_bits(component, RT5663_HP_CHARGE_PUMP_1, RT5663_OVCD_HP_MASK, RT5663_OVCD_HP_EN); } break; @@ -2345,23 +2345,23 @@ static int rt5663_hp_event(struct snd_soc_dapm_widget *w, static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (rt5663->codec_ver == CODEC_VER_0) { - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0x0030); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0x0003); } break; case SND_SOC_DAPM_POST_PMD: if (rt5663->codec_ver == CODEC_VER_0) { - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0003, 0); - snd_soc_update_bits(codec, RT5663_DEPOP_1, 0x0030, 0); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0003, 0); + snd_soc_component_update_bits(component, RT5663_DEPOP_1, 0x0030, 0); } break; @@ -2375,17 +2375,17 @@ static int rt5663_charge_pump_event(struct snd_soc_dapm_widget *w, static int rt5663_bst2_power(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, RT5663_PWR_BST2 | RT5663_PWR_BST2_OP); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_2, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_2, RT5663_PWR_BST2_MASK | RT5663_PWR_BST2_OP_MASK, 0); break; @@ -2399,17 +2399,17 @@ static int rt5663_bst2_power(struct snd_soc_dapm_widget *w, static int rt5663_pre_div_power(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0xff00); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0xfffc); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0xff00); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0xfffc); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_write(codec, RT5663_PRE_DIV_GATING_1, 0x0000); - snd_soc_write(codec, RT5663_PRE_DIV_GATING_2, 0x0000); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_1, 0x0000); + snd_soc_component_write(component, RT5663_PRE_DIV_GATING_2, 0x0000); break; default: @@ -2731,8 +2731,8 @@ static const struct snd_soc_dapm_route rt5663_specific_dapm_routes[] = { static int rt5663_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0; int pre_div; @@ -2743,7 +2743,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, pre_div = rl6231_get_clk_info(rt5663->sysclk, rt5663->lrck); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", + dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", rt5663->lrck, dai->id); return -EINVAL; } @@ -2767,10 +2767,10 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, RT5663_I2S1_SDP, + snd_soc_component_update_bits(component, RT5663_I2S1_SDP, RT5663_I2S_DL_MASK, val_len); - snd_soc_update_bits(codec, RT5663_ADDA_CLK_1, + snd_soc_component_update_bits(component, RT5663_ADDA_CLK_1, RT5663_I2S_PD1_MASK, pre_div << RT5663_I2S_PD1_SHIFT); return 0; @@ -2778,7 +2778,7 @@ static int rt5663_hw_params(struct snd_pcm_substream *substream, static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -2817,7 +2817,7 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, RT5663_I2S1_SDP, RT5663_I2S_MS_MASK | + snd_soc_component_update_bits(component, RT5663_I2S1_SDP, RT5663_I2S_MS_MASK | RT5663_I2S_BP_MASK | RT5663_I2S_DF_MASK, reg_val); return 0; @@ -2826,8 +2826,8 @@ static int rt5663_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5663->sysclk && clk_id == rt5663->sysclk_src) @@ -2844,15 +2844,15 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, reg_val |= RT5663_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, + snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, reg_val); rt5663->sysclk = freq; rt5663->sysclk_src = clk_id; - dev_dbg(codec->dev, "Sysclk is %dHz and clock id is %d\n", + dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); return 0; @@ -2861,8 +2861,8 @@ static int rt5663_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; int mask, shift, val; @@ -2872,11 +2872,11 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5663->pll_in = 0; rt5663->pll_out = 0; - snd_soc_update_bits(codec, RT5663_GLB_CLK, + snd_soc_component_update_bits(component, RT5663_GLB_CLK, RT5663_SCLK_SRC_MASK, RT5663_SCLK_SRC_MCLK); return 0; } @@ -2891,7 +2891,7 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, shift = RT5663_PLL1_SRC_SHIFT; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); return -EINVAL; } @@ -2903,24 +2903,24 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, val = 0x1; break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } - snd_soc_update_bits(codec, RT5663_GLB_CLK, mask, (val << shift)); + snd_soc_component_update_bits(component, RT5663_GLB_CLK, mask, (val << shift)); ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5663_PLL_1, + snd_soc_component_write(component, RT5663_PLL_1, pll_code.n_code << RT5663_PLL_N_SHIFT | pll_code.k_code); - snd_soc_write(codec, RT5663_PLL_2, + snd_soc_component_write(component, RT5663_PLL_2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5663_PLL_M_SHIFT | pll_code.m_bp << RT5663_PLL_M_BP_SHIFT); @@ -2934,8 +2934,8 @@ static int rt5663_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int val = 0, reg; if (rx_mask || tx_mask) @@ -2987,11 +2987,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, reg = RT5663_TDM_1; break; default: - dev_err(codec->dev, "Unknown CODEC Version\n"); + dev_err(component->dev, "Unknown CODEC Version\n"); return -EINVAL; } - snd_soc_update_bits(codec, reg, RT5663_TDM_MODE_MASK | + snd_soc_component_update_bits(component, reg, RT5663_TDM_MODE_MASK | RT5663_TDM_IN_CH_MASK | RT5663_TDM_OUT_CH_MASK | RT5663_TDM_IN_LEN_MASK | RT5663_TDM_OUT_LEN_MASK, val); @@ -3000,11 +3000,11 @@ static int rt5663_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) { - struct snd_soc_codec *codec = dai->codec; - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); unsigned int reg; - dev_dbg(codec->dev, "%s ratio = %d\n", __func__, ratio); + dev_dbg(component->dev, "%s ratio = %d\n", __func__, ratio); if (rt5663->codec_ver == CODEC_VER_1) reg = RT5663_TDM_9; @@ -3013,51 +3013,51 @@ static int rt5663_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) switch (ratio) { case 32: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_16); break; case 40: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_20); break; case 48: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_24); break; case 64: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, RT5663_TDM_LENGTN_MASK, RT5663_TDM_LENGTN_32); break; default: - dev_err(codec->dev, "Invalid ratio!\n"); + dev_err(component->dev, "Invalid ratio!\n"); return -EINVAL; } return 0; } -static int rt5663_set_bias_level(struct snd_soc_codec *codec, +static int rt5663_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK, RT5663_PWR_FV1 | RT5663_PWR_FV2); break; case SND_SOC_BIAS_PREPARE: if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_DIG_MISC, + snd_soc_component_update_bits(component, RT5663_DIG_MISC, RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_EN); - snd_soc_update_bits(codec, RT5663_SIG_CLK_DET, + snd_soc_component_update_bits(component, RT5663_SIG_CLK_DET, RT5663_EN_ANA_CLK_DET_MASK | RT5663_PWR_CLK_DET_MASK, RT5663_EN_ANA_CLK_DET_AUTO | @@ -3067,17 +3067,17 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_STANDBY: if (rt5663->codec_ver == CODEC_VER_1) - snd_soc_update_bits(codec, RT5663_DIG_MISC, + snd_soc_component_update_bits(component, RT5663_DIG_MISC, RT5663_DIG_GATE_CTRL_MASK, RT5663_DIG_GATE_CTRL_DIS); - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_FV1_MASK | RT5663_PWR_FV2_MASK | RT5663_PWR_MB_MASK, RT5663_PWR_VREF1 | RT5663_PWR_VREF2 | RT5663_PWR_MB); usleep_range(10000, 10005); if (rt5663->codec_ver == CODEC_VER_1) { - snd_soc_update_bits(codec, RT5663_SIG_CLK_DET, + snd_soc_component_update_bits(component, RT5663_SIG_CLK_DET, RT5663_EN_ANA_CLK_DET_MASK | RT5663_PWR_CLK_DET_MASK, RT5663_EN_ANA_CLK_DET_DIS | @@ -3086,7 +3086,7 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, RT5663_PWR_ANLG_1, + snd_soc_component_update_bits(component, RT5663_PWR_ANLG_1, RT5663_PWR_VREF1_MASK | RT5663_PWR_VREF2_MASK | RT5663_PWR_FV1 | RT5663_PWR_FV2, 0x0); break; @@ -3098,12 +3098,12 @@ static int rt5663_set_bias_level(struct snd_soc_codec *codec, return 0; } -static int rt5663_probe(struct snd_soc_codec *codec) +static int rt5663_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); - rt5663->codec = codec; + rt5663->component = component; switch (rt5663->codec_ver) { case CODEC_VER_1: @@ -3113,7 +3113,7 @@ static int rt5663_probe(struct snd_soc_codec *codec) snd_soc_dapm_add_routes(dapm, rt5663_v2_specific_dapm_routes, ARRAY_SIZE(rt5663_v2_specific_dapm_routes)); - snd_soc_add_codec_controls(codec, rt5663_v2_specific_controls, + snd_soc_add_component_controls(component, rt5663_v2_specific_controls, ARRAY_SIZE(rt5663_v2_specific_controls)); break; case CODEC_VER_0: @@ -3123,11 +3123,11 @@ static int rt5663_probe(struct snd_soc_codec *codec) snd_soc_dapm_add_routes(dapm, rt5663_specific_dapm_routes, ARRAY_SIZE(rt5663_specific_dapm_routes)); - snd_soc_add_codec_controls(codec, rt5663_specific_controls, + snd_soc_add_component_controls(component, rt5663_specific_controls, ARRAY_SIZE(rt5663_specific_controls)); if (!rt5663->imp_table) - snd_soc_add_codec_controls(codec, rt5663_hpvol_controls, + snd_soc_add_component_controls(component, rt5663_hpvol_controls, ARRAY_SIZE(rt5663_hpvol_controls)); break; } @@ -3135,19 +3135,17 @@ static int rt5663_probe(struct snd_soc_codec *codec) return 0; } -static int rt5663_remove(struct snd_soc_codec *codec) +static void rt5663_remove(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); regmap_write(rt5663->regmap, RT5663_RESET, 0); - - return 0; } #ifdef CONFIG_PM -static int rt5663_suspend(struct snd_soc_codec *codec) +static int rt5663_suspend(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5663->regmap, true); regcache_mark_dirty(rt5663->regmap); @@ -3155,9 +3153,9 @@ static int rt5663_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5663_resume(struct snd_soc_codec *codec) +static int rt5663_resume(struct snd_soc_component *component) { - struct rt5663_priv *rt5663 = snd_soc_codec_get_drvdata(codec); + struct rt5663_priv *rt5663 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5663->regmap, false); regcache_sync(rt5663->regmap); @@ -3206,21 +3204,22 @@ static struct snd_soc_dai_driver rt5663_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5663 = { - .probe = rt5663_probe, - .remove = rt5663_remove, - .suspend = rt5663_suspend, - .resume = rt5663_resume, - .set_bias_level = rt5663_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5663_snd_controls, - .num_controls = ARRAY_SIZE(rt5663_snd_controls), - .dapm_widgets = rt5663_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5663_dapm_widgets), - .dapm_routes = rt5663_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5663_dapm_routes), - } +static const struct snd_soc_component_driver soc_component_dev_rt5663 = { + .probe = rt5663_probe, + .remove = rt5663_remove, + .suspend = rt5663_suspend, + .resume = rt5663_resume, + .set_bias_level = rt5663_set_bias_level, + .controls = rt5663_snd_controls, + .num_controls = ARRAY_SIZE(rt5663_snd_controls), + .dapm_widgets = rt5663_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5663_dapm_widgets), + .dapm_routes = rt5663_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5663_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, + }; static const struct regmap_config rt5663_v2_regmap = { @@ -3610,7 +3609,8 @@ static int rt5663_i2c_probe(struct i2c_client *i2c, __func__, ret); } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5663, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5663, rt5663_dai, ARRAY_SIZE(rt5663_dai)); if (ret) { @@ -3628,8 +3628,6 @@ static int rt5663_i2c_remove(struct i2c_client *i2c) if (i2c->irq) free_irq(i2c->irq, rt5663); - snd_soc_unregister_codec(&i2c->dev); - return 0; } diff --git a/sound/soc/codecs/rt5663.h b/sound/soc/codecs/rt5663.h index 03adc8004ba9..865203cc2034 100644 --- a/sound/soc/codecs/rt5663.h +++ b/sound/soc/codecs/rt5663.h @@ -1125,9 +1125,9 @@ enum { RT5663_AD_STEREO_FILTER = 0x2, }; -int rt5663_set_jack_detect(struct snd_soc_codec *codec, +int rt5663_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hs_jack); -int rt5663_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5663_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); #endif /* __RT5663_H__ */ diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index 6dcbbcefc25b..370cd916faba 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -78,7 +78,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = { static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret = 0; ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset, @@ -86,7 +86,7 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt286_mic_detect(codec, &broadwell_headset); + rt286_mic_detect(component, &broadwell_headset); return 0; } @@ -224,10 +224,9 @@ static int broadwell_suspend(struct snd_soc_card *card){ list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strcmp(component->name, "i2c-INT343A:00")) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "disabling jack detect before going to suspend.\n"); - rt286_mic_detect(codec, NULL); + dev_dbg(component->dev, "disabling jack detect before going to suspend.\n"); + rt286_mic_detect(component, NULL); break; } } @@ -239,10 +238,9 @@ static int broadwell_resume(struct snd_soc_card *card){ list_for_each_entry(component, &card->component_dev_list, card_list) { if (!strcmp(component->name, "i2c-INT343A:00")) { - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); - dev_dbg(codec->dev, "enabling jack detect for resume.\n"); - rt286_mic_detect(codec, &broadwell_headset); + dev_dbg(component->dev, "enabling jack detect for resume.\n"); + rt286_mic_detect(component, &broadwell_headset); break; } } diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c index f8a91a6f2a17..668c0934e942 100644 --- a/sound/soc/intel/boards/bxt_da7219_max98357a.c +++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c @@ -169,7 +169,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_dai *codec_dai = rtd->codec_dai; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* Configure sysclk for codec */ ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000, @@ -192,7 +192,7 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - da7219_aad_jack_det(codec, &broxton_headset); + da7219_aad_jack_det(component, &broxton_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -522,12 +522,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) { struct bxt_card_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -545,10 +545,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* broxton audio machine driver for SPT + da7219 */ diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 7843104fadcb..875d85119c66 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -167,7 +167,7 @@ static int broxton_rt298_fe_init(struct snd_soc_pcm_runtime *rtd) static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret = 0; ret = snd_soc_card_jack_new(rtd->card, "Headset", @@ -178,7 +178,7 @@ static int broxton_rt298_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt298_mic_detect(codec, &broxton_headset); + rt298_mic_detect(component, &broxton_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -496,12 +496,12 @@ static int bxt_card_late_probe(struct snd_soc_card *card) { struct bxt_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct bxt_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -519,10 +519,10 @@ static int bxt_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index f5df6bca3156..3c9585eb6860 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -272,7 +272,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; /* @@ -294,7 +294,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + rt5663_set_jack_detect(component, &ctx->kabylake_headset); return ret; } @@ -448,7 +448,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, int ret; /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, + rt5663_sel_asrc_clk_src(codec_dai->component, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_CLK_SEL_I2S1_ASRC); @@ -898,12 +898,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_rt5663_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -921,10 +921,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* kabylake audio machine driver for SPT + RT5663 */ diff --git a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c index 90ea98f01c4c..69c3d8446f06 100644 --- a/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c @@ -178,7 +178,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; /* @@ -200,7 +200,7 @@ static int kabylake_rt5663_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - rt5663_set_jack_detect(codec, &ctx->kabylake_headset); + rt5663_set_jack_detect(component, &ctx->kabylake_headset); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "DMIC"); if (ret) @@ -333,7 +333,7 @@ static int kabylake_rt5663_hw_params(struct snd_pcm_substream *substream, int ret; /* use ASRC for internal clocks, as PLL rate isn't multiple of BCLK */ - rt5663_sel_asrc_clk_src(codec_dai->codec, + rt5663_sel_asrc_clk_src(codec_dai->component, RT5663_DA_STEREO_FILTER | RT5663_AD_STEREO_FILTER, RT5663_CLK_SEL_I2S1_ASRC); @@ -599,12 +599,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP,pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -620,10 +620,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* diff --git a/sound/soc/intel/boards/skl_nau88l25_max98357a.c b/sound/soc/intel/boards/skl_nau88l25_max98357a.c index 1b5a689dc99b..9a7a0646bffe 100644 --- a/sound/soc/intel/boards/skl_nau88l25_max98357a.c +++ b/sound/soc/intel/boards/skl_nau88l25_max98357a.c @@ -165,7 +165,7 @@ static int skylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* * Headset buttons map to the google Reference headset. @@ -180,7 +180,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - nau8825_enable_jack_detect(codec, &skylake_headset); + nau8825_enable_jack_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -592,12 +592,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_nau8825_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -616,10 +616,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + NAU88L25 */ diff --git a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c index 7bea4bc77481..212ac8971e55 100644 --- a/sound/soc/intel/boards/skl_nau88l25_ssm4567.c +++ b/sound/soc/intel/boards/skl_nau88l25_ssm4567.c @@ -195,7 +195,7 @@ static int skylake_ssm4567_codec_init(struct snd_soc_pcm_runtime *rtd) static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) { int ret; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* * 4 buttons here map to the google Reference headset @@ -210,7 +210,7 @@ static int skylake_nau8825_codec_init(struct snd_soc_pcm_runtime *rtd) return ret; } - nau8825_enable_jack_detect(codec, &skylake_headset); + nau8825_enable_jack_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -643,12 +643,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_nau88125_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -667,10 +667,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + NAU88L25 */ diff --git a/sound/soc/intel/boards/skl_rt286.c b/sound/soc/intel/boards/skl_rt286.c index 2bc4cfca594e..737d5615b0ef 100644 --- a/sound/soc/intel/boards/skl_rt286.c +++ b/sound/soc/intel/boards/skl_rt286.c @@ -130,7 +130,7 @@ static int skylake_rt286_fe_init(struct snd_soc_pcm_runtime *rtd) static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret; ret = snd_soc_card_jack_new(rtd->card, "Headset", @@ -141,7 +141,7 @@ static int skylake_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) if (ret) return ret; - rt286_mic_detect(codec, &skylake_headset); + rt286_mic_detect(component, &skylake_headset); snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); @@ -478,12 +478,12 @@ static int skylake_card_late_probe(struct snd_soc_card *card) { struct skl_rt286_private *ctx = snd_soc_card_get_drvdata(card); struct skl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -501,10 +501,10 @@ static int skylake_card_late_probe(struct snd_soc_card *card) i++; } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* skylake audio machine driver for SPT + RT286S */ diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index 214bfc78cf5c..9a10181a0811 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c @@ -176,7 +176,7 @@ static int rockchip_sound_da7219_hw_params(struct snd_pcm_substream *substream, static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec_dais[0]->codec; + struct snd_soc_component *component = rtd->codec_dais[0]->component; struct snd_soc_dai *codec_dai = rtd->codec_dai; int ret; @@ -215,7 +215,7 @@ static int rockchip_sound_da7219_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key( rockchip_sound_jack.jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); - da7219_aad_jack_det(codec, &rockchip_sound_jack); + da7219_aad_jack_det(component, &rockchip_sound_jack); return 0; } From 79223bf190919199652441d9f455cb0deabc75f5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:49:31 +0000 Subject: [PATCH 187/942] ASoC: rt5645/rt5677: replace codec to component Now we can replace Codec to Component. Let's do it. Because Intel/Mediatek platforms are using rt5645/rt5677, we need to update these all related drivers in same time. Otherwise compile error/warning happen rt5645: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 rt5677: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/amd/acp-rt5645.c | 4 +- sound/soc/codecs/rt5645.c | 370 +++++++++--------- sound/soc/codecs/rt5645.h | 4 +- sound/soc/codecs/rt5677.c | 205 +++++----- sound/soc/codecs/rt5677.h | 4 +- sound/soc/intel/boards/bdw-rt5677.c | 38 +- sound/soc/intel/boards/cht_bsw_rt5645.c | 8 +- .../mediatek/mt8173/mt8173-rt5650-rt5514.c | 6 +- .../mediatek/mt8173/mt8173-rt5650-rt5676.c | 12 +- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 12 +- sound/soc/rockchip/rockchip_rt5645.c | 8 +- 11 files changed, 331 insertions(+), 340 deletions(-) diff --git a/sound/soc/amd/acp-rt5645.c b/sound/soc/amd/acp-rt5645.c index 941aed6bb364..b79b922b08a0 100644 --- a/sound/soc/amd/acp-rt5645.c +++ b/sound/soc/amd/acp-rt5645.c @@ -71,9 +71,9 @@ static int cz_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_card *card; - struct snd_soc_codec *codec; + struct snd_soc_component *codec; - codec = rtd->codec; + codec = rtd->codec_dai->component; card = rtd->card; ret = snd_soc_card_jack_new(card, "Headset Jack", diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 8f140c8b93ac..bc8d829ce45b 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -407,7 +407,7 @@ static const char *const rt5645_supply_names[] = { }; struct rt5645_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5645_platform_data pdata; struct regmap *regmap; struct i2c_client *i2c; @@ -437,9 +437,9 @@ struct rt5645_priv { int v_id; }; -static int rt5645_reset(struct snd_soc_codec *codec) +static int rt5645_reset(struct snd_soc_component *component) { - return snd_soc_write(codec, RT5645_RESET, 0); + return snd_soc_component_write(component, RT5645_RESET, 0); } static bool rt5645_volatile_register(struct device *dev, unsigned int reg) @@ -846,17 +846,17 @@ static const struct snd_kcontrol_new rt5645_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5645->sysclk / rl6231_get_pre_div(rt5645->regmap, RT5645_ADDA_CLK1, RT5645_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else - snd_soc_update_bits(codec, RT5645_DMIC_CTRL1, + snd_soc_component_update_bits(component, RT5645_DMIC_CTRL1, RT5645_DMIC_CLK_MASK, idx << RT5645_DMIC_CLK_SFT); return idx; } @@ -864,10 +864,10 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int val; - val = snd_soc_read(codec, RT5645_GLB_CLK); + val = snd_soc_component_read32(component, RT5645_GLB_CLK); val &= RT5645_SCLK_SRC_MASK; if (val == RT5645_SCLK_SRC_PLL1) return 1; @@ -878,7 +878,7 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); unsigned int reg, shift, val; switch (source->shift) { @@ -910,7 +910,7 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, return 0; } - val = (snd_soc_read(codec, reg) >> shift) & 0xf; + val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; switch (val) { case 1: case 2: @@ -923,9 +923,9 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, } -static int rt5645_enable_hweq(struct snd_soc_codec *codec) +static int rt5645_enable_hweq(struct snd_soc_component *component) { - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < RT5645_HWEQ_NUM; i++) { @@ -941,7 +941,7 @@ static int rt5645_enable_hweq(struct snd_soc_codec *codec) /** * rt5645_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -953,7 +953,7 @@ static int rt5645_enable_hweq(struct snd_soc_codec *codec) * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5645_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { unsigned int asrc2_mask = 0; @@ -1009,11 +1009,11 @@ int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec, } if (asrc2_mask) - snd_soc_update_bits(codec, RT5645_ASRC_2, + snd_soc_component_update_bits(component, RT5645_ASRC_2, asrc2_mask, asrc2_value); if (asrc3_mask) - snd_soc_update_bits(codec, RT5645_ASRC_3, + snd_soc_component_update_bits(component, RT5645_ASRC_3, asrc3_mask, asrc3_value); return 0; @@ -1678,56 +1678,56 @@ static const struct snd_kcontrol_new pdm1_r_vol_control = SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5645_PDM_OUT_CTRL, RT5645_M_PDM1_R, 1, 1); -static void hp_amp_power(struct snd_soc_codec *codec, int on) +static void hp_amp_power(struct snd_soc_component *component, int on) { static int hp_amp_power_count; - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); if (on) { if (hp_amp_power_count <= 0) { if (rt5645->codec_type == CODEC_TYPE_RT5650) { - snd_soc_write(codec, RT5645_DEPOP_M2, 0x3100); - snd_soc_write(codec, RT5645_CHARGE_PUMP, + snd_soc_component_write(component, RT5645_DEPOP_M2, 0x3100); + snd_soc_component_write(component, RT5645_CHARGE_PUMP, 0x0e06); - snd_soc_write(codec, RT5645_DEPOP_M1, 0x000d); + snd_soc_component_write(component, RT5645_DEPOP_M1, 0x000d); regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_HP_DCC_INT1, 0x9f01); msleep(20); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_HP_CO_MASK, RT5645_HP_CO_EN); regmap_write(rt5645->regmap, RT5645_PR_BASE + 0x3e, 0x7400); - snd_soc_write(codec, RT5645_DEPOP_M3, 0x0737); + snd_soc_component_write(component, RT5645_DEPOP_M3, 0x0737); regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2, 0xfc00); - snd_soc_write(codec, RT5645_DEPOP_M2, 0x1140); + snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1140); msleep(90); rt5645->hp_on = true; } else { /* depop parameters */ - snd_soc_update_bits(codec, RT5645_DEPOP_M2, + snd_soc_component_update_bits(component, RT5645_DEPOP_M2, RT5645_DEPOP_MASK, RT5645_DEPOP_MAN); - snd_soc_write(codec, RT5645_DEPOP_M1, 0x000d); + snd_soc_component_write(component, RT5645_DEPOP_M1, 0x000d); regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_HP_DCC_INT1, 0x9f01); mdelay(150); /* headphone amp power on */ - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_FV1 | RT5645_PWR_FV2, 0); - snd_soc_update_bits(codec, RT5645_PWR_VOL, + snd_soc_component_update_bits(component, RT5645_PWR_VOL, RT5645_PWR_HV_L | RT5645_PWR_HV_R, RT5645_PWR_HV_L | RT5645_PWR_HV_R); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_HP_L | RT5645_PWR_HP_R | RT5645_PWR_HA, RT5645_PWR_HP_L | RT5645_PWR_HP_R | RT5645_PWR_HA); mdelay(5); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_FV1 | RT5645_PWR_FV2, RT5645_PWR_FV1 | RT5645_PWR_FV2); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_HP_CO_MASK | RT5645_HP_SG_MASK, RT5645_HP_CO_EN | RT5645_HP_SG_EN); regmap_write(rt5645->regmap, RT5645_PR_BASE + @@ -1743,15 +1743,15 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on) if (rt5645->codec_type == CODEC_TYPE_RT5650) { regmap_write(rt5645->regmap, RT5645_PR_BASE + 0x3e, 0x7400); - snd_soc_write(codec, RT5645_DEPOP_M3, 0x0737); + snd_soc_component_write(component, RT5645_DEPOP_M3, 0x0737); regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2, 0xfc00); - snd_soc_write(codec, RT5645_DEPOP_M2, 0x1140); + snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1140); msleep(100); - snd_soc_write(codec, RT5645_DEPOP_M1, 0x0001); + snd_soc_component_write(component, RT5645_DEPOP_M1, 0x0001); } else { - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_HP_SG_MASK | RT5645_HP_L_SMT_MASK | RT5645_HP_R_SMT_MASK, @@ -1759,11 +1759,11 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on) RT5645_HP_L_SMT_DIS | RT5645_HP_R_SMT_DIS); /* headphone amp power down */ - snd_soc_write(codec, RT5645_DEPOP_M1, 0x0000); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_write(component, RT5645_DEPOP_M1, 0x0000); + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_HP_L | RT5645_PWR_HP_R | RT5645_PWR_HA, 0); - snd_soc_update_bits(codec, RT5645_DEPOP_M2, + snd_soc_component_update_bits(component, RT5645_DEPOP_M2, RT5645_DEPOP_MASK, 0); } } @@ -1773,15 +1773,15 @@ static void hp_amp_power(struct snd_soc_codec *codec, int on) static int rt5645_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power(codec, 1); + hp_amp_power(component, 1); /* headphone unmute sequence */ if (rt5645->codec_type == CODEC_TYPE_RT5645) { - snd_soc_update_bits(codec, RT5645_DEPOP_M3, + snd_soc_component_update_bits(component, RT5645_DEPOP_M3, RT5645_CP_FQ1_MASK | RT5645_CP_FQ2_MASK | RT5645_CP_FQ3_MASK, (RT5645_CP_FQ_192_KHZ << RT5645_CP_FQ1_SFT) | @@ -1789,16 +1789,16 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, (RT5645_CP_FQ_192_KHZ << RT5645_CP_FQ3_SFT)); regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2, 0xfc00); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_SMT_TRIG_MASK, RT5645_SMT_TRIG_EN); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_RSTN_MASK, RT5645_RSTN_EN); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_RSTN_MASK | RT5645_HP_L_SMT_MASK | RT5645_HP_R_SMT_MASK, RT5645_RSTN_DIS | RT5645_HP_L_SMT_EN | RT5645_HP_R_SMT_EN); msleep(40); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_HP_SG_MASK | RT5645_HP_L_SMT_MASK | RT5645_HP_R_SMT_MASK, RT5645_HP_SG_DIS | RT5645_HP_L_SMT_DIS | RT5645_HP_R_SMT_DIS); @@ -1808,7 +1808,7 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMD: /* headphone mute sequence */ if (rt5645->codec_type == CODEC_TYPE_RT5645) { - snd_soc_update_bits(codec, RT5645_DEPOP_M3, + snd_soc_component_update_bits(component, RT5645_DEPOP_M3, RT5645_CP_FQ1_MASK | RT5645_CP_FQ2_MASK | RT5645_CP_FQ3_MASK, (RT5645_CP_FQ_96_KHZ << RT5645_CP_FQ1_SFT) | @@ -1816,17 +1816,17 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, (RT5645_CP_FQ_96_KHZ << RT5645_CP_FQ3_SFT)); regmap_write(rt5645->regmap, RT5645_PR_BASE + RT5645_MAMP_INT_REG2, 0xfc00); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_HP_SG_MASK, RT5645_HP_SG_EN); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_RSTP_MASK, RT5645_RSTP_EN); - snd_soc_update_bits(codec, RT5645_DEPOP_M1, + snd_soc_component_update_bits(component, RT5645_DEPOP_M1, RT5645_RSTP_MASK | RT5645_HP_L_SMT_MASK | RT5645_HP_R_SMT_MASK, RT5645_RSTP_DIS | RT5645_HP_L_SMT_EN | RT5645_HP_R_SMT_EN); msleep(30); } - hp_amp_power(codec, 0); + hp_amp_power(component, 0); break; default: @@ -1839,25 +1839,25 @@ static int rt5645_hp_event(struct snd_soc_dapm_widget *w, static int rt5645_spk_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - rt5645_enable_hweq(codec); - snd_soc_update_bits(codec, RT5645_PWR_DIG1, + rt5645_enable_hweq(component); + snd_soc_component_update_bits(component, RT5645_PWR_DIG1, RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | RT5645_PWR_CLS_D_L, RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | RT5645_PWR_CLS_D_L); - snd_soc_update_bits(codec, RT5645_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL3, RT5645_DET_CLK_MASK, RT5645_DET_CLK_MODE1); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5645_GEN_CTRL3, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL3, RT5645_DET_CLK_MASK, RT5645_DET_CLK_DIS); - snd_soc_write(codec, RT5645_EQ_CTRL2, 0); - snd_soc_update_bits(codec, RT5645_PWR_DIG1, + snd_soc_component_write(component, RT5645_EQ_CTRL2, 0); + snd_soc_component_update_bits(component, RT5645_PWR_DIG1, RT5645_PWR_CLS_D | RT5645_PWR_CLS_D_R | RT5645_PWR_CLS_D_L, 0); break; @@ -1872,24 +1872,24 @@ static int rt5645_spk_event(struct snd_soc_dapm_widget *w, static int rt5645_lout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - hp_amp_power(codec, 1); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + hp_amp_power(component, 1); + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_LM, RT5645_PWR_LM); - snd_soc_update_bits(codec, RT5645_LOUT1, + snd_soc_component_update_bits(component, RT5645_LOUT1, RT5645_L_MUTE | RT5645_R_MUTE, 0); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5645_LOUT1, + snd_soc_component_update_bits(component, RT5645_LOUT1, RT5645_L_MUTE | RT5645_R_MUTE, RT5645_L_MUTE | RT5645_R_MUTE); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_LM, 0); - hp_amp_power(codec, 0); + hp_amp_power(component, 0); break; default: @@ -1902,16 +1902,16 @@ static int rt5645_lout_event(struct snd_soc_dapm_widget *w, static int rt5645_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, RT5645_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG2, RT5645_PWR_BST2_P, RT5645_PWR_BST2_P); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, RT5645_PWR_ANLG2, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG2, RT5645_PWR_BST2_P, 0); break; @@ -1925,8 +1925,8 @@ static int rt5645_bst2_event(struct snd_soc_dapm_widget *w, static int rt5650_hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -1946,17 +1946,17 @@ static int rt5650_hp_event(struct snd_soc_dapm_widget *w, static int rt5645_set_micbias1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5645_GEN_CTRL2, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL2, RT5645_MICBIAS1_POW_CTRL_SEL_MASK, RT5645_MICBIAS1_POW_CTRL_SEL_M); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, RT5645_GEN_CTRL2, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL2, RT5645_MICBIAS1_POW_CTRL_SEL_MASK, RT5645_MICBIAS1_POW_CTRL_SEL_A); break; @@ -1971,17 +1971,17 @@ static int rt5645_set_micbias1_event(struct snd_soc_dapm_widget *w, static int rt5645_set_micbias2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - snd_soc_update_bits(codec, RT5645_GEN_CTRL2, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL2, RT5645_MICBIAS2_POW_CTRL_SEL_MASK, RT5645_MICBIAS2_POW_CTRL_SEL_M); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, RT5645_GEN_CTRL2, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL2, RT5645_MICBIAS2_POW_CTRL_SEL_MASK, RT5645_MICBIAS2_POW_CTRL_SEL_A); break; @@ -2768,20 +2768,20 @@ static const struct snd_soc_dapm_route rt5645_old_dapm_routes[] = { static int rt5645_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk, dl_sft; int pre_div, bclk_ms, frame_size; rt5645->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5645->sysclk, rt5645->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting\n"); + dev_err(component->dev, "Unsupported clock setting\n"); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } @@ -2822,20 +2822,20 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, case RT5645_AIF1: mask_clk = RT5645_I2S_PD1_MASK; val_clk = pre_div << RT5645_I2S_PD1_SFT; - snd_soc_update_bits(codec, RT5645_I2S1_SDP, + snd_soc_component_update_bits(component, RT5645_I2S1_SDP, (0x3 << dl_sft), (val_len << dl_sft)); - snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5645_ADDA_CLK1, mask_clk, val_clk); break; case RT5645_AIF2: mask_clk = RT5645_I2S_BCLK_MS2_MASK | RT5645_I2S_PD2_MASK; val_clk = bclk_ms << RT5645_I2S_BCLK_MS2_SFT | pre_div << RT5645_I2S_PD2_SFT; - snd_soc_update_bits(codec, RT5645_I2S2_SDP, + snd_soc_component_update_bits(component, RT5645_I2S2_SDP, (0x3 << dl_sft), (val_len << dl_sft)); - snd_soc_update_bits(codec, RT5645_ADDA_CLK1, mask_clk, val_clk); + snd_soc_component_update_bits(component, RT5645_ADDA_CLK1, mask_clk, val_clk); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } @@ -2844,8 +2844,8 @@ static int rt5645_hw_params(struct snd_pcm_substream *substream, static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0, pol_sft; switch (rt5645->codec_type) { @@ -2896,17 +2896,17 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) } switch (dai->id) { case RT5645_AIF1: - snd_soc_update_bits(codec, RT5645_I2S1_SDP, + snd_soc_component_update_bits(component, RT5645_I2S1_SDP, RT5645_I2S_MS_MASK | (1 << pol_sft) | RT5645_I2S_DF_MASK, reg_val); break; case RT5645_AIF2: - snd_soc_update_bits(codec, RT5645_I2S2_SDP, + snd_soc_component_update_bits(component, RT5645_I2S2_SDP, RT5645_I2S_MS_MASK | (1 << pol_sft) | RT5645_I2S_DF_MASK, reg_val); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } return 0; @@ -2915,8 +2915,8 @@ static int rt5645_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5645_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5645->sysclk && clk_id == rt5645->sysclk_src) @@ -2933,10 +2933,10 @@ static int rt5645_set_dai_sysclk(struct snd_soc_dai *dai, reg_val |= RT5645_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } - snd_soc_update_bits(codec, RT5645_GLB_CLK, + snd_soc_component_update_bits(component, RT5645_GLB_CLK, RT5645_SCLK_SRC_MASK, reg_val); rt5645->sysclk = freq; rt5645->sysclk_src = clk_id; @@ -2949,8 +2949,8 @@ static int rt5645_set_dai_sysclk(struct snd_soc_dai *dai, static int rt5645_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -2959,54 +2959,54 @@ static int rt5645_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5645->pll_in = 0; rt5645->pll_out = 0; - snd_soc_update_bits(codec, RT5645_GLB_CLK, + snd_soc_component_update_bits(component, RT5645_GLB_CLK, RT5645_SCLK_SRC_MASK, RT5645_SCLK_SRC_MCLK); return 0; } switch (source) { case RT5645_PLL1_S_MCLK: - snd_soc_update_bits(codec, RT5645_GLB_CLK, + snd_soc_component_update_bits(component, RT5645_GLB_CLK, RT5645_PLL1_SRC_MASK, RT5645_PLL1_SRC_MCLK); break; case RT5645_PLL1_S_BCLK1: case RT5645_PLL1_S_BCLK2: switch (dai->id) { case RT5645_AIF1: - snd_soc_update_bits(codec, RT5645_GLB_CLK, + snd_soc_component_update_bits(component, RT5645_GLB_CLK, RT5645_PLL1_SRC_MASK, RT5645_PLL1_SRC_BCLK1); break; case RT5645_AIF2: - snd_soc_update_bits(codec, RT5645_GLB_CLK, + snd_soc_component_update_bits(component, RT5645_GLB_CLK, RT5645_PLL1_SRC_MASK, RT5645_PLL1_SRC_BCLK2); break; default: - dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); + dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); return -EINVAL; } break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); - snd_soc_write(codec, RT5645_PLL_CTRL1, + snd_soc_component_write(component, RT5645_PLL_CTRL1, pll_code.n_code << RT5645_PLL_N_SFT | pll_code.k_code); - snd_soc_write(codec, RT5645_PLL_CTRL2, + snd_soc_component_write(component, RT5645_PLL_CTRL2, (pll_code.m_bp ? 0 : pll_code.m_code) << RT5645_PLL_M_SFT | pll_code.m_bp << RT5645_PLL_M_BP_SFT); @@ -3020,8 +3020,8 @@ static int rt5645_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); unsigned int i_slot_sft, o_slot_sft, i_width_sht, o_width_sht, en_sft; unsigned int mask, val = 0; @@ -3044,7 +3044,7 @@ static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, if (rx_mask || tx_mask) { val |= (1 << en_sft); if (rt5645->codec_type == CODEC_TYPE_RT5645) - snd_soc_update_bits(codec, RT5645_BASS_BACK, + snd_soc_component_update_bits(component, RT5645_BASS_BACK, RT5645_G_BB_BST_MASK, RT5645_G_BB_BST_25DB); } @@ -3078,45 +3078,45 @@ static int rt5645_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, break; } - snd_soc_update_bits(codec, RT5645_TDM_CTRL_1, mask, val); + snd_soc_component_update_bits(component, RT5645_TDM_CTRL_1, mask, val); return 0; } -static int rt5645_set_bias_level(struct snd_soc_codec *codec, +static int rt5645_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_PREPARE: - if (SND_SOC_BIAS_STANDBY == snd_soc_codec_get_bias_level(codec)) { - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_BG | RT5645_PWR_VREF2, RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_BG | RT5645_PWR_VREF2); mdelay(10); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_FV1 | RT5645_PWR_FV2, RT5645_PWR_FV1 | RT5645_PWR_FV2); - snd_soc_update_bits(codec, RT5645_GEN_CTRL1, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL1, RT5645_DIG_GATE_CTRL, RT5645_DIG_GATE_CTRL); } break; case SND_SOC_BIAS_STANDBY: - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_BG | RT5645_PWR_VREF2, RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_BG | RT5645_PWR_VREF2); mdelay(10); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_FV1 | RT5645_PWR_FV2, RT5645_PWR_FV1 | RT5645_PWR_FV2); - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { - snd_soc_write(codec, RT5645_DEPOP_M2, 0x1140); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { + snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1140); msleep(40); if (rt5645->en_button_func) queue_delayed_work(system_power_efficient_wq, @@ -3126,11 +3126,11 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - snd_soc_write(codec, RT5645_DEPOP_M2, 0x1100); + snd_soc_component_write(component, RT5645_DEPOP_M2, 0x1100); if (!rt5645->en_button_func) - snd_soc_update_bits(codec, RT5645_GEN_CTRL1, + snd_soc_component_update_bits(component, RT5645_GEN_CTRL1, RT5645_DIG_GATE_CTRL, 0); - snd_soc_update_bits(codec, RT5645_PWR_ANLG1, + snd_soc_component_update_bits(component, RT5645_PWR_ANLG1, RT5645_PWR_VREF1 | RT5645_PWR_MB | RT5645_PWR_BG | RT5645_PWR_VREF2 | RT5645_PWR_FV1 | RT5645_PWR_FV2, 0x0); @@ -3143,27 +3143,27 @@ static int rt5645_set_bias_level(struct snd_soc_codec *codec, return 0; } -static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec, +static void rt5645_enable_push_button_irq(struct snd_soc_component *component, bool enable) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); if (enable) { snd_soc_dapm_force_enable_pin(dapm, "ADC L power"); snd_soc_dapm_force_enable_pin(dapm, "ADC R power"); snd_soc_dapm_sync(dapm); - snd_soc_update_bits(codec, RT5650_4BTN_IL_CMD1, 0x3, 0x3); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT5650_4BTN_IL_CMD1, 0x3, 0x3); + snd_soc_component_update_bits(component, RT5645_INT_IRQ_ST, 0x8, 0x8); - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, RT5650_4BTN_IL_CMD2, 0x8000, 0x8000); - snd_soc_read(codec, RT5650_4BTN_IL_CMD1); + snd_soc_component_read32(component, RT5650_4BTN_IL_CMD1); pr_debug("%s read %x = %x\n", __func__, RT5650_4BTN_IL_CMD1, - snd_soc_read(codec, RT5650_4BTN_IL_CMD1)); + snd_soc_component_read32(component, RT5650_4BTN_IL_CMD1)); } else { - snd_soc_update_bits(codec, RT5650_4BTN_IL_CMD2, 0x8000, 0x0); - snd_soc_update_bits(codec, RT5645_INT_IRQ_ST, 0x8, 0x0); + snd_soc_component_update_bits(component, RT5650_4BTN_IL_CMD2, 0x8000, 0x0); + snd_soc_component_update_bits(component, RT5645_INT_IRQ_ST, 0x8, 0x0); snd_soc_dapm_disable_pin(dapm, "ADC L power"); snd_soc_dapm_disable_pin(dapm, "ADC R power"); @@ -3171,10 +3171,10 @@ static void rt5645_enable_push_button_irq(struct snd_soc_codec *codec, } } -static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) +static int rt5645_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); unsigned int val; if (jack_insert) { @@ -3208,12 +3208,12 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) msleep(600); regmap_read(rt5645->regmap, RT5645_IN1_CTRL3, &val); val &= 0x7; - dev_dbg(codec->dev, "val = %d\n", val); + dev_dbg(component->dev, "val = %d\n", val); if (val == 1 || val == 2) { rt5645->jack_type = SND_JACK_HEADSET; if (rt5645->en_button_func) { - rt5645_enable_push_button_irq(codec, true); + rt5645_enable_push_button_irq(component, true); } } else { snd_soc_dapm_disable_pin(dapm, "Mic Det Power"); @@ -3235,7 +3235,7 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) RT5645_CBJ_BST1_EN, 0); if (rt5645->en_button_func) - rt5645_enable_push_button_irq(codec, false); + rt5645_enable_push_button_irq(component, false); if (rt5645->pdata.jd_mode == 0) snd_soc_dapm_disable_pin(dapm, "LDO2"); @@ -3249,25 +3249,25 @@ static int rt5645_jack_detect(struct snd_soc_codec *codec, int jack_insert) return rt5645->jack_type; } -static int rt5645_button_detect(struct snd_soc_codec *codec) +static int rt5645_button_detect(struct snd_soc_component *component) { int btn_type, val; - val = snd_soc_read(codec, RT5650_4BTN_IL_CMD1); + val = snd_soc_component_read32(component, RT5650_4BTN_IL_CMD1); pr_debug("val=0x%x\n", val); btn_type = val & 0xfff0; - snd_soc_write(codec, RT5650_4BTN_IL_CMD1, val); + snd_soc_component_write(component, RT5650_4BTN_IL_CMD1, val); return btn_type; } static irqreturn_t rt5645_irq(int irq, void *data); -int rt5645_set_jack_detect(struct snd_soc_codec *codec, +int rt5645_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack, struct snd_soc_jack *btn_jack) { - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); rt5645->hp_jack = hp_jack; rt5645->mic_jack = mic_jack; @@ -3291,16 +3291,16 @@ static void rt5645_jack_detect_work(struct work_struct *work) container_of(work, struct rt5645_priv, jack_detect_work.work); int val, btn_type, gpio_state = 0, report = 0; - if (!rt5645->codec) + if (!rt5645->component) return; switch (rt5645->pdata.jd_mode) { case 0: /* Not using rt5645 JD */ if (rt5645->gpiod_hp_det) { gpio_state = gpiod_get_value(rt5645->gpiod_hp_det); - dev_dbg(rt5645->codec->dev, "gpio_state = %d\n", + dev_dbg(rt5645->component->dev, "gpio_state = %d\n", gpio_state); - report = rt5645_jack_detect(rt5645->codec, gpio_state); + report = rt5645_jack_detect(rt5645->component, gpio_state); } snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE); @@ -3308,20 +3308,20 @@ static void rt5645_jack_detect_work(struct work_struct *work) report, SND_JACK_MICROPHONE); return; default: /* read rt5645 jd1_1 status */ - val = snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x1000; + val = snd_soc_component_read32(rt5645->component, RT5645_INT_IRQ_ST) & 0x1000; break; } if (!val && (rt5645->jack_type == 0)) { /* jack in */ - report = rt5645_jack_detect(rt5645->codec, 1); + report = rt5645_jack_detect(rt5645->component, 1); } else if (!val && rt5645->jack_type != 0) { /* for push button and jack out */ btn_type = 0; - if (snd_soc_read(rt5645->codec, RT5645_INT_IRQ_ST) & 0x4) { + if (snd_soc_component_read32(rt5645->component, RT5645_INT_IRQ_ST) & 0x4) { /* button pressed */ report = SND_JACK_HEADSET; - btn_type = rt5645_button_detect(rt5645->codec); + btn_type = rt5645_button_detect(rt5645->component); /* rt5650 can report three kinds of button behavior, one click, double click and hold. However, currently we will report button pressed/released @@ -3351,7 +3351,7 @@ static void rt5645_jack_detect_work(struct work_struct *work) case 0x0000: /* unpressed */ break; default: - dev_err(rt5645->codec->dev, + dev_err(rt5645->component->dev, "Unexpected button code 0x%04x\n", btn_type); break; @@ -3366,9 +3366,9 @@ static void rt5645_jack_detect_work(struct work_struct *work) } else { /* jack out */ report = 0; - snd_soc_update_bits(rt5645->codec, + snd_soc_component_update_bits(rt5645->component, RT5645_INT_IRQ_ST, 0x1, 0x0); - rt5645_jack_detect(rt5645->codec, 0); + rt5645_jack_detect(rt5645->component, 0); } snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE); @@ -3406,12 +3406,12 @@ static void rt5645_btn_check_callback(struct timer_list *t) &rt5645->jack_detect_work, msecs_to_jiffies(5)); } -static int rt5645_probe(struct snd_soc_codec *codec) +static int rt5645_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); - rt5645->codec = codec; + rt5645->component = component; switch (rt5645->codec_type) { case CODEC_TYPE_RT5645: @@ -3437,7 +3437,7 @@ static int rt5645_probe(struct snd_soc_codec *codec) break; } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); /* for JD function */ if (rt5645->pdata.jd_mode) { @@ -3447,24 +3447,23 @@ static int rt5645_probe(struct snd_soc_codec *codec) } if (rt5645->pdata.long_name) - codec->component.card->long_name = rt5645->pdata.long_name; + component->card->long_name = rt5645->pdata.long_name; - rt5645->eq_param = devm_kzalloc(codec->dev, + rt5645->eq_param = devm_kzalloc(component->dev, RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL); return 0; } -static int rt5645_remove(struct snd_soc_codec *codec) +static void rt5645_remove(struct snd_soc_component *component) { - rt5645_reset(codec); - return 0; + rt5645_reset(component); } #ifdef CONFIG_PM -static int rt5645_suspend(struct snd_soc_codec *codec) +static int rt5645_suspend(struct snd_soc_component *component) { - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5645->regmap, true); regcache_mark_dirty(rt5645->regmap); @@ -3472,9 +3471,9 @@ static int rt5645_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5645_resume(struct snd_soc_codec *codec) +static int rt5645_resume(struct snd_soc_component *component) { - struct rt5645_priv *rt5645 = snd_soc_codec_get_drvdata(codec); + struct rt5645_priv *rt5645 = snd_soc_component_get_drvdata(component); regcache_cache_only(rt5645->regmap, false); regcache_sync(rt5645->regmap); @@ -3539,21 +3538,21 @@ static struct snd_soc_dai_driver rt5645_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5645 = { - .probe = rt5645_probe, - .remove = rt5645_remove, - .suspend = rt5645_suspend, - .resume = rt5645_resume, - .set_bias_level = rt5645_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5645_snd_controls, - .num_controls = ARRAY_SIZE(rt5645_snd_controls), - .dapm_widgets = rt5645_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5645_dapm_widgets), - .dapm_routes = rt5645_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5645_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5645 = { + .probe = rt5645_probe, + .remove = rt5645_remove, + .suspend = rt5645_suspend, + .resume = rt5645_resume, + .set_bias_level = rt5645_set_bias_level, + .controls = rt5645_snd_controls, + .num_controls = ARRAY_SIZE(rt5645_snd_controls), + .dapm_widgets = rt5645_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5645_dapm_widgets), + .dapm_routes = rt5645_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5645_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5645_regmap = { @@ -4028,7 +4027,7 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, } } - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5645, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5645, rt5645_dai, ARRAY_SIZE(rt5645_dai)); if (ret) goto err_irq; @@ -4054,7 +4053,6 @@ static int rt5645_i2c_remove(struct i2c_client *i2c) cancel_delayed_work_sync(&rt5645->rcclock_work); del_timer_sync(&rt5645->btn_check_timer); - snd_soc_unregister_codec(&i2c->dev); regulator_bulk_disable(ARRAY_SIZE(rt5645->supplies), rt5645->supplies); return 0; diff --git a/sound/soc/codecs/rt5645.h b/sound/soc/codecs/rt5645.h index 940325b28c29..cc2455768368 100644 --- a/sound/soc/codecs/rt5645.h +++ b/sound/soc/codecs/rt5645.h @@ -2200,10 +2200,10 @@ enum { RT5645_AD_MONO_R_FILTER = (0x1 << 5), }; -int rt5645_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5645_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); -int rt5645_set_jack_detect(struct snd_soc_codec *codec, +int rt5645_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack, struct snd_soc_jack *btn_jack); #endif /* __RT5645_H__ */ diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 0791fec398fb..bc1a23dd7c2d 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c @@ -554,7 +554,7 @@ static bool rt5677_readable_register(struct device *dev, unsigned int reg) static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677, unsigned int addr, unsigned int value, unsigned int opcode) { - struct snd_soc_codec *codec = rt5677->codec; + struct snd_soc_component *component = rt5677->component; int ret; mutex_lock(&rt5677->dsp_cmd_lock); @@ -562,35 +562,35 @@ static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677, ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB, addr >> 16); if (ret < 0) { - dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret); + dev_err(component->dev, "Failed to set addr msb value: %d\n", ret); goto err; } ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB, addr & 0xffff); if (ret < 0) { - dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret); + dev_err(component->dev, "Failed to set addr lsb value: %d\n", ret); goto err; } ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, value >> 16); if (ret < 0) { - dev_err(codec->dev, "Failed to set data msb value: %d\n", ret); + dev_err(component->dev, "Failed to set data msb value: %d\n", ret); goto err; } ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, value & 0xffff); if (ret < 0) { - dev_err(codec->dev, "Failed to set data lsb value: %d\n", ret); + dev_err(component->dev, "Failed to set data lsb value: %d\n", ret); goto err; } ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE, opcode); if (ret < 0) { - dev_err(codec->dev, "Failed to set op code value: %d\n", ret); + dev_err(component->dev, "Failed to set op code value: %d\n", ret); goto err; } @@ -612,7 +612,7 @@ err: static int rt5677_dsp_mode_i2c_read_addr( struct rt5677_priv *rt5677, unsigned int addr, unsigned int *value) { - struct snd_soc_codec *codec = rt5677->codec; + struct snd_soc_component *component = rt5677->component; int ret; unsigned int msb, lsb; @@ -621,21 +621,21 @@ static int rt5677_dsp_mode_i2c_read_addr( ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB, addr >> 16); if (ret < 0) { - dev_err(codec->dev, "Failed to set addr msb value: %d\n", ret); + dev_err(component->dev, "Failed to set addr msb value: %d\n", ret); goto err; } ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB, addr & 0xffff); if (ret < 0) { - dev_err(codec->dev, "Failed to set addr lsb value: %d\n", ret); + dev_err(component->dev, "Failed to set addr lsb value: %d\n", ret); goto err; } ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE, 0x0002); if (ret < 0) { - dev_err(codec->dev, "Failed to set op code value: %d\n", ret); + dev_err(component->dev, "Failed to set op code value: %d\n", ret); goto err; } @@ -685,9 +685,9 @@ static int rt5677_dsp_mode_i2c_read( return ret; } -static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on) +static void rt5677_set_dsp_mode(struct snd_soc_component *component, bool on) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); if (on) { regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x2, 0x2); @@ -698,9 +698,9 @@ static void rt5677_set_dsp_mode(struct snd_soc_codec *codec, bool on) } } -static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on) +static int rt5677_set_dsp_vad(struct snd_soc_component *component, bool on) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); static bool activity; int ret; @@ -740,17 +740,17 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on) } regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x07ff); regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x07fd); - rt5677_set_dsp_mode(codec, true); + rt5677_set_dsp_mode(component, true); ret = request_firmware(&rt5677->fw1, RT5677_FIRMWARE1, - codec->dev); + component->dev); if (ret == 0) { rt5677_spi_write_firmware(0x50000000, rt5677->fw1); release_firmware(rt5677->fw1); } ret = request_firmware(&rt5677->fw2, RT5677_FIRMWARE2, - codec->dev); + component->dev); if (ret == 0) { rt5677_spi_write_firmware(0x60000000, rt5677->fw2); release_firmware(rt5677->fw2); @@ -767,7 +767,7 @@ static int rt5677_set_dsp_vad(struct snd_soc_codec *codec, bool on) regcache_cache_bypass(rt5677->regmap, true); regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1, 0x1, 0x1); - rt5677_set_dsp_mode(codec, false); + rt5677_set_dsp_mode(component, false); regmap_write(rt5677->regmap, RT5677_PWR_DSP1, 0x0001); regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); @@ -812,12 +812,11 @@ static int rt5677_dsp_vad_put(struct snd_kcontrol *kcontrol, { struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); - struct snd_soc_codec *codec = snd_soc_component_to_codec(component); rt5677->dsp_vad_en = !!ucontrol->value.integer.value[0]; - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) - rt5677_set_dsp_vad(codec, rt5677->dsp_vad_en); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) + rt5677_set_dsp_vad(component, rt5677->dsp_vad_en); return 0; } @@ -911,15 +910,15 @@ static const struct snd_kcontrol_new rt5677_snd_controls[] = { static int set_dmic_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); int idx, rate; rate = rt5677->sysclk / rl6231_get_pre_div(rt5677->regmap, RT5677_CLK_TREE_CTRL1, RT5677_I2S_PD1_SFT); idx = rl6231_calc_dmic_clk(rate); if (idx < 0) - dev_err(codec->dev, "Failed to set DMIC clock\n"); + dev_err(component->dev, "Failed to set DMIC clock\n"); else regmap_update_bits(rt5677->regmap, RT5677_DMIC_CTRL1, RT5677_DMIC_CLK_MASK, idx << RT5677_DMIC_CLK_SFT); @@ -929,8 +928,8 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int val; regmap_read(rt5677->regmap, RT5677_GLB_CLK1, &val); @@ -944,8 +943,8 @@ static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, static int is_using_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int reg, shift, val; if (source->reg == RT5677_ASRC_1) { @@ -1027,8 +1026,8 @@ static int is_using_asrc(struct snd_soc_dapm_widget *source, static int can_use_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); if (rt5677->sysclk > rt5677->lrck[RT5677_AIF1] * 384) return 1; @@ -1038,7 +1037,7 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, /** * rt5677_sel_asrc_clk_src - select ASRC clock source for a set of filters - * @codec: SoC audio codec device. + * @component: SoC audio component device. * @filter_mask: mask of filters. * @clk_src: clock source * @@ -1050,10 +1049,10 @@ static int can_use_asrc(struct snd_soc_dapm_widget *source, * set of filters specified by the mask. And the codec driver will turn on ASRC * for these filters if ASRC is selected as their clock source. */ -int rt5677_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5677_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int asrc3_mask = 0, asrc3_value = 0; unsigned int asrc4_mask = 0, asrc4_value = 0; unsigned int asrc5_mask = 0, asrc5_value = 0; @@ -1232,8 +1231,8 @@ EXPORT_SYMBOL_GPL(rt5677_sel_asrc_clk_src); static int rt5677_dmic_use_asrc(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int asrc_setting; switch (source->shift) { @@ -2393,8 +2392,8 @@ static const struct snd_kcontrol_new rt5677_if2_dac7_tdm_sel_mux = static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -2417,8 +2416,8 @@ static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -2441,8 +2440,8 @@ static int rt5677_bst2_event(struct snd_soc_dapm_widget *w, static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -2463,8 +2462,8 @@ static int rt5677_set_pll1_event(struct snd_soc_dapm_widget *w, static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -2485,8 +2484,8 @@ static int rt5677_set_pll2_event(struct snd_soc_dapm_widget *w, static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: @@ -2512,8 +2511,8 @@ static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int value; switch (event) { @@ -2535,8 +2534,8 @@ static int rt5677_if1_adc_tdm_event(struct snd_soc_dapm_widget *w, static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int value; switch (event) { @@ -2558,12 +2557,12 @@ static int rt5677_if2_adc_tdm_event(struct snd_soc_dapm_widget *w, static int rt5677_vref_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: - if (snd_soc_codec_get_bias_level(codec) != SND_SOC_BIAS_ON && + if (snd_soc_component_get_bias_level(component) != SND_SOC_BIAS_ON && !rt5677->is_vref_slow) { mdelay(20); regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, @@ -4098,21 +4097,21 @@ static const struct snd_soc_dapm_route rt5677_dmic2_clk_2[] = { static int rt5677_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int val_len = 0, val_clk, mask_clk; int pre_div, bclk_ms, frame_size; rt5677->lrck[dai->id] = params_rate(params); pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]); if (pre_div < 0) { - dev_err(codec->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n", + dev_err(component->dev, "Unsupported clock setting: sysclk=%dHz lrck=%dHz\n", rt5677->sysclk, rt5677->lrck[dai->id]); return -EINVAL; } frame_size = snd_soc_params_to_frame_size(params); if (frame_size < 0) { - dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); + dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); return -EINVAL; } bclk_ms = frame_size > 32; @@ -4183,8 +4182,8 @@ static int rt5677_hw_params(struct snd_pcm_substream *substream, static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -4257,8 +4256,8 @@ static int rt5677_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; if (freq == rt5677->sysclk && clk_id == rt5677->sysclk_src) @@ -4275,7 +4274,7 @@ static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai, reg_val |= RT5677_SCLK_SRC_RCCLK; break; default: - dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); + dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } regmap_update_bits(rt5677->regmap, RT5677_GLB_CLK1, @@ -4310,8 +4309,8 @@ static int rt5677_pll_calc(const unsigned int freq_in, static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = dai->codec; - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); struct rl6231_pll_code pll_code; int ret; @@ -4320,7 +4319,7 @@ static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, return 0; if (!freq_in || !freq_out) { - dev_dbg(codec->dev, "PLL disabled\n"); + dev_dbg(component->dev, "PLL disabled\n"); rt5677->pll_in = 0; rt5677->pll_out = 0; @@ -4360,17 +4359,17 @@ static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, } break; default: - dev_err(codec->dev, "Unknown PLL source %d\n", source); + dev_err(component->dev, "Unknown PLL source %d\n", source); return -EINVAL; } ret = rt5677_pll_calc(freq_in, freq_out, &pll_code); if (ret < 0) { - dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); + dev_err(component->dev, "Unsupport input clock %d\n", freq_in); return ret; } - dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n", + dev_dbg(component->dev, "m_bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, pll_code.k_code); @@ -4390,8 +4389,8 @@ static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); unsigned int val = 0, slot_width_25 = 0; if (rx_mask || tx_mask) @@ -4449,18 +4448,18 @@ static int rt5677_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, return 0; } -static int rt5677_set_bias_level(struct snd_soc_codec *codec, +static int rt5677_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: break; case SND_SOC_BIAS_PREPARE: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) { - rt5677_set_dsp_vad(codec, false); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) { + rt5677_set_dsp_vad(component, false); regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG1, RT5677_LDO1_SEL_MASK | RT5677_LDO2_SEL_MASK, @@ -4495,7 +4494,7 @@ static int rt5677_set_bias_level(struct snd_soc_codec *codec, RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000); if (rt5677->dsp_vad_en) - rt5677_set_dsp_vad(codec, true); + rt5677_set_dsp_vad(component, true); break; default: @@ -4696,13 +4695,13 @@ static void rt5677_free_gpio(struct i2c_client *i2c) } #endif -static int rt5677_probe(struct snd_soc_codec *codec) +static int rt5677_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); int i; - rt5677->codec = codec; + rt5677->component = component; if (rt5677->pdata.dmic2_clk_pin == RT5677_DMIC_CLK2) { snd_soc_dapm_add_routes(dapm, @@ -4714,7 +4713,7 @@ static int rt5677_probe(struct snd_soc_codec *codec) ARRAY_SIZE(rt5677_dmic2_clk_1)); } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); regmap_write(rt5677->regmap, RT5677_DIG_MISC, 0x0020); regmap_write(rt5677->regmap, RT5677_PWR_DSP2, 0x0c00); @@ -4753,21 +4752,19 @@ static int rt5677_probe(struct snd_soc_codec *codec) return 0; } -static int rt5677_remove(struct snd_soc_codec *codec) +static void rt5677_remove(struct snd_soc_component *component) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); regmap_write(rt5677->regmap, RT5677_RESET, 0x10ec); gpiod_set_value_cansleep(rt5677->pow_ldo2, 0); gpiod_set_value_cansleep(rt5677->reset_pin, 1); - - return 0; } #ifdef CONFIG_PM -static int rt5677_suspend(struct snd_soc_codec *codec) +static int rt5677_suspend(struct snd_soc_component *component) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); if (!rt5677->dsp_vad_en) { regcache_cache_only(rt5677->regmap, true); @@ -4780,9 +4777,9 @@ static int rt5677_suspend(struct snd_soc_codec *codec) return 0; } -static int rt5677_resume(struct snd_soc_codec *codec) +static int rt5677_resume(struct snd_soc_component *component) { - struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); + struct rt5677_priv *rt5677 = snd_soc_component_get_drvdata(component); if (!rt5677->dsp_vad_en) { rt5677->pll_src = 0; @@ -4959,21 +4956,21 @@ static struct snd_soc_dai_driver rt5677_dai[] = { }, }; -static const struct snd_soc_codec_driver soc_codec_dev_rt5677 = { - .probe = rt5677_probe, - .remove = rt5677_remove, - .suspend = rt5677_suspend, - .resume = rt5677_resume, - .set_bias_level = rt5677_set_bias_level, - .idle_bias_off = true, - .component_driver = { - .controls = rt5677_snd_controls, - .num_controls = ARRAY_SIZE(rt5677_snd_controls), - .dapm_widgets = rt5677_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets), - .dapm_routes = rt5677_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_rt5677 = { + .probe = rt5677_probe, + .remove = rt5677_remove, + .suspend = rt5677_suspend, + .resume = rt5677_resume, + .set_bias_level = rt5677_set_bias_level, + .controls = rt5677_snd_controls, + .num_controls = ARRAY_SIZE(rt5677_snd_controls), + .dapm_widgets = rt5677_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(rt5677_dapm_widgets), + .dapm_routes = rt5677_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(rt5677_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config rt5677_regmap_physical = { @@ -5262,13 +5259,13 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, rt5677_init_gpio(i2c); rt5677_init_irq(i2c); - return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677, + return devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_rt5677, rt5677_dai, ARRAY_SIZE(rt5677_dai)); } static int rt5677_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); rt5677_free_irq(i2c); rt5677_free_gpio(i2c); diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index 97239973edc4..183d92b03045 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h @@ -1790,7 +1790,7 @@ struct rt5677_platform_data { }; struct rt5677_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct rt5677_platform_data pdata; struct regmap *regmap, *regmap_physical; const struct firmware *fw1, *fw2; @@ -1816,7 +1816,7 @@ struct rt5677_priv { bool is_vref_slow; }; -int rt5677_sel_asrc_clk_src(struct snd_soc_codec *codec, +int rt5677_sel_asrc_clk_src(struct snd_soc_component *component, unsigned int filter_mask, unsigned int clk_src); #endif /* __RT5677_H__ */ diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c index 058b8ccedf02..b19d2d977a41 100644 --- a/sound/soc/intel/boards/bdw-rt5677.c +++ b/sound/soc/intel/boards/bdw-rt5677.c @@ -34,7 +34,7 @@ struct bdw_rt5677_priv { struct gpio_desc *gpio_hp_en; - struct snd_soc_codec *codec; + struct snd_soc_component *component; }; static int bdw_rt5677_event_hp(struct snd_soc_dapm_widget *w, @@ -203,26 +203,26 @@ static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd) { struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = rtd->codec_dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; - ret = devm_acpi_dev_add_driver_gpios(codec->dev, bdw_rt5677_gpios); + ret = devm_acpi_dev_add_driver_gpios(component->dev, bdw_rt5677_gpios); if (ret) - dev_warn(codec->dev, "Failed to add driver gpios\n"); + dev_warn(component->dev, "Failed to add driver gpios\n"); /* Enable codec ASRC function for Stereo DAC/Stereo1 ADC/DMIC/I2S1. * The ASRC clock source is clk_i2s1_asrc. */ - rt5677_sel_asrc_clk_src(codec, RT5677_DA_STEREO_FILTER | + rt5677_sel_asrc_clk_src(component, RT5677_DA_STEREO_FILTER | RT5677_AD_STEREO1_FILTER | RT5677_I2S1_SOURCE, RT5677_CLK_SEL_I2S1_ASRC); /* Request rt5677 GPIO for headphone amp control */ - bdw_rt5677->gpio_hp_en = devm_gpiod_get(codec->dev, "headphone-enable", + bdw_rt5677->gpio_hp_en = devm_gpiod_get(component->dev, "headphone-enable", GPIOD_OUT_LOW); if (IS_ERR(bdw_rt5677->gpio_hp_en)) { - dev_err(codec->dev, "Can't find HP_AMP_SHDN_L gpio\n"); + dev_err(component->dev, "Can't find HP_AMP_SHDN_L gpio\n"); return PTR_ERR(bdw_rt5677->gpio_hp_en); } @@ -230,25 +230,25 @@ static int bdw_rt5677_init(struct snd_soc_pcm_runtime *rtd) if (!snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, &headphone_jack, &headphone_jack_pin, 1)) { - headphone_jack_gpio.gpiod_dev = codec->dev; + headphone_jack_gpio.gpiod_dev = component->dev; if (snd_soc_jack_add_gpios(&headphone_jack, 1, &headphone_jack_gpio)) - dev_err(codec->dev, "Can't add headphone jack gpio\n"); + dev_err(component->dev, "Can't add headphone jack gpio\n"); } else { - dev_err(codec->dev, "Can't create headphone jack\n"); + dev_err(component->dev, "Can't create headphone jack\n"); } /* Create and initialize mic jack */ if (!snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, &mic_jack, &mic_jack_pin, 1)) { - mic_jack_gpio.gpiod_dev = codec->dev; + mic_jack_gpio.gpiod_dev = component->dev; if (snd_soc_jack_add_gpios(&mic_jack, 1, &mic_jack_gpio)) - dev_err(codec->dev, "Can't add mic jack gpio\n"); + dev_err(component->dev, "Can't add mic jack gpio\n"); } else { - dev_err(codec->dev, "Can't create mic jack\n"); + dev_err(component->dev, "Can't create mic jack\n"); } - bdw_rt5677->codec = codec; + bdw_rt5677->component = component; snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); return 0; @@ -301,8 +301,8 @@ static int bdw_rt5677_suspend_pre(struct snd_soc_card *card) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card); struct snd_soc_dapm_context *dapm; - if (bdw_rt5677->codec) { - dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec); + if (bdw_rt5677->component) { + dapm = snd_soc_component_get_dapm(bdw_rt5677->component); snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); } return 0; @@ -313,8 +313,8 @@ static int bdw_rt5677_resume_post(struct snd_soc_card *card) struct bdw_rt5677_priv *bdw_rt5677 = snd_soc_card_get_drvdata(card); struct snd_soc_dapm_context *dapm; - if (bdw_rt5677->codec) { - dapm = snd_soc_codec_get_dapm(bdw_rt5677->codec); + if (bdw_rt5677->component) { + dapm = snd_soc_component_get_dapm(bdw_rt5677->component); snd_soc_dapm_force_enable_pin(dapm, "MICBIAS1"); } return 0; diff --git a/sound/soc/intel/boards/cht_bsw_rt5645.c b/sound/soc/intel/boards/cht_bsw_rt5645.c index 31641aab62cd..49ba1a956a06 100644 --- a/sound/soc/intel/boards/cht_bsw_rt5645.c +++ b/sound/soc/intel/boards/cht_bsw_rt5645.c @@ -252,14 +252,14 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); - struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_component *component = runtime->codec_dai->component; int jack_type; int ret; if ((cht_rt5645_quirk & CHT_RT5645_SSP2_AIF2) || (cht_rt5645_quirk & CHT_RT5645_SSP0_AIF2)) { /* Select clk_i2s2_asrc as ASRC clock source */ - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_DA_MONO_L_FILTER | RT5645_DA_MONO_R_FILTER | @@ -267,7 +267,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) RT5645_CLK_SEL_I2S2_ASRC); } else { /* Select clk_i2s1_asrc as ASRC clock source */ - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_DA_MONO_L_FILTER | RT5645_DA_MONO_R_FILTER | @@ -310,7 +310,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) return ret; } - rt5645_set_jack_detect(codec, &ctx->jack, &ctx->jack, &ctx->jack); + rt5645_set_jack_detect(component, &ctx->jack, &ctx->jack, &ctx->jack); /* diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c index 5a9a5482976e..904f3ee6b0eb 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c @@ -82,10 +82,10 @@ static struct snd_soc_jack mt8173_rt5650_rt5514_jack; static int mt8173_rt5650_rt5514_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec_dais[0]->codec; + struct snd_soc_component *component = runtime->codec_dais[0]->component; int ret; - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_AD_STEREO_FILTER, RT5645_CLK_SEL_I2S1_ASRC); @@ -101,7 +101,7 @@ static int mt8173_rt5650_rt5514_init(struct snd_soc_pcm_runtime *runtime) return ret; } - return rt5645_set_jack_detect(codec, + return rt5645_set_jack_detect(component, &mt8173_rt5650_rt5514_jack, &mt8173_rt5650_rt5514_jack, &mt8173_rt5650_rt5514_jack); diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c index b7248085ca04..9c61b8c099c5 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c @@ -86,19 +86,19 @@ static struct snd_soc_jack mt8173_rt5650_rt5676_jack; static int mt8173_rt5650_rt5676_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec_dais[0]->codec; - struct snd_soc_codec *codec_sub = runtime->codec_dais[1]->codec; + struct snd_soc_component *component = runtime->codec_dais[0]->component; + struct snd_soc_component *component_sub = runtime->codec_dais[1]->component; int ret; - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER | RT5645_AD_STEREO_FILTER, RT5645_CLK_SEL_I2S1_ASRC); - rt5677_sel_asrc_clk_src(codec_sub, + rt5677_sel_asrc_clk_src(component_sub, RT5677_DA_STEREO_FILTER | RT5677_AD_STEREO1_FILTER, RT5677_CLK_SEL_I2S1_ASRC); - rt5677_sel_asrc_clk_src(codec_sub, + rt5677_sel_asrc_clk_src(component_sub, RT5677_AD_STEREO2_FILTER | RT5677_I2S2_SOURCE, RT5677_CLK_SEL_I2S2_ASRC); @@ -114,7 +114,7 @@ static int mt8173_rt5650_rt5676_init(struct snd_soc_pcm_runtime *runtime) return ret; } - return rt5645_set_jack_detect(codec, + return rt5645_set_jack_detect(component, &mt8173_rt5650_rt5676_jack, &mt8173_rt5650_rt5676_jack, &mt8173_rt5650_rt5676_jack); diff --git a/sound/soc/mediatek/mt8173/mt8173-rt5650.c b/sound/soc/mediatek/mt8173/mt8173-rt5650.c index 679fc8bea0a3..84aa09d3dd98 100644 --- a/sound/soc/mediatek/mt8173/mt8173-rt5650.c +++ b/sound/soc/mediatek/mt8173/mt8173-rt5650.c @@ -112,26 +112,26 @@ static struct snd_soc_jack mt8173_rt5650_jack; static int mt8173_rt5650_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; - struct snd_soc_codec *codec = runtime->codec_dais[0]->codec; + struct snd_soc_component *component = runtime->codec_dais[0]->component; const char *codec_capture_dai = runtime->codec_dais[1]->name; int ret; - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_DA_STEREO_FILTER, RT5645_CLK_SEL_I2S1_ASRC); if (!strcmp(codec_capture_dai, "rt5645-aif1")) { - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_AD_STEREO_FILTER, RT5645_CLK_SEL_I2S1_ASRC); } else if (!strcmp(codec_capture_dai, "rt5645-aif2")) { - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_AD_STEREO_FILTER, RT5645_CLK_SEL_I2S2_ASRC); } else { dev_warn(card->dev, "Only one dai codec found in DTS, enabled rt5645 AD filter\n"); - rt5645_sel_asrc_clk_src(codec, + rt5645_sel_asrc_clk_src(component, RT5645_AD_STEREO_FILTER, RT5645_CLK_SEL_I2S1_ASRC); } @@ -147,7 +147,7 @@ static int mt8173_rt5650_init(struct snd_soc_pcm_runtime *runtime) return ret; } - return rt5645_set_jack_detect(codec, + return rt5645_set_jack_detect(component, &mt8173_rt5650_jack, &mt8173_rt5650_jack, &mt8173_rt5650_jack); diff --git a/sound/soc/rockchip/rockchip_rt5645.c b/sound/soc/rockchip/rockchip_rt5645.c index 9e0c17805807..4db4fd56db35 100644 --- a/sound/soc/rockchip/rockchip_rt5645.c +++ b/sound/soc/rockchip/rockchip_rt5645.c @@ -29,16 +29,12 @@ #include #include #include "rockchip_i2s.h" +#include "../codecs/rt5645.h" #define DRV_NAME "rockchip-snd-rt5645" static struct snd_soc_jack headset_jack; -/* Jack detect via rt5645 driver. */ -extern int rt5645_set_jack_detect(struct snd_soc_codec *codec, - struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack, - struct snd_soc_jack *btn_jack); - static const struct snd_soc_dapm_widget rk_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphones", NULL), SND_SOC_DAPM_SPK("Speakers", NULL), @@ -129,7 +125,7 @@ static int rk_init(struct snd_soc_pcm_runtime *runtime) return ret; } - return rt5645_set_jack_detect(runtime->codec, + return rt5645_set_jack_detect(runtime->codec_dai->component, &headset_jack, &headset_jack, &headset_jack); From 00a6941c841205fbdade825219a828c81008149b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:12:21 +0000 Subject: [PATCH 188/942] ASoC: wm8993/wm8994/wm8958: replace codec to component Now we can replace Codec to Component. Let's do it. Becase wm8993/wm8994/wm8958 are using wm_hubs feature, we need to update these all related drivers in same time. Otherwise compile error/warning happen wm8993: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 wm8994: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm8958-dsp2.c | 278 +++++------ sound/soc/codecs/wm8993.c | 237 +++++----- sound/soc/codecs/wm8994.c | 810 +++++++++++++++++---------------- sound/soc/codecs/wm8994.h | 8 +- sound/soc/codecs/wm_hubs.c | 254 +++++------ sound/soc/codecs/wm_hubs.h | 18 +- sound/soc/samsung/littlemill.c | 8 +- 7 files changed, 809 insertions(+), 804 deletions(-) diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 6b864c0fc2b6..8d495220fa25 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c @@ -39,10 +39,10 @@ #define WM_FW_BLOCK_A 0x08 #define WM_FW_BLOCK_C 0x0c -static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, +static int wm8958_dsp2_fw(struct snd_soc_component *component, const char *name, const struct firmware *fw, bool check) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); u64 data64; u32 data32; const u8 *data; @@ -55,7 +55,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, return 0; if (fw->size < 32) { - dev_err(codec->dev, "%s: firmware too short (%zd bytes)\n", + dev_err(component->dev, "%s: firmware too short (%zd bytes)\n", name, fw->size); goto err; } @@ -63,7 +63,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, if (memcmp(fw->data, "WMFW", 4) != 0) { memcpy(&data32, fw->data, sizeof(data32)); data32 = be32_to_cpu(data32); - dev_err(codec->dev, "%s: firmware has bad file magic %08x\n", + dev_err(component->dev, "%s: firmware has bad file magic %08x\n", name, data32); goto err; } @@ -74,35 +74,35 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, memcpy(&data32, fw->data + 8, sizeof(data32)); data32 = be32_to_cpu(data32); if ((data32 >> 24) & 0xff) { - dev_err(codec->dev, "%s: unsupported firmware version %d\n", + dev_err(component->dev, "%s: unsupported firmware version %d\n", name, (data32 >> 24) & 0xff); goto err; } if ((data32 & 0xffff) != 8958) { - dev_err(codec->dev, "%s: unsupported target device %d\n", + dev_err(component->dev, "%s: unsupported target device %d\n", name, data32 & 0xffff); goto err; } if (((data32 >> 16) & 0xff) != 0xc) { - dev_err(codec->dev, "%s: unsupported target core %d\n", + dev_err(component->dev, "%s: unsupported target core %d\n", name, (data32 >> 16) & 0xff); goto err; } if (check) { memcpy(&data64, fw->data + 24, sizeof(u64)); - dev_info(codec->dev, "%s timestamp %llx\n", + dev_info(component->dev, "%s timestamp %llx\n", name, be64_to_cpu(data64)); } else { - snd_soc_write(codec, 0x102, 0x2); - snd_soc_write(codec, 0x900, 0x2); + snd_soc_component_write(component, 0x102, 0x2); + snd_soc_component_write(component, 0x900, 0x2); } data = fw->data + len; len = fw->size - len; while (len) { if (len < 12) { - dev_err(codec->dev, "%s short data block of %zd\n", + dev_err(component->dev, "%s short data block of %zd\n", name, len); goto err; } @@ -110,12 +110,12 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, memcpy(&data32, data + 4, sizeof(data32)); block_len = be32_to_cpu(data32); if (block_len + 8 > len) { - dev_err(codec->dev, "%zd byte block longer than file\n", + dev_err(component->dev, "%zd byte block longer than file\n", block_len); goto err; } if (block_len == 0) { - dev_err(codec->dev, "Zero length block\n"); + dev_err(component->dev, "Zero length block\n"); goto err; } @@ -131,10 +131,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, str = kzalloc(block_len + 1, GFP_KERNEL); if (str) { memcpy(str, data + 8, block_len); - dev_info(codec->dev, "%s: %s\n", name, str); + dev_info(component->dev, "%s: %s\n", name, str); kfree(str); } else { - dev_err(codec->dev, "Out of memory\n"); + dev_err(component->dev, "Out of memory\n"); } break; case WM_FW_BLOCK_PM: @@ -144,7 +144,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, case WM_FW_BLOCK_I: case WM_FW_BLOCK_A: case WM_FW_BLOCK_C: - dev_dbg(codec->dev, "%s: %zd bytes of %x@%x\n", name, + dev_dbg(component->dev, "%s: %zd bytes of %x@%x\n", name, block_len, (data32 >> 24) & 0xff, data32 & 0xffffff); @@ -160,7 +160,7 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, break; default: - dev_warn(codec->dev, "%s: unknown block type %d\n", + dev_warn(component->dev, "%s: unknown block type %d\n", name, (data32 >> 24) & 0xff); break; } @@ -173,10 +173,10 @@ static int wm8958_dsp2_fw(struct snd_soc_codec *codec, const char *name, } if (!check) { - dev_dbg(codec->dev, "%s: download done\n", name); + dev_dbg(component->dev, "%s: download done\n", name); wm8994->cur_fw = fw; } else { - dev_info(codec->dev, "%s: got firmware\n", name); + dev_info(component->dev, "%s: got firmware\n", name); } goto ok; @@ -185,28 +185,28 @@ err: ret = -EINVAL; ok: if (!check) { - snd_soc_write(codec, 0x900, 0x0); - snd_soc_write(codec, 0x102, 0x0); + snd_soc_component_write(component, 0x900, 0x0); + snd_soc_component_write(component, 0x102, 0x0); } return ret; } -static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) +static void wm8958_dsp_start_mbc(struct snd_soc_component *component, int path) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i; /* If the DSP is already running then noop */ - if (snd_soc_read(codec, WM8958_DSP2_PROGRAM) & WM8958_DSP2_ENA) + if (snd_soc_component_read32(component, WM8958_DSP2_PROGRAM) & WM8958_DSP2_ENA) return; /* If we have MBC firmware download it */ if (wm8994->mbc) - wm8958_dsp2_fw(codec, "MBC", wm8994->mbc, false); + wm8958_dsp2_fw(component, "MBC", wm8994->mbc, false); - snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, WM8958_DSP2_ENA); /* If we've got user supplied MBC settings use them */ @@ -215,37 +215,37 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) = &control->pdata.mbc_cfgs[wm8994->mbc_cfg]; for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++) - snd_soc_write(codec, i + WM8958_MBC_BAND_1_K_1, + snd_soc_component_write(component, i + WM8958_MBC_BAND_1_K_1, cfg->coeff_regs[i]); for (i = 0; i < ARRAY_SIZE(cfg->cutoff_regs); i++) - snd_soc_write(codec, + snd_soc_component_write(component, i + WM8958_MBC_BAND_2_LOWER_CUTOFF_C1_1, cfg->cutoff_regs[i]); } /* Run the DSP */ - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_RUNR); /* And we're off! */ - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_ENA | WM8958_MBC_SEL_MASK, path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); } -static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) +static void wm8958_dsp_start_vss(struct snd_soc_component *component, int path) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i, ena; if (wm8994->mbc_vss) - wm8958_dsp2_fw(codec, "MBC+VSS", wm8994->mbc_vss, false); + wm8958_dsp2_fw(component, "MBC+VSS", wm8994->mbc_vss, false); - snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, WM8958_DSP2_ENA); /* If we've got user supplied settings use them */ @@ -254,7 +254,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) = &control->pdata.mbc_cfgs[wm8994->mbc_cfg]; for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++) - snd_soc_write(codec, i + 0x2800, + snd_soc_component_write(component, i + 0x2800, cfg->combined_regs[i]); } @@ -263,7 +263,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) = &control->pdata.vss_cfgs[wm8994->vss_cfg]; for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) - snd_soc_write(codec, i + 0x2600, cfg->regs[i]); + snd_soc_component_write(component, i + 0x2600, cfg->regs[i]); } if (control->pdata.num_vss_hpf_cfgs) { @@ -271,11 +271,11 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) = &control->pdata.vss_hpf_cfgs[wm8994->vss_hpf_cfg]; for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) - snd_soc_write(codec, i + 0x2400, cfg->regs[i]); + snd_soc_component_write(component, i + 0x2400, cfg->regs[i]); } /* Run the DSP */ - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_RUNR); /* Enable the algorithms we've selected */ @@ -289,23 +289,23 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) if (wm8994->vss_ena[path]) ena |= 0x1; - snd_soc_write(codec, 0x2201, ena); + snd_soc_component_write(component, 0x2201, ena); /* Switch the DSP into the data path */ - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_SEL_MASK | WM8958_MBC_ENA, path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); } -static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) +static void wm8958_dsp_start_enh_eq(struct snd_soc_component *component, int path) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i; - wm8958_dsp2_fw(codec, "ENH_EQ", wm8994->enh_eq, false); + wm8958_dsp2_fw(component, "ENH_EQ", wm8994->enh_eq, false); - snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, WM8958_DSP2_ENA); /* If we've got user supplied settings use them */ @@ -314,24 +314,24 @@ static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) = &control->pdata.enh_eq_cfgs[wm8994->enh_eq_cfg]; for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) - snd_soc_write(codec, i + 0x2200, + snd_soc_component_write(component, i + 0x2200, cfg->regs[i]); } /* Run the DSP */ - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_RUNR); /* Switch the DSP into the data path */ - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_SEL_MASK | WM8958_MBC_ENA, path << WM8958_MBC_SEL_SHIFT | WM8958_MBC_ENA); } -static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) +static void wm8958_dsp_apply(struct snd_soc_component *component, int path, int start) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); - int pwr_reg = snd_soc_read(codec, WM8994_POWER_MANAGEMENT_5); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); + int pwr_reg = snd_soc_component_read32(component, WM8994_POWER_MANAGEMENT_5); int ena, reg, aif; switch (path) { @@ -359,9 +359,9 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) if (!pwr_reg) ena = 0; - reg = snd_soc_read(codec, WM8958_DSP2_PROGRAM); + reg = snd_soc_component_read32(component, WM8958_DSP2_PROGRAM); - dev_dbg(codec->dev, "DSP path %d %d startup: %d, power: %x, DSP: %x\n", + dev_dbg(component->dev, "DSP path %d %d startup: %d, power: %x, DSP: %x\n", path, wm8994->dsp_active, start, pwr_reg, reg); if (start && ena) { @@ -370,29 +370,29 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) return; /* If either AIFnCLK is not yet enabled postpone */ - if (!(snd_soc_read(codec, WM8994_AIF1_CLOCKING_1) + if (!(snd_soc_component_read32(component, WM8994_AIF1_CLOCKING_1) & WM8994_AIF1CLK_ENA_MASK) && - !(snd_soc_read(codec, WM8994_AIF2_CLOCKING_1) + !(snd_soc_component_read32(component, WM8994_AIF2_CLOCKING_1) & WM8994_AIF2CLK_ENA_MASK)) return; /* Switch the clock over to the appropriate AIF */ - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8958_DSP2CLK_SRC | WM8958_DSP2CLK_ENA, aif << WM8958_DSP2CLK_SRC_SHIFT | WM8958_DSP2CLK_ENA); if (wm8994->enh_eq_ena[path]) - wm8958_dsp_start_enh_eq(codec, path); + wm8958_dsp_start_enh_eq(component, path); else if (wm8994->vss_ena[path] || wm8994->hpf1_ena[path] || wm8994->hpf2_ena[path]) - wm8958_dsp_start_vss(codec, path); + wm8958_dsp_start_vss(component, path); else if (wm8994->mbc_ena[path]) - wm8958_dsp_start_mbc(codec, path); + wm8958_dsp_start_mbc(component, path); wm8994->dsp_active = path; - dev_dbg(codec->dev, "DSP running in path %d\n", path); + dev_dbg(component->dev, "DSP running in path %d\n", path); } if (!start && wm8994->dsp_active == path) { @@ -400,37 +400,37 @@ static void wm8958_dsp_apply(struct snd_soc_codec *codec, int path, int start) if (!(reg & WM8958_DSP2_ENA)) return; - snd_soc_update_bits(codec, WM8958_DSP2_CONFIG, + snd_soc_component_update_bits(component, WM8958_DSP2_CONFIG, WM8958_MBC_ENA, 0); - snd_soc_write(codec, WM8958_DSP2_EXECCONTROL, + snd_soc_component_write(component, WM8958_DSP2_EXECCONTROL, WM8958_DSP2_STOP); - snd_soc_update_bits(codec, WM8958_DSP2_PROGRAM, + snd_soc_component_update_bits(component, WM8958_DSP2_PROGRAM, WM8958_DSP2_ENA, 0); - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8958_DSP2CLK_ENA, 0); wm8994->dsp_active = -1; - dev_dbg(codec->dev, "DSP stopped\n"); + dev_dbg(component->dev, "DSP stopped\n"); } } int wm8958_aif_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int i; switch (event) { case SND_SOC_DAPM_POST_PMU: case SND_SOC_DAPM_PRE_PMU: for (i = 0; i < 3; i++) - wm8958_dsp_apply(codec, i, 1); + wm8958_dsp_apply(component, i, 1); break; case SND_SOC_DAPM_POST_PMD: case SND_SOC_DAPM_PRE_PMD: for (i = 0; i < 3; i++) - wm8958_dsp_apply(codec, i, 0); + wm8958_dsp_apply(component, i, 0); break; } @@ -456,14 +456,14 @@ static int wm8958_dsp2_busy(struct wm8994_priv *wm8994, int aif) static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg; /* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY; @@ -478,8 +478,8 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_mbc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->mbc_cfg; @@ -500,8 +500,8 @@ static int wm8958_mbc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8994->mbc_ena[mbc]; @@ -512,8 +512,8 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int mbc = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (wm8994->mbc_ena[mbc] == ucontrol->value.integer.value[0]) return 0; @@ -522,7 +522,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, return -EINVAL; if (wm8958_dsp2_busy(wm8994, mbc)) { - dev_dbg(codec->dev, "DSP2 active on %d already\n", mbc); + dev_dbg(component->dev, "DSP2 active on %d already\n", mbc); return -EBUSY; } @@ -531,7 +531,7 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, wm8994->mbc_ena[mbc] = ucontrol->value.integer.value[0]; - wm8958_dsp_apply(codec, mbc, wm8994->mbc_ena[mbc]); + wm8958_dsp_apply(component, mbc, wm8994->mbc_ena[mbc]); return 0; } @@ -546,14 +546,14 @@ static int wm8958_mbc_put(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg; /* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY; @@ -568,8 +568,8 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->vss_cfg; @@ -579,14 +579,14 @@ static int wm8958_get_vss_enum(struct snd_kcontrol *kcontrol, static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg; /* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY; @@ -601,8 +601,8 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_vss_hpf_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->vss_hpf_cfg; @@ -623,8 +623,8 @@ static int wm8958_vss_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8994->vss_ena[vss]; @@ -635,8 +635,8 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int vss = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (wm8994->vss_ena[vss] == ucontrol->value.integer.value[0]) return 0; @@ -648,7 +648,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, return -ENODEV; if (wm8958_dsp2_busy(wm8994, vss)) { - dev_dbg(codec->dev, "DSP2 active on %d already\n", vss); + dev_dbg(component->dev, "DSP2 active on %d already\n", vss); return -EBUSY; } @@ -657,7 +657,7 @@ static int wm8958_vss_put(struct snd_kcontrol *kcontrol, wm8994->vss_ena[vss] = ucontrol->value.integer.value[0]; - wm8958_dsp_apply(codec, vss, wm8994->vss_ena[vss]); + wm8958_dsp_apply(component, vss, wm8994->vss_ena[vss]); return 0; } @@ -684,8 +684,8 @@ static int wm8958_hpf_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int hpf = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (hpf < 3) ucontrol->value.integer.value[0] = wm8994->hpf1_ena[hpf % 3]; @@ -699,8 +699,8 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int hpf = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (hpf < 3) { if (wm8994->hpf1_ena[hpf % 3] == @@ -719,7 +719,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, return -ENODEV; if (wm8958_dsp2_busy(wm8994, hpf % 3)) { - dev_dbg(codec->dev, "DSP2 active on %d already\n", hpf); + dev_dbg(component->dev, "DSP2 active on %d already\n", hpf); return -EBUSY; } @@ -731,7 +731,7 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, else wm8994->hpf2_ena[hpf % 3] = ucontrol->value.integer.value[0]; - wm8958_dsp_apply(codec, hpf % 3, ucontrol->value.integer.value[0]); + wm8958_dsp_apply(component, hpf % 3, ucontrol->value.integer.value[0]); return 0; } @@ -746,14 +746,14 @@ static int wm8958_hpf_put(struct snd_kcontrol *kcontrol, static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int value = ucontrol->value.enumerated.item[0]; int reg; /* Don't allow on the fly reconfiguration */ - reg = snd_soc_read(codec, WM8994_CLOCKING_1); + reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (reg < 0 || reg & WM8958_DSP2CLK_ENA) return -EBUSY; @@ -768,8 +768,8 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol, static int wm8958_get_enh_eq_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = wm8994->enh_eq_cfg; @@ -790,8 +790,8 @@ static int wm8958_enh_eq_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = wm8994->enh_eq_ena[eq]; @@ -802,8 +802,8 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int eq = kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (wm8994->enh_eq_ena[eq] == ucontrol->value.integer.value[0]) return 0; @@ -815,7 +815,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, return -ENODEV; if (wm8958_dsp2_busy(wm8994, eq)) { - dev_dbg(codec->dev, "DSP2 active on %d already\n", eq); + dev_dbg(component->dev, "DSP2 active on %d already\n", eq); return -EBUSY; } @@ -825,7 +825,7 @@ static int wm8958_enh_eq_put(struct snd_kcontrol *kcontrol, wm8994->enh_eq_ena[eq] = ucontrol->value.integer.value[0]; - wm8958_dsp_apply(codec, eq, ucontrol->value.integer.value[0]); + wm8958_dsp_apply(component, eq, ucontrol->value.integer.value[0]); return 0; } @@ -863,10 +863,10 @@ WM8958_ENH_EQ_SWITCH("AIF2DAC Enhanced EQ Switch", 2), static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context) { - struct snd_soc_codec *codec = context; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = context; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); - if (fw && (wm8958_dsp2_fw(codec, "ENH_EQ", fw, true) == 0)) { + if (fw && (wm8958_dsp2_fw(component, "ENH_EQ", fw, true) == 0)) { mutex_lock(&wm8994->fw_lock); wm8994->enh_eq = fw; mutex_unlock(&wm8994->fw_lock); @@ -875,10 +875,10 @@ static void wm8958_enh_eq_loaded(const struct firmware *fw, void *context) static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context) { - struct snd_soc_codec *codec = context; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = context; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); - if (fw && (wm8958_dsp2_fw(codec, "MBC+VSS", fw, true) == 0)) { + if (fw && (wm8958_dsp2_fw(component, "MBC+VSS", fw, true) == 0)) { mutex_lock(&wm8994->fw_lock); wm8994->mbc_vss = fw; mutex_unlock(&wm8994->fw_lock); @@ -887,43 +887,43 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context) static void wm8958_mbc_loaded(const struct firmware *fw, void *context) { - struct snd_soc_codec *codec = context; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = context; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); - if (fw && (wm8958_dsp2_fw(codec, "MBC", fw, true) == 0)) { + if (fw && (wm8958_dsp2_fw(component, "MBC", fw, true) == 0)) { mutex_lock(&wm8994->fw_lock); wm8994->mbc = fw; mutex_unlock(&wm8994->fw_lock); } } -void wm8958_dsp2_init(struct snd_soc_codec *codec) +void wm8958_dsp2_init(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int ret, i; wm8994->dsp_active = -1; - snd_soc_add_codec_controls(codec, wm8958_mbc_snd_controls, + snd_soc_add_component_controls(component, wm8958_mbc_snd_controls, ARRAY_SIZE(wm8958_mbc_snd_controls)); - snd_soc_add_codec_controls(codec, wm8958_vss_snd_controls, + snd_soc_add_component_controls(component, wm8958_vss_snd_controls, ARRAY_SIZE(wm8958_vss_snd_controls)); - snd_soc_add_codec_controls(codec, wm8958_enh_eq_snd_controls, + snd_soc_add_component_controls(component, wm8958_enh_eq_snd_controls, ARRAY_SIZE(wm8958_enh_eq_snd_controls)); /* We don't *require* firmware and don't want to delay boot */ request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, - "wm8958_mbc.wfw", codec->dev, GFP_KERNEL, - codec, wm8958_mbc_loaded); + "wm8958_mbc.wfw", component->dev, GFP_KERNEL, + component, wm8958_mbc_loaded); request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, - "wm8958_mbc_vss.wfw", codec->dev, GFP_KERNEL, - codec, wm8958_mbc_vss_loaded); + "wm8958_mbc_vss.wfw", component->dev, GFP_KERNEL, + component, wm8958_mbc_vss_loaded); request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, - "wm8958_enh_eq.wfw", codec->dev, GFP_KERNEL, - codec, wm8958_enh_eq_loaded); + "wm8958_enh_eq.wfw", component->dev, GFP_KERNEL, + component, wm8958_enh_eq_loaded); if (pdata->num_mbc_cfgs) { struct snd_kcontrol_new control[] = { @@ -943,10 +943,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) wm8994->mbc_enum.items = pdata->num_mbc_cfgs; wm8994->mbc_enum.texts = wm8994->mbc_texts; - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, + ret = snd_soc_add_component_controls(wm8994->hubs.component, control, 1); if (ret != 0) - dev_err(wm8994->hubs.codec->dev, + dev_err(wm8994->hubs.component->dev, "Failed to add MBC mode controls: %d\n", ret); } @@ -968,10 +968,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) wm8994->vss_enum.items = pdata->num_vss_cfgs; wm8994->vss_enum.texts = wm8994->vss_texts; - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, + ret = snd_soc_add_component_controls(wm8994->hubs.component, control, 1); if (ret != 0) - dev_err(wm8994->hubs.codec->dev, + dev_err(wm8994->hubs.component->dev, "Failed to add VSS mode controls: %d\n", ret); } @@ -994,10 +994,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) wm8994->vss_hpf_enum.items = pdata->num_vss_hpf_cfgs; wm8994->vss_hpf_enum.texts = wm8994->vss_hpf_texts; - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, + ret = snd_soc_add_component_controls(wm8994->hubs.component, control, 1); if (ret != 0) - dev_err(wm8994->hubs.codec->dev, + dev_err(wm8994->hubs.component->dev, "Failed to add VSS HPFmode controls: %d\n", ret); } @@ -1021,10 +1021,10 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) wm8994->enh_eq_enum.items = pdata->num_enh_eq_cfgs; wm8994->enh_eq_enum.texts = wm8994->enh_eq_texts; - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, + ret = snd_soc_add_component_controls(wm8994->hubs.component, control, 1); if (ret != 0) - dev_err(wm8994->hubs.codec->dev, + dev_err(wm8994->hubs.component->dev, "Failed to add enhanced EQ controls: %d\n", ret); } diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index 830ffd80de4a..2c61655c44ea 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c @@ -466,11 +466,11 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref, return 0; } -static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int _wm8993_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); - struct i2c_client *i2c = to_i2c_client(codec->dev); + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); + struct i2c_client *i2c = to_i2c_client(component->dev); u16 reg1, reg4, reg5; struct _fll_div fll_div; unsigned int timeout; @@ -482,13 +482,13 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, /* Disable the FLL */ if (Fout == 0) { - dev_dbg(codec->dev, "FLL disabled\n"); + dev_dbg(component->dev, "FLL disabled\n"); wm8993->fll_fref = 0; wm8993->fll_fout = 0; - reg1 = snd_soc_read(codec, WM8993_FLL_CONTROL_1); + reg1 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_1); reg1 &= ~WM8993_FLL_ENA; - snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1); return 0; } @@ -497,7 +497,7 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, if (ret != 0) return ret; - reg5 = snd_soc_read(codec, WM8993_FLL_CONTROL_5); + reg5 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_5); reg5 &= ~WM8993_FLL_CLK_SRC_MASK; switch (fll_id) { @@ -513,36 +513,36 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, break; default: - dev_err(codec->dev, "Unknown FLL ID %d\n", fll_id); + dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); return -EINVAL; } /* Any FLL configuration change requires that the FLL be * disabled first. */ - reg1 = snd_soc_read(codec, WM8993_FLL_CONTROL_1); + reg1 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_1); reg1 &= ~WM8993_FLL_ENA; - snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1); /* Apply the configuration */ if (fll_div.k) reg1 |= WM8993_FLL_FRAC_MASK; else reg1 &= ~WM8993_FLL_FRAC_MASK; - snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1); + snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1); - snd_soc_write(codec, WM8993_FLL_CONTROL_2, + snd_soc_component_write(component, WM8993_FLL_CONTROL_2, (fll_div.fll_outdiv << WM8993_FLL_OUTDIV_SHIFT) | (fll_div.fll_fratio << WM8993_FLL_FRATIO_SHIFT)); - snd_soc_write(codec, WM8993_FLL_CONTROL_3, fll_div.k); + snd_soc_component_write(component, WM8993_FLL_CONTROL_3, fll_div.k); - reg4 = snd_soc_read(codec, WM8993_FLL_CONTROL_4); + reg4 = snd_soc_component_read32(component, WM8993_FLL_CONTROL_4); reg4 &= ~WM8993_FLL_N_MASK; reg4 |= fll_div.n << WM8993_FLL_N_SHIFT; - snd_soc_write(codec, WM8993_FLL_CONTROL_4, reg4); + snd_soc_component_write(component, WM8993_FLL_CONTROL_4, reg4); reg5 &= ~WM8993_FLL_CLK_REF_DIV_MASK; reg5 |= fll_div.fll_clk_ref_div << WM8993_FLL_CLK_REF_DIV_SHIFT; - snd_soc_write(codec, WM8993_FLL_CONTROL_5, reg5); + snd_soc_component_write(component, WM8993_FLL_CONTROL_5, reg5); /* If we've got an interrupt wired up make sure we get it */ if (i2c->irq) @@ -555,13 +555,13 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, try_wait_for_completion(&wm8993->fll_lock); /* Enable the FLL */ - snd_soc_write(codec, WM8993_FLL_CONTROL_1, reg1 | WM8993_FLL_ENA); + snd_soc_component_write(component, WM8993_FLL_CONTROL_1, reg1 | WM8993_FLL_ENA); timeout = wait_for_completion_timeout(&wm8993->fll_lock, timeout); if (i2c->irq && !timeout) - dev_warn(codec->dev, "Timed out waiting for FLL\n"); + dev_warn(component->dev, "Timed out waiting for FLL\n"); - dev_dbg(codec->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); + dev_dbg(component->dev, "FLL enabled at %dHz->%dHz\n", Fref, Fout); wm8993->fll_fref = Fref; wm8993->fll_fout = Fout; @@ -573,20 +573,20 @@ static int _wm8993_set_fll(struct snd_soc_codec *codec, int fll_id, int source, static int wm8993_set_fll(struct snd_soc_dai *dai, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - return _wm8993_set_fll(dai->codec, fll_id, source, Fref, Fout); + return _wm8993_set_fll(dai->component, fll_id, source, Fref, Fout); } -static int configure_clock(struct snd_soc_codec *codec) +static int configure_clock(struct snd_soc_component *component) { - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); unsigned int reg; /* This should be done on init() for bypass paths */ switch (wm8993->sysclk_source) { case WM8993_SYSCLK_MCLK: - dev_dbg(codec->dev, "Using %dHz MCLK\n", wm8993->mclk_rate); + dev_dbg(component->dev, "Using %dHz MCLK\n", wm8993->mclk_rate); - reg = snd_soc_read(codec, WM8993_CLOCKING_2); + reg = snd_soc_component_read32(component, WM8993_CLOCKING_2); reg &= ~(WM8993_MCLK_DIV | WM8993_SYSCLK_SRC); if (wm8993->mclk_rate > 13500000) { reg |= WM8993_MCLK_DIV; @@ -595,14 +595,14 @@ static int configure_clock(struct snd_soc_codec *codec) reg &= ~WM8993_MCLK_DIV; wm8993->sysclk_rate = wm8993->mclk_rate; } - snd_soc_write(codec, WM8993_CLOCKING_2, reg); + snd_soc_component_write(component, WM8993_CLOCKING_2, reg); break; case WM8993_SYSCLK_FLL: - dev_dbg(codec->dev, "Using %dHz FLL clock\n", + dev_dbg(component->dev, "Using %dHz FLL clock\n", wm8993->fll_fout); - reg = snd_soc_read(codec, WM8993_CLOCKING_2); + reg = snd_soc_component_read32(component, WM8993_CLOCKING_2); reg |= WM8993_SYSCLK_SRC; if (wm8993->fll_fout > 13500000) { reg |= WM8993_MCLK_DIV; @@ -611,15 +611,15 @@ static int configure_clock(struct snd_soc_codec *codec) reg &= ~WM8993_MCLK_DIV; wm8993->sysclk_rate = wm8993->fll_fout; } - snd_soc_write(codec, WM8993_CLOCKING_2, reg); + snd_soc_component_write(component, WM8993_CLOCKING_2, reg); break; default: - dev_err(codec->dev, "System clock not configured\n"); + dev_err(component->dev, "System clock not configured\n"); return -EINVAL; } - dev_dbg(codec->dev, "CLK_SYS is %dHz\n", wm8993->sysclk_rate); + dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm8993->sysclk_rate); return 0; } @@ -809,11 +809,11 @@ SOC_SINGLE_TLV("EQ5 Volume", WM8993_EQ6, 0, 24, 0, eq_tlv), static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - return configure_clock(codec); + return configure_clock(component); case SND_SOC_DAPM_POST_PMD: break; @@ -972,26 +972,26 @@ static const struct snd_soc_dapm_route routes[] = { { "Right Headphone Mux", "DAC", "DACR" }, }; -static int wm8993_set_bias_level(struct snd_soc_codec *codec, +static int wm8993_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); int ret; - wm_hubs_set_bias_level(codec, level); + wm_hubs_set_bias_level(component, level); switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: /* VMID=2*40k */ - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_VMID_SEL_MASK, 0x2); - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_2, WM8993_TSHUT_ENA, WM8993_TSHUT_ENA); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { ret = regulator_bulk_enable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); if (ret != 0) @@ -1000,10 +1000,10 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec, regcache_cache_only(wm8993->regmap, false); regcache_sync(wm8993->regmap); - wm_hubs_vmid_ena(codec); + wm_hubs_vmid_ena(component); /* Bring up VMID with fast soft start */ - snd_soc_update_bits(codec, WM8993_ANTIPOP2, + snd_soc_component_update_bits(component, WM8993_ANTIPOP2, WM8993_STARTUP_BIAS_ENA | WM8993_VMID_BUF_ENA | WM8993_VMID_RAMP_MASK | @@ -1017,40 +1017,40 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec, * need the VMID buffer */ if (!wm8993->pdata.lineout1_diff || !wm8993->pdata.lineout2_diff) - snd_soc_update_bits(codec, WM8993_ANTIPOP1, + snd_soc_component_update_bits(component, WM8993_ANTIPOP1, WM8993_LINEOUT_VMID_BUF_ENA, WM8993_LINEOUT_VMID_BUF_ENA); /* VMID=2*40k */ - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_VMID_SEL_MASK | WM8993_BIAS_ENA, WM8993_BIAS_ENA | 0x2); msleep(32); /* Switch to normal bias */ - snd_soc_update_bits(codec, WM8993_ANTIPOP2, + snd_soc_component_update_bits(component, WM8993_ANTIPOP2, WM8993_BIAS_SRC | WM8993_STARTUP_BIAS_ENA, 0); } /* VMID=2*240k */ - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_VMID_SEL_MASK, 0x4); - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_2, WM8993_TSHUT_ENA, 0); break; case SND_SOC_BIAS_OFF: - snd_soc_update_bits(codec, WM8993_ANTIPOP1, + snd_soc_component_update_bits(component, WM8993_ANTIPOP1, WM8993_LINEOUT_VMID_BUF_ENA, 0); - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_VMID_SEL_MASK | WM8993_BIAS_ENA, 0); - snd_soc_update_bits(codec, WM8993_ANTIPOP2, + snd_soc_component_update_bits(component, WM8993_ANTIPOP2, WM8993_STARTUP_BIAS_ENA | WM8993_VMID_BUF_ENA | WM8993_VMID_RAMP_MASK | @@ -1070,8 +1070,8 @@ static int wm8993_set_bias_level(struct snd_soc_codec *codec, static int wm8993_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); switch (clk_id) { case WM8993_SYSCLK_MCLK: @@ -1091,10 +1091,10 @@ static int wm8993_set_sysclk(struct snd_soc_dai *codec_dai, static int wm8993_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); - unsigned int aif1 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_1); - unsigned int aif4 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_4); + struct snd_soc_component *component = dai->component; + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); + unsigned int aif1 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_1); + unsigned int aif4 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_4); aif1 &= ~(WM8993_BCLK_DIR | WM8993_AIF_BCLK_INV | WM8993_AIF_LRCLK_INV | WM8993_AIF_FMT_MASK); @@ -1178,8 +1178,8 @@ static int wm8993_set_dai_fmt(struct snd_soc_dai *dai, return -EINVAL; } - snd_soc_write(codec, WM8993_AUDIO_INTERFACE_1, aif1); - snd_soc_write(codec, WM8993_AUDIO_INTERFACE_4, aif4); + snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_4, aif4); return 0; } @@ -1188,28 +1188,28 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); int ret, i, best, best_val, cur_val; unsigned int clocking1, clocking3, aif1, aif4; - clocking1 = snd_soc_read(codec, WM8993_CLOCKING_1); + clocking1 = snd_soc_component_read32(component, WM8993_CLOCKING_1); clocking1 &= ~WM8993_BCLK_DIV_MASK; - clocking3 = snd_soc_read(codec, WM8993_CLOCKING_3); + clocking3 = snd_soc_component_read32(component, WM8993_CLOCKING_3); clocking3 &= ~(WM8993_CLK_SYS_RATE_MASK | WM8993_SAMPLE_RATE_MASK); - aif1 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_1); + aif1 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_1); aif1 &= ~WM8993_AIF_WL_MASK; - aif4 = snd_soc_read(codec, WM8993_AUDIO_INTERFACE_4); + aif4 = snd_soc_component_read32(component, WM8993_AUDIO_INTERFACE_4); aif4 &= ~WM8993_LRCLK_RATE_MASK; /* What BCLK do we need? */ wm8993->fs = params_rate(params); wm8993->bclk = 2 * wm8993->fs; if (wm8993->tdm_slots) { - dev_dbg(codec->dev, "Configuring for %d %d bit TDM slots\n", + dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", wm8993->tdm_slots, wm8993->tdm_width); wm8993->bclk *= wm8993->tdm_width * wm8993->tdm_slots; } else { @@ -1234,9 +1234,9 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, } } - dev_dbg(codec->dev, "Target BCLK is %dHz\n", wm8993->bclk); + dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8993->bclk); - ret = configure_clock(codec); + ret = configure_clock(component); if (ret != 0) return ret; @@ -1252,7 +1252,7 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected CLK_SYS_RATIO of %d\n", + dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", clk_sys_rates[best].ratio); clocking3 |= (clk_sys_rates[best].clk_sys_rate << WM8993_CLK_SYS_RATE_SHIFT); @@ -1268,7 +1268,7 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, best_val = cur_val; } } - dev_dbg(codec->dev, "Selected SAMPLE_RATE of %dHz\n", + dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", sample_rates[best].rate); clocking3 |= (sample_rates[best].sample_rate << WM8993_SAMPLE_RATE_SHIFT); @@ -1287,22 +1287,22 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, } } wm8993->bclk = (wm8993->sysclk_rate * 10) / bclk_divs[best].div; - dev_dbg(codec->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", + dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", bclk_divs[best].div, wm8993->bclk); clocking1 |= bclk_divs[best].bclk_div << WM8993_BCLK_DIV_SHIFT; /* LRCLK is a simple fraction of BCLK */ - dev_dbg(codec->dev, "LRCLK_RATE is %d\n", wm8993->bclk / wm8993->fs); + dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8993->bclk / wm8993->fs); aif4 |= wm8993->bclk / wm8993->fs; - snd_soc_write(codec, WM8993_CLOCKING_1, clocking1); - snd_soc_write(codec, WM8993_CLOCKING_3, clocking3); - snd_soc_write(codec, WM8993_AUDIO_INTERFACE_1, aif1); - snd_soc_write(codec, WM8993_AUDIO_INTERFACE_4, aif4); + snd_soc_component_write(component, WM8993_CLOCKING_1, clocking1); + snd_soc_component_write(component, WM8993_CLOCKING_3, clocking3); + snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_1, aif1); + snd_soc_component_write(component, WM8993_AUDIO_INTERFACE_4, aif4); /* ReTune Mobile? */ if (wm8993->pdata.num_retune_configs) { - u16 eq1 = snd_soc_read(codec, WM8993_EQ1); + u16 eq1 = snd_soc_component_read32(component, WM8993_EQ1); struct wm8993_retune_mobile_setting *s; best = 0; @@ -1318,16 +1318,16 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, } s = &wm8993->pdata.retune_configs[best]; - dev_dbg(codec->dev, "ReTune Mobile %s tuned for %dHz\n", + dev_dbg(component->dev, "ReTune Mobile %s tuned for %dHz\n", s->name, s->rate); /* Disable EQ while we reconfigure */ - snd_soc_update_bits(codec, WM8993_EQ1, WM8993_EQ_ENA, 0); + snd_soc_component_update_bits(component, WM8993_EQ1, WM8993_EQ_ENA, 0); for (i = 1; i < ARRAY_SIZE(s->config); i++) - snd_soc_write(codec, WM8993_EQ1 + i, s->config[i]); + snd_soc_component_write(component, WM8993_EQ1 + i, s->config[i]); - snd_soc_update_bits(codec, WM8993_EQ1, WM8993_EQ_ENA, eq1); + snd_soc_component_update_bits(component, WM8993_EQ1, WM8993_EQ_ENA, eq1); } return 0; @@ -1335,17 +1335,17 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, static int wm8993_digital_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; unsigned int reg; - reg = snd_soc_read(codec, WM8993_DAC_CTRL); + reg = snd_soc_component_read32(component, WM8993_DAC_CTRL); if (mute) reg |= WM8993_DAC_MUTE; else reg &= ~WM8993_DAC_MUTE; - snd_soc_write(codec, WM8993_DAC_CTRL, reg); + snd_soc_component_write(component, WM8993_DAC_CTRL, reg); return 0; } @@ -1353,8 +1353,8 @@ static int wm8993_digital_mute(struct snd_soc_dai *codec_dai, int mute) static int wm8993_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); int aif1 = 0; int aif2 = 0; @@ -1396,9 +1396,9 @@ out: wm8993->tdm_width = slot_width; wm8993->tdm_slots = slots / 2; - snd_soc_update_bits(codec, WM8993_AUDIO_INTERFACE_1, + snd_soc_component_update_bits(component, WM8993_AUDIO_INTERFACE_1, WM8993_AIFADC_TDM | WM8993_AIFADC_TDM_CHAN, aif1); - snd_soc_update_bits(codec, WM8993_AUDIO_INTERFACE_2, + snd_soc_component_update_bits(component, WM8993_AUDIO_INTERFACE_2, WM8993_AIFDAC_TDM | WM8993_AIFDAC_TDM_CHAN, aif2); return 0; @@ -1481,10 +1481,10 @@ static struct snd_soc_dai_driver wm8993_dai = { .symmetric_rates = 1, }; -static int wm8993_probe(struct snd_soc_codec *codec) +static int wm8993_probe(struct snd_soc_component *component) { - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); wm8993->hubs_data.hp_startup_mode = 1; wm8993->hubs_data.dcs_codes_l = -2; @@ -1492,20 +1492,20 @@ static int wm8993_probe(struct snd_soc_codec *codec) wm8993->hubs_data.series_startup = 1; /* Latch volume update bits and default ZC on */ - snd_soc_update_bits(codec, WM8993_RIGHT_DAC_DIGITAL_VOLUME, + snd_soc_component_update_bits(component, WM8993_RIGHT_DAC_DIGITAL_VOLUME, WM8993_DAC_VU, WM8993_DAC_VU); - snd_soc_update_bits(codec, WM8993_RIGHT_ADC_DIGITAL_VOLUME, + snd_soc_component_update_bits(component, WM8993_RIGHT_ADC_DIGITAL_VOLUME, WM8993_ADC_VU, WM8993_ADC_VU); /* Manualy manage the HPOUT sequencing for independent stereo * control. */ - snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0, WM8993_HPOUT1_AUTO_PU, 0); /* Use automatic clock configuration */ - snd_soc_update_bits(codec, WM8993_CLOCKING_4, WM8993_SR_MODE, 0); + snd_soc_component_update_bits(component, WM8993_CLOCKING_4, WM8993_SR_MODE, 0); - wm_hubs_handle_analogue_pdata(codec, wm8993->pdata.lineout1_diff, + wm_hubs_handle_analogue_pdata(component, wm8993->pdata.lineout1_diff, wm8993->pdata.lineout2_diff, wm8993->pdata.lineout1fb, wm8993->pdata.lineout2fb, @@ -1516,22 +1516,22 @@ static int wm8993_probe(struct snd_soc_codec *codec) wm8993->pdata.micbias1_lvl, wm8993->pdata.micbias2_lvl); - snd_soc_add_codec_controls(codec, wm8993_snd_controls, + snd_soc_add_component_controls(component, wm8993_snd_controls, ARRAY_SIZE(wm8993_snd_controls)); if (wm8993->pdata.num_retune_configs != 0) { - dev_dbg(codec->dev, "Using ReTune Mobile\n"); + dev_dbg(component->dev, "Using ReTune Mobile\n"); } else { - dev_dbg(codec->dev, "No ReTune Mobile, using normal EQ\n"); - snd_soc_add_codec_controls(codec, wm8993_eq_controls, + dev_dbg(component->dev, "No ReTune Mobile, using normal EQ\n"); + snd_soc_add_component_controls(component, wm8993_eq_controls, ARRAY_SIZE(wm8993_eq_controls)); } snd_soc_dapm_new_controls(dapm, wm8993_dapm_widgets, ARRAY_SIZE(wm8993_dapm_widgets)); - wm_hubs_add_analogue_controls(codec); + wm_hubs_add_analogue_controls(component); snd_soc_dapm_add_routes(dapm, routes, ARRAY_SIZE(routes)); - wm_hubs_add_analogue_routes(codec, wm8993->pdata.lineout1_diff, + wm_hubs_add_analogue_routes(component, wm8993->pdata.lineout1_diff, wm8993->pdata.lineout2_diff); /* If the line outputs are differential then we aren't presenting @@ -1545,34 +1545,34 @@ static int wm8993_probe(struct snd_soc_codec *codec) } #ifdef CONFIG_PM -static int wm8993_suspend(struct snd_soc_codec *codec) +static int wm8993_suspend(struct snd_soc_component *component) { - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); int fll_fout = wm8993->fll_fout; int fll_fref = wm8993->fll_fref; int ret; /* Stop the FLL in an orderly fashion */ - ret = _wm8993_set_fll(codec, 0, 0, 0, 0); + ret = _wm8993_set_fll(component, 0, 0, 0, 0); if (ret != 0) { - dev_err(codec->dev, "Failed to stop FLL\n"); + dev_err(component->dev, "Failed to stop FLL\n"); return ret; } wm8993->fll_fout = fll_fout; wm8993->fll_fref = fll_fref; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); return 0; } -static int wm8993_resume(struct snd_soc_codec *codec) +static int wm8993_resume(struct snd_soc_component *component) { - struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec); + struct wm8993_priv *wm8993 = snd_soc_component_get_drvdata(component); int ret; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* Restart the FLL? */ if (wm8993->fll_fout) { @@ -1582,10 +1582,10 @@ static int wm8993_resume(struct snd_soc_codec *codec) wm8993->fll_fref = 0; wm8993->fll_fout = 0; - ret = _wm8993_set_fll(codec, 0, wm8993->fll_src, + ret = _wm8993_set_fll(component, 0, wm8993->fll_src, fll_fref, fll_fout); if (ret != 0) - dev_err(codec->dev, "Failed to restart FLL\n"); + dev_err(component->dev, "Failed to restart FLL\n"); } return 0; @@ -1615,11 +1615,15 @@ static const struct regmap_config wm8993_regmap = { .num_reg_defaults = ARRAY_SIZE(wm8993_reg_defaults), }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8993 = { - .probe = wm8993_probe, - .suspend = wm8993_suspend, - .resume = wm8993_resume, - .set_bias_level = wm8993_set_bias_level, +static const struct snd_soc_component_driver soc_component_dev_wm8993 = { + .probe = wm8993_probe, + .suspend = wm8993_suspend, + .resume = wm8993_resume, + .set_bias_level = wm8993_set_bias_level, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8993_i2c_probe(struct i2c_client *i2c, @@ -1705,8 +1709,8 @@ static int wm8993_i2c_probe(struct i2c_client *i2c, regcache_cache_only(wm8993->regmap, true); - ret = snd_soc_register_codec(&i2c->dev, - &soc_codec_dev_wm8993, &wm8993_dai, 1); + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_component_dev_wm8993, &wm8993_dai, 1); if (ret != 0) { dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret); goto err_irq; @@ -1726,7 +1730,6 @@ static int wm8993_i2c_remove(struct i2c_client *i2c) { struct wm8993_priv *wm8993 = i2c_get_clientdata(i2c); - snd_soc_unregister_codec(&i2c->dev); if (i2c->irq) free_irq(i2c->irq, wm8993); regulator_bulk_disable(ARRAY_SIZE(wm8993->supplies), wm8993->supplies); diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 21ffd6403173..6e9e32a07259 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -106,9 +106,9 @@ static const struct wm8958_micd_rate jackdet_rates[] = { { 44100 * 256, false, 7, 8 }, }; -static void wm8958_micd_set_rate(struct snd_soc_codec *codec) +static void wm8958_micd_set_rate(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int best, i, sysclk, val; bool idle; @@ -117,7 +117,7 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec) idle = !wm8994->jack_mic; - sysclk = snd_soc_read(codec, WM8994_CLOCKING_1); + sysclk = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (sysclk & WM8994_SYSCLK_SRC) sysclk = wm8994->aifclk[1]; else @@ -148,18 +148,18 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec) val = rates[best].start << WM8958_MICD_BIAS_STARTTIME_SHIFT | rates[best].rate << WM8958_MICD_RATE_SHIFT; - dev_dbg(codec->dev, "MICD rate %d,%d for %dHz %s\n", + dev_dbg(component->dev, "MICD rate %d,%d for %dHz %s\n", rates[best].start, rates[best].rate, sysclk, idle ? "idle" : "active"); - snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_BIAS_STARTTIME_MASK | WM8958_MICD_RATE_MASK, val); } -static int configure_aif_clock(struct snd_soc_codec *codec, int aif) +static int configure_aif_clock(struct snd_soc_component *component, int aif) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int rate; int reg1 = 0; int offset; @@ -197,28 +197,28 @@ static int configure_aif_clock(struct snd_soc_codec *codec, int aif) rate /= 2; reg1 |= WM8994_AIF1CLK_DIV; - dev_dbg(codec->dev, "Dividing AIF%d clock to %dHz\n", + dev_dbg(component->dev, "Dividing AIF%d clock to %dHz\n", aif + 1, rate); } wm8994->aifclk[aif] = rate; - snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1 + offset, + snd_soc_component_update_bits(component, WM8994_AIF1_CLOCKING_1 + offset, WM8994_AIF1CLK_SRC_MASK | WM8994_AIF1CLK_DIV, reg1); return 0; } -static int configure_clock(struct snd_soc_codec *codec) +static int configure_clock(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int change, new; /* Bring up the AIF clocks first */ - configure_aif_clock(codec, 0); - configure_aif_clock(codec, 1); + configure_aif_clock(component, 0); + configure_aif_clock(component, 1); /* Then switch CLK_SYS over to the higher of them; a change * can only happen as a result of a clocking change which can @@ -228,7 +228,7 @@ static int configure_clock(struct snd_soc_codec *codec) /* If they're equal it doesn't matter which is used */ if (wm8994->aifclk[0] == wm8994->aifclk[1]) { - wm8958_micd_set_rate(codec); + wm8958_micd_set_rate(component); return 0; } @@ -237,12 +237,12 @@ static int configure_clock(struct snd_soc_codec *codec) else new = 0; - change = snd_soc_update_bits(codec, WM8994_CLOCKING_1, + change = snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8994_SYSCLK_SRC, new); if (change) snd_soc_dapm_sync(dapm); - wm8958_micd_set_rate(codec); + wm8958_micd_set_rate(component); return 0; } @@ -250,8 +250,8 @@ static int configure_clock(struct snd_soc_codec *codec) static int check_clk_sys(struct snd_soc_dapm_widget *source, struct snd_soc_dapm_widget *sink) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(source->dapm); - int reg = snd_soc_read(codec, WM8994_CLOCKING_1); + struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); + int reg = snd_soc_component_read32(component, WM8994_CLOCKING_1); const char *clk; /* Check what we're currently using for CLK_SYS */ @@ -300,7 +300,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, { struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); int mask, ret; /* Can't enable both ADC and DAC paths simultaneously */ @@ -310,7 +310,7 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, else mask = WM8994_AIF1DAC1_DRC_ENA_MASK; - ret = snd_soc_read(codec, mc->reg); + ret = snd_soc_component_read32(component, mc->reg); if (ret < 0) return ret; if (ret & mask) @@ -319,9 +319,9 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol, return snd_soc_put_volsw(kcontrol, ucontrol); } -static void wm8994_set_drc(struct snd_soc_codec *codec, int drc) +static void wm8994_set_drc(struct snd_soc_component *component, int drc) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int base = wm8994_drc_base[drc]; @@ -329,15 +329,15 @@ static void wm8994_set_drc(struct snd_soc_codec *codec, int drc) int save, i; /* Save any enables; the configuration should clear them. */ - save = snd_soc_read(codec, base); + save = snd_soc_component_read32(component, base); save &= WM8994_AIF1DAC1_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA | WM8994_AIF1ADC1R_DRC_ENA; for (i = 0; i < WM8994_DRC_REGS; i++) - snd_soc_update_bits(codec, base + i, 0xffff, + snd_soc_component_update_bits(component, base + i, 0xffff, pdata->drc_cfgs[cfg].regs[i]); - snd_soc_update_bits(codec, base, WM8994_AIF1DAC1_DRC_ENA | + snd_soc_component_update_bits(component, base, WM8994_AIF1DAC1_DRC_ENA | WM8994_AIF1ADC1L_DRC_ENA | WM8994_AIF1ADC1R_DRC_ENA, save); } @@ -357,8 +357,8 @@ static int wm8994_get_drc(const char *name) static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int drc = wm8994_get_drc(kcontrol->id.name); @@ -372,7 +372,7 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, wm8994->drc_cfg[drc] = value; - wm8994_set_drc(codec, drc); + wm8994_set_drc(component, drc); return 0; } @@ -380,8 +380,8 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int drc = wm8994_get_drc(kcontrol->id.name); if (drc < 0) @@ -391,9 +391,9 @@ static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol, return 0; } -static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) +static void wm8994_set_retune_mobile(struct snd_soc_component *component, int block) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int base = wm8994_retune_mobile_base[block]; @@ -430,7 +430,7 @@ static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) } } - dev_dbg(codec->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", + dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", block, pdata->retune_mobile_cfgs[best].name, pdata->retune_mobile_cfgs[best].rate, @@ -439,14 +439,14 @@ static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) /* The EQ will be disabled while reconfiguring it, remember the * current configuration. */ - save = snd_soc_read(codec, base); + save = snd_soc_component_read32(component, base); save &= WM8994_AIF1DAC1_EQ_ENA; for (i = 0; i < WM8994_EQ_REGS; i++) - snd_soc_update_bits(codec, base + i, 0xffff, + snd_soc_component_update_bits(component, base + i, 0xffff, pdata->retune_mobile_cfgs[best].regs[i]); - snd_soc_update_bits(codec, base, WM8994_AIF1DAC1_EQ_ENA, save); + snd_soc_component_update_bits(component, base, WM8994_AIF1DAC1_EQ_ENA, save); } /* Icky as hell but saves code duplication */ @@ -464,8 +464,8 @@ static int wm8994_get_retune_mobile_block(const char *name) static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int block = wm8994_get_retune_mobile_block(kcontrol->id.name); @@ -479,7 +479,7 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, wm8994->retune_mobile_cfg[block] = value; - wm8994_set_retune_mobile(codec, block); + wm8994_set_retune_mobile(component, block); return 0; } @@ -487,8 +487,8 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol, static int wm8994_get_retune_mobile_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int block = wm8994_get_retune_mobile_block(kcontrol->id.name); if (block < 0) @@ -740,9 +740,9 @@ SOC_SINGLE_TLV("MIXINL IN1RP Boost Volume", WM8994_INPUT_MIXER_1, 8, 1, 0, }; /* We run all mode setting through a function to enforce audio mode */ -static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) +static void wm1811_jackdet_set_mode(struct snd_soc_component *component, u16 mode) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (!wm8994->jackdet || !wm8994->micdet[0].jack) return; @@ -759,37 +759,37 @@ static void wm1811_jackdet_set_mode(struct snd_soc_codec *codec, u16 mode) if (mode != WM1811_JACKDET_MODE_NONE) mode = WM1811_JACKDET_MODE_AUDIO; - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM1811_JACKDET_MODE_MASK, mode); } -static void active_reference(struct snd_soc_codec *codec) +static void active_reference(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); mutex_lock(&wm8994->accdet_lock); wm8994->active_refcount++; - dev_dbg(codec->dev, "Active refcount incremented, now %d\n", + dev_dbg(component->dev, "Active refcount incremented, now %d\n", wm8994->active_refcount); /* If we're using jack detection go into audio mode */ - wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_AUDIO); + wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_AUDIO); mutex_unlock(&wm8994->accdet_lock); } -static void active_dereference(struct snd_soc_codec *codec) +static void active_dereference(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); u16 mode; mutex_lock(&wm8994->accdet_lock); wm8994->active_refcount--; - dev_dbg(codec->dev, "Active refcount decremented, now %d\n", + dev_dbg(component->dev, "Active refcount decremented, now %d\n", wm8994->active_refcount); if (wm8994->active_refcount == 0) { @@ -799,7 +799,7 @@ static void active_dereference(struct snd_soc_codec *codec) else mode = WM1811_JACKDET_MODE_JACK; - wm1811_jackdet_set_mode(codec, mode); + wm1811_jackdet_set_mode(component, mode); } mutex_unlock(&wm8994->accdet_lock); @@ -808,12 +808,12 @@ static void active_dereference(struct snd_soc_codec *codec) static int clk_sys_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: - return configure_clock(codec); + return configure_clock(component); case SND_SOC_DAPM_POST_PMU: /* @@ -832,30 +832,30 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: - configure_clock(codec); + configure_clock(component); break; } return 0; } -static void vmid_reference(struct snd_soc_codec *codec) +static void vmid_reference(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); wm8994->vmid_refcount++; - dev_dbg(codec->dev, "Referencing VMID, refcount is now %d\n", + dev_dbg(component->dev, "Referencing VMID, refcount is now %d\n", wm8994->vmid_refcount); if (wm8994->vmid_refcount == 1) { - snd_soc_update_bits(codec, WM8994_ANTIPOP_1, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_1, WM8994_LINEOUT1_DISCH | WM8994_LINEOUT2_DISCH, 0); - wm_hubs_vmid_ena(codec); + wm_hubs_vmid_ena(component); switch (wm8994->vmid_mode) { default: @@ -863,7 +863,7 @@ static void vmid_reference(struct snd_soc_codec *codec) /* fall through */ case WM8994_VMID_NORMAL: /* Startup bias, VMID ramp & buffer */ - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM8994_BIAS_SRC | WM8994_VMID_DISCH | WM8994_STARTUP_BIAS_ENA | @@ -875,14 +875,14 @@ static void vmid_reference(struct snd_soc_codec *codec) (0x2 << WM8994_VMID_RAMP_SHIFT)); /* Main bias enable, VMID=2x40k */ - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1, WM8994_BIAS_ENA | WM8994_VMID_SEL_MASK, WM8994_BIAS_ENA | 0x2); msleep(300); - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM8994_VMID_RAMP_MASK | WM8994_BIAS_SRC, 0); @@ -890,7 +890,7 @@ static void vmid_reference(struct snd_soc_codec *codec) case WM8994_VMID_FORCE: /* Startup bias, slow VMID ramp & buffer */ - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM8994_BIAS_SRC | WM8994_VMID_DISCH | WM8994_STARTUP_BIAS_ENA | @@ -902,14 +902,14 @@ static void vmid_reference(struct snd_soc_codec *codec) (0x2 << WM8994_VMID_RAMP_SHIFT)); /* Main bias enable, VMID=2x40k */ - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1, WM8994_BIAS_ENA | WM8994_VMID_SEL_MASK, WM8994_BIAS_ENA | 0x2); msleep(400); - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM8994_VMID_RAMP_MASK | WM8994_BIAS_SRC, 0); @@ -918,120 +918,120 @@ static void vmid_reference(struct snd_soc_codec *codec) } } -static void vmid_dereference(struct snd_soc_codec *codec) +static void vmid_dereference(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); wm8994->vmid_refcount--; - dev_dbg(codec->dev, "Dereferencing VMID, refcount is now %d\n", + dev_dbg(component->dev, "Dereferencing VMID, refcount is now %d\n", wm8994->vmid_refcount); if (wm8994->vmid_refcount == 0) { if (wm8994->hubs.lineout1_se) - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_3, WM8994_LINEOUT1N_ENA | WM8994_LINEOUT1P_ENA, WM8994_LINEOUT1N_ENA | WM8994_LINEOUT1P_ENA); if (wm8994->hubs.lineout2_se) - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_3, WM8994_LINEOUT2N_ENA | WM8994_LINEOUT2P_ENA, WM8994_LINEOUT2N_ENA | WM8994_LINEOUT2P_ENA); /* Start discharging VMID */ - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM8994_BIAS_SRC | WM8994_VMID_DISCH, WM8994_BIAS_SRC | WM8994_VMID_DISCH); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1, WM8994_VMID_SEL_MASK, 0); msleep(400); /* Active discharge */ - snd_soc_update_bits(codec, WM8994_ANTIPOP_1, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_1, WM8994_LINEOUT1_DISCH | WM8994_LINEOUT2_DISCH, WM8994_LINEOUT1_DISCH | WM8994_LINEOUT2_DISCH); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_3, WM8994_LINEOUT1N_ENA | WM8994_LINEOUT1P_ENA | WM8994_LINEOUT2N_ENA | WM8994_LINEOUT2P_ENA, 0); /* Switch off startup biases */ - snd_soc_update_bits(codec, WM8994_ANTIPOP_2, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_2, WM8994_BIAS_SRC | WM8994_STARTUP_BIAS_ENA | WM8994_VMID_BUF_ENA | WM8994_VMID_RAMP_MASK, 0); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_1, WM8994_VMID_SEL_MASK, 0); } - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); } static int vmid_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); switch (event) { case SND_SOC_DAPM_PRE_PMU: - vmid_reference(codec); + vmid_reference(component); break; case SND_SOC_DAPM_POST_PMD: - vmid_dereference(codec); + vmid_dereference(component); break; } return 0; } -static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec) +static bool wm8994_check_class_w_digital(struct snd_soc_component *component) { int source = 0; /* GCC flow analysis can't track enable */ int reg, reg_r; /* We also need the same AIF source for L/R and only one path */ - reg = snd_soc_read(codec, WM8994_DAC1_LEFT_MIXER_ROUTING); + reg = snd_soc_component_read32(component, WM8994_DAC1_LEFT_MIXER_ROUTING); switch (reg) { case WM8994_AIF2DACL_TO_DAC1L: - dev_vdbg(codec->dev, "Class W source AIF2DAC\n"); + dev_vdbg(component->dev, "Class W source AIF2DAC\n"); source = 2 << WM8994_CP_DYN_SRC_SEL_SHIFT; break; case WM8994_AIF1DAC2L_TO_DAC1L: - dev_vdbg(codec->dev, "Class W source AIF1DAC2\n"); + dev_vdbg(component->dev, "Class W source AIF1DAC2\n"); source = 1 << WM8994_CP_DYN_SRC_SEL_SHIFT; break; case WM8994_AIF1DAC1L_TO_DAC1L: - dev_vdbg(codec->dev, "Class W source AIF1DAC1\n"); + dev_vdbg(component->dev, "Class W source AIF1DAC1\n"); source = 0 << WM8994_CP_DYN_SRC_SEL_SHIFT; break; default: - dev_vdbg(codec->dev, "DAC mixer setting: %x\n", reg); + dev_vdbg(component->dev, "DAC mixer setting: %x\n", reg); return false; } - reg_r = snd_soc_read(codec, WM8994_DAC1_RIGHT_MIXER_ROUTING); + reg_r = snd_soc_component_read32(component, WM8994_DAC1_RIGHT_MIXER_ROUTING); if (reg_r != reg) { - dev_vdbg(codec->dev, "Left and right DAC mixers different\n"); + dev_vdbg(component->dev, "Left and right DAC mixers different\n"); return false; } /* Set the source up */ - snd_soc_update_bits(codec, WM8994_CLASS_W_1, + snd_soc_component_update_bits(component, WM8994_CLASS_W_1, WM8994_CP_DYN_SRC_SEL_MASK, source); return true; @@ -1040,8 +1040,8 @@ static bool wm8994_check_class_w_digital(struct snd_soc_codec *codec) static int aif1clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int mask = WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC1R_ENA; int i; @@ -1064,7 +1064,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, if (wm8994->channels[0] <= 2) mask &= ~(WM8994_AIF1DAC2L_ENA | WM8994_AIF1DAC2R_ENA); - val = snd_soc_read(codec, WM8994_AIF1_CONTROL_1); + val = snd_soc_component_read32(component, WM8994_AIF1_CONTROL_1); if ((val & WM8994_AIF1ADCL_SRC) && (val & WM8994_AIF1ADCR_SRC)) adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA; @@ -1075,7 +1075,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, adc = WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC2R_ENA | WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2L_ENA; - val = snd_soc_read(codec, WM8994_AIF1_CONTROL_2); + val = snd_soc_component_read32(component, WM8994_AIF1_CONTROL_2); if ((val & WM8994_AIF1DACL_SRC) && (val & WM8994_AIF1DACR_SRC)) dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA; @@ -1086,21 +1086,21 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, dac = WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC2R_ENA | WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2L_ENA; - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, mask, adc); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, mask, dac); - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8994_AIF1DSPCLK_ENA | WM8994_SYSDSPCLK_ENA, WM8994_AIF1DSPCLK_ENA | WM8994_SYSDSPCLK_ENA); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, mask, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, mask, WM8994_AIF1ADC1R_ENA | WM8994_AIF1ADC1L_ENA | WM8994_AIF1ADC2R_ENA | WM8994_AIF1ADC2L_ENA); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, mask, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, mask, WM8994_AIF1DAC1R_ENA | WM8994_AIF1DAC1L_ENA | WM8994_AIF1DAC2R_ENA | @@ -1109,24 +1109,24 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++) - snd_soc_write(codec, wm8994_vu_bits[i].reg, - snd_soc_read(codec, + snd_soc_component_write(component, wm8994_vu_bits[i].reg, + snd_soc_component_read32(component, wm8994_vu_bits[i].reg)); break; case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, mask, 0); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, mask, 0); - val = snd_soc_read(codec, WM8994_CLOCKING_1); + val = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (val & WM8994_AIF2DSPCLK_ENA) val = WM8994_SYSDSPCLK_ENA; else val = 0; - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8994_SYSDSPCLK_ENA | WM8994_AIF1DSPCLK_ENA, val); break; @@ -1138,7 +1138,7 @@ static int aif1clk_ev(struct snd_soc_dapm_widget *w, static int aif2clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); int i; int dac; int adc; @@ -1146,7 +1146,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_PRE_PMU: - val = snd_soc_read(codec, WM8994_AIF2_CONTROL_1); + val = snd_soc_component_read32(component, WM8994_AIF2_CONTROL_1); if ((val & WM8994_AIF2ADCL_SRC) && (val & WM8994_AIF2ADCR_SRC)) adc = WM8994_AIF2ADCR_ENA; @@ -1157,7 +1157,7 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, adc = WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA; - val = snd_soc_read(codec, WM8994_AIF2_CONTROL_2); + val = snd_soc_component_read32(component, WM8994_AIF2_CONTROL_2); if ((val & WM8994_AIF2DACL_SRC) && (val & WM8994_AIF2DACR_SRC)) dac = WM8994_AIF2DACR_ENA; @@ -1167,23 +1167,23 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, else dac = WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA; - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA, adc); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA, dac); - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8994_AIF2DSPCLK_ENA | WM8994_SYSDSPCLK_ENA, WM8994_AIF2DSPCLK_ENA | WM8994_SYSDSPCLK_ENA); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA, WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA, WM8994_AIF2DACL_ENA | @@ -1192,26 +1192,26 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_POST_PMU: for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++) - snd_soc_write(codec, wm8994_vu_bits[i].reg, - snd_soc_read(codec, + snd_soc_component_write(component, wm8994_vu_bits[i].reg, + snd_soc_component_read32(component, wm8994_vu_bits[i].reg)); break; case SND_SOC_DAPM_PRE_PMD: case SND_SOC_DAPM_POST_PMD: - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, WM8994_AIF2DACL_ENA | WM8994_AIF2DACR_ENA, 0); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_4, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_4, WM8994_AIF2ADCL_ENA | WM8994_AIF2ADCR_ENA, 0); - val = snd_soc_read(codec, WM8994_CLOCKING_1); + val = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (val & WM8994_AIF1DSPCLK_ENA) val = WM8994_SYSDSPCLK_ENA; else val = 0; - snd_soc_update_bits(codec, WM8994_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_CLOCKING_1, WM8994_SYSDSPCLK_ENA | WM8994_AIF2DSPCLK_ENA, val); break; @@ -1223,8 +1223,8 @@ static int aif2clk_ev(struct snd_soc_dapm_widget *w, static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1241,8 +1241,8 @@ static int aif1clk_late_ev(struct snd_soc_dapm_widget *w, static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -1259,14 +1259,14 @@ static int aif2clk_late_ev(struct snd_soc_dapm_widget *w, static int late_enable_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: if (wm8994->aif1clk_enable) { aif1clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMU); - snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_AIF1_CLOCKING_1, WM8994_AIF1CLK_ENA_MASK, WM8994_AIF1CLK_ENA); aif1clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMU); @@ -1274,7 +1274,7 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w, } if (wm8994->aif2clk_enable) { aif2clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMU); - snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_AIF2_CLOCKING_1, WM8994_AIF2CLK_ENA_MASK, WM8994_AIF2CLK_ENA); aif2clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMU); @@ -1292,21 +1292,21 @@ static int late_enable_ev(struct snd_soc_dapm_widget *w, static int late_disable_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMD: if (wm8994->aif1clk_disable) { aif1clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMD); - snd_soc_update_bits(codec, WM8994_AIF1_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_AIF1_CLOCKING_1, WM8994_AIF1CLK_ENA_MASK, 0); aif1clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMD); wm8994->aif1clk_disable = 0; } if (wm8994->aif2clk_disable) { aif2clk_ev(w, kcontrol, SND_SOC_DAPM_PRE_PMD); - snd_soc_update_bits(codec, WM8994_AIF2_CLOCKING_1, + snd_soc_component_update_bits(component, WM8994_AIF2_CLOCKING_1, WM8994_AIF2CLK_ENA_MASK, 0); aif2clk_ev(w, kcontrol, SND_SOC_DAPM_POST_PMD); wm8994->aif2clk_disable = 0; @@ -1334,10 +1334,10 @@ static int micbias_ev(struct snd_soc_dapm_widget *w, static int dac_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int mask = 1 << w->shift; - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_5, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_5, mask, mask); return 0; } @@ -1375,9 +1375,9 @@ SOC_DAPM_SINGLE("DAC1 Switch", WM8994_SPEAKER_MIXER, 0, 1, 0), static int post_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - dev_dbg(codec->dev, "SRC status: %x\n", - snd_soc_read(codec, + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + dev_dbg(component->dev, "SRC status: %x\n", + snd_soc_component_read32(component, WM8994_RATE_STATUS)); return 0; } @@ -1443,12 +1443,12 @@ SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING, static int wm8994_put_class_w(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); int ret; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); - wm_hubs_update_class_w(codec); + wm_hubs_update_class_w(component); return ret; } @@ -2130,10 +2130,10 @@ static int wm8994_get_fll_config(struct wm8994 *control, struct fll_div *fll, return 0; } -static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, +static int _wm8994_set_fll(struct snd_soc_component *component, int id, int src, unsigned int freq_in, unsigned int freq_out) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int reg_offset, ret; struct fll_div fll; @@ -2156,7 +2156,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, return -EINVAL; } - reg = snd_soc_read(codec, WM8994_FLL1_CONTROL_1 + reg_offset); + reg = snd_soc_component_read32(component, WM8994_FLL1_CONTROL_1 + reg_offset); was_enabled = reg & WM8994_FLL1_ENA; switch (src) { @@ -2197,57 +2197,57 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, return ret; /* Make sure that we're not providing SYSCLK right now */ - clk1 = snd_soc_read(codec, WM8994_CLOCKING_1); + clk1 = snd_soc_component_read32(component, WM8994_CLOCKING_1); if (clk1 & WM8994_SYSCLK_SRC) aif_reg = WM8994_AIF2_CLOCKING_1; else aif_reg = WM8994_AIF1_CLOCKING_1; - reg = snd_soc_read(codec, aif_reg); + reg = snd_soc_component_read32(component, aif_reg); if ((reg & WM8994_AIF1CLK_ENA) && (reg & WM8994_AIF1CLK_SRC_MASK) == aif_src) { - dev_err(codec->dev, "FLL%d is currently providing SYSCLK\n", + dev_err(component->dev, "FLL%d is currently providing SYSCLK\n", id + 1); return -EBUSY; } /* We always need to disable the FLL while reconfiguring */ - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset, + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_1 + reg_offset, WM8994_FLL1_ENA, 0); if (wm8994->fll_byp && src == WM8994_FLL_SRC_BCLK && freq_in == freq_out && freq_out) { - dev_dbg(codec->dev, "Bypassing FLL%d\n", id + 1); - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset, + dev_dbg(component->dev, "Bypassing FLL%d\n", id + 1); + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_5 + reg_offset, WM8958_FLL1_BYP, WM8958_FLL1_BYP); goto out; } reg = (fll.outdiv << WM8994_FLL1_OUTDIV_SHIFT) | (fll.fll_fratio << WM8994_FLL1_FRATIO_SHIFT); - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_2 + reg_offset, + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_2 + reg_offset, WM8994_FLL1_OUTDIV_MASK | WM8994_FLL1_FRATIO_MASK, reg); - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_3 + reg_offset, + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_3 + reg_offset, WM8994_FLL1_K_MASK, fll.k); - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_4 + reg_offset, + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_4 + reg_offset, WM8994_FLL1_N_MASK, fll.n << WM8994_FLL1_N_SHIFT); if (fll.lambda) { - snd_soc_update_bits(codec, WM8958_FLL1_EFS_1 + reg_offset, + snd_soc_component_update_bits(component, WM8958_FLL1_EFS_1 + reg_offset, WM8958_FLL1_LAMBDA_MASK, fll.lambda); - snd_soc_update_bits(codec, WM8958_FLL1_EFS_2 + reg_offset, + snd_soc_component_update_bits(component, WM8958_FLL1_EFS_2 + reg_offset, WM8958_FLL1_EFS_ENA, WM8958_FLL1_EFS_ENA); } else { - snd_soc_update_bits(codec, WM8958_FLL1_EFS_2 + reg_offset, + snd_soc_component_update_bits(component, WM8958_FLL1_EFS_2 + reg_offset, WM8958_FLL1_EFS_ENA, 0); } - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_5 + reg_offset, + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_5 + reg_offset, WM8994_FLL1_FRC_NCO | WM8958_FLL1_BYP | WM8994_FLL1_REFCLK_DIV_MASK | WM8994_FLL1_REFCLK_SRC_MASK, @@ -2263,15 +2263,15 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, if (freq_out) { /* Enable VMID if we need it */ if (!was_enabled) { - active_reference(codec); + active_reference(component); switch (control->type) { case WM8994: - vmid_reference(codec); + vmid_reference(component); break; case WM8958: if (control->revision < 1) - vmid_reference(codec); + vmid_reference(component); break; default: break; @@ -2285,7 +2285,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, if (src == WM8994_FLL_SRC_INTERNAL) reg |= WM8994_FLL1_OSC_ENA; - snd_soc_update_bits(codec, WM8994_FLL1_CONTROL_1 + reg_offset, + snd_soc_component_update_bits(component, WM8994_FLL1_CONTROL_1 + reg_offset, WM8994_FLL1_ENA | WM8994_FLL1_OSC_ENA | WM8994_FLL1_FRAC, reg); @@ -2293,7 +2293,7 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, timeout = wait_for_completion_timeout(&wm8994->fll_locked[id], msecs_to_jiffies(10)); if (timeout == 0) - dev_warn(codec->dev, + dev_warn(component->dev, "Timed out waiting for FLL lock\n"); } else { msleep(5); @@ -2302,17 +2302,17 @@ static int _wm8994_set_fll(struct snd_soc_codec *codec, int id, int src, if (was_enabled) { switch (control->type) { case WM8994: - vmid_dereference(codec); + vmid_dereference(component); break; case WM8958: if (control->revision < 1) - vmid_dereference(codec); + vmid_dereference(component); break; default: break; } - active_dereference(codec); + active_dereference(component); } } @@ -2321,29 +2321,29 @@ out: wm8994->fll[id].out = freq_out; wm8994->fll[id].src = src; - configure_clock(codec); + configure_clock(component); /* * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers * for detection. */ if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { - dev_dbg(codec->dev, "Configuring AIFs for 128fs\n"); + dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); - wm8994->aifdiv[0] = snd_soc_read(codec, WM8994_AIF1_RATE) + wm8994->aifdiv[0] = snd_soc_component_read32(component, WM8994_AIF1_RATE) & WM8994_AIF1CLK_RATE_MASK; - wm8994->aifdiv[1] = snd_soc_read(codec, WM8994_AIF2_RATE) + wm8994->aifdiv[1] = snd_soc_component_read32(component, WM8994_AIF2_RATE) & WM8994_AIF1CLK_RATE_MASK; - snd_soc_update_bits(codec, WM8994_AIF1_RATE, + snd_soc_component_update_bits(component, WM8994_AIF1_RATE, WM8994_AIF1CLK_RATE_MASK, 0x1); - snd_soc_update_bits(codec, WM8994_AIF2_RATE, + snd_soc_component_update_bits(component, WM8994_AIF2_RATE, WM8994_AIF2CLK_RATE_MASK, 0x1); } else if (wm8994->aifdiv[0]) { - snd_soc_update_bits(codec, WM8994_AIF1_RATE, + snd_soc_component_update_bits(component, WM8994_AIF1_RATE, WM8994_AIF1CLK_RATE_MASK, wm8994->aifdiv[0]); - snd_soc_update_bits(codec, WM8994_AIF2_RATE, + snd_soc_component_update_bits(component, WM8994_AIF2_RATE, WM8994_AIF2CLK_RATE_MASK, wm8994->aifdiv[1]); @@ -2368,14 +2368,14 @@ static int opclk_divs[] = { 10, 20, 30, 40, 55, 60, 80, 120, 160 }; static int wm8994_set_fll(struct snd_soc_dai *dai, int id, int src, unsigned int freq_in, unsigned int freq_out) { - return _wm8994_set_fll(dai->codec, id, src, freq_in, freq_out); + return _wm8994_set_fll(dai->component, id, src, freq_in, freq_out); } static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int i; switch (dai->id) { @@ -2424,12 +2424,12 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, break; if (i == ARRAY_SIZE(opclk_divs)) return -EINVAL; - snd_soc_update_bits(codec, WM8994_CLOCKING_2, + snd_soc_component_update_bits(component, WM8994_CLOCKING_2, WM8994_OPCLK_DIV_MASK, i); - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_2, WM8994_OPCLK_ENA, WM8994_OPCLK_ENA); } else { - snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_2, + snd_soc_component_update_bits(component, WM8994_POWER_MANAGEMENT_2, WM8994_OPCLK_ENA, 0); } @@ -2437,29 +2437,29 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, return -EINVAL; } - configure_clock(codec); + configure_clock(component); /* * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers * for detection. */ if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { - dev_dbg(codec->dev, "Configuring AIFs for 128fs\n"); + dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); - wm8994->aifdiv[0] = snd_soc_read(codec, WM8994_AIF1_RATE) + wm8994->aifdiv[0] = snd_soc_component_read32(component, WM8994_AIF1_RATE) & WM8994_AIF1CLK_RATE_MASK; - wm8994->aifdiv[1] = snd_soc_read(codec, WM8994_AIF2_RATE) + wm8994->aifdiv[1] = snd_soc_component_read32(component, WM8994_AIF2_RATE) & WM8994_AIF1CLK_RATE_MASK; - snd_soc_update_bits(codec, WM8994_AIF1_RATE, + snd_soc_component_update_bits(component, WM8994_AIF1_RATE, WM8994_AIF1CLK_RATE_MASK, 0x1); - snd_soc_update_bits(codec, WM8994_AIF2_RATE, + snd_soc_component_update_bits(component, WM8994_AIF2_RATE, WM8994_AIF2CLK_RATE_MASK, 0x1); } else if (wm8994->aifdiv[0]) { - snd_soc_update_bits(codec, WM8994_AIF1_RATE, + snd_soc_component_update_bits(component, WM8994_AIF1_RATE, WM8994_AIF1CLK_RATE_MASK, wm8994->aifdiv[0]); - snd_soc_update_bits(codec, WM8994_AIF2_RATE, + snd_soc_component_update_bits(component, WM8994_AIF2_RATE, WM8994_AIF2CLK_RATE_MASK, wm8994->aifdiv[1]); @@ -2470,13 +2470,13 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai, return 0; } -static int wm8994_set_bias_level(struct snd_soc_codec *codec, +static int wm8994_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; - wm_hubs_set_bias_level(codec, level); + wm_hubs_set_bias_level(component, level); switch (level) { case SND_SOC_BIAS_ON: @@ -2487,26 +2487,26 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, switch (control->type) { case WM8958: case WM1811: - snd_soc_update_bits(codec, WM8958_MICBIAS1, + snd_soc_component_update_bits(component, WM8958_MICBIAS1, WM8958_MICB1_MODE, 0); - snd_soc_update_bits(codec, WM8958_MICBIAS2, + snd_soc_component_update_bits(component, WM8958_MICBIAS2, WM8958_MICB2_MODE, 0); break; default: break; } - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) - active_reference(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) + active_reference(component); break; case SND_SOC_BIAS_STANDBY: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) { + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) { switch (control->type) { case WM8958: if (control->revision == 0) { /* Optimise performance for rev A */ - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8958_CHARGE_PUMP_2, WM8958_CP_DISCH, WM8958_CP_DISCH); @@ -2518,24 +2518,24 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, } /* Discharge LINEOUT1 & 2 */ - snd_soc_update_bits(codec, WM8994_ANTIPOP_1, + snd_soc_component_update_bits(component, WM8994_ANTIPOP_1, WM8994_LINEOUT1_DISCH | WM8994_LINEOUT2_DISCH, WM8994_LINEOUT1_DISCH | WM8994_LINEOUT2_DISCH); } - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_PREPARE) - active_dereference(codec); + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_PREPARE) + active_dereference(component); /* MICBIAS into bypass mode on newer devices */ switch (control->type) { case WM8958: case WM1811: - snd_soc_update_bits(codec, WM8958_MICBIAS1, + snd_soc_component_update_bits(component, WM8958_MICBIAS1, WM8958_MICB1_MODE, WM8958_MICB1_MODE); - snd_soc_update_bits(codec, WM8958_MICBIAS2, + snd_soc_component_update_bits(component, WM8958_MICBIAS2, WM8958_MICB2_MODE, WM8958_MICB2_MODE); break; @@ -2545,7 +2545,7 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, break; case SND_SOC_BIAS_OFF: - if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) + if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) wm8994->cur_fw = NULL; break; } @@ -2553,10 +2553,10 @@ static int wm8994_set_bias_level(struct snd_soc_codec *codec, return 0; } -int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode) +int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); switch (mode) { case WM8994_VMID_NORMAL: @@ -2613,8 +2613,8 @@ int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode) static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int ms_reg; int aif1_reg; @@ -2717,7 +2717,7 @@ static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) case WM1811: case WM8958: if (dai->id == 2) - snd_soc_update_bits(codec, WM8958_AIF3_CONTROL_1, + snd_soc_component_update_bits(component, WM8958_AIF3_CONTROL_1, WM8994_AIF1_LRCLK_INV | WM8958_AIF3_FMT_MASK, aif1); break; @@ -2726,15 +2726,15 @@ static int wm8994_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) break; } - snd_soc_update_bits(codec, aif1_reg, + snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_BCLK_INV | WM8994_AIF1_LRCLK_INV | WM8994_AIF1_FMT_MASK, aif1); - snd_soc_update_bits(codec, ms_reg, WM8994_AIF1_MSTR, + snd_soc_component_update_bits(component, ms_reg, WM8994_AIF1_MSTR, ms); - snd_soc_update_bits(codec, dac_reg, + snd_soc_component_update_bits(component, dac_reg, WM8958_AIF1_LRCLK_INV, lrclk); - snd_soc_update_bits(codec, adc_reg, + snd_soc_component_update_bits(component, adc_reg, WM8958_AIF1_LRCLK_INV, lrclk); return 0; @@ -2769,8 +2769,8 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int aif1_reg; @@ -2798,7 +2798,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, lrclk_reg = WM8994_AIF1DAC_LRCLK; } else { lrclk_reg = WM8994_AIF1ADC_LRCLK; - dev_dbg(codec->dev, "AIF1 using split LRCLK\n"); + dev_dbg(component->dev, "AIF1 using split LRCLK\n"); } break; case 2: @@ -2811,7 +2811,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, lrclk_reg = WM8994_AIF2DAC_LRCLK; } else { lrclk_reg = WM8994_AIF2ADC_LRCLK; - dev_dbg(codec->dev, "AIF2 using split LRCLK\n"); + dev_dbg(component->dev, "AIF2 using split LRCLK\n"); } break; default: @@ -2870,7 +2870,7 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, dai->id, wm8994->aifclk[id], bclk_rate); if (wm8994->channels[id] == 1 && - (snd_soc_read(codec, aif1_reg) & 0x18) == 0x18) + (snd_soc_component_read32(component, aif1_reg) & 0x18) == 0x18) aif2 |= WM8994_AIF1_MONO; if (wm8994->aifclk[id] == 0) { @@ -2920,24 +2920,24 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", lrclk, bclk_rate / lrclk); - snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1); - snd_soc_update_bits(codec, aif2_reg, WM8994_AIF1_MONO, aif2); - snd_soc_update_bits(codec, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk); - snd_soc_update_bits(codec, lrclk_reg, WM8994_AIF1DAC_RATE_MASK, + snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_WL_MASK, aif1); + snd_soc_component_update_bits(component, aif2_reg, WM8994_AIF1_MONO, aif2); + snd_soc_component_update_bits(component, bclk_reg, WM8994_AIF1_BCLK_DIV_MASK, bclk); + snd_soc_component_update_bits(component, lrclk_reg, WM8994_AIF1DAC_RATE_MASK, lrclk); - snd_soc_update_bits(codec, rate_reg, WM8994_AIF1_SR_MASK | + snd_soc_component_update_bits(component, rate_reg, WM8994_AIF1_SR_MASK | WM8994_AIF1CLK_RATE_MASK, rate_val); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { switch (dai->id) { case 1: wm8994->dac_rates[0] = params_rate(params); - wm8994_set_retune_mobile(codec, 0); - wm8994_set_retune_mobile(codec, 1); + wm8994_set_retune_mobile(component, 0); + wm8994_set_retune_mobile(component, 1); break; case 2: wm8994->dac_rates[1] = params_rate(params); - wm8994_set_retune_mobile(codec, 2); + wm8994_set_retune_mobile(component, 2); break; } } @@ -2949,8 +2949,8 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int aif1_reg; int aif1 = 0; @@ -2986,12 +2986,12 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - return snd_soc_update_bits(codec, aif1_reg, WM8994_AIF1_WL_MASK, aif1); + return snd_soc_component_update_bits(component, aif1_reg, WM8994_AIF1_WL_MASK, aif1); } static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int mute_reg; int reg; @@ -3011,14 +3011,14 @@ static int wm8994_aif_mute(struct snd_soc_dai *codec_dai, int mute) else reg = 0; - snd_soc_update_bits(codec, mute_reg, WM8994_AIF1DAC1_MUTE, reg); + snd_soc_component_update_bits(component, mute_reg, WM8994_AIF1DAC1_MUTE, reg); return 0; } static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; int reg, val, mask; switch (codec_dai->id) { @@ -3039,19 +3039,19 @@ static int wm8994_set_tristate(struct snd_soc_dai *codec_dai, int tristate) else val = 0; - return snd_soc_update_bits(codec, reg, mask, val); + return snd_soc_component_update_bits(component, reg, mask, val); } static int wm8994_aif2_probe(struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; /* Disable the pulls on the AIF if we're using it to save power. */ - snd_soc_update_bits(codec, WM8994_GPIO_3, + snd_soc_component_update_bits(component, WM8994_GPIO_3, WM8994_GPN_PU | WM8994_GPN_PD, 0); - snd_soc_update_bits(codec, WM8994_GPIO_4, + snd_soc_component_update_bits(component, WM8994_GPIO_4, WM8994_GPN_PU | WM8994_GPN_PD, 0); - snd_soc_update_bits(codec, WM8994_GPIO_5, + snd_soc_component_update_bits(component, WM8994_GPIO_5, WM8994_GPN_PU | WM8994_GPN_PD, 0); return 0; @@ -3152,53 +3152,53 @@ static struct snd_soc_dai_driver wm8994_dai[] = { }; #ifdef CONFIG_PM -static int wm8994_codec_suspend(struct snd_soc_codec *codec) +static int wm8994_component_suspend(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int i, ret; for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { memcpy(&wm8994->fll_suspend[i], &wm8994->fll[i], sizeof(struct wm8994_fll_config)); - ret = _wm8994_set_fll(codec, i + 1, 0, 0, 0); + ret = _wm8994_set_fll(component, i + 1, 0, 0, 0); if (ret < 0) - dev_warn(codec->dev, "Failed to stop FLL%d: %d\n", + dev_warn(component->dev, "Failed to stop FLL%d: %d\n", i + 1, ret); } - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_OFF); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); return 0; } -static int wm8994_codec_resume(struct snd_soc_codec *codec) +static int wm8994_component_resume(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int i, ret; for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { if (!wm8994->fll_suspend[i].out) continue; - ret = _wm8994_set_fll(codec, i + 1, + ret = _wm8994_set_fll(component, i + 1, wm8994->fll_suspend[i].src, wm8994->fll_suspend[i].in, wm8994->fll_suspend[i].out); if (ret < 0) - dev_warn(codec->dev, "Failed to restore FLL%d: %d\n", + dev_warn(component->dev, "Failed to restore FLL%d: %d\n", i + 1, ret); } return 0; } #else -#define wm8994_codec_suspend NULL -#define wm8994_codec_resume NULL +#define wm8994_component_suspend NULL +#define wm8994_component_resume NULL #endif static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) { - struct snd_soc_codec *codec = wm8994->hubs.codec; + struct snd_soc_component *component = wm8994->hubs.component; struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; struct snd_kcontrol_new controls[] = { @@ -3251,22 +3251,22 @@ static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) wm8994->retune_mobile_texts = t; } - dev_dbg(codec->dev, "Allocated %d unique ReTune Mobile names\n", + dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", wm8994->num_retune_mobile_texts); wm8994->retune_mobile_enum.items = wm8994->num_retune_mobile_texts; wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts; - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls, + ret = snd_soc_add_component_controls(wm8994->hubs.component, controls, ARRAY_SIZE(controls)); if (ret != 0) - dev_err(wm8994->hubs.codec->dev, + dev_err(wm8994->hubs.component->dev, "Failed to add ReTune Mobile controls: %d\n", ret); } static void wm8994_handle_pdata(struct wm8994_priv *wm8994) { - struct snd_soc_codec *codec = wm8994->hubs.codec; + struct snd_soc_component *component = wm8994->hubs.component; struct wm8994 *control = wm8994->wm8994; struct wm8994_pdata *pdata = &control->pdata; int ret, i; @@ -3274,7 +3274,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) if (!pdata) return; - wm_hubs_handle_analogue_pdata(codec, pdata->lineout1_diff, + wm_hubs_handle_analogue_pdata(component, pdata->lineout1_diff, pdata->lineout2_diff, pdata->lineout1fb, pdata->lineout2fb, @@ -3285,7 +3285,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) pdata->micbias1_lvl, pdata->micbias2_lvl); - dev_dbg(codec->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); + dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); if (pdata->num_drc_cfgs) { struct snd_kcontrol_new controls[] = { @@ -3298,7 +3298,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) }; /* We need an array of texts for the enum API */ - wm8994->drc_texts = devm_kzalloc(wm8994->hubs.codec->dev, + wm8994->drc_texts = devm_kzalloc(wm8994->hubs.component->dev, sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); if (!wm8994->drc_texts) return; @@ -3309,33 +3309,33 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) wm8994->drc_enum.items = pdata->num_drc_cfgs; wm8994->drc_enum.texts = wm8994->drc_texts; - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, controls, + ret = snd_soc_add_component_controls(wm8994->hubs.component, controls, ARRAY_SIZE(controls)); for (i = 0; i < WM8994_NUM_DRC; i++) - wm8994_set_drc(codec, i); + wm8994_set_drc(component, i); } else { - ret = snd_soc_add_codec_controls(wm8994->hubs.codec, + ret = snd_soc_add_component_controls(wm8994->hubs.component, wm8994_drc_controls, ARRAY_SIZE(wm8994_drc_controls)); } if (ret != 0) - dev_err(wm8994->hubs.codec->dev, + dev_err(wm8994->hubs.component->dev, "Failed to add DRC mode controls: %d\n", ret); - dev_dbg(codec->dev, "%d ReTune Mobile configurations\n", + dev_dbg(component->dev, "%d ReTune Mobile configurations\n", pdata->num_retune_mobile_cfgs); if (pdata->num_retune_mobile_cfgs) wm8994_handle_retune_mobile_pdata(wm8994); else - snd_soc_add_codec_controls(wm8994->hubs.codec, wm8994_eq_controls, + snd_soc_add_component_controls(wm8994->hubs.component, wm8994_eq_controls, ARRAY_SIZE(wm8994_eq_controls)); for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) { if (pdata->micbias[i]) { - snd_soc_write(codec, WM8958_MICBIAS1 + i, + snd_soc_component_write(component, WM8958_MICBIAS1 + i, pdata->micbias[i] & 0xffff); } } @@ -3344,7 +3344,7 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) /** * wm8994_mic_detect - Enable microphone detection via the WM8994 IRQ * - * @codec: WM8994 codec + * @component: WM8994 component * @jack: jack to report detection events on * @micbias: microphone bias to detect on * @@ -3356,17 +3356,17 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) * Configuration of detection levels is available via the micbias1_lvl * and micbias2_lvl platform data members. */ -int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int micbias) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994_micdet *micdet; struct wm8994 *control = wm8994->wm8994; int reg, ret; if (control->type != WM8994) { - dev_warn(codec->dev, "Not a WM8994\n"); + dev_warn(component->dev, "Not a WM8994\n"); return -EINVAL; } @@ -3386,15 +3386,15 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, ret = snd_soc_dapm_disable_pin(dapm, "MICBIAS1"); break; default: - dev_warn(codec->dev, "Invalid MICBIAS %d\n", micbias); + dev_warn(component->dev, "Invalid MICBIAS %d\n", micbias); return -EINVAL; } if (ret != 0) - dev_warn(codec->dev, "Failed to configure MICBIAS%d: %d\n", + dev_warn(component->dev, "Failed to configure MICBIAS%d: %d\n", micbias, ret); - dev_dbg(codec->dev, "Configuring microphone detection on %d %p\n", + dev_dbg(component->dev, "Configuring microphone detection on %d %p\n", micbias, jack); /* Store the configuration */ @@ -3407,10 +3407,10 @@ int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, else reg = 0; - snd_soc_update_bits(codec, WM8994_MICBIAS, WM8994_MICD_ENA, reg); + snd_soc_component_update_bits(component, WM8994_MICBIAS, WM8994_MICD_ENA, reg); /* enable MICDET and MICSHRT deboune */ - snd_soc_update_bits(codec, WM8994_IRQ_DEBOUNCE, + snd_soc_component_update_bits(component, WM8994_IRQ_DEBOUNCE, WM8994_MIC1_DET_DB_MASK | WM8994_MIC1_SHRT_DB_MASK | WM8994_MIC2_DET_DB_MASK | WM8994_MIC2_SHRT_DB_MASK, WM8994_MIC1_DET_DB | WM8994_MIC1_SHRT_DB); @@ -3488,13 +3488,13 @@ static void wm8994_mic_work(struct work_struct *work) static irqreturn_t wm8994_mic_irq(int irq, void *data) { struct wm8994_priv *priv = data; - struct snd_soc_codec *codec = priv->hubs.codec; + struct snd_soc_component *component = priv->hubs.component; #ifndef CONFIG_SND_SOC_WM8994_MODULE - trace_snd_soc_jack_irq(dev_name(codec->dev)); + trace_snd_soc_jack_irq(dev_name(component->dev)); #endif - pm_wakeup_event(codec->dev, 300); + pm_wakeup_event(component->dev, 300); queue_delayed_work(system_power_efficient_wq, &priv->mic_work, msecs_to_jiffies(250)); @@ -3503,25 +3503,25 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data) } /* Should be called with accdet_lock held */ -static void wm1811_micd_stop(struct snd_soc_codec *codec) +static void wm1811_micd_stop(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); if (!wm8994->jackdet) return; - snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); - wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK); + wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_JACK); if (wm8994->wm8994->pdata.jd_ext_cap) snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); } -static void wm8958_button_det(struct snd_soc_codec *codec, u16 status) +static void wm8958_button_det(struct snd_soc_component *component, u16 status) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); int report; report = 0; @@ -3556,14 +3556,14 @@ static void wm8958_open_circuit_work(struct work_struct *work) mutex_lock(&wm8994->accdet_lock); - wm1811_micd_stop(wm8994->hubs.codec); + wm1811_micd_stop(wm8994->hubs.component); dev_dbg(dev, "Reporting open circuit\n"); wm8994->jack_mic = false; wm8994->mic_detecting = true; - wm8958_micd_set_rate(wm8994->hubs.codec); + wm8958_micd_set_rate(wm8994->hubs.component); snd_soc_jack_report(wm8994->micdet[0].jack, 0, wm8994->btn_mask | @@ -3574,13 +3574,13 @@ static void wm8958_open_circuit_work(struct work_struct *work) static void wm8958_mic_id(void *data, u16 status) { - struct snd_soc_codec *codec = data; - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = data; + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); /* Either nothing present or just starting detection */ if (!(status & WM8958_MICD_STS)) { /* If nothing present then clear our statuses */ - dev_dbg(codec->dev, "Detected open circuit\n"); + dev_dbg(component->dev, "Detected open circuit\n"); queue_delayed_work(system_power_efficient_wq, &wm8994->open_circuit_work, @@ -3592,12 +3592,12 @@ static void wm8958_mic_id(void *data, u16 status) * microphone. */ if (status & 0x600) { - dev_dbg(codec->dev, "Detected microphone\n"); + dev_dbg(component->dev, "Detected microphone\n"); wm8994->mic_detecting = false; wm8994->jack_mic = true; - wm8958_micd_set_rate(codec); + wm8958_micd_set_rate(component); snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADSET, SND_JACK_HEADSET); @@ -3605,13 +3605,13 @@ static void wm8958_mic_id(void *data, u16 status) if (status & 0xfc) { - dev_dbg(codec->dev, "Detected headphone\n"); + dev_dbg(component->dev, "Detected headphone\n"); wm8994->mic_detecting = false; - wm8958_micd_set_rate(codec); + wm8958_micd_set_rate(component); /* If we have jackdet that will detect removal */ - wm1811_micd_stop(codec); + wm1811_micd_stop(component); snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADPHONE, SND_JACK_HEADSET); @@ -3624,10 +3624,10 @@ static void wm1811_mic_work(struct work_struct *work) struct wm8994_priv *wm8994 = container_of(work, struct wm8994_priv, mic_work.work); struct wm8994 *control = wm8994->wm8994; - struct snd_soc_codec *codec = wm8994->hubs.codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = wm8994->hubs.component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); /* If required for an external cap force MICBIAS on */ if (control->pdata.jd_ext_cap) { @@ -3637,7 +3637,7 @@ static void wm1811_mic_work(struct work_struct *work) mutex_lock(&wm8994->accdet_lock); - dev_dbg(codec->dev, "Starting mic detection\n"); + dev_dbg(component->dev, "Starting mic detection\n"); /* Use a user-supplied callback if we have one */ if (wm8994->micd_cb) { @@ -3648,54 +3648,54 @@ static void wm1811_mic_work(struct work_struct *work) * what's actually there. */ wm8994->mic_detecting = true; - wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_MIC); + wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_MIC); - snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, WM8958_MICD_ENA); } mutex_unlock(&wm8994->accdet_lock); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); } static irqreturn_t wm1811_jackdet_irq(int irq, void *data) { struct wm8994_priv *wm8994 = data; struct wm8994 *control = wm8994->wm8994; - struct snd_soc_codec *codec = wm8994->hubs.codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = wm8994->hubs.component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int reg, delay; bool present; - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); cancel_delayed_work_sync(&wm8994->mic_complete_work); mutex_lock(&wm8994->accdet_lock); - reg = snd_soc_read(codec, WM1811_JACKDET_CTRL); + reg = snd_soc_component_read32(component, WM1811_JACKDET_CTRL); if (reg < 0) { - dev_err(codec->dev, "Failed to read jack status: %d\n", reg); + dev_err(component->dev, "Failed to read jack status: %d\n", reg); mutex_unlock(&wm8994->accdet_lock); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return IRQ_NONE; } - dev_dbg(codec->dev, "JACKDET %x\n", reg); + dev_dbg(component->dev, "JACKDET %x\n", reg); present = reg & WM1811_JACKDET_LVL; if (present) { - dev_dbg(codec->dev, "Jack detected\n"); + dev_dbg(component->dev, "Jack detected\n"); - wm8958_micd_set_rate(codec); + wm8958_micd_set_rate(component); - snd_soc_update_bits(codec, WM8958_MICBIAS2, + snd_soc_component_update_bits(component, WM8958_MICBIAS2, WM8958_MICB2_DISCH, 0); /* Disable debounce while inserted */ - snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, + snd_soc_component_update_bits(component, WM1811_JACKDET_CTRL, WM1811_JACKDET_DB, 0); delay = control->pdata.micdet_delay; @@ -3703,22 +3703,22 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data) &wm8994->mic_work, msecs_to_jiffies(delay)); } else { - dev_dbg(codec->dev, "Jack not detected\n"); + dev_dbg(component->dev, "Jack not detected\n"); cancel_delayed_work_sync(&wm8994->mic_work); - snd_soc_update_bits(codec, WM8958_MICBIAS2, + snd_soc_component_update_bits(component, WM8958_MICBIAS2, WM8958_MICB2_DISCH, WM8958_MICB2_DISCH); /* Enable debounce while removed */ - snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, + snd_soc_component_update_bits(component, WM1811_JACKDET_CTRL, WM1811_JACKDET_DB, WM1811_JACKDET_DB); wm8994->mic_detecting = false; wm8994->jack_mic = false; - snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); - wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK); + wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_JACK); } mutex_unlock(&wm8994->accdet_lock); @@ -3739,7 +3739,7 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data) * avoid bootstrapping issues with the core. */ snd_soc_jack_report(wm8994->micdet[0].jack, 0, 0); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return IRQ_HANDLED; } @@ -3754,7 +3754,7 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work) /** * wm8958_mic_detect - Enable microphone detection via the WM8958 IRQ * - * @codec: WM8958 codec + * @component: WM8958 component * @jack: jack to report detection events on * * Enable microphone detection functionality for the WM8958. By @@ -3767,12 +3767,12 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work) * flexiblity a callback is provided which allows a completely custom * detection algorithm. */ -int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, wm1811_micdet_cb det_cb, void *det_cb_data, wm1811_mic_id_cb id_cb, void *id_cb_data) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; u16 micd_lvl_sel; @@ -3803,10 +3803,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, wm8994->mic_id_cb_data = id_cb_data; } else { wm8994->mic_id_cb = wm8958_mic_id; - wm8994->mic_id_cb_data = codec; + wm8994->mic_id_cb_data = component; } - wm8958_micd_set_rate(codec); + wm8958_micd_set_rate(component); /* Detect microphones and short circuits by default */ if (control->pdata.micd_lvl_sel) @@ -3818,10 +3818,10 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_BTN_4 | SND_JACK_BTN_5; - snd_soc_update_bits(codec, WM8958_MIC_DETECT_2, + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_2, WM8958_MICD_LVL_SEL_MASK, micd_lvl_sel); - WARN_ON(snd_soc_codec_get_bias_level(codec) > SND_SOC_BIAS_STANDBY); + WARN_ON(snd_soc_component_get_bias_level(component) > SND_SOC_BIAS_STANDBY); /* * If we can use jack detection start off with that, @@ -3829,25 +3829,25 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, */ if (wm8994->jackdet) { /* Disable debounce for the initial detect */ - snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, + snd_soc_component_update_bits(component, WM1811_JACKDET_CTRL, WM1811_JACKDET_DB, 0); - snd_soc_update_bits(codec, WM8958_MICBIAS2, + snd_soc_component_update_bits(component, WM8958_MICBIAS2, WM8958_MICB2_DISCH, WM8958_MICB2_DISCH); - snd_soc_update_bits(codec, WM8994_LDO_1, + snd_soc_component_update_bits(component, WM8994_LDO_1, WM8994_LDO1_DISCH, 0); - wm1811_jackdet_set_mode(codec, + wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_JACK); } else { - snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, WM8958_MICD_ENA); } } else { - snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, + snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); - wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_NONE); + wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_NONE); snd_soc_dapm_disable_pin(dapm, "CLK_SYS"); snd_soc_dapm_sync(dapm); } @@ -3861,9 +3861,9 @@ static void wm8958_mic_work(struct work_struct *work) struct wm8994_priv *wm8994 = container_of(work, struct wm8994_priv, mic_complete_work.work); - struct snd_soc_codec *codec = wm8994->hubs.codec; + struct snd_soc_component *component = wm8994->hubs.component; - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); mutex_lock(&wm8994->accdet_lock); @@ -3871,13 +3871,13 @@ static void wm8958_mic_work(struct work_struct *work) mutex_unlock(&wm8994->accdet_lock); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); } static irqreturn_t wm8958_mic_irq(int irq, void *data) { struct wm8994_priv *wm8994 = data; - struct snd_soc_codec *codec = wm8994->hubs.codec; + struct snd_soc_component *component = wm8994->hubs.component; int reg, count, ret, id_delay; /* @@ -3885,30 +3885,30 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) * with an update of the MICDET status; if so it will have * stopped detection and we can ignore this interrupt. */ - if (!(snd_soc_read(codec, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA)) + if (!(snd_soc_component_read32(component, WM8958_MIC_DETECT_1) & WM8958_MICD_ENA)) return IRQ_HANDLED; cancel_delayed_work_sync(&wm8994->mic_complete_work); cancel_delayed_work_sync(&wm8994->open_circuit_work); - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); /* We may occasionally read a detection without an impedence * range being provided - if that happens loop again. */ count = 10; do { - reg = snd_soc_read(codec, WM8958_MIC_DETECT_3); + reg = snd_soc_component_read32(component, WM8958_MIC_DETECT_3); if (reg < 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read mic detect status: %d\n", reg); - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return IRQ_NONE; } if (!(reg & WM8958_MICD_VALID)) { - dev_dbg(codec->dev, "Mic detect data not valid\n"); + dev_dbg(component->dev, "Mic detect data not valid\n"); goto out; } @@ -3919,20 +3919,20 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) } while (count--); if (count == 0) - dev_warn(codec->dev, "No impedance range reported for jack\n"); + dev_warn(component->dev, "No impedance range reported for jack\n"); #ifndef CONFIG_SND_SOC_WM8994_MODULE - trace_snd_soc_jack_irq(dev_name(codec->dev)); + trace_snd_soc_jack_irq(dev_name(component->dev)); #endif /* Avoid a transient report when the accessory is being removed */ if (wm8994->jackdet) { - ret = snd_soc_read(codec, WM1811_JACKDET_CTRL); + ret = snd_soc_component_read32(component, WM1811_JACKDET_CTRL); if (ret < 0) { - dev_err(codec->dev, "Failed to read jack status: %d\n", + dev_err(component->dev, "Failed to read jack status: %d\n", ret); } else if (!(ret & WM1811_JACKDET_LVL)) { - dev_dbg(codec->dev, "Ignoring removed jack\n"); + dev_dbg(component->dev, "Ignoring removed jack\n"); goto out; } } else if (!(reg & WM8958_MICD_STS)) { @@ -3951,51 +3951,51 @@ static irqreturn_t wm8958_mic_irq(int irq, void *data) &wm8994->mic_complete_work, msecs_to_jiffies(id_delay)); else - wm8958_button_det(codec, reg); + wm8958_button_det(component, reg); out: - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); return IRQ_HANDLED; } static irqreturn_t wm8994_fifo_error(int irq, void *data) { - struct snd_soc_codec *codec = data; + struct snd_soc_component *component = data; - dev_err(codec->dev, "FIFO error\n"); + dev_err(component->dev, "FIFO error\n"); return IRQ_HANDLED; } static irqreturn_t wm8994_temp_warn(int irq, void *data) { - struct snd_soc_codec *codec = data; + struct snd_soc_component *component = data; - dev_err(codec->dev, "Thermal warning\n"); + dev_err(component->dev, "Thermal warning\n"); return IRQ_HANDLED; } static irqreturn_t wm8994_temp_shut(int irq, void *data) { - struct snd_soc_codec *codec = data; + struct snd_soc_component *component = data; - dev_crit(codec->dev, "Thermal shutdown\n"); + dev_crit(component->dev, "Thermal shutdown\n"); return IRQ_HANDLED; } -static int wm8994_codec_probe(struct snd_soc_codec *codec) +static int wm8994_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8994 *control = dev_get_drvdata(codec->dev->parent); - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8994 *control = dev_get_drvdata(component->dev->parent); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); unsigned int reg; int ret, i; - snd_soc_codec_init_regmap(codec, control->regmap); + snd_soc_component_init_regmap(component, control->regmap); - wm8994->hubs.codec = codec; + wm8994->hubs.component = component; mutex_init(&wm8994->accdet_lock); INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, @@ -4070,7 +4070,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994->hubs.dcs_codes_l = -9; wm8994->hubs.dcs_codes_r = -7; - snd_soc_update_bits(codec, WM8994_ANALOGUE_HP_1, + snd_soc_component_update_bits(component, WM8994_ANALOGUE_HP_1, WM1811_HPOUT1_ATTN, WM1811_HPOUT1_ATTN); break; @@ -4079,11 +4079,11 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) } wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, - wm8994_fifo_error, "FIFO error", codec); + wm8994_fifo_error, "FIFO error", component); wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, - wm8994_temp_warn, "Thermal warning", codec); + wm8994_temp_warn, "Thermal warning", component); wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, - wm8994_temp_shut, "Thermal shutdown", codec); + wm8994_temp_shut, "Thermal shutdown", component); switch (control->type) { case WM8994: @@ -4101,7 +4101,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994); if (ret != 0) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to request Mic1 detect IRQ: %d\n", ret); @@ -4111,7 +4111,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994_mic_irq, "Mic 1 short", wm8994); if (ret != 0) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to request Mic1 short IRQ: %d\n", ret); @@ -4120,7 +4120,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994_mic_irq, "Mic 2 detect", wm8994); if (ret != 0) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to request Mic2 detect IRQ: %d\n", ret); @@ -4129,7 +4129,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994_mic_irq, "Mic 2 short", wm8994); if (ret != 0) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to request Mic2 short IRQ: %d\n", ret); break; @@ -4144,7 +4144,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) "Mic detect", wm8994); if (ret != 0) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to request Mic detect IRQ: %d\n", ret); } else { @@ -4180,7 +4180,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) } /* Make sure we can read from the GPIOs if they're inputs */ - pm_runtime_get_sync(codec->dev); + pm_runtime_get_sync(component->dev); /* Remember if AIFnLRCLK is configured as a GPIO. This should be * configured on init - if a system wants to do this dynamically @@ -4188,7 +4188,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) */ ret = regmap_read(control->regmap, WM8994_GPIO_1, ®); if (ret < 0) { - dev_err(codec->dev, "Failed to read GPIO1 state: %d\n", ret); + dev_err(component->dev, "Failed to read GPIO1 state: %d\n", ret); goto err_irq; } if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { @@ -4200,7 +4200,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ret = regmap_read(control->regmap, WM8994_GPIO_6, ®); if (ret < 0) { - dev_err(codec->dev, "Failed to read GPIO6 state: %d\n", ret); + dev_err(component->dev, "Failed to read GPIO6 state: %d\n", ret); goto err_irq; } if ((reg & WM8994_GPN_FN_MASK) != WM8994_GP_FN_PIN_SPECIFIC) { @@ -4210,22 +4210,22 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) wm8994->lrclk_shared[1] = 0; } - pm_runtime_put(codec->dev); + pm_runtime_put(component->dev); /* Latch volume update bits */ for (i = 0; i < ARRAY_SIZE(wm8994_vu_bits); i++) - snd_soc_update_bits(codec, wm8994_vu_bits[i].reg, + snd_soc_component_update_bits(component, wm8994_vu_bits[i].reg, wm8994_vu_bits[i].mask, wm8994_vu_bits[i].mask); /* Set the low bit of the 3D stereo depth so TLV matches */ - snd_soc_update_bits(codec, WM8994_AIF1_DAC1_FILTERS_2, + snd_soc_component_update_bits(component, WM8994_AIF1_DAC1_FILTERS_2, 1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT, 1 << WM8994_AIF1DAC1_3D_GAIN_SHIFT); - snd_soc_update_bits(codec, WM8994_AIF1_DAC2_FILTERS_2, + snd_soc_component_update_bits(component, WM8994_AIF1_DAC2_FILTERS_2, 1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT, 1 << WM8994_AIF1DAC2_3D_GAIN_SHIFT); - snd_soc_update_bits(codec, WM8994_AIF2_DAC_FILTERS_2, + snd_soc_component_update_bits(component, WM8994_AIF2_DAC_FILTERS_2, 1 << WM8994_AIF2DAC_3D_GAIN_SHIFT, 1 << WM8994_AIF2DAC_3D_GAIN_SHIFT); @@ -4235,7 +4235,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) switch (control->type) { case WM8994: case WM8958: - snd_soc_update_bits(codec, WM8994_AIF1_CONTROL_1, + snd_soc_component_update_bits(component, WM8994_AIF1_CONTROL_1, WM8994_AIF1ADC_TDM, WM8994_AIF1ADC_TDM); break; default: @@ -4246,9 +4246,9 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) switch (control->type) { case WM8958: case WM1811: - snd_soc_update_bits(codec, WM8958_MICBIAS1, + snd_soc_component_update_bits(component, WM8958_MICBIAS1, WM8958_MICB1_MODE, WM8958_MICB1_MODE); - snd_soc_update_bits(codec, WM8958_MICBIAS2, + snd_soc_component_update_bits(component, WM8958_MICBIAS2, WM8958_MICB2_MODE, WM8958_MICB2_MODE); break; default: @@ -4256,12 +4256,12 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) } wm8994->hubs.check_class_w_digital = wm8994_check_class_w_digital; - wm_hubs_update_class_w(codec); + wm_hubs_update_class_w(component); wm8994_handle_pdata(wm8994); - wm_hubs_add_analogue_controls(codec); - snd_soc_add_codec_controls(codec, wm8994_snd_controls, + wm_hubs_add_analogue_controls(component); + snd_soc_add_component_controls(component, wm8994_snd_controls, ARRAY_SIZE(wm8994_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8994_dapm_widgets, ARRAY_SIZE(wm8994_dapm_widgets)); @@ -4287,7 +4287,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) } break; case WM8958: - snd_soc_add_codec_controls(codec, wm8958_snd_controls, + snd_soc_add_component_controls(component, wm8958_snd_controls, ARRAY_SIZE(wm8958_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8958_dapm_widgets, ARRAY_SIZE(wm8958_dapm_widgets)); @@ -4309,7 +4309,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) break; case WM1811: - snd_soc_add_codec_controls(codec, wm8958_snd_controls, + snd_soc_add_component_controls(component, wm8958_snd_controls, ARRAY_SIZE(wm8958_snd_controls)); snd_soc_dapm_new_controls(dapm, wm8958_dapm_widgets, ARRAY_SIZE(wm8958_dapm_widgets)); @@ -4322,7 +4322,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) break; } - wm_hubs_add_analogue_routes(codec, 0, 0); + wm_hubs_add_analogue_routes(component, 0, 0); ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, wm_hubs_dcs_done, "DC servo done", &wm8994->hubs); @@ -4360,7 +4360,7 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec) ARRAY_SIZE(wm8958_intercon)); } - wm8958_dsp2_init(codec); + wm8958_dsp2_init(component); break; case WM1811: snd_soc_dapm_add_routes(dapm, wm8994_lateclk_intercon, @@ -4385,16 +4385,16 @@ err_irq: &wm8994->fll_locked[i]); wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, &wm8994->hubs); - wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, codec); - wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, codec); - wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, codec); + wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, component); + wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, component); + wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, component); return ret; } -static int wm8994_codec_remove(struct snd_soc_codec *codec) +static void wm8994_component_remove(struct snd_soc_component *component) { - struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); + struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component); struct wm8994 *control = wm8994->wm8994; int i; @@ -4404,9 +4404,9 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, &wm8994->hubs); - wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, codec); - wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, codec); - wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, codec); + wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, component); + wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, component); + wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, component); if (wm8994->jackdet) wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_GPIO(6), wm8994); @@ -4433,15 +4433,18 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec) release_firmware(wm8994->mbc_vss); release_firmware(wm8994->enh_eq); kfree(wm8994->retune_mobile_texts); - return 0; } -static const 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, - .set_bias_level = wm8994_set_bias_level, +static const struct snd_soc_component_driver soc_component_dev_wm8994 = { + .probe = wm8994_component_probe, + .remove = wm8994_component_remove, + .suspend = wm8994_component_suspend, + .resume = wm8994_component_resume, + .set_bias_level = wm8994_set_bias_level, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8994_probe(struct platform_device *pdev) @@ -4461,13 +4464,12 @@ static int wm8994_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); pm_runtime_idle(&pdev->dev); - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8994, + return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8994, wm8994_dai, ARRAY_SIZE(wm8994_dai)); } static int wm8994_remove(struct platform_device *pdev) { - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); return 0; diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h index dd73387b1cc4..a72efb0e6867 100644 --- a/sound/soc/codecs/wm8994.h +++ b/sound/soc/codecs/wm8994.h @@ -43,18 +43,18 @@ enum wm8994_vmid_mode { typedef void (*wm1811_micdet_cb)(void *data); typedef void (*wm1811_mic_id_cb)(void *data, u16 status); -int wm8994_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, int micbias); -int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack, +int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack, wm1811_micdet_cb cb, void *det_cb_data, wm1811_mic_id_cb id_cb, void *id_cb_data); -int wm8994_vmid_mode(struct snd_soc_codec *codec, enum wm8994_vmid_mode mode); +int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode); int wm8958_aif_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); -void wm8958_dsp2_init(struct snd_soc_codec *codec); +void wm8958_dsp2_init(struct snd_soc_component *component); struct wm8994_micdet { struct snd_soc_jack *jack; diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index 63b2745f8169..fed6ea9b019f 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c @@ -60,9 +60,9 @@ static const char *speaker_mode_text[] = { static SOC_ENUM_SINGLE_DECL(speaker_mode, WM8993_SPKMIXR_ATTENUATION, 8, speaker_mode_text); -static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) +static void wait_for_dc_servo(struct snd_soc_component *component, unsigned int op) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); unsigned int reg; int count = 0; int timeout; @@ -71,9 +71,9 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) val = op | WM8993_DCS_ENA_CHAN_0 | WM8993_DCS_ENA_CHAN_1; /* Trigger the command */ - snd_soc_write(codec, WM8993_DC_SERVO_0, val); + snd_soc_component_write(component, WM8993_DC_SERVO_0, val); - dev_dbg(codec->dev, "Waiting for DC servo...\n"); + dev_dbg(component->dev, "Waiting for DC servo...\n"); if (hubs->dcs_done_irq) timeout = 4; @@ -89,12 +89,12 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, unsigned int op) else msleep(1); - reg = snd_soc_read(codec, WM8993_DC_SERVO_0); - dev_dbg(codec->dev, "DC servo: %x\n", reg); + reg = snd_soc_component_read32(component, WM8993_DC_SERVO_0); + dev_dbg(component->dev, "DC servo: %x\n", reg); } while (reg & op && count < timeout); if (reg & op) - dev_err(codec->dev, "Timed out waiting for DC Servo %x\n", + dev_err(component->dev, "Timed out waiting for DC Servo %x\n", op); } @@ -108,35 +108,35 @@ irqreturn_t wm_hubs_dcs_done(int irq, void *data) } EXPORT_SYMBOL_GPL(wm_hubs_dcs_done); -static bool wm_hubs_dac_hp_direct(struct snd_soc_codec *codec) +static bool wm_hubs_dac_hp_direct(struct snd_soc_component *component) { int reg; /* If we're going via the mixer we'll need to do additional checks */ - reg = snd_soc_read(codec, WM8993_OUTPUT_MIXER1); + reg = snd_soc_component_read32(component, WM8993_OUTPUT_MIXER1); if (!(reg & WM8993_DACL_TO_HPOUT1L)) { if (reg & ~WM8993_DACL_TO_MIXOUTL) { - dev_vdbg(codec->dev, "Analogue paths connected: %x\n", + dev_vdbg(component->dev, "Analogue paths connected: %x\n", reg & ~WM8993_DACL_TO_HPOUT1L); return false; } else { - dev_vdbg(codec->dev, "HPL connected to mixer\n"); + dev_vdbg(component->dev, "HPL connected to mixer\n"); } } else { - dev_vdbg(codec->dev, "HPL connected to DAC\n"); + dev_vdbg(component->dev, "HPL connected to DAC\n"); } - reg = snd_soc_read(codec, WM8993_OUTPUT_MIXER2); + reg = snd_soc_component_read32(component, WM8993_OUTPUT_MIXER2); if (!(reg & WM8993_DACR_TO_HPOUT1R)) { if (reg & ~WM8993_DACR_TO_MIXOUTR) { - dev_vdbg(codec->dev, "Analogue paths connected: %x\n", + dev_vdbg(component->dev, "Analogue paths connected: %x\n", reg & ~WM8993_DACR_TO_HPOUT1R); return false; } else { - dev_vdbg(codec->dev, "HPR connected to mixer\n"); + dev_vdbg(component->dev, "HPR connected to mixer\n"); } } else { - dev_vdbg(codec->dev, "HPR connected to DAC\n"); + dev_vdbg(component->dev, "HPR connected to DAC\n"); } return true; @@ -149,17 +149,17 @@ struct wm_hubs_dcs_cache { u16 dcs_cfg; }; -static bool wm_hubs_dcs_cache_get(struct snd_soc_codec *codec, +static bool wm_hubs_dcs_cache_get(struct snd_soc_component *component, struct wm_hubs_dcs_cache **entry) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); struct wm_hubs_dcs_cache *cache; unsigned int left, right; - left = snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME); + left = snd_soc_component_read32(component, WM8993_LEFT_OUTPUT_VOLUME); left &= WM8993_HPOUT1L_VOL_MASK; - right = snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME); + right = snd_soc_component_read32(component, WM8993_RIGHT_OUTPUT_VOLUME); right &= WM8993_HPOUT1R_VOL_MASK; list_for_each_entry(cache, &hubs->dcs_cache, list) { @@ -173,22 +173,22 @@ static bool wm_hubs_dcs_cache_get(struct snd_soc_codec *codec, return false; } -static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg) +static void wm_hubs_dcs_cache_set(struct snd_soc_component *component, u16 dcs_cfg) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); struct wm_hubs_dcs_cache *cache; if (hubs->no_cache_dac_hp_direct) return; - cache = devm_kzalloc(codec->dev, sizeof(*cache), GFP_KERNEL); + cache = devm_kzalloc(component->dev, sizeof(*cache), GFP_KERNEL); if (!cache) return; - cache->left = snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME); + cache->left = snd_soc_component_read32(component, WM8993_LEFT_OUTPUT_VOLUME); cache->left &= WM8993_HPOUT1L_VOL_MASK; - cache->right = snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME); + cache->right = snd_soc_component_read32(component, WM8993_RIGHT_OUTPUT_VOLUME); cache->right &= WM8993_HPOUT1R_VOL_MASK; cache->dcs_cfg = dcs_cfg; @@ -196,10 +196,10 @@ static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg) list_add_tail(&cache->list, &hubs->dcs_cache); } -static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec, +static int wm_hubs_read_dc_servo(struct snd_soc_component *component, u16 *reg_l, u16 *reg_r) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); u16 dcs_reg, reg; int ret = 0; @@ -220,14 +220,14 @@ static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec, */ switch (hubs->dcs_readback_mode) { case 0: - *reg_l = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_1) + *reg_l = snd_soc_component_read32(component, WM8993_DC_SERVO_READBACK_1) & WM8993_DCS_INTEG_CHAN_0_MASK; - *reg_r = snd_soc_read(codec, WM8993_DC_SERVO_READBACK_2) + *reg_r = snd_soc_component_read32(component, WM8993_DC_SERVO_READBACK_2) & WM8993_DCS_INTEG_CHAN_1_MASK; break; case 2: case 1: - reg = snd_soc_read(codec, dcs_reg); + reg = snd_soc_component_read32(component, dcs_reg); *reg_r = (reg & WM8993_DCS_DAC_WR_VAL_1_MASK) >> WM8993_DCS_DAC_WR_VAL_1_SHIFT; *reg_l = reg & WM8993_DCS_DAC_WR_VAL_0_MASK; @@ -242,9 +242,9 @@ static int wm_hubs_read_dc_servo(struct snd_soc_codec *codec, /* * Startup calibration of the DC servo */ -static void enable_dc_servo(struct snd_soc_codec *codec) +static void enable_dc_servo(struct snd_soc_component *component) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); struct wm_hubs_dcs_cache *cache; s8 offset; u16 reg_l, reg_r, dcs_cfg, dcs_reg; @@ -260,12 +260,12 @@ static void enable_dc_servo(struct snd_soc_codec *codec) /* If we're using a digital only path and have a previously * callibrated DC servo offset stored then use that. */ - if (wm_hubs_dac_hp_direct(codec) && - wm_hubs_dcs_cache_get(codec, &cache)) { - dev_dbg(codec->dev, "Using cached DCS offset %x for %d,%d\n", + if (wm_hubs_dac_hp_direct(component) && + wm_hubs_dcs_cache_get(component, &cache)) { + dev_dbg(component->dev, "Using cached DCS offset %x for %d,%d\n", cache->dcs_cfg, cache->left, cache->right); - snd_soc_write(codec, dcs_reg, cache->dcs_cfg); - wait_for_dc_servo(codec, + snd_soc_component_write(component, dcs_reg, cache->dcs_cfg); + wait_for_dc_servo(component, WM8993_DCS_TRIG_DAC_WR_0 | WM8993_DCS_TRIG_DAC_WR_1); return; @@ -273,48 +273,48 @@ static void enable_dc_servo(struct snd_soc_codec *codec) if (hubs->series_startup) { /* Set for 32 series updates */ - snd_soc_update_bits(codec, WM8993_DC_SERVO_1, + snd_soc_component_update_bits(component, WM8993_DC_SERVO_1, WM8993_DCS_SERIES_NO_01_MASK, 32 << WM8993_DCS_SERIES_NO_01_SHIFT); - wait_for_dc_servo(codec, + wait_for_dc_servo(component, WM8993_DCS_TRIG_SERIES_0 | WM8993_DCS_TRIG_SERIES_1); } else { - wait_for_dc_servo(codec, + wait_for_dc_servo(component, WM8993_DCS_TRIG_STARTUP_0 | WM8993_DCS_TRIG_STARTUP_1); } - if (wm_hubs_read_dc_servo(codec, ®_l, ®_r) < 0) + if (wm_hubs_read_dc_servo(component, ®_l, ®_r) < 0) return; - dev_dbg(codec->dev, "DCS input: %x %x\n", reg_l, reg_r); + dev_dbg(component->dev, "DCS input: %x %x\n", reg_l, reg_r); /* Apply correction to DC servo result */ if (hubs->dcs_codes_l || hubs->dcs_codes_r) { - dev_dbg(codec->dev, + dev_dbg(component->dev, "Applying %d/%d code DC servo correction\n", hubs->dcs_codes_l, hubs->dcs_codes_r); /* HPOUT1R */ offset = (s8)reg_r; - dev_dbg(codec->dev, "DCS right %d->%d\n", offset, + dev_dbg(component->dev, "DCS right %d->%d\n", offset, offset + hubs->dcs_codes_r); offset += hubs->dcs_codes_r; dcs_cfg = (u8)offset << WM8993_DCS_DAC_WR_VAL_1_SHIFT; /* HPOUT1L */ offset = (s8)reg_l; - dev_dbg(codec->dev, "DCS left %d->%d\n", offset, + dev_dbg(component->dev, "DCS left %d->%d\n", offset, offset + hubs->dcs_codes_l); offset += hubs->dcs_codes_l; dcs_cfg |= (u8)offset; - dev_dbg(codec->dev, "DCS result: %x\n", dcs_cfg); + dev_dbg(component->dev, "DCS result: %x\n", dcs_cfg); /* Do it */ - snd_soc_write(codec, dcs_reg, dcs_cfg); - wait_for_dc_servo(codec, + snd_soc_component_write(component, dcs_reg, dcs_cfg); + wait_for_dc_servo(component, WM8993_DCS_TRIG_DAC_WR_0 | WM8993_DCS_TRIG_DAC_WR_1); } else { @@ -324,8 +324,8 @@ static void enable_dc_servo(struct snd_soc_codec *codec) /* Save the callibrated offset if we're in class W mode and * therefore don't have any analogue signal mixed in. */ - if (wm_hubs_dac_hp_direct(codec)) - wm_hubs_dcs_cache_set(codec, dcs_cfg); + if (wm_hubs_dac_hp_direct(component)) + wm_hubs_dcs_cache_set(component, dcs_cfg); } /* @@ -334,8 +334,8 @@ static void enable_dc_servo(struct snd_soc_codec *codec) static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); int ret; ret = snd_soc_put_volsw(kcontrol, ucontrol); @@ -346,9 +346,9 @@ static int wm8993_put_dc_servo(struct snd_kcontrol *kcontrol, return ret; /* Only need to do this if the outputs are active */ - if (snd_soc_read(codec, WM8993_POWER_MANAGEMENT_1) + if (snd_soc_component_read32(component, WM8993_POWER_MANAGEMENT_1) & (WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA)) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, WM8993_DC_SERVO_0, WM8993_DCS_TRIG_SINGLE_0 | WM8993_DCS_TRIG_SINGLE_1, @@ -499,8 +499,8 @@ SOC_SINGLE_TLV("LINEOUT2 Volume", WM8993_LINE_OUTPUTS_VOLUME, 0, 1, 1, static int hp_supply_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_PRE_PMU: @@ -509,28 +509,28 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, break; case 1: /* Enable the headphone amp */ - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); /* Enable the second stage */ - snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0, WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY, WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY); break; default: - dev_err(codec->dev, "Unknown HP startup mode %d\n", + dev_err(component->dev, "Unknown HP startup mode %d\n", hubs->hp_startup_mode); break; } break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM8993_CHARGE_PUMP_1, WM8993_CP_ENA, 0); break; } @@ -541,47 +541,47 @@ static int hp_supply_event(struct snd_soc_dapm_widget *w, static int hp_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - unsigned int reg = snd_soc_read(codec, WM8993_ANALOGUE_HP_0); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + unsigned int reg = snd_soc_component_read32(component, WM8993_ANALOGUE_HP_0); switch (event) { case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, WM8993_CHARGE_PUMP_1, + snd_soc_component_update_bits(component, WM8993_CHARGE_PUMP_1, WM8993_CP_ENA, WM8993_CP_ENA); msleep(5); - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA); reg |= WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY; - snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM8993_ANALOGUE_HP_0, reg); - snd_soc_update_bits(codec, WM8993_DC_SERVO_1, + snd_soc_component_update_bits(component, WM8993_DC_SERVO_1, WM8993_DCS_TIMER_PERIOD_01_MASK, 0); - enable_dc_servo(codec); + enable_dc_servo(component); reg |= WM8993_HPOUT1R_OUTP | WM8993_HPOUT1R_RMV_SHORT | WM8993_HPOUT1L_OUTP | WM8993_HPOUT1L_RMV_SHORT; - snd_soc_write(codec, WM8993_ANALOGUE_HP_0, reg); + snd_soc_component_write(component, WM8993_ANALOGUE_HP_0, reg); break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0, WM8993_HPOUT1L_OUTP | WM8993_HPOUT1R_OUTP | WM8993_HPOUT1L_RMV_SHORT | WM8993_HPOUT1R_RMV_SHORT, 0); - snd_soc_update_bits(codec, WM8993_ANALOGUE_HP_0, + snd_soc_component_update_bits(component, WM8993_ANALOGUE_HP_0, WM8993_HPOUT1L_DLY | WM8993_HPOUT1R_DLY, 0); - snd_soc_write(codec, WM8993_DC_SERVO_0, 0); + snd_soc_component_write(component, WM8993_DC_SERVO_0, 0); - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_1, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_1, WM8993_HPOUT1L_ENA | WM8993_HPOUT1R_ENA, 0); break; @@ -593,18 +593,18 @@ static int hp_event(struct snd_soc_dapm_widget *w, static int earpiece_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *control, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - u16 reg = snd_soc_read(codec, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + u16 reg = snd_soc_component_read32(component, WM8993_ANTIPOP1) & ~WM8993_HPOUT2_IN_ENA; switch (event) { case SND_SOC_DAPM_PRE_PMU: reg |= WM8993_HPOUT2_IN_ENA; - snd_soc_write(codec, WM8993_ANTIPOP1, reg); + snd_soc_component_write(component, WM8993_ANTIPOP1, reg); udelay(50); break; case SND_SOC_DAPM_POST_PMD: - snd_soc_write(codec, WM8993_ANTIPOP1, reg); + snd_soc_component_write(component, WM8993_ANTIPOP1, reg); break; default: @@ -618,8 +618,8 @@ static int earpiece_event(struct snd_soc_dapm_widget *w, static int lineout_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *control, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); bool *flag; switch (w->shift) { @@ -648,8 +648,8 @@ static int lineout_event(struct snd_soc_dapm_widget *w, static int micbias_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); switch (w->shift) { case WM8993_MICB1_ENA_SHIFT: @@ -667,26 +667,26 @@ static int micbias_event(struct snd_soc_dapm_widget *w, return 0; } -void wm_hubs_update_class_w(struct snd_soc_codec *codec) +void wm_hubs_update_class_w(struct snd_soc_component *component) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); int enable = WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ; - if (!wm_hubs_dac_hp_direct(codec)) + if (!wm_hubs_dac_hp_direct(component)) enable = false; - if (hubs->check_class_w_digital && !hubs->check_class_w_digital(codec)) + if (hubs->check_class_w_digital && !hubs->check_class_w_digital(component)) enable = false; - dev_vdbg(codec->dev, "Class W %s\n", enable ? "enabled" : "disabled"); + dev_vdbg(component->dev, "Class W %s\n", enable ? "enabled" : "disabled"); - snd_soc_update_bits(codec, WM8993_CLASS_W_0, + snd_soc_component_update_bits(component, WM8993_CLASS_W_0, WM8993_CP_DYN_V | WM8993_CP_DYN_FREQ, enable); - snd_soc_write(codec, WM8993_LEFT_OUTPUT_VOLUME, - snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME)); - snd_soc_write(codec, WM8993_RIGHT_OUTPUT_VOLUME, - snd_soc_read(codec, WM8993_RIGHT_OUTPUT_VOLUME)); + snd_soc_component_write(component, WM8993_LEFT_OUTPUT_VOLUME, + snd_soc_component_read32(component, WM8993_LEFT_OUTPUT_VOLUME)); + snd_soc_component_write(component, WM8993_RIGHT_OUTPUT_VOLUME, + snd_soc_component_read32(component, WM8993_RIGHT_OUTPUT_VOLUME)); } EXPORT_SYMBOL_GPL(wm_hubs_update_class_w); @@ -697,12 +697,12 @@ EXPORT_SYMBOL_GPL(wm_hubs_update_class_w); static int class_w_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); int ret; ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol); - wm_hubs_update_class_w(codec); + wm_hubs_update_class_w(component); return ret; } @@ -717,12 +717,12 @@ static int class_w_put_volsw(struct snd_kcontrol *kcontrol, static int class_w_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); int ret; ret = snd_soc_dapm_put_enum_double(kcontrol, ucontrol); - wm_hubs_update_class_w(codec); + wm_hubs_update_class_w(component); return ret; } @@ -1113,40 +1113,40 @@ static const struct snd_soc_dapm_route lineout2_se_routes[] = { { "LINEOUT2P Driver", NULL, "LINEOUT2P Mixer" }, }; -int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) +int wm_hubs_add_analogue_controls(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); /* Latch volume update bits & default ZC on */ - snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, + snd_soc_component_update_bits(component, WM8993_LEFT_LINE_INPUT_1_2_VOLUME, WM8993_IN1_VU, WM8993_IN1_VU); - snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, + snd_soc_component_update_bits(component, WM8993_RIGHT_LINE_INPUT_1_2_VOLUME, WM8993_IN1_VU, WM8993_IN1_VU); - snd_soc_update_bits(codec, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, + snd_soc_component_update_bits(component, WM8993_LEFT_LINE_INPUT_3_4_VOLUME, WM8993_IN2_VU, WM8993_IN2_VU); - snd_soc_update_bits(codec, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, + snd_soc_component_update_bits(component, WM8993_RIGHT_LINE_INPUT_3_4_VOLUME, WM8993_IN2_VU, WM8993_IN2_VU); - snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_LEFT, + snd_soc_component_update_bits(component, WM8993_SPEAKER_VOLUME_LEFT, WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); - snd_soc_update_bits(codec, WM8993_SPEAKER_VOLUME_RIGHT, + snd_soc_component_update_bits(component, WM8993_SPEAKER_VOLUME_RIGHT, WM8993_SPKOUT_VU, WM8993_SPKOUT_VU); - snd_soc_update_bits(codec, WM8993_LEFT_OUTPUT_VOLUME, + snd_soc_component_update_bits(component, WM8993_LEFT_OUTPUT_VOLUME, WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC, WM8993_HPOUT1_VU | WM8993_HPOUT1L_ZC); - snd_soc_update_bits(codec, WM8993_RIGHT_OUTPUT_VOLUME, + snd_soc_component_update_bits(component, WM8993_RIGHT_OUTPUT_VOLUME, WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC, WM8993_HPOUT1_VU | WM8993_HPOUT1R_ZC); - snd_soc_update_bits(codec, WM8993_LEFT_OPGA_VOLUME, + snd_soc_component_update_bits(component, WM8993_LEFT_OPGA_VOLUME, WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU, WM8993_MIXOUTL_ZC | WM8993_MIXOUT_VU); - snd_soc_update_bits(codec, WM8993_RIGHT_OPGA_VOLUME, + snd_soc_component_update_bits(component, WM8993_RIGHT_OPGA_VOLUME, WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU, WM8993_MIXOUTR_ZC | WM8993_MIXOUT_VU); - snd_soc_add_codec_controls(codec, analogue_snd_controls, + snd_soc_add_component_controls(component, analogue_snd_controls, ARRAY_SIZE(analogue_snd_controls)); snd_soc_dapm_new_controls(dapm, analogue_dapm_widgets, @@ -1155,13 +1155,13 @@ int wm_hubs_add_analogue_controls(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_controls); -int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, +int wm_hubs_add_analogue_routes(struct snd_soc_component *component, int lineout1_diff, int lineout2_diff) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - hubs->codec = codec; + hubs->component = component; INIT_LIST_HEAD(&hubs->dcs_cache); init_completion(&hubs->dcs_done); @@ -1191,14 +1191,14 @@ int wm_hubs_add_analogue_routes(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(wm_hubs_add_analogue_routes); -int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, +int wm_hubs_handle_analogue_pdata(struct snd_soc_component *component, int lineout1_diff, int lineout2_diff, int lineout1fb, int lineout2fb, int jd_scthr, int jd_thr, int micbias1_delay, int micbias2_delay, int micbias1_lvl, int micbias2_lvl) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); hubs->lineout1_se = !lineout1_diff; hubs->lineout2_se = !lineout2_diff; @@ -1206,28 +1206,28 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, hubs->micb2_delay = micbias2_delay; if (!lineout1_diff) - snd_soc_update_bits(codec, WM8993_LINE_MIXER1, + snd_soc_component_update_bits(component, WM8993_LINE_MIXER1, WM8993_LINEOUT1_MODE, WM8993_LINEOUT1_MODE); if (!lineout2_diff) - snd_soc_update_bits(codec, WM8993_LINE_MIXER2, + snd_soc_component_update_bits(component, WM8993_LINE_MIXER2, WM8993_LINEOUT2_MODE, WM8993_LINEOUT2_MODE); if (!lineout1_diff && !lineout2_diff) - snd_soc_update_bits(codec, WM8993_ANTIPOP1, + snd_soc_component_update_bits(component, WM8993_ANTIPOP1, WM8993_LINEOUT_VMID_BUF_ENA, WM8993_LINEOUT_VMID_BUF_ENA); if (lineout1fb) - snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8993_ADDITIONAL_CONTROL, WM8993_LINEOUT1_FB, WM8993_LINEOUT1_FB); if (lineout2fb) - snd_soc_update_bits(codec, WM8993_ADDITIONAL_CONTROL, + snd_soc_component_update_bits(component, WM8993_ADDITIONAL_CONTROL, WM8993_LINEOUT2_FB, WM8993_LINEOUT2_FB); - snd_soc_update_bits(codec, WM8993_MICBIAS, + snd_soc_component_update_bits(component, WM8993_MICBIAS, WM8993_JD_SCTHR_MASK | WM8993_JD_THR_MASK | WM8993_MICB1_LVL | WM8993_MICB2_LVL, jd_scthr << WM8993_JD_SCTHR_SHIFT | @@ -1239,9 +1239,9 @@ int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(wm_hubs_handle_analogue_pdata); -void wm_hubs_vmid_ena(struct snd_soc_codec *codec) +void wm_hubs_vmid_ena(struct snd_soc_component *component) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); int val = 0; if (hubs->lineout1_se) @@ -1251,20 +1251,20 @@ void wm_hubs_vmid_ena(struct snd_soc_codec *codec) val |= WM8993_LINEOUT2N_ENA | WM8993_LINEOUT2P_ENA; /* Enable the line outputs while we power up */ - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3, val, val); + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_3, val, val); } EXPORT_SYMBOL_GPL(wm_hubs_vmid_ena); -void wm_hubs_set_bias_level(struct snd_soc_codec *codec, +void wm_hubs_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct wm_hubs_data *hubs = snd_soc_codec_get_drvdata(codec); + struct wm_hubs_data *hubs = snd_soc_component_get_drvdata(component); int mask, val; switch (level) { case SND_SOC_BIAS_STANDBY: /* Clamp the inputs to VMID while we ramp to charge caps */ - snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG, + snd_soc_component_update_bits(component, WM8993_INPUTS_CLAMP_REG, WM8993_INPUTS_CLAMP, WM8993_INPUTS_CLAMP); break; @@ -1291,11 +1291,11 @@ void wm_hubs_set_bias_level(struct snd_soc_codec *codec, if (hubs->lineout2_se && hubs->lineout2p_ena) val |= WM8993_LINEOUT2P_ENA; - snd_soc_update_bits(codec, WM8993_POWER_MANAGEMENT_3, + snd_soc_component_update_bits(component, WM8993_POWER_MANAGEMENT_3, mask, val); /* Remove the input clamps */ - snd_soc_update_bits(codec, WM8993_INPUTS_CLAMP_REG, + snd_soc_component_update_bits(component, WM8993_INPUTS_CLAMP_REG, WM8993_INPUTS_CLAMP, 0); break; diff --git a/sound/soc/codecs/wm_hubs.h b/sound/soc/codecs/wm_hubs.h index 24c763df21f9..ee339ad8514d 100644 --- a/sound/soc/codecs/wm_hubs.h +++ b/sound/soc/codecs/wm_hubs.h @@ -19,7 +19,7 @@ #include #include -struct snd_soc_codec; +struct snd_soc_component; extern const unsigned int wm_hubs_spkmix_tlv[]; @@ -34,7 +34,7 @@ struct wm_hubs_data { bool no_cache_dac_hp_direct; struct list_head dcs_cache; - bool (*check_class_w_digital)(struct snd_soc_codec *); + bool (*check_class_w_digital)(struct snd_soc_component *); int micb1_delay; int micb2_delay; @@ -50,12 +50,12 @@ struct wm_hubs_data { bool dcs_done_irq; struct completion dcs_done; - struct snd_soc_codec *codec; + struct snd_soc_component *component; }; -extern int wm_hubs_add_analogue_controls(struct snd_soc_codec *); -extern int wm_hubs_add_analogue_routes(struct snd_soc_codec *, int, int); -extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *, +extern int wm_hubs_add_analogue_controls(struct snd_soc_component *); +extern int wm_hubs_add_analogue_routes(struct snd_soc_component *, int, int); +extern int wm_hubs_handle_analogue_pdata(struct snd_soc_component *, int lineout1_diff, int lineout2_diff, int lineout1fb, int lineout2fb, int jd_scthr, int jd_thr, @@ -63,10 +63,10 @@ extern int wm_hubs_handle_analogue_pdata(struct snd_soc_codec *, int micbias1_lvl, int micbias2_lvl); extern irqreturn_t wm_hubs_dcs_done(int irq, void *data); -extern void wm_hubs_vmid_ena(struct snd_soc_codec *codec); -extern void wm_hubs_set_bias_level(struct snd_soc_codec *codec, +extern void wm_hubs_vmid_ena(struct snd_soc_component *component); +extern void wm_hubs_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level); -extern void wm_hubs_update_class_w(struct snd_soc_codec *codec); +extern void wm_hubs_update_class_w(struct snd_soc_component *component); extern const struct snd_kcontrol_new wm_hubs_hpl_mux; extern const struct snd_kcontrol_new wm_hubs_hpr_mux; diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c index 7cb204e649ca..087f8d738dfb 100644 --- a/sound/soc/samsung/littlemill.c +++ b/sound/soc/samsung/littlemill.c @@ -258,13 +258,13 @@ static struct snd_soc_jack littlemill_headset; static int littlemill_late_probe(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct snd_soc_dai *aif1_dai; struct snd_soc_dai *aif2_dai; int ret; rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec = rtd->codec; + component = rtd->codec_dai->component; aif1_dai = rtd->codec_dai; rtd = snd_soc_get_pcm_runtime(card, card->dai_link[1].name); @@ -290,10 +290,10 @@ static int littlemill_late_probe(struct snd_soc_card *card) return ret; /* This will check device compatibility itself */ - wm8958_mic_detect(codec, &littlemill_headset, NULL, NULL, NULL, NULL); + wm8958_mic_detect(component, &littlemill_headset, NULL, NULL, NULL, NULL); /* As will this */ - wm8994_mic_detect(codec, &littlemill_headset, 1); + wm8994_mic_detect(component, &littlemill_headset, 1); return 0; } From bbf4d71aa9e21e8ee05e16cbb2cd2999252ce930 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:40:28 +0000 Subject: [PATCH 189/942] ASoC: remove rtd->platform checck Now, we are ready to replace rtd->platform to rtdcom list. From this patch, rtd->platform check is no longer needed. It will be replaced into rtdcom. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96c44f6576c9..9558125b448d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1162,11 +1162,6 @@ static int soc_bind_dai_link(struct snd_soc_card *card, rtd->platform = platform; } - if (!rtd->platform) { - dev_err(card->dev, "ASoC: platform %s not registered\n", - dai_link->platform_name); - goto _err_defer; - } soc_add_pcm_runtime(card, rtd); return 0; From 2d59ebd3e2531c48298e7bee6e621e04fccc4a72 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:40:52 +0000 Subject: [PATCH 190/942] ASoC: soc-utils: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index bcd3da2739e2..e237858c9ed4 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -284,7 +284,7 @@ static const struct snd_pcm_ops dummy_dma_ops = { .ioctl = snd_pcm_lib_ioctl, }; -static const struct snd_soc_platform_driver dummy_platform = { +static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, }; @@ -342,7 +342,8 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) if (ret < 0) return ret; - ret = snd_soc_register_platform(&pdev->dev, &dummy_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, + NULL, 0); if (ret < 0) { snd_soc_unregister_codec(&pdev->dev); return ret; @@ -353,7 +354,6 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) static int snd_soc_dummy_remove(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); return 0; From be7ee5f32a9a4eba881d18e85d58e9a03a9cca99 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:41:09 +0000 Subject: [PATCH 191/942] ASoC: soc-generic-dmaengine-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- include/sound/dmaengine_pcm.h | 2 + sound/soc/soc-generic-dmaengine-pcm.c | 55 ++++++++++++++++----------- 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 67be2445941a..8a5a8404966e 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -161,4 +161,6 @@ int snd_dmaengine_pcm_prepare_slave_config(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct dma_slave_config *slave_config); +#define SND_DMAENGINE_PCM_DRV_NAME "snd_dmaengine_pcm" + #endif diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index d53786498b61..c07d5c79ca91 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -33,13 +33,13 @@ struct dmaengine_pcm { struct dma_chan *chan[SNDRV_PCM_STREAM_LAST + 1]; const struct snd_dmaengine_pcm_config *config; - struct snd_soc_platform platform; + struct snd_soc_component component; unsigned int flags; }; -static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) +static struct dmaengine_pcm *soc_component_to_pcm(struct snd_soc_component *p) { - return container_of(p, struct dmaengine_pcm, platform); + return container_of(p, struct dmaengine_pcm, component); } static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, @@ -88,7 +88,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); int (*prepare_slave_config)(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, @@ -119,7 +121,9 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct device *dma_dev = dmaengine_dma_dev(pcm, substream); struct dma_chan *chan = pcm->chan[substream->stream]; struct snd_dmaengine_dai_dma_data *dma_data; @@ -206,7 +210,9 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea static int dmaengine_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct dma_chan *chan = pcm->chan[substream->stream]; int ret; @@ -221,7 +227,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); struct snd_dmaengine_dai_dma_data *dma_data; dma_filter_fn fn = NULL; @@ -260,9 +268,11 @@ static bool dmaengine_pcm_can_report_residue(struct device *dev, static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) { - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); const struct snd_dmaengine_pcm_config *config = pcm->config; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; struct snd_dmaengine_dai_dma_data *dma_data; struct snd_pcm_substream *substream; size_t prealloc_buffer_size; @@ -296,7 +306,7 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) } if (!pcm->chan[i]) { - dev_err(rtd->platform->dev, + dev_err(component->dev, "Missing dma channel for stream: %d\n", i); return -EINVAL; } @@ -320,7 +330,9 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); if (pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_RESIDUE) return snd_dmaengine_pcm_pointer_no_residue(substream); @@ -338,10 +350,9 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = { .pointer = dmaengine_pcm_pointer, }; -static const struct snd_soc_platform_driver dmaengine_pcm_platform = { - .component_driver = { - .probe_order = SND_SOC_COMP_ORDER_LATE, - }, +static const struct snd_soc_component_driver dmaengine_pcm_component = { + .name = SND_DMAENGINE_PCM_DRV_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, .ops = &dmaengine_pcm_ops, .pcm_new = dmaengine_pcm_new, }; @@ -438,8 +449,8 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_dma; - ret = snd_soc_add_platform(dev, &pcm->platform, - &dmaengine_pcm_platform); + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component, NULL, 0); if (ret) goto err_free_dma; @@ -461,16 +472,16 @@ EXPORT_SYMBOL_GPL(snd_dmaengine_pcm_register); */ void snd_dmaengine_pcm_unregister(struct device *dev) { - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct dmaengine_pcm *pcm; - platform = snd_soc_lookup_platform(dev); - if (!platform) + component = snd_soc_lookup_component(dev, SND_DMAENGINE_PCM_DRV_NAME); + if (!component) return; - pcm = soc_platform_to_pcm(platform); + pcm = soc_component_to_pcm(component); - snd_soc_remove_platform(platform); + snd_soc_unregister_component(dev); dmaengine_pcm_release_chan(pcm); kfree(pcm); } From 6840962b0a19c2716f01f4274f24e153c8ca045c Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:41:28 +0000 Subject: [PATCH 192/942] ASoC: intel: atom: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: "Kp, Jeeja" Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst-atom-controls.c | 36 +++++++++---------- .../intel/atom/sst-mfld-platform-compress.c | 4 +-- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 32 +++++------------ sound/soc/intel/atom/sst-mfld-platform.h | 4 ++- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/sound/soc/intel/atom/sst-atom-controls.c b/sound/soc/intel/atom/sst-atom-controls.c index 0f3604b55942..3672d36b4b66 100644 --- a/sound/soc/intel/atom/sst-atom-controls.c +++ b/sound/soc/intel/atom/sst-atom-controls.c @@ -1414,11 +1414,11 @@ static int sst_fill_module_list(struct snd_kcontrol *kctl, * name. First part of control name contains the pipe name (widget name). */ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, - struct snd_soc_platform *platform) + struct snd_soc_component *component) { struct snd_kcontrol *kctl; int index, ret = 0; - struct snd_card *card = platform->component.card->snd_card; + struct snd_card *card = component->card->snd_card; char *idx; down_read(&card->controls_rwsem); @@ -1468,13 +1468,13 @@ static int sst_fill_widget_module_info(struct snd_soc_dapm_widget *w, /** * sst_fill_linked_widgets - fill the parent pointer for the linked widget */ -static void sst_fill_linked_widgets(struct snd_soc_platform *platform, +static void sst_fill_linked_widgets(struct snd_soc_component *component, struct sst_ids *ids) { struct snd_soc_dapm_widget *w; unsigned int len = strlen(ids->parent_wname); - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (!strncmp(ids->parent_wname, w->name, len)) { ids->parent_w = w; break; @@ -1485,41 +1485,41 @@ static void sst_fill_linked_widgets(struct snd_soc_platform *platform, /** * sst_map_modules_to_pipe - fill algo/gains list for all pipes */ -static int sst_map_modules_to_pipe(struct snd_soc_platform *platform) +static int sst_map_modules_to_pipe(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; int ret = 0; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_sst_dapm_widget(w) && (w->priv)) { struct sst_ids *ids = w->priv; - dev_dbg(platform->dev, "widget type=%d name=%s\n", + dev_dbg(component->dev, "widget type=%d name=%s\n", w->id, w->name); INIT_LIST_HEAD(&ids->algo_list); INIT_LIST_HEAD(&ids->gain_list); - ret = sst_fill_widget_module_info(w, platform); + ret = sst_fill_widget_module_info(w, component); if (ret < 0) return ret; /* fill linked widgets */ if (ids->parent_wname != NULL) - sst_fill_linked_widgets(platform, ids); + sst_fill_linked_widgets(component, ids); } } return 0; } -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component) { int i, ret = 0; struct snd_soc_dapm_context *dapm = - snd_soc_component_get_dapm(&platform->component); - struct sst_data *drv = snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_dapm(component); + struct sst_data *drv = snd_soc_component_get_drvdata(component); unsigned int gains = ARRAY_SIZE(sst_gain_controls)/3; - drv->byte_stream = devm_kzalloc(platform->dev, + drv->byte_stream = devm_kzalloc(component->dev, SST_MAX_BIN_BYTES, GFP_KERNEL); if (!drv->byte_stream) return -ENOMEM; @@ -1537,26 +1537,26 @@ int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform) sst_gains[i].ramp_duration = SST_GAIN_RAMP_DURATION_DEFAULT; } - ret = snd_soc_add_platform_controls(platform, sst_gain_controls, + ret = snd_soc_add_component_controls(component, sst_gain_controls, ARRAY_SIZE(sst_gain_controls)); if (ret) return ret; /* Initialize algo control params */ - ret = sst_algo_control_init(platform->dev); + ret = sst_algo_control_init(component->dev); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_algo_controls, + ret = snd_soc_add_component_controls(component, sst_algo_controls, ARRAY_SIZE(sst_algo_controls)); if (ret) return ret; - ret = snd_soc_add_platform_controls(platform, sst_slot_controls, + ret = snd_soc_add_component_controls(component, sst_slot_controls, ARRAY_SIZE(sst_slot_controls)); if (ret) return ret; - ret = sst_map_modules_to_pipe(platform); + ret = sst_map_modules_to_pipe(component); return ret; } diff --git a/sound/soc/intel/atom/sst-mfld-platform-compress.c b/sound/soc/intel/atom/sst-mfld-platform-compress.c index 1dbcab5a6ff0..6a44b19423cf 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-compress.c +++ b/sound/soc/intel/atom/sst-mfld-platform-compress.c @@ -107,8 +107,8 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, struct snd_sst_params str_params; struct sst_compress_cb cb; struct snd_soc_pcm_runtime *rtd = cstream->private_data; - struct snd_soc_platform *platform = rtd->platform; - struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_data *ctx = snd_soc_component_get_drvdata(component); stream = cstream->runtime->private_data; /* construct fw structure for this*/ diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 43e7fdd19f29..6c36da560877 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -697,26 +697,22 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) return retval; } -static int sst_soc_probe(struct snd_soc_platform *platform) +static int sst_soc_probe(struct snd_soc_component *component) { - struct sst_data *drv = dev_get_drvdata(platform->dev); + struct sst_data *drv = dev_get_drvdata(component->dev); - drv->soc_card = platform->component.card; - return sst_dsp_init_v2_dpcm(platform); + drv->soc_card = component->card; + return sst_dsp_init_v2_dpcm(component); } -static const struct snd_soc_platform_driver sst_soc_platform_drv = { +static const struct snd_soc_component_driver sst_soc_platform_drv = { + .name = DRV_NAME, .probe = sst_soc_probe, .ops = &sst_platform_ops, .compr_ops = &sst_platform_compr_ops, .pcm_new = sst_pcm_new, }; -static const struct snd_soc_component_driver sst_component = { - .name = "sst", -}; - - static int sst_platform_probe(struct platform_device *pdev) { struct sst_data *drv; @@ -740,26 +736,16 @@ static int sst_platform_probe(struct platform_device *pdev) mutex_init(&drv->lock); dev_set_drvdata(&pdev->dev, drv); - ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); - if (ret) { - dev_err(&pdev->dev, "registering soc platform failed\n"); - return ret; - } - - ret = snd_soc_register_component(&pdev->dev, &sst_component, + ret = devm_snd_soc_register_component(&pdev->dev, &sst_soc_platform_drv, sst_platform_dai, ARRAY_SIZE(sst_platform_dai)); - if (ret) { + if (ret) dev_err(&pdev->dev, "registering cpu dais failed\n"); - snd_soc_unregister_platform(&pdev->dev); - } + return ret; } static int sst_platform_remove(struct platform_device *pdev) { - - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); dev_dbg(&pdev->dev, "sst_platform_remove success\n"); return 0; } diff --git a/sound/soc/intel/atom/sst-mfld-platform.h b/sound/soc/intel/atom/sst-mfld-platform.h index 31a58c25472c..5f729df57bb5 100644 --- a/sound/soc/intel/atom/sst-mfld-platform.h +++ b/sound/soc/intel/atom/sst-mfld-platform.h @@ -27,6 +27,8 @@ extern struct sst_device *sst; extern const struct snd_compr_ops sst_platform_compr_ops; +#define DRV_NAME "sst" + #define SST_MONO 1 #define SST_STEREO 2 #define SST_MAX_CAP 5 @@ -155,7 +157,7 @@ struct sst_device { struct sst_data; -int sst_dsp_init_v2_dpcm(struct snd_soc_platform *platform); +int sst_dsp_init_v2_dpcm(struct snd_soc_component *component); int sst_send_pipe_gains(struct snd_soc_dai *dai, int stream, int mute); int send_ssp_cmd(struct snd_soc_dai *dai, const char *id, bool enable); int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable); From 56b03b4c4f5e8e1a44328b2df75bfb31fc4c3609 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:41:43 +0000 Subject: [PATCH 193/942] ASoC: intel: skylake: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: "Kp, Jeeja" Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-debug.c | 2 +- sound/soc/intel/skylake/skl-pcm.c | 52 +++++++++----------------- sound/soc/intel/skylake/skl-topology.c | 26 ++++++------- sound/soc/intel/skylake/skl-topology.h | 2 +- sound/soc/intel/skylake/skl.h | 2 +- 5 files changed, 34 insertions(+), 50 deletions(-) diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c index dc20d91f62e6..a016455a6ddb 100644 --- a/sound/soc/intel/skylake/skl-debug.c +++ b/sound/soc/intel/skylake/skl-debug.c @@ -231,7 +231,7 @@ struct skl_debug *skl_debugfs_init(struct skl *skl) /* create the debugfs dir with platform component's debugfs as parent */ d->fs = debugfs_create_dir("dsp", - skl->platform->component.debugfs_root); + skl->component->debugfs_root); if (IS_ERR(d->fs) || !d->fs) { dev_err(&skl->pci->dev, "debugfs root creation failed\n"); return NULL; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e46828533826..36a521562cf7 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1313,23 +1313,23 @@ static int skl_populate_modules(struct skl *skl) return ret; } -static int skl_platform_soc_probe(struct snd_soc_platform *platform) +static int skl_platform_soc_probe(struct snd_soc_component *component) { - struct hdac_ext_bus *ebus = dev_get_drvdata(platform->dev); + struct hdac_ext_bus *ebus = dev_get_drvdata(component->dev); struct skl *skl = ebus_to_skl(ebus); const struct skl_dsp_ops *ops; int ret; - pm_runtime_get_sync(platform->dev); + pm_runtime_get_sync(component->dev); if ((ebus_to_hbus(ebus))->ppcap) { - skl->platform = platform; + skl->component = component; /* init debugfs */ skl->debugfs = skl_debugfs_init(skl); - ret = skl_tplg_init(platform, ebus); + ret = skl_tplg_init(component, ebus); if (ret < 0) { - dev_err(platform->dev, "Failed to init topology!\n"); + dev_err(component->dev, "Failed to init topology!\n"); return ret; } @@ -1339,17 +1339,17 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) return -EIO; if (skl->skl_sst->is_first_boot == false) { - dev_err(platform->dev, "DSP reports first boot done!!!\n"); + dev_err(component->dev, "DSP reports first boot done!!!\n"); return -EIO; } /* disable dynamic clock gating during fw and lib download */ - skl->skl_sst->enable_miscbdcge(platform->dev, false); + skl->skl_sst->enable_miscbdcge(component->dev, false); - ret = ops->init_fw(platform->dev, skl->skl_sst); - skl->skl_sst->enable_miscbdcge(platform->dev, true); + ret = ops->init_fw(component->dev, skl->skl_sst); + skl->skl_sst->enable_miscbdcge(component->dev, true); if (ret < 0) { - dev_err(platform->dev, "Failed to boot first fw: %d\n", ret); + dev_err(component->dev, "Failed to boot first fw: %d\n", ret); return ret; } skl_populate_modules(skl); @@ -1362,22 +1362,20 @@ static int skl_platform_soc_probe(struct snd_soc_platform *platform) skl->cfg.astate_cfg); } } - pm_runtime_mark_last_busy(platform->dev); - pm_runtime_put_autosuspend(platform->dev); + pm_runtime_mark_last_busy(component->dev); + pm_runtime_put_autosuspend(component->dev); return 0; } -static const struct snd_soc_platform_driver skl_platform_drv = { + +static const struct snd_soc_component_driver skl_component = { + .name = "pcm", .probe = skl_platform_soc_probe, .ops = &skl_platform_ops, .pcm_new = skl_pcm_new, .pcm_free = skl_pcm_free, }; -static const struct snd_soc_component_driver skl_component = { - .name = "pcm", -}; - int skl_platform_register(struct device *dev) { int ret; @@ -1389,12 +1387,6 @@ int skl_platform_register(struct device *dev) INIT_LIST_HEAD(&skl->ppl_list); INIT_LIST_HEAD(&skl->bind_list); - ret = snd_soc_register_platform(dev, &skl_platform_drv); - if (ret) { - dev_err(dev, "soc platform registration failed %d\n", ret); - return ret; - } - skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai), GFP_KERNEL); if (!skl->dais) { @@ -1416,18 +1408,12 @@ int skl_platform_register(struct device *dev) num_dais += ARRAY_SIZE(skl_fe_dai); } - ret = snd_soc_register_component(dev, &skl_component, + ret = devm_snd_soc_register_component(dev, &skl_component, skl->dais, num_dais); - if (ret) { + if (ret) dev_err(dev, "soc component registration failed %d\n", ret); - goto err; - } - - return 0; err: - snd_soc_unregister_platform(dev); return ret; - } int skl_platform_unregister(struct device *dev) @@ -1443,8 +1429,6 @@ int skl_platform_unregister(struct device *dev) } } - snd_soc_unregister_component(dev); - snd_soc_unregister_platform(dev); kfree(skl->dais); return 0; diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 73af6e19ebbd..515e4b6d1950 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -2710,15 +2710,15 @@ static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, return 0; } -static void skl_clear_pin_config(struct snd_soc_platform *platform, +static void skl_clear_pin_config(struct snd_soc_component *component, struct snd_soc_dapm_widget *w) { int i; struct skl_module_cfg *mconfig; struct skl_pipe *pipe; - if (!strncmp(w->dapm->component->name, platform->component.name, - strlen(platform->component.name))) { + if (!strncmp(w->dapm->component->name, component->name, + strlen(component->name))) { mconfig = w->priv; pipe = mconfig->pipe; for (i = 0; i < mconfig->module->max_input_pins; i++) { @@ -2737,14 +2737,14 @@ static void skl_clear_pin_config(struct snd_soc_platform *platform, void skl_cleanup_resources(struct skl *skl) { struct skl_sst *ctx = skl->skl_sst; - struct snd_soc_platform *soc_platform = skl->platform; + struct snd_soc_component *soc_component = skl->component; struct snd_soc_dapm_widget *w; struct snd_soc_card *card; - if (soc_platform == NULL) + if (soc_component == NULL) return; - card = soc_platform->component.card; + card = soc_component->card; if (!card || !card->instantiated) return; @@ -2753,7 +2753,7 @@ void skl_cleanup_resources(struct skl *skl) list_for_each_entry(w, &card->widgets, list) { if (is_skl_dsp_widget_type(w) && (w->priv != NULL)) - skl_clear_pin_config(soc_platform, w); + skl_clear_pin_config(soc_component, w); } skl_clear_module_cnt(ctx->dsp); @@ -3400,19 +3400,19 @@ static struct snd_soc_tplg_ops skl_tplg_ops = { * widgets in a pipelines, so this helper - skl_tplg_create_pipe_widget_list() * helps to get the SKL type widgets in that pipeline */ -static int skl_tplg_create_pipe_widget_list(struct snd_soc_platform *platform) +static int skl_tplg_create_pipe_widget_list(struct snd_soc_component *component) { struct snd_soc_dapm_widget *w; struct skl_module_cfg *mcfg = NULL; struct skl_pipe_module *p_module = NULL; struct skl_pipe *pipe; - list_for_each_entry(w, &platform->component.card->widgets, list) { + list_for_each_entry(w, &component->card->widgets, list) { if (is_skl_dsp_widget_type(w) && w->priv != NULL) { mcfg = w->priv; pipe = mcfg->pipe; - p_module = devm_kzalloc(platform->dev, + p_module = devm_kzalloc(component->dev, sizeof(*p_module), GFP_KERNEL); if (!p_module) return -ENOMEM; @@ -3455,7 +3455,7 @@ static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe) /* * SKL topology init routine */ -int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus) { int ret; const struct firmware *fw; @@ -3479,7 +3479,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) * The complete tplg for SKL is loaded as index 0, we don't use * any other index */ - ret = snd_soc_tplg_component_load(&platform->component, + ret = snd_soc_tplg_component_load(component, &skl_tplg_ops, fw, 0); if (ret < 0) { dev_err(bus->dev, "tplg component load failed%d\n", ret); @@ -3491,7 +3491,7 @@ int skl_tplg_init(struct snd_soc_platform *platform, struct hdac_ext_bus *ebus) skl->resource.max_mem = SKL_FW_MAX_MEM; skl->tplg = fw; - ret = skl_tplg_create_pipe_widget_list(platform); + ret = skl_tplg_create_pipe_widget_list(component); if (ret < 0) return ret; diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index b6496513fe55..87c946835705 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -460,7 +460,7 @@ int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, u32 caps_size, u32 node_id); void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, struct skl_pipe_params *params, int stream); -int skl_tplg_init(struct snd_soc_platform *platform, +int skl_tplg_init(struct snd_soc_component *component, struct hdac_ext_bus *ebus); struct skl_module_cfg *skl_tplg_fe_get_cpr_module( struct snd_soc_dai *dai, int stream); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index 2d13f3fd988a..ca46ad1d0a08 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -74,7 +74,7 @@ struct skl { struct platform_device *dmic_dev; struct platform_device *i2s_dev; struct platform_device *clk_dev; - struct snd_soc_platform *platform; + struct snd_soc_component *component; struct snd_soc_dai_driver *dais; struct nhlt_acpi_table *nhlt; /* nhlt ptr */ From 81dc5f3d806ad50283b4b58abebd08ef65817f87 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:02 +0000 Subject: [PATCH 194/942] ASoC: intel: baytrail: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/baytrail/sst-baytrail-pcm.c | 66 ++++++++------------- 1 file changed, 25 insertions(+), 41 deletions(-) diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c index c54529320f07..aabb35bf6b96 100644 --- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c +++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c @@ -23,6 +23,7 @@ #include "../common/sst-dsp-priv.h" #include "../common/sst-dsp.h" +#define DRV_NAME "byt-dai" #define BYT_PCM_COUNT 2 static const struct snd_pcm_hardware sst_byt_pcm_hardware = { @@ -69,8 +70,8 @@ static int sst_byt_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; u32 rate, bits; @@ -141,8 +142,8 @@ static int sst_byt_pcm_hw_free(struct snd_pcm_substream *substream) static int sst_byt_pcm_restore_stream_context(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -174,8 +175,8 @@ static void sst_byt_pcm_work(struct work_struct *work) static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -216,8 +217,8 @@ static u32 byt_notify_pointer(struct sst_byt_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt *byt = pdata->byt; u32 pos, hw_pos; @@ -238,8 +239,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; dev_dbg(rtd->dev, "PCM: DMA pointer %u bytes\n", pcm_data->hw_ptr); @@ -250,8 +251,8 @@ static snd_pcm_uframes_t sst_byt_pcm_pointer(struct snd_pcm_substream *substream static int sst_byt_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; @@ -278,8 +279,8 @@ static int sst_byt_pcm_open(struct snd_pcm_substream *substream) static int sst_byt_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct sst_byt_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream]; struct sst_byt *byt = pdata->byt; int ret; @@ -324,8 +325,8 @@ static int sst_byt_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; size_t size; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); int ret = 0; if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || @@ -366,21 +367,21 @@ static struct snd_soc_dai_driver byt_dais[] = { }, }; -static int sst_byt_pcm_probe(struct snd_soc_platform *platform) +static int sst_byt_pcm_probe(struct snd_soc_component *component) { - struct sst_pdata *plat_data = dev_get_platdata(platform->dev); + struct sst_pdata *plat_data = dev_get_platdata(component->dev); struct sst_byt_priv_data *priv_data; int i; if (!plat_data) return -ENODEV; - priv_data = devm_kzalloc(platform->dev, sizeof(*priv_data), + priv_data = devm_kzalloc(component->dev, sizeof(*priv_data), GFP_KERNEL); if (!priv_data) return -ENOMEM; priv_data->byt = plat_data->dsp; - snd_soc_platform_set_drvdata(platform, priv_data); + snd_soc_component_set_drvdata(component, priv_data); for (i = 0; i < BYT_PCM_COUNT; i++) { mutex_init(&priv_data->pcm[i].mutex); @@ -390,22 +391,13 @@ static int sst_byt_pcm_probe(struct snd_soc_platform *platform) return 0; } -static int sst_byt_pcm_remove(struct snd_soc_platform *platform) -{ - return 0; -} - -static const struct snd_soc_platform_driver byt_soc_platform = { +static const struct snd_soc_component_driver byt_dai_component = { + .name = DRV_NAME, .probe = sst_byt_pcm_probe, - .remove = sst_byt_pcm_remove, .ops = &sst_byt_pcm_ops, .pcm_new = sst_byt_pcm_new, }; -static const struct snd_soc_component_driver byt_dai_component = { - .name = "byt-dai", -}; - #ifdef CONFIG_PM static int sst_byt_pcm_dev_suspend_late(struct device *dev) { @@ -461,19 +453,13 @@ static int sst_byt_pcm_dev_probe(struct platform_device *pdev) if (ret < 0) return -ENODEV; - ret = snd_soc_register_platform(&pdev->dev, &byt_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &byt_dai_component, + byt_dais, ARRAY_SIZE(byt_dais)); if (ret < 0) goto err_plat; - ret = snd_soc_register_component(&pdev->dev, &byt_dai_component, - byt_dais, ARRAY_SIZE(byt_dais)); - if (ret < 0) - goto err_comp; - return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_byt_dsp_free(&pdev->dev, sst_pdata); return ret; @@ -483,8 +469,6 @@ static int sst_byt_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_byt_dsp_free(&pdev->dev, sst_pdata); return 0; From 2ee178dbeb3974676b23751d602f79cc276f46e4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:21 +0000 Subject: [PATCH 195/942] ASoC: intel: haswell: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/boards/bdw-rt5677.c | 3 +- sound/soc/intel/boards/broadwell.c | 3 +- sound/soc/intel/boards/haswell.c | 3 +- sound/soc/intel/haswell/sst-haswell-ipc.h | 2 + sound/soc/intel/haswell/sst-haswell-pcm.c | 118 ++++++++++------------ 5 files changed, 60 insertions(+), 69 deletions(-) diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c index 058b8ccedf02..8999f8de119c 100644 --- a/sound/soc/intel/boards/bdw-rt5677.c +++ b/sound/soc/intel/boards/bdw-rt5677.c @@ -183,7 +183,8 @@ static const struct snd_soc_ops bdw_rt5677_ops = { static int bdw_rt5677_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c index 6dcbbcefc25b..249b8a3290b8 100644 --- a/sound/soc/intel/boards/broadwell.c +++ b/sound/soc/intel/boards/broadwell.c @@ -132,7 +132,8 @@ static const struct snd_soc_ops broadwell_rt286_ops = { static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *broadwell = pdata->dsp; int ret; diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c index 3c5160779204..eab1f439dd3f 100644 --- a/sound/soc/intel/boards/haswell.c +++ b/sound/soc/intel/boards/haswell.c @@ -87,7 +87,8 @@ static const struct snd_soc_ops haswell_rt5640_ops = { static int haswell_rtd_init(struct snd_soc_pcm_runtime *rtd) { - struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct sst_hsw *haswell = pdata->dsp; int ret; diff --git a/sound/soc/intel/haswell/sst-haswell-ipc.h b/sound/soc/intel/haswell/sst-haswell-ipc.h index 06d71aefa1fe..fbc14df139e4 100644 --- a/sound/soc/intel/haswell/sst-haswell-ipc.h +++ b/sound/soc/intel/haswell/sst-haswell-ipc.h @@ -22,6 +22,8 @@ #include #include +#define DRV_NAME "haswell-dai" + #define SST_HSW_NO_CHANNELS 4 #define SST_HSW_MAX_DX_REGIONS 14 #define SST_HSW_DX_CONTEXT_SIZE (640 * 1024) diff --git a/sound/soc/intel/haswell/sst-haswell-pcm.c b/sound/soc/intel/haswell/sst-haswell-pcm.c index c044400540ec..fe2c826e710c 100644 --- a/sound/soc/intel/haswell/sst-haswell-pcm.c +++ b/sound/soc/intel/haswell/sst-haswell-pcm.c @@ -181,11 +181,11 @@ static inline unsigned int hsw_ipc_to_mixer(u32 value) static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -230,11 +230,11 @@ static int hsw_stream_volume_put(struct snd_kcontrol *kcontrol, static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -273,8 +273,8 @@ static int hsw_stream_volume_get(struct snd_kcontrol *kcontrol, static int hsw_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 volume; @@ -302,8 +302,8 @@ static int hsw_volume_put(struct snd_kcontrol *kcontrol, static int hsw_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; unsigned int volume = 0; @@ -322,8 +322,8 @@ static int hsw_volume_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -336,8 +336,8 @@ static int hsw_waves_switch_get(struct snd_kcontrol *kcontrol, static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret = 0; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -370,8 +370,8 @@ static int hsw_waves_switch_put(struct snd_kcontrol *kcontrol, static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; /* return a matching line from param buffer */ @@ -381,8 +381,8 @@ static int hsw_waves_param_get(struct snd_kcontrol *kcontrol, static int hsw_waves_param_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_platform *platform = snd_soc_kcontrol_platform(kcontrol); - struct hsw_priv_data *pdata = snd_soc_platform_get_drvdata(platform); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; int ret; enum sst_hsw_module_id id = SST_HSW_MODULE_WAVES; @@ -472,8 +472,8 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; struct sst_module *module_data; @@ -674,8 +674,8 @@ static int hsw_pcm_hw_free(struct snd_pcm_substream *substream) static int hsw_pcm_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw_stream *sst_stream; struct sst_hsw *hsw = pdata->hsw; @@ -718,8 +718,8 @@ static u32 hsw_notify_pointer(struct sst_hsw_stream *stream, void *data) struct snd_pcm_substream *substream = pcm_data->substream; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct sst_hsw *hsw = pdata->hsw; u32 pos; snd_pcm_uframes_t position = bytes_to_frames(runtime, @@ -783,8 +783,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; snd_pcm_uframes_t offset; @@ -807,8 +807,8 @@ static snd_pcm_uframes_t hsw_pcm_pointer(struct snd_pcm_substream *substream) static int hsw_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int dai; @@ -840,8 +840,8 @@ static int hsw_pcm_open(struct snd_pcm_substream *substream) static int hsw_pcm_close(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct hsw_priv_data *pdata = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct hsw_priv_data *pdata = snd_soc_component_get_drvdata(component); struct hsw_pcm_data *pcm_data; struct sst_hsw *hsw = pdata->hsw; int ret, dai; @@ -942,9 +942,9 @@ static void hsw_pcm_free_modules(struct hsw_priv_data *pdata) static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) { struct snd_pcm *pcm = rtd->pcm; - struct snd_soc_platform *platform = rtd->platform; - struct sst_pdata *pdata = dev_get_platdata(platform->dev); - struct hsw_priv_data *priv_data = dev_get_drvdata(platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct sst_pdata *pdata = dev_get_platdata(component->dev); + struct hsw_priv_data *priv_data = dev_get_drvdata(component->dev); struct device *dev = pdata->dma_dev; int ret = 0; @@ -1052,23 +1052,23 @@ static const struct snd_soc_dapm_route graph[] = { {"Analog Capture", NULL, "SSP0 CODEC IN"}, }; -static int hsw_pcm_probe(struct snd_soc_platform *platform) +static int hsw_pcm_probe(struct snd_soc_component *component) { - struct hsw_priv_data *priv_data = snd_soc_platform_get_drvdata(platform); - struct sst_pdata *pdata = dev_get_platdata(platform->dev); + struct hsw_priv_data *priv_data = snd_soc_component_get_drvdata(component); + struct sst_pdata *pdata = dev_get_platdata(component->dev); struct device *dma_dev, *dev; int i, ret = 0; if (!pdata) return -ENODEV; - dev = platform->dev; + dev = component->dev; dma_dev = pdata->dma_dev; priv_data->hsw = pdata->dsp; - priv_data->dev = platform->dev; + priv_data->dev = dev; priv_data->pm_state = HSW_PM_STATE_D0; - priv_data->soc_card = platform->component.card; + priv_data->soc_card = component->card; /* allocate DSP buffer page tables */ for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1098,11 +1098,10 @@ static int hsw_pcm_probe(struct snd_soc_platform *platform) goto err; /* enable runtime PM with auto suspend */ - pm_runtime_set_autosuspend_delay(platform->dev, - SST_RUNTIME_SUSPEND_DELAY); - pm_runtime_use_autosuspend(platform->dev); - pm_runtime_enable(platform->dev); - pm_runtime_idle(platform->dev); + pm_runtime_set_autosuspend_delay(dev, SST_RUNTIME_SUSPEND_DELAY); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + pm_runtime_idle(dev); return 0; @@ -1116,13 +1115,13 @@ err: return ret; } -static int hsw_pcm_remove(struct snd_soc_platform *platform) +static void hsw_pcm_remove(struct snd_soc_component *component) { struct hsw_priv_data *priv_data = - snd_soc_platform_get_drvdata(platform); + snd_soc_component_get_drvdata(component); int i; - pm_runtime_disable(platform->dev); + pm_runtime_disable(component->dev); hsw_pcm_free_modules(priv_data); for (i = 0; i < ARRAY_SIZE(hsw_dais); i++) { @@ -1131,24 +1130,19 @@ static int hsw_pcm_remove(struct snd_soc_platform *platform) if (hsw_dais[i].capture.channels_min) snd_dma_free_pages(&priv_data->dmab[i][1]); } - - return 0; } -static const struct snd_soc_platform_driver hsw_soc_platform = { +static const struct snd_soc_component_driver hsw_dai_component = { + .name = DRV_NAME, .probe = hsw_pcm_probe, .remove = hsw_pcm_remove, .ops = &hsw_pcm_ops, .pcm_new = hsw_pcm_new, -}; - -static const struct snd_soc_component_driver hsw_dai_component = { - .name = "haswell-dai", - .controls = hsw_volume_controls, - .num_controls = ARRAY_SIZE(hsw_volume_controls), - .dapm_widgets = widgets, + .controls = hsw_volume_controls, + .num_controls = ARRAY_SIZE(hsw_volume_controls), + .dapm_widgets = widgets, .num_dapm_widgets = ARRAY_SIZE(widgets), - .dapm_routes = graph, + .dapm_routes = graph, .num_dapm_routes = ARRAY_SIZE(graph), }; @@ -1172,19 +1166,13 @@ static int hsw_pcm_dev_probe(struct platform_device *pdev) priv_data->hsw = sst_pdata->dsp; platform_set_drvdata(pdev, priv_data); - ret = snd_soc_register_platform(&pdev->dev, &hsw_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &hsw_dai_component, + hsw_dais, ARRAY_SIZE(hsw_dais)); if (ret < 0) goto err_plat; - ret = snd_soc_register_component(&pdev->dev, &hsw_dai_component, - hsw_dais, ARRAY_SIZE(hsw_dais)); - if (ret < 0) - goto err_comp; - return 0; -err_comp: - snd_soc_unregister_platform(&pdev->dev); err_plat: sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; @@ -1194,8 +1182,6 @@ static int hsw_pcm_dev_remove(struct platform_device *pdev) { struct sst_pdata *sst_pdata = dev_get_platdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); sst_hsw_dsp_free(&pdev->dev, sst_pdata); return 0; From 540b925af4c0456adf220dea991d91bf05ad77c0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:37 +0000 Subject: [PATCH 196/942] ASoC: bcm: cygnus: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-pcm.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/bcm/cygnus-pcm.c b/sound/soc/bcm/cygnus-pcm.c index d616e096462e..123ecf5479d7 100644 --- a/sound/soc/bcm/cygnus-pcm.c +++ b/sound/soc/bcm/cygnus-pcm.c @@ -820,7 +820,7 @@ static int cygnus_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver cygnus_soc_platform = { +static struct snd_soc_component_driver cygnus_soc_platform = { .ops = &cygnus_pcm_ops, .pcm_new = cygnus_dma_new, .pcm_free = cygnus_dma_free_dma_buffers, @@ -840,7 +840,8 @@ int cygnus_soc_platform_register(struct device *dev, return rc; } - rc = snd_soc_register_platform(dev, &cygnus_soc_platform); + rc = devm_snd_soc_register_component(dev, &cygnus_soc_platform, + NULL, 0); if (rc) { dev_err(dev, "%s failed\n", __func__); return rc; @@ -851,8 +852,6 @@ int cygnus_soc_platform_register(struct device *dev, int cygnus_soc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(dev); - return 0; } From 019ea01b7c510803d2f1ca8315916084887463c9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:42:53 +0000 Subject: [PATCH 197/942] ASoC: sh: rsnd: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 64d5ecb86528..b4007669c704 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1337,7 +1337,7 @@ int rsnd_kctrl_new(struct rsnd_mod *mod, } /* - * snd_soc_platform + * snd_soc_component */ #define PREALLOC_BUFFER (32 * 1024) @@ -1364,12 +1364,9 @@ static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); } -static const struct snd_soc_platform_driver rsnd_soc_platform = { +static const struct snd_soc_component_driver rsnd_soc_component = { .ops = &rsnd_pcm_ops, .pcm_new = rsnd_pcm_new, -}; - -static const struct snd_soc_component_driver rsnd_soc_component = { .name = "rsnd", }; @@ -1478,17 +1475,11 @@ static int rsnd_probe(struct platform_device *pdev) /* * asoc register */ - ret = snd_soc_register_platform(dev, &rsnd_soc_platform); - if (ret < 0) { - dev_err(dev, "cannot snd soc register\n"); - return ret; - } - - ret = snd_soc_register_component(dev, &rsnd_soc_component, + ret = devm_snd_soc_register_component(dev, &rsnd_soc_component, priv->daidrv, rsnd_rdai_nr(priv)); if (ret < 0) { dev_err(dev, "cannot snd dai register\n"); - goto exit_snd_soc; + goto exit_snd_probe; } pm_runtime_enable(dev); @@ -1496,8 +1487,6 @@ static int rsnd_probe(struct platform_device *pdev) dev_info(dev, "probed\n"); return ret; -exit_snd_soc: - snd_soc_unregister_platform(dev); exit_snd_probe: for_each_rsnd_dai(rdai, priv, i) { rsnd_dai_call(remove, &rdai->playback, priv); @@ -1535,9 +1524,6 @@ static int rsnd_remove(struct platform_device *pdev) for (i = 0; i < ARRAY_SIZE(remove_func); i++) remove_func[i](priv); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - return ret; } From eb5d510c869b95d3e219d4b01156f9095ec162f6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:43:10 +0000 Subject: [PATCH 198/942] ASoC: sh: dma-sh7760: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/dma-sh7760.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/sh/dma-sh7760.c b/sound/soc/sh/dma-sh7760.c index 1e7d417b53ef..2dc3b762fdd9 100644 --- a/sound/soc/sh/dma-sh7760.c +++ b/sound/soc/sh/dma-sh7760.c @@ -320,14 +320,15 @@ static int camelot_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_soc_platform_driver sh7760_soc_platform = { +static const struct snd_soc_component_driver sh7760_soc_component = { .ops = &camelot_pcm_ops, .pcm_new = camelot_pcm_new, }; static int sh7760_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &sh7760_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &sh7760_soc_component, + NULL, 0); } static struct platform_driver sh7760_pcm_driver = { From f5a82fa6016ad1c2a3f45a4d44eab2ac48daf130 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:43:26 +0000 Subject: [PATCH 199/942] ASoC: sh: fsi: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/fsi.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index c3aaf4788557..3bae06dd121f 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c @@ -1764,7 +1764,7 @@ static const struct snd_pcm_ops fsi_pcm_ops = { }; /* - * snd_soc_platform + * snd_soc_component */ #define PREALLOC_BUFFER (32 * 1024) @@ -1818,13 +1818,10 @@ static struct snd_soc_dai_driver fsi_soc_dai[] = { }, }; -static const struct snd_soc_platform_driver fsi_soc_platform = { - .ops = &fsi_pcm_ops, - .pcm_new = fsi_pcm_new, -}; - static const struct snd_soc_component_driver fsi_soc_component = { .name = "fsi", + .ops = &fsi_pcm_ops, + .pcm_new = fsi_pcm_new, }; /* @@ -2007,23 +2004,15 @@ static int fsi_probe(struct platform_device *pdev) goto exit_fsib; } - ret = snd_soc_register_platform(&pdev->dev, &fsi_soc_platform); - if (ret < 0) { - dev_err(&pdev->dev, "cannot snd soc register\n"); - goto exit_fsib; - } - - ret = snd_soc_register_component(&pdev->dev, &fsi_soc_component, + ret = devm_snd_soc_register_component(&pdev->dev, &fsi_soc_component, fsi_soc_dai, ARRAY_SIZE(fsi_soc_dai)); if (ret < 0) { dev_err(&pdev->dev, "cannot snd component register\n"); - goto exit_snd_soc; + goto exit_fsib; } return ret; -exit_snd_soc: - snd_soc_unregister_platform(&pdev->dev); exit_fsib: pm_runtime_disable(&pdev->dev); fsi_stream_remove(&master->fsib); @@ -2041,9 +2030,6 @@ static int fsi_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - fsi_stream_remove(&master->fsia); fsi_stream_remove(&master->fsib); From be3eabe99803b2526f8829b7c7225763f0703b1f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:43:45 +0000 Subject: [PATCH 200/942] ASoC: sh: siu: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/sh/siu.h | 2 +- sound/soc/sh/siu_dai.c | 10 +--------- sound/soc/sh/siu_pcm.c | 9 ++++++--- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/sound/soc/sh/siu.h b/sound/soc/sh/siu.h index 83c3430ad797..6088d627c0e4 100644 --- a/sound/soc/sh/siu.h +++ b/sound/soc/sh/siu.h @@ -183,7 +183,7 @@ static inline u32 siu_read32(u32 __iomem *addr) #define SIU_BRGBSEL (0x108 / sizeof(u32)) #define SIU_BRRB (0x10c / sizeof(u32)) -extern struct snd_soc_platform_driver siu_platform; +extern struct snd_soc_component_driver siu_component; extern struct siu_info *siu_i2s_data; int siu_init_port(int port, struct siu_port **port_info, struct snd_card *card); diff --git a/sound/soc/sh/siu_dai.c b/sound/soc/sh/siu_dai.c index 160502947da2..ee2211635e92 100644 --- a/sound/soc/sh/siu_dai.c +++ b/sound/soc/sh/siu_dai.c @@ -727,10 +727,6 @@ static struct snd_soc_dai_driver siu_i2s_dai = { .ops = &siu_dai_ops, }; -static const struct snd_soc_component_driver siu_i2s_component = { - .name = "siu-i2s", -}; - static int siu_probe(struct platform_device *pdev) { const struct firmware *fw_entry; @@ -786,15 +782,11 @@ static int siu_probe(struct platform_device *pdev) dev_set_drvdata(&pdev->dev, info); /* register using ARRAY version so we can keep dai name */ - ret = devm_snd_soc_register_component(&pdev->dev, &siu_i2s_component, + ret = devm_snd_soc_register_component(&pdev->dev, &siu_component, &siu_i2s_dai, 1); if (ret < 0) return ret; - ret = devm_snd_soc_register_platform(&pdev->dev, &siu_platform); - if (ret < 0) - return ret; - pm_runtime_enable(&pdev->dev); return 0; diff --git a/sound/soc/sh/siu_pcm.c b/sound/soc/sh/siu_pcm.c index 3118cb0ee3f2..172909570ed5 100644 --- a/sound/soc/sh/siu_pcm.c +++ b/sound/soc/sh/siu_pcm.c @@ -35,6 +35,7 @@ #include "siu.h" +#define DRV_NAME "siu-i2s" #define GET_MAX_PERIODS(buf_bytes, period_bytes) \ ((buf_bytes) / (period_bytes)) #define PERIOD_OFFSET(buf_addr, period_num, period_bytes) \ @@ -340,7 +341,8 @@ static int siu_pcm_open(struct snd_pcm_substream *ss) { /* Playback / Capture */ struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct siu_platform *pdata = rtd->platform->dev->platform_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct siu_platform *pdata = component->dev->platform_data; struct siu_info *info = siu_i2s_data; struct siu_port *port_info = siu_port_info(ss); struct siu_stream *siu_stream; @@ -604,9 +606,10 @@ static const struct snd_pcm_ops siu_pcm_ops = { .pointer = siu_pcm_pointer_dma, }; -struct snd_soc_platform_driver siu_platform = { +struct snd_soc_component_driver siu_component = { + .name = DRV_NAME, .ops = &siu_pcm_ops, .pcm_new = siu_pcm_new, .pcm_free = siu_pcm_free, }; -EXPORT_SYMBOL_GPL(siu_platform); +EXPORT_SYMBOL_GPL(siu_component); From 6dea9df84aa2c2c1c645fac933adf1c4e0c20ac7 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:44:05 +0000 Subject: [PATCH 201/942] ASoC: atmel: replace platform to component Now platform can be replaced to component, let's do it. To avoid complex operation, this patch adds device pointer to atmel_classd. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-classd.c | 4 +++- sound/soc/atmel/atmel-pcm-pdc.c | 6 +++--- sound/soc/atmel/atmel-pdmic.c | 4 +++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index ebabed69f0e6..6bc2b729495c 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -32,6 +32,7 @@ struct atmel_classd { struct regmap *regmap; struct clk *pclk; struct clk *gclk; + struct device *dev; int irq; const struct atmel_classd_pdata *pdata; }; @@ -165,7 +166,7 @@ atmel_classd_platform_configure_dma(struct snd_pcm_substream *substream, struct atmel_classd *dd = snd_soc_card_get_drvdata(rtd->card); if (params_physical_width(params) != 16) { - dev_err(rtd->platform->dev, + dev_err(dd->dev, "only supports 16-bit audio data\n"); return -EINVAL; } @@ -587,6 +588,7 @@ static int atmel_classd_probe(struct platform_device *pdev) } dd->phy_base = res->start; + dd->dev = dev; dd->regmap = devm_regmap_init_mmio(dev, io_base, &atmel_classd_regmap_config); diff --git a/sound/soc/atmel/atmel-pcm-pdc.c b/sound/soc/atmel/atmel-pcm-pdc.c index 91b7069c3499..99ca23d527c9 100644 --- a/sound/soc/atmel/atmel-pcm-pdc.c +++ b/sound/soc/atmel/atmel-pcm-pdc.c @@ -393,7 +393,7 @@ static const struct snd_pcm_ops atmel_pcm_ops = { .mmap = atmel_pcm_mmap, }; -static struct snd_soc_platform_driver atmel_soc_platform = { +static struct snd_soc_component_driver atmel_soc_platform = { .ops = &atmel_pcm_ops, .pcm_new = atmel_pcm_new, .pcm_free = atmel_pcm_free, @@ -401,13 +401,13 @@ static struct snd_soc_platform_driver atmel_soc_platform = { int atmel_pcm_pdc_platform_register(struct device *dev) { - return snd_soc_register_platform(dev, &atmel_soc_platform); + return devm_snd_soc_register_component(dev, &atmel_soc_platform, + NULL, 0); } EXPORT_SYMBOL(atmel_pcm_pdc_platform_register); void atmel_pcm_pdc_platform_unregister(struct device *dev) { - snd_soc_unregister_platform(dev); } EXPORT_SYMBOL(atmel_pcm_pdc_platform_unregister); diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 8e3d34be9e69..4eea738c1047 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -32,6 +32,7 @@ struct atmel_pdmic { struct regmap *regmap; struct clk *pclk; struct clk *gclk; + struct device *dev; int irq; struct snd_pcm_substream *substream; const struct atmel_pdmic_pdata *pdata; @@ -206,7 +207,7 @@ atmel_pdmic_platform_configure_dma(struct snd_pcm_substream *substream, ret = snd_hwparams_to_dma_slave_config(substream, params, slave_config); if (ret) { - dev_err(rtd->platform->dev, + dev_err(dd->dev, "hw params to dma slave configure failed\n"); return ret; } @@ -596,6 +597,7 @@ static int atmel_pdmic_probe(struct platform_device *pdev) return -ENOMEM; dd->pdata = pdata; + dd->dev = dev; dd->irq = platform_get_irq(pdev, 0); if (dd->irq < 0) { From a1042a42bc5cc03969be40521c0e163be187ec8f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:44:23 +0000 Subject: [PATCH 202/942] ASoC: amd: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Mukunda,Vijendar Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index c33a512283a4..78d7b6238376 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -23,6 +23,8 @@ #include #include "acp.h" +#define DRV_NAME "acp_audio_dma" + #define PLAYBACK_MIN_NUM_PERIODS 2 #define PLAYBACK_MAX_NUM_PERIODS 2 #define PLAYBACK_MAX_PERIOD_SIZE 16384 @@ -702,8 +704,8 @@ static int acp_dma_open(struct snd_pcm_substream *substream) int ret = 0; struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *intr_data = dev_get_drvdata(prtd->platform->dev); - + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *intr_data = dev_get_drvdata(component->dev); struct audio_substream_data *adata = kzalloc(sizeof(struct audio_substream_data), GFP_KERNEL); if (adata == NULL) @@ -730,7 +732,7 @@ static int acp_dma_open(struct snd_pcm_substream *substream) ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) { - dev_err(prtd->platform->dev, "set integer constraint failed\n"); + dev_err(component->dev, "set integer constraint failed\n"); kfree(adata); return ret; } @@ -778,7 +780,8 @@ static int acp_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime; struct audio_substream_data *rtd; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); runtime = substream->runtime; rtd = runtime->private_data; @@ -907,6 +910,7 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *prtd = substream->private_data; struct audio_substream_data *rtd = runtime->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); if (!rtd) return -EINVAL; @@ -924,7 +928,7 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & BIT(SYSRAM_TO_ACP_CH_NUM)) { if (!loops--) { - dev_err(prtd->platform->dev, + dev_err(component->dev, "acp dma start timeout\n"); return -ETIMEDOUT; } @@ -970,7 +974,8 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) { int ret; - struct audio_drv_data *adata = dev_get_drvdata(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); switch (adata->asic_type) { case CHIP_STONEY: @@ -987,7 +992,7 @@ static int acp_dma_new(struct snd_soc_pcm_runtime *rtd) break; } if (ret < 0) - dev_err(rtd->platform->dev, + dev_err(component->dev, "buffer preallocation failer error:%d\n", ret); return ret; } @@ -998,7 +1003,8 @@ static int acp_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct audio_substream_data *rtd = runtime->private_data; struct snd_soc_pcm_runtime *prtd = substream->private_data; - struct audio_drv_data *adata = dev_get_drvdata(prtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(prtd, DRV_NAME); + struct audio_drv_data *adata = dev_get_drvdata(component->dev); kfree(rtd); @@ -1044,7 +1050,8 @@ static const struct snd_pcm_ops acp_dma_ops = { .prepare = acp_dma_prepare, }; -static struct snd_soc_platform_driver acp_asoc_platform = { +static struct snd_soc_component_driver acp_asoc_platform = { + .name = DRV_NAME, .ops = &acp_dma_ops, .pcm_new = acp_dma_new, }; @@ -1102,7 +1109,8 @@ static int acp_audio_probe(struct platform_device *pdev) return status; } - status = snd_soc_register_platform(&pdev->dev, &acp_asoc_platform); + status = devm_snd_soc_register_component(&pdev->dev, + &acp_asoc_platform, NULL, 0); if (status != 0) { dev_err(&pdev->dev, "Fail to register ALSA platform device\n"); return status; @@ -1123,7 +1131,6 @@ static int acp_audio_remove(struct platform_device *pdev) status = acp_deinit(adata->acp_mmio); if (status) dev_err(&pdev->dev, "ACP Deinit failed status:%d\n", status); - snd_soc_unregister_platform(&pdev->dev); pm_runtime_disable(&pdev->dev); return 0; From 48102b0426f6d134ebd9f2624d5d42d9e7a8a9fd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:44:44 +0000 Subject: [PATCH 203/942] ASoC: cs47l24: replace platform to component Now platform can be replaced to component, let's do it. This patch merges cs47l24_compr_platform into soc_codec_dev_cs47l24 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Tested-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/cs47l24.c | 42 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index be2750680838..3f34de5f800e 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -33,6 +33,8 @@ #include "wm_adsp.h" #include "cs47l24.h" +#define DRV_NAME "cs47l24-codec" + struct cs47l24_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -1069,7 +1071,8 @@ static struct snd_soc_dai_driver cs47l24_dai[] = { static int cs47l24_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct cs47l24_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int n_adsp; @@ -1177,6 +1180,16 @@ static unsigned int cs47l24_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_4L, }; +static struct snd_compr_ops cs47l24_compr_ops = { + .open = cs47l24_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .probe = cs47l24_codec_probe, .remove = cs47l24_codec_remove, @@ -1187,6 +1200,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { .set_pll = cs47l24_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &cs47l24_compr_ops, .controls = cs47l24_snd_controls, .num_controls = ARRAY_SIZE(cs47l24_snd_controls), .dapm_widgets = cs47l24_dapm_widgets, @@ -1196,20 +1211,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { }, }; -static const struct snd_compr_ops cs47l24_compr_ops = { - .open = cs47l24_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver cs47l24_compr_platform = { - .compr_ops = &cs47l24_compr_ops, -}; - static int cs47l24_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -1298,23 +1299,15 @@ static int cs47l24_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &cs47l24_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cs47l24, cs47l24_dai, ARRAY_SIZE(cs47l24_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -1328,7 +1321,6 @@ static int cs47l24_remove(struct platform_device *pdev) struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev); struct arizona *arizona = cs47l24->core.arizona; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); From 9fe3b2bac02c6d06724d526b0245568bca49349f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:45:13 +0000 Subject: [PATCH 204/942] ASoC: rt5514-spi: replace platform to component Now platform can be replaced to component, let's do it. This patch merges rt5514_spi_dai_component into rt5514_spi_component Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514-spi.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 2144edca97b0..84184d90385b 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -35,6 +35,8 @@ #include "rt5514-spi.h" +#define DRV_NAME "rt5514-spi" + static struct spi_device *rt5514_spi; struct rt5514_dsp { @@ -211,8 +213,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); int ret; u8 buf[8]; @@ -235,8 +238,9 @@ static int rt5514_spi_hw_params(struct snd_pcm_substream *substream, static int rt5514_spi_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); mutex_lock(&rt5514_dsp->dma_lock); rt5514_dsp->substream = NULL; @@ -252,8 +256,9 @@ static snd_pcm_uframes_t rt5514_spi_pcm_pointer( { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct rt5514_dsp *rt5514_dsp = - snd_soc_platform_get_drvdata(rtd->platform); + snd_soc_component_get_drvdata(component); return bytes_to_frames(runtime, rt5514_dsp->dma_offset); } @@ -267,18 +272,18 @@ static const struct snd_pcm_ops rt5514_spi_pcm_ops = { .page = snd_pcm_lib_get_vmalloc_page, }; -static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) +static int rt5514_spi_pcm_probe(struct snd_soc_component *component) { struct rt5514_dsp *rt5514_dsp; int ret; - rt5514_dsp = devm_kzalloc(platform->dev, sizeof(*rt5514_dsp), + rt5514_dsp = devm_kzalloc(component->dev, sizeof(*rt5514_dsp), GFP_KERNEL); rt5514_dsp->dev = &rt5514_spi->dev; mutex_init(&rt5514_dsp->dma_lock); INIT_DELAYED_WORK(&rt5514_dsp->copy_work, rt5514_spi_copy_work); - snd_soc_platform_set_drvdata(platform, rt5514_dsp); + snd_soc_component_set_drvdata(component, rt5514_dsp); if (rt5514_spi->irq) { ret = devm_request_threaded_irq(&rt5514_spi->dev, @@ -296,15 +301,12 @@ static int rt5514_spi_pcm_probe(struct snd_soc_platform *platform) return 0; } -static const struct snd_soc_platform_driver rt5514_spi_platform = { +static const struct snd_soc_component_driver rt5514_spi_component = { + .name = DRV_NAME, .probe = rt5514_spi_pcm_probe, .ops = &rt5514_spi_pcm_ops, }; -static const struct snd_soc_component_driver rt5514_spi_dai_component = { - .name = "rt5514-spi-dai", -}; - /** * rt5514_spi_burst_read - Read data from SPI by rt5514 address. * @addr: Start address. @@ -445,14 +447,8 @@ static int rt5514_spi_probe(struct spi_device *spi) rt5514_spi = spi; - ret = devm_snd_soc_register_platform(&spi->dev, &rt5514_spi_platform); - if (ret < 0) { - dev_err(&spi->dev, "Failed to register platform.\n"); - return ret; - } - ret = devm_snd_soc_register_component(&spi->dev, - &rt5514_spi_dai_component, + &rt5514_spi_component, &rt5514_spi_dai, 1); if (ret < 0) { dev_err(&spi->dev, "Failed to register component.\n"); From 0a2b051bf63916a5f567cbdbeb86b1da6e28c4d2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:45:30 +0000 Subject: [PATCH 205/942] ASoC: wm5110: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Tested-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5110.c | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index fb0cf9c61f48..d5ece6c6fcb6 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -35,6 +35,8 @@ #define WM5110_NUM_ADSP 4 +#define DRV_NAME "wm5110-codec" + struct wm5110_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -2229,7 +2231,8 @@ static struct snd_soc_dai_driver wm5110_dai[] = { static int wm5110_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct wm5110_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int n_adsp; @@ -2346,6 +2349,16 @@ static unsigned int wm5110_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_6R, }; +static struct snd_compr_ops wm5110_compr_ops = { + .open = wm5110_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .probe = wm5110_codec_probe, .remove = wm5110_codec_remove, @@ -2356,6 +2369,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { .set_pll = wm5110_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &wm5110_compr_ops, .controls = wm5110_snd_controls, .num_controls = ARRAY_SIZE(wm5110_snd_controls), .dapm_widgets = wm5110_dapm_widgets, @@ -2365,20 +2380,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { }, }; -static const struct snd_compr_ops wm5110_compr_ops = { - .open = wm5110_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver wm5110_compr_platform = { - .compr_ops = &wm5110_compr_ops, -}; - static int wm5110_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -2464,23 +2465,15 @@ static int wm5110_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &wm5110_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5110, wm5110_dai, ARRAY_SIZE(wm5110_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2495,7 +2488,6 @@ static int wm5110_remove(struct platform_device *pdev) struct arizona *arizona = wm5110->core.arizona; int i; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); From a20863256f88513b3ba97484179911c2b9aa5dfd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:45:48 +0000 Subject: [PATCH 206/942] ASoC: wm5102: replace platform to component Now platform can be replaced to component, let's do it. This patch merges wm5102_compr_platform into soc_codec_dev_wm5102 Signed-off-by: Kuninori Morimoto Acked-by: Charles Keepax Tested-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm5102.c | 42 ++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index fc066caa1918..a568050090ad 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -34,6 +34,8 @@ #include "wm5102.h" #include "wm_adsp.h" +#define DRV_NAME "wm5102-codec" + struct wm5102_priv { struct arizona_priv core; struct arizona_fll fll[2]; @@ -1910,7 +1912,8 @@ static struct snd_soc_dai_driver wm5102_dai[] = { static int wm5102_open(struct snd_compr_stream *stream) { struct snd_soc_pcm_runtime *rtd = stream->private_data; - struct wm5102_priv *priv = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct wm5102_priv *priv = snd_soc_component_get_drvdata(component); return wm_adsp_compr_open(&priv->core.adsp[0], stream); } @@ -1992,6 +1995,16 @@ static unsigned int wm5102_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; +static struct snd_compr_ops wm5102_compr_ops = { + .open = wm5102_open, + .free = wm_adsp_compr_free, + .set_params = wm_adsp_compr_set_params, + .get_caps = wm_adsp_compr_get_caps, + .trigger = wm_adsp_compr_trigger, + .pointer = wm_adsp_compr_pointer, + .copy = wm_adsp_compr_copy, +}; + static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .probe = wm5102_codec_probe, .remove = wm5102_codec_remove, @@ -2002,6 +2015,8 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { .set_pll = wm5102_set_fll, .component_driver = { + .name = DRV_NAME, + .compr_ops = &wm5102_compr_ops, .controls = wm5102_snd_controls, .num_controls = ARRAY_SIZE(wm5102_snd_controls), .dapm_widgets = wm5102_dapm_widgets, @@ -2011,20 +2026,6 @@ static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { }, }; -static const struct snd_compr_ops wm5102_compr_ops = { - .open = wm5102_open, - .free = wm_adsp_compr_free, - .set_params = wm_adsp_compr_set_params, - .get_caps = wm_adsp_compr_get_caps, - .trigger = wm_adsp_compr_trigger, - .pointer = wm_adsp_compr_pointer, - .copy = wm_adsp_compr_copy, -}; - -static const struct snd_soc_platform_driver wm5102_compr_platform = { - .compr_ops = &wm5102_compr_ops, -}; - static int wm5102_probe(struct platform_device *pdev) { struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); @@ -2109,23 +2110,15 @@ static int wm5102_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_platform(&pdev->dev, &wm5102_compr_platform); - if (ret < 0) { - dev_err(&pdev->dev, "Failed to register platform: %d\n", ret); - goto err_spk_irqs; - } - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, wm5102_dai, ARRAY_SIZE(wm5102_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); - goto err_platform; + goto err_spk_irqs; } return ret; -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_spk_irqs: arizona_free_spk_irqs(arizona); err_dsp_irq: @@ -2139,7 +2132,6 @@ static int wm5102_remove(struct platform_device *pdev) struct wm5102_priv *wm5102 = platform_get_drvdata(pdev); struct arizona *arizona = wm5102->core.arizona; - snd_soc_unregister_platform(&pdev->dev); snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); From a49cb31cc7c84eab032c790df476f57ad14c8eeb Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:46:04 +0000 Subject: [PATCH 207/942] ASoC: davinci-i2s: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/davinci/davinci-i2s.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sound/soc/davinci/davinci-i2s.c b/sound/soc/davinci/davinci-i2s.c index 384961651904..807040bb3921 100644 --- a/sound/soc/davinci/davinci-i2s.c +++ b/sound/soc/davinci/davinci-i2s.c @@ -34,6 +34,7 @@ #include "edma-pcm.h" #include "davinci-i2s.h" +#define DRV_NAME "davinci-i2s" /* * NOTE: terminology here is confusing. @@ -190,7 +191,7 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_platform *platform = rtd->platform; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); int playback = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); u32 spcr; u32 mask = playback ? DAVINCI_MCBSP_SPCR_XRST : DAVINCI_MCBSP_SPCR_RRST; @@ -211,8 +212,8 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, if (playback) { /* Stop the DMA to avoid data loss */ /* while the transmitter is out of reset to handle XSYNCERR */ - if (platform->driver->ops->trigger) { - int ret = platform->driver->ops->trigger(substream, + if (component->driver->ops->trigger) { + int ret = component->driver->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); if (ret < 0) printk(KERN_DEBUG "Playback DMA stop failed\n"); @@ -233,8 +234,8 @@ static void davinci_mcbsp_start(struct davinci_mcbsp_dev *dev, toggle_clock(dev, playback); /* Restart the DMA */ - if (platform->driver->ops->trigger) { - int ret = platform->driver->ops->trigger(substream, + if (component->driver->ops->trigger) { + int ret = component->driver->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); if (ret < 0) printk(KERN_DEBUG "Playback DMA start failed\n"); @@ -651,7 +652,7 @@ static struct snd_soc_dai_driver davinci_i2s_dai = { }; static const struct snd_soc_component_driver davinci_i2s_component = { - .name = "davinci-i2s", + .name = DRV_NAME, }; static int davinci_i2s_probe(struct platform_device *pdev) From 4cb1ea925e66a2a04bcaf880f62bce425ddb9f94 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:46:22 +0000 Subject: [PATCH 208/942] ASoC: fsl: dma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_dma.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sound/soc/fsl/fsl_dma.c b/sound/soc/fsl/fsl_dma.c index 8c2981b70f64..fce2010d3c53 100644 --- a/sound/soc/fsl/fsl_dma.c +++ b/sound/soc/fsl/fsl_dma.c @@ -37,6 +37,8 @@ #include "fsl_dma.h" #include "fsl_ssi.h" /* For the offset of stx0 and srx0 */ +#define DRV_NAME "fsl_dma" + /* * The formats that the DMA controller supports, which is anything * that is 8, 16, or 32 bits. @@ -56,7 +58,7 @@ SNDRV_PCM_FMTBIT_U32_LE | \ SNDRV_PCM_FMTBIT_U32_BE) struct dma_object { - struct snd_soc_platform_driver dai; + struct snd_soc_component_driver dai; dma_addr_t ssi_stx_phys; dma_addr_t ssi_srx_phys; unsigned int ssi_fifo_depth; @@ -203,7 +205,8 @@ static irqreturn_t fsl_dma_isr(int irq, void *dev_id) struct fsl_dma_private *dma_private = dev_id; struct snd_pcm_substream *substream = dma_private->substream; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; irqreturn_t ret = IRQ_NONE; u32 sr, sr2 = 0; @@ -385,9 +388,10 @@ static int fsl_dma_open(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct dma_object *dma = - container_of(rtd->platform->driver, struct dma_object, dai); + container_of(component->driver, struct dma_object, dai); struct fsl_dma_private *dma_private; struct ccsr_dma_channel __iomem *dma_channel; dma_addr_t ld_buf_phys; @@ -539,7 +543,8 @@ static int fsl_dma_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; /* Number of bits per sample */ unsigned int sample_bits = @@ -702,7 +707,8 @@ static snd_pcm_uframes_t fsl_dma_pointer(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct ccsr_dma_channel __iomem *dma_channel = dma_private->dma_channel; dma_addr_t position; snd_pcm_uframes_t frames; @@ -799,9 +805,10 @@ static int fsl_dma_close(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_dma_private *dma_private = runtime->private_data; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct dma_object *dma = - container_of(rtd->platform->driver, struct dma_object, dai); + container_of(component->driver, struct dma_object, dai); if (dma_private) { if (dma_private->irq) @@ -908,6 +915,7 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) return -ENOMEM; } + dma->dai.name = DRV_NAME; dma->dai.ops = &fsl_dma_ops; dma->dai.pcm_new = fsl_dma_new; dma->dai.pcm_free = fsl_dma_free_dma_buffers; @@ -925,7 +933,7 @@ static int fsl_soc_dma_probe(struct platform_device *pdev) of_node_put(ssi_np); - ret = snd_soc_register_platform(&pdev->dev, &dma->dai); + ret = devm_snd_soc_register_component(&pdev->dev, &dma->dai, NULL, 0); if (ret) { dev_err(&pdev->dev, "could not register platform\n"); kfree(dma); @@ -944,7 +952,6 @@ static int fsl_soc_dma_remove(struct platform_device *pdev) { struct dma_object *dma = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); iounmap(dma->channel); irq_dispose_mapping(dma->irq); kfree(dma); From 7f1106616ab634c6b827ce7abf1331a2a817de40 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:46:46 +0000 Subject: [PATCH 209/942] ASoC: fsl: asrc: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Nicolin Chen Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_asrc.c | 10 ---------- sound/soc/fsl/fsl_asrc.h | 3 ++- sound/soc/fsl/fsl_asrc_dma.c | 14 +++++++++----- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 806d39927318..adfb8135d739 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -582,10 +582,6 @@ static struct snd_soc_dai_driver fsl_asrc_dai = { .ops = &fsl_asrc_dai_ops, }; -static const struct snd_soc_component_driver fsl_asrc_component = { - .name = "fsl-asrc-dai", -}; - static bool fsl_asrc_readable_reg(struct device *dev, unsigned int reg) { switch (reg) { @@ -927,12 +923,6 @@ static int fsl_asrc_probe(struct platform_device *pdev) return ret; } - ret = devm_snd_soc_register_platform(&pdev->dev, &fsl_asrc_platform); - if (ret) { - dev_err(&pdev->dev, "failed to register ASoC platform\n"); - return ret; - } - return 0; } diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h index 2c5856ac5bc3..d558dd5499a5 100644 --- a/sound/soc/fsl/fsl_asrc.h +++ b/sound/soc/fsl/fsl_asrc.h @@ -462,6 +462,7 @@ struct fsl_asrc { u32 regcache_cfg; }; -extern struct snd_soc_platform_driver fsl_asrc_platform; +#define DRV_NAME "fsl-asrc-dai" +extern struct snd_soc_component_driver fsl_asrc_component; struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir); #endif /* _FSL_ASRC_H */ diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c index e1b97e59275a..565e16d8fe85 100644 --- a/sound/soc/fsl/fsl_asrc_dma.c +++ b/sound/soc/fsl/fsl_asrc_dma.c @@ -64,7 +64,8 @@ static int fsl_asrc_dma_prepare_and_submit(struct snd_pcm_substream *substream) struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_asrc_pair *pair = runtime->private_data; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; unsigned long flags = DMA_CTRL_ACK; /* Prepare and submit Front-End DMA channel */ @@ -137,12 +138,13 @@ static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream, bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct snd_dmaengine_dai_dma_data *dma_params_fe = NULL; struct snd_dmaengine_dai_dma_data *dma_params_be = NULL; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_pcm_runtime *runtime = substream->runtime; struct fsl_asrc_pair *pair = runtime->private_data; struct fsl_asrc *asrc_priv = pair->asrc_priv; struct dma_slave_config config_fe, config_be; enum asrc_pair_index index = pair->index; - struct device *dev = rtd->platform->dev; + struct device *dev = component->dev; int stream = substream->stream; struct imx_dma_data *tmp_data; struct snd_soc_dpcm *dpcm; @@ -274,7 +276,8 @@ static int fsl_asrc_dma_startup(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime *runtime = substream->runtime; - struct device *dev = rtd->platform->dev; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct device *dev = component->dev; struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); struct fsl_asrc_pair *pair; @@ -381,9 +384,10 @@ static void fsl_asrc_dma_pcm_free(struct snd_pcm *pcm) } } -struct snd_soc_platform_driver fsl_asrc_platform = { +struct snd_soc_component_driver fsl_asrc_component = { + .name = DRV_NAME, .ops = &fsl_asrc_dma_pcm_ops, .pcm_new = fsl_asrc_dma_pcm_new, .pcm_free = fsl_asrc_dma_pcm_free, }; -EXPORT_SYMBOL_GPL(fsl_asrc_platform); +EXPORT_SYMBOL_GPL(fsl_asrc_component); From 1d0a01f2d4051bc62ba5e0d73ed99272414045ba Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:47:02 +0000 Subject: [PATCH 210/942] ASoC: fsl: imx: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/fsl/imx-pcm-fiq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/imx-pcm-fiq.c b/sound/soc/fsl/imx-pcm-fiq.c index 4e5fefee111e..0578f3486847 100644 --- a/sound/soc/fsl/imx-pcm-fiq.c +++ b/sound/soc/fsl/imx-pcm-fiq.c @@ -341,7 +341,7 @@ static void imx_pcm_fiq_free(struct snd_pcm *pcm) imx_pcm_free(pcm); } -static const struct snd_soc_platform_driver imx_soc_platform_fiq = { +static const struct snd_soc_component_driver imx_soc_component_fiq = { .ops = &imx_pcm_ops, .pcm_new = imx_pcm_fiq_new, .pcm_free = imx_pcm_fiq_free, @@ -368,7 +368,8 @@ int imx_pcm_fiq_init(struct platform_device *pdev, params->dma_params_tx->maxburst = 4; params->dma_params_rx->maxburst = 6; - ret = snd_soc_register_platform(&pdev->dev, &imx_soc_platform_fiq); + ret = devm_snd_soc_register_component(&pdev->dev, &imx_soc_component_fiq, + NULL, 0); if (ret) goto failed_register; @@ -384,7 +385,6 @@ EXPORT_SYMBOL_GPL(imx_pcm_fiq_init); void imx_pcm_fiq_exit(struct platform_device *pdev) { - snd_soc_unregister_platform(&pdev->dev); } EXPORT_SYMBOL_GPL(imx_pcm_fiq_exit); From 60bceb8029e26c49549a276d5d67198cdfb57b5d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:47:19 +0000 Subject: [PATCH 211/942] ASoC: fsl: mpc5200: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/fsl/mpc5200_dma.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/mpc5200_dma.c b/sound/soc/fsl/mpc5200_dma.c index e63029f1aabc..c1a4544eb16b 100644 --- a/sound/soc/fsl/mpc5200_dma.c +++ b/sound/soc/fsl/mpc5200_dma.c @@ -22,6 +22,8 @@ #include "mpc5200_dma.h" +#define DRV_NAME "mpc5200_dma" + /* * Interrupt handlers */ @@ -300,12 +302,13 @@ static const struct snd_pcm_ops psc_dma_ops = { static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) { struct snd_card *card = rtd->card->snd_card; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; size_t size = psc_dma_hardware.buffer_bytes_max; int rc; - dev_dbg(rtd->platform->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", + dev_dbg(component->dev, "psc_dma_new(card=%p, dai=%p, pcm=%p)\n", card, dai, pcm); rc = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); @@ -341,10 +344,11 @@ static int psc_dma_new(struct snd_soc_pcm_runtime *rtd) static void psc_dma_free(struct snd_pcm *pcm) { struct snd_soc_pcm_runtime *rtd = pcm->private_data; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct snd_pcm_substream *substream; int stream; - dev_dbg(rtd->platform->dev, "psc_dma_free(pcm=%p)\n", pcm); + dev_dbg(component->dev, "psc_dma_free(pcm=%p)\n", pcm); for (stream = 0; stream < 2; stream++) { substream = pcm->streams[stream].substream; @@ -356,7 +360,8 @@ static void psc_dma_free(struct snd_pcm *pcm) } } -static const struct snd_soc_platform_driver mpc5200_audio_dma_platform = { +static const struct snd_soc_component_driver mpc5200_audio_dma_component = { + .name = DRV_NAME, .ops = &psc_dma_ops, .pcm_new = &psc_dma_new, .pcm_free = &psc_dma_free, @@ -468,7 +473,8 @@ int mpc5200_audio_dma_create(struct platform_device *op) dev_set_drvdata(&op->dev, psc_dma); /* Tell the ASoC OF helpers about it */ - return snd_soc_register_platform(&op->dev, &mpc5200_audio_dma_platform); + return devm_snd_soc_register_component(&op->dev, + &mpc5200_audio_dma_component, NULL, 0); out_irq: free_irq(psc_dma->irq, psc_dma); free_irq(psc_dma->capture.irq, &psc_dma->capture); @@ -487,8 +493,6 @@ int mpc5200_audio_dma_destroy(struct platform_device *op) dev_dbg(&op->dev, "mpc5200_audio_dma_destroy()\n"); - snd_soc_unregister_platform(&op->dev); - bcom_gen_bd_rx_release(psc_dma->capture.bcom_task); bcom_gen_bd_tx_release(psc_dma->playback.bcom_task); From ddce03ceea3c84bbfca6f465853b543b32184ec2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:47:38 +0000 Subject: [PATCH 212/942] ASoC: dwc-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/dwc/dwc-pcm.c b/sound/soc/dwc/dwc-pcm.c index 406fd867117b..2cc9632024fc 100644 --- a/sound/soc/dwc/dwc-pcm.c +++ b/sound/soc/dwc/dwc-pcm.c @@ -269,7 +269,7 @@ static const struct snd_pcm_ops dw_pcm_ops = { .pointer = dw_pcm_pointer, }; -static const struct snd_soc_platform_driver dw_pcm_platform = { +static const struct snd_soc_component_driver dw_pcm_component = { .pcm_new = dw_pcm_new, .pcm_free = dw_pcm_free, .ops = &dw_pcm_ops, @@ -277,5 +277,6 @@ static const struct snd_soc_platform_driver dw_pcm_platform = { int dw_pcm_register(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &dw_pcm_platform); + return devm_snd_soc_register_component(&pdev->dev, &dw_pcm_component, + NULL, 0); } From f98fc0f8154ed17a00a588f1a95f02cb3e33b0d0 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:03 +0000 Subject: [PATCH 213/942] ASoC: kirkwood: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/kirkwood/kirkwood-dma.c | 3 ++- sound/soc/kirkwood/kirkwood-i2s.c | 20 ++------------------ sound/soc/kirkwood/kirkwood.h | 4 +++- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index 505b0ff03c3b..c6a58520d377 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c @@ -318,7 +318,8 @@ static void kirkwood_dma_free_dma_buffers(struct snd_pcm *pcm) } } -const struct snd_soc_platform_driver kirkwood_soc_platform = { +const struct snd_soc_component_driver kirkwood_soc_component = { + .name = DRV_NAME, .ops = &kirkwood_dma_ops, .pcm_new = kirkwood_dma_new, .pcm_free = kirkwood_dma_free_dma_buffers, diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 105a73cc5158..9a2777b72dcd 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c @@ -26,8 +26,6 @@ #include "kirkwood.h" -#define DRV_NAME "mvebu-audio" - #define KIRKWOOD_I2S_FORMATS \ (SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | \ @@ -524,10 +522,6 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { }, }; -static const struct snd_soc_component_driver kirkwood_i2s_component = { - .name = DRV_NAME, -}; - static int kirkwood_i2s_dev_probe(struct platform_device *pdev) { struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; @@ -601,24 +595,17 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) priv->ctl_rec |= KIRKWOOD_RECCTL_BURST_128; } - err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, + err = devm_snd_soc_register_component(&pdev->dev, &kirkwood_soc_component, soc_dai, 2); if (err) { dev_err(&pdev->dev, "snd_soc_register_component failed\n"); goto err_component; } - err = snd_soc_register_platform(&pdev->dev, &kirkwood_soc_platform); - if (err) { - dev_err(&pdev->dev, "snd_soc_register_platform failed\n"); - goto err_platform; - } - kirkwood_i2s_init(priv); return 0; - err_platform: - snd_soc_unregister_component(&pdev->dev); + err_component: if (!IS_ERR(priv->extclk)) clk_disable_unprepare(priv->extclk); @@ -631,9 +618,6 @@ static int kirkwood_i2s_dev_remove(struct platform_device *pdev) { struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - if (!IS_ERR(priv->extclk)) clk_disable_unprepare(priv->extclk); clk_disable_unprepare(priv->clk); diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index 783cb1a4f30e..c13ee5f69446 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h @@ -12,6 +12,8 @@ #ifndef _KIRKWOOD_AUDIO_H #define _KIRKWOOD_AUDIO_H +#define DRV_NAME "mvebu-audio" + #define KIRKWOOD_RECORD_WIN 0 #define KIRKWOOD_PLAYBACK_WIN 1 #define KIRKWOOD_MAX_AUDIO_WIN 2 @@ -143,6 +145,6 @@ struct kirkwood_dma_data { int burst; }; -extern const struct snd_soc_platform_driver kirkwood_soc_platform; +extern const struct snd_soc_component_driver kirkwood_soc_component; #endif From 797d16971a2a4fc3aafc4e5ff13c7ebfae4bf91b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:18 +0000 Subject: [PATCH 214/942] ASoC: pxa: mmp: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-pcm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sound/soc/pxa/mmp-pcm.c b/sound/soc/pxa/mmp-pcm.c index 624d9bd5dadd..d2d4652de32c 100644 --- a/sound/soc/pxa/mmp-pcm.c +++ b/sound/soc/pxa/mmp-pcm.c @@ -25,6 +25,8 @@ #include #include +#define DRV_NAME "mmp-pcm" + struct mmp_dma_data { int ssp_id; struct resource *dma_res; @@ -100,7 +102,8 @@ static bool filter(struct dma_chan *chan, void *param) static int mmp_pcm_open(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct platform_device *pdev = to_platform_device(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct platform_device *pdev = to_platform_device(component->dev); struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct mmp_dma_data dma_data; struct resource *r; @@ -211,7 +214,8 @@ err: return ret; } -static const struct snd_soc_platform_driver mmp_soc_platform = { +static const struct snd_soc_component_driver mmp_soc_component = { + .name = DRV_NAME, .ops = &mmp_pcm_ops, .pcm_new = mmp_pcm_new, .pcm_free = mmp_pcm_free_dma_buffers, @@ -231,7 +235,8 @@ static int mmp_pcm_probe(struct platform_device *pdev) mmp_pcm_hardware[SNDRV_PCM_STREAM_CAPTURE].period_bytes_max = pdata->period_max_capture; } - return devm_snd_soc_register_platform(&pdev->dev, &mmp_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &mmp_soc_component, + NULL, 0); } static struct platform_driver mmp_pcm_driver = { From 0717e66f404123be9c58d8a6559e975acc17fcdd Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:35 +0000 Subject: [PATCH 215/942] ASoC: pxa: pxa2xx: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/pxa/pxa2xx-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/pxa/pxa2xx-pcm.c b/sound/soc/pxa/pxa2xx-pcm.c index e64958d8bff0..8b6a70e94c01 100644 --- a/sound/soc/pxa/pxa2xx-pcm.c +++ b/sound/soc/pxa/pxa2xx-pcm.c @@ -84,7 +84,7 @@ static int pxa2xx_soc_pcm_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static const struct snd_soc_platform_driver pxa2xx_soc_platform = { +static const struct snd_soc_component_driver pxa2xx_soc_platform = { .ops = &pxa2xx_pcm_ops, .pcm_new = pxa2xx_soc_pcm_new, .pcm_free = pxa2xx_pcm_free_dma_buffers, @@ -92,7 +92,8 @@ static const struct snd_soc_platform_driver pxa2xx_soc_platform = { static int pxa2xx_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &pxa2xx_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &pxa2xx_soc_platform, + NULL, 0); } #ifdef CONFIG_OF From 121de3b4bee60a817aee2e61df26108ccd6dd6c6 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:48:52 +0000 Subject: [PATCH 216/942] ASoC: qcom: lpass-platform: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/qcom/lpass-platform.c | 42 ++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/sound/soc/qcom/lpass-platform.c b/sound/soc/qcom/lpass-platform.c index caf71aab8196..31fe78aa207f 100644 --- a/sound/soc/qcom/lpass-platform.c +++ b/sound/soc/qcom/lpass-platform.c @@ -24,6 +24,8 @@ #include "lpass-lpaif-reg.h" #include "lpass.h" +#define DRV_NAME "lpass-platform" + struct lpass_pcm_data { int dma_ch; int i2s_port; @@ -61,8 +63,8 @@ static int lpass_platform_pcmops_open(struct snd_pcm_substream *substream) struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; struct snd_soc_dai *cpu_dai = soc_runtime->cpu_dai; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct lpass_variant *v = drvdata->variant; int ret, dma_ch, dir = substream->stream; struct lpass_pcm_data *data; @@ -115,8 +117,8 @@ static int lpass_platform_pcmops_close(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct lpass_variant *v = drvdata->variant; struct lpass_pcm_data *data; @@ -132,8 +134,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -225,8 +227,8 @@ static int lpass_platform_pcmops_hw_params(struct snd_pcm_substream *substream, static int lpass_platform_pcmops_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -246,8 +248,8 @@ static int lpass_platform_pcmops_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -298,8 +300,8 @@ static int lpass_platform_pcmops_trigger(struct snd_pcm_substream *substream, int cmd) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -372,8 +374,8 @@ static snd_pcm_uframes_t lpass_platform_pcmops_pointer( struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *soc_runtime = substream->private_data; - struct lpass_data *drvdata = - snd_soc_platform_get_drvdata(soc_runtime->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); + struct lpass_data *drvdata = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *rt = substream->runtime; struct lpass_pcm_data *pcm_data = rt->private_data; struct lpass_variant *v = drvdata->variant; @@ -509,13 +511,14 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) { struct snd_pcm *pcm = soc_runtime->pcm; struct snd_pcm_substream *psubstream, *csubstream; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(soc_runtime, DRV_NAME); int ret = -EINVAL; size_t size = lpass_platform_pcm_hardware.buffer_bytes_max; psubstream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; if (psubstream) { ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - soc_runtime->platform->dev, + component->dev, size, &psubstream->dma_buffer); if (ret) { dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); @@ -526,7 +529,7 @@ static int lpass_platform_pcm_new(struct snd_soc_pcm_runtime *soc_runtime) csubstream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; if (csubstream) { ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, - soc_runtime->platform->dev, + component->dev, size, &csubstream->dma_buffer); if (ret) { dev_err(soc_runtime->dev, "Cannot allocate buffer(s)\n"); @@ -555,7 +558,8 @@ static void lpass_platform_pcm_free(struct snd_pcm *pcm) } } -static const struct snd_soc_platform_driver lpass_platform_driver = { +static const struct snd_soc_component_driver lpass_component_driver = { + .name = DRV_NAME, .pcm_new = lpass_platform_pcm_new, .pcm_free = lpass_platform_pcm_free, .ops = &lpass_platform_pcm_ops, @@ -591,8 +595,8 @@ int asoc_qcom_lpass_platform_register(struct platform_device *pdev) } - return devm_snd_soc_register_platform(&pdev->dev, - &lpass_platform_driver); + return devm_snd_soc_register_component(&pdev->dev, + &lpass_component_driver, NULL, 0); } EXPORT_SYMBOL_GPL(asoc_qcom_lpass_platform_register); From 17d619da7b4e6ee2b5b54a9e3e321679963afa4d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:49:08 +0000 Subject: [PATCH 217/942] ASoC: samsung: idma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/samsung/idma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index a635df61f928..b1f09b942410 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c @@ -399,7 +399,7 @@ void idma_reg_addr_init(void __iomem *regs, dma_addr_t addr) } EXPORT_SYMBOL_GPL(idma_reg_addr_init); -static const struct snd_soc_platform_driver asoc_idma_platform = { +static const struct snd_soc_component_driver asoc_idma_platform = { .ops = &idma_ops, .pcm_new = idma_new, .pcm_free = idma_free, @@ -411,7 +411,8 @@ static int asoc_idma_platform_probe(struct platform_device *pdev) if (idma_irq < 0) return idma_irq; - return devm_snd_soc_register_platform(&pdev->dev, &asoc_idma_platform); + return devm_snd_soc_register_component(&pdev->dev, &asoc_idma_platform, + NULL, 0); } static struct platform_driver asoc_idma_driver = { From 80f23c295b0bb64a65cd19aa5f09104d21bfa165 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:49:25 +0000 Subject: [PATCH 218/942] ASoC: xtfpga-i2s: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/xtensa/xtfpga-i2s.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/sound/soc/xtensa/xtfpga-i2s.c b/sound/soc/xtensa/xtfpga-i2s.c index 2472144b329e..503560916620 100644 --- a/sound/soc/xtensa/xtfpga-i2s.c +++ b/sound/soc/xtensa/xtfpga-i2s.c @@ -483,13 +483,10 @@ static const struct snd_pcm_ops xtfpga_pcm_ops = { .pointer = xtfpga_pcm_pointer, }; -static const struct snd_soc_platform_driver xtfpga_soc_platform = { - .pcm_new = xtfpga_pcm_new, - .ops = &xtfpga_pcm_ops, -}; - static const struct snd_soc_component_driver xtfpga_i2s_component = { .name = DRV_NAME, + .pcm_new = xtfpga_pcm_new, + .ops = &xtfpga_pcm_ops, }; static const struct snd_soc_dai_ops xtfpga_i2s_dai_ops = { @@ -591,18 +588,13 @@ static int xtfpga_i2s_probe(struct platform_device *pdev) goto err; } - err = snd_soc_register_platform(&pdev->dev, &xtfpga_soc_platform); - if (err < 0) { - dev_err(&pdev->dev, "couldn't register platform\n"); - goto err; - } err = devm_snd_soc_register_component(&pdev->dev, &xtfpga_i2s_component, xtfpga_i2s_dai, ARRAY_SIZE(xtfpga_i2s_dai)); if (err < 0) { dev_err(&pdev->dev, "couldn't register component\n"); - goto err_unregister_platform; + goto err; } pm_runtime_enable(&pdev->dev); @@ -615,8 +607,6 @@ static int xtfpga_i2s_probe(struct platform_device *pdev) err_pm_disable: pm_runtime_disable(&pdev->dev); -err_unregister_platform: - snd_soc_unregister_platform(&pdev->dev); err: dev_err(&pdev->dev, "%s: err = %d\n", __func__, err); return err; @@ -626,7 +616,6 @@ static int xtfpga_i2s_remove(struct platform_device *pdev) { struct xtfpga_i2s *i2s = dev_get_drvdata(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); if (i2s->regmap && !IS_ERR(i2s->regmap)) { regmap_write(i2s->regmap, XTFPGA_I2S_CONFIG, 0); regmap_write(i2s->regmap, XTFPGA_I2S_INT_MASK, 0); From 825f90183bdb6cf02a818a699137191806e088a2 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:49:43 +0000 Subject: [PATCH 219/942] ASoC: blackfin: bf5xx-ac97-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-ac97-pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c index 8c1d1983b8f9..08bceb519c29 100644 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ b/sound/soc/blackfin/bf5xx-ac97-pcm.c @@ -453,7 +453,7 @@ static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd) return ret; } -static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = { +static struct snd_soc_component_driver bf5xx_ac97_soc_component = { .ops = &bf5xx_pcm_ac97_ops, .pcm_new = bf5xx_pcm_ac97_new, .pcm_free = bf5xx_pcm_free_dma_buffers, @@ -461,8 +461,8 @@ static struct snd_soc_platform_driver bf5xx_ac97_soc_platform = { static int bf5xx_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &bf5xx_ac97_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &bf5xx_ac97_soc_component, NULL, 0); } static struct platform_driver bf5xx_pcm_driver = { From abd5ef092aeec03e5c3ce8b20945c6df634b3726 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:02 +0000 Subject: [PATCH 220/942] ASoC: blackfin: bf5xx-i2s-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/blackfin/bf5xx-i2s-pcm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index 51cae76f14e6..6712b01dabd1 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c @@ -347,15 +347,15 @@ static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd) SNDRV_DMA_TYPE_DEV, card->dev, size, size); } -static struct snd_soc_platform_driver bf5xx_i2s_soc_platform = { +static struct snd_soc_component_driver bf5xx_i2s_soc_component = { .ops = &bf5xx_pcm_i2s_ops, .pcm_new = bf5xx_pcm_i2s_new, }; static int bfin_i2s_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &bf5xx_i2s_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &bf5xx_i2s_soc_component, NULL, 0); } static struct platform_driver bfin_i2s_pcm_driver = { From 703c13e447f84a7ed8315938719540ea05ad5045 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:19 +0000 Subject: [PATCH 221/942] ASoC: omap-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/omap/omap-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index aca2c43d0f03..778cc8f75b6a 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c @@ -243,7 +243,7 @@ out: return ret; } -static const struct snd_soc_platform_driver omap_soc_platform = { +static const struct snd_soc_component_driver omap_soc_component = { .ops = &omap_pcm_ops, .pcm_new = omap_pcm_new, .pcm_free = omap_pcm_free_dma_buffers, @@ -252,7 +252,8 @@ static const struct snd_soc_platform_driver omap_soc_platform = { int omap_pcm_platform_register(struct device *dev) { omap_pcm_limit_supported_formats(); - return devm_snd_soc_register_platform(dev, &omap_soc_platform); + return devm_snd_soc_register_component(dev, &omap_soc_component, + NULL, 0); } EXPORT_SYMBOL_GPL(omap_pcm_platform_register); From abf33c7a536f97b78cce6d016768af2253810a15 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:37 +0000 Subject: [PATCH 222/942] ASoC: au1x: dbdma2: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/au1x/dbdma2.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 6a035ca0f521..fb650659c3a3 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -32,6 +32,8 @@ /*#define PCM_DEBUG*/ +#define DRV_NAME "dbdma2" + #define MSG(x...) printk(KERN_INFO "au1xpsc_pcm: " x) #ifdef PCM_DEBUG #define DBG MSG @@ -187,8 +189,8 @@ out: static inline struct au1xpsc_audio_dmadata *to_dmadata(struct snd_pcm_substream *ss) { struct snd_soc_pcm_runtime *rtd = ss->private_data; - struct au1xpsc_audio_dmadata *pcd = - snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct au1xpsc_audio_dmadata *pcd = snd_soc_component_get_drvdata(component); return &pcd[ss->stream]; } @@ -327,7 +329,8 @@ static int au1xpsc_pcm_new(struct snd_soc_pcm_runtime *rtd) } /* au1xpsc audio platform */ -static struct snd_soc_platform_driver au1xpsc_soc_platform = { +static struct snd_soc_component_driver au1xpsc_soc_component = { + .name = DRV_NAME, .ops = &au1xpsc_pcm_ops, .pcm_new = au1xpsc_pcm_new, }; @@ -344,8 +347,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) platform_set_drvdata(pdev, dmadata); - return devm_snd_soc_register_platform(&pdev->dev, - &au1xpsc_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &au1xpsc_soc_component, NULL, 0); } static struct platform_driver au1xpsc_pcm_driver = { From 781a9fcccae535d3f46cd05177366c7e67aa01ef Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:50:54 +0000 Subject: [PATCH 223/942] ASoC: au1x: dma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/au1x/dma.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/au1x/dma.c b/sound/soc/au1x/dma.c index 19457e2b351e..efff1e293a1b 100644 --- a/sound/soc/au1x/dma.c +++ b/sound/soc/au1x/dma.c @@ -21,6 +21,8 @@ #include "psc.h" +#define DRV_NAME "au1x_dma" + struct pcm_period { u32 start; u32 relative_end; /* relative to start of buffer */ @@ -174,7 +176,8 @@ static const struct snd_pcm_hardware alchemy_pcm_hardware = { static inline struct alchemy_pcm_ctx *ss_to_ctx(struct snd_pcm_substream *ss) { struct snd_soc_pcm_runtime *rtd = ss->private_data; - return snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + return snd_soc_component_get_drvdata(component); } static inline struct audio_stream *ss_to_as(struct snd_pcm_substream *ss) @@ -297,7 +300,8 @@ static int alchemy_pcm_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static struct snd_soc_platform_driver alchemy_pcm_soc_platform = { +static struct snd_soc_component_driver alchemy_pcm_soc_component = { + .name = DRV_NAME, .ops = &alchemy_pcm_ops, .pcm_new = alchemy_pcm_new, }; @@ -312,8 +316,8 @@ static int alchemy_pcm_drvprobe(struct platform_device *pdev) platform_set_drvdata(pdev, ctx); - return devm_snd_soc_register_platform(&pdev->dev, - &alchemy_pcm_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &alchemy_pcm_soc_component, NULL, 0); } static struct platform_driver alchemy_pcmdma_driver = { From bab9dc53d5bfbfa057e02c5edd97787829ee0b31 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:09 +0000 Subject: [PATCH 224/942] ASoC: nuc900-pcm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/nuc900/nuc900-pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/nuc900/nuc900-pcm.c b/sound/soc/nuc900/nuc900-pcm.c index bd6dfa218d59..ad8392a87df9 100644 --- a/sound/soc/nuc900/nuc900-pcm.c +++ b/sound/soc/nuc900/nuc900-pcm.c @@ -299,14 +299,15 @@ static int nuc900_dma_new(struct snd_soc_pcm_runtime *rtd) return 0; } -static const struct snd_soc_platform_driver nuc900_soc_platform = { +static const struct snd_soc_component_driver nuc900_soc_component = { .ops = &nuc900_dma_ops, .pcm_new = nuc900_dma_new, }; static int nuc900_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, &nuc900_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, &nuc900_soc_component, + NULL, 0); } static struct platform_driver nuc900_pcm_driver = { From e049cf4e6adcb14e34c37123a67158a7e671d000 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:26 +0000 Subject: [PATCH 225/942] ASoC: txx9aclc: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/txx9/txx9aclc.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/sound/soc/txx9/txx9aclc.c b/sound/soc/txx9/txx9aclc.c index a2bb68fea5a3..8d31fe628e2f 100644 --- a/sound/soc/txx9/txx9aclc.c +++ b/sound/soc/txx9/txx9aclc.c @@ -23,6 +23,8 @@ #include #include "txx9aclc.h" +#define DRV_NAME "txx9aclc" + static struct txx9aclc_soc_device { struct txx9aclc_dmadata dmadata[2]; } txx9aclc_soc_device; @@ -53,6 +55,7 @@ static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); struct txx9aclc_dmadata *dmadata = runtime->private_data; int ret; @@ -60,13 +63,13 @@ static int txx9aclc_pcm_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - dev_dbg(rtd->platform->dev, + dev_dbg(component->dev, "runtime->dma_area = %#lx dma_addr = %#lx dma_bytes = %zd " "runtime->min_align %ld\n", (unsigned long)runtime->dma_area, (unsigned long)runtime->dma_addr, runtime->dma_bytes, runtime->min_align); - dev_dbg(rtd->platform->dev, + dev_dbg(component->dev, "periods %d period_bytes %d stream %d\n", params_periods(params), params_period_bytes(params), substream->stream); @@ -287,7 +290,8 @@ static int txx9aclc_pcm_new(struct snd_soc_pcm_runtime *rtd) struct snd_card *card = rtd->card->snd_card; struct snd_soc_dai *dai = rtd->cpu_dai; struct snd_pcm *pcm = rtd->pcm; - struct platform_device *pdev = to_platform_device(rtd->platform->dev); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME); + struct platform_device *pdev = to_platform_device(component->dev); struct txx9aclc_soc_device *dev; struct resource *r; int i; @@ -371,15 +375,15 @@ static int txx9aclc_dma_init(struct txx9aclc_soc_device *dev, return 0; } -static int txx9aclc_pcm_probe(struct snd_soc_platform *platform) +static int txx9aclc_pcm_probe(struct snd_soc_component *component) { - snd_soc_platform_set_drvdata(platform, &txx9aclc_soc_device); + snd_soc_component_set_drvdata(component, &txx9aclc_soc_device); return 0; } -static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) +static void txx9aclc_pcm_remove(struct snd_soc_component *component) { - struct txx9aclc_soc_device *dev = snd_soc_platform_get_drvdata(platform); + struct txx9aclc_soc_device *dev = snd_soc_component_get_drvdata(component); struct txx9aclc_plat_drvdata *drvdata = txx9aclc_drvdata; void __iomem *base = drvdata->base; int i; @@ -400,10 +404,10 @@ static int txx9aclc_pcm_remove(struct snd_soc_platform *platform) } dev->dmadata[i].dma_chan = NULL; } - return 0; } -static const struct snd_soc_platform_driver txx9aclc_soc_platform = { +static const struct snd_soc_component_driver txx9aclc_soc_component = { + .name = DRV_NAME, .probe = txx9aclc_pcm_probe, .remove = txx9aclc_pcm_remove, .ops = &txx9aclc_pcm_ops, @@ -412,8 +416,8 @@ static const struct snd_soc_platform_driver txx9aclc_soc_platform = { static int txx9aclc_soc_platform_probe(struct platform_device *pdev) { - return devm_snd_soc_register_platform(&pdev->dev, - &txx9aclc_soc_platform); + return devm_snd_soc_register_component(&pdev->dev, + &txx9aclc_soc_component, NULL, 0); } static struct platform_driver txx9aclc_pcm_driver = { From f1b5bf07365d4d6599ce90f49ef96dd8833fbd90 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:42 +0000 Subject: [PATCH 226/942] ASoC: mt2701/mt8173: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Garlic Tseng Signed-off-by: Mark Brown --- sound/soc/mediatek/common/mtk-afe-fe-dai.c | 16 ++++-- .../mediatek/common/mtk-afe-platform-driver.c | 9 ++-- .../mediatek/common/mtk-afe-platform-driver.h | 3 +- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 50 ++++++++++++------- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 42 +++++++++------- 5 files changed, 73 insertions(+), 47 deletions(-) diff --git a/sound/soc/mediatek/common/mtk-afe-fe-dai.c b/sound/soc/mediatek/common/mtk-afe-fe-dai.c index ac231d33d8fe..c91e5f4cd902 100644 --- a/sound/soc/mediatek/common/mtk-afe-fe-dai.c +++ b/sound/soc/mediatek/common/mtk-afe-fe-dai.c @@ -18,6 +18,7 @@ #include #include #include +#include "mtk-afe-platform-driver.h" #include "mtk-afe-fe-dai.h" #include "mtk-base-afe.h" @@ -43,7 +44,8 @@ int mtk_afe_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct snd_pcm_runtime *runtime = substream->runtime; int memif_num = rtd->cpu_dai->id; struct mtk_base_afe_memif *memif = &afe->memif[memif_num]; @@ -105,7 +107,8 @@ void mtk_afe_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int irq_id; @@ -128,7 +131,8 @@ int mtk_afe_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int msb_at_bit33 = 0; int ret, fs = 0; @@ -192,7 +196,8 @@ int mtk_afe_fe_trigger(struct snd_pcm_substream *substream, int cmd, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; struct mtk_base_afe_irq *irqs = &afe->irqs[memif->irq_usage]; const struct mtk_base_irq_data *irq_data = irqs->irq_data; @@ -255,7 +260,8 @@ int mtk_afe_fe_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int hd_audio = 0; diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.c b/sound/soc/mediatek/common/mtk-afe-platform-driver.c index 82d439c15f4e..53215b52e4f2 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.c +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.c @@ -25,7 +25,8 @@ static snd_pcm_uframes_t mtk_afe_pcm_pointer (struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; const struct mtk_base_memif_data *memif_data = memif->data; struct regmap *regmap = afe->regmap; @@ -65,7 +66,8 @@ static int mtk_afe_pcm_new(struct snd_soc_pcm_runtime *rtd) size_t size; struct snd_card *card = rtd->card->snd_card; struct snd_pcm *pcm = rtd->pcm; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); size = afe->mtk_afe_hardware->buffer_bytes_max; return snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, @@ -77,7 +79,8 @@ static void mtk_afe_pcm_free(struct snd_pcm *pcm) snd_pcm_lib_preallocate_free_for_all(pcm); } -const struct snd_soc_platform_driver mtk_afe_pcm_platform = { +const struct snd_soc_component_driver mtk_afe_pcm_platform = { + .name = AFE_PCM_NAME, .ops = &mtk_afe_pcm_ops, .pcm_new = mtk_afe_pcm_new, .pcm_free = mtk_afe_pcm_free, diff --git a/sound/soc/mediatek/common/mtk-afe-platform-driver.h b/sound/soc/mediatek/common/mtk-afe-platform-driver.h index a973fc9253b4..8dcdbed959ea 100644 --- a/sound/soc/mediatek/common/mtk-afe-platform-driver.h +++ b/sound/soc/mediatek/common/mtk-afe-platform-driver.h @@ -17,7 +17,8 @@ #ifndef _MTK_AFE_PLATFORM_DRIVER_H_ #define _MTK_AFE_PLATFORM_DRIVER_H_ -extern const struct snd_soc_platform_driver mtk_afe_pcm_platform; +#define AFE_PCM_NAME "mtk-afe-pcm" +extern const struct snd_soc_component_driver mtk_afe_pcm_platform; #endif diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index d68b53f7cefe..f7e0702d92f8 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -93,7 +93,8 @@ static int mt2701_afe_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); if (i2s_num < 0) @@ -108,7 +109,8 @@ static int mt2701_afe_i2s_path_shutdown(struct snd_pcm_substream *substream, int dir_invert) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; const struct mt2701_i2s_data *i2s_data; @@ -144,7 +146,8 @@ static void mt2701_afe_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); struct mt2701_i2s_path *i2s_path; @@ -176,7 +179,8 @@ static int mt2701_i2s_path_prepare_enable(struct snd_pcm_substream *substream, int dir_invert) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; struct mt2701_i2s_path *i2s_path = &afe_priv->i2s_path[i2s_num]; const struct mt2701_i2s_data *i2s_data; @@ -247,7 +251,8 @@ static int mt2701_afe_i2s_prepare(struct snd_pcm_substream *substream, { int clk_domain; struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int i2s_num = mt2701_dai_num_to_i2s(afe, dai->id); struct mt2701_i2s_path *i2s_path; @@ -312,7 +317,8 @@ static int mt2701_btmrg_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; int ret; @@ -329,7 +335,8 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_fs; u32 val, msk; @@ -372,7 +379,8 @@ static void mt2701_btmrg_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt2701_afe_private *afe_priv = afe->platform_priv; /* if the other direction stream is not occupied */ @@ -392,7 +400,8 @@ static int mt2701_simple_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_dir = substream->stream; int memif_num = rtd->cpu_dai->id; struct mtk_base_afe_memif *memif_tmp; @@ -414,7 +423,8 @@ static int mt2701_simple_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int stream_dir = substream->stream; /* single DL use PAIR_INTERLEAVE */ @@ -431,7 +441,8 @@ static int mt2701_dlm_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif_tmp; const struct mtk_base_memif_data *memif_data; int i; @@ -458,7 +469,8 @@ static void mt2701_dlm_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); const struct mtk_base_memif_data *memif_data; int i; @@ -477,7 +489,8 @@ static int mt2701_dlm_fe_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); int channels = params_channels(params); regmap_update_bits(afe->regmap, @@ -500,7 +513,8 @@ static int mt2701_dlm_fe_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif_tmp = &afe->memif[MT2701_MEMIF_DL1]; switch (cmd) { @@ -1517,7 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) } pm_runtime_get_sync(dev); - ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform); + ret = devm_snd_soc_register_component(&pdev->dev, &mtk_afe_pcm_platform, + NULL, 0); if (ret) { dev_warn(dev, "err_platform\n"); goto err_platform; @@ -1526,13 +1541,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) ret = mt2701_afe_add_component(afe); if (ret) { dev_warn(dev, "err_dai_component\n"); - goto err_dai_component; + goto err_platform; } return 0; -err_dai_component: - snd_soc_unregister_platform(dev); err_platform: pm_runtime_put_sync(dev); err_pm_disable: @@ -1549,7 +1562,6 @@ static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev) mt2701_afe_runtime_suspend(&pdev->dev); snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); return 0; } diff --git a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c index c7f7f8add5d9..65d1433a0944 100644 --- a/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +++ b/sound/soc/mediatek/mt8173/mt8173-afe-pcm.c @@ -304,7 +304,8 @@ static int mt8173_afe_i2s_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); if (dai->active) return 0; @@ -318,7 +319,8 @@ static void mt8173_afe_i2s_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); if (dai->active) return; @@ -334,7 +336,8 @@ static int mt8173_afe_i2s_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; int ret; @@ -356,7 +359,8 @@ static int mt8173_afe_hdmi_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; if (dai->active) @@ -371,7 +375,8 @@ static void mt8173_afe_hdmi_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; if (dai->active) @@ -386,7 +391,8 @@ static int mt8173_afe_hdmi_prepare(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_runtime * const runtime = substream->runtime; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mt8173_afe_private *afe_priv = afe->platform_priv; unsigned int val; @@ -449,7 +455,8 @@ static int mt8173_afe_hdmi_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); dev_info(afe->dev, "%s cmd=%d %s\n", __func__, cmd, dai->name); @@ -498,7 +505,8 @@ static int mt8173_memif_fs(struct snd_pcm_substream *substream, unsigned int rate) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct mtk_base_afe *afe = snd_soc_platform_get_drvdata(rtd->platform); + struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, AFE_PCM_NAME); + struct mtk_base_afe *afe = snd_soc_component_get_drvdata(component); struct mtk_base_afe_memif *memif = &afe->memif[rtd->cpu_dai->id]; int fs; @@ -1172,31 +1180,29 @@ static int mt8173_afe_pcm_dev_probe(struct platform_device *pdev) afe->runtime_resume = mt8173_afe_runtime_resume; afe->runtime_suspend = mt8173_afe_runtime_suspend; - ret = snd_soc_register_platform(&pdev->dev, &mtk_afe_pcm_platform); + ret = devm_snd_soc_register_component(&pdev->dev, + &mtk_afe_pcm_platform, + NULL, 0); if (ret) goto err_pm_disable; - ret = snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_pcm_dai_component, mt8173_afe_pcm_dais, ARRAY_SIZE(mt8173_afe_pcm_dais)); if (ret) - goto err_platform; + goto err_pm_disable; - ret = snd_soc_register_component(&pdev->dev, + ret = devm_snd_soc_register_component(&pdev->dev, &mt8173_afe_hdmi_dai_component, mt8173_afe_hdmi_dais, ARRAY_SIZE(mt8173_afe_hdmi_dais)); if (ret) - goto err_comp; + goto err_pm_disable; dev_info(&pdev->dev, "MT8173 AFE driver initialized.\n"); return 0; -err_comp: - snd_soc_unregister_component(&pdev->dev); -err_platform: - snd_soc_unregister_platform(&pdev->dev); err_pm_disable: pm_runtime_disable(&pdev->dev); return ret; @@ -1207,8 +1213,6 @@ static int mt8173_afe_pcm_dev_remove(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); if (!pm_runtime_status_suspended(&pdev->dev)) mt8173_afe_runtime_suspend(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - snd_soc_unregister_platform(&pdev->dev); return 0; } From 66bf428e555cdbf77c5a9cffefd8fca4af76ce9d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:51:58 +0000 Subject: [PATCH 227/942] ASoC: stm: stm32_adfsdm: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/stm/stm32_adfsdm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index 7306e3eca9e1..db73fef3e500 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -281,7 +281,7 @@ static void stm32_adfsdm_pcm_free(struct snd_pcm *pcm) } } -static struct snd_soc_platform_driver stm32_adfsdm_soc_platform = { +static struct snd_soc_component_driver stm32_adfsdm_soc_platform = { .ops = &stm32_adfsdm_pcm_ops, .pcm_new = stm32_adfsdm_pcm_new, .pcm_free = stm32_adfsdm_pcm_free, @@ -322,8 +322,9 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) if (IS_ERR(priv->iio_cb)) return PTR_ERR(priv->iio_cb); - ret = devm_snd_soc_register_platform(&pdev->dev, - &stm32_adfsdm_soc_platform); + ret = devm_snd_soc_register_component(&pdev->dev, + &stm32_adfsdm_soc_platform, + NULL, 0); if (ret < 0) dev_err(&pdev->dev, "%s: Failed to register PCM platform\n", __func__); From 03a0ddeda7ebafea8e99078581a50d856e3587a4 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 02:58:01 +0000 Subject: [PATCH 228/942] ASoC: soc-utils: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-utils.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index e237858c9ed4..2d9e98bd1530 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c @@ -288,7 +288,12 @@ static const struct snd_soc_component_driver dummy_platform = { .ops = &dummy_dma_ops, }; -static const struct snd_soc_codec_driver dummy_codec; +static const struct snd_soc_component_driver dummy_codec = { + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; #define STUB_RATES SNDRV_PCM_RATE_8000_192000 #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ @@ -338,33 +343,22 @@ static int snd_soc_dummy_probe(struct platform_device *pdev) { int ret; - ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1); + ret = devm_snd_soc_register_component(&pdev->dev, + &dummy_codec, &dummy_dai, 1); if (ret < 0) return ret; ret = devm_snd_soc_register_component(&pdev->dev, &dummy_platform, NULL, 0); - if (ret < 0) { - snd_soc_unregister_codec(&pdev->dev); - return ret; - } return ret; } -static int snd_soc_dummy_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - - return 0; -} - static struct platform_driver soc_dummy_driver = { .driver = { .name = "snd-soc-dummy", }, .probe = snd_soc_dummy_probe, - .remove = snd_soc_dummy_remove, }; static struct platform_device *soc_dummy_dev; From beff23ff26db0c1df2eaabc0dfe877bcbf05f6db Mon Sep 17 00:00:00 2001 From: Corentin Labbe Date: Mon, 29 Jan 2018 12:26:16 +0000 Subject: [PATCH 229/942] ASoC: samsung: clean makefile about inexistant files Clean makefile rules about inexistant files. Thoses files were removed in commit a076d418235f ("ASoC: samsung: Drop AC97 drivers") Signed-off-by: Corentin Labbe Reviewed-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index 030949e1e434..c3b76035f69c 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile @@ -21,8 +21,6 @@ obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-idma.o # S3C24XX Machine Support snd-soc-jive-wm8750-objs := jive_wm8750.o snd-soc-neo1973-wm8753-objs := neo1973_wm8753.o -snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o -snd-soc-ln2440sbc-alc650-objs := ln2440sbc_alc650.o snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o snd-soc-s3c24xx-simtec-objs := s3c24xx_simtec.o snd-soc-s3c24xx-simtec-hermes-objs := s3c24xx_simtec_hermes.o @@ -32,7 +30,6 @@ snd-soc-rx1950-uda1380-objs := rx1950_uda1380.o snd-soc-smdk-wm8580-objs := smdk_wm8580.o snd-soc-smdk-wm8994-objs := smdk_wm8994.o snd-soc-snow-objs := snow.o -snd-soc-smdk-wm9713-objs := smdk_wm9713.o snd-soc-s3c64xx-smartq-wm8987-objs := smartq_wm8987.o snd-soc-smdk-spdif-objs := smdk_spdif.o snd-soc-smdk-wm8994pcm-objs := smdk_wm8994pcm.o From e0b9f3aa45fcfce1873503e5ff85d919697427cb Mon Sep 17 00:00:00 2001 From: Corentin Labbe Date: Mon, 29 Jan 2018 12:28:54 +0000 Subject: [PATCH 230/942] ASoC: sn95031: remove dead makefile about sn95031 All sn95031 stuff was removed in commit 987da3fe1759 ("ASoC: sn95031: remove this code") Since SND_SOC_SN95031 was gone, remove makefile about it. Signed-off-by: Corentin Labbe Signed-off-by: Mark Brown --- sound/soc/codecs/Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..4053c72d852b 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -387,7 +387,6 @@ obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o obj-$(CONFIG_SND_SOC_SIGMADSP_I2C) += snd-soc-sigmadsp-i2c.o obj-$(CONFIG_SND_SOC_SIGMADSP_REGMAP) += snd-soc-sigmadsp-regmap.o obj-$(CONFIG_SND_SOC_SI476X) += snd-soc-si476x.o -obj-$(CONFIG_SND_SOC_SN95031) +=snd-soc-sn95031.o obj-$(CONFIG_SND_SOC_SPDIF) += snd-soc-spdif-rx.o snd-soc-spdif-tx.o obj-$(CONFIG_SND_SOC_SIRF_AUDIO_CODEC) += sirf-audio-codec.o obj-$(CONFIG_SND_SOC_SSM2518) += snd-soc-ssm2518.o From 20ebbd2f89a9b2c61c4d432aa1156fc09e37f37c Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 29 Jan 2018 19:15:38 +0800 Subject: [PATCH 231/942] ASoC: rt5665: remove rt5668 support Remove rt5668 support from rt5665 codec driver since rt5668 will not go into mass production. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/rt5665.txt | 4 ++-- sound/soc/codecs/rt5665.c | 5 ----- sound/soc/codecs/rt5665.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/rt5665.txt b/Documentation/devicetree/bindings/sound/rt5665.txt index 419c89219681..8df170506986 100644 --- a/Documentation/devicetree/bindings/sound/rt5665.txt +++ b/Documentation/devicetree/bindings/sound/rt5665.txt @@ -1,10 +1,10 @@ -RT5665/RT5666/RT5668 audio CODEC +RT5665/RT5666 audio CODEC This device supports I2C only. Required properties: -- compatible : One of "realtek,rt5665", "realtek,rt5666" or "realtek,rt5668". +- compatible : One of "realtek,rt5665", "realtek,rt5666". - reg : The I2C address of the device. diff --git a/sound/soc/codecs/rt5665.c b/sound/soc/codecs/rt5665.c index 819df1a32dd4..6ba99f5ed3f4 100644 --- a/sound/soc/codecs/rt5665.c +++ b/sound/soc/codecs/rt5665.c @@ -4826,9 +4826,6 @@ static int rt5665_i2c_probe(struct i2c_client *i2c, case 0x0: rt5665->id = CODEC_5666; break; - case 0x6: - rt5665->id = CODEC_5668; - break; case 0x3: default: rt5665->id = CODEC_5665; @@ -4955,7 +4952,6 @@ static void rt5665_i2c_shutdown(struct i2c_client *client) static const struct of_device_id rt5665_of_match[] = { {.compatible = "realtek,rt5665"}, {.compatible = "realtek,rt5666"}, - {.compatible = "realtek,rt5668"}, {}, }; MODULE_DEVICE_TABLE(of, rt5665_of_match); @@ -4965,7 +4961,6 @@ MODULE_DEVICE_TABLE(of, rt5665_of_match); static const struct acpi_device_id rt5665_acpi_match[] = { {"10EC5665", 0,}, {"10EC5666", 0,}, - {"10EC5668", 0,}, {}, }; MODULE_DEVICE_TABLE(acpi, rt5665_acpi_match); diff --git a/sound/soc/codecs/rt5665.h b/sound/soc/codecs/rt5665.h index b528e416b592..b0a98ca39c5b 100644 --- a/sound/soc/codecs/rt5665.h +++ b/sound/soc/codecs/rt5665.h @@ -1978,7 +1978,6 @@ enum { enum { CODEC_5665, CODEC_5666, - CODEC_5668, }; /* filter mask */ From 6b49087912e311bc884d36874592595508630b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= Date: Thu, 1 Feb 2018 11:09:41 +0100 Subject: [PATCH 232/942] ASoC: soc-core: remove error due to probe deferral MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deferred probes shouldn't cause error messages in the boot log, so change the dev_err() to the more harmless dev_info(). Signed-off-by: Martin Hundebøll Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96c44f6576c9..60a542f35dbd 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1100,8 +1100,8 @@ static int soc_bind_dai_link(struct snd_soc_card *card, cpu_dai_component.dai_name = dai_link->cpu_dai_name; rtd->cpu_dai = snd_soc_find_dai(&cpu_dai_component); if (!rtd->cpu_dai) { - dev_err(card->dev, "ASoC: CPU DAI %s not registered\n", - dai_link->cpu_dai_name); + dev_info(card->dev, "ASoC: CPU DAI %s not registered\n", + dai_link->cpu_dai_name); goto _err_defer; } snd_soc_rtdcom_add(rtd, rtd->cpu_dai->component); From b9aa4716281247960e009dd55c38bcc4c2e4cb94 Mon Sep 17 00:00:00 2001 From: olivier moysan Date: Wed, 31 Jan 2018 17:47:02 +0100 Subject: [PATCH 233/942] ASoC: stm32: spdifrx: fix typo in function name. Fix function name prefix for naming consistency. Signed-off-by: olivier moysan Signed-off-by: Mark Brown --- sound/soc/stm/stm32_spdifrx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index b9bdefcd3e10..42ad2ae22d21 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -858,8 +858,8 @@ static const struct of_device_id stm32_spdifrx_ids[] = { {} }; -static int stm_spdifrx_parse_of(struct platform_device *pdev, - struct stm32_spdifrx_data *spdifrx) +static int stm32_spdifrx_parse_of(struct platform_device *pdev, + struct stm32_spdifrx_data *spdifrx) { struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id; @@ -914,7 +914,7 @@ static int stm32_spdifrx_probe(struct platform_device *pdev) platform_set_drvdata(pdev, spdifrx); - ret = stm_spdifrx_parse_of(pdev, spdifrx); + ret = stm32_spdifrx_parse_of(pdev, spdifrx); if (ret) return ret; From 037002b14b7ae217aa79b260228ba51afc516a8c Mon Sep 17 00:00:00 2001 From: olivier moysan Date: Wed, 31 Jan 2018 17:47:03 +0100 Subject: [PATCH 234/942] ASoC: stm32: spdifrx: Use default dai name Use dai name provided by framework from dev_name() function. Signed-off-by: olivier moysan Signed-off-by: Mark Brown --- sound/soc/stm/stm32_spdifrx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/stm/stm32_spdifrx.c b/sound/soc/stm/stm32_spdifrx.c index 42ad2ae22d21..373df4f24be1 100644 --- a/sound/soc/stm/stm32_spdifrx.c +++ b/sound/soc/stm/stm32_spdifrx.c @@ -819,7 +819,6 @@ static const struct snd_soc_dai_ops stm32_spdifrx_pcm_dai_ops = { static struct snd_soc_dai_driver stm32_spdifrx_dai[] = { { - .name = "spdifrx-capture-cpu-dai", .probe = stm32_spdifrx_dai_probe, .capture = { .stream_name = "CPU-Capture", From 4bb83cf0a034cbe83c413a69705d315f5660bdb9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:11:56 +0000 Subject: [PATCH 235/942] ASoC: adau1701: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/adau1701.c | 101 ++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 55 deletions(-) diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c index 805afac8146b..b5a61741c800 100644 --- a/sound/soc/codecs/adau1701.c +++ b/sound/soc/codecs/adau1701.c @@ -298,10 +298,10 @@ static const struct sigmadsp_ops adau1701_sigmadsp_ops = { .safeload = adau1701_safeload, }; -static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, +static int adau1701_reset(struct snd_soc_component *component, unsigned int clkdiv, unsigned int rate) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); int ret; sigmadsp_reset(adau1701->sigmadsp); @@ -348,7 +348,7 @@ static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, if (clkdiv != ADAU1707_CLKDIV_UNSET) { ret = sigmadsp_setup(adau1701->sigmadsp, rate); if (ret) { - dev_warn(codec->dev, "Failed to load firmware\n"); + dev_warn(component->dev, "Failed to load firmware\n"); return ret; } } @@ -362,10 +362,10 @@ static int adau1701_reset(struct snd_soc_codec *codec, unsigned int clkdiv, return 0; } -static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec, +static int adau1701_set_capture_pcm_format(struct snd_soc_component *component, struct snd_pcm_hw_params *params) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); unsigned int mask = ADAU1701_SEROCTL_WORD_LEN_MASK; unsigned int val; @@ -403,10 +403,10 @@ static int adau1701_set_capture_pcm_format(struct snd_soc_codec *codec, return 0; } -static int adau1701_set_playback_pcm_format(struct snd_soc_codec *codec, +static int adau1701_set_playback_pcm_format(struct snd_soc_component *component, struct snd_pcm_hw_params *params) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); unsigned int val; if (adau1701->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) @@ -435,8 +435,8 @@ static int adau1701_set_playback_pcm_format(struct snd_soc_codec *codec, static int adau1701_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); unsigned int clkdiv = adau1701->sysclk / params_rate(params); unsigned int val; int ret; @@ -447,7 +447,7 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream, * firmware upload. */ if (clkdiv != adau1701->pll_clkdiv) { - ret = adau1701_reset(codec, clkdiv, params_rate(params)); + ret = adau1701_reset(component, clkdiv, params_rate(params)); if (ret < 0) return ret; } @@ -470,16 +470,16 @@ static int adau1701_hw_params(struct snd_pcm_substream *substream, ADAU1701_DSPCTRL_SR_MASK, val); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - return adau1701_set_playback_pcm_format(codec, params); + return adau1701_set_playback_pcm_format(component, params); else - return adau1701_set_capture_pcm_format(codec, params); + return adau1701_set_capture_pcm_format(component, params); } static int adau1701_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); unsigned int serictl = 0x00, seroctl = 0x00; bool invert_lrclk; @@ -548,11 +548,11 @@ static int adau1701_set_dai_fmt(struct snd_soc_dai *codec_dai, return 0; } -static int adau1701_set_bias_level(struct snd_soc_codec *codec, +static int adau1701_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { unsigned int mask = ADAU1701_AUXNPOW_VBPD | ADAU1701_AUXNPOW_VRPD; - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); switch (level) { case SND_SOC_BIAS_ON: @@ -576,9 +576,9 @@ static int adau1701_set_bias_level(struct snd_soc_codec *codec, static int adau1701_digital_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; unsigned int mask = ADAU1701_DSPCTRL_DAM; - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); unsigned int val; if (mute) @@ -591,11 +591,11 @@ static int adau1701_digital_mute(struct snd_soc_dai *dai, int mute) return 0; } -static int adau1701_set_sysclk(struct snd_soc_codec *codec, int clk_id, +static int adau1701_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { unsigned int val; - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); switch (clk_id) { case ADAU1701_CLK_SRC_OSC: @@ -618,7 +618,7 @@ static int adau1701_set_sysclk(struct snd_soc_codec *codec, int clk_id, static int adau1701_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(dai->codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(dai->component); return sigmadsp_restrict_params(adau1701->sigmadsp, substream); } @@ -664,20 +664,20 @@ static const struct of_device_id adau1701_dt_ids[] = { MODULE_DEVICE_TABLE(of, adau1701_dt_ids); #endif -static int adau1701_probe(struct snd_soc_codec *codec) +static int adau1701_probe(struct snd_soc_component *component) { int i, ret; unsigned int val; - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); - ret = sigmadsp_attach(adau1701->sigmadsp, &codec->component); + ret = sigmadsp_attach(adau1701->sigmadsp, component); if (ret) return ret; ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); if (ret < 0) { - dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); + dev_err(component->dev, "Failed to enable regulators: %d\n", ret); return ret; } @@ -690,7 +690,7 @@ static int adau1701_probe(struct snd_soc_codec *codec) adau1701->pll_clkdiv = ADAU1707_CLKDIV_UNSET; /* initalize with pre-configured pll mode settings */ - ret = adau1701_reset(codec, adau1701->pll_clkdiv, 0); + ret = adau1701_reset(component, adau1701->pll_clkdiv, 0); if (ret < 0) goto exit_regulators_disable; @@ -715,22 +715,20 @@ exit_regulators_disable: return ret; } -static int adau1701_remove(struct snd_soc_codec *codec) +static void adau1701_remove(struct snd_soc_component *component) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); if (gpio_is_valid(adau1701->gpio_nreset)) gpio_set_value_cansleep(adau1701->gpio_nreset, 0); regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); - - return 0; } #ifdef CONFIG_PM -static int adau1701_suspend(struct snd_soc_codec *codec) +static int adau1701_suspend(struct snd_soc_component *component) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); regulator_bulk_disable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); @@ -738,42 +736,41 @@ static int adau1701_suspend(struct snd_soc_codec *codec) return 0; } -static int adau1701_resume(struct snd_soc_codec *codec) +static int adau1701_resume(struct snd_soc_component *component) { - struct adau1701 *adau1701 = snd_soc_codec_get_drvdata(codec); + struct adau1701 *adau1701 = snd_soc_component_get_drvdata(component); int ret; ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies), adau1701->supplies); if (ret < 0) { - dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); + dev_err(component->dev, "Failed to enable regulators: %d\n", ret); return ret; } - return adau1701_reset(codec, adau1701->pll_clkdiv, 0); + return adau1701_reset(component, adau1701->pll_clkdiv, 0); } #else #define adau1701_resume NULL #define adau1701_suspend NULL #endif /* CONFIG_PM */ -static const struct snd_soc_codec_driver adau1701_codec_drv = { +static const struct snd_soc_component_driver adau1701_component_drv = { .probe = adau1701_probe, .remove = adau1701_remove, .resume = adau1701_resume, .suspend = adau1701_suspend, .set_bias_level = adau1701_set_bias_level, - .idle_bias_off = true, - - .component_driver = { - .controls = adau1701_controls, - .num_controls = ARRAY_SIZE(adau1701_controls), - .dapm_widgets = adau1701_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(adau1701_dapm_widgets), - .dapm_routes = adau1701_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(adau1701_dapm_routes), - }, + .controls = adau1701_controls, + .num_controls = ARRAY_SIZE(adau1701_controls), + .dapm_widgets = adau1701_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(adau1701_dapm_widgets), + .dapm_routes = adau1701_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(adau1701_dapm_routes), .set_sysclk = adau1701_set_sysclk, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config adau1701_regmap = { @@ -889,7 +886,8 @@ static int adau1701_i2c_probe(struct i2c_client *client, goto exit_regulators_disable; } - ret = snd_soc_register_codec(&client->dev, &adau1701_codec_drv, + ret = devm_snd_soc_register_component(&client->dev, + &adau1701_component_drv, &adau1701_dai, 1); exit_regulators_disable: @@ -898,12 +896,6 @@ exit_regulators_disable: return ret; } -static int adau1701_i2c_remove(struct i2c_client *client) -{ - snd_soc_unregister_codec(&client->dev); - return 0; -} - static const struct i2c_device_id adau1701_i2c_id[] = { { "adau1401", 0 }, { "adau1401a", 0 }, @@ -919,7 +911,6 @@ static struct i2c_driver adau1701_i2c_driver = { .of_match_table = of_match_ptr(adau1701_dt_ids), }, .probe = adau1701_i2c_probe, - .remove = adau1701_i2c_remove, .id_table = adau1701_i2c_id, }; From 28fb53de064b24eed55540ddeccab517e4babca3 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 19 Jan 2018 18:25:28 +0900 Subject: [PATCH 236/942] ASoC: uniphier: add DT bindings documentation for UniPhier AIO This patch adds DT binding documentation for UniPhier AIO audio subsystem. Acked-by: Rob Herring Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- .../bindings/sound/uniphier,aio.txt | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/uniphier,aio.txt diff --git a/Documentation/devicetree/bindings/sound/uniphier,aio.txt b/Documentation/devicetree/bindings/sound/uniphier,aio.txt new file mode 100644 index 000000000000..73f6c27ae4f7 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/uniphier,aio.txt @@ -0,0 +1,36 @@ +Socionext UniPhier SoC audio driver + +The Socionext UniPhier audio subsystem consists of I2S and S/PDIF blocks in +the same register space. + +Required properties: +- compatible : should be one of the following: + "socionext,uniphier-ld11-aio" + "socionext,uniphier-ld20-aio" +- reg : offset and length of the register set for the device. +- interrupts : should contain I2S or S/PDIF interrupt. +- pinctrl-names : should be "default". +- pinctrl-0 : defined I2S signal pins for an external codec chip. +- clock-names : should include following entries: + "aio" +- clocks : a list of phandle, should contain an entry for each + entry in clock-names. +- reset-names : should include following entries: + "aio" +- resets : a list of phandle, should contain an entry for each + entry in reset-names. +- #sound-dai-cells: should be 1. + +Example: + audio { + compatible = "socionext,uniphier-ld20-aio"; + reg = <0x56000000 0x80000>; + interrupts = <0 144 4>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_aout>; + clock-names = "aio"; + clocks = <&sys_clk 40>; + reset-names = "aio"; + resets = <&sys_rst 40>; + #sound-dai-cells = <1>; + }; From f37fe2f9987b0460f25a87b1380f8e97a5959121 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 19 Jan 2018 18:25:29 +0900 Subject: [PATCH 237/942] ASoC: uniphier: add support for UniPhier AIO common driver This patch adds common functions for UniPhier AIO audio sound system. This provides commonly used APIs for input/output control registers for UniPhier AIO. This module provides all sound devices for I2S, S/PDIF and so on. Since the AIO has mixed register map for those I/Os, it is hard to split register areas for each sound devices. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/Kconfig | 10 + sound/soc/uniphier/Makefile | 4 + sound/soc/uniphier/aio-core.c | 1104 +++++++++++++++++++++++++++++++++ sound/soc/uniphier/aio-reg.h | 462 ++++++++++++++ sound/soc/uniphier/aio.h | 343 ++++++++++ 5 files changed, 1923 insertions(+) create mode 100644 sound/soc/uniphier/aio-core.c create mode 100644 sound/soc/uniphier/aio-reg.h create mode 100644 sound/soc/uniphier/aio.h diff --git a/sound/soc/uniphier/Kconfig b/sound/soc/uniphier/Kconfig index 02886a457eaf..78ce101d2cc2 100644 --- a/sound/soc/uniphier/Kconfig +++ b/sound/soc/uniphier/Kconfig @@ -8,6 +8,16 @@ config SND_SOC_UNIPHIER audio interfaces to support below. If unsure select "N". +config SND_SOC_UNIPHIER_AIO + tristate "UniPhier AIO DAI Driver" + select REGMAP_MMIO + depends on SND_SOC_UNIPHIER + help + This adds ASoC driver support for Socionext UniPhier + 'AIO' Audio Input/Output subsystem. + Select Y if you use such device. + If unsure select "N". + config SND_SOC_UNIPHIER_EVEA_CODEC tristate "UniPhier SoC internal audio codec" depends on SND_SOC_UNIPHIER diff --git a/sound/soc/uniphier/Makefile b/sound/soc/uniphier/Makefile index 3be00d72f5e5..f3b36aba4879 100644 --- a/sound/soc/uniphier/Makefile +++ b/sound/soc/uniphier/Makefile @@ -1,3 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 +snd-soc-uniphier-aio-cpu-objs := aio-core.o + +obj-$(CONFIG_SND_SOC_UNIPHIER_AIO) += snd-soc-uniphier-aio-cpu.o + snd-soc-uniphier-evea-objs := evea.o obj-$(CONFIG_SND_SOC_UNIPHIER_EVEA_CODEC) += snd-soc-uniphier-evea.o diff --git a/sound/soc/uniphier/aio-core.c b/sound/soc/uniphier/aio-core.c new file mode 100644 index 000000000000..7e9451ca24af --- /dev/null +++ b/sound/soc/uniphier/aio-core.c @@ -0,0 +1,1104 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext UniPhier AIO ALSA common driver. +// +// Copyright (c) 2016-2018 Socionext Inc. +// +// 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; version 2 +// of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "aio.h" +#include "aio-reg.h" + +static u64 rb_cnt(u64 wr, u64 rd, u64 len) +{ + if (rd <= wr) + return wr - rd; + else + return len - (rd - wr); +} + +static u64 rb_cnt_to_end(u64 wr, u64 rd, u64 len) +{ + if (rd <= wr) + return wr - rd; + else + return len - rd; +} + +static u64 rb_space(u64 wr, u64 rd, u64 len) +{ + if (rd <= wr) + return len - (wr - rd) - 8; + else + return rd - wr - 8; +} + +static u64 rb_space_to_end(u64 wr, u64 rd, u64 len) +{ + if (rd > wr) + return rd - wr - 8; + else if (rd > 0) + return len - wr; + else + return len - wr - 8; +} + +u64 aio_rb_cnt(struct uniphier_aio_sub *sub) +{ + return rb_cnt(sub->wr_offs, sub->rd_offs, sub->compr_bytes); +} + +u64 aio_rbt_cnt_to_end(struct uniphier_aio_sub *sub) +{ + return rb_cnt_to_end(sub->wr_offs, sub->rd_offs, sub->compr_bytes); +} + +u64 aio_rb_space(struct uniphier_aio_sub *sub) +{ + return rb_space(sub->wr_offs, sub->rd_offs, sub->compr_bytes); +} + +u64 aio_rb_space_to_end(struct uniphier_aio_sub *sub) +{ + return rb_space_to_end(sub->wr_offs, sub->rd_offs, sub->compr_bytes); +} + +/** + * aio_chip_set_pll - set frequency to audio PLL + * @chip : the AIO chip pointer + * @source: PLL + * @freq : frequency in Hz, 0 is ignored + * + * Sets frequency of audio PLL. This function can be called anytime, + * but it takes time till PLL is locked. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_chip_set_pll(struct uniphier_aio_chip *chip, int pll_id, + unsigned int freq) +{ + struct device *dev = &chip->pdev->dev; + struct regmap *r = chip->regmap; + int shift; + u32 v; + + /* Not change */ + if (freq == 0) + return 0; + + switch (pll_id) { + case AUD_PLL_A1: + shift = 0; + break; + case AUD_PLL_F1: + shift = 1; + break; + case AUD_PLL_A2: + shift = 2; + break; + case AUD_PLL_F2: + shift = 3; + break; + default: + dev_err(dev, "PLL(%d) not supported\n", pll_id); + return -EINVAL; + } + + switch (freq) { + case 36864000: + v = A2APLLCTR1_APLLX_36MHZ; + break; + case 33868800: + v = A2APLLCTR1_APLLX_33MHZ; + break; + default: + dev_err(dev, "PLL frequency not supported(%d)\n", freq); + return -EINVAL; + } + chip->plls[pll_id].freq = freq; + + regmap_update_bits(r, A2APLLCTR1, A2APLLCTR1_APLLX_MASK << shift, + v << shift); + + return 0; +} + +/** + * aio_chip_init - initialize AIO whole settings + * @chip: the AIO chip pointer + * + * Sets AIO fixed and whole device settings to AIO. + * This function need to call once at driver startup. + * + * The register area that is changed by this function is shared by all + * modules of AIO. But there is not race condition since this function + * has always set the same initialize values. + */ +void aio_chip_init(struct uniphier_aio_chip *chip) +{ + struct regmap *r = chip->regmap; + + regmap_update_bits(r, A2APLLCTR0, + A2APLLCTR0_APLLXPOW_MASK, + A2APLLCTR0_APLLXPOW_PWON); + + regmap_update_bits(r, A2EXMCLKSEL0, + A2EXMCLKSEL0_EXMCLK_MASK, + A2EXMCLKSEL0_EXMCLK_OUTPUT); + + regmap_update_bits(r, A2AIOINPUTSEL, A2AIOINPUTSEL_RXSEL_MASK, + A2AIOINPUTSEL_RXSEL_PCMI1_HDMIRX1 | + A2AIOINPUTSEL_RXSEL_PCMI2_SIF | + A2AIOINPUTSEL_RXSEL_PCMI3_EVEA | + A2AIOINPUTSEL_RXSEL_IECI1_HDMIRX1); + + if (chip->chip_spec->addr_ext) + regmap_update_bits(r, CDA2D_TEST, CDA2D_TEST_DDR_MODE_MASK, + CDA2D_TEST_DDR_MODE_EXTON0); + else + regmap_update_bits(r, CDA2D_TEST, CDA2D_TEST_DDR_MODE_MASK, + CDA2D_TEST_DDR_MODE_EXTOFF1); +} + +/** + * aio_init - initialize AIO substream + * @sub: the AIO substream pointer + * + * Sets fixed settings of each AIO substreams. + * This function need to call once at substream startup. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_init(struct uniphier_aio_sub *sub) +{ + struct device *dev = &sub->aio->chip->pdev->dev; + struct regmap *r = sub->aio->chip->regmap; + + regmap_write(r, A2RBNMAPCTR0(sub->swm->rb.hw), + MAPCTR0_EN | sub->swm->rb.map); + regmap_write(r, A2CHNMAPCTR0(sub->swm->ch.hw), + MAPCTR0_EN | sub->swm->ch.map); + + switch (sub->swm->type) { + case PORT_TYPE_I2S: + case PORT_TYPE_SPDIF: + case PORT_TYPE_EVE: + if (sub->swm->dir == PORT_DIR_INPUT) { + regmap_write(r, A2IIFNMAPCTR0(sub->swm->iif.hw), + MAPCTR0_EN | sub->swm->iif.map); + regmap_write(r, A2IPORTNMAPCTR0(sub->swm->iport.hw), + MAPCTR0_EN | sub->swm->iport.map); + } else { + regmap_write(r, A2OIFNMAPCTR0(sub->swm->oif.hw), + MAPCTR0_EN | sub->swm->oif.map); + regmap_write(r, A2OPORTNMAPCTR0(sub->swm->oport.hw), + MAPCTR0_EN | sub->swm->oport.map); + } + break; + case PORT_TYPE_CONV: + regmap_write(r, A2OIFNMAPCTR0(sub->swm->oif.hw), + MAPCTR0_EN | sub->swm->oif.map); + regmap_write(r, A2OPORTNMAPCTR0(sub->swm->oport.hw), + MAPCTR0_EN | sub->swm->oport.map); + regmap_write(r, A2CHNMAPCTR0(sub->swm->och.hw), + MAPCTR0_EN | sub->swm->och.map); + regmap_write(r, A2IIFNMAPCTR0(sub->swm->iif.hw), + MAPCTR0_EN | sub->swm->iif.map); + break; + default: + dev_err(dev, "Unknown port type %d.\n", sub->swm->type); + return -EINVAL; + } + + return 0; +} + +/** + * aio_port_reset - reset AIO port block + * @sub: the AIO substream pointer + * + * Resets the digital signal input/output port block of AIO. + */ +void aio_port_reset(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + regmap_write(r, AOUTRSTCTR0, BIT(sub->swm->oport.map)); + regmap_write(r, AOUTRSTCTR1, BIT(sub->swm->oport.map)); + } else { + regmap_update_bits(r, IPORTMXRSTCTR(sub->swm->iport.map), + IPORTMXRSTCTR_RSTPI_MASK, + IPORTMXRSTCTR_RSTPI_RESET); + regmap_update_bits(r, IPORTMXRSTCTR(sub->swm->iport.map), + IPORTMXRSTCTR_RSTPI_MASK, + IPORTMXRSTCTR_RSTPI_RELEASE); + } +} + +/** + * aio_port_set_rate - set sampling rate of LPCM + * @sub: the AIO substream pointer, PCM substream only + * @rate: Sampling rate in Hz. + * + * Set suitable I2S format settings to input/output port block of AIO. + * Parameter is specified by hw_params(). + * + * This function may return error if non-PCM substream. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_port_set_rate(struct uniphier_aio_sub *sub, int rate) +{ + struct regmap *r = sub->aio->chip->regmap; + struct device *dev = &sub->aio->chip->pdev->dev; + u32 v; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + switch (rate) { + case 8000: + v = OPORTMXCTR1_FSSEL_8; + break; + case 11025: + v = OPORTMXCTR1_FSSEL_11_025; + break; + case 12000: + v = OPORTMXCTR1_FSSEL_12; + break; + case 16000: + v = OPORTMXCTR1_FSSEL_16; + break; + case 22050: + v = OPORTMXCTR1_FSSEL_22_05; + break; + case 24000: + v = OPORTMXCTR1_FSSEL_24; + break; + case 32000: + v = OPORTMXCTR1_FSSEL_32; + break; + case 44100: + v = OPORTMXCTR1_FSSEL_44_1; + break; + case 48000: + v = OPORTMXCTR1_FSSEL_48; + break; + case 88200: + v = OPORTMXCTR1_FSSEL_88_2; + break; + case 96000: + v = OPORTMXCTR1_FSSEL_96; + break; + case 176400: + v = OPORTMXCTR1_FSSEL_176_4; + break; + case 192000: + v = OPORTMXCTR1_FSSEL_192; + break; + default: + dev_err(dev, "Rate not supported(%d)\n", rate); + return -EINVAL; + } + + regmap_update_bits(r, OPORTMXCTR1(sub->swm->oport.map), + OPORTMXCTR1_FSSEL_MASK, v); + } else { + switch (rate) { + case 8000: + v = IPORTMXCTR1_FSSEL_8; + break; + case 11025: + v = IPORTMXCTR1_FSSEL_11_025; + break; + case 12000: + v = IPORTMXCTR1_FSSEL_12; + break; + case 16000: + v = IPORTMXCTR1_FSSEL_16; + break; + case 22050: + v = IPORTMXCTR1_FSSEL_22_05; + break; + case 24000: + v = IPORTMXCTR1_FSSEL_24; + break; + case 32000: + v = IPORTMXCTR1_FSSEL_32; + break; + case 44100: + v = IPORTMXCTR1_FSSEL_44_1; + break; + case 48000: + v = IPORTMXCTR1_FSSEL_48; + break; + case 88200: + v = IPORTMXCTR1_FSSEL_88_2; + break; + case 96000: + v = IPORTMXCTR1_FSSEL_96; + break; + case 176400: + v = IPORTMXCTR1_FSSEL_176_4; + break; + case 192000: + v = IPORTMXCTR1_FSSEL_192; + break; + default: + dev_err(dev, "Rate not supported(%d)\n", rate); + return -EINVAL; + } + + regmap_update_bits(r, IPORTMXCTR1(sub->swm->iport.map), + IPORTMXCTR1_FSSEL_MASK, v); + } + + return 0; +} + +/** + * aio_port_set_fmt - set format of I2S data + * @sub: the AIO substream pointer, PCM substream only + * This parameter has no effect if substream is I2S or PCM. + * + * Set suitable I2S format settings to input/output port block of AIO. + * Parameter is specified by set_fmt(). + * + * This function may return error if non-PCM substream. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_port_set_fmt(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + struct device *dev = &sub->aio->chip->pdev->dev; + u32 v; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + switch (sub->aio->fmt) { + case SND_SOC_DAIFMT_LEFT_J: + v = OPORTMXCTR1_I2SLRSEL_LEFT; + break; + case SND_SOC_DAIFMT_RIGHT_J: + v = OPORTMXCTR1_I2SLRSEL_RIGHT; + break; + case SND_SOC_DAIFMT_I2S: + v = OPORTMXCTR1_I2SLRSEL_I2S; + break; + default: + dev_err(dev, "Format is not supported(%d)\n", + sub->aio->fmt); + return -EINVAL; + } + + v |= OPORTMXCTR1_OUTBITSEL_24; + regmap_update_bits(r, OPORTMXCTR1(sub->swm->oport.map), + OPORTMXCTR1_I2SLRSEL_MASK | + OPORTMXCTR1_OUTBITSEL_MASK, v); + } else { + switch (sub->aio->fmt) { + case SND_SOC_DAIFMT_LEFT_J: + v = IPORTMXCTR1_LRSEL_LEFT; + break; + case SND_SOC_DAIFMT_RIGHT_J: + v = IPORTMXCTR1_LRSEL_RIGHT; + break; + case SND_SOC_DAIFMT_I2S: + v = IPORTMXCTR1_LRSEL_I2S; + break; + default: + dev_err(dev, "Format is not supported(%d)\n", + sub->aio->fmt); + return -EINVAL; + } + + v |= IPORTMXCTR1_OUTBITSEL_24 | + IPORTMXCTR1_CHSEL_ALL; + regmap_update_bits(r, IPORTMXCTR1(sub->swm->iport.map), + IPORTMXCTR1_LRSEL_MASK | + IPORTMXCTR1_OUTBITSEL_MASK | + IPORTMXCTR1_CHSEL_MASK, v); + } + + return 0; +} + +/** + * aio_port_set_clk - set clock and divider of AIO port block + * @sub: the AIO substream pointer + * + * Set suitable PLL clock divider and relational settings to + * input/output port block of AIO. Parameters are specified by + * set_sysclk() and set_pll(). + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_port_set_clk(struct uniphier_aio_sub *sub) +{ + struct uniphier_aio_chip *chip = sub->aio->chip; + struct device *dev = &sub->aio->chip->pdev->dev; + struct regmap *r = sub->aio->chip->regmap; + u32 v_pll[] = { + OPORTMXCTR2_ACLKSEL_A1, OPORTMXCTR2_ACLKSEL_F1, + OPORTMXCTR2_ACLKSEL_A2, OPORTMXCTR2_ACLKSEL_F2, + OPORTMXCTR2_ACLKSEL_A2PLL, + OPORTMXCTR2_ACLKSEL_RX1, + }; + u32 v_div[] = { + OPORTMXCTR2_DACCKSEL_1_2, OPORTMXCTR2_DACCKSEL_1_3, + OPORTMXCTR2_DACCKSEL_1_1, OPORTMXCTR2_DACCKSEL_2_3, + }; + u32 v; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + if (sub->swm->type == PORT_TYPE_I2S) { + if (sub->aio->pll_out >= ARRAY_SIZE(v_pll)) { + dev_err(dev, "PLL(%d) is invalid\n", + sub->aio->pll_out); + return -EINVAL; + } + if (sub->aio->plldiv >= ARRAY_SIZE(v_div)) { + dev_err(dev, "PLL divider(%d) is invalid\n", + sub->aio->plldiv); + return -EINVAL; + } + + v = v_pll[sub->aio->pll_out] | + OPORTMXCTR2_MSSEL_MASTER | + v_div[sub->aio->plldiv]; + + switch (chip->plls[sub->aio->pll_out].freq) { + case 0: + case 36864000: + case 33868800: + v |= OPORTMXCTR2_EXTLSIFSSEL_36; + break; + default: + v |= OPORTMXCTR2_EXTLSIFSSEL_24; + break; + } + } else if (sub->swm->type == PORT_TYPE_EVE) { + v = OPORTMXCTR2_ACLKSEL_A2PLL | + OPORTMXCTR2_MSSEL_MASTER | + OPORTMXCTR2_EXTLSIFSSEL_36 | + OPORTMXCTR2_DACCKSEL_1_2; + } else { + if (sub->aio->pll_out >= ARRAY_SIZE(v_pll)) { + dev_err(dev, "PLL(%d) is invalid\n", + sub->aio->pll_out); + return -EINVAL; + } + v = v_pll[sub->aio->pll_out] | + OPORTMXCTR2_MSSEL_MASTER | + OPORTMXCTR2_DACCKSEL_1_2; + + switch (chip->plls[sub->aio->pll_out].freq) { + case 0: + case 36864000: + case 33868800: + v |= OPORTMXCTR2_EXTLSIFSSEL_36; + break; + default: + v |= OPORTMXCTR2_EXTLSIFSSEL_24; + break; + } + } + regmap_write(r, OPORTMXCTR2(sub->swm->oport.map), v); + } else { + v = IPORTMXCTR2_ACLKSEL_A1 | + IPORTMXCTR2_MSSEL_SLAVE | + IPORTMXCTR2_EXTLSIFSSEL_36 | + IPORTMXCTR2_DACCKSEL_1_2; + regmap_write(r, IPORTMXCTR2(sub->swm->iport.map), v); + } + + return 0; +} + +/** + * aio_port_set_param - set parameters of AIO port block + * @sub: the AIO substream pointer + * @pass_through: Zero if sound data is LPCM, otherwise if data is not LPCM. + * This parameter has no effect if substream is I2S or PCM. + * @params: hardware parameters of ALSA + * + * Set suitable setting to input/output port block of AIO to process the + * specified in params. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_port_set_param(struct uniphier_aio_sub *sub, int pass_through, + const struct snd_pcm_hw_params *params) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 v; + int ret; + + if (!pass_through) { + ret = aio_port_set_rate(sub, params_rate(params)); + if (ret) + return ret; + + ret = aio_port_set_fmt(sub); + if (ret) + return ret; + } + + ret = aio_port_set_clk(sub); + if (ret) + return ret; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + if (pass_through) + v = OPORTMXCTR3_SRCSEL_STREAM | + OPORTMXCTR3_VALID_STREAM; + else + v = OPORTMXCTR3_SRCSEL_PCM | + OPORTMXCTR3_VALID_PCM; + + v |= OPORTMXCTR3_IECTHUR_IECOUT | + OPORTMXCTR3_PMSEL_PAUSE | + OPORTMXCTR3_PMSW_MUTE_OFF; + regmap_write(r, OPORTMXCTR3(sub->swm->oport.map), v); + } else { + regmap_write(r, IPORTMXACLKSEL0EX(sub->swm->iport.map), + IPORTMXACLKSEL0EX_ACLKSEL0EX_INTERNAL); + regmap_write(r, IPORTMXEXNOE(sub->swm->iport.map), + IPORTMXEXNOE_PCMINOE_INPUT); + } + + return 0; +} + +/** + * aio_port_set_enable - start or stop of AIO port block + * @sub: the AIO substream pointer + * @enable: zero to stop the block, otherwise to start + * + * Start or stop the signal input/output port block of AIO. + */ +void aio_port_set_enable(struct uniphier_aio_sub *sub, int enable) +{ + struct regmap *r = sub->aio->chip->regmap; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + regmap_write(r, OPORTMXPATH(sub->swm->oport.map), + sub->swm->oif.map); + + regmap_update_bits(r, OPORTMXMASK(sub->swm->oport.map), + OPORTMXMASK_IUDXMSK_MASK | + OPORTMXMASK_IUXCKMSK_MASK | + OPORTMXMASK_DXMSK_MASK | + OPORTMXMASK_XCKMSK_MASK, + OPORTMXMASK_IUDXMSK_OFF | + OPORTMXMASK_IUXCKMSK_OFF | + OPORTMXMASK_DXMSK_OFF | + OPORTMXMASK_XCKMSK_OFF); + + if (enable) + regmap_write(r, AOUTENCTR0, BIT(sub->swm->oport.map)); + else + regmap_write(r, AOUTENCTR1, BIT(sub->swm->oport.map)); + } else { + regmap_update_bits(r, IPORTMXMASK(sub->swm->iport.map), + IPORTMXMASK_IUXCKMSK_MASK | + IPORTMXMASK_XCKMSK_MASK, + IPORTMXMASK_IUXCKMSK_OFF | + IPORTMXMASK_XCKMSK_OFF); + + if (enable) + regmap_update_bits(r, + IPORTMXCTR2(sub->swm->iport.map), + IPORTMXCTR2_REQEN_MASK, + IPORTMXCTR2_REQEN_ENABLE); + else + regmap_update_bits(r, + IPORTMXCTR2(sub->swm->iport.map), + IPORTMXCTR2_REQEN_MASK, + IPORTMXCTR2_REQEN_DISABLE); + } +} + +/** + * aio_if_set_param - set parameters of AIO DMA I/F block + * @sub: the AIO substream pointer + * @pass_through: Zero if sound data is LPCM, otherwise if data is not LPCM. + * This parameter has no effect if substream is I2S or PCM. + * + * Set suitable setting to DMA interface block of AIO to process the + * specified in settings. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_if_set_param(struct uniphier_aio_sub *sub, int pass_through) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 v; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + if (pass_through) + v = PBOUTMXCTR0_ENDIAN_0123 | + PBOUTMXCTR0_MEMFMT_STREAM; + else + v = PBOUTMXCTR0_ENDIAN_3210 | + PBOUTMXCTR0_MEMFMT_2CH; + + regmap_write(r, PBOUTMXCTR0(sub->swm->oif.map), v); + regmap_write(r, PBOUTMXCTR1(sub->swm->oif.map), 0); + } else { + regmap_write(r, PBINMXCTR(sub->swm->iif.map), + PBINMXCTR_NCONNECT_CONNECT | + PBINMXCTR_INOUTSEL_IN | + (sub->swm->iport.map << PBINMXCTR_PBINSEL_SHIFT) | + PBINMXCTR_ENDIAN_3210 | + PBINMXCTR_MEMFMT_D0); + } + + return 0; +} + +/** + * aio_oport_set_stream_type - set parameters of AIO playback port block + * @sub: the AIO substream pointer + * @pc: Pc type of IEC61937 + * + * Set special setting to output port block of AIO to output the stream + * via S/PDIF. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_oport_set_stream_type(struct uniphier_aio_sub *sub, + enum IEC61937_PC pc) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 repet = 0, pause = OPORTMXPAUDAT_PAUSEPC_CMN; + + switch (pc) { + case IEC61937_PC_AC3: + repet = OPORTMXREPET_STRLENGTH_AC3 | + OPORTMXREPET_PMLENGTH_AC3; + pause |= OPORTMXPAUDAT_PAUSEPD_AC3; + break; + case IEC61937_PC_MPA: + repet = OPORTMXREPET_STRLENGTH_MPA | + OPORTMXREPET_PMLENGTH_MPA; + pause |= OPORTMXPAUDAT_PAUSEPD_MPA; + break; + case IEC61937_PC_MP3: + repet = OPORTMXREPET_STRLENGTH_MP3 | + OPORTMXREPET_PMLENGTH_MP3; + pause |= OPORTMXPAUDAT_PAUSEPD_MP3; + break; + case IEC61937_PC_DTS1: + repet = OPORTMXREPET_STRLENGTH_DTS1 | + OPORTMXREPET_PMLENGTH_DTS1; + pause |= OPORTMXPAUDAT_PAUSEPD_DTS1; + break; + case IEC61937_PC_DTS2: + repet = OPORTMXREPET_STRLENGTH_DTS2 | + OPORTMXREPET_PMLENGTH_DTS2; + pause |= OPORTMXPAUDAT_PAUSEPD_DTS2; + break; + case IEC61937_PC_DTS3: + repet = OPORTMXREPET_STRLENGTH_DTS3 | + OPORTMXREPET_PMLENGTH_DTS3; + pause |= OPORTMXPAUDAT_PAUSEPD_DTS3; + break; + case IEC61937_PC_AAC: + repet = OPORTMXREPET_STRLENGTH_AAC | + OPORTMXREPET_PMLENGTH_AAC; + pause |= OPORTMXPAUDAT_PAUSEPD_AAC; + break; + case IEC61937_PC_PAUSE: + /* Do nothing */ + break; + } + + regmap_write(r, OPORTMXREPET(sub->swm->oport.map), repet); + regmap_write(r, OPORTMXPAUDAT(sub->swm->oport.map), pause); + + return 0; +} + +/** + * aio_src_reset - reset AIO SRC block + * @sub: the AIO substream pointer + * + * Resets the digital signal input/output port with sampling rate converter + * block of AIO. + * This function has no effect if substream is not supported rate converter. + */ +void aio_src_reset(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + + if (sub->swm->dir != PORT_DIR_OUTPUT) + return; + + regmap_write(r, AOUTSRCRSTCTR0, BIT(sub->swm->oport.map)); + regmap_write(r, AOUTSRCRSTCTR1, BIT(sub->swm->oport.map)); +} + +/** + * aio_src_set_param - set parameters of AIO SRC block + * @sub: the AIO substream pointer + * @params: hardware parameters of ALSA + * + * Set suitable setting to input/output port with sampling rate converter + * block of AIO to process the specified in params. + * This function has no effect if substream is not supported rate converter. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int aio_src_set_param(struct uniphier_aio_sub *sub, + const struct snd_pcm_hw_params *params) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 v; + + if (sub->swm->dir != PORT_DIR_OUTPUT) + return 0; + + regmap_write(r, OPORTMXSRC1CTR(sub->swm->oport.map), + OPORTMXSRC1CTR_THMODE_SRC | + OPORTMXSRC1CTR_SRCPATH_CALC | + OPORTMXSRC1CTR_SYNC_ASYNC | + OPORTMXSRC1CTR_FSIIPSEL_INNER | + OPORTMXSRC1CTR_FSISEL_ACLK); + + switch (params_rate(params)) { + default: + case 48000: + v = OPORTMXRATE_I_ACLKSEL_APLLA1 | + OPORTMXRATE_I_MCKSEL_36 | + OPORTMXRATE_I_FSSEL_48; + break; + case 44100: + v = OPORTMXRATE_I_ACLKSEL_APLLA2 | + OPORTMXRATE_I_MCKSEL_33 | + OPORTMXRATE_I_FSSEL_44_1; + break; + case 32000: + v = OPORTMXRATE_I_ACLKSEL_APLLA1 | + OPORTMXRATE_I_MCKSEL_36 | + OPORTMXRATE_I_FSSEL_32; + break; + } + + regmap_write(r, OPORTMXRATE_I(sub->swm->oport.map), + v | OPORTMXRATE_I_ACLKSRC_APLL | + OPORTMXRATE_I_LRCKSTP_STOP); + regmap_update_bits(r, OPORTMXRATE_I(sub->swm->oport.map), + OPORTMXRATE_I_LRCKSTP_MASK, + OPORTMXRATE_I_LRCKSTP_START); + + return 0; +} + +int aio_srcif_set_param(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + + regmap_write(r, PBINMXCTR(sub->swm->iif.map), + PBINMXCTR_NCONNECT_CONNECT | + PBINMXCTR_INOUTSEL_OUT | + (sub->swm->oport.map << PBINMXCTR_PBINSEL_SHIFT) | + PBINMXCTR_ENDIAN_3210 | + PBINMXCTR_MEMFMT_D0); + + return 0; +} + +int aio_srcch_set_param(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + + regmap_write(r, CDA2D_CHMXCTRL1(sub->swm->och.map), + CDA2D_CHMXCTRL1_INDSIZE_INFINITE); + + regmap_write(r, CDA2D_CHMXSRCAMODE(sub->swm->och.map), + CDA2D_CHMXAMODE_ENDIAN_3210 | + CDA2D_CHMXAMODE_AUPDT_FIX | + CDA2D_CHMXAMODE_TYPE_NORMAL); + + regmap_write(r, CDA2D_CHMXDSTAMODE(sub->swm->och.map), + CDA2D_CHMXAMODE_ENDIAN_3210 | + CDA2D_CHMXAMODE_AUPDT_INC | + CDA2D_CHMXAMODE_TYPE_RING | + (sub->swm->och.map << CDA2D_CHMXAMODE_RSSEL_SHIFT)); + + return 0; +} + +void aio_srcch_set_enable(struct uniphier_aio_sub *sub, int enable) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 v; + + if (enable) + v = CDA2D_STRT0_STOP_START; + else + v = CDA2D_STRT0_STOP_STOP; + + regmap_write(r, CDA2D_STRT0, + v | BIT(sub->swm->och.map)); +} + +int aiodma_ch_set_param(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 v; + + regmap_write(r, CDA2D_CHMXCTRL1(sub->swm->ch.map), + CDA2D_CHMXCTRL1_INDSIZE_INFINITE); + + v = CDA2D_CHMXAMODE_ENDIAN_3210 | + CDA2D_CHMXAMODE_AUPDT_INC | + CDA2D_CHMXAMODE_TYPE_NORMAL | + (sub->swm->rb.map << CDA2D_CHMXAMODE_RSSEL_SHIFT); + if (sub->swm->dir == PORT_DIR_OUTPUT) + regmap_write(r, CDA2D_CHMXSRCAMODE(sub->swm->ch.map), v); + else + regmap_write(r, CDA2D_CHMXDSTAMODE(sub->swm->ch.map), v); + + return 0; +} + +void aiodma_ch_set_enable(struct uniphier_aio_sub *sub, int enable) +{ + struct regmap *r = sub->aio->chip->regmap; + + if (enable) { + regmap_write(r, CDA2D_STRT0, + CDA2D_STRT0_STOP_START | BIT(sub->swm->ch.map)); + + regmap_update_bits(r, INTRBIM(0), + BIT(sub->swm->rb.map), + BIT(sub->swm->rb.map)); + } else { + regmap_write(r, CDA2D_STRT0, + CDA2D_STRT0_STOP_STOP | BIT(sub->swm->ch.map)); + + regmap_update_bits(r, INTRBIM(0), + BIT(sub->swm->rb.map), + 0); + } +} + +u64 aiodma_rb_get_rp(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 pos_u, pos_l; + int i; + + regmap_write(r, CDA2D_RDPTRLOAD, + CDA2D_RDPTRLOAD_LSFLAG_STORE | BIT(sub->swm->rb.map)); + /* Wait for setup */ + for (i = 0; i < 6; i++) + regmap_read(r, CDA2D_RBMXRDPTR(sub->swm->rb.map), &pos_l); + + regmap_read(r, CDA2D_RBMXRDPTR(sub->swm->rb.map), &pos_l); + regmap_read(r, CDA2D_RBMXRDPTRU(sub->swm->rb.map), &pos_u); + pos_u = FIELD_GET(CDA2D_RBMXPTRU_PTRU_MASK, pos_u); + + return ((u64)pos_u << 32) | pos_l; +} + +static void aiodma_rb_set_rp(struct uniphier_aio_sub *sub, u64 pos) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 tmp; + int i; + + regmap_write(r, CDA2D_RBMXRDPTR(sub->swm->rb.map), (u32)pos); + regmap_write(r, CDA2D_RBMXRDPTRU(sub->swm->rb.map), (u32)(pos >> 32)); + regmap_write(r, CDA2D_RDPTRLOAD, BIT(sub->swm->rb.map)); + /* Wait for setup */ + for (i = 0; i < 6; i++) + regmap_read(r, CDA2D_RBMXRDPTR(sub->swm->rb.map), &tmp); +} + +static u64 aiodma_rb_get_wp(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 pos_u, pos_l; + int i; + + regmap_write(r, CDA2D_WRPTRLOAD, + CDA2D_WRPTRLOAD_LSFLAG_STORE | BIT(sub->swm->rb.map)); + /* Wait for setup */ + for (i = 0; i < 6; i++) + regmap_read(r, CDA2D_RBMXWRPTR(sub->swm->rb.map), &pos_l); + + regmap_read(r, CDA2D_RBMXWRPTR(sub->swm->rb.map), &pos_l); + regmap_read(r, CDA2D_RBMXWRPTRU(sub->swm->rb.map), &pos_u); + pos_u = FIELD_GET(CDA2D_RBMXPTRU_PTRU_MASK, pos_u); + + return ((u64)pos_u << 32) | pos_l; +} + +static void aiodma_rb_set_wp(struct uniphier_aio_sub *sub, u64 pos) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 tmp; + int i; + + regmap_write(r, CDA2D_RBMXWRPTR(sub->swm->rb.map), + lower_32_bits(pos)); + regmap_write(r, CDA2D_RBMXWRPTRU(sub->swm->rb.map), + upper_32_bits(pos)); + regmap_write(r, CDA2D_WRPTRLOAD, BIT(sub->swm->rb.map)); + /* Wait for setup */ + for (i = 0; i < 6; i++) + regmap_read(r, CDA2D_RBMXWRPTR(sub->swm->rb.map), &tmp); +} + +int aiodma_rb_set_threshold(struct uniphier_aio_sub *sub, u64 size, u32 th) +{ + struct regmap *r = sub->aio->chip->regmap; + + if (size <= th) + return -EINVAL; + + regmap_write(r, CDA2D_RBMXBTH(sub->swm->rb.map), th); + regmap_write(r, CDA2D_RBMXRTH(sub->swm->rb.map), th); + + return 0; +} + +int aiodma_rb_set_buffer(struct uniphier_aio_sub *sub, u64 start, u64 end, + int period) +{ + struct regmap *r = sub->aio->chip->regmap; + u64 size = end - start; + int ret; + + if (end < start || period < 0) + return -EINVAL; + + regmap_write(r, CDA2D_RBMXCNFG(sub->swm->rb.map), 0); + regmap_write(r, CDA2D_RBMXBGNADRS(sub->swm->rb.map), + lower_32_bits(start)); + regmap_write(r, CDA2D_RBMXBGNADRSU(sub->swm->rb.map), + upper_32_bits(start)); + regmap_write(r, CDA2D_RBMXENDADRS(sub->swm->rb.map), + lower_32_bits(end)); + regmap_write(r, CDA2D_RBMXENDADRSU(sub->swm->rb.map), + upper_32_bits(end)); + + regmap_write(r, CDA2D_RBADRSLOAD, BIT(sub->swm->rb.map)); + + ret = aiodma_rb_set_threshold(sub, size, 2 * period); + if (ret) + return ret; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + aiodma_rb_set_rp(sub, start); + aiodma_rb_set_wp(sub, end - period); + + regmap_update_bits(r, CDA2D_RBMXIE(sub->swm->rb.map), + CDA2D_RBMXIX_SPACE, + CDA2D_RBMXIX_SPACE); + } else { + aiodma_rb_set_rp(sub, end - period); + aiodma_rb_set_wp(sub, start); + + regmap_update_bits(r, CDA2D_RBMXIE(sub->swm->rb.map), + CDA2D_RBMXIX_REMAIN, + CDA2D_RBMXIX_REMAIN); + } + + sub->threshold = 2 * period; + sub->rd_offs = 0; + sub->wr_offs = 0; + sub->rd_org = 0; + sub->wr_org = 0; + sub->rd_total = 0; + sub->wr_total = 0; + + return 0; +} + +void aiodma_rb_sync(struct uniphier_aio_sub *sub, u64 start, u64 size, + int period) +{ + if (sub->swm->dir == PORT_DIR_OUTPUT) { + sub->rd_offs = aiodma_rb_get_rp(sub) - start; + + if (sub->use_mmap) { + sub->threshold = 2 * period; + aiodma_rb_set_threshold(sub, size, 2 * period); + + sub->wr_offs = sub->rd_offs - period; + if (sub->rd_offs < period) + sub->wr_offs += size; + } + aiodma_rb_set_wp(sub, sub->wr_offs + start); + } else { + sub->wr_offs = aiodma_rb_get_wp(sub) - start; + + if (sub->use_mmap) { + sub->threshold = 2 * period; + aiodma_rb_set_threshold(sub, size, 2 * period); + + sub->rd_offs = sub->wr_offs - period; + if (sub->wr_offs < period) + sub->rd_offs += size; + } + aiodma_rb_set_rp(sub, sub->rd_offs + start); + } + + sub->rd_total += sub->rd_offs - sub->rd_org; + if (sub->rd_offs < sub->rd_org) + sub->rd_total += size; + sub->wr_total += sub->wr_offs - sub->wr_org; + if (sub->wr_offs < sub->wr_org) + sub->wr_total += size; + + sub->rd_org = sub->rd_offs; + sub->wr_org = sub->wr_offs; +} + +bool aiodma_rb_is_irq(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + u32 ir; + + regmap_read(r, CDA2D_RBMXIR(sub->swm->rb.map), &ir); + + if (sub->swm->dir == PORT_DIR_OUTPUT) + return !!(ir & CDA2D_RBMXIX_SPACE); + else + return !!(ir & CDA2D_RBMXIX_REMAIN); +} + +void aiodma_rb_clear_irq(struct uniphier_aio_sub *sub) +{ + struct regmap *r = sub->aio->chip->regmap; + + if (sub->swm->dir == PORT_DIR_OUTPUT) + regmap_write(r, CDA2D_RBMXIR(sub->swm->rb.map), + CDA2D_RBMXIX_SPACE); + else + regmap_write(r, CDA2D_RBMXIR(sub->swm->rb.map), + CDA2D_RBMXIX_REMAIN); +} diff --git a/sound/soc/uniphier/aio-reg.h b/sound/soc/uniphier/aio-reg.h new file mode 100644 index 000000000000..eaf2c65acf14 --- /dev/null +++ b/sound/soc/uniphier/aio-reg.h @@ -0,0 +1,462 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Socionext UniPhier AIO ALSA driver. + * + * Copyright (c) 2016-2018 Socionext Inc. + * + * 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; version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef SND_UNIPHIER_AIO_REG_H__ +#define SND_UNIPHIER_AIO_REG_H__ + +#include + +/* SW view */ +#define A2CHNMAPCTR0(n) (0x00000 + 0x40 * (n)) +#define A2RBNMAPCTR0(n) (0x01000 + 0x40 * (n)) +#define A2IPORTNMAPCTR0(n) (0x02000 + 0x40 * (n)) +#define A2IPORTNMAPCTR1(n) (0x02004 + 0x40 * (n)) +#define A2IIFNMAPCTR0(n) (0x03000 + 0x40 * (n)) +#define A2OPORTNMAPCTR0(n) (0x04000 + 0x40 * (n)) +#define A2OPORTNMAPCTR1(n) (0x04004 + 0x40 * (n)) +#define A2OPORTNMAPCTR2(n) (0x04008 + 0x40 * (n)) +#define A2OIFNMAPCTR0(n) (0x05000 + 0x40 * (n)) +#define A2ATNMAPCTR0(n) (0x06000 + 0x40 * (n)) + +#define MAPCTR0_EN 0x80000000 + +/* CTL */ +#define A2APLLCTR0 0x07000 +#define A2APLLCTR0_APLLXPOW_MASK GENMASK(3, 0) +#define A2APLLCTR0_APLLXPOW_PWOFF (0x0 << 0) +#define A2APLLCTR0_APLLXPOW_PWON (0xf << 0) +#define A2APLLCTR1 0x07004 +#define A2APLLCTR1_APLLX_MASK 0x00010101 +#define A2APLLCTR1_APLLX_36MHZ 0x00000000 +#define A2APLLCTR1_APLLX_33MHZ 0x00000001 +#define A2EXMCLKSEL0 0x07030 +#define A2EXMCLKSEL0_EXMCLK_MASK GENMASK(2, 0) +#define A2EXMCLKSEL0_EXMCLK_OUTPUT (0x0 << 0) +#define A2EXMCLKSEL0_EXMCLK_INPUT (0x7 << 0) +#define A2SSIFSW 0x07050 +#define A2CH22_2CTR 0x07054 +#define A2AIOINPUTSEL 0x070e0 +#define A2AIOINPUTSEL_RXSEL_PCMI1_MASK GENMASK(2, 0) +#define A2AIOINPUTSEL_RXSEL_PCMI1_HDMIRX1 (0x2 << 0) +#define A2AIOINPUTSEL_RXSEL_PCMI2_MASK GENMASK(6, 4) +#define A2AIOINPUTSEL_RXSEL_PCMI2_SIF (0x7 << 4) +#define A2AIOINPUTSEL_RXSEL_PCMI3_MASK GENMASK(10, 8) +#define A2AIOINPUTSEL_RXSEL_PCMI3_EVEA (0x1 << 8) +#define A2AIOINPUTSEL_RXSEL_IECI1_MASK GENMASK(14, 12) +#define A2AIOINPUTSEL_RXSEL_IECI1_HDMIRX1 (0x2 << 12) +#define A2AIOINPUTSEL_RXSEL_MASK (A2AIOINPUTSEL_RXSEL_PCMI1_MASK | \ + A2AIOINPUTSEL_RXSEL_PCMI2_MASK | \ + A2AIOINPUTSEL_RXSEL_PCMI3_MASK | \ + A2AIOINPUTSEL_RXSEL_IECI1_HDMIRX1) + +/* INTC */ +#define INTCHIM(m) (0x9028 + 0x80 * (m)) +#define INTRBIM(m) (0x9030 + 0x80 * (m)) +#define INTCHID(m) (0xa028 + 0x80 * (m)) +#define INTRBID(m) (0xa030 + 0x80 * (m)) + +/* AIN(PCMINN) */ +#define IPORTMXCTR1(n) (0x22000 + 0x400 * (n)) +#define IPORTMXCTR1_LRSEL_MASK GENMASK(11, 10) +#define IPORTMXCTR1_LRSEL_RIGHT (0x0 << 10) +#define IPORTMXCTR1_LRSEL_LEFT (0x1 << 10) +#define IPORTMXCTR1_LRSEL_I2S (0x2 << 10) +#define IPORTMXCTR1_OUTBITSEL_MASK (0x800003U << 8) +#define IPORTMXCTR1_OUTBITSEL_32 (0x800000U << 8) +#define IPORTMXCTR1_OUTBITSEL_24 (0x000000U << 8) +#define IPORTMXCTR1_OUTBITSEL_20 (0x000001U << 8) +#define IPORTMXCTR1_OUTBITSEL_16 (0x000002U << 8) +#define IPORTMXCTR1_CHSEL_MASK GENMASK(6, 4) +#define IPORTMXCTR1_CHSEL_ALL (0x0 << 4) +#define IPORTMXCTR1_CHSEL_D0_D2 (0x1 << 4) +#define IPORTMXCTR1_CHSEL_D0 (0x2 << 4) +#define IPORTMXCTR1_CHSEL_D1 (0x3 << 4) +#define IPORTMXCTR1_CHSEL_D2 (0x4 << 4) +#define IPORTMXCTR1_CHSEL_DMIX (0x5 << 4) +#define IPORTMXCTR1_FSSEL_MASK GENMASK(3, 0) +#define IPORTMXCTR1_FSSEL_48 (0x0 << 0) +#define IPORTMXCTR1_FSSEL_96 (0x1 << 0) +#define IPORTMXCTR1_FSSEL_192 (0x2 << 0) +#define IPORTMXCTR1_FSSEL_32 (0x3 << 0) +#define IPORTMXCTR1_FSSEL_44_1 (0x4 << 0) +#define IPORTMXCTR1_FSSEL_88_2 (0x5 << 0) +#define IPORTMXCTR1_FSSEL_176_4 (0x6 << 0) +#define IPORTMXCTR1_FSSEL_16 (0x8 << 0) +#define IPORTMXCTR1_FSSEL_22_05 (0x9 << 0) +#define IPORTMXCTR1_FSSEL_24 (0xa << 0) +#define IPORTMXCTR1_FSSEL_8 (0xb << 0) +#define IPORTMXCTR1_FSSEL_11_025 (0xc << 0) +#define IPORTMXCTR1_FSSEL_12 (0xd << 0) +#define IPORTMXCTR2(n) (0x22004 + 0x400 * (n)) +#define IPORTMXCTR2_ACLKSEL_MASK GENMASK(19, 16) +#define IPORTMXCTR2_ACLKSEL_A1 (0x0 << 16) +#define IPORTMXCTR2_ACLKSEL_F1 (0x1 << 16) +#define IPORTMXCTR2_ACLKSEL_A2 (0x2 << 16) +#define IPORTMXCTR2_ACLKSEL_F2 (0x3 << 16) +#define IPORTMXCTR2_ACLKSEL_A2PLL (0x4 << 16) +#define IPORTMXCTR2_ACLKSEL_RX1 (0x5 << 16) +#define IPORTMXCTR2_ACLKSEL_RX2 (0x6 << 16) +#define IPORTMXCTR2_MSSEL_MASK BIT(15) +#define IPORTMXCTR2_MSSEL_SLAVE (0x0 << 15) +#define IPORTMXCTR2_MSSEL_MASTER (0x1 << 15) +#define IPORTMXCTR2_EXTLSIFSSEL_MASK BIT(14) +#define IPORTMXCTR2_EXTLSIFSSEL_36 (0x0 << 14) +#define IPORTMXCTR2_EXTLSIFSSEL_24 (0x1 << 14) +#define IPORTMXCTR2_DACCKSEL_MASK GENMASK(9, 8) +#define IPORTMXCTR2_DACCKSEL_1_2 (0x0 << 8) +#define IPORTMXCTR2_DACCKSEL_1_3 (0x1 << 8) +#define IPORTMXCTR2_DACCKSEL_1_1 (0x2 << 8) +#define IPORTMXCTR2_DACCKSEL_2_3 (0x3 << 8) +#define IPORTMXCTR2_REQEN_MASK BIT(0) +#define IPORTMXCTR2_REQEN_DISABLE (0x0 << 0) +#define IPORTMXCTR2_REQEN_ENABLE (0x1 << 0) +#define IPORTMXCNTCTR(n) (0x22010 + 0x400 * (n)) +#define IPORTMXCOUNTER(n) (0x22014 + 0x400 * (n)) +#define IPORTMXCNTMONI(n) (0x22018 + 0x400 * (n)) +#define IPORTMXACLKSEL0EX(n) (0x22020 + 0x400 * (n)) +#define IPORTMXACLKSEL0EX_ACLKSEL0EX_MASK GENMASK(3, 0) +#define IPORTMXACLKSEL0EX_ACLKSEL0EX_INTERNAL (0x0 << 0) +#define IPORTMXACLKSEL0EX_ACLKSEL0EX_EXTERNAL (0xf << 0) +#define IPORTMXEXNOE(n) (0x22070 + 0x400 * (n)) +#define IPORTMXEXNOE_PCMINOE_MASK BIT(0) +#define IPORTMXEXNOE_PCMINOE_OUTPUT (0x0 << 0) +#define IPORTMXEXNOE_PCMINOE_INPUT (0x1 << 0) +#define IPORTMXMASK(n) (0x22078 + 0x400 * (n)) +#define IPORTMXMASK_IUXCKMSK_MASK GENMASK(18, 16) +#define IPORTMXMASK_IUXCKMSK_ON (0x0 << 16) +#define IPORTMXMASK_IUXCKMSK_OFF (0x7 << 16) +#define IPORTMXMASK_XCKMSK_MASK GENMASK(2, 0) +#define IPORTMXMASK_XCKMSK_ON (0x0 << 0) +#define IPORTMXMASK_XCKMSK_OFF (0x7 << 0) +#define IPORTMXRSTCTR(n) (0x2207c + 0x400 * (n)) +#define IPORTMXRSTCTR_RSTPI_MASK BIT(7) +#define IPORTMXRSTCTR_RSTPI_RELEASE (0x0 << 7) +#define IPORTMXRSTCTR_RSTPI_RESET (0x1 << 7) + +/* AIN(PBinMX) */ +#define PBINMXCTR(n) (0x20200 + 0x40 * (n)) +#define PBINMXCTR_NCONNECT_MASK BIT(15) +#define PBINMXCTR_NCONNECT_CONNECT (0x0 << 15) +#define PBINMXCTR_NCONNECT_DISCONNECT (0x1 << 15) +#define PBINMXCTR_INOUTSEL_MASK BIT(14) +#define PBINMXCTR_INOUTSEL_IN (0x0 << 14) +#define PBINMXCTR_INOUTSEL_OUT (0x1 << 14) +#define PBINMXCTR_PBINSEL_SHIFT (8) +#define PBINMXCTR_ENDIAN_MASK GENMASK(5, 4) +#define PBINMXCTR_ENDIAN_3210 (0x0 << 4) +#define PBINMXCTR_ENDIAN_0123 (0x1 << 4) +#define PBINMXCTR_ENDIAN_1032 (0x2 << 4) +#define PBINMXCTR_ENDIAN_2301 (0x3 << 4) +#define PBINMXCTR_MEMFMT_MASK GENMASK(3, 0) +#define PBINMXCTR_MEMFMT_D0 (0x0 << 0) +#define PBINMXCTR_MEMFMT_5_1CH_DMIX (0x1 << 0) +#define PBINMXCTR_MEMFMT_6CH (0x2 << 0) +#define PBINMXCTR_MEMFMT_4CH (0x3 << 0) +#define PBINMXCTR_MEMFMT_DMIX (0x4 << 0) +#define PBINMXCTR_MEMFMT_1CH (0x5 << 0) +#define PBINMXCTR_MEMFMT_16LR (0x6 << 0) +#define PBINMXCTR_MEMFMT_7_1CH (0x7 << 0) +#define PBINMXCTR_MEMFMT_7_1CH_DMIX (0x8 << 0) +#define PBINMXCTR_MEMFMT_STREAM (0xf << 0) +#define PBINMXPAUSECTR0(n) (0x20204 + 0x40 * (n)) +#define PBINMXPAUSECTR1(n) (0x20208 + 0x40 * (n)) + +/* AOUT */ +#define AOUTENCTR0 0x40040 +#define AOUTENCTR1 0x40044 +#define AOUTENCTR2 0x40048 +#define AOUTRSTCTR0 0x40060 +#define AOUTRSTCTR1 0x40064 +#define AOUTRSTCTR2 0x40068 +#define AOUTSRCRSTCTR0 0x400c0 +#define AOUTSRCRSTCTR1 0x400c4 +#define AOUTSRCRSTCTR2 0x400c8 + +/* AOUT(PCMOUTN) */ +#define OPORTMXCTR1(n) (0x42000 + 0x400 * (n)) +#define OPORTMXCTR1_I2SLRSEL_MASK (0x11 << 10) +#define OPORTMXCTR1_I2SLRSEL_RIGHT (0x00 << 10) +#define OPORTMXCTR1_I2SLRSEL_LEFT (0x01 << 10) +#define OPORTMXCTR1_I2SLRSEL_I2S (0x11 << 10) +#define OPORTMXCTR1_OUTBITSEL_MASK (0x800003U << 8) +#define OPORTMXCTR1_OUTBITSEL_32 (0x800000U << 8) +#define OPORTMXCTR1_OUTBITSEL_24 (0x000000U << 8) +#define OPORTMXCTR1_OUTBITSEL_20 (0x000001U << 8) +#define OPORTMXCTR1_OUTBITSEL_16 (0x000002U << 8) +#define OPORTMXCTR1_FSSEL_MASK GENMASK(3, 0) +#define OPORTMXCTR1_FSSEL_48 (0x0 << 0) +#define OPORTMXCTR1_FSSEL_96 (0x1 << 0) +#define OPORTMXCTR1_FSSEL_192 (0x2 << 0) +#define OPORTMXCTR1_FSSEL_32 (0x3 << 0) +#define OPORTMXCTR1_FSSEL_44_1 (0x4 << 0) +#define OPORTMXCTR1_FSSEL_88_2 (0x5 << 0) +#define OPORTMXCTR1_FSSEL_176_4 (0x6 << 0) +#define OPORTMXCTR1_FSSEL_16 (0x8 << 0) +#define OPORTMXCTR1_FSSEL_22_05 (0x9 << 0) +#define OPORTMXCTR1_FSSEL_24 (0xa << 0) +#define OPORTMXCTR1_FSSEL_8 (0xb << 0) +#define OPORTMXCTR1_FSSEL_11_025 (0xc << 0) +#define OPORTMXCTR1_FSSEL_12 (0xd << 0) +#define OPORTMXCTR2(n) (0x42004 + 0x400 * (n)) +#define OPORTMXCTR2_ACLKSEL_MASK GENMASK(19, 16) +#define OPORTMXCTR2_ACLKSEL_A1 (0x0 << 16) +#define OPORTMXCTR2_ACLKSEL_F1 (0x1 << 16) +#define OPORTMXCTR2_ACLKSEL_A2 (0x2 << 16) +#define OPORTMXCTR2_ACLKSEL_F2 (0x3 << 16) +#define OPORTMXCTR2_ACLKSEL_A2PLL (0x4 << 16) +#define OPORTMXCTR2_ACLKSEL_RX1 (0x5 << 16) +#define OPORTMXCTR2_ACLKSEL_RX2 (0x6 << 16) +#define OPORTMXCTR2_MSSEL_MASK BIT(15) +#define OPORTMXCTR2_MSSEL_SLAVE (0x0 << 15) +#define OPORTMXCTR2_MSSEL_MASTER (0x1 << 15) +#define OPORTMXCTR2_EXTLSIFSSEL_MASK BIT(14) +#define OPORTMXCTR2_EXTLSIFSSEL_36 (0x0 << 14) +#define OPORTMXCTR2_EXTLSIFSSEL_24 (0x1 << 14) +#define OPORTMXCTR2_DACCKSEL_MASK GENMASK(9, 8) +#define OPORTMXCTR2_DACCKSEL_1_2 (0x0 << 8) +#define OPORTMXCTR2_DACCKSEL_1_3 (0x1 << 8) +#define OPORTMXCTR2_DACCKSEL_1_1 (0x2 << 8) +#define OPORTMXCTR2_DACCKSEL_2_3 (0x3 << 8) +#define OPORTMXCTR3(n) (0x42008 + 0x400 * (n)) +#define OPORTMXCTR3_IECTHUR_MASK BIT(19) +#define OPORTMXCTR3_IECTHUR_IECOUT (0x0 << 19) +#define OPORTMXCTR3_IECTHUR_IECIN (0x1 << 19) +#define OPORTMXCTR3_SRCSEL_MASK GENMASK(18, 16) +#define OPORTMXCTR3_SRCSEL_PCM (0x0 << 16) +#define OPORTMXCTR3_SRCSEL_STREAM (0x1 << 16) +#define OPORTMXCTR3_SRCSEL_CDDTS (0x2 << 16) +#define OPORTMXCTR3_VALID_MASK BIT(12) +#define OPORTMXCTR3_VALID_PCM (0x0 << 12) +#define OPORTMXCTR3_VALID_STREAM (0x1 << 12) +#define OPORTMXCTR3_PMSEL_MASK BIT(3) +#define OPORTMXCTR3_PMSEL_MUTE (0x0 << 3) +#define OPORTMXCTR3_PMSEL_PAUSE (0x1 << 3) +#define OPORTMXCTR3_PMSW_MASK BIT(2) +#define OPORTMXCTR3_PMSW_MUTE_OFF (0x0 << 2) +#define OPORTMXCTR3_PMSW_MUTE_ON (0x1 << 2) +#define OPORTMXSRC1CTR(n) (0x4200c + 0x400 * (n)) +#define OPORTMXSRC1CTR_FSIIPNUM_SHIFT (24) +#define OPORTMXSRC1CTR_THMODE_MASK BIT(23) +#define OPORTMXSRC1CTR_THMODE_SRC (0x0 << 23) +#define OPORTMXSRC1CTR_THMODE_BYPASS (0x1 << 23) +#define OPORTMXSRC1CTR_LOCK_MASK BIT(16) +#define OPORTMXSRC1CTR_LOCK_UNLOCK (0x0 << 16) +#define OPORTMXSRC1CTR_LOCK_LOCK (0x1 << 16) +#define OPORTMXSRC1CTR_SRCPATH_MASK BIT(15) +#define OPORTMXSRC1CTR_SRCPATH_BYPASS (0x0 << 15) +#define OPORTMXSRC1CTR_SRCPATH_CALC (0x1 << 15) +#define OPORTMXSRC1CTR_SYNC_MASK BIT(14) +#define OPORTMXSRC1CTR_SYNC_ASYNC (0x0 << 14) +#define OPORTMXSRC1CTR_SYNC_SYNC (0x1 << 14) +#define OPORTMXSRC1CTR_FSOCK_MASK GENMASK(11, 10) +#define OPORTMXSRC1CTR_FSOCK_44_1 (0x0 << 10) +#define OPORTMXSRC1CTR_FSOCK_48 (0x1 << 10) +#define OPORTMXSRC1CTR_FSOCK_32 (0x2 << 10) +#define OPORTMXSRC1CTR_FSICK_MASK GENMASK(9, 8) +#define OPORTMXSRC1CTR_FSICK_44_1 (0x0 << 8) +#define OPORTMXSRC1CTR_FSICK_48 (0x1 << 8) +#define OPORTMXSRC1CTR_FSICK_32 (0x2 << 8) +#define OPORTMXSRC1CTR_FSIIPSEL_MASK GENMASK(5, 4) +#define OPORTMXSRC1CTR_FSIIPSEL_INNER (0x0 << 4) +#define OPORTMXSRC1CTR_FSIIPSEL_OUTER (0x1 << 4) +#define OPORTMXSRC1CTR_FSISEL_MASK GENMASK(3, 0) +#define OPORTMXSRC1CTR_FSISEL_ACLK (0x0 << 0) +#define OPORTMXSRC1CTR_FSISEL_DD (0x1 << 0) +#define OPORTMXDSDMUTEDAT(n) (0x42020 + 0x400 * (n)) +#define OPORTMXDXDFREQMODE(n) (0x42024 + 0x400 * (n)) +#define OPORTMXDSDSEL(n) (0x42028 + 0x400 * (n)) +#define OPORTMXDSDPORT(n) (0x4202c + 0x400 * (n)) +#define OPORTMXACLKSEL0EX(n) (0x42030 + 0x400 * (n)) +#define OPORTMXPATH(n) (0x42040 + 0x400 * (n)) +#define OPORTMXSYNC(n) (0x42044 + 0x400 * (n)) +#define OPORTMXREPET(n) (0x42050 + 0x400 * (n)) +#define OPORTMXREPET_STRLENGTH_AC3 SBF_(IEC61937_FRM_STR_AC3, 16) +#define OPORTMXREPET_STRLENGTH_MPA SBF_(IEC61937_FRM_STR_MPA, 16) +#define OPORTMXREPET_STRLENGTH_MP3 SBF_(IEC61937_FRM_STR_MP3, 16) +#define OPORTMXREPET_STRLENGTH_DTS1 SBF_(IEC61937_FRM_STR_DTS1, 16) +#define OPORTMXREPET_STRLENGTH_DTS2 SBF_(IEC61937_FRM_STR_DTS2, 16) +#define OPORTMXREPET_STRLENGTH_DTS3 SBF_(IEC61937_FRM_STR_DTS3, 16) +#define OPORTMXREPET_STRLENGTH_AAC SBF_(IEC61937_FRM_STR_AAC, 16) +#define OPORTMXREPET_PMLENGTH_AC3 SBF_(IEC61937_FRM_PAU_AC3, 0) +#define OPORTMXREPET_PMLENGTH_MPA SBF_(IEC61937_FRM_PAU_MPA, 0) +#define OPORTMXREPET_PMLENGTH_MP3 SBF_(IEC61937_FRM_PAU_MP3, 0) +#define OPORTMXREPET_PMLENGTH_DTS1 SBF_(IEC61937_FRM_PAU_DTS1, 0) +#define OPORTMXREPET_PMLENGTH_DTS2 SBF_(IEC61937_FRM_PAU_DTS2, 0) +#define OPORTMXREPET_PMLENGTH_DTS3 SBF_(IEC61937_FRM_PAU_DTS3, 0) +#define OPORTMXREPET_PMLENGTH_AAC SBF_(IEC61937_FRM_PAU_AAC, 0) +#define OPORTMXPAUDAT(n) (0x42054 + 0x400 * (n)) +#define OPORTMXPAUDAT_PAUSEPC_CMN (IEC61937_PC_PAUSE << 16) +#define OPORTMXPAUDAT_PAUSEPD_AC3 (IEC61937_FRM_PAU_AC3 * 4) +#define OPORTMXPAUDAT_PAUSEPD_MPA (IEC61937_FRM_PAU_MPA * 4) +#define OPORTMXPAUDAT_PAUSEPD_MP3 (IEC61937_FRM_PAU_MP3 * 4) +#define OPORTMXPAUDAT_PAUSEPD_DTS1 (IEC61937_FRM_PAU_DTS1 * 4) +#define OPORTMXPAUDAT_PAUSEPD_DTS2 (IEC61937_FRM_PAU_DTS2 * 4) +#define OPORTMXPAUDAT_PAUSEPD_DTS3 (IEC61937_FRM_PAU_DTS3 * 4) +#define OPORTMXPAUDAT_PAUSEPD_AAC (IEC61937_FRM_PAU_AAC * 4) +#define OPORTMXRATE_I(n) (0x420e4 + 0x400 * (n)) +#define OPORTMXRATE_I_EQU_MASK BIT(31) +#define OPORTMXRATE_I_EQU_NOTEQUAL (0x0 << 31) +#define OPORTMXRATE_I_EQU_EQUAL (0x1 << 31) +#define OPORTMXRATE_I_SRCBPMD_MASK BIT(29) +#define OPORTMXRATE_I_SRCBPMD_BYPASS (0x0 << 29) +#define OPORTMXRATE_I_SRCBPMD_SRC (0x1 << 29) +#define OPORTMXRATE_I_LRCKSTP_MASK BIT(24) +#define OPORTMXRATE_I_LRCKSTP_START (0x0 << 24) +#define OPORTMXRATE_I_LRCKSTP_STOP (0x1 << 24) +#define OPORTMXRATE_I_ACLKSRC_MASK GENMASK(15, 12) +#define OPORTMXRATE_I_ACLKSRC_APLL (0x0 << 12) +#define OPORTMXRATE_I_ACLKSRC_USB (0x1 << 12) +#define OPORTMXRATE_I_ACLKSRC_HSC (0x3 << 12) +/* if OPORTMXRATE_I_ACLKSRC_APLL */ +#define OPORTMXRATE_I_ACLKSEL_MASK GENMASK(11, 8) +#define OPORTMXRATE_I_ACLKSEL_APLLA1 (0x0 << 8) +#define OPORTMXRATE_I_ACLKSEL_APLLF1 (0x1 << 8) +#define OPORTMXRATE_I_ACLKSEL_APLLA2 (0x2 << 8) +#define OPORTMXRATE_I_ACLKSEL_APLLF2 (0x3 << 8) +#define OPORTMXRATE_I_ACLKSEL_APLL (0x4 << 8) +#define OPORTMXRATE_I_ACLKSEL_HDMI1 (0x5 << 8) +#define OPORTMXRATE_I_ACLKSEL_HDMI2 (0x6 << 8) +#define OPORTMXRATE_I_ACLKSEL_AI1ADCCK (0xc << 8) +#define OPORTMXRATE_I_ACLKSEL_AI2ADCCK (0xd << 8) +#define OPORTMXRATE_I_ACLKSEL_AI3ADCCK (0xe << 8) +#define OPORTMXRATE_I_MCKSEL_MASK GENMASK(7, 4) +#define OPORTMXRATE_I_MCKSEL_36 (0x0 << 4) +#define OPORTMXRATE_I_MCKSEL_33 (0x1 << 4) +#define OPORTMXRATE_I_MCKSEL_HSC27 (0xb << 4) +#define OPORTMXRATE_I_FSSEL_MASK GENMASK(3, 0) +#define OPORTMXRATE_I_FSSEL_48 (0x0 << 0) +#define OPORTMXRATE_I_FSSEL_96 (0x1 << 0) +#define OPORTMXRATE_I_FSSEL_192 (0x2 << 0) +#define OPORTMXRATE_I_FSSEL_32 (0x3 << 0) +#define OPORTMXRATE_I_FSSEL_44_1 (0x4 << 0) +#define OPORTMXRATE_I_FSSEL_88_2 (0x5 << 0) +#define OPORTMXRATE_I_FSSEL_176_4 (0x6 << 0) +#define OPORTMXRATE_I_FSSEL_16 (0x8 << 0) +#define OPORTMXRATE_I_FSSEL_22_05 (0x9 << 0) +#define OPORTMXRATE_I_FSSEL_24 (0xa << 0) +#define OPORTMXRATE_I_FSSEL_8 (0xb << 0) +#define OPORTMXRATE_I_FSSEL_11_025 (0xc << 0) +#define OPORTMXRATE_I_FSSEL_12 (0xd << 0) +#define OPORTMXEXNOE(n) (0x420f0 + 0x400 * (n)) +#define OPORTMXMASK(n) (0x420f8 + 0x400 * (n)) +#define OPORTMXMASK_IUDXMSK_MASK GENMASK(28, 24) +#define OPORTMXMASK_IUDXMSK_ON (0x00 << 24) +#define OPORTMXMASK_IUDXMSK_OFF (0x1f << 24) +#define OPORTMXMASK_IUXCKMSK_MASK GENMASK(18, 16) +#define OPORTMXMASK_IUXCKMSK_ON (0x0 << 16) +#define OPORTMXMASK_IUXCKMSK_OFF (0x7 << 16) +#define OPORTMXMASK_DXMSK_MASK GENMASK(12, 8) +#define OPORTMXMASK_DXMSK_ON (0x00 << 8) +#define OPORTMXMASK_DXMSK_OFF (0x1f << 8) +#define OPORTMXMASK_XCKMSK_MASK GENMASK(2, 0) +#define OPORTMXMASK_XCKMSK_ON (0x0 << 0) +#define OPORTMXMASK_XCKMSK_OFF (0x7 << 0) +#define OPORTMXDEBUG(n) (0x420fc + 0x400 * (n)) +#define OPORTMXT0RSTCTR(n) (0x4211c + 0x400 * (n)) +#define OPORTMXT1RSTCTR(n) (0x4213c + 0x400 * (n)) +#define OPORTMXT2RSTCTR(n) (0x4215c + 0x400 * (n)) +#define OPORTMXT3RSTCTR(n) (0x4217c + 0x400 * (n)) +#define OPORTMXT4RSTCTR(n) (0x4219c + 0x400 * (n)) + +#define SBF_(frame, shift) (((frame) * 2 - 1) << shift) + +/* AOUT(PBoutMX) */ +#define PBOUTMXCTR0(n) (0x40200 + 0x40 * (n)) +#define PBOUTMXCTR0_ENDIAN_MASK GENMASK(5, 4) +#define PBOUTMXCTR0_ENDIAN_3210 (0x0 << 4) +#define PBOUTMXCTR0_ENDIAN_0123 (0x1 << 4) +#define PBOUTMXCTR0_ENDIAN_1032 (0x2 << 4) +#define PBOUTMXCTR0_ENDIAN_2301 (0x3 << 4) +#define PBOUTMXCTR0_MEMFMT_MASK GENMASK(3, 0) +#define PBOUTMXCTR0_MEMFMT_10CH (0x0 << 0) +#define PBOUTMXCTR0_MEMFMT_8CH (0x1 << 0) +#define PBOUTMXCTR0_MEMFMT_6CH (0x2 << 0) +#define PBOUTMXCTR0_MEMFMT_4CH (0x3 << 0) +#define PBOUTMXCTR0_MEMFMT_2CH (0x4 << 0) +#define PBOUTMXCTR0_MEMFMT_STREAM (0x5 << 0) +#define PBOUTMXCTR0_MEMFMT_1CH (0x6 << 0) +#define PBOUTMXCTR1(n) (0x40204 + 0x40 * (n)) +#define PBOUTMXINTCTR(n) (0x40208 + 0x40 * (n)) + +/* A2D(subsystem) */ +#define CDA2D_STRT0 0x10000 +#define CDA2D_STRT0_STOP_MASK BIT(31) +#define CDA2D_STRT0_STOP_START (0x0 << 31) +#define CDA2D_STRT0_STOP_STOP (0x1 << 31) +#define CDA2D_STAT0 0x10020 +#define CDA2D_TEST 0x100a0 +#define CDA2D_TEST_DDR_MODE_MASK GENMASK(3, 2) +#define CDA2D_TEST_DDR_MODE_EXTON0 (0x0 << 2) +#define CDA2D_TEST_DDR_MODE_EXTOFF1 (0x3 << 2) +#define CDA2D_STRTADRSLOAD 0x100b0 + +#define CDA2D_CHMXCTRL1(n) (0x12000 + 0x80 * (n)) +#define CDA2D_CHMXCTRL1_INDSIZE_MASK BIT(0) +#define CDA2D_CHMXCTRL1_INDSIZE_FINITE (0x0 << 0) +#define CDA2D_CHMXCTRL1_INDSIZE_INFINITE (0x1 << 0) +#define CDA2D_CHMXCTRL2(n) (0x12004 + 0x80 * (n)) +#define CDA2D_CHMXSRCAMODE(n) (0x12020 + 0x80 * (n)) +#define CDA2D_CHMXDSTAMODE(n) (0x12024 + 0x80 * (n)) +#define CDA2D_CHMXAMODE_ENDIAN_MASK GENMASK(17, 16) +#define CDA2D_CHMXAMODE_ENDIAN_3210 (0x0 << 16) +#define CDA2D_CHMXAMODE_ENDIAN_0123 (0x1 << 16) +#define CDA2D_CHMXAMODE_ENDIAN_1032 (0x2 << 16) +#define CDA2D_CHMXAMODE_ENDIAN_2301 (0x3 << 16) +#define CDA2D_CHMXAMODE_RSSEL_SHIFT (8) +#define CDA2D_CHMXAMODE_AUPDT_MASK GENMASK(5, 4) +#define CDA2D_CHMXAMODE_AUPDT_INC (0x0 << 4) +#define CDA2D_CHMXAMODE_AUPDT_FIX (0x2 << 4) +#define CDA2D_CHMXAMODE_TYPE_MASK GENMASK(3, 2) +#define CDA2D_CHMXAMODE_TYPE_NORMAL (0x0 << 2) +#define CDA2D_CHMXAMODE_TYPE_RING (0x1 << 2) +#define CDA2D_CHMXSRCSTRTADRS(n) (0x12030 + 0x80 * (n)) +#define CDA2D_CHMXSRCSTRTADRSU(n) (0x12034 + 0x80 * (n)) +#define CDA2D_CHMXDSTSTRTADRS(n) (0x12038 + 0x80 * (n)) +#define CDA2D_CHMXDSTSTRTADRSU(n) (0x1203c + 0x80 * (n)) + +/* A2D(ring buffer) */ +#define CDA2D_RBFLUSH0 0x10040 +#define CDA2D_RBADRSLOAD 0x100b4 +#define CDA2D_RDPTRLOAD 0x100b8 +#define CDA2D_RDPTRLOAD_LSFLAG_LOAD (0x0 << 31) +#define CDA2D_RDPTRLOAD_LSFLAG_STORE (0x1 << 31) +#define CDA2D_WRPTRLOAD 0x100bc +#define CDA2D_WRPTRLOAD_LSFLAG_LOAD (0x0 << 31) +#define CDA2D_WRPTRLOAD_LSFLAG_STORE (0x1 << 31) + +#define CDA2D_RBMXBGNADRS(n) (0x14000 + 0x80 * (n)) +#define CDA2D_RBMXBGNADRSU(n) (0x14004 + 0x80 * (n)) +#define CDA2D_RBMXENDADRS(n) (0x14008 + 0x80 * (n)) +#define CDA2D_RBMXENDADRSU(n) (0x1400c + 0x80 * (n)) +#define CDA2D_RBMXBTH(n) (0x14038 + 0x80 * (n)) +#define CDA2D_RBMXRTH(n) (0x1403c + 0x80 * (n)) +#define CDA2D_RBMXRDPTR(n) (0x14020 + 0x80 * (n)) +#define CDA2D_RBMXRDPTRU(n) (0x14024 + 0x80 * (n)) +#define CDA2D_RBMXWRPTR(n) (0x14028 + 0x80 * (n)) +#define CDA2D_RBMXWRPTRU(n) (0x1402c + 0x80 * (n)) +#define CDA2D_RBMXPTRU_PTRU_MASK GENMASK(1, 0) +#define CDA2D_RBMXCNFG(n) (0x14030 + 0x80 * (n)) +#define CDA2D_RBMXIR(n) (0x14014 + 0x80 * (n)) +#define CDA2D_RBMXIE(n) (0x14018 + 0x80 * (n)) +#define CDA2D_RBMXID(n) (0x1401c + 0x80 * (n)) +#define CDA2D_RBMXIX_SPACE BIT(3) +#define CDA2D_RBMXIX_REMAIN BIT(4) + +#endif /* SND_UNIPHIER_AIO_REG_H__ */ diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h new file mode 100644 index 000000000000..774abae28028 --- /dev/null +++ b/sound/soc/uniphier/aio.h @@ -0,0 +1,343 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Socionext UniPhier AIO ALSA driver. + * + * Copyright (c) 2016-2018 Socionext Inc. + * + * 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; version 2 + * of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef SND_UNIPHIER_AIO_H__ +#define SND_UNIPHIER_AIO_H__ + +#include +#include +#include +#include +#include + +struct platform_device; + +enum ID_PORT_TYPE { + PORT_TYPE_UNKNOWN, + PORT_TYPE_I2S, + PORT_TYPE_SPDIF, + PORT_TYPE_EVE, + PORT_TYPE_CONV, +}; + +enum ID_PORT_DIR { + PORT_DIR_OUTPUT, + PORT_DIR_INPUT, +}; + +enum IEC61937_PC { + IEC61937_PC_AC3 = 0x0001, + IEC61937_PC_PAUSE = 0x0003, + IEC61937_PC_MPA = 0x0004, + IEC61937_PC_MP3 = 0x0005, + IEC61937_PC_DTS1 = 0x000b, + IEC61937_PC_DTS2 = 0x000c, + IEC61937_PC_DTS3 = 0x000d, + IEC61937_PC_AAC = 0x0007, +}; + +/* IEC61937 Repetition period of data-burst in IEC60958 frames */ +#define IEC61937_FRM_STR_AC3 1536 +#define IEC61937_FRM_STR_MPA 1152 +#define IEC61937_FRM_STR_MP3 1152 +#define IEC61937_FRM_STR_DTS1 512 +#define IEC61937_FRM_STR_DTS2 1024 +#define IEC61937_FRM_STR_DTS3 2048 +#define IEC61937_FRM_STR_AAC 1024 + +/* IEC61937 Repetition period of Pause data-burst in IEC60958 frames */ +#define IEC61937_FRM_PAU_AC3 3 +#define IEC61937_FRM_PAU_MPA 32 +#define IEC61937_FRM_PAU_MP3 32 +#define IEC61937_FRM_PAU_DTS1 3 +#define IEC61937_FRM_PAU_DTS2 3 +#define IEC61937_FRM_PAU_DTS3 3 +#define IEC61937_FRM_PAU_AAC 32 + +/* IEC61937 Pa and Pb */ +#define IEC61937_HEADER_SIGN 0x1f4e72f8 + +#define AUD_HW_PCMIN1 0 +#define AUD_HW_PCMIN2 1 +#define AUD_HW_PCMIN3 2 +#define AUD_HW_IECIN1 3 +#define AUD_HW_DIECIN1 4 + +#define AUD_NAME_PCMIN1 "aio-pcmin1" +#define AUD_NAME_PCMIN2 "aio-pcmin2" +#define AUD_NAME_PCMIN3 "aio-pcmin3" +#define AUD_NAME_IECIN1 "aio-iecin1" +#define AUD_NAME_DIECIN1 "aio-diecin1" + +#define AUD_HW_HPCMOUT1 0 +#define AUD_HW_PCMOUT1 1 +#define AUD_HW_PCMOUT2 2 +#define AUD_HW_PCMOUT3 3 +#define AUD_HW_EPCMOUT1 4 +#define AUD_HW_EPCMOUT2 5 +#define AUD_HW_EPCMOUT3 6 +#define AUD_HW_EPCMOUT6 9 +#define AUD_HW_HIECOUT1 10 +#define AUD_HW_IECOUT1 11 +#define AUD_HW_CMASTER 31 + +#define AUD_NAME_HPCMOUT1 "aio-hpcmout1" +#define AUD_NAME_PCMOUT1 "aio-pcmout1" +#define AUD_NAME_PCMOUT2 "aio-pcmout2" +#define AUD_NAME_PCMOUT3 "aio-pcmout3" +#define AUD_NAME_EPCMOUT1 "aio-epcmout1" +#define AUD_NAME_EPCMOUT2 "aio-epcmout2" +#define AUD_NAME_EPCMOUT3 "aio-epcmout3" +#define AUD_NAME_EPCMOUT6 "aio-epcmout6" +#define AUD_NAME_HIECOUT1 "aio-hiecout1" +#define AUD_NAME_IECOUT1 "aio-iecout1" +#define AUD_NAME_CMASTER "aio-cmaster" +#define AUD_NAME_HIECCOMPOUT1 "aio-hieccompout1" + +#define AUD_GNAME_HDMI "aio-hdmi" +#define AUD_GNAME_LINE "aio-line" +#define AUD_GNAME_IEC "aio-iec" + +#define AUD_CLK_IO 0 +#define AUD_CLK_A1 1 +#define AUD_CLK_F1 2 +#define AUD_CLK_A2 3 +#define AUD_CLK_F2 4 +#define AUD_CLK_A 5 +#define AUD_CLK_F 6 +#define AUD_CLK_APLL 7 +#define AUD_CLK_RX0 8 +#define AUD_CLK_USB0 9 +#define AUD_CLK_HSC0 10 + +#define AUD_PLL_A1 0 +#define AUD_PLL_F1 1 +#define AUD_PLL_A2 2 +#define AUD_PLL_F2 3 +#define AUD_PLL_APLL 4 +#define AUD_PLL_RX0 5 +#define AUD_PLL_USB0 6 +#define AUD_PLL_HSC0 7 + +#define AUD_PLLDIV_1_2 0 +#define AUD_PLLDIV_1_3 1 +#define AUD_PLLDIV_1_1 2 +#define AUD_PLLDIV_2_3 3 + +#define AUD_RING_SIZE (128 * 1024) + +#define AUD_MIN_FRAGMENT 4 +#define AUD_MAX_FRAGMENT 8 +#define AUD_MIN_FRAGMENT_SIZE (4 * 1024) +#define AUD_MAX_FRAGMENT_SIZE (16 * 1024) + +/* + * This is a selector for virtual register map of AIO. + * + * map: Specify the index of virtual register map. + * hw : Specify the ID of real register map, selector uses this value. + * A meaning of this value depends specification of SoC. + */ +struct uniphier_aio_selector { + int map; + int hw; +}; + +/** + * 'SoftWare MAPping' setting of UniPhier AIO registers. + * + * We have to setup 'virtual' register maps to access 'real' registers of AIO. + * This feature is legacy and meaningless but AIO needs this to work. + * + * Each hardware blocks have own virtual register maps as following: + * + * Address Virtual Real + * ------- --------- --------------- + * 0x12000 DMAC map0 --> [selector] --> DMAC hardware 3 + * 0x12080 DMAC map1 --> [selector] --> DMAC hardware 1 + * ... + * 0x42000 Port map0 --> [selector] --> Port hardware 1 + * 0x42400 Port map1 --> [selector] --> Port hardware 2 + * ... + * + * ch : Input or output channel of DMAC + * rb : Ring buffer + * iport: PCM input port + * iif : Input interface + * oport: PCM output port + * oif : Output interface + * och : Output channel of DMAC for sampling rate converter + * + * These are examples for sound data paths: + * + * For caputure device: + * (outer of AIO) -> iport -> iif -> ch -> rb -> (CPU) + * For playback device: + * (CPU) -> rb -> ch -> oif -> oport -> (outer of AIO) + * For sampling rate converter device: + * (CPU) -> rb -> ch -> oif -> (HW SRC) -> iif -> och -> orb -> (CPU) + */ +struct uniphier_aio_swmap { + int type; + int dir; + + struct uniphier_aio_selector ch; + struct uniphier_aio_selector rb; + struct uniphier_aio_selector iport; + struct uniphier_aio_selector iif; + struct uniphier_aio_selector oport; + struct uniphier_aio_selector oif; + struct uniphier_aio_selector och; +}; + +struct uniphier_aio_spec { + const char *name; + const char *gname; + struct uniphier_aio_swmap swm; +}; + +struct uniphier_aio_pll { + bool enable; + unsigned int freq; +}; + +struct uniphier_aio_chip_spec { + const struct uniphier_aio_spec *specs; + int num_specs; + const struct uniphier_aio_pll *plls; + int num_plls; + struct snd_soc_dai_driver *dais; + int num_dais; + + /* DMA access mode, this is workaround for DMA hungup */ + int addr_ext; +}; + +struct uniphier_aio_sub { + struct uniphier_aio *aio; + + /* Guard sub->rd_offs and wr_offs from IRQ handler. */ + spinlock_t lock; + + const struct uniphier_aio_swmap *swm; + const struct uniphier_aio_spec *spec; + + /* For PCM audio */ + struct snd_pcm_substream *substream; + struct snd_pcm_hw_params params; + + /* For compress audio */ + struct snd_compr_stream *cstream; + struct snd_compr_params cparams; + unsigned char *compr_area; + dma_addr_t compr_addr; + size_t compr_bytes; + int pass_through; + enum IEC61937_PC iec_pc; + bool iec_header; + + /* Both PCM and compress audio */ + bool use_mmap; + int setting; + int running; + u64 rd_offs; + u64 wr_offs; + u32 threshold; + u64 rd_org; + u64 wr_org; + u64 rd_total; + u64 wr_total; +}; + +struct uniphier_aio { + struct uniphier_aio_chip *chip; + + struct uniphier_aio_sub sub[2]; + + unsigned int fmt; + /* Set one of AUD_CLK_X */ + int clk_in; + int clk_out; + /* Set one of AUD_PLL_X */ + int pll_in; + int pll_out; + /* Set one of AUD_PLLDIV_X */ + int plldiv; +}; + +struct uniphier_aio_chip { + struct platform_device *pdev; + const struct uniphier_aio_chip_spec *chip_spec; + + struct uniphier_aio *aios; + int num_aios; + struct uniphier_aio_pll *plls; + int num_plls; + + struct clk *clk; + struct reset_control *rst; + struct regmap *regmap; + int active; +}; + +static inline struct uniphier_aio *uniphier_priv(struct snd_soc_dai *dai) +{ + struct uniphier_aio_chip *chip = snd_soc_dai_get_drvdata(dai); + + return &chip->aios[dai->id]; +} + +u64 aio_rb_cnt(struct uniphier_aio_sub *sub); +u64 aio_rbt_cnt_to_end(struct uniphier_aio_sub *sub); +u64 aio_rb_space(struct uniphier_aio_sub *sub); +u64 aio_rb_space_to_end(struct uniphier_aio_sub *sub); + +int aio_chip_set_pll(struct uniphier_aio_chip *chip, int pll_id, + unsigned int freq); +void aio_chip_init(struct uniphier_aio_chip *chip); +int aio_init(struct uniphier_aio_sub *sub); +void aio_port_reset(struct uniphier_aio_sub *sub); +int aio_port_set_rate(struct uniphier_aio_sub *sub, int rate); +int aio_port_set_fmt(struct uniphier_aio_sub *sub); +int aio_port_set_clk(struct uniphier_aio_sub *sub); +int aio_port_set_param(struct uniphier_aio_sub *sub, int pass_through, + const struct snd_pcm_hw_params *params); +void aio_port_set_enable(struct uniphier_aio_sub *sub, int enable); +int aio_if_set_param(struct uniphier_aio_sub *sub, int pass_through); +int aio_oport_set_stream_type(struct uniphier_aio_sub *sub, + enum IEC61937_PC pc); +void aio_src_reset(struct uniphier_aio_sub *sub); +int aio_src_set_param(struct uniphier_aio_sub *sub, + const struct snd_pcm_hw_params *params); +int aio_srcif_set_param(struct uniphier_aio_sub *sub); +int aio_srcch_set_param(struct uniphier_aio_sub *sub); +void aio_srcch_set_enable(struct uniphier_aio_sub *sub, int enable); + +int aiodma_ch_set_param(struct uniphier_aio_sub *sub); +void aiodma_ch_set_enable(struct uniphier_aio_sub *sub, int enable); +int aiodma_rb_set_threshold(struct uniphier_aio_sub *sub, u64 size, u32 th); +int aiodma_rb_set_buffer(struct uniphier_aio_sub *sub, u64 start, u64 end, + int period); +void aiodma_rb_sync(struct uniphier_aio_sub *sub, u64 start, u64 size, + int period); +bool aiodma_rb_is_irq(struct uniphier_aio_sub *sub); +void aiodma_rb_clear_irq(struct uniphier_aio_sub *sub); + +#endif /* SND_UNIPHIER_AIO_H__ */ From caa3e443aef6308abfe0710e8d8f602a75bed0ed Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 19 Jan 2018 18:25:30 +0900 Subject: [PATCH 238/942] ASoC: uniphier: add support for UniPhier AIO DMA driver This patch adds supports for UniPhier AIO DMA. This module shared register area with all sound devices for I2S, S/PDIF and so on. Since the AIO has mixed register map for those I/Os, it is hard to split register areas for each sound devices. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/Makefile | 2 +- sound/soc/uniphier/aio-dma.c | 317 +++++++++++++++++++++++++++++++++++ sound/soc/uniphier/aio.h | 2 + 3 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 sound/soc/uniphier/aio-dma.c diff --git a/sound/soc/uniphier/Makefile b/sound/soc/uniphier/Makefile index f3b36aba4879..9efe0feffdc2 100644 --- a/sound/soc/uniphier/Makefile +++ b/sound/soc/uniphier/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -snd-soc-uniphier-aio-cpu-objs := aio-core.o +snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o obj-$(CONFIG_SND_SOC_UNIPHIER_AIO) += snd-soc-uniphier-aio-cpu.o diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c new file mode 100644 index 000000000000..6d0ca6dde913 --- /dev/null +++ b/sound/soc/uniphier/aio-dma.c @@ -0,0 +1,317 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext UniPhier AIO DMA driver. +// +// Copyright (c) 2016-2018 Socionext Inc. +// +// 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; version 2 +// of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . + +#include +#include +#include +#include +#include +#include +#include + +#include "aio.h" + +static struct snd_pcm_hardware uniphier_aiodma_hw = { + .info = SNDRV_PCM_INFO_MMAP | + SNDRV_PCM_INFO_MMAP_VALID | + SNDRV_PCM_INFO_INTERLEAVED, + .period_bytes_min = 256, + .period_bytes_max = 4096, + .periods_min = 4, + .periods_max = 1024, + .buffer_bytes_max = 128 * 1024, +}; + +static void aiodma_pcm_irq(struct uniphier_aio_sub *sub) +{ + struct snd_pcm_runtime *runtime = sub->substream->runtime; + int bytes = runtime->period_size * + runtime->channels * samples_to_bytes(runtime, 1); + int ret; + + spin_lock(&sub->lock); + ret = aiodma_rb_set_threshold(sub, runtime->dma_bytes, + sub->threshold + bytes); + if (!ret) + sub->threshold += bytes; + + aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes); + aiodma_rb_clear_irq(sub); + spin_unlock(&sub->lock); + + snd_pcm_period_elapsed(sub->substream); +} + +static void aiodma_compr_irq(struct uniphier_aio_sub *sub) +{ + struct snd_compr_runtime *runtime = sub->cstream->runtime; + int bytes = runtime->fragment_size; + int ret; + + spin_lock(&sub->lock); + ret = aiodma_rb_set_threshold(sub, sub->compr_bytes, + sub->threshold + bytes); + if (!ret) + sub->threshold += bytes; + + aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes); + aiodma_rb_clear_irq(sub); + spin_unlock(&sub->lock); + + snd_compr_fragment_elapsed(sub->cstream); +} + +static irqreturn_t aiodma_irq(int irq, void *p) +{ + struct platform_device *pdev = p; + struct uniphier_aio_chip *chip = platform_get_drvdata(pdev); + irqreturn_t ret = IRQ_NONE; + int i, j; + + for (i = 0; i < chip->num_aios; i++) { + struct uniphier_aio *aio = &chip->aios[i]; + + for (j = 0; j < ARRAY_SIZE(aio->sub); j++) { + struct uniphier_aio_sub *sub = &aio->sub[j]; + + /* Skip channel that does not trigger */ + if (!sub->running || !aiodma_rb_is_irq(sub)) + continue; + + if (sub->substream) + aiodma_pcm_irq(sub); + if (sub->cstream) + aiodma_compr_irq(sub); + + ret = IRQ_HANDLED; + } + } + + return ret; +} + +static int uniphier_aiodma_open(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + snd_soc_set_runtime_hwparams(substream, &uniphier_aiodma_hw); + + return snd_pcm_hw_constraint_step(runtime, 0, + SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256); +} + +static int uniphier_aiodma_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); + substream->runtime->dma_bytes = params_buffer_bytes(params); + + return 0; +} + +static int uniphier_aiodma_hw_free(struct snd_pcm_substream *substream) +{ + snd_pcm_set_runtime_buffer(substream, NULL); + substream->runtime->dma_bytes = 0; + + return 0; +} + +static int uniphier_aiodma_prepare(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + int bytes = runtime->period_size * + runtime->channels * samples_to_bytes(runtime, 1); + unsigned long flags; + int ret; + + ret = aiodma_ch_set_param(sub); + if (ret) + return ret; + + spin_lock_irqsave(&sub->lock, flags); + ret = aiodma_rb_set_buffer(sub, runtime->dma_addr, + runtime->dma_addr + runtime->dma_bytes, + bytes); + spin_unlock_irqrestore(&sub->lock, flags); + if (ret) + return ret; + + return 0; +} + +static int uniphier_aiodma_trigger(struct snd_pcm_substream *substream, int cmd) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + struct device *dev = &aio->chip->pdev->dev; + int bytes = runtime->period_size * + runtime->channels * samples_to_bytes(runtime, 1); + unsigned long flags; + + spin_lock_irqsave(&sub->lock, flags); + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, + bytes); + aiodma_ch_set_enable(sub, 1); + sub->running = 1; + + break; + case SNDRV_PCM_TRIGGER_STOP: + sub->running = 0; + aiodma_ch_set_enable(sub, 0); + + break; + default: + dev_warn(dev, "Unknown trigger(%d) ignored\n", cmd); + break; + } + spin_unlock_irqrestore(&sub->lock, flags); + + return 0; +} + +static snd_pcm_uframes_t uniphier_aiodma_pointer( + struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream); + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + int bytes = runtime->period_size * + runtime->channels * samples_to_bytes(runtime, 1); + unsigned long flags; + snd_pcm_uframes_t pos; + + spin_lock_irqsave(&sub->lock, flags); + aiodma_rb_sync(sub, runtime->dma_addr, runtime->dma_bytes, bytes); + + if (sub->swm->dir == PORT_DIR_OUTPUT) + pos = bytes_to_frames(runtime, sub->rd_offs); + else + pos = bytes_to_frames(runtime, sub->wr_offs); + spin_unlock_irqrestore(&sub->lock, flags); + + return pos; +} + +static int uniphier_aiodma_mmap(struct snd_pcm_substream *substream, + struct vm_area_struct *vma) +{ + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + + return remap_pfn_range(vma, vma->vm_start, + substream->dma_buffer.addr >> PAGE_SHIFT, + vma->vm_end - vma->vm_start, vma->vm_page_prot); +} + +static const struct snd_pcm_ops uniphier_aiodma_ops = { + .open = uniphier_aiodma_open, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = uniphier_aiodma_hw_params, + .hw_free = uniphier_aiodma_hw_free, + .prepare = uniphier_aiodma_prepare, + .trigger = uniphier_aiodma_trigger, + .pointer = uniphier_aiodma_pointer, + .mmap = uniphier_aiodma_mmap, +}; + +static int uniphier_aiodma_new(struct snd_soc_pcm_runtime *rtd) +{ + struct device *dev = rtd->card->snd_card->dev; + struct snd_pcm *pcm = rtd->pcm; + int ret; + + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33)); + if (ret) + return ret; + + return snd_pcm_lib_preallocate_pages_for_all(pcm, + SNDRV_DMA_TYPE_DEV, dev, + uniphier_aiodma_hw.buffer_bytes_max, + uniphier_aiodma_hw.buffer_bytes_max); +} + +static void uniphier_aiodma_free(struct snd_pcm *pcm) +{ + snd_pcm_lib_preallocate_free_for_all(pcm); +} + +static const struct snd_soc_platform_driver uniphier_soc_platform = { + .pcm_new = uniphier_aiodma_new, + .pcm_free = uniphier_aiodma_free, + .ops = &uniphier_aiodma_ops, +}; + +static const struct regmap_config aiodma_regmap_config = { + .reg_bits = 32, + .reg_stride = 4, + .val_bits = 32, + .max_register = 0x7fffc, + .cache_type = REGCACHE_NONE, +}; + +/** + * uniphier_aiodma_soc_register_platform - register the AIO DMA + * @pdev: the platform device + * + * Register and setup the DMA of AIO to transfer the sound data to device. + * This function need to call once at driver startup and need NOT to call + * unregister function. + * + * Return: Zero if successful, otherwise a negative value on error. + */ +int uniphier_aiodma_soc_register_platform(struct platform_device *pdev) +{ + struct uniphier_aio_chip *chip = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + struct resource *res; + void __iomem *preg; + int irq, ret; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + preg = devm_ioremap_resource(dev, res); + if (IS_ERR(preg)) + return PTR_ERR(preg); + + chip->regmap = devm_regmap_init_mmio(dev, preg, + &aiodma_regmap_config); + if (IS_ERR(chip->regmap)) + return PTR_ERR(chip->regmap); + + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(dev, "Could not get irq.\n"); + return irq; + } + + ret = devm_request_irq(dev, irq, aiodma_irq, + IRQF_SHARED, dev_name(dev), pdev); + if (ret) + return ret; + + return devm_snd_soc_register_platform(dev, &uniphier_soc_platform); +} +EXPORT_SYMBOL_GPL(uniphier_aiodma_soc_register_platform); diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index 774abae28028..3687f6ff30b1 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -304,6 +304,8 @@ static inline struct uniphier_aio *uniphier_priv(struct snd_soc_dai *dai) return &chip->aios[dai->id]; } +int uniphier_aiodma_soc_register_platform(struct platform_device *pdev); + u64 aio_rb_cnt(struct uniphier_aio_sub *sub); u64 aio_rbt_cnt_to_end(struct uniphier_aio_sub *sub); u64 aio_rb_space(struct uniphier_aio_sub *sub); From 139a342002330e2e9730a564766ec04bd028d511 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 19 Jan 2018 18:25:31 +0900 Subject: [PATCH 239/942] ASoC: uniphier: add support for UniPhier AIO CPU DAI driver This patch adds CPU DAI driver for UniPhier AIO audio sound system. This module provides PCM devices for all input/output port of AIO such as I2S, S/PDIF. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/Makefile | 2 +- sound/soc/uniphier/aio-cpu.c | 570 +++++++++++++++++++++++++++++++++++ sound/soc/uniphier/aio.h | 9 + 3 files changed, 580 insertions(+), 1 deletion(-) create mode 100644 sound/soc/uniphier/aio-cpu.c diff --git a/sound/soc/uniphier/Makefile b/sound/soc/uniphier/Makefile index 9efe0feffdc2..3ef2784b2383 100644 --- a/sound/soc/uniphier/Makefile +++ b/sound/soc/uniphier/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o +snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o aio-cpu.o obj-$(CONFIG_SND_SOC_UNIPHIER_AIO) += snd-soc-uniphier-aio-cpu.o diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c new file mode 100644 index 000000000000..55f3248a31fd --- /dev/null +++ b/sound/soc/uniphier/aio-cpu.c @@ -0,0 +1,570 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext UniPhier AIO ALSA CPU DAI driver. +// +// Copyright (c) 2016-2018 Socionext Inc. +// +// 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; version 2 +// of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "aio.h" + +static bool is_valid_pll(struct uniphier_aio_chip *chip, int pll_id) +{ + struct device *dev = &chip->pdev->dev; + + if (pll_id < 0 || chip->num_plls <= pll_id) { + dev_err(dev, "PLL(%d) is not supported\n", pll_id); + return false; + } + + return chip->plls[pll_id].enable; +} + +static bool match_spec(const struct uniphier_aio_spec *spec, + const char *name, int dir) +{ + if (dir == SNDRV_PCM_STREAM_PLAYBACK && + spec->swm.dir != PORT_DIR_OUTPUT) { + return false; + } + + if (dir == SNDRV_PCM_STREAM_CAPTURE && + spec->swm.dir != PORT_DIR_INPUT) { + return false; + } + + if (spec->name && strcmp(spec->name, name) == 0) + return true; + + if (spec->gname && strcmp(spec->gname, name) == 0) + return true; + + return false; +} + +/** + * find_spec - find HW specification info by name + * @aio: the AIO device pointer + * @name: name of device + * @direction: the direction of substream, SNDRV_PCM_STREAM_* + * + * Find hardware specification information from list by device name. This + * information is used for telling the difference of SoCs to driver. + * + * Specification list is array of 'struct uniphier_aio_spec' which is defined + * in each drivers (see: aio-i2s.c). + * + * Return: The pointer of hardware specification of AIO if successful, + * otherwise NULL on error. + */ +static const struct uniphier_aio_spec *find_spec(struct uniphier_aio *aio, + const char *name, + int direction) +{ + const struct uniphier_aio_chip_spec *chip_spec = aio->chip->chip_spec; + int i; + + for (i = 0; i < chip_spec->num_specs; i++) { + const struct uniphier_aio_spec *spec = &chip_spec->specs[i]; + + if (match_spec(spec, name, direction)) + return spec; + } + + return NULL; +} + +/** + * find_divider - find clock divider by frequency + * @aio: the AIO device pointer + * @pll_id: PLL ID, should be AUD_PLL_XX + * @freq: required frequency + * + * Find suitable clock divider by frequency. + * + * Return: The ID of PLL if successful, otherwise negative error value. + */ +static int find_divider(struct uniphier_aio *aio, int pll_id, unsigned int freq) +{ + struct uniphier_aio_pll *pll; + int mul[] = { 1, 1, 1, 2, }; + int div[] = { 2, 3, 1, 3, }; + int i; + + if (!is_valid_pll(aio->chip, pll_id)) + return -EINVAL; + + pll = &aio->chip->plls[pll_id]; + for (i = 0; i < ARRAY_SIZE(mul); i++) + if (pll->freq * mul[i] / div[i] == freq) + return i; + + return -ENOTSUPP; +} + +static int uniphier_aio_set_sysclk(struct snd_soc_dai *dai, int clk_id, + unsigned int freq, int dir) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct device *dev = &aio->chip->pdev->dev; + bool pll_auto = false; + int pll_id, div_id; + + if (clk_id == AUD_CLK_IO) + return -ENOTSUPP; + + switch (clk_id) { + case AUD_CLK_IO: + return -ENOTSUPP; + case AUD_CLK_A1: + pll_id = AUD_PLL_A1; + break; + case AUD_CLK_F1: + pll_id = AUD_PLL_F1; + break; + case AUD_CLK_A2: + pll_id = AUD_PLL_A2; + break; + case AUD_CLK_F2: + pll_id = AUD_PLL_F2; + break; + case AUD_CLK_A: + pll_id = AUD_PLL_A1; + pll_auto = true; + break; + case AUD_CLK_F: + pll_id = AUD_PLL_F1; + pll_auto = true; + break; + case AUD_CLK_APLL: + pll_id = AUD_PLL_APLL; + break; + case AUD_CLK_RX0: + pll_id = AUD_PLL_RX0; + break; + case AUD_CLK_USB0: + pll_id = AUD_PLL_USB0; + break; + case AUD_CLK_HSC0: + pll_id = AUD_PLL_HSC0; + break; + default: + dev_err(dev, "Sysclk(%d) is not supported\n", clk_id); + return -EINVAL; + } + + if (pll_auto) { + for (pll_id = 0; pll_id < aio->chip->num_plls; pll_id++) { + div_id = find_divider(aio, pll_id, freq); + if (div_id >= 0) { + aio->plldiv = div_id; + break; + } + } + if (pll_id == aio->chip->num_plls) { + dev_err(dev, "Sysclk frequency is not supported(%d)\n", + freq); + return -EINVAL; + } + } + + if (dir == SND_SOC_CLOCK_OUT) + aio->pll_out = pll_id; + else + aio->pll_in = pll_id; + + return 0; +} + +static int uniphier_aio_set_pll(struct snd_soc_dai *dai, int pll_id, + int source, unsigned int freq_in, + unsigned int freq_out) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct device *dev = &aio->chip->pdev->dev; + int ret; + + if (!is_valid_pll(aio->chip, pll_id)) + return -EINVAL; + if (!aio->chip->plls[pll_id].enable) { + dev_err(dev, "PLL(%d) is not implemented\n", pll_id); + return -ENOTSUPP; + } + + ret = aio_chip_set_pll(aio->chip, pll_id, freq_out); + if (ret < 0) + return ret; + + return 0; +} + +static int uniphier_aio_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct device *dev = &aio->chip->pdev->dev; + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_LEFT_J: + case SND_SOC_DAIFMT_RIGHT_J: + case SND_SOC_DAIFMT_I2S: + aio->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; + break; + default: + dev_err(dev, "Format is not supported(%d)\n", + fmt & SND_SOC_DAIFMT_FORMAT_MASK); + return -EINVAL; + } + + return 0; +} + +static int uniphier_aio_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + int ret; + + sub->substream = substream; + sub->pass_through = 0; + sub->use_mmap = true; + + ret = aio_init(sub); + if (ret) + return ret; + + return 0; +} + +static void uniphier_aio_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + + sub->substream = NULL; +} + +static int uniphier_aio_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + struct device *dev = &aio->chip->pdev->dev; + int freq, ret; + + switch (params_rate(params)) { + case 48000: + case 32000: + case 24000: + freq = 12288000; + break; + case 44100: + case 22050: + freq = 11289600; + break; + default: + dev_err(dev, "Rate is not supported(%d)\n", + params_rate(params)); + return -EINVAL; + } + ret = snd_soc_dai_set_sysclk(dai, AUD_CLK_A, + freq, SND_SOC_CLOCK_OUT); + if (ret) + return ret; + + sub->params = *params; + sub->setting = 1; + + aio_port_reset(sub); + aio_src_reset(sub); + + return 0; +} + +static int uniphier_aio_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + + sub->setting = 0; + + return 0; +} + +static int uniphier_aio_prepare(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + struct uniphier_aio_sub *sub = &aio->sub[substream->stream]; + int ret; + + ret = aio_port_set_param(sub, sub->pass_through, &sub->params); + if (ret) + return ret; + ret = aio_src_set_param(sub, &sub->params); + if (ret) + return ret; + aio_port_set_enable(sub, 1); + + ret = aio_if_set_param(sub, sub->pass_through); + if (ret) + return ret; + + if (sub->swm->type == PORT_TYPE_CONV) { + ret = aio_srcif_set_param(sub); + if (ret) + return ret; + ret = aio_srcch_set_param(sub); + if (ret) + return ret; + aio_srcch_set_enable(sub, 1); + } + + return 0; +} + +const struct snd_soc_dai_ops uniphier_aio_i2s_ops = { + .set_sysclk = uniphier_aio_set_sysclk, + .set_pll = uniphier_aio_set_pll, + .set_fmt = uniphier_aio_set_fmt, + .startup = uniphier_aio_startup, + .shutdown = uniphier_aio_shutdown, + .hw_params = uniphier_aio_hw_params, + .hw_free = uniphier_aio_hw_free, + .prepare = uniphier_aio_prepare, +}; +EXPORT_SYMBOL_GPL(uniphier_aio_i2s_ops); + +const struct snd_soc_dai_ops uniphier_aio_spdif_ops = { + .set_sysclk = uniphier_aio_set_sysclk, + .set_pll = uniphier_aio_set_pll, + .startup = uniphier_aio_startup, + .shutdown = uniphier_aio_shutdown, + .hw_params = uniphier_aio_hw_params, + .hw_free = uniphier_aio_hw_free, + .prepare = uniphier_aio_prepare, +}; +EXPORT_SYMBOL_GPL(uniphier_aio_spdif_ops); + +int uniphier_aio_dai_probe(struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + int i; + + for (i = 0; i < ARRAY_SIZE(aio->sub); i++) { + struct uniphier_aio_sub *sub = &aio->sub[i]; + const struct uniphier_aio_spec *spec; + + spec = find_spec(aio, dai->name, i); + if (!spec) + continue; + + sub->swm = &spec->swm; + sub->spec = spec; + } + + aio_chip_init(aio->chip); + aio->chip->active = 1; + + return 0; +} +EXPORT_SYMBOL_GPL(uniphier_aio_dai_probe); + +int uniphier_aio_dai_remove(struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + + aio->chip->active = 0; + + return 0; +} +EXPORT_SYMBOL_GPL(uniphier_aio_dai_remove); + +int uniphier_aio_dai_suspend(struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + + reset_control_assert(aio->chip->rst); + clk_disable_unprepare(aio->chip->clk); + + return 0; +} +EXPORT_SYMBOL_GPL(uniphier_aio_dai_suspend); + +int uniphier_aio_dai_resume(struct snd_soc_dai *dai) +{ + struct uniphier_aio *aio = uniphier_priv(dai); + int ret, i; + + if (!aio->chip->active) + return 0; + + ret = clk_prepare_enable(aio->chip->clk); + if (ret) + return ret; + + ret = reset_control_deassert(aio->chip->rst); + if (ret) + goto err_out_clock; + + aio_chip_init(aio->chip); + + for (i = 0; i < ARRAY_SIZE(aio->sub); i++) { + struct uniphier_aio_sub *sub = &aio->sub[i]; + + if (!sub->spec || !sub->substream) + continue; + + ret = aio_init(sub); + if (ret) + goto err_out_clock; + + if (!sub->setting) + continue; + + aio_port_reset(sub); + aio_src_reset(sub); + } + + return 0; + +err_out_clock: + clk_disable_unprepare(aio->chip->clk); + + return ret; +} +EXPORT_SYMBOL_GPL(uniphier_aio_dai_resume); + +static const struct snd_soc_component_driver uniphier_aio_component = { + .name = "uniphier-aio", +}; + +int uniphier_aio_probe(struct platform_device *pdev) +{ + struct uniphier_aio_chip *chip; + struct device *dev = &pdev->dev; + int ret, i, j; + + chip = devm_kzalloc(dev, sizeof(*chip), GFP_KERNEL); + if (!chip) + return -ENOMEM; + + chip->chip_spec = of_device_get_match_data(dev); + if (!chip->chip_spec) + return -EINVAL; + + chip->clk = devm_clk_get(dev, "aio"); + if (IS_ERR(chip->clk)) + return PTR_ERR(chip->clk); + + chip->rst = devm_reset_control_get_shared(dev, "aio"); + if (IS_ERR(chip->rst)) + return PTR_ERR(chip->rst); + + chip->num_aios = chip->chip_spec->num_dais; + chip->aios = devm_kzalloc(dev, + sizeof(struct uniphier_aio) * chip->num_aios, + GFP_KERNEL); + if (!chip->aios) + return -ENOMEM; + + chip->num_plls = chip->chip_spec->num_plls; + chip->plls = devm_kzalloc(dev, sizeof(struct uniphier_aio_pll) * + chip->num_plls, GFP_KERNEL); + if (!chip->plls) + return -ENOMEM; + memcpy(chip->plls, chip->chip_spec->plls, + sizeof(struct uniphier_aio_pll) * chip->num_plls); + + for (i = 0; i < chip->num_aios; i++) { + struct uniphier_aio *aio = &chip->aios[i]; + + aio->chip = chip; + aio->fmt = SND_SOC_DAIFMT_I2S; + + for (j = 0; j < ARRAY_SIZE(aio->sub); j++) { + struct uniphier_aio_sub *sub = &aio->sub[j]; + + sub->aio = aio; + spin_lock_init(&sub->lock); + } + } + + chip->pdev = pdev; + platform_set_drvdata(pdev, chip); + + ret = clk_prepare_enable(chip->clk); + if (ret) + return ret; + + ret = reset_control_deassert(chip->rst); + if (ret) + goto err_out_clock; + + ret = devm_snd_soc_register_component(dev, &uniphier_aio_component, + chip->chip_spec->dais, + chip->chip_spec->num_dais); + if (ret) { + dev_err(dev, "Register component failed.\n"); + goto err_out_reset; + } + + ret = uniphier_aiodma_soc_register_platform(pdev); + if (ret) { + dev_err(dev, "Register platform failed.\n"); + goto err_out_reset; + } + + return 0; + +err_out_reset: + reset_control_assert(chip->rst); + +err_out_clock: + clk_disable_unprepare(chip->clk); + + return ret; +} +EXPORT_SYMBOL_GPL(uniphier_aio_probe); + +int uniphier_aio_remove(struct platform_device *pdev) +{ + struct uniphier_aio_chip *chip = platform_get_drvdata(pdev); + + reset_control_assert(chip->rst); + clk_disable_unprepare(chip->clk); + + return 0; +} +EXPORT_SYMBOL_GPL(uniphier_aio_remove); + +MODULE_AUTHOR("Katsuhiro Suzuki "); +MODULE_DESCRIPTION("UniPhier AIO CPU DAI driver."); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index 3687f6ff30b1..b12e2e3d7699 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -306,6 +306,15 @@ static inline struct uniphier_aio *uniphier_priv(struct snd_soc_dai *dai) int uniphier_aiodma_soc_register_platform(struct platform_device *pdev); +int uniphier_aio_dai_probe(struct snd_soc_dai *dai); +int uniphier_aio_dai_remove(struct snd_soc_dai *dai); +int uniphier_aio_dai_suspend(struct snd_soc_dai *dai); +int uniphier_aio_dai_resume(struct snd_soc_dai *dai); +int uniphier_aio_probe(struct platform_device *pdev); +int uniphier_aio_remove(struct platform_device *pdev); +extern const struct snd_soc_dai_ops uniphier_aio_i2s_ops; +extern const struct snd_soc_dai_ops uniphier_aio_spdif_ops; + u64 aio_rb_cnt(struct uniphier_aio_sub *sub); u64 aio_rbt_cnt_to_end(struct uniphier_aio_sub *sub); u64 aio_rb_space(struct uniphier_aio_sub *sub); From e98131222ff931a670739cede00d1fb9d6f83763 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 19 Jan 2018 18:25:32 +0900 Subject: [PATCH 240/942] ASoC: uniphier: add support for UniPhier AIO compress audio This patch adds support of UniPhier AIO compress audio. For passing through compress audio to S/PDIF. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/Kconfig | 1 + sound/soc/uniphier/Makefile | 2 +- sound/soc/uniphier/aio-compress.c | 440 ++++++++++++++++++++++++++++++ sound/soc/uniphier/aio-dma.c | 1 + sound/soc/uniphier/aio.h | 1 + 5 files changed, 444 insertions(+), 1 deletion(-) create mode 100644 sound/soc/uniphier/aio-compress.c diff --git a/sound/soc/uniphier/Kconfig b/sound/soc/uniphier/Kconfig index 78ce101d2cc2..1a55ccebd8f5 100644 --- a/sound/soc/uniphier/Kconfig +++ b/sound/soc/uniphier/Kconfig @@ -11,6 +11,7 @@ config SND_SOC_UNIPHIER config SND_SOC_UNIPHIER_AIO tristate "UniPhier AIO DAI Driver" select REGMAP_MMIO + select SND_SOC_COMPRESS depends on SND_SOC_UNIPHIER help This adds ASoC driver support for Socionext UniPhier diff --git a/sound/soc/uniphier/Makefile b/sound/soc/uniphier/Makefile index 3ef2784b2383..4448175c70ab 100644 --- a/sound/soc/uniphier/Makefile +++ b/sound/soc/uniphier/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o aio-cpu.o +snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o aio-cpu.o aio-compress.o obj-$(CONFIG_SND_SOC_UNIPHIER_AIO) += snd-soc-uniphier-aio-cpu.o diff --git a/sound/soc/uniphier/aio-compress.c b/sound/soc/uniphier/aio-compress.c new file mode 100644 index 000000000000..7f7abe3ae99d --- /dev/null +++ b/sound/soc/uniphier/aio-compress.c @@ -0,0 +1,440 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext UniPhier AIO Compress Audio driver. +// +// Copyright (c) 2017-2018 Socionext Inc. +// +// 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; version 2 +// of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "aio.h" + +static int uniphier_aio_compr_prepare(struct snd_compr_stream *cstream); +static int uniphier_aio_compr_hw_free(struct snd_compr_stream *cstream); + +static int uniphier_aio_comprdma_new(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_compr *compr = rtd->compr; + struct device *dev = compr->card->dev; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[compr->direction]; + size_t size = AUD_RING_SIZE; + int dma_dir = DMA_FROM_DEVICE, ret; + + ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(33)); + if (ret) + return ret; + + sub->compr_area = kzalloc(size, GFP_KERNEL); + if (!sub->compr_area) + return -ENOMEM; + + if (sub->swm->dir == PORT_DIR_OUTPUT) + dma_dir = DMA_TO_DEVICE; + + sub->compr_addr = dma_map_single(dev, sub->compr_area, size, dma_dir); + ret = dma_mapping_error(dev, sub->compr_addr); + if (ret) { + kfree(sub->compr_area); + sub->compr_area = NULL; + + return ret; + } + + sub->compr_bytes = size; + + return 0; +} + +static int uniphier_aio_comprdma_free(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_compr *compr = rtd->compr; + struct device *dev = compr->card->dev; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[compr->direction]; + int dma_dir = DMA_FROM_DEVICE; + + if (sub->swm->dir == PORT_DIR_OUTPUT) + dma_dir = DMA_TO_DEVICE; + + dma_unmap_single(dev, sub->compr_addr, sub->compr_bytes, dma_dir); + kfree(sub->compr_area); + sub->compr_area = NULL; + + return 0; +} + +static int uniphier_aio_compr_open(struct snd_compr_stream *cstream) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + int ret; + + if (sub->cstream) + return -EBUSY; + + sub->cstream = cstream; + sub->pass_through = 1; + sub->use_mmap = false; + + ret = uniphier_aio_comprdma_new(rtd); + if (ret) + return ret; + + ret = aio_init(sub); + if (ret) + return ret; + + return 0; +} + +static int uniphier_aio_compr_free(struct snd_compr_stream *cstream) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + int ret; + + ret = uniphier_aio_compr_hw_free(cstream); + if (ret) + return ret; + ret = uniphier_aio_comprdma_free(rtd); + if (ret) + return ret; + + sub->cstream = NULL; + + return 0; +} + +static int uniphier_aio_compr_get_params(struct snd_compr_stream *cstream, + struct snd_codec *params) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + + *params = sub->cparams.codec; + + return 0; +} + +static int uniphier_aio_compr_set_params(struct snd_compr_stream *cstream, + struct snd_compr_params *params) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + struct device *dev = &aio->chip->pdev->dev; + int ret; + + if (params->codec.id != SND_AUDIOCODEC_IEC61937) { + dev_err(dev, "Codec ID is not supported(%d)\n", + params->codec.id); + return -EINVAL; + } + if (params->codec.profile != SND_AUDIOPROFILE_IEC61937_SPDIF) { + dev_err(dev, "Codec profile is not supported(%d)\n", + params->codec.profile); + return -EINVAL; + } + + /* IEC frame type will be changed after received valid data */ + sub->iec_pc = IEC61937_PC_AAC; + + sub->cparams = *params; + sub->setting = 1; + + aio_port_reset(sub); + aio_src_reset(sub); + + ret = uniphier_aio_compr_prepare(cstream); + if (ret) + return ret; + + return 0; +} + +static int uniphier_aio_compr_hw_free(struct snd_compr_stream *cstream) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + + sub->setting = 0; + + return 0; +} + +static int uniphier_aio_compr_prepare(struct snd_compr_stream *cstream) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_compr_runtime *runtime = cstream->runtime; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + int bytes = runtime->fragment_size; + unsigned long flags; + int ret; + + ret = aiodma_ch_set_param(sub); + if (ret) + return ret; + + spin_lock_irqsave(&sub->lock, flags); + ret = aiodma_rb_set_buffer(sub, sub->compr_addr, + sub->compr_addr + sub->compr_bytes, + bytes); + spin_unlock_irqrestore(&sub->lock, flags); + if (ret) + return ret; + + ret = aio_port_set_param(sub, sub->pass_through, &sub->params); + if (ret) + return ret; + ret = aio_oport_set_stream_type(sub, sub->iec_pc); + if (ret) + return ret; + aio_port_set_enable(sub, 1); + + ret = aio_if_set_param(sub, sub->pass_through); + if (ret) + return ret; + + return 0; +} + +static int uniphier_aio_compr_trigger(struct snd_compr_stream *cstream, + int cmd) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_compr_runtime *runtime = cstream->runtime; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + struct device *dev = &aio->chip->pdev->dev; + int bytes = runtime->fragment_size, ret = 0; + unsigned long flags; + + spin_lock_irqsave(&sub->lock, flags); + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes); + aiodma_ch_set_enable(sub, 1); + sub->running = 1; + + break; + case SNDRV_PCM_TRIGGER_STOP: + sub->running = 0; + aiodma_ch_set_enable(sub, 0); + + break; + default: + dev_warn(dev, "Unknown trigger(%d)\n", cmd); + ret = -EINVAL; + } + spin_unlock_irqrestore(&sub->lock, flags); + + return ret; +} + +static int uniphier_aio_compr_pointer(struct snd_compr_stream *cstream, + struct snd_compr_tstamp *tstamp) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_compr_runtime *runtime = cstream->runtime; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + int bytes = runtime->fragment_size; + unsigned long flags; + u32 pos; + + spin_lock_irqsave(&sub->lock, flags); + + aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes); + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + pos = sub->rd_offs; + /* Size of AIO output format is double of IEC61937 */ + tstamp->copied_total = sub->rd_total / 2; + } else { + pos = sub->wr_offs; + tstamp->copied_total = sub->rd_total; + } + tstamp->byte_offset = pos; + + spin_unlock_irqrestore(&sub->lock, flags); + + return 0; +} + +static int aio_compr_send_to_hw(struct uniphier_aio_sub *sub, + char __user *buf, size_t dstsize) +{ + u32 __user *srcbuf = (u32 __user *)buf; + u32 *dstbuf = (u32 *)(sub->compr_area + sub->wr_offs); + int src = 0, dst = 0, ret; + u32 frm, frm_a, frm_b; + + while (dstsize > 0) { + ret = get_user(frm, srcbuf + src); + if (ret) + return ret; + src++; + + frm_a = frm & 0xffff; + frm_b = (frm >> 16) & 0xffff; + + if (frm == IEC61937_HEADER_SIGN) { + frm_a |= 0x01000000; + + /* Next data is Pc and Pd */ + sub->iec_header = true; + } else { + u16 pc = be16_to_cpu((__be16)frm_a); + + if (sub->iec_header && sub->iec_pc != pc) { + /* Force overwrite IEC frame type */ + sub->iec_pc = pc; + ret = aio_oport_set_stream_type(sub, pc); + if (ret) + return ret; + } + sub->iec_header = false; + } + dstbuf[dst++] = frm_a; + dstbuf[dst++] = frm_b; + + dstsize -= sizeof(u32) * 2; + } + + return 0; +} + +static int uniphier_aio_compr_copy(struct snd_compr_stream *cstream, + char __user *buf, size_t count) +{ + struct snd_soc_pcm_runtime *rtd = cstream->private_data; + struct snd_compr_runtime *runtime = cstream->runtime; + struct device *carddev = rtd->compr->card->dev; + struct uniphier_aio *aio = uniphier_priv(rtd->cpu_dai); + struct uniphier_aio_sub *sub = &aio->sub[cstream->direction]; + size_t cnt = min_t(size_t, count, aio_rb_space_to_end(sub) / 2); + int bytes = runtime->fragment_size; + unsigned long flags; + size_t s; + int ret; + + if (cnt < sizeof(u32)) + return 0; + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + dma_addr_t dmapos = sub->compr_addr + sub->wr_offs; + + /* Size of AIO output format is double of IEC61937 */ + s = cnt * 2; + + dma_sync_single_for_cpu(carddev, dmapos, s, DMA_TO_DEVICE); + ret = aio_compr_send_to_hw(sub, buf, s); + dma_sync_single_for_device(carddev, dmapos, s, DMA_TO_DEVICE); + } else { + dma_addr_t dmapos = sub->compr_addr + sub->rd_offs; + + s = cnt; + + dma_sync_single_for_cpu(carddev, dmapos, s, DMA_FROM_DEVICE); + ret = copy_to_user(buf, sub->compr_area + sub->rd_offs, s); + dma_sync_single_for_device(carddev, dmapos, s, DMA_FROM_DEVICE); + } + if (ret) + return -EFAULT; + + spin_lock_irqsave(&sub->lock, flags); + + sub->threshold = 2 * bytes; + aiodma_rb_set_threshold(sub, sub->compr_bytes, 2 * bytes); + + if (sub->swm->dir == PORT_DIR_OUTPUT) { + sub->wr_offs += s; + if (sub->wr_offs >= sub->compr_bytes) + sub->wr_offs -= sub->compr_bytes; + } else { + sub->rd_offs += s; + if (sub->rd_offs >= sub->compr_bytes) + sub->rd_offs -= sub->compr_bytes; + } + aiodma_rb_sync(sub, sub->compr_addr, sub->compr_bytes, bytes); + + spin_unlock_irqrestore(&sub->lock, flags); + + return cnt; +} + +static int uniphier_aio_compr_get_caps(struct snd_compr_stream *cstream, + struct snd_compr_caps *caps) +{ + caps->num_codecs = 1; + caps->min_fragment_size = AUD_MIN_FRAGMENT_SIZE; + caps->max_fragment_size = AUD_MAX_FRAGMENT_SIZE; + caps->min_fragments = AUD_MIN_FRAGMENT; + caps->max_fragments = AUD_MAX_FRAGMENT; + caps->codecs[0] = SND_AUDIOCODEC_IEC61937; + + return 0; +} + +static const struct snd_compr_codec_caps caps_iec = { + .num_descriptors = 1, + .descriptor[0].max_ch = 8, + .descriptor[0].num_sample_rates = 0, + .descriptor[0].num_bitrates = 0, + .descriptor[0].profiles = SND_AUDIOPROFILE_IEC61937_SPDIF, + .descriptor[0].modes = SND_AUDIOMODE_IEC_AC3 | + SND_AUDIOMODE_IEC_MPEG1 | + SND_AUDIOMODE_IEC_MP3 | + SND_AUDIOMODE_IEC_DTS, + .descriptor[0].formats = 0, +}; + +static int uniphier_aio_compr_get_codec_caps(struct snd_compr_stream *stream, + struct snd_compr_codec_caps *codec) +{ + if (codec->codec == SND_AUDIOCODEC_IEC61937) + *codec = caps_iec; + else + return -EINVAL; + + return 0; +} + +const struct snd_compr_ops uniphier_aio_compr_ops = { + .open = uniphier_aio_compr_open, + .free = uniphier_aio_compr_free, + .get_params = uniphier_aio_compr_get_params, + .set_params = uniphier_aio_compr_set_params, + .trigger = uniphier_aio_compr_trigger, + .pointer = uniphier_aio_compr_pointer, + .copy = uniphier_aio_compr_copy, + .get_caps = uniphier_aio_compr_get_caps, + .get_codec_caps = uniphier_aio_compr_get_codec_caps, +}; diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c index 6d0ca6dde913..22f122a42442 100644 --- a/sound/soc/uniphier/aio-dma.c +++ b/sound/soc/uniphier/aio-dma.c @@ -263,6 +263,7 @@ static const struct snd_soc_platform_driver uniphier_soc_platform = { .pcm_new = uniphier_aiodma_new, .pcm_free = uniphier_aiodma_free, .ops = &uniphier_aiodma_ops, + .compr_ops = &uniphier_aio_compr_ops, }; static const struct regmap_config aiodma_regmap_config = { diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index b12e2e3d7699..2cd64273fb5b 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -305,6 +305,7 @@ static inline struct uniphier_aio *uniphier_priv(struct snd_soc_dai *dai) } int uniphier_aiodma_soc_register_platform(struct platform_device *pdev); +extern const struct snd_compr_ops uniphier_aio_compr_ops; int uniphier_aio_dai_probe(struct snd_soc_dai *dai); int uniphier_aio_dai_remove(struct snd_soc_dai *dai); From db4cb3d04eba91db48da0032c44b83ed7185973c Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 19 Jan 2018 18:25:33 +0900 Subject: [PATCH 241/942] ASoC: uniphier: add support for UniPhier LD11/LD20 AIO driver This patch adds support for UniPhier AIO sound driver which is included in UniPhier LD11/LD20 SoCs. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/Kconfig | 11 + sound/soc/uniphier/Makefile | 2 + sound/soc/uniphier/aio-ld11.c | 431 ++++++++++++++++++++++++++++++++++ 3 files changed, 444 insertions(+) create mode 100644 sound/soc/uniphier/aio-ld11.c diff --git a/sound/soc/uniphier/Kconfig b/sound/soc/uniphier/Kconfig index 1a55ccebd8f5..5da545b9bf2a 100644 --- a/sound/soc/uniphier/Kconfig +++ b/sound/soc/uniphier/Kconfig @@ -19,6 +19,17 @@ config SND_SOC_UNIPHIER_AIO Select Y if you use such device. If unsure select "N". +config SND_SOC_UNIPHIER_LD11 + tristate "UniPhier LD11/LD20 Device Driver" + depends on SND_SOC_UNIPHIER + select SND_SOC_UNIPHIER_AIO + select SND_SOC_UNIPHIER_AIO_DMA + help + This adds ASoC driver for Socionext UniPhier LD11/LD20 + input and output that can be used with other codecs. + Select Y if you use such device. + If unsure select "N". + config SND_SOC_UNIPHIER_EVEA_CODEC tristate "UniPhier SoC internal audio codec" depends on SND_SOC_UNIPHIER diff --git a/sound/soc/uniphier/Makefile b/sound/soc/uniphier/Makefile index 4448175c70ab..587a89700950 100644 --- a/sound/soc/uniphier/Makefile +++ b/sound/soc/uniphier/Makefile @@ -1,7 +1,9 @@ # SPDX-License-Identifier: GPL-2.0 snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o aio-cpu.o aio-compress.o +snd-soc-uniphier-aio-ld11-objs := aio-ld11.o obj-$(CONFIG_SND_SOC_UNIPHIER_AIO) += snd-soc-uniphier-aio-cpu.o +obj-$(CONFIG_SND_SOC_UNIPHIER_LD11) += snd-soc-uniphier-aio-ld11.o snd-soc-uniphier-evea-objs := evea.o obj-$(CONFIG_SND_SOC_UNIPHIER_EVEA_CODEC) += snd-soc-uniphier-evea.o diff --git a/sound/soc/uniphier/aio-ld11.c b/sound/soc/uniphier/aio-ld11.c new file mode 100644 index 000000000000..8e40e6c2e42f --- /dev/null +++ b/sound/soc/uniphier/aio-ld11.c @@ -0,0 +1,431 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext UniPhier AIO ALSA driver for LD11/LD20. +// +// Copyright (c) 2016-2018 Socionext Inc. +// +// 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; version 2 +// of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, see . + +#include + +#include "aio.h" + +static const struct uniphier_aio_spec uniphier_aio_ld11[] = { + /* for HDMI PCM In, Pin:AI1Dx */ + { + .name = AUD_NAME_PCMIN1, + .gname = AUD_GNAME_HDMI, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_INPUT, + .rb = { 21, 14, }, + .ch = { 21, 14, }, + .iif = { 5, 3, }, + .iport = { 0, AUD_HW_PCMIN1, }, + }, + }, + + /* for SIF In, Pin:AI2Dx */ + { + .name = AUD_NAME_PCMIN2, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_INPUT, + .rb = { 22, 15, }, + .ch = { 22, 15, }, + .iif = { 6, 4, }, + .iport = { 1, AUD_HW_PCMIN2, }, + }, + }, + + /* for Line In, Pin:AI3Dx */ + { + .name = AUD_NAME_PCMIN3, + .gname = AUD_GNAME_LINE, + .swm = { + .type = PORT_TYPE_EVE, + .dir = PORT_DIR_INPUT, + .rb = { 23, 16, }, + .ch = { 23, 16, }, + .iif = { 7, 5, }, + .iport = { 2, AUD_HW_PCMIN3, }, + }, + }, + + /* for S/PDIF In, Pin:AI1IEC */ + { + .name = AUD_NAME_IECIN1, + .gname = AUD_GNAME_IEC, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_INPUT, + .rb = { 26, 17, }, + .ch = { 26, 17, }, + .iif = { 10, 6, }, + .iport = { 3, AUD_HW_IECIN1, }, + }, + }, + + /* for Speaker, Pin:AO1Dx */ + { + .name = AUD_NAME_HPCMOUT1, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_OUTPUT, + .rb = { 0, 0, }, + .ch = { 0, 0, }, + .oif = { 0, 0, }, + .oport = { 0, AUD_HW_HPCMOUT1, }, + }, + }, + + /* for HDMI PCM, Pin:AO2Dx */ + { + .name = AUD_NAME_PCMOUT1, + .gname = AUD_GNAME_HDMI, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_OUTPUT, + .rb = { 0, 0, }, + .ch = { 0, 0, }, + .oif = { 0, 0, }, + .oport = { 3, AUD_HW_PCMOUT1, }, + }, + }, + + /* for Line Out, Pin:LO2_x */ + { + .name = AUD_NAME_PCMOUT2, + .gname = AUD_GNAME_LINE, + .swm = { + .type = PORT_TYPE_EVE, + .dir = PORT_DIR_OUTPUT, + .rb = { 2, 2, }, + .ch = { 2, 2, }, + .oif = { 2, 2, }, + .oport = { 1, AUD_HW_PCMOUT2, }, + }, + }, + + /* for Headphone, Pin:HP1_x */ + { + .name = AUD_NAME_PCMOUT3, + .swm = { + .type = PORT_TYPE_EVE, + .dir = PORT_DIR_OUTPUT, + .rb = { 3, 3, }, + .ch = { 3, 3, }, + .oif = { 3, 3, }, + .oport = { 2, AUD_HW_PCMOUT3, }, + }, + }, + + /* for HW Sampling Rate Converter */ + { + .name = AUD_NAME_EPCMOUT2, + .swm = { + .type = PORT_TYPE_CONV, + .dir = PORT_DIR_OUTPUT, + .rb = { 7, 5, }, + .ch = { 7, 5, }, + .oif = { 7, 5, }, + .oport = { 6, AUD_HW_EPCMOUT2, }, + .och = { 17, 12, }, + .iif = { 1, 1, }, + }, + }, + + /* for HW Sampling Rate Converter 2 */ + { + .name = AUD_NAME_EPCMOUT3, + .swm = { + .type = PORT_TYPE_CONV, + .dir = PORT_DIR_OUTPUT, + .rb = { 8, 6, }, + .ch = { 8, 6, }, + .oif = { 8, 6, }, + .oport = { 7, AUD_HW_EPCMOUT3, }, + .och = { 18, 13, }, + .iif = { 2, 2, }, + }, + }, + + /* for S/PDIF Out, Pin:AO1IEC */ + { + .name = AUD_NAME_HIECOUT1, + .gname = AUD_GNAME_IEC, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_OUTPUT, + .rb = { 1, 1, }, + .ch = { 1, 1, }, + .oif = { 1, 1, }, + .oport = { 12, AUD_HW_HIECOUT1, }, + }, + }, + + /* for S/PDIF Out, Pin:AO1IEC, Compress */ + { + .name = AUD_NAME_HIECCOMPOUT1, + .gname = AUD_GNAME_IEC, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_OUTPUT, + .rb = { 1, 1, }, + .ch = { 1, 1, }, + .oif = { 1, 1, }, + .oport = { 12, AUD_HW_HIECOUT1, }, + }, + }, +}; + +static const struct uniphier_aio_pll uniphier_aio_pll_ld11[] = { + [AUD_PLL_A1] = { .enable = true, }, + [AUD_PLL_F1] = { .enable = true, }, + [AUD_PLL_A2] = { .enable = true, }, + [AUD_PLL_F2] = { .enable = true, }, + [AUD_PLL_APLL] = { .enable = true, }, + [AUD_PLL_RX0] = { .enable = true, }, + [AUD_PLL_USB0] = { .enable = true, }, + [AUD_PLL_HSC0] = { .enable = true, }, +}; + +static int uniphier_aio_ld11_probe(struct snd_soc_dai *dai) +{ + int ret; + + ret = uniphier_aio_dai_probe(dai); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_pll(dai, AUD_PLL_A1, 0, 0, 36864000); + if (ret < 0) + return ret; + ret = snd_soc_dai_set_pll(dai, AUD_PLL_F1, 0, 0, 36864000); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_pll(dai, AUD_PLL_A2, 0, 0, 33868800); + if (ret < 0) + return ret; + ret = snd_soc_dai_set_pll(dai, AUD_PLL_F2, 0, 0, 33868800); + if (ret < 0) + return ret; + + return 0; +} + +static struct snd_soc_dai_driver uniphier_aio_dai_ld11[] = { + { + .name = AUD_GNAME_HDMI, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_PCMOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .capture = { + .stream_name = AUD_NAME_PCMIN1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_32000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_PCMIN2, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .capture = { + .stream_name = AUD_NAME_PCMIN2, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_GNAME_LINE, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_PCMOUT2, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .capture = { + .stream_name = AUD_NAME_PCMIN3, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_HPCMOUT1, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_HPCMOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_PCMOUT3, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_PCMOUT3, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_HIECOUT1, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_HIECOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_spdif_ops, + }, + { + .name = AUD_NAME_EPCMOUT2, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_EPCMOUT2, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_32000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_EPCMOUT3, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_EPCMOUT3, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_32000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_HIECCOMPOUT1, + .probe = uniphier_aio_ld11_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .compress_new = snd_soc_new_compress, + .playback = { + .stream_name = AUD_NAME_HIECCOMPOUT1, + .channels_min = 1, + .channels_max = 1, + }, + .ops = &uniphier_aio_spdif_ops, + }, +}; + +static const struct uniphier_aio_chip_spec uniphier_aio_ld11_spec = { + .specs = uniphier_aio_ld11, + .num_specs = ARRAY_SIZE(uniphier_aio_ld11), + .dais = uniphier_aio_dai_ld11, + .num_dais = ARRAY_SIZE(uniphier_aio_dai_ld11), + .plls = uniphier_aio_pll_ld11, + .num_plls = ARRAY_SIZE(uniphier_aio_pll_ld11), + .addr_ext = 0, +}; + +static const struct uniphier_aio_chip_spec uniphier_aio_ld20_spec = { + .specs = uniphier_aio_ld11, + .num_specs = ARRAY_SIZE(uniphier_aio_ld11), + .dais = uniphier_aio_dai_ld11, + .num_dais = ARRAY_SIZE(uniphier_aio_dai_ld11), + .plls = uniphier_aio_pll_ld11, + .num_plls = ARRAY_SIZE(uniphier_aio_pll_ld11), + .addr_ext = 1, +}; + +static const struct of_device_id uniphier_aio_of_match[] = { + { + .compatible = "socionext,uniphier-ld11-aio", + .data = &uniphier_aio_ld11_spec, + }, + { + .compatible = "socionext,uniphier-ld20-aio", + .data = &uniphier_aio_ld20_spec, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, uniphier_aio_of_match); + +static struct platform_driver uniphier_aio_driver = { + .driver = { + .name = "snd-uniphier-aio", + .of_match_table = of_match_ptr(uniphier_aio_of_match), + }, + .probe = uniphier_aio_probe, + .remove = uniphier_aio_remove, +}; +module_platform_driver(uniphier_aio_driver); + +MODULE_AUTHOR("Katsuhiro Suzuki "); +MODULE_DESCRIPTION("UniPhier LD11/LD20 AIO driver."); +MODULE_LICENSE("GPL v2"); From 0d3e45bc6507bd1f8728bf586ebd16c2d9e40613 Mon Sep 17 00:00:00 2001 From: Dong Bo Date: Fri, 26 Jan 2018 11:21:49 +0800 Subject: [PATCH 242/942] libata: Fix compile warning with ATA_DEBUG enabled This fixs the following comile warnings with ATA_DEBUG enabled, which detected by Linaro GCC 5.2-2015.11: drivers/ata/libata-scsi.c: In function 'ata_scsi_dump_cdb': ./include/linux/kern_levels.h:5:18: warning: format '%d' expects argument of type 'int', but argument 6 has type 'u64 {aka long long unsigned int}' [-Wformat=] tj: Patch hand-applied and description trimmed. Signed-off-by: Dong Bo Signed-off-by: Tejun Heo --- drivers/ata/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 66be961c93a4..d959b154de4f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -4282,7 +4282,7 @@ static inline void ata_scsi_dump_cdb(struct ata_port *ap, #ifdef ATA_DEBUG struct scsi_device *scsidev = cmd->device; - DPRINTK("CDB (%u:%d,%d,%d) %9ph\n", + DPRINTK("CDB (%u:%d,%d,%lld) %9ph\n", ap->print_id, scsidev->channel, scsidev->id, scsidev->lun, cmd->cmnd); From 3b61e5121d5c4d0ea79fe90ced8df2fe5cb67dc2 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 30 Jan 2018 11:02:55 +0100 Subject: [PATCH 243/942] ahci: Add check for device presence (PCIe hot unplug) in ahci_stop_engine() Exit directly with ENODEV, if the AHCI controller is not available anymore. Otherwise a delay of 500ms for each port is added to the remove function while trying to issue a command on the non-existent controller. Signed-off-by: Stefan Roese Cc: Tejun Heo Signed-off-by: Tejun Heo --- drivers/ata/libahci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index a0de7a38430c..7adcf3caabd0 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -665,6 +665,16 @@ int ahci_stop_engine(struct ata_port *ap) if ((tmp & (PORT_CMD_START | PORT_CMD_LIST_ON)) == 0) return 0; + /* + * Don't try to issue commands but return with ENODEV if the + * AHCI controller not available anymore (e.g. due to PCIe hot + * unplugging). Otherwise a 500ms delay for each port is added. + */ + if (tmp == 0xffffffff) { + dev_err(ap->host->dev, "AHCI controller unavailable!\n"); + return -ENODEV; + } + /* setting HBA to idle */ tmp &= ~PORT_CMD_START; writel(tmp, port_mmio + PORT_CMD); From 9f2b51db5b551085e26c8af5fbe484d62b891ec9 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Mon, 5 Feb 2018 13:50:36 +0200 Subject: [PATCH 244/942] ata: libahci: fix comment indentation Indent the numbered item with one space like all other items in the same list. Signed-off-by: Baruch Siach Signed-off-by: Tejun Heo --- drivers/ata/libahci_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 341d0ef82cbd..30cc8f1a31e1 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c @@ -340,7 +340,7 @@ static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port, * 2) regulator for controlling the targets power (optional) * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node, * or for non devicetree enabled platforms a single clock - * 4) phys (optional) + * 4) phys (optional) * * RETURNS: * The allocated ahci_host_priv on success, otherwise an ERR_PTR value From 058f58e235cbe03e923b30ea7c49995a46a8725f Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 3 Feb 2018 20:30:56 -0800 Subject: [PATCH 245/942] libata: fix length validation of ATAPI-relayed SCSI commands syzkaller reported a crash in ata_bmdma_fill_sg() when writing to /dev/sg1. The immediate cause was that the ATA command's scatterlist was not DMA-mapped, which causes 'pi - 1' to underflow, resulting in a write to 'qc->ap->bmdma_prd[0xffffffff]'. Strangely though, the flag ATA_QCFLAG_DMAMAP was set in qc->flags. The root cause is that when __ata_scsi_queuecmd() is preparing to relay a SCSI command to an ATAPI device, it doesn't correctly validate the CDB length before copying it into the 16-byte buffer 'cdb' in 'struct ata_queued_cmd'. Namely, it validates the fixed CDB length expected based on the SCSI opcode but not the actual CDB length, which can be larger due to the use of the SG_NEXT_CMD_LEN ioctl. Since 'flags' is the next member in ata_queued_cmd, a buffer overflow corrupts it. Fix it by requiring that the actual CDB length be <= 16 (ATAPI_CDB_LEN). [Really it seems the length should be required to be <= dev->cdb_len, but the current behavior seems to have been intentionally introduced by commit 607126c2a21c ("libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs") to work around a userspace bug in mplayer. Probably the workaround is no longer needed (mplayer was fixed in 2007), but continuing to allow lengths to up 16 appears harmless for now.] Here's a reproducer that works in QEMU when /dev/sg1 refers to the CD-ROM drive that qemu-system-x86_64 creates by default: #include #include #include #define SG_NEXT_CMD_LEN 0x2283 int main() { char buf[53] = { [36] = 0x7e, [52] = 0x02 }; int fd = open("/dev/sg1", O_RDWR); ioctl(fd, SG_NEXT_CMD_LEN, &(int){ 17 }); write(fd, buf, sizeof(buf)); } The crash was: BUG: unable to handle kernel paging request at ffff8cb97db37ffc IP: ata_bmdma_fill_sg drivers/ata/libata-sff.c:2623 [inline] IP: ata_bmdma_qc_prep+0xa4/0xc0 drivers/ata/libata-sff.c:2727 PGD fb6c067 P4D fb6c067 PUD 0 Oops: 0002 [#1] SMP CPU: 1 PID: 150 Comm: syz_ata_bmdma_q Not tainted 4.15.0-next-20180202 #99 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-20171110_100015-anatol 04/01/2014 [...] Call Trace: ata_qc_issue+0x100/0x1d0 drivers/ata/libata-core.c:5421 ata_scsi_translate+0xc9/0x1a0 drivers/ata/libata-scsi.c:2024 __ata_scsi_queuecmd drivers/ata/libata-scsi.c:4326 [inline] ata_scsi_queuecmd+0x8c/0x210 drivers/ata/libata-scsi.c:4375 scsi_dispatch_cmd+0xa2/0xe0 drivers/scsi/scsi_lib.c:1727 scsi_request_fn+0x24c/0x530 drivers/scsi/scsi_lib.c:1865 __blk_run_queue_uncond block/blk-core.c:412 [inline] __blk_run_queue+0x3a/0x60 block/blk-core.c:432 blk_execute_rq_nowait+0x93/0xc0 block/blk-exec.c:78 sg_common_write.isra.7+0x272/0x5a0 drivers/scsi/sg.c:806 sg_write+0x1ef/0x340 drivers/scsi/sg.c:677 __vfs_write+0x31/0x160 fs/read_write.c:480 vfs_write+0xa7/0x160 fs/read_write.c:544 SYSC_write fs/read_write.c:589 [inline] SyS_write+0x4d/0xc0 fs/read_write.c:581 do_syscall_64+0x5e/0x110 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x21/0x86 Fixes: 607126c2a21c ("libata-scsi: be tolerant of 12-byte ATAPI commands in 16-byte CDBs") Reported-by: syzbot+1ff6f9fcc3c35f1c72a95e26528c8e7e3276e4da@syzkaller.appspotmail.com Cc: # v2.6.24+ Signed-off-by: Eric Biggers Signed-off-by: Tejun Heo --- drivers/ata/libata-scsi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index d959b154de4f..9ae8986bae48 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -4309,7 +4309,9 @@ static inline int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { /* relay SCSI command to ATAPI device */ int len = COMMAND_SIZE(scsi_op); - if (unlikely(len > scmd->cmd_len || len > dev->cdb_len)) + if (unlikely(len > scmd->cmd_len || + len > dev->cdb_len || + scmd->cmd_len > ATAPI_CDB_LEN)) goto bad_cdb_len; xlat_func = atapi_xlat; From 9173e5e80729c8434b8d27531527c5245f4a5594 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 3 Feb 2018 20:33:27 -0800 Subject: [PATCH 246/942] libata: remove WARN() for DMA or PIO command without data syzkaller hit a WARN() in ata_qc_issue() when writing to /dev/sg0. This happened because it issued a READ_6 command with no data buffer. Just remove the WARN(), as it doesn't appear indicate a kernel bug. The expected behavior is to fail the command, which the code does. Here's a reproducer that works in QEMU when /dev/sg0 refers to a disk of the default type ("82371SB PIIX3 IDE"): #include #include int main() { char buf[42] = { [36] = 0x8 /* READ_6 */ }; write(open("/dev/sg0", O_RDWR), buf, sizeof(buf)); } Fixes: f92a26365a72 ("libata: change ATA_QCFLAG_DMAMAP semantics") Reported-by: syzbot+f7b556d1766502a69d85071d2ff08bd87be53d0f@syzkaller.appspotmail.com Cc: # v2.6.25+ Signed-off-by: Eric Biggers Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 3c09122bf038..61b09968d032 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -5401,8 +5401,7 @@ void ata_qc_issue(struct ata_queued_cmd *qc) * We guarantee to LLDs that they will have at least one * non-zero sg if the command is a data command. */ - if (WARN_ON_ONCE(ata_is_data(prot) && - (!qc->sg || !qc->n_elem || !qc->nbytes))) + if (ata_is_data(prot) && (!qc->sg || !qc->n_elem || !qc->nbytes)) goto sys_err; if (ata_is_dma(prot) || (ata_is_pio(prot) && From 2c1ec6fda2d07044cda922ee25337cf5d4b429b3 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sat, 3 Feb 2018 20:33:51 -0800 Subject: [PATCH 247/942] libata: don't try to pass through NCQ commands to non-NCQ devices syzkaller hit a WARN() in ata_bmdma_qc_issue() when writing to /dev/sg0. This happened because it issued an ATA pass-through command (ATA_16) where the protocol field indicated that NCQ should be used -- but the device did not support NCQ. We could just remove the WARN() from libata-sff.c, but the real problem seems to be that the SCSI -> ATA translation code passes through NCQ commands without verifying that the device actually supports NCQ. Fix this by adding the appropriate check to ata_scsi_pass_thru(). Here's reproducer that works in QEMU when /dev/sg0 refers to a disk of the default type ("82371SB PIIX3 IDE"): #include #include int main() { char buf[53] = { 0 }; buf[36] = 0x85; /* ATA_16 */ buf[37] = (12 << 1); /* FPDMA */ buf[38] = 0x1; /* Has data */ buf[51] = 0xC8; /* ATA_CMD_READ */ write(open("/dev/sg0", O_RDWR), buf, sizeof(buf)); } Fixes: ee7fb331c3ac ("libata: add support for NCQ commands for SG interface") Reported-by: syzbot+2f69ca28df61bdfc77cd36af2e789850355a221e@syzkaller.appspotmail.com Cc: # v4.4+ Signed-off-by: Eric Biggers Signed-off-by: Tejun Heo --- drivers/ata/libata-scsi.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 9ae8986bae48..89a9d4a2efc8 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -3316,6 +3316,12 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) goto invalid_fld; } + /* We may not issue NCQ commands to devices not supporting NCQ */ + if (ata_is_ncq(tf->protocol) && !ata_ncq_enabled(dev)) { + fp = 1; + goto invalid_fld; + } + /* sanity check for pio multi commands */ if ((cdb[1] & 0xe0) && !is_multi_taskfile(tf)) { fp = 1; From da77d76b95a0e8940793f4f7fe12a4a2d2048e39 Mon Sep 17 00:00:00 2001 From: Khiem Nguyen Date: Mon, 5 Feb 2018 04:18:51 +0900 Subject: [PATCH 248/942] sata_rcar: Reset SATA PHY when Salvator-X board resumes Because power of Salvator-X board is cut off in suspend, it needs to reset SATA PHY state in resume. Otherwise, SATA partition could not be accessed anymore. Signed-off-by: Khiem Nguyen Signed-off-by: Hien Dang [reinit phy in sata_rcar_resume() function on R-Car Gen3 only] [factor out SATA module init sequence] [fixed the prefix for the subject] Signed-off-by: Yoshihiro Kaneko Signed-off-by: Tejun Heo --- drivers/ata/sata_rcar.c | 63 ++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 23 deletions(-) diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 80ee2f2a50d0..6f47ca34767d 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -146,6 +146,7 @@ enum sata_rcar_type { RCAR_GEN1_SATA, RCAR_GEN2_SATA, + RCAR_GEN3_SATA, RCAR_R8A7790_ES1_SATA, }; @@ -784,26 +785,11 @@ static void sata_rcar_setup_port(struct ata_host *host) ioaddr->command_addr = ioaddr->cmd_addr + (ATA_REG_CMD << 2); } -static void sata_rcar_init_controller(struct ata_host *host) +static void sata_rcar_init_module(struct sata_rcar_priv *priv) { - struct sata_rcar_priv *priv = host->private_data; void __iomem *base = priv->base; u32 val; - /* reset and setup phy */ - switch (priv->type) { - case RCAR_GEN1_SATA: - sata_rcar_gen1_phy_init(priv); - break; - case RCAR_GEN2_SATA: - case RCAR_R8A7790_ES1_SATA: - sata_rcar_gen2_phy_init(priv); - break; - default: - dev_warn(host->dev, "SATA phy is not initialized\n"); - break; - } - /* SATA-IP reset state */ val = ioread32(base + ATAPI_CONTROL1_REG); val |= ATAPI_CONTROL1_RESET; @@ -824,10 +810,34 @@ static void sata_rcar_init_controller(struct ata_host *host) /* ack and mask */ iowrite32(0, base + SATAINTSTAT_REG); iowrite32(0x7ff, base + SATAINTMASK_REG); + /* enable interrupts */ iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); } +static void sata_rcar_init_controller(struct ata_host *host) +{ + struct sata_rcar_priv *priv = host->private_data; + void __iomem *base = priv->base; + + /* reset and setup phy */ + switch (priv->type) { + case RCAR_GEN1_SATA: + sata_rcar_gen1_phy_init(priv); + break; + case RCAR_GEN2_SATA: + case RCAR_GEN3_SATA: + case RCAR_R8A7790_ES1_SATA: + sata_rcar_gen2_phy_init(priv); + break; + default: + dev_warn(host->dev, "SATA phy is not initialized\n"); + break; + } + + sata_rcar_init_module(priv); +} + static const struct of_device_id sata_rcar_match[] = { { /* Deprecated by "renesas,sata-r8a7779" */ @@ -856,7 +866,7 @@ static const struct of_device_id sata_rcar_match[] = { }, { .compatible = "renesas,sata-r8a7795", - .data = (void *)RCAR_GEN2_SATA + .data = (void *)RCAR_GEN3_SATA }, { .compatible = "renesas,rcar-gen2-sata", @@ -864,7 +874,7 @@ static const struct of_device_id sata_rcar_match[] = { }, { .compatible = "renesas,rcar-gen3-sata", - .data = (void *)RCAR_GEN2_SATA + .data = (void *)RCAR_GEN3_SATA }, { }, }; @@ -982,11 +992,18 @@ static int sata_rcar_resume(struct device *dev) if (ret) return ret; - /* ack and mask */ - iowrite32(0, base + SATAINTSTAT_REG); - iowrite32(0x7ff, base + SATAINTMASK_REG); - /* enable interrupts */ - iowrite32(ATAPI_INT_ENABLE_SATAINT, base + ATAPI_INT_ENABLE_REG); + if (priv->type == RCAR_GEN3_SATA) { + sata_rcar_gen2_phy_init(priv); + sata_rcar_init_module(priv); + } else { + /* ack and mask */ + iowrite32(0, base + SATAINTSTAT_REG); + iowrite32(0x7ff, base + SATAINTMASK_REG); + + /* enable interrupts */ + iowrite32(ATAPI_INT_ENABLE_SATAINT, + base + ATAPI_INT_ENABLE_REG); + } ata_host_resume(host); From c53593e5cb693d59d9e8b64fb3a79436bf99c3b3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 22 Jan 2018 11:26:18 -0800 Subject: [PATCH 249/942] sched, cgroup: Don't reject lower cpu.max on ancestors While adding cgroup2 interface for the cpu controller, 0d5936344f30 ("sched: Implement interface for cgroup unified hierarchy") forgot to update input validation and left it to reject cpu.max config if any descendant has set a higher value. cgroup2 officially supports delegation and a descendant must not be able to restrict what its ancestors can configure. For absolute limits such as cpu.max and memory.max, this means that the config at each level should only act as the upper limit at that level and shouldn't interfere with what other cgroups can configure. This patch updates config validation on cgroup2 so that the cpu controller follows the same convention. Signed-off-by: Tejun Heo Fixes: 0d5936344f30 ("sched: Implement interface for cgroup unified hierarchy") Acked-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org # v4.15+ --- kernel/sched/core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index bf724c1952ea..1bc6a694c84f 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -6678,13 +6678,18 @@ static int tg_cfs_schedulable_down(struct task_group *tg, void *data) parent_quota = parent_b->hierarchical_quota; /* - * Ensure max(child_quota) <= parent_quota, inherit when no + * Ensure max(child_quota) <= parent_quota. On cgroup2, + * always take the min. On cgroup1, only inherit when no * limit is set: */ - if (quota == RUNTIME_INF) - quota = parent_quota; - else if (parent_quota != RUNTIME_INF && quota > parent_quota) - return -EINVAL; + if (cgroup_subsys_on_dfl(cpu_cgrp_subsys)) { + quota = min(quota, parent_quota); + } else { + if (quota == RUNTIME_INF) + quota = parent_quota; + else if (parent_quota != RUNTIME_INF && quota > parent_quota) + return -EINVAL; + } } cfs_b->hierarchical_quota = quota; From 685469e5bf9d31ccd9212be86f861a18fc213d05 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Mon, 12 Feb 2018 12:10:41 -0800 Subject: [PATCH 250/942] percpu: add Dennis Zhou as a percpu co-maintainer Dennis rewrote the percpu area allocator some months ago, understands most of the code base and has been responsive with the bug reports and questions. Let's add him as a co-maintainer. Signed-off-by: Tejun Heo Acked-by: Christopher Lameter --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3bdc260e36b7..f384e22546d3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10832,6 +10832,7 @@ F: drivers/platform/x86/peaq-wmi.c PER-CPU MEMORY ALLOCATOR M: Tejun Heo M: Christoph Lameter +M: Dennis Zhou T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu.git S: Maintained F: include/linux/percpu*.h From 2471c98165494173a3cd03231b216b909c063e41 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Thu, 1 Feb 2018 11:26:12 +0100 Subject: [PATCH 251/942] xfrm: Fix policy hold queue after flowcache removal. Now that the flowcache is removed we need to generate a new dummy bundle every time we check if the needed SAs are in place because the dummy bundle is not cached anymore. Fix it by passing the XFRM_LOOKUP_QUEUE flag to xfrm_lookup(). This makes sure that we get a dummy bundle in case the SAs are not yet in place. Fixes: 3ca28286ea80 ("xfrm_policy: bypass flow_cache_lookup") Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 7a23078132cf..8b3811ff002d 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1891,7 +1891,7 @@ static void xfrm_policy_queue_process(struct timer_list *t) spin_unlock(&pq->hold_queue.lock); dst_hold(xfrm_dst_path(dst)); - dst = xfrm_lookup(net, xfrm_dst_path(dst), &fl, sk, 0); + dst = xfrm_lookup(net, xfrm_dst_path(dst), &fl, sk, XFRM_LOOKUP_QUEUE); if (IS_ERR(dst)) goto purge_queue; From d97ca5d714a5334aecadadf696875da40f1fbf3e Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Mon, 12 Feb 2018 14:42:01 +0100 Subject: [PATCH 252/942] xfrm_user: uncoditionally validate esn replay attribute struct The sanity test added in ecd7918745234 can be bypassed, validation only occurs if XFRM_STATE_ESN flag is set, but rest of code doesn't care and just checks if the attribute itself is present. So always validate. Alternative is to reject if we have the attribute without the flag but that would change abi. Reported-by: syzbot+0ab777c27d2bb7588f73@syzkaller.appspotmail.com Cc: Mathias Krause Fixes: ecd7918745234 ("xfrm_user: ensure user supplied esn replay window is valid") Fixes: d8647b79c3b7e ("xfrm: Add user interface for esn and big anti-replay windows") Signed-off-by: Florian Westphal Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_user.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 7f52b8eb177d..080035f056d9 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -121,22 +121,17 @@ static inline int verify_replay(struct xfrm_usersa_info *p, struct nlattr *rt = attrs[XFRMA_REPLAY_ESN_VAL]; struct xfrm_replay_state_esn *rs; - if (p->flags & XFRM_STATE_ESN) { - if (!rt) - return -EINVAL; - - rs = nla_data(rt); - - if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8) - return -EINVAL; - - if (nla_len(rt) < (int)xfrm_replay_state_esn_len(rs) && - nla_len(rt) != sizeof(*rs)) - return -EINVAL; - } - if (!rt) - return 0; + return (p->flags & XFRM_STATE_ESN) ? -EINVAL : 0; + + rs = nla_data(rt); + + if (rs->bmp_len > XFRMA_REPLAY_ESN_MAX / sizeof(rs->bmp[0]) / 8) + return -EINVAL; + + if (nla_len(rt) < (int)xfrm_replay_state_esn_len(rs) && + nla_len(rt) != sizeof(*rs)) + return -EINVAL; /* As only ESP and AH support ESN feature. */ if ((p->id.proto != IPPROTO_ESP) && (p->id.proto != IPPROTO_AH)) From 2b62786951ca38cc9fd0bd9273de0aae1b45134d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 13 Feb 2018 02:08:53 +0000 Subject: [PATCH 253/942] ASoC: rsnd: indicate IRQ error status for debug SSI/SRC have under/over flow error handling, and its status is useful for debuging. But sometimes it might be too much message, and it might blocks necessity other information. To avoid such situation, basically this patch indicates interrupt status debug message if DEBUG was defined, but it will be suppressed if RSND_DEBUG_NO_IRQ_STATUS was defined. Reported-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Signed-off-by: Mark Brown --- sound/soc/sh/rcar/rsnd.h | 10 ++++++++++ sound/soc/sh/rcar/src.c | 22 ++++++++++++++++++++-- sound/soc/sh/rcar/ssi.c | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index ad6523595b0a..5241ea7cf153 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -788,4 +788,14 @@ void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type); #define rsnd_mod_confirm_dvc(mdvc) #endif +/* + * If you don't need interrupt status debug message, + * define RSND_DEBUG_NO_IRQ_STATUS as 1 on top of src.c/ssi.c + * + * #define RSND_DEBUG_NO_IRQ_STATUS 1 + */ +#define rsnd_dbg_irq_status(dev, param...) \ + if (!IS_BUILTIN(RSND_DEBUG_NO_IRQ_STATUS)) \ + dev_dbg(dev, param) + #endif diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 510b68a483b4..a727e71587b6 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -8,6 +8,15 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +/* + * you can enable below define if you don't need + * SSI interrupt status debug message when debugging + * see rsnd_dbg_irq_status() + * + * #define RSND_DEBUG_NO_IRQ_STATUS 1 + */ + #include "rsnd.h" #define SRC_NAME "src" @@ -325,7 +334,10 @@ static void rsnd_src_status_clear(struct rsnd_mod *mod) static bool rsnd_src_error_occurred(struct rsnd_mod *mod) { + struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); u32 val0, val1; + u32 status0, status1; bool ret = false; val0 = val1 = OUF_SRC(rsnd_mod_id(mod)); @@ -338,9 +350,15 @@ static bool rsnd_src_error_occurred(struct rsnd_mod *mod) if (rsnd_src_sync_is_enabled(mod)) val0 = val0 & 0xffff; - if ((rsnd_mod_read(mod, SCU_SYS_STATUS0) & val0) || - (rsnd_mod_read(mod, SCU_SYS_STATUS1) & val1)) + status0 = rsnd_mod_read(mod, SCU_SYS_STATUS0); + status1 = rsnd_mod_read(mod, SCU_SYS_STATUS1); + if ((status0 & val0) || (status1 & val1)) { + rsnd_dbg_irq_status(dev, "%s[%d] err status : 0x%08x, 0x%08x\n", + rsnd_mod_name(mod), rsnd_mod_id(mod), + status0, status1); + ret = true; + } return ret; } diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 97a9db892a8f..333b802681ad 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -11,6 +11,15 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ + +/* + * you can enable below define if you don't need + * SSI interrupt status debug message when debugging + * see rsnd_dbg_irq_status() + * + * #define RSND_DEBUG_NO_IRQ_STATUS 1 + */ + #include #include #include "rsnd.h" @@ -603,6 +612,7 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod, struct rsnd_dai_stream *io) { struct rsnd_priv *priv = rsnd_mod_to_priv(mod); + struct device *dev = rsnd_priv_to_dev(priv); int is_dma = rsnd_ssi_is_dma_mode(mod); u32 status; bool elapsed = false; @@ -621,8 +631,12 @@ static void __rsnd_ssi_interrupt(struct rsnd_mod *mod, elapsed = rsnd_ssi_pio_interrupt(mod, io); /* DMA only */ - if (is_dma && (status & (UIRQ | OIRQ))) + if (is_dma && (status & (UIRQ | OIRQ))) { + rsnd_dbg_irq_status(dev, "%s[%d] err status : 0x%08x\n", + rsnd_mod_name(mod), rsnd_mod_id(mod), status); + stop = true; + } rsnd_ssi_status_clear(mod); rsnd_ssi_interrupt_out: From 1f6e920faae065fa8e6985b99ec86899bc3308de Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 13 Feb 2018 02:09:14 +0000 Subject: [PATCH 254/942] ASoC: rsnd: suppress rsnd_dai_call() debug message rsnd_dai_call() is using dev_dbg(), but its message is sometimes blocks nessesary other messages. If RSND_DEBUG_NO_DAI_CALL was defined it will be suppressed by this patch. Reported-by: Hiroyuki Yokoyama Signed-off-by: Kuninori Morimoto Tested-by: Hiroyuki Yokoyama Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 11 ++++++++++- sound/soc/sh/rcar/rsnd.h | 10 ++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 64d5ecb86528..5aafc37f5119 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -93,6 +93,15 @@ * [mod]->fn() -> [mod]->fn() -> [mod]->fn()... * */ + +/* + * you can enable below define if you don't need + * DAI status debug message when debugging + * see rsnd_dbg_dai_call() + * + * #define RSND_DEBUG_NO_DAI_CALL 1 + */ + #include #include "rsnd.h" @@ -468,7 +477,7 @@ static int rsnd_status_update(u32 *status, __rsnd_mod_shift_##fn, \ __rsnd_mod_add_##fn, \ __rsnd_mod_call_##fn); \ - dev_dbg(dev, "%s[%d]\t0x%08x %s\n", \ + rsnd_dbg_dai_call(dev, "%s[%d]\t0x%08x %s\n", \ rsnd_mod_name(mod), rsnd_mod_id(mod), *status, \ (func_call && (mod)->ops->fn) ? #fn : ""); \ if (func_call && (mod)->ops->fn) \ diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 5241ea7cf153..172c8d612890 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h @@ -798,4 +798,14 @@ void rsnd_mod_make_sure(struct rsnd_mod *mod, enum rsnd_mod_type type); if (!IS_BUILTIN(RSND_DEBUG_NO_IRQ_STATUS)) \ dev_dbg(dev, param) +/* + * If you don't need rsnd_dai_call debug message, + * define RSND_DEBUG_NO_DAI_CALL as 1 on top of core.c + * + * #define RSND_DEBUG_NO_DAI_CALL 1 + */ +#define rsnd_dbg_dai_call(dev, param...) \ + if (!IS_BUILTIN(RSND_DEBUG_NO_DAI_CALL)) \ + dev_dbg(dev, param) + #endif From d732d89b154af23946180bf785b7b0ec42275b49 Mon Sep 17 00:00:00 2001 From: Wu Fengguang Date: Tue, 13 Feb 2018 01:53:10 +0800 Subject: [PATCH 255/942] ASoC: uniphier: aiodma_rb_get_rp() can be static Fixes: f37fe2f9987b ("ASoC: uniphier: add support for UniPhier AIO common driver") Signed-off-by: Fengguang Wu Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/uniphier/aio-core.c b/sound/soc/uniphier/aio-core.c index 7e9451ca24af..1e5f053d9f6b 100644 --- a/sound/soc/uniphier/aio-core.c +++ b/sound/soc/uniphier/aio-core.c @@ -904,7 +904,7 @@ void aiodma_ch_set_enable(struct uniphier_aio_sub *sub, int enable) } } -u64 aiodma_rb_get_rp(struct uniphier_aio_sub *sub) +static u64 aiodma_rb_get_rp(struct uniphier_aio_sub *sub) { struct regmap *r = sub->aio->chip->regmap; u32 pos_u, pos_l; From 2fa0b7fdf8bd16b6cdda8516793989511c9322ed Mon Sep 17 00:00:00 2001 From: Wu Fengguang Date: Tue, 13 Feb 2018 01:16:06 +0800 Subject: [PATCH 256/942] ASoC: rt5659: rt5659_intel_hd_header_probe_setup() can be static Fixes: 041e74b71491 ("ASoC: rt5659: Add the support of Intel HDA Header") Signed-off-by: Fengguang Wu Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index ef3a44d6386b..b7721940b76f 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -4038,7 +4038,7 @@ static void rt5659_calibrate(struct rt5659_priv *rt5659) regmap_write(rt5659->regmap, RT5659_HP_CHARGE_PUMP_1, 0x0c16); } -void rt5659_intel_hd_header_probe_setup(struct rt5659_priv *rt5659) +static void rt5659_intel_hd_header_probe_setup(struct rt5659_priv *rt5659) { int value; From 1417c5fa3962d768bb8f18f4725a5fc039dbbb0e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 13 Feb 2018 02:54:58 +0000 Subject: [PATCH 257/942] ASoC: wm9081: fixup wm9081_digital_mute() reg read commit 48c338764296 ("ASoC: wm9081: replace codec to component") replaced codec to component, but it didn't keep WM9081_DAC_DIGITAL_2 value to reg. This patch fixup it. Reported-by: kbuild test robot Reported-by: Stephen Rothwell Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm9081.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 52dd610cd8dc..5a0ea7b3c149 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c @@ -1155,7 +1155,7 @@ static int wm9081_digital_mute(struct snd_soc_dai *codec_dai, int mute) struct snd_soc_component *component = codec_dai->component; unsigned int reg; - snd_soc_component_read32(component, WM9081_DAC_DIGITAL_2); + reg = snd_soc_component_read32(component, WM9081_DAC_DIGITAL_2); if (mute) reg |= WM9081_DAC_MUTE; From 143b44845d87042c0d49243ac32af92bce35a0d9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:10:45 +0000 Subject: [PATCH 258/942] ASoC: wm9712: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm9712.c | 109 ++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 58 deletions(-) diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 4f6d1a442bc4..7aeeeec8adbd 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -220,8 +220,8 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); unsigned int val = ucontrol->value.integer.value[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -264,8 +264,8 @@ static int wm9712_hp_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int shift, mixer; @@ -527,33 +527,33 @@ static const struct snd_soc_dapm_route wm9712_audio_map[] = { static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg; struct snd_pcm_runtime *runtime = substream->runtime; - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE; - return snd_soc_write(codec, reg, runtime->rate); + return snd_soc_component_write(component, reg, runtime->rate); } static int ac97_aux_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime; - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); - snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1); + snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000); if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return -ENODEV; - return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); + return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); } #define WM9712_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ @@ -597,7 +597,7 @@ static struct snd_soc_dai_driver wm9712_dai[] = { } }; -static int wm9712_set_bias_level(struct snd_soc_codec *codec, +static int wm9712_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { @@ -605,20 +605,20 @@ static int wm9712_set_bias_level(struct snd_soc_codec *codec, case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: - snd_soc_write(codec, AC97_POWERDOWN, 0x0000); + snd_soc_component_write(component, AC97_POWERDOWN, 0x0000); break; case SND_SOC_BIAS_OFF: /* disable everything including AC link */ - snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); break; } return 0; } -static int wm9712_soc_resume(struct snd_soc_codec *codec) +static int wm9712_soc_resume(struct snd_soc_component *component) { - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); int ret; ret = snd_ac97_reset(wm9712->ac97, true, WM9712_VENDOR_ID, @@ -626,17 +626,17 @@ static int wm9712_soc_resume(struct snd_soc_codec *codec) if (ret < 0) return ret; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); if (ret == 0) - regcache_sync(codec->component.regmap); + snd_soc_component_cache_sync(component); return ret; } -static int wm9712_soc_probe(struct snd_soc_codec *codec) +static int wm9712_soc_probe(struct snd_soc_component *component) { - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); struct regmap *regmap; int ret; @@ -645,59 +645,59 @@ static int wm9712_soc_probe(struct snd_soc_codec *codec) regmap = wm9712->mfd_pdata->regmap; } else { #ifdef CONFIG_SND_SOC_AC97_BUS - wm9712->ac97 = snd_soc_new_ac97_codec(codec, WM9712_VENDOR_ID, + wm9712->ac97 = snd_soc_new_ac97_component(component, WM9712_VENDOR_ID, WM9712_VENDOR_ID_MASK); if (IS_ERR(wm9712->ac97)) { ret = PTR_ERR(wm9712->ac97); - dev_err(codec->dev, + dev_err(component->dev, "Failed to register AC97 codec: %d\n", ret); return ret; } regmap = regmap_init_ac97(wm9712->ac97, &wm9712_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9712->ac97); + snd_soc_free_ac97_component(wm9712->ac97); return PTR_ERR(regmap); } #endif } - snd_soc_codec_init_regmap(codec, regmap); + snd_soc_component_init_regmap(component, regmap); /* set alc mux to none */ - snd_soc_update_bits(codec, AC97_VIDEO, 0x3000, 0x3000); + snd_soc_component_update_bits(component, AC97_VIDEO, 0x3000, 0x3000); return 0; } -static int wm9712_soc_remove(struct snd_soc_codec *codec) +static void wm9712_soc_remove(struct snd_soc_component *component) { #ifdef CONFIG_SND_SOC_AC97_BUS - struct wm9712_priv *wm9712 = snd_soc_codec_get_drvdata(codec); + struct wm9712_priv *wm9712 = snd_soc_component_get_drvdata(component); if (!wm9712->mfd_pdata) { - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9712->ac97); + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(wm9712->ac97); } #endif - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm9712 = { - .probe = wm9712_soc_probe, - .remove = wm9712_soc_remove, - .resume = wm9712_soc_resume, - .set_bias_level = wm9712_set_bias_level, - .suspend_bias_off = true, - - .component_driver = { - .controls = wm9712_snd_ac97_controls, - .num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls), - .dapm_widgets = wm9712_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets), - .dapm_routes = wm9712_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm9712_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9712 = { + .probe = wm9712_soc_probe, + .remove = wm9712_soc_remove, + .resume = wm9712_soc_resume, + .set_bias_level = wm9712_set_bias_level, + .controls = wm9712_snd_ac97_controls, + .num_controls = ARRAY_SIZE(wm9712_snd_ac97_controls), + .dapm_widgets = wm9712_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9712_dapm_widgets), + .dapm_routes = wm9712_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm9712_audio_map), + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm9712_probe(struct platform_device *pdev) @@ -713,26 +713,19 @@ static int wm9712_probe(struct platform_device *pdev) wm9712->mfd_pdata = dev_get_platdata(&pdev->dev); platform_set_drvdata(pdev, wm9712); - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai)); + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm9712, wm9712_dai, ARRAY_SIZE(wm9712_dai)); } -static int wm9712_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - -static struct platform_driver wm9712_codec_driver = { +static struct platform_driver wm9712_component_driver = { .driver = { - .name = "wm9712-codec", + .name = "wm9712-component", }, .probe = wm9712_probe, - .remove = wm9712_remove, }; -module_platform_driver(wm9712_codec_driver); +module_platform_driver(wm9712_component_driver); MODULE_DESCRIPTION("ASoC WM9711/WM9712 driver"); MODULE_AUTHOR("Liam Girdwood"); From 8ea99bc6619a0bf61931ed642fb35aeffdd0936f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:11:03 +0000 Subject: [PATCH 259/942] ASoC: wm9713: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm9713.c | 201 ++++++++++++++++++-------------------- 1 file changed, 97 insertions(+), 104 deletions(-) diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index df7220656d98..3d6cf0085005 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -196,16 +196,16 @@ SOC_SINGLE("3D Depth", AC97_REC_GAIN_MIC, 0, 15, 1), static int wm9713_voice_shutdown(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); if (WARN_ON(event != SND_SOC_DAPM_PRE_PMD)) return -EINVAL; /* Gracefully shut down the voice interface. */ - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, 0x0200); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0200); schedule_timeout_interruptible(msecs_to_jiffies(1)); - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, 0x0f00); - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x1000, 0x1000); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, 0x0f00); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x1000, 0x1000); return 0; } @@ -229,8 +229,8 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); unsigned int val = ucontrol->value.integer.value[0]; struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; @@ -273,8 +273,8 @@ static int wm9713_hp_mixer_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int mixer, shift; @@ -753,7 +753,7 @@ struct _pll_div { * to allow rounding later */ #define FIXED_PLL_SIZE ((1 << 22) * 10) -static void pll_factors(struct snd_soc_codec *codec, +static void pll_factors(struct snd_soc_component *component, struct _pll_div *pll_div, unsigned int source) { u64 Kpart; @@ -789,7 +789,7 @@ static void pll_factors(struct snd_soc_codec *codec, Ndiv = target / source; if ((Ndiv < 5) || (Ndiv > 12)) - dev_warn(codec->dev, + dev_warn(component->dev, "WM9713 PLL N value %u out of recommended range!\n", Ndiv); @@ -815,28 +815,28 @@ static void pll_factors(struct snd_soc_codec *codec, * Please note that changing the PLL input frequency may require * resynchronisation with the AC97 controller. */ -static int wm9713_set_pll(struct snd_soc_codec *codec, +static int wm9713_set_pll(struct snd_soc_component *component, int pll_id, unsigned int freq_in, unsigned int freq_out) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); u16 reg, reg2; struct _pll_div pll_div; /* turn PLL off ? */ if (freq_in == 0) { /* disable PLL power and select ext source */ - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0080, 0x0080); - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x0200, 0x0200); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0080); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0200); wm9713->pll_in = 0; return 0; } - pll_factors(codec, &pll_div, freq_in); + pll_factors(component, &pll_div, freq_in); if (pll_div.k == 0) { reg = (pll_div.n << 12) | (pll_div.lf << 11) | (pll_div.divsel << 9) | (pll_div.divctl << 8); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); } else { /* write the fractional k to the reg 0x46 pages */ reg2 = (pll_div.n << 12) | (pll_div.lf << 11) | (1 << 10) | @@ -844,31 +844,31 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, /* K [21:20] */ reg = reg2 | (0x5 << 4) | (pll_div.k >> 20); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); /* K [19:16] */ reg = reg2 | (0x4 << 4) | ((pll_div.k >> 16) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); /* K [15:12] */ reg = reg2 | (0x3 << 4) | ((pll_div.k >> 12) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); /* K [11:8] */ reg = reg2 | (0x2 << 4) | ((pll_div.k >> 8) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); /* K [7:4] */ reg = reg2 | (0x1 << 4) | ((pll_div.k >> 4) & 0xf); - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); reg = reg2 | (0x0 << 4) | (pll_div.k & 0xf); /* K [3:0] */ - snd_soc_write(codec, AC97_LINE1_LEVEL, reg); + snd_soc_component_write(component, AC97_LINE1_LEVEL, reg); } /* turn PLL on and select as source */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x0200, 0x0000); - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0080, 0x0000); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x0200, 0x0000); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0080, 0x0000); wm9713->pll_in = freq_in; /* wait 10ms AC97 link frames for the link to stabilise */ @@ -879,8 +879,8 @@ static int wm9713_set_pll(struct snd_soc_codec *codec, static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, int source, unsigned int freq_in, unsigned int freq_out) { - struct snd_soc_codec *codec = codec_dai->codec; - return wm9713_set_pll(codec, pll_id, freq_in, freq_out); + struct snd_soc_component *component = codec_dai->component; + return wm9713_set_pll(component, pll_id, freq_in, freq_out); } /* @@ -890,10 +890,10 @@ static int wm9713_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id, static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, int tristate) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; if (tristate) - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x6000, 0x0000); return 0; @@ -906,30 +906,30 @@ static int wm9713_set_dai_tristate(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div) { - struct snd_soc_codec *codec = codec_dai->codec; + struct snd_soc_component *component = codec_dai->component; switch (div_id) { case WM9713_PCMCLK_DIV: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0f00, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0f00, div); break; case WM9713_CLKA_MULT: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0002, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0002, div); break; case WM9713_CLKB_MULT: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x0004, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x0004, div); break; case WM9713_HIFI_DIV: - snd_soc_update_bits(codec, AC97_HANDSET_RATE, 0x7000, div); + snd_soc_component_update_bits(component, AC97_HANDSET_RATE, 0x7000, div); break; case WM9713_PCMBCLK_DIV: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, 0x0e00, div); + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x0e00, div); break; case WM9713_PCMCLK_PLL_DIV: - snd_soc_update_bits(codec, AC97_LINE1_LEVEL, + snd_soc_component_update_bits(component, AC97_LINE1_LEVEL, 0x007f, div | 0x60); break; case WM9713_HIFI_PLL_DIV: - snd_soc_update_bits(codec, AC97_LINE1_LEVEL, + snd_soc_component_update_bits(component, AC97_LINE1_LEVEL, 0x007f, div | 0x70); break; default: @@ -942,8 +942,8 @@ static int wm9713_set_dai_clkdiv(struct snd_soc_dai *codec_dai, static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - u16 gpio = snd_soc_read(codec, AC97_GPIO_CFG) & 0xffc5; + struct snd_soc_component *component = codec_dai->component; + u16 gpio = snd_soc_component_read32(component, AC97_GPIO_CFG) & 0xffc5; u16 reg = 0x8000; /* clock masters */ @@ -996,8 +996,8 @@ static int wm9713_set_dai_fmt(struct snd_soc_dai *codec_dai, break; } - snd_soc_write(codec, AC97_GPIO_CFG, gpio); - snd_soc_write(codec, AC97_CENTER_LFE_MASTER, reg); + snd_soc_component_write(component, AC97_GPIO_CFG, gpio); + snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, reg); return 0; } @@ -1005,22 +1005,22 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; /* enable PCM interface in master mode */ switch (params_width(params)) { case 16: break; case 20: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x000c, 0x0004); break; case 24: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x000c, 0x0008); break; case 32: - snd_soc_update_bits(codec, AC97_CENTER_LFE_MASTER, + snd_soc_component_update_bits(component, AC97_CENTER_LFE_MASTER, 0x000c, 0x000c); break; } @@ -1030,33 +1030,33 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, static int ac97_hifi_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime; int reg; - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x0001, 0x0001); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE; - return snd_soc_write(codec, reg, runtime->rate); + return snd_soc_component_write(component, reg, runtime->rate); } static int ac97_aux_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime; - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x0001, 0x0001); - snd_soc_update_bits(codec, AC97_PCI_SID, 0x8000, 0x8000); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x0001, 0x0001); + snd_soc_component_update_bits(component, AC97_PCI_SID, 0x8000, 0x8000); if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) return -ENODEV; - return snd_soc_write(codec, AC97_PCM_SURR_DAC_RATE, runtime->rate); + return snd_soc_component_write(component, AC97_PCM_SURR_DAC_RATE, runtime->rate); } #define WM9713_RATES (SNDRV_PCM_RATE_8000 | \ @@ -1142,48 +1142,48 @@ static struct snd_soc_dai_driver wm9713_dai[] = { }, }; -static int wm9713_set_bias_level(struct snd_soc_codec *codec, +static int wm9713_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: /* enable thermal shutdown */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0xe400, 0x0000); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xe400, 0x0000); break; case SND_SOC_BIAS_PREPARE: break; case SND_SOC_BIAS_STANDBY: /* enable master bias and vmid */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0xc400, 0x0000); - snd_soc_write(codec, AC97_POWERDOWN, 0x0000); + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0xc400, 0x0000); + snd_soc_component_write(component, AC97_POWERDOWN, 0x0000); break; case SND_SOC_BIAS_OFF: /* disable everything including AC link */ - snd_soc_write(codec, AC97_EXTENDED_MID, 0xffff); - snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MID, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); break; } return 0; } -static int wm9713_soc_suspend(struct snd_soc_codec *codec) +static int wm9713_soc_suspend(struct snd_soc_component *component) { /* Disable everything except touchpanel - that will be handled * by the touch driver and left disabled if touch is not in * use. */ - snd_soc_update_bits(codec, AC97_EXTENDED_MID, 0x7fff, + snd_soc_component_update_bits(component, AC97_EXTENDED_MID, 0x7fff, 0x7fff); - snd_soc_write(codec, AC97_EXTENDED_MSTATUS, 0xffff); - snd_soc_write(codec, AC97_POWERDOWN, 0x6f00); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_EXTENDED_MSTATUS, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0x6f00); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); return 0; } -static int wm9713_soc_resume(struct snd_soc_codec *codec) +static int wm9713_soc_resume(struct snd_soc_component *component) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); int ret; ret = snd_ac97_reset(wm9713->ac97, true, WM9713_VENDOR_ID, @@ -1191,24 +1191,24 @@ static int wm9713_soc_resume(struct snd_soc_codec *codec) if (ret < 0) return ret; - snd_soc_codec_force_bias_level(codec, SND_SOC_BIAS_STANDBY); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_STANDBY); /* do we need to re-start the PLL ? */ if (wm9713->pll_in) - wm9713_set_pll(codec, 0, wm9713->pll_in, 0); + wm9713_set_pll(component, 0, wm9713->pll_in, 0); /* only synchronise the codec if warm reset failed */ if (ret == 0) { - regcache_mark_dirty(codec->component.regmap); - snd_soc_cache_sync(codec); + regcache_mark_dirty(component->regmap); + snd_soc_component_cache_sync(component); } return ret; } -static int wm9713_soc_probe(struct snd_soc_codec *codec) +static int wm9713_soc_probe(struct snd_soc_component *component) { - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); struct regmap *regmap = NULL; if (wm9713->mfd_pdata) { @@ -1216,54 +1216,54 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) regmap = wm9713->mfd_pdata->regmap; } else { #ifdef CONFIG_SND_SOC_AC97_BUS - wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID, + wm9713->ac97 = snd_soc_new_ac97_component(component, WM9713_VENDOR_ID, WM9713_VENDOR_ID_MASK); if (IS_ERR(wm9713->ac97)) return PTR_ERR(wm9713->ac97); regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9713->ac97); + snd_soc_free_ac97_component(wm9713->ac97); return PTR_ERR(regmap); } #endif } - snd_soc_codec_init_regmap(codec, regmap); + snd_soc_component_init_regmap(component, regmap); /* unmute the adc - move to kcontrol */ - snd_soc_update_bits(codec, AC97_CD, 0x7fff, 0x0000); + snd_soc_component_update_bits(component, AC97_CD, 0x7fff, 0x0000); return 0; } -static int wm9713_soc_remove(struct snd_soc_codec *codec) +static void wm9713_soc_remove(struct snd_soc_component *component) { #ifdef CONFIG_SND_SOC_AC97_BUS - struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); + struct wm9713_priv *wm9713 = snd_soc_component_get_drvdata(component); if (!wm9713->mfd_pdata) { - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9713->ac97); + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(wm9713->ac97); } #endif - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm9713 = { - .probe = wm9713_soc_probe, - .remove = wm9713_soc_remove, - .suspend = wm9713_soc_suspend, - .resume = wm9713_soc_resume, - .set_bias_level = wm9713_set_bias_level, - - .component_driver = { - .controls = wm9713_snd_ac97_controls, - .num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls), - .dapm_widgets = wm9713_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets), - .dapm_routes = wm9713_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm9713_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9713 = { + .probe = wm9713_soc_probe, + .remove = wm9713_soc_remove, + .suspend = wm9713_soc_suspend, + .resume = wm9713_soc_resume, + .set_bias_level = wm9713_set_bias_level, + .controls = wm9713_snd_ac97_controls, + .num_controls = ARRAY_SIZE(wm9713_snd_ac97_controls), + .dapm_widgets = wm9713_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9713_dapm_widgets), + .dapm_routes = wm9713_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm9713_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm9713_probe(struct platform_device *pdev) @@ -1279,14 +1279,8 @@ static int wm9713_probe(struct platform_device *pdev) wm9713->mfd_pdata = dev_get_platdata(&pdev->dev); platform_set_drvdata(pdev, wm9713); - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); -} - -static int wm9713_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm9713, wm9713_dai, ARRAY_SIZE(wm9713_dai)); } static struct platform_driver wm9713_codec_driver = { @@ -1295,7 +1289,6 @@ static struct platform_driver wm9713_codec_driver = { }, .probe = wm9713_probe, - .remove = wm9713_remove, }; module_platform_driver(wm9713_codec_driver); From be4b1c09765c91897ecbfdb8d4e1c8239d5e0650 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:26:41 +0000 Subject: [PATCH 260/942] ASoC: ad73311: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ad73311.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/sound/soc/codecs/ad73311.c b/sound/soc/codecs/ad73311.c index d8d86a0fea60..03ee571e1b7a 100644 --- a/sound/soc/codecs/ad73311.c +++ b/sound/soc/codecs/ad73311.c @@ -54,25 +54,21 @@ static struct snd_soc_dai_driver ad73311_dai = { .formats = SNDRV_PCM_FMTBIT_S16_LE, }, }; -static const struct snd_soc_codec_driver soc_codec_dev_ad73311 = { - .component_driver = { - .dapm_widgets = ad73311_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), - .dapm_routes = ad73311_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ad73311 = { + .dapm_widgets = ad73311_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad73311_dapm_widgets), + .dapm_routes = ad73311_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ad73311_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ad73311_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ad73311, &ad73311_dai, 1); -} - -static int ad73311_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ad73311, &ad73311_dai, 1); } static struct platform_driver ad73311_codec_driver = { @@ -81,7 +77,6 @@ static struct platform_driver ad73311_codec_driver = { }, .probe = ad73311_probe, - .remove = ad73311_remove, }; module_platform_driver(ad73311_codec_driver); From b5b410de5550b0417f8648ccbf267192d8fc2272 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:38:18 +0000 Subject: [PATCH 261/942] ASoC: stac9766: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/stac9766.c | 77 +++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/sound/soc/codecs/stac9766.c b/sound/soc/codecs/stac9766.c index c66363a2cac7..f62101a629e0 100644 --- a/sound/soc/codecs/stac9766.c +++ b/sound/soc/codecs/stac9766.c @@ -168,58 +168,58 @@ static const struct snd_kcontrol_new stac9766_snd_ac97_controls[] = { static int ac97_analog_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime; unsigned short reg; /* enable variable rate audio, disable SPDIF output */ - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x1); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x1); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE; - return snd_soc_write(codec, reg, runtime->rate); + return snd_soc_component_write(component, reg, runtime->rate); } static int ac97_digital_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; struct snd_pcm_runtime *runtime = substream->runtime; unsigned short reg; - snd_soc_write(codec, AC97_SPDIF, 0x2002); + snd_soc_component_write(component, AC97_SPDIF, 0x2002); /* Enable VRA and SPDIF out */ - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x5, 0x5); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x5, 0x5); reg = AC97_PCM_FRONT_DAC_RATE; - return snd_soc_write(codec, reg, runtime->rate); + return snd_soc_component_write(component, reg, runtime->rate); } -static int stac9766_set_bias_level(struct snd_soc_codec *codec, +static int stac9766_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { switch (level) { case SND_SOC_BIAS_ON: /* full On */ case SND_SOC_BIAS_PREPARE: /* partial On */ case SND_SOC_BIAS_STANDBY: /* Off, with power */ - snd_soc_write(codec, AC97_POWERDOWN, 0x0000); + snd_soc_component_write(component, AC97_POWERDOWN, 0x0000); break; case SND_SOC_BIAS_OFF: /* Off, without power */ /* disable everything including AC link */ - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); break; } return 0; } -static int stac9766_codec_resume(struct snd_soc_codec *codec) +static int stac9766_component_resume(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); return snd_ac97_reset(ac97, true, STAC9766_VENDOR_ID, STAC9766_VENDOR_ID_MASK); @@ -272,13 +272,13 @@ static struct snd_soc_dai_driver stac9766_dai[] = { } }; -static int stac9766_codec_probe(struct snd_soc_codec *codec) +static int stac9766_component_probe(struct snd_soc_component *component) { struct snd_ac97 *ac97; struct regmap *regmap; int ret; - ac97 = snd_soc_new_ac97_codec(codec, STAC9766_VENDOR_ID, + ac97 = snd_soc_new_ac97_component(component, STAC9766_VENDOR_ID, STAC9766_VENDOR_ID_MASK); if (IS_ERR(ac97)) return PTR_ERR(ac97); @@ -289,46 +289,42 @@ static int stac9766_codec_probe(struct snd_soc_codec *codec) goto err_free_ac97; } - snd_soc_codec_init_regmap(codec, regmap); - snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_component_init_regmap(component, regmap); + snd_soc_component_set_drvdata(component, ac97); return 0; err_free_ac97: - snd_soc_free_ac97_codec(ac97); + snd_soc_free_ac97_component(ac97); return ret; } -static int stac9766_codec_remove(struct snd_soc_codec *codec) +static void stac9766_component_remove(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(ac97); - return 0; + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(ac97); } -static const struct snd_soc_codec_driver soc_codec_dev_stac9766 = { - .component_driver = { - .controls = stac9766_snd_ac97_controls, - .num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls), - }, - .set_bias_level = stac9766_set_bias_level, - .suspend_bias_off = true, - .probe = stac9766_codec_probe, - .remove = stac9766_codec_remove, - .resume = stac9766_codec_resume, +static const struct snd_soc_component_driver soc_component_dev_stac9766 = { + .controls = stac9766_snd_ac97_controls, + .num_controls = ARRAY_SIZE(stac9766_snd_ac97_controls), + .set_bias_level = stac9766_set_bias_level, + .probe = stac9766_component_probe, + .remove = stac9766_component_remove, + .resume = stac9766_component_resume, + .suspend_bias_off = 1, + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, + }; static int stac9766_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai)); -} - -static int stac9766_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_stac9766, stac9766_dai, ARRAY_SIZE(stac9766_dai)); } static struct platform_driver stac9766_codec_driver = { @@ -337,7 +333,6 @@ static struct platform_driver stac9766_codec_driver = { }, .probe = stac9766_probe, - .remove = stac9766_remove, }; module_platform_driver(stac9766_codec_driver); From 28f898499f3306274c900ad85b579435f9e4c8b5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 03:10:29 +0000 Subject: [PATCH 262/942] ASoC: wm9705: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/wm9705.c | 83 ++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 45 deletions(-) diff --git a/sound/soc/codecs/wm9705.c b/sound/soc/codecs/wm9705.c index 2c09f71fe433..ccdf088461b7 100644 --- a/sound/soc/codecs/wm9705.c +++ b/sound/soc/codecs/wm9705.c @@ -235,17 +235,17 @@ static const struct snd_soc_dapm_route wm9705_audio_map[] = { static int ac97_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int reg; - snd_soc_update_bits(codec, AC97_EXTENDED_STATUS, 0x1, 0x1); + snd_soc_component_update_bits(component, AC97_EXTENDED_STATUS, 0x1, 0x1); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) reg = AC97_PCM_FRONT_DAC_RATE; else reg = AC97_PCM_LR_ADC_RATE; - return snd_soc_write(codec, reg, substream->runtime->rate); + return snd_soc_component_write(component, reg, substream->runtime->rate); } #define WM9705_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 | \ @@ -289,18 +289,18 @@ static struct snd_soc_dai_driver wm9705_dai[] = { }; #ifdef CONFIG_PM -static int wm9705_soc_suspend(struct snd_soc_codec *codec) +static int wm9705_soc_suspend(struct snd_soc_component *component) { - regcache_cache_bypass(codec->component.regmap, true); - snd_soc_write(codec, AC97_POWERDOWN, 0xffff); - regcache_cache_bypass(codec->component.regmap, false); + regcache_cache_bypass(component->regmap, true); + snd_soc_component_write(component, AC97_POWERDOWN, 0xffff); + regcache_cache_bypass(component->regmap, false); return 0; } -static int wm9705_soc_resume(struct snd_soc_codec *codec) +static int wm9705_soc_resume(struct snd_soc_component *component) { - struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component); int ret; ret = snd_ac97_reset(wm9705->ac97, true, WM9705_VENDOR_ID, @@ -308,7 +308,7 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) if (ret < 0) return ret; - regcache_sync(codec->component.regmap); + snd_soc_component_cache_sync(component); return 0; } @@ -317,9 +317,9 @@ static int wm9705_soc_resume(struct snd_soc_codec *codec) #define wm9705_soc_resume NULL #endif -static int wm9705_soc_probe(struct snd_soc_codec *codec) +static int wm9705_soc_probe(struct snd_soc_component *component) { - struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component); struct regmap *regmap; if (wm9705->mfd_pdata) { @@ -327,54 +327,54 @@ static int wm9705_soc_probe(struct snd_soc_codec *codec) regmap = wm9705->mfd_pdata->regmap; } else { #ifdef CONFIG_SND_SOC_AC97_BUS - wm9705->ac97 = snd_soc_new_ac97_codec(codec, WM9705_VENDOR_ID, + wm9705->ac97 = snd_soc_new_ac97_component(component, WM9705_VENDOR_ID, WM9705_VENDOR_ID_MASK); if (IS_ERR(wm9705->ac97)) { - dev_err(codec->dev, "Failed to register AC97 codec\n"); + dev_err(component->dev, "Failed to register AC97 codec\n"); return PTR_ERR(wm9705->ac97); } regmap = regmap_init_ac97(wm9705->ac97, &wm9705_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9705->ac97); + snd_soc_free_ac97_component(wm9705->ac97); return PTR_ERR(regmap); } #endif } - snd_soc_codec_set_drvdata(codec, wm9705->ac97); - snd_soc_codec_init_regmap(codec, regmap); + snd_soc_component_set_drvdata(component, wm9705->ac97); + snd_soc_component_init_regmap(component, regmap); return 0; } -static int wm9705_soc_remove(struct snd_soc_codec *codec) +static void wm9705_soc_remove(struct snd_soc_component *component) { #ifdef CONFIG_SND_SOC_AC97_BUS - struct wm9705_priv *wm9705 = snd_soc_codec_get_drvdata(codec); + struct wm9705_priv *wm9705 = snd_soc_component_get_drvdata(component); if (!wm9705->mfd_pdata) { - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9705->ac97); + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(wm9705->ac97); } #endif - return 0; } -static const struct snd_soc_codec_driver soc_codec_dev_wm9705 = { - .probe = wm9705_soc_probe, - .remove = wm9705_soc_remove, - .suspend = wm9705_soc_suspend, - .resume = wm9705_soc_resume, - - .component_driver = { - .controls = wm9705_snd_ac97_controls, - .num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls), - .dapm_widgets = wm9705_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets), - .dapm_routes = wm9705_audio_map, - .num_dapm_routes = ARRAY_SIZE(wm9705_audio_map), - }, +static const struct snd_soc_component_driver soc_component_dev_wm9705 = { + .probe = wm9705_soc_probe, + .remove = wm9705_soc_remove, + .suspend = wm9705_soc_suspend, + .resume = wm9705_soc_resume, + .controls = wm9705_snd_ac97_controls, + .num_controls = ARRAY_SIZE(wm9705_snd_ac97_controls), + .dapm_widgets = wm9705_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm9705_dapm_widgets), + .dapm_routes = wm9705_audio_map, + .num_dapm_routes = ARRAY_SIZE(wm9705_audio_map), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm9705_probe(struct platform_device *pdev) @@ -388,14 +388,8 @@ static int wm9705_probe(struct platform_device *pdev) wm9705->mfd_pdata = dev_get_platdata(&pdev->dev); platform_set_drvdata(pdev, wm9705); - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); -} - -static int wm9705_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm9705, wm9705_dai, ARRAY_SIZE(wm9705_dai)); } static struct platform_driver wm9705_codec_driver = { @@ -404,7 +398,6 @@ static struct platform_driver wm9705_codec_driver = { }, .probe = wm9705_probe, - .remove = wm9705_remove, }; module_platform_driver(wm9705_codec_driver); From ac6267e34abfb322d2c408598866560922fccc22 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:26:20 +0000 Subject: [PATCH 263/942] ASoC: ad1980: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ad1980.c | 87 ++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c index ce89bfb42094..16dab3f00a1c 100644 --- a/sound/soc/codecs/ad1980.c +++ b/sound/soc/codecs/ad1980.c @@ -205,9 +205,9 @@ static struct snd_soc_dai_driver ad1980_dai = { #define AD1980_VENDOR_ID 0x41445300 #define AD1980_VENDOR_MASK 0xffffff00 -static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) +static int ad1980_reset(struct snd_soc_component *component, int try_warm) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); unsigned int retry_cnt = 0; int ret; @@ -223,16 +223,16 @@ static int ad1980_reset(struct snd_soc_codec *codec, int try_warm) * case the first nibble of data is eaten by the addr. (Tag is * always 16 bit) */ - snd_soc_write(codec, AC97_AD_SERIAL_CFG, 0x9900); + snd_soc_component_write(component, AC97_AD_SERIAL_CFG, 0x9900); } while (retry_cnt++ < 10); - dev_err(codec->dev, "Failed to reset: AC97 link error\n"); + dev_err(component->dev, "Failed to reset: AC97 link error\n"); return -EIO; } -static int ad1980_soc_probe(struct snd_soc_codec *codec) +static int ad1980_soc_probe(struct snd_soc_component *component) { struct snd_ac97 *ac97; struct regmap *regmap; @@ -240,10 +240,10 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) u16 vendor_id2; u16 ext_status; - ac97 = snd_soc_new_ac97_codec(codec, 0, 0); + ac97 = snd_soc_new_ac97_component(component, 0, 0); if (IS_ERR(ac97)) { ret = PTR_ERR(ac97); - dev_err(codec->dev, "Failed to register AC97 codec: %d\n", ret); + dev_err(component->dev, "Failed to register AC97 component: %d\n", ret); return ret; } @@ -253,72 +253,66 @@ static int ad1980_soc_probe(struct snd_soc_codec *codec) goto err_free_ac97; } - snd_soc_codec_init_regmap(codec, regmap); - snd_soc_codec_set_drvdata(codec, ac97); + snd_soc_component_init_regmap(component, regmap); + snd_soc_component_set_drvdata(component, ac97); - ret = ad1980_reset(codec, 0); + ret = ad1980_reset(component, 0); if (ret < 0) goto reset_err; - vendor_id2 = snd_soc_read(codec, AC97_VENDOR_ID2); + vendor_id2 = snd_soc_component_read32(component, AC97_VENDOR_ID2); if (vendor_id2 == 0x5374) { - dev_warn(codec->dev, + dev_warn(component->dev, "Found AD1981 - only 2/2 IN/OUT Channels supported\n"); } /* unmute captures and playbacks volume */ - snd_soc_write(codec, AC97_MASTER, 0x0000); - snd_soc_write(codec, AC97_PCM, 0x0000); - snd_soc_write(codec, AC97_REC_GAIN, 0x0000); - snd_soc_write(codec, AC97_CENTER_LFE_MASTER, 0x0000); - snd_soc_write(codec, AC97_SURROUND_MASTER, 0x0000); + snd_soc_component_write(component, AC97_MASTER, 0x0000); + snd_soc_component_write(component, AC97_PCM, 0x0000); + snd_soc_component_write(component, AC97_REC_GAIN, 0x0000); + snd_soc_component_write(component, AC97_CENTER_LFE_MASTER, 0x0000); + snd_soc_component_write(component, AC97_SURROUND_MASTER, 0x0000); /*power on LFE/CENTER/Surround DACs*/ - ext_status = snd_soc_read(codec, AC97_EXTENDED_STATUS); - snd_soc_write(codec, AC97_EXTENDED_STATUS, ext_status&~0x3800); + ext_status = snd_soc_component_read32(component, AC97_EXTENDED_STATUS); + snd_soc_component_write(component, AC97_EXTENDED_STATUS, ext_status&~0x3800); return 0; reset_err: - snd_soc_codec_exit_regmap(codec); + snd_soc_component_exit_regmap(component); err_free_ac97: - snd_soc_free_ac97_codec(ac97); + snd_soc_free_ac97_component(ac97); return ret; } -static int ad1980_soc_remove(struct snd_soc_codec *codec) +static void ad1980_soc_remove(struct snd_soc_component *component) { - struct snd_ac97 *ac97 = snd_soc_codec_get_drvdata(codec); + struct snd_ac97 *ac97 = snd_soc_component_get_drvdata(component); - snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(ac97); - return 0; + snd_soc_component_exit_regmap(component); + snd_soc_free_ac97_component(ac97); } -static const struct snd_soc_codec_driver soc_codec_dev_ad1980 = { - .probe = ad1980_soc_probe, - .remove = ad1980_soc_remove, - - .component_driver = { - .controls = ad1980_snd_ac97_controls, - .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), - .dapm_widgets = ad1980_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), - .dapm_routes = ad1980_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_ad1980 = { + .probe = ad1980_soc_probe, + .remove = ad1980_soc_remove, + .controls = ad1980_snd_ac97_controls, + .num_controls = ARRAY_SIZE(ad1980_snd_ac97_controls), + .dapm_widgets = ad1980_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ad1980_dapm_widgets), + .dapm_routes = ad1980_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(ad1980_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int ad1980_probe(struct platform_device *pdev) { - return snd_soc_register_codec(&pdev->dev, - &soc_codec_dev_ad1980, &ad1980_dai, 1); -} - -static int ad1980_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; + return devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_ad1980, &ad1980_dai, 1); } static struct platform_driver ad1980_codec_driver = { @@ -327,7 +321,6 @@ static struct platform_driver ad1980_codec_driver = { }, .probe = ad1980_probe, - .remove = ad1980_remove, }; module_platform_driver(ad1980_codec_driver); From 2b5803b95977d60f6e3c88672969b1da024fc3e8 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 13 Feb 2018 02:02:39 +0000 Subject: [PATCH 264/942] ASoC: uniphier: aio-dma: replace platform to component Now platform can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Tested-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-dma.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/uniphier/aio-dma.c b/sound/soc/uniphier/aio-dma.c index 22f122a42442..ef7bafa8e171 100644 --- a/sound/soc/uniphier/aio-dma.c +++ b/sound/soc/uniphier/aio-dma.c @@ -259,7 +259,7 @@ static void uniphier_aiodma_free(struct snd_pcm *pcm) snd_pcm_lib_preallocate_free_for_all(pcm); } -static const struct snd_soc_platform_driver uniphier_soc_platform = { +static const struct snd_soc_component_driver uniphier_soc_platform = { .pcm_new = uniphier_aiodma_new, .pcm_free = uniphier_aiodma_free, .ops = &uniphier_aiodma_ops, @@ -313,6 +313,7 @@ int uniphier_aiodma_soc_register_platform(struct platform_device *pdev) if (ret) return ret; - return devm_snd_soc_register_platform(dev, &uniphier_soc_platform); + return devm_snd_soc_register_component(dev, &uniphier_soc_platform, + NULL, 0); } EXPORT_SYMBOL_GPL(uniphier_aiodma_soc_register_platform); From b1c7fe26e0497386d3ae2e2404d1fa7f93895405 Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 13 Feb 2018 16:51:59 +0530 Subject: [PATCH 265/942] libata: transport: cleanup documentation of sysfs interface Clean-up the documentation of sysfs interfaces to be in the same format as described in Documentation/ABI/README. This will be useful for tracking changes in the ABI. Attributes are grouped by function (device, link or port) and then by date added. This patch also adds documentation for one attribute - /sys/class/ata_port/ataX/port_no Signed-off-by: Aishwarya Pant Signed-off-by: Tejun Heo --- Documentation/ABI/testing/sysfs-ata | 167 ++++++++++++++++------------ 1 file changed, 98 insertions(+), 69 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-ata b/Documentation/ABI/testing/sysfs-ata index aa4296498859..9ab0ef1dd1c7 100644 --- a/Documentation/ABI/testing/sysfs-ata +++ b/Documentation/ABI/testing/sysfs-ata @@ -1,110 +1,139 @@ What: /sys/class/ata_... -Date: August 2008 -Contact: Gwendal Grignou Description: - -Provide a place in sysfs for storing the ATA topology of the system. This allows -retrieving various information about ATA objects. + Provide a place in sysfs for storing the ATA topology of the + system. This allows retrieving various information about ATA + objects. Files under /sys/class/ata_port ------------------------------- - For each port, a directory ataX is created where X is the ata_port_id of - the port. The device parent is the ata host device. +For each port, a directory ataX is created where X is the ata_port_id of the +port. The device parent is the ata host device. -idle_irq (read) - Number of IRQ received by the port while idle [some ata HBA only]. +What: /sys/class/ata_port/ataX/nr_pmp_links +What: /sys/class/ata_port/ataX/idle_irq +Date: May, 2010 +KernelVersion: v2.6.37 +Contact: Gwendal Grignou +Description: + nr_pmp_links: (RO) If a SATA Port Multiplier (PM) is + connected, the number of links behind it. -nr_pmp_links (read) + idle_irq: (RO) Number of IRQ received by the port while + idle [some ata HBA only]. - If a SATA Port Multiplier (PM) is connected, number of link behind it. + +What: /sys/class/ata_port/ataX/port_no +Date: May, 2013 +KernelVersion: v3.11 +Contact: Gwendal Grignou +Description: + (RO) Host local port number. While registering host controller, + port numbers are tracked based upon number of ports available on + the controller. This attribute is needed by udev for composing + persistent links in /dev/disk/by-path. Files under /sys/class/ata_link ------------------------------- - Behind each port, there is a ata_link. If there is a SATA PM in the - topology, 15 ata_link objects are created. +Behind each port, there is a ata_link. If there is a SATA PM in the topology, 15 +ata_link objects are created. - If a link is behind a port, the directory name is linkX, where X is - ata_port_id of the port. - If a link is behind a PM, its name is linkX.Y where X is ata_port_id - of the parent port and Y the PM port. +If a link is behind a port, the directory name is linkX, where X is ata_port_id +of the port. If a link is behind a PM, its name is linkX.Y where X is +ata_port_id of the parent port and Y the PM port. -hw_sata_spd_limit - Maximum speed supported by the connected SATA device. +What: /sys/class/ata_link/linkX[.Y]/hw_sata_spd_limit +What: /sys/class/ata_link/linkX[.Y]/sata_spd_limit +What: /sys/class/ata_link/linkX[.Y]/sata_spd +Date: May, 2010 +KernelVersion: v2.6.37 +Contact: Gwendal Grignou +Description: + hw_sata_spd_limit: (RO) Maximum speed supported by the + connected SATA device. -sata_spd_limit + sata_spd_limit: (RO) Maximum speed imposed by libata. - Maximum speed imposed by libata. + sata_spd: (RO) Current speed of the link + eg. 1.5, 3 Gbps etc. -sata_spd - - Current speed of the link [1.5, 3Gps,...]. Files under /sys/class/ata_device --------------------------------- - Behind each link, up to two ata device are created. - The name of the directory is devX[.Y].Z where: - - X is ata_port_id of the port where the device is connected, - - Y the port of the PM if any, and - - Z the device id: for PATA, there is usually 2 devices [0,1], - only 1 for SATA. +Behind each link, up to two ata devices are created. +The name of the directory is devX[.Y].Z where: +- X is ata_port_id of the port where the device is connected, +- Y the port of the PM if any, and +- Z the device id: for PATA, there is usually 2 devices [0,1], only 1 for SATA. -class - Device class. Can be "ata" for disk, "atapi" for packet device, - "pmp" for PM, or "none" if no device was found behind the link. -dma_mode +What: /sys/class/ata_device/devX[.Y].Z/spdn_cnt +What: /sys/class/ata_device/devX[.Y].Z/gscr +What: /sys/class/ata_device/devX[.Y].Z/ering +What: /sys/class/ata_device/devX[.Y].Z/id +What: /sys/class/ata_device/devX[.Y].Z/pio_mode +What: /sys/class/ata_device/devX[.Y].Z/xfer_mode +What: /sys/class/ata_device/devX[.Y].Z/dma_mode +What: /sys/class/ata_device/devX[.Y].Z/class +Date: May, 2010 +KernelVersion: v2.6.37 +Contact: Gwendal Grignou +Description: + spdn_cnt: (RO) Number of times libata decided to lower the + speed of link due to errors. - Transfer modes supported by the device when in DMA mode. - Mostly used by PATA device. + gscr: (RO) Cached result of the dump of PM GSCR + register. Valid registers are: -pio_mode + 0: SATA_PMP_GSCR_PROD_ID, + 1: SATA_PMP_GSCR_REV, + 2: SATA_PMP_GSCR_PORT_INFO, + 32: SATA_PMP_GSCR_ERROR, + 33: SATA_PMP_GSCR_ERROR_EN, + 64: SATA_PMP_GSCR_FEAT, + 96: SATA_PMP_GSCR_FEAT_EN, + 130: SATA_PMP_GSCR_SII_GPIO - Transfer modes supported by the device when in PIO mode. - Mostly used by PATA device. + Only valid if the device is a PM. -xfer_mode + ering: (RO) Formatted output of the error ring of the + device. - Current transfer mode. + id: (RO) Cached result of IDENTIFY command, as + described in ATA8 7.16 and 7.17. Only valid if + the device is not a PM. -id + pio_mode: (RO) Transfer modes supported by the device when + in PIO mode. Mostly used by PATA device. - Cached result of IDENTIFY command, as described in ATA8 7.16 and 7.17. - Only valid if the device is not a PM. + xfer_mode: (RO) Current transfer mode -gscr + dma_mode: (RO) Transfer modes supported by the device when + in DMA mode. Mostly used by PATA device. - Cached result of the dump of PM GSCR register. - Valid registers are: - 0: SATA_PMP_GSCR_PROD_ID, - 1: SATA_PMP_GSCR_REV, - 2: SATA_PMP_GSCR_PORT_INFO, - 32: SATA_PMP_GSCR_ERROR, - 33: SATA_PMP_GSCR_ERROR_EN, - 64: SATA_PMP_GSCR_FEAT, - 96: SATA_PMP_GSCR_FEAT_EN, - 130: SATA_PMP_GSCR_SII_GPIO - Only valid if the device is a PM. + class: (RO) Device class. Can be "ata" for disk, + "atapi" for packet device, "pmp" for PM, or + "none" if no device was found behind the link. -trim - Shows the DSM TRIM mode currently used by the device. Valid - values are: - unsupported: Drive does not support DSM TRIM - unqueued: Drive supports unqueued DSM TRIM only - queued: Drive supports queued DSM TRIM - forced_unqueued: Drive's queued DSM support is known to be - buggy and only unqueued TRIM commands - are sent +What: /sys/class/ata_device/devX[.Y].Z/trim +Date: May, 2015 +KernelVersion: v4.10 +Contact: Gwendal Grignou +Description: + (RO) Shows the DSM TRIM mode currently used by the device. Valid + values are: -spdn_cnt + unsupported: Drive does not support DSM TRIM - Number of time libata decided to lower the speed of link due to errors. + unqueued: Drive supports unqueued DSM TRIM only -ering + queued: Drive supports queued DSM TRIM - Formatted output of the error ring of the device. + forced_unqueued: Drive's queued DSM support is known to + be buggy and only unqueued TRIM commands + are sent From 8f8ca51dbb4da0457f57f83d94aea81931b0707a Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 13 Feb 2018 13:43:23 +0100 Subject: [PATCH 266/942] ata: sata_rcar: Remove unused variable in sata_rcar_init_controller() drivers/ata/sata_rcar.c: In function 'sata_rcar_init_controller': drivers/ata/sata_rcar.c:821:8: warning: unused variable 'base' [-Wunused-variable] Fixes: da77d76b95a0e894 ("sata_rcar: Reset SATA PHY when Salvator-X board resumes") Signed-off-by: Geert Uytterhoeven Signed-off-by: Tejun Heo --- drivers/ata/sata_rcar.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/ata/sata_rcar.c b/drivers/ata/sata_rcar.c index 6f47ca34767d..6456e07db72a 100644 --- a/drivers/ata/sata_rcar.c +++ b/drivers/ata/sata_rcar.c @@ -818,7 +818,6 @@ static void sata_rcar_init_module(struct sata_rcar_priv *priv) static void sata_rcar_init_controller(struct ata_host *host) { struct sata_rcar_priv *priv = host->private_data; - void __iomem *base = priv->base; /* reset and setup phy */ switch (priv->type) { From 0a65e125150c227314dcd561a202a84228398449 Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 13 Feb 2018 13:48:16 +0530 Subject: [PATCH 267/942] libata: update documentation for sysfs interfaces Dcoumentation has been added by parsing through git commit history and reading code. This might be useful for scripting and tracking changes in the ABI. I do not have complete descriptions for the following 3 attributes; they have been annotated with the comment [to be documented] - /sys/class/scsi_host/hostX/ahci_port_cmd /sys/class/scsi_host/hostX/ahci_host_caps /sys/class/scsi_host/hostX/ahci_host_cap2 Signed-off-by: Aishwarya Pant Signed-off-by: Tejun Heo --- Documentation/ABI/testing/sysfs-block-device | 58 ++++++++++++ .../ABI/testing/sysfs-class-scsi_host | 89 +++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-block-device diff --git a/Documentation/ABI/testing/sysfs-block-device b/Documentation/ABI/testing/sysfs-block-device new file mode 100644 index 000000000000..82ef6eab042d --- /dev/null +++ b/Documentation/ABI/testing/sysfs-block-device @@ -0,0 +1,58 @@ +What: /sys/block/*/device/sw_activity +Date: Jun, 2008 +KernelVersion: v2.6.27 +Contact: linux-ide@vger.kernel.org +Description: + (RW) Used by drivers which support software controlled activity + LEDs. + + It has the following valid values: + + 0 OFF - the LED is not activated on activity + 1 BLINK_ON - the LED blinks on every 10ms when activity is + detected. + 2 BLINK_OFF - the LED is on when idle, and blinks off + every 10ms when activity is detected. + + Note that the user must turn sw_activity OFF it they wish to + control the activity LED via the em_message file. + + +What: /sys/block/*/device/unload_heads +Date: Sep, 2008 +KernelVersion: v2.6.28 +Contact: linux-ide@vger.kernel.org +Description: + (RW) Hard disk shock protection + + Writing an integer value to this file will take the heads of the + respective drive off the platter and block all I/O operations + for the specified number of milliseconds. + + - If the device does not support the unload heads feature, + access is denied with -EOPNOTSUPP. + - The maximal value accepted for a timeout is 30000 + milliseconds. + - A previously set timeout can be cancelled and disk can resume + normal operation immediately by specifying a timeout of 0. + - Some hard drives only comply with an earlier version of the + ATA standard, but support the unload feature nonetheless. + There is no safe way Linux can detect these devices, so this + is not enabled by default. If it is known that your device + does support the unload feature, then you can tell the kernel + to enable it by writing -1. It can be disabled again by + writing -2. + - Values below -2 are rejected with -EINVAL + + For more information, see + Documentation/laptops/disk-shock-protection.txt + + +What: /sys/block/*/device/ncq_prio_enable +Date: Oct, 2016 +KernelVersion: v4.10 +Contact: linux-ide@vger.kernel.org +Description: + (RW) Write to the file to turn on or off the SATA ncq (native + command queueing) support. By default this feature is turned + off. diff --git a/Documentation/ABI/testing/sysfs-class-scsi_host b/Documentation/ABI/testing/sysfs-class-scsi_host index 0eb255e7db12..bafc59fd7b69 100644 --- a/Documentation/ABI/testing/sysfs-class-scsi_host +++ b/Documentation/ABI/testing/sysfs-class-scsi_host @@ -27,3 +27,92 @@ Description: This file contains the current status of the "SSD Smart Path" the direct i/o path to physical devices. This setting is controller wide, affecting all configured logical drives on the controller. This file is readable and writable. + +What: /sys/class/scsi_host/hostX/link_power_management_policy +Date: Oct, 2007 +KernelVersion: v2.6.24 +Contact: linux-ide@vger.kernel.org +Description: + (RW) This parameter allows the user to read and set the link + (interface) power management. + + There are four possible options: + + min_power: Tell the controller to try to make the link use the + least possible power when possible. This may sacrifice some + performance due to increased latency when coming out of lower + power states. + + max_performance: Generally, this means no power management. + Tell the controller to have performance be a priority over power + management. + + medium_power: Tell the controller to enter a lower power state + when possible, but do not enter the lowest power state, thus + improving latency over min_power setting. + + med_power_with_dipm: Identical to the existing medium_power + setting except that it enables dipm (device initiated power + management) on top, which makes it match the Windows IRST (Intel + Rapid Storage Technology) driver settings. This setting is also + close to min_power, except that: + a) It does not use host-initiated slumber mode, but it does + allow device-initiated slumber + b) It does not enable low power device sleep mode (DevSlp). + +What: /sys/class/scsi_host/hostX/em_message +What: /sys/class/scsi_host/hostX/em_message_type +Date: Jun, 2008 +KernelVersion: v2.6.27 +Contact: linux-ide@vger.kernel.org +Description: + em_message: (RW) Enclosure management support. For the LED + protocol, writes and reads correspond to the LED message format + as defined in the AHCI spec. + + The user must turn sw_activity (under /sys/block/*/device/) OFF + it they wish to control the activity LED via the em_message + file. + + em_message_type: (RO) Displays the current enclosure management + protocol that is being used by the driver (for eg. LED, SAF-TE, + SES-2, SGPIO etc). + +What: /sys/class/scsi_host/hostX/ahci_port_cmd +What: /sys/class/scsi_host/hostX/ahci_host_caps +What: /sys/class/scsi_host/hostX/ahci_host_cap2 +Date: Mar, 2010 +KernelVersion: v2.6.35 +Contact: linux-ide@vger.kernel.org +Description: + [to be documented] + +What: /sys/class/scsi_host/hostX/ahci_host_version +Date: Mar, 2010 +KernelVersion: v2.6.35 +Contact: linux-ide@vger.kernel.org +Description: + (RO) Display the version of the AHCI spec implemented by the + host. + +What: /sys/class/scsi_host/hostX/em_buffer +Date: Apr, 2010 +KernelVersion: v2.6.35 +Contact: linux-ide@vger.kernel.org +Description: + (RW) Allows access to AHCI EM (enclosure management) buffer + directly if the host supports EM. + + For eg. the AHCI driver supports SGPIO EM messages but the + SATA/AHCI specs do not define the SGPIO message format of the EM + buffer. Different hardware(HW) vendors may have different + definitions. With the em_buffer attribute, this issue can be + solved by allowing HW vendors to provide userland drivers and + tools for their SGPIO initiators. + +What: /sys/class/scsi_host/hostX/em_message_supported +Date: Oct, 2009 +KernelVersion: v2.6.39 +Contact: linux-ide@vger.kernel.org +Description: + (RO) Displays supported enclosure management message types. From 0fe1daa6663ae9437c7168b81fe23c9ed50f55df Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Tue, 13 Feb 2018 02:03:12 +0000 Subject: [PATCH 268/942] ASoC: arizona: replace codec to component Now we can replace Codec to Component. Let's do it. Because there are many drivers which are using arizona, we need to update these all related drivers in same time. Otherwise compile error/warning happen Note: cs47l24 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 wm5102 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 wm5110 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 wm8997 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 wm8998 xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 1 -> .idle_bias_on = 0 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Tested-by: Charles Keepax Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 208 ++++++++++++++++----------------- sound/soc/codecs/arizona.h | 24 ++-- sound/soc/codecs/cs47l24.c | 86 +++++++------- sound/soc/codecs/wm5102.c | 106 ++++++++--------- sound/soc/codecs/wm5110.c | 140 +++++++++++----------- sound/soc/codecs/wm8997.c | 62 +++++----- sound/soc/codecs/wm8998.c | 88 +++++++------- sound/soc/codecs/wm_adsp.c | 58 ++++----- sound/soc/codecs/wm_adsp.h | 6 +- sound/soc/samsung/tm2_wm5110.c | 54 ++++----- 10 files changed, 400 insertions(+), 432 deletions(-) diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index b3375e19598a..ffcfe8ea1848 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -84,13 +84,13 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); int val; switch (event) { case SND_SOC_DAPM_POST_PMU: - val = snd_soc_read(codec, ARIZONA_INTERRUPT_RAW_STATUS_3); + val = snd_soc_component_read32(component, ARIZONA_INTERRUPT_RAW_STATUS_3); if (val & ARIZONA_SPK_OVERHEAT_STS) { dev_crit(arizona->dev, "Speaker not enabled due to temperature\n"); @@ -169,10 +169,10 @@ static const struct snd_soc_dapm_widget arizona_spkr = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD); -int arizona_init_spk(struct snd_soc_codec *codec) +int arizona_init_spk(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int ret; @@ -238,10 +238,10 @@ static const struct snd_soc_dapm_route arizona_mono_routes[] = { { "OUT6R", NULL, "OUT6L" }, }; -int arizona_init_mono(struct snd_soc_codec *codec) +int arizona_init_mono(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int i; @@ -255,11 +255,9 @@ int arizona_init_mono(struct snd_soc_codec *codec) } EXPORT_SYMBOL_GPL(arizona_init_mono); -int arizona_init_gpio(struct snd_soc_codec *codec) +int arizona_init_gpio(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int i; @@ -882,9 +880,9 @@ const struct snd_kcontrol_new arizona_voice_trigger_switch[] = { }; EXPORT_SYMBOL_GPL(arizona_voice_trigger_switch); -static void arizona_in_set_vu(struct snd_soc_codec *codec, int ena) +static void arizona_in_set_vu(struct snd_soc_component *component, int ena) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); unsigned int val; int i; @@ -894,15 +892,15 @@ static void arizona_in_set_vu(struct snd_soc_codec *codec, int ena) val = 0; for (i = 0; i < priv->num_inputs; i++) - snd_soc_update_bits(codec, + snd_soc_component_update_bits(component, ARIZONA_ADC_DIGITAL_VOLUME_1L + (i * 4), ARIZONA_IN_VU, val); } -bool arizona_input_analog(struct snd_soc_codec *codec, int shift) +bool arizona_input_analog(struct snd_soc_component *component, int shift) { unsigned int reg = ARIZONA_IN1L_CONTROL + ((shift / 2) * 8); - unsigned int val = snd_soc_read(codec, reg); + unsigned int val = snd_soc_component_read32(component, reg); return !(val & ARIZONA_IN1_MODE_MASK); } @@ -911,8 +909,8 @@ EXPORT_SYMBOL_GPL(arizona_input_analog); int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); unsigned int reg; if (w->shift % 2) @@ -925,25 +923,25 @@ int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, priv->in_pending++; break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, reg, ARIZONA_IN1L_MUTE, 0); + snd_soc_component_update_bits(component, reg, ARIZONA_IN1L_MUTE, 0); /* If this is the last input pending then allow VU */ priv->in_pending--; if (priv->in_pending == 0) { msleep(1); - arizona_in_set_vu(codec, 1); + arizona_in_set_vu(component, 1); } break; case SND_SOC_DAPM_PRE_PMD: - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, ARIZONA_IN1L_MUTE | ARIZONA_IN_VU, ARIZONA_IN1L_MUTE | ARIZONA_IN_VU); break; case SND_SOC_DAPM_POST_PMD: /* Disable volume updates if no inputs are enabled */ - reg = snd_soc_read(codec, ARIZONA_INPUT_ENABLES); + reg = snd_soc_component_read32(component, ARIZONA_INPUT_ENABLES); if (reg == 0) - arizona_in_set_vu(codec, 0); + arizona_in_set_vu(component, 0); break; default: break; @@ -957,8 +955,8 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; switch (event) { @@ -1001,7 +999,7 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, case ARIZONA_OUT4R_ENA_SHIFT: priv->out_up_pending--; if (!priv->out_up_pending && priv->out_up_delay) { - dev_dbg(codec->dev, "Power up delay: %d\n", + dev_dbg(component->dev, "Power up delay: %d\n", priv->out_up_delay); msleep(priv->out_up_delay); priv->out_up_delay = 0; @@ -1054,7 +1052,7 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, case ARIZONA_OUT4R_ENA_SHIFT: priv->out_down_pending--; if (!priv->out_down_pending && priv->out_down_delay) { - dev_dbg(codec->dev, "Power down delay: %d\n", + dev_dbg(component->dev, "Power down delay: %d\n", priv->out_down_delay); msleep(priv->out_down_delay); priv->out_down_delay = 0; @@ -1076,8 +1074,8 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; unsigned int mask = 1 << w->shift; unsigned int val; @@ -1111,15 +1109,15 @@ int arizona_hp_ev(struct snd_soc_dapm_widget *w, } EXPORT_SYMBOL_GPL(arizona_hp_ev); -static int arizona_dvfs_enable(struct snd_soc_codec *codec) +static int arizona_dvfs_enable(struct snd_soc_component *component) { - const struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + const struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int ret; ret = regulator_set_voltage(arizona->dcvdd, 1800000, 1800000); if (ret) { - dev_err(codec->dev, "Failed to boost DCVDD: %d\n", ret); + dev_err(component->dev, "Failed to boost DCVDD: %d\n", ret); return ret; } @@ -1128,7 +1126,7 @@ static int arizona_dvfs_enable(struct snd_soc_codec *codec) ARIZONA_SUBSYS_MAX_FREQ, ARIZONA_SUBSYS_MAX_FREQ); if (ret) { - dev_err(codec->dev, "Failed to enable subsys max: %d\n", ret); + dev_err(component->dev, "Failed to enable subsys max: %d\n", ret); regulator_set_voltage(arizona->dcvdd, 1200000, 1800000); return ret; } @@ -1136,9 +1134,9 @@ static int arizona_dvfs_enable(struct snd_soc_codec *codec) return 0; } -static int arizona_dvfs_disable(struct snd_soc_codec *codec) +static int arizona_dvfs_disable(struct snd_soc_component *component) { - const struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + const struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int ret; @@ -1146,28 +1144,28 @@ static int arizona_dvfs_disable(struct snd_soc_codec *codec) ARIZONA_DYNAMIC_FREQUENCY_SCALING_1, ARIZONA_SUBSYS_MAX_FREQ, 0); if (ret) { - dev_err(codec->dev, "Failed to disable subsys max: %d\n", ret); + dev_err(component->dev, "Failed to disable subsys max: %d\n", ret); return ret; } ret = regulator_set_voltage(arizona->dcvdd, 1200000, 1800000); if (ret) { - dev_err(codec->dev, "Failed to unboost DCVDD: %d\n", ret); + dev_err(component->dev, "Failed to unboost DCVDD: %d\n", ret); return ret; } return 0; } -int arizona_dvfs_up(struct snd_soc_codec *codec, unsigned int flags) +int arizona_dvfs_up(struct snd_soc_component *component, unsigned int flags) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); int ret = 0; mutex_lock(&priv->dvfs_lock); if (!priv->dvfs_cached && !priv->dvfs_reqs) { - ret = arizona_dvfs_enable(codec); + ret = arizona_dvfs_enable(component); if (ret) goto err; } @@ -1179,9 +1177,9 @@ err: } EXPORT_SYMBOL_GPL(arizona_dvfs_up); -int arizona_dvfs_down(struct snd_soc_codec *codec, unsigned int flags) +int arizona_dvfs_down(struct snd_soc_component *component, unsigned int flags) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); unsigned int old_reqs; int ret = 0; @@ -1191,7 +1189,7 @@ int arizona_dvfs_down(struct snd_soc_codec *codec, unsigned int flags) priv->dvfs_reqs &= ~flags; if (!priv->dvfs_cached && old_reqs && !priv->dvfs_reqs) - ret = arizona_dvfs_disable(codec); + ret = arizona_dvfs_disable(component); mutex_unlock(&priv->dvfs_lock); return ret; @@ -1201,8 +1199,8 @@ EXPORT_SYMBOL_GPL(arizona_dvfs_down); int arizona_dvfs_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); int ret = 0; mutex_lock(&priv->dvfs_lock); @@ -1210,7 +1208,7 @@ int arizona_dvfs_sysclk_ev(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: if (priv->dvfs_reqs) - ret = arizona_dvfs_enable(codec); + ret = arizona_dvfs_enable(component); priv->dvfs_cached = false; break; @@ -1222,7 +1220,7 @@ int arizona_dvfs_sysclk_ev(struct snd_soc_dapm_widget *w, priv->dvfs_cached = true; if (priv->dvfs_reqs) - ret = arizona_dvfs_disable(codec); + ret = arizona_dvfs_disable(component); break; default: break; @@ -1243,7 +1241,7 @@ int arizona_anc_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int val; switch (event) { @@ -1257,7 +1255,7 @@ int arizona_anc_ev(struct snd_soc_dapm_widget *w, return 0; } - snd_soc_write(codec, ARIZONA_CLOCK_CONTROL, val); + snd_soc_component_write(component, ARIZONA_CLOCK_CONTROL, val); return 0; } @@ -1277,10 +1275,10 @@ static unsigned int arizona_opclk_ref_44k1_rates[] = { 45158400, }; -static int arizona_set_opclk(struct snd_soc_codec *codec, unsigned int clk, +static int arizona_set_opclk(struct snd_soc_component *component, unsigned int clk, unsigned int freq) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); unsigned int reg; unsigned int *rates; int ref, div, refclk; @@ -1308,9 +1306,9 @@ static int arizona_set_opclk(struct snd_soc_codec *codec, unsigned int clk, div = 1; while (rates[ref] / div >= freq && div < 32) { if (rates[ref] / div == freq) { - dev_dbg(codec->dev, "Configured %dHz OPCLK\n", + dev_dbg(component->dev, "Configured %dHz OPCLK\n", freq); - snd_soc_update_bits(codec, reg, + snd_soc_component_update_bits(component, reg, ARIZONA_OPCLK_DIV_MASK | ARIZONA_OPCLK_SEL_MASK, (div << @@ -1322,22 +1320,22 @@ static int arizona_set_opclk(struct snd_soc_codec *codec, unsigned int clk, } } - dev_err(codec->dev, "Unable to generate %dHz OPCLK\n", freq); + dev_err(component->dev, "Unable to generate %dHz OPCLK\n", freq); return -EINVAL; } int arizona_clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); unsigned int val; int clk_idx; int ret; ret = regmap_read(arizona->regmap, w->reg, &val); if (ret) { - dev_err(codec->dev, "Failed to check clock source: %d\n", ret); + dev_err(component->dev, "Failed to check clock source: %d\n", ret); return ret; } @@ -1366,10 +1364,10 @@ int arizona_clk_ev(struct snd_soc_dapm_widget *w, } EXPORT_SYMBOL_GPL(arizona_clk_ev); -int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, +int arizona_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; char *name; unsigned int reg; @@ -1391,7 +1389,7 @@ int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, break; case ARIZONA_CLK_OPCLK: case ARIZONA_CLK_ASYNC_OPCLK: - return arizona_set_opclk(codec, clk_id, freq); + return arizona_set_opclk(component, clk_id, freq); default: return -EINVAL; } @@ -1445,8 +1443,8 @@ EXPORT_SYMBOL_GPL(arizona_set_sysclk); static int arizona_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int lrclk, bclk, mode, base; @@ -1620,8 +1618,8 @@ static const struct snd_pcm_hw_constraint_list arizona_constraint = { static int arizona_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; unsigned int base_rate; @@ -1651,10 +1649,10 @@ static int arizona_startup(struct snd_pcm_substream *substream, &dai_priv->constraint); } -static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec, +static void arizona_wm5102_set_dac_comp(struct snd_soc_component *component, unsigned int rate) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; struct reg_sequence dac_comp[] = { { 0x80, 0x3 }, @@ -1680,8 +1678,8 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; int base = dai->driver->base; int i, sr_val, ret; @@ -1704,9 +1702,9 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, case WM5102: case WM8997: if (arizona_sr_vals[sr_val] >= 88200) - ret = arizona_dvfs_up(codec, ARIZONA_DVFS_SR1_RQ); + ret = arizona_dvfs_up(component, ARIZONA_DVFS_SR1_RQ); else - ret = arizona_dvfs_down(codec, ARIZONA_DVFS_SR1_RQ); + ret = arizona_dvfs_down(component, ARIZONA_DVFS_SR1_RQ); if (ret) { arizona_aif_err(dai, "Failed to change DVFS %d\n", ret); @@ -1721,24 +1719,24 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, case ARIZONA_CLK_SYSCLK: switch (priv->arizona->type) { case WM5102: - arizona_wm5102_set_dac_comp(codec, + arizona_wm5102_set_dac_comp(component, params_rate(params)); break; default: break; } - snd_soc_update_bits(codec, ARIZONA_SAMPLE_RATE_1, + snd_soc_component_update_bits(component, ARIZONA_SAMPLE_RATE_1, ARIZONA_SAMPLE_RATE_1_MASK, sr_val); if (base) - snd_soc_update_bits(codec, base + ARIZONA_AIF_RATE_CTRL, + snd_soc_component_update_bits(component, base + ARIZONA_AIF_RATE_CTRL, ARIZONA_AIF1_RATE_MASK, 0); break; case ARIZONA_CLK_ASYNCCLK: - snd_soc_update_bits(codec, ARIZONA_ASYNC_SAMPLE_RATE_1, + snd_soc_component_update_bits(component, ARIZONA_ASYNC_SAMPLE_RATE_1, ARIZONA_ASYNC_SAMPLE_RATE_1_MASK, sr_val); if (base) - snd_soc_update_bits(codec, base + ARIZONA_AIF_RATE_CTRL, + snd_soc_component_update_bits(component, base + ARIZONA_AIF_RATE_CTRL, ARIZONA_AIF1_RATE_MASK, 8 << ARIZONA_AIF1_RATE_SHIFT); break; @@ -1750,20 +1748,20 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, return 0; } -static bool arizona_aif_cfg_changed(struct snd_soc_codec *codec, +static bool arizona_aif_cfg_changed(struct snd_soc_component *component, int base, int bclk, int lrclk, int frame) { int val; - val = snd_soc_read(codec, base + ARIZONA_AIF_BCLK_CTRL); + val = snd_soc_component_read32(component, base + ARIZONA_AIF_BCLK_CTRL); if (bclk != (val & ARIZONA_AIF1_BCLK_FREQ_MASK)) return true; - val = snd_soc_read(codec, base + ARIZONA_AIF_TX_BCLK_RATE); + val = snd_soc_component_read32(component, base + ARIZONA_AIF_TX_BCLK_RATE); if (lrclk != (val & ARIZONA_AIF1TX_BCPF_MASK)) return true; - val = snd_soc_read(codec, base + ARIZONA_AIF_FRAME_CTRL_1); + val = snd_soc_component_read32(component, base + ARIZONA_AIF_FRAME_CTRL_1); if (frame != (val & (ARIZONA_AIF1TX_WL_MASK | ARIZONA_AIF1TX_SLOT_LEN_MASK))) return true; @@ -1775,8 +1773,8 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int base = dai->driver->base; const int *rates; @@ -1813,7 +1811,7 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, } /* Force multiple of 2 channels for I2S mode */ - val = snd_soc_read(codec, base + ARIZONA_AIF_FORMAT); + val = snd_soc_component_read32(component, base + ARIZONA_AIF_FORMAT); val &= ARIZONA_AIF1_FMT_MASK; if ((channels & 1) && (val == ARIZONA_FMT_I2S_MODE)) { arizona_aif_dbg(dai, "Forcing stereo mode\n"); @@ -1841,13 +1839,13 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, frame = wl << ARIZONA_AIF1TX_WL_SHIFT | tdm_width; - reconfig = arizona_aif_cfg_changed(codec, base, bclk, lrclk, frame); + reconfig = arizona_aif_cfg_changed(component, base, bclk, lrclk, frame); if (reconfig) { /* Save AIF TX/RX state */ - aif_tx_state = snd_soc_read(codec, + aif_tx_state = snd_soc_component_read32(component, base + ARIZONA_AIF_TX_ENABLES); - aif_rx_state = snd_soc_read(codec, + aif_rx_state = snd_soc_component_read32(component, base + ARIZONA_AIF_RX_ENABLES); /* Disable AIF TX/RX before reconfiguring it */ regmap_update_bits_async(arizona->regmap, @@ -1908,9 +1906,9 @@ static const char *arizona_dai_clk_str(int clk_id) static int arizona_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = dai->codec; - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona_dai_priv *dai_priv = &priv->dai[dai->id - 1]; struct snd_soc_dapm_route routes[2]; @@ -1926,12 +1924,12 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai, return 0; if (dai->active) { - dev_err(codec->dev, "Can't change clock on active DAI %d\n", + dev_err(component->dev, "Can't change clock on active DAI %d\n", dai->id); return -EBUSY; } - dev_dbg(codec->dev, "Setting AIF%d to %s\n", dai->id + 1, + dev_dbg(component->dev, "Setting AIF%d to %s\n", dai->id + 1, arizona_dai_clk_str(clk_id)); memset(&routes, 0, sizeof(routes)); @@ -1953,7 +1951,7 @@ static int arizona_dai_set_sysclk(struct snd_soc_dai *dai, static int arizona_set_tristate(struct snd_soc_dai *dai, int tristate) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; int base = dai->driver->base; unsigned int reg; @@ -1962,7 +1960,7 @@ static int arizona_set_tristate(struct snd_soc_dai *dai, int tristate) else reg = 0; - return snd_soc_update_bits(codec, base + ARIZONA_AIF_RATE_CTRL, + return snd_soc_component_update_bits(component, base + ARIZONA_AIF_RATE_CTRL, ARIZONA_AIF1_TRI, reg); } @@ -1970,8 +1968,8 @@ static void arizona_set_channels_to_mask(struct snd_soc_dai *dai, unsigned int base, int channels, unsigned int mask) { - struct snd_soc_codec *codec = dai->codec; - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int slot, i; @@ -1992,8 +1990,8 @@ static void arizona_set_channels_to_mask(struct snd_soc_dai *dai, static int arizona_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; int base = dai->driver->base; int rx_max_chan = dai->driver->playback.channels_max; @@ -2645,7 +2643,7 @@ EXPORT_SYMBOL_GPL(arizona_init_fll); /** * arizona_set_output_mode - Set the mode of the specified output * - * @codec: Device to configure + * @component: Device to configure * @output: Output number * @diff: True to set the output to differential mode * @@ -2658,7 +2656,7 @@ EXPORT_SYMBOL_GPL(arizona_init_fll); * Most systems have a single static configuration and should use * platform data instead. */ -int arizona_set_output_mode(struct snd_soc_codec *codec, int output, bool diff) +int arizona_set_output_mode(struct snd_soc_component *component, int output, bool diff) { unsigned int reg, val; @@ -2672,7 +2670,7 @@ int arizona_set_output_mode(struct snd_soc_codec *codec, int output, bool diff) else val = 0; - return snd_soc_update_bits(codec, reg, ARIZONA_OUT1_MONO, val); + return snd_soc_component_update_bits(component, reg, ARIZONA_OUT1_MONO, val); } EXPORT_SYMBOL_GPL(arizona_set_output_mode); @@ -2721,8 +2719,8 @@ static bool arizona_eq_filter_unstable(bool mode, __be16 _a, __be16 _b) int arizona_eq_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct soc_bytes *params = (void *)kcontrol->private_value; unsigned int val; __be16 *data; @@ -2765,8 +2763,8 @@ EXPORT_SYMBOL_GPL(arizona_eq_coeff_put); int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); __be16 *data = (__be16 *)ucontrol->value.bytes.data; s16 val = be16_to_cpu(*data); diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index dfdf6d8c9687..e3ccee5627c6 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h @@ -273,7 +273,7 @@ int arizona_lhpf_coeff_put(struct snd_kcontrol *kcontrol, int arizona_clk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); -int arizona_set_sysclk(struct snd_soc_codec *codec, int clk_id, int source, +int arizona_set_sysclk(struct snd_soc_component *component, int clk_id, int source, unsigned int freq, int dir); extern const struct snd_soc_dai_ops arizona_dai_ops; @@ -297,8 +297,8 @@ struct arizona_fll { char clock_ok_name[ARIZONA_FLL_NAME_LEN]; }; -int arizona_dvfs_up(struct snd_soc_codec *codec, unsigned int flags); -int arizona_dvfs_down(struct snd_soc_codec *codec, unsigned int flags); +int arizona_dvfs_up(struct snd_soc_component *component, unsigned int flags); +int arizona_dvfs_down(struct snd_soc_component *component, unsigned int flags); int arizona_dvfs_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); void arizona_init_dvfs(struct arizona_priv *priv); @@ -310,9 +310,9 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source, int arizona_set_fll(struct arizona_fll *fll, int source, unsigned int Fref, unsigned int Fout); -int arizona_init_spk(struct snd_soc_codec *codec); -int arizona_init_gpio(struct snd_soc_codec *codec); -int arizona_init_mono(struct snd_soc_codec *codec); +int arizona_init_spk(struct snd_soc_component *component); +int arizona_init_gpio(struct snd_soc_component *component); +int arizona_init_mono(struct snd_soc_component *component); int arizona_init_common(struct arizona *arizona); int arizona_init_vol_limit(struct arizona *arizona); @@ -322,20 +322,20 @@ int arizona_free_spk_irqs(struct arizona *arizona); int arizona_init_dai(struct arizona_priv *priv, int dai); -int arizona_set_output_mode(struct snd_soc_codec *codec, int output, +int arizona_set_output_mode(struct snd_soc_component *component, int output, bool diff); -bool arizona_input_analog(struct snd_soc_codec *codec, int shift); +bool arizona_input_analog(struct snd_soc_component *component, int shift); const char *arizona_sample_rate_val_to_name(unsigned int rate_val); -static inline int arizona_register_notifier(struct snd_soc_codec *codec, +static inline int arizona_register_notifier(struct snd_soc_component *component, struct notifier_block *nb, int (*notify) (struct notifier_block *nb, unsigned long action, void *data)) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; nb->notifier_call = notify; @@ -343,10 +343,10 @@ static inline int arizona_register_notifier(struct snd_soc_codec *codec, return blocking_notifier_chain_register(&arizona->notifier, nb); } -static inline int arizona_unregister_notifier(struct snd_soc_codec *codec, +static inline int arizona_unregister_notifier(struct snd_soc_component *component, struct notifier_block *nb) { - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; return blocking_notifier_chain_unregister(&arizona->notifier, nb); diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index 3f34de5f800e..c93d3f7e8e36 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -62,14 +62,14 @@ static const struct wm_adsp_region *cs47l24_dsp_regions[] = { static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); unsigned int v; int ret; ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v); if (ret != 0) { - dev_err(codec->dev, "Failed to read SYSCLK state: %d\n", ret); + dev_err(component->dev, "Failed to read SYSCLK state: %d\n", ret); return ret; } @@ -931,10 +931,10 @@ static const struct snd_soc_dapm_route cs47l24_dapm_routes[] = { { "DSP3 Voice Trigger", "Switch", "DSP3" }, }; -static int cs47l24_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int cs47l24_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct cs47l24_priv *cs47l24 = snd_soc_codec_get_drvdata(codec); + struct cs47l24_priv *cs47l24 = snd_soc_component_get_drvdata(component); switch (fll_id) { case CS47L24_FLL1: @@ -1118,33 +1118,32 @@ static irqreturn_t cs47l24_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } -static int cs47l24_codec_probe(struct snd_soc_codec *codec) +static int cs47l24_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - struct cs47l24_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int ret; arizona->dapm = dapm; - snd_soc_codec_init_regmap(codec, arizona->regmap); + snd_soc_component_init_regmap(component, arizona->regmap); - ret = arizona_init_spk(codec); + ret = arizona_init_spk(component); if (ret < 0) return ret; - arizona_init_gpio(codec); - arizona_init_mono(codec); + arizona_init_gpio(component); + arizona_init_mono(component); - ret = wm_adsp2_codec_probe(&priv->core.adsp[1], codec); + ret = wm_adsp2_component_probe(&priv->core.adsp[1], component); if (ret) goto err_adsp2_codec_probe; - ret = wm_adsp2_codec_probe(&priv->core.adsp[2], codec); + ret = wm_adsp2_component_probe(&priv->core.adsp[2], component); if (ret) goto err_adsp2_codec_probe; - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, &arizona_adsp2_rate_controls[1], 2); if (ret) goto err_adsp2_codec_probe; @@ -1154,22 +1153,20 @@ static int cs47l24_codec_probe(struct snd_soc_codec *codec) return 0; err_adsp2_codec_probe: - wm_adsp2_codec_remove(&priv->core.adsp[1], codec); - wm_adsp2_codec_remove(&priv->core.adsp[2], codec); + wm_adsp2_component_remove(&priv->core.adsp[1], component); + wm_adsp2_component_remove(&priv->core.adsp[2], component); return ret; } -static int cs47l24_codec_remove(struct snd_soc_codec *codec) +static void cs47l24_component_remove(struct snd_soc_component *component) { - struct cs47l24_priv *priv = snd_soc_codec_get_drvdata(codec); + struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component); - wm_adsp2_codec_remove(&priv->core.adsp[1], codec); - wm_adsp2_codec_remove(&priv->core.adsp[2], codec); + wm_adsp2_component_remove(&priv->core.adsp[1], component); + wm_adsp2_component_remove(&priv->core.adsp[2], component); priv->core.arizona->dapm = NULL; - - return 0; } #define CS47L24_DIG_VU 0x0200 @@ -1190,25 +1187,22 @@ static struct snd_compr_ops cs47l24_compr_ops = { .copy = wm_adsp_compr_copy, }; -static const struct snd_soc_codec_driver soc_codec_dev_cs47l24 = { - .probe = cs47l24_codec_probe, - .remove = cs47l24_codec_remove, - - .idle_bias_off = true, - - .set_sysclk = arizona_set_sysclk, - .set_pll = cs47l24_set_fll, - - .component_driver = { - .name = DRV_NAME, - .compr_ops = &cs47l24_compr_ops, - .controls = cs47l24_snd_controls, - .num_controls = ARRAY_SIZE(cs47l24_snd_controls), - .dapm_widgets = cs47l24_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cs47l24_dapm_widgets), - .dapm_routes = cs47l24_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(cs47l24_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_cs47l24 = { + .probe = cs47l24_component_probe, + .remove = cs47l24_component_remove, + .set_sysclk = arizona_set_sysclk, + .set_pll = cs47l24_set_fll, + .name = DRV_NAME, + .compr_ops = &cs47l24_compr_ops, + .controls = cs47l24_snd_controls, + .num_controls = ARRAY_SIZE(cs47l24_snd_controls), + .dapm_widgets = cs47l24_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cs47l24_dapm_widgets), + .dapm_routes = cs47l24_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(cs47l24_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int cs47l24_probe(struct platform_device *pdev) @@ -1299,10 +1293,11 @@ static int cs47l24_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cs47l24, + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_cs47l24, cs47l24_dai, ARRAY_SIZE(cs47l24_dai)); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; } @@ -1321,7 +1316,6 @@ static int cs47l24_remove(struct platform_device *pdev) struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev); struct arizona *arizona = cs47l24->core.arizona; - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); wm_adsp2_remove(&cs47l24->core.adsp[1]); diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index a568050090ad..24f19cfc98f5 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -583,8 +583,8 @@ static const struct reg_default wm5102_sysclk_revb_patch[] = { static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; int i, patch_size; @@ -622,8 +622,8 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); unsigned int v = 0; int ret; @@ -631,7 +631,7 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, case SND_SOC_DAPM_PRE_PMU: ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v); if (ret != 0) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to read SYSCLK state: %d\n", ret); return -EIO; } @@ -639,9 +639,9 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT; if (v >= 3) { - ret = arizona_dvfs_up(codec, ARIZONA_DVFS_ADSP1_RQ); + ret = arizona_dvfs_up(component, ARIZONA_DVFS_ADSP1_RQ); if (ret) { - dev_err(codec->dev, + dev_err(component->dev, "Failed to raise DVFS: %d\n", ret); return ret; } @@ -649,9 +649,9 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMD: - ret = arizona_dvfs_down(codec, ARIZONA_DVFS_ADSP1_RQ); + ret = arizona_dvfs_down(component, ARIZONA_DVFS_ADSP1_RQ); if (ret) - dev_warn(codec->dev, + dev_warn(component->dev, "Failed to lower DVFS: %d\n", ret); break; @@ -665,8 +665,8 @@ static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); mutex_lock(&arizona->dac_comp_lock); put_unaligned_be16(arizona->dac_comp_coeff, @@ -679,8 +679,8 @@ static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); mutex_lock(&arizona->dac_comp_lock); memcpy(&arizona->dac_comp_coeff, ucontrol->value.bytes.data, @@ -694,8 +694,8 @@ static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); mutex_lock(&arizona->dac_comp_lock); ucontrol->value.integer.value[0] = arizona->dac_comp_enabled; @@ -707,8 +707,8 @@ static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol, static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); mutex_lock(&arizona->dac_comp_lock); arizona->dac_comp_enabled = ucontrol->value.integer.value[0]; @@ -1736,10 +1736,10 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = { { "DRC1 Signal Activity", NULL, "DRC1R" }, }; -static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm5102_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm5102_priv *wm5102 = snd_soc_codec_get_drvdata(codec); + struct wm5102_priv *wm5102 = snd_soc_component_get_drvdata(component); switch (fll_id) { case WM5102_FLL1: @@ -1933,30 +1933,29 @@ static irqreturn_t wm5102_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } -static int wm5102_codec_probe(struct snd_soc_codec *codec) +static int wm5102_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm5102_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int ret; - snd_soc_codec_init_regmap(codec, arizona->regmap); + snd_soc_component_init_regmap(component, arizona->regmap); - ret = wm_adsp2_codec_probe(&priv->core.adsp[0], codec); + ret = wm_adsp2_component_probe(&priv->core.adsp[0], component); if (ret) return ret; - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, arizona_adsp2_rate_controls, 1); if (ret) goto err_adsp2_codec_probe; - ret = arizona_init_spk(codec); + ret = arizona_init_spk(component); if (ret < 0) return ret; - arizona_init_gpio(codec); + arizona_init_gpio(component); snd_soc_component_disable_pin(component, "HAPTICS"); @@ -1965,20 +1964,18 @@ static int wm5102_codec_probe(struct snd_soc_codec *codec) return 0; err_adsp2_codec_probe: - wm_adsp2_codec_remove(&priv->core.adsp[0], codec); + wm_adsp2_component_remove(&priv->core.adsp[0], component); return ret; } -static int wm5102_codec_remove(struct snd_soc_codec *codec) +static void wm5102_component_remove(struct snd_soc_component *component) { - struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec); + struct wm5102_priv *priv = snd_soc_component_get_drvdata(component); - wm_adsp2_codec_remove(&priv->core.adsp[0], codec); + wm_adsp2_component_remove(&priv->core.adsp[0], component); priv->core.arizona->dapm = NULL; - - return 0; } #define WM5102_DIG_VU 0x0200 @@ -2005,25 +2002,22 @@ static struct snd_compr_ops wm5102_compr_ops = { .copy = wm_adsp_compr_copy, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm5102 = { - .probe = wm5102_codec_probe, - .remove = wm5102_codec_remove, - - .idle_bias_off = true, - - .set_sysclk = arizona_set_sysclk, - .set_pll = wm5102_set_fll, - - .component_driver = { - .name = DRV_NAME, - .compr_ops = &wm5102_compr_ops, - .controls = wm5102_snd_controls, - .num_controls = ARRAY_SIZE(wm5102_snd_controls), - .dapm_widgets = wm5102_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm5102_dapm_widgets), - .dapm_routes = wm5102_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm5102 = { + .probe = wm5102_component_probe, + .remove = wm5102_component_remove, + .set_sysclk = arizona_set_sysclk, + .set_pll = wm5102_set_fll, + .name = DRV_NAME, + .compr_ops = &wm5102_compr_ops, + .controls = wm5102_snd_controls, + .num_controls = ARRAY_SIZE(wm5102_snd_controls), + .dapm_widgets = wm5102_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm5102_dapm_widgets), + .dapm_routes = wm5102_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm5102_probe(struct platform_device *pdev) @@ -2110,10 +2104,11 @@ static int wm5102_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102, + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm5102, wm5102_dai, ARRAY_SIZE(wm5102_dai)); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; } @@ -2132,7 +2127,6 @@ static int wm5102_remove(struct platform_device *pdev) struct wm5102_priv *wm5102 = platform_get_drvdata(pdev); struct arizona *arizona = wm5102->core.arizona; - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); wm_adsp2_remove(&wm5102->core.adsp[0]); diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index d5ece6c6fcb6..b33cbd0161d3 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -161,8 +161,8 @@ static const struct reg_default wm5110_sysclk_reve_patch[] = { static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; int i, patch_size; @@ -198,14 +198,14 @@ static int wm5110_sysclk_ev(struct snd_soc_dapm_widget *w, static int wm5110_adsp_power_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); unsigned int v; int ret; ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v); if (ret != 0) { - dev_err(codec->dev, "Failed to read SYSCLK state: %d\n", ret); + dev_err(component->dev, "Failed to read SYSCLK state: %d\n", ret); return ret; } @@ -288,10 +288,10 @@ static const struct reg_sequence wm5110_dre_right_enable[] = { static int wm5110_hp_pre_enable(struct snd_soc_dapm_widget *w) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; - unsigned int val = snd_soc_read(codec, ARIZONA_DRE_ENABLE); + unsigned int val = snd_soc_component_read32(component, ARIZONA_DRE_ENABLE); const struct reg_sequence *wseq; int nregs; @@ -325,25 +325,25 @@ static int wm5110_hp_pre_enable(struct snd_soc_dapm_widget *w) static int wm5110_hp_pre_disable(struct snd_soc_dapm_widget *w) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); - unsigned int val = snd_soc_read(codec, ARIZONA_DRE_ENABLE); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); + unsigned int val = snd_soc_component_read32(component, ARIZONA_DRE_ENABLE); switch (w->shift) { case ARIZONA_OUT1L_ENA_SHIFT: if (!(val & ARIZONA_DRE1L_ENA_MASK)) { - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, + snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, ARIZONA_WS_TRG1, ARIZONA_WS_TRG1); - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, + snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, ARIZONA_WS_TRG1, 0); priv->out_down_delay += 27; } break; case ARIZONA_OUT1R_ENA_SHIFT: if (!(val & ARIZONA_DRE1R_ENA_MASK)) { - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, + snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, ARIZONA_WS_TRG2, ARIZONA_WS_TRG2); - snd_soc_update_bits(codec, ARIZONA_SPARE_TRIGGERS, + snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, ARIZONA_WS_TRG2, 0); priv->out_down_delay += 27; } @@ -358,8 +358,8 @@ static int wm5110_hp_pre_disable(struct snd_soc_dapm_widget *w) static int wm5110_hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); switch (priv->arizona->rev) { case 0 ... 3: @@ -397,9 +397,9 @@ static int wm5110_clear_pga_volume(struct arizona *arizona, int output) static int wm5110_put_dre(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int ena, dre; @@ -458,8 +458,8 @@ err: static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; /* @@ -478,8 +478,8 @@ static int wm5110_in_pga_get(struct snd_kcontrol *kcontrol, static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int ret; /* @@ -498,9 +498,9 @@ static int wm5110_in_pga_put(struct snd_kcontrol *kcontrol, static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); - struct wm5110_priv *wm5110 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); + struct wm5110_priv *wm5110 = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; unsigned int reg, mask; struct reg_sequence analog_seq[] = { @@ -519,9 +519,9 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, wm5110->in_post_pending++; return 0; case SND_SOC_DAPM_PRE_PMU: - wm5110->in_pga_cache[w->shift] = snd_soc_read(codec, reg); + wm5110->in_pga_cache[w->shift] = snd_soc_component_read32(component, reg); - snd_soc_update_bits(codec, reg, mask, + snd_soc_component_update_bits(component, reg, mask, 0x40 << ARIZONA_IN1L_PGA_VOL_SHIFT); wm5110->in_pre_pending--; @@ -538,7 +538,7 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: - snd_soc_update_bits(codec, reg, mask, + snd_soc_component_update_bits(component, reg, mask, wm5110->in_pga_cache[w->shift]); wm5110->in_post_pending--; @@ -557,13 +557,13 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, static int wm5110_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->arizona; switch (arizona->rev) { case 0 ... 4: - if (arizona_input_analog(codec, w->shift)) + if (arizona_input_analog(component, w->shift)) wm5110_in_analog_ev(w, kcontrol, event); break; @@ -2034,10 +2034,10 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { { "DSP3 Voice Trigger", "Switch", "DSP3" }, }; -static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm5110_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm5110_priv *wm5110 = snd_soc_codec_get_drvdata(codec); + struct wm5110_priv *wm5110 = snd_soc_component_get_drvdata(component); switch (fll_id) { case WM5110_FLL1: @@ -2278,31 +2278,30 @@ static irqreturn_t wm5110_adsp2_irq(int irq, void *data) return IRQ_HANDLED; } -static int wm5110_codec_probe(struct snd_soc_codec *codec) +static int wm5110_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int i, ret; arizona->dapm = dapm; - snd_soc_codec_init_regmap(codec, arizona->regmap); + snd_soc_component_init_regmap(component, arizona->regmap); - ret = arizona_init_spk(codec); + ret = arizona_init_spk(component); if (ret < 0) return ret; - arizona_init_gpio(codec); - arizona_init_mono(codec); + arizona_init_gpio(component); + arizona_init_mono(component); for (i = 0; i < WM5110_NUM_ADSP; ++i) { - ret = wm_adsp2_codec_probe(&priv->core.adsp[i], codec); + ret = wm_adsp2_component_probe(&priv->core.adsp[i], component); if (ret) goto err_adsp2_codec_probe; } - ret = snd_soc_add_codec_controls(codec, + ret = snd_soc_add_component_controls(component, arizona_adsp2_rate_controls, WM5110_NUM_ADSP); if (ret) @@ -2314,22 +2313,20 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) err_adsp2_codec_probe: for (--i; i >= 0; --i) - wm_adsp2_codec_remove(&priv->core.adsp[i], codec); + wm_adsp2_component_remove(&priv->core.adsp[i], component); return ret; } -static int wm5110_codec_remove(struct snd_soc_codec *codec) +static void wm5110_component_remove(struct snd_soc_component *component) { - struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec); + struct wm5110_priv *priv = snd_soc_component_get_drvdata(component); int i; for (i = 0; i < WM5110_NUM_ADSP; ++i) - wm_adsp2_codec_remove(&priv->core.adsp[i], codec); + wm_adsp2_component_remove(&priv->core.adsp[i], component); priv->core.arizona->dapm = NULL; - - return 0; } #define WM5110_DIG_VU 0x0200 @@ -2359,25 +2356,22 @@ static struct snd_compr_ops wm5110_compr_ops = { .copy = wm_adsp_compr_copy, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm5110 = { - .probe = wm5110_codec_probe, - .remove = wm5110_codec_remove, - - .idle_bias_off = true, - - .set_sysclk = arizona_set_sysclk, - .set_pll = wm5110_set_fll, - - .component_driver = { - .name = DRV_NAME, - .compr_ops = &wm5110_compr_ops, - .controls = wm5110_snd_controls, - .num_controls = ARRAY_SIZE(wm5110_snd_controls), - .dapm_widgets = wm5110_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm5110_dapm_widgets), - .dapm_routes = wm5110_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm5110_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm5110 = { + .probe = wm5110_component_probe, + .remove = wm5110_component_remove, + .set_sysclk = arizona_set_sysclk, + .set_pll = wm5110_set_fll, + .name = DRV_NAME, + .compr_ops = &wm5110_compr_ops, + .controls = wm5110_snd_controls, + .num_controls = ARRAY_SIZE(wm5110_snd_controls), + .dapm_widgets = wm5110_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm5110_dapm_widgets), + .dapm_routes = wm5110_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm5110_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm5110_probe(struct platform_device *pdev) @@ -2465,10 +2459,11 @@ static int wm5110_probe(struct platform_device *pdev) if (ret < 0) goto err_dsp_irq; - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5110, + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm5110, wm5110_dai, ARRAY_SIZE(wm5110_dai)); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; } @@ -2488,7 +2483,6 @@ static int wm5110_remove(struct platform_device *pdev) struct arizona *arizona = wm5110->core.arizona; int i; - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); for (i = 0; i < WM5110_NUM_ADSP; i++) diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index cac9b3e7e15d..45ee1e6bf715 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -84,8 +84,8 @@ static const struct reg_default wm8997_sysclk_reva_patch[] = { static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct arizona *arizona = dev_get_drvdata(codec->dev->parent); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct arizona *arizona = dev_get_drvdata(component->dev->parent); struct regmap *regmap = arizona->regmap; const struct reg_default *patch = NULL; int i, patch_size; @@ -927,10 +927,10 @@ static const struct snd_soc_dapm_route wm8997_dapm_routes[] = { { "MICSUPP", NULL, "SYSCLK" }, }; -static int wm8997_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm8997_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8997_priv *wm8997 = snd_soc_codec_get_drvdata(codec); + struct wm8997_priv *wm8997 = snd_soc_component_get_drvdata(component); switch (fll_id) { case WM8997_FLL1: @@ -1057,17 +1057,16 @@ static struct snd_soc_dai_driver wm8997_dai[] = { }, }; -static int wm8997_codec_probe(struct snd_soc_codec *codec) +static int wm8997_component_probe(struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); - struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8997_priv *priv = snd_soc_component_get_drvdata(component); struct arizona *arizona = priv->core.arizona; int ret; - snd_soc_codec_init_regmap(codec, arizona->regmap); + snd_soc_component_init_regmap(component, arizona->regmap); - ret = arizona_init_spk(codec); + ret = arizona_init_spk(component); if (ret < 0) return ret; @@ -1078,13 +1077,11 @@ static int wm8997_codec_probe(struct snd_soc_codec *codec) return 0; } -static int wm8997_codec_remove(struct snd_soc_codec *codec) +static void wm8997_component_remove(struct snd_soc_component *component) { - struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec); + struct wm8997_priv *priv = snd_soc_component_get_drvdata(component); priv->core.arizona->dapm = NULL; - - return 0; } #define WM8997_DIG_VU 0x0200 @@ -1098,23 +1095,20 @@ static unsigned int wm8997_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8997 = { - .probe = wm8997_codec_probe, - .remove = wm8997_codec_remove, - - .idle_bias_off = true, - - .set_sysclk = arizona_set_sysclk, - .set_pll = wm8997_set_fll, - - .component_driver = { - .controls = wm8997_snd_controls, - .num_controls = ARRAY_SIZE(wm8997_snd_controls), - .dapm_widgets = wm8997_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8997_dapm_widgets), - .dapm_routes = wm8997_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8997_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8997 = { + .probe = wm8997_component_probe, + .remove = wm8997_component_remove, + .set_sysclk = arizona_set_sysclk, + .set_pll = wm8997_set_fll, + .controls = wm8997_snd_controls, + .num_controls = ARRAY_SIZE(wm8997_snd_controls), + .dapm_widgets = wm8997_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8997_dapm_widgets), + .dapm_routes = wm8997_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8997_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8997_probe(struct platform_device *pdev) @@ -1178,10 +1172,11 @@ static int wm8997_probe(struct platform_device *pdev) if (ret < 0) return ret; - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8997, + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8997, wm8997_dai, ARRAY_SIZE(wm8997_dai)); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; } @@ -1196,7 +1191,6 @@ static int wm8997_remove(struct platform_device *pdev) struct wm8997_priv *wm8997 = platform_get_drvdata(pdev); struct arizona *arizona = wm8997->core.arizona; - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); arizona_free_spk_irqs(arizona); diff --git a/sound/soc/codecs/wm8998.c b/sound/soc/codecs/wm8998.c index 1288e1f67dcf..6f3fdd7b095e 100644 --- a/sound/soc/codecs/wm8998.c +++ b/sound/soc/codecs/wm8998.c @@ -41,12 +41,12 @@ static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); unsigned int val; switch (event) { case SND_SOC_DAPM_PRE_PMU: - val = snd_soc_read(codec, ARIZONA_ASRC_RATE1); + val = snd_soc_component_read32(component, ARIZONA_ASRC_RATE1); val &= ARIZONA_ASRC_RATE1_MASK; val >>= ARIZONA_ASRC_RATE1_SHIFT; @@ -54,23 +54,23 @@ static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, case 0: case 1: case 2: - val = snd_soc_read(codec, + val = snd_soc_component_read32(component, ARIZONA_SAMPLE_RATE_1 + val); if (val >= 0x11) { - dev_warn(codec->dev, + dev_warn(component->dev, "Unsupported ASRC rate1 (%s)\n", arizona_sample_rate_val_to_name(val)); return -EINVAL; } break; default: - dev_err(codec->dev, + dev_err(component->dev, "Illegal ASRC rate1 selector (0x%x)\n", val); return -EINVAL; } - val = snd_soc_read(codec, ARIZONA_ASRC_RATE2); + val = snd_soc_component_read32(component, ARIZONA_ASRC_RATE2); val &= ARIZONA_ASRC_RATE2_MASK; val >>= ARIZONA_ASRC_RATE2_SHIFT; @@ -78,17 +78,17 @@ static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, case 8: case 9: val -= 0x8; - val = snd_soc_read(codec, + val = snd_soc_component_read32(component, ARIZONA_ASYNC_SAMPLE_RATE_1 + val); if (val >= 0x11) { - dev_warn(codec->dev, + dev_warn(component->dev, "Unsupported ASRC rate2 (%s)\n", arizona_sample_rate_val_to_name(val)); return -EINVAL; } break; default: - dev_err(codec->dev, + dev_err(component->dev, "Illegal ASRC rate2 selector (0x%x)\n", val); return -EINVAL; @@ -104,9 +104,9 @@ static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w, static int wm8998_inmux_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct wm8998_priv *wm8998 = snd_soc_component_get_drvdata(component); struct arizona *arizona = wm8998->core.arizona; struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int mode_reg, mode_index; @@ -137,9 +137,9 @@ static int wm8998_inmux_put(struct snd_kcontrol *kcontrol, if (inmode & ARIZONA_INMODE_SE) src_val |= 1 << ARIZONA_IN1L_SRC_SE_SHIFT; - snd_soc_update_bits(codec, mode_reg, ARIZONA_IN1_MODE_MASK, mode_val); + snd_soc_component_update_bits(component, mode_reg, ARIZONA_IN1_MODE_MASK, mode_val); - snd_soc_update_bits(codec, e->reg, + snd_soc_component_update_bits(component, e->reg, ARIZONA_IN1L_SRC_MASK | ARIZONA_IN1L_SRC_SE_MASK, src_val); @@ -1249,10 +1249,10 @@ static struct snd_soc_dai_driver wm8998_dai[] = { }, }; -static int wm8998_set_fll(struct snd_soc_codec *codec, int fll_id, int source, +static int wm8998_set_fll(struct snd_soc_component *component, int fll_id, int source, unsigned int Fref, unsigned int Fout) { - struct wm8998_priv *wm8998 = snd_soc_codec_get_drvdata(codec); + struct wm8998_priv *wm8998 = snd_soc_component_get_drvdata(component); switch (fll_id) { case WM8998_FLL1: @@ -1270,35 +1270,32 @@ static int wm8998_set_fll(struct snd_soc_codec *codec, int fll_id, int source, } } -static int wm8998_codec_probe(struct snd_soc_codec *codec) +static int wm8998_component_probe(struct snd_soc_component *component) { - struct wm8998_priv *priv = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); - struct snd_soc_component *component = snd_soc_dapm_to_component(dapm); + struct wm8998_priv *priv = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct arizona *arizona = priv->core.arizona; int ret; arizona->dapm = dapm; - snd_soc_codec_init_regmap(codec, arizona->regmap); + snd_soc_component_init_regmap(component, arizona->regmap); - ret = arizona_init_spk(codec); + ret = arizona_init_spk(component); if (ret < 0) return ret; - arizona_init_gpio(codec); + arizona_init_gpio(component); snd_soc_component_disable_pin(component, "HAPTICS"); return 0; } -static int wm8998_codec_remove(struct snd_soc_codec *codec) +static void wm8998_component_remove(struct snd_soc_component *component) { - struct wm8998_priv *priv = snd_soc_codec_get_drvdata(codec); + struct wm8998_priv *priv = snd_soc_component_get_drvdata(component); priv->core.arizona->dapm = NULL; - - return 0; } #define WM8998_DIG_VU 0x0200 @@ -1315,23 +1312,20 @@ static unsigned int wm8998_digital_vu[] = { ARIZONA_DAC_DIGITAL_VOLUME_5R, }; -static const struct snd_soc_codec_driver soc_codec_dev_wm8998 = { - .probe = wm8998_codec_probe, - .remove = wm8998_codec_remove, - - .idle_bias_off = true, - - .set_sysclk = arizona_set_sysclk, - .set_pll = wm8998_set_fll, - - .component_driver = { - .controls = wm8998_snd_controls, - .num_controls = ARRAY_SIZE(wm8998_snd_controls), - .dapm_widgets = wm8998_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(wm8998_dapm_widgets), - .dapm_routes = wm8998_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(wm8998_dapm_routes), - }, +static const struct snd_soc_component_driver soc_component_dev_wm8998 = { + .probe = wm8998_component_probe, + .remove = wm8998_component_remove, + .set_sysclk = arizona_set_sysclk, + .set_pll = wm8998_set_fll, + .controls = wm8998_snd_controls, + .num_controls = ARRAY_SIZE(wm8998_snd_controls), + .dapm_widgets = wm8998_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8998_dapm_widgets), + .dapm_routes = wm8998_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(wm8998_dapm_routes), + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int wm8998_probe(struct platform_device *pdev) @@ -1384,10 +1378,11 @@ static int wm8998_probe(struct platform_device *pdev) if (ret < 0) return ret; - ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8998, + ret = devm_snd_soc_register_component(&pdev->dev, + &soc_component_dev_wm8998, wm8998_dai, ARRAY_SIZE(wm8998_dai)); if (ret < 0) { - dev_err(&pdev->dev, "Failed to register codec: %d\n", ret); + dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; } @@ -1404,7 +1399,6 @@ static int wm8998_remove(struct platform_device *pdev) struct wm8998_priv *wm8998 = platform_get_drvdata(pdev); struct arizona *arizona = wm8998->core.arizona; - snd_soc_unregister_codec(&pdev->dev); pm_runtime_disable(&pdev->dev); arizona_free_spk_irqs(arizona); diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 66e32f5d2917..4847e947410b 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -605,13 +605,13 @@ static const struct { }; static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { struct dentry *root = NULL; char *root_name; int i; - if (!codec->component.debugfs_root) { + if (!component->debugfs_root) { adsp_err(dsp, "No codec debugfs root\n"); goto err; } @@ -621,7 +621,7 @@ static void wm_adsp2_init_debugfs(struct wm_adsp *dsp, goto err; snprintf(root_name, PAGE_SIZE, "dsp%d", dsp->num); - root = debugfs_create_dir(root_name, codec->component.debugfs_root); + root = debugfs_create_dir(root_name, component->debugfs_root); kfree(root_name); if (!root) @@ -662,7 +662,7 @@ static void wm_adsp2_cleanup_debugfs(struct wm_adsp *dsp) } #else static inline void wm_adsp2_init_debugfs(struct wm_adsp *dsp, - struct snd_soc_codec *codec) + struct snd_soc_component *component) { } @@ -688,9 +688,9 @@ static inline void wm_adsp_debugfs_clear(struct wm_adsp *dsp) static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = dsp[e->shift_l].fw; @@ -700,9 +700,9 @@ static int wm_adsp_fw_get(struct snd_kcontrol *kcontrol, static int wm_adsp_fw_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); int ret = 0; if (ucontrol->value.enumerated.item[0] == dsp[e->shift_l].fw) @@ -1213,7 +1213,7 @@ static int wmfw_add_ctl(struct wm_adsp *dsp, struct wm_coeff_ctl *ctl) break; } - ret = snd_soc_add_codec_controls(dsp->codec, kcontrol, 1); + ret = snd_soc_add_component_controls(dsp->component, kcontrol, 1); if (ret < 0) goto err_kcontrol; @@ -2396,14 +2396,14 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_coeff_ctl *ctl; int ret; unsigned int val; - dsp->codec = codec; + dsp->component = component; mutex_lock(&dsp->pwr_lock); @@ -2633,8 +2633,8 @@ static void wm_adsp2_set_dspclk(struct wm_adsp *dsp, unsigned int freq) int wm_adsp2_preloader_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); ucontrol->value.integer.value[0] = dsp->preloaded; @@ -2645,9 +2645,9 @@ EXPORT_SYMBOL_GPL(wm_adsp2_preloader_get); int wm_adsp2_preloader_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct wm_adsp *dsp = snd_soc_codec_get_drvdata(codec); - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct wm_adsp *dsp = snd_soc_component_get_drvdata(component); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; char preload[32]; @@ -2683,8 +2683,8 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event, unsigned int freq) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_coeff_ctl *ctl; @@ -2726,8 +2726,8 @@ EXPORT_SYMBOL_GPL(wm_adsp2_early_event); int wm_adsp2_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct wm_adsp *dsps = snd_soc_component_get_drvdata(component); struct wm_adsp *dsp = &dsps[w->shift]; int ret; @@ -2841,31 +2841,31 @@ err: } EXPORT_SYMBOL_GPL(wm_adsp2_event); -int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec) +int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component) { - struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec); + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); char preload[32]; snprintf(preload, ARRAY_SIZE(preload), "DSP%d Preload", dsp->num); snd_soc_dapm_disable_pin(dapm, preload); - wm_adsp2_init_debugfs(dsp, codec); + wm_adsp2_init_debugfs(dsp, component); - dsp->codec = codec; + dsp->component = component; - return snd_soc_add_codec_controls(codec, + return snd_soc_add_component_controls(component, &wm_adsp_fw_controls[dsp->num - 1], 1); } -EXPORT_SYMBOL_GPL(wm_adsp2_codec_probe); +EXPORT_SYMBOL_GPL(wm_adsp2_component_probe); -int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec) +int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component) { wm_adsp2_cleanup_debugfs(dsp); return 0; } -EXPORT_SYMBOL_GPL(wm_adsp2_codec_remove); +EXPORT_SYMBOL_GPL(wm_adsp2_component_remove); int wm_adsp2_init(struct wm_adsp *dsp) { diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h index 41cc11c19b83..82d651ff9d73 100644 --- a/sound/soc/codecs/wm_adsp.h +++ b/sound/soc/codecs/wm_adsp.h @@ -62,7 +62,7 @@ struct wm_adsp { int type; struct device *dev; struct regmap *regmap; - struct snd_soc_codec *codec; + struct snd_soc_component *component; int base; int sysclk_reg; @@ -126,8 +126,8 @@ extern const struct snd_kcontrol_new wm_adsp_fw_controls[]; int wm_adsp1_init(struct wm_adsp *dsp); int wm_adsp2_init(struct wm_adsp *dsp); void wm_adsp2_remove(struct wm_adsp *dsp); -int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec); -int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec); +int wm_adsp2_component_probe(struct wm_adsp *dsp, struct snd_soc_component *component); +int wm_adsp2_component_remove(struct wm_adsp *dsp, struct snd_soc_component *component); int wm_adsp1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c index a55d18703fe7..6faaec889d1b 100644 --- a/sound/soc/samsung/tm2_wm5110.c +++ b/sound/soc/samsung/tm2_wm5110.c @@ -31,7 +31,7 @@ #define TM2_DAI_AIF2 1 struct tm2_machine_priv { - struct snd_soc_codec *codec; + struct snd_soc_component *component; unsigned int sysclk_rate; struct gpio_desc *gpio_mic_bias; }; @@ -39,33 +39,33 @@ struct tm2_machine_priv { static int tm2_start_sysclk(struct snd_soc_card *card) { struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card); - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; int ret; - ret = snd_soc_codec_set_pll(codec, WM5110_FLL1_REFCLK, + ret = snd_soc_component_set_pll(component, WM5110_FLL1_REFCLK, ARIZONA_FLL_SRC_MCLK1, MCLK_RATE, priv->sysclk_rate); if (ret < 0) { - dev_err(codec->dev, "Failed to set FLL1 source: %d\n", ret); + dev_err(component->dev, "Failed to set FLL1 source: %d\n", ret); return ret; } - ret = snd_soc_codec_set_pll(codec, WM5110_FLL1, + ret = snd_soc_component_set_pll(component, WM5110_FLL1, ARIZONA_FLL_SRC_MCLK1, MCLK_RATE, priv->sysclk_rate); if (ret < 0) { - dev_err(codec->dev, "Failed to start FLL1: %d\n", ret); + dev_err(component->dev, "Failed to start FLL1: %d\n", ret); return ret; } - ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK, + ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK, ARIZONA_CLK_SRC_FLL1, priv->sysclk_rate, SND_SOC_CLOCK_IN); if (ret < 0) { - dev_err(codec->dev, "Failed to set SYSCLK source: %d\n", ret); + dev_err(component->dev, "Failed to set SYSCLK source: %d\n", ret); return ret; } @@ -75,19 +75,19 @@ static int tm2_start_sysclk(struct snd_soc_card *card) static int tm2_stop_sysclk(struct snd_soc_card *card) { struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(card); - struct snd_soc_codec *codec = priv->codec; + struct snd_soc_component *component = priv->component; int ret; - ret = snd_soc_codec_set_pll(codec, WM5110_FLL1, 0, 0, 0); + ret = snd_soc_component_set_pll(component, WM5110_FLL1, 0, 0, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to stop FLL1: %d\n", ret); + dev_err(component->dev, "Failed to stop FLL1: %d\n", ret); return ret; } - ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_SYSCLK, + ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_SYSCLK, ARIZONA_CLK_SRC_FLL1, 0, 0); if (ret < 0) { - dev_err(codec->dev, "Failed to stop SYSCLK: %d\n", ret); + dev_err(component->dev, "Failed to stop SYSCLK: %d\n", ret); return ret; } @@ -98,7 +98,7 @@ static int tm2_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct tm2_machine_priv *priv = snd_soc_card_get_drvdata(rtd->card); switch (params_rate(params)) { @@ -123,7 +123,7 @@ static int tm2_aif1_hw_params(struct snd_pcm_substream *substream, priv->sysclk_rate = 135475200U; break; default: - dev_err(codec->dev, "Not supported sample rate: %d\n", + dev_err(component->dev, "Not supported sample rate: %d\n", params_rate(params)); return -EINVAL; } @@ -139,7 +139,7 @@ static int tm2_aif2_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; unsigned int asyncclk_rate; int ret; @@ -155,35 +155,35 @@ static int tm2_aif2_hw_params(struct snd_pcm_substream *substream, asyncclk_rate = 45158400U; break; default: - dev_err(codec->dev, "Not supported sample rate: %d\n", + dev_err(component->dev, "Not supported sample rate: %d\n", params_rate(params)); return -EINVAL; } - ret = snd_soc_codec_set_pll(codec, WM5110_FLL2_REFCLK, + ret = snd_soc_component_set_pll(component, WM5110_FLL2_REFCLK, ARIZONA_FLL_SRC_MCLK1, MCLK_RATE, asyncclk_rate); if (ret < 0) { - dev_err(codec->dev, "Failed to set FLL2 source: %d\n", ret); + dev_err(component->dev, "Failed to set FLL2 source: %d\n", ret); return ret; } - ret = snd_soc_codec_set_pll(codec, WM5110_FLL2, + ret = snd_soc_component_set_pll(component, WM5110_FLL2, ARIZONA_FLL_SRC_MCLK1, MCLK_RATE, asyncclk_rate); if (ret < 0) { - dev_err(codec->dev, "Failed to start FLL2: %d\n", ret); + dev_err(component->dev, "Failed to start FLL2: %d\n", ret); return ret; } - ret = snd_soc_codec_set_sysclk(codec, ARIZONA_CLK_ASYNCCLK, + ret = snd_soc_component_set_sysclk(component, ARIZONA_CLK_ASYNCCLK, ARIZONA_CLK_SRC_FLL2, asyncclk_rate, SND_SOC_CLOCK_IN); if (ret < 0) { - dev_err(codec->dev, "Failed to set ASYNCCLK source: %d\n", ret); + dev_err(component->dev, "Failed to set ASYNCCLK source: %d\n", ret); return ret; } @@ -193,14 +193,14 @@ static int tm2_aif2_hw_params(struct snd_pcm_substream *substream, static int tm2_aif2_hw_free(struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; int ret; /* disable FLL2 */ - ret = snd_soc_codec_set_pll(codec, WM5110_FLL2, ARIZONA_FLL_SRC_MCLK1, + ret = snd_soc_component_set_pll(component, WM5110_FLL2, ARIZONA_FLL_SRC_MCLK1, 0, 0); if (ret < 0) - dev_err(codec->dev, "Failed to stop FLL2: %d\n", ret); + dev_err(component->dev, "Failed to stop FLL2: %d\n", ret); return ret; } @@ -269,7 +269,7 @@ static int tm2_late_probe(struct snd_soc_card *card) rtd = snd_soc_get_pcm_runtime(card, card->dai_link[TM2_DAI_AIF1].name); aif1_dai = rtd->codec_dai; - priv->codec = rtd->codec; + priv->component = rtd->codec_dai->component; ret = snd_soc_dai_set_sysclk(aif1_dai, ARIZONA_CLK_SYSCLK, 0, 0); if (ret < 0) { From 36372922847c8686971bd714f24ca64558dff467 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 14 Feb 2018 03:01:24 +0000 Subject: [PATCH 269/942] ASoC: ak4613: don't have .use_pmdown_time snd_soc_runtime_ignore_pmdown_time() returns "ignore pmdown time" decision. Then, it collects each component driver's .use_pmdown_time settings by using AND operation. But, ak4613 has no reason to ignore/use pmdown time. Thus, It should has use_pmdown_time=0, it means it doesn't have decision right of "ignore pmdown time". Otherwise, ak4613 paired driver's pmdown_time settings doesn't have meaning. In other words, "ignore pmdown time" is determined irrespective of the value of paired driver's settings (= ignore will be 0 by ak4613). Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4613.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/ak4613.c b/sound/soc/codecs/ak4613.c index a7b1e3a1ec58..8523ff9351cf 100644 --- a/sound/soc/codecs/ak4613.c +++ b/sound/soc/codecs/ak4613.c @@ -610,7 +610,6 @@ static const struct snd_soc_component_driver soc_component_dev_ak4613 = { .dapm_routes = ak4613_intercon, .num_dapm_routes = ARRAY_SIZE(ak4613_intercon), .idle_bias_on = 1, - .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, }; From fe439c7c377920d608678db9a6724d6ec91f4cda Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 14 Feb 2018 03:01:46 +0000 Subject: [PATCH 270/942] ASoC: ak4642: don't have .use_pmdown_time snd_soc_runtime_ignore_pmdown_time() returns "ignore pmdown time" decision. Then, it collects each component driver's .use_pmdown_time settings by using AND operation. But, ak4613 has no reason to ignore/use pmdown time. Thus, It should has use_pmdown_time=0, it means it doesn't have decision right of "ignore pmdown time". Otherwise, ak4642 paired driver's pmdown_time settings doesn't have meaning. In other words, "ignore pmdown time" is determined irrespective of the value of paired driver's settings (= ignore will be 0 by ak4642). Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4642.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 9c35e91d412d..605055964529 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c @@ -562,7 +562,6 @@ static const struct snd_soc_component_driver soc_component_dev_ak4642 = { .dapm_routes = ak4642_intercon, .num_dapm_routes = ARRAY_SIZE(ak4642_intercon), .idle_bias_on = 1, - .use_pmdown_time = 1, .endianness = 1, .non_legacy_dai_naming = 1, }; From 60edb2006030894a4e45c84b04369cb70939d695 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 13 Feb 2018 17:37:50 -0200 Subject: [PATCH 271/942] ASoC: wm9712: Use empty struct initializer { 0 } only clears the first member of the structure. The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in the following sparse warning: sound/soc/codecs/wm9712.c:229:47: warning: Using plain integer as NULL pointer Use the empty struct initializer that clears all the struct members and fixes the sparse warning. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/wm9712.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm9712.c b/sound/soc/codecs/wm9712.c index 4f6d1a442bc4..c672d5d88827 100644 --- a/sound/soc/codecs/wm9712.c +++ b/sound/soc/codecs/wm9712.c @@ -226,7 +226,7 @@ static int wm9712_hp_mixer_put(struct snd_kcontrol *kcontrol, struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int mixer, mask, shift, old; - struct snd_soc_dapm_update update = { 0 }; + struct snd_soc_dapm_update update = {}; bool change; mixer = mc->shift >> 8; From 68fb425baea14f5647743eb56dc6675fcd8d93b3 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 13 Feb 2018 17:37:51 -0200 Subject: [PATCH 272/942] ASoC: tlv320aic3x: Use empty struct initializer { 0 } only clears the first member of the structure. The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in the following sparse warning: sound/soc/codecs/tlv320aic3x.c:175:47: warning: Using plain integer as NULL pointer Use the empty struct initializer that clears all the struct members and fixes the sparse warning. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic3x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index dbfa0d8f11a3..6a271e6e6b8f 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -172,7 +172,7 @@ static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol, unsigned int mask = (1 << fls(max)) - 1; unsigned int invert = mc->invert; unsigned short val; - struct snd_soc_dapm_update update = { 0 }; + struct snd_soc_dapm_update update = {}; int connect, change; val = (ucontrol->value.integer.value[0] & mask); From 21957b5bf0ff607e6e0ed55a3a89454e969511ba Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 14 Feb 2018 10:15:31 +0300 Subject: [PATCH 273/942] ASoC: uniphier: fix an error code in uniphier_aio_comprdma_new() The dma_mapping_error() returns true or false, but we want to return -ENOMEM if there was an error. Fixes: e98131222ff9 ("ASoC: uniphier: add support for UniPhier AIO compress audio") Signed-off-by: Dan Carpenter Tested-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-compress.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sound/soc/uniphier/aio-compress.c b/sound/soc/uniphier/aio-compress.c index 7f7abe3ae99d..4751c8bdabec 100644 --- a/sound/soc/uniphier/aio-compress.c +++ b/sound/soc/uniphier/aio-compress.c @@ -54,12 +54,11 @@ static int uniphier_aio_comprdma_new(struct snd_soc_pcm_runtime *rtd) dma_dir = DMA_TO_DEVICE; sub->compr_addr = dma_map_single(dev, sub->compr_area, size, dma_dir); - ret = dma_mapping_error(dev, sub->compr_addr); - if (ret) { + if (dma_mapping_error(dev, sub->compr_addr)) { kfree(sub->compr_area); sub->compr_area = NULL; - return ret; + return -ENOMEM; } sub->compr_bytes = size; From 7a2ccad58106696b7909815cc7ab359ae2743bcc Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 14 Feb 2018 02:58:03 +0000 Subject: [PATCH 274/942] ASoC: soc-core: soc_probe_dai() code simplification Current soc_probe_dai() is using deep nested condition. Thus, it is difficult to read/understand. This patch simplification it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 60a542f35dbd..574048a73b1c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1624,22 +1624,21 @@ static int soc_probe_link_components(struct snd_soc_card *card, static int soc_probe_dai(struct snd_soc_dai *dai, int order) { - int ret; + if (dai->probed || + dai->driver->probe_order != order) + return 0; - if (!dai->probed && dai->driver->probe_order == order) { - if (dai->driver->probe) { - ret = dai->driver->probe(dai); - if (ret < 0) { - dev_err(dai->dev, - "ASoC: failed to probe DAI %s: %d\n", - dai->name, ret); - return ret; - } + if (dai->driver->probe) { + int ret = dai->driver->probe(dai); + if (ret < 0) { + dev_err(dai->dev, "ASoC: failed to probe DAI %s: %d\n", + dai->name, ret); + return ret; } - - dai->probed = 1; } + dai->probed = 1; + return 0; } From e2ce852a7464fe3caaf72f9f3da87d2bfcf3eb84 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:32 +0100 Subject: [PATCH 275/942] ASoC: samsung: i2s: Update clock-output-names property documentation The clock-output-names property is marked as deprecated. While at it, and few typos are fixed. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Reviewed-by: Rob Herring Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/samsung-i2s.txt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/samsung-i2s.txt b/Documentation/devicetree/bindings/sound/samsung-i2s.txt index bf100cd0d0f7..c1f508f18ac8 100644 --- a/Documentation/devicetree/bindings/sound/samsung-i2s.txt +++ b/Documentation/devicetree/bindings/sound/samsung-i2s.txt @@ -7,7 +7,7 @@ Required SoC Specific Properties: - samsung,s5pv210-i2s: for 8/16/24bit multichannel(5.1) I2S with secondary fifo, s/w reset control and internal mux for root clk src. - samsung,exynos5420-i2s: for 8/16/24bit multichannel(5.1) I2S for - playback, sterio channel capture, secondary fifo using internal + playback, stereo channel capture, secondary fifo using internal or external dma, s/w reset control, internal mux for root clk src and 7.1 channel TDM support for playback. TDM (Time division multiplexing) is to allow transfer of multiple channel audio data on single data line. @@ -25,7 +25,7 @@ Required SoC Specific Properties: These strings correspond 1:1 with the ordered pairs in dmas. - clocks: Handle to iis clock and RCLK source clk. - clock-names: - i2s0 uses some base clks from CMU and some are from audio subsystem internal + i2s0 uses some base clocks from CMU and some are from audio subsystem internal clock controller. The clock names for i2s0 should be "iis", "i2s_opclk0" and "i2s_opclk1" as shown in the example below. i2s1 and i2s2 uses clocks from CMU. The clock names for i2s1 and i2s2 should @@ -36,9 +36,9 @@ Required SoC Specific Properties: - #clock-cells: should be 1, this property must be present if the I2S device is a clock provider in terms of the common clock bindings, described in ../clock/clock-bindings.txt. -- clock-output-names: from the common clock bindings, names of the CDCLK - I2S output clocks, suggested values are "i2s_cdclk0", "i2s_cdclk1", - "i2s_cdclk3" for the I2S0, I2S1, I2S2 devices recpectively. +- clock-output-names (deprecated): from the common clock bindings, names of + the CDCLK I2S output clocks, suggested values are "i2s_cdclk0", "i2s_cdclk1", + "i2s_cdclk3" for the I2S0, I2S1, I2S2 devices respectively. There are following clocks available at the I2S device nodes: CLK_I2S_CDCLK - the CDCLK (CODECLKO) gate clock, @@ -49,9 +49,10 @@ There are following clocks available at the I2S device nodes: Refer to the SoC datasheet for availability of the above clocks. The CLK_I2S_RCLK_PSR and CLK_I2S_RCLK_SRC clocks are usually only available -in the IIS Multi Audio Interface (I2S0). -Note: Old DTs may not have the #clock-cells, clock-output-names properties -and then not use the I2S node as a clock supplier. +in the IIS Multi Audio Interface. + +Note: Old DTs may not have the #clock-cells property and then not use the I2S +node as a clock supplier. Optional SoC Specific Properties: @@ -74,8 +75,7 @@ i2s0: i2s@3830000 { <&clock_audss EXYNOS_I2S_BUS>, <&clock_audss EXYNOS_SCLK_I2S>; clock-names = "iis", "i2s_opclk0", "i2s_opclk1"; - #clock-cells; - clock-output-names = "i2s_cdclk0"; + #clock-cells = <1>; samsung,idma-addr = <0x03000000>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_bus>; From aa274c5cfd13381372d2dace32b7354ccba7d2ab Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:33 +0100 Subject: [PATCH 276/942] ASoC: samsung: i2s: Ensure names of supplied clocks are unique In order to support multiple instances of the I2S IP block the platform device name is prepended to each clock registered by the driver. The clock-output-names property is now not used, this should not cause any issues as, for example, CDCLK clock is referenced through DT 'clocks' property, not by name. This change allows to have both I2S0 and I2S1 enabled simultaneously on exynos5433 and working properly when #clock-cells property is specified in respective DT nodes. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index aeba0ae890ea..5088d12faeda 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1193,11 +1193,13 @@ static void i2s_unregister_clock_provider(struct platform_device *pdev) static int i2s_register_clock_provider(struct platform_device *pdev) { - struct device *dev = &pdev->dev; - struct i2s_dai *i2s = dev_get_drvdata(dev); + const char * const i2s_clk_desc[] = { "cdclk", "rclk_src", "prescaler" }; const char *clk_name[2] = { "i2s_opclk0", "i2s_opclk1" }; const char *p_names[2] = { NULL }; + struct device *dev = &pdev->dev; + struct i2s_dai *i2s = dev_get_drvdata(dev); const struct samsung_i2s_variant_regs *reg_info = i2s->variant_regs; + const char *i2s_clk_name[ARRAY_SIZE(i2s_clk_desc)]; struct clk *rclksrc; int ret, i; @@ -1214,30 +1216,38 @@ static int i2s_register_clock_provider(struct platform_device *pdev) clk_put(rclksrc); } + for (i = 0; i < ARRAY_SIZE(i2s_clk_desc); i++) { + i2s_clk_name[i] = devm_kasprintf(dev, GFP_KERNEL, "%s_%s", + dev_name(dev), i2s_clk_desc[i]); + if (!i2s_clk_name[i]) + return -ENOMEM; + } + if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { /* Activate the prescaler */ u32 val = readl(i2s->addr + I2SPSR); writel(val | PSR_PSREN, i2s->addr + I2SPSR); i2s->clk_table[CLK_I2S_RCLK_SRC] = clk_register_mux(dev, - "i2s_rclksrc", p_names, ARRAY_SIZE(p_names), + i2s_clk_name[CLK_I2S_RCLK_SRC], p_names, + ARRAY_SIZE(p_names), CLK_SET_RATE_NO_REPARENT | CLK_SET_RATE_PARENT, i2s->addr + I2SMOD, reg_info->rclksrc_off, 1, 0, i2s->lock); i2s->clk_table[CLK_I2S_RCLK_PSR] = clk_register_divider(dev, - "i2s_presc", "i2s_rclksrc", + i2s_clk_name[CLK_I2S_RCLK_PSR], + i2s_clk_name[CLK_I2S_RCLK_SRC], CLK_SET_RATE_PARENT, i2s->addr + I2SPSR, 8, 6, 0, i2s->lock); - p_names[0] = "i2s_presc"; + p_names[0] = i2s_clk_name[CLK_I2S_RCLK_PSR]; i2s->clk_data.clk_num = 2; } - of_property_read_string_index(dev->of_node, - "clock-output-names", 0, &clk_name[0]); - i2s->clk_table[CLK_I2S_CDCLK] = clk_register_gate(dev, clk_name[0], - p_names[0], CLK_SET_RATE_PARENT, + i2s->clk_table[CLK_I2S_CDCLK] = clk_register_gate(dev, + i2s_clk_name[CLK_I2S_CDCLK], p_names[0], + CLK_SET_RATE_PARENT, i2s->addr + I2SMOD, reg_info->cdclkcon_off, CLK_GATE_SET_TO_DISABLE, i2s->lock); From 48279c53fd1d09dc0d1b6ebb9f21732c507cea0b Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:34 +0100 Subject: [PATCH 277/942] ASoC: samsung: i2s: Prevent external abort on exynos5433 I2S1 access It seems both PCLK_I2S1 and SCLK_I2S1 clocks need to be enabled before I2S1 control registers can be accessed on exynos5433. If SCLK clock is disabled an exception is triggered. To fix this parent clock of the RCLK_SRC clock is assigned to pri_dai->op_clk so required gate clock is handled by the runtime PM ops. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 5088d12faeda..7b57ad11ca15 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1404,9 +1404,14 @@ static int samsung_i2s_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); ret = i2s_register_clock_provider(pdev); - if (!ret) - return 0; + if (ret < 0) + goto err_disable_pm; + pri_dai->op_clk = clk_get_parent(pri_dai->clk_table[CLK_I2S_RCLK_SRC]); + + return 0; + +err_disable_pm: pm_runtime_disable(&pdev->dev); err_disable_clk: clk_disable_unprepare(pri_dai->clk); From 45ae70e8b60e1d1bbc71eeccaef4026c5e6638a3 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:35 +0100 Subject: [PATCH 278/942] ASoC: samsung: i2s: Define the parameters list for SAMSUNG_I2S_OPCLK The SAMSUNG_I2S_OPCLK is not currently used by any card driver thus we can safely change semantics of 'dir' argument of the I2S set_sysclk() callback. Now an enumeration is exported instead of directly using register bit field values. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/i2s-regs.h | 11 ++++++----- sound/soc/samsung/i2s.c | 2 +- sound/soc/samsung/i2s.h | 11 ++++++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sound/soc/samsung/i2s-regs.h b/sound/soc/samsung/i2s-regs.h index fe6914005494..964985ea2e80 100644 --- a/sound/soc/samsung/i2s-regs.h +++ b/sound/soc/samsung/i2s-regs.h @@ -65,11 +65,12 @@ #define CON_RXDMA_ACTIVE (1 << 1) #define CON_ACTIVE (1 << 0) -#define MOD_OPCLK_CDCLK_OUT (0 << 30) -#define MOD_OPCLK_CDCLK_IN (1 << 30) -#define MOD_OPCLK_BCLK_OUT (2 << 30) -#define MOD_OPCLK_PCLK (3 << 30) -#define MOD_OPCLK_MASK (3 << 30) +#define MOD_OPCLK_SHIFT 30 +#define MOD_OPCLK_CDCLK_OUT (0 << MOD_OPCLK_SHIFT) +#define MOD_OPCLK_CDCLK_IN (1 << MOD_OPCLK_SHIFT) +#define MOD_OPCLK_BCLK_OUT (2 << MOD_OPCLK_SHIFT) +#define MOD_OPCLK_PCLK (3 << MOD_OPCLK_SHIFT) +#define MOD_OPCLK_MASK (3 << MOD_OPCLK_SHIFT) #define MOD_TXS_IDMA (1 << 28) /* Sec_TXFIFO use I-DMA */ #define MOD_BLCS_SHIFT 26 diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 7b57ad11ca15..b6407fbabdd1 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -489,7 +489,7 @@ static int i2s_set_sysclk(struct snd_soc_dai *dai, switch (clk_id) { case SAMSUNG_I2S_OPCLK: mask = MOD_OPCLK_MASK; - val = dir; + val = (dir << MOD_OPCLK_SHIFT) & MOD_OPCLK_MASK; break; case SAMSUNG_I2S_CDCLK: mask = 1 << i2s_regs->cdclkcon_off; diff --git a/sound/soc/samsung/i2s.h b/sound/soc/samsung/i2s.h index 79781de2f247..a9832a9555cb 100644 --- a/sound/soc/samsung/i2s.h +++ b/sound/soc/samsung/i2s.h @@ -16,11 +16,16 @@ #define SAMSUNG_I2S_DAI "samsung-i2s" #define SAMSUNG_I2S_DAI_SEC "samsung-i2s-sec" -#define SAMSUNG_I2S_DIV_BCLK 1 +#define SAMSUNG_I2S_DIV_BCLK 1 -#define SAMSUNG_I2S_RCLKSRC_0 0 -#define SAMSUNG_I2S_RCLKSRC_1 1 +#define SAMSUNG_I2S_RCLKSRC_0 0 +#define SAMSUNG_I2S_RCLKSRC_1 1 #define SAMSUNG_I2S_CDCLK 2 +/* Operation clock for IIS logic */ #define SAMSUNG_I2S_OPCLK 3 +#define SAMSUNG_I2S_OPCLK_CDCLK_OUT 0 /* CODEC clock out */ +#define SAMSUNG_I2S_OPCLK_CDCLK_IN 1 /* CODEC clock in */ +#define SAMSUNG_I2S_OPCLK_BCLK_OUT 2 /* Bit clock out */ +#define SAMSUNG_I2S_OPCLK_PCLK 3 /* Audio bus clock */ #endif /* __SND_SOC_SAMSUNG_I2S_H */ From 3a3ac1ea898399f14748a358dd33262c97a9a86b Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:36 +0100 Subject: [PATCH 279/942] ASoC: samsung,tm2-audio DT binding documentation update This patch documents additional entries of the audio-codec and i2s-controller properties required for the HDMI audio support. Signed-off-by: Sylwester Nawrocki Reviewed-by: Rob Herring Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- .../bindings/sound/samsung,tm2-audio.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt b/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt index 94442e5673b3..f5ccc12ddc00 100644 --- a/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt +++ b/Documentation/devicetree/bindings/sound/samsung,tm2-audio.txt @@ -4,9 +4,13 @@ Required properties: - compatible : "samsung,tm2-audio" - model : the user-visible name of this sound complex - - audio-codec : the phandle of the wm5110 audio codec node, - as described in ../mfd/arizona.txt - - i2s-controller : the phandle of the I2S controller + - audio-codec : the first entry should be phandle of the wm5110 audio + codec node, as described in ../mfd/arizona.txt; + the second entry should be phandle of the HDMI + transmitter node + - i2s-controller : the list of phandle and argument tuples pointing to + I2S controllers, the first entry should be I2S0 and + the second one I2S1 - audio-amplifier : the phandle of the MAX98504 amplifier - samsung,audio-routing : a list of the connections between audio components; each entry is a pair of strings, the first being the @@ -22,8 +26,8 @@ Example: sound { compatible = "samsung,tm2-audio"; - audio-codec = <&wm5110>; - i2s-controller = <&i2s0>; + audio-codec = <&wm5110>, <&hdmi>; + i2s-controller = <&i2s0 0>, <&i2s1 0>; audio-amplifier = <&max98504>; mic-bias-gpios = <&gpr3 2 0>; model = "wm5110"; From 8d1513cef51a11dcf8ccb89d089515483a5ad397 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:37 +0100 Subject: [PATCH 280/942] ASoC: samsung: Add support for HDMI audio on TM2 board This patch defines I2S1 - HDMI DAI link and implements related hw_params callback. The AUD PLL frequency is configured through the CLK_SCLK_I2S1 leaf clock, the exynos5433 clock tree definitions are updated in a separate patch. The device tree parsing part is changed is a way it supports older DTBs with just a single CPU DAI specified, without the HDMI link. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/tm2_wm5110.c | 152 ++++++++++++++++++++++++++++----- 1 file changed, 129 insertions(+), 23 deletions(-) diff --git a/sound/soc/samsung/tm2_wm5110.c b/sound/soc/samsung/tm2_wm5110.c index a55d18703fe7..b6a492f1ec02 100644 --- a/sound/soc/samsung/tm2_wm5110.c +++ b/sound/soc/samsung/tm2_wm5110.c @@ -210,6 +210,59 @@ static struct snd_soc_ops tm2_aif2_ops = { .hw_free = tm2_aif2_hw_free, }; +static int tm2_hdmi_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + unsigned int bfs; + int bitwidth, ret; + + bitwidth = snd_pcm_format_width(params_format(params)); + if (bitwidth < 0) { + dev_err(rtd->card->dev, "Invalid bit-width: %d\n", bitwidth); + return bitwidth; + } + + switch (bitwidth) { + case 48: + bfs = 64; + break; + case 16: + bfs = 32; + break; + default: + dev_err(rtd->card->dev, "Unsupported bit-width: %d\n", bitwidth); + return -EINVAL; + } + + switch (params_rate(params)) { + case 48000: + case 96000: + case 192000: + break; + default: + dev_err(rtd->card->dev, "Unsupported sample rate: %d\n", + params_rate(params)); + return -EINVAL; + } + + ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_OPCLK, + 0, SAMSUNG_I2S_OPCLK_PCLK); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_clkdiv(cpu_dai, SAMSUNG_I2S_DIV_BCLK, bfs); + if (ret < 0) + return ret; + + return 0; +} + +static struct snd_soc_ops tm2_hdmi_ops = { + .hw_params = tm2_hdmi_hw_params, +}; + static int tm2_mic_bias(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { @@ -405,6 +458,12 @@ static struct snd_soc_dai_link tm2_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM, .ignore_suspend = 1, + }, { + .name = "HDMI", + .stream_name = "i2s1", + .ops = &tm2_hdmi_ops, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, } }; @@ -412,7 +471,6 @@ static struct snd_soc_card tm2_card = { .owner = THIS_MODULE, .dai_link = tm2_dai_links, - .num_links = ARRAY_SIZE(tm2_dai_links), .controls = tm2_controls, .num_controls = ARRAY_SIZE(tm2_controls), .dapm_widgets = tm2_dapm_widgets, @@ -426,11 +484,14 @@ static struct snd_soc_card tm2_card = { static int tm2_probe(struct platform_device *pdev) { + struct device_node *cpu_dai_node[2] = {}; + struct device_node *codec_dai_node[2] = {}; + const char *cells_name = NULL; struct device *dev = &pdev->dev; struct snd_soc_card *card = &tm2_card; struct tm2_machine_priv *priv; - struct device_node *cpu_dai_node, *codec_dai_node; - int ret, i; + struct of_phandle_args args; + int num_codecs, ret, i; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -464,47 +525,92 @@ static int tm2_probe(struct platform_device *pdev) return -EINVAL; } - cpu_dai_node = of_parse_phandle(dev->of_node, "i2s-controller", 0); - if (!cpu_dai_node) { - dev_err(dev, "i2s-controllers property invalid or missing\n"); - ret = -EINVAL; - goto amp_node_put; + num_codecs = of_count_phandle_with_args(dev->of_node, "audio-codec", + NULL); + + /* Skip the HDMI link if not specified in DT */ + if (num_codecs > 1) { + card->num_links = ARRAY_SIZE(tm2_dai_links); + cells_name = "#sound-dai-cells"; + } else { + card->num_links = ARRAY_SIZE(tm2_dai_links) - 1; } - codec_dai_node = of_parse_phandle(dev->of_node, "audio-codec", 0); - if (!codec_dai_node) { - dev_err(dev, "audio-codec property invalid or missing\n"); - ret = -EINVAL; - goto cpu_dai_node_put; + for (i = 0; i < num_codecs; i++) { + struct of_phandle_args args; + + ret = of_parse_phandle_with_args(dev->of_node, "i2s-controller", + cells_name, i, &args); + if (!args.np) { + dev_err(dev, "i2s-controller property parse error: %d\n", i); + ret = -EINVAL; + goto dai_node_put; + } + cpu_dai_node[i] = args.np; + + codec_dai_node[i] = of_parse_phandle(dev->of_node, + "audio-codec", i); + if (!codec_dai_node[i]) { + dev_err(dev, "audio-codec property parse error\n"); + ret = -EINVAL; + goto dai_node_put; + } } + /* Initialize WM5110 - I2S and HDMI - I2S1 DAI links */ for (i = 0; i < card->num_links; i++) { + unsigned int dai_index = 0; /* WM5110 */ + card->dai_link[i].cpu_name = NULL; card->dai_link[i].platform_name = NULL; - card->dai_link[i].codec_of_node = codec_dai_node; - card->dai_link[i].cpu_of_node = cpu_dai_node; - card->dai_link[i].platform_of_node = cpu_dai_node; + + if (num_codecs > 1 && i == card->num_links - 1) + dai_index = 1; /* HDMI */ + + card->dai_link[i].codec_of_node = codec_dai_node[dai_index]; + card->dai_link[i].cpu_of_node = cpu_dai_node[dai_index]; + card->dai_link[i].platform_of_node = cpu_dai_node[dai_index]; + } + + if (num_codecs > 1) { + /* HDMI DAI link (I2S1) */ + i = card->num_links - 1; + + ret = of_parse_phandle_with_fixed_args(dev->of_node, + "audio-codec", 0, 1, &args); + if (ret) { + dev_err(dev, "audio-codec property parse error\n"); + goto dai_node_put; + } + + ret = snd_soc_get_dai_name(&args, &card->dai_link[i].codec_dai_name); + if (ret) { + dev_err(dev, "Unable to get codec_dai_name\n"); + goto dai_node_put; + } } ret = devm_snd_soc_register_component(dev, &tm2_component, tm2_ext_dai, ARRAY_SIZE(tm2_ext_dai)); if (ret < 0) { dev_err(dev, "Failed to register component: %d\n", ret); - goto codec_dai_node_put; + goto dai_node_put; } ret = devm_snd_soc_register_card(dev, card); if (ret < 0) { dev_err(dev, "Failed to register card: %d\n", ret); - goto codec_dai_node_put; + goto dai_node_put; + } + +dai_node_put: + for (i = 0; i < num_codecs; i++) { + of_node_put(codec_dai_node[i]); + of_node_put(cpu_dai_node[i]); } -codec_dai_node_put: - of_node_put(codec_dai_node); -cpu_dai_node_put: - of_node_put(cpu_dai_node); -amp_node_put: of_node_put(card->aux_dev[0].codec_of_node); + return ret; } From 3f0c43e60d19e1c126ddad47c77a5e1036e52378 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Feb 2018 17:15:38 +0100 Subject: [PATCH 281/942] ASoC: samsung: Add missing #sound-dai-cells property documentation The #sound-dai-cells property might be helpful in selecting primary or secondary CPU DAI and it's already present in i2s nodes for some exynos SoCs so let's add it to the DT binding documentation. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/samsung-i2s.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/samsung-i2s.txt b/Documentation/devicetree/bindings/sound/samsung-i2s.txt index c1f508f18ac8..a88cb00fa096 100644 --- a/Documentation/devicetree/bindings/sound/samsung-i2s.txt +++ b/Documentation/devicetree/bindings/sound/samsung-i2s.txt @@ -60,6 +60,7 @@ Optional SoC Specific Properties: sub system(used in secondary sound source). - pinctrl-0: Should specify pin control groups used for this controller. - pinctrl-names: Should contain only one value - "default". +- #sound-dai-cells: should be 1. Example: @@ -79,4 +80,5 @@ i2s0: i2s@3830000 { samsung,idma-addr = <0x03000000>; pinctrl-names = "default"; pinctrl-0 = <&i2s0_bus>; + #sound-dai-cells = <1>; }; From d460b3f861e18b9c826abe178b2db57c6dc6b3e4 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Wed, 14 Feb 2018 14:20:56 +0200 Subject: [PATCH 282/942] ASoC: tlv320aic31xx: Fix master mode clock I2S bus clocks In the reset state of the codec we do not have complete playback or capture routes. The audio playback/capture will not work due to missing clock signals on the I2S bus if PLL, MDAC/NDAC/DAC MADC/NADC/ADC is powered down. To make sure that even if all output/input is disconnected the codec is generating clocks, we need to have valid DAPM route in every case to power up the must needed parts of the codec. I have verified that switching DAC (during playback) or ADC (during capture) will stop the I2S clocks, so the only solution is to connect the 'Off' routes as well to output/input. The routes will be only added if the codec is clock master. In case the role changes runtime, the applied routes are removed. Tested on am43x-epos-evm with aic3111 codec in master mode. Signed-off-by: Peter Ujfalusi Reviewed-by: Jyri Sarha Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 73 +++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index d3cd924dc300..7090342e8285 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -166,6 +166,7 @@ struct aic31xx_priv { unsigned int sysclk; u8 p_div; int rate_div_line; + bool master_dapm_route_applied; }; struct aic31xx_rate_divs { @@ -670,6 +671,29 @@ aic310x_audio_map[] = { {"SPK", NULL, "SPK ClassD"}, }; +/* + * Always connected DAPM routes for codec clock master modes. + * If the codec is the master on the I2S bus, we need to power on components + * to have valid DAC_CLK and also the DACs and ADC for playback/capture. + * Otherwise the codec will not generate clocks on the bus. + */ +static const struct snd_soc_dapm_route +common31xx_cm_audio_map[] = { + {"DAC Left Input", "Off", "DAC IN"}, + {"DAC Right Input", "Off", "DAC IN"}, + + {"HPL", NULL, "DAC Left"}, + {"HPR", NULL, "DAC Right"}, +}; + +static const struct snd_soc_dapm_route +aic31xx_cm_audio_map[] = { + {"MIC1LP P-Terminal", "Off", "MIC1LP"}, + {"MIC1RP P-Terminal", "Off", "MIC1RP"}, + {"MIC1LM P-Terminal", "Off", "MIC1LM"}, + {"MIC1LM M-Terminal", "Off", "MIC1LM"}, +}; + static int aic31xx_add_controls(struct snd_soc_component *component) { int ret = 0; @@ -912,6 +936,53 @@ static int aic31xx_dac_mute(struct snd_soc_dai *codec_dai, int mute) return 0; } +static int aic31xx_clock_master_routes(struct snd_soc_component *component, + unsigned int fmt) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct aic31xx_priv *aic31xx = snd_soc_component_get_drvdata(component); + int ret; + + fmt &= SND_SOC_DAIFMT_MASTER_MASK; + if (fmt == SND_SOC_DAIFMT_CBS_CFS && + aic31xx->master_dapm_route_applied) { + /* + * Remove the DAPM route(s) for codec clock master modes, + * if applied + */ + ret = snd_soc_dapm_del_routes(dapm, common31xx_cm_audio_map, + ARRAY_SIZE(common31xx_cm_audio_map)); + if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) + ret = snd_soc_dapm_del_routes(dapm, + aic31xx_cm_audio_map, + ARRAY_SIZE(aic31xx_cm_audio_map)); + + if (ret) + return ret; + + aic31xx->master_dapm_route_applied = false; + } else if (fmt != SND_SOC_DAIFMT_CBS_CFS && + !aic31xx->master_dapm_route_applied) { + /* + * Add the needed DAPM route(s) for codec clock master modes, + * if it is not done already + */ + ret = snd_soc_dapm_add_routes(dapm, common31xx_cm_audio_map, + ARRAY_SIZE(common31xx_cm_audio_map)); + if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) + ret = snd_soc_dapm_add_routes(dapm, + aic31xx_cm_audio_map, + ARRAY_SIZE(aic31xx_cm_audio_map)); + + if (ret) + return ret; + + aic31xx->master_dapm_route_applied = true; + } + + return 0; +} + static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { @@ -992,7 +1063,7 @@ static int aic31xx_set_dai_fmt(struct snd_soc_dai *codec_dai, AIC31XX_BCLKINV_MASK, iface_reg2); - return 0; + return aic31xx_clock_master_routes(component, fmt); } static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai, From c90ef8c7419180ee873dd64e5ae162d32faca762 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 14 Feb 2018 13:39:03 -0200 Subject: [PATCH 283/942] ASoC: adau17x1: Use empty struct initializer { 0 } only clears the first member of the structure. The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in a sparse warning. Use the empty struct initializer that clears all the struct members and fixes the sparse warning. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/adau17x1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/adau17x1.c b/sound/soc/codecs/adau17x1.c index df3434982b43..80c2a06285bb 100644 --- a/sound/soc/codecs/adau17x1.c +++ b/sound/soc/codecs/adau17x1.c @@ -181,7 +181,7 @@ static int adau17x1_dsp_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct adau *adau = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; - struct snd_soc_dapm_update update = { 0 }; + struct snd_soc_dapm_update update = {}; unsigned int stream = e->shift_l; unsigned int val, change; int reg; From 91cd00083d734258bf293dcf76793e2348be391a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 14 Feb 2018 13:39:04 -0200 Subject: [PATCH 284/942] ASoC: wm9713: Use empty struct initializer { 0 } only clears the first member of the structure. The first member of the snd_soc_dapm_update struct is a pointer, and writing 0 to a pointer results in a sparse warning. Use the empty struct initializer that clears all the struct members and fixes the sparse warning. Cc: Charles Keepax Signed-off-by: Fabio Estevam Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm9713.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index df7220656d98..093be043c1b0 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -235,7 +235,7 @@ static int wm9713_hp_mixer_put(struct snd_kcontrol *kcontrol, struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; unsigned int mixer, mask, shift, old; - struct snd_soc_dapm_update update = { 0 }; + struct snd_soc_dapm_update update = {}; bool change; mixer = mc->shift >> 8; From 33d9245c6092336420c67f761b3bdcdd6c7c1d5d Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 14 Feb 2018 13:39:05 -0200 Subject: [PATCH 285/942] ASoC: soc-dapm: Use empty struct initializer { NULL } only clears the first member of the structure. Even though the first member of the snd_soc_dapm_update struct is a pointer,it is more robust to use the empty struct initializer that clears all the struct members. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-dapm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 92894d9cac19..2f34590bcb72 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3165,7 +3165,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, unsigned int invert = mc->invert; unsigned int val, rval = 0; int connect, rconnect = -1, change, reg_change = 0; - struct snd_soc_dapm_update update = { NULL }; + struct snd_soc_dapm_update update = {}; int ret = 0; val = (ucontrol->value.integer.value[0] & mask); @@ -3292,7 +3292,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, unsigned int *item = ucontrol->value.enumerated.item; unsigned int val, change, reg_change = 0; unsigned int mask; - struct snd_soc_dapm_update update = { NULL }; + struct snd_soc_dapm_update update = {}; int ret = 0; if (item[0] >= e->items) From 753597fbb7031ff147d4f2862426699e4ad8efca Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar Date: Thu, 15 Feb 2018 14:05:38 +0530 Subject: [PATCH 286/942] ASoC: hdac_hdmi : Ensuring proper setting of output widget power state In usecases like hot plug-unplug DP panel or modeset during a playback, sometimes we observe no audio after codec resets. During no audio condition, we have noticed that the power state of the pin or the connector is D3. Optimizing the way we set the power mitigates the issue. With this changes the verb is sent to set the power state and waits until actual state reaches target state. Thus ensuring power state is set. Signed-off-by: Abhijeet Kumar Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 0758927d1e06..60bea9d69fc0 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -718,10 +718,22 @@ static struct hdac_hdmi_pcm *hdac_hdmi_get_pcm(struct hdac_ext_device *edev, static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, hda_nid_t nid, unsigned int pwr_state) { + int count; + unsigned int state; + if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) { - if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state)) - snd_hdac_codec_write(&edev->hdev, nid, 0, - AC_VERB_SET_POWER_STATE, pwr_state); + if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) { + for (count = 0; count < 10; count++) { + snd_hdac_codec_read(&edev->hdac, nid, 0, + AC_VERB_SET_POWER_STATE, + pwr_state); + state = snd_hdac_sync_power_state(&edev->hdac, + nid, pwr_state); + if (!(state & AC_PWRST_ERROR)) + break; + } + } + } } From 53b8e4504aaa7fc88fd18e6caac3a4d4367bd4a4 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 14 Feb 2018 16:10:36 +0000 Subject: [PATCH 287/942] ASoC: uniphier: remove redundant check of blk_id The check of blk_id == AUD_CLK_IO is redundant as it also being performed in the following switch statement with the same return of -ENOTSUPP. Fix this by removing the redundant comparison. Detected by CoverityScan, CID#1465227 ("Logically dead code") Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-cpu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c index 55f3248a31fd..7cf2316c69a2 100644 --- a/sound/soc/uniphier/aio-cpu.c +++ b/sound/soc/uniphier/aio-cpu.c @@ -134,9 +134,6 @@ static int uniphier_aio_set_sysclk(struct snd_soc_dai *dai, int clk_id, bool pll_auto = false; int pll_id, div_id; - if (clk_id == AUD_CLK_IO) - return -ENOTSUPP; - switch (clk_id) { case AUD_CLK_IO: return -ENOTSUPP; From 390f7bbdd7c8f812e22100248b0ed7ae1f68b8c9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 14 Feb 2018 17:21:53 +0000 Subject: [PATCH 288/942] ASoC: TSCS42xx: make const array norm_addrs static, reduces object code size Don't populate the const array norm_addrs on the stack, instead make it static. Makes the object code smaller by over 230 bytes. Also re-format array data as the insertion of the static keywork made the first line overly long. Before: text data bss dec hex filename 53780 34752 256 88788 15ad4 linux/sound/soc/codecs/tscs42xx.o After: text data bss dec hex filename 53461 34840 256 88557 159ed linux/sound/soc/codecs/tscs42xx.o (gcc version 7.2.0 x86_64) Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/tscs42xx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c index f4f8c613386a..e915261fa1cb 100644 --- a/sound/soc/codecs/tscs42xx.c +++ b/sound/soc/codecs/tscs42xx.c @@ -1319,11 +1319,13 @@ static struct snd_soc_component_driver soc_codec_dev_tscs42xx = { static inline void init_coeff_ram_cache(struct tscs42xx *tscs42xx) { - const u8 norm_addrs[] = { 0x00, 0x05, 0x0a, 0x0f, 0x14, 0x19, 0x1f, - 0x20, 0x25, 0x2a, 0x2f, 0x34, 0x39, 0x3f, 0x40, 0x45, 0x4a, - 0x4f, 0x54, 0x59, 0x5f, 0x60, 0x65, 0x6a, 0x6f, 0x74, 0x79, - 0x7f, 0x80, 0x85, 0x8c, 0x91, 0x96, 0x97, 0x9c, 0xa3, 0xa8, - 0xad, 0xaf, 0xb0, 0xb5, 0xba, 0xbf, 0xc4, 0xc9, }; + static const u8 norm_addrs[] = { + 0x00, 0x05, 0x0a, 0x0f, 0x14, 0x19, 0x1f, 0x20, 0x25, 0x2a, + 0x2f, 0x34, 0x39, 0x3f, 0x40, 0x45, 0x4a, 0x4f, 0x54, 0x59, + 0x5f, 0x60, 0x65, 0x6a, 0x6f, 0x74, 0x79, 0x7f, 0x80, 0x85, + 0x8c, 0x91, 0x96, 0x97, 0x9c, 0xa3, 0xa8, 0xad, 0xaf, 0xb0, + 0xb5, 0xba, 0xbf, 0xc4, 0xc9, + }; u8 *coeff_ram = tscs42xx->coeff_ram; int i; From c15b2a1d185bcdab6556492b81b55ba9e658e201 Mon Sep 17 00:00:00 2001 From: Peng Donglin Date: Wed, 14 Feb 2018 22:48:07 +0800 Subject: [PATCH 289/942] ASoC: use DEFINE_SHOW_ATTRIBUTE() to decrease code duplication There is some duplicate code in soc-core.c, and the kernel provides DEFINE_SHOW_ATTRIBUTE() helper macro to decrease it in seq_file.h. Signed-off-by: Peng Donglin Reviewed-by: Andy Shevchenko Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 45 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 39 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 574048a73b1c..e1f047de599e 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -349,7 +349,7 @@ static void soc_init_codec_debugfs(struct snd_soc_component *component) "ASoC: Failed to create codec register debugfs file\n"); } -static int codec_list_seq_show(struct seq_file *m, void *v) +static int codec_list_show(struct seq_file *m, void *v) { struct snd_soc_codec *codec; @@ -362,20 +362,9 @@ static int codec_list_seq_show(struct seq_file *m, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(codec_list); -static int codec_list_seq_open(struct inode *inode, struct file *file) -{ - return single_open(file, codec_list_seq_show, NULL); -} - -static const struct file_operations codec_list_fops = { - .open = codec_list_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int dai_list_seq_show(struct seq_file *m, void *v) +static int dai_list_show(struct seq_file *m, void *v) { struct snd_soc_component *component; struct snd_soc_dai *dai; @@ -390,20 +379,9 @@ static int dai_list_seq_show(struct seq_file *m, void *v) return 0; } +DEFINE_SHOW_ATTRIBUTE(dai_list); -static int dai_list_seq_open(struct inode *inode, struct file *file) -{ - return single_open(file, dai_list_seq_show, NULL); -} - -static const struct file_operations dai_list_fops = { - .open = dai_list_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static int platform_list_seq_show(struct seq_file *m, void *v) +static int platform_list_show(struct seq_file *m, void *v) { struct snd_soc_platform *platform; @@ -416,18 +394,7 @@ static int platform_list_seq_show(struct seq_file *m, void *v) return 0; } - -static int platform_list_seq_open(struct inode *inode, struct file *file) -{ - return single_open(file, platform_list_seq_show, NULL); -} - -static const struct file_operations platform_list_fops = { - .open = platform_list_seq_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(platform_list); static void soc_init_card_debugfs(struct snd_soc_card *card) { From 0b9751c7179b8ec7a33addc3a8b2b1639d4678cb Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Thu, 15 Feb 2018 17:14:16 +0000 Subject: [PATCH 290/942] ASoC: Intel: Fix build One of the recently introduced commits hadn't been build tested, fix that. Reported-by: kbuild test robot Signed-off-by: Mark Brown --- sound/soc/codecs/hdac_hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 60bea9d69fc0..84f7a7a36e4b 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c @@ -722,12 +722,12 @@ static void hdac_hdmi_set_power_state(struct hdac_ext_device *edev, unsigned int state; if (get_wcaps(&edev->hdev, nid) & AC_WCAP_POWER) { - if (!snd_hdac_check_power_state(&edev->hdac, nid, pwr_state)) { + if (!snd_hdac_check_power_state(&edev->hdev, nid, pwr_state)) { for (count = 0; count < 10; count++) { - snd_hdac_codec_read(&edev->hdac, nid, 0, + snd_hdac_codec_read(&edev->hdev, nid, 0, AC_VERB_SET_POWER_STATE, pwr_state); - state = snd_hdac_sync_power_state(&edev->hdac, + state = snd_hdac_sync_power_state(&edev->hdev, nid, pwr_state); if (!(state & AC_PWRST_ERROR)) break; From 510c321b557121861601f9d259aadd65aa274f35 Mon Sep 17 00:00:00 2001 From: Xin Long Date: Wed, 14 Feb 2018 19:06:02 +0800 Subject: [PATCH 291/942] xfrm: reuse uncached_list to track xdsts In early time, when freeing a xdst, it would be inserted into dst_garbage.list first. Then if it's refcnt was still held somewhere, later it would be put into dst_busy_list in dst_gc_task(). When one dev was being unregistered, the dev of these dsts in dst_busy_list would be set with loopback_dev and put this dev. So that this dev's removal wouldn't get blocked, and avoid the kmsg warning: kernel:unregister_netdevice: waiting for veth0 to become \ free. Usage count = 2 However after Commit 52df157f17e5 ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle"), the xdst will not be freed with dst gc, and this warning happens. To fix it, we need to find these xdsts that are still held by others when removing the dev, and free xdst's dev and set it with loopback_dev. But unfortunately after flow_cache for xfrm was deleted, no list tracks them anymore. So we need to save these xdsts somewhere to release the xdst's dev later. To make this easier, this patch is to reuse uncached_list to track xdsts, so that the dev refcnt can be released in the event NETDEV_UNREGISTER process of fib_netdev_notifier. Thanks to Florian, we could move forward this fix quickly. Fixes: 52df157f17e5 ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle") Reported-by: Jianlin Shi Reported-by: Hangbin Liu Tested-by: Eyal Birger Signed-off-by: Xin Long Signed-off-by: Steffen Klassert --- include/net/ip6_route.h | 3 +++ include/net/route.h | 3 +++ net/ipv4/route.c | 21 +++++++++++++-------- net/ipv4/xfrm4_policy.c | 4 +++- net/ipv6/route.c | 4 ++-- net/ipv6/xfrm6_policy.c | 5 +++++ 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 27d23a65f3cd..ac0866bb9e93 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h @@ -179,6 +179,9 @@ void rt6_disable_ip(struct net_device *dev, unsigned long event); void rt6_sync_down_dev(struct net_device *dev, unsigned long event); void rt6_multipath_rebalance(struct rt6_info *rt); +void rt6_uncached_list_add(struct rt6_info *rt); +void rt6_uncached_list_del(struct rt6_info *rt); + static inline const struct rt6_info *skb_rt6_info(const struct sk_buff *skb) { const struct dst_entry *dst = skb_dst(skb); diff --git a/include/net/route.h b/include/net/route.h index 1eb9ce470e25..40b870d58f38 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -227,6 +227,9 @@ struct in_ifaddr; void fib_add_ifaddr(struct in_ifaddr *); void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); +void rt_add_uncached_list(struct rtable *rt); +void rt_del_uncached_list(struct rtable *rt); + static inline void ip_rt_put(struct rtable *rt) { /* dst_release() accepts a NULL parameter. diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 49cc1c1df1ba..1d1e4abe04b0 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1383,7 +1383,7 @@ struct uncached_list { static DEFINE_PER_CPU_ALIGNED(struct uncached_list, rt_uncached_list); -static void rt_add_uncached_list(struct rtable *rt) +void rt_add_uncached_list(struct rtable *rt) { struct uncached_list *ul = raw_cpu_ptr(&rt_uncached_list); @@ -1394,14 +1394,8 @@ static void rt_add_uncached_list(struct rtable *rt) spin_unlock_bh(&ul->lock); } -static void ipv4_dst_destroy(struct dst_entry *dst) +void rt_del_uncached_list(struct rtable *rt) { - struct dst_metrics *p = (struct dst_metrics *)DST_METRICS_PTR(dst); - struct rtable *rt = (struct rtable *) dst; - - if (p != &dst_default_metrics && refcount_dec_and_test(&p->refcnt)) - kfree(p); - if (!list_empty(&rt->rt_uncached)) { struct uncached_list *ul = rt->rt_uncached_list; @@ -1411,6 +1405,17 @@ static void ipv4_dst_destroy(struct dst_entry *dst) } } +static void ipv4_dst_destroy(struct dst_entry *dst) +{ + struct dst_metrics *p = (struct dst_metrics *)DST_METRICS_PTR(dst); + struct rtable *rt = (struct rtable *)dst; + + if (p != &dst_default_metrics && refcount_dec_and_test(&p->refcnt)) + kfree(p); + + rt_del_uncached_list(rt); +} + void rt_flush_dev(struct net_device *dev) { struct net *net = dev_net(dev); diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 05017e2c849c..8d33f7b311f4 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -102,6 +102,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, xdst->u.rt.rt_pmtu = rt->rt_pmtu; xdst->u.rt.rt_table_id = rt->rt_table_id; INIT_LIST_HEAD(&xdst->u.rt.rt_uncached); + rt_add_uncached_list(&xdst->u.rt); return 0; } @@ -241,7 +242,8 @@ static void xfrm4_dst_destroy(struct dst_entry *dst) struct xfrm_dst *xdst = (struct xfrm_dst *)dst; dst_destroy_metrics_generic(dst); - + if (xdst->u.rt.rt_uncached_list) + rt_del_uncached_list(&xdst->u.rt); xfrm_dst_destroy(xdst); } diff --git a/net/ipv6/route.c b/net/ipv6/route.c index fb2d251c0500..38b75e9d6eae 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -128,7 +128,7 @@ struct uncached_list { static DEFINE_PER_CPU_ALIGNED(struct uncached_list, rt6_uncached_list); -static void rt6_uncached_list_add(struct rt6_info *rt) +void rt6_uncached_list_add(struct rt6_info *rt) { struct uncached_list *ul = raw_cpu_ptr(&rt6_uncached_list); @@ -139,7 +139,7 @@ static void rt6_uncached_list_add(struct rt6_info *rt) spin_unlock_bh(&ul->lock); } -static void rt6_uncached_list_del(struct rt6_info *rt) +void rt6_uncached_list_del(struct rt6_info *rt) { if (!list_empty(&rt->rt6i_uncached)) { struct uncached_list *ul = rt->rt6i_uncached_list; diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 09fb44ee3b45..416fe67271a9 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c @@ -113,6 +113,9 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, xdst->u.rt6.rt6i_gateway = rt->rt6i_gateway; xdst->u.rt6.rt6i_dst = rt->rt6i_dst; xdst->u.rt6.rt6i_src = rt->rt6i_src; + INIT_LIST_HEAD(&xdst->u.rt6.rt6i_uncached); + rt6_uncached_list_add(&xdst->u.rt6); + atomic_inc(&dev_net(dev)->ipv6.rt6_stats->fib_rt_uncache); return 0; } @@ -244,6 +247,8 @@ static void xfrm6_dst_destroy(struct dst_entry *dst) if (likely(xdst->u.rt6.rt6i_idev)) in6_dev_put(xdst->u.rt6.rt6i_idev); dst_destroy_metrics_generic(dst); + if (xdst->u.rt6.rt6i_uncached_list) + rt6_uncached_list_del(&xdst->u.rt6); xfrm_dst_destroy(xdst); } From b3ea70ee64ea50d6719f09f781ff11ac9c86d0c2 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Mon, 5 Feb 2018 09:59:56 +0530 Subject: [PATCH 292/942] ASoC: Intel: Add Kabylake-y Dialog Maxim machine driver This patch adds Kabylake-y I2S machine driver which uses DA7219 as headset on ssp1 and MAX98357A codec as speaker on ssp0. Signed-off-by: Naveen Manohar Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 14 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/kbl_da7219_max98357a.c | 613 ++++++++++++++++++ 3 files changed, 629 insertions(+) create mode 100644 sound/soc/intel/boards/kbl_da7219_max98357a.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index fefb1ee9fec6..eedc83b96fbb 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -256,6 +256,20 @@ config SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH create an alsa sound card for RT5663 + RT5514 + MAX98927. Say Y or m if you have such a device. This is a recommended option. If unsure select "N". + +config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH + tristate "KBL with DA7219 and MAX98357A in I2S Mode" + depends on MFD_INTEL_LPSS && I2C && ACPI + select SND_SOC_DA7219 + select SND_SOC_MAX98357A + select SND_SOC_DMIC + select SND_SOC_HDAC_HDMI + help + This adds support for ASoC Onboard Codec I2S machine driver. This will + create an alsa sound card for DA7219 + MAX98357A I2S audio codec. + Say Y if you have such a device. + If unsure select "N". + endif ## SND_SOC_INTEL_SKYLAKE endif ## SND_SOC_INTEL_MACH diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 69d2dfaeb00c..6fae506c40fa 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -14,6 +14,7 @@ snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o +snd-soc-kbl_da7219_max98357a-objs := kbl_da7219_max98357a.o snd-soc-kbl_rt5663_max98927-objs := kbl_rt5663_max98927.o snd-soc-kbl_rt5663_rt5514_max98927-objs := kbl_rt5663_rt5514_max98927.o snd-soc-skl_rt286-objs := skl_rt286.o @@ -35,6 +36,7 @@ obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max9 obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o +obj-$(CONFIG_SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH) += snd-soc-kbl_da7219_max98357a.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_MAX98927_MACH) += snd-soc-kbl_rt5663_max98927.o obj-$(CONFIG_SND_SOC_INTEL_KBL_RT5663_RT5514_MAX98927_MACH) += snd-soc-kbl_rt5663_rt5514_max98927.o obj-$(CONFIG_SND_SOC_INTEL_SKL_RT286_MACH) += snd-soc-skl_rt286.o diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c new file mode 100644 index 000000000000..d689124f6687 --- /dev/null +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -0,0 +1,613 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright(c) 2017-18 Intel Corporation. + +/* + * Intel Kabylake I2S Machine Driver with MAX98357A & DA7219 Codecs + * + * Modified from: + * Intel Kabylake I2S Machine driver supporting MAXIM98927 and + * RT5663 codecs + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../codecs/da7219.h" +#include "../../codecs/hdac_hdmi.h" +#include "../skylake/skl.h" +#include "../../codecs/da7219-aad.h" + +#define KBL_DIALOG_CODEC_DAI "da7219-hifi" +#define KBL_MAXIM_CODEC_DAI "HiFi" +#define MAXIM_DEV0_NAME "MX98357A:00" +#define DUAL_CHANNEL 2 +#define QUAD_CHANNEL 4 + +static struct snd_soc_card *kabylake_audio_card; +static struct snd_soc_jack skylake_hdmi[3]; + +struct kbl_hdmi_pcm { + struct list_head head; + struct snd_soc_dai *codec_dai; + int device; +}; + +struct kbl_codec_private { + struct snd_soc_jack kabylake_headset; + struct list_head hdmi_pcm_list; +}; + +enum { + KBL_DPCM_AUDIO_PB = 0, + KBL_DPCM_AUDIO_CP, + KBL_DPCM_AUDIO_DMIC_CP, + KBL_DPCM_AUDIO_HDMI1_PB, + KBL_DPCM_AUDIO_HDMI2_PB, + KBL_DPCM_AUDIO_HDMI3_PB, +}; + +static int platform_clock_control(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *k, int event) +{ + struct snd_soc_dapm_context *dapm = w->dapm; + struct snd_soc_card *card = dapm->card; + struct snd_soc_dai *codec_dai; + int ret = 0; + + codec_dai = snd_soc_card_get_codec_dai(card, KBL_DIALOG_CODEC_DAI); + if (!codec_dai) { + dev_err(card->dev, "Codec dai not found; Unable to set/unset codec pll\n"); + return -EIO; + } + + /* Configure sysclk for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 24576000, + SND_SOC_CLOCK_IN); + if (ret) { + dev_err(card->dev, "can't set codec sysclk configuration\n"); + return ret; + } + + if (SND_SOC_DAPM_EVENT_OFF(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, + DA7219_SYSCLK_MCLK, 0, 0); + if (ret) + dev_err(card->dev, "failed to stop PLL: %d\n", ret); + } else if (SND_SOC_DAPM_EVENT_ON(event)) { + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL_SRM, + 0, DA7219_PLL_FREQ_OUT_98304); + if (ret) + dev_err(card->dev, "failed to start PLL: %d\n", ret); + } + + return ret; +} + +static const struct snd_kcontrol_new kabylake_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone Jack"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Spk"), +}; + +static const struct snd_soc_dapm_widget kabylake_widgets[] = { + SND_SOC_DAPM_HP("Headphone Jack", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_SPK("Spk", NULL), + SND_SOC_DAPM_MIC("SoC DMIC", NULL), + SND_SOC_DAPM_SPK("DP", NULL), + SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), +}; + +static const struct snd_soc_dapm_route kabylake_map[] = { + { "Headphone Jack", NULL, "HPL" }, + { "Headphone Jack", NULL, "HPR" }, + + /* speaker */ + { "Spk", NULL, "Speaker" }, + + /* other jacks */ + { "MIC", NULL, "Headset Mic" }, + { "DMic", NULL, "SoC DMIC" }, + + { "HDMI", NULL, "hif5 Output" }, + { "DP", NULL, "hif6 Output" }, + + /* CODEC BE connections */ + { "HiFi Playback", NULL, "ssp0 Tx" }, + { "ssp0 Tx", NULL, "codec0_out" }, + + { "Playback", NULL, "ssp1 Tx" }, + { "ssp1 Tx", NULL, "codec1_out" }, + + { "codec0_in", NULL, "ssp1 Rx" }, + { "ssp1 Rx", NULL, "Capture" }, + + /* DMIC */ + { "dmic01_hifi", NULL, "DMIC01 Rx" }, + { "DMIC01 Rx", NULL, "DMIC AIF" }, + + { "hifi1", NULL, "iDisp1 Tx" }, + { "iDisp1 Tx", NULL, "iDisp1_out" }, + { "hifi2", NULL, "iDisp2 Tx" }, + { "iDisp2 Tx", NULL, "iDisp2_out" }, + { "hifi3", NULL, "iDisp3 Tx"}, + { "iDisp3 Tx", NULL, "iDisp3_out"}, + + { "Headphone Jack", NULL, "Platform Clock" }, + { "Headset Mic", NULL, "Platform Clock" }, +}; + +static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* The ADSP will convert the FE rate to 48k, stereo */ + rate->min = rate->max = 48000; + channels->min = channels->max = DUAL_CHANNEL; + + /* set SSP to 24 bit */ + snd_mask_none(fmt); + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_jack *jack; + int ret; + + /* + * Headset buttons map to the google Reference headset. + * These can be configured by userspace. + */ + ret = snd_soc_card_jack_new(kabylake_audio_card, "Headset Jack", + SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3 | SND_JACK_LINEOUT, + &ctx->kabylake_headset, NULL, 0); + if (ret) { + dev_err(rtd->dev, "Headset Jack creation failed: %d\n", ret); + return ret; + } + + jack = &ctx->kabylake_headset; + + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); + da7219_aad_jack_det(codec, &ctx->kabylake_headset); + + ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); + if (ret) + dev_err(rtd->dev, "SoC DMIC - Ignore suspend failed %d\n", ret); + + return ret; +} + +static int kabylake_hdmi_init(struct snd_soc_pcm_runtime *rtd, int device) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *dai = rtd->codec_dai; + struct kbl_hdmi_pcm *pcm; + + pcm = devm_kzalloc(rtd->card->dev, sizeof(*pcm), GFP_KERNEL); + if (!pcm) + return -ENOMEM; + + pcm->device = device; + pcm->codec_dai = dai; + + list_add_tail(&pcm->head, &ctx->hdmi_pcm_list); + + return 0; +} + +static int kabylake_hdmi1_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI1_PB); +} + +static int kabylake_hdmi2_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI2_PB); +} + +static int kabylake_hdmi3_init(struct snd_soc_pcm_runtime *rtd) +{ + return kabylake_hdmi_init(rtd, KBL_DPCM_AUDIO_HDMI3_PB); +} + +static int kabylake_da7219_fe_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_dapm_context *dapm; + struct snd_soc_component *component = rtd->cpu_dai->component; + + dapm = snd_soc_component_get_dapm(component); + snd_soc_dapm_ignore_suspend(dapm, "Reference Capture"); + + return 0; +} + +static const unsigned int rates[] = { + 48000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, +}; + +static const unsigned int channels[] = { + DUAL_CHANNEL, +}; + +static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, +}; + +static unsigned int channels_quad[] = { + QUAD_CHANNEL, +}; + +static struct snd_pcm_hw_constraint_list constraints_channels_quad = { + .count = ARRAY_SIZE(channels_quad), + .list = channels_quad, + .mask = 0, +}; + +static int kbl_fe_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + /* + * On this platform for PCM device we support, + * 48Khz + * stereo + * 16 bit audio + */ + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + + runtime->hw.formats = SNDRV_PCM_FMTBIT_S16_LE; + snd_pcm_hw_constraint_msbits(runtime, 0, 16, 16); + + snd_pcm_hw_constraint_list(runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); + + return 0; +} + +static const struct snd_soc_ops kabylake_da7219_fe_ops = { + .startup = kbl_fe_startup, +}; + +static int kabylake_dmic_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + /* + * set BE channel constraint as user FE channels + */ + + if (params_channels(params) == 2) + channels->min = channels->max = 2; + else + channels->min = channels->max = 4; + + return 0; +} + +static int kabylake_dmic_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + runtime->hw.channels_min = runtime->hw.channels_max = QUAD_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels_quad); + + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, &constraints_rates); +} + +static struct snd_soc_ops kabylake_dmic_ops = { + .startup = kabylake_dmic_startup, +}; + +static const unsigned int rates_16000[] = { + 16000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_16000 = { + .count = ARRAY_SIZE(rates_16000), + .list = rates_16000, +}; + +static const unsigned int ch_mono[] = { + 1, +}; + +/* kabylake digital audio interface glue - connects codec <--> CPU */ +static struct snd_soc_dai_link kabylake_dais[] = { + /* Front End DAI links */ + [KBL_DPCM_AUDIO_PB] = { + .name = "Kbl Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .init = kabylake_da7219_fe_init, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .ops = &kabylake_da7219_fe_ops, + }, + [KBL_DPCM_AUDIO_CP] = { + .name = "Kbl Audio Capture Port", + .stream_name = "Audio Record", + .cpu_dai_name = "System Pin", + .platform_name = "0000:00:1f.3", + .dynamic = 1, + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .nonatomic = 1, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_capture = 1, + }, + [KBL_DPCM_AUDIO_DMIC_CP] = { + .name = "Kbl Audio DMIC cap", + .stream_name = "dmiccap", + .cpu_dai_name = "DMIC Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .init = NULL, + .dpcm_capture = 1, + .nonatomic = 1, + .dynamic = 1, + .ops = &kabylake_dmic_ops, + }, + [KBL_DPCM_AUDIO_HDMI1_PB] = { + .name = "Kbl HDMI Port1", + .stream_name = "Hdmi1", + .cpu_dai_name = "HDMI1 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_HDMI2_PB] = { + .name = "Kbl HDMI Port2", + .stream_name = "Hdmi2", + .cpu_dai_name = "HDMI2 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = NULL, + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .nonatomic = 1, + .dynamic = 1, + }, + [KBL_DPCM_AUDIO_HDMI3_PB] = { + .name = "Kbl HDMI Port3", + .stream_name = "Hdmi3", + .cpu_dai_name = "HDMI3 Pin", + .codec_name = "snd-soc-dummy", + .codec_dai_name = "snd-soc-dummy-dai", + .platform_name = "0000:00:1f.3", + .trigger = { + SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, + .dpcm_playback = 1, + .init = NULL, + .nonatomic = 1, + .dynamic = 1, + }, + + /* Back End DAI links */ + { + /* SSP0 - Codec */ + .name = "SSP0-Codec", + .id = 0, + .cpu_dai_name = "SSP0 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = MAXIM_DEV0_NAME, + .codec_dai_name = KBL_MAXIM_CODEC_DAI, + .dai_fmt = SND_SOC_DAIFMT_I2S | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .dpcm_playback = 1, + }, + { + /* SSP1 - Codec */ + .name = "SSP1-Codec", + .id = 1, + .cpu_dai_name = "SSP1 Pin", + .platform_name = "0000:00:1f.3", + .no_pcm = 1, + .codec_name = "i2c-DLGS7219:00", + .codec_dai_name = KBL_DIALOG_CODEC_DAI, + .init = kabylake_da7219_codec_init, + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS, + .ignore_pmdown_time = 1, + .be_hw_params_fixup = kabylake_ssp_fixup, + .dpcm_playback = 1, + .dpcm_capture = 1, + }, + { + .name = "dmic01", + .id = 2, + .cpu_dai_name = "DMIC01 Pin", + .codec_name = "dmic-codec", + .codec_dai_name = "dmic-hifi", + .platform_name = "0000:00:1f.3", + .be_hw_params_fixup = kabylake_dmic_fixup, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, + { + .name = "iDisp1", + .id = 3, + .cpu_dai_name = "iDisp1 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi1", + .platform_name = "0000:00:1f.3", + .dpcm_playback = 1, + .init = kabylake_hdmi1_init, + .no_pcm = 1, + }, + { + .name = "iDisp2", + .id = 4, + .cpu_dai_name = "iDisp2 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi2", + .platform_name = "0000:00:1f.3", + .init = kabylake_hdmi2_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, + { + .name = "iDisp3", + .id = 5, + .cpu_dai_name = "iDisp3 Pin", + .codec_name = "ehdaudio0D2", + .codec_dai_name = "intel-hdmi-hifi3", + .platform_name = "0000:00:1f.3", + .init = kabylake_hdmi3_init, + .dpcm_playback = 1, + .no_pcm = 1, + }, +}; + +#define NAME_SIZE 32 +static int kabylake_card_late_probe(struct snd_soc_card *card) +{ + struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); + struct kbl_hdmi_pcm *pcm; + struct snd_soc_codec *codec = NULL; + int err, i = 0; + char jack_name[NAME_SIZE]; + + list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { + codec = pcm->codec_dai->codec; + snprintf(jack_name, sizeof(jack_name), + "HDMI/DP, pcm=%d Jack", pcm->device); + err = snd_soc_card_jack_new(card, jack_name, + SND_JACK_AVOUT, &skylake_hdmi[i], + NULL, 0); + + if (err) + return err; + + err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, + &skylake_hdmi[i]); + if (err < 0) + return err; + + i++; + + } + + if (!codec) + return -EINVAL; + + return hdac_hdmi_jack_port_init(codec, &card->dapm); +} + +/* kabylake audio machine driver for SPT + DA7219 */ +static struct snd_soc_card kabylake_audio_card_da7219_m98357a = { + .name = "kblda7219max", + .owner = THIS_MODULE, + .dai_link = kabylake_dais, + .num_links = ARRAY_SIZE(kabylake_dais), + .controls = kabylake_controls, + .num_controls = ARRAY_SIZE(kabylake_controls), + .dapm_widgets = kabylake_widgets, + .num_dapm_widgets = ARRAY_SIZE(kabylake_widgets), + .dapm_routes = kabylake_map, + .num_dapm_routes = ARRAY_SIZE(kabylake_map), + .fully_routed = true, + .late_probe = kabylake_card_late_probe, +}; + +static int kabylake_audio_probe(struct platform_device *pdev) +{ + struct kbl_codec_private *ctx; + + ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_ATOMIC); + if (!ctx) + return -ENOMEM; + + INIT_LIST_HEAD(&ctx->hdmi_pcm_list); + + kabylake_audio_card = + (struct snd_soc_card *)pdev->id_entry->driver_data; + + kabylake_audio_card->dev = &pdev->dev; + snd_soc_card_set_drvdata(kabylake_audio_card, ctx); + return devm_snd_soc_register_card(&pdev->dev, kabylake_audio_card); +} + +static const struct platform_device_id kbl_board_ids[] = { + { + .name = "kbl_da7219_max98357a", + .driver_data = + (kernel_ulong_t)&kabylake_audio_card_da7219_m98357a, + }, + { } +}; + +static struct platform_driver kabylake_audio = { + .probe = kabylake_audio_probe, + .driver = { + .name = "kbl_da7219_max98357a", + .pm = &snd_soc_pm_ops, + }, + .id_table = kbl_board_ids, +}; + +module_platform_driver(kabylake_audio) + +/* Module information */ +MODULE_DESCRIPTION("Audio Machine driver-DA7219 & MAX98357A in I2S mode"); +MODULE_AUTHOR("Naveen Manohar "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:kbl_da7219_max98357a"); From ea954fbc35e655c77c11389124a29aae873e5ca6 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Mon, 5 Feb 2018 09:59:57 +0530 Subject: [PATCH 293/942] ASoC: Intel: Add Kabylake Dialog+Maxim machine driver entry Adds Kabylake kbl_da7219_max98357a_i2s machine driver entry into machine table Signed-off-by: Naveen Manohar Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index 32ce64c6b2dc..aa9edc84eefb 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -1017,6 +1017,11 @@ static struct snd_soc_acpi_codecs kbl_5663_5514_codecs = { .codecs = {"10EC5663", "10EC5514"} }; +static struct snd_soc_acpi_codecs kbl_7219_98357_codecs = { + .num_codecs = 1, + .codecs = {"MX98357A"} +}; + static struct skl_machine_pdata cnl_pdata = { .use_tplg_pcm = true, }; @@ -1105,6 +1110,14 @@ static struct snd_soc_acpi_mach sst_kbl_devdata[] = { .drv_name = "kbl_rt5663", .fw_filename = "intel/dsp_fw_kbl.bin", }, + { + .id = "DLGS7219", + .drv_name = "kbl_da7219_max98357a", + .fw_filename = "intel/dsp_fw_kbl.bin", + .machine_quirk = snd_soc_acpi_codec_list, + .quirk_data = &kbl_7219_98357_codecs, + .pdata = &skl_dmic_data + }, {} }; From 08660086eff9e9e69246a65ee48aba5c3901bf5e Mon Sep 17 00:00:00 2001 From: Cosmin-Gabriel Samoila Date: Wed, 14 Feb 2018 15:21:06 +0200 Subject: [PATCH 294/942] ASoC: ak4458: Add support for AK4458 DAC driver The AK4458 is a 32-bit 8ch Premium DAC that corresponds to a 768kHz PCM input and an 11.2MHz DSD input at maximum. It supports I2S, DSD and TDM modes with 24 or 32 bit MSB or 16, 24, 32 LSB formats. Its datasheet is available here: https://www.akm.com/akm/en/file/datasheet/AK4458VN.pdf Signed-off-by: Junichi Wakasugi Signed-off-by: Mihai Serban Signed-off-by: Shengjiu Wang Signed-off-by: Cosmin-Gabriel Samoila Reviewed-by: Andy Shevchenko Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ak4458.c | 659 ++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ak4458.h | 86 +++++ 4 files changed, 753 insertions(+) create mode 100644 sound/soc/codecs/ak4458.c create mode 100644 sound/soc/codecs/ak4458.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..7f6fb5e234f1 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -35,6 +35,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ADAU7002 select SND_SOC_ADS117X select SND_SOC_AK4104 if SPI_MASTER + select SND_SOC_AK4458 if I2C select SND_SOC_AK4535 if I2C select SND_SOC_AK4554 select SND_SOC_AK4613 if I2C @@ -375,6 +376,11 @@ config SND_SOC_AK4104 tristate "AKM AK4104 CODEC" depends on SPI_MASTER +config SND_SOC_AK4458 + tristate "AKM AK4458 CODEC" + depends on I2C + select REGMAP_I2C + config SND_SOC_AK4535 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..7f5d57517a5e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -27,6 +27,7 @@ snd-soc-adav801-objs := adav801.o snd-soc-adav803-objs := adav803.o snd-soc-ads117x-objs := ads117x.o snd-soc-ak4104-objs := ak4104.o +snd-soc-ak4458-objs := ak4458.o snd-soc-ak4535-objs := ak4535.o snd-soc-ak4554-objs := ak4554.o snd-soc-ak4613-objs := ak4613.o @@ -270,6 +271,7 @@ obj-$(CONFIG_SND_SOC_ADAV801) += snd-soc-adav801.o obj-$(CONFIG_SND_SOC_ADAV803) += snd-soc-adav803.o obj-$(CONFIG_SND_SOC_ADS117X) += snd-soc-ads117x.o obj-$(CONFIG_SND_SOC_AK4104) += snd-soc-ak4104.o +obj-$(CONFIG_SND_SOC_AK4458) += snd-soc-ak4458.o obj-$(CONFIG_SND_SOC_AK4535) += snd-soc-ak4535.o obj-$(CONFIG_SND_SOC_AK4554) += snd-soc-ak4554.o obj-$(CONFIG_SND_SOC_AK4613) += snd-soc-ak4613.o diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c new file mode 100644 index 000000000000..b579cda8e418 --- /dev/null +++ b/sound/soc/codecs/ak4458.c @@ -0,0 +1,659 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Audio driver for AK4458 DAC + * + * Copyright (C) 2016 Asahi Kasei Microdevices Corporation + * Copyright 2018 NXP + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ak4458.h" + +/* AK4458 Codec Private Data */ +struct ak4458_priv { + struct device *dev; + struct regmap *regmap; + struct gpio_desc *reset_gpiod; + struct gpio_desc *mute_gpiod; + int digfil; /* SSLOW, SD, SLOW bits */ + int fs; /* sampling rate */ + int fmt; + int slots; + int slot_width; +}; + +static const struct reg_default ak4458_reg_defaults[] = { + { 0x00, 0x0C }, /* 0x00 AK4458_00_CONTROL1 */ + { 0x01, 0x22 }, /* 0x01 AK4458_01_CONTROL2 */ + { 0x02, 0x00 }, /* 0x02 AK4458_02_CONTROL3 */ + { 0x03, 0xFF }, /* 0x03 AK4458_03_LCHATT */ + { 0x04, 0xFF }, /* 0x04 AK4458_04_RCHATT */ + { 0x05, 0x00 }, /* 0x05 AK4458_05_CONTROL4 */ + { 0x06, 0x00 }, /* 0x06 AK4458_06_DSD1 */ + { 0x07, 0x03 }, /* 0x07 AK4458_07_CONTROL5 */ + { 0x08, 0x00 }, /* 0x08 AK4458_08_SOUND_CONTROL */ + { 0x09, 0x00 }, /* 0x09 AK4458_09_DSD2 */ + { 0x0A, 0x0D }, /* 0x0A AK4458_0A_CONTROL6 */ + { 0x0B, 0x0C }, /* 0x0B AK4458_0B_CONTROL7 */ + { 0x0C, 0x00 }, /* 0x0C AK4458_0C_CONTROL8 */ + { 0x0D, 0x00 }, /* 0x0D AK4458_0D_CONTROL9 */ + { 0x0E, 0x50 }, /* 0x0E AK4458_0E_CONTROL10 */ + { 0x0F, 0xFF }, /* 0x0F AK4458_0F_L2CHATT */ + { 0x10, 0xFF }, /* 0x10 AK4458_10_R2CHATT */ + { 0x11, 0xFF }, /* 0x11 AK4458_11_L3CHATT */ + { 0x12, 0xFF }, /* 0x12 AK4458_12_R3CHATT */ + { 0x13, 0xFF }, /* 0x13 AK4458_13_L4CHATT */ + { 0x14, 0xFF }, /* 0x14 AK4458_14_R4CHATT */ +}; + +/* + * Volume control: + * from -127 to 0 dB in 0.5 dB steps (mute instead of -127.5 dB) + */ +static DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1); + +/* + * DEM1 bit DEM0 bit Mode + * 0 0 44.1kHz + * 0 1 OFF (default) + * 1 0 48kHz + * 1 1 32kHz + */ +static const char * const ak4458_dem_select_texts[] = { + "44.1kHz", "OFF", "48kHz", "32kHz" +}; + +/* + * SSLOW, SD, SLOW bits Digital Filter Setting + * 0, 0, 0 : Sharp Roll-Off Filter + * 0, 0, 1 : Slow Roll-Off Filter + * 0, 1, 0 : Short delay Sharp Roll-Off Filter + * 0, 1, 1 : Short delay Slow Roll-Off Filter + * 1, *, * : Super Slow Roll-Off Filter + */ +static const char * const ak4458_digfil_select_texts[] = { + "Sharp Roll-Off Filter", + "Slow Roll-Off Filter", + "Short delay Sharp Roll-Off Filter", + "Short delay Slow Roll-Off Filter", + "Super Slow Roll-Off Filter" +}; + +/* + * DZFB: Inverting Enable of DZF + * 0: DZF goes H at Zero Detection + * 1: DZF goes L at Zero Detection + */ +static const char * const ak4458_dzfb_select_texts[] = {"H", "L"}; + +/* + * SC1-0 bits: Sound Mode Setting + * 0 0 : Sound Mode 0 + * 0 1 : Sound Mode 1 + * 1 0 : Sound Mode 2 + * 1 1 : Reserved + */ +static const char * const ak4458_sc_select_texts[] = { + "Sound Mode 0", "Sound Mode 1", "Sound Mode 2" +}; + +/* FIR2-0 bits: FIR Filter Mode Setting */ +static const char * const ak4458_fir_select_texts[] = { + "Mode 0", "Mode 1", "Mode 2", "Mode 3", + "Mode 4", "Mode 5", "Mode 6", "Mode 7", +}; + +/* ATS1-0 bits Attenuation Speed */ +static const char * const ak4458_ats_select_texts[] = { + "4080/fs", "2040/fs", "510/fs", "255/fs", +}; + +/* DIF2 bit Audio Interface Format Setting(BICK fs) */ +static const char * const ak4458_dif_select_texts[] = {"32fs,48fs", "64fs",}; + +static const struct soc_enum ak4458_dac1_dem_enum = + SOC_ENUM_SINGLE(AK4458_01_CONTROL2, 1, + ARRAY_SIZE(ak4458_dem_select_texts), + ak4458_dem_select_texts); +static const struct soc_enum ak4458_dac2_dem_enum = + SOC_ENUM_SINGLE(AK4458_0A_CONTROL6, 0, + ARRAY_SIZE(ak4458_dem_select_texts), + ak4458_dem_select_texts); +static const struct soc_enum ak4458_dac3_dem_enum = + SOC_ENUM_SINGLE(AK4458_0E_CONTROL10, 4, + ARRAY_SIZE(ak4458_dem_select_texts), + ak4458_dem_select_texts); +static const struct soc_enum ak4458_dac4_dem_enum = + SOC_ENUM_SINGLE(AK4458_0E_CONTROL10, 6, + ARRAY_SIZE(ak4458_dem_select_texts), + ak4458_dem_select_texts); +static const struct soc_enum ak4458_digfil_enum = + SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(ak4458_digfil_select_texts), + ak4458_digfil_select_texts); +static const struct soc_enum ak4458_dzfb_enum = + SOC_ENUM_SINGLE(AK4458_02_CONTROL3, 2, + ARRAY_SIZE(ak4458_dzfb_select_texts), + ak4458_dzfb_select_texts); +static const struct soc_enum ak4458_sm_enum = + SOC_ENUM_SINGLE(AK4458_08_SOUND_CONTROL, 0, + ARRAY_SIZE(ak4458_sc_select_texts), + ak4458_sc_select_texts); +static const struct soc_enum ak4458_fir_enum = + SOC_ENUM_SINGLE(AK4458_0C_CONTROL8, 0, + ARRAY_SIZE(ak4458_fir_select_texts), + ak4458_fir_select_texts); +static const struct soc_enum ak4458_ats_enum = + SOC_ENUM_SINGLE(AK4458_0B_CONTROL7, 6, + ARRAY_SIZE(ak4458_ats_select_texts), + ak4458_ats_select_texts); +static const struct soc_enum ak4458_dif_enum = + SOC_ENUM_SINGLE(AK4458_00_CONTROL1, 3, + ARRAY_SIZE(ak4458_dif_select_texts), + ak4458_dif_select_texts); + +static int get_digfil(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + + ucontrol->value.enumerated.item[0] = ak4458->digfil; + + return 0; +} + +static int set_digfil(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + int num; + + num = ucontrol->value.enumerated.item[0]; + if (num > 4) + return -EINVAL; + + ak4458->digfil = num; + + /* write SD bit */ + snd_soc_update_bits(codec, AK4458_01_CONTROL2, + AK4458_SD_MASK, + ((ak4458->digfil & 0x02) << 4)); + + /* write SLOW bit */ + snd_soc_update_bits(codec, AK4458_02_CONTROL3, + AK4458_SLOW_MASK, + (ak4458->digfil & 0x01)); + + /* write SSLOW bit */ + snd_soc_update_bits(codec, AK4458_05_CONTROL4, + AK4458_SSLOW_MASK, + ((ak4458->digfil & 0x04) >> 2)); + + return 0; +} + +static const struct snd_kcontrol_new ak4458_snd_controls[] = { + SOC_DOUBLE_R_TLV("DAC1 Playback Volume", AK4458_03_LCHATT, + AK4458_04_RCHATT, 0, 0xFF, 0, dac_tlv), + SOC_DOUBLE_R_TLV("DAC2 Playback Volume", AK4458_0F_L2CHATT, + AK4458_10_R2CHATT, 0, 0xFF, 0, dac_tlv), + SOC_DOUBLE_R_TLV("DAC3 Playback Volume", AK4458_11_L3CHATT, + AK4458_12_R3CHATT, 0, 0xFF, 0, dac_tlv), + SOC_DOUBLE_R_TLV("DAC4 Playback Volume", AK4458_13_L4CHATT, + AK4458_14_R4CHATT, 0, 0xFF, 0, dac_tlv), + SOC_ENUM("AK4458 De-emphasis Response DAC1", ak4458_dac1_dem_enum), + SOC_ENUM("AK4458 De-emphasis Response DAC2", ak4458_dac2_dem_enum), + SOC_ENUM("AK4458 De-emphasis Response DAC3", ak4458_dac3_dem_enum), + SOC_ENUM("AK4458 De-emphasis Response DAC4", ak4458_dac4_dem_enum), + SOC_ENUM_EXT("AK4458 Digital Filter Setting", ak4458_digfil_enum, + get_digfil, set_digfil), + SOC_ENUM("AK4458 Inverting Enable of DZFB", ak4458_dzfb_enum), + SOC_ENUM("AK4458 Sound Mode", ak4458_sm_enum), + SOC_ENUM("AK4458 FIR Filter Mode Setting", ak4458_fir_enum), + SOC_ENUM("AK4458 Attenuation transition Time Setting", + ak4458_ats_enum), + SOC_ENUM("AK4458 BICK fs Setting", ak4458_dif_enum), +}; + +/* ak4458 dapm widgets */ +static const struct snd_soc_dapm_widget ak4458_dapm_widgets[] = { + SND_SOC_DAPM_DAC("AK4458 DAC1", NULL, AK4458_0A_CONTROL6, 2, 0),/*pw*/ + SND_SOC_DAPM_AIF_IN("AK4458 SDTI", "Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_OUTPUT("AK4458 AOUTA"), + + SND_SOC_DAPM_DAC("AK4458 DAC2", NULL, AK4458_0A_CONTROL6, 3, 0),/*pw*/ + SND_SOC_DAPM_OUTPUT("AK4458 AOUTB"), + + SND_SOC_DAPM_DAC("AK4458 DAC3", NULL, AK4458_0B_CONTROL7, 2, 0),/*pw*/ + SND_SOC_DAPM_OUTPUT("AK4458 AOUTC"), + + SND_SOC_DAPM_DAC("AK4458 DAC4", NULL, AK4458_0B_CONTROL7, 3, 0),/*pw*/ + SND_SOC_DAPM_OUTPUT("AK4458 AOUTD"), +}; + +static const struct snd_soc_dapm_route ak4458_intercon[] = { + {"AK4458 DAC1", NULL, "AK4458 SDTI"}, + {"AK4458 AOUTA", NULL, "AK4458 DAC1"}, + + {"AK4458 DAC2", NULL, "AK4458 SDTI"}, + {"AK4458 AOUTB", NULL, "AK4458 DAC2"}, + + {"AK4458 DAC3", NULL, "AK4458 SDTI"}, + {"AK4458 AOUTC", NULL, "AK4458 DAC3"}, + + {"AK4458 DAC4", NULL, "AK4458 SDTI"}, + {"AK4458 AOUTD", NULL, "AK4458 DAC4"}, +}; + +static int ak4458_rstn_control(struct snd_soc_codec *codec, int bit) +{ + int ret; + + if (bit) + ret = snd_soc_update_bits(codec, + AK4458_00_CONTROL1, + AK4458_RSTN_MASK, + 0x1); + else + ret = snd_soc_update_bits(codec, + AK4458_00_CONTROL1, + AK4458_RSTN_MASK, + 0x0); + return ret; +} + +static int ak4458_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + int pcm_width = max(params_physical_width(params), ak4458->slot_width); + int nfs1; + u8 format; + + nfs1 = params_rate(params); + ak4458->fs = nfs1; + + /* Master Clock Frequency Auto Setting Mode Enable */ + snd_soc_update_bits(codec, AK4458_00_CONTROL1, 0x80, 0x80); + + switch (pcm_width) { + case 16: + if (ak4458->fmt == SND_SOC_DAIFMT_I2S) + format = AK4458_DIF_24BIT_I2S; + else + format = AK4458_DIF_16BIT_LSB; + break; + case 32: + switch (ak4458->fmt) { + case SND_SOC_DAIFMT_I2S: + format = AK4458_DIF_32BIT_I2S; + break; + case SND_SOC_DAIFMT_LEFT_J: + format = AK4458_DIF_32BIT_MSB; + break; + case SND_SOC_DAIFMT_RIGHT_J: + format = AK4458_DIF_32BIT_LSB; + break; + case SND_SOC_DAIFMT_DSP_B: + format = AK4458_DIF_32BIT_MSB; + break; + default: + return -EINVAL; + } + break; + default: + return -EINVAL; + } + + snd_soc_update_bits(codec, AK4458_00_CONTROL1, + AK4458_DIF_MASK, format); + + ak4458_rstn_control(codec, 0); + ak4458_rstn_control(codec, 1); + + return 0; +} + +static int ak4458_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: /* Slave Mode */ + break; + case SND_SOC_DAIFMT_CBM_CFM: /* Master Mode is not supported */ + case SND_SOC_DAIFMT_CBS_CFM: + case SND_SOC_DAIFMT_CBM_CFS: + default: + dev_err(codec->dev, "Master mode unsupported\n"); + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + case SND_SOC_DAIFMT_LEFT_J: + case SND_SOC_DAIFMT_RIGHT_J: + case SND_SOC_DAIFMT_DSP_B: + ak4458->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; + break; + default: + dev_err(codec->dev, "Audio format 0x%02X unsupported\n", + fmt & SND_SOC_DAIFMT_FORMAT_MASK); + return -EINVAL; + } + + ak4458_rstn_control(codec, 0); + ak4458_rstn_control(codec, 1); + + return 0; +} + +static const int att_speed[] = { 4080, 2040, 510, 255 }; + +static int ak4458_set_dai_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + int nfs, ndt, ret, reg; + int ats; + + nfs = ak4458->fs; + + reg = snd_soc_read(codec, AK4458_0B_CONTROL7); + ats = (reg & AK4458_ATS_MASK) >> AK4458_ATS_SHIFT; + + ndt = att_speed[ats] / (nfs / 1000); + + if (mute) { + ret = snd_soc_update_bits(codec, AK4458_01_CONTROL2, 0x01, 1); + mdelay(ndt); + if (ak4458->mute_gpiod) + gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); + } else { + if (ak4458->mute_gpiod) + gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); + ret = snd_soc_update_bits(codec, AK4458_01_CONTROL2, 0x01, 0); + mdelay(ndt); + } + + return 0; +} + +static int ak4458_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, + unsigned int rx_mask, int slots, int slot_width) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + int mode; + + ak4458->slots = slots; + ak4458->slot_width = slot_width; + + switch (slots * slot_width) { + case 128: + mode = AK4458_MODE_TDM128; + break; + case 256: + mode = AK4458_MODE_TDM256; + break; + case 512: + mode = AK4458_MODE_TDM512; + break; + default: + mode = AK4458_MODE_NORMAL; + break; + } + + snd_soc_update_bits(codec, AK4458_0A_CONTROL6, + AK4458_MODE_MASK, + mode); + + return 0; +} + +#define AK4458_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ + SNDRV_PCM_FMTBIT_S24_LE |\ + SNDRV_PCM_FMTBIT_S32_LE) + +static const unsigned int ak4458_rates[] = { + 8000, 11025, 16000, 22050, + 32000, 44100, 48000, 88200, + 96000, 176400, 192000, 352800, + 384000, 705600, 768000, 1411200, + 2822400, +}; + +static const struct snd_pcm_hw_constraint_list ak4458_rate_constraints = { + .count = ARRAY_SIZE(ak4458_rates), + .list = ak4458_rates, +}; + +static int ak4458_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + int ret; + + ret = snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &ak4458_rate_constraints); + + return ret; +} + +static struct snd_soc_dai_ops ak4458_dai_ops = { + .startup = ak4458_startup, + .hw_params = ak4458_hw_params, + .set_fmt = ak4458_set_dai_fmt, + .digital_mute = ak4458_set_dai_mute, + .set_tdm_slot = ak4458_set_tdm_slot, +}; + +static struct snd_soc_dai_driver ak4458_dai = { + .name = "ak4458-aif", + .playback = { + .stream_name = "Playback", + .channels_min = 1, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = AK4458_FORMATS, + }, + .ops = &ak4458_dai_ops, +}; + +static void ak4458_power_off(struct ak4458_priv *ak4458) +{ + if (ak4458->reset_gpiod) { + gpiod_set_value_cansleep(ak4458->reset_gpiod, 0); + usleep_range(1000, 2000); + } +} + +static void ak4458_power_on(struct ak4458_priv *ak4458) +{ + if (ak4458->reset_gpiod) { + gpiod_set_value_cansleep(ak4458->reset_gpiod, 1); + usleep_range(1000, 2000); + } +} + +static void ak4458_init(struct snd_soc_codec *codec) +{ + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + + /* External Mute ON */ + if (ak4458->mute_gpiod) + gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); + + ak4458_power_on(ak4458); + + snd_soc_update_bits(codec, AK4458_00_CONTROL1, + 0x80, 0x80); /* ACKS bit = 1; 10000000 */ + + ak4458_rstn_control(codec, 1); +} + +static int ak4458_probe(struct snd_soc_codec *codec) +{ + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + + ak4458_init(codec); + + ak4458->fs = 48000; + + return 0; +} + +static int ak4458_remove(struct snd_soc_codec *codec) +{ + struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + + ak4458_power_off(ak4458); + + return 0; +} + +#ifdef CONFIG_PM +static int __maybe_unused ak4458_runtime_suspend(struct device *dev) +{ + struct ak4458_priv *ak4458 = dev_get_drvdata(dev); + + regcache_cache_only(ak4458->regmap, true); + + ak4458_power_off(ak4458); + + if (ak4458->mute_gpiod) + gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); + + return 0; +} + +static int __maybe_unused ak4458_runtime_resume(struct device *dev) +{ + struct ak4458_priv *ak4458 = dev_get_drvdata(dev); + + if (ak4458->mute_gpiod) + gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); + + ak4458_power_off(ak4458); + ak4458_power_on(ak4458); + + regcache_cache_only(ak4458->regmap, false); + regcache_mark_dirty(ak4458->regmap); + + return regcache_sync(ak4458->regmap); +} +#endif /* CONFIG_PM */ + +struct snd_soc_codec_driver soc_codec_dev_ak4458 = { + .probe = ak4458_probe, + .remove = ak4458_remove, + .component_driver = { + .controls = ak4458_snd_controls, + .num_controls = ARRAY_SIZE(ak4458_snd_controls), + .dapm_widgets = ak4458_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4458_dapm_widgets), + .dapm_routes = ak4458_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4458_intercon), + }, +}; + +const struct regmap_config ak4458_regmap = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = AK4458_14_R4CHATT, + .reg_defaults = ak4458_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(ak4458_reg_defaults), + .cache_type = REGCACHE_RBTREE, +}; + +const struct dev_pm_ops ak4458_pm = { + SET_RUNTIME_PM_OPS(ak4458_runtime_suspend, ak4458_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +}; + +static int ak4458_i2c_probe(struct i2c_client *i2c) +{ + struct ak4458_priv *ak4458; + int ret; + + ak4458 = devm_kzalloc(&i2c->dev, sizeof(*ak4458), GFP_KERNEL); + if (!ak4458) + return -ENOMEM; + + ak4458->regmap = devm_regmap_init_i2c(i2c, &ak4458_regmap); + if (IS_ERR(ak4458->regmap)) + return PTR_ERR(ak4458->regmap); + + i2c_set_clientdata(i2c, ak4458); + ak4458->dev = &i2c->dev; + + ak4458->reset_gpiod = devm_gpiod_get_optional(ak4458->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ak4458->reset_gpiod)) + return PTR_ERR(ak4458->reset_gpiod); + + ak4458->mute_gpiod = devm_gpiod_get_optional(ak4458->dev, "mute", + GPIOD_OUT_LOW); + if (IS_ERR(ak4458->mute_gpiod)) + return PTR_ERR(ak4458->mute_gpiod); + + ret = snd_soc_register_codec(ak4458->dev, &soc_codec_dev_ak4458, + &ak4458_dai, 1); + if (ret < 0) { + dev_err(ak4458->dev, "Failed to register CODEC: %d\n", ret); + return ret; + } + + pm_runtime_enable(&i2c->dev); + + return 0; +} + +static int ak4458_i2c_remove(struct i2c_client *i2c) +{ + snd_soc_unregister_codec(&i2c->dev); + pm_runtime_disable(&i2c->dev); + + return 0; +} + +static const struct of_device_id ak4458_of_match[] = { + { .compatible = "asahi-kasei,ak4458", }, + { }, +}; + +static struct i2c_driver ak4458_i2c_driver = { + .driver = { + .name = "ak4458", + .pm = &ak4458_pm, + .of_match_table = ak4458_of_match, + }, + .probe_new = ak4458_i2c_probe, + .remove = ak4458_i2c_remove, +}; + +module_i2c_driver(ak4458_i2c_driver); + +MODULE_AUTHOR("Junichi Wakasugi "); +MODULE_AUTHOR("Mihai Serban "); +MODULE_DESCRIPTION("ASoC AK4458 DAC driver"); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/ak4458.h b/sound/soc/codecs/ak4458.h new file mode 100644 index 000000000000..16d9d22a413a --- /dev/null +++ b/sound/soc/codecs/ak4458.h @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Audio driver for AK4458 + * + * Copyright (C) 2016 Asahi Kasei Microdevices Corporation + * Copyright 2018 NXP + */ + +#ifndef _AK4458_H +#define _AK4458_H + +#include + +/* Settings */ + +#define AK4458_00_CONTROL1 0x00 +#define AK4458_01_CONTROL2 0x01 +#define AK4458_02_CONTROL3 0x02 +#define AK4458_03_LCHATT 0x03 +#define AK4458_04_RCHATT 0x04 +#define AK4458_05_CONTROL4 0x05 +#define AK4458_06_DSD1 0x06 +#define AK4458_07_CONTROL5 0x07 +#define AK4458_08_SOUND_CONTROL 0x08 +#define AK4458_09_DSD2 0x09 +#define AK4458_0A_CONTROL6 0x0A +#define AK4458_0B_CONTROL7 0x0B +#define AK4458_0C_CONTROL8 0x0C +#define AK4458_0D_CONTROL9 0x0D +#define AK4458_0E_CONTROL10 0x0E +#define AK4458_0F_L2CHATT 0x0F +#define AK4458_10_R2CHATT 0x10 +#define AK4458_11_L3CHATT 0x11 +#define AK4458_12_R3CHATT 0x12 +#define AK4458_13_L4CHATT 0x13 +#define AK4458_14_R4CHATT 0x14 + +/* Bitfield Definitions */ + +/* AK4458_00_CONTROL1 (0x00) Fields + * Addr Register Name D7 D6 D5 D4 D3 D2 D1 D0 + * 00H Control 1 ACKS 0 0 0 DIF2 DIF1 DIF0 RSTN + */ + +/* Digital Filter (SD, SLOW, SSLOW) */ +#define AK4458_SD_MASK GENMASK(5, 5) +#define AK4458_SLOW_MASK GENMASK(0, 0) +#define AK4458_SSLOW_MASK GENMASK(0, 0) + +/* DIF2 1 0 + * x 1 0 MSB justified Figure 3 (default) + * x 1 1 I2S Compliment Figure 4 + */ +#define AK4458_DIF_SHIFT 1 +#define AK4458_DIF_MASK GENMASK(3, 1) + +#define AK4458_DIF_16BIT_LSB (0 << 1) +#define AK4458_DIF_24BIT_I2S (3 << 1) +#define AK4458_DIF_32BIT_LSB (5 << 1) +#define AK4458_DIF_32BIT_MSB (6 << 1) +#define AK4458_DIF_32BIT_I2S (7 << 1) + +/* AK4458_00_CONTROL1 (0x00) D0 bit */ +#define AK4458_RSTN_MASK GENMASK(0, 0) +#define AK4458_RSTN (0x1 << 0) + +/* AK4458_0A_CONTROL6 Mode bits */ +#define AK4458_MODE_SHIFT 6 +#define AK4458_MODE_MASK GENMASK(7, 6) +#define AK4458_MODE_NORMAL (0 << AK4458_MODE_SHIFT) +#define AK4458_MODE_TDM128 (1 << AK4458_MODE_SHIFT) +#define AK4458_MODE_TDM256 (2 << AK4458_MODE_SHIFT) +#define AK4458_MODE_TDM512 (3 << AK4458_MODE_SHIFT) + +/* DAC Digital attenuator transition time setting + * Table 19 + * Mode ATS1 ATS2 ATT speed + * 0 0 0 4080/fs + * 1 0 1 2040/fs + * 2 1 0 510/fs + * 3 1 1 255/fs + * */ +#define AK4458_ATS_SHIFT 6 +#define AK4458_ATS_MASK GENMASK(7, 6) + +#endif /* _AK4458_H */ From 17e2304f0ad31d3f9bba4285b7024bf3c3626600 Mon Sep 17 00:00:00 2001 From: Cosmin-Gabriel Samoila Date: Wed, 14 Feb 2018 15:21:07 +0200 Subject: [PATCH 295/942] ASoC: ak4458: Add bindings for AK4458 DAC Document the bindings for AK4458 DAC Signed-off-by: Cosmin-Gabriel Samoila Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/ak4458.txt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ak4458.txt diff --git a/Documentation/devicetree/bindings/sound/ak4458.txt b/Documentation/devicetree/bindings/sound/ak4458.txt new file mode 100644 index 000000000000..7839be78448d --- /dev/null +++ b/Documentation/devicetree/bindings/sound/ak4458.txt @@ -0,0 +1,23 @@ +AK4458 audio DAC + +This device supports I2C mode. + +Required properties: + +- compatible : "asahi-kasei,ak4458" +- reg : The I2C address of the device for I2C + +Optional properties: +- reset-gpios: A GPIO specifier for the power down & reset pin +- mute-gpios: A GPIO specifier for the soft mute pin + +Example: + +&i2c { + ak4458: dac@10 { + compatible = "asahi-kasei,ak4458"; + reg = <0x10>; + reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW> + mute-gpios = <&gpio1 11 GPIO_ACTIVE_HIGH> + }; +}; From 920884777480739789bb94ce8aeab1bc1de30dc2 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 13 Feb 2018 16:29:33 +0200 Subject: [PATCH 296/942] ASoC: ak5558: Add support for AK5558 ADC driver AK5558 is a 32-bit, 768 kHZ sampling, differential input ADC for digital audio systems. Datasheet is available at: https://www.akm.com/akm/en/file/datasheet/AK5558VN.pdf Initial patch includes support for normal and TDM modes. Reviewed-by: Andy Shevchenko Reviewed-by: Fabio Estevam Signed-off-by: Junichi Wakasugi [initial coding for 3.18 kernel] Signed-off-by: Mihai Serban [cleanups and porting to 4.9 kernel] Signed-off-by: Shengjiu Wang [tdm support] Signed-off-by: Daniel Baluta [pm support, cleanups and porting to latest kernel] Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/ak5558.c | 417 ++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/ak5558.h | 52 +++++ 4 files changed, 477 insertions(+) create mode 100644 sound/soc/codecs/ak5558.c create mode 100644 sound/soc/codecs/ak5558.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..c29728c5f4e0 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -42,6 +42,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_AK4642 if I2C select SND_SOC_AK4671 if I2C select SND_SOC_AK5386 + select SND_SOC_AK5558 if I2C select SND_SOC_ALC5623 if I2C select SND_SOC_ALC5632 if I2C select SND_SOC_BT_SCO @@ -398,6 +399,11 @@ config SND_SOC_AK4671 config SND_SOC_AK5386 tristate "AKM AK5638 CODEC" +config SND_SOC_AK5558 + tristate "AKM AK5558 CODEC" + depends on I2C + select REGMAP_I2C + config SND_SOC_ALC5623 tristate "Realtek ALC5623 CODEC" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..3e71d40cca19 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -34,6 +34,7 @@ snd-soc-ak4641-objs := ak4641.o snd-soc-ak4642-objs := ak4642.o snd-soc-ak4671-objs := ak4671.o snd-soc-ak5386-objs := ak5386.o +snd-soc-ak5558-objs := ak5558.o snd-soc-arizona-objs := arizona.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-cq93vc-objs := cq93vc.o @@ -277,6 +278,7 @@ obj-$(CONFIG_SND_SOC_AK4641) += snd-soc-ak4641.o obj-$(CONFIG_SND_SOC_AK4642) += snd-soc-ak4642.o obj-$(CONFIG_SND_SOC_AK4671) += snd-soc-ak4671.o obj-$(CONFIG_SND_SOC_AK5386) += snd-soc-ak5386.o +obj-$(CONFIG_SND_SOC_AK5558) += snd-soc-ak5558.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c new file mode 100644 index 000000000000..225173ff4efa --- /dev/null +++ b/sound/soc/codecs/ak5558.c @@ -0,0 +1,417 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Audio driver for AK5558 ADC + * + * Copyright (C) 2015 Asahi Kasei Microdevices Corporation + * Copyright 2018 NXP + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "ak5558.h" + +/* AK5558 Codec Private Data */ +struct ak5558_priv { + struct snd_soc_codec codec; + struct regmap *regmap; + struct i2c_client *i2c; + struct gpio_desc *reset_gpiod; /* Reset & Power down GPIO */ + int slots; + int slot_width; +}; + +/* ak5558 register cache & default register settings */ +static const struct reg_default ak5558_reg[] = { + { 0x0, 0xFF }, /* 0x00 AK5558_00_POWER_MANAGEMENT1 */ + { 0x1, 0x01 }, /* 0x01 AK5558_01_POWER_MANAGEMENT2 */ + { 0x2, 0x01 }, /* 0x02 AK5558_02_CONTROL1 */ + { 0x3, 0x00 }, /* 0x03 AK5558_03_CONTROL2 */ + { 0x4, 0x00 }, /* 0x04 AK5558_04_CONTROL3 */ + { 0x5, 0x00 } /* 0x05 AK5558_05_DSD */ +}; + +static const char * const mono_texts[] = { + "8 Slot", "2 Slot", "4 Slot", "1 Slot", +}; + +static const struct soc_enum ak5558_mono_enum[] = { + SOC_ENUM_SINGLE(AK5558_01_POWER_MANAGEMENT2, 1, + ARRAY_SIZE(mono_texts), mono_texts), +}; + +static const char * const digfil_texts[] = { + "Sharp Roll-Off", "Show Roll-Off", + "Short Delay Sharp Roll-Off", "Short Delay Show Roll-Off", +}; + +static const struct soc_enum ak5558_adcset_enum[] = { + SOC_ENUM_SINGLE(AK5558_04_CONTROL3, 0, + ARRAY_SIZE(digfil_texts), digfil_texts), +}; + +static const struct snd_kcontrol_new ak5558_snd_controls[] = { + SOC_ENUM("AK5558 Monaural Mode", ak5558_mono_enum[0]), + SOC_ENUM("AK5558 Digital Filter", ak5558_adcset_enum[0]), +}; + +static const struct snd_soc_dapm_widget ak5558_dapm_widgets[] = { + /* Analog Input */ + SND_SOC_DAPM_INPUT("AIN1"), + SND_SOC_DAPM_INPUT("AIN2"), + SND_SOC_DAPM_INPUT("AIN3"), + SND_SOC_DAPM_INPUT("AIN4"), + SND_SOC_DAPM_INPUT("AIN5"), + SND_SOC_DAPM_INPUT("AIN6"), + SND_SOC_DAPM_INPUT("AIN7"), + SND_SOC_DAPM_INPUT("AIN8"), + + SND_SOC_DAPM_ADC("ADC Ch1", NULL, AK5558_00_POWER_MANAGEMENT1, 0, 0), + SND_SOC_DAPM_ADC("ADC Ch2", NULL, AK5558_00_POWER_MANAGEMENT1, 1, 0), + SND_SOC_DAPM_ADC("ADC Ch3", NULL, AK5558_00_POWER_MANAGEMENT1, 2, 0), + SND_SOC_DAPM_ADC("ADC Ch4", NULL, AK5558_00_POWER_MANAGEMENT1, 3, 0), + SND_SOC_DAPM_ADC("ADC Ch5", NULL, AK5558_00_POWER_MANAGEMENT1, 4, 0), + SND_SOC_DAPM_ADC("ADC Ch6", NULL, AK5558_00_POWER_MANAGEMENT1, 5, 0), + SND_SOC_DAPM_ADC("ADC Ch7", NULL, AK5558_00_POWER_MANAGEMENT1, 6, 0), + SND_SOC_DAPM_ADC("ADC Ch8", NULL, AK5558_00_POWER_MANAGEMENT1, 7, 0), + + SND_SOC_DAPM_AIF_OUT("SDTO", "Capture", 0, SND_SOC_NOPM, 0, 0), +}; + +static const struct snd_soc_dapm_route ak5558_intercon[] = { + {"ADC Ch1", NULL, "AIN1"}, + {"SDTO", NULL, "ADC Ch1"}, + + {"ADC Ch2", NULL, "AIN2"}, + {"SDTO", NULL, "ADC Ch2"}, + + {"ADC Ch3", NULL, "AIN3"}, + {"SDTO", NULL, "ADC Ch3"}, + + {"ADC Ch4", NULL, "AIN4"}, + {"SDTO", NULL, "ADC Ch4"}, + + {"ADC Ch5", NULL, "AIN5"}, + {"SDTO", NULL, "ADC Ch5"}, + + {"ADC Ch6", NULL, "AIN6"}, + {"SDTO", NULL, "ADC Ch6"}, + + {"ADC Ch7", NULL, "AIN7"}, + {"SDTO", NULL, "ADC Ch7"}, + + {"ADC Ch8", NULL, "AIN8"}, + {"SDTO", NULL, "ADC Ch8"}, +}; + +static int ak5558_set_mcki(struct snd_soc_codec *codec) +{ + return snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_CKS, + AK5558_CKS_AUTO); +} + +static int ak5558_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + u8 bits; + int pcm_width = max(params_physical_width(params), ak5558->slot_width); + + /* set master/slave audio interface */ + bits = snd_soc_read(codec, AK5558_02_CONTROL1); + bits &= ~AK5558_BITS; + + switch (pcm_width) { + case 16: + bits |= AK5558_DIF_24BIT_MODE; + break; + case 32: + bits |= AK5558_DIF_32BIT_MODE; + break; + default: + return -EINVAL; + } + + snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_BITS, bits); + + return 0; +} + +static int ak5558_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) +{ + struct snd_soc_codec *codec = dai->codec; + u8 format; + + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBS_CFS: + break; + case SND_SOC_DAIFMT_CBM_CFM: + break; + case SND_SOC_DAIFMT_CBS_CFM: + case SND_SOC_DAIFMT_CBM_CFS: + default: + dev_err(dai->dev, "Clock mode unsupported"); + return -EINVAL; + } + + /* set master/slave audio interface */ + format = snd_soc_read(codec, AK5558_02_CONTROL1); + format &= ~AK5558_DIF; + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + format |= AK5558_DIF_I2S_MODE; + break; + case SND_SOC_DAIFMT_LEFT_J: + format |= AK5558_DIF_MSB_MODE; + break; + case SND_SOC_DAIFMT_DSP_B: + format |= AK5558_DIF_MSB_MODE; + break; + default: + return -EINVAL; + } + + snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_DIF, format); + + return 0; +} + +static int ak5558_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, + unsigned int rx_mask, int slots, + int slot_width) +{ + struct snd_soc_codec *codec = dai->codec; + struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + int tdm_mode; + + ak5558->slots = slots; + ak5558->slot_width = slot_width; + + switch (slots * slot_width) { + case 128: + tdm_mode = AK5558_MODE_TDM128; + break; + case 256: + tdm_mode = AK5558_MODE_TDM256; + break; + case 512: + tdm_mode = AK5558_MODE_TDM512; + break; + default: + tdm_mode = AK5558_MODE_NORMAL; + break; + } + + snd_soc_update_bits(codec, AK5558_03_CONTROL2, AK5558_MODE_BITS, + tdm_mode); + return 0; +} + +#define AK5558_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ + SNDRV_PCM_FMTBIT_S24_LE |\ + SNDRV_PCM_FMTBIT_S32_LE) + +static const unsigned int ak5558_rates[] = { + 8000, 11025, 16000, 22050, + 32000, 44100, 48000, 88200, + 96000, 176400, 192000, 352800, + 384000, 705600, 768000, 1411200, + 2822400, +}; + +static const struct snd_pcm_hw_constraint_list ak5558_rate_constraints = { + .count = ARRAY_SIZE(ak5558_rates), + .list = ak5558_rates, +}; + +static int ak5558_startup(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + return snd_pcm_hw_constraint_list(substream->runtime, 0, + SNDRV_PCM_HW_PARAM_RATE, + &ak5558_rate_constraints); +} + +static struct snd_soc_dai_ops ak5558_dai_ops = { + .startup = ak5558_startup, + .hw_params = ak5558_hw_params, + + .set_fmt = ak5558_set_dai_fmt, + .set_tdm_slot = ak5558_set_tdm_slot, +}; + +static struct snd_soc_dai_driver ak5558_dai = { + .name = "ak5558-aif", + .capture = { + .stream_name = "Capture", + .channels_min = 1, + .channels_max = 8, + .rates = SNDRV_PCM_RATE_KNOT, + .formats = AK5558_FORMATS, + }, + .ops = &ak5558_dai_ops, +}; + +static void ak5558_power_off(struct ak5558_priv *ak5558) +{ + if (!ak5558->reset_gpiod) + return; + + gpiod_set_value_cansleep(ak5558->reset_gpiod, 0); + usleep_range(1000, 2000); +} + +static void ak5558_power_on(struct ak5558_priv *ak5558) +{ + if (!ak5558->reset_gpiod) + return; + + gpiod_set_value_cansleep(ak5558->reset_gpiod, 1); + usleep_range(1000, 2000); +} + +static int ak5558_probe(struct snd_soc_codec *codec) +{ + struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + + ak5558_power_on(ak5558); + return ak5558_set_mcki(codec); +} + +static int ak5558_remove(struct snd_soc_codec *codec) +{ + struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + + ak5558_power_off(ak5558); + + return 0; +} + +static int __maybe_unused ak5558_runtime_suspend(struct device *dev) +{ + struct ak5558_priv *ak5558 = dev_get_drvdata(dev); + + regcache_cache_only(ak5558->regmap, true); + ak5558_power_off(ak5558); + + return 0; +} + +static int __maybe_unused ak5558_runtime_resume(struct device *dev) +{ + struct ak5558_priv *ak5558 = dev_get_drvdata(dev); + + ak5558_power_off(ak5558); + ak5558_power_on(ak5558); + + regcache_cache_only(ak5558->regmap, false); + regcache_mark_dirty(ak5558->regmap); + + return regcache_sync(ak5558->regmap); +} + +const struct dev_pm_ops ak5558_pm = { + SET_RUNTIME_PM_OPS(ak5558_runtime_suspend, ak5558_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) +}; + +struct snd_soc_codec_driver soc_codec_dev_ak5558 = { + .probe = ak5558_probe, + .remove = ak5558_remove, + + .component_driver = { + .controls = ak5558_snd_controls, + .num_controls = ARRAY_SIZE(ak5558_snd_controls), + .dapm_widgets = ak5558_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak5558_dapm_widgets), + .dapm_routes = ak5558_intercon, + .num_dapm_routes = ARRAY_SIZE(ak5558_intercon), + }, +}; + +static const struct regmap_config ak5558_regmap = { + .reg_bits = 8, + .val_bits = 8, + + .max_register = AK5558_05_DSD, + .reg_defaults = ak5558_reg, + .num_reg_defaults = ARRAY_SIZE(ak5558_reg), + .cache_type = REGCACHE_RBTREE, +}; + +static int ak5558_i2c_probe(struct i2c_client *i2c) +{ + struct ak5558_priv *ak5558; + int ret = 0; + + ak5558 = devm_kzalloc(&i2c->dev, sizeof(*ak5558), GFP_KERNEL); + if (!ak5558) + return -ENOMEM; + + ak5558->regmap = devm_regmap_init_i2c(i2c, &ak5558_regmap); + if (IS_ERR(ak5558->regmap)) + return PTR_ERR(ak5558->regmap); + + i2c_set_clientdata(i2c, ak5558); + ak5558->i2c = i2c; + + ak5558->reset_gpiod = devm_gpiod_get_optional(&i2c->dev, "reset", + GPIOD_OUT_LOW); + if (IS_ERR(ak5558->reset_gpiod)) + return PTR_ERR(ak5558->reset_gpiod); + + ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak5558, + &ak5558_dai, 1); + if (ret) + return ret; + + pm_runtime_enable(&i2c->dev); + + return 0; +} + +static int ak5558_i2c_remove(struct i2c_client *i2c) +{ + snd_soc_unregister_codec(&i2c->dev); + pm_runtime_disable(&i2c->dev); + + return 0; +} + +static const struct of_device_id ak5558_i2c_dt_ids[] = { + { .compatible = "asahi-kasei,ak5558"}, + { } +}; + +static struct i2c_driver ak5558_i2c_driver = { + .driver = { + .name = "ak5558", + .of_match_table = of_match_ptr(ak5558_i2c_dt_ids), + .pm = &ak5558_pm, + }, + .probe_new = ak5558_i2c_probe, + .remove = ak5558_i2c_remove, +}; + +module_i2c_driver(ak5558_i2c_driver); + +MODULE_AUTHOR("Junichi Wakasugi "); +MODULE_AUTHOR("Mihai Serban "); +MODULE_DESCRIPTION("ASoC AK5558 ADC driver"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/ak5558.h b/sound/soc/codecs/ak5558.h new file mode 100644 index 000000000000..7c9e37374f39 --- /dev/null +++ b/sound/soc/codecs/ak5558.h @@ -0,0 +1,52 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Audio driver header for AK5558 + * + * Copyright (C) 2016 Asahi Kasei Microdevices Corporation + * Copyright 2018 NXP + */ + +#ifndef _AK5558_H +#define _AK5558_H + +#define AK5558_00_POWER_MANAGEMENT1 0x00 +#define AK5558_01_POWER_MANAGEMENT2 0x01 +#define AK5558_02_CONTROL1 0x02 +#define AK5558_03_CONTROL2 0x03 +#define AK5558_04_CONTROL3 0x04 +#define AK5558_05_DSD 0x05 + +/* AK5558_02_CONTROL1 fields */ +#define AK5558_DIF GENMASK(1, 1) +#define AK5558_DIF_MSB_MODE (0 << 1) +#define AK5558_DIF_I2S_MODE (1 << 1) + +#define AK5558_BITS GENMASK(2, 2) +#define AK5558_DIF_24BIT_MODE (0 << 2) +#define AK5558_DIF_32BIT_MODE (1 << 2) + +#define AK5558_CKS GENMASK(6, 3) +#define AK5558_CKS_128FS_192KHZ (0 << 3) +#define AK5558_CKS_192FS_192KHZ (1 << 3) +#define AK5558_CKS_256FS_48KHZ (2 << 3) +#define AK5558_CKS_256FS_96KHZ (3 << 3) +#define AK5558_CKS_384FS_96KHZ (4 << 3) +#define AK5558_CKS_384FS_48KHZ (5 << 3) +#define AK5558_CKS_512FS_48KHZ (6 << 3) +#define AK5558_CKS_768FS_48KHZ (7 << 3) +#define AK5558_CKS_64FS_384KHZ (8 << 3) +#define AK5558_CKS_32FS_768KHZ (9 << 3) +#define AK5558_CKS_96FS_384KHZ (10 << 3) +#define AK5558_CKS_48FS_768KHZ (11 << 3) +#define AK5558_CKS_64FS_768KHZ (12 << 3) +#define AK5558_CKS_1024FS_16KHZ (13 << 3) +#define AK5558_CKS_AUTO (15 << 3) + +/* AK5558_03_CONTROL2 fields */ +#define AK5558_MODE_BITS GENMASK(6, 5) +#define AK5558_MODE_NORMAL (0 << 5) +#define AK5558_MODE_TDM128 (1 << 5) +#define AK5558_MODE_TDM256 (2 << 5) +#define AK5558_MODE_TDM512 (3 << 5) + +#endif From af0424e44c180d66c2ddfb0a99c52382de8f69f8 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 13 Feb 2018 16:29:34 +0200 Subject: [PATCH 297/942] ASoC: ak5558: Add bindings for AK5558 ADC Document the bindings for AK5558 ADC. Reviewed-by: Rob Herring Signed-off-by: Daniel Baluta Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/ak5558.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/ak5558.txt diff --git a/Documentation/devicetree/bindings/sound/ak5558.txt b/Documentation/devicetree/bindings/sound/ak5558.txt new file mode 100644 index 000000000000..7d67ca6ced80 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/ak5558.txt @@ -0,0 +1,22 @@ +AK5558 8 channel differential 32-bit delta-sigma ADC + +This device supports I2C mode only. + +Required properties: + +- compatible : "asahi-kasei,ak5558" +- reg : The I2C address of the device. + +Optional properties: + +- reset-gpios: A GPIO specifier for the power down & reset pin. + +Example: + +&i2c { + ak5558: adc@10 { + compatible = "asahi-kasei,ak5558"; + reg = <0x10>; + reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>; + }; +}; From 5ab2ba931255d8bf03009c06d58dce97de32797c Mon Sep 17 00:00:00 2001 From: Sara Sharon Date: Tue, 29 Mar 2016 10:56:57 +0300 Subject: [PATCH 298/942] iwlwifi: mvm: fix security bug in PN checking A previous patch allowed the same PN for packets originating from the same AMSDU by copying PN only for the last packet in the series. This however is bogus since we cannot assume the last frame will be received on the same queue, and if it is received on a different ueue we will end up not incrementing the PN and possibly let the next packet to have the same PN and pass through. Change the logic instead to driver explicitly indicate for the second sub frame and on to be allowed to have the same PN as the first subframe. Indicate it to mac80211 as well for the fallback queue. Fixes: f1ae02b186d9 ("iwlwifi: mvm: allow same PN for de-aggregated AMSDU") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c index a3f7c1bf3cc8..580de5851fc7 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c @@ -71,6 +71,7 @@ static inline int iwl_mvm_check_pn(struct iwl_mvm *mvm, struct sk_buff *skb, struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct ieee80211_rx_status *stats = IEEE80211_SKB_RXCB(skb); struct iwl_mvm_key_pn *ptk_pn; + int res; u8 tid, keyidx; u8 pn[IEEE80211_CCMP_PN_LEN]; u8 *extiv; @@ -127,12 +128,13 @@ static inline int iwl_mvm_check_pn(struct iwl_mvm *mvm, struct sk_buff *skb, pn[4] = extiv[1]; pn[5] = extiv[0]; - if (memcmp(pn, ptk_pn->q[queue].pn[tid], - IEEE80211_CCMP_PN_LEN) <= 0) + res = memcmp(pn, ptk_pn->q[queue].pn[tid], IEEE80211_CCMP_PN_LEN); + if (res < 0) + return -1; + if (!res && !(stats->flag & RX_FLAG_ALLOW_SAME_PN)) return -1; - if (!(stats->flag & RX_FLAG_AMSDU_MORE)) - memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN); + memcpy(ptk_pn->q[queue].pn[tid], pn, IEEE80211_CCMP_PN_LEN); stats->flag |= RX_FLAG_PN_VALIDATED; return 0; @@ -314,28 +316,21 @@ static void iwl_mvm_rx_csum(struct ieee80211_sta *sta, } /* - * returns true if a packet outside BA session is a duplicate and - * should be dropped + * returns true if a packet is a duplicate and should be dropped. + * Updates AMSDU PN tracking info */ -static bool iwl_mvm_is_nonagg_dup(struct ieee80211_sta *sta, int queue, - struct ieee80211_rx_status *rx_status, - struct ieee80211_hdr *hdr, - struct iwl_rx_mpdu_desc *desc) +static bool iwl_mvm_is_dup(struct ieee80211_sta *sta, int queue, + struct ieee80211_rx_status *rx_status, + struct ieee80211_hdr *hdr, + struct iwl_rx_mpdu_desc *desc) { struct iwl_mvm_sta *mvm_sta; struct iwl_mvm_rxq_dup_data *dup_data; - u8 baid, tid, sub_frame_idx; + u8 tid, sub_frame_idx; if (WARN_ON(IS_ERR_OR_NULL(sta))) return false; - baid = (le32_to_cpu(desc->reorder_data) & - IWL_RX_MPDU_REORDER_BAID_MASK) >> - IWL_RX_MPDU_REORDER_BAID_SHIFT; - - if (baid != IWL_RX_REORDER_DATA_INVALID_BAID) - return false; - mvm_sta = iwl_mvm_sta_from_mac80211(sta); dup_data = &mvm_sta->dup_data[queue]; @@ -365,6 +360,12 @@ static bool iwl_mvm_is_nonagg_dup(struct ieee80211_sta *sta, int queue, dup_data->last_sub_frame[tid] >= sub_frame_idx)) return true; + /* Allow same PN as the first subframe for following sub frames */ + if (dup_data->last_seq[tid] == hdr->seq_ctrl && + sub_frame_idx > dup_data->last_sub_frame[tid] && + desc->mac_flags2 & IWL_RX_MPDU_MFLG2_AMSDU) + rx_status->flag |= RX_FLAG_ALLOW_SAME_PN; + dup_data->last_seq[tid] = hdr->seq_ctrl; dup_data->last_sub_frame[tid] = sub_frame_idx; @@ -971,7 +972,7 @@ void iwl_mvm_rx_mpdu_mq(struct iwl_mvm *mvm, struct napi_struct *napi, if (ieee80211_is_data(hdr->frame_control)) iwl_mvm_rx_csum(sta, skb, desc); - if (iwl_mvm_is_nonagg_dup(sta, queue, rx_status, hdr, desc)) { + if (iwl_mvm_is_dup(sta, queue, rx_status, hdr, desc)) { kfree_skb(skb); goto out; } From fc07bd8ce19bff9e7479c04077ddb5957d1a27be Mon Sep 17 00:00:00 2001 From: Sara Sharon Date: Thu, 21 Dec 2017 15:05:28 +0200 Subject: [PATCH 299/942] iwlwifi: mvm: fix IBSS for devices that support station type API In IBSS, the mac80211 sets the cab_queue to be invalid. However, the multicast station uses it, so we need to override it. A previous patch did it, but it was nested inside the if's and was applied only for legacy FWs that don't support the new station type API, instead of being applied for all paths. In addition, add a missing NL80211_IFTYPE_ADHOC to the initialization of the queues in iwl_mvm_mac_ctxt_init() Fixes: ee48b72211f8 ("iwlwifi: mvm: support ibss in dqa mode") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho --- .../net/wireless/intel/iwlwifi/mvm/mac-ctxt.c | 3 ++- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 24 +++++++++---------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c index 2f22e14e00fe..8ba16fc24e3a 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c @@ -438,7 +438,8 @@ int iwl_mvm_mac_ctxt_init(struct iwl_mvm *mvm, struct ieee80211_vif *vif) } /* Allocate the CAB queue for softAP and GO interfaces */ - if (vif->type == NL80211_IFTYPE_AP) { + if (vif->type == NL80211_IFTYPE_AP || + vif->type == NL80211_IFTYPE_ADHOC) { /* * For TVQM this will be overwritten later with the FW assigned * queue value (when queue is enabled). diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index 6b2674e02606..dbd2ba2bb714 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -2052,6 +2052,17 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) vif->type != NL80211_IFTYPE_ADHOC)) return -ENOTSUPP; + /* + * In IBSS, ieee80211_check_queues() sets the cab_queue to be + * invalid, so make sure we use the queue we want. + * Note that this is done here as we want to avoid making DQA + * changes in mac80211 layer. + */ + if (vif->type == NL80211_IFTYPE_ADHOC) { + vif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE; + mvmvif->cab_queue = vif->cab_queue; + } + /* * While in previous FWs we had to exclude cab queue from TFD queue * mask, now it is needed as any other queue. @@ -2083,20 +2094,9 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) timeout); mvmvif->cab_queue = queue; } else if (!fw_has_api(&mvm->fw->ucode_capa, - IWL_UCODE_TLV_API_STA_TYPE)) { - /* - * In IBSS, ieee80211_check_queues() sets the cab_queue to be - * invalid, so make sure we use the queue we want. - * Note that this is done here as we want to avoid making DQA - * changes in mac80211 layer. - */ - if (vif->type == NL80211_IFTYPE_ADHOC) { - vif->cab_queue = IWL_MVM_DQA_GCAST_QUEUE; - mvmvif->cab_queue = vif->cab_queue; - } + IWL_UCODE_TLV_API_STA_TYPE)) iwl_mvm_enable_txq(mvm, vif->cab_queue, vif->cab_queue, 0, &cfg, timeout); - } return 0; } From 4437ba7ee7de7e71d11deb91c87a370e4ffd2601 Mon Sep 17 00:00:00 2001 From: Emmanuel Grumbach Date: Wed, 27 Dec 2017 08:58:02 +0200 Subject: [PATCH 300/942] iwlwifi: pcie: don't warn if we use all the transmit pointers Our Transmit Frame Descriptor (TFD) is a DMA descriptor that includes several pointers to be able to transmit a packet which is not physically contiguous. Depending on the hardware being use, we can have 20 or 25 pointers in a single TFD. In both cases, it is more than enough and it is quite hard to hit this limit. It has been reported that when using specific applications (Ktorrent), we can actually use all the pointers and then a long standing bug showed up. When we free the TFD, we check its number of valid pointers and make sure it doesn't exceed the number of pointers the hardware support. This check had an off by one bug: it is perfectly valid to free the 20 pointers if the TFD has 20 pointers. Fix that. https://bugzilla.kernel.org/show_bug.cgi?id=197981 Signed-off-by: Emmanuel Grumbach Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c | 2 +- drivers/net/wireless/intel/iwlwifi/pcie/tx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c index 6d0a907d5ba5..fabae0f60683 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx-gen2.c @@ -147,7 +147,7 @@ static void iwl_pcie_gen2_tfd_unmap(struct iwl_trans *trans, /* Sanity check on number of chunks */ num_tbs = iwl_pcie_gen2_get_num_tbs(trans, tfd); - if (num_tbs >= trans_pcie->max_tbs) { + if (num_tbs > trans_pcie->max_tbs) { IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); return; } diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c index 3f85713c41dc..1a566287993d 100644 --- a/drivers/net/wireless/intel/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/pcie/tx.c @@ -378,7 +378,7 @@ static void iwl_pcie_tfd_unmap(struct iwl_trans *trans, /* Sanity check on number of chunks */ num_tbs = iwl_pcie_tfd_get_num_tbs(trans, tfd); - if (num_tbs >= trans_pcie->max_tbs) { + if (num_tbs > trans_pcie->max_tbs) { IWL_ERR(trans, "Too many chunks: %i\n", num_tbs); /* @todo issue fatal error, it is quite serious situation */ return; From 71ca54b6e87df90ecab3ce1968d60543750c7507 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Fri, 16 Feb 2018 21:55:28 +0800 Subject: [PATCH 301/942] ASoC: ak4458: ak4458_regmap can be static Fixes: 08660086eff9 ("ASoC: ak4458: Add support for AK4458 DAC driver") Signed-off-by: Fengguang Wu Signed-off-by: Mark Brown --- sound/soc/codecs/ak4458.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index b579cda8e418..c9762162b53f 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -574,7 +574,7 @@ struct snd_soc_codec_driver soc_codec_dev_ak4458 = { }, }; -const struct regmap_config ak4458_regmap = { +static const struct regmap_config ak4458_regmap = { .reg_bits = 8, .val_bits = 8, @@ -584,7 +584,7 @@ const struct regmap_config ak4458_regmap = { .cache_type = REGCACHE_RBTREE, }; -const struct dev_pm_ops ak4458_pm = { +static const struct dev_pm_ops ak4458_pm = { SET_RUNTIME_PM_OPS(ak4458_runtime_suspend, ak4458_runtime_resume, NULL) SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume) From 4b7f7ee2a5f523cf002328c6c02cb3e28a0fb30b Mon Sep 17 00:00:00 2001 From: Shaul Triebitz Date: Thu, 28 Dec 2017 13:28:30 +0200 Subject: [PATCH 302/942] iwlwifi: align timestamp cancel with timestamp start Canceling the periodic timestamp work should be done in the opposite flow to where it was started. This also prevents from sending the MARKER command during the mac_stop flow - causing a false queue hang (FW is no longer there to send a response). Fixes: 93b167c13a3a ("iwlwifi: runtime: sync FW and host clocks for logs") Signed-off-by: Shaul Triebitz Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/fw/init.c | 6 ------ drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 2 ++ drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 2 -- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/init.c b/drivers/net/wireless/intel/iwlwifi/fw/init.c index c39fe84bb4c4..45f21acbd842 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/init.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/init.c @@ -76,9 +76,3 @@ void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans, iwl_fwrt_dbgfs_register(fwrt, dbgfs_dir); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_init); - -void iwl_fw_runtime_exit(struct iwl_fw_runtime *fwrt) -{ - iwl_fw_cancel_timestamp(fwrt); -} -IWL_EXPORT_SYMBOL(iwl_fw_runtime_exit); diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h index 2d28e0804218..89ff02d7c876 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h @@ -90,6 +90,7 @@ #include "fw/runtime.h" #include "fw/dbg.h" #include "fw/acpi.h" +#include "fw/debugfs.h" #define IWL_MVM_MAX_ADDRESSES 5 /* RSSI offset for WkP */ @@ -1783,6 +1784,7 @@ static inline u32 iwl_mvm_flushable_queues(struct iwl_mvm *mvm) static inline void iwl_mvm_stop_device(struct iwl_mvm *mvm) { + iwl_fw_cancel_timestamp(&mvm->fwrt); iwl_free_fw_paging(&mvm->fwrt); clear_bit(IWL_MVM_STATUS_FIRMWARE_RUNNING, &mvm->status); iwl_fw_dump_conf_clear(&mvm->fwrt); diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index 5d525a0023dc..6bb347bf0d6e 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -802,7 +802,6 @@ iwl_op_mode_mvm_start(struct iwl_trans *trans, const struct iwl_cfg *cfg, iwl_mvm_leds_exit(mvm); iwl_mvm_thermal_exit(mvm); out_free: - iwl_fw_runtime_exit(&mvm->fwrt); iwl_fw_flush_dump(&mvm->fwrt); if (iwlmvm_mod_params.init_dbg) @@ -843,7 +842,6 @@ static void iwl_op_mode_mvm_stop(struct iwl_op_mode *op_mode) #if defined(CONFIG_PM_SLEEP) && defined(CONFIG_IWLWIFI_DEBUGFS) kfree(mvm->d3_resume_sram); #endif - iwl_fw_runtime_exit(&mvm->fwrt); iwl_trans_op_mode_leave(mvm->trans); iwl_phy_db_free(mvm->phy_db); From 6b7a5aea71b342ec0593d23b08383e1f33da4c9a Mon Sep 17 00:00:00 2001 From: Naftali Goldstein Date: Thu, 28 Dec 2017 15:53:04 +0200 Subject: [PATCH 303/942] iwlwifi: mvm: always init rs with 20mhz bandwidth rates In AP mode, when a new station associates, rs is initialized immediately upon association completion, before the phy context is updated with the association parameters, so the sta bandwidth might be wider than the phy context allows. To avoid this issue, always initialize rs with 20mhz bandwidth rate, and after authorization, when the phy context is already up-to-date, re-init rs with the correct bw. Signed-off-by: Naftali Goldstein Signed-off-by: Luca Coelho --- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 4 +++ drivers/net/wireless/intel/iwlwifi/mvm/rs.c | 28 +++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index 8aed40a8bc38..08de822c3ef0 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -2682,6 +2682,10 @@ static int iwl_mvm_mac_sta_state(struct ieee80211_hw *hw, /* enable beacon filtering */ WARN_ON(iwl_mvm_enable_beacon_filter(mvm, vif, 0)); + + iwl_mvm_rs_rate_init(mvm, sta, mvmvif->phy_ctxt->channel->band, + false); + ret = 0; } else if (old_state == IEEE80211_STA_AUTHORIZED && new_state == IEEE80211_STA_ASSOC) { diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c index 60abb0084ee5..47f4c7a1d80d 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/rs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/rs.c @@ -2684,7 +2684,8 @@ static void rs_get_initial_rate(struct iwl_mvm *mvm, struct ieee80211_sta *sta, struct iwl_lq_sta *lq_sta, enum nl80211_band band, - struct rs_rate *rate) + struct rs_rate *rate, + bool init) { int i, nentries; unsigned long active_rate; @@ -2738,14 +2739,25 @@ static void rs_get_initial_rate(struct iwl_mvm *mvm, */ if (sta->vht_cap.vht_supported && best_rssi > IWL_RS_LOW_RSSI_THRESHOLD) { - switch (sta->bandwidth) { - case IEEE80211_STA_RX_BW_160: - case IEEE80211_STA_RX_BW_80: - case IEEE80211_STA_RX_BW_40: + /* + * In AP mode, when a new station associates, rs is initialized + * immediately upon association completion, before the phy + * context is updated with the association parameters, so the + * sta bandwidth might be wider than the phy context allows. + * To avoid this issue, always initialize rs with 20mhz + * bandwidth rate, and after authorization, when the phy context + * is already up-to-date, re-init rs with the correct bw. + */ + u32 bw = init ? RATE_MCS_CHAN_WIDTH_20 : rs_bw_from_sta_bw(sta); + + switch (bw) { + case RATE_MCS_CHAN_WIDTH_40: + case RATE_MCS_CHAN_WIDTH_80: + case RATE_MCS_CHAN_WIDTH_160: initial_rates = rs_optimal_rates_vht; nentries = ARRAY_SIZE(rs_optimal_rates_vht); break; - case IEEE80211_STA_RX_BW_20: + case RATE_MCS_CHAN_WIDTH_20: initial_rates = rs_optimal_rates_vht_20mhz; nentries = ARRAY_SIZE(rs_optimal_rates_vht_20mhz); break; @@ -2756,7 +2768,7 @@ static void rs_get_initial_rate(struct iwl_mvm *mvm, active_rate = lq_sta->active_siso_rate; rate->type = LQ_VHT_SISO; - rate->bw = rs_bw_from_sta_bw(sta); + rate->bw = bw; } else if (sta->ht_cap.ht_supported && best_rssi > IWL_RS_LOW_RSSI_THRESHOLD) { initial_rates = rs_optimal_rates_ht; @@ -2839,7 +2851,7 @@ static void rs_initialize_lq(struct iwl_mvm *mvm, tbl = &(lq_sta->lq_info[active_tbl]); rate = &tbl->rate; - rs_get_initial_rate(mvm, sta, lq_sta, band, rate); + rs_get_initial_rate(mvm, sta, lq_sta, band, rate, init); rs_init_optimal_rate(mvm, sta, lq_sta); WARN_ONCE(rate->ant != ANT_A && rate->ant != ANT_B, From e21a5acfab2f13eeffe50d5d5f87c099540a3bf3 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Fri, 16 Feb 2018 14:36:10 +0000 Subject: [PATCH 304/942] ASoC: wm_adsp: Fix some signedness errors in register access base and sysclk_reg should be unsigned int, as that is what regmap takes as a register address. sysclk_mask is used to mask unsigned register values so should be unsigned. sysclk_shift is a shift value so is not allowed to be negative. Signed-off-by: Richard Fitzgerald Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h index 41cc11c19b83..d4042c95315e 100644 --- a/sound/soc/codecs/wm_adsp.h +++ b/sound/soc/codecs/wm_adsp.h @@ -64,10 +64,10 @@ struct wm_adsp { struct regmap *regmap; struct snd_soc_codec *codec; - int base; - int sysclk_reg; - int sysclk_mask; - int sysclk_shift; + unsigned int base; + unsigned int sysclk_reg; + unsigned int sysclk_mask; + unsigned int sysclk_shift; struct list_head alg_regions; From 608a300fc1f0e088446cbef8e13ded686c5172b6 Mon Sep 17 00:00:00 2001 From: Akshu Agrawal Date: Fri, 16 Feb 2018 13:11:13 +0530 Subject: [PATCH 305/942] ASoC: AMD: Add machine driver for ST DA7219 MAX98357 The driver is used for AMD board using DA7219 and MAX98357 codec. TEST=Build, apply grunt_mixer_settings: iotools mmio_write32 0xfed80e40 0x040c40c0 iotools mmio_write32 0xfed80e28 0x10000 iotools mmio_write8 0xfed816de 0xc0 aplay -D plughw:0,0 ./sample_48000.wav -vv aplay -D plughw:0,0 ./sample_44100.wav -vv Signed-off-by: Akshu Agrawal Signed-off-by: Daniel Kurtz Reviewed-by: Alex Deucher Signed-off-by: Mark Brown --- sound/soc/amd/Kconfig | 9 + sound/soc/amd/Makefile | 2 + sound/soc/amd/acp-da7219-max98357a.c | 246 +++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 sound/soc/amd/acp-da7219-max98357a.c diff --git a/sound/soc/amd/Kconfig b/sound/soc/amd/Kconfig index d5838402f667..6cbf9cf4d1a4 100644 --- a/sound/soc/amd/Kconfig +++ b/sound/soc/amd/Kconfig @@ -3,6 +3,15 @@ config SND_SOC_AMD_ACP help This option enables ACP DMA support on AMD platform. +config SND_SOC_AMD_CZ_DA7219MX98357_MACH + tristate "AMD CZ support for DA7219 and MAX9835" + select SND_SOC_DA7219 + select SND_SOC_MAX98357A + select SND_SOC_ADAU7002 + depends on SND_SOC_AMD_ACP && I2C + help + This option enables machine driver for DA7219 and MAX9835. + config SND_SOC_AMD_CZ_RT5645_MACH tristate "AMD CZ support for RT5645" select SND_SOC_RT5645 diff --git a/sound/soc/amd/Makefile b/sound/soc/amd/Makefile index f07fd2e2870a..79b0622fa5d3 100644 --- a/sound/soc/amd/Makefile +++ b/sound/soc/amd/Makefile @@ -1,5 +1,7 @@ acp_audio_dma-objs := acp-pcm-dma.o +snd-soc-acp-da7219mx98357-mach-objs := acp-da7219-max98357a.o snd-soc-acp-rt5645-mach-objs := acp-rt5645.o obj-$(CONFIG_SND_SOC_AMD_ACP) += acp_audio_dma.o +obj-$(CONFIG_SND_SOC_AMD_CZ_DA7219MX98357_MACH) += snd-soc-acp-da7219mx98357-mach.o obj-$(CONFIG_SND_SOC_AMD_CZ_RT5645_MACH) += snd-soc-acp-rt5645-mach.o diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c new file mode 100644 index 000000000000..e51a878890ce --- /dev/null +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -0,0 +1,246 @@ +/* + * Machine driver for AMD ACP Audio engine using DA7219 & MAX98357 codec + * + * Copyright 2017 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../codecs/da7219.h" +#include "../codecs/da7219-aad.h" + +#define CZ_PLAT_CLK 24000000 +#define MCLK_RATE 24576000 +#define DUAL_CHANNEL 2 + +static struct snd_soc_jack cz_jack; + +static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) +{ + int ret; + struct snd_soc_card *card = rtd->card; + struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + + dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name); + + ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, + CZ_PLAT_CLK, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec sysclk: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_pll(codec_dai, 0, DA7219_SYSCLK_PLL, + CZ_PLAT_CLK, MCLK_RATE); + if (ret < 0) { + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); + return ret; + } + + ret = snd_soc_card_jack_new(card, "Headset Jack", + SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | + SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3, + &cz_jack, NULL, 0); + if (ret) { + dev_err(card->dev, "HP jack creation failed %d\n", ret); + return ret; + } + + da7219_aad_jack_det(codec, &cz_jack); + + return 0; +} + +static const unsigned int channels[] = { + DUAL_CHANNEL, +}; + +static const unsigned int rates[] = { + 48000, +}; + +static const struct snd_pcm_hw_constraint_list constraints_rates = { + .count = ARRAY_SIZE(rates), + .list = rates, + .mask = 0, +}; + +static const struct snd_pcm_hw_constraint_list constraints_channels = { + .count = ARRAY_SIZE(channels), + .list = channels, + .mask = 0, +}; + +static int cz_fe_startup(struct snd_pcm_substream *substream) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + + /* + * On this platform for PCM device we support stereo + */ + + runtime->hw.channels_max = DUAL_CHANNEL; + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, + &constraints_channels); + snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, + &constraints_rates); + + return 0; +} + +static struct snd_soc_ops cz_da7219_cap_ops = { + .startup = cz_fe_startup, +}; + +static struct snd_soc_dai_link cz_dai_7219_98357[] = { + { + .name = "amd-da7219-play", + .stream_name = "Playback", + .platform_name = "acp_audio_dma.0.auto", + .cpu_dai_name = "designware-i2s.3.auto", + .codec_dai_name = "da7219-hifi", + .codec_name = "i2c-DLGS7219:00", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM, + .init = cz_da7219_init, + .dpcm_playback = 1, + }, + { + .name = "amd-da7219-cap", + .stream_name = "Capture", + .platform_name = "acp_audio_dma.0.auto", + .cpu_dai_name = "designware-i2s.4.auto", + .codec_dai_name = "da7219-hifi", + .codec_name = "i2c-DLGS7219:00", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM, + .dpcm_capture = 1, + .ops = &cz_da7219_cap_ops, + }, + { + .name = "amd-max98357-play", + .stream_name = "HiFi Playback", + .platform_name = "acp_audio_dma.0.auto", + .cpu_dai_name = "designware-i2s.1.auto", + .codec_dai_name = "HiFi", + .codec_name = "MX98357A:00", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM, + .dpcm_playback = 1, + }, + { + .name = "dmic", + .stream_name = "DMIC Capture", + .platform_name = "acp_audio_dma.0.auto", + .cpu_dai_name = "designware-i2s.2.auto", + .codec_dai_name = "adau7002-hifi", + .codec_name = "ADAU7002:00", + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF + | SND_SOC_DAIFMT_CBM_CFM, + .dpcm_capture = 1, + }, +}; + +static const struct snd_soc_dapm_widget cz_widgets[] = { + SND_SOC_DAPM_HP("Headphones", NULL), + SND_SOC_DAPM_SPK("Speakers", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), +}; + +static const struct snd_soc_dapm_route cz_audio_route[] = { + {"Headphones", NULL, "HPL"}, + {"Headphones", NULL, "HPR"}, + {"MIC", NULL, "Headset Mic"}, + {"Speakers", NULL, "Speaker"}, + {"PDM_DAT", NULL, "Int Mic"}, +}; + +static const struct snd_kcontrol_new cz_mc_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphones"), + SOC_DAPM_PIN_SWITCH("Speakers"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Int Mic"), +}; + +static struct snd_soc_card cz_card = { + .name = "acpd7219m98357", + .owner = THIS_MODULE, + .dai_link = cz_dai_7219_98357, + .num_links = ARRAY_SIZE(cz_dai_7219_98357), + .dapm_widgets = cz_widgets, + .num_dapm_widgets = ARRAY_SIZE(cz_widgets), + .dapm_routes = cz_audio_route, + .num_dapm_routes = ARRAY_SIZE(cz_audio_route), + .controls = cz_mc_controls, + .num_controls = ARRAY_SIZE(cz_mc_controls), +}; + +static int cz_probe(struct platform_device *pdev) +{ + int ret; + struct snd_soc_card *card; + + card = &cz_card; + cz_card.dev = &pdev->dev; + platform_set_drvdata(pdev, card); + ret = devm_snd_soc_register_card(&pdev->dev, &cz_card); + if (ret) { + dev_err(&pdev->dev, + "devm_snd_soc_register_card(%s) failed: %d\n", + cz_card.name, ret); + return ret; + } + return 0; +} + +static const struct acpi_device_id cz_audio_acpi_match[] = { + { "AMD7219", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(acpi, cz_audio_acpi_match); + +static struct platform_driver cz_pcm_driver = { + .driver = { + .name = "cz-da7219-max98357a", + .acpi_match_table = ACPI_PTR(cz_audio_acpi_match), + .pm = &snd_soc_pm_ops, + }, + .probe = cz_probe, +}; + +module_platform_driver(cz_pcm_driver); + +MODULE_AUTHOR("akshu.agrawal@amd.com"); +MODULE_DESCRIPTION("DA7219 & MAX98357A audio support"); +MODULE_LICENSE("GPL v2"); From 97a865d3c3438041913756a08e523fb1d0bbbe3c Mon Sep 17 00:00:00 2001 From: Akshu Agrawal Date: Fri, 16 Feb 2018 13:11:15 +0530 Subject: [PATCH 306/942] ASoC: dwc: Extends DW_I2S_QUIRK_COMP_PARAM1 to playback When we have same register to tell capture and playback capability of a device and we want separate cpu dais for playback and capture. Then, DW_I2S_QUIRK_COMP_PARAM1 is used to enable one capability per dai. Signed-off-by: Akshu Agrawal Reviewed-by: Alex Deucher Signed-off-by: Mark Brown --- sound/soc/dwc/dwc-i2s.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c index e27e21f8569a..65112b9d8588 100644 --- a/sound/soc/dwc/dwc-i2s.c +++ b/sound/soc/dwc/dwc-i2s.c @@ -491,6 +491,10 @@ static int dw_configure_dai(struct dw_i2s_dev *dev, dev->quirks & DW_I2S_QUIRK_COMP_PARAM1) comp1 = comp1 & ~BIT(5); + if (dev->capability & DWC_I2S_PLAY && + dev->quirks & DW_I2S_QUIRK_COMP_PARAM1) + comp1 = comp1 & ~BIT(6); + if (COMP1_TX_ENABLED(comp1)) { dev_dbg(dev->dev, " designware: play supported\n"); idx = COMP1_TX_WORDSIZE_0(comp1); From 50c330973c0c9f1e300b07bbab78d306dcc6e612 Mon Sep 17 00:00:00 2001 From: Robin Murphy Date: Fri, 16 Feb 2018 16:57:56 +0000 Subject: [PATCH 307/942] irqchip/gic-v3-its: Fix misplaced __iomem annotations Save 26 lines worth of Sparse complaints by fixing up this minor mishap. The pointee lies in the __iomem space; the pointer does not. Signed-off-by: Robin Murphy Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 1d3056f53747..94b7d74d519f 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -2495,7 +2495,7 @@ static int its_vpe_set_affinity(struct irq_data *d, static void its_vpe_schedule(struct its_vpe *vpe) { - void * __iomem vlpi_base = gic_data_rdist_vlpi_base(); + void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); u64 val; /* Schedule the VPE */ @@ -2527,7 +2527,7 @@ static void its_vpe_schedule(struct its_vpe *vpe) static void its_vpe_deschedule(struct its_vpe *vpe) { - void * __iomem vlpi_base = gic_data_rdist_vlpi_base(); + void __iomem *vlpi_base = gic_data_rdist_vlpi_base(); u32 count = 1000000; /* 1s! */ bool clean; u64 val; From 9c7be59fc519af9081c46c48f06f2b8fadf55ad8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 16 Feb 2018 10:48:20 +0100 Subject: [PATCH 308/942] libata: Apply NOLPM quirk to Crucial MX100 512GB SSDs Various people have reported the Crucial MX100 512GB model not working with LPM set to min_power. I've now received a report that it also does not work with the new med_power_with_dipm level. It does work with medium_power, but that has no measurable power-savings and given the amount of people being bitten by the other levels not working, this commit just disables LPM altogether. Note all reporters of this have either the 512GB model (max capacity), or are not specifying their SSD's size. So for now this quirk assumes this is a problem with the 512GB model only. Buglink: https://bugzilla.kernel.org/show_bug.cgi?id=89261 Buglink: https://github.com/linrunner/TLP/issues/84 Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 61b09968d032..28cad49fc846 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4530,6 +4530,11 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, + /* The 512GB version of the MX100 has both queued TRIM and LPM issues */ + { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM | + ATA_HORKAGE_NOLPM, }, + /* devices that don't properly handle queued TRIM commands */ { "Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, From 15d9f3d116c02a485441d758d9ca0a2e4f3b30be Mon Sep 17 00:00:00 2001 From: Dennis Zhou Date: Thu, 15 Feb 2018 10:08:14 -0600 Subject: [PATCH 309/942] percpu: match chunk allocator declarations with definitions At some point the function declaration parameters got out of sync with the function definitions in percpu-vm.c and percpu-km.c. This patch makes them match again. Signed-off-by: Dennis Zhou Acked-by: Christoph Lameter Signed-off-by: Tejun Heo --- mm/percpu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 50e7fdf84055..e1ea41002173 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1277,8 +1277,10 @@ static void pcpu_chunk_depopulated(struct pcpu_chunk *chunk, * pcpu_addr_to_page - translate address to physical address * pcpu_verify_alloc_info - check alloc_info is acceptable during init */ -static int pcpu_populate_chunk(struct pcpu_chunk *chunk, int off, int size); -static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size); +static int pcpu_populate_chunk(struct pcpu_chunk *chunk, + int page_start, int page_end); +static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, + int page_start, int page_end); static struct pcpu_chunk *pcpu_create_chunk(void); static void pcpu_destroy_chunk(struct pcpu_chunk *chunk); static struct page *pcpu_addr_to_page(void *addr); From 47504ee04b9241548ae2c28be7d0b01cff3b7aa6 Mon Sep 17 00:00:00 2001 From: Dennis Zhou Date: Fri, 16 Feb 2018 12:07:19 -0600 Subject: [PATCH 310/942] percpu: add __GFP_NORETRY semantics to the percpu balancing path Percpu memory using the vmalloc area based chunk allocator lazily populates chunks by first requesting the full virtual address space required for the chunk and subsequently adding pages as allocations come through. To ensure atomic allocations can succeed, a workqueue item is used to maintain a minimum number of empty pages. In certain scenarios, such as reported in [1], it is possible that physical memory becomes quite scarce which can result in either a rather long time spent trying to find free pages or worse, a kernel panic. This patch adds support for __GFP_NORETRY and __GFP_NOWARN passing them through to the underlying allocators. This should prevent any unnecessary panics potentially caused by the workqueue item. The passing of gfp around is as additional flags rather than a full set of flags. The next patch will change these to caller passed semantics. V2: Added const modifier to gfp flags in the balance path. Removed an extra whitespace. [1] https://lkml.org/lkml/2018/2/12/551 Signed-off-by: Dennis Zhou Suggested-by: Daniel Borkmann Reported-by: syzbot+adb03f3f0bb57ce3acda@syzkaller.appspotmail.com Acked-by: Christoph Lameter Signed-off-by: Tejun Heo --- mm/percpu-km.c | 8 ++++---- mm/percpu-vm.c | 18 +++++++++++------- mm/percpu.c | 44 +++++++++++++++++++++++++++----------------- 3 files changed, 42 insertions(+), 28 deletions(-) diff --git a/mm/percpu-km.c b/mm/percpu-km.c index d2a76642c4ae..0d88d7bd5706 100644 --- a/mm/percpu-km.c +++ b/mm/percpu-km.c @@ -34,7 +34,7 @@ #include static int pcpu_populate_chunk(struct pcpu_chunk *chunk, - int page_start, int page_end) + int page_start, int page_end, gfp_t gfp) { return 0; } @@ -45,18 +45,18 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, /* nada */ } -static struct pcpu_chunk *pcpu_create_chunk(void) +static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp) { const int nr_pages = pcpu_group_sizes[0] >> PAGE_SHIFT; struct pcpu_chunk *chunk; struct page *pages; int i; - chunk = pcpu_alloc_chunk(); + chunk = pcpu_alloc_chunk(gfp); if (!chunk) return NULL; - pages = alloc_pages(GFP_KERNEL, order_base_2(nr_pages)); + pages = alloc_pages(gfp | GFP_KERNEL, order_base_2(nr_pages)); if (!pages) { pcpu_free_chunk(chunk); return NULL; diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c index 9158e5a81391..0af71eb2fff0 100644 --- a/mm/percpu-vm.c +++ b/mm/percpu-vm.c @@ -37,7 +37,7 @@ static struct page **pcpu_get_pages(void) lockdep_assert_held(&pcpu_alloc_mutex); if (!pages) - pages = pcpu_mem_zalloc(pages_size); + pages = pcpu_mem_zalloc(pages_size, 0); return pages; } @@ -73,18 +73,21 @@ static void pcpu_free_pages(struct pcpu_chunk *chunk, * @pages: array to put the allocated pages into, indexed by pcpu_page_idx() * @page_start: page index of the first page to be allocated * @page_end: page index of the last page to be allocated + 1 + * @gfp: allocation flags passed to the underlying allocator * * Allocate pages [@page_start,@page_end) into @pages for all units. * The allocation is for @chunk. Percpu core doesn't care about the * content of @pages and will pass it verbatim to pcpu_map_pages(). */ static int pcpu_alloc_pages(struct pcpu_chunk *chunk, - struct page **pages, int page_start, int page_end) + struct page **pages, int page_start, int page_end, + gfp_t gfp) { - const gfp_t gfp = GFP_KERNEL | __GFP_HIGHMEM; unsigned int cpu, tcpu; int i; + gfp |= GFP_KERNEL | __GFP_HIGHMEM; + for_each_possible_cpu(cpu) { for (i = page_start; i < page_end; i++) { struct page **pagep = &pages[pcpu_page_idx(cpu, i)]; @@ -262,6 +265,7 @@ static void pcpu_post_map_flush(struct pcpu_chunk *chunk, * @chunk: chunk of interest * @page_start: the start page * @page_end: the end page + * @gfp: allocation flags passed to the underlying memory allocator * * For each cpu, populate and map pages [@page_start,@page_end) into * @chunk. @@ -270,7 +274,7 @@ static void pcpu_post_map_flush(struct pcpu_chunk *chunk, * pcpu_alloc_mutex, does GFP_KERNEL allocation. */ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, - int page_start, int page_end) + int page_start, int page_end, gfp_t gfp) { struct page **pages; @@ -278,7 +282,7 @@ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, if (!pages) return -ENOMEM; - if (pcpu_alloc_pages(chunk, pages, page_start, page_end)) + if (pcpu_alloc_pages(chunk, pages, page_start, page_end, gfp)) return -ENOMEM; if (pcpu_map_pages(chunk, pages, page_start, page_end)) { @@ -325,12 +329,12 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, pcpu_free_pages(chunk, pages, page_start, page_end); } -static struct pcpu_chunk *pcpu_create_chunk(void) +static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp) { struct pcpu_chunk *chunk; struct vm_struct **vms; - chunk = pcpu_alloc_chunk(); + chunk = pcpu_alloc_chunk(gfp); if (!chunk) return NULL; diff --git a/mm/percpu.c b/mm/percpu.c index e1ea41002173..f97443d488a8 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -447,10 +447,12 @@ static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits, /** * pcpu_mem_zalloc - allocate memory * @size: bytes to allocate + * @gfp: allocation flags * * Allocate @size bytes. If @size is smaller than PAGE_SIZE, - * kzalloc() is used; otherwise, vzalloc() is used. The returned - * memory is always zeroed. + * kzalloc() is used; otherwise, the equivalent of vzalloc() is used. + * This is to facilitate passing through whitelisted flags. The + * returned memory is always zeroed. * * CONTEXT: * Does GFP_KERNEL allocation. @@ -458,15 +460,16 @@ static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits, * RETURNS: * Pointer to the allocated area on success, NULL on failure. */ -static void *pcpu_mem_zalloc(size_t size) +static void *pcpu_mem_zalloc(size_t size, gfp_t gfp) { if (WARN_ON_ONCE(!slab_is_available())) return NULL; if (size <= PAGE_SIZE) - return kzalloc(size, GFP_KERNEL); + return kzalloc(size, gfp | GFP_KERNEL); else - return vzalloc(size); + return __vmalloc(size, gfp | GFP_KERNEL | __GFP_ZERO, + PAGE_KERNEL); } /** @@ -1154,12 +1157,12 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, return chunk; } -static struct pcpu_chunk *pcpu_alloc_chunk(void) +static struct pcpu_chunk *pcpu_alloc_chunk(gfp_t gfp) { struct pcpu_chunk *chunk; int region_bits; - chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size); + chunk = pcpu_mem_zalloc(pcpu_chunk_struct_size, gfp); if (!chunk) return NULL; @@ -1168,17 +1171,17 @@ static struct pcpu_chunk *pcpu_alloc_chunk(void) region_bits = pcpu_chunk_map_bits(chunk); chunk->alloc_map = pcpu_mem_zalloc(BITS_TO_LONGS(region_bits) * - sizeof(chunk->alloc_map[0])); + sizeof(chunk->alloc_map[0]), gfp); if (!chunk->alloc_map) goto alloc_map_fail; chunk->bound_map = pcpu_mem_zalloc(BITS_TO_LONGS(region_bits + 1) * - sizeof(chunk->bound_map[0])); + sizeof(chunk->bound_map[0]), gfp); if (!chunk->bound_map) goto bound_map_fail; chunk->md_blocks = pcpu_mem_zalloc(pcpu_chunk_nr_blocks(chunk) * - sizeof(chunk->md_blocks[0])); + sizeof(chunk->md_blocks[0]), gfp); if (!chunk->md_blocks) goto md_blocks_fail; @@ -1278,10 +1281,10 @@ static void pcpu_chunk_depopulated(struct pcpu_chunk *chunk, * pcpu_verify_alloc_info - check alloc_info is acceptable during init */ static int pcpu_populate_chunk(struct pcpu_chunk *chunk, - int page_start, int page_end); + int page_start, int page_end, gfp_t gfp); static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int page_start, int page_end); -static struct pcpu_chunk *pcpu_create_chunk(void); +static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp); static void pcpu_destroy_chunk(struct pcpu_chunk *chunk); static struct page *pcpu_addr_to_page(void *addr); static int __init pcpu_verify_alloc_info(const struct pcpu_alloc_info *ai); @@ -1423,7 +1426,7 @@ restart: } if (list_empty(&pcpu_slot[pcpu_nr_slots - 1])) { - chunk = pcpu_create_chunk(); + chunk = pcpu_create_chunk(0); if (!chunk) { err = "failed to allocate new chunk"; goto fail; @@ -1452,7 +1455,7 @@ area_found: page_start, page_end) { WARN_ON(chunk->immutable); - ret = pcpu_populate_chunk(chunk, rs, re); + ret = pcpu_populate_chunk(chunk, rs, re, 0); spin_lock_irqsave(&pcpu_lock, flags); if (ret) { @@ -1563,10 +1566,17 @@ void __percpu *__alloc_reserved_percpu(size_t size, size_t align) * pcpu_balance_workfn - manage the amount of free chunks and populated pages * @work: unused * - * Reclaim all fully free chunks except for the first one. + * Reclaim all fully free chunks except for the first one. This is also + * responsible for maintaining the pool of empty populated pages. However, + * it is possible that this is called when physical memory is scarce causing + * OOM killer to be triggered. We should avoid doing so until an actual + * allocation causes the failure as it is possible that requests can be + * serviced from already backed regions. */ static void pcpu_balance_workfn(struct work_struct *work) { + /* gfp flags passed to underlying allocators */ + const gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; LIST_HEAD(to_free); struct list_head *free_head = &pcpu_slot[pcpu_nr_slots - 1]; struct pcpu_chunk *chunk, *next; @@ -1647,7 +1657,7 @@ retry_pop: chunk->nr_pages) { int nr = min(re - rs, nr_to_pop); - ret = pcpu_populate_chunk(chunk, rs, rs + nr); + ret = pcpu_populate_chunk(chunk, rs, rs + nr, gfp); if (!ret) { nr_to_pop -= nr; spin_lock_irq(&pcpu_lock); @@ -1664,7 +1674,7 @@ retry_pop: if (nr_to_pop) { /* ran out of chunks to populate, create a new one and retry */ - chunk = pcpu_create_chunk(); + chunk = pcpu_create_chunk(gfp); if (chunk) { spin_lock_irq(&pcpu_lock); pcpu_chunk_relocate(chunk, -1); From 554fef1c39ee148623a496e04569dabb11463406 Mon Sep 17 00:00:00 2001 From: Dennis Zhou Date: Fri, 16 Feb 2018 12:09:58 -0600 Subject: [PATCH 311/942] percpu: allow select gfp to be passed to underlying allocators The prior patch added support for passing gfp flags through to the underlying allocators. This patch allows users to pass along gfp flags (currently only __GFP_NORETRY and __GFP_NOWARN) to the underlying allocators. This should allow users to decide if they are ok with failing allocations recovering in a more graceful way. Additionally, gfp passing was done as additional flags in the previous patch. Instead, change this to caller passed semantics. GFP_KERNEL is also removed as the default flag. It continues to be used for internally caused underlying percpu allocations. V2: Removed gfp_percpu_mask in favor of doing it inline. Removed GFP_KERNEL as a default flag for __alloc_percpu_gfp. Signed-off-by: Dennis Zhou Suggested-by: Daniel Borkmann Acked-by: Christoph Lameter Signed-off-by: Tejun Heo --- mm/percpu-km.c | 2 +- mm/percpu-vm.c | 4 ++-- mm/percpu.c | 16 +++++++--------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/mm/percpu-km.c b/mm/percpu-km.c index 0d88d7bd5706..38de70ab1a0d 100644 --- a/mm/percpu-km.c +++ b/mm/percpu-km.c @@ -56,7 +56,7 @@ static struct pcpu_chunk *pcpu_create_chunk(gfp_t gfp) if (!chunk) return NULL; - pages = alloc_pages(gfp | GFP_KERNEL, order_base_2(nr_pages)); + pages = alloc_pages(gfp, order_base_2(nr_pages)); if (!pages) { pcpu_free_chunk(chunk); return NULL; diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c index 0af71eb2fff0..d8078de912de 100644 --- a/mm/percpu-vm.c +++ b/mm/percpu-vm.c @@ -37,7 +37,7 @@ static struct page **pcpu_get_pages(void) lockdep_assert_held(&pcpu_alloc_mutex); if (!pages) - pages = pcpu_mem_zalloc(pages_size, 0); + pages = pcpu_mem_zalloc(pages_size, GFP_KERNEL); return pages; } @@ -86,7 +86,7 @@ static int pcpu_alloc_pages(struct pcpu_chunk *chunk, unsigned int cpu, tcpu; int i; - gfp |= GFP_KERNEL | __GFP_HIGHMEM; + gfp |= __GFP_HIGHMEM; for_each_possible_cpu(cpu) { for (i = page_start; i < page_end; i++) { diff --git a/mm/percpu.c b/mm/percpu.c index f97443d488a8..fa3f854634a1 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -454,9 +454,6 @@ static void pcpu_next_fit_region(struct pcpu_chunk *chunk, int alloc_bits, * This is to facilitate passing through whitelisted flags. The * returned memory is always zeroed. * - * CONTEXT: - * Does GFP_KERNEL allocation. - * * RETURNS: * Pointer to the allocated area on success, NULL on failure. */ @@ -466,10 +463,9 @@ static void *pcpu_mem_zalloc(size_t size, gfp_t gfp) return NULL; if (size <= PAGE_SIZE) - return kzalloc(size, gfp | GFP_KERNEL); + return kzalloc(size, gfp); else - return __vmalloc(size, gfp | GFP_KERNEL | __GFP_ZERO, - PAGE_KERNEL); + return __vmalloc(size, gfp | __GFP_ZERO, PAGE_KERNEL); } /** @@ -1344,6 +1340,8 @@ static struct pcpu_chunk *pcpu_chunk_addr_search(void *addr) static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, gfp_t gfp) { + /* whitelisted flags that can be passed to the backing allocators */ + gfp_t pcpu_gfp = gfp & (GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); bool is_atomic = (gfp & GFP_KERNEL) != GFP_KERNEL; bool do_warn = !(gfp & __GFP_NOWARN); static int warn_limit = 10; @@ -1426,7 +1424,7 @@ restart: } if (list_empty(&pcpu_slot[pcpu_nr_slots - 1])) { - chunk = pcpu_create_chunk(0); + chunk = pcpu_create_chunk(pcpu_gfp); if (!chunk) { err = "failed to allocate new chunk"; goto fail; @@ -1455,7 +1453,7 @@ area_found: page_start, page_end) { WARN_ON(chunk->immutable); - ret = pcpu_populate_chunk(chunk, rs, re, 0); + ret = pcpu_populate_chunk(chunk, rs, re, pcpu_gfp); spin_lock_irqsave(&pcpu_lock, flags); if (ret) { @@ -1576,7 +1574,7 @@ void __percpu *__alloc_reserved_percpu(size_t size, size_t align) static void pcpu_balance_workfn(struct work_struct *work) { /* gfp flags passed to underlying allocators */ - const gfp_t gfp = __GFP_NORETRY | __GFP_NOWARN; + const gfp_t gfp = GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN; LIST_HEAD(to_free); struct list_head *free_head = &pcpu_slot[pcpu_nr_slots - 1]; struct pcpu_chunk *chunk, *next; From 143a4454daaf0e80a2b9f37159a0d6d2b61e64ed Mon Sep 17 00:00:00 2001 From: Xin Long Date: Sat, 17 Feb 2018 15:16:22 +0800 Subject: [PATCH 312/942] xfrm: do not call rcu_read_unlock when afinfo is NULL in xfrm_get_tos When xfrm_policy_get_afinfo returns NULL, it will not hold rcu read lock. In this case, rcu_read_unlock should not be called in xfrm_get_tos, just like other places where it's calling xfrm_policy_get_afinfo. Fixes: f5e2bb4f5b22 ("xfrm: policy: xfrm_get_tos cannot fail") Signed-off-by: Xin Long Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_policy.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 8b3811ff002d..150d46633ce6 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -1458,10 +1458,13 @@ xfrm_tmpl_resolve(struct xfrm_policy **pols, int npols, const struct flowi *fl, static int xfrm_get_tos(const struct flowi *fl, int family) { const struct xfrm_policy_afinfo *afinfo; - int tos = 0; + int tos; afinfo = xfrm_policy_get_afinfo(family); - tos = afinfo ? afinfo->get_tos(fl) : 0; + if (!afinfo) + return 0; + + tos = afinfo->get_tos(fl); rcu_read_unlock(); From 5682e268350f9eccdbb04006605c1b7068a7b323 Mon Sep 17 00:00:00 2001 From: Chen-Yu Tsai Date: Sat, 17 Feb 2018 21:05:04 +0800 Subject: [PATCH 313/942] clk: sunxi-ng: a31: Fix CLK_OUT_* clock ops When support for the A31/A31s CCU was first added, the clock ops for the CLK_OUT_* clocks was set to the wrong type. The clocks are MP-type, but the ops was set for div (M) clocks. This went unnoticed until now. This was because while they are different clocks, their data structures aligned in a way that ccu_div_ops would access the second ccu_div_internal and ccu_mux_internal structures, which were valid, if not incorrect. Furthermore, the use of these CLK_OUT_* was for feeding a precise 32.768 kHz clock signal to the WiFi chip. This was achievable by using the parent with the same clock rate and no divider. So the incorrect divider setting did not affect this usage. Commit 946797aa3f08 ("clk: sunxi-ng: Support fixed post-dividers on MP style clocks") added a new field to the ccu_mp structure, which broke the aforementioned alignment. Now the system crashes as div_ops tries to look up a nonexistent table. Reported-by: Philipp Rossak Tested-by: Philipp Rossak Fixes: c6e6c96d8fa6 ("clk: sunxi-ng: Add A31/A31s clocks") Cc: Signed-off-by: Chen-Yu Tsai Signed-off-by: Maxime Ripard --- drivers/clk/sunxi-ng/ccu-sun6i-a31.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c index 72b16ed1012b..3b97f60540ad 100644 --- a/drivers/clk/sunxi-ng/ccu-sun6i-a31.c +++ b/drivers/clk/sunxi-ng/ccu-sun6i-a31.c @@ -762,7 +762,7 @@ static struct ccu_mp out_a_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init = CLK_HW_INIT_PARENTS("out-a", clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, }; @@ -783,7 +783,7 @@ static struct ccu_mp out_b_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init = CLK_HW_INIT_PARENTS("out-b", clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, }; @@ -804,7 +804,7 @@ static struct ccu_mp out_c_clk = { .features = CCU_FEATURE_FIXED_PREDIV, .hw.init = CLK_HW_INIT_PARENTS("out-c", clk_out_parents, - &ccu_div_ops, + &ccu_mp_ops, 0), }, }; From 257aaceb63eb2337e50cd9f9008d11df2cb86207 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Feb 2018 04:15:38 +0000 Subject: [PATCH 314/942] ASoC: intel: kbl_da7219_max98357: replace codec to component Now we can replace Codec to Component. Let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_da7219_max98357a.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/intel/boards/kbl_da7219_max98357a.c b/sound/soc/intel/boards/kbl_da7219_max98357a.c index d689124f6687..e84baafd5f63 100644 --- a/sound/soc/intel/boards/kbl_da7219_max98357a.c +++ b/sound/soc/intel/boards/kbl_da7219_max98357a.c @@ -168,7 +168,7 @@ static int kabylake_ssp_fixup(struct snd_soc_pcm_runtime *rtd, static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(rtd->card); - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; struct snd_soc_jack *jack; int ret; @@ -191,7 +191,7 @@ static int kabylake_da7219_codec_init(struct snd_soc_pcm_runtime *rtd) snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEDOWN); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOICECOMMAND); - da7219_aad_jack_det(codec, &ctx->kabylake_headset); + da7219_aad_jack_det(component, &ctx->kabylake_headset); ret = snd_soc_dapm_ignore_suspend(&rtd->card->dapm, "SoC DMIC"); if (ret) @@ -522,12 +522,12 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) { struct kbl_codec_private *ctx = snd_soc_card_get_drvdata(card); struct kbl_hdmi_pcm *pcm; - struct snd_soc_codec *codec = NULL; + struct snd_soc_component *component = NULL; int err, i = 0; char jack_name[NAME_SIZE]; list_for_each_entry(pcm, &ctx->hdmi_pcm_list, head) { - codec = pcm->codec_dai->codec; + component = pcm->codec_dai->component; snprintf(jack_name, sizeof(jack_name), "HDMI/DP, pcm=%d Jack", pcm->device); err = snd_soc_card_jack_new(card, jack_name, @@ -546,10 +546,10 @@ static int kabylake_card_late_probe(struct snd_soc_card *card) } - if (!codec) + if (!component) return -EINVAL; - return hdac_hdmi_jack_port_init(codec, &card->dapm); + return hdac_hdmi_jack_port_init(component, &card->dapm); } /* kabylake audio machine driver for SPT + DA7219 */ From 9a60cde2dd63e10b421e87e1397641304dd1ef13 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Feb 2018 04:16:06 +0000 Subject: [PATCH 315/942] ASoC: amd: acp-da7219-max98357: replace codec to component Now we can replace Codec to Component. Let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/amd/acp-da7219-max98357a.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index e51a878890ce..bbe0f103e6a8 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -47,8 +47,8 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_card *card = rtd->card; - struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dai *codec_dai = rtd->codec_dai; + struct snd_soc_component *component = codec_dai->component; dev_info(rtd->dev, "codec dai name = %s\n", codec_dai->name); @@ -76,7 +76,7 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) return ret; } - da7219_aad_jack_det(codec, &cz_jack); + da7219_aad_jack_det(component, &cz_jack); return 0; } From c988e67507934e0198233729b7f326154b211a7f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Feb 2018 04:16:42 +0000 Subject: [PATCH 316/942] ASoC: ak4458: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak4458.c | 107 +++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index c9762162b53f..d2815ac9cffa 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -167,8 +167,8 @@ static const struct soc_enum ak4458_dif_enum = static int get_digfil(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); ucontrol->value.enumerated.item[0] = ak4458->digfil; @@ -178,8 +178,8 @@ static int get_digfil(struct snd_kcontrol *kcontrol, static int set_digfil(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); int num; num = ucontrol->value.enumerated.item[0]; @@ -189,17 +189,17 @@ static int set_digfil(struct snd_kcontrol *kcontrol, ak4458->digfil = num; /* write SD bit */ - snd_soc_update_bits(codec, AK4458_01_CONTROL2, + snd_soc_component_update_bits(component, AK4458_01_CONTROL2, AK4458_SD_MASK, ((ak4458->digfil & 0x02) << 4)); /* write SLOW bit */ - snd_soc_update_bits(codec, AK4458_02_CONTROL3, + snd_soc_component_update_bits(component, AK4458_02_CONTROL3, AK4458_SLOW_MASK, (ak4458->digfil & 0x01)); /* write SSLOW bit */ - snd_soc_update_bits(codec, AK4458_05_CONTROL4, + snd_soc_component_update_bits(component, AK4458_05_CONTROL4, AK4458_SSLOW_MASK, ((ak4458->digfil & 0x04) >> 2)); @@ -259,17 +259,17 @@ static const struct snd_soc_dapm_route ak4458_intercon[] = { {"AK4458 AOUTD", NULL, "AK4458 DAC4"}, }; -static int ak4458_rstn_control(struct snd_soc_codec *codec, int bit) +static int ak4458_rstn_control(struct snd_soc_component *component, int bit) { int ret; if (bit) - ret = snd_soc_update_bits(codec, + ret = snd_soc_component_update_bits(component, AK4458_00_CONTROL1, AK4458_RSTN_MASK, 0x1); else - ret = snd_soc_update_bits(codec, + ret = snd_soc_component_update_bits(component, AK4458_00_CONTROL1, AK4458_RSTN_MASK, 0x0); @@ -280,8 +280,8 @@ static int ak4458_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); int pcm_width = max(params_physical_width(params), ak4458->slot_width); int nfs1; u8 format; @@ -290,7 +290,7 @@ static int ak4458_hw_params(struct snd_pcm_substream *substream, ak4458->fs = nfs1; /* Master Clock Frequency Auto Setting Mode Enable */ - snd_soc_update_bits(codec, AK4458_00_CONTROL1, 0x80, 0x80); + snd_soc_component_update_bits(component, AK4458_00_CONTROL1, 0x80, 0x80); switch (pcm_width) { case 16: @@ -321,19 +321,19 @@ static int ak4458_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, AK4458_00_CONTROL1, + snd_soc_component_update_bits(component, AK4458_00_CONTROL1, AK4458_DIF_MASK, format); - ak4458_rstn_control(codec, 0); - ak4458_rstn_control(codec, 1); + ak4458_rstn_control(component, 0); + ak4458_rstn_control(component, 1); return 0; } static int ak4458_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { case SND_SOC_DAIFMT_CBS_CFS: /* Slave Mode */ @@ -342,7 +342,7 @@ static int ak4458_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) case SND_SOC_DAIFMT_CBS_CFM: case SND_SOC_DAIFMT_CBM_CFS: default: - dev_err(codec->dev, "Master mode unsupported\n"); + dev_err(component->dev, "Master mode unsupported\n"); return -EINVAL; } @@ -354,13 +354,13 @@ static int ak4458_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) ak4458->fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; break; default: - dev_err(codec->dev, "Audio format 0x%02X unsupported\n", + dev_err(component->dev, "Audio format 0x%02X unsupported\n", fmt & SND_SOC_DAIFMT_FORMAT_MASK); return -EINVAL; } - ak4458_rstn_control(codec, 0); - ak4458_rstn_control(codec, 1); + ak4458_rstn_control(component, 0); + ak4458_rstn_control(component, 1); return 0; } @@ -369,27 +369,27 @@ static const int att_speed[] = { 4080, 2040, 510, 255 }; static int ak4458_set_dai_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); int nfs, ndt, ret, reg; int ats; nfs = ak4458->fs; - reg = snd_soc_read(codec, AK4458_0B_CONTROL7); + reg = snd_soc_component_read32(component, AK4458_0B_CONTROL7); ats = (reg & AK4458_ATS_MASK) >> AK4458_ATS_SHIFT; ndt = att_speed[ats] / (nfs / 1000); if (mute) { - ret = snd_soc_update_bits(codec, AK4458_01_CONTROL2, 0x01, 1); + ret = snd_soc_component_update_bits(component, AK4458_01_CONTROL2, 0x01, 1); mdelay(ndt); if (ak4458->mute_gpiod) gpiod_set_value_cansleep(ak4458->mute_gpiod, 1); } else { if (ak4458->mute_gpiod) gpiod_set_value_cansleep(ak4458->mute_gpiod, 0); - ret = snd_soc_update_bits(codec, AK4458_01_CONTROL2, 0x01, 0); + ret = snd_soc_component_update_bits(component, AK4458_01_CONTROL2, 0x01, 0); mdelay(ndt); } @@ -399,8 +399,8 @@ static int ak4458_set_dai_mute(struct snd_soc_dai *dai, int mute) static int ak4458_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); int mode; ak4458->slots = slots; @@ -421,7 +421,7 @@ static int ak4458_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, break; } - snd_soc_update_bits(codec, AK4458_0A_CONTROL6, + snd_soc_component_update_bits(component, AK4458_0A_CONTROL6, AK4458_MODE_MASK, mode); @@ -493,9 +493,9 @@ static void ak4458_power_on(struct ak4458_priv *ak4458) } } -static void ak4458_init(struct snd_soc_codec *codec) +static void ak4458_init(struct snd_soc_component *component) { - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); /* External Mute ON */ if (ak4458->mute_gpiod) @@ -503,30 +503,28 @@ static void ak4458_init(struct snd_soc_codec *codec) ak4458_power_on(ak4458); - snd_soc_update_bits(codec, AK4458_00_CONTROL1, + snd_soc_component_update_bits(component, AK4458_00_CONTROL1, 0x80, 0x80); /* ACKS bit = 1; 10000000 */ - ak4458_rstn_control(codec, 1); + ak4458_rstn_control(component, 1); } -static int ak4458_probe(struct snd_soc_codec *codec) +static int ak4458_probe(struct snd_soc_component *component) { - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); - ak4458_init(codec); + ak4458_init(component); ak4458->fs = 48000; return 0; } -static int ak4458_remove(struct snd_soc_codec *codec) +static void ak4458_remove(struct snd_soc_component *component) { - struct ak4458_priv *ak4458 = snd_soc_codec_get_drvdata(codec); + struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component); ak4458_power_off(ak4458); - - return 0; } #ifdef CONFIG_PM @@ -561,17 +559,19 @@ static int __maybe_unused ak4458_runtime_resume(struct device *dev) } #endif /* CONFIG_PM */ -struct snd_soc_codec_driver soc_codec_dev_ak4458 = { - .probe = ak4458_probe, - .remove = ak4458_remove, - .component_driver = { - .controls = ak4458_snd_controls, - .num_controls = ARRAY_SIZE(ak4458_snd_controls), - .dapm_widgets = ak4458_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak4458_dapm_widgets), - .dapm_routes = ak4458_intercon, - .num_dapm_routes = ARRAY_SIZE(ak4458_intercon), - }, +struct snd_soc_component_driver soc_codec_dev_ak4458 = { + .probe = ak4458_probe, + .remove = ak4458_remove, + .controls = ak4458_snd_controls, + .num_controls = ARRAY_SIZE(ak4458_snd_controls), + .dapm_widgets = ak4458_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak4458_dapm_widgets), + .dapm_routes = ak4458_intercon, + .num_dapm_routes = ARRAY_SIZE(ak4458_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak4458_regmap = { @@ -616,7 +616,7 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) if (IS_ERR(ak4458->mute_gpiod)) return PTR_ERR(ak4458->mute_gpiod); - ret = snd_soc_register_codec(ak4458->dev, &soc_codec_dev_ak4458, + ret = devm_snd_soc_register_component(ak4458->dev, &soc_codec_dev_ak4458, &ak4458_dai, 1); if (ret < 0) { dev_err(ak4458->dev, "Failed to register CODEC: %d\n", ret); @@ -630,7 +630,6 @@ static int ak4458_i2c_probe(struct i2c_client *i2c) static int ak4458_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); pm_runtime_disable(&i2c->dev); return 0; From 3f15aa198fb88a6a0db8c7ba136637d566effb55 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Feb 2018 04:17:16 +0000 Subject: [PATCH 317/942] ASoC: ak5558: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/ak5558.c | 67 +++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 34 deletions(-) diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c index 225173ff4efa..f2248315677e 100644 --- a/sound/soc/codecs/ak5558.c +++ b/sound/soc/codecs/ak5558.c @@ -25,7 +25,7 @@ /* AK5558 Codec Private Data */ struct ak5558_priv { - struct snd_soc_codec codec; + struct snd_soc_component component; struct regmap *regmap; struct i2c_client *i2c; struct gpio_desc *reset_gpiod; /* Reset & Power down GPIO */ @@ -116,9 +116,9 @@ static const struct snd_soc_dapm_route ak5558_intercon[] = { {"SDTO", NULL, "ADC Ch8"}, }; -static int ak5558_set_mcki(struct snd_soc_codec *codec) +static int ak5558_set_mcki(struct snd_soc_component *component) { - return snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_CKS, + return snd_soc_component_update_bits(component, AK5558_02_CONTROL1, AK5558_CKS, AK5558_CKS_AUTO); } @@ -126,13 +126,13 @@ static int ak5558_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak5558_priv *ak5558 = snd_soc_component_get_drvdata(component); u8 bits; int pcm_width = max(params_physical_width(params), ak5558->slot_width); /* set master/slave audio interface */ - bits = snd_soc_read(codec, AK5558_02_CONTROL1); + bits = snd_soc_component_read32(component, AK5558_02_CONTROL1); bits &= ~AK5558_BITS; switch (pcm_width) { @@ -146,14 +146,14 @@ static int ak5558_hw_params(struct snd_pcm_substream *substream, return -EINVAL; } - snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_BITS, bits); + snd_soc_component_update_bits(component, AK5558_02_CONTROL1, AK5558_BITS, bits); return 0; } static int ak5558_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) { - struct snd_soc_codec *codec = dai->codec; + struct snd_soc_component *component = dai->component; u8 format; switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { @@ -169,7 +169,7 @@ static int ak5558_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) } /* set master/slave audio interface */ - format = snd_soc_read(codec, AK5558_02_CONTROL1); + format = snd_soc_component_read32(component, AK5558_02_CONTROL1); format &= ~AK5558_DIF; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { @@ -186,7 +186,7 @@ static int ak5558_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) return -EINVAL; } - snd_soc_update_bits(codec, AK5558_02_CONTROL1, AK5558_DIF, format); + snd_soc_component_update_bits(component, AK5558_02_CONTROL1, AK5558_DIF, format); return 0; } @@ -195,8 +195,8 @@ static int ak5558_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width) { - struct snd_soc_codec *codec = dai->codec; - struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct ak5558_priv *ak5558 = snd_soc_component_get_drvdata(component); int tdm_mode; ak5558->slots = slots; @@ -217,7 +217,7 @@ static int ak5558_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, break; } - snd_soc_update_bits(codec, AK5558_03_CONTROL2, AK5558_MODE_BITS, + snd_soc_component_update_bits(component, AK5558_03_CONTROL2, AK5558_MODE_BITS, tdm_mode); return 0; } @@ -285,21 +285,19 @@ static void ak5558_power_on(struct ak5558_priv *ak5558) usleep_range(1000, 2000); } -static int ak5558_probe(struct snd_soc_codec *codec) +static int ak5558_probe(struct snd_soc_component *component) { - struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + struct ak5558_priv *ak5558 = snd_soc_component_get_drvdata(component); ak5558_power_on(ak5558); - return ak5558_set_mcki(codec); + return ak5558_set_mcki(component); } -static int ak5558_remove(struct snd_soc_codec *codec) +static void ak5558_remove(struct snd_soc_component *component) { - struct ak5558_priv *ak5558 = snd_soc_codec_get_drvdata(codec); + struct ak5558_priv *ak5558 = snd_soc_component_get_drvdata(component); ak5558_power_off(ak5558); - - return 0; } static int __maybe_unused ak5558_runtime_suspend(struct device *dev) @@ -331,18 +329,19 @@ const struct dev_pm_ops ak5558_pm = { pm_runtime_force_resume) }; -struct snd_soc_codec_driver soc_codec_dev_ak5558 = { - .probe = ak5558_probe, - .remove = ak5558_remove, - - .component_driver = { - .controls = ak5558_snd_controls, - .num_controls = ARRAY_SIZE(ak5558_snd_controls), - .dapm_widgets = ak5558_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(ak5558_dapm_widgets), - .dapm_routes = ak5558_intercon, - .num_dapm_routes = ARRAY_SIZE(ak5558_intercon), - }, +struct snd_soc_component_driver soc_codec_dev_ak5558 = { + .probe = ak5558_probe, + .remove = ak5558_remove, + .controls = ak5558_snd_controls, + .num_controls = ARRAY_SIZE(ak5558_snd_controls), + .dapm_widgets = ak5558_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(ak5558_dapm_widgets), + .dapm_routes = ak5558_intercon, + .num_dapm_routes = ARRAY_SIZE(ak5558_intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static const struct regmap_config ak5558_regmap = { @@ -376,7 +375,8 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) if (IS_ERR(ak5558->reset_gpiod)) return PTR_ERR(ak5558->reset_gpiod); - ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_ak5558, + ret = devm_snd_soc_register_component(&i2c->dev, + &soc_codec_dev_ak5558, &ak5558_dai, 1); if (ret) return ret; @@ -388,7 +388,6 @@ static int ak5558_i2c_probe(struct i2c_client *i2c) static int ak5558_i2c_remove(struct i2c_client *i2c) { - snd_soc_unregister_codec(&i2c->dev); pm_runtime_disable(&i2c->dev); return 0; From 7d41bc28e9fa3fed28691019ca0fe36ed68d7b86 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 19 Feb 2018 11:45:07 +0200 Subject: [PATCH 318/942] ASoC: tlv320aic31xx: Rename AIF_IN from 'DAC IN' to 'AIF IN' The audio interface is not really the DAC input. Use more generic name for it. Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 7090342e8285..e5a1e2be17aa 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -468,7 +468,7 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, } static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { - SND_SOC_DAPM_AIF_IN("DAC IN", "DAC Playback", 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_IN("AIF IN", "Playback", 0, SND_SOC_NOPM, 0, 0), SND_SOC_DAPM_MUX("DAC Left Input", SND_SOC_NOPM, 0, 0, &ldac_in_control), @@ -584,12 +584,12 @@ static const struct snd_soc_dapm_widget aic310x_dapm_widgets[] = { static const struct snd_soc_dapm_route common31xx_audio_map[] = { /* DAC Input Routing */ - {"DAC Left Input", "Left Data", "DAC IN"}, - {"DAC Left Input", "Right Data", "DAC IN"}, - {"DAC Left Input", "Mono", "DAC IN"}, - {"DAC Right Input", "Left Data", "DAC IN"}, - {"DAC Right Input", "Right Data", "DAC IN"}, - {"DAC Right Input", "Mono", "DAC IN"}, + {"DAC Left Input", "Left Data", "AIF IN"}, + {"DAC Left Input", "Right Data", "AIF IN"}, + {"DAC Left Input", "Mono", "AIF IN"}, + {"DAC Right Input", "Left Data", "AIF IN"}, + {"DAC Right Input", "Right Data", "AIF IN"}, + {"DAC Right Input", "Mono", "AIF IN"}, {"DAC Left", NULL, "DAC Left Input"}, {"DAC Right", NULL, "DAC Right Input"}, @@ -679,8 +679,8 @@ aic310x_audio_map[] = { */ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input", "Off", "DAC IN"}, - {"DAC Right Input", "Off", "DAC IN"}, + {"DAC Left Input", "Off", "AIF IN"}, + {"DAC Right Input", "Off", "AIF IN"}, {"HPL", NULL, "DAC Left"}, {"HPR", NULL, "DAC Right"}, From a16be2a6e2ffa8ad5e24e96289f317e1b5b8c17a Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 19 Feb 2018 11:45:08 +0200 Subject: [PATCH 319/942] ASoC: tlv320aic31xx: Do not force power on the DAC/ADC in clock master mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With P0 R29, Bit2 set the I2S clocks will be running when the DAC/ADC is powered down, but still the codec need to be powered up by needing at least one complete DAPM path for the stream. If the AIF is not needed (analog loopback for example) the I2S clocks will not run as they are not needed. Signed-off-by: Peter Ujfalusi Suggested-by: Stefan Müller-Klieser Signed-off-by: Mark Brown --- sound/soc/codecs/tlv320aic31xx.c | 32 ++++++++++++++++++++++---------- sound/soc/codecs/tlv320aic31xx.h | 1 + 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index e5a1e2be17aa..bf92d36b8f8a 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c @@ -501,6 +501,10 @@ static const struct snd_soc_dapm_widget common31xx_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("MICBIAS", SND_SOC_NOPM, 0, 0, mic_bias_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + /* Keep BCLK/WCLK enabled even if DAC/ADC is powered down */ + SND_SOC_DAPM_SUPPLY("Activate I2S clocks", AIC31XX_IFACE2, 2, 0, + NULL, 0), + /* Outputs */ SND_SOC_DAPM_OUTPUT("HPL"), SND_SOC_DAPM_OUTPUT("HPR"), @@ -553,6 +557,8 @@ static const struct snd_soc_dapm_widget aic31xx_dapm_widgets[] = { SND_SOC_DAPM_MIXER("Output Right", SND_SOC_NOPM, 0, 0, aic31xx_right_output_switches, ARRAY_SIZE(aic31xx_right_output_switches)), + + SND_SOC_DAPM_AIF_OUT("AIF OUT", "Capture", 0, SND_SOC_NOPM, 0, 0), }; static const struct snd_soc_dapm_widget aic311x_dapm_widgets[] = { @@ -640,6 +646,8 @@ aic31xx_audio_map[] = { {"ADC", NULL, "MIC_GAIN_CTL"}, + {"AIF OUT", NULL, "ADC"}, + /* Left Output */ {"Output Left", "From Left DAC", "DAC Left"}, {"Output Left", "From MIC1LP", "MIC1LP"}, @@ -673,25 +681,29 @@ aic310x_audio_map[] = { /* * Always connected DAPM routes for codec clock master modes. - * If the codec is the master on the I2S bus, we need to power on components - * to have valid DAC_CLK and also the DACs and ADC for playback/capture. + * If the codec is the master on the I2S bus, we need to power up components + * to have valid DAC_CLK. + * + * In order to have the I2S clocks on the bus either the DACs/ADC need to be + * enabled, or the P0/R29/D2 (Keep bclk/wclk in power down) need to be set. + * * Otherwise the codec will not generate clocks on the bus. */ static const struct snd_soc_dapm_route common31xx_cm_audio_map[] = { - {"DAC Left Input", "Off", "AIF IN"}, - {"DAC Right Input", "Off", "AIF IN"}, + {"HPL", NULL, "AIF IN"}, + {"HPR", NULL, "AIF IN"}, - {"HPL", NULL, "DAC Left"}, - {"HPR", NULL, "DAC Right"}, + {"AIF IN", NULL, "Activate I2S clocks"}, }; static const struct snd_soc_dapm_route aic31xx_cm_audio_map[] = { - {"MIC1LP P-Terminal", "Off", "MIC1LP"}, - {"MIC1RP P-Terminal", "Off", "MIC1RP"}, - {"MIC1LM P-Terminal", "Off", "MIC1LM"}, - {"MIC1LM M-Terminal", "Off", "MIC1LM"}, + {"AIF OUT", NULL, "MIC1LP"}, + {"AIF OUT", NULL, "MIC1RP"}, + {"AIF OUT", NULL, "MIC1LM"}, + + {"AIF OUT", NULL, "Activate I2S clocks"}, }; static int aic31xx_add_controls(struct snd_soc_component *component) diff --git a/sound/soc/codecs/tlv320aic31xx.h b/sound/soc/codecs/tlv320aic31xx.h index 15ac7cba86fe..0b587585b38b 100644 --- a/sound/soc/codecs/tlv320aic31xx.h +++ b/sound/soc/codecs/tlv320aic31xx.h @@ -160,6 +160,7 @@ struct aic31xx_pdata { #define AIC31XX_DACMOD2BCLK 0x01 #define AIC31XX_ADC2BCLK 0x02 #define AIC31XX_ADCMOD2BCLK 0x03 +#define AIC31XX_KEEP_I2SCLK BIT(2) /* AIC31XX_ADCFLAG */ #define AIC31XX_ADCPWRSTATUS_MASK BIT(6) From 7f7d5239f56cfd25ba8470354d9705815c079157 Mon Sep 17 00:00:00 2001 From: Michal Oleszczyk Date: Mon, 19 Feb 2018 10:03:45 +0100 Subject: [PATCH 320/942] ASoC: sgtl5000: add 'Audio Switch' block implementation Add mux for choosing DAC source: ADC, I2S or DAP. DAP - digital audio processing block. Moreover create choosing mux for DAP main source (ADC or I2S) and DAP mixer source (ADC or I2S). Mixer block allows summing DAP main and mixer sources togheter with defined volumes. Signed-off-by: Michal Oleszczyk Signed-off-by: Mark Brown --- sound/soc/codecs/sgtl5000.c | 80 +++++++++++++++++++++++++++++++------ 1 file changed, 68 insertions(+), 12 deletions(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 05592ddcf0e6..1724c4622052 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -216,17 +216,54 @@ static SOC_ENUM_SINGLE_DECL(adc_enum, static const struct snd_kcontrol_new adc_mux = SOC_DAPM_ENUM("Capture Mux", adc_enum); -/* input sources for DAC */ -static const char *dac_mux_text[] = { +/* input sources for headphone */ +static const char *hp_mux_text[] = { "DAC", "LINE_IN" }; -static SOC_ENUM_SINGLE_DECL(dac_enum, +static SOC_ENUM_SINGLE_DECL(hp_enum, SGTL5000_CHIP_ANA_CTRL, 6, + hp_mux_text); + +static const struct snd_kcontrol_new hp_mux = +SOC_DAPM_ENUM("Headphone Mux", hp_enum); + +/* input sources for DAC */ +static const char *dac_mux_text[] = { + "ADC", "I2S", "Rsvrd", "DAP" +}; + +static SOC_ENUM_SINGLE_DECL(dac_enum, + SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAC_SEL_SHIFT, dac_mux_text); static const struct snd_kcontrol_new dac_mux = -SOC_DAPM_ENUM("Headphone Mux", dac_enum); +SOC_DAPM_ENUM("Digital Input Mux", dac_enum); + +/* input sources for DAP */ +static const char *dap_mux_text[] = { + "ADC", "I2S" +}; + +static SOC_ENUM_SINGLE_DECL(dap_enum, + SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAP_SEL_SHIFT, + dap_mux_text); + +static const struct snd_kcontrol_new dap_mux = +SOC_DAPM_ENUM("DAP Mux", dap_enum); + +/* input sources for DAP mix */ +static const char *dapmix_mux_text[] = { + "ADC", "I2S" +}; + +static SOC_ENUM_SINGLE_DECL(dapmix_enum, + SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAP_MIX_SEL_SHIFT, + dapmix_mux_text); + +static const struct snd_kcontrol_new dapmix_mux = +SOC_DAPM_ENUM("DAP MIX Mux", dapmix_enum); + static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = { SND_SOC_DAPM_INPUT("LINE_IN"), @@ -243,7 +280,12 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = { SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0), SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux), - SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &dac_mux), + SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &hp_mux), + SND_SOC_DAPM_MUX("Digital Input Mux", SND_SOC_NOPM, 0, 0, &dac_mux), + SND_SOC_DAPM_MUX("DAP Mux", SGTL5000_DAP_CTRL, 0, 0, &dap_mux), + SND_SOC_DAPM_MUX("DAP MIX Mux", SGTL5000_DAP_CTRL, 4, 0, &dapmix_mux), + SND_SOC_DAPM_MIXER("DAP", SGTL5000_CHIP_DIG_POWER, 4, 0, NULL, 0), + /* aif for i2s input */ SND_SOC_DAPM_AIF_IN("AIFIN", "Playback", @@ -270,7 +312,19 @@ static const struct snd_soc_dapm_route sgtl5000_dapm_routes[] = { {"ADC", NULL, "Capture Mux"}, /* adc_mux --> adc */ {"AIFOUT", NULL, "ADC"}, /* adc --> i2s_out */ - {"DAC", NULL, "AIFIN"}, /* i2s-->dac,skip audio mux */ + {"DAP Mux", "ADC", "ADC"}, /* adc --> DAP mux */ + {"DAP Mux", NULL, "AIFIN"}, /* i2s --> DAP mux */ + {"DAP", NULL, "DAP Mux"}, /* DAP mux --> dap */ + + {"DAP MIX Mux", "ADC", "ADC"}, /* adc --> DAP MIX mux */ + {"DAP MIX Mux", NULL, "AIFIN"}, /* i2s --> DAP MIX mux */ + {"DAP", NULL, "DAP MIX Mux"}, /* DAP MIX mux --> dap */ + + {"Digital Input Mux", "ADC", "ADC"}, /* adc --> audio mux */ + {"Digital Input Mux", NULL, "AIFIN"}, /* i2s --> audio mux */ + {"Digital Input Mux", NULL, "DAP"}, /* dap --> audio mux */ + {"DAC", NULL, "Digital Input Mux"}, /* audio mux --> dac */ + {"Headphone Mux", "DAC", "DAC"}, /* dac --> hp_mux */ {"LO", NULL, "DAC"}, /* dac --> line_out */ @@ -463,6 +517,9 @@ static const DECLARE_TLV_DB_RANGE(mic_gain_tlv, 1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0) ); +/* tlv for DAP channels, 0% - 100% - 200% */ +static const DECLARE_TLV_DB_SCALE(dap_volume, 0, 1, 0); + /* tlv for hp volume, -51.5db to 12.0db, step .5db */ static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0); @@ -514,6 +571,11 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = { lineout_volume), SOC_SINGLE("Lineout Playback Switch", SGTL5000_CHIP_ANA_CTRL, 8, 1, 1), + SOC_SINGLE_TLV("DAP Main channel", SGTL5000_DAP_MAIN_CHAN, + 0, 0xffff, 0, dap_volume), + + SOC_SINGLE_TLV("DAP Mix channel", SGTL5000_DAP_MIX_CHAN, + 0, 0xffff, 0, dap_volume), /* Automatic Volume Control (DAP AVC) */ SOC_SINGLE("AVC Switch", SGTL5000_DAP_AVC_CTRL, 0, 1, 0), SOC_SINGLE("AVC Hard Limiter Switch", SGTL5000_DAP_AVC_CTRL, 5, 1, 0), @@ -1217,12 +1279,6 @@ static int sgtl5000_probe(struct snd_soc_component *component) /* disable short cut detector */ snd_soc_component_write(component, SGTL5000_CHIP_SHORT_CTRL, 0); - /* - * set i2s as default input of sound switch - * TODO: add sound switch to control and dapm widge. - */ - snd_soc_component_write(component, SGTL5000_CHIP_SSS_CTRL, - SGTL5000_DAC_SEL_I2S_IN << SGTL5000_DAC_SEL_SHIFT); snd_soc_component_write(component, SGTL5000_CHIP_DIG_POWER, SGTL5000_ADC_EN | SGTL5000_DAC_EN); From 92a2742f9813ef65da19145a77e8067d6abbc822 Mon Sep 17 00:00:00 2001 From: Michal Oleszczyk Date: Mon, 19 Feb 2018 10:03:46 +0100 Subject: [PATCH 321/942] ASoC: sgtl5000: add 5 band graphic equalizer Enable 5-band graphic equalizer which allows manipulation of gain in range -11.75dB to 12dB for 5 specific sound bands: 115Hz, 330Hz, 990Hz, 3000Hz, 9900Hz. Signed-off-by: Michal Oleszczyk Signed-off-by: Mark Brown --- sound/soc/codecs/sgtl5000.c | 24 +++++++++++++++++++++--- sound/soc/codecs/sgtl5000.h | 7 +++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 1724c4622052..7c1d65830c05 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -520,6 +520,9 @@ static const DECLARE_TLV_DB_RANGE(mic_gain_tlv, /* tlv for DAP channels, 0% - 100% - 200% */ static const DECLARE_TLV_DB_SCALE(dap_volume, 0, 1, 0); +/* tlv for bass bands, -11.75db to 12.0db, step .25db */ +static const DECLARE_TLV_DB_SCALE(bass_band, -1175, 25, 0); + /* tlv for hp volume, -51.5db to 12.0db, step .5db */ static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0); @@ -585,6 +588,21 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = { SOC_SINGLE_EXT_TLV("AVC Threshold Volume", SGTL5000_DAP_AVC_THRESHOLD, 0, 96, 0, avc_get_threshold, avc_put_threshold, avc_threshold), + + SOC_SINGLE_TLV("BASS 0", SGTL5000_DAP_EQ_BASS_BAND0, + 0, 0x5F, 0, bass_band), + + SOC_SINGLE_TLV("BASS 1", SGTL5000_DAP_EQ_BASS_BAND1, + 0, 0x5F, 0, bass_band), + + SOC_SINGLE_TLV("BASS 2", SGTL5000_DAP_EQ_BASS_BAND2, + 0, 0x5F, 0, bass_band), + + SOC_SINGLE_TLV("BASS 3", SGTL5000_DAP_EQ_BASS_BAND3, + 0, 0x5F, 0, bass_band), + + SOC_SINGLE_TLV("BASS 4", SGTL5000_DAP_EQ_BASS_BAND4, + 0, 0x5F, 0, bass_band), }; /* mute the codec used by alsa core */ @@ -1303,11 +1321,11 @@ static int sgtl5000_probe(struct snd_soc_component *component) SGTL5000_BIAS_VOLT_MASK, sgtl5000->micbias_voltage << SGTL5000_BIAS_VOLT_SHIFT); /* - * disable DAP + * enable DAP Graphic EQ * TODO: - * Enable DAP in kcontrol and dapm. + * Add control for changing between PEQ/Tone Control/GEQ */ - snd_soc_component_write(component, SGTL5000_DAP_CTRL, 0); + snd_soc_component_write(component, SGTL5000_DAP_AUDIO_EQ, SGTL5000_DAP_SEL_GEQ); /* Unmute DAC after start */ snd_soc_component_update_bits(component, SGTL5000_CHIP_ADCDAC_CTRL, diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 22f3442af982..28cf637155bb 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -399,4 +399,11 @@ #define SGTL5000_SYSCLK 0x00 #define SGTL5000_LRCLK 0x01 +/* + * SGTL5000_DAP_AUDIO_EQ + */ +#define SGTL5000_DAP_SEL_PEQ 1 +#define SGTL5000_DAP_SEL_TONE_CTRL 2 +#define SGTL5000_DAP_SEL_GEQ 3 + #endif From 05c9b302eda71083840392d74ce62dd1e1f30621 Mon Sep 17 00:00:00 2001 From: Matthias Kaehlcke Date: Fri, 16 Feb 2018 09:53:12 -0800 Subject: [PATCH 322/942] ASoC: dmic: Add optional wakeup delay On some systems a delay is needed after switching on the clocks, to allow the output to stabilize and avoid a popping noise at the beginning of the recording. Add the optional device tree property 'wakeup-delay-ms' and apply the specified delay after enabling the mic. A blocking delay can't be applied in dmic_daiops_trigger() since the function is called in atomic context. Instead use a DAPM event handler to set the enable GPIO and apply the delay in the handler. Signed-off-by: Matthias Kaehlcke Reviewed-by: Peter Ujfalusi Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/dmic.txt | 2 + sound/soc/codecs/dmic.c | 63 ++++++++++--------- 2 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/dmic.txt b/Documentation/devicetree/bindings/sound/dmic.txt index f7bf65611453..e957b4136716 100644 --- a/Documentation/devicetree/bindings/sound/dmic.txt +++ b/Documentation/devicetree/bindings/sound/dmic.txt @@ -8,6 +8,7 @@ Required properties: Optional properties: - dmicen-gpios: GPIO specifier for dmic to control start and stop - num-channels: Number of microphones on this DAI + - wakeup-delay-ms: Delay (in ms) after enabling the DMIC Example node: @@ -15,4 +16,5 @@ Example node: compatible = "dmic-codec"; dmicen-gpios = <&gpio4 3 GPIO_ACTIVE_HIGH>; num-channels = <1>; + wakeup-delay-ms <50>; }; diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index 32a8f71d51f1..bac5bbb2dd59 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -19,6 +19,7 @@ * */ +#include #include #include #include @@ -29,34 +30,33 @@ #include #include -static int dmic_daiops_trigger(struct snd_pcm_substream *substream, - int cmd, struct snd_soc_dai *dai) -{ - struct gpio_desc *dmic_en = snd_soc_dai_get_drvdata(dai); +struct dmic { + struct gpio_desc *gpio_en; + int wakeup_delay; +}; - if (!dmic_en) - return 0; +static int dmic_aif_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) { + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct dmic *dmic = snd_soc_codec_get_drvdata(codec); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - gpiod_set_value(dmic_en, 1); + switch (event) { + case SND_SOC_DAPM_POST_PMU: + if (dmic->gpio_en) + gpiod_set_value(dmic->gpio_en, 1); + + if (dmic->wakeup_delay) + msleep(dmic->wakeup_delay); break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - gpiod_set_value(dmic_en, 0); + case SND_SOC_DAPM_POST_PMD: + if (dmic->gpio_en) + gpiod_set_value(dmic->gpio_en, 0); break; } return 0; } -static const struct snd_soc_dai_ops dmic_dai_ops = { - .trigger = dmic_daiops_trigger, -}; - static struct snd_soc_dai_driver dmic_dai = { .name = "dmic-hifi", .capture = { @@ -68,26 +68,33 @@ static struct snd_soc_dai_driver dmic_dai = { | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE, }, - .ops = &dmic_dai_ops, }; static int dmic_component_probe(struct snd_soc_component *component) { - struct gpio_desc *dmic_en; + struct dmic *dmic; - dmic_en = devm_gpiod_get_optional(component->dev, - "dmicen", GPIOD_OUT_LOW); - if (IS_ERR(dmic_en)) - return PTR_ERR(dmic_en); + dmic = devm_kzalloc(component->dev, sizeof(*dmic), GFP_KERNEL); + if (!dmic) + return -ENOMEM; - snd_soc_component_set_drvdata(component, dmic_en); + dmic->gpio_en = devm_gpiod_get_optional(component->dev, + "dmicen", GPIOD_OUT_LOW); + if (IS_ERR(dmic->gpio_en)) + return PTR_ERR(dmic->gpio_en); + + device_property_read_u32(component->dev, "wakeup-delay-ms", + &dmic->wakeup_delay); + + snd_soc_component_set_drvdata(component, dmic); return 0; } static const struct snd_soc_dapm_widget dmic_dapm_widgets[] = { - SND_SOC_DAPM_AIF_OUT("DMIC AIF", "Capture", 0, - SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT_E("DMIC AIF", "Capture", 0, + SND_SOC_NOPM, 0, 0, dmic_aif_event, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_INPUT("DMic"), }; From 6aa89ef38d7123b35747af058f43eb7c1a70042e Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 29 Jan 2018 04:46:53 +0000 Subject: [PATCH 323/942] ASoC: pxa/mioa701_wm9713: replace codec to component Now codec can be replaced to component, let's do it. Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/pxa/mioa701_wm9713.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c index c4c6fbedc723..47052fe3f5f4 100644 --- a/sound/soc/pxa/mioa701_wm9713.c +++ b/sound/soc/pxa/mioa701_wm9713.c @@ -58,20 +58,20 @@ #define AC97_GPIO_PULL 0x58 /* Use GPIO8 for rear speaker amplifier */ -static int rear_amp_power(struct snd_soc_codec *codec, int power) +static int rear_amp_power(struct snd_soc_component *component, int power) { unsigned short reg; if (power) { - reg = snd_soc_read(codec, AC97_GPIO_CFG); - snd_soc_write(codec, AC97_GPIO_CFG, reg | 0x0100); - reg = snd_soc_read(codec, AC97_GPIO_PULL); - snd_soc_write(codec, AC97_GPIO_PULL, reg | (1<<15)); + reg = snd_soc_component_read32(component, AC97_GPIO_CFG); + snd_soc_component_write(component, AC97_GPIO_CFG, reg | 0x0100); + reg = snd_soc_component_read32(component, AC97_GPIO_PULL); + snd_soc_component_write(component, AC97_GPIO_PULL, reg | (1<<15)); } else { - reg = snd_soc_read(codec, AC97_GPIO_CFG); - snd_soc_write(codec, AC97_GPIO_CFG, reg & ~0x0100); - reg = snd_soc_read(codec, AC97_GPIO_PULL); - snd_soc_write(codec, AC97_GPIO_PULL, reg & ~(1<<15)); + reg = snd_soc_component_read32(component, AC97_GPIO_CFG); + snd_soc_component_write(component, AC97_GPIO_CFG, reg & ~0x0100); + reg = snd_soc_component_read32(component, AC97_GPIO_PULL); + snd_soc_component_write(component, AC97_GPIO_PULL, reg & ~(1<<15)); } return 0; @@ -82,11 +82,11 @@ static int rear_amp_event(struct snd_soc_dapm_widget *widget, { struct snd_soc_card *card = widget->dapm->card; struct snd_soc_pcm_runtime *rtd; - struct snd_soc_codec *codec; + struct snd_soc_component *component; rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec = rtd->codec; - return rear_amp_power(codec, SND_SOC_DAPM_EVENT_ON(event)); + component = rtd->codec_dai->component; + return rear_amp_power(component, SND_SOC_DAPM_EVENT_ON(event)); } /* mioa701 machine dapm widgets */ @@ -129,13 +129,13 @@ static const struct snd_soc_dapm_route audio_map[] = { static int mioa701_wm9713_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_component *component = rtd->codec_dai->component; /* Prepare GPIO8 for rear speaker amplifier */ - snd_soc_update_bits(codec, AC97_GPIO_CFG, 0x100, 0x100); + snd_soc_component_update_bits(component, AC97_GPIO_CFG, 0x100, 0x100); /* Prepare MIC input */ - snd_soc_update_bits(codec, AC97_3D_CONTROL, 0xc000, 0xc000); + snd_soc_component_update_bits(component, AC97_3D_CONTROL, 0xc000, 0xc000); return 0; } From e21358c43b426301aefef27c498eee2e2525b3ce Mon Sep 17 00:00:00 2001 From: "Mukunda, Vijendar" Date: Fri, 16 Feb 2018 13:03:46 +0530 Subject: [PATCH 324/942] ASoC: amd: renaming pcm substream names and bytescount params With in ACP, There are three I2S controllers can be configured. (I2S SP ,I2S MICSP and I2S BT).These controllers can support both playback/capture scenarios. Default enabled i2s controller instance is i2s sp instance. Renamed stream names and bytescount params as i2ssp. These changes required to distinguish with other I2S controller instance pcm substreams and bytescount params. Signed-off-by: Vijendar Mukunda Reviewed-by: Alex Deucher Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 49 +++++++++++++++++++------------------ sound/soc/amd/acp.h | 8 +++--- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index c33a512283a4..3c39a0d8125d 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -662,7 +662,7 @@ static irqreturn_t dma_irq_handler(int irq, void *arg) 1, 0); acp_dma_start(acp_mmio, SYSRAM_TO_ACP_CH_NUM, false); - snd_pcm_period_elapsed(irq_data->play_stream); + snd_pcm_period_elapsed(irq_data->play_i2ssp_stream); acp_reg_write((intr_flag & BIT(ACP_TO_I2S_DMA_CH_NUM)) << 16, acp_mmio, mmACP_EXTERNAL_INTR_STAT); @@ -685,7 +685,7 @@ static irqreturn_t dma_irq_handler(int irq, void *arg) if ((intr_flag & BIT(ACP_TO_SYSRAM_CH_NUM)) != 0) { valid_irq = true; - snd_pcm_period_elapsed(irq_data->capture_stream); + snd_pcm_period_elapsed(irq_data->capture_i2ssp_stream); acp_reg_write((intr_flag & BIT(ACP_TO_SYSRAM_CH_NUM)) << 16, acp_mmio, mmACP_EXTERNAL_INTR_STAT); } @@ -743,11 +743,11 @@ static int acp_dma_open(struct snd_pcm_substream *substream) * This enablement is not required for another stream, if current * stream is not closed */ - if (!intr_data->play_stream && !intr_data->capture_stream) + if (!intr_data->play_i2ssp_stream && !intr_data->capture_i2ssp_stream) acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - intr_data->play_stream = substream; + intr_data->play_i2ssp_stream = substream; /* For Stoney, Memory gating is disabled,i.e SRAM Banks * won't be turned off. The default state for SRAM banks is ON. * Setting SRAM bank state code skipped for STONEY platform. @@ -758,7 +758,7 @@ static int acp_dma_open(struct snd_pcm_substream *substream) bank, true); } } else { - intr_data->capture_stream = substream; + intr_data->capture_i2ssp_stream = substream; if (intr_data->asic_type != CHIP_STONEY) { for (bank = 5; bank <= 8; bank++) acp_set_sram_bank_state(intr_data->acp_mmio, @@ -857,11 +857,11 @@ static snd_pcm_uframes_t acp_dma_pointer(struct snd_pcm_substream *substream) bytescount = acp_get_byte_count(rtd->acp_mmio, substream->stream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (bytescount > rtd->renderbytescount) - bytescount = bytescount - rtd->renderbytescount; + if (bytescount > rtd->i2ssp_renderbytescount) + bytescount = bytescount - rtd->i2ssp_renderbytescount; } else { - if (bytescount > rtd->capturebytescount) - bytescount = bytescount - rtd->capturebytescount; + if (bytescount > rtd->i2ssp_capturebytescount) + bytescount = bytescount - rtd->i2ssp_capturebytescount; } pos = do_div(bytescount, buffersize); return bytes_to_frames(runtime, pos); @@ -917,8 +917,8 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) bytescount = acp_get_byte_count(rtd->acp_mmio, substream->stream); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (rtd->renderbytescount == 0) - rtd->renderbytescount = bytescount; + if (rtd->i2ssp_renderbytescount == 0) + rtd->i2ssp_renderbytescount = bytescount; acp_dma_start(rtd->acp_mmio, SYSRAM_TO_ACP_CH_NUM, false); while (acp_reg_read(rtd->acp_mmio, mmACP_DMA_CH_STS) & @@ -935,8 +935,8 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) ACP_TO_I2S_DMA_CH_NUM, true); } else { - if (rtd->capturebytescount == 0) - rtd->capturebytescount = bytescount; + if (rtd->i2ssp_capturebytescount == 0) + rtd->i2ssp_capturebytescount = bytescount; acp_dma_start(rtd->acp_mmio, I2S_TO_ACP_DMA_CH_NUM, true); } @@ -953,11 +953,11 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { ret = acp_dma_stop(rtd->acp_mmio, ACP_TO_I2S_DMA_CH_NUM); - rtd->renderbytescount = 0; + rtd->i2ssp_renderbytescount = 0; } else { ret = acp_dma_stop(rtd->acp_mmio, I2S_TO_ACP_DMA_CH_NUM); - rtd->capturebytescount = 0; + rtd->i2ssp_capturebytescount = 0; } break; default: @@ -1003,7 +1003,7 @@ static int acp_dma_close(struct snd_pcm_substream *substream) kfree(rtd); if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - adata->play_stream = NULL; + adata->play_i2ssp_stream = NULL; /* For Stoney, Memory gating is disabled,i.e SRAM Banks * won't be turned off. The default state for SRAM banks is ON. * Setting SRAM bank state code skipped for STONEY platform. @@ -1015,7 +1015,7 @@ static int acp_dma_close(struct snd_pcm_substream *substream) false); } } else { - adata->capture_stream = NULL; + adata->capture_i2ssp_stream = NULL; if (adata->asic_type != CHIP_STONEY) { for (bank = 5; bank <= 8; bank++) acp_set_sram_bank_state(adata->acp_mmio, bank, @@ -1026,7 +1026,7 @@ static int acp_dma_close(struct snd_pcm_substream *substream) /* Disable ACP irq, when the current stream is being closed and * another stream is also not active. */ - if (!adata->play_stream && !adata->capture_stream) + if (!adata->play_i2ssp_stream && !adata->capture_i2ssp_stream) acp_reg_write(0, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); return 0; @@ -1076,8 +1076,9 @@ static int acp_audio_probe(struct platform_device *pdev) * and device doesn't generate any interrupts. */ - audio_drv_data->play_stream = NULL; - audio_drv_data->capture_stream = NULL; + audio_drv_data->play_i2ssp_stream = NULL; + audio_drv_data->capture_i2ssp_stream = NULL; + audio_drv_data->asic_type = *pdata; res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); @@ -1141,7 +1142,7 @@ static int acp_pcm_resume(struct device *dev) return status; } - if (adata->play_stream && adata->play_stream->runtime) { + if (adata->play_i2ssp_stream && adata->play_i2ssp_stream->runtime) { /* For Stoney, Memory gating is disabled,i.e SRAM Banks * won't be turned off. The default state for SRAM banks is ON. * Setting SRAM bank state code skipped for STONEY platform. @@ -1152,17 +1153,17 @@ static int acp_pcm_resume(struct device *dev) true); } config_acp_dma(adata->acp_mmio, - adata->play_stream->runtime->private_data, + adata->play_i2ssp_stream->runtime->private_data, adata->asic_type); } - if (adata->capture_stream && adata->capture_stream->runtime) { + if (adata->capture_i2ssp_stream && adata->capture_i2ssp_stream->runtime) { if (adata->asic_type != CHIP_STONEY) { for (bank = 5; bank <= 8; bank++) acp_set_sram_bank_state(adata->acp_mmio, bank, true); } config_acp_dma(adata->acp_mmio, - adata->capture_stream->runtime->private_data, + adata->capture_i2ssp_stream->runtime->private_data, adata->asic_type); } acp_reg_write(1, adata->acp_mmio, mmACP_EXTERNAL_INTR_ENB); diff --git a/sound/soc/amd/acp.h b/sound/soc/amd/acp.h index ecb458935d1e..27803b26fc35 100644 --- a/sound/soc/amd/acp.h +++ b/sound/soc/amd/acp.h @@ -84,14 +84,14 @@ struct audio_substream_data { u16 num_of_pages; u16 direction; uint64_t size; - u64 renderbytescount; - u64 capturebytescount; + u64 i2ssp_renderbytescount; + u64 i2ssp_capturebytescount; void __iomem *acp_mmio; }; struct audio_drv_data { - struct snd_pcm_substream *play_stream; - struct snd_pcm_substream *capture_stream; + struct snd_pcm_substream *play_i2ssp_stream; + struct snd_pcm_substream *capture_i2ssp_stream; void __iomem *acp_mmio; u32 asic_type; }; From 4376a86caa5f7011969801f41c4c2230c1685c23 Mon Sep 17 00:00:00 2001 From: "Mukunda, Vijendar" Date: Fri, 16 Feb 2018 13:03:47 +0530 Subject: [PATCH 325/942] ASoC: amd: Coding style changes for acp dma driver Removed hardcoding in dma descriptor programming api's. These changes are required to extend the logic to support dma descriptor programming for multiple i2s controller instances. Signed-off-by: Vijendar Mukunda Reviewed-by: Alex Deucher Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 124 ++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 63 deletions(-) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 3c39a0d8125d..935c8fd42a7a 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -182,19 +182,18 @@ static void config_dma_descriptor_in_sram(void __iomem *acp_mmio, * system memory <-> ACP SRAM */ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, - u32 size, int direction, - u32 pte_offset, u32 asic_type) + u32 size, int direction, u32 pte_offset, + u16 ch, u32 sram_bank, + u16 dma_dscr_idx, u32 asic_type) { u16 i; - u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; acp_dma_dscr_transfer_t dmadscr[NUM_DSCRS_PER_CHANNEL]; for (i = 0; i < NUM_DSCRS_PER_CHANNEL; i++) { dmadscr[i].xfer_val = 0; if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12 + i; - dmadscr[i].dest = ACP_SHARED_RAM_BANK_1_ADDRESS - + (i * (size/2)); + dma_dscr_idx = dma_dscr_idx + i; + dmadscr[i].dest = sram_bank + (i * (size/2)); dmadscr[i].src = ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + (pte_offset * SZ_4K) + (i * (size/2)); switch (asic_type) { @@ -209,25 +208,19 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, (size / 2); } } else { - dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14 + i; + dma_dscr_idx = dma_dscr_idx + i; + dmadscr[i].src = sram_bank + (i * (size/2)); + dmadscr[i].dest = + ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + + (pte_offset * SZ_4K) + (i * (size/2)); switch (asic_type) { case CHIP_STONEY: - dmadscr[i].src = ACP_SHARED_RAM_BANK_3_ADDRESS + - (i * (size/2)); - dmadscr[i].dest = - ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + - (pte_offset * SZ_4K) + (i * (size/2)); dmadscr[i].xfer_val |= BIT(22) | (ACP_DMA_ATTRIBUTES_SHARED_MEM_TO_DAGB_GARLIC << 16) | (size / 2); break; default: - dmadscr[i].src = ACP_SHARED_RAM_BANK_5_ADDRESS + - (i * (size/2)); - dmadscr[i].dest = - ACP_INTERNAL_APERTURE_WINDOW_0_ADDRESS + - (pte_offset * SZ_4K) + (i * (size/2)); dmadscr[i].xfer_val |= BIT(22) | (ACP_DMA_ATTRIBUTES_SHAREDMEM_TO_DAGB_ONION << 16) | @@ -237,72 +230,49 @@ static void set_acp_sysmem_dma_descriptors(void __iomem *acp_mmio, config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx, &dmadscr[i]); } - if (direction == SNDRV_PCM_STREAM_PLAYBACK) - config_acp_dma_channel(acp_mmio, SYSRAM_TO_ACP_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH12, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); - else - config_acp_dma_channel(acp_mmio, ACP_TO_SYSRAM_CH_NUM, - CAPTURE_START_DMA_DESCR_CH14, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); + config_acp_dma_channel(acp_mmio, ch, + dma_dscr_idx - 1, + NUM_DSCRS_PER_CHANNEL, + ACP_DMA_PRIORITY_LEVEL_NORMAL); } /* Initialize the DMA descriptor information for transfer between * ACP SRAM <-> I2S */ -static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, - u32 size, int direction, - u32 asic_type) +static void set_acp_to_i2s_dma_descriptors(void __iomem *acp_mmio, u32 size, + int direction, u32 sram_bank, + u16 destination, u16 ch, + u16 dma_dscr_idx, u32 asic_type) { u16 i; - u16 dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13; acp_dma_dscr_transfer_t dmadscr[NUM_DSCRS_PER_CHANNEL]; for (i = 0; i < NUM_DSCRS_PER_CHANNEL; i++) { dmadscr[i].xfer_val = 0; if (direction == SNDRV_PCM_STREAM_PLAYBACK) { - dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13 + i; - dmadscr[i].src = ACP_SHARED_RAM_BANK_1_ADDRESS + - (i * (size/2)); + dma_dscr_idx = dma_dscr_idx + i; + dmadscr[i].src = sram_bank + (i * (size/2)); /* dmadscr[i].dest is unused by hardware. */ dmadscr[i].dest = 0; - dmadscr[i].xfer_val |= BIT(22) | (TO_ACP_I2S_1 << 16) | + dmadscr[i].xfer_val |= BIT(22) | (destination << 16) | (size / 2); } else { - dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15 + i; + dma_dscr_idx = dma_dscr_idx + i; /* dmadscr[i].src is unused by hardware. */ dmadscr[i].src = 0; - switch (asic_type) { - case CHIP_STONEY: - dmadscr[i].dest = - ACP_SHARED_RAM_BANK_3_ADDRESS + - (i * (size / 2)); - break; - default: - dmadscr[i].dest = - ACP_SHARED_RAM_BANK_5_ADDRESS + - (i * (size / 2)); - } + dmadscr[i].dest = + sram_bank + (i * (size / 2)); dmadscr[i].xfer_val |= BIT(22) | - (FROM_ACP_I2S_1 << 16) | (size / 2); + (destination << 16) | (size / 2); } config_dma_descriptor_in_sram(acp_mmio, dma_dscr_idx, &dmadscr[i]); } /* Configure the DMA channel with the above descriptore */ - if (direction == SNDRV_PCM_STREAM_PLAYBACK) - config_acp_dma_channel(acp_mmio, ACP_TO_I2S_DMA_CH_NUM, - PLAYBACK_START_DMA_DESCR_CH13, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); - else - config_acp_dma_channel(acp_mmio, I2S_TO_ACP_DMA_CH_NUM, - CAPTURE_START_DMA_DESCR_CH15, - NUM_DSCRS_PER_CHANNEL, - ACP_DMA_PRIORITY_LEVEL_NORMAL); + config_acp_dma_channel(acp_mmio, ch, dma_dscr_idx - 1, + NUM_DSCRS_PER_CHANNEL, + ACP_DMA_PRIORITY_LEVEL_NORMAL); } /* Create page table entries in ACP SRAM for the allocated memory */ @@ -344,23 +314,51 @@ static void config_acp_dma(void __iomem *acp_mmio, struct audio_substream_data *audio_config, u32 asic_type) { - u32 pte_offset; + u32 pte_offset, sram_bank; + u16 ch1, ch2, destination, dma_dscr_idx; - if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) + if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) { pte_offset = ACP_PLAYBACK_PTE_OFFSET; - else + ch1 = SYSRAM_TO_ACP_CH_NUM; + ch2 = ACP_TO_I2S_DMA_CH_NUM; + sram_bank = ACP_SHARED_RAM_BANK_1_ADDRESS; + destination = TO_ACP_I2S_1; + + } else { pte_offset = ACP_CAPTURE_PTE_OFFSET; + ch1 = SYSRAM_TO_ACP_CH_NUM; + ch2 = ACP_TO_I2S_DMA_CH_NUM; + switch (asic_type) { + case CHIP_STONEY: + sram_bank = ACP_SHARED_RAM_BANK_3_ADDRESS; + break; + default: + sram_bank = ACP_SHARED_RAM_BANK_5_ADDRESS; + } + destination = FROM_ACP_I2S_1; + } acp_pte_config(acp_mmio, audio_config->pg, audio_config->num_of_pages, pte_offset); + if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) + dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH12; + else + dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH14; /* Configure System memory <-> ACP SRAM DMA descriptors */ set_acp_sysmem_dma_descriptors(acp_mmio, audio_config->size, - audio_config->direction, pte_offset, asic_type); + audio_config->direction, pte_offset, + ch1, sram_bank, dma_dscr_idx, asic_type); + if (audio_config->direction == SNDRV_PCM_STREAM_PLAYBACK) + dma_dscr_idx = PLAYBACK_START_DMA_DESCR_CH13; + else + dma_dscr_idx = CAPTURE_START_DMA_DESCR_CH15; /* Configure ACP SRAM <-> I2S DMA descriptors */ set_acp_to_i2s_dma_descriptors(acp_mmio, audio_config->size, - audio_config->direction, asic_type); + audio_config->direction, sram_bank, + destination, ch2, dma_dscr_idx, + asic_type); } /* Start a given DMA channel transfer */ From ba7a3a971d2726affba6335496b5452a6e288e61 Mon Sep 17 00:00:00 2001 From: Akshu Agrawal Date: Fri, 16 Feb 2018 13:11:12 +0530 Subject: [PATCH 326/942] ASoC: ADAU7002: Adding ACPI id Adding ACPI entry id for probing the driver. Signed-off-by: Akshu Agrawal Reviewed-by: Alex Deucher Signed-off-by: Mark Brown --- sound/soc/codecs/adau7002.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/soc/codecs/adau7002.c b/sound/soc/codecs/adau7002.c index 49475e36a4e4..fdff86878287 100644 --- a/sound/soc/codecs/adau7002.c +++ b/sound/soc/codecs/adau7002.c @@ -7,6 +7,7 @@ * Licensed under the GPL-2. */ +#include #include #include #include @@ -69,10 +70,19 @@ static const struct of_device_id adau7002_dt_ids[] = { MODULE_DEVICE_TABLE(of, adau7002_dt_ids); #endif +#ifdef CONFIG_ACPI +static const struct acpi_device_id adau7002_acpi_match[] = { + { "ADAU7002", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(acpi, adau7002_acpi_match); +#endif + static struct platform_driver adau7002_driver = { .driver = { .name = "adau7002", .of_match_table = of_match_ptr(adau7002_dt_ids), + .acpi_match_table = ACPI_PTR(adau7002_acpi_match), }, .probe = adau7002_probe, .remove = adau7002_remove, From 013cb81e89f8a70deef086ca29a923faf5585ab0 Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Mon, 19 Feb 2018 07:44:07 +0100 Subject: [PATCH 327/942] xfrm: Fix infinite loop in xfrm_get_dst_nexthop with transport mode. On transport mode we forget to fetch the child dst_entry before we continue the while loop, this leads to an infinite loop. Fix this by fetching the child dst_entry before we continue the while loop. Fixes: 0f6c480f23f4 ("xfrm: Move dst->path into struct xfrm_dst") Reported-by: syzbot+7d03c810e50aaedef98a@syzkaller.appspotmail.com Tested-by: Florian Westphal Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_policy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 150d46633ce6..625b3fca5704 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c @@ -2732,14 +2732,14 @@ static const void *xfrm_get_dst_nexthop(const struct dst_entry *dst, while (dst->xfrm) { const struct xfrm_state *xfrm = dst->xfrm; + dst = xfrm_dst_child(dst); + if (xfrm->props.mode == XFRM_MODE_TRANSPORT) continue; if (xfrm->type->flags & XFRM_TYPE_REMOTE_COADDR) daddr = xfrm->coaddr; else if (!(xfrm->type->flags & XFRM_TYPE_LOCAL_COADDR)) daddr = &xfrm->id.daddr; - - dst = xfrm_dst_child(dst); } return daddr; } From 09ad28a31c27df439e838ee5700d4e2dfea0e462 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Tue, 20 Feb 2018 18:53:10 +0900 Subject: [PATCH 328/942] ASoC: uniphier: evea: fix typo 'eva' -> 'evea' Signed-off-by: Katsuhiro Suzuki Reviewed-by: Masami Hiramatsu Signed-off-by: Mark Brown --- sound/soc/uniphier/evea.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/uniphier/evea.c b/sound/soc/uniphier/evea.c index cad7e60de21d..ac2d30b55fb6 100644 --- a/sound/soc/uniphier/evea.c +++ b/sound/soc/uniphier/evea.c @@ -292,7 +292,7 @@ static int evea_set_switch_hp(struct snd_kcontrol *kcontrol, return evea_update_switch_hp(evea); } -static const struct snd_kcontrol_new eva_controls[] = { +static const struct snd_kcontrol_new evea_controls[] = { SOC_SINGLE_BOOL_EXT("Line Capture Switch", 0, evea_get_switch_lin, evea_set_switch_lin), SOC_SINGLE_BOOL_EXT("Line Playback Switch", 0, @@ -384,8 +384,8 @@ static struct snd_soc_component_driver soc_codec_evea = { .num_dapm_widgets = ARRAY_SIZE(evea_widgets), .dapm_routes = evea_routes, .num_dapm_routes = ARRAY_SIZE(evea_routes), - .controls = eva_controls, - .num_controls = ARRAY_SIZE(eva_controls), + .controls = evea_controls, + .num_controls = ARRAY_SIZE(evea_controls), .idle_bias_on = 1, .use_pmdown_time = 1, .endianness = 1, From 05aa6165cfdb796916197da6b8ef93b22a62e3a9 Mon Sep 17 00:00:00 2001 From: Cosmin-Gabriel Samoila Date: Tue, 20 Feb 2018 10:56:07 +0200 Subject: [PATCH 329/942] ASoC: ak4458: Modify SPDX license format Modify SPDX comment style to match the rules. Since the original code had a GPL-2.0 license and SPDX is compatible with GPL-2.0+, we also modified the MODULE_LICENSE. Signed-off-by: Cosmin-Gabriel Samoila Signed-off-by: Mark Brown --- sound/soc/codecs/ak4458.c | 13 ++++++------- sound/soc/codecs/ak4458.h | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index d2815ac9cffa..8a49dd24e6b7 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -1,10 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -/* - * Audio driver for AK4458 DAC - * - * Copyright (C) 2016 Asahi Kasei Microdevices Corporation - * Copyright 2018 NXP - */ +// +// Audio driver for AK4458 DAC +// +// Copyright (C) 2016 Asahi Kasei Microdevices Corporation +// Copyright 2018 NXP #include #include @@ -655,4 +654,4 @@ module_i2c_driver(ak4458_i2c_driver); MODULE_AUTHOR("Junichi Wakasugi "); MODULE_AUTHOR("Mihai Serban "); MODULE_DESCRIPTION("ASoC AK4458 DAC driver"); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/codecs/ak4458.h b/sound/soc/codecs/ak4458.h index 16d9d22a413a..f906215f7e4e 100644 --- a/sound/soc/codecs/ak4458.h +++ b/sound/soc/codecs/ak4458.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Audio driver for AK4458 * From de03af56602a3b57bfef958045a4d43ad50db46a Mon Sep 17 00:00:00 2001 From: Cosmin-Gabriel Samoila Date: Tue, 20 Feb 2018 10:56:08 +0200 Subject: [PATCH 330/942] ASoC: ak4458: Sort headers alphabetically Keep headers sorted alphabetically. Signed-off-by: Cosmin-Gabriel Samoila Signed-off-by: Mark Brown --- sound/soc/codecs/ak4458.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c index 8a49dd24e6b7..31ec0ba2e639 100644 --- a/sound/soc/codecs/ak4458.c +++ b/sound/soc/codecs/ak4458.c @@ -5,19 +5,19 @@ // Copyright (C) 2016 Asahi Kasei Microdevices Corporation // Copyright 2018 NXP -#include #include -#include #include +#include +#include #include #include #include -#include +#include +#include +#include #include #include -#include #include -#include #include "ak4458.h" From 01182d6529ae499bb73129f4766b45c2ae8e700b Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 19 Feb 2018 14:45:57 +0100 Subject: [PATCH 331/942] ASoC: Add DT bindings documentation for max9759 amplifier This patch adds DT bindings documentation for Maxim MAX9759 speaker amplifier. Signed-off-by: Neil Armstrong Reviewed-by: Rob Herring Signed-off-by: Mark Brown --- .../bindings/sound/maxim,max9759.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/maxim,max9759.txt diff --git a/Documentation/devicetree/bindings/sound/maxim,max9759.txt b/Documentation/devicetree/bindings/sound/maxim,max9759.txt new file mode 100644 index 000000000000..737a996374d3 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/maxim,max9759.txt @@ -0,0 +1,18 @@ +Maxim MAX9759 Speaker Amplifier +=============================== + +Required properties: +- compatible : "maxim,max9759" +- shutdown-gpios : the gpio connected to the shutdown pin +- mute-gpios : the gpio connected to the mute pin +- gain-gpios : the 2 gpios connected to the g1 and g2 pins + +Example: + +max9759: analog-amplifier { + compatible = "maxim,max9759"; + shutdown-gpios = <&gpio3 20 GPIO_ACTIVE_LOW>; + mute-gpios = <&gpio3 19 GPIO_ACTIVE_LOW>; + gain-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>, + <&gpio3 25 GPIO_ACTIVE_LOW>; +}; From fa8d915172b8c10ec0734c4021e99e9705023b07 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 19 Feb 2018 14:45:58 +0100 Subject: [PATCH 332/942] ASoC: max9759: Add Amplifier Driver The max9759 is a gpio controlled amplifier. Tested on a Variscite Dart MX6 SoM based custom board. Signed-off-by: Neil Armstrong Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 5 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/max9759.c | 207 +++++++++++++++++++++++++++++++++++++ 3 files changed, 214 insertions(+) create mode 100644 sound/soc/codecs/max9759.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..f9ea4603a903 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -98,6 +98,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_MAX98373 if I2C select SND_SOC_MAX9850 if I2C select SND_SOC_MAX9860 if I2C + select SND_SOC_MAX9759 select SND_SOC_MAX9768 if I2C select SND_SOC_MAX9877 if I2C select SND_SOC_MC13783 if MFD_MC13XXX @@ -1187,6 +1188,10 @@ config SND_SOC_ZX_AUD96P22 config SND_SOC_LM4857 tristate +config SND_SOC_MAX9759 + tristate "Maxim MAX9759 speaker Amplifier" + select GPIOLIB + config SND_SOC_MAX9768 tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..af4238d90c99 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -80,6 +80,7 @@ snd-soc-jz4740-codec-objs := jz4740.o snd-soc-l3-objs := l3.o snd-soc-lm4857-objs := lm4857.o snd-soc-lm49453-objs := lm49453.o +snd-soc-max9759-objs := max9759.o snd-soc-max9768-objs := max9768.o snd-soc-max98088-objs := max98088.o snd-soc-max98090-objs := max98090.o @@ -325,6 +326,7 @@ obj-$(CONFIG_SND_SOC_JZ4740_CODEC) += snd-soc-jz4740-codec.o obj-$(CONFIG_SND_SOC_L3) += snd-soc-l3.o obj-$(CONFIG_SND_SOC_LM4857) += snd-soc-lm4857.o obj-$(CONFIG_SND_SOC_LM49453) += snd-soc-lm49453.o +obj-$(CONFIG_SND_SOC_MAX9759) += snd-soc-max9759.o obj-$(CONFIG_SND_SOC_MAX9768) += snd-soc-max9768.o obj-$(CONFIG_SND_SOC_MAX98088) += snd-soc-max98088.o obj-$(CONFIG_SND_SOC_MAX98090) += snd-soc-max98090.o diff --git a/sound/soc/codecs/max9759.c b/sound/soc/codecs/max9759.c new file mode 100644 index 000000000000..ecfb4a80424b --- /dev/null +++ b/sound/soc/codecs/max9759.c @@ -0,0 +1,207 @@ +// SPDX-Licence-Identifier: GPL-2.0 +/* + * MAX9759 Amplifier Driver + * + * Copyright (c) 2017 BayLibre, SAS. + * Author: Neil Armstrong + */ + +#include +#include +#include +#include +#include + +#define DRV_NAME "max9759" + +struct max9759 { + struct gpio_desc *gpiod_shutdown; + struct gpio_desc *gpiod_mute; + struct gpio_descs *gpiod_gain; + bool is_mute; + unsigned int gain; +}; + +static int pga_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *control, int event) +{ + struct snd_soc_component *c = snd_soc_dapm_to_component(w->dapm); + struct max9759 *priv = snd_soc_component_get_drvdata(c); + + if (SND_SOC_DAPM_EVENT_ON(event)) + gpiod_set_value_cansleep(priv->gpiod_shutdown, 0); + else + gpiod_set_value_cansleep(priv->gpiod_shutdown, 1); + + return 0; +} + +/* From 6dB to 24dB in steps of 6dB */ +static const DECLARE_TLV_DB_SCALE(speaker_gain_tlv, 600, 600, 0); + +static int speaker_gain_control_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct max9759 *priv = snd_soc_component_get_drvdata(c); + + ucontrol->value.integer.value[0] = priv->gain; + + return 0; +} + +static const bool speaker_gain_table[4][2] = { + /* G1, G2 */ + {true, true}, /* +6dB */ + {false, true}, /* +12dB */ + {true, false}, /* +18dB */ + {false, false}, /* +24dB */ +}; + +static int speaker_gain_control_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct max9759 *priv = snd_soc_component_get_drvdata(c); + + if (ucontrol->value.integer.value[0] > 3) + return -EINVAL; + + priv->gain = ucontrol->value.integer.value[0]; + + /* G1 */ + gpiod_set_value_cansleep(priv->gpiod_gain->desc[0], + speaker_gain_table[priv->gain][0]); + /* G2 */ + gpiod_set_value_cansleep(priv->gpiod_gain->desc[1], + speaker_gain_table[priv->gain][1]); + + return 1; +} + +static int speaker_mute_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct max9759 *priv = snd_soc_component_get_drvdata(c); + + ucontrol->value.integer.value[0] = !priv->is_mute; + + return 0; +} + +static int speaker_mute_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol); + struct max9759 *priv = snd_soc_component_get_drvdata(c); + + priv->is_mute = !ucontrol->value.integer.value[0]; + + gpiod_set_value_cansleep(priv->gpiod_mute, priv->is_mute); + + return 1; +} + +static const struct snd_kcontrol_new max9759_dapm_controls[] = { + SOC_SINGLE_EXT_TLV("Speaker Gain Volume", 0, 0, 3, 0, + speaker_gain_control_get, speaker_gain_control_put, + speaker_gain_tlv), + SOC_SINGLE_BOOL_EXT("Playback Switch", 0, + speaker_mute_get, speaker_mute_put), +}; + +static const struct snd_soc_dapm_widget max9759_dapm_widgets[] = { + SND_SOC_DAPM_INPUT("INL"), + SND_SOC_DAPM_INPUT("INR"), + SND_SOC_DAPM_PGA_E("PGA", SND_SOC_NOPM, 0, 0, NULL, 0, pga_event, + (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD)), + SND_SOC_DAPM_OUTPUT("OUTL"), + SND_SOC_DAPM_OUTPUT("OUTR"), +}; + +static const struct snd_soc_dapm_route max9759_dapm_routes[] = { + { "PGA", NULL, "INL" }, + { "PGA", NULL, "INR" }, + { "OUTL", NULL, "PGA" }, + { "OUTR", NULL, "PGA" }, +}; + +static const struct snd_soc_component_driver max9759_component_driver = { + .controls = max9759_dapm_controls, + .num_controls = ARRAY_SIZE(max9759_dapm_controls), + .dapm_widgets = max9759_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(max9759_dapm_widgets), + .dapm_routes = max9759_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(max9759_dapm_routes), +}; + +static int max9759_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct max9759 *priv; + int err; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + platform_set_drvdata(pdev, priv); + + priv->gpiod_shutdown = devm_gpiod_get(dev, "shutdown", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_shutdown)) { + err = PTR_ERR(priv->gpiod_shutdown); + if (err != -EPROBE_DEFER) + dev_err(dev, "Failed to get 'shutdown' gpio: %d", err); + return err; + } + + priv->gpiod_mute = devm_gpiod_get(dev, "mute", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_mute)) { + err = PTR_ERR(priv->gpiod_mute); + if (err != -EPROBE_DEFER) + dev_err(dev, "Failed to get 'mute' gpio: %d", err); + return err; + } + priv->is_mute = true; + + priv->gpiod_gain = devm_gpiod_get_array(dev, "gain", GPIOD_OUT_HIGH); + if (IS_ERR(priv->gpiod_gain)) { + err = PTR_ERR(priv->gpiod_gain); + if (err != -EPROBE_DEFER) + dev_err(dev, "Failed to get 'gain' gpios: %d", err); + return err; + } + priv->gain = 0; + + if (priv->gpiod_gain->ndescs != 2) { + dev_err(dev, "Invalid 'gain' gpios count: %d", + priv->gpiod_gain->ndescs); + return -EINVAL; + } + + return devm_snd_soc_register_component(dev, &max9759_component_driver, + NULL, 0); +} + +#ifdef CONFIG_OF +static const struct of_device_id max9759_ids[] = { + { .compatible = "maxim,max9759", }, + { } +}; +MODULE_DEVICE_TABLE(of, max9759_ids); +#endif + +static struct platform_driver max9759_driver = { + .driver = { + .name = DRV_NAME, + .of_match_table = of_match_ptr(max9759_ids), + }, + .probe = max9759_probe, +}; + +module_platform_driver(max9759_driver); + +MODULE_DESCRIPTION("ASoC MAX9759 amplifier driver"); +MODULE_AUTHOR("Neil Armstrong "); +MODULE_LICENSE("GPL"); From f1c680f5ef7ad3211bf1ae5630bd6a8219534e3c Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 20 Feb 2018 14:30:10 +0200 Subject: [PATCH 333/942] ASoC: hdmi-codec: Fix module unloading caused kernel crash The hcp->chmap_info must not be freed up in the hdmi_codec_remove() function as it leads to kernel crash due ALSA core's pcm_chmap_ctl_private_free() is trying to free it up again when the card destroyed via snd_card_free. Since the driver was converted to devm_snd_soc_register_component() the whole platform_device.remove can be removed. Commit cd6111b26280a ("ASoC: hdmi-codec: add channel mapping control") should not have added the kfree(hcp->chmap_info); to the hdmi_codec_remove function. [Separate verison of the fix for -next -- broonie] Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/hdmi-codec.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 42df579cb507..6fa11888672d 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -798,23 +798,11 @@ static int hdmi_codec_probe(struct platform_device *pdev) return 0; } -static int hdmi_codec_remove(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct hdmi_codec_priv *hcp; - - hcp = dev_get_drvdata(dev); - kfree(hcp->chmap_info); - - return 0; -} - static struct platform_driver hdmi_codec_driver = { .driver = { .name = HDMI_CODEC_DRV_NAME, }, .probe = hdmi_codec_probe, - .remove = hdmi_codec_remove, }; module_platform_driver(hdmi_codec_driver); From af3acca3e35c01920fe476f730dca7345d0a48df Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Tue, 20 Feb 2018 14:53:10 +0200 Subject: [PATCH 334/942] ASoC: ak5558: Fix style for SPDX identifier Use // for .c and /* for .h files according to: Documentation/process/license-rules.rst file. Signed-off-by: Daniel Baluta Signed-off-by: Mark Brown --- sound/soc/codecs/ak5558.c | 11 +++++------ sound/soc/codecs/ak5558.h | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c index f2248315677e..f4ed5cc40661 100644 --- a/sound/soc/codecs/ak5558.c +++ b/sound/soc/codecs/ak5558.c @@ -1,10 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 -/* - * Audio driver for AK5558 ADC - * - * Copyright (C) 2015 Asahi Kasei Microdevices Corporation - * Copyright 2018 NXP - */ +// +// Audio driver for AK5558 ADC +// +// Copyright (C) 2015 Asahi Kasei Microdevices Corporation +// Copyright 2018 NXP #include #include diff --git a/sound/soc/codecs/ak5558.h b/sound/soc/codecs/ak5558.h index 7c9e37374f39..61059086f161 100644 --- a/sound/soc/codecs/ak5558.h +++ b/sound/soc/codecs/ak5558.h @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -/* +/* SPDX-License-Identifier: GPL-2.0 + * * Audio driver header for AK5558 * * Copyright (C) 2016 Asahi Kasei Microdevices Corporation From b17e5729a630d8326a48ec34ef02e6b4464a6aef Mon Sep 17 00:00:00 2001 From: Kai-Heng Feng Date: Sun, 18 Feb 2018 22:17:09 +0800 Subject: [PATCH 335/942] libata: disable LPM for Crucial BX100 SSD 500GB drive After Laptop Mode Tools starts to use min_power for LPM, a user found out Crucial BX100 SSD can't get mounted. Crucial BX100 SSD 500GB drive don't work well with min_power. This also happens to med_power_with_dipm. So let's disable LPM for Crucial BX100 SSD 500GB drive. BugLink: https://bugs.launchpad.net/bugs/1726930 Signed-off-by: Kai-Heng Feng Signed-off-by: Tejun Heo Cc: stable@vger.kernel.org --- drivers/ata/libata-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 28cad49fc846..cb789f8849ae 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4530,6 +4530,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "PIONEER DVD-RW DVR-212D", NULL, ATA_HORKAGE_NOSETXFER }, { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, + /* Crucial BX100 SSD 500GB has broken LPM support */ + { "CT500BX100SSD1", "MU02", ATA_HORKAGE_NOLPM }, + /* The 512GB version of the MX100 has both queued TRIM and LPM issues */ { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM | From 15b7c5de7c0c4f55d529ca71a5a0feca4cf03ab3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 21 Feb 2018 02:06:29 +0000 Subject: [PATCH 336/942] ASoC: dmic: don't use codec anymore commit 6d6c3946d877 ("ASoC: dmic: replace codec to component") replaced codec to component, but commit 05c9b302eda7 ("ASoC: dmic: Add optional wakeup delay") used codec again. This patch fix it up. Fixes: 05c9b302eda7 ("ASoC: dmic: Add optional wakeup delay") Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/dmic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/dmic.c b/sound/soc/codecs/dmic.c index bac5bbb2dd59..8c4926df9286 100644 --- a/sound/soc/codecs/dmic.c +++ b/sound/soc/codecs/dmic.c @@ -37,8 +37,8 @@ struct dmic { static int dmic_aif_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct dmic *dmic = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct dmic *dmic = snd_soc_component_get_drvdata(component); switch (event) { case SND_SOC_DAPM_POST_PMU: From 7dd0f7ca5f23a9c8b4a5b69587b41b413b2ecc2d Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Tue, 20 Feb 2018 16:08:11 +0000 Subject: [PATCH 337/942] ASoC: arizona: Fixup some minor formatting issues Repair any formatting/style issues that can be fixed without major code refactoring. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/arizona.c | 59 ++++++++++++++++++++---------------- sound/soc/codecs/cs47l24.c | 22 +++++++------- sound/soc/codecs/wm5102.c | 20 ++++++------ sound/soc/codecs/wm5110.c | 62 +++++++++++++++++++++----------------- sound/soc/codecs/wm8997.c | 14 ++++----- sound/soc/codecs/wm8998.c | 33 +++++++++++--------- 6 files changed, 113 insertions(+), 97 deletions(-) diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index ffcfe8ea1848..5727ea079ad7 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c @@ -90,7 +90,8 @@ static int arizona_spk_ev(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: - val = snd_soc_component_read32(component, ARIZONA_INTERRUPT_RAW_STATUS_3); + val = snd_soc_component_read32(component, + ARIZONA_INTERRUPT_RAW_STATUS_3); if (val & ARIZONA_SPK_OVERHEAT_STS) { dev_crit(arizona->dev, "Speaker not enabled due to temperature\n"); @@ -641,7 +642,6 @@ const unsigned int arizona_rate_val[ARIZONA_RATE_ENUM_SIZE] = { }; EXPORT_SYMBOL_GPL(arizona_rate_val); - const struct soc_enum arizona_isrc_fsh[] = { SOC_VALUE_ENUM_SINGLE(ARIZONA_ISRC_1_CTRL_1, ARIZONA_ISRC1_FSH_SHIFT, 0xf, @@ -923,7 +923,8 @@ int arizona_in_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, priv->in_pending++; break; case SND_SOC_DAPM_POST_PMU: - snd_soc_component_update_bits(component, reg, ARIZONA_IN1L_MUTE, 0); + snd_soc_component_update_bits(component, reg, + ARIZONA_IN1L_MUTE, 0); /* If this is the last input pending then allow VU */ priv->in_pending--; @@ -1070,9 +1071,8 @@ int arizona_out_ev(struct snd_soc_dapm_widget *w, } EXPORT_SYMBOL_GPL(arizona_out_ev); -int arizona_hp_ev(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, - int event) +int arizona_hp_ev(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, + int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct arizona_priv *priv = snd_soc_component_get_drvdata(component); @@ -1275,8 +1275,8 @@ static unsigned int arizona_opclk_ref_44k1_rates[] = { 45158400, }; -static int arizona_set_opclk(struct snd_soc_component *component, unsigned int clk, - unsigned int freq) +static int arizona_set_opclk(struct snd_soc_component *component, + unsigned int clk, unsigned int freq) { struct arizona_priv *priv = snd_soc_component_get_drvdata(component); unsigned int reg; @@ -1302,7 +1302,7 @@ static int arizona_set_opclk(struct snd_soc_component *component, unsigned int c rates = arizona_opclk_ref_48k_rates; for (ref = 0; ref < ARRAY_SIZE(arizona_opclk_ref_48k_rates) && - rates[ref] <= refclk; ref++) { + rates[ref] <= refclk; ref++) { div = 1; while (rates[ref] / div >= freq && div < 32) { if (rates[ref] / div == freq) { @@ -1727,18 +1727,23 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, } snd_soc_component_update_bits(component, ARIZONA_SAMPLE_RATE_1, - ARIZONA_SAMPLE_RATE_1_MASK, sr_val); + ARIZONA_SAMPLE_RATE_1_MASK, + sr_val); if (base) - snd_soc_component_update_bits(component, base + ARIZONA_AIF_RATE_CTRL, - ARIZONA_AIF1_RATE_MASK, 0); + snd_soc_component_update_bits(component, + base + ARIZONA_AIF_RATE_CTRL, + ARIZONA_AIF1_RATE_MASK, 0); break; case ARIZONA_CLK_ASYNCCLK: - snd_soc_component_update_bits(component, ARIZONA_ASYNC_SAMPLE_RATE_1, - ARIZONA_ASYNC_SAMPLE_RATE_1_MASK, sr_val); + snd_soc_component_update_bits(component, + ARIZONA_ASYNC_SAMPLE_RATE_1, + ARIZONA_ASYNC_SAMPLE_RATE_1_MASK, + sr_val); if (base) - snd_soc_component_update_bits(component, base + ARIZONA_AIF_RATE_CTRL, - ARIZONA_AIF1_RATE_MASK, - 8 << ARIZONA_AIF1_RATE_SHIFT); + snd_soc_component_update_bits(component, + base + ARIZONA_AIF_RATE_CTRL, + ARIZONA_AIF1_RATE_MASK, + 8 << ARIZONA_AIF1_RATE_SHIFT); break; default: arizona_aif_err(dai, "Invalid clock %d\n", dai_priv->clk); @@ -1849,9 +1854,10 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, base + ARIZONA_AIF_RX_ENABLES); /* Disable AIF TX/RX before reconfiguring it */ regmap_update_bits_async(arizona->regmap, - base + ARIZONA_AIF_TX_ENABLES, 0xff, 0x0); + base + ARIZONA_AIF_TX_ENABLES, + 0xff, 0x0); regmap_update_bits(arizona->regmap, - base + ARIZONA_AIF_RX_ENABLES, 0xff, 0x0); + base + ARIZONA_AIF_RX_ENABLES, 0xff, 0x0); } ret = arizona_hw_params_rate(substream, params, dai); @@ -1960,8 +1966,9 @@ static int arizona_set_tristate(struct snd_soc_dai *dai, int tristate) else reg = 0; - return snd_soc_component_update_bits(component, base + ARIZONA_AIF_RATE_CTRL, - ARIZONA_AIF1_TRI, reg); + return snd_soc_component_update_bits(component, + base + ARIZONA_AIF_RATE_CTRL, + ARIZONA_AIF1_TRI, reg); } static void arizona_set_channels_to_mask(struct snd_soc_dai *dai, @@ -2319,7 +2326,6 @@ static int arizona_calc_fll(struct arizona_fll *fll, arizona_fll_dbg(fll, "GAIN=0x%x(%d)\n", cfg->gain, 1 << cfg->gain); return 0; - } static void arizona_apply_fll(struct arizona *arizona, unsigned int base, @@ -2565,9 +2571,8 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source, fll->ref_src = source; fll->ref_freq = Fref; - if (fll->fout && Fref > 0) { + if (fll->fout && Fref > 0) ret = arizona_enable_fll(fll); - } return ret; } @@ -2656,7 +2661,8 @@ EXPORT_SYMBOL_GPL(arizona_init_fll); * Most systems have a single static configuration and should use * platform data instead. */ -int arizona_set_output_mode(struct snd_soc_component *component, int output, bool diff) +int arizona_set_output_mode(struct snd_soc_component *component, int output, + bool diff) { unsigned int reg, val; @@ -2670,7 +2676,8 @@ int arizona_set_output_mode(struct snd_soc_component *component, int output, boo else val = 0; - return snd_soc_component_update_bits(component, reg, ARIZONA_OUT1_MONO, val); + return snd_soc_component_update_bits(component, reg, + ARIZONA_OUT1_MONO, val); } EXPORT_SYMBOL_GPL(arizona_set_output_mode); diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c index c93d3f7e8e36..196e9c343aeb 100644 --- a/sound/soc/codecs/cs47l24.c +++ b/sound/soc/codecs/cs47l24.c @@ -196,14 +196,13 @@ SOC_SINGLE("HPOUT1 SC Protect Switch", ARIZONA_HP1_SHORT_CIRCUIT_CTRL, SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1), SOC_SINGLE("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L, - ARIZONA_OUT4L_MUTE_SHIFT, 1, 1), + ARIZONA_OUT4L_MUTE_SHIFT, 1, 1), SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L, ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT, 0xbf, 0, digital_tlv), SOC_SINGLE_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L, - ARIZONA_OUT4L_VOL_SHIFT, - 0xbf, 0, digital_tlv), + ARIZONA_OUT4L_VOL_SHIFT, 0xbf, 0, digital_tlv), SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), @@ -494,8 +493,7 @@ SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3, ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &cs47l24_aec_loopback_mux), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &cs47l24_aec_loopback_mux), SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0), @@ -931,8 +929,8 @@ static const struct snd_soc_dapm_route cs47l24_dapm_routes[] = { { "DSP3 Voice Trigger", "Switch", "DSP3" }, }; -static int cs47l24_set_fll(struct snd_soc_component *component, int fll_id, int source, - unsigned int Fref, unsigned int Fout) +static int cs47l24_set_fll(struct snd_soc_component *component, int fll_id, + int source, unsigned int Fref, unsigned int Fout) { struct cs47l24_priv *cs47l24 = snd_soc_component_get_drvdata(component); @@ -1144,7 +1142,8 @@ static int cs47l24_component_probe(struct snd_soc_component *component) goto err_adsp2_codec_probe; ret = snd_soc_add_component_controls(component, - &arizona_adsp2_rate_controls[1], 2); + &arizona_adsp2_rate_controls[1], + 2); if (ret) goto err_adsp2_codec_probe; @@ -1214,7 +1213,7 @@ static int cs47l24_probe(struct platform_device *pdev) BUILD_BUG_ON(ARRAY_SIZE(cs47l24_dai) > ARIZONA_MAX_DAI); cs47l24 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l24_priv), - GFP_KERNEL); + GFP_KERNEL); if (!cs47l24) return -ENOMEM; @@ -1294,8 +1293,9 @@ static int cs47l24_probe(struct platform_device *pdev) goto err_dsp_irq; ret = devm_snd_soc_register_component(&pdev->dev, - &soc_component_dev_cs47l24, - cs47l24_dai, ARRAY_SIZE(cs47l24_dai)); + &soc_component_dev_cs47l24, + cs47l24_dai, + ARRAY_SIZE(cs47l24_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 24f19cfc98f5..1ac83388d1b8 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c @@ -620,7 +620,7 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, } static int wm5102_adsp_power_ev(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *kcontrol, int event) + struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct arizona *arizona = dev_get_drvdata(component->dev->parent); @@ -717,7 +717,7 @@ static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol, return 0; } -static const char *wm5102_osr_text[] = { +static const char * const wm5102_osr_text[] = { "Low power", "Normal", "High performance", }; @@ -1062,7 +1062,7 @@ ARIZONA_MIXER_ENUMS(DSP1R, ARIZONA_DSP1RMIX_INPUT_1_SOURCE); ARIZONA_DSP_AUX_ENUMS(DSP1, ARIZONA_DSP1AUX1MIX_INPUT_1_SOURCE); -static const char *wm5102_aec_loopback_texts[] = { +static const char * const wm5102_aec_loopback_texts[] = { "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT", "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R", }; @@ -1317,8 +1317,7 @@ SND_SOC_DAPM_AIF_IN("SLIMRX8", NULL, 0, ARIZONA_DSP_WIDGETS(DSP1, "DSP1"), SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &wm5102_aec_loopback_mux), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm5102_aec_loopback_mux), SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, @@ -1736,8 +1735,8 @@ static const struct snd_soc_dapm_route wm5102_dapm_routes[] = { { "DRC1 Signal Activity", NULL, "DRC1R" }, }; -static int wm5102_set_fll(struct snd_soc_component *component, int fll_id, int source, - unsigned int Fref, unsigned int Fout) +static int wm5102_set_fll(struct snd_soc_component *component, int fll_id, + int source, unsigned int Fref, unsigned int Fout) { struct wm5102_priv *wm5102 = snd_soc_component_get_drvdata(component); @@ -1947,7 +1946,7 @@ static int wm5102_component_probe(struct snd_soc_component *component) return ret; ret = snd_soc_add_component_controls(component, - arizona_adsp2_rate_controls, 1); + arizona_adsp2_rate_controls, 1); if (ret) goto err_adsp2_codec_probe; @@ -2105,8 +2104,9 @@ static int wm5102_probe(struct platform_device *pdev) goto err_dsp_irq; ret = devm_snd_soc_register_component(&pdev->dev, - &soc_component_dev_wm5102, - wm5102_dai, ARRAY_SIZE(wm5102_dai)); + &soc_component_dev_wm5102, + wm5102_dai, + ARRAY_SIZE(wm5102_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index b33cbd0161d3..fb9835dcd836 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c @@ -332,19 +332,25 @@ static int wm5110_hp_pre_disable(struct snd_soc_dapm_widget *w) switch (w->shift) { case ARIZONA_OUT1L_ENA_SHIFT: if (!(val & ARIZONA_DRE1L_ENA_MASK)) { - snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG1, ARIZONA_WS_TRG1); - snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG1, 0); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG1, + ARIZONA_WS_TRG1); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG1, 0); priv->out_down_delay += 27; } break; case ARIZONA_OUT1R_ENA_SHIFT: if (!(val & ARIZONA_DRE1R_ENA_MASK)) { - snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG2, ARIZONA_WS_TRG2); - snd_soc_component_update_bits(component, ARIZONA_SPARE_TRIGGERS, - ARIZONA_WS_TRG2, 0); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG2, + ARIZONA_WS_TRG2); + snd_soc_component_update_bits(component, + ARIZONA_SPARE_TRIGGERS, + ARIZONA_WS_TRG2, 0); priv->out_down_delay += 27; } break; @@ -539,7 +545,7 @@ static int wm5110_in_analog_ev(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: snd_soc_component_update_bits(component, reg, mask, - wm5110->in_pga_cache[w->shift]); + wm5110->in_pga_cache[w->shift]); wm5110->in_post_pending--; if (wm5110->in_post_pending == 0) @@ -863,14 +869,14 @@ SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT, ARIZONA_SPK2R_MUTE_SHIFT, 1, 1), SOC_DOUBLE_EXT("HPOUT1 DRE Switch", ARIZONA_DRE_ENABLE, - ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0, - snd_soc_get_volsw, wm5110_put_dre), + ARIZONA_DRE1L_ENA_SHIFT, ARIZONA_DRE1R_ENA_SHIFT, 1, 0, + snd_soc_get_volsw, wm5110_put_dre), SOC_DOUBLE_EXT("HPOUT2 DRE Switch", ARIZONA_DRE_ENABLE, - ARIZONA_DRE2L_ENA_SHIFT, ARIZONA_DRE2R_ENA_SHIFT, 1, 0, - snd_soc_get_volsw, wm5110_put_dre), + ARIZONA_DRE2L_ENA_SHIFT, ARIZONA_DRE2R_ENA_SHIFT, 1, 0, + snd_soc_get_volsw, wm5110_put_dre), SOC_DOUBLE_EXT("HPOUT3 DRE Switch", ARIZONA_DRE_ENABLE, - ARIZONA_DRE3L_ENA_SHIFT, ARIZONA_DRE3R_ENA_SHIFT, 1, 0, - snd_soc_get_volsw, wm5110_put_dre), + ARIZONA_DRE3L_ENA_SHIFT, ARIZONA_DRE3R_ENA_SHIFT, 1, 0, + snd_soc_get_volsw, wm5110_put_dre), SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp), SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp), @@ -1036,7 +1042,7 @@ ARIZONA_MUX_ENUMS(ISRC3DEC2, ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE); ARIZONA_MUX_ENUMS(ISRC3DEC3, ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE); ARIZONA_MUX_ENUMS(ISRC3DEC4, ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE); -static const char *wm5110_aec_loopback_texts[] = { +static const char * const wm5110_aec_loopback_texts[] = { "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "HPOUT3L", "HPOUT3R", "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R", "SPKDAT2L", "SPKDAT2R", }; @@ -1274,18 +1280,17 @@ SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3, ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &wm5110_aec_loopback_mux), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm5110_aec_loopback_mux), SND_SOC_DAPM_SUPPLY("RXANC NG External Clock", SND_SOC_NOPM, - ARIZONA_EXT_NG_SEL_SET_SHIFT, 0, arizona_anc_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + ARIZONA_EXT_NG_SEL_SET_SHIFT, 0, arizona_anc_ev, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), SND_SOC_DAPM_PGA("RXANCL NG External", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_PGA("RXANCR NG External", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("RXANC NG Clock", SND_SOC_NOPM, - ARIZONA_CLK_NG_ENA_SET_SHIFT, 0, arizona_anc_ev, - SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), + ARIZONA_CLK_NG_ENA_SET_SHIFT, 0, arizona_anc_ev, + SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), SND_SOC_DAPM_PGA("RXANCL NG Internal", SND_SOC_NOPM, 0, 0, NULL, 0), SND_SOC_DAPM_PGA("RXANCR NG Internal", SND_SOC_NOPM, 0, 0, NULL, 0), @@ -2034,8 +2039,8 @@ static const struct snd_soc_dapm_route wm5110_dapm_routes[] = { { "DSP3 Voice Trigger", "Switch", "DSP3" }, }; -static int wm5110_set_fll(struct snd_soc_component *component, int fll_id, int source, - unsigned int Fref, unsigned int Fout) +static int wm5110_set_fll(struct snd_soc_component *component, int fll_id, + int source, unsigned int Fref, unsigned int Fout) { struct wm5110_priv *wm5110 = snd_soc_component_get_drvdata(component); @@ -2302,8 +2307,8 @@ static int wm5110_component_probe(struct snd_soc_component *component) } ret = snd_soc_add_component_controls(component, - arizona_adsp2_rate_controls, - WM5110_NUM_ADSP); + arizona_adsp2_rate_controls, + WM5110_NUM_ADSP); if (ret) goto err_adsp2_codec_probe; @@ -2460,8 +2465,9 @@ static int wm5110_probe(struct platform_device *pdev) goto err_dsp_irq; ret = devm_snd_soc_register_component(&pdev->dev, - &soc_component_dev_wm5110, - wm5110_dai, ARRAY_SIZE(wm5110_dai)); + &soc_component_dev_wm5110, + wm5110_dai, + ARRAY_SIZE(wm5110_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index 45ee1e6bf715..df5b36b8fc5a 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c @@ -118,7 +118,7 @@ static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w, return arizona_dvfs_sysclk_ev(w, kcontrol, event); } -static const char *wm8997_osr_text[] = { +static const char * const wm8997_osr_text[] = { "Low power", "Normal", "High performance", }; @@ -609,8 +609,7 @@ SND_SOC_DAPM_AIF_IN("SLIMRX8", NULL, 0, ARIZONA_SLIMRX8_ENA_SHIFT, 0), SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &wm8997_aec_loopback_mux), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm8997_aec_loopback_mux), SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM, ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev, @@ -927,8 +926,8 @@ static const struct snd_soc_dapm_route wm8997_dapm_routes[] = { { "MICSUPP", NULL, "SYSCLK" }, }; -static int wm8997_set_fll(struct snd_soc_component *component, int fll_id, int source, - unsigned int Fref, unsigned int Fout) +static int wm8997_set_fll(struct snd_soc_component *component, int fll_id, + int source, unsigned int Fref, unsigned int Fout) { struct wm8997_priv *wm8997 = snd_soc_component_get_drvdata(component); @@ -1173,8 +1172,9 @@ static int wm8997_probe(struct platform_device *pdev) return ret; ret = devm_snd_soc_register_component(&pdev->dev, - &soc_component_dev_wm8997, - wm8997_dai, ARRAY_SIZE(wm8997_dai)); + &soc_component_dev_wm8997, + wm8997_dai, + ARRAY_SIZE(wm8997_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; diff --git a/sound/soc/codecs/wm8998.c b/sound/soc/codecs/wm8998.c index 6f3fdd7b095e..61294c787f27 100644 --- a/sound/soc/codecs/wm8998.c +++ b/sound/soc/codecs/wm8998.c @@ -137,11 +137,13 @@ static int wm8998_inmux_put(struct snd_kcontrol *kcontrol, if (inmode & ARIZONA_INMODE_SE) src_val |= 1 << ARIZONA_IN1L_SRC_SE_SHIFT; - snd_soc_component_update_bits(component, mode_reg, ARIZONA_IN1_MODE_MASK, mode_val); + snd_soc_component_update_bits(component, mode_reg, + ARIZONA_IN1_MODE_MASK, mode_val); snd_soc_component_update_bits(component, e->reg, - ARIZONA_IN1L_SRC_MASK | ARIZONA_IN1L_SRC_SE_MASK, - src_val); + ARIZONA_IN1L_SRC_MASK | + ARIZONA_IN1L_SRC_SE_MASK, + src_val); return snd_soc_dapm_mux_update_power(dapm, kcontrol, ucontrol->value.enumerated.item[0], @@ -322,7 +324,7 @@ SOC_DOUBLE_R("HPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L, SOC_DOUBLE_R("LINEOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L, ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1), SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L, - ARIZONA_OUT3L_MUTE_SHIFT, 1, 1), + ARIZONA_OUT3L_MUTE_SHIFT, 1, 1), SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L, ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1), SOC_DOUBLE_R("SPKDAT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L, @@ -335,7 +337,7 @@ SOC_DOUBLE_R_TLV("LINEOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L, ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT, 0xbf, 0, digital_tlv), SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L, - ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv), + ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv), SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L, ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT, 0xbf, 0, digital_tlv), @@ -615,12 +617,12 @@ SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3, ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0), SND_SOC_DAPM_MUX("AEC1 Loopback", ARIZONA_DAC_AEC_CONTROL_1, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &wm8998_aec_loopback_mux[0]), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, + &wm8998_aec_loopback_mux[0]), SND_SOC_DAPM_MUX("AEC2 Loopback", ARIZONA_DAC_AEC_CONTROL_2, - ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, - &wm8998_aec_loopback_mux[1]), + ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, + &wm8998_aec_loopback_mux[1]), SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0, ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0), @@ -739,9 +741,9 @@ SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1, SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_PGA("SPD1TX1", ARIZONA_SPD1_TX_CONTROL, - ARIZONA_SPD1_VAL1_SHIFT, 0, NULL, 0), + ARIZONA_SPD1_VAL1_SHIFT, 0, NULL, 0), SND_SOC_DAPM_PGA("SPD1TX2", ARIZONA_SPD1_TX_CONTROL, - ARIZONA_SPD1_VAL2_SHIFT, 0, NULL, 0), + ARIZONA_SPD1_VAL2_SHIFT, 0, NULL, 0), SND_SOC_DAPM_OUT_DRV("SPD1", ARIZONA_SPD1_TX_CONTROL, ARIZONA_SPD1_ENA_SHIFT, 0, NULL, 0), @@ -1249,8 +1251,8 @@ static struct snd_soc_dai_driver wm8998_dai[] = { }, }; -static int wm8998_set_fll(struct snd_soc_component *component, int fll_id, int source, - unsigned int Fref, unsigned int Fout) +static int wm8998_set_fll(struct snd_soc_component *component, int fll_id, + int source, unsigned int Fref, unsigned int Fout) { struct wm8998_priv *wm8998 = snd_soc_component_get_drvdata(component); @@ -1379,8 +1381,9 @@ static int wm8998_probe(struct platform_device *pdev) return ret; ret = devm_snd_soc_register_component(&pdev->dev, - &soc_component_dev_wm8998, - wm8998_dai, ARRAY_SIZE(wm8998_dai)); + &soc_component_dev_wm8998, + wm8998_dai, + ARRAY_SIZE(wm8998_dai)); if (ret < 0) { dev_err(&pdev->dev, "Failed to register component: %d\n", ret); goto err_spk_irqs; From 1476105c3f4a6b8f0c6c1fe07295fc85cbffbd83 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:09 -0800 Subject: [PATCH 338/942] ASoC: fsl_ssi: Redefine RX and TX macros The RX and TX macros were defined implicitly and there was a potential risk if someone changes their values. Since they were defined to index the array ssi->regvals[2], this patch moves these two macros to fsl_ssi.c, closer to its owner ssi->regvals. And it also puts some comments here to limit their value within [0, 1]. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 4 ++++ sound/soc/fsl/fsl_ssi.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 24fb672f3c65..3c8dd609e42e 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -56,6 +56,10 @@ #include "fsl_ssi.h" #include "imx-pcm.h" +/* Define RX and TX to index ssi->regvals array; Can be 0 or 1 only */ +#define RX 0 +#define TX 1 + /** * FSLSSI_I2S_FORMATS: audio formats supported by the SSI * diff --git a/sound/soc/fsl/fsl_ssi.h b/sound/soc/fsl/fsl_ssi.h index de2fdc5db726..18f8dd5209d5 100644 --- a/sound/soc/fsl/fsl_ssi.h +++ b/sound/soc/fsl/fsl_ssi.h @@ -12,9 +12,6 @@ #ifndef _MPC8610_I2S_H #define _MPC8610_I2S_H -#define RX 0 -#define TX 1 - /* -- SSI Register Map -- */ /* SSI Transmit Data Register 0 */ From ebf08ae3bc906fc5dd33d02977efa5d4b9831517 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:10 -0800 Subject: [PATCH 339/942] ASoC: fsl_ssi: Keep ssi->i2s_net updated The hw_params() overwrites i2s_net settings for special cases like mono-channel support, however, it doesn't update ssi->i2s_net as set_dai_fmt() does. This patch removes the local i2s_net variable and directly updates ssi->i2s_net in the hw_params() so that the driver can simply look up the ssi->i2s_net instead of reading the register. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 3c8dd609e42e..d4f1f0d64136 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -838,16 +838,16 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, } if (!fsl_ssi_is_ac97(ssi)) { - u8 i2s_net; /* Normal + Network mode to send 16-bit data in 32-bit frames */ if (fsl_ssi_is_i2s_cbm_cfs(ssi) && sample_size == 16) - i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET; - else - i2s_net = ssi->i2s_net; + ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL | SSI_SCR_NET; + + /* Use Normal mode to send mono data at 1st slot of 2 slots */ + if (channels == 1) + ssi->i2s_net = SSI_SCR_I2S_MODE_NORMAL; regmap_update_bits(regs, REG_SSI_SCR, - SSI_SCR_I2S_NET_MASK, - channels == 1 ? 0 : i2s_net); + SSI_SCR_I2S_NET_MASK, ssi->i2s_net); } /* In synchronous mode, the SSI uses STCCR for capture */ From 09947634829ccc5568a80ac02c3395a8b77276c1 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:11 -0800 Subject: [PATCH 340/942] ASoC: fsl_ssi: Clean up set_dai_tdm_slot() This patch replaces the register read with ssi->i2s_net for simplification. It also removes masking SSIEN from scr value since it's handled later by regmap_update_bits() to set this scr value back. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index d4f1f0d64136..14046c32dc07 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -1055,9 +1055,7 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, } /* The slot number should be >= 2 if using Network mode or I2S mode */ - regmap_read(regs, REG_SSI_SCR, &val); - val &= SSI_SCR_I2S_MODE_MASK | SSI_SCR_NET; - if (val && slots < 2) { + if (ssi->i2s_net && slots < 2) { dev_err(dai->dev, "slot number should be >= 2 in I2S or NET\n"); return -EINVAL; } @@ -1067,9 +1065,8 @@ static int fsl_ssi_set_dai_tdm_slot(struct snd_soc_dai *dai, u32 tx_mask, regmap_update_bits(regs, REG_SSI_SRCCR, SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots)); - /* Save SSIEN bit of the SCR register */ + /* Save the SCR register value */ regmap_read(regs, REG_SSI_SCR, &val); - val &= SSI_SCR_SSIEN; /* Temporarily enable SSI to allow SxMSKs to be configurable */ regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_SSIEN, SSI_SCR_SSIEN); From e0582731abe004163e78ad2dac4cd1196db0908f Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:12 -0800 Subject: [PATCH 341/942] ASoC: fsl_ssi: Maintain a mask of active streams Checking TE and RE bits in SCR register doesn't work for AC97 mode which enables SSIEN, TE and RE in the fsl_ssi_setup_ac97() that's called during probe(). So when running into the trigger(), it will always get the result of both TE and RE being enabled already, even if actually there is no active stream. This patch fixes this issue by adding a variable to log the active streams manually. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 14046c32dc07..b277a563ff48 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -205,6 +205,7 @@ struct fsl_ssi_soc_data { * @cpu_dai_drv: CPU DAI driver for this device * * @dai_fmt: DAI configuration this device is currently used with + * @streams: Mask of current active streams: BIT(TX) and BIT(RX) * @i2s_net: I2S and Network mode configurations of SCR register * @use_dma: DMA is used or FIQ with stream filter * @use_dual_fifo: DMA with support for dual FIFO mode @@ -249,6 +250,7 @@ struct fsl_ssi { struct snd_soc_dai_driver cpu_dai_drv; unsigned int dai_fmt; + u8 streams; u8 i2s_net; bool use_dma; bool use_dual_fifo; @@ -444,15 +446,14 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, struct fsl_ssi_regvals *vals) { + int dir = (&ssi->regvals[TX] == vals) ? TX : RX; struct regmap *regs = ssi->regs; struct fsl_ssi_regvals *avals; int nr_active_streams; - u32 scr; int keep_active; - regmap_read(regs, REG_SSI_SCR, &scr); - - nr_active_streams = !!(scr & SSI_SCR_TE) + !!(scr & SSI_SCR_RE); + nr_active_streams = !!(ssi->streams & BIT(TX)) + + !!(ssi->streams & BIT(RX)); if (nr_active_streams - 1 > 0) keep_active = 1; @@ -474,6 +475,9 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, keep_active); /* Safely disable SCR register for the stream */ regmap_update_bits(regs, REG_SSI_SCR, scr, 0); + + /* Log the disabled stream to the mask */ + ssi->streams &= ~BIT(dir); } /* @@ -549,6 +553,9 @@ config_done: } /* Enable all remaining bits */ regmap_update_bits(regs, REG_SSI_SCR, vals->scr, vals->scr); + + /* Log the enabled stream to the mask */ + ssi->streams |= BIT(dir); } } From 06a994540505a9ce7028d9e801c52f967654b836 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:13 -0800 Subject: [PATCH 342/942] ASoC: fsl_ssi: Rename fsl_ssi_disable_val macro The define of fsl_ssi_disable_val is not so clear as it mixes two steps of calculations together. And those parameter names are also a bit long to read. Since it just tries to exclude the shared bits from the regvals of current stream while the opposite stream is active, it's better to use something like ssi_excl_shared_bits. This patch also bisects fsl_ssi_disable_val into two macros of two corresponding steps and then shortens its parameter names. It also updates callers in the fsl_ssi_config() accordingly. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 55 +++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b277a563ff48..0d8c800db0b3 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -421,24 +421,24 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) } /** - * Calculate the bits that have to be disabled for the current stream that is - * getting disabled. This keeps the bits enabled that are necessary for the - * second stream to work if 'stream_active' is true. + * Exclude bits that are used by the opposite stream * - * Detailed calculation: - * These are the values that need to be active after disabling. For non-active - * second stream, this is 0: - * vals_stream * !!stream_active + * When both streams are active, disabling some bits for the current stream + * might break the other stream if these bits are used by it. * - * The following computes the overall differences between the setup for the - * to-disable stream and the active stream, a simple XOR: - * vals_disable ^ (vals_stream * !!(stream_active)) + * @vals : regvals of the current stream + * @avals: regvals of the opposite stream + * @aactive: active state of the opposite stream * - * The full expression adds a mask on all values we care about + * 1) XOR vals and avals to get the differences if the other stream is active; + * Otherwise, return current vals if the other stream is not active + * 2) AND the result of 1) with the current vals */ -#define fsl_ssi_disable_val(vals_disable, vals_stream, stream_active) \ - ((vals_disable) & \ - ((vals_disable) ^ ((vals_stream) * (u32)!!(stream_active)))) +#define _ssi_xor_shared_bits(vals, avals, aactive) \ + ((vals) ^ ((avals) * (aactive))) + +#define ssi_excl_shared_bits(vals, avals, aactive) \ + ((vals) & _ssi_xor_shared_bits(vals, avals, aactive)) /** * Enable or disable SSI configuration. @@ -446,19 +446,14 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, struct fsl_ssi_regvals *vals) { + int adir = (&ssi->regvals[TX] == vals) ? RX : TX; int dir = (&ssi->regvals[TX] == vals) ? TX : RX; struct regmap *regs = ssi->regs; struct fsl_ssi_regvals *avals; - int nr_active_streams; - int keep_active; + bool aactive; - nr_active_streams = !!(ssi->streams & BIT(TX)) + - !!(ssi->streams & BIT(RX)); - - if (nr_active_streams - 1 > 0) - keep_active = 1; - else - keep_active = 0; + /* Check if the opposite stream is active */ + aactive = ssi->streams & BIT(adir); /* Get the opposite direction to keep its values untouched */ if (&ssi->regvals[RX] == vals) @@ -471,8 +466,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, * To keep the other stream safe, exclude shared bits between * both streams, and get safe bits to disable current stream */ - u32 scr = fsl_ssi_disable_val(vals->scr, avals->scr, - keep_active); + u32 scr = ssi_excl_shared_bits(vals->scr, avals->scr, aactive); /* Safely disable SCR register for the stream */ regmap_update_bits(regs, REG_SSI_SCR, scr, 0); @@ -487,7 +481,7 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, * 2) Disable all remaining bits of both streams when last stream ends */ if (ssi->soc->offline_config) { - if ((enable && !nr_active_streams) || (!enable && !keep_active)) + if ((enable && !ssi->streams) || (!enable && !aactive)) fsl_ssi_rxtx_config(ssi, enable); goto config_done; @@ -509,12 +503,9 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, * To keep the other stream safe, exclude shared bits between * both streams, and get safe bits to disable current stream */ - sier = fsl_ssi_disable_val(vals->sier, avals->sier, - keep_active); - srcr = fsl_ssi_disable_val(vals->srcr, avals->srcr, - keep_active); - stcr = fsl_ssi_disable_val(vals->stcr, avals->stcr, - keep_active); + sier = ssi_excl_shared_bits(vals->sier, avals->sier, aactive); + srcr = ssi_excl_shared_bits(vals->srcr, avals->srcr, aactive); + stcr = ssi_excl_shared_bits(vals->stcr, avals->stcr, aactive); /* Safely disable other control registers for the stream */ regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0); From 2e1327403b2543bc4dd639571b84bf6174212cee Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:14 -0800 Subject: [PATCH 343/942] ASoC: fsl_ssi: Clear FIFO directly in fsl_ssi_config() The FIFO clear helper function is just one line of code now. So it could be cleaned up by removing it and calling regmap directly. Meanwhile, FIFO clear could be applied to all use cases, not confined to AC97. So this patch also moves FIFO clear in the trigger() to fsl_ssi_config() and removes the AC97 check. Note that SOR register is safe from offline_config HW limit. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 0d8c800db0b3..d276b78684e4 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -409,17 +409,6 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable) } } -/** - * Clear remaining data in the FIFO to avoid dirty data or channel slipping - */ -static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) -{ - bool tx = !is_rx; - - regmap_update_bits(ssi->regs, REG_SSI_SOR, - SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); -} - /** * Exclude bits that are used by the opposite stream * @@ -446,10 +435,11 @@ static void fsl_ssi_fifo_clear(struct fsl_ssi *ssi, bool is_rx) static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, struct fsl_ssi_regvals *vals) { - int adir = (&ssi->regvals[TX] == vals) ? RX : TX; - int dir = (&ssi->regvals[TX] == vals) ? TX : RX; + bool tx = &ssi->regvals[TX] == vals; struct regmap *regs = ssi->regs; struct fsl_ssi_regvals *avals; + int adir = tx ? RX : TX; + int dir = tx ? TX : RX; bool aactive; /* Check if the opposite stream is active */ @@ -489,7 +479,9 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, /* Online configure single direction while SSI is running */ if (enable) { - fsl_ssi_fifo_clear(ssi, vals->scr & SSI_SCR_RE); + /* Clear FIFO to prevent dirty data or channel slipping */ + regmap_update_bits(ssi->regs, REG_SSI_SOR, + SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); regmap_update_bits(regs, REG_SSI_SRCR, vals->srcr, vals->srcr); regmap_update_bits(regs, REG_SSI_STCR, vals->stcr, vals->stcr); @@ -511,6 +503,10 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0); regmap_update_bits(regs, REG_SSI_STCR, stcr, 0); regmap_update_bits(regs, REG_SSI_SIER, sier, 0); + + /* Clear FIFO to prevent dirty data or channel slipping */ + regmap_update_bits(ssi->regs, REG_SSI_SOR, + SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); } config_done: @@ -1091,7 +1087,6 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai); - struct regmap *regs = ssi->regs; switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -1116,14 +1111,6 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, return -EINVAL; } - /* Clear corresponding FIFO */ - if (fsl_ssi_is_ac97(ssi)) { - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - regmap_write(regs, REG_SSI_SOR, SSI_SOR_TX_CLR); - else - regmap_write(regs, REG_SSI_SOR, SSI_SOR_RX_CLR); - } - return 0; } From 7d67bcb669bc92d5de037c7dadcebaf0c8f5ad24 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:15 -0800 Subject: [PATCH 344/942] ASoC: fsl_ssi: Clean up helper functions of trigger() The trigger() calls fsl_ssi_tx_config() and fsl_ssi_rx_config(), and both of them jump to fsl_ssi_config(). And fsl_ssi_config() later calls another fsl_ssi_rxtx_config(). However, the whole routine, especially fsl_ssi_config() function, is too complicated because of the folowing reasons: 1) It has to handle the concern of the opposite stream. 2) It has to handle cases of offline configurations support. 3) It has to handle enable and disable operations while they're mostly different. Since the enable and disable routines have more differences than TX and RX rountines, this patch simplifies these helper functions with the following changes: - Changing to two helper functions of enable and disable instead of TX and RX. - Removing fsl_ssi_rxtx_config() by separately integrating it to two newly introduced enable & disable functions. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 260 +++++++++++++++++++--------------------- 1 file changed, 124 insertions(+), 136 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index d276b78684e4..9f024a9afaa5 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -382,31 +382,83 @@ static irqreturn_t fsl_ssi_isr(int irq, void *dev_id) } /** - * Enable or disable all rx/tx config flags at once + * Set SCR, SIER, STCR and SRCR registers with cached values in regvals + * + * Notes: + * 1) For offline_config SoCs, enable all necessary bits of both streams + * when 1st stream starts, even if the opposite stream will not start + * 2) It also clears FIFO before setting regvals; SOR is safe to set online */ -static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable) +static void fsl_ssi_config_enable(struct fsl_ssi *ssi, bool tx) { - struct regmap *regs = ssi->regs; struct fsl_ssi_regvals *vals = ssi->regvals; + int dir = tx ? TX : RX; + u32 sier, srcr, stcr; - if (enable) { - regmap_update_bits(regs, REG_SSI_SIER, - vals[RX].sier | vals[TX].sier, - vals[RX].sier | vals[TX].sier); - regmap_update_bits(regs, REG_SSI_SRCR, - vals[RX].srcr | vals[TX].srcr, - vals[RX].srcr | vals[TX].srcr); - regmap_update_bits(regs, REG_SSI_STCR, - vals[RX].stcr | vals[TX].stcr, - vals[RX].stcr | vals[TX].stcr); + /* Clear dirty data in the FIFO; It also prevents channel slipping */ + regmap_update_bits(ssi->regs, REG_SSI_SOR, + SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); + + /* + * On offline_config SoCs, SxCR and SIER are already configured when + * the previous stream started. So skip all SxCR and SIER settings + * to prevent online reconfigurations, then jump to set SCR directly + */ + if (ssi->soc->offline_config && ssi->streams) + goto enable_scr; + + if (ssi->soc->offline_config) { + /* + * Online reconfiguration not supported, so enable all bits for + * both streams at once to avoid necessity of reconfigurations + */ + srcr = vals[RX].srcr | vals[TX].srcr; + stcr = vals[RX].stcr | vals[TX].stcr; + sier = vals[RX].sier | vals[TX].sier; } else { - regmap_update_bits(regs, REG_SSI_SRCR, - vals[RX].srcr | vals[TX].srcr, 0); - regmap_update_bits(regs, REG_SSI_STCR, - vals[RX].stcr | vals[TX].stcr, 0); - regmap_update_bits(regs, REG_SSI_SIER, - vals[RX].sier | vals[TX].sier, 0); + /* Otherwise, only set bits for the current stream */ + srcr = vals[dir].srcr; + stcr = vals[dir].stcr; + sier = vals[dir].sier; } + + /* Configure SRCR, STCR and SIER at once */ + regmap_update_bits(ssi->regs, REG_SSI_SRCR, srcr, srcr); + regmap_update_bits(ssi->regs, REG_SSI_STCR, stcr, stcr); + regmap_update_bits(ssi->regs, REG_SSI_SIER, sier, sier); + +enable_scr: + /* + * Start DMA before setting TE to avoid FIFO underrun + * which may cause a channel slip or a channel swap + * + * TODO: FIQ cases might also need this upon testing + */ + if (ssi->use_dma && tx) { + int try = 100; + u32 sfcsr; + + /* Enable SSI first to send TX DMA request */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, + SSI_SCR_SSIEN, SSI_SCR_SSIEN); + + /* Busy wait until TX FIFO not empty -- DMA working */ + do { + regmap_read(ssi->regs, REG_SSI_SFCSR, &sfcsr); + if (SSI_SFCSR_TFCNT0(sfcsr)) + break; + } while (--try); + + /* FIFO still empty -- something might be wrong */ + if (!SSI_SFCSR_TFCNT0(sfcsr)) + dev_warn(ssi->dev, "Timeout waiting TX FIFO filling\n"); + } + /* Enable all remaining bits in SCR */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, + vals[dir].scr, vals[dir].scr); + + /* Log the enabled stream to the mask */ + ssi->streams |= BIT(dir); } /** @@ -430,14 +482,17 @@ static void fsl_ssi_rxtx_config(struct fsl_ssi *ssi, bool enable) ((vals) & _ssi_xor_shared_bits(vals, avals, aactive)) /** - * Enable or disable SSI configuration. + * Unset SCR, SIER, STCR and SRCR registers with cached values in regvals + * + * Notes: + * 1) For offline_config SoCs, to avoid online reconfigurations, disable all + * bits of both streams at once when the last stream is abort to end + * 2) It also clears FIFO after unsetting regvals; SOR is safe to set online */ -static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, - struct fsl_ssi_regvals *vals) +static void fsl_ssi_config_disable(struct fsl_ssi *ssi, bool tx) { - bool tx = &ssi->regvals[TX] == vals; - struct regmap *regs = ssi->regs; - struct fsl_ssi_regvals *avals; + struct fsl_ssi_regvals *vals, *avals; + u32 sier, srcr, stcr, scr; int adir = tx ? RX : TX; int dir = tx ? TX : RX; bool aactive; @@ -445,52 +500,36 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, /* Check if the opposite stream is active */ aactive = ssi->streams & BIT(adir); - /* Get the opposite direction to keep its values untouched */ - if (&ssi->regvals[RX] == vals) - avals = &ssi->regvals[TX]; - else - avals = &ssi->regvals[RX]; + vals = &ssi->regvals[dir]; - if (!enable) { - /* - * To keep the other stream safe, exclude shared bits between - * both streams, and get safe bits to disable current stream - */ - u32 scr = ssi_excl_shared_bits(vals->scr, avals->scr, aactive); - /* Safely disable SCR register for the stream */ - regmap_update_bits(regs, REG_SSI_SCR, scr, 0); - - /* Log the disabled stream to the mask */ - ssi->streams &= ~BIT(dir); - } + /* Get regvals of the opposite stream to keep opposite stream safe */ + avals = &ssi->regvals[adir]; /* - * For cases where online configuration is not supported, - * 1) Enable all necessary bits of both streams when 1st stream starts - * even if the opposite stream will not start - * 2) Disable all remaining bits of both streams when last stream ends + * To keep the other stream safe, exclude shared bits between + * both streams, and get safe bits to disable current stream */ + scr = ssi_excl_shared_bits(vals->scr, avals->scr, aactive); + + /* Disable safe bits of SCR register for the current stream */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, scr, 0); + + /* Log the disabled stream to the mask */ + ssi->streams &= ~BIT(dir); + + /* + * On offline_config SoCs, if the other stream is active, skip + * SxCR and SIER settings to prevent online reconfigurations + */ + if (ssi->soc->offline_config && aactive) + goto fifo_clear; + if (ssi->soc->offline_config) { - if ((enable && !ssi->streams) || (!enable && !aactive)) - fsl_ssi_rxtx_config(ssi, enable); - - goto config_done; - } - - /* Online configure single direction while SSI is running */ - if (enable) { - /* Clear FIFO to prevent dirty data or channel slipping */ - regmap_update_bits(ssi->regs, REG_SSI_SOR, - SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); - - regmap_update_bits(regs, REG_SSI_SRCR, vals->srcr, vals->srcr); - regmap_update_bits(regs, REG_SSI_STCR, vals->stcr, vals->stcr); - regmap_update_bits(regs, REG_SSI_SIER, vals->sier, vals->sier); + /* Now there is only current stream active, disable all bits */ + srcr = vals->srcr | avals->srcr; + stcr = vals->stcr | avals->stcr; + sier = vals->sier | avals->sier; } else { - u32 sier; - u32 srcr; - u32 stcr; - /* * To keep the other stream safe, exclude shared bits between * both streams, and get safe bits to disable current stream @@ -498,57 +537,17 @@ static void fsl_ssi_config(struct fsl_ssi *ssi, bool enable, sier = ssi_excl_shared_bits(vals->sier, avals->sier, aactive); srcr = ssi_excl_shared_bits(vals->srcr, avals->srcr, aactive); stcr = ssi_excl_shared_bits(vals->stcr, avals->stcr, aactive); - - /* Safely disable other control registers for the stream */ - regmap_update_bits(regs, REG_SSI_SRCR, srcr, 0); - regmap_update_bits(regs, REG_SSI_STCR, stcr, 0); - regmap_update_bits(regs, REG_SSI_SIER, sier, 0); - - /* Clear FIFO to prevent dirty data or channel slipping */ - regmap_update_bits(ssi->regs, REG_SSI_SOR, - SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); } -config_done: - /* Enabling of subunits is done after configuration */ - if (enable) { - /* - * Start DMA before setting TE to avoid FIFO underrun - * which may cause a channel slip or a channel swap - * - * TODO: FIQ cases might also need this upon testing - */ - if (ssi->use_dma && (vals->scr & SSI_SCR_TE)) { - int i; - int max_loop = 100; + /* Clear configurations of SRCR, STCR and SIER at once */ + regmap_update_bits(ssi->regs, REG_SSI_SRCR, srcr, 0); + regmap_update_bits(ssi->regs, REG_SSI_STCR, stcr, 0); + regmap_update_bits(ssi->regs, REG_SSI_SIER, sier, 0); - /* Enable SSI first to send TX DMA request */ - regmap_update_bits(regs, REG_SSI_SCR, - SSI_SCR_SSIEN, SSI_SCR_SSIEN); - - /* Busy wait until TX FIFO not empty -- DMA working */ - for (i = 0; i < max_loop; i++) { - u32 sfcsr; - regmap_read(regs, REG_SSI_SFCSR, &sfcsr); - if (SSI_SFCSR_TFCNT0(sfcsr)) - break; - } - if (i == max_loop) { - dev_err(ssi->dev, - "Timeout waiting TX FIFO filling\n"); - } - } - /* Enable all remaining bits */ - regmap_update_bits(regs, REG_SSI_SCR, vals->scr, vals->scr); - - /* Log the enabled stream to the mask */ - ssi->streams |= BIT(dir); - } -} - -static void fsl_ssi_rx_config(struct fsl_ssi *ssi, bool enable) -{ - fsl_ssi_config(ssi, enable, &ssi->regvals[RX]); +fifo_clear: + /* Clear remaining data in the FIFO */ + regmap_update_bits(ssi->regs, REG_SSI_SOR, + SSI_SOR_xX_CLR(tx), SSI_SOR_xX_CLR(tx)); } static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi) @@ -564,21 +563,6 @@ static void fsl_ssi_tx_ac97_saccst_setup(struct fsl_ssi *ssi) } } -static void fsl_ssi_tx_config(struct fsl_ssi *ssi, bool enable) -{ - /* - * SACCST might be modified via AC Link by a CODEC if it sends - * extra bits in their SLOTREQ requests, which'll accidentally - * send valid data to slots other than normal playback slots. - * - * To be safe, configure SACCST right before TX starts. - */ - if (enable && fsl_ssi_is_ac97(ssi)) - fsl_ssi_tx_ac97_saccst_setup(ssi); - - fsl_ssi_config(ssi, enable, &ssi->regvals[TX]); -} - /** * Cache critical bits of SIER, SRCR, STCR and SCR to later set them safely */ @@ -1087,24 +1071,28 @@ static int fsl_ssi_trigger(struct snd_pcm_substream *substream, int cmd, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(rtd->cpu_dai); + bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; switch (cmd) { case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - fsl_ssi_tx_config(ssi, true); - else - fsl_ssi_rx_config(ssi, true); + /* + * SACCST might be modified via AC Link by a CODEC if it sends + * extra bits in their SLOTREQ requests, which'll accidentally + * send valid data to slots other than normal playback slots. + * + * To be safe, configure SACCST right before TX starts. + */ + if (tx && fsl_ssi_is_ac97(ssi)) + fsl_ssi_tx_ac97_saccst_setup(ssi); + fsl_ssi_config_enable(ssi, tx); break; case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - fsl_ssi_tx_config(ssi, false); - else - fsl_ssi_rx_config(ssi, false); + fsl_ssi_config_disable(ssi, tx); break; default: From b6c93f7f60a0d0b61c1fce2872b9d4f7263d6ec2 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:16 -0800 Subject: [PATCH 345/942] ASoC: fsl_ssi: Add DAIFMT define for AC97 The _fsl_ssi_set_dai_fmt() bypasses an undefined format for AC97 mode. However, it's not really necessary if AC97 has its complete format defined. So this patch adds a DAIFMT macro of complete format including a clock direction and polarity. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 9f024a9afaa5..fc5768d243d1 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -90,6 +90,16 @@ SNDRV_PCM_FMTBIT_S24_LE) #endif +/* + * In AC97 mode, TXDIR bit is forced to 0 and TFDIR bit is forced to 1: + * - SSI inputs external bit clock and outputs frame sync clock -- CBM_CFS + * - Also have NB_NF to mark these two clocks will not be inverted + */ +#define FSLSSI_AC97_DAIFMT \ + (SND_SOC_DAIFMT_AC97 | \ + SND_SOC_DAIFMT_CBM_CFS | \ + SND_SOC_DAIFMT_NB_NF) + #define FSLSSI_SIER_DBG_RX_FLAGS \ (SSI_SIER_RFF0_EN | \ SSI_SIER_RLS_EN | \ @@ -964,8 +974,7 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, scr &= ~SSI_SCR_SYS_CLK_EN; break; default: - if (!fsl_ssi_is_ac97(ssi)) - return -EINVAL; + return -EINVAL; } stcr |= strcr; @@ -1372,7 +1381,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) sprop = of_get_property(np, "fsl,mode", NULL); if (sprop) { if (!strcmp(sprop, "ac97-slave")) - ssi->dai_fmt = SND_SOC_DAIFMT_AC97; + ssi->dai_fmt = FSLSSI_AC97_DAIFMT; } /* Select DMA or FIQ */ From 501bc1d70cf5ba8ccd9775ce987c90485034464e Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:17 -0800 Subject: [PATCH 346/942] ASoC: fsl_ssi: Clean up fsl_ssi_setup_regvals() This patch cleans fsl_ssi_setup_regvals() by following changes: 1) Moving DBG bits to the first lines. 2) Setting SSIE, RE/TE as default and cleaning it for AC97 Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index fc5768d243d1..156f5132feba 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -580,18 +580,16 @@ static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi) { struct fsl_ssi_regvals *vals = ssi->regvals; - vals[RX].sier = SSI_SIER_RFF0_EN; + vals[RX].sier = SSI_SIER_RFF0_EN | FSLSSI_SIER_DBG_RX_FLAGS; vals[RX].srcr = SSI_SRCR_RFEN0; - vals[RX].scr = 0; - vals[TX].sier = SSI_SIER_TFE0_EN; + vals[RX].scr = SSI_SCR_SSIEN | SSI_SCR_RE; + vals[TX].sier = SSI_SIER_TFE0_EN | FSLSSI_SIER_DBG_TX_FLAGS; vals[TX].stcr = SSI_STCR_TFEN0; - vals[TX].scr = 0; + vals[TX].scr = SSI_SCR_SSIEN | SSI_SCR_TE; /* AC97 has already enabled SSIEN, RE and TE, so ignore them */ - if (!fsl_ssi_is_ac97(ssi)) { - vals[RX].scr = SSI_SCR_SSIEN | SSI_SCR_RE; - vals[TX].scr = SSI_SCR_SSIEN | SSI_SCR_TE; - } + if (fsl_ssi_is_ac97(ssi)) + vals[RX].scr = vals[TX].scr = 0; if (ssi->use_dma) { vals[RX].sier |= SSI_SIER_RDMAE; @@ -600,9 +598,6 @@ static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi) vals[RX].sier |= SSI_SIER_RIE; vals[TX].sier |= SSI_SIER_TIE; } - - vals[RX].sier |= FSLSSI_SIER_DBG_RX_FLAGS; - vals[TX].sier |= FSLSSI_SIER_DBG_TX_FLAGS; } static void fsl_ssi_setup_ac97(struct fsl_ssi *ssi) From 702d7965e402a8dcd88e964fd5bba6f5f159d625 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:18 -0800 Subject: [PATCH 347/942] ASoC: fsl_ssi: Set xFEN0 and xFEN1 together It'd be safer to enable both FIFOs for TX or RX at the same time. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 156f5132feba..00dfdc77b567 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -591,6 +591,11 @@ static void fsl_ssi_setup_regvals(struct fsl_ssi *ssi) if (fsl_ssi_is_ac97(ssi)) vals[RX].scr = vals[TX].scr = 0; + if (ssi->use_dual_fifo) { + vals[RX].srcr |= SSI_SRCR_RFEN1; + vals[TX].stcr |= SSI_STCR_TFEN1; + } + if (ssi->use_dma) { vals[RX].sier |= SSI_SIER_RDMAE; vals[TX].sier |= SSI_SIER_TDMAE; @@ -991,14 +996,9 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) | SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm)); - if (ssi->use_dual_fifo) { - regmap_update_bits(regs, REG_SSI_SRCR, - SSI_SRCR_RFEN1, SSI_SRCR_RFEN1); - regmap_update_bits(regs, REG_SSI_STCR, - SSI_STCR_TFEN1, SSI_STCR_TFEN1); + if (ssi->use_dual_fifo) regmap_update_bits(regs, REG_SSI_SCR, SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); - } if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97) fsl_ssi_setup_ac97(ssi); From 40f2563377006b14b94a4f5e9547b8e4498125af Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:19 -0800 Subject: [PATCH 348/942] ASoC: fsl_ssi: Use snd_soc_init_dma_data instead Since there is a helper function, use it to help readability. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 00dfdc77b567..7e15b30d4f94 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -1110,10 +1110,9 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai) { struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai); - if (ssi->soc->imx && ssi->use_dma) { - dai->playback_dma_data = &ssi->dma_params_tx; - dai->capture_dma_data = &ssi->dma_params_rx; - } + if (ssi->soc->imx && ssi->use_dma) + snd_soc_dai_init_dma_data(dai, &ssi->dma_params_tx, + &ssi->dma_params_rx); return 0; } From a1d154ac2765cf982be0d4d378bc6ba342c467a3 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:20 -0800 Subject: [PATCH 349/942] ASoC: fsl_ssi: Move one-time configurations to probe() The probe() could handle some one-time configurations since they will not be changed once being configured. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 7e15b30d4f94..36f3d51c5c43 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -865,7 +865,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, { struct regmap *regs = ssi->regs; u32 strcr = 0, stcr, srcr, scr, mask; - u8 wm; ssi->dai_fmt = fmt; @@ -874,8 +873,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, return -EINVAL; } - fsl_ssi_setup_regvals(ssi); - regmap_read(regs, REG_SSI_SCR, &scr); scr &= ~(SSI_SCR_SYN | SSI_SCR_I2S_MODE_MASK); /* Synchronize frame sync clock for TE to avoid data slipping */ @@ -990,16 +987,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, regmap_write(regs, REG_SSI_SRCR, srcr); regmap_write(regs, REG_SSI_SCR, scr); - wm = ssi->fifo_watermark; - - regmap_write(regs, REG_SSI_SFCSR, - SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) | - SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm)); - - if (ssi->use_dual_fifo) - regmap_update_bits(regs, REG_SSI_SCR, - SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); - if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97) fsl_ssi_setup_ac97(ssi); @@ -1248,6 +1235,29 @@ static struct snd_ac97_bus_ops fsl_ssi_ac97_ops = { .write = fsl_ssi_ac97_write, }; +/** + * Initialize SSI registers + */ +static int fsl_ssi_hw_init(struct fsl_ssi *ssi) +{ + u32 wm = ssi->fifo_watermark; + + /* Initialize regvals */ + fsl_ssi_setup_regvals(ssi); + + /* Set watermarks */ + regmap_write(ssi->regs, REG_SSI_SFCSR, + SSI_SFCSR_TFWM0(wm) | SSI_SFCSR_RFWM0(wm) | + SSI_SFCSR_TFWM1(wm) | SSI_SFCSR_RFWM1(wm)); + + /* Enable Dual FIFO mode */ + if (ssi->use_dual_fifo) + regmap_update_bits(ssi->regs, REG_SSI_SCR, + SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); + + return 0; +} + /** * Make every character in a string lower-case */ @@ -1533,6 +1543,9 @@ done: if (ssi->dai_fmt) _fsl_ssi_set_dai_fmt(dev, ssi, ssi->dai_fmt); + /* Initially configures SSI registers */ + fsl_ssi_hw_init(ssi); + if (fsl_ssi_is_ac97(ssi)) { u32 ssi_idx; From 37ac30a4bdc397cf1311111264ac35dc8473e1de Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:21 -0800 Subject: [PATCH 350/942] ASoC: fsl_ssi: Setup AC97 in fsl_ssi_hw_init() AC97 configures most of registers earlier to start a communication with CODECs in order to successfully initialize CODEC. Currently, _fsl_ssi_set_dai_fmt() and fsl_ssi_setup_ac97() are called to get all SSI registers properly set. Since now the driver has a fsl_ssi_hw_init() to handle all register initial settings, this patch moves those register settings of AC97 to the fsl_ssi_hw_init() as well. Meanwhile it applies _fsl_ssi_set_dai_fmt() call to AC97 only since other formats would be configured via normal set_dai_fmt() directly. This patch also adds fsl_ssi_hw_clean() to cleanup control bits for AC97 in the platform remote() function. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 36f3d51c5c43..dfb0da3cedda 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -987,9 +987,6 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, regmap_write(regs, REG_SSI_SRCR, srcr); regmap_write(regs, REG_SSI_SCR, scr); - if ((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_AC97) - fsl_ssi_setup_ac97(ssi); - return 0; } @@ -1255,9 +1252,33 @@ static int fsl_ssi_hw_init(struct fsl_ssi *ssi) regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_TCH_EN, SSI_SCR_TCH_EN); + /* AC97 should start earlier to communicate with CODECs */ + if (fsl_ssi_is_ac97(ssi)) { + _fsl_ssi_set_dai_fmt(ssi->dev, ssi, ssi->dai_fmt); + fsl_ssi_setup_ac97(ssi); + } + return 0; } +/** + * Clear SSI registers + */ +static void fsl_ssi_hw_clean(struct fsl_ssi *ssi) +{ + /* Disable registers for AC97 */ + if (fsl_ssi_is_ac97(ssi)) { + /* Disable TE and RE bits first */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, + SSI_SCR_TE | SSI_SCR_RE, 0); + /* Disable AC97 mode */ + regmap_write(ssi->regs, REG_SSI_SACNT, 0); + /* Unset WAIT bits */ + regmap_write(ssi->regs, REG_SSI_SOR, 0); + /* Disable SSI -- software reset */ + regmap_update_bits(ssi->regs, REG_SSI_SCR, SSI_SCR_SSIEN, 0); + } +} /** * Make every character in a string lower-case */ @@ -1540,9 +1561,6 @@ static int fsl_ssi_probe(struct platform_device *pdev) } done: - if (ssi->dai_fmt) - _fsl_ssi_set_dai_fmt(dev, ssi, ssi->dai_fmt); - /* Initially configures SSI registers */ fsl_ssi_hw_init(ssi); @@ -1592,6 +1610,9 @@ static int fsl_ssi_remove(struct platform_device *pdev) if (ssi->pdev) platform_device_unregister(ssi->pdev); + /* Clean up SSI registers */ + fsl_ssi_hw_clean(ssi); + if (ssi->soc->imx) fsl_ssi_imx_clean(pdev, ssi); From 26b31f4f7d7905f67b6faa52ef147595341134c5 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:22 -0800 Subject: [PATCH 351/942] ASoC: fsl_ssi: Clean up _fsl_ssi_set_dai_fmt() The _fsl_ssi_set_dai_fmt() is a helper function being called from fsl_ssi_set_dai_fmt() as an ASoC operation and fsl_ssi_hw_init() mainly for AC97 format initialization. This patch cleans the _fsl_ssi_set_dai_fmt() in following ways: * Removing *dev pointer in the parameters as it's included in the *ssi pointer of struct fsl_ssi. * Using regmap_update_bits() instead of regmap_read() with masking the value manually. * Moving baudclk check to the switch-case routine to skip the I2S master check. And moving SxCCR.DC settings after baudclk check. * Adding format settings for SND_SOC_DAIFMT_AC97 like others. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 74 +++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 39 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index dfb0da3cedda..ed9102d91cf5 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -860,42 +860,31 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream, return 0; } -static int _fsl_ssi_set_dai_fmt(struct device *dev, - struct fsl_ssi *ssi, unsigned int fmt) +static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt) { - struct regmap *regs = ssi->regs; - u32 strcr = 0, stcr, srcr, scr, mask; + u32 strcr = 0, scr = 0, stcr, srcr, mask; ssi->dai_fmt = fmt; - if (fsl_ssi_is_i2s_master(ssi) && IS_ERR(ssi->baudclk)) { - dev_err(dev, "missing baudclk for master mode\n"); - return -EINVAL; - } - - regmap_read(regs, REG_SSI_SCR, &scr); - scr &= ~(SSI_SCR_SYN | SSI_SCR_I2S_MODE_MASK); /* Synchronize frame sync clock for TE to avoid data slipping */ scr |= SSI_SCR_SYNC_TX_FS; - mask = SSI_STCR_TXBIT0 | SSI_STCR_TFDIR | SSI_STCR_TXDIR | - SSI_STCR_TSCKP | SSI_STCR_TFSI | SSI_STCR_TFSL | SSI_STCR_TEFS; - regmap_read(regs, REG_SSI_STCR, &stcr); - regmap_read(regs, REG_SSI_SRCR, &srcr); - stcr &= ~mask; - srcr &= ~mask; + /* Set to default shifting settings: LSB_ALIGNED */ + strcr |= SSI_STCR_TXBIT0; /* Use Network mode as default */ ssi->i2s_net = SSI_SCR_NET; switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { case SND_SOC_DAIFMT_I2S: - regmap_update_bits(regs, REG_SSI_STCCR, - SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2)); - regmap_update_bits(regs, REG_SSI_SRCCR, - SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2)); switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFS: case SND_SOC_DAIFMT_CBS_CFS: + if (IS_ERR(ssi->baudclk)) { + dev_err(ssi->dev, + "missing baudclk for master mode\n"); + return -EINVAL; + } + /* fall through */ + case SND_SOC_DAIFMT_CBM_CFS: ssi->i2s_net |= SSI_SCR_I2S_MODE_MASTER; break; case SND_SOC_DAIFMT_CBM_CFM: @@ -905,30 +894,34 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, return -EINVAL; } + regmap_update_bits(ssi->regs, REG_SSI_STCCR, + SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2)); + regmap_update_bits(ssi->regs, REG_SSI_SRCCR, + SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2)); + /* Data on rising edge of bclk, frame low, 1clk before data */ - strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP | - SSI_STCR_TXBIT0 | SSI_STCR_TEFS; + strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP | SSI_STCR_TEFS; break; case SND_SOC_DAIFMT_LEFT_J: /* Data on rising edge of bclk, frame high */ - strcr |= SSI_STCR_TXBIT0 | SSI_STCR_TSCKP; + strcr |= SSI_STCR_TSCKP; break; case SND_SOC_DAIFMT_DSP_A: /* Data on rising edge of bclk, frame high, 1clk before data */ - strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP | - SSI_STCR_TXBIT0 | SSI_STCR_TEFS; + strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP | SSI_STCR_TEFS; break; case SND_SOC_DAIFMT_DSP_B: /* Data on rising edge of bclk, frame high */ - strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP | SSI_STCR_TXBIT0; + strcr |= SSI_STCR_TFSL | SSI_STCR_TSCKP; break; case SND_SOC_DAIFMT_AC97: /* Data on falling edge of bclk, frame high, 1clk before data */ - ssi->i2s_net |= SSI_SCR_I2S_MODE_NORMAL; + strcr |= SSI_STCR_TEFS; break; default: return -EINVAL; } + scr |= ssi->i2s_net; /* DAI clock inversion */ @@ -962,20 +955,17 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, break; case SND_SOC_DAIFMT_CBM_CFM: /* Input bit or frame sync clocks */ - scr &= ~SSI_SCR_SYS_CLK_EN; break; case SND_SOC_DAIFMT_CBM_CFS: /* Input bit clock but output frame sync clock */ - strcr &= ~SSI_STCR_TXDIR; strcr |= SSI_STCR_TFDIR; - scr &= ~SSI_SCR_SYS_CLK_EN; break; default: return -EINVAL; } - stcr |= strcr; - srcr |= strcr; + stcr = strcr; + srcr = strcr; /* Set SYN mode and clear RXDIR bit when using SYN or AC97 mode */ if (ssi->cpu_dai_drv.symmetric_rates || fsl_ssi_is_ac97(ssi)) { @@ -983,9 +973,15 @@ static int _fsl_ssi_set_dai_fmt(struct device *dev, scr |= SSI_SCR_SYN; } - regmap_write(regs, REG_SSI_STCR, stcr); - regmap_write(regs, REG_SSI_SRCR, srcr); - regmap_write(regs, REG_SSI_SCR, scr); + mask = SSI_STCR_TFDIR | SSI_STCR_TXDIR | SSI_STCR_TSCKP | + SSI_STCR_TFSL | SSI_STCR_TFSI | SSI_STCR_TEFS | SSI_STCR_TXBIT0; + + regmap_update_bits(ssi->regs, REG_SSI_STCR, mask, stcr); + regmap_update_bits(ssi->regs, REG_SSI_SRCR, mask, srcr); + + mask = SSI_SCR_SYNC_TX_FS | SSI_SCR_I2S_MODE_MASK | + SSI_SCR_SYS_CLK_EN | SSI_SCR_SYN; + regmap_update_bits(ssi->regs, REG_SSI_SCR, mask, scr); return 0; } @@ -1001,7 +997,7 @@ static int fsl_ssi_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) if (fsl_ssi_is_ac97(ssi)) return 0; - return _fsl_ssi_set_dai_fmt(dai->dev, ssi, fmt); + return _fsl_ssi_set_dai_fmt(ssi, fmt); } /** @@ -1254,7 +1250,7 @@ static int fsl_ssi_hw_init(struct fsl_ssi *ssi) /* AC97 should start earlier to communicate with CODECs */ if (fsl_ssi_is_ac97(ssi)) { - _fsl_ssi_set_dai_fmt(ssi->dev, ssi, ssi->dai_fmt); + _fsl_ssi_set_dai_fmt(ssi, ssi->dai_fmt); fsl_ssi_setup_ac97(ssi); } From badc9595bc15686be3b01e3554421647de348df0 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:23 -0800 Subject: [PATCH 352/942] ASoC: fsl_ssi: Add bool synchronous to mark synchronous mode Using symmetric_rates in the cpu_dai_drv is a bit implicit, so this patch adds a bool synchronous instead. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index ed9102d91cf5..b58fabe77c6f 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -217,6 +217,7 @@ struct fsl_ssi_soc_data { * @dai_fmt: DAI configuration this device is currently used with * @streams: Mask of current active streams: BIT(TX) and BIT(RX) * @i2s_net: I2S and Network mode configurations of SCR register + * @synchronous: Use synchronous mode - both of TX and RX use STCK and SFCK * @use_dma: DMA is used or FIQ with stream filter * @use_dual_fifo: DMA with support for dual FIFO mode * @has_ipg_clk_name: If "ipg" is in the clock name list of device tree @@ -262,6 +263,7 @@ struct fsl_ssi { unsigned int dai_fmt; u8 streams; u8 i2s_net; + bool synchronous; bool use_dma; bool use_dual_fifo; bool has_ipg_clk_name; @@ -673,7 +675,6 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, bool tx2, tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; struct fsl_ssi *ssi = snd_soc_dai_get_drvdata(dai); struct regmap *regs = ssi->regs; - int synchronous = ssi->cpu_dai_drv.symmetric_rates, ret; u32 pm = 999, div2, psr, stccr, mask, afreq, factor, i; unsigned long clkrate, baudrate, tmprate; unsigned int slots = params_channels(hw_params); @@ -681,6 +682,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, u64 sub, savesub = 100000; unsigned int freq; bool baudclk_is_used; + int ret; /* Override slots and slot_width if being specifically set... */ if (ssi->slots) @@ -759,7 +761,7 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, mask = SSI_SxCCR_PM_MASK | SSI_SxCCR_DIV2 | SSI_SxCCR_PSR; /* STCCR is used for RX in synchronous mode */ - tx2 = tx || synchronous; + tx2 = tx || ssi->synchronous; regmap_update_bits(regs, REG_SSI_SxCCR(tx2), mask, stccr); if (!baudclk_is_used) { @@ -807,7 +809,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, * that should set separate configurations for STCCR and SRCCR * despite running in the synchronous mode. */ - if (enabled && ssi->cpu_dai_drv.symmetric_rates) + if (enabled && ssi->synchronous) return 0; if (fsl_ssi_is_i2s_master(ssi)) { @@ -839,7 +841,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, } /* In synchronous mode, the SSI uses STCCR for capture */ - tx2 = tx || ssi->cpu_dai_drv.symmetric_rates; + tx2 = tx || ssi->synchronous; regmap_update_bits(regs, REG_SSI_SxCCR(tx2), SSI_SxCCR_WL_MASK, wl); return 0; @@ -968,7 +970,7 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt) srcr = strcr; /* Set SYN mode and clear RXDIR bit when using SYN or AC97 mode */ - if (ssi->cpu_dai_drv.symmetric_rates || fsl_ssi_is_ac97(ssi)) { + if (ssi->synchronous || fsl_ssi_is_ac97(ssi)) { srcr &= ~SSI_SRCR_RXDIR; scr |= SSI_SCR_SYN; } @@ -1456,6 +1458,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) if (!fsl_ssi_is_ac97(ssi)) { ssi->cpu_dai_drv.symmetric_rates = 1; ssi->cpu_dai_drv.symmetric_samplebits = 1; + ssi->synchronous = true; } ssi->cpu_dai_drv.symmetric_channels = 1; From 76f3845110d7d40eb60c12bc64cdfe431a985947 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:24 -0800 Subject: [PATCH 353/942] ASoC: fsl_ssi: Move DT related code to a separate probe() This patch cleans up probe() function by moving all Device Tree related code into a separate function. It allows the probe() to be Device Tree independent. This will be very useful for future integration of imx-ssi driver which has similar functionalities while exists only because it supports non-DT cases. This patch also moves symmetric_channels of AC97 from the probe to the structure snd_soc_dai_driver for simplification. Additionally, since PowerPC and AC97 use the same pdev pointer to register a platform device, this patch also unifies related code. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 217 +++++++++++++++++++++++----------------- 1 file changed, 123 insertions(+), 94 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b58fabe77c6f..5bc67ad8000f 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -239,8 +239,12 @@ struct fsl_ssi_soc_data { * * @fiq_params: FIQ stream filtering parameters * - * @pdev: Pointer to pdev when using fsl-ssi as sound card (ppc only) - * TODO: Should be replaced with simple-sound-card + * @card_pdev: Platform_device pointer to register a sound card for PowerPC or + * to register a CODEC platform device for AC97 + * @card_name: Platform_device name to register a sound card for PowerPC or + * to register a CODEC platform device for AC97 + * @card_idx: The index of SSI to register a sound card for PowerPC or + * to register a CODEC platform device for AC97 * * @dbg_stats: Debugging statistics * @@ -285,7 +289,9 @@ struct fsl_ssi { struct imx_pcm_fiq_params fiq_params; - struct platform_device *pdev; + struct platform_device *card_pdev; + char card_name[32]; + u32 card_idx; struct fsl_ssi_dbg dbg_stats; @@ -1134,6 +1140,7 @@ static const struct snd_soc_component_driver fsl_ssi_component = { static struct snd_soc_dai_driver fsl_ssi_ac97_dai = { .bus_control = true, + .symmetric_channels = 1, .probe = fsl_ssi_dai_probe, .playback = { .stream_name = "AC97 Playback", @@ -1291,9 +1298,7 @@ static void make_lowercase(char *s) static int fsl_ssi_imx_probe(struct platform_device *pdev, struct fsl_ssi *ssi, void __iomem *iomem) { - struct device_node *np = pdev->dev.of_node; struct device *dev = &pdev->dev; - u32 dmas[4]; int ret; /* Backward compatible for a DT without ipg clock name assigned */ @@ -1327,14 +1332,8 @@ static int fsl_ssi_imx_probe(struct platform_device *pdev, ssi->dma_params_tx.addr = ssi->ssi_phys + REG_SSI_STX0; ssi->dma_params_rx.addr = ssi->ssi_phys + REG_SSI_SRX0; - /* Set to dual FIFO mode according to the SDMA sciprt */ - ret = of_property_read_u32_array(np, "dmas", dmas, 4); - if (ssi->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) { - ssi->use_dual_fifo = true; - /* - * Use even numbers to avoid channel swap due to SDMA - * script design - */ + /* Use even numbers to avoid channel swap due to SDMA script design */ + if (ssi->use_dual_fifo) { ssi->dma_params_tx.maxburst &= ~0x1; ssi->dma_params_rx.maxburst &= ~0x1; } @@ -1375,41 +1374,109 @@ static void fsl_ssi_imx_clean(struct platform_device *pdev, struct fsl_ssi *ssi) clk_disable_unprepare(ssi->clk); } -static int fsl_ssi_probe(struct platform_device *pdev) +static int fsl_ssi_probe_from_dt(struct fsl_ssi *ssi) { - struct fsl_ssi *ssi; - int ret = 0; - struct device_node *np = pdev->dev.of_node; - struct device *dev = &pdev->dev; + struct device *dev = ssi->dev; + struct device_node *np = dev->of_node; const struct of_device_id *of_id; const char *p, *sprop; const __be32 *iprop; - struct resource *res; - void __iomem *iomem; - char name[64]; - struct regmap_config regconfig = fsl_ssi_regconfig; + u32 dmas[4]; + int ret; of_id = of_match_device(fsl_ssi_ids, dev); if (!of_id || !of_id->data) return -EINVAL; - ssi = devm_kzalloc(dev, sizeof(*ssi), GFP_KERNEL); - if (!ssi) - return -ENOMEM; - ssi->soc = of_id->data; - ssi->dev = dev; + + ret = of_property_match_string(np, "clock-names", "ipg"); + /* Get error code if not found */ + ssi->has_ipg_clk_name = ret >= 0; /* Check if being used in AC97 mode */ sprop = of_get_property(np, "fsl,mode", NULL); - if (sprop) { - if (!strcmp(sprop, "ac97-slave")) - ssi->dai_fmt = FSLSSI_AC97_DAIFMT; + if (sprop && !strcmp(sprop, "ac97-slave")) { + ssi->dai_fmt = FSLSSI_AC97_DAIFMT; + + ret = of_property_read_u32(np, "cell-index", &ssi->card_idx); + if (ret) { + dev_err(dev, "failed to get SSI index property\n"); + return -EINVAL; + } + strcpy(ssi->card_name, "ac97-codec"); + } else if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) { + /* + * In synchronous mode, STCK and STFS ports are used by RX + * as well. So the software should limit the sample rates, + * sample bits and channels to be symmetric. + * + * This is exclusive with FSLSSI_AC97_FORMATS as AC97 runs + * in the SSI synchronous mode however it does not have to + * limit symmetric sample rates and sample bits. + */ + ssi->synchronous = true; } /* Select DMA or FIQ */ ssi->use_dma = !of_property_read_bool(np, "fsl,fiq-stream-filter"); + /* Fetch FIFO depth; Set to 8 for older DT without this property */ + iprop = of_get_property(np, "fsl,fifo-depth", NULL); + if (iprop) + ssi->fifo_depth = be32_to_cpup(iprop); + else + ssi->fifo_depth = 8; + + /* Use dual FIFO mode depending on the support from SDMA script */ + ret = of_property_read_u32_array(np, "dmas", dmas, 4); + if (ssi->use_dma && !ret && dmas[2] == IMX_DMATYPE_SSI_DUAL) + ssi->use_dual_fifo = true; + + /* + * Backward compatible for older bindings by manually triggering the + * machine driver's probe(). Use /compatible property, including the + * address of CPU DAI driver structure, as the name of machine driver + * + * If card_name is set by AC97 earlier, bypass here since it uses a + * different name to register the device. + */ + if (!ssi->card_name[0] && of_get_property(np, "codec-handle", NULL)) { + sprop = of_get_property(of_find_node_by_path("/"), + "compatible", NULL); + /* Strip "fsl," in the compatible name if applicable */ + p = strrchr(sprop, ','); + if (p) + sprop = p + 1; + snprintf(ssi->card_name, sizeof(ssi->card_name), + "snd-soc-%s", sprop); + make_lowercase(ssi->card_name); + ssi->card_idx = 0; + } + + return 0; +} + +static int fsl_ssi_probe(struct platform_device *pdev) +{ + struct regmap_config regconfig = fsl_ssi_regconfig; + struct device *dev = &pdev->dev; + struct fsl_ssi *ssi; + struct resource *res; + void __iomem *iomem; + int ret = 0; + + ssi = devm_kzalloc(dev, sizeof(*ssi), GFP_KERNEL); + if (!ssi) + return -ENOMEM; + + ssi->dev = dev; + + /* Probe from DT */ + ret = fsl_ssi_probe_from_dt(ssi); + if (ret) + return ret; + if (fsl_ssi_is_ac97(ssi)) { memcpy(&ssi->cpu_dai_drv, &fsl_ssi_ac97_dai, sizeof(fsl_ssi_ac97_dai)); @@ -1433,15 +1500,11 @@ static int fsl_ssi_probe(struct platform_device *pdev) REG_SSI_SRMSK / sizeof(uint32_t) + 1; } - ret = of_property_match_string(np, "clock-names", "ipg"); - if (ret < 0) { - ssi->has_ipg_clk_name = false; - ssi->regs = devm_regmap_init_mmio(dev, iomem, ®config); - } else { - ssi->has_ipg_clk_name = true; + if (ssi->has_ipg_clk_name) ssi->regs = devm_regmap_init_mmio_clk(dev, "ipg", iomem, ®config); - } + else + ssi->regs = devm_regmap_init_mmio(dev, iomem, ®config); if (IS_ERR(ssi->regs)) { dev_err(dev, "failed to init register map\n"); return PTR_ERR(ssi->regs); @@ -1453,24 +1516,13 @@ static int fsl_ssi_probe(struct platform_device *pdev) return ssi->irq; } - /* Set software limitations for synchronous mode */ - if (!of_find_property(np, "fsl,ssi-asynchronous", NULL)) { - if (!fsl_ssi_is_ac97(ssi)) { - ssi->cpu_dai_drv.symmetric_rates = 1; - ssi->cpu_dai_drv.symmetric_samplebits = 1; - ssi->synchronous = true; - } - + /* Set software limitations for synchronous mode except AC97 */ + if (ssi->synchronous && !fsl_ssi_is_ac97(ssi)) { + ssi->cpu_dai_drv.symmetric_rates = 1; ssi->cpu_dai_drv.symmetric_channels = 1; + ssi->cpu_dai_drv.symmetric_samplebits = 1; } - /* Fetch FIFO depth; Set to 8 for older DT without this property */ - iprop = of_get_property(np, "fsl,fifo-depth", NULL); - if (iprop) - ssi->fifo_depth = be32_to_cpup(iprop); - else - ssi->fifo_depth = 8; - /* * Configure TX and RX DMA watermarks -- when to send a DMA request * @@ -1535,50 +1587,27 @@ static int fsl_ssi_probe(struct platform_device *pdev) if (ret) goto error_asoc_register; - /* Bypass it if using newer DT bindings of ASoC machine drivers */ - if (!of_get_property(np, "codec-handle", NULL)) - goto done; - - /* - * Backward compatible for older bindings by manually triggering the - * machine driver's probe(). Use /compatible property, including the - * address of CPU DAI driver structure, as the name of machine driver. - */ - sprop = of_get_property(of_find_node_by_path("/"), "compatible", NULL); - /* Sometimes the compatible name has a "fsl," prefix, so we strip it. */ - p = strrchr(sprop, ','); - if (p) - sprop = p + 1; - snprintf(name, sizeof(name), "snd-soc-%s", sprop); - make_lowercase(name); - - ssi->pdev = platform_device_register_data(dev, name, 0, NULL, 0); - if (IS_ERR(ssi->pdev)) { - ret = PTR_ERR(ssi->pdev); - dev_err(dev, "failed to register platform: %d\n", ret); - goto error_sound_card; - } - -done: /* Initially configures SSI registers */ fsl_ssi_hw_init(ssi); - if (fsl_ssi_is_ac97(ssi)) { - u32 ssi_idx; + /* Register a platform device for older bindings or AC97 */ + if (ssi->card_name[0]) { + struct device *parent = dev; + /* + * Do not set SSI dev as the parent of AC97 CODEC device since + * it does not have a DT node. Otherwise ASoC core will assume + * CODEC has the same DT node as the SSI, so it may bypass the + * dai_probe() of SSI and then cause NULL DMA data pointers. + */ + if (fsl_ssi_is_ac97(ssi)) + parent = NULL; - ret = of_property_read_u32(np, "cell-index", &ssi_idx); - if (ret) { - dev_err(dev, "failed to get SSI index property\n"); - goto error_sound_card; - } - - ssi->pdev = platform_device_register_data(NULL, "ac97-codec", - ssi_idx, NULL, 0); - if (IS_ERR(ssi->pdev)) { - ret = PTR_ERR(ssi->pdev); - dev_err(dev, - "failed to register AC97 codec platform: %d\n", - ret); + ssi->card_pdev = platform_device_register_data(parent, + ssi->card_name, ssi->card_idx, NULL, 0); + if (IS_ERR(ssi->card_pdev)) { + ret = PTR_ERR(ssi->card_pdev); + dev_err(dev, "failed to register %s: %d\n", + ssi->card_name, ret); goto error_sound_card; } } @@ -1606,8 +1635,8 @@ static int fsl_ssi_remove(struct platform_device *pdev) fsl_ssi_debugfs_remove(&ssi->dbg_stats); - if (ssi->pdev) - platform_device_unregister(ssi->pdev); + if (ssi->card_pdev) + platform_device_unregister(ssi->card_pdev); /* Clean up SSI registers */ fsl_ssi_hw_clean(ssi); From 9c4f509a53cbcd968677c7f15c07260dd6c2276c Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Mon, 12 Feb 2018 14:03:25 -0800 Subject: [PATCH 354/942] ASoC: fsl_ssi: Use ssi->streams instead of reading register Since ssi->streams is being updated along with SCR register and its SSIEN bit, it's simpler to use it instead. Signed-off-by: Nicolin Chen Tested-by: Caleb Crome Tested-by: Maciej S. Szmigiero Reviewed-by: Maciej S. Szmigiero Signed-off-by: Mark Brown --- sound/soc/fsl/fsl_ssi.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 5bc67ad8000f..0823b08923b5 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -803,11 +803,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, unsigned int sample_size = params_width(hw_params); u32 wl = SSI_SxCCR_WL(sample_size); int ret; - u32 scr; - int enabled; - - regmap_read(regs, REG_SSI_SCR, &scr); - enabled = scr & SSI_SCR_SSIEN; /* * SSI is properly configured if it is enabled and running in @@ -815,7 +810,7 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, * that should set separate configurations for STCCR and SRCCR * despite running in the synchronous mode. */ - if (enabled && ssi->synchronous) + if (ssi->streams && ssi->synchronous) return 0; if (fsl_ssi_is_i2s_master(ssi)) { From d1897c9538edafd4ae6bbd03cc075962ddde2c21 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 21 Feb 2018 11:39:22 -0800 Subject: [PATCH 355/942] cgroup: fix rule checking for threaded mode switching A domain cgroup isn't allowed to be turned threaded if its subtree is populated or domain controllers are enabled. cgroup_enable_threaded() depended on cgroup_can_be_thread_root() test to enforce this rule. A parent which has populated domain descendants or have domain controllers enabled can't become a thread root, so the above rules are enforced automatically. However, for the root cgroup which can host mixed domain and threaded children, cgroup_can_be_thread_root() doesn't check any of those conditions and thus first level cgroups ends up escaping those rules. This patch fixes the bug by adding explicit checks for those rules in cgroup_enable_threaded(). Reported-by: Michael Kerrisk (man-pages) Signed-off-by: Tejun Heo Fixes: 8cfd8147df67 ("cgroup: implement cgroup v2 thread support") Cc: stable@vger.kernel.org # v4.14+ --- kernel/cgroup/cgroup.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 8cda3bc3ae22..4bfb2908ec15 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -3183,6 +3183,16 @@ static int cgroup_enable_threaded(struct cgroup *cgrp) if (cgroup_is_threaded(cgrp)) return 0; + /* + * If @cgroup is populated or has domain controllers enabled, it + * can't be switched. While the below cgroup_can_be_thread_root() + * test can catch the same conditions, that's only when @parent is + * not mixable, so let's check it explicitly. + */ + if (cgroup_is_populated(cgrp) || + cgrp->subtree_control & ~cgrp_dfl_threaded_ss_mask) + return -EOPNOTSUPP; + /* we're joining the parent's domain, ensure its validity */ if (!cgroup_is_valid_domain(dom_cgrp) || !cgroup_can_be_thread_root(dom_cgrp)) From a275b315334dea3c2151094765387ede421aac92 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 15 Jan 2018 13:21:48 -0200 Subject: [PATCH 356/942] clk: imx51-imx53: Fix UART4/5 registration on i.MX50 and i.MX53 Since commit 59dc3d8c8673 ("clk: imx51: uart4, uart5 gates only exist on imx50, imx53") the following warnings are seen on i.MX53: [ 2.776190] ------------[ cut here ]------------ [ 2.780948] WARNING: CPU: 0 PID: 1 at ../drivers/clk/clk.c:811 clk_core_disable+0xc4/0xe0 [ 2.789145] Modules linked in: [ 2.792236] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.15.0-rc7-next-20180115 #1 [ 2.799735] Hardware name: Freescale i.MX53 (Device Tree Support) [ 2.805845] Backtrace: [ 2.808329] [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [ 2.815919] r7:00000000 r6:60000093 r5:00000000 r4:c10798d4 [ 2.821607] [] (show_stack) from [] (dump_stack+0xb4/0xe8) [ 2.828854] [] (dump_stack) from [] (__warn+0xf0/0x11c) [ 2.835837] r9:00000000 r8:0000032b r7:00000009 r6:c0d429f8 r5:00000000 r4:00000000 [ 2.843601] [] (__warn) from [] (warn_slowpath_null+0x44/0x50) [ 2.851191] r8:c1008908 r7:c0e08874 r6:c04bfac8 r5:0000032b r4:c0d429f8 [ 2.857913] [] (warn_slowpath_null) from [] (clk_core_disable+0xc4/0xe0) [ 2.866369] r6:dc02bb00 r5:dc02a980 r4:dc02a980 [ 2.871011] [] (clk_core_disable) from [] (clk_core_disable_lock+0x20/0x2c) [ 2.879726] r5:dc02a980 r4:80000013 [ 2.883323] [] (clk_core_disable_lock) from [] (clk_disable+0x24/0x28) [ 2.891604] r5:c0f6b3e4 r4:0000001c [ 2.895209] [] (clk_disable) from [] (imx_clk_disable_uart+0x50/0x68) [ 2.903412] [] (imx_clk_disable_uart) from [] (do_one_initcall+0x50/0x19c) [ 2.912043] r7:c0e08874 r6:c0f63854 r5:c0f233bc r4:ffffe000 [ 2.917726] [] (do_one_initcall) from [] (kernel_init_freeable+0x118/0x1d0) [ 2.926447] r9:c0f63858 r8:000000f0 r7:c0e08874 r6:c0f63854 r5:c107b500 r4:c0f75260 [ 2.934220] [] (kernel_init_freeable) from [] (kernel_init+0x10/0x118) [ 2.942506] r10:00000000 r9:00000000 r8:00000000 r7:00000000 r6:00000000 r5:c0a4a5e0 [ 2.950351] r4:00000000 [ 2.952908] [] (kernel_init) from [] (ret_from_fork+0x14/0x20) [ 2.960496] Exception stack(0xdc05dfb0 to 0xdc05dff8) [ 2.965569] dfa0: 00000000 00000000 00000000 00000000 [ 2.973768] dfc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 2.981965] dfe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 2.988596] r5:c0a4a5e0 r4:00000000 [ 2.992188] ---[ end trace 346e26f708876edd ]--- [ 2.997420] ------------[ cut here ]------------ In order to fix the problem UART4/5 registration needs to happen only on i.MX50 and i.MX53. So let mx51_clocks_init() register only UART1-3 and mx50_clocks_init()/mx53_clocks_init register all the UART1-5 ports. Fixes: 59dc3d8c8673 ("clk: imx51: uart4, uart5 gates only exist on imx50, imx53") Signed-off-by: Fabio Estevam Reviewed-by: Philipp Zabel Signed-off-by: Shawn Guo --- drivers/clk/imx/clk-imx51-imx53.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/clk/imx/clk-imx51-imx53.c b/drivers/clk/imx/clk-imx51-imx53.c index c864992e6983..caa8bd40692c 100644 --- a/drivers/clk/imx/clk-imx51-imx53.c +++ b/drivers/clk/imx/clk-imx51-imx53.c @@ -131,7 +131,17 @@ static const char *ieee1588_sels[] = { "pll3_sw", "pll4_sw", "dummy" /* usbphy2_ static struct clk *clk[IMX5_CLK_END]; static struct clk_onecell_data clk_data; -static struct clk ** const uart_clks[] __initconst = { +static struct clk ** const uart_clks_mx51[] __initconst = { + &clk[IMX5_CLK_UART1_IPG_GATE], + &clk[IMX5_CLK_UART1_PER_GATE], + &clk[IMX5_CLK_UART2_IPG_GATE], + &clk[IMX5_CLK_UART2_PER_GATE], + &clk[IMX5_CLK_UART3_IPG_GATE], + &clk[IMX5_CLK_UART3_PER_GATE], + NULL +}; + +static struct clk ** const uart_clks_mx50_mx53[] __initconst = { &clk[IMX5_CLK_UART1_IPG_GATE], &clk[IMX5_CLK_UART1_PER_GATE], &clk[IMX5_CLK_UART2_IPG_GATE], @@ -321,8 +331,6 @@ static void __init mx5_clocks_common_init(void __iomem *ccm_base) clk_prepare_enable(clk[IMX5_CLK_TMAX1]); clk_prepare_enable(clk[IMX5_CLK_TMAX2]); /* esdhc2, fec */ clk_prepare_enable(clk[IMX5_CLK_TMAX3]); /* esdhc1, esdhc4 */ - - imx_register_uart_clocks(uart_clks); } static void __init mx50_clocks_init(struct device_node *np) @@ -388,6 +396,8 @@ static void __init mx50_clocks_init(struct device_node *np) r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000); clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r); + + imx_register_uart_clocks(uart_clks_mx50_mx53); } CLK_OF_DECLARE(imx50_ccm, "fsl,imx50-ccm", mx50_clocks_init); @@ -477,6 +487,8 @@ static void __init mx51_clocks_init(struct device_node *np) val = readl(MXC_CCM_CLPCR); val |= 1 << 23; writel(val, MXC_CCM_CLPCR); + + imx_register_uart_clocks(uart_clks_mx51); } CLK_OF_DECLARE(imx51_ccm, "fsl,imx51-ccm", mx51_clocks_init); @@ -606,5 +618,7 @@ static void __init mx53_clocks_init(struct device_node *np) r = clk_round_rate(clk[IMX5_CLK_USBOH3_PER_GATE], 54000000); clk_set_rate(clk[IMX5_CLK_USBOH3_PER_GATE], r); + + imx_register_uart_clocks(uart_clks_mx50_mx53); } CLK_OF_DECLARE(imx53_ccm, "fsl,imx53-ccm", mx53_clocks_init); From 24745dca8e7e17c20b6cf2bfb94a9acd09dce1b9 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Thu, 22 Feb 2018 08:42:32 +0900 Subject: [PATCH 357/942] ASoC: uniphier: evea: fix lisence comment style This patch changes lisence comment style from C to C++. And use SPDX instead of boiler plate of GPLv2, as same as other audio codec drivers. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/evea.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/sound/soc/uniphier/evea.c b/sound/soc/uniphier/evea.c index ac2d30b55fb6..439f14f91b23 100644 --- a/sound/soc/uniphier/evea.c +++ b/sound/soc/uniphier/evea.c @@ -1,22 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/* - * Socionext UniPhier EVEA ADC/DAC codec driver. - * - * Copyright (c) 2016-2017 Socionext Inc. - * - * 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; version 2 - * of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see . - */ +// +// Socionext UniPhier EVEA ADC/DAC codec driver. +// +// Copyright (c) 2016-2017 Socionext Inc. #include #include From f0b3bdbd5c63c3f69f3b6a869355c676d22fd348 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 21 Feb 2018 14:57:33 -0300 Subject: [PATCH 358/942] ASoC: soc-generic-dmaengine-pcm: Add a DMA debugfs_prefix entry After the conversion from platform to component the following warnings are seen: fsl-ssi-dai 2028000.ssi: ASoC: Failed to create component debugfs directory fsl-spdif-dai 2004000.spdif: ASoC: Failed to create component debugfs directory As explained by Mark Brown: "It's a legit warning - we shouldn't really be creating two components for the same device. However this is a bit of a corner case as it's the dmaengine platform driver which is kind of a virtual device, it's not really the device that we use with DMA that's being represented but rather the link between that and the DMA controller." Disambiguate the DMA component name by adding a "dma" debugfs_prefix entry. Suggested-by: Mark Brown Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index d53786498b61..8fb828bb8a7f 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -431,6 +431,9 @@ int snd_dmaengine_pcm_register(struct device *dev, if (!pcm) return -ENOMEM; +#ifdef CONFIG_DEBUG_FS + pcm->component.debugfs_prefix = "dma"; +#endif pcm->config = config; pcm->flags = flags; From accd4f36a7d11c2d54544007eb65e10604dcf2f5 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Fri, 23 Feb 2018 08:12:42 -0800 Subject: [PATCH 359/942] percpu: add a schedule point in pcpu_balance_workfn() When a large BPF percpu map is destroyed, I have seen pcpu_balance_workfn() holding cpu for hundreds of milliseconds. On KASAN config and 112 hyperthreads, average time to destroy a chunk is ~4 ms. [ 2489.841376] destroy chunk 1 in 4148689 ns ... [ 2490.093428] destroy chunk 32 in 4072718 ns Signed-off-by: Eric Dumazet Signed-off-by: Tejun Heo --- mm/percpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/percpu.c b/mm/percpu.c index fa3f854634a1..36e7b65ba6cf 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1610,6 +1610,7 @@ static void pcpu_balance_workfn(struct work_struct *work) spin_unlock_irq(&pcpu_lock); } pcpu_destroy_chunk(chunk); + cond_resched(); } /* From 3b821409632ab778d46e807516b457dfa72736ed Mon Sep 17 00:00:00 2001 From: Al Viro Date: Fri, 23 Feb 2018 20:47:17 -0500 Subject: [PATCH 360/942] lock_parent() needs to recheck if dentry got __dentry_kill'ed under it In case when dentry passed to lock_parent() is protected from freeing only by the fact that it's on a shrink list and trylock of parent fails, we could get hit by __dentry_kill() (and subsequent dentry_kill(parent)) between unlocking dentry and locking presumed parent. We need to recheck that dentry is alive once we lock both it and parent *and* postpone rcu_read_unlock() until after that point. Otherwise we could return a pointer to struct dentry that already is rcu-scheduled for freeing, with ->d_lock held on it; caller's subsequent attempt to unlock it can end up with memory corruption. Cc: stable@vger.kernel.org # 3.12+, counting backports Signed-off-by: Al Viro --- fs/dcache.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/dcache.c b/fs/dcache.c index 7c38f39958bc..32aaab21e648 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -647,11 +647,16 @@ again: spin_unlock(&parent->d_lock); goto again; } - rcu_read_unlock(); - if (parent != dentry) + if (parent != dentry) { spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); - else + if (unlikely(dentry->d_lockref.count < 0)) { + spin_unlock(&parent->d_lock); + parent = NULL; + } + } else { parent = NULL; + } + rcu_read_unlock(); return parent; } From b91e146c38b003c899710ede6d05fc824675e386 Mon Sep 17 00:00:00 2001 From: Richard Lai Date: Sat, 17 Feb 2018 16:28:24 +0000 Subject: [PATCH 361/942] iio: chemical: ccs811: Corrected firmware boot/application mode transition CCS811 has different I2C register maps in boot and application mode. When CCS811 is in boot mode, register APP_START (0xF4) is used to transit the firmware state from boot to application mode. However, APP_START is not a valid register location when CCS811 is in application mode (refer to "CCS811 Bootloader Register Map" and "CCS811 Application Register Map" in CCS811 datasheet). The driver should not attempt to perform a write to APP_START while CCS811 is in application mode, as this is not a valid or documented register location. When prob function is being called, the driver assumes the CCS811 sensor is in boot mode, and attempts to perform a write to APP_START. Although CCS811 powers-up in boot mode, it may have already been transited to application mode by previous instances, e.g. unload and reload device driver by the system, or explicitly by user. Depending on the system design, CCS811 sensor may be permanently connected to system power source rather than power controlled by GPIO, hence it is possible that the sensor is never power reset, thus the firmware could be in either boot or application mode at any given time when driver prob function is being called. This patch checks the STATUS register before attempting to send a write to APP_START. Only if the firmware is not in application mode and has valid firmware application loaded, then it will continue to start transiting the firmware boot to application mode. Signed-off-by: Richard Lai Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/chemical/ccs811.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/chemical/ccs811.c b/drivers/iio/chemical/ccs811.c index fbe2431f5b81..1ea9f5513b02 100644 --- a/drivers/iio/chemical/ccs811.c +++ b/drivers/iio/chemical/ccs811.c @@ -133,6 +133,9 @@ static int ccs811_start_sensor_application(struct i2c_client *client) if (ret < 0) return ret; + if ((ret & CCS811_STATUS_FW_MODE_APPLICATION)) + return 0; + if ((ret & CCS811_STATUS_APP_VALID_MASK) != CCS811_STATUS_APP_VALID_LOADED) return -EIO; From 4e4f9fbc5620a060dc7d3a651cdfb001c1d7c2f9 Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Fri, 23 Feb 2018 13:50:55 +0100 Subject: [PATCH 362/942] iio: adc: stm32-dfsdm: fix compatible data use Fix use of compatible data: stm32h7 regmap configuration is statically used. Rather use regmap_cfg from compatible data. Fixes: bed73904e76f ("IIO: ADC: add stm32 DFSDM core support") Signed-off-by: Fabrice Gasnier Acked-by: Arnaud Pouliquen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index 6290332cfd3f..0635f9390b20 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -274,7 +274,7 @@ static int stm32_dfsdm_probe(struct platform_device *pdev) dfsdm->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "dfsdm", dfsdm->base, - &stm32h7_dfsdm_regmap_cfg); + dev_data->regmap_cfg); if (IS_ERR(dfsdm->regmap)) { ret = PTR_ERR(dfsdm->regmap); dev_err(&pdev->dev, "%s: Failed to allocate regmap: %d\n", From c278609bdde9df330b7fe3d61ec1bc1a8cac4a78 Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Fri, 23 Feb 2018 13:50:56 +0100 Subject: [PATCH 363/942] iio: adc: stm32-dfsdm: fix call to stop channel stm32_dfsdm_stop_channel must be called with channel id, not filter id. Fixes: e2e6771c6462 ("IIO: ADC: add STM32 DFSDM sigma delta ADC support") Signed-off-by: Fabrice Gasnier Acked-by: Arnaud Pouliquen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index daa026d6a94f..0eff8119119c 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -464,7 +464,7 @@ stop_channels: regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id), DFSDM_CR1_RCONT_MASK, 0); - stm32_dfsdm_stop_channel(adc->dfsdm, adc->fl_id); + stm32_dfsdm_stop_channel(adc->dfsdm, adc->ch_id); return ret; } From 179858efd94f49945d41919c1d09a8e17c2afa98 Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Fri, 23 Feb 2018 13:50:57 +0100 Subject: [PATCH 364/942] iio: adc: stm32-dfsdm: fix clock source selection Add missing clock source selection. In case "audio" clock is provided, it's unused currently: "dfsdm" clock is wrongly used by default. Fixes: bed73904e76f ("IIO: ADC: add stm32 DFSDM core support") Signed-off-by: Fabrice Gasnier Acked-by: Arnaud Pouliquen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index 0635f9390b20..e50efdcc41ff 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -83,7 +83,7 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) { struct dfsdm_priv *priv = container_of(dfsdm, struct dfsdm_priv, dfsdm); struct device *dev = &priv->pdev->dev; - unsigned int clk_div = priv->spi_clk_out_div; + unsigned int clk_div = priv->spi_clk_out_div, clk_src; int ret; if (atomic_inc_return(&priv->n_active_ch) == 1) { @@ -100,6 +100,14 @@ int stm32_dfsdm_start_dfsdm(struct stm32_dfsdm *dfsdm) } } + /* select clock source, e.g. 0 for "dfsdm" or 1 for "audio" */ + clk_src = priv->aclk ? 1 : 0; + ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), + DFSDM_CHCFGR1_CKOUTSRC_MASK, + DFSDM_CHCFGR1_CKOUTSRC(clk_src)); + if (ret < 0) + goto disable_aclk; + /* Output the SPI CLKOUT (if clk_div == 0 clock if OFF) */ ret = regmap_update_bits(dfsdm->regmap, DFSDM_CHCFGR1(0), DFSDM_CHCFGR1_CKOUTDIV_MASK, From 0645af1b6988467b8362aaf44fb4013abb045bee Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Fri, 23 Feb 2018 13:50:58 +0100 Subject: [PATCH 365/942] iio: adc: stm32-dfsdm: fix multiple channel initialization When several channels are registered (e.g. via st,adc-channels property): - channels array is wrongly filled in. Only 1st element in array is being initialized with last registered channel. Fix it by passing reference to relevant channel (e.g. array[index]). - only last initialized channel can work properly (e.g. unique 'ch_id' is used). Converting any other channel result in conversion timeout. Fix it by getting rid of 'ch_id', use chan->channel instead. Signed-off-by: Fabrice Gasnier Acked-by: Arnaud Pouliquen Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 39 +++++++++++++++++-------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 0eff8119119c..01422d11753c 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -54,7 +54,6 @@ struct stm32_dfsdm_adc { struct stm32_dfsdm *dfsdm; const struct stm32_dfsdm_dev_data *dev_data; unsigned int fl_id; - unsigned int ch_id; /* ADC specific */ unsigned int oversamp; @@ -384,7 +383,7 @@ static ssize_t dfsdm_adc_audio_set_spiclk(struct iio_dev *indio_dev, { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; - struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[adc->ch_id]; + struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel]; unsigned int sample_freq = adc->sample_freq; unsigned int spi_freq; int ret; @@ -419,18 +418,20 @@ static ssize_t dfsdm_adc_audio_set_spiclk(struct iio_dev *indio_dev, return len; } -static int stm32_dfsdm_start_conv(struct stm32_dfsdm_adc *adc, bool dma) +static int stm32_dfsdm_start_conv(struct stm32_dfsdm_adc *adc, + const struct iio_chan_spec *chan, + bool dma) { struct regmap *regmap = adc->dfsdm->regmap; int ret; unsigned int dma_en = 0, cont_en = 0; - ret = stm32_dfsdm_start_channel(adc->dfsdm, adc->ch_id); + ret = stm32_dfsdm_start_channel(adc->dfsdm, chan->channel); if (ret < 0) return ret; ret = stm32_dfsdm_filter_configure(adc->dfsdm, adc->fl_id, - adc->ch_id); + chan->channel); if (ret < 0) goto stop_channels; @@ -464,12 +465,13 @@ stop_channels: regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id), DFSDM_CR1_RCONT_MASK, 0); - stm32_dfsdm_stop_channel(adc->dfsdm, adc->ch_id); + stm32_dfsdm_stop_channel(adc->dfsdm, chan->channel); return ret; } -static void stm32_dfsdm_stop_conv(struct stm32_dfsdm_adc *adc) +static void stm32_dfsdm_stop_conv(struct stm32_dfsdm_adc *adc, + const struct iio_chan_spec *chan) { struct regmap *regmap = adc->dfsdm->regmap; @@ -482,7 +484,7 @@ static void stm32_dfsdm_stop_conv(struct stm32_dfsdm_adc *adc) regmap_update_bits(regmap, DFSDM_CR1(adc->fl_id), DFSDM_CR1_RCONT_MASK, 0); - stm32_dfsdm_stop_channel(adc->dfsdm, adc->ch_id); + stm32_dfsdm_stop_channel(adc->dfsdm, chan->channel); } static int stm32_dfsdm_set_watermark(struct iio_dev *indio_dev, @@ -609,6 +611,7 @@ static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) static int stm32_dfsdm_postenable(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + const struct iio_chan_spec *chan = &indio_dev->channels[0]; int ret; /* Reset adc buffer index */ @@ -618,7 +621,7 @@ static int stm32_dfsdm_postenable(struct iio_dev *indio_dev) if (ret < 0) return ret; - ret = stm32_dfsdm_start_conv(adc, true); + ret = stm32_dfsdm_start_conv(adc, chan, true); if (ret) { dev_err(&indio_dev->dev, "Can't start conversion\n"); goto stop_dfsdm; @@ -635,7 +638,7 @@ static int stm32_dfsdm_postenable(struct iio_dev *indio_dev) return 0; err_stop_conv: - stm32_dfsdm_stop_conv(adc); + stm32_dfsdm_stop_conv(adc, chan); stop_dfsdm: stm32_dfsdm_stop_dfsdm(adc->dfsdm); @@ -645,11 +648,12 @@ stop_dfsdm: static int stm32_dfsdm_predisable(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + const struct iio_chan_spec *chan = &indio_dev->channels[0]; if (adc->dma_chan) dmaengine_terminate_all(adc->dma_chan); - stm32_dfsdm_stop_conv(adc); + stm32_dfsdm_stop_conv(adc, chan); stm32_dfsdm_stop_dfsdm(adc->dfsdm); @@ -730,7 +734,7 @@ static int stm32_dfsdm_single_conv(struct iio_dev *indio_dev, if (ret < 0) goto stop_dfsdm; - ret = stm32_dfsdm_start_conv(adc, false); + ret = stm32_dfsdm_start_conv(adc, chan, false); if (ret < 0) { regmap_update_bits(adc->dfsdm->regmap, DFSDM_CR2(adc->fl_id), DFSDM_CR2_REOCIE_MASK, DFSDM_CR2_REOCIE(0)); @@ -751,7 +755,7 @@ static int stm32_dfsdm_single_conv(struct iio_dev *indio_dev, else ret = IIO_VAL_INT; - stm32_dfsdm_stop_conv(adc); + stm32_dfsdm_stop_conv(adc, chan); stop_dfsdm: stm32_dfsdm_stop_dfsdm(adc->dfsdm); @@ -765,7 +769,7 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; - struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[adc->ch_id]; + struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel]; unsigned int spi_freq = adc->spi_freq; int ret = -EINVAL; @@ -972,7 +976,6 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, } ch->scan_type.realbits = 24; ch->scan_type.storagebits = 32; - adc->ch_id = ch->channel; return stm32_dfsdm_chan_configure(adc->dfsdm, &adc->dfsdm->ch_list[ch->channel]); @@ -1001,7 +1004,7 @@ static int stm32_dfsdm_audio_init(struct iio_dev *indio_dev) } ch->info_mask_separate = BIT(IIO_CHAN_INFO_SAMP_FREQ); - d_ch = &adc->dfsdm->ch_list[adc->ch_id]; + d_ch = &adc->dfsdm->ch_list[ch->channel]; if (d_ch->src != DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL) adc->spi_freq = adc->dfsdm->spi_master_freq; @@ -1042,8 +1045,8 @@ static int stm32_dfsdm_adc_init(struct iio_dev *indio_dev) return -ENOMEM; for (chan_idx = 0; chan_idx < num_ch; chan_idx++) { - ch->scan_index = chan_idx; - ret = stm32_dfsdm_adc_chan_init_one(indio_dev, ch); + ch[chan_idx].scan_index = chan_idx; + ret = stm32_dfsdm_adc_chan_init_one(indio_dev, &ch[chan_idx]); if (ret < 0) { dev_err(&indio_dev->dev, "Channels init failed\n"); return ret; From 6de2aeb5746e79b50d2b99bd63f08da880f735a3 Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Fri, 23 Feb 2018 12:07:21 +0100 Subject: [PATCH 366/942] dt-bindings: iio: adc: sd-modulator: fix io-channel-cells io-channel-cells should be <0> since sigma delta modulator exports only one channel, as described in ../iio/iio-bindings.txt "IIO providers" section. Only the phandle is necessary for IIO consumers in this case. Fixes: af11143757b7 ("IIO: Add DT bindings for sigma delta adc modulator") Signed-off-by: Fabrice Gasnier Acked-by: Arnaud Pouliquen Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/sigma-delta-modulator.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt b/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt index e9ebb8a20e0d..ba24ca7ba95e 100644 --- a/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt +++ b/Documentation/devicetree/bindings/iio/adc/sigma-delta-modulator.txt @@ -3,11 +3,11 @@ Device-Tree bindings for sigma delta modulator Required properties: - compatible: should be "ads1201", "sd-modulator". "sd-modulator" can be use as a generic SD modulator if modulator not specified in compatible list. -- #io-channel-cells = <1>: See the IIO bindings section "IIO consumers". +- #io-channel-cells = <0>: See the IIO bindings section "IIO consumers". Example node: ads1202: adc@0 { compatible = "sd-modulator"; - #io-channel-cells = <1>; + #io-channel-cells = <0>; }; From 78dc897b7ee67205423dbbc6b56be49fb18d15b5 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 22 Feb 2018 14:28:59 -0600 Subject: [PATCH 367/942] rtlwifi: rtl8723be: Fix loss of signal In commit c713fb071edc ("rtlwifi: rtl8821ae: Fix connection lost problem correctly") a problem in rtl8821ae that caused loss of signal was fixed. That same problem has now been reported for rtl8723be. Accordingly, the ASPM L1 latency has been increased from 0 to 7 to fix the instability. Signed-off-by: Larry Finger Cc: Stable Tested-by: James Cameron Signed-off-by: Kalle Valo --- drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c index f9ccd13c79f9..e7bbbc95cdb1 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723be/hw.c @@ -1125,7 +1125,8 @@ static void _rtl8723be_enable_aspm_back_door(struct ieee80211_hw *hw) /* Configuration Space offset 0x70f BIT7 is used to control L0S */ tmp8 = _rtl8723be_dbi_read(rtlpriv, 0x70f); - _rtl8723be_dbi_write(rtlpriv, 0x70f, tmp8 | BIT(7)); + _rtl8723be_dbi_write(rtlpriv, 0x70f, tmp8 | BIT(7) | + ASPM_L1_LATENCY << 3); /* Configuration Space offset 0x719 Bit3 is for L1 * BIT4 is for clock request From 015555fd4d2930bc0c86952c46ad88b3392f66e4 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Mon, 19 Feb 2018 14:55:54 +0000 Subject: [PATCH 368/942] fs: dcache: Avoid livelock between d_alloc_parallel and __d_add If d_alloc_parallel runs concurrently with __d_add, it is possible for d_alloc_parallel to continuously retry whilst i_dir_seq has been incremented to an odd value by __d_add: CPU0: __d_add n = start_dir_add(dir); cmpxchg(&dir->i_dir_seq, n, n + 1) == n CPU1: d_alloc_parallel retry: seq = smp_load_acquire(&parent->d_inode->i_dir_seq) & ~1; hlist_bl_lock(b); bit_spin_lock(0, (unsigned long *)b); // Always succeeds CPU0: __d_lookup_done(dentry) hlist_bl_lock bit_spin_lock(0, (unsigned long *)b); // Never succeeds CPU1: if (unlikely(parent->d_inode->i_dir_seq != seq)) { hlist_bl_unlock(b); goto retry; } Since the simple bit_spin_lock used to implement hlist_bl_lock does not provide any fairness guarantees, then CPU1 can starve CPU0 of the lock and prevent it from reaching end_dir_add(dir), therefore CPU1 cannot exit its retry loop because the sequence number always has the bottom bit set. This patch resolves the livelock by not taking hlist_bl_lock in d_alloc_parallel if the sequence counter is odd, since any subsequent masked comparison with i_dir_seq will fail anyway. Cc: Peter Zijlstra Cc: Al Viro Reported-by: Naresh Madhusudana Acked-by: Peter Zijlstra (Intel) Reviewed-by: Matthew Wilcox Signed-off-by: Will Deacon Signed-off-by: Al Viro --- fs/dcache.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/dcache.c b/fs/dcache.c index 32aaab21e648..bde3b6662601 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2479,7 +2479,7 @@ struct dentry *d_alloc_parallel(struct dentry *parent, retry: rcu_read_lock(); - seq = smp_load_acquire(&parent->d_inode->i_dir_seq) & ~1; + seq = smp_load_acquire(&parent->d_inode->i_dir_seq); r_seq = read_seqbegin(&rename_lock); dentry = __d_lookup_rcu(parent, name, &d_seq); if (unlikely(dentry)) { @@ -2500,6 +2500,12 @@ retry: rcu_read_unlock(); goto retry; } + + if (unlikely(seq & 1)) { + rcu_read_unlock(); + goto retry; + } + hlist_bl_lock(b); if (unlikely(parent->d_inode->i_dir_seq != seq)) { hlist_bl_unlock(b); From 8cc07c808c9d595e81cbe5aad419b7769eb2e5c9 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Mon, 19 Feb 2018 14:55:55 +0000 Subject: [PATCH 369/942] fs: dcache: Use READ_ONCE when accessing i_dir_seq i_dir_seq is subject to concurrent modification by a cmpxchg or store-release operation, so ensure that the relaxed access in d_alloc_parallel uses READ_ONCE. Reported-by: Peter Zijlstra Signed-off-by: Will Deacon Signed-off-by: Al Viro --- fs/dcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/dcache.c b/fs/dcache.c index bde3b6662601..8945e6cabd93 100644 --- a/fs/dcache.c +++ b/fs/dcache.c @@ -2507,7 +2507,7 @@ retry: } hlist_bl_lock(b); - if (unlikely(parent->d_inode->i_dir_seq != seq)) { + if (unlikely(READ_ONCE(parent->d_inode->i_dir_seq) != seq)) { hlist_bl_unlock(b); rcu_read_unlock(); goto retry; From 398fa30bf138fd4b928dc11422abfe5486aaa8fe Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 23 Feb 2018 21:17:01 +0900 Subject: [PATCH 370/942] ASoC: uniphier: fix broken sound if use SRC in replay This patch fixes settings for ports with SRC. These ports need to set the fixed audio rate and clock. If not, the SRC outputs broken sound. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-core.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/sound/soc/uniphier/aio-core.c b/sound/soc/uniphier/aio-core.c index 1e5f053d9f6b..1711361fc0c2 100644 --- a/sound/soc/uniphier/aio-core.c +++ b/sound/soc/uniphier/aio-core.c @@ -501,7 +501,7 @@ int aio_port_set_clk(struct uniphier_aio_sub *sub) OPORTMXCTR2_MSSEL_MASTER | OPORTMXCTR2_EXTLSIFSSEL_36 | OPORTMXCTR2_DACCKSEL_1_2; - } else { + } else if (sub->swm->type == PORT_TYPE_SPDIF) { if (sub->aio->pll_out >= ARRAY_SIZE(v_pll)) { dev_err(dev, "PLL(%d) is invalid\n", sub->aio->pll_out); @@ -521,6 +521,11 @@ int aio_port_set_clk(struct uniphier_aio_sub *sub) v |= OPORTMXCTR2_EXTLSIFSSEL_24; break; } + } else { + v = OPORTMXCTR2_ACLKSEL_A1 | + OPORTMXCTR2_MSSEL_MASTER | + OPORTMXCTR2_EXTLSIFSSEL_36 | + OPORTMXCTR2_DACCKSEL_1_2; } regmap_write(r, OPORTMXCTR2(sub->swm->oport.map), v); } else { @@ -550,11 +555,19 @@ int aio_port_set_param(struct uniphier_aio_sub *sub, int pass_through, const struct snd_pcm_hw_params *params) { struct regmap *r = sub->aio->chip->regmap; + unsigned int rate; u32 v; int ret; if (!pass_through) { - ret = aio_port_set_rate(sub, params_rate(params)); + if (sub->swm->type == PORT_TYPE_EVE || + sub->swm->type == PORT_TYPE_CONV) { + rate = 48000; + } else { + rate = params_rate(params); + } + + ret = aio_port_set_rate(sub, rate); if (ret) return ret; From f49f49aa1541615f1f77bf2c62f184459825ed92 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 23 Feb 2018 12:41:17 +0000 Subject: [PATCH 371/942] ASoC: sirf: remove duplicated bit-wise or of USP_RXFIFO_THD_INT Bit pattern USP_RXFIFO_THD_INT is being bit-wise or'd twice; remove the redundant 2nd USP_RXFIFO_THD_INT Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/sirf/sirf-usp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/sirf/sirf-usp.h b/sound/soc/sirf/sirf-usp.h index bf0201cb15bc..e22e13a619e8 100644 --- a/sound/soc/sirf/sirf-usp.h +++ b/sound/soc/sirf/sirf-usp.h @@ -154,7 +154,7 @@ USP_RX_IO_DMA_INT|\ USP_RXFIFO_FULL_INT|\ USP_RXFIFO_THD_INT|\ - USP_RXFIFO_THD_INT|USP_RX_TIMEOUT_INT) + USP_RX_TIMEOUT_INT) #define USP_INT_ALL 0x1FFF From 8b597ff47053c9f53384a3a26dcc4c4316a375e5 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 23 Feb 2018 14:37:38 +0000 Subject: [PATCH 372/942] ASoC: pxa: remove duplicated bit-wise or of SNDRV_PCM_FMTBIT_S24_LE Bit pattern SNDRV_PCM_FMTBIT_S24_LE is being bit-wise or'd twice; remove the redundant 2nd SNDRV_PCM_FMTBIT_S24_LE Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/pxa/mmp-sspa.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 64b85e30c1f8..7c998ea4ebee 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -377,7 +377,6 @@ static int mmp_sspa_probe(struct snd_soc_dai *dai) #define MMP_SSPA_FORMATS (SNDRV_PCM_FMTBIT_S8 | \ SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | \ - SNDRV_PCM_FMTBIT_S24_LE | \ SNDRV_PCM_FMTBIT_S32_LE) static const struct snd_soc_dai_ops mmp_sspa_dai_ops = { From 61fc060c40e6b92350c08a210619fc7d93c61e42 Mon Sep 17 00:00:00 2001 From: Charles Keepax Date: Mon, 26 Feb 2018 10:49:47 +0000 Subject: [PATCH 373/942] ASoC: wm_adsp: Support streams which can start/stop with DSP active Clear the buffer data structure on each trigger start such that the buffer is in a sensible state even if the DSP itself didn't restart. This is necessary to support voice control streams which can trigger multiple times without reloading the firmware. Signed-off-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm_adsp.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 0060aeb63a9f..ab91f1320ad5 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -3258,6 +3258,13 @@ static int wm_adsp_buffer_populate(struct wm_adsp_compr_buf *buf) return 0; } +static void wm_adsp_buffer_clear(struct wm_adsp_compr_buf *buf) +{ + buf->irq_count = 0xFFFFFFFF; + buf->read_index = -1; + buf->avail = 0; +} + static int wm_adsp_buffer_init(struct wm_adsp *dsp) { struct wm_adsp_compr_buf *buf; @@ -3268,8 +3275,8 @@ static int wm_adsp_buffer_init(struct wm_adsp *dsp) return -ENOMEM; buf->dsp = dsp; - buf->read_index = -1; - buf->irq_count = 0xFFFFFFFF; + + wm_adsp_buffer_clear(buf); ret = wm_adsp_buffer_locate(buf); if (ret < 0) { @@ -3327,16 +3334,17 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd) switch (cmd) { case SNDRV_PCM_TRIGGER_START: - if (wm_adsp_compr_attached(compr)) - break; - - ret = wm_adsp_compr_attach(compr); - if (ret < 0) { - adsp_err(dsp, "Failed to link buffer and stream: %d\n", - ret); - break; + if (!wm_adsp_compr_attached(compr)) { + ret = wm_adsp_compr_attach(compr); + if (ret < 0) { + adsp_err(dsp, "Failed to link buffer and stream: %d\n", + ret); + break; + } } + wm_adsp_buffer_clear(compr->buf); + /* Trigger the IRQ at one fragment of data */ ret = wm_adsp_buffer_write(compr->buf, HOST_BUFFER_FIELD(high_water_mark), From f91b1e73ccde71d4bc69ae10d475196df38844ab Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 22 Feb 2018 16:02:21 -0300 Subject: [PATCH 374/942] ASoC: soc-generic-dmaengine-pcm: Fix error handling When dmaengine_pcm_request_chan_of() fails it should release the previously acquired resources, which in this case is to call kfree(pcm), so jump to the correct point in the error path. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 768247fd92c5..32ea16d062b1 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -450,7 +450,7 @@ int snd_dmaengine_pcm_register(struct device *dev, ret = dmaengine_pcm_request_chan_of(pcm, dev, config); if (ret) - goto err_free_dma; + goto err_free_pcm; ret = snd_soc_add_component(dev, &pcm->component, &dmaengine_pcm_component, NULL, 0); @@ -461,6 +461,7 @@ int snd_dmaengine_pcm_register(struct device *dev, err_free_dma: dmaengine_pcm_release_chan(pcm); +err_free_pcm: kfree(pcm); return ret; } From 7ed310bd51bec0b440a551fc4da1993c7f6cd231 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Thu, 22 Feb 2018 16:02:22 -0300 Subject: [PATCH 375/942] ASoC: soc-generic-dmaengine-pcm: Fix sparse warnings Currently the following sparse warnings are observed: sound/soc/soc-generic-dmaengine-pcm.c:185:34: warning: restricted snd_pcm_format_t degrades to integer sound/soc/soc-generic-dmaengine-pcm.c:186:66: warning: incorrect type in argument 1 (different base types) sound/soc/soc-generic-dmaengine-pcm.c:186:66: expected restricted snd_pcm_format_t [usertype] format sound/soc/soc-generic-dmaengine-pcm.c:186:66: got int [signed] [assigned] i Fix it by changing the loop variable to be of 'snd_pcm_format_t'. Also introduce a SNDRV_PCM_FORMAT_FIRST label, which corresponds to the first member (index 0) of the snd_pcm_format_t formats. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- include/uapi/sound/asound.h | 1 + sound/soc/soc-generic-dmaengine-pcm.c | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/uapi/sound/asound.h b/include/uapi/sound/asound.h index 07d61583fd02..ed0a120d4f08 100644 --- a/include/uapi/sound/asound.h +++ b/include/uapi/sound/asound.h @@ -242,6 +242,7 @@ typedef int __bitwise snd_pcm_format_t; #define SNDRV_PCM_FORMAT_DSD_U16_BE ((__force snd_pcm_format_t) 51) /* DSD, 2-byte samples DSD (x16), big endian */ #define SNDRV_PCM_FORMAT_DSD_U32_BE ((__force snd_pcm_format_t) 52) /* DSD, 4-byte samples DSD (x32), big endian */ #define SNDRV_PCM_FORMAT_LAST SNDRV_PCM_FORMAT_DSD_U32_BE +#define SNDRV_PCM_FORMAT_FIRST SNDRV_PCM_FORMAT_S8 #ifdef SNDRV_LITTLE_ENDIAN #define SNDRV_PCM_FORMAT_S16 SNDRV_PCM_FORMAT_S16_LE diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 32ea16d062b1..785f25ede3e5 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -132,7 +132,8 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea u32 addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); - int i, ret; + snd_pcm_format_t i; + int ret; if (pcm->config && pcm->config->pcm_hardware) return snd_soc_set_runtime_hwparams(substream, @@ -182,7 +183,7 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea * default assumption is that it supports 1, 2 and 4 bytes * widths. */ - for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) { + for (i = SNDRV_PCM_FORMAT_FIRST; i <= SNDRV_PCM_FORMAT_LAST; i++) { int bits = snd_pcm_format_physical_width(i); /* From 78648092ef46255e6dc6685202164199c86cf930 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Mon, 19 Feb 2018 16:00:36 +0100 Subject: [PATCH 376/942] ASoC: dmaengine_pcm: add processing support Allow dmaengine client to optionally register a processing callback. This callback is intended to apply processing on samples in buffer copied from/to user space, before/after DMA transfer. Signed-off-by: Olivier Moysan Signed-off-by: Mark Brown --- include/sound/dmaengine_pcm.h | 3 ++ sound/soc/soc-generic-dmaengine-pcm.c | 62 ++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 8a5a8404966e..47ef486852ed 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -140,6 +140,9 @@ struct snd_dmaengine_pcm_config { struct dma_chan *(*compat_request_channel)( struct snd_soc_pcm_runtime *rtd, struct snd_pcm_substream *substream); + int (*process)(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes); dma_filter_fn compat_filter_fn; struct device *dma_dev; const char *chan_names[SNDRV_PCM_STREAM_LAST + 1]; diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 785f25ede3e5..567fbdfd1ca9 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -341,6 +341,41 @@ static snd_pcm_uframes_t dmaengine_pcm_pointer( return snd_dmaengine_pcm_pointer(substream); } +static int dmaengine_copy_user(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_component *component = + snd_soc_rtdcom_lookup(rtd, SND_DMAENGINE_PCM_DRV_NAME); + struct snd_pcm_runtime *runtime = substream->runtime; + struct dmaengine_pcm *pcm = soc_component_to_pcm(component); + int (*process)(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes) = pcm->config->process; + bool is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; + void *dma_ptr = runtime->dma_area + hwoff + + channel * (runtime->dma_bytes / runtime->channels); + int ret; + + if (is_playback) + if (copy_from_user(dma_ptr, (void __user *)buf, bytes)) + return -EFAULT; + + if (process) { + ret = process(substream, channel, hwoff, + (void __user *)buf, bytes); + if (ret < 0) + return ret; + } + + if (!is_playback) + if (copy_to_user((void __user *)buf, dma_ptr, bytes)) + return -EFAULT; + + return 0; +} + static const struct snd_pcm_ops dmaengine_pcm_ops = { .open = dmaengine_pcm_open, .close = snd_dmaengine_pcm_close, @@ -351,6 +386,17 @@ static const struct snd_pcm_ops dmaengine_pcm_ops = { .pointer = dmaengine_pcm_pointer, }; +static const struct snd_pcm_ops dmaengine_pcm_process_ops = { + .open = dmaengine_pcm_open, + .close = snd_dmaengine_pcm_close, + .ioctl = snd_pcm_lib_ioctl, + .hw_params = dmaengine_pcm_hw_params, + .hw_free = snd_pcm_lib_free_pages, + .trigger = snd_dmaengine_pcm_trigger, + .pointer = dmaengine_pcm_pointer, + .copy_user = dmaengine_copy_user, +}; + static const struct snd_soc_component_driver dmaengine_pcm_component = { .name = SND_DMAENGINE_PCM_DRV_NAME, .probe_order = SND_SOC_COMP_ORDER_LATE, @@ -358,6 +404,13 @@ static const struct snd_soc_component_driver dmaengine_pcm_component = { .pcm_new = dmaengine_pcm_new, }; +static const struct snd_soc_component_driver dmaengine_pcm_component_process = { + .name = SND_DMAENGINE_PCM_DRV_NAME, + .probe_order = SND_SOC_COMP_ORDER_LATE, + .ops = &dmaengine_pcm_process_ops, + .pcm_new = dmaengine_pcm_new, +}; + static const char * const dmaengine_pcm_dma_channel_names[] = { [SNDRV_PCM_STREAM_PLAYBACK] = "tx", [SNDRV_PCM_STREAM_CAPTURE] = "rx", @@ -453,8 +506,13 @@ int snd_dmaengine_pcm_register(struct device *dev, if (ret) goto err_free_pcm; - ret = snd_soc_add_component(dev, &pcm->component, - &dmaengine_pcm_component, NULL, 0); + if (config && config->process) + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component_process, + NULL, 0); + else + ret = snd_soc_add_component(dev, &pcm->component, + &dmaengine_pcm_component, NULL, 0); if (ret) goto err_free_dma; From 994f46610bafd75a5881544bce9dd3acdbe3626a Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Mon, 19 Feb 2018 16:00:35 +0100 Subject: [PATCH 377/942] ASoC: stm32: Add S/PDIF to SAI bindings Add S/PDIF IEC6958 protocol support to STM32 SAI bindings. Signed-off-by: olivier moysan Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/st,stm32-sai.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/st,stm32-sai.txt b/Documentation/devicetree/bindings/sound/st,stm32-sai.txt index b1acc1a256ba..f301cdf0b7e6 100644 --- a/Documentation/devicetree/bindings/sound/st,stm32-sai.txt +++ b/Documentation/devicetree/bindings/sound/st,stm32-sai.txt @@ -45,6 +45,12 @@ SAI subnodes Optional properties: This property sets SAI sub-block as slave of another SAI sub-block. Must contain the phandle and index of the sai sub-block providing the synchronization. + - st,iec60958: support S/PDIF IEC6958 protocol for playback + IEC60958 protocol is not available for capture. + By default, custom protocol is assumed, meaning that protocol is + configured according to protocol defined in related DAI link node, + such as i2s, left justified, right justified, dsp and pdm protocols. + Note: ac97 protocol is not supported by SAI driver The device node should contain one 'port' child node with one child 'endpoint' node, according to the bindings defined in Documentation/devicetree/bindings/ From 6eb17d70932b5fbe25d9e7fc6d45d29d7a6cdf94 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Mon, 19 Feb 2018 16:00:37 +0100 Subject: [PATCH 378/942] ASoC: stm32: sai: Add support of S/PDIF playback Add support of S/PDIF iec60958 playback on STM32 SAI. Signed-off-by: olivier moysan Signed-off-by: Mark Brown --- sound/soc/stm/stm32_sai.c | 2 + sound/soc/stm/stm32_sai.h | 2 + sound/soc/stm/stm32_sai_sub.c | 153 ++++++++++++++++++++++++++++------ 3 files changed, 133 insertions(+), 24 deletions(-) diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c index d743b7dd52fb..f22654253c43 100644 --- a/sound/soc/stm/stm32_sai.c +++ b/sound/soc/stm/stm32_sai.c @@ -30,10 +30,12 @@ static const struct stm32_sai_conf stm32_sai_conf_f4 = { .version = SAI_STM32F4, + .has_spdif = false, }; static const struct stm32_sai_conf stm32_sai_conf_h7 = { .version = SAI_STM32H7, + .has_spdif = true, }; static const struct of_device_id stm32_sai_ids[] = { diff --git a/sound/soc/stm/stm32_sai.h b/sound/soc/stm/stm32_sai.h index bb062e70de63..f25422174909 100644 --- a/sound/soc/stm/stm32_sai.h +++ b/sound/soc/stm/stm32_sai.h @@ -248,9 +248,11 @@ enum stm32_sai_version { /** * struct stm32_sai_conf - SAI configuration * @version: SAI version + * @has_spdif: SAI S/PDIF support flag */ struct stm32_sai_conf { int version; + bool has_spdif; }; /** diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c index 08583b958430..cfeb219e1d78 100644 --- a/sound/soc/stm/stm32_sai_sub.c +++ b/sound/soc/stm/stm32_sai_sub.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include "stm32_sai.h" #define SAI_FREE_PROTOCOL 0x0 +#define SAI_SPDIF_PROTOCOL 0x1 #define SAI_SLOT_SIZE_AUTO 0x0 #define SAI_SLOT_SIZE_16 0x1 @@ -59,8 +61,13 @@ #define SAI_SYNC_INTERNAL 0x1 #define SAI_SYNC_EXTERNAL 0x2 +#define STM_SAI_PROTOCOL_IS_SPDIF(ip) ((ip)->spdif) +#define STM_SAI_HAS_SPDIF(x) ((x)->pdata->conf->has_spdif) #define STM_SAI_HAS_EXT_SYNC(x) (!STM_SAI_IS_F4(sai->pdata)) +#define SAI_IEC60958_BLOCK_FRAMES 192 +#define SAI_IEC60958_STATUS_BYTES 24 + /** * struct stm32_sai_sub_data - private data of SAI sub block (block A or B) * @pdev: device data pointer @@ -78,6 +85,7 @@ * @id: SAI sub block id corresponding to sub-block A or B * @dir: SAI block direction (playback or capture). set at init * @master: SAI block mode flag. (true=master, false=slave) set at init + * @spdif: SAI S/PDIF iec60958 mode flag. set at init * @fmt: SAI block format. relevant only for custom protocols. set at init * @sync: SAI block synchronization mode. (none, internal or external) * @synco: SAI block ext sync source (provider setting). (none, sub-block A/B) @@ -87,6 +95,8 @@ * @slot_width: rx or tx slot width in bits * @slot_mask: rx or tx active slots mask. set at init or at runtime * @data_size: PCM data width. corresponds to PCM substream width. + * @spdif_frm_cnt: S/PDIF playback frame counter + * @spdif_status_bits: S/PDIF status bits */ struct stm32_sai_sub_data { struct platform_device *pdev; @@ -104,6 +114,7 @@ struct stm32_sai_sub_data { unsigned int id; int dir; bool master; + bool spdif; int fmt; int sync; int synco; @@ -113,6 +124,8 @@ struct stm32_sai_sub_data { int slot_width; int slot_mask; int data_size; + unsigned int spdif_frm_cnt; + unsigned char spdif_status_bits[SAI_IEC60958_STATUS_BYTES]; }; enum stm32_sai_fifo_th { @@ -171,6 +184,10 @@ static bool stm32_sai_sub_writeable_reg(struct device *dev, unsigned int reg) } } +static const unsigned char default_status_bits[SAI_IEC60958_STATUS_BYTES] = { + 0, 0, 0, IEC958_AES3_CON_FS_48000, +}; + static const struct regmap_config stm32_sai_sub_regmap_config_f4 = { .reg_bits = 32, .reg_stride = 4, @@ -277,6 +294,11 @@ static int stm32_sai_set_dai_tdm_slot(struct snd_soc_dai *cpu_dai, u32 tx_mask, struct stm32_sai_sub_data *sai = snd_soc_dai_get_drvdata(cpu_dai); int slotr, slotr_mask, slot_size; + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { + dev_warn(cpu_dai->dev, "Slot setting relevant only for TDM\n"); + return 0; + } + dev_dbg(cpu_dai->dev, "Masks tx/rx:%#x/%#x, slots:%d, width:%d\n", tx_mask, rx_mask, slots, slot_width); @@ -326,8 +348,17 @@ static int stm32_sai_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) dev_dbg(cpu_dai->dev, "fmt %x\n", fmt); - cr1_mask = SAI_XCR1_PRTCFG_MASK; - cr1 = SAI_XCR1_PRTCFG_SET(SAI_FREE_PROTOCOL); + /* Do not generate master by default */ + cr1 = SAI_XCR1_NODIV; + cr1_mask = SAI_XCR1_NODIV; + + cr1_mask |= SAI_XCR1_PRTCFG_MASK; + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { + cr1 |= SAI_XCR1_PRTCFG_SET(SAI_SPDIF_PROTOCOL); + goto conf_update; + } + + cr1 |= SAI_XCR1_PRTCFG_SET(SAI_FREE_PROTOCOL); switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { /* SCK active high for all protocols */ @@ -409,10 +440,7 @@ static int stm32_sai_set_dai_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt) cr1_mask |= SAI_XCR1_SLAVE; - /* do not generate master by default */ - cr1 |= SAI_XCR1_NODIV; - cr1_mask |= SAI_XCR1_NODIV; - +conf_update: ret = regmap_update_bits(sai->regmap, STM_SAI_CR1_REGX, cr1_mask, cr1); if (ret < 0) { dev_err(cpu_dai->dev, "Failed to update CR1 register\n"); @@ -478,6 +506,12 @@ static int stm32_sai_set_config(struct snd_soc_dai *cpu_dai, SAI_XCR2_FFLUSH | SAI_XCR2_FTH_SET(STM_SAI_FIFO_TH_HALF)); + /* DS bits in CR1 not set for SPDIF (size forced to 24 bits).*/ + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { + sai->spdif_frm_cnt = 0; + return 0; + } + /* Mode, data format and channel config */ cr1_mask = SAI_XCR1_DS_MASK; switch (params_format(params)) { @@ -592,13 +626,14 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai, int cr1, mask, div = 0; int sai_clk_rate, mclk_ratio, den, ret; int version = sai->pdata->conf->version; + unsigned int rate = params_rate(params); if (!sai->mclk_rate) { dev_err(cpu_dai->dev, "Mclk rate is null\n"); return -EINVAL; } - if (!(params_rate(params) % 11025)) + if (!(rate % 11025)) clk_set_parent(sai->sai_ck, sai->pdata->clk_x11k); else clk_set_parent(sai->sai_ck, sai->pdata->clk_x8k); @@ -623,24 +658,28 @@ static int stm32_sai_configure_clock(struct snd_soc_dai *cpu_dai, * MCKDIV = sai_ck / (frl x ws) (NOMCK=1) * Note: NOMCK/NODIV correspond to same bit. */ - if (sai->mclk_rate) { - mclk_ratio = sai->mclk_rate / params_rate(params); - if (mclk_ratio != 256) { + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) { + div = DIV_ROUND_CLOSEST(sai_clk_rate, + (params_rate(params) * 128)); + } else { + if (sai->mclk_rate) { + mclk_ratio = sai->mclk_rate / rate; if (mclk_ratio == 512) { mask = SAI_XCR1_OSR; cr1 = SAI_XCR1_OSR; - } else { + } else if (mclk_ratio != 256) { dev_err(cpu_dai->dev, "Wrong mclk ratio %d\n", mclk_ratio); return -EINVAL; } + div = DIV_ROUND_CLOSEST(sai_clk_rate, + sai->mclk_rate); + } else { + /* mclk-fs not set, master clock not active */ + den = sai->fs_length * params_rate(params); + div = DIV_ROUND_CLOSEST(sai_clk_rate, den); } - div = DIV_ROUND_CLOSEST(sai_clk_rate, sai->mclk_rate); - } else { - /* mclk-fs not set, master clock not active. NOMCK=1 */ - den = sai->fs_length * params_rate(params); - div = DIV_ROUND_CLOSEST(sai_clk_rate, den); } } @@ -670,10 +709,12 @@ static int stm32_sai_hw_params(struct snd_pcm_substream *substream, sai->data_size = params_width(params); - ret = stm32_sai_set_slots(cpu_dai); - if (ret < 0) - return ret; - stm32_sai_set_frame(cpu_dai); + if (!STM_SAI_PROTOCOL_IS_SPDIF(sai)) { + ret = stm32_sai_set_slots(cpu_dai); + if (ret < 0) + return ret; + stm32_sai_set_frame(cpu_dai); + } ret = stm32_sai_set_config(cpu_dai, substream, params); if (ret) @@ -723,6 +764,9 @@ static int stm32_sai_trigger(struct snd_pcm_substream *substream, int cmd, (unsigned int)~SAI_XCR1_DMAEN); if (ret < 0) dev_err(cpu_dai->dev, "Failed to update CR1 register\n"); + + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) + sai->spdif_frm_cnt = 0; break; default: return -EINVAL; @@ -776,6 +820,10 @@ static int stm32_sai_dai_probe(struct snd_soc_dai *cpu_dai) sai->synco, sai->synci); } + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) + memcpy(sai->spdif_status_bits, default_status_bits, + sizeof(default_status_bits)); + cr1_mask |= SAI_XCR1_SYNCEN_MASK; cr1 |= SAI_XCR1_SYNCEN_SET(sai->sync); @@ -792,6 +840,42 @@ static const struct snd_soc_dai_ops stm32_sai_pcm_dai_ops = { .shutdown = stm32_sai_shutdown, }; +static int stm32_sai_pcm_process_spdif(struct snd_pcm_substream *substream, + int channel, unsigned long hwoff, + void *buf, unsigned long bytes) +{ + struct snd_pcm_runtime *runtime = substream->runtime; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + struct stm32_sai_sub_data *sai = dev_get_drvdata(cpu_dai->dev); + int *ptr = (int *)(runtime->dma_area + hwoff + + channel * (runtime->dma_bytes / runtime->channels)); + ssize_t cnt = bytes_to_samples(runtime, bytes); + unsigned int frm_cnt = sai->spdif_frm_cnt; + unsigned int byte; + unsigned int mask; + + do { + *ptr = ((*ptr >> 8) & 0x00ffffff); + + /* Set channel status bit */ + byte = frm_cnt >> 3; + mask = 1 << (frm_cnt - (byte << 3)); + if (sai->spdif_status_bits[byte] & mask) + *ptr |= 0x04000000; + ptr++; + + if (!(cnt % 2)) + frm_cnt++; + + if (frm_cnt == SAI_IEC60958_BLOCK_FRAMES) + frm_cnt = 0; + } while (--cnt); + sai->spdif_frm_cnt = frm_cnt; + + return 0; +} + static const struct snd_pcm_hardware stm32_sai_pcm_hw = { .info = SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_MMAP, .buffer_bytes_max = 8 * PAGE_SIZE, @@ -842,8 +926,14 @@ static struct snd_soc_dai_driver stm32_sai_capture_dai[] = { }; static const struct snd_dmaengine_pcm_config stm32_sai_pcm_config = { - .pcm_hardware = &stm32_sai_pcm_hw, - .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .pcm_hardware = &stm32_sai_pcm_hw, + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, +}; + +static const struct snd_dmaengine_pcm_config stm32_sai_pcm_config_spdif = { + .pcm_hardware = &stm32_sai_pcm_hw, + .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, + .process = stm32_sai_pcm_process_spdif, }; static const struct snd_soc_component_driver stm32_component = { @@ -900,6 +990,18 @@ static int stm32_sai_sub_parse_of(struct platform_device *pdev, return -EINVAL; } + /* Get spdif iec60958 property */ + sai->spdif = false; + if (of_get_property(np, "st,iec60958", NULL)) { + if (!STM_SAI_HAS_SPDIF(sai) || + sai->dir == SNDRV_PCM_STREAM_CAPTURE) { + dev_err(&pdev->dev, "S/PDIF IEC60958 not supported\n"); + return -EINVAL; + } + sai->spdif = true; + sai->master = true; + } + /* Get synchronization property */ args.np = NULL; ret = of_parse_phandle_with_fixed_args(np, "st,sync", 1, 0, &args); @@ -999,6 +1101,7 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) { struct stm32_sai_sub_data *sai; const struct of_device_id *of_id; + const struct snd_dmaengine_pcm_config *conf = &stm32_sai_pcm_config; int ret; sai = devm_kzalloc(&pdev->dev, sizeof(*sai), GFP_KERNEL); @@ -1039,8 +1142,10 @@ static int stm32_sai_sub_probe(struct platform_device *pdev) if (ret) return ret; - ret = devm_snd_dmaengine_pcm_register(&pdev->dev, - &stm32_sai_pcm_config, 0); + if (STM_SAI_PROTOCOL_IS_SPDIF(sai)) + conf = &stm32_sai_pcm_config_spdif; + + ret = devm_snd_dmaengine_pcm_register(&pdev->dev, conf, 0); if (ret) { dev_err(&pdev->dev, "Could not register pcm dma\n"); return ret; From b84acf44d5b86597cebcb6aca16e7dd9ca2b0294 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 26 Feb 2018 15:55:25 -0300 Subject: [PATCH 379/942] ASoC: Revert "ASoC: soc-generic-dmaengine-pcm: Fix error handling" This reverts commit f91b1e73ccde71d4bc69ae10d475196df38844ab. As explained by Lars-Peter Clausen: "This creates a resource leak. dmaengine_pcm_request_chan_of() requests bothtransmit and receive channels. It might return with an error if one of them fails, but the other one succeeded. In this case we need to call dmaengine_pcm_release_chan() to free the requested channel" So revert the commit. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/soc-generic-dmaengine-pcm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 567fbdfd1ca9..56a541b9ff9e 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c @@ -504,7 +504,7 @@ int snd_dmaengine_pcm_register(struct device *dev, ret = dmaengine_pcm_request_chan_of(pcm, dev, config); if (ret) - goto err_free_pcm; + goto err_free_dma; if (config && config->process) ret = snd_soc_add_component(dev, &pcm->component, @@ -520,7 +520,6 @@ int snd_dmaengine_pcm_register(struct device *dev, err_free_dma: dmaengine_pcm_release_chan(pcm); -err_free_pcm: kfree(pcm); return ret; } From 790d631dcfec6b073b04bb6809bce4c09baf198a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 26 Feb 2018 22:24:49 -0300 Subject: [PATCH 380/942] ASoC: imx-wm8962: Remove machine driver fsl-asoc-card machine driver also handles wm8962, so there is really no need for keeping the dedicated imx-wm8962 driver anymore. Remove the imx-wm8962 machine driver. Suggested-by: Nicolin Chen Signed-off-by: Fabio Estevam Acked-by: Nicolin Chen Reviewed-by: Daniel Baluta Signed-off-by: Mark Brown --- .../bindings/sound/fsl-asoc-card.txt | 1 - .../bindings/sound/imx-audio-wm8962.txt | 53 --- sound/soc/fsl/Kconfig | 11 - sound/soc/fsl/Makefile | 2 - sound/soc/fsl/imx-wm8962.c | 312 ------------------ 5 files changed, 379 deletions(-) delete mode 100644 Documentation/devicetree/bindings/sound/imx-audio-wm8962.txt delete mode 100644 sound/soc/fsl/imx-wm8962.c diff --git a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt index f749e2744824..c60a5732d29c 100644 --- a/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt +++ b/Documentation/devicetree/bindings/sound/fsl-asoc-card.txt @@ -28,7 +28,6 @@ The compatible list for this generic sound card currently: (compatible with CS4271 and CS4272) "fsl,imx-audio-wm8962" - (compatible with Documentation/devicetree/bindings/sound/imx-audio-wm8962.txt) "fsl,imx-audio-sgtl5000" (compatible with Documentation/devicetree/bindings/sound/imx-audio-sgtl5000.txt) diff --git a/Documentation/devicetree/bindings/sound/imx-audio-wm8962.txt b/Documentation/devicetree/bindings/sound/imx-audio-wm8962.txt deleted file mode 100644 index acea71bee34f..000000000000 --- a/Documentation/devicetree/bindings/sound/imx-audio-wm8962.txt +++ /dev/null @@ -1,53 +0,0 @@ -Freescale i.MX audio complex with WM8962 codec - -Required properties: - - - compatible : "fsl,imx-audio-wm8962" - - - model : The user-visible name of this sound complex - - - ssi-controller : The phandle of the i.MX SSI controller - - - audio-codec : The phandle of the WM8962 audio codec - - - audio-routing : A list of the connections between audio components. - Each entry is a pair of strings, the first being the - connection's sink, the second being the connection's - source. Valid names could be power supplies, WM8962 - pins, and the jacks on the board: - - Power supplies: - * Mic Bias - - Board connectors: - * Mic Jack - * Headphone Jack - * Ext Spk - - - mux-int-port : The internal port of the i.MX audio muxer (AUDMUX) - - - mux-ext-port : The external port of the i.MX audio muxer - -Note: The AUDMUX port numbering should start at 1, which is consistent with -hardware manual. - -Example: - -sound { - compatible = "fsl,imx6q-sabresd-wm8962", - "fsl,imx-audio-wm8962"; - model = "wm8962-audio"; - ssi-controller = <&ssi2>; - audio-codec = <&codec>; - audio-routing = - "Headphone Jack", "HPOUTL", - "Headphone Jack", "HPOUTR", - "Ext Spk", "SPKOUTL", - "Ext Spk", "SPKOUTR", - "MICBIAS", "AMIC", - "IN3R", "MICBIAS", - "DMIC", "MICBIAS", - "DMICDAT", "DMIC"; - mux-int-port = <2>; - mux-ext-port = <3>; -}; diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 37f9b6201918..6ec19fb4a934 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig @@ -231,17 +231,6 @@ config SND_SOC_EUKREA_TLV320 Enable I2S based access to the TLV320AIC23B codec attached to the SSI interface -config SND_SOC_IMX_WM8962 - tristate "SoC Audio support for i.MX boards with wm8962" - depends on OF && I2C && INPUT - select SND_SOC_WM8962 - select SND_SOC_IMX_PCM_DMA - select SND_SOC_IMX_AUDMUX - select SND_SOC_FSL_SSI - help - Say Y if you want to add support for SoC audio on an i.MX board with - a wm8962 codec. - config SND_SOC_IMX_ES8328 tristate "SoC Audio support for i.MX boards with the ES8328 codec" depends on OF && (I2C || SPI) diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index c67bf1139e1e..de94fa057e24 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile @@ -55,7 +55,6 @@ snd-soc-mx27vis-aic32x4-objs := mx27vis-aic32x4.o snd-soc-wm1133-ev1-objs := wm1133-ev1.o snd-soc-imx-es8328-objs := imx-es8328.o snd-soc-imx-sgtl5000-objs := imx-sgtl5000.o -snd-soc-imx-wm8962-objs := imx-wm8962.o snd-soc-imx-spdif-objs := imx-spdif.o snd-soc-imx-mc13783-objs := imx-mc13783.o @@ -65,6 +64,5 @@ obj-$(CONFIG_SND_SOC_MX27VIS_AIC32X4) += snd-soc-mx27vis-aic32x4.o obj-$(CONFIG_SND_MXC_SOC_WM1133_EV1) += snd-soc-wm1133-ev1.o obj-$(CONFIG_SND_SOC_IMX_ES8328) += snd-soc-imx-es8328.o obj-$(CONFIG_SND_SOC_IMX_SGTL5000) += snd-soc-imx-sgtl5000.o -obj-$(CONFIG_SND_SOC_IMX_WM8962) += snd-soc-imx-wm8962.o obj-$(CONFIG_SND_SOC_IMX_SPDIF) += snd-soc-imx-spdif.o obj-$(CONFIG_SND_SOC_IMX_MC13783) += snd-soc-imx-mc13783.o diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c deleted file mode 100644 index 206b898e554c..000000000000 --- a/sound/soc/fsl/imx-wm8962.c +++ /dev/null @@ -1,312 +0,0 @@ -/* - * Copyright 2013 Freescale Semiconductor, Inc. - * - * Based on imx-sgtl5000.c - * Copyright 2012 Freescale Semiconductor, Inc. - * Copyright 2012 Linaro Ltd. - * - * The code contained herein is licensed under the GNU General Public - * License. You may obtain a copy of the GNU General Public License - * Version 2 or later at the following locations: - * - * http://www.opensource.org/licenses/gpl-license.html - * http://www.gnu.org/copyleft/gpl.html - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../codecs/wm8962.h" -#include "imx-audmux.h" - -#define DAI_NAME_SIZE 32 - -struct imx_wm8962_data { - struct snd_soc_dai_link dai; - struct snd_soc_card card; - char codec_dai_name[DAI_NAME_SIZE]; - char platform_name[DAI_NAME_SIZE]; - unsigned int clk_frequency; -}; - -struct imx_priv { - struct platform_device *pdev; - int sample_rate; - snd_pcm_format_t sample_format; -}; - -static const struct snd_soc_dapm_widget imx_wm8962_dapm_widgets[] = { - SND_SOC_DAPM_HP("Headphone Jack", NULL), - SND_SOC_DAPM_SPK("Ext Spk", NULL), - SND_SOC_DAPM_MIC("AMIC", NULL), - SND_SOC_DAPM_MIC("DMIC", NULL), -}; - -static int imx_hifi_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct imx_priv *priv = snd_soc_card_get_drvdata(rtd->card); - - priv->sample_rate = params_rate(params); - priv->sample_format = params_format(params); - - return 0; -} - -static const struct snd_soc_ops imx_hifi_ops = { - .hw_params = imx_hifi_hw_params, -}; - -static int imx_wm8962_set_bias_level(struct snd_soc_card *card, - struct snd_soc_dapm_context *dapm, - enum snd_soc_bias_level level) -{ - struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai *codec_dai; - struct imx_priv *priv = snd_soc_card_get_drvdata(card); - struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card); - struct device *dev = &priv->pdev->dev; - unsigned int pll_out; - int ret; - - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec_dai = rtd->codec_dai; - if (dapm->dev != codec_dai->dev) - return 0; - - switch (level) { - case SND_SOC_BIAS_PREPARE: - if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { - if (priv->sample_format == SNDRV_PCM_FORMAT_S24_LE) - pll_out = priv->sample_rate * 384; - else - pll_out = priv->sample_rate * 256; - - ret = snd_soc_dai_set_pll(codec_dai, WM8962_FLL, - WM8962_FLL_MCLK, data->clk_frequency, - pll_out); - if (ret < 0) { - dev_err(dev, "failed to start FLL: %d\n", ret); - return ret; - } - - ret = snd_soc_dai_set_sysclk(codec_dai, - WM8962_SYSCLK_FLL, pll_out, - SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(dev, "failed to set SYSCLK: %d\n", ret); - return ret; - } - } - break; - - case SND_SOC_BIAS_STANDBY: - if (dapm->bias_level == SND_SOC_BIAS_PREPARE) { - ret = snd_soc_dai_set_sysclk(codec_dai, - WM8962_SYSCLK_MCLK, data->clk_frequency, - SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(dev, - "failed to switch away from FLL: %d\n", - ret); - return ret; - } - - ret = snd_soc_dai_set_pll(codec_dai, WM8962_FLL, - 0, 0, 0); - if (ret < 0) { - dev_err(dev, "failed to stop FLL: %d\n", ret); - return ret; - } - } - break; - - default: - break; - } - - return 0; -} - -static int imx_wm8962_late_probe(struct snd_soc_card *card) -{ - struct snd_soc_pcm_runtime *rtd; - struct snd_soc_dai *codec_dai; - struct imx_priv *priv = snd_soc_card_get_drvdata(card); - struct imx_wm8962_data *data = snd_soc_card_get_drvdata(card); - struct device *dev = &priv->pdev->dev; - int ret; - - rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec_dai = rtd->codec_dai; - ret = snd_soc_dai_set_sysclk(codec_dai, WM8962_SYSCLK_MCLK, - data->clk_frequency, SND_SOC_CLOCK_IN); - if (ret < 0) - dev_err(dev, "failed to set sysclk in %s\n", __func__); - - return ret; -} - -static int imx_wm8962_probe(struct platform_device *pdev) -{ - struct device_node *np = pdev->dev.of_node; - struct device_node *ssi_np, *codec_np; - struct platform_device *ssi_pdev; - struct i2c_client *codec_dev; - struct imx_wm8962_data *data; - struct imx_priv *priv; - struct clk *codec_clk; - int int_port, ext_port; - int ret; - - priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) - return -ENOMEM; - - priv->pdev = pdev; - priv->sample_rate = 44100; - priv->sample_format = SNDRV_PCM_FORMAT_S16_LE; - - ret = of_property_read_u32(np, "mux-int-port", &int_port); - if (ret) { - dev_err(&pdev->dev, "mux-int-port missing or invalid\n"); - return ret; - } - ret = of_property_read_u32(np, "mux-ext-port", &ext_port); - if (ret) { - dev_err(&pdev->dev, "mux-ext-port missing or invalid\n"); - return ret; - } - - /* - * The port numbering in the hardware manual starts at 1, while - * the audmux API expects it starts at 0. - */ - int_port--; - ext_port--; - ret = imx_audmux_v2_configure_port(int_port, - IMX_AUDMUX_V2_PTCR_SYN | - IMX_AUDMUX_V2_PTCR_TFSEL(ext_port) | - IMX_AUDMUX_V2_PTCR_TCSEL(ext_port) | - IMX_AUDMUX_V2_PTCR_TFSDIR | - IMX_AUDMUX_V2_PTCR_TCLKDIR, - IMX_AUDMUX_V2_PDCR_RXDSEL(ext_port)); - if (ret) { - dev_err(&pdev->dev, "audmux internal port setup failed\n"); - return ret; - } - ret = imx_audmux_v2_configure_port(ext_port, - IMX_AUDMUX_V2_PTCR_SYN, - IMX_AUDMUX_V2_PDCR_RXDSEL(int_port)); - if (ret) { - dev_err(&pdev->dev, "audmux external port setup failed\n"); - return ret; - } - - ssi_np = of_parse_phandle(pdev->dev.of_node, "ssi-controller", 0); - codec_np = of_parse_phandle(pdev->dev.of_node, "audio-codec", 0); - if (!ssi_np || !codec_np) { - dev_err(&pdev->dev, "phandle missing or invalid\n"); - ret = -EINVAL; - goto fail; - } - - ssi_pdev = of_find_device_by_node(ssi_np); - if (!ssi_pdev) { - dev_err(&pdev->dev, "failed to find SSI platform device\n"); - ret = -EINVAL; - goto fail; - } - codec_dev = of_find_i2c_device_by_node(codec_np); - if (!codec_dev || !codec_dev->dev.driver) { - dev_err(&pdev->dev, "failed to find codec platform device\n"); - ret = -EINVAL; - goto fail; - } - - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto fail; - } - - codec_clk = clk_get(&codec_dev->dev, NULL); - if (IS_ERR(codec_clk)) { - ret = PTR_ERR(codec_clk); - dev_err(&codec_dev->dev, "failed to get codec clk: %d\n", ret); - goto fail; - } - - data->clk_frequency = clk_get_rate(codec_clk); - clk_put(codec_clk); - - data->dai.name = "HiFi"; - data->dai.stream_name = "HiFi"; - data->dai.codec_dai_name = "wm8962"; - data->dai.codec_of_node = codec_np; - data->dai.cpu_dai_name = dev_name(&ssi_pdev->dev); - data->dai.platform_of_node = ssi_np; - data->dai.ops = &imx_hifi_ops; - data->dai.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM; - - data->card.dev = &pdev->dev; - ret = snd_soc_of_parse_card_name(&data->card, "model"); - if (ret) - goto fail; - ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing"); - if (ret) - goto fail; - data->card.num_links = 1; - data->card.owner = THIS_MODULE; - data->card.dai_link = &data->dai; - data->card.dapm_widgets = imx_wm8962_dapm_widgets; - data->card.num_dapm_widgets = ARRAY_SIZE(imx_wm8962_dapm_widgets); - - data->card.late_probe = imx_wm8962_late_probe; - data->card.set_bias_level = imx_wm8962_set_bias_level; - - platform_set_drvdata(pdev, &data->card); - snd_soc_card_set_drvdata(&data->card, data); - - ret = devm_snd_soc_register_card(&pdev->dev, &data->card); - if (ret) { - dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); - goto fail; - } - -fail: - of_node_put(ssi_np); - of_node_put(codec_np); - - return ret; -} - -static const struct of_device_id imx_wm8962_dt_ids[] = { - { .compatible = "fsl,imx-audio-wm8962", }, - { /* sentinel */ } -}; -MODULE_DEVICE_TABLE(of, imx_wm8962_dt_ids); - -static struct platform_driver imx_wm8962_driver = { - .driver = { - .name = "imx-wm8962", - .pm = &snd_soc_pm_ops, - .of_match_table = imx_wm8962_dt_ids, - }, - .probe = imx_wm8962_probe, -}; -module_platform_driver(imx_wm8962_driver); - -MODULE_AUTHOR("Freescale Semiconductor, Inc."); -MODULE_DESCRIPTION("Freescale i.MX WM8962 ASoC machine driver"); -MODULE_LICENSE("GPL v2"); -MODULE_ALIAS("platform:imx-wm8962"); From f5ca3ab9bc1b160966c1e5cc7bf831f7b8ec31e5 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 23 Feb 2018 10:17:16 +0900 Subject: [PATCH 381/942] ASoC: add DT bindings documentation for ROHM BD28623 codec This patch adds DT bindings documentation for ROHM BD28623MUV class D speaker amplifier. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- .../bindings/sound/rohm,bd28623.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/rohm,bd28623.txt diff --git a/Documentation/devicetree/bindings/sound/rohm,bd28623.txt b/Documentation/devicetree/bindings/sound/rohm,bd28623.txt new file mode 100644 index 000000000000..d84557c2686e --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rohm,bd28623.txt @@ -0,0 +1,29 @@ +ROHM BD28623MUV Class D speaker amplifier for digital input + +This codec does not have any control buses such as I2C, it detect format and +rate of I2S signal automatically. It has two signals that can be connected +to GPIOs: reset and mute. + +Required properties: +- compatible : should be "rohm,bd28623" +- #sound-dai-cells: should be 0. +- VCCA-supply : regulator phandle for the VCCA supply +- VCCP1-supply : regulator phandle for the VCCP1 supply +- VCCP2-supply : regulator phandle for the VCCP2 supply + +Optional properties: +- reset-gpios : GPIO specifier for the active low reset line +- mute-gpios : GPIO specifier for the active low mute line + +Example: + + codec { + compatible = "rohm,bd28623"; + #sound-dai-cells = <0>; + + VCCA-supply = <&vcc_reg>; + VCCP1-supply = <&vcc_reg>; + VCCP2-supply = <&vcc_reg>; + reset-gpios = <&gpio 0 GPIO_ACTIVE_LOW>; + mute-gpios = <&gpio 1 GPIO_ACTIVE_LOW>; + }; From f6d4b052175d84c6f2b73e884f3ab8c83c5f4d45 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 23 Feb 2018 10:17:17 +0900 Subject: [PATCH 382/942] ASoC: support ROHM BD28623 codec This patch adds support of the ROHM BD28623MUV Class D speaker amplifier for Flat-panel TVs. This IC delivers an output power of 20W + 20W. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 8 ++ sound/soc/codecs/Makefile | 2 + sound/soc/codecs/bd28623.c | 242 +++++++++++++++++++++++++++++++++++++ 3 files changed, 252 insertions(+) create mode 100644 sound/soc/codecs/bd28623.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..4545f8fde220 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -45,6 +45,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_ALC5623 if I2C select SND_SOC_ALC5632 if I2C select SND_SOC_BT_SCO + select SND_SOC_BD28623 select SND_SOC_CQ0093VC select SND_SOC_CS35L32 if I2C select SND_SOC_CS35L33 if I2C @@ -405,6 +406,13 @@ config SND_SOC_ALC5623 config SND_SOC_ALC5632 tristate +config SND_SOC_BD28623 + tristate "ROHM BD28623 CODEC" + help + Enable support for ROHM BD28623MUV Class D speaker amplifier. + This codec does not have any control buses such as I2C, it + detect format of I2S automatically. + config SND_SOC_BT_SCO tristate "Dummy BT SCO codec driver" diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..6df2fb32fc7e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -35,6 +35,7 @@ snd-soc-ak4642-objs := ak4642.o snd-soc-ak4671-objs := ak4671.o snd-soc-ak5386-objs := ak5386.o snd-soc-arizona-objs := arizona.o +snd-soc-bd28623-objs := bd28623.o snd-soc-bt-sco-objs := bt-sco.o snd-soc-cq93vc-objs := cq93vc.o snd-soc-cs35l32-objs := cs35l32.o @@ -280,6 +281,7 @@ obj-$(CONFIG_SND_SOC_AK5386) += snd-soc-ak5386.o obj-$(CONFIG_SND_SOC_ALC5623) += snd-soc-alc5623.o obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o +obj-$(CONFIG_SND_SOC_BD28623) += snd-soc-bd28623.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o diff --git a/sound/soc/codecs/bd28623.c b/sound/soc/codecs/bd28623.c new file mode 100644 index 000000000000..31904ef5c88b --- /dev/null +++ b/sound/soc/codecs/bd28623.c @@ -0,0 +1,242 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// ROHM BD28623MUV class D speaker amplifier codec driver. +// +// Copyright (c) 2018 Socionext Inc. + +#include +#include +#include +#include +#include +#include +#include + +#define BD28623_NUM_SUPPLIES 3 + +static const char *const bd28623_supply_names[BD28623_NUM_SUPPLIES] = { + "VCCA", + "VCCP1", + "VCCP2", +}; + +struct bd28623_priv { + struct device *dev; + struct regulator_bulk_data supplies[BD28623_NUM_SUPPLIES]; + struct gpio_desc *reset_gpio; + struct gpio_desc *mute_gpio; + + int switch_spk; +}; + +static const struct snd_soc_dapm_widget bd28623_widgets[] = { + SND_SOC_DAPM_DAC("DAC", "Playback", SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_OUTPUT("OUT1P"), + SND_SOC_DAPM_OUTPUT("OUT1N"), + SND_SOC_DAPM_OUTPUT("OUT2P"), + SND_SOC_DAPM_OUTPUT("OUT2N"), +}; + +static const struct snd_soc_dapm_route bd28623_routes[] = { + { "OUT1P", NULL, "DAC" }, + { "OUT1N", NULL, "DAC" }, + { "OUT2P", NULL, "DAC" }, + { "OUT2N", NULL, "DAC" }, +}; + +static int bd28623_power_on(struct bd28623_priv *bd) +{ + int ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(bd->supplies), bd->supplies); + if (ret) { + dev_err(bd->dev, "Failed to enable supplies: %d\n", ret); + return ret; + } + + gpiod_set_value_cansleep(bd->reset_gpio, 0); + usleep_range(300000, 400000); + + return 0; +} + +static void bd28623_power_off(struct bd28623_priv *bd) +{ + gpiod_set_value_cansleep(bd->reset_gpio, 1); + + regulator_bulk_disable(ARRAY_SIZE(bd->supplies), bd->supplies); +} + +static int bd28623_get_switch_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); + + ucontrol->value.integer.value[0] = bd->switch_spk; + + return 0; +} + +static int bd28623_set_switch_spk(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_soc_kcontrol_component(kcontrol); + struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); + + if (bd->switch_spk == ucontrol->value.integer.value[0]) + return 0; + + bd->switch_spk = ucontrol->value.integer.value[0]; + + gpiod_set_value_cansleep(bd->mute_gpio, bd->switch_spk ? 0 : 1); + + return 0; +} + +static const struct snd_kcontrol_new bd28623_controls[] = { + SOC_SINGLE_BOOL_EXT("Speaker Switch", 0, + bd28623_get_switch_spk, bd28623_set_switch_spk), +}; + +static int bd28623_codec_probe(struct snd_soc_component *component) +{ + struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); + int ret; + + bd->switch_spk = 1; + + ret = bd28623_power_on(bd); + if (ret) + return ret; + + gpiod_set_value_cansleep(bd->mute_gpio, bd->switch_spk ? 0 : 1); + + return 0; +} + +static void bd28623_codec_remove(struct snd_soc_component *component) +{ + struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); + + bd28623_power_off(bd); +} + +static int bd28623_codec_suspend(struct snd_soc_component *component) +{ + struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); + + bd28623_power_off(bd); + + return 0; +} + +static int bd28623_codec_resume(struct snd_soc_component *component) +{ + struct bd28623_priv *bd = snd_soc_component_get_drvdata(component); + int ret; + + ret = bd28623_power_on(bd); + if (ret) + return ret; + + gpiod_set_value_cansleep(bd->mute_gpio, bd->switch_spk ? 0 : 1); + + return 0; +} + +static const struct snd_soc_component_driver soc_codec_bd = { + .probe = bd28623_codec_probe, + .remove = bd28623_codec_remove, + .suspend = bd28623_codec_suspend, + .resume = bd28623_codec_resume, + .dapm_widgets = bd28623_widgets, + .num_dapm_widgets = ARRAY_SIZE(bd28623_widgets), + .dapm_routes = bd28623_routes, + .num_dapm_routes = ARRAY_SIZE(bd28623_routes), + .controls = bd28623_controls, + .num_controls = ARRAY_SIZE(bd28623_controls), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + +static struct snd_soc_dai_driver soc_dai_bd = { + .name = "bd28623-speaker", + .playback = { + .stream_name = "Playback", + .formats = SNDRV_PCM_FMTBIT_S32_LE | + SNDRV_PCM_FMTBIT_S24_LE | + SNDRV_PCM_FMTBIT_S16_LE, + .rates = SNDRV_PCM_RATE_48000 | + SNDRV_PCM_RATE_44100 | + SNDRV_PCM_RATE_32000, + .channels_min = 2, + .channels_max = 2, + }, +}; + +static int bd28623_probe(struct platform_device *pdev) +{ + struct bd28623_priv *bd; + struct device *dev = &pdev->dev; + int i, ret; + + bd = devm_kzalloc(&pdev->dev, sizeof(struct bd28623_priv), GFP_KERNEL); + if (!bd) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(bd->supplies); i++) + bd->supplies[i].supply = bd28623_supply_names[i]; + + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(bd->supplies), + bd->supplies); + if (ret) { + dev_err(dev, "Failed to get supplies: %d\n", ret); + return ret; + } + + bd->reset_gpio = devm_gpiod_get_optional(dev, "reset", + GPIOD_OUT_HIGH); + if (IS_ERR(bd->reset_gpio)) { + dev_err(dev, "Failed to request reset_gpio: %ld\n", + PTR_ERR(bd->reset_gpio)); + return PTR_ERR(bd->reset_gpio); + } + + bd->mute_gpio = devm_gpiod_get_optional(dev, "mute", + GPIOD_OUT_HIGH); + if (IS_ERR(bd->mute_gpio)) { + dev_err(dev, "Failed to request mute_gpio: %ld\n", + PTR_ERR(bd->mute_gpio)); + return PTR_ERR(bd->mute_gpio); + } + + platform_set_drvdata(pdev, bd); + bd->dev = dev; + + return devm_snd_soc_register_component(dev, &soc_codec_bd, + &soc_dai_bd, 1); +} + +static const struct of_device_id bd28623_of_match[] = { + { .compatible = "rohm,bd28623", }, + {} +}; +MODULE_DEVICE_TABLE(of, bd28623_of_match); + +static struct platform_driver bd28623_codec_driver = { + .driver = { + .name = "bd28623", + .of_match_table = of_match_ptr(bd28623_of_match), + }, + .probe = bd28623_probe, +}; +module_platform_driver(bd28623_codec_driver); + +MODULE_AUTHOR("Katsuhiro Suzuki "); +MODULE_DESCRIPTION("ROHM BD28623 speaker amplifier driver"); +MODULE_LICENSE("GPL v2"); From f6cdf2d3445d73f5b27ec8e620b8fe7a1f5c0ea1 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 23 Feb 2018 21:02:51 +0100 Subject: [PATCH 383/942] ASoC: cpcap: new codec Motorola CPCAP is a PMIC with audio functionality, that can be found on Motorola Droid 4 and probably a few other phones from Motorola's Droid series. The driver has been written from scratch using Motorola's Android driver, register dumps from running Android and datasheet for NXP MC13783UG (which is similar to Motorola CPCAP, but not the same). The chip provides two audio interfaces, that can be muxed to two different audio codecs. One provides support for stereo output (named StDAC or HiFi), while the other only provides mono output (named Voice). Only the Voice codec provides a Capture interface. Signed-off-by: Sebastian Reichel Acked-by: Tony Lindgren Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 4 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/cpcap.c | 1568 +++++++++++++++++++++++++++++++++++++ 3 files changed, 1574 insertions(+) create mode 100644 sound/soc/codecs/cpcap.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..5bd94841feb6 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -408,6 +408,10 @@ config SND_SOC_ALC5632 config SND_SOC_BT_SCO tristate "Dummy BT SCO codec driver" +config SND_SOC_CPCAP + tristate "Motorola CPCAP codec" + depends on MFD_CPCAP + config SND_SOC_CQ0093VC tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..2aeee1ba034e 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -36,6 +36,7 @@ snd-soc-ak4671-objs := ak4671.o snd-soc-ak5386-objs := ak5386.o snd-soc-arizona-objs := arizona.o snd-soc-bt-sco-objs := bt-sco.o +snd-soc-cpcap-objs := cpcap.o snd-soc-cq93vc-objs := cq93vc.o snd-soc-cs35l32-objs := cs35l32.o snd-soc-cs35l33-objs := cs35l33.o @@ -282,6 +283,7 @@ obj-$(CONFIG_SND_SOC_ALC5632) += snd-soc-alc5632.o obj-$(CONFIG_SND_SOC_ARIZONA) += snd-soc-arizona.o obj-$(CONFIG_SND_SOC_BT_SCO) += snd-soc-bt-sco.o obj-$(CONFIG_SND_SOC_CQ0093VC) += snd-soc-cq93vc.o +obj-$(CONFIG_SND_SOC_CPCAP) += snd-soc-cpcap.o obj-$(CONFIG_SND_SOC_CS35L32) += snd-soc-cs35l32.o obj-$(CONFIG_SND_SOC_CS35L33) += snd-soc-cs35l33.o obj-$(CONFIG_SND_SOC_CS35L34) += snd-soc-cs35l34.o diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c new file mode 100644 index 000000000000..aedb267d4581 --- /dev/null +++ b/sound/soc/codecs/cpcap.c @@ -0,0 +1,1568 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ALSA SoC CPCAP codec driver + * + * Copyright (C) 2017 - 2018 Sebastian Reichel + * + * Very loosely based on original driver from Motorola: + * Copyright (C) 2007 - 2009 Motorola, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include + +/* Register 513 CPCAP_REG_CC --- CODEC */ +#define CPCAP_BIT_CDC_CLK2 15 +#define CPCAP_BIT_CDC_CLK1 14 +#define CPCAP_BIT_CDC_CLK0 13 +#define CPCAP_BIT_CDC_SR3 12 +#define CPCAP_BIT_CDC_SR2 11 +#define CPCAP_BIT_CDC_SR1 10 +#define CPCAP_BIT_CDC_SR0 9 +#define CPCAP_BIT_CDC_CLOCK_TREE_RESET 8 +#define CPCAP_BIT_MIC2_CDC_EN 7 +#define CPCAP_BIT_CDC_EN_RX 6 +#define CPCAP_BIT_DF_RESET 5 +#define CPCAP_BIT_MIC1_CDC_EN 4 +#define CPCAP_BIT_AUDOHPF_1 3 +#define CPCAP_BIT_AUDOHPF_0 2 +#define CPCAP_BIT_AUDIHPF_1 1 +#define CPCAP_BIT_AUDIHPF_0 0 + +/* Register 514 CPCAP_REG_CDI --- CODEC Digital Audio Interface */ +#define CPCAP_BIT_CDC_PLL_SEL 15 +#define CPCAP_BIT_CLK_IN_SEL 13 +#define CPCAP_BIT_DIG_AUD_IN 12 +#define CPCAP_BIT_CDC_CLK_EN 11 +#define CPCAP_BIT_CDC_DIG_AUD_FS1 10 +#define CPCAP_BIT_CDC_DIG_AUD_FS0 9 +#define CPCAP_BIT_MIC2_TIMESLOT2 8 +#define CPCAP_BIT_MIC2_TIMESLOT1 7 +#define CPCAP_BIT_MIC2_TIMESLOT0 6 +#define CPCAP_BIT_MIC1_RX_TIMESLOT2 5 +#define CPCAP_BIT_MIC1_RX_TIMESLOT1 4 +#define CPCAP_BIT_MIC1_RX_TIMESLOT0 3 +#define CPCAP_BIT_FS_INV 2 +#define CPCAP_BIT_CLK_INV 1 +#define CPCAP_BIT_SMB_CDC 0 + +/* Register 515 CPCAP_REG_SDAC --- Stereo DAC */ +#define CPCAP_BIT_FSYNC_CLK_IN_COMMON 11 +#define CPCAP_BIT_SLAVE_PLL_CLK_INPUT 10 +#define CPCAP_BIT_ST_CLOCK_TREE_RESET 9 +#define CPCAP_BIT_DF_RESET_ST_DAC 8 +#define CPCAP_BIT_ST_SR3 7 +#define CPCAP_BIT_ST_SR2 6 +#define CPCAP_BIT_ST_SR1 5 +#define CPCAP_BIT_ST_SR0 4 +#define CPCAP_BIT_ST_DAC_CLK2 3 +#define CPCAP_BIT_ST_DAC_CLK1 2 +#define CPCAP_BIT_ST_DAC_CLK0 1 +#define CPCAP_BIT_ST_DAC_EN 0 + +/* Register 516 CPCAP_REG_SDACDI --- Stereo DAC Digital Audio Interface */ +#define CPCAP_BIT_ST_L_TIMESLOT2 13 +#define CPCAP_BIT_ST_L_TIMESLOT1 12 +#define CPCAP_BIT_ST_L_TIMESLOT0 11 +#define CPCAP_BIT_ST_R_TIMESLOT2 10 +#define CPCAP_BIT_ST_R_TIMESLOT1 9 +#define CPCAP_BIT_ST_R_TIMESLOT0 8 +#define CPCAP_BIT_ST_DAC_CLK_IN_SEL 7 +#define CPCAP_BIT_ST_FS_INV 6 +#define CPCAP_BIT_ST_CLK_INV 5 +#define CPCAP_BIT_ST_DIG_AUD_FS1 4 +#define CPCAP_BIT_ST_DIG_AUD_FS0 3 +#define CPCAP_BIT_DIG_AUD_IN_ST_DAC 2 +#define CPCAP_BIT_ST_CLK_EN 1 +#define CPCAP_BIT_SMB_ST_DAC 0 + +/* Register 517 CPCAP_REG_TXI --- TX Interface */ +#define CPCAP_BIT_PTT_TH 15 +#define CPCAP_BIT_PTT_CMP_EN 14 +#define CPCAP_BIT_HS_ID_TX 13 +#define CPCAP_BIT_MB_ON2 12 +#define CPCAP_BIT_MB_ON1L 11 +#define CPCAP_BIT_MB_ON1R 10 +#define CPCAP_BIT_RX_L_ENCODE 9 +#define CPCAP_BIT_RX_R_ENCODE 8 +#define CPCAP_BIT_MIC2_MUX 7 +#define CPCAP_BIT_MIC2_PGA_EN 6 +#define CPCAP_BIT_CDET_DIS 5 +#define CPCAP_BIT_EMU_MIC_MUX 4 +#define CPCAP_BIT_HS_MIC_MUX 3 +#define CPCAP_BIT_MIC1_MUX 2 +#define CPCAP_BIT_MIC1_PGA_EN 1 +#define CPCAP_BIT_DLM 0 + +/* Register 518 CPCAP_REG_TXMP --- Mic Gain */ +#define CPCAP_BIT_MB_BIAS_R1 11 +#define CPCAP_BIT_MB_BIAS_R0 10 +#define CPCAP_BIT_MIC2_GAIN_4 9 +#define CPCAP_BIT_MIC2_GAIN_3 8 +#define CPCAP_BIT_MIC2_GAIN_2 7 +#define CPCAP_BIT_MIC2_GAIN_1 6 +#define CPCAP_BIT_MIC2_GAIN_0 5 +#define CPCAP_BIT_MIC1_GAIN_4 4 +#define CPCAP_BIT_MIC1_GAIN_3 3 +#define CPCAP_BIT_MIC1_GAIN_2 2 +#define CPCAP_BIT_MIC1_GAIN_1 1 +#define CPCAP_BIT_MIC1_GAIN_0 0 + +/* Register 519 CPCAP_REG_RXOA --- RX Output Amplifier */ +#define CPCAP_BIT_UNUSED_519_15 15 +#define CPCAP_BIT_UNUSED_519_14 14 +#define CPCAP_BIT_UNUSED_519_13 13 +#define CPCAP_BIT_STDAC_LOW_PWR_DISABLE 12 +#define CPCAP_BIT_HS_LOW_PWR 11 +#define CPCAP_BIT_HS_ID_RX 10 +#define CPCAP_BIT_ST_HS_CP_EN 9 +#define CPCAP_BIT_EMU_SPKR_R_EN 8 +#define CPCAP_BIT_EMU_SPKR_L_EN 7 +#define CPCAP_BIT_HS_L_EN 6 +#define CPCAP_BIT_HS_R_EN 5 +#define CPCAP_BIT_A4_LINEOUT_L_EN 4 +#define CPCAP_BIT_A4_LINEOUT_R_EN 3 +#define CPCAP_BIT_A2_LDSP_L_EN 2 +#define CPCAP_BIT_A2_LDSP_R_EN 1 +#define CPCAP_BIT_A1_EAR_EN 0 + +/* Register 520 CPCAP_REG_RXVC --- RX Volume Control */ +#define CPCAP_BIT_VOL_EXT3 15 +#define CPCAP_BIT_VOL_EXT2 14 +#define CPCAP_BIT_VOL_EXT1 13 +#define CPCAP_BIT_VOL_EXT0 12 +#define CPCAP_BIT_VOL_DAC3 11 +#define CPCAP_BIT_VOL_DAC2 10 +#define CPCAP_BIT_VOL_DAC1 9 +#define CPCAP_BIT_VOL_DAC0 8 +#define CPCAP_BIT_VOL_DAC_LSB_1dB1 7 +#define CPCAP_BIT_VOL_DAC_LSB_1dB0 6 +#define CPCAP_BIT_VOL_CDC3 5 +#define CPCAP_BIT_VOL_CDC2 4 +#define CPCAP_BIT_VOL_CDC1 3 +#define CPCAP_BIT_VOL_CDC0 2 +#define CPCAP_BIT_VOL_CDC_LSB_1dB1 1 +#define CPCAP_BIT_VOL_CDC_LSB_1dB0 0 + +/* Register 521 CPCAP_REG_RXCOA --- Codec to Output Amp Switches */ +#define CPCAP_BIT_PGA_CDC_EN 10 +#define CPCAP_BIT_CDC_SW 9 +#define CPCAP_BIT_PGA_OUTR_USBDP_CDC_SW 8 +#define CPCAP_BIT_PGA_OUTL_USBDN_CDC_SW 7 +#define CPCAP_BIT_ALEFT_HS_CDC_SW 6 +#define CPCAP_BIT_ARIGHT_HS_CDC_SW 5 +#define CPCAP_BIT_A4_LINEOUT_L_CDC_SW 4 +#define CPCAP_BIT_A4_LINEOUT_R_CDC_SW 3 +#define CPCAP_BIT_A2_LDSP_L_CDC_SW 2 +#define CPCAP_BIT_A2_LDSP_R_CDC_SW 1 +#define CPCAP_BIT_A1_EAR_CDC_SW 0 + +/* Register 522 CPCAP_REG_RXSDOA --- RX Stereo DAC to Output Amp Switches */ +#define CPCAP_BIT_PGA_DAC_EN 12 +#define CPCAP_BIT_ST_DAC_SW 11 +#define CPCAP_BIT_MONO_DAC1 10 +#define CPCAP_BIT_MONO_DAC0 9 +#define CPCAP_BIT_PGA_OUTR_USBDP_DAC_SW 8 +#define CPCAP_BIT_PGA_OUTL_USBDN_DAC_SW 7 +#define CPCAP_BIT_ALEFT_HS_DAC_SW 6 +#define CPCAP_BIT_ARIGHT_HS_DAC_SW 5 +#define CPCAP_BIT_A4_LINEOUT_L_DAC_SW 4 +#define CPCAP_BIT_A4_LINEOUT_R_DAC_SW 3 +#define CPCAP_BIT_A2_LDSP_L_DAC_SW 2 +#define CPCAP_BIT_A2_LDSP_R_DAC_SW 1 +#define CPCAP_BIT_A1_EAR_DAC_SW 0 + +/* Register 523 CPCAP_REG_RXEPOA --- RX External PGA to Output Amp Switches */ +#define CPCAP_BIT_PGA_EXT_L_EN 14 +#define CPCAP_BIT_PGA_EXT_R_EN 13 +#define CPCAP_BIT_PGA_IN_L_SW 12 +#define CPCAP_BIT_PGA_IN_R_SW 11 +#define CPCAP_BIT_MONO_EXT1 10 +#define CPCAP_BIT_MONO_EXT0 9 +#define CPCAP_BIT_PGA_OUTR_USBDP_EXT_SW 8 +#define CPCAP_BIT_PGA_OUTL_USBDN_EXT_SW 7 +#define CPCAP_BIT_ALEFT_HS_EXT_SW 6 +#define CPCAP_BIT_ARIGHT_HS_EXT_SW 5 +#define CPCAP_BIT_A4_LINEOUT_L_EXT_SW 4 +#define CPCAP_BIT_A4_LINEOUT_R_EXT_SW 3 +#define CPCAP_BIT_A2_LDSP_L_EXT_SW 2 +#define CPCAP_BIT_A2_LDSP_R_EXT_SW 1 +#define CPCAP_BIT_A1_EAR_EXT_SW 0 + +/* Register 525 CPCAP_REG_A2LA --- SPK Amplifier and Clock Config for Headset */ +#define CPCAP_BIT_NCP_CLK_SYNC 7 +#define CPCAP_BIT_A2_CLK_SYNC 6 +#define CPCAP_BIT_A2_FREE_RUN 5 +#define CPCAP_BIT_A2_CLK2 4 +#define CPCAP_BIT_A2_CLK1 3 +#define CPCAP_BIT_A2_CLK0 2 +#define CPCAP_BIT_A2_CLK_IN 1 +#define CPCAP_BIT_A2_CONFIG 0 + +#define SLEEP_ACTIVATE_POWER 2 +#define CLOCK_TREE_RESET_TIME 1 + +/* constants for ST delay workaround */ +#define STM_STDAC_ACTIVATE_RAMP_TIME 1 +#define STM_STDAC_EN_TEST_PRE 0x090C +#define STM_STDAC_EN_TEST_POST 0x0000 +#define STM_STDAC_EN_ST_TEST1_PRE 0x2400 +#define STM_STDAC_EN_ST_TEST1_POST 0x0400 + +struct cpcap_reg_info { + u16 reg; + u16 mask; + u16 val; +}; + +static const struct cpcap_reg_info cpcap_default_regs[] = { + { CPCAP_REG_CC, 0xFFFF, 0x0000 }, + { CPCAP_REG_CC, 0xFFFF, 0x0000 }, + { CPCAP_REG_CDI, 0xBFFF, 0x0000 }, + { CPCAP_REG_SDAC, 0x0FFF, 0x0000 }, + { CPCAP_REG_SDACDI, 0x3FFF, 0x0000 }, + { CPCAP_REG_TXI, 0x0FDF, 0x0000 }, + { CPCAP_REG_TXMP, 0x0FFF, 0x0400 }, + { CPCAP_REG_RXOA, 0x01FF, 0x0000 }, + { CPCAP_REG_RXVC, 0xFF3C, 0x0000 }, + { CPCAP_REG_RXCOA, 0x07FF, 0x0000 }, + { CPCAP_REG_RXSDOA, 0x1FFF, 0x0000 }, + { CPCAP_REG_RXEPOA, 0x7FFF, 0x0000 }, + { CPCAP_REG_A2LA, BIT(CPCAP_BIT_A2_FREE_RUN), + BIT(CPCAP_BIT_A2_FREE_RUN) }, +}; + +enum cpcap_dai { + CPCAP_DAI_HIFI, + CPCAP_DAI_VOICE, +}; + +struct cpcap_audio { + struct snd_soc_codec *codec; + struct regmap *regmap; + + u16 vendor; + + int codec_clk_id; + int codec_freq; + int codec_format; +}; + +static int cpcap_st_workaround(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + int err = 0; + + /* Only CPCAP from ST requires workaround */ + if (cpcap->vendor != CPCAP_VENDOR_ST) + return 0; + + switch (event) { + case SND_SOC_DAPM_PRE_PMU: + err = regmap_write(cpcap->regmap, CPCAP_REG_TEST, + STM_STDAC_EN_TEST_PRE); + if (err) + return err; + err = regmap_write(cpcap->regmap, CPCAP_REG_ST_TEST1, + STM_STDAC_EN_ST_TEST1_PRE); + break; + case SND_SOC_DAPM_POST_PMU: + msleep(STM_STDAC_ACTIVATE_RAMP_TIME); + + err = regmap_write(cpcap->regmap, CPCAP_REG_ST_TEST1, + STM_STDAC_EN_ST_TEST1_POST); + if (err) + return err; + err = regmap_write(cpcap->regmap, CPCAP_REG_TEST, + STM_STDAC_EN_TEST_POST); + break; + default: + break; + } + + return err; +} + +/* Capture Gain Control: 0dB to 31dB in 1dB steps */ +static const DECLARE_TLV_DB_SCALE(mic_gain_tlv, 0, 100, 0); + +/* Playback Gain Control: -33dB to 12dB in 3dB steps */ +static const DECLARE_TLV_DB_SCALE(vol_tlv, -3300, 300, 0); + +static const struct snd_kcontrol_new cpcap_snd_controls[] = { + /* Playback Gain */ + SOC_SINGLE_TLV("HiFi Playback Volume", + CPCAP_REG_RXVC, CPCAP_BIT_VOL_DAC0, 0xF, 0, vol_tlv), + SOC_SINGLE_TLV("Voice Playback Volume", + CPCAP_REG_RXVC, CPCAP_BIT_VOL_CDC0, 0xF, 0, vol_tlv), + SOC_SINGLE_TLV("Ext Playback Volume", + CPCAP_REG_RXVC, CPCAP_BIT_VOL_EXT0, 0xF, 0, vol_tlv), + + /* Capture Gain */ + SOC_SINGLE_TLV("Mic1 Capture Volume", + CPCAP_REG_TXMP, CPCAP_BIT_MIC1_GAIN_0, 0x1F, 0, mic_gain_tlv), + SOC_SINGLE_TLV("Mic2 Capture Volume", + CPCAP_REG_TXMP, CPCAP_BIT_MIC2_GAIN_0, 0x1F, 0, mic_gain_tlv), + + /* Phase Invert */ + SOC_SINGLE("Hifi Left Phase Invert Switch", + CPCAP_REG_RXSDOA, CPCAP_BIT_MONO_DAC0, 1, 0), + SOC_SINGLE("Ext Left Phase Invert Switch", + CPCAP_REG_RXEPOA, CPCAP_BIT_MONO_EXT0, 1, 0), +}; + +static const char * const cpcap_out_mux_texts[] = { + "Off", "Voice", "HiFi", "Ext" +}; + +static const char * const cpcap_in_right_mux_texts[] = { + "Off", "Mic 1", "Headset Mic", "EMU Mic", "Ext Right" +}; + +static const char * const cpcap_in_left_mux_texts[] = { + "Off", "Mic 2", "Ext Left" +}; + +/* + * input muxes use unusual register layout, so that we need to use custom + * getter/setter methods + */ +static SOC_ENUM_SINGLE_EXT_DECL(cpcap_input_left_mux_enum, + cpcap_in_left_mux_texts); +static SOC_ENUM_SINGLE_EXT_DECL(cpcap_input_right_mux_enum, + cpcap_in_right_mux_texts); + +/* + * mux uses same bit in CPCAP_REG_RXCOA, CPCAP_REG_RXSDOA & CPCAP_REG_RXEPOA; + * even though the register layout makes it look like a mixer, this is a mux. + * Enabling multiple inputs will result in no audio being forwarded. + */ +static SOC_ENUM_SINGLE_DECL(cpcap_earpiece_mux_enum, 0, 0, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_spkr_r_mux_enum, 0, 1, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_spkr_l_mux_enum, 0, 2, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_line_r_mux_enum, 0, 3, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_line_l_mux_enum, 0, 4, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_hs_r_mux_enum, 0, 5, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_hs_l_mux_enum, 0, 6, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_emu_l_mux_enum, 0, 7, cpcap_out_mux_texts); +static SOC_ENUM_SINGLE_DECL(cpcap_emu_r_mux_enum, 0, 8, cpcap_out_mux_texts); + +static int cpcap_output_mux_get_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int shift = e->shift_l; + int reg_voice, reg_hifi, reg_ext, status; + int err; + + err = regmap_read(cpcap->regmap, CPCAP_REG_RXCOA, ®_voice); + if (err) + return err; + err = regmap_read(cpcap->regmap, CPCAP_REG_RXSDOA, ®_hifi); + if (err) + return err; + err = regmap_read(cpcap->regmap, CPCAP_REG_RXEPOA, ®_ext); + if (err) + return err; + + reg_voice = (reg_voice >> shift) & 1; + reg_hifi = (reg_hifi >> shift) & 1; + reg_ext = (reg_ext >> shift) & 1; + status = reg_ext << 2 | reg_hifi << 1 | reg_voice; + + switch (status) { + case 0x04: + ucontrol->value.enumerated.item[0] = 3; + break; + case 0x02: + ucontrol->value.enumerated.item[0] = 2; + break; + case 0x01: + ucontrol->value.enumerated.item[0] = 1; + break; + default: + ucontrol->value.enumerated.item[0] = 0; + break; + } + + return 0; +} + +static int cpcap_output_mux_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int muxval = ucontrol->value.enumerated.item[0]; + unsigned int mask = BIT(e->shift_l); + u16 reg_voice = 0x00, reg_hifi = 0x00, reg_ext = 0x00; + int err; + + switch (muxval) { + case 1: + reg_voice = mask; + break; + case 2: + reg_hifi = mask; + break; + case 3: + reg_ext = mask; + break; + default: + break; + } + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXCOA, + mask, reg_voice); + if (err) + return err; + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXSDOA, + mask, reg_hifi); + if (err) + return err; + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_RXEPOA, + mask, reg_ext); + if (err) + return err; + + snd_soc_dapm_mux_update_power(dapm, kcontrol, muxval, e, NULL); + + return 0; +} + +static int cpcap_input_right_mux_get_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + int regval, mask; + int err; + + err = regmap_read(cpcap->regmap, CPCAP_REG_TXI, ®val); + if (err) + return err; + + mask = 0; + mask |= BIT(CPCAP_BIT_MIC1_MUX); + mask |= BIT(CPCAP_BIT_HS_MIC_MUX); + mask |= BIT(CPCAP_BIT_EMU_MIC_MUX); + mask |= BIT(CPCAP_BIT_RX_R_ENCODE); + + switch (regval & mask) { + case BIT(CPCAP_BIT_RX_R_ENCODE): + ucontrol->value.enumerated.item[0] = 4; + break; + case BIT(CPCAP_BIT_EMU_MIC_MUX): + ucontrol->value.enumerated.item[0] = 3; + break; + case BIT(CPCAP_BIT_HS_MIC_MUX): + ucontrol->value.enumerated.item[0] = 2; + break; + case BIT(CPCAP_BIT_MIC1_MUX): + ucontrol->value.enumerated.item[0] = 1; + break; + default: + ucontrol->value.enumerated.item[0] = 0; + break; + } + + return 0; +} + +static int cpcap_input_right_mux_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int muxval = ucontrol->value.enumerated.item[0]; + int regval = 0, mask; + int err; + + mask = 0; + mask |= BIT(CPCAP_BIT_MIC1_MUX); + mask |= BIT(CPCAP_BIT_HS_MIC_MUX); + mask |= BIT(CPCAP_BIT_EMU_MIC_MUX); + mask |= BIT(CPCAP_BIT_RX_R_ENCODE); + + switch (muxval) { + case 1: + regval = BIT(CPCAP_BIT_MIC1_MUX); + break; + case 2: + regval = BIT(CPCAP_BIT_HS_MIC_MUX); + break; + case 3: + regval = BIT(CPCAP_BIT_EMU_MIC_MUX); + break; + case 4: + regval = BIT(CPCAP_BIT_RX_R_ENCODE); + break; + default: + break; + } + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI, + mask, regval); + if (err) + return err; + + snd_soc_dapm_mux_update_power(dapm, kcontrol, muxval, e, NULL); + + return 0; +} + +static int cpcap_input_left_mux_get_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + int regval, mask; + int err; + + err = regmap_read(cpcap->regmap, CPCAP_REG_TXI, ®val); + if (err) + return err; + + mask = 0; + mask |= BIT(CPCAP_BIT_MIC2_MUX); + mask |= BIT(CPCAP_BIT_RX_L_ENCODE); + + switch (regval & mask) { + case BIT(CPCAP_BIT_RX_L_ENCODE): + ucontrol->value.enumerated.item[0] = 2; + break; + case BIT(CPCAP_BIT_MIC2_MUX): + ucontrol->value.enumerated.item[0] = 1; + break; + default: + ucontrol->value.enumerated.item[0] = 0; + break; + } + + return 0; +} + +static int cpcap_input_left_mux_put_enum(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_dapm_context *dapm = + snd_soc_dapm_kcontrol_dapm(kcontrol); + struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; + unsigned int muxval = ucontrol->value.enumerated.item[0]; + int regval = 0, mask; + int err; + + mask = 0; + mask |= BIT(CPCAP_BIT_MIC2_MUX); + mask |= BIT(CPCAP_BIT_RX_L_ENCODE); + + switch (muxval) { + case 1: + regval = BIT(CPCAP_BIT_MIC2_MUX); + break; + case 2: + regval = BIT(CPCAP_BIT_RX_L_ENCODE); + break; + default: + break; + } + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_TXI, + mask, regval); + if (err) + return err; + + snd_soc_dapm_mux_update_power(dapm, kcontrol, muxval, e, NULL); + + return 0; +} + +static const struct snd_kcontrol_new cpcap_input_left_mux = + SOC_DAPM_ENUM_EXT("Input Left", cpcap_input_left_mux_enum, + cpcap_input_left_mux_get_enum, + cpcap_input_left_mux_put_enum); +static const struct snd_kcontrol_new cpcap_input_right_mux = + SOC_DAPM_ENUM_EXT("Input Right", cpcap_input_right_mux_enum, + cpcap_input_right_mux_get_enum, + cpcap_input_right_mux_put_enum); +static const struct snd_kcontrol_new cpcap_emu_left_mux = + SOC_DAPM_ENUM_EXT("EMU Left", cpcap_emu_l_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_emu_right_mux = + SOC_DAPM_ENUM_EXT("EMU Right", cpcap_emu_r_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_hs_left_mux = + SOC_DAPM_ENUM_EXT("Headset Left", cpcap_hs_l_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_hs_right_mux = + SOC_DAPM_ENUM_EXT("Headset Right", cpcap_hs_r_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_line_left_mux = + SOC_DAPM_ENUM_EXT("Line Left", cpcap_line_l_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_line_right_mux = + SOC_DAPM_ENUM_EXT("Line Right", cpcap_line_r_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_speaker_left_mux = + SOC_DAPM_ENUM_EXT("Speaker Left", cpcap_spkr_l_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_speaker_right_mux = + SOC_DAPM_ENUM_EXT("Speaker Right", cpcap_spkr_r_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); +static const struct snd_kcontrol_new cpcap_earpiece_mux = + SOC_DAPM_ENUM_EXT("Earpiece", cpcap_earpiece_mux_enum, + cpcap_output_mux_get_enum, cpcap_output_mux_put_enum); + +static const struct snd_kcontrol_new cpcap_hifi_mono_mixer_controls[] = { + SOC_DAPM_SINGLE("HiFi Mono Playback Switch", + CPCAP_REG_RXSDOA, CPCAP_BIT_MONO_DAC1, 1, 0), +}; +static const struct snd_kcontrol_new cpcap_ext_mono_mixer_controls[] = { + SOC_DAPM_SINGLE("Ext Mono Playback Switch", + CPCAP_REG_RXEPOA, CPCAP_BIT_MONO_EXT0, 1, 0), +}; + +static const struct snd_kcontrol_new cpcap_extr_mute_control = + SOC_DAPM_SINGLE("Switch", + CPCAP_REG_RXEPOA, CPCAP_BIT_PGA_IN_R_SW, 1, 0); +static const struct snd_kcontrol_new cpcap_extl_mute_control = + SOC_DAPM_SINGLE("Switch", + CPCAP_REG_RXEPOA, CPCAP_BIT_PGA_IN_L_SW, 1, 0); + +static const struct snd_kcontrol_new cpcap_voice_loopback = + SOC_DAPM_SINGLE("Switch", + CPCAP_REG_TXI, CPCAP_BIT_DLM, 1, 0); + +static const struct snd_soc_dapm_widget cpcap_dapm_widgets[] = { + /* DAIs */ + SND_SOC_DAPM_AIF_IN("HiFi RX", NULL, 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_IN("Voice RX", NULL, 0, SND_SOC_NOPM, 0, 0), + SND_SOC_DAPM_AIF_OUT("Voice TX", NULL, 0, SND_SOC_NOPM, 0, 0), + + /* Power Supply */ + SND_SOC_DAPM_REGULATOR_SUPPLY("VAUDIO", SLEEP_ACTIVATE_POWER, 0), + + /* Highpass Filters */ + SND_SOC_DAPM_REG(snd_soc_dapm_pga, "Highpass Filter RX", + CPCAP_REG_CC, CPCAP_BIT_AUDIHPF_0, 0x3, 0x3, 0x0), + SND_SOC_DAPM_REG(snd_soc_dapm_pga, "Highpass Filter TX", + CPCAP_REG_CC, CPCAP_BIT_AUDOHPF_0, 0x3, 0x3, 0x0), + + /* Clocks */ + SND_SOC_DAPM_SUPPLY("HiFi DAI Clock", + CPCAP_REG_SDACDI, CPCAP_BIT_ST_CLK_EN, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("Voice DAI Clock", + CPCAP_REG_CDI, CPCAP_BIT_CDC_CLK_EN, 0, NULL, 0), + + /* Microphone Bias */ + SND_SOC_DAPM_SUPPLY("MIC1R Bias", + CPCAP_REG_TXI, CPCAP_BIT_MB_ON1R, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MIC1L Bias", + CPCAP_REG_TXI, CPCAP_BIT_MB_ON1L, 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MIC2 Bias", + CPCAP_REG_TXI, CPCAP_BIT_MB_ON2, 0, NULL, 0), + + /* Inputs */ + SND_SOC_DAPM_INPUT("MICR"), + SND_SOC_DAPM_INPUT("HSMIC"), + SND_SOC_DAPM_INPUT("EMUMIC"), + SND_SOC_DAPM_INPUT("MICL"), + SND_SOC_DAPM_INPUT("EXTR"), + SND_SOC_DAPM_INPUT("EXTL"), + + /* Capture Route */ + SND_SOC_DAPM_MUX("Right Capture Route", + SND_SOC_NOPM, 0, 0, &cpcap_input_right_mux), + SND_SOC_DAPM_MUX("Left Capture Route", + SND_SOC_NOPM, 0, 0, &cpcap_input_left_mux), + + /* Capture PGAs */ + SND_SOC_DAPM_PGA("Microphone 1 PGA", + CPCAP_REG_TXI, CPCAP_BIT_MIC1_PGA_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Microphone 2 PGA", + CPCAP_REG_TXI, CPCAP_BIT_MIC2_PGA_EN, 0, NULL, 0), + + /* ADC */ + SND_SOC_DAPM_ADC("ADC Right", NULL, + CPCAP_REG_CC, CPCAP_BIT_MIC1_CDC_EN, 0), + SND_SOC_DAPM_ADC("ADC Left", NULL, + CPCAP_REG_CC, CPCAP_BIT_MIC2_CDC_EN, 0), + + /* DAC */ + SND_SOC_DAPM_DAC_E("DAC HiFi", NULL, + CPCAP_REG_SDAC, CPCAP_BIT_ST_DAC_EN, 0, + cpcap_st_workaround, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_DAC_E("DAC Voice", NULL, + CPCAP_REG_CC, CPCAP_BIT_CDC_EN_RX, 0, + cpcap_st_workaround, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), + + /* Playback PGA */ + SND_SOC_DAPM_PGA("HiFi PGA", + CPCAP_REG_RXSDOA, CPCAP_BIT_PGA_DAC_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Voice PGA", + CPCAP_REG_RXCOA, CPCAP_BIT_PGA_CDC_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA_E("Ext Right PGA", + CPCAP_REG_RXEPOA, CPCAP_BIT_PGA_EXT_R_EN, 0, + NULL, 0, + cpcap_st_workaround, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), + SND_SOC_DAPM_PGA_E("Ext Left PGA", + CPCAP_REG_RXEPOA, CPCAP_BIT_PGA_EXT_L_EN, 0, + NULL, 0, + cpcap_st_workaround, + SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU), + + /* Playback Switch */ + SND_SOC_DAPM_SWITCH("Ext Right Enable", SND_SOC_NOPM, 0, 0, + &cpcap_extr_mute_control), + SND_SOC_DAPM_SWITCH("Ext Left Enable", SND_SOC_NOPM, 0, 0, + &cpcap_extl_mute_control), + + /* Loopback Switch */ + SND_SOC_DAPM_SWITCH("Voice Loopback", SND_SOC_NOPM, 0, 0, + &cpcap_voice_loopback), + + /* Mono Mixer */ + SOC_MIXER_ARRAY("HiFi Mono Left Mixer", SND_SOC_NOPM, 0, 0, + cpcap_hifi_mono_mixer_controls), + SOC_MIXER_ARRAY("HiFi Mono Right Mixer", SND_SOC_NOPM, 0, 0, + cpcap_hifi_mono_mixer_controls), + SOC_MIXER_ARRAY("Ext Mono Left Mixer", SND_SOC_NOPM, 0, 0, + cpcap_ext_mono_mixer_controls), + SOC_MIXER_ARRAY("Ext Mono Right Mixer", SND_SOC_NOPM, 0, 0, + cpcap_ext_mono_mixer_controls), + + /* Output Routes */ + SND_SOC_DAPM_MUX("Earpiece Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_earpiece_mux), + SND_SOC_DAPM_MUX("Speaker Right Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_speaker_right_mux), + SND_SOC_DAPM_MUX("Speaker Left Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_speaker_left_mux), + SND_SOC_DAPM_MUX("Lineout Right Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_line_right_mux), + SND_SOC_DAPM_MUX("Lineout Left Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_line_left_mux), + SND_SOC_DAPM_MUX("Headset Right Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_hs_right_mux), + SND_SOC_DAPM_MUX("Headset Left Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_hs_left_mux), + SND_SOC_DAPM_MUX("EMU Right Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_emu_right_mux), + SND_SOC_DAPM_MUX("EMU Left Playback Route", SND_SOC_NOPM, 0, 0, + &cpcap_emu_left_mux), + + /* Output Amplifier */ + SND_SOC_DAPM_PGA("Earpiece PGA", + CPCAP_REG_RXOA, CPCAP_BIT_A1_EAR_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Speaker Right PGA", + CPCAP_REG_RXOA, CPCAP_BIT_A2_LDSP_R_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Speaker Left PGA", + CPCAP_REG_RXOA, CPCAP_BIT_A2_LDSP_L_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Lineout Right PGA", + CPCAP_REG_RXOA, CPCAP_BIT_A4_LINEOUT_R_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Lineout Left PGA", + CPCAP_REG_RXOA, CPCAP_BIT_A4_LINEOUT_L_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Headset Right PGA", + CPCAP_REG_RXOA, CPCAP_BIT_HS_R_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("Headset Left PGA", + CPCAP_REG_RXOA, CPCAP_BIT_HS_L_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("EMU Right PGA", + CPCAP_REG_RXOA, CPCAP_BIT_EMU_SPKR_R_EN, 0, NULL, 0), + SND_SOC_DAPM_PGA("EMU Left PGA", + CPCAP_REG_RXOA, CPCAP_BIT_EMU_SPKR_L_EN, 0, NULL, 0), + + /* Headet Charge Pump */ + SND_SOC_DAPM_SUPPLY("Headset Charge Pump", + CPCAP_REG_RXOA, CPCAP_BIT_ST_HS_CP_EN, 0, NULL, 0), + + /* Outputs */ + SND_SOC_DAPM_OUTPUT("EP"), + SND_SOC_DAPM_OUTPUT("SPKR"), + SND_SOC_DAPM_OUTPUT("SPKL"), + SND_SOC_DAPM_OUTPUT("LINER"), + SND_SOC_DAPM_OUTPUT("LINEL"), + SND_SOC_DAPM_OUTPUT("HSR"), + SND_SOC_DAPM_OUTPUT("HSL"), + SND_SOC_DAPM_OUTPUT("EMUR"), + SND_SOC_DAPM_OUTPUT("EMUL"), +}; + +static const struct snd_soc_dapm_route intercon[] = { + /* Power Supply */ + {"HiFi PGA", NULL, "VAUDIO"}, + {"Voice PGA", NULL, "VAUDIO"}, + {"Ext Right PGA", NULL, "VAUDIO"}, + {"Ext Left PGA", NULL, "VAUDIO"}, + {"Microphone 1 PGA", NULL, "VAUDIO"}, + {"Microphone 2 PGA", NULL, "VAUDIO"}, + + /* Stream -> AIF */ + {"HiFi RX", NULL, "HiFi Playback"}, + {"Voice RX", NULL, "Voice Playback"}, + {"Voice Capture", NULL, "Voice TX"}, + + /* AIF clocks */ + {"HiFi RX", NULL, "HiFi DAI Clock"}, + {"Voice RX", NULL, "Voice DAI Clock"}, + {"Voice TX", NULL, "Voice DAI Clock"}, + + /* Digital Loopback */ + {"Voice Loopback", "Switch", "Voice TX"}, + {"Voice RX", NULL, "Voice Loopback"}, + + /* Highpass Filters */ + {"Highpass Filter RX", NULL, "Voice RX"}, + {"Voice TX", NULL, "Highpass Filter TX"}, + + /* AIF -> DAC mapping */ + {"DAC HiFi", NULL, "HiFi RX"}, + {"DAC Voice", NULL, "Highpass Filter RX"}, + + /* DAC -> PGA */ + {"HiFi PGA", NULL, "DAC HiFi"}, + {"Voice PGA", NULL, "DAC Voice"}, + + /* Ext Input -> PGA */ + {"Ext Right PGA", NULL, "EXTR"}, + {"Ext Left PGA", NULL, "EXTL"}, + + /* Ext PGA -> Ext Playback Switch */ + {"Ext Right Enable", "Switch", "Ext Right PGA"}, + {"Ext Left Enable", "Switch", "Ext Left PGA"}, + + /* HiFi PGA -> Mono Mixer */ + {"HiFi Mono Left Mixer", NULL, "HiFi PGA"}, + {"HiFi Mono Left Mixer", "HiFi Mono Playback Switch", "HiFi PGA"}, + {"HiFi Mono Right Mixer", NULL, "HiFi PGA"}, + {"HiFi Mono Right Mixer", "HiFi Mono Playback Switch", "HiFi PGA"}, + + /* Ext Playback Switch -> Ext Mono Mixer */ + {"Ext Mono Right Mixer", NULL, "Ext Right Enable"}, + {"Ext Mono Right Mixer", "Ext Mono Playback Switch", "Ext Left Enable"}, + {"Ext Mono Left Mixer", NULL, "Ext Left Enable"}, + {"Ext Mono Left Mixer", "Ext Mono Playback Switch", "Ext Right Enable"}, + + /* HiFi Mono Mixer -> Output Route */ + {"Earpiece Playback Route", "HiFi", "HiFi Mono Right Mixer"}, + {"Speaker Right Playback Route", "HiFi", "HiFi Mono Right Mixer"}, + {"Speaker Left Playback Route", "HiFi", "HiFi Mono Left Mixer"}, + {"Lineout Right Playback Route", "HiFi", "HiFi Mono Right Mixer"}, + {"Lineout Left Playback Route", "HiFi", "HiFi Mono Left Mixer"}, + {"Headset Right Playback Route", "HiFi", "HiFi Mono Right Mixer"}, + {"Headset Left Playback Route", "HiFi", "HiFi Mono Left Mixer"}, + {"EMU Right Playback Route", "HiFi", "HiFi Mono Right Mixer"}, + {"EMU Left Playback Route", "HiFi", "HiFi Mono Left Mixer"}, + + /* Voice PGA -> Output Route */ + {"Earpiece Playback Route", "Voice", "Voice PGA"}, + {"Speaker Right Playback Route", "Voice", "Voice PGA"}, + {"Speaker Left Playback Route", "Voice", "Voice PGA"}, + {"Lineout Right Playback Route", "Voice", "Voice PGA"}, + {"Lineout Left Playback Route", "Voice", "Voice PGA"}, + {"Headset Right Playback Route", "Voice", "Voice PGA"}, + {"Headset Left Playback Route", "Voice", "Voice PGA"}, + {"EMU Right Playback Route", "Voice", "Voice PGA"}, + {"EMU Left Playback Route", "Voice", "Voice PGA"}, + + /* Ext Mono Mixer -> Output Route */ + {"Earpiece Playback Route", "Ext", "Ext Mono Right Mixer"}, + {"Speaker Right Playback Route", "Ext", "Ext Mono Right Mixer"}, + {"Speaker Left Playback Route", "Ext", "Ext Mono Left Mixer"}, + {"Lineout Right Playback Route", "Ext", "Ext Mono Right Mixer"}, + {"Lineout Left Playback Route", "Ext", "Ext Mono Left Mixer"}, + {"Headset Right Playback Route", "Ext", "Ext Mono Right Mixer"}, + {"Headset Left Playback Route", "Ext", "Ext Mono Left Mixer"}, + {"EMU Right Playback Route", "Ext", "Ext Mono Right Mixer"}, + {"EMU Left Playback Route", "Ext", "Ext Mono Left Mixer"}, + + /* Output Route -> Output Amplifier */ + {"Earpiece PGA", NULL, "Earpiece Playback Route"}, + {"Speaker Right PGA", NULL, "Speaker Right Playback Route"}, + {"Speaker Left PGA", NULL, "Speaker Left Playback Route"}, + {"Lineout Right PGA", NULL, "Lineout Right Playback Route"}, + {"Lineout Left PGA", NULL, "Lineout Left Playback Route"}, + {"Headset Right PGA", NULL, "Headset Right Playback Route"}, + {"Headset Left PGA", NULL, "Headset Left Playback Route"}, + {"EMU Right PGA", NULL, "EMU Right Playback Route"}, + {"EMU Left PGA", NULL, "EMU Left Playback Route"}, + + /* Output Amplifier -> Output */ + {"EP", NULL, "Earpiece PGA"}, + {"SPKR", NULL, "Speaker Right PGA"}, + {"SPKL", NULL, "Speaker Left PGA"}, + {"LINER", NULL, "Lineout Right PGA"}, + {"LINEL", NULL, "Lineout Left PGA"}, + {"HSR", NULL, "Headset Right PGA"}, + {"HSL", NULL, "Headset Left PGA"}, + {"EMUR", NULL, "EMU Right PGA"}, + {"EMUL", NULL, "EMU Left PGA"}, + + /* Headset Charge Pump -> Headset */ + {"HSR", NULL, "Headset Charge Pump"}, + {"HSL", NULL, "Headset Charge Pump"}, + + /* Mic -> Mic Route */ + {"Right Capture Route", "Mic 1", "MICR"}, + {"Right Capture Route", "Headset Mic", "HSMIC"}, + {"Right Capture Route", "EMU Mic", "EMUMIC"}, + {"Right Capture Route", "Ext Right", "EXTR"}, + {"Left Capture Route", "Mic 2", "MICL"}, + {"Left Capture Route", "Ext Left", "EXTL"}, + + /* Input Route -> Microphone PGA */ + {"Microphone 1 PGA", NULL, "Right Capture Route"}, + {"Microphone 2 PGA", NULL, "Left Capture Route"}, + + /* Microphone PGA -> ADC */ + {"ADC Right", NULL, "Microphone 1 PGA"}, + {"ADC Left", NULL, "Microphone 2 PGA"}, + + /* ADC -> Stream */ + {"Highpass Filter TX", NULL, "ADC Right"}, + {"Highpass Filter TX", NULL, "ADC Left"}, + + /* Mic Bias */ + {"MICL", NULL, "MIC1L Bias"}, + {"MICR", NULL, "MIC1R Bias"}, +}; + +static int cpcap_set_sysclk(struct cpcap_audio *cpcap, enum cpcap_dai dai, + int clk_id, int freq) +{ + u16 clkfreqreg, clkfreqshift; + u16 clkfreqmask, clkfreqval; + u16 clkidreg, clkidshift; + u16 mask, val; + int err; + + switch (dai) { + case CPCAP_DAI_HIFI: + clkfreqreg = CPCAP_REG_SDAC; + clkfreqshift = CPCAP_BIT_ST_DAC_CLK0; + clkidreg = CPCAP_REG_SDACDI; + clkidshift = CPCAP_BIT_ST_DAC_CLK_IN_SEL; + break; + case CPCAP_DAI_VOICE: + clkfreqreg = CPCAP_REG_CC; + clkfreqshift = CPCAP_BIT_CDC_CLK0; + clkidreg = CPCAP_REG_CDI; + clkidshift = CPCAP_BIT_CLK_IN_SEL; + break; + default: + dev_err(cpcap->codec->dev, "invalid DAI: %d", dai); + return -EINVAL; + } + + /* setup clk id */ + if (clk_id < 0 || clk_id > 1) { + dev_err(cpcap->codec->dev, "invalid clk id %d", clk_id); + return -EINVAL; + } + err = regmap_update_bits(cpcap->regmap, clkidreg, BIT(clkidshift), + clk_id ? BIT(clkidshift) : 0); + if (err) + return err; + + /* enable PLL for Voice DAI */ + if (dai == CPCAP_DAI_VOICE) { + mask = BIT(CPCAP_BIT_CDC_PLL_SEL); + val = BIT(CPCAP_BIT_CDC_PLL_SEL); + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI, + mask, val); + if (err) + return err; + } + + /* setup frequency */ + clkfreqmask = 0x7 << clkfreqshift; + switch (freq) { + case 15360000: + clkfreqval = 0x01 << clkfreqshift; + break; + case 16800000: + clkfreqval = 0x02 << clkfreqshift; + break; + case 19200000: + clkfreqval = 0x03 << clkfreqshift; + break; + case 26000000: + clkfreqval = 0x04 << clkfreqshift; + break; + case 33600000: + clkfreqval = 0x05 << clkfreqshift; + break; + case 38400000: + clkfreqval = 0x06 << clkfreqshift; + break; + default: + dev_err(cpcap->codec->dev, "unsupported freq %u", freq); + return -EINVAL; + } + + err = regmap_update_bits(cpcap->regmap, clkfreqreg, + clkfreqmask, clkfreqval); + if (err) + return err; + + if (dai == CPCAP_DAI_VOICE) { + cpcap->codec_clk_id = clk_id; + cpcap->codec_freq = freq; + } + + return 0; +} + +static int cpcap_set_samprate(struct cpcap_audio *cpcap, enum cpcap_dai dai, + int samplerate) +{ + struct snd_soc_codec *codec = cpcap->codec; + u16 sampreg, sampmask, sampshift, sampval, sampreset; + int err, sampreadval; + + switch (dai) { + case CPCAP_DAI_HIFI: + sampreg = CPCAP_REG_SDAC; + sampshift = CPCAP_BIT_ST_SR0; + sampreset = BIT(CPCAP_BIT_DF_RESET_ST_DAC) | + BIT(CPCAP_BIT_ST_CLOCK_TREE_RESET); + break; + case CPCAP_DAI_VOICE: + sampreg = CPCAP_REG_CC; + sampshift = CPCAP_BIT_CDC_SR0; + sampreset = BIT(CPCAP_BIT_DF_RESET) | + BIT(CPCAP_BIT_CDC_CLOCK_TREE_RESET); + break; + default: + dev_err(codec->dev, "invalid DAI: %d", dai); + return -EINVAL; + } + + sampmask = 0xF << sampshift | sampreset; + switch (samplerate) { + case 48000: + sampval = 0x8 << sampshift; + break; + case 44100: + sampval = 0x7 << sampshift; + break; + case 32000: + sampval = 0x6 << sampshift; + break; + case 24000: + sampval = 0x5 << sampshift; + break; + case 22050: + sampval = 0x4 << sampshift; + break; + case 16000: + sampval = 0x3 << sampshift; + break; + case 12000: + sampval = 0x2 << sampshift; + break; + case 11025: + sampval = 0x1 << sampshift; + break; + case 8000: + sampval = 0x0 << sampshift; + break; + default: + dev_err(codec->dev, "unsupported samplerate %d", samplerate); + return -EINVAL; + } + err = regmap_update_bits(cpcap->regmap, sampreg, + sampmask, sampval | sampreset); + if (err) + return err; + + /* Wait for clock tree reset to complete */ + mdelay(CLOCK_TREE_RESET_TIME); + + err = regmap_read(cpcap->regmap, sampreg, &sampreadval); + if (err) + return err; + + if (sampreadval & sampreset) { + dev_err(codec->dev, "reset self-clear failed: %04x", + sampreadval); + return -EIO; + } + + return 0; +} + +static int cpcap_hifi_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + int rate = params_rate(params); + + dev_dbg(codec->dev, "HiFi setup HW params: rate=%d", rate); + return cpcap_set_samprate(cpcap, CPCAP_DAI_HIFI, rate); +} + +static int cpcap_hifi_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, + unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct device *dev = codec->dev; + + dev_dbg(dev, "HiFi setup sysclk: clk_id=%u, freq=%u", clk_id, freq); + return cpcap_set_sysclk(cpcap, CPCAP_DAI_HIFI, clk_id, freq); +} + +static int cpcap_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct device *dev = codec->dev; + static const u16 reg = CPCAP_REG_SDACDI; + static const u16 mask = + BIT(CPCAP_BIT_SMB_ST_DAC) | + BIT(CPCAP_BIT_ST_CLK_INV) | + BIT(CPCAP_BIT_ST_FS_INV) | + BIT(CPCAP_BIT_ST_DIG_AUD_FS0) | + BIT(CPCAP_BIT_ST_DIG_AUD_FS1) | + BIT(CPCAP_BIT_ST_L_TIMESLOT0) | + BIT(CPCAP_BIT_ST_L_TIMESLOT1) | + BIT(CPCAP_BIT_ST_L_TIMESLOT2) | + BIT(CPCAP_BIT_ST_R_TIMESLOT0) | + BIT(CPCAP_BIT_ST_R_TIMESLOT1) | + BIT(CPCAP_BIT_ST_R_TIMESLOT2); + u16 val = 0x0000; + + dev_dbg(dev, "HiFi setup dai format (%08x)", fmt); + + /* + * "HiFi Playback" should always be configured as + * SND_SOC_DAIFMT_CBM_CFM - codec clk & frm master + * SND_SOC_DAIFMT_I2S - I2S mode + */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + val &= ~BIT(CPCAP_BIT_SMB_ST_DAC); + break; + default: + dev_err(dev, "HiFi dai fmt failed: CPCAP should be master"); + return -EINVAL; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_IB_IF: + val |= BIT(CPCAP_BIT_ST_FS_INV); + val |= BIT(CPCAP_BIT_ST_CLK_INV); + break; + case SND_SOC_DAIFMT_IB_NF: + val &= ~BIT(CPCAP_BIT_ST_FS_INV); + val |= BIT(CPCAP_BIT_ST_CLK_INV); + break; + case SND_SOC_DAIFMT_NB_IF: + val |= BIT(CPCAP_BIT_ST_FS_INV); + val &= ~BIT(CPCAP_BIT_ST_CLK_INV); + break; + case SND_SOC_DAIFMT_NB_NF: + val &= ~BIT(CPCAP_BIT_ST_FS_INV); + val &= ~BIT(CPCAP_BIT_ST_CLK_INV); + break; + default: + dev_err(dev, "HiFi dai fmt failed: unsupported clock invert mode"); + return -EINVAL; + } + + if (val & BIT(CPCAP_BIT_ST_CLK_INV)) + val &= ~BIT(CPCAP_BIT_ST_CLK_INV); + else + val |= BIT(CPCAP_BIT_ST_CLK_INV); + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + val |= BIT(CPCAP_BIT_ST_DIG_AUD_FS0); + val |= BIT(CPCAP_BIT_ST_DIG_AUD_FS1); + break; + default: + /* 01 - 4 slots network mode */ + val |= BIT(CPCAP_BIT_ST_DIG_AUD_FS0); + val &= ~BIT(CPCAP_BIT_ST_DIG_AUD_FS1); + /* L on slot 1 */ + val |= BIT(CPCAP_BIT_ST_L_TIMESLOT0); + break; + } + + dev_dbg(dev, "HiFi dai format: val=%04x", val); + return regmap_update_bits(cpcap->regmap, reg, mask, val); +} + +static int cpcap_hifi_set_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + static const u16 reg = CPCAP_REG_RXSDOA; + static const u16 mask = BIT(CPCAP_BIT_ST_DAC_SW); + u16 val; + + if (mute) + val = 0; + else + val = BIT(CPCAP_BIT_ST_DAC_SW); + + dev_dbg(codec->dev, "HiFi mute: %d", mute); + return regmap_update_bits(cpcap->regmap, reg, mask, val); +} + +static const struct snd_soc_dai_ops cpcap_dai_hifi_ops = { + .hw_params = cpcap_hifi_hw_params, + .set_sysclk = cpcap_hifi_set_dai_sysclk, + .set_fmt = cpcap_hifi_set_dai_fmt, + .digital_mute = cpcap_hifi_set_mute, +}; + +static int cpcap_voice_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + struct snd_soc_codec *codec = dai->codec; + struct device *dev = codec->dev; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + static const u16 reg_cdi = CPCAP_REG_CDI; + int rate = params_rate(params); + int channels = params_channels(params); + int direction = substream->stream; + u16 val, mask; + int err; + + dev_dbg(dev, "Voice setup HW params: rate=%d, direction=%d, chan=%d", + rate, direction, channels); + + err = cpcap_set_samprate(cpcap, CPCAP_DAI_VOICE, rate); + if (err) + return err; + + if (direction == SNDRV_PCM_STREAM_CAPTURE) { + mask = 0x0000; + mask |= CPCAP_BIT_MIC1_RX_TIMESLOT0; + mask |= CPCAP_BIT_MIC1_RX_TIMESLOT1; + mask |= CPCAP_BIT_MIC1_RX_TIMESLOT2; + mask |= CPCAP_BIT_MIC2_TIMESLOT0; + mask |= CPCAP_BIT_MIC2_TIMESLOT1; + mask |= CPCAP_BIT_MIC2_TIMESLOT2; + val = 0x0000; + if (channels >= 2) + val = BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0); + err = regmap_update_bits(cpcap->regmap, reg_cdi, mask, val); + if (err) + return err; + } + + return 0; +} + +static int cpcap_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, + unsigned int freq, int dir) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + + dev_dbg(codec->dev, "Voice setup sysclk: clk_id=%u, freq=%u", + clk_id, freq); + return cpcap_set_sysclk(cpcap, CPCAP_DAI_VOICE, clk_id, freq); +} + +static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int fmt) +{ + struct snd_soc_codec *codec = codec_dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + static const u16 mask = BIT(CPCAP_BIT_SMB_CDC) | + BIT(CPCAP_BIT_CLK_INV) | + BIT(CPCAP_BIT_FS_INV) | + BIT(CPCAP_BIT_CDC_DIG_AUD_FS0) | + BIT(CPCAP_BIT_CDC_DIG_AUD_FS1); + u16 val = 0x0000; + int err; + + dev_dbg(codec->dev, "Voice setup dai format (%08x)", fmt); + + /* + * "Voice Playback" and "Voice Capture" should always be + * configured as SND_SOC_DAIFMT_CBM_CFM - codec clk & frm + * master + */ + switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { + case SND_SOC_DAIFMT_CBM_CFM: + val &= ~BIT(CPCAP_BIT_SMB_CDC); + break; + default: + dev_err(codec->dev, "Voice dai fmt failed: CPCAP should be the master"); + val &= ~BIT(CPCAP_BIT_SMB_CDC); + break; + } + + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_IB_IF: + val |= BIT(CPCAP_BIT_CLK_INV); + val |= BIT(CPCAP_BIT_FS_INV); + break; + case SND_SOC_DAIFMT_IB_NF: + val |= BIT(CPCAP_BIT_CLK_INV); + val &= ~BIT(CPCAP_BIT_FS_INV); + break; + case SND_SOC_DAIFMT_NB_IF: + val &= ~BIT(CPCAP_BIT_CLK_INV); + val |= BIT(CPCAP_BIT_FS_INV); + break; + case SND_SOC_DAIFMT_NB_NF: + val &= ~BIT(CPCAP_BIT_CLK_INV); + val &= ~BIT(CPCAP_BIT_FS_INV); + break; + default: + dev_err(codec->dev, "Voice dai fmt failed: unsupported clock invert mode"); + break; + } + + if (val & BIT(CPCAP_BIT_CLK_INV)) + val &= ~BIT(CPCAP_BIT_CLK_INV); + else + val |= BIT(CPCAP_BIT_CLK_INV); + + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + /* 11 - true I2S mode */ + val |= BIT(CPCAP_BIT_CDC_DIG_AUD_FS0); + val |= BIT(CPCAP_BIT_CDC_DIG_AUD_FS1); + break; + default: + /* 4 timeslots network mode */ + val |= BIT(CPCAP_BIT_CDC_DIG_AUD_FS0); + val &= ~BIT(CPCAP_BIT_CDC_DIG_AUD_FS1); + break; + } + + dev_dbg(codec->dev, "Voice dai format: val=%04x", val); + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI, mask, val); + if (err) + return err; + + cpcap->codec_format = val; + return 0; +} + +static int cpcap_voice_set_mute(struct snd_soc_dai *dai, int mute) +{ + struct snd_soc_codec *codec = dai->codec; + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + static const u16 reg = CPCAP_REG_RXCOA; + static const u16 mask = BIT(CPCAP_BIT_CDC_SW); + u16 val; + + if (mute) + val = 0; + else + val = BIT(CPCAP_BIT_CDC_SW); + + dev_dbg(codec->dev, "Voice mute: %d", mute); + return regmap_update_bits(cpcap->regmap, reg, mask, val); +}; + +static const struct snd_soc_dai_ops cpcap_dai_voice_ops = { + .hw_params = cpcap_voice_hw_params, + .set_sysclk = cpcap_voice_set_dai_sysclk, + .set_fmt = cpcap_voice_set_dai_fmt, + .digital_mute = cpcap_voice_set_mute, +}; + +static struct snd_soc_dai_driver cpcap_dai[] = { +{ + .id = 0, + .name = "cpcap-hifi", + .playback = { + .stream_name = "HiFi Playback", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE, + }, + .ops = &cpcap_dai_hifi_ops, +}, +{ + .id = 1, + .name = "cpcap-voice", + .playback = { + .stream_name = "Voice Playback", + .channels_min = 1, + .channels_max = 1, + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .capture = { + .stream_name = "Voice Capture", + .channels_min = 1, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_8000_48000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, + .ops = &cpcap_dai_voice_ops, +}, +}; + +static int cpcap_dai_mux(struct cpcap_audio *cpcap, bool swap_dai_configuration) +{ + u16 hifi_val, voice_val; + u16 hifi_mask = BIT(CPCAP_BIT_DIG_AUD_IN_ST_DAC); + u16 voice_mask = BIT(CPCAP_BIT_DIG_AUD_IN); + int err; + + + + if (!swap_dai_configuration) { + /* Codec on DAI0, HiFi on DAI1 */ + voice_val = 0; + hifi_val = hifi_mask; + } else { + /* Codec on DAI1, HiFi on DAI0 */ + voice_val = voice_mask; + hifi_val = 0; + } + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI, + voice_mask, voice_val); + if (err) + return err; + + err = regmap_update_bits(cpcap->regmap, CPCAP_REG_SDACDI, + hifi_mask, hifi_val); + if (err) + return err; + + return 0; +} + +static int cpcap_audio_reset(struct snd_soc_codec *codec, + bool swap_dai_configuration) +{ + struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + int i, err = 0; + + dev_dbg(codec->dev, "init audio codec"); + + for (i = 0; i < ARRAY_SIZE(cpcap_default_regs); i++) { + err = regmap_update_bits(cpcap->regmap, + cpcap_default_regs[i].reg, + cpcap_default_regs[i].mask, + cpcap_default_regs[i].val); + if (err) + return err; + } + + /* setup default settings */ + err = cpcap_dai_mux(cpcap, swap_dai_configuration); + if (err) + return err; + + err = cpcap_set_sysclk(cpcap, CPCAP_DAI_HIFI, 0, 26000000); + if (err) + return err; + err = cpcap_set_sysclk(cpcap, CPCAP_DAI_VOICE, 0, 26000000); + if (err) + return err; + + err = cpcap_set_samprate(cpcap, CPCAP_DAI_HIFI, 48000); + if (err) + return err; + + err = cpcap_set_samprate(cpcap, CPCAP_DAI_VOICE, 48000); + if (err) + return err; + + return 0; +} + +static int cpcap_soc_probe(struct snd_soc_codec *codec) +{ + struct cpcap_audio *cpcap; + int err; + + cpcap = devm_kzalloc(codec->dev, sizeof(*cpcap), GFP_KERNEL); + if (!cpcap) + return -ENOMEM; + snd_soc_codec_set_drvdata(codec, cpcap); + cpcap->codec = codec; + + cpcap->regmap = dev_get_regmap(codec->dev->parent, NULL); + if (!cpcap->regmap) + return -ENODEV; + snd_soc_codec_init_regmap(codec, cpcap->regmap); + + err = cpcap_get_vendor(codec->dev, cpcap->regmap, &cpcap->vendor); + if (err) + return err; + + return cpcap_audio_reset(codec, false); +} + +static struct snd_soc_codec_driver soc_codec_dev_cpcap = { + .probe = cpcap_soc_probe, + + .component_driver = { + .controls = cpcap_snd_controls, + .num_controls = ARRAY_SIZE(cpcap_snd_controls), + .dapm_widgets = cpcap_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cpcap_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + }, +}; + +static int cpcap_codec_probe(struct platform_device *pdev) +{ + struct device_node *codec_node = + of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec"); + + pdev->dev.of_node = codec_node; + + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cpcap, + cpcap_dai, ARRAY_SIZE(cpcap_dai)); +} + +static int cpcap_codec_remove(struct platform_device *pdev) +{ + snd_soc_unregister_codec(&pdev->dev); + return 0; +} + +static struct platform_driver cpcap_codec_driver = { + .probe = cpcap_codec_probe, + .remove = cpcap_codec_remove, + .driver = { + .name = "cpcap-codec", + }, +}; +module_platform_driver(cpcap_codec_driver); + +MODULE_ALIAS("platform:cpcap-codec"); +MODULE_DESCRIPTION("ASoC CPCAP codec driver"); +MODULE_AUTHOR("Sebastian Reichel"); +MODULE_LICENSE("GPL v2"); From 084a804e01205bcd74cd0849bc72cb5c88f8e648 Mon Sep 17 00:00:00 2001 From: Roger Quadros Date: Tue, 27 Feb 2018 12:41:41 +0200 Subject: [PATCH 384/942] usb: dwc3: Fix lock-up on ID change during system suspend/resume To reproduce the lock up do the following - connect otg host adapter and a USB device to the dual-role port so that it is in host mode. - suspend to mem. - disconnect otg adapter. - resume the system. If we call dwc3_host_exit() before tasks are thawed xhci_plat_remove() seems to lock up at the second usb_remove_hcd() call. To work around this we queue the _dwc3_set_mode() work on the system_freezable_wq. Fixes: 41ce1456e1db ("usb: dwc3: core: make dwc3_set_mode() work properly") Cc: # v4.12+ Suggested-by: Manu Gautam Signed-off-by: Roger Quadros Signed-off-by: Felipe Balbi --- drivers/usb/dwc3/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index f1d838a4acd6..e94bf91cc58a 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -175,7 +175,7 @@ void dwc3_set_mode(struct dwc3 *dwc, u32 mode) dwc->desired_dr_role = mode; spin_unlock_irqrestore(&dwc->lock, flags); - queue_work(system_power_efficient_wq, &dwc->drd_work); + queue_work(system_freezable_wq, &dwc->drd_work); } u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type) From 28b0f8a6962a24ed21737578f3b1b07424635c9e Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Tue, 13 Feb 2018 07:38:08 -0800 Subject: [PATCH 385/942] tty: make n_tty_read() always abort if hangup is in progress A tty is hung up by __tty_hangup() setting file->f_op to hung_up_tty_fops, which is skipped on ttys whose write operation isn't tty_write(). This means that, for example, /dev/console whose write op is redirected_tty_write() is never actually marked hung up. Because n_tty_read() uses the hung up status to decide whether to abort the waiting readers, the lack of hung-up marking can lead to the following scenario. 1. A session contains two processes. The leader and its child. The child ignores SIGHUP. 2. The leader exits and starts disassociating from the controlling terminal (/dev/console). 3. __tty_hangup() skips setting f_op to hung_up_tty_fops. 4. SIGHUP is delivered and ignored. 5. tty_ldisc_hangup() is invoked. It wakes up the waits which should clear the read lockers of tty->ldisc_sem. 6. The reader wakes up but because tty_hung_up_p() is false, it doesn't abort and goes back to sleep while read-holding tty->ldisc_sem. 7. The leader progresses to tty_ldisc_lock() in tty_ldisc_hangup() and is now stuck in D sleep indefinitely waiting for tty->ldisc_sem. The following is Alan's explanation on why some ttys aren't hung up. http://lkml.kernel.org/r/20171101170908.6ad08580@alans-desktop 1. It broke the serial consoles because they would hang up and close down the hardware. With tty_port that *should* be fixable properly for any cases remaining. 2. The console layer was (and still is) completely broken and doens't refcount properly. So if you turn on console hangups it breaks (as indeed does freeing consoles and half a dozen other things). As neither can be fixed quickly, this patch works around the problem by introducing a new flag, TTY_HUPPING, which is used solely to tell n_tty_read() that hang-up is in progress for the console and the readers should be aborted regardless of the hung-up status of the device. The following is a sample hung task warning caused by this issue. INFO: task agetty:2662 blocked for more than 120 seconds. Not tainted 4.11.3-dbg-tty-lockup-02478-gfd6c7ee-dirty #28 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. 0 2662 1 0x00000086 Call Trace: __schedule+0x267/0x890 schedule+0x36/0x80 schedule_timeout+0x23c/0x2e0 ldsem_down_write+0xce/0x1f6 tty_ldisc_lock+0x16/0x30 tty_ldisc_hangup+0xb3/0x1b0 __tty_hangup+0x300/0x410 disassociate_ctty+0x6c/0x290 do_exit+0x7ef/0xb00 do_group_exit+0x3f/0xa0 get_signal+0x1b3/0x5d0 do_signal+0x28/0x660 exit_to_usermode_loop+0x46/0x86 do_syscall_64+0x9c/0xb0 entry_SYSCALL64_slow_path+0x25/0x25 The following is the repro. Run "$PROG /dev/console". The parent process hangs in D state. #include #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { struct sigaction sact = { .sa_handler = SIG_IGN }; struct timespec ts1s = { .tv_sec = 1 }; pid_t pid; int fd; if (argc < 2) { fprintf(stderr, "test-hung-tty /dev/$TTY\n"); return 1; } /* fork a child to ensure that it isn't already the session leader */ pid = fork(); if (pid < 0) { perror("fork"); return 1; } if (pid > 0) { /* top parent, wait for everyone */ while (waitpid(-1, NULL, 0) >= 0) ; if (errno != ECHILD) perror("waitpid"); return 0; } /* new session, start a new session and set the controlling tty */ if (setsid() < 0) { perror("setsid"); return 1; } fd = open(argv[1], O_RDWR); if (fd < 0) { perror("open"); return 1; } if (ioctl(fd, TIOCSCTTY, 1) < 0) { perror("ioctl"); return 1; } /* fork a child, sleep a bit and exit */ pid = fork(); if (pid < 0) { perror("fork"); return 1; } if (pid > 0) { nanosleep(&ts1s, NULL); printf("Session leader exiting\n"); exit(0); } /* * The child ignores SIGHUP and keeps reading from the controlling * tty. Because SIGHUP is ignored, the child doesn't get killed on * parent exit and the bug in n_tty makes the read(2) block the * parent's control terminal hangup attempt. The parent ends up in * D sleep until the child is explicitly killed. */ sigaction(SIGHUP, &sact, NULL); printf("Child reading tty\n"); while (1) { char buf[1024]; if (read(fd, buf, sizeof(buf)) < 0) { perror("read"); return 1; } } return 0; } Signed-off-by: Tejun Heo Cc: Alan Cox Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/tty/n_tty.c | 6 ++++++ drivers/tty/tty_io.c | 9 +++++++++ include/linux/tty.h | 1 + 3 files changed, 16 insertions(+) diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 5c0e59e8fe46..cbe98bc2b998 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -2180,6 +2180,12 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, } if (tty_hung_up_p(file)) break; + /* + * Abort readers for ttys which never actually + * get hung up. See __tty_hangup(). + */ + if (test_bit(TTY_HUPPING, &tty->flags)) + break; if (!timeout) break; if (file->f_flags & O_NONBLOCK) { diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index eb9133b472f4..63114ea35ec1 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -586,6 +586,14 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session) return; } + /* + * Some console devices aren't actually hung up for technical and + * historical reasons, which can lead to indefinite interruptible + * sleep in n_tty_read(). The following explicitly tells + * n_tty_read() to abort readers. + */ + set_bit(TTY_HUPPING, &tty->flags); + /* inuse_filps is protected by the single tty lock, this really needs to change if we want to flush the workqueue with the lock held */ @@ -640,6 +648,7 @@ static void __tty_hangup(struct tty_struct *tty, int exit_session) * from the ldisc side, which is now guaranteed. */ set_bit(TTY_HUPPED, &tty->flags); + clear_bit(TTY_HUPPING, &tty->flags); tty_unlock(tty); if (f) diff --git a/include/linux/tty.h b/include/linux/tty.h index 0a6c71e0ad01..47f8af22f216 100644 --- a/include/linux/tty.h +++ b/include/linux/tty.h @@ -364,6 +364,7 @@ struct tty_file_private { #define TTY_PTY_LOCK 16 /* pty private */ #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ #define TTY_HUPPED 18 /* Post driver->hangup() */ +#define TTY_HUPPING 19 /* Hangup in progress */ #define TTY_LDISC_HALTED 22 /* Line discipline is halted */ /* Values for tty->flow_change */ From fd63a8903a2c40425a9811c3371dd4d0f42c0ad3 Mon Sep 17 00:00:00 2001 From: Jonas Danielsson Date: Mon, 29 Jan 2018 12:39:15 +0100 Subject: [PATCH 386/942] tty/serial: atmel: add new version check for usart On our at91sam9260 based board the usart0 and usart1 ports report their versions (ATMEL_US_VERSION) as 0x10302. This version is not included in the current checks in the driver. Signed-off-by: Jonas Danielsson Acked-by: Richard Genoud Acked-by: Nicolas Ferre Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/atmel_serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index df46a9e88c34..e287fe8f10fc 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c @@ -1734,6 +1734,7 @@ static void atmel_get_ip_name(struct uart_port *port) switch (version) { case 0x302: case 0x10213: + case 0x10302: dev_dbg(port->dev, "This version is usart\n"); atmel_port->has_frac_baudrate = true; atmel_port->has_hw_timer = true; From e7f3e99cb1a667d04d60d02957fbed58b50d4e5a Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Fri, 2 Feb 2018 20:39:13 +0200 Subject: [PATCH 387/942] serial: 8250_pci: Don't fail on multiport card class Do not fail on multiport cards in serial_pci_is_class_communication(). It restores behaviour for SUNIX multiport cards, that enumerated by class and have a custom board data. Moreover it allows users to reenumerate port-by-port from user space. Fixes: 7d8905d06405 ("serial: 8250_pci: Enable device after we check black list") Reported-by: Nikola Ciprich Signed-off-by: Andy Shevchenko Tested-by: Nikola Ciprich Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_pci.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 54adf8d56350..d580625acc79 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -3387,11 +3387,9 @@ static int serial_pci_is_class_communication(struct pci_dev *dev) /* * If it is not a communications device or the programming * interface is greater than 6, give up. - * - * (Should we try to make guesses for multiport serial devices - * later?) */ if ((((dev->class >> 8) != PCI_CLASS_COMMUNICATION_SERIAL) && + ((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MULTISERIAL) && ((dev->class >> 8) != PCI_CLASS_COMMUNICATION_MODEM)) || (dev->class & 0xff) > 6) return -ENODEV; @@ -3428,6 +3426,12 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) { int num_iomem, num_port, first_port = -1, i; + /* + * Should we try to make guesses for multiport serial devices later? + */ + if ((dev->class >> 8) == PCI_CLASS_COMMUNICATION_MULTISERIAL) + return -ENODEV; + num_iomem = num_port = 0; for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { if (pci_resource_flags(dev, i) & IORESOURCE_IO) { From 714569064adee3c114a2a6490735b94abe269068 Mon Sep 17 00:00:00 2001 From: Sebastian Andrzej Siewior Date: Sat, 3 Feb 2018 12:27:23 +0100 Subject: [PATCH 388/942] serial: core: mark port as initialized in autoconfig This is a followup on 44117a1d1732 ("serial: core: mark port as initialized after successful IRQ change"). Nikola has been using autoconfig via setserial and reported a crash similar to what I fixed in the earlier mentioned commit. Here I do the same fixup for the autoconfig. I wasn't sure that this is the right approach. Nikola confirmed that it fixes his crash. Fixes: b3b576461864 ("tty: serial_core: convert uart_open to use tty_port_open") Link: http://lkml.kernel.org/r/20180131072000.GD1853@localhost.localdomain Reported-by: Nikola Ciprich Tested-by: Nikola Ciprich Cc: Signed-off-by: Sebastian Andrzej Siewior Tested-by: Nikola Ciprich Acked-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/serial_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index c8dde56b532b..35b9201db3b4 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1144,6 +1144,8 @@ static int uart_do_autoconfig(struct tty_struct *tty,struct uart_state *state) uport->ops->config_port(uport, flags); ret = uart_startup(tty, state, 1); + if (ret == 0) + tty_port_set_initialized(port, true); if (ret > 0) ret = 0; } From 1f66dd36bb18437397ea0d7882c52f7e3c476e15 Mon Sep 17 00:00:00 2001 From: Greentime Hu Date: Tue, 13 Feb 2018 17:09:08 +0800 Subject: [PATCH 389/942] earlycon: add reg-offset to physical address before mapping It will get the wrong virtual address because port->mapbase is not added the correct reg-offset yet. We have to update it before earlycon_map() is called Signed-off-by: Greentime Hu Acked-by: Arnd Bergmann Cc: Peter Hurley Cc: stable@vger.kernel.org Fixes: 088da2a17619 ("of: earlycon: Initialize port fields from DT properties") Acked-by: Rob Herring Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/earlycon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index 870e84fb6e39..a24278380fec 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c @@ -245,11 +245,12 @@ int __init of_setup_earlycon(const struct earlycon_id *match, } port->mapbase = addr; port->uartclk = BASE_BAUD * 16; - port->membase = earlycon_map(port->mapbase, SZ_4K); val = of_get_flat_dt_prop(node, "reg-offset", NULL); if (val) port->mapbase += be32_to_cpu(*val); + port->membase = earlycon_map(port->mapbase, SZ_4K); + val = of_get_flat_dt_prop(node, "reg-shift", NULL); if (val) port->regshift = be32_to_cpu(*val); From 9f2068f35729948bde84d87a40d135015911345d Mon Sep 17 00:00:00 2001 From: Nikola Ciprich Date: Tue, 13 Feb 2018 15:04:46 +0100 Subject: [PATCH 390/942] serial: 8250_pci: Add Brainboxes UC-260 4 port serial device Add PCI ids for two variants of Brainboxes UC-260 quad port PCI serial cards. Suggested-by: Andy Shevchenko Signed-off-by: Nikola Ciprich Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/8250/8250_pci.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index d580625acc79..a93f77ab3da0 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c @@ -4702,6 +4702,17 @@ static const struct pci_device_id serial_pci_tbl[] = { { PCI_VENDOR_ID_INTASHIELD, PCI_DEVICE_ID_INTASHIELD_IS400, PCI_ANY_ID, PCI_ANY_ID, 0, 0, /* 135a.0dc0 */ pbn_b2_4_115200 }, + /* + * BrainBoxes UC-260 + */ + { PCI_VENDOR_ID_INTASHIELD, 0x0D21, + PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, + pbn_b2_4_115200 }, + { PCI_VENDOR_ID_INTASHIELD, 0x0E34, + PCI_ANY_ID, PCI_ANY_ID, + PCI_CLASS_COMMUNICATION_MULTISERIAL << 8, 0xffff00, + pbn_b2_4_115200 }, /* * Perle PCI-RAS cards */ From 7842055bfce4bf0170d0f61df8b2add8399697be Mon Sep 17 00:00:00 2001 From: Ulrich Hecht Date: Thu, 15 Feb 2018 13:02:27 +0100 Subject: [PATCH 391/942] serial: sh-sci: prevent lockup on full TTY buffers When the TTY buffers fill up to the configured maximum, a system lockup occurs: [ 598.820128] INFO: rcu_preempt detected stalls on CPUs/tasks: [ 598.825796] 0-...!: (1 GPs behind) idle=5a6/2/0 softirq=1974/1974 fqs=1 [ 598.832577] (detected by 3, t=62517 jiffies, g=296, c=295, q=126) [ 598.838755] Task dump for CPU 0: [ 598.841977] swapper/0 R running task 0 0 0 0x00000022 [ 598.849023] Call trace: [ 598.851476] __switch_to+0x98/0xb0 [ 598.854870] (null) This can be prevented by doing a dummy read of the RX data register. This issue affects both HSCIF and SCIF ports. Reported for R-Car H3 ES2.0; reproduced and fixed on H3 ES1.1. Probably affects other R-Car platforms as well. Reported-by: Yoshihiro Shimoda Signed-off-by: Ulrich Hecht Reviewed-by: Geert Uytterhoeven Cc: stable Tested-by: Nguyen Viet Dung Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/sh-sci.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index 7257c078e155..44adf9db38f8 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c @@ -885,6 +885,8 @@ static void sci_receive_chars(struct uart_port *port) /* Tell the rest of the system the news. New characters! */ tty_flip_buffer_push(tport); } else { + /* TTY buffers full; read from RX reg to prevent lockup */ + serial_port_in(port, SCxRDR); serial_port_in(port, SCxSR); /* dummy read */ sci_clear_SCxSR(port, SCxSR_RDxF_CLEAR(port)); } From 5d7f77ec72d10c421bc33958f06a5583f2d27ed6 Mon Sep 17 00:00:00 2001 From: phil eichinger Date: Mon, 19 Feb 2018 10:24:15 +0100 Subject: [PATCH 392/942] serial: imx: fix bogus dev_err MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only one of the two is really required, not both: * have_rtscts or * have_rtsgpio In imx_rs485_config() this is done correctly, so RS485 is working, just the error message is false. Signed-off-by: Phil Eichinger Reviewed-by: Fabio Estevam Fixes: b8f3bff057b0 ("serial: imx: Support common rs485 binding for RTS polarity" Acked-by: Uwe Kleine-König Signed-off-by: Greg Kroah-Hartman --- drivers/tty/serial/imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 1d7ca382bc12..a33c685af990 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -2093,7 +2093,7 @@ static int serial_imx_probe(struct platform_device *pdev) uart_get_rs485_mode(&pdev->dev, &sport->port.rs485); if (sport->port.rs485.flags & SER_RS485_ENABLED && - (!sport->have_rtscts || !sport->have_rtsgpio)) + (!sport->have_rtscts && !sport->have_rtsgpio)) dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); imx_rs485_config(&sport->port, &sport->port.rs485); From b8b549eec8187ac1b12075d69a2d84d89b5e811a Mon Sep 17 00:00:00 2001 From: Steffen Klassert Date: Wed, 28 Feb 2018 09:23:19 +0100 Subject: [PATCH 393/942] xfrm: Fix ESN sequence number handling for IPsec GSO packets. When IPsec offloading was introduced, we accidentally incremented the sequence number counter on the xfrm_state by one packet too much in the ESN case. This leads to a sequence number gap of one packet after each GSO packet. Fix this by setting the sequence number to the correct value. Fixes: d7dbefc45cf5 ("xfrm: Add xfrm_replay_overflow functions for offloading") Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_replay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c index 1d38c6acf8af..9e3a5e85f828 100644 --- a/net/xfrm/xfrm_replay.c +++ b/net/xfrm/xfrm_replay.c @@ -660,7 +660,7 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff } else { XFRM_SKB_CB(skb)->seq.output.low = oseq + 1; XFRM_SKB_CB(skb)->seq.output.hi = oseq_hi; - xo->seq.low = oseq = oseq + 1; + xo->seq.low = oseq + 1; xo->seq.hi = oseq_hi; oseq += skb_shinfo(skb)->gso_segs; } From 6f5062773747b3d3eb9f957030ac1be98e983ac2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:38 +0100 Subject: [PATCH 394/942] ASoC: Intel: sst: Fix error-code check in sst_pause_stream() The value returned by sst_prepare_and_post_msg() is a negated SST_ERR_* value, so we must check for -SST_ERR_INVALID_STREAM_ID. Note that sst_pause_resume() already has the correct check. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index 7ee6aeb7e0af..b082b0922a7a 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -253,7 +253,7 @@ int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) if (retval == 0) { str_info->prev = str_info->status; str_info->status = STREAM_PAUSED; - } else if (retval == SST_ERR_INVALID_STREAM_ID) { + } else if (retval == -SST_ERR_INVALID_STREAM_ID) { retval = -EINVAL; mutex_lock(&sst_drv_ctx->sst_lock); sst_clean_stream(str_info); From bd47469c9985b50831a55bdda5a36f4672452764 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:39 +0100 Subject: [PATCH 395/942] ASoC: Intel: sst: Remove 2 unused members from stream_info struct Remove the unused ops and str_id members from the stream_info struct. While at it also remove some kernel-doc comments for members which have already been removed in the past. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 7 ------- sound/soc/intel/atom/sst/sst_pvt.c | 1 - 2 files changed, 8 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index e02e2b4cc08f..1f3107909044 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -181,21 +181,15 @@ struct sst_block { * * @status : stream current state * @prev : stream prev state - * @ops : stream operation pb/cp/drm... - * @bufs: stream buffer list * @lock : stream mutex for protecting state * @pcm_substream : PCM substream * @period_elapsed : PCM period elapsed callback * @sfreq : stream sampling freq - * @str_type : stream type * @cumm_bytes : cummulative bytes decoded - * @str_type : stream type - * @src : stream source */ struct stream_info { unsigned int status; unsigned int prev; - unsigned int ops; struct mutex lock; void *pcm_substream; @@ -212,7 +206,6 @@ struct stream_info { unsigned int num_ch; unsigned int pipe_id; - unsigned int str_id; unsigned int task_id; }; diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c index b1e6b8f34a6a..d7d38b0f68db 100644 --- a/sound/soc/intel/atom/sst/sst_pvt.c +++ b/sound/soc/intel/atom/sst/sst_pvt.c @@ -365,7 +365,6 @@ void sst_init_stream(struct stream_info *stream, { stream->status = STREAM_INIT; stream->prev = STREAM_UN_INIT; - stream->ops = ops; } int sst_validate_strid( From 8cf732bbd8d6bc9a28ac48c7bac0ccc9f55cb151 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:40 +0100 Subject: [PATCH 396/942] ASoC: Intel: sst: Remove unnecessary sst_init_stream() function sst_init_stream() has only one caller and all its function arguments are unused. Inline it on the one call site and remove it. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 2 -- sound/soc/intel/atom/sst/sst_pvt.c | 7 ------- sound/soc/intel/atom/sst/sst_stream.c | 5 ++--- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index 1f3107909044..164b0f674c20 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -494,8 +494,6 @@ int sst_prepare_and_post_msg(struct intel_sst_drv *sst, void sst_process_pending_msg(struct work_struct *work); int sst_assign_pvt_id(struct intel_sst_drv *sst_drv_ctx); -void sst_init_stream(struct stream_info *stream, - int codec, int sst_id, int ops, u8 slot); int sst_validate_strid(struct intel_sst_drv *sst_drv_ctx, int str_id); struct stream_info *get_stream_info(struct intel_sst_drv *sst_drv_ctx, int str_id); diff --git a/sound/soc/intel/atom/sst/sst_pvt.c b/sound/soc/intel/atom/sst/sst_pvt.c index d7d38b0f68db..af93244b4868 100644 --- a/sound/soc/intel/atom/sst/sst_pvt.c +++ b/sound/soc/intel/atom/sst/sst_pvt.c @@ -360,13 +360,6 @@ int sst_assign_pvt_id(struct intel_sst_drv *drv) return local; } -void sst_init_stream(struct stream_info *stream, - int codec, int sst_id, int ops, u8 slot) -{ - stream->status = STREAM_INIT; - stream->prev = STREAM_UN_INIT; -} - int sst_validate_strid( struct intel_sst_drv *sst_drv_ctx, int str_id) { diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index b082b0922a7a..7cf5dd1993bc 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -83,6 +83,8 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) pipe_id = str_params->device_type; task_id = str_params->task; + sst_drv_ctx->streams[str_id].status = STREAM_INIT; + sst_drv_ctx->streams[str_id].prev = STREAM_UN_INIT; sst_drv_ctx->streams[str_id].pipe_id = pipe_id; sst_drv_ctx->streams[str_id].task_id = task_id; sst_drv_ctx->streams[str_id].num_ch = num_ch; @@ -100,9 +102,6 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) pipe_id, task_id); /* allocate device type context */ - sst_init_stream(&sst_drv_ctx->streams[str_id], alloc_param.codec_type, - str_id, alloc_param.operation, 0); - dev_dbg(sst_drv_ctx->dev, "Alloc for str %d pipe %#x\n", str_id, pipe_id); ret = sst_prepare_and_post_msg(sst_drv_ctx, task_id, IPC_CMD, From de9833476de7eb1d4b8bdc599cbbd616fb0e1a28 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:41 +0100 Subject: [PATCH 397/942] ASoC: Intel: sst: Remove unused STREAM_DECODE and STREAM_RESET states STREAM_DECODE is completely unused, status == STREAM_RESET was checked for, but never set, remove both. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 4 +--- sound/soc/intel/atom/sst/sst_drv_interface.c | 19 ------------------- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index 164b0f674c20..f4fd442080b2 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -65,9 +65,7 @@ enum sst_stream_states { STREAM_UN_INIT = 0, /* Freed/Not used stream */ STREAM_RUNNING = 1, /* Running */ STREAM_PAUSED = 2, /* Paused stream */ - STREAM_DECODE = 3, /* stream is in decoding only state */ - STREAM_INIT = 4, /* stream init, waiting for data */ - STREAM_RESET = 5, /* force reset on recovery */ + STREAM_INIT = 3, /* stream init, waiting for data */ }; enum sst_ram_type { diff --git a/sound/soc/intel/atom/sst/sst_drv_interface.c b/sound/soc/intel/atom/sst/sst_drv_interface.c index 71af5449be90..6a8b253c58d2 100644 --- a/sound/soc/intel/atom/sst/sst_drv_interface.c +++ b/sound/soc/intel/atom/sst/sst_drv_interface.c @@ -238,16 +238,7 @@ static int sst_cdev_close(struct device *dev, unsigned int str_id) return -EINVAL; } - if (stream->status == STREAM_RESET) { - dev_dbg(dev, "stream in reset state...\n"); - stream->status = STREAM_UN_INIT; - - retval = 0; - goto put; - } - retval = sst_free_stream(ctx, str_id); -put: stream->compr_cb_param = NULL; stream->compr_cb = NULL; @@ -256,7 +247,6 @@ put: dev_dbg(dev, "End\n"); return retval; - } static int sst_cdev_ack(struct device *dev, unsigned int str_id, @@ -486,16 +476,7 @@ static int sst_close_pcm_stream(struct device *dev, unsigned int str_id) return -EINVAL; } - if (stream->status == STREAM_RESET) { - /* silently fail here as we have cleaned the stream earlier */ - dev_dbg(ctx->dev, "stream in reset state...\n"); - - retval = 0; - goto put; - } - retval = free_stream_context(ctx, str_id); -put: stream->pcm_substream = NULL; stream->status = STREAM_UN_INIT; stream->period_elapsed = NULL; From 473858cad1ea3d4e6c287bad23961cd5fb7382d9 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:42 +0100 Subject: [PATCH 398/942] ASoC: Intel: sst: Add sst_realloc_stream() function Move the struct snd_sst_alloc_mrfld alloc parameters from the stack into struct stream_info and add a new sst_realloc_stream() function which can re-alloc a stream with the same parameters as before. This is a preparation patch for fixing suspend/resume issues with some SST / DSP firmware versions. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/atom/sst/sst.h | 3 + sound/soc/intel/atom/sst/sst_stream.c | 92 ++++++++++++++++----------- 2 files changed, 58 insertions(+), 37 deletions(-) diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index f4fd442080b2..a357cd615b59 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -180,6 +180,7 @@ struct sst_block { * @status : stream current state * @prev : stream prev state * @lock : stream mutex for protecting state + * @alloc_param : parameters used for stream (re-)allocation * @pcm_substream : PCM substream * @period_elapsed : PCM period elapsed callback * @sfreq : stream sampling freq @@ -189,6 +190,7 @@ struct stream_info { unsigned int status; unsigned int prev; struct mutex lock; + struct snd_sst_alloc_mrfld alloc_param; void *pcm_substream; void (*period_elapsed)(void *pcm_substream); @@ -429,6 +431,7 @@ struct intel_sst_ops { void (*post_download)(struct intel_sst_drv *sst); }; +int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id); int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int id); int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int id); int sst_drop_stream(struct intel_sst_drv *sst_drv_ctx, int id); diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index 7cf5dd1993bc..fcedaa237505 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -35,29 +35,31 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) { - struct snd_sst_alloc_mrfld alloc_param; + struct snd_pcm_params *pcm_params; struct snd_sst_params *str_params; struct snd_sst_tstamp fw_tstamp; struct stream_info *str_info; - struct snd_sst_alloc_response *response; - unsigned int str_id, pipe_id, task_id; - int i, num_ch, ret = 0; - void *data = NULL; + int i, num_ch, str_id; dev_dbg(sst_drv_ctx->dev, "Enter\n"); str_params = (struct snd_sst_params *)params; - memset(&alloc_param, 0, sizeof(alloc_param)); - alloc_param.operation = str_params->ops; - alloc_param.codec_type = str_params->codec; - alloc_param.sg_count = str_params->aparams.sg_count; - alloc_param.ring_buf_info[0].addr = - str_params->aparams.ring_buf_info[0].addr; - alloc_param.ring_buf_info[0].size = - str_params->aparams.ring_buf_info[0].size; - alloc_param.frag_size = str_params->aparams.frag_size; + str_id = str_params->stream_id; + str_info = get_stream_info(sst_drv_ctx, str_id); + if (!str_info) + return -EINVAL; - memcpy(&alloc_param.codec_params, &str_params->sparams, + memset(&str_info->alloc_param, 0, sizeof(str_info->alloc_param)); + str_info->alloc_param.operation = str_params->ops; + str_info->alloc_param.codec_type = str_params->codec; + str_info->alloc_param.sg_count = str_params->aparams.sg_count; + str_info->alloc_param.ring_buf_info[0].addr = + str_params->aparams.ring_buf_info[0].addr; + str_info->alloc_param.ring_buf_info[0].size = + str_params->aparams.ring_buf_info[0].size; + str_info->alloc_param.frag_size = str_params->aparams.frag_size; + + memcpy(&str_info->alloc_param.codec_params, &str_params->sparams, sizeof(struct snd_sst_stream_params)); /* @@ -67,46 +69,62 @@ int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params) * Currently hardcoding as per FW reqm. */ num_ch = sst_get_num_channel(str_params); + pcm_params = &str_info->alloc_param.codec_params.uc.pcm_params; for (i = 0; i < 8; i++) { if (i < num_ch) - alloc_param.codec_params.uc.pcm_params.channel_map[i] = i; + pcm_params->channel_map[i] = i; else - alloc_param.codec_params.uc.pcm_params.channel_map[i] = 0xFF; + pcm_params->channel_map[i] = 0xff; } - str_id = str_params->stream_id; - str_info = get_stream_info(sst_drv_ctx, str_id); - if (str_info == NULL) { - dev_err(sst_drv_ctx->dev, "get stream info returned null\n"); - return -EINVAL; - } - - pipe_id = str_params->device_type; - task_id = str_params->task; sst_drv_ctx->streams[str_id].status = STREAM_INIT; sst_drv_ctx->streams[str_id].prev = STREAM_UN_INIT; - sst_drv_ctx->streams[str_id].pipe_id = pipe_id; - sst_drv_ctx->streams[str_id].task_id = task_id; + sst_drv_ctx->streams[str_id].pipe_id = str_params->device_type; + sst_drv_ctx->streams[str_id].task_id = str_params->task; sst_drv_ctx->streams[str_id].num_ch = num_ch; if (sst_drv_ctx->info.lpe_viewpt_rqd) - alloc_param.ts = sst_drv_ctx->info.mailbox_start + + str_info->alloc_param.ts = sst_drv_ctx->info.mailbox_start + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); else - alloc_param.ts = sst_drv_ctx->mailbox_add + + str_info->alloc_param.ts = sst_drv_ctx->mailbox_add + sst_drv_ctx->tstamp + (str_id * sizeof(fw_tstamp)); dev_dbg(sst_drv_ctx->dev, "alloc tstamp location = 0x%x\n", - alloc_param.ts); + str_info->alloc_param.ts); dev_dbg(sst_drv_ctx->dev, "assigned pipe id 0x%x to task %d\n", - pipe_id, task_id); + str_info->pipe_id, str_info->task_id); + + return sst_realloc_stream(sst_drv_ctx, str_id); +} + +/** + * sst_realloc_stream - Send msg for (re-)allocating a stream using the + * @sst_drv_ctx intel_sst_drv context pointer + * @str_id: stream ID + * + * Send a msg for (re-)allocating a stream using the parameters previously + * passed to sst_alloc_stream_mrfld() for the same stream ID. + * Return: 0 or negative errno value. + */ +int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) +{ + struct snd_sst_alloc_response *response; + struct stream_info *str_info; + void *data = NULL; + int ret; + + str_info = get_stream_info(sst_drv_ctx, str_id); + if (!str_info) + return -EINVAL; - /* allocate device type context */ dev_dbg(sst_drv_ctx->dev, "Alloc for str %d pipe %#x\n", - str_id, pipe_id); - ret = sst_prepare_and_post_msg(sst_drv_ctx, task_id, IPC_CMD, - IPC_IA_ALLOC_STREAM_MRFLD, pipe_id, sizeof(alloc_param), - &alloc_param, &data, true, true, false, true); + str_id, str_info->pipe_id); + + ret = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD, + IPC_IA_ALLOC_STREAM_MRFLD, str_info->pipe_id, + sizeof(str_info->alloc_param), &str_info->alloc_param, + &data, true, true, false, true); if (ret < 0) { dev_err(sst_drv_ctx->dev, "FW alloc failed ret %d\n", ret); From bf642bf57398572327072d306e26e38aebd94fa7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 18 Feb 2018 23:01:43 +0100 Subject: [PATCH 399/942] ASoC: Intel: sst: Free streams on suspend, re-alloc on resume The Bay Trail SST-DSP firmware version looses track of all streams over a suspend/resume, failing any attempts to resume and/or free streams, with a SST_ERR_INVALID_STREAM_ID error. This commit adds support for free-ing the streams on suspend and re-allocating them on resume, fixing suspend/resume issues on devices using this firmware version. This new behavior gets triggered by a new flag in sst_platform_info which only gets set on Bay Trail platforms. This has been tested on the following devices: -Asus T100TA, Bay Trail + ALC5642 codec -Ployer MOMO7W, Bay Trail CR + ALC5652 codec Tested-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- arch/x86/include/asm/platform_sst_audio.h | 1 + sound/soc/intel/atom/sst/sst.c | 24 ++++++++++++++++++++++- sound/soc/intel/atom/sst/sst.h | 4 ++++ sound/soc/intel/atom/sst/sst_acpi.c | 3 ++- sound/soc/intel/atom/sst/sst_stream.c | 24 ++++++++++++++++++++++- 5 files changed, 53 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/platform_sst_audio.h b/arch/x86/include/asm/platform_sst_audio.h index 5973a2f3db3d..059823bb8af7 100644 --- a/arch/x86/include/asm/platform_sst_audio.h +++ b/arch/x86/include/asm/platform_sst_audio.h @@ -135,6 +135,7 @@ struct sst_platform_info { const struct sst_res_info *res_info; const struct sst_lib_dnld_info *lib_info; const char *platform; + bool streams_lost_on_suspend; }; int add_sst_platform_device(void); #endif diff --git a/sound/soc/intel/atom/sst/sst.c b/sound/soc/intel/atom/sst/sst.c index 8afdff457579..0962bc9adc62 100644 --- a/sound/soc/intel/atom/sst/sst.c +++ b/sound/soc/intel/atom/sst/sst.c @@ -449,6 +449,13 @@ static int intel_sst_suspend(struct device *dev) dev_err(dev, "stream %d is running, can't suspend, abort\n", i); return -EBUSY; } + + if (ctx->pdata->streams_lost_on_suspend) { + stream->resume_status = stream->status; + stream->resume_prev = stream->prev; + if (stream->status != STREAM_UN_INIT) + sst_free_stream(ctx, i); + } } synchronize_irq(ctx->irq_num); flush_workqueue(ctx->post_msg_wq); @@ -509,8 +516,8 @@ static int intel_sst_resume(struct device *dev) { struct intel_sst_drv *ctx = dev_get_drvdata(dev); struct sst_fw_save *fw_save = ctx->fw_save; - int ret = 0; struct sst_block *block; + int i, ret = 0; if (!fw_save) return 0; @@ -550,6 +557,21 @@ static int intel_sst_resume(struct device *dev) sst_set_fw_state_locked(ctx, SST_FW_RUNNING); } + if (ctx->pdata->streams_lost_on_suspend) { + for (i = 1; i <= ctx->info.max_streams; i++) { + struct stream_info *stream = &ctx->streams[i]; + + if (stream->resume_status != STREAM_UN_INIT) { + dev_dbg(ctx->dev, "Re-allocing stream %d status %d prev %d\n", + i, stream->resume_status, + stream->resume_prev); + sst_realloc_stream(ctx, i); + stream->status = stream->resume_status; + stream->prev = stream->resume_prev; + } + } + } + sst_free_block(ctx, block); return ret; } diff --git a/sound/soc/intel/atom/sst/sst.h b/sound/soc/intel/atom/sst/sst.h index a357cd615b59..b2a705dc9304 100644 --- a/sound/soc/intel/atom/sst/sst.h +++ b/sound/soc/intel/atom/sst/sst.h @@ -179,6 +179,8 @@ struct sst_block { * * @status : stream current state * @prev : stream prev state + * @resume_status : stream current state to restore on resume + * @resume_prev : stream prev state to restore on resume * @lock : stream mutex for protecting state * @alloc_param : parameters used for stream (re-)allocation * @pcm_substream : PCM substream @@ -189,6 +191,8 @@ struct sst_block { struct stream_info { unsigned int status; unsigned int prev; + unsigned int resume_status; + unsigned int resume_prev; struct mutex lock; struct snd_sst_alloc_mrfld alloc_param; diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c index 6cd481bec275..c90b04cc071d 100644 --- a/sound/soc/intel/atom/sst/sst_acpi.c +++ b/sound/soc/intel/atom/sst/sst_acpi.c @@ -143,10 +143,11 @@ static struct sst_platform_info byt_rvp_platform_data = { .lib_info = &byt_lib_dnld_info, .res_info = &byt_rvp_res_info, .platform = "sst-mfld-platform", + .streams_lost_on_suspend = true, }; /* Cherryview (Cherrytrail and Braswell) uses same mrfld dpcm fw as Baytrail, - * so pdata is same as Baytrail. + * so pdata is same as Baytrail, minus the streams_lost_on_suspend quirk. */ static struct sst_platform_info chv_platform_data = { .probe_data = &byt_fwparse_info, diff --git a/sound/soc/intel/atom/sst/sst_stream.c b/sound/soc/intel/atom/sst/sst_stream.c index fcedaa237505..107271f7dd63 100644 --- a/sound/soc/intel/atom/sst/sst_stream.c +++ b/sound/soc/intel/atom/sst/sst_stream.c @@ -302,7 +302,29 @@ int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int str_id) return -EINVAL; if (str_info->status == STREAM_RUNNING) return 0; - if (str_info->status == STREAM_PAUSED) { + + if (str_info->resume_status == STREAM_PAUSED && + str_info->resume_prev == STREAM_RUNNING) { + /* + * Stream was running before suspend and re-created on resume, + * start it to get back to running state. + */ + dev_dbg(sst_drv_ctx->dev, "restart recreated stream after resume\n"); + str_info->status = STREAM_RUNNING; + str_info->prev = STREAM_PAUSED; + retval = sst_start_stream(sst_drv_ctx, str_id); + str_info->resume_status = STREAM_UN_INIT; + } else if (str_info->resume_status == STREAM_PAUSED && + str_info->resume_prev == STREAM_INIT) { + /* + * Stream was idle before suspend and re-created on resume, + * keep it as is. + */ + dev_dbg(sst_drv_ctx->dev, "leaving recreated stream idle after resume\n"); + str_info->status = STREAM_INIT; + str_info->prev = STREAM_PAUSED; + str_info->resume_status = STREAM_UN_INIT; + } else if (str_info->status == STREAM_PAUSED) { retval = sst_prepare_and_post_msg(sst_drv_ctx, str_info->task_id, IPC_CMD, IPC_IA_RESUME_STREAM_MRFLD, str_info->pipe_id, 0, NULL, NULL, From 256ac58a7ea343600bd6d0e3df3eb7eebb2d65e0 Mon Sep 17 00:00:00 2001 From: Naveen Manohar Date: Mon, 19 Feb 2018 08:15:02 +0530 Subject: [PATCH 400/942] ASoC: Intel: kbl: Enable mclk and ssp sclk early for rt5663 rt5663 requires mclk/sclk early to synchronize its internal clocks. Enable these clocks early. Signed-off-by: Naveen Manohar Signed-off-by: Kevin Cheng Signed-off-by: Mark Brown --- sound/soc/intel/boards/kbl_rt5663_max98927.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/intel/boards/kbl_rt5663_max98927.c b/sound/soc/intel/boards/kbl_rt5663_max98927.c index 3c9585eb6860..0e6b7e79441c 100644 --- a/sound/soc/intel/boards/kbl_rt5663_max98927.c +++ b/sound/soc/intel/boards/kbl_rt5663_max98927.c @@ -204,13 +204,18 @@ static const struct snd_soc_dapm_widget kabylake_5663_widgets[] = { SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_SPK("DP", NULL), SND_SOC_DAPM_SPK("HDMI", NULL), + SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0, + platform_clock_control, SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD), }; static const struct snd_soc_dapm_route kabylake_5663_map[] = { + { "Headphone Jack", NULL, "Platform Clock" }, { "Headphone Jack", NULL, "HPOL" }, { "Headphone Jack", NULL, "HPOR" }, /* other jacks */ + { "Headset Mic", NULL, "Platform Clock" }, { "IN1P", NULL, "Headset Mic" }, { "IN1N", NULL, "Headset Mic" }, From cb57469c9573f6018cd1302953dd45d6e05aba7b Mon Sep 17 00:00:00 2001 From: Joel Fernandes Date: Fri, 16 Feb 2018 11:02:01 -0800 Subject: [PATCH 401/942] staging: android: ashmem: Fix lockdep issue during llseek ashmem_mutex create a chain of dependencies like so: (1) mmap syscall -> mmap_sem -> (acquired) ashmem_mmap ashmem_mutex (try to acquire) (block) (2) llseek syscall -> ashmem_llseek -> ashmem_mutex -> (acquired) inode_lock -> inode->i_rwsem (try to acquire) (block) (3) getdents -> iterate_dir -> inode_lock -> inode->i_rwsem (acquired) copy_to_user -> mmap_sem (try to acquire) There is a lock ordering created between mmap_sem and inode->i_rwsem causing a lockdep splat [2] during a syzcaller test, this patch fixes the issue by unlocking the mutex earlier. Functionally that's Ok since we don't need to protect vfs_llseek. [1] https://patchwork.kernel.org/patch/10185031/ [2] https://lkml.org/lkml/2018/1/10/48 Acked-by: Todd Kjos Cc: Arve Hjonnevag Cc: stable@vger.kernel.org Reported-by: syzbot+8ec30bb7bf1a981a2012@syzkaller.appspotmail.com Signed-off-by: Joel Fernandes Acked-by: Greg Hackmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 6dbba5aff191..d5450365769c 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -326,24 +326,23 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin) mutex_lock(&ashmem_mutex); if (asma->size == 0) { - ret = -EINVAL; - goto out; + mutex_unlock(&ashmem_mutex); + return -EINVAL; } if (!asma->file) { - ret = -EBADF; - goto out; + mutex_unlock(&ashmem_mutex); + return -EBADF; } + mutex_unlock(&ashmem_mutex); + ret = vfs_llseek(asma->file, offset, origin); if (ret < 0) - goto out; + return ret; /** Copy f_pos from backing file, since f_ops->llseek() sets it */ file->f_pos = asma->file->f_pos; - -out: - mutex_unlock(&ashmem_mutex); return ret; } From 5b00ce63e07fac692400db80d3e1fbd1f1f65701 Mon Sep 17 00:00:00 2001 From: John Hsu Date: Tue, 6 Feb 2018 15:02:43 +0800 Subject: [PATCH 402/942] ASoC: Intel: add nau8824 sound card Create sound card with NAU88L24 codec in Intel Cherryview-based platforms, Cherrytrail and Braswell. Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/intel/boards/Kconfig | 11 + sound/soc/intel/boards/Makefile | 2 + sound/soc/intel/boards/cht_bsw_nau8824.c | 282 ++++++++++++++++++ .../intel/common/soc-acpi-intel-cht-match.c | 9 + 4 files changed, 304 insertions(+) create mode 100644 sound/soc/intel/boards/cht_bsw_nau8824.c diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig index eedc83b96fbb..24797482a3d2 100644 --- a/sound/soc/intel/boards/Kconfig +++ b/sound/soc/intel/boards/Kconfig @@ -125,6 +125,17 @@ config SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH Say Y or m if you have such a device. This is a recommended option. If unsure select "N". +config SND_SOC_INTEL_CHT_BSW_NAU8824_MACH + tristate "Cherrytrail & Braswell with NAU88L24 codec" + depends on X86_INTEL_LPSS && I2C && ACPI + select SND_SOC_ACPI + select SND_SOC_NAU8824 + help + This adds support for ASoC machine driver for Intel(R) Cherrytrail & Braswell + platforms with NAU88L24 audio codec. + Say Y or m if you have such a device. This is a recommended option. + If unsure select "N". + config SND_SOC_INTEL_BYT_CHT_DA7213_MACH tristate "Baytrail & Cherrytrail with DA7212/7213 codec" depends on X86_INTEL_LPSS && I2C && ACPI diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile index 6fae506c40fa..92b5507291af 100644 --- a/sound/soc/intel/boards/Makefile +++ b/sound/soc/intel/boards/Makefile @@ -11,6 +11,7 @@ snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o +snd-soc-sst-cht-bsw-nau8824-objs := cht_bsw_nau8824.o snd-soc-sst-byt-cht-da7213-objs := bytcht_da7213.o snd-soc-sst-byt-cht-es8316-objs := bytcht_es8316.o snd-soc-sst-byt-cht-nocodec-objs := bytcht_nocodec.o @@ -33,6 +34,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o +obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_NAU8824_MACH) += snd-soc-sst-cht-bsw-nau8824.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_DA7213_MACH) += snd-soc-sst-byt-cht-da7213.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_ES8316_MACH) += snd-soc-sst-byt-cht-es8316.o obj-$(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH) += snd-soc-sst-byt-cht-nocodec.o diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c new file mode 100644 index 000000000000..08d0b8128fab --- /dev/null +++ b/sound/soc/intel/boards/cht_bsw_nau8824.c @@ -0,0 +1,282 @@ +/* + * cht-bsw-nau8824.c - ASoc Machine driver for Intel Cherryview-based + * platforms Cherrytrail and Braswell, with nau8824 codec. + * + * Copyright (C) 2018 Intel Corp + * Copyright (C) 2018 Nuvoton Technology Corp + * + * Author: Wang, Joseph C + * Co-author: John Hsu + * This file is based on cht_bsw_rt5672.c and cht-bsw-max98090.c + * + * 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; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../atom/sst-atom-controls.h" +#include "../../codecs/nau8824.h" + +struct cht_mc_private { + struct snd_soc_jack jack; +}; + +static struct snd_soc_jack_pin cht_bsw_jack_pins[] = { + { + .pin = "Headphone", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Mic", + .mask = SND_JACK_MICROPHONE, + }, +}; + +static const struct snd_soc_dapm_widget cht_dapm_widgets[] = { + SND_SOC_DAPM_HP("Headphone", NULL), + SND_SOC_DAPM_MIC("Headset Mic", NULL), + SND_SOC_DAPM_MIC("Int Mic", NULL), + SND_SOC_DAPM_SPK("Ext Spk", NULL), +}; + +static const struct snd_soc_dapm_route cht_audio_map[] = { + {"Ext Spk", NULL, "SPKOUTL"}, + {"Ext Spk", NULL, "SPKOUTR"}, + {"Headphone", NULL, "HPOL"}, + {"Headphone", NULL, "HPOR"}, + {"MIC1", NULL, "Int Mic"}, + {"MIC2", NULL, "Int Mic"}, + {"HSMIC1", NULL, "Headset Mic"}, + {"HSMIC2", NULL, "Headset Mic"}, + {"Playback", NULL, "ssp2 Tx"}, + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx" }, + {"codec_in1", NULL, "ssp2 Rx" }, + {"ssp2 Rx", NULL, "Capture"}, +}; + +static const struct snd_kcontrol_new cht_mc_controls[] = { + SOC_DAPM_PIN_SWITCH("Headphone"), + SOC_DAPM_PIN_SWITCH("Headset Mic"), + SOC_DAPM_PIN_SWITCH("Int Mic"), + SOC_DAPM_PIN_SWITCH("Ext Spk"), +}; + +static int cht_aif1_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *codec_dai = rtd->codec_dai; + int ret; + + ret = snd_soc_dai_set_sysclk(codec_dai, NAU8824_CLK_FLL_FS, 0, + SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set FS clock %d\n", ret); + return ret; + } + ret = snd_soc_dai_set_pll(codec_dai, 0, 0, params_rate(params), + params_rate(params) * 256); + if (ret < 0) { + dev_err(codec_dai->dev, "can't set FLL: %d\n", ret); + return ret; + } + + return 0; +} + +static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) +{ + struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); + struct snd_soc_jack *jack = &ctx->jack; + struct snd_soc_codec *codec = runtime->codec; + struct snd_soc_dai *codec_dai = runtime->codec_dai; + int ret, jack_type; + + /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ + ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xf, 0x1, 4, 24); + if (ret < 0) { + dev_err(runtime->dev, "can't set codec TDM slot %d\n", ret); + return ret; + } + + /* NAU88L24 supports 4 butons headset detection + * KEY_MEDIA + * KEY_VOICECOMMAND + * KEY_VOLUMEUP + * KEY_VOLUMEDOWN + */ + jack_type = SND_JACK_HEADPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | + SND_JACK_BTN_2 | SND_JACK_BTN_3; + ret = snd_soc_card_jack_new(runtime->card, "Headset", jack_type, jack, + cht_bsw_jack_pins, ARRAY_SIZE(cht_bsw_jack_pins)); + if (ret) { + dev_err(runtime->dev, + "Headset Jack creation failed %d\n", ret); + return ret; + } + snd_jack_set_key(jack->jack, SND_JACK_BTN_0, KEY_MEDIA); + snd_jack_set_key(jack->jack, SND_JACK_BTN_1, KEY_VOICECOMMAND); + snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); + snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); + + nau8824_enable_jack_detect(codec, jack); + + return ret; +} + +static int cht_codec_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + struct snd_mask *fmt = + hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + /* The DSP will covert the FE rate to 48k, stereo, 24bits */ + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + /* set SSP2 to 24-bit */ + snd_mask_none(fmt); + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + + return 0; +} + +static int cht_aif1_startup(struct snd_pcm_substream *substream) +{ + return snd_pcm_hw_constraint_single(substream->runtime, + SNDRV_PCM_HW_PARAM_RATE, 48000); +} + +static const struct snd_soc_ops cht_aif1_ops = { + .startup = cht_aif1_startup, +}; + +static const struct snd_soc_ops cht_be_ssp2_ops = { + .hw_params = cht_aif1_hw_params, +}; + +static struct snd_soc_dai_link cht_dailink[] = { + /* Front End DAI links */ + [MERR_DPCM_AUDIO] = { + .name = "Audio Port", + .stream_name = "Audio", + .cpu_dai_name = "media-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .nonatomic = true, + .dynamic = 1, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_DEEP_BUFFER] = { + .name = "Deep-Buffer Audio Port", + .stream_name = "Deep-Buffer Audio", + .cpu_dai_name = "deepbuffer-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + .nonatomic = true, + .dynamic = 1, + .dpcm_playback = 1, + .ops = &cht_aif1_ops, + }, + [MERR_DPCM_COMPR] = { + .name = "Compressed Port", + .stream_name = "Compress", + .cpu_dai_name = "compress-cpu-dai", + .codec_dai_name = "snd-soc-dummy-dai", + .codec_name = "snd-soc-dummy", + .platform_name = "sst-mfld-platform", + }, + /* Back End DAI links */ + { + /* SSP2 - Codec */ + .name = "SSP2-Codec", + .id = 1, + .cpu_dai_name = "ssp2-port", + .platform_name = "sst-mfld-platform", + .no_pcm = 1, + .codec_dai_name = NAU8824_CODEC_DAI, + .codec_name = "i2c-10508824:00", + .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF + | SND_SOC_DAIFMT_CBS_CFS, + .init = cht_codec_init, + .be_hw_params_fixup = cht_codec_fixup, + .dpcm_playback = 1, + .dpcm_capture = 1, + .ops = &cht_be_ssp2_ops, + }, +}; + +/* SoC card */ +static struct snd_soc_card snd_soc_card_cht = { + .name = "chtnau8824", + .owner = THIS_MODULE, + .dai_link = cht_dailink, + .num_links = ARRAY_SIZE(cht_dailink), + .dapm_widgets = cht_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cht_dapm_widgets), + .dapm_routes = cht_audio_map, + .num_dapm_routes = ARRAY_SIZE(cht_audio_map), + .controls = cht_mc_controls, + .num_controls = ARRAY_SIZE(cht_mc_controls), +}; + +static int snd_cht_mc_probe(struct platform_device *pdev) +{ + struct cht_mc_private *drv; + int ret_val; + + drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_ATOMIC); + if (!drv) + return -ENOMEM; + snd_soc_card_set_drvdata(&snd_soc_card_cht, drv); + + /* register the soc card */ + snd_soc_card_cht.dev = &pdev->dev; + ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_cht); + if (ret_val) { + dev_err(&pdev->dev, + "snd_soc_register_card failed %d\n", ret_val); + return ret_val; + } + platform_set_drvdata(pdev, &snd_soc_card_cht); + + return ret_val; +} + +static struct platform_driver snd_cht_mc_driver = { + .driver = { + .name = "cht-bsw-nau8824", + }, + .probe = snd_cht_mc_probe, +}; + +module_platform_driver(snd_cht_mc_driver); + +MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver"); +MODULE_AUTHOR("Wang, Joseph C "); +MODULE_AUTHOR("John Hsu "); +MODULE_LICENSE("GPL v2"); +MODULE_ALIAS("platform:cht-bsw-nau8824"); diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c index b50a0d53846b..ad1eb2d644be 100644 --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c @@ -117,6 +117,15 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = { .sof_tplg_filename = "intel/reef-cht-max98090.tplg", .asoc_plat_name = "sst-mfld-platform", }, + { + .id = "10508824", + .drv_name = "cht-bsw-nau8824", + .fw_filename = "intel/fw_sst_22a8.bin", + .board = "cht-bsw", + .sof_fw_filename = "intel/reef-cht.ri", + .sof_tplg_filename = "intel/reef-cht-nau8824.tplg", + .asoc_plat_name = "sst-mfld-platform", + }, { .id = "DLGS7212", .drv_name = "bytcht_da7213", From 54e3a3a152a6f466f3a94b28be10f08b86905bc0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:42 +0100 Subject: [PATCH 403/942] ASoC: rt5651: Remove unused rt5651_platform_data There are no in tree users of platform-data for the rt5651 codec driver, so lets remove support for it. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/sound/rt5651.h | 8 ------- sound/soc/codecs/rt5651.c | 47 ++++++++------------------------------- sound/soc/codecs/rt5651.h | 2 +- 3 files changed, 10 insertions(+), 47 deletions(-) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 18b79a761f10..1612462bf5ad 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -18,12 +18,4 @@ enum rt5651_jd_src { RT5651_JD2, }; -struct rt5651_platform_data { - /* IN2 can optionally be differential */ - bool in2_diff; - - bool dmic_en; - enum rt5651_jd_src jd_src; -}; - #endif diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 3a844725684b..eecd6e662210 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -33,8 +33,6 @@ #include "rt5651.h" #define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define RT5651_IN2_DIFF BIT(16) -#define RT5651_DMIC_EN BIT(17) #define RT5651_DEVICE_ID_VALUE 0x6281 @@ -1569,7 +1567,7 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { @@ -1604,7 +1602,7 @@ static int rt5651_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { snd_soc_dapm_force_enable_pin(dapm, "JD Power"); snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); @@ -1764,26 +1762,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} }; -static int rt5651_parse_dt(struct rt5651_priv *rt5651, struct device_node *np) -{ - if (of_property_read_bool(np, "realtek,in2-differential")) - rt5651_quirk |= RT5651_IN2_DIFF; - if (of_property_read_bool(np, "realtek,dmic-en")) - rt5651_quirk |= RT5651_DMIC_EN; - - return 0; -} - -static void rt5651_set_pdata(struct rt5651_priv *rt5651) -{ - if (rt5651_quirk & RT5651_IN2_DIFF) - rt5651->pdata.in2_diff = true; - if (rt5651_quirk & RT5651_DMIC_EN) - rt5651->pdata.dmic_en = true; - if (RT5651_JD_MAP(rt5651_quirk)) - rt5651->pdata.jd_src = RT5651_JD_MAP(rt5651_quirk); -} - static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1840,7 +1818,7 @@ static void rt5651_jack_detect_work(struct work_struct *work) if (!rt5651->component) return; - switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; break; @@ -1874,7 +1852,6 @@ EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { - struct rt5651_platform_data *pdata = dev_get_platdata(&i2c->dev); struct rt5651_priv *rt5651; int ret; @@ -1885,14 +1862,8 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5651); - if (pdata) - rt5651->pdata = *pdata; - else if (i2c->dev.of_node) - rt5651_parse_dt(rt5651, i2c->dev.of_node); - else - dmi_check_system(rt5651_quirk_table); - - rt5651_set_pdata(rt5651); + dmi_check_system(rt5651_quirk_table); + rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk); rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { @@ -1916,23 +1887,23 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - if (rt5651->pdata.in2_diff) + if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2); - if (rt5651->pdata.dmic_en) + if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); rt5651->hp_mute = 1; - if (rt5651->pdata.jd_src) { + if (rt5651->jd_src) { /* IRQ output on GPIO1 */ regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - switch (rt5651->pdata.jd_src) { + switch (rt5651->jd_src) { case RT5651_JD1_1: regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, RT5651_JD_TRG_SEL_MASK, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 1ef38429e6a0..148e139e6a26 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2060,10 +2060,10 @@ struct rt5651_pll_code { struct rt5651_priv { struct snd_soc_component *component; - struct rt5651_platform_data pdata; struct regmap *regmap; struct snd_soc_jack *hp_jack; struct delayed_work jack_detect_work; + enum rt5651_jd_src jd_src; int sysclk; int sysclk_src; From f06da4fdb5fc2b78d52f62c32aec65b7819178b0 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:43 +0100 Subject: [PATCH 404/942] ASoC: rt5651: Move all jack-detect initialization to rt5651_set_jack_detect Move all jack-detect initialization to rt5651_set_jack_detect. The main reason to do this is so that platform code can setup jack-detect properties after the device has been probed, which unfortunately is necessary on some platforms. This has 2 additional advantages: 1) Grouping all jack-detect init together makes it easier to follow what is happening and results in a small reduction in the number of loc. 2) Before we would register the irq handler before rt5651->hp_jack was assigned, leading to a potential NULL deref if the jack_detect work runs before the machine driver has called set_jack. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 119 ++++++++++++++++++-------------------- sound/soc/codecs/rt5651.h | 1 + 2 files changed, 58 insertions(+), 62 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index eecd6e662210..390cab134ba0 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1586,7 +1586,6 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); rt5651->component = component; @@ -1602,15 +1601,6 @@ static int rt5651_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); - if (rt5651->jd_src) { - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - - regmap_update_bits(rt5651->regmap, RT5651_MICBIAS, - 0x38, 0x38); - } - return 0; } @@ -1840,10 +1830,65 @@ static void rt5651_jack_detect_work(struct work_struct *work) int rt5651_set_jack_detect(struct snd_soc_component *component, struct snd_soc_jack *hp_jack) { + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int ret; + + if (!rt5651->irq) + return -EINVAL; + + /* IRQ output on GPIO1 */ + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); + + /* Select jack detect source */ + switch (rt5651->jd_src) { + case RT5651_JD1_1: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); + break; + case RT5651_JD1_2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); + break; + case RT5651_JD2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); + break; + case RT5651_JD_NULL: + return 0; + default: + dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); + return -EINVAL; + } + + snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); + snd_soc_dapm_sync(dapm); + + snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); rt5651->hp_jack = hp_jack; - rt5651_irq(0, rt5651); + + ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, + rt5651_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, "rt5651", rt5651); + if (ret) { + dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + /* sync initial jack state */ + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, 0); return 0; } @@ -1895,61 +1940,11 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); + rt5651->irq = i2c->irq; rt5651->hp_mute = 1; - if (rt5651->jd_src) { - - /* IRQ output on GPIO1 */ - regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, - RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - - switch (rt5651->jd_src) { - case RT5651_JD1_1: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD1_1); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD1_1_IRQ_EN, - RT5651_JD1_1_IRQ_EN); - break; - case RT5651_JD1_2: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD1_2); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD1_2_IRQ_EN, - RT5651_JD1_2_IRQ_EN); - break; - case RT5651_JD2: - regmap_update_bits(rt5651->regmap, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, - RT5651_JD_TRG_SEL_JD2); - regmap_update_bits(rt5651->regmap, RT5651_IRQ_CTRL1, - RT5651_JD2_IRQ_EN, - RT5651_JD2_IRQ_EN); - break; - case RT5651_JD_NULL: - break; - default: - dev_warn(&i2c->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - break; - } - } - INIT_DELAYED_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); - if (i2c->irq) { - ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - } - ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5651, rt5651_dai, ARRAY_SIZE(rt5651_dai)); diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 148e139e6a26..8f128d057ff0 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2065,6 +2065,7 @@ struct rt5651_priv { struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src; + int irq; int sysclk; int sysclk_src; int lrck[RT5651_AIFS]; From d8b8c878e86593ad8bd86676a2a4c2be58a8b889 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:44 +0100 Subject: [PATCH 405/942] ASoC: rt5651: Move 2 functions higher up in rt5651.c Move 2 functions higher up in rt5651.c, this is a preparation patch to avoid needing forward declarations when moving over from a codec private function to the standard snd_soc_component_set_jack(). This commit purely moves these 2 functions up, not a single line is changed. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 154 +++++++++++++++++++------------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 390cab134ba0..c9698229fc33 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1583,6 +1583,83 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, return 0; } +static irqreturn_t rt5651_irq(int irq, void *data) +{ + struct rt5651_priv *rt5651 = data; + + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, msecs_to_jiffies(250)); + + return IRQ_HANDLED; +} + +int rt5651_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int ret; + + if (!rt5651->irq) + return -EINVAL; + + /* IRQ output on GPIO1 */ + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); + + /* Select jack detect source */ + switch (rt5651->jd_src) { + case RT5651_JD1_1: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); + break; + case RT5651_JD1_2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); + break; + case RT5651_JD2: + snd_soc_component_update_bits(component, RT5651_JD_CTRL2, + RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, + RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); + break; + case RT5651_JD_NULL: + return 0; + default: + dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); + return -EINVAL; + } + + snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); + snd_soc_dapm_sync(dapm); + + snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); + + rt5651->hp_jack = hp_jack; + + ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, + rt5651_irq, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, "rt5651", rt5651); + if (ret) { + dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); + return ret; + } + + /* sync initial jack state */ + queue_delayed_work(system_power_efficient_wq, + &rt5651->jack_detect_work, 0); + + return 0; +} +EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); + static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1752,16 +1829,6 @@ static const struct dmi_system_id rt5651_quirk_table[] = { {} }; -static irqreturn_t rt5651_irq(int irq, void *data) -{ - struct rt5651_priv *rt5651 = data; - - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, msecs_to_jiffies(250)); - - return IRQ_HANDLED; -} - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); @@ -1827,73 +1894,6 @@ static void rt5651_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } -int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) -{ - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); - struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - int ret; - - if (!rt5651->irq) - return -EINVAL; - - /* IRQ output on GPIO1 */ - snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, - RT5651_GP1_PIN_MASK, RT5651_GP1_PIN_IRQ); - - /* Select jack detect source */ - switch (rt5651->jd_src) { - case RT5651_JD1_1: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_1); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD1_1_IRQ_EN, RT5651_JD1_1_IRQ_EN); - break; - case RT5651_JD1_2: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD1_2); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD1_2_IRQ_EN, RT5651_JD1_2_IRQ_EN); - break; - case RT5651_JD2: - snd_soc_component_update_bits(component, RT5651_JD_CTRL2, - RT5651_JD_TRG_SEL_MASK, RT5651_JD_TRG_SEL_JD2); - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL1, - RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); - break; - case RT5651_JD_NULL: - return 0; - default: - dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - return -EINVAL; - } - - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); - - rt5651->hp_jack = hp_jack; - - ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - - /* sync initial jack state */ - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, 0); - - return 0; -} -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); - static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { From 6f0b819ae2b36614a514824c622ac0e02650b718 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:45 +0100 Subject: [PATCH 406/942] ASoC: rt5651: Use standard component set_jack callback Use the standard component set_jack callback instead of defining a codec private API for this. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 6 +++--- sound/soc/codecs/rt5651.h | 2 -- sound/soc/intel/boards/bytcr_rt5651.c | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c9698229fc33..030889143249 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1593,8 +1593,8 @@ static irqreturn_t rt5651_irq(int irq, void *data) return IRQ_HANDLED; } -int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack) +static int rt5651_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack, void *data) { struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1658,7 +1658,6 @@ int rt5651_set_jack_detect(struct snd_soc_component *component, return 0; } -EXPORT_SYMBOL_GPL(rt5651_set_jack_detect); static int rt5651_probe(struct snd_soc_component *component) { @@ -1762,6 +1761,7 @@ static const struct snd_soc_component_driver soc_component_dev_rt5651 = { .suspend = rt5651_suspend, .resume = rt5651_resume, .set_bias_level = rt5651_set_bias_level, + .set_jack = rt5651_set_jack, .controls = rt5651_snd_controls, .num_controls = ARRAY_SIZE(rt5651_snd_controls), .dapm_widgets = rt5651_dapm_widgets, diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 8f128d057ff0..f3158488fc89 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,6 +2080,4 @@ struct rt5651_priv { bool hp_mute; }; -int rt5651_set_jack_detect(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack); #endif /* __RT5651_H__ */ diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index b6bf92191b9a..afb27e5e6756 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -370,7 +370,7 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) return ret; } - rt5651_set_jack_detect(codec, &priv->jack); + snd_soc_component_set_jack(codec, &priv->jack, NULL); return ret; } From 5f293d4354f8aae3c8617f83a3cbd30047676b4d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:46 +0100 Subject: [PATCH 407/942] ASoC: rt5651: Add rt5651_apply_properties() helper function Move the applying of the differential input and dmic properties to a new rt5651_apply_properties() helper function. This new function can be called by platform code which attaches properties after probe() has run to apply these new properties. Note this also moves the time when we apply these properties for DT platforms from i2c-probe to snd-component-probe time, this should not result in any functional difference. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 22 ++++++++++++++-------- sound/soc/codecs/rt5651.h | 2 ++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 030889143249..4d93248b6401 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1659,6 +1659,18 @@ static int rt5651_set_jack(struct snd_soc_component *component, return 0; } +void rt5651_apply_properties(struct snd_soc_component *component) +{ + if (device_property_read_bool(component->dev, "realtek,in2-differential")) + snd_soc_component_update_bits(component, RT5651_IN1_IN2, + RT5651_IN_DF2, RT5651_IN_DF2); + + if (device_property_read_bool(component->dev, "realtek,dmic-en")) + snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, + RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); +} +EXPORT_SYMBOL_GPL(rt5651_apply_properties); + static int rt5651_probe(struct snd_soc_component *component) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); @@ -1677,6 +1689,8 @@ static int rt5651_probe(struct snd_soc_component *component) snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); + rt5651_apply_properties(component); + return 0; } @@ -1932,14 +1946,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - if (device_property_read_bool(&i2c->dev, "realtek,in2-differential")) - regmap_update_bits(rt5651->regmap, RT5651_IN1_IN2, - RT5651_IN_DF2, RT5651_IN_DF2); - - if (device_property_read_bool(&i2c->dev, "realtek,dmic-en")) - regmap_update_bits(rt5651->regmap, RT5651_GPIO_CTRL1, - RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); - rt5651->irq = i2c->irq; rt5651->hp_mute = 1; diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index f3158488fc89..7d9d5fa09d6f 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,4 +2080,6 @@ struct rt5651_priv { bool hp_mute; }; +void rt5651_apply_properties(struct snd_soc_component *component); + #endif /* __RT5651_H__ */ From 3ac9ce8858ae3c6fef308692dc4580c164adc96b Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 1 Mar 2018 15:19:23 +0100 Subject: [PATCH 408/942] ASoC: max9867: Show Kconfig entry Allow codec to be selected. Signed-off-by: Ladislav Michl Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..56542e939a5f 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -615,7 +615,8 @@ config SND_SOC_MAX98504 depends on I2C config SND_SOC_MAX9867 - tristate + tristate "Maxim MAX9867 CODEC" + depends on I2C config SND_SOC_MAX98925 tristate From 8b9c716aada77e72e2fe82320aba5a95b75ca400 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 1 Mar 2018 15:19:53 +0100 Subject: [PATCH 409/942] ASoC: max9867: Improve error logging Tell user what are clock rate limits and reindent log messages. Signed-off-by: Ladislav Michl Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 2f60924fe919..ac30213deac4 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -291,7 +291,9 @@ static int max9867_set_dai_sysclk(struct snd_soc_dai *codec_dai, value |= MAX9867_PSCLK_40_60; max9867->pclk = freq/4; } else { - pr_err("bad clock frequency %d", freq); + dev_err(component->dev, + "Invalid clock frequency %uHz (required 10-60MHz)\n", + freq); return -EINVAL; } value = value << MAX9867_PSCLK_SHIFT; @@ -486,8 +488,7 @@ static int max9867_i2c_probe(struct i2c_client *i2c, max9867->regmap = devm_regmap_init_i2c(i2c, &max9867_regmap); if (IS_ERR(max9867->regmap)) { ret = PTR_ERR(max9867->regmap); - dev_err(&i2c->dev, - "Failed to allocate regmap: %d\n", ret); + dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); return ret; } ret = regmap_read(max9867->regmap, From e6ceb922ca802711db4b48639a9c73f9dc412f87 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 1 Mar 2018 15:20:56 +0100 Subject: [PATCH 410/942] ASoC: max9867: Fix codec capabilities Codes is stereo only with playback and capture streams bind to the same rate. Signed-off-by: Ladislav Michl Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index ac30213deac4..367c0329d5c8 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -369,19 +369,20 @@ static struct snd_soc_dai_driver max9867_dai[] = { .name = "max9867-aif1", .playback = { .stream_name = "HiFi Playback", - .channels_min = 1, + .channels_min = 2, .channels_max = 2, .rates = MAX9867_RATES, .formats = MAX9867_FORMATS, }, .capture = { .stream_name = "HiFi Capture", - .channels_min = 1, + .channels_min = 2, .channels_max = 2, .rates = MAX9867_RATES, .formats = MAX9867_FORMATS, }, .ops = &max9867_dai_ops, + .symmetric_rates = 1, } }; From 79e139744508105bd749300f364563934bff23f2 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 1 Mar 2018 15:21:30 +0100 Subject: [PATCH 411/942] ASoC: max9867: DSP mode Add configuration for DSP mode. Signed-off-by: Ladislav Michl Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 367c0329d5c8..0dbf3136e3ef 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -325,10 +325,16 @@ static int max9867_dai_set_fmt(struct snd_soc_dai *codec_dai, return -EINVAL; } - /* for i2s compatible mode */ - iface1A |= MAX9867_I2S_DLY; - /* SDOUT goes to hiz state after all data is transferred */ - iface1A |= MAX9867_SDOUT_HIZ; + switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_I2S: + iface1A |= MAX9867_I2S_DLY; + break; + case SND_SOC_DAIFMT_DSP_A: + iface1A |= MAX9867_TDM_MODE | MAX9867_SDOUT_HIZ; + break; + default: + return -EINVAL; + } /* Clock inversion bits, BCI and WCI */ switch (fmt & SND_SOC_DAIFMT_INV_MASK) { From 1f598e6861ab1d3cc46d6eff155c0a0a6736de38 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Thu, 1 Mar 2018 14:37:31 +0100 Subject: [PATCH 412/942] ASoC: atmel: Remove redundant dev_err() call in probe function There is an error message within devm_ioremap_resource already, so remove the redundant dev_err() call. Signed-off-by: Ladislav Michl Acked-by: Nicolas Ferre Acked-by: Alexandre Belloni Signed-off-by: Mark Brown --- sound/soc/atmel/atmel-classd.c | 7 ++----- sound/soc/atmel/atmel-pdmic.c | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 27bb55ca07ae..709a13221d79 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -582,11 +582,8 @@ static int atmel_classd_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); - if (IS_ERR(io_base)) { - ret = PTR_ERR(io_base); - dev_err(dev, "failed to remap register memory: %d\n", ret); - return ret; - } + if (IS_ERR(io_base)) + return PTR_ERR(io_base); dd->phy_base = res->start; diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index 5f72baa5f5c7..53217dfac5fe 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -631,11 +631,8 @@ static int atmel_pdmic_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); io_base = devm_ioremap_resource(dev, res); - if (IS_ERR(io_base)) { - ret = PTR_ERR(io_base); - dev_err(dev, "failed to remap register memory: %d\n", ret); - return ret; - } + if (IS_ERR(io_base)) + return PTR_ERR(io_base); dd->phy_base = res->start; From f0e8c61110c2c85903b136ba070daf643a8b6842 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 28 Feb 2018 11:57:50 +0100 Subject: [PATCH 413/942] Bluetooth: btusb: Remove Yoga 920 from the btusb_needs_reset_resume_table Commit 1fdb92697469 ("Bluetooth: btusb: Use DMI matching for QCA reset_resume quirking"), added the Lenovo Yoga 920 to the btusb_needs_reset_resume_table. Testing has shown that this is a false positive and the problems where caused by issues with the initial fix: commit fd865802c66b ("Bluetooth: btusb: fix QCA Rome suspend/resume"), which has already been reverted. So the QCA Rome BT in the Yoga 920 does not need a reset-resume quirk at all and this commit removes it from the btusb_needs_reset_resume_table. Note that after this commit the btusb_needs_reset_resume_table is now empty. It is kept around on purpose, since this whole series of commits started for a reason and there are actually broken platforms around, which need to be added to it. BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1514836 Fixes: 1fdb92697469 ("Bluetooth: btusb: Use DMI matching for QCA ...") Cc: stable@vger.kernel.org Cc: Brian Norris Cc: Kai-Heng Feng Tested-by: Kevin Fenzi Suggested-by: Brian Norris Signed-off-by: Hans de Goede Reviewed-by: Brian Norris Signed-off-by: Marcel Holtmann --- drivers/bluetooth/btusb.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 60bf04b8f103..041c17e0c668 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -385,13 +385,6 @@ static const struct usb_device_id blacklist_table[] = { * the module itself. So we use a DMI list to match known broken platforms. */ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { - { - /* Lenovo Yoga 920 (QCA Rome device 0cf3:e300) */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), - DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 920"), - }, - }, {} }; From 0c6e526646c04ce31d4aaa280ed2237dd1cd774c Mon Sep 17 00:00:00 2001 From: Kai-Heng Feng Date: Thu, 1 Mar 2018 13:42:52 +0800 Subject: [PATCH 414/942] Bluetooth: btusb: Add Dell OptiPlex 3060 to btusb_needs_reset_resume_table The issue can be reproduced before commit fd865802c66b ("Bluetooth: btusb: fix QCA Rome suspend/resume") gets introduced, so the reset resume quirk is still needed for this system. T: Bus=01 Lev=01 Prnt=01 Port=13 Cnt=01 Dev#= 4 Spd=12 MxCh= 0 D: Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=e007 Rev=00.01 C: #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I: If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb Cc: stable@vger.kernel.org Cc: Brian Norris Cc: Hans de Goede Signed-off-by: Kai-Heng Feng Signed-off-by: Marcel Holtmann --- drivers/bluetooth/btusb.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 041c17e0c668..382be00a8329 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -385,6 +385,13 @@ static const struct usb_device_id blacklist_table[] = { * the module itself. So we use a DMI list to match known broken platforms. */ static const struct dmi_system_id btusb_needs_reset_resume_table[] = { + { + /* Dell OptiPlex 3060 (QCA ROME device 0cf3:e007) */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 3060"), + }, + }, {} }; From 64e759f58f128730b97a3c3a26d283c075ad7c86 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 26 Feb 2018 15:41:53 +0100 Subject: [PATCH 415/942] Bluetooth: Fix missing encryption refresh on Security Request If Security Request is received on connection that is already encrypted with sufficient security master should perform encryption key refresh procedure instead of just ignoring Slave Security Request (Core Spec 5.0 Vol 3 Part H 2.4.6). > ACL Data RX: Handle 3585 flags 0x02 dlen 6 SMP: Security Request (0x0b) len 1 Authentication requirement: Bonding, No MITM, SC, No Keypresses (0x09) < HCI Command: LE Start Encryption (0x08|0x0019) plen 28 Handle: 3585 Random number: 0x0000000000000000 Encrypted diversifier: 0x0000 Long term key: 44264272a5c426a9e868f034cf0e69f3 > HCI Event: Command Status (0x0f) plen 4 LE Start Encryption (0x08|0x0019) ncmd 1 Status: Success (0x00) > HCI Event: Encryption Key Refresh Complete (0x30) plen 3 Status: Success (0x00) Handle: 3585 Signed-off-by: Szymon Janc Signed-off-by: Marcel Holtmann --- net/bluetooth/smp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 01117ae84f1d..a2ddae2f37d7 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c @@ -2296,8 +2296,14 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) else sec_level = authreq_to_seclevel(auth); - if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) + if (smp_sufficient_security(hcon, sec_level, SMP_USE_LTK)) { + /* If link is already encrypted with sufficient security we + * still need refresh encryption as per Core Spec 5.0 Vol 3, + * Part H 2.4.6 + */ + smp_ltk_encrypt(conn, hcon->sec_level); return 0; + } if (sec_level > hcon->pending_sec_level) hcon->pending_sec_level = sec_level; From d082174c99e77beb06a51c90ac61934554e516e1 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:48 +0100 Subject: [PATCH 416/942] ASoC: rt5651: Remove is_sys_clk_from_pll() is_sys_clk_from_pll() is used as a snd_soc_dapm_route.connected callback, checking RT5651_GBL_CLK to determine if the sys-clk is PLL1 and thus the PWR_PLL bit in reg PWR_ANLG2 must be set. RT5651_GBL_CLK is changed by rt5651_set_dai_sysclk(), which gets called by the pre_pmu / post_pmd functions of the "Platform Clock" dapm-supply. This creates an ordering issue, during a dapm transition first all connected() callbacks are called to build a list of supplies to enable and then the complete list is walked to enable the supplies. Since the connected() check happens before enabling any supplies, is_sys_clk_from_pll() ends up deciding if the PWR_PLL bit should be set based on the state the "Platform Clock" supply had *before* the transition. This sometimes results in PWR_PLL being off, even though *after* the transition PLL1 is configured as sys-clk. This commit removes is_sys_clk_from_pll() instead simply setting / clearing PWR_PLL in rt5651_set_dai_sysclk() based on the selected sys-clk, which fixes this and as a bonus results in a nice cleanup. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 4d93248b6401..8548f9406520 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -398,20 +398,6 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, return idx; } -static int is_sysclk_from_pll(struct snd_soc_dapm_widget *source, - struct snd_soc_dapm_widget *sink) -{ - struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); - unsigned int val; - - val = snd_soc_component_read32(component, RT5651_GLB_CLK); - val &= RT5651_SCLK_SRC_MASK; - if (val == RT5651_SCLK_SRC_PLL1) - return 1; - else - return 0; -} - /* Digital Mixer */ static const struct snd_kcontrol_new rt5651_sto1_adc_l_mix[] = { SOC_DAPM_SINGLE("ADC1 Switch", RT5651_STO1_ADC_MIXER, @@ -883,8 +869,6 @@ static const struct snd_soc_dapm_widget rt5651_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY_S("ADC ASRC", 1, RT5651_PLL_MODE_2, 11, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("PLL1", RT5651_PWR_ANLG2, - RT5651_PWR_PLL_BIT, 0, NULL, 0), /* Input Side */ SND_SOC_DAPM_SUPPLY("JD Power", RT5651_PWR_ANLG2, RT5651_PWM_JD_M_BIT, 0, NULL, 0), @@ -1167,7 +1151,6 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { {"Stereo1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux"}, {"Stereo1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux"}, {"Stereo1 ADC MIXL", NULL, "Stereo1 Filter"}, - {"Stereo1 Filter", NULL, "PLL1", is_sysclk_from_pll}, {"Stereo1 Filter", NULL, "ADC ASRC"}, {"Stereo1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux"}, @@ -1177,7 +1160,6 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { {"Stereo2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux"}, {"Stereo2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux"}, {"Stereo2 ADC MIXL", NULL, "Stereo2 Filter"}, - {"Stereo2 Filter", NULL, "PLL1", is_sysclk_from_pll}, {"Stereo2 Filter", NULL, "ADC ASRC"}, {"Stereo2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux"}, @@ -1244,10 +1226,8 @@ static const struct snd_soc_dapm_route rt5651_dapm_routes[] = { {"PDM R Mux", "DD MIX", "DAC MIXR"}, {"DAC L1", NULL, "Stereo DAC MIXL"}, - {"DAC L1", NULL, "PLL1", is_sysclk_from_pll}, {"DAC L1", NULL, "DAC L1 Power"}, {"DAC R1", NULL, "Stereo DAC MIXR"}, - {"DAC R1", NULL, "PLL1", is_sysclk_from_pll}, {"DAC R1", NULL, "DAC R1 Power"}, {"DD MIXL", "DAC L1 Switch", "DAC MIXL"}, @@ -1443,6 +1423,7 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, struct snd_soc_component *component = dai->component; struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); unsigned int reg_val = 0; + unsigned int pll_bit = 0; if (freq == rt5651->sysclk && clk_id == rt5651->sysclk_src) return 0; @@ -1453,6 +1434,7 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, break; case RT5651_SCLK_S_PLL1: reg_val |= RT5651_SCLK_SRC_PLL1; + pll_bit |= RT5651_PWR_PLL; break; case RT5651_SCLK_S_RCCLK: reg_val |= RT5651_SCLK_SRC_RCCLK; @@ -1461,6 +1443,8 @@ static int rt5651_set_dai_sysclk(struct snd_soc_dai *dai, dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); return -EINVAL; } + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, + RT5651_PWR_PLL, pll_bit); snd_soc_component_update_bits(component, RT5651_GLB_CLK, RT5651_SCLK_SRC_MASK, reg_val); rt5651->sysclk = freq; From 984c803f9a2ad6f1d2bea0b7ef2e3c18d69fbdfd Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:49 +0100 Subject: [PATCH 417/942] ASoC: rt5651: Fix bias_level confusion The rt5651_set_bias_level() function was turning everything off at SND_SOC_BIAS_STANDBY, rather then at SND_SOC_BIAS_OFF, requiring the bias- level to be raised to SND_SOC_BIAS_PREPARE before turning anything on. This is not how the bias-levels are supposed to work, this commit fixes this by turning everything off at the SND_SOC_BIAS_OFF level and enabling the pwr-bits needed for minimum functionality at SND_SOC_BIAS_STANDBY. This fixes the minimum set of pwr-bits not getting enabled when force-enabling some dapm-supplies (e.g. for jack type detection), which raises the bias-level to standby. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 8548f9406520..c565607f95f7 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1526,6 +1526,13 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { + if (snd_soc_component_read32(component, RT5651_PLL_MODE_1) & 0x9200) + snd_soc_component_update_bits(component, RT5651_D_MISC, + 0xc00, 0xc00); + } + break; + case SND_SOC_BIAS_STANDBY: + if (SND_SOC_BIAS_OFF == snd_soc_component_get_bias_level(component)) { snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_VREF1 | RT5651_PWR_MB | RT5651_PWR_BG | RT5651_PWR_VREF2, @@ -1539,13 +1546,10 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1); - if (snd_soc_component_read32(component, RT5651_PLL_MODE_1) & 0x9200) - snd_soc_component_update_bits(component, RT5651_D_MISC, - 0xc00, 0xc00); } break; - case SND_SOC_BIAS_STANDBY: + case SND_SOC_BIAS_OFF: snd_soc_component_write(component, RT5651_D_MISC, 0x0010); snd_soc_component_write(component, RT5651_PWR_DIG1, 0x0000); snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); From bba4e685dae8643469ca6fac22f10ca81554586e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:50 +0100 Subject: [PATCH 418/942] ASoC: rt5651: Do not modify the LDO voltage control bits from set_bias_level() The PWR_ANLG1 reg not only contains various power on/off bits, it also contains 2 bits which select if the LDO generates 1.0, 1.1 or 1.2V. Note there is a separate on/off bit for the LDO. rt5651_set_bias_level(BIAS_OFF) used to unconditionally clear the entire register, when jack-detection support was introduced a special case for jack-detect was added which hard-codes a register value to keep the LDO voltage at 1.2 volt. This commit removes the jack-detect special case, instead simply always leaving the LDO voltage control bits as is on BIAS_OFF. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c565607f95f7..c93539ee2200 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1555,11 +1555,12 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_write(component, RT5651_PWR_DIG2, 0x0000); snd_soc_component_write(component, RT5651_PWR_VOL, 0x0000); snd_soc_component_write(component, RT5651_PWR_MIXER, 0x0000); + /* Do not touch the LDO voltage select bits on bias-off */ + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, + ~RT5651_PWR_LDO_DVO_MASK, 0); if (rt5651->jd_src) { snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); - snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0002); } else { - snd_soc_component_write(component, RT5651_PWR_ANLG1, 0x0000); snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0000); } break; From 887fcc6f0514380f17d5016dd8cdfc4d9a4437ee Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:51 +0100 Subject: [PATCH 419/942] ASoC: rt5651: Do not modify jd and PLL power bits from set_bias_level() rt5651_set_bias_level(BIAS_OFF) used to unconditionally clear the entire register, including the jack-detect and PLL power bits. When jack-detection support was introduced a special case for jack-detect was added which hard-codes a register value to keep both on. This commit removes the jack-detect special case, instead simply leaving these bits as is on BIAS_OFF. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index c93539ee2200..d4fb16686889 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1521,8 +1521,6 @@ static int rt5651_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, static int rt5651_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { - struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - switch (level) { case SND_SOC_BIAS_PREPARE: if (SND_SOC_BIAS_STANDBY == snd_soc_component_get_bias_level(component)) { @@ -1558,11 +1556,9 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, /* Do not touch the LDO voltage select bits on bias-off */ snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, ~RT5651_PWR_LDO_DVO_MASK, 0); - if (rt5651->jd_src) { - snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0204); - } else { - snd_soc_component_write(component, RT5651_PWR_ANLG2, 0x0000); - } + /* Leave PLL1 and jack-detect power as is, all others off */ + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, + ~(RT5651_PWR_PLL | RT5651_PWR_JD_M), 0); break; default: From a25fe11746846f5dd3286cf690b470e3d049797f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:52 +0100 Subject: [PATCH 420/942] ASoC: rt5651: Remove programming of PWR regs before force_bias_level() call Remove the setup of the PWR_ANLG1 reg which was done directly before calling snd_soc_component_force_bias_level(SND_SOC_BIAS_OFF), as the latter will override any settings done to PWR_ANLG1 immediately anyways. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index d4fb16686889..74f83af3b6be 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1662,16 +1662,6 @@ static int rt5651_probe(struct snd_soc_component *component) rt5651->component = component; - snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, - RT5651_PWR_VREF1 | RT5651_PWR_MB | - RT5651_PWR_BG | RT5651_PWR_VREF2, - RT5651_PWR_VREF1 | RT5651_PWR_MB | - RT5651_PWR_BG | RT5651_PWR_VREF2); - usleep_range(10000, 15000); - snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, - RT5651_PWR_FV1 | RT5651_PWR_FV2, - RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); rt5651_apply_properties(component); From 3d7719d3cc8efe88be4c72cb7cbb0d866ed7d1b2 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:53 +0100 Subject: [PATCH 421/942] ASoC: rt5651: Only configure LDO voltage once at boot Now that rt5651_set_bias_level(BIAS_OFF) no longer modifies the LDO voltage selection bits, there is no need to set them each time we move to standby. Instead configure them once at component-probe() time. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 74f83af3b6be..9460bdcad349 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1540,9 +1540,6 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, RT5651_PWR_FV1 | RT5651_PWR_FV2, RT5651_PWR_FV1 | RT5651_PWR_FV2); - snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, - RT5651_PWR_LDO_DVO_MASK, - RT5651_PWR_LDO_DVO_1_2V); snd_soc_component_update_bits(component, RT5651_D_MISC, 0x1, 0x1); } break; @@ -1662,6 +1659,9 @@ static int rt5651_probe(struct snd_soc_component *component) rt5651->component = component; + snd_soc_component_update_bits(component, RT5651_PWR_ANLG1, + RT5651_PWR_LDO_DVO_MASK, RT5651_PWR_LDO_DVO_1_2V); + snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); rt5651_apply_properties(component); From 57d9d7c32fc24ca4de49392fec1fdd3db1f58e92 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:54 +0100 Subject: [PATCH 422/942] ASoC: rt5651: Remove "JD Power" dapm supply Remove the "JD power" dapm supply which gets force-enabled once when using jack-detect and never gets disabled again. Since the PWR_JD_M bit simply needs to be always on when using jack-detect there is no need to have it tracked by dapm, instead we can simply set it to 1 once when initializing the jack-detection. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 9460bdcad349..cbf9f56ecb14 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -869,10 +869,6 @@ static const struct snd_soc_dapm_widget rt5651_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY_S("ADC ASRC", 1, RT5651_PLL_MODE_2, 11, 0, NULL, 0), - /* Input Side */ - SND_SOC_DAPM_SUPPLY("JD Power", RT5651_PWR_ANLG2, - RT5651_PWM_JD_M_BIT, 0, NULL, 0), - /* micbias */ SND_SOC_DAPM_SUPPLY("LDO", RT5651_PWR_ANLG1, RT5651_PWR_LDO_BIT, 0, NULL, 0), @@ -1616,7 +1612,10 @@ static int rt5651_set_jack(struct snd_soc_component *component, return -EINVAL; } - snd_soc_dapm_force_enable_pin(dapm, "JD Power"); + /* Enable jack detect power */ + snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, + RT5651_PWR_JD_M, RT5651_PWR_JD_M); + snd_soc_dapm_force_enable_pin(dapm, "LDO"); snd_soc_dapm_sync(dapm); From 1310e737a68741c9b06cf63be0084bae6018b308 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:55 +0100 Subject: [PATCH 423/942] ASoC: rt5651: Enable LDO and micbias1 supplies for jack-type detection To determine if a plugged in jack is a headset (speakers + mic) or headphones (mic contact shorted to ground) we use the micbias1 OVer Current Detect (OVCD) functionality. For this to work we need to have a micbias current to actually cause an overcurrent condition when headphones are plugged in, so jack-type detection requires both the LDO and micbias1 supplies to be on. Before this commit there were 2 issues with the handling of this: 1) The LDO supply was force-enabled twice and never disabled again even though it only needs to be forced on when doing jack-type detection 2) micbias1 was not force-enabled, and thus may be off when doing jack-type detection This commit fixes both by force-enabling the LDO and micbias1 supplies before checking for an overcurrent condition and disabling them afterwards. Note that both supplies will still get turned on normally (and OVCD will protect against overcurrent) when the micbias1 is enabled normally because the user has activated a sound stream recording from the mic. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index cbf9f56ecb14..be942886700d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1561,6 +1561,28 @@ static int rt5651_set_bias_level(struct snd_soc_component *component, return 0; } +static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + + snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO"); + snd_soc_dapm_force_enable_pin_unlocked(dapm, "micbias1"); + snd_soc_dapm_sync_unlocked(dapm); + snd_soc_dapm_mutex_unlock(dapm); +} + +static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component) +{ + struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); + + snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_disable_pin_unlocked(dapm, "micbias1"); + snd_soc_dapm_disable_pin_unlocked(dapm, "LDO"); + snd_soc_dapm_sync_unlocked(dapm); + snd_soc_dapm_mutex_unlock(dapm); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1574,7 +1596,6 @@ static irqreturn_t rt5651_irq(int irq, void *data) static int rt5651_set_jack(struct snd_soc_component *component, struct snd_soc_jack *hp_jack, void *data) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); int ret; @@ -1616,9 +1637,6 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); rt5651->hp_jack = hp_jack; @@ -1819,13 +1837,10 @@ static const struct dmi_system_id rt5651_quirk_table[] = { static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { - struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); int jack_type; if (jack_insert) { - snd_soc_dapm_force_enable_pin(dapm, "LDO"); - snd_soc_dapm_sync(dapm); - + rt5651_enable_micbias1_for_ovcd(component); snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | @@ -1842,6 +1857,7 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse jack_type = SND_JACK_HEADSET; snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, RT5651_MB1_OC_CLR, 0); + rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0; From 9e1795925d0e967d2a0191b1487b5caf0693f2ae Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:56 +0100 Subject: [PATCH 424/942] ASoC: rt5651: Only configure OVCD once at set_jack time Only configure OVCD once at set_jack time, rather then configuring it on every jack-insertion event and switch to using bit field defines instead of hardcoding a magic value. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index be942886700d..41d7c192ac03 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1637,7 +1637,15 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); - snd_soc_component_update_bits(component, RT5651_MICBIAS, 0x38, 0x38); + snd_soc_component_update_bits(component, RT5651_MICBIAS, + RT5651_MIC1_OVCD_MASK | + RT5651_MIC1_OVTH_MASK | + RT5651_PWR_CLK12M_MASK | + RT5651_PWR_MB_MASK, + RT5651_MIC1_OVCD_DIS | + RT5651_MIC1_OVTH_600UA | + RT5651_PWR_MB_PU | + RT5651_PWR_CLK12M_PU); rt5651->hp_jack = hp_jack; @@ -1842,14 +1850,8 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); snd_soc_component_update_bits(component, RT5651_MICBIAS, - RT5651_MIC1_OVCD_MASK | - RT5651_MIC1_OVTH_MASK | - RT5651_PWR_CLK12M_MASK | - RT5651_PWR_MB_MASK, - RT5651_MIC1_OVCD_EN | - RT5651_MIC1_OVTH_600UA | - RT5651_PWR_MB_PU | - RT5651_PWR_CLK12M_PU); + RT5651_MIC1_OVCD_MASK, + RT5651_MIC1_OVCD_EN); msleep(100); if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) jack_type = SND_JACK_HEADPHONE; From f1088d4b813fb4d20fc9e8e8db5ca252923f25eb Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 11:46:57 +0100 Subject: [PATCH 425/942] ASoC: rt5651: Always keep OVCD enabled OVCD is not only useful for jack-type detection, but is also useful to protect against over-current faults in general, so always keep OVCD enabled, instead of only enabling it for jack-type detection. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 41d7c192ac03..55bcc74e344f 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1642,7 +1642,7 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_MIC1_OVTH_MASK | RT5651_PWR_CLK12M_MASK | RT5651_PWR_MB_MASK, - RT5651_MIC1_OVCD_DIS | + RT5651_MIC1_OVCD_EN | RT5651_MIC1_OVTH_600UA | RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); @@ -1849,9 +1849,6 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); - snd_soc_component_update_bits(component, RT5651_MICBIAS, - RT5651_MIC1_OVCD_MASK, - RT5651_MIC1_OVCD_EN); msleep(100); if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) jack_type = SND_JACK_HEADPHONE; @@ -1862,10 +1859,6 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0; - - snd_soc_component_update_bits(component, RT5651_MICBIAS, - RT5651_MIC1_OVCD_MASK, - RT5651_MIC1_OVCD_DIS); } return jack_type; From 29838a5c1e77ed93d41fb9837390e243b9b73518 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 30 Jan 2018 14:19:42 +0100 Subject: [PATCH 426/942] ASoC: rt5514: Fix rt5514_spi_burst_read() buffer passing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rt5514_dsp_voice_wake_up_put() passes "(u8 *)&buf" to rt5514_spi_burst_read(), where the cast is needed to silence a compiler warning: sound/soc/codecs/rt5514.c: In function ‘rt5514_dsp_voice_wake_up_put’: sound/soc/codecs/rt5514.c:357: warning: passing argument 2 of ‘rt5514_spi_burst_read’ from incompatible pointer type However, as the variable is declared as an array ("u8 buf[8]"), the function should just pass "buf" instead. Fixes: fc9cab05837639ce ("ASoC: rt5514: The DSP clock can be calibrated by the other clock source") Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index 2d79571098ac..b358704ee19c 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -353,8 +353,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, msleep(20); #if IS_ENABLED(CONFIG_SND_SOC_RT5514_SPI) rt5514_spi_burst_read(RT5514_PLL3_CALIB_CTRL6 | - RT5514_DSP_MAPPING, - (u8 *)&buf, sizeof(buf)); + RT5514_DSP_MAPPING, buf, sizeof(buf)); #else dev_err(component->dev, "There is no SPI driver for" " loading the firmware\n"); From 890861aa85043cc9d99a01e1bd26883722e95243 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Tue, 30 Jan 2018 14:19:43 +0100 Subject: [PATCH 427/942] ASoC: rt5514: Fix uninitialized calibration value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With gcc-4.1.2, if CONFIG_SND_SOC_RT5514_SPI is not set: sound/soc/codecs/rt5514.c: In function ‘rt5514_dsp_voice_wake_up_put’: sound/soc/codecs/rt5514.c:363: warning: ‘buf[0]’ is used uninitialized in this function sound/soc/codecs/rt5514.c:363: warning: ‘buf[1]’ is used uninitialized in this function sound/soc/codecs/rt5514.c:363: warning: ‘buf[2]’ is used uninitialized in this function sound/soc/codecs/rt5514.c:363: warning: ‘buf[3]’ is used uninitialized in this function Fix this by initializing the buffer with zeroes, to avoid random bits being written to the calibration register later. Fixes: fc9cab05837639ce ("ASoC: rt5514: The DSP clock can be calibrated by the other clock source") Signed-off-by: Geert Uytterhoeven Signed-off-by: Mark Brown --- sound/soc/codecs/rt5514.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/rt5514.c b/sound/soc/codecs/rt5514.c index b358704ee19c..e8a66b03faab 100644 --- a/sound/soc/codecs/rt5514.c +++ b/sound/soc/codecs/rt5514.c @@ -357,6 +357,7 @@ static int rt5514_dsp_voice_wake_up_put(struct snd_kcontrol *kcontrol, #else dev_err(component->dev, "There is no SPI driver for" " loading the firmware\n"); + memset(buf, 0, sizeof(buf)); #endif rt5514->pll3_cal_value = buf[0] | buf[1] << 8 | buf[2] << 16 | buf[3] << 24; From cb1f904d91c52bc4e03e11eb161288c40c655095 Mon Sep 17 00:00:00 2001 From: Guneshwor Singh Date: Sat, 27 Jan 2018 09:50:21 +0530 Subject: [PATCH 428/942] ASoC: Intel: Skylake: Refine skl widget type check The current check is not effective when all the widgets of a card are involved since other widgets also can be of same type. So, make widget type check more stringent by checking dev pointer additionally. Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-topology.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 73af6e19ebbd..dbe6a19b84f5 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -94,8 +94,12 @@ void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps) * SKL DSP driver modelling uses only few DAPM widgets so for rest we will * ignore. This helpers checks if the SKL driver handles this widget type */ -static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w) +static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w, + struct device *dev) { + if (w->dapm->dev != dev) + return false; + switch (w->id) { case snd_soc_dapm_dai_link: case snd_soc_dapm_dai_in: @@ -969,7 +973,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, next_sink = p->sink; - if (!is_skl_dsp_widget_type(p->sink)) + if (!is_skl_dsp_widget_type(p->sink, ctx->dev)) return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig); /* @@ -978,7 +982,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, * they are ones used for SKL so check that first */ if ((p->sink->priv != NULL) && - is_skl_dsp_widget_type(p->sink)) { + is_skl_dsp_widget_type(p->sink, ctx->dev)) { sink = p->sink; sink_mconfig = sink->priv; @@ -1092,7 +1096,7 @@ static struct snd_soc_dapm_widget *skl_get_src_dsp_widget( * ones used for SKL so check that first */ if ((p->source->priv != NULL) && - is_skl_dsp_widget_type(p->source)) { + is_skl_dsp_widget_type(p->source, ctx->dev)) { return p->source; } } @@ -1654,7 +1658,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) w = dai->playback_widget; snd_soc_dapm_widget_for_each_sink_path(w, p) { if (p->connect && p->sink->power && - !is_skl_dsp_widget_type(p->sink)) + !is_skl_dsp_widget_type(p->sink, dai->dev)) continue; if (p->sink->priv) { @@ -1667,7 +1671,7 @@ skl_tplg_fe_get_cpr_module(struct snd_soc_dai *dai, int stream) w = dai->capture_widget; snd_soc_dapm_widget_for_each_source_path(w, p) { if (p->connect && p->source->power && - !is_skl_dsp_widget_type(p->source)) + !is_skl_dsp_widget_type(p->source, dai->dev)) continue; if (p->source->priv) { @@ -1819,7 +1823,7 @@ static int skl_tplg_be_set_src_pipe_params(struct snd_soc_dai *dai, int ret = -EIO; snd_soc_dapm_widget_for_each_source_path(w, p) { - if (p->connect && is_skl_dsp_widget_type(p->source) && + if (p->connect && is_skl_dsp_widget_type(p->source, dai->dev) && p->source->priv) { ret = skl_tplg_be_fill_pipe_params(dai, @@ -1844,7 +1848,7 @@ static int skl_tplg_be_set_sink_pipe_params(struct snd_soc_dai *dai, int ret = -EIO; snd_soc_dapm_widget_for_each_sink_path(w, p) { - if (p->connect && is_skl_dsp_widget_type(p->sink) && + if (p->connect && is_skl_dsp_widget_type(p->sink, dai->dev) && p->sink->priv) { ret = skl_tplg_be_fill_pipe_params(dai, @@ -2752,7 +2756,7 @@ void skl_cleanup_resources(struct skl *skl) skl->resource.mcps = 0; list_for_each_entry(w, &card->widgets, list) { - if (is_skl_dsp_widget_type(w) && (w->priv != NULL)) + if (is_skl_dsp_widget_type(w, ctx->dev) && w->priv != NULL) skl_clear_pin_config(soc_platform, w); } @@ -3408,7 +3412,7 @@ static int skl_tplg_create_pipe_widget_list(struct snd_soc_platform *platform) struct skl_pipe *pipe; list_for_each_entry(w, &platform->component.card->widgets, list) { - if (is_skl_dsp_widget_type(w) && w->priv != NULL) { + if (is_skl_dsp_widget_type(w, platform->dev) && w->priv) { mcfg = w->priv; pipe = mcfg->pipe; From 66b4860641cd459cd5e189ed5db6e9f339c31a0f Mon Sep 17 00:00:00 2001 From: "Pawse, GuruprasadX" Date: Sat, 27 Jan 2018 09:50:22 +0530 Subject: [PATCH 429/942] ASoC: Intel: Skylake: Add BE DAI for WoV usecase Currently DMIC capture and WoV usecase uses same BE DAI but operate at different sampling rates, this results in config mismatch for WoV when DMIC is already running in parallel. DMIC has two slots which can operate with some constraints, so add BE DAI for DMICvoice pin which can used for WoV usecases to capture 4ch, 16KHz, 16bit data. Signed-off-by: Pawse, GuruprasadX Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index e46828533826..2685d511c06f 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -958,6 +958,17 @@ static struct snd_soc_dai_driver skl_platform_dai[] = { .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE, }, }, +{ + .name = "DMIC16k Pin", + .ops = &skl_dmic_dai_ops, + .capture = { + .stream_name = "DMIC16k Rx", + .channels_min = HDA_MONO, + .channels_max = HDA_QUAD, + .rates = SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + }, +}, { .name = "HD-Codec Pin", .ops = &skl_link_dai_ops, From 8913f97d2317f363d4d525fdbff5817942bda6d1 Mon Sep 17 00:00:00 2001 From: "Pawse, GuruprasadX" Date: Sat, 27 Jan 2018 09:50:23 +0530 Subject: [PATCH 430/942] ASoC: Intel: board: Add BE DAI link for WoV and update DAPM machine map. Create BE DAI link for WoV and accordingly update the DAPM machine map Signed-off-by: Pawse, GuruprasadX Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/boards/bxt_rt298.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/soc/intel/boards/bxt_rt298.c b/sound/soc/intel/boards/bxt_rt298.c index 875d85119c66..c7e9024e65ef 100644 --- a/sound/soc/intel/boards/bxt_rt298.c +++ b/sound/soc/intel/boards/bxt_rt298.c @@ -146,6 +146,9 @@ static const struct snd_soc_dapm_route geminilake_rt298_map[] = { { "dmic01_hifi", NULL, "DMIC01 Rx" }, { "DMIC01 Rx", NULL, "Capture" }, + { "dmic_voice", NULL, "DMIC16k Rx" }, + { "DMIC16k Rx", NULL, "Capture" }, + { "hifi3", NULL, "iDisp3 Tx"}, { "iDisp3 Tx", NULL, "iDisp3_out"}, { "hifi2", NULL, "iDisp2 Tx"}, @@ -456,6 +459,18 @@ static struct snd_soc_dai_link broxton_rt298_dais[] = { .dpcm_capture = 1, .no_pcm = 1, }, + { + .name = "dmic16k", + .id = 2, + .cpu_dai_name = "DMIC16k Pin", + .codec_name = "dmic-codec", + .codec_dai_name = "dmic-hifi", + .platform_name = "0000:00:0e.0", + .be_hw_params_fixup = broxton_dmic_fixup, + .ignore_suspend = 1, + .dpcm_capture = 1, + .no_pcm = 1, + }, { .name = "iDisp1", .id = 3, From f7a9f77256e7fbd6150651bfab44f60c39f0b7a2 Mon Sep 17 00:00:00 2001 From: Sriram Periyasamy Date: Sat, 27 Jan 2018 09:50:24 +0530 Subject: [PATCH 431/942] ASoC: Intel: Skylake: Find module id from UUID for bind params Module id is a property of firmware manifest and can vary across platforms. So use the uuid to find module id dynamically for bind params like kpb post bind params. Signed-off-by: Sriram Periyasamy Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-pcm.c | 2 + sound/soc/intel/skylake/skl-topology.c | 83 +++++++++++++++++++++++++- sound/soc/intel/skylake/skl-topology.h | 13 +++- 3 files changed, 96 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 2685d511c06f..91d858e25fce 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1318,6 +1318,8 @@ static int skl_populate_modules(struct skl *skl) "query module info failed\n"); return ret; } + + skl_tplg_add_moduleid_in_bind_params(skl, w); } } diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index dbe6a19b84f5..17da3b58c214 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -830,7 +830,7 @@ static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params, if (mcfg->m_type == SKL_MODULE_TYPE_KPB) { struct skl_kpb_params *kpb_params = (struct skl_kpb_params *)params; - struct skl_mod_inst_map *inst = kpb_params->map; + struct skl_mod_inst_map *inst = kpb_params->u.map; for (i = 0; i < kpb_params->num_modules; i++) { pvt_id = skl_get_pvt_instance_id_map(ctx, inst->mod_id, @@ -915,6 +915,87 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w, return 0; } +static int skl_get_module_id(struct skl_sst *ctx, uuid_le *uuid) +{ + struct uuid_module *module; + + list_for_each_entry(module, &ctx->uuid_list, list) { + if (uuid_le_cmp(*uuid, module->uuid) == 0) + return module->id; + } + + return -EINVAL; +} + +static int skl_tplg_find_moduleid_from_uuid(struct skl *skl, + const struct snd_kcontrol_new *k) +{ + struct soc_bytes_ext *sb = (void *) k->private_value; + struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private; + struct skl_kpb_params *uuid_params, *params; + struct hdac_bus *bus = ebus_to_hbus(skl_to_ebus(skl)); + int i, size, module_id; + + if (bc->set_params == SKL_PARAM_BIND && bc->max) { + uuid_params = (struct skl_kpb_params *)bc->params; + size = uuid_params->num_modules * + sizeof(struct skl_mod_inst_map) + + sizeof(uuid_params->num_modules); + + params = devm_kzalloc(bus->dev, size, GFP_KERNEL); + if (!params) + return -ENOMEM; + + params->num_modules = uuid_params->num_modules; + + for (i = 0; i < uuid_params->num_modules; i++) { + module_id = skl_get_module_id(skl->skl_sst, + &uuid_params->u.map_uuid[i].mod_uuid); + if (module_id < 0) { + devm_kfree(bus->dev, params); + return -EINVAL; + } + + params->u.map[i].mod_id = module_id; + params->u.map[i].inst_id = + uuid_params->u.map_uuid[i].inst_id; + } + + devm_kfree(bus->dev, bc->params); + bc->params = (char *)params; + bc->max = size; + } + + return 0; +} + +/* + * Retrieve the module id from UUID mentioned in the + * post bind params + */ +void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, + struct snd_soc_dapm_widget *w) +{ + struct skl_module_cfg *mconfig = w->priv; + int i; + + /* + * Post bind params are used for only for KPB + * to set copier instances to drain the data + * in fast mode + */ + if (mconfig->m_type != SKL_MODULE_TYPE_KPB) + return; + + for (i = 0; i < w->num_kcontrols; i++) + if ((w->kcontrol_news[i].access & + SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) && + (skl_tplg_find_moduleid_from_uuid(skl, + &w->kcontrol_news[i]) < 0)) + dev_err(skl->skl_sst->dev, + "%s: invalid kpb post bind params\n", + __func__); +} static int skl_tplg_module_add_deferred_bind(struct skl *skl, struct skl_module_cfg *src, struct skl_module_cfg *dst) diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h index b6496513fe55..a467129cc705 100644 --- a/sound/soc/intel/skylake/skl-topology.h +++ b/sound/soc/intel/skylake/skl-topology.h @@ -221,9 +221,18 @@ struct skl_mod_inst_map { u16 inst_id; }; +struct skl_uuid_inst_map { + u16 inst_id; + u16 reserved; + uuid_le mod_uuid; +} __packed; + struct skl_kpb_params { u32 num_modules; - struct skl_mod_inst_map map[0]; + union { + struct skl_mod_inst_map map[0]; + struct skl_uuid_inst_map map_uuid[0]; + } u; }; struct skl_module_inst_id { @@ -505,4 +514,6 @@ int skl_pcm_link_dma_prepare(struct device *dev, int skl_dai_load(struct snd_soc_component *cmp, struct snd_soc_dai_driver *pcm_dai); +void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, + struct snd_soc_dapm_widget *w); #endif From 6f54120e17e311fd7ac42b9ec2a0611caa5b46ad Mon Sep 17 00:00:00 2001 From: Jason Yan Date: Wed, 28 Feb 2018 09:11:10 +0800 Subject: [PATCH 432/942] ata: do not schedule hot plug if it is a sas host We've got a kernel panic when using sata disk with sas controller: [115946.152283] Unable to handle kernel NULL pointer dereference at virtual address 000007d8 [115946.223963] CPU: 0 PID: 22175 Comm: kworker/0:1 Tainted: G W OEL 4.14.0 #1 [115946.232925] Workqueue: events ata_scsi_hotplug [115946.237938] task: ffff8021ee50b180 task.stack: ffff00000d5d0000 [115946.244717] PC is at sas_find_dev_by_rphy+0x44/0x114 [115946.250224] LR is at sas_find_dev_by_rphy+0x3c/0x114 ...... [115946.355701] Process kworker/0:1 (pid: 22175, stack limit = 0xffff00000d5d0000) [115946.363369] Call trace: [115946.456356] [] sas_find_dev_by_rphy+0x44/0x114 [115946.462908] [] sas_target_alloc+0x20/0x5c [115946.469408] [] scsi_alloc_target+0x250/0x308 [115946.475781] [] __scsi_add_device+0xb0/0x154 [115946.481991] [] ata_scsi_scan_host+0x180/0x218 [115946.488367] [] ata_scsi_hotplug+0xb0/0xcc [115946.494801] [] process_one_work+0x144/0x390 [115946.501115] [] worker_thread+0x144/0x418 [115946.507093] [] kthread+0x10c/0x138 [115946.512792] [] ret_from_fork+0x10/0x18 We found that Ding Xiang has reported a similar bug before: https://patchwork.kernel.org/patch/9179817/ And this bug still exists in mainline. Since libsas handles hotplug and device adding/removing itself, do not need to schedule ata hot plug task here if it is a sas host. Signed-off-by: Jason Yan Cc: Ding Xiang Cc: stable@vger.kernel.org Signed-off-by: Tejun Heo --- drivers/ata/libata-eh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 11c3137d7b0a..c016829a38fd 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c @@ -815,7 +815,8 @@ void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap) if (ap->pflags & ATA_PFLAG_LOADING) ap->pflags &= ~ATA_PFLAG_LOADING; - else if (ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) + else if ((ap->pflags & ATA_PFLAG_SCSI_HOTPLUG) && + !(ap->flags & ATA_FLAG_SAS_HOST)) schedule_delayed_work(&ap->hotplug_task, 0); if (ap->pflags & ATA_PFLAG_RECOVERED) From 7f8ae00f63725e835b5ed8a97bc18bf1c950acb2 Mon Sep 17 00:00:00 2001 From: Haim Dreyfuss Date: Wed, 27 Dec 2017 15:21:18 +0200 Subject: [PATCH 433/942] iwlwifi: Cancel and set MARKER_CMD timer during suspend-resume While entering to D3 mode there is a gap between the time the driver handles the D3_CONFIG_CMD response to the time the host is going to sleep. In between there might be cases which MARKER_CMD can tailgate. Also during resume flow the MARKER_CMD might get sent while D0I3_CMD is being handled in the FW. Cancel MARKER_CMD timer and set it again properly during suspend resume flows to prevent this command from being sent accidentlly. Signed-off-by: Haim Dreyfuss Signed-off-by: Luca Coelho --- .../net/wireless/intel/iwlwifi/fw/debugfs.h | 18 ++++++++++++++++++ drivers/net/wireless/intel/iwlwifi/fw/init.c | 12 ++++++++++++ .../net/wireless/intel/iwlwifi/fw/runtime.h | 4 ++++ drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 8 ++++++++ 4 files changed, 42 insertions(+) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h index e57ff92a68ae..3da468d2cc92 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/debugfs.h @@ -75,6 +75,20 @@ static inline void iwl_fw_cancel_timestamp(struct iwl_fw_runtime *fwrt) cancel_delayed_work_sync(&fwrt->timestamp.wk); } +static inline void iwl_fw_suspend_timestamp(struct iwl_fw_runtime *fwrt) +{ + cancel_delayed_work_sync(&fwrt->timestamp.wk); +} + +static inline void iwl_fw_resume_timestamp(struct iwl_fw_runtime *fwrt) +{ + if (!fwrt->timestamp.delay) + return; + + schedule_delayed_work(&fwrt->timestamp.wk, + round_jiffies_relative(fwrt->timestamp.delay)); +} + #else static inline int iwl_fwrt_dbgfs_register(struct iwl_fw_runtime *fwrt, struct dentry *dbgfs_dir) @@ -84,4 +98,8 @@ static inline int iwl_fwrt_dbgfs_register(struct iwl_fw_runtime *fwrt, static inline void iwl_fw_cancel_timestamp(struct iwl_fw_runtime *fwrt) {} +static inline void iwl_fw_suspend_timestamp(struct iwl_fw_runtime *fwrt) {} + +static inline void iwl_fw_resume_timestamp(struct iwl_fw_runtime *fwrt) {} + #endif /* CONFIG_IWLWIFI_DEBUGFS */ diff --git a/drivers/net/wireless/intel/iwlwifi/fw/init.c b/drivers/net/wireless/intel/iwlwifi/fw/init.c index 45f21acbd842..2efac307909e 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/init.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/init.c @@ -76,3 +76,15 @@ void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans, iwl_fwrt_dbgfs_register(fwrt, dbgfs_dir); } IWL_EXPORT_SYMBOL(iwl_fw_runtime_init); + +void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt) +{ + iwl_fw_suspend_timestamp(fwrt); +} +IWL_EXPORT_SYMBOL(iwl_fw_runtime_suspend); + +void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt) +{ + iwl_fw_resume_timestamp(fwrt); +} +IWL_EXPORT_SYMBOL(iwl_fw_runtime_resume); diff --git a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h index e25c049f980f..f3197f7c13b6 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h @@ -150,6 +150,10 @@ void iwl_fw_runtime_init(struct iwl_fw_runtime *fwrt, struct iwl_trans *trans, void iwl_fw_runtime_exit(struct iwl_fw_runtime *fwrt); +void iwl_fw_runtime_suspend(struct iwl_fw_runtime *fwrt); + +void iwl_fw_runtime_resume(struct iwl_fw_runtime *fwrt); + static inline void iwl_fw_set_current_image(struct iwl_fw_runtime *fwrt, enum iwl_ucode_type cur_fw_img) { diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c index 0e6cf39285f4..2efe9b099556 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c @@ -1098,6 +1098,8 @@ int iwl_mvm_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan) /* make sure the d0i3 exit work is not pending */ flush_work(&mvm->d0i3_exit_work); + iwl_fw_runtime_suspend(&mvm->fwrt); + ret = iwl_trans_suspend(trans); if (ret) return ret; @@ -2012,6 +2014,8 @@ int iwl_mvm_resume(struct ieee80211_hw *hw) mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED; + iwl_fw_runtime_resume(&mvm->fwrt); + return ret; } @@ -2038,6 +2042,8 @@ static int iwl_mvm_d3_test_open(struct inode *inode, struct file *file) mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_D3; + iwl_fw_runtime_suspend(&mvm->fwrt); + /* start pseudo D3 */ rtnl_lock(); err = __iwl_mvm_suspend(mvm->hw, mvm->hw->wiphy->wowlan_config, true); @@ -2098,6 +2104,8 @@ static int iwl_mvm_d3_test_release(struct inode *inode, struct file *file) __iwl_mvm_resume(mvm, true); rtnl_unlock(); + iwl_fw_runtime_resume(&mvm->fwrt); + mvm->trans->system_pm_mode = IWL_PLAT_PM_MODE_DISABLED; iwl_abort_notification_waits(&mvm->notif_wait); From de04d4fbf87b769ab18c480e4f020c53e74bbdd2 Mon Sep 17 00:00:00 2001 From: Sara Sharon Date: Tue, 2 Jan 2018 11:40:15 +0200 Subject: [PATCH 434/942] iwlwifi: mvm: fix TX of CCMP 256 We don't have enough room in the TX command for a CCMP 256 key, and need to use key from table. Fixes: 3264bf032bd9 ("[BUGFIX] iwlwifi: mvm: Fix CCMP IV setting") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index dda77b327c98..57ad6019ffad 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c @@ -419,11 +419,11 @@ static void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm, { struct ieee80211_key_conf *keyconf = info->control.hw_key; u8 *crypto_hdr = skb_frag->data + hdrlen; + enum iwl_tx_cmd_sec_ctrl type = TX_CMD_SEC_CCM; u64 pn; switch (keyconf->cipher) { case WLAN_CIPHER_SUITE_CCMP: - case WLAN_CIPHER_SUITE_CCMP_256: iwl_mvm_set_tx_cmd_ccmp(info, tx_cmd); iwl_mvm_set_tx_cmd_pn(info, crypto_hdr); break; @@ -447,13 +447,16 @@ static void iwl_mvm_set_tx_cmd_crypto(struct iwl_mvm *mvm, break; case WLAN_CIPHER_SUITE_GCMP: case WLAN_CIPHER_SUITE_GCMP_256: + type = TX_CMD_SEC_GCMP; + /* Fall through */ + case WLAN_CIPHER_SUITE_CCMP_256: /* TODO: Taking the key from the table might introduce a race * when PTK rekeying is done, having an old packets with a PN * based on the old key but the message encrypted with a new * one. * Need to handle this. */ - tx_cmd->sec_ctl |= TX_CMD_SEC_GCMP | TX_CMD_SEC_KEY_FROM_TABLE; + tx_cmd->sec_ctl |= type | TX_CMD_SEC_KEY_FROM_TABLE; tx_cmd->key[0] = keyconf->hw_key_idx; iwl_mvm_set_tx_cmd_pn(info, crypto_hdr); break; From 40d53f4a60c9eb10d4fa58066c23ba1af8a59e39 Mon Sep 17 00:00:00 2001 From: Andrei Otcheretianski Date: Thu, 4 Jan 2018 17:39:08 +0200 Subject: [PATCH 435/942] iwlwifi: mvm: Fix channel switch for count 0 and 1 It was assumed that apply_time==0 implies immediate scheduling, which is wrong. Instead, the fw expects the START_IMMEDIATELY flag to be set. Otherwise, this resulted in 0x3063 assert. Fix that. While at it rename the T2_V2_START_IMMEDIATELY to TE_V2_START_IMMEDIATELY. Fixes: f5d8f50f271d ("iwlwifi: mvm: Fix channel switch in case of count <= 1") Signed-off-by: Andrei Otcheretianski Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h | 4 ++-- drivers/net/wireless/intel/iwlwifi/mvm/time-event.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h b/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h index 3721a3ed358b..f824bebceb06 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/api/time-event.h @@ -211,7 +211,7 @@ enum { * @TE_V2_NOTIF_HOST_FRAG_END:request/receive notification on frag end * @TE_V2_NOTIF_INTERNAL_FRAG_START: internal FW use. * @TE_V2_NOTIF_INTERNAL_FRAG_END: internal FW use. - * @T2_V2_START_IMMEDIATELY: start time event immediately + * @TE_V2_START_IMMEDIATELY: start time event immediately * @TE_V2_DEP_OTHER: depends on another time event * @TE_V2_DEP_TSF: depends on a specific time * @TE_V2_EVENT_SOCIOPATHIC: can't co-exist with other events of tha same MAC @@ -230,7 +230,7 @@ enum iwl_time_event_policy { TE_V2_NOTIF_HOST_FRAG_END = BIT(5), TE_V2_NOTIF_INTERNAL_FRAG_START = BIT(6), TE_V2_NOTIF_INTERNAL_FRAG_END = BIT(7), - T2_V2_START_IMMEDIATELY = BIT(11), + TE_V2_START_IMMEDIATELY = BIT(11), /* placement characteristics */ TE_V2_DEP_OTHER = BIT(TE_V2_PLACEMENT_POS), diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c b/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c index 200ab50ec86b..acb217e666db 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/time-event.c @@ -616,7 +616,7 @@ void iwl_mvm_protect_session(struct iwl_mvm *mvm, time_cmd.repeat = 1; time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START | TE_V2_NOTIF_HOST_EVENT_END | - T2_V2_START_IMMEDIATELY); + TE_V2_START_IMMEDIATELY); if (!wait_for_notif) { iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); @@ -803,7 +803,7 @@ int iwl_mvm_start_p2p_roc(struct iwl_mvm *mvm, struct ieee80211_vif *vif, time_cmd.repeat = 1; time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START | TE_V2_NOTIF_HOST_EVENT_END | - T2_V2_START_IMMEDIATELY); + TE_V2_START_IMMEDIATELY); return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); } @@ -913,6 +913,8 @@ int iwl_mvm_schedule_csa_period(struct iwl_mvm *mvm, time_cmd.interval = cpu_to_le32(1); time_cmd.policy = cpu_to_le16(TE_V2_NOTIF_HOST_EVENT_START | TE_V2_ABSENCE); + if (!apply_time) + time_cmd.policy |= cpu_to_le16(TE_V2_START_IMMEDIATELY); return iwl_mvm_time_event_send_add(mvm, vif, te_data, &time_cmd); } From 63dd5d022f4766e6b05ee611124afcc7cbfbb953 Mon Sep 17 00:00:00 2001 From: Sara Sharon Date: Sun, 7 Jan 2018 14:30:49 +0200 Subject: [PATCH 436/942] iwlwifi: mvm: fix assert 0x2B00 on older FWs We should add the multicast station before adding the broadcast station. However, in older FW, the firmware will start beaconing when we add the multicast station, and since the broadcast station is not added at this point so the transmission of the beacon will fail on assert 0x2b00. This is fixed in later firmware, so make the order of addition depend on the TLV. Fixes: 26d6c16bed53 ("iwlwifi: mvm: add multicast station") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho --- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c index 08de822c3ef0..ebf511150f4d 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c @@ -8,6 +8,7 @@ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -2106,15 +2107,40 @@ static int iwl_mvm_start_ap_ibss(struct ieee80211_hw *hw, if (ret) goto out_remove; - ret = iwl_mvm_add_mcast_sta(mvm, vif); - if (ret) - goto out_unbind; - - /* Send the bcast station. At this stage the TBTT and DTIM time events - * are added and applied to the scheduler */ - ret = iwl_mvm_send_add_bcast_sta(mvm, vif); - if (ret) - goto out_rm_mcast; + /* + * This is not very nice, but the simplest: + * For older FWs adding the mcast sta before the bcast station may + * cause assert 0x2b00. + * This is fixed in later FW so make the order of removal depend on + * the TLV + */ + if (fw_has_api(&mvm->fw->ucode_capa, IWL_UCODE_TLV_API_STA_TYPE)) { + ret = iwl_mvm_add_mcast_sta(mvm, vif); + if (ret) + goto out_unbind; + /* + * Send the bcast station. At this stage the TBTT and DTIM time + * events are added and applied to the scheduler + */ + ret = iwl_mvm_send_add_bcast_sta(mvm, vif); + if (ret) { + iwl_mvm_rm_mcast_sta(mvm, vif); + goto out_unbind; + } + } else { + /* + * Send the bcast station. At this stage the TBTT and DTIM time + * events are added and applied to the scheduler + */ + iwl_mvm_send_add_bcast_sta(mvm, vif); + if (ret) + goto out_unbind; + iwl_mvm_add_mcast_sta(mvm, vif); + if (ret) { + iwl_mvm_send_rm_bcast_sta(mvm, vif); + goto out_unbind; + } + } /* must be set before quota calculations */ mvmvif->ap_ibss_active = true; @@ -2144,7 +2170,6 @@ out_quota_failed: iwl_mvm_power_update_mac(mvm); mvmvif->ap_ibss_active = false; iwl_mvm_send_rm_bcast_sta(mvm, vif); -out_rm_mcast: iwl_mvm_rm_mcast_sta(mvm, vif); out_unbind: iwl_mvm_binding_remove_vif(mvm, vif); From 8745f12a6600dd9d31122588621d4c8ddb332cd7 Mon Sep 17 00:00:00 2001 From: Shaul Triebitz Date: Thu, 11 Jan 2018 16:18:46 +0200 Subject: [PATCH 437/942] iwlwifi: avoid collecting firmware dump if not loaded Trying to collect firmware debug data while firmware is not loaded causes various errors (e.g. failing NIC access). This causes even a bigger issue if at that time the HW radio is off. In that case, when later turning the radio on, the Driver fails to read the HW (registers contain garbage values). (It may be that the CSR_GP_CNTRL_REG_FLAG_RFKILL_WAKE_L1A_EN bit is cleared on faulty NIC access - since the same behavior was seen in HW RFKILL toggling before setting that bit.) Signed-off-by: Shaul Triebitz Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/fw/dbg.c | 13 +++++++++++-- drivers/net/wireless/intel/iwlwifi/fw/dbg.h | 3 +++ drivers/net/wireless/intel/iwlwifi/fw/runtime.h | 3 +++ drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c | 5 ++--- drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 8 ++++++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c index 67aefc8fc9ac..7bd704a3e640 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.c +++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.c @@ -8,6 +8,7 @@ * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -33,6 +34,7 @@ * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -942,7 +944,6 @@ dump_trans_data: out: iwl_fw_free_dump_desc(fwrt); - fwrt->dump.trig = NULL; clear_bit(IWL_FWRT_STATUS_DUMPING, &fwrt->status); IWL_DEBUG_INFO(fwrt, "WRT dump done\n"); } @@ -1112,6 +1113,14 @@ void iwl_fw_error_dump_wk(struct work_struct *work) fwrt->ops->dump_start(fwrt->ops_ctx)) return; + if (fwrt->ops && fwrt->ops->fw_running && + !fwrt->ops->fw_running(fwrt->ops_ctx)) { + IWL_ERR(fwrt, "Firmware not running - cannot dump error\n"); + iwl_fw_free_dump_desc(fwrt); + clear_bit(IWL_FWRT_STATUS_DUMPING, &fwrt->status); + goto out; + } + if (fwrt->trans->cfg->device_family == IWL_DEVICE_FAMILY_7000) { /* stop recording */ iwl_fw_dbg_stop_recording(fwrt); @@ -1145,7 +1154,7 @@ void iwl_fw_error_dump_wk(struct work_struct *work) iwl_write_prph(fwrt->trans, DBGC_OUT_CTRL, out_ctrl); } } - +out: if (fwrt->ops && fwrt->ops->dump_end) fwrt->ops->dump_end(fwrt->ops_ctx); } diff --git a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h index 223fb77a3aa9..72259bff9922 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/dbg.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/dbg.h @@ -8,6 +8,7 @@ * Copyright(c) 2008 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -33,6 +34,7 @@ * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2015 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,6 +93,7 @@ static inline void iwl_fw_free_dump_desc(struct iwl_fw_runtime *fwrt) if (fwrt->dump.desc != &iwl_dump_desc_assert) kfree(fwrt->dump.desc); fwrt->dump.desc = NULL; + fwrt->dump.trig = NULL; } void iwl_fw_error_dump(struct iwl_fw_runtime *fwrt); diff --git a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h index f3197f7c13b6..3fb940ebd74a 100644 --- a/drivers/net/wireless/intel/iwlwifi/fw/runtime.h +++ b/drivers/net/wireless/intel/iwlwifi/fw/runtime.h @@ -6,6 +6,7 @@ * GPL LICENSE SUMMARY * * Copyright(c) 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -26,6 +27,7 @@ * BSD LICENSE * * Copyright(c) 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -68,6 +70,7 @@ struct iwl_fw_runtime_ops { int (*dump_start)(void *ctx); void (*dump_end)(void *ctx); + bool (*fw_running)(void *ctx); }; #define MAX_NUM_LMAC 2 diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c index a7892c1254a2..9c436d8d001d 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs.c @@ -8,6 +8,7 @@ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -35,6 +36,7 @@ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1281,9 +1283,6 @@ static ssize_t iwl_dbgfs_fw_dbg_collect_write(struct iwl_mvm *mvm, { int ret; - if (!iwl_mvm_firmware_running(mvm)) - return -EIO; - ret = iwl_mvm_ref_sync(mvm, IWL_MVM_REF_PRPH_WRITE); if (ret) return ret; diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c index 6bb347bf0d6e..ab7fb5aad984 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/ops.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/ops.c @@ -8,6 +8,7 @@ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -35,6 +36,7 @@ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH * Copyright(c) 2016 - 2017 Intel Deutschland GmbH + * Copyright(c) 2018 Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -552,9 +554,15 @@ static void iwl_mvm_fwrt_dump_end(void *ctx) iwl_mvm_unref(mvm, IWL_MVM_REF_FW_DBG_COLLECT); } +static bool iwl_mvm_fwrt_fw_running(void *ctx) +{ + return iwl_mvm_firmware_running(ctx); +} + static const struct iwl_fw_runtime_ops iwl_mvm_fwrt_ops = { .dump_start = iwl_mvm_fwrt_dump_start, .dump_end = iwl_mvm_fwrt_dump_end, + .fw_running = iwl_mvm_fwrt_fw_running, }; static struct iwl_op_mode * From e4f13ad07823b24a1537518d2163bd164292fb10 Mon Sep 17 00:00:00 2001 From: Sara Sharon Date: Mon, 15 Jan 2018 13:50:59 +0200 Subject: [PATCH 438/942] iwlwifi: mvm: fix "failed to remove key" message When the GTK is installed, we install it to HW with the station ID of the AP. Mac80211 will try to remove it only after the AP sta is removed, which will result in a failure to remove key since we do not have any station for it. This is a valid situation, but a previous commit removed the early return and added a return with error value, which resulted in an error message that is confusing to users. Remove the error return value. Fixes: 85aeb58cec1a ("iwlwifi: mvm: Enable security on new TX API") Signed-off-by: Sara Sharon Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index dbd2ba2bb714..3739e42b34e4 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -3170,8 +3170,9 @@ static int __iwl_mvm_remove_sta_key(struct iwl_mvm *mvm, u8 sta_id, int ret, size; u32 status; + /* This is a valid situation for GTK removal */ if (sta_id == IWL_MVM_INVALID_STA) - return -EINVAL; + return 0; key_flags = cpu_to_le16((keyconf->keyidx << STA_KEY_FLG_KEYID_POS) & STA_KEY_FLG_KEYID_MSK); From 7c305de2b9548ab6b65fce342c78618bbed5db73 Mon Sep 17 00:00:00 2001 From: Ilan Peer Date: Mon, 22 Jan 2018 08:55:06 +0200 Subject: [PATCH 439/942] iwlwifi: mvm: Direct multicast frames to the correct station Multicast frames for NL80211_IFTYPE_AP and NL80211_IFTYPE_ADHOC were directed to the broadcast station, however, as the broadcast station did not have keys configured, these frames were sent unencrypted. Fix this by using the multicast station which is the station for which encryption keys are configured. Signed-off-by: Ilan Peer Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c index 57ad6019ffad..af6dfceab6b8 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/tx.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tx.c @@ -648,7 +648,11 @@ int iwl_mvm_tx_skb_non_sta(struct iwl_mvm *mvm, struct sk_buff *skb) if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE || info.control.vif->type == NL80211_IFTYPE_AP || info.control.vif->type == NL80211_IFTYPE_ADHOC) { - sta_id = mvmvif->bcast_sta.sta_id; + if (info.control.vif->type == NL80211_IFTYPE_P2P_DEVICE) + sta_id = mvmvif->bcast_sta.sta_id; + else + sta_id = mvmvif->mcast_sta.sta_id; + queue = iwl_mvm_get_ctrl_vif_queue(mvm, &info, hdr->frame_control); if (queue < 0) From 6508de0305d560235b366cc2cc98f7bcfb029e92 Mon Sep 17 00:00:00 2001 From: Ilan Peer Date: Thu, 25 Jan 2018 15:22:41 +0200 Subject: [PATCH 440/942] iwlwifi: mvm: Correctly set the tid for mcast queue In the scheduler config command, the meaning of tid == 0xf was intended to indicate the configuration is for management frames. However, tid == 0xf was also used for the multicast queue that was meant only for multicast data frames, which resulted with the FW not encrypting multicast data frames. As multicast frames do not have a QoS header, fix this by setting tid == 0, to indicate that this is a data queue and not management one. Signed-off-by: Ilan Peer Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c index 3739e42b34e4..630e23cb0ffb 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/sta.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/sta.c @@ -2039,7 +2039,7 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) struct iwl_trans_txq_scd_cfg cfg = { .fifo = IWL_MVM_TX_FIFO_MCAST, .sta_id = msta->sta_id, - .tid = IWL_MAX_TID_COUNT, + .tid = 0, .aggregate = false, .frame_limit = IWL_FRAME_LIMIT, }; @@ -2090,7 +2090,7 @@ int iwl_mvm_add_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) if (iwl_mvm_has_new_tx_api(mvm)) { int queue = iwl_mvm_tvqm_enable_txq(mvm, vif->cab_queue, msta->sta_id, - IWL_MAX_TID_COUNT, + 0, timeout); mvmvif->cab_queue = queue; } else if (!fw_has_api(&mvm->fw->ucode_capa, @@ -2115,7 +2115,7 @@ int iwl_mvm_rm_mcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif) iwl_mvm_flush_sta(mvm, &mvmvif->mcast_sta, true, 0); iwl_mvm_disable_txq(mvm, mvmvif->cab_queue, vif->cab_queue, - IWL_MAX_TID_COUNT, 0); + 0, 0); ret = iwl_mvm_rm_sta_common(mvm, mvmvif->mcast_sta.sta_id); if (ret) From de655fa8fb237d0eaf838e8833b464c1dec90070 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Mon, 5 Feb 2018 02:21:30 +0100 Subject: [PATCH 441/942] iwlwifi: fix malformed CONFIG_IWLWIFI_PCIE_RTPM default 'default false' should be 'default n', though they happen to have the same effect here, due to undefined symbols ('false' in this case) evaluating to n in a tristate sense. Remove the default instead of changing it. bool and tristate symbols implicitly default to n. Discovered with the https://github.com/ulfalizer/Kconfiglib/blob/master/examples/list_undefined.py script. Signed-off-by: Ulf Magnusson Signed-off-by: Luca Coelho --- drivers/net/wireless/intel/iwlwifi/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/wireless/intel/iwlwifi/Kconfig b/drivers/net/wireless/intel/iwlwifi/Kconfig index c5f2ddf9b0fe..e5a2fc738ac3 100644 --- a/drivers/net/wireless/intel/iwlwifi/Kconfig +++ b/drivers/net/wireless/intel/iwlwifi/Kconfig @@ -91,7 +91,6 @@ config IWLWIFI_BCAST_FILTERING config IWLWIFI_PCIE_RTPM bool "Enable runtime power management mode for PCIe devices" depends on IWLMVM && PM && EXPERT - default false help Say Y here to enable runtime power management for PCIe devices. If enabled, the device will go into low power mode From 3bf045d15f52529e8abe26543dbe22af44efb41a Mon Sep 17 00:00:00 2001 From: John Hsu Date: Fri, 2 Mar 2018 10:45:14 +0800 Subject: [PATCH 442/942] ASoC: Intel: fix argument error in nau8824 machine Fix the error: passing argument 1 of 'nau8824_enable_jack_detect' from incompatible pointer type nau8824_enable_jack_detect(codec, jack); ^~~~~ Which expects 'struct snd_soc_component *' but argument is of type 'struct snd_soc_codec *' Reported-by: Stephen Rothwell Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/intel/boards/cht_bsw_nau8824.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/cht_bsw_nau8824.c b/sound/soc/intel/boards/cht_bsw_nau8824.c index 08d0b8128fab..680f2b3a24f9 100644 --- a/sound/soc/intel/boards/cht_bsw_nau8824.c +++ b/sound/soc/intel/boards/cht_bsw_nau8824.c @@ -103,8 +103,8 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) { struct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card); struct snd_soc_jack *jack = &ctx->jack; - struct snd_soc_codec *codec = runtime->codec; struct snd_soc_dai *codec_dai = runtime->codec_dai; + struct snd_soc_component *component = codec_dai->component; int ret, jack_type; /* TDM 4 slots 24 bit, set Rx & Tx bitmask to 4 active slots */ @@ -134,7 +134,7 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) snd_jack_set_key(jack->jack, SND_JACK_BTN_2, KEY_VOLUMEUP); snd_jack_set_key(jack->jack, SND_JACK_BTN_3, KEY_VOLUMEDOWN); - nau8824_enable_jack_detect(codec, jack); + nau8824_enable_jack_detect(component, jack); return ret; } From b3e9c3f0d98135d8b9991c2a34e42627c20664a4 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Fri, 2 Mar 2018 14:11:00 +0100 Subject: [PATCH 443/942] ASoC: max9867: Drop probe function Driver probe function has no use and can be deleted. Signed-off-by: Ladislav Michl Signed-off-by: Mark Brown --- sound/soc/codecs/max9867.c | 10 ---------- sound/soc/codecs/max9867.h | 1 - 2 files changed, 11 deletions(-) diff --git a/sound/soc/codecs/max9867.c b/sound/soc/codecs/max9867.c index 349d9cc116ee..4ea3287162ad 100644 --- a/sound/soc/codecs/max9867.c +++ b/sound/soc/codecs/max9867.c @@ -413,17 +413,7 @@ static int max9867_resume(struct device *dev) } #endif -static int max9867_probe(struct snd_soc_component *component) -{ - struct max9867_priv *max9867 = snd_soc_component_get_drvdata(component); - - dev_dbg(component->dev, "max98090_probe\n"); - max9867->component = component; - return 0; -} - static const struct snd_soc_component_driver max9867_component = { - .probe = max9867_probe, .controls = max9867_snd_controls, .num_controls = ARRAY_SIZE(max9867_snd_controls), .dapm_routes = max9867_audio_map, diff --git a/sound/soc/codecs/max9867.h b/sound/soc/codecs/max9867.h index c0aea3d1f2ba..55cd9976ff47 100644 --- a/sound/soc/codecs/max9867.h +++ b/sound/soc/codecs/max9867.h @@ -75,7 +75,6 @@ /* codec private data */ struct max9867_priv { struct regmap *regmap; - struct snd_soc_component *component; unsigned int sysclk; unsigned int pclk; unsigned int master; From d02f51cbcf12b09ab945873e35046045875eed9a Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Sat, 3 Mar 2018 03:03:46 +0100 Subject: [PATCH 444/942] bpf: fix bpf_skb_adjust_net/bpf_skb_proto_xlat to deal with gso sctp skbs SCTP GSO skbs have a gso_size of GSO_BY_FRAGS, so any sort of unconditionally mangling of that will result in nonsense value and would corrupt the skb later on. Therefore, i) add two helpers skb_increase_gso_size() and skb_decrease_gso_size() that would throw a one time warning and bail out for such skbs and ii) refuse and return early with an error in those BPF helpers that are affected. We do need to bail out as early as possible from there before any changes on the skb have been performed. Fixes: 6578171a7ff0 ("bpf: add bpf_skb_change_proto helper") Co-authored-by: Daniel Borkmann Signed-off-by: Daniel Axtens Cc: Marcelo Ricardo Leitner Acked-by: Alexei Starovoitov Signed-off-by: Alexei Starovoitov --- .../networking/segmentation-offloads.txt | 11 +++- include/linux/skbuff.h | 22 +++++++ net/core/filter.c | 60 +++++++++++++------ 3 files changed, 73 insertions(+), 20 deletions(-) diff --git a/Documentation/networking/segmentation-offloads.txt b/Documentation/networking/segmentation-offloads.txt index d47480b61ac6..23a8dd91a9ec 100644 --- a/Documentation/networking/segmentation-offloads.txt +++ b/Documentation/networking/segmentation-offloads.txt @@ -153,8 +153,15 @@ To signal this, gso_size is set to the special value GSO_BY_FRAGS. Therefore, any code in the core networking stack must be aware of the possibility that gso_size will be GSO_BY_FRAGS and handle that case -appropriately. (For size checks, the skb_gso_validate_*_len family of -helpers do this automatically.) +appropriately. + +There are a couple of helpers to make this easier: + + - For size checks, the skb_gso_validate_*_len family of helpers correctly + considers GSO_BY_FRAGS. + + - For manipulating packets, skb_increase_gso_size and skb_decrease_gso_size + will check for GSO_BY_FRAGS and WARN if asked to manipulate these skbs. This also affects drivers with the NETIF_F_FRAGLIST & NETIF_F_GSO_SCTP bits set. Note also that NETIF_F_GSO_SCTP is included in NETIF_F_GSO_SOFTWARE. diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index c1e66bdcf583..8c67c33f40c9 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -4038,6 +4038,12 @@ static inline bool skb_is_gso_v6(const struct sk_buff *skb) return skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6; } +/* Note: Should be called only if skb_is_gso(skb) is true */ +static inline bool skb_is_gso_sctp(const struct sk_buff *skb) +{ + return skb_shinfo(skb)->gso_type & SKB_GSO_SCTP; +} + static inline void skb_gso_reset(struct sk_buff *skb) { skb_shinfo(skb)->gso_size = 0; @@ -4045,6 +4051,22 @@ static inline void skb_gso_reset(struct sk_buff *skb) skb_shinfo(skb)->gso_type = 0; } +static inline void skb_increase_gso_size(struct skb_shared_info *shinfo, + u16 increment) +{ + if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) + return; + shinfo->gso_size += increment; +} + +static inline void skb_decrease_gso_size(struct skb_shared_info *shinfo, + u16 decrement) +{ + if (WARN_ON_ONCE(shinfo->gso_size == GSO_BY_FRAGS)) + return; + shinfo->gso_size -= decrement; +} + void __skb_warn_lro_forwarding(const struct sk_buff *skb); static inline bool skb_warn_if_lro(const struct sk_buff *skb) diff --git a/net/core/filter.c b/net/core/filter.c index 0c121adbdbaa..48aa7c7320db 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2087,6 +2087,10 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb) u32 off = skb_mac_header_len(skb); int ret; + /* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */ + if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb))) + return -ENOTSUPP; + ret = skb_cow(skb, len_diff); if (unlikely(ret < 0)) return ret; @@ -2096,19 +2100,21 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb) return ret; if (skb_is_gso(skb)) { + struct skb_shared_info *shinfo = skb_shinfo(skb); + /* SKB_GSO_TCPV4 needs to be changed into * SKB_GSO_TCPV6. */ - if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) { - skb_shinfo(skb)->gso_type &= ~SKB_GSO_TCPV4; - skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; + if (shinfo->gso_type & SKB_GSO_TCPV4) { + shinfo->gso_type &= ~SKB_GSO_TCPV4; + shinfo->gso_type |= SKB_GSO_TCPV6; } /* Due to IPv6 header, MSS needs to be downgraded. */ - skb_shinfo(skb)->gso_size -= len_diff; + skb_decrease_gso_size(shinfo, len_diff); /* Header must be checked, and gso_segs recomputed. */ - skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; - skb_shinfo(skb)->gso_segs = 0; + shinfo->gso_type |= SKB_GSO_DODGY; + shinfo->gso_segs = 0; } skb->protocol = htons(ETH_P_IPV6); @@ -2123,6 +2129,10 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb) u32 off = skb_mac_header_len(skb); int ret; + /* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */ + if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb))) + return -ENOTSUPP; + ret = skb_unclone(skb, GFP_ATOMIC); if (unlikely(ret < 0)) return ret; @@ -2132,19 +2142,21 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb) return ret; if (skb_is_gso(skb)) { + struct skb_shared_info *shinfo = skb_shinfo(skb); + /* SKB_GSO_TCPV6 needs to be changed into * SKB_GSO_TCPV4. */ - if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) { - skb_shinfo(skb)->gso_type &= ~SKB_GSO_TCPV6; - skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4; + if (shinfo->gso_type & SKB_GSO_TCPV6) { + shinfo->gso_type &= ~SKB_GSO_TCPV6; + shinfo->gso_type |= SKB_GSO_TCPV4; } /* Due to IPv4 header, MSS can be upgraded. */ - skb_shinfo(skb)->gso_size += len_diff; + skb_increase_gso_size(shinfo, len_diff); /* Header must be checked, and gso_segs recomputed. */ - skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; - skb_shinfo(skb)->gso_segs = 0; + shinfo->gso_type |= SKB_GSO_DODGY; + shinfo->gso_segs = 0; } skb->protocol = htons(ETH_P_IP); @@ -2243,6 +2255,10 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff) u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb); int ret; + /* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */ + if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb))) + return -ENOTSUPP; + ret = skb_cow(skb, len_diff); if (unlikely(ret < 0)) return ret; @@ -2252,11 +2268,13 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 len_diff) return ret; if (skb_is_gso(skb)) { + struct skb_shared_info *shinfo = skb_shinfo(skb); + /* Due to header grow, MSS needs to be downgraded. */ - skb_shinfo(skb)->gso_size -= len_diff; + skb_decrease_gso_size(shinfo, len_diff); /* Header must be checked, and gso_segs recomputed. */ - skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; - skb_shinfo(skb)->gso_segs = 0; + shinfo->gso_type |= SKB_GSO_DODGY; + shinfo->gso_segs = 0; } return 0; @@ -2267,6 +2285,10 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff) u32 off = skb_mac_header_len(skb) + bpf_skb_net_base_len(skb); int ret; + /* SCTP uses GSO_BY_FRAGS, thus cannot adjust it. */ + if (skb_is_gso(skb) && unlikely(skb_is_gso_sctp(skb))) + return -ENOTSUPP; + ret = skb_unclone(skb, GFP_ATOMIC); if (unlikely(ret < 0)) return ret; @@ -2276,11 +2298,13 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 len_diff) return ret; if (skb_is_gso(skb)) { + struct skb_shared_info *shinfo = skb_shinfo(skb); + /* Due to header shrink, MSS can be upgraded. */ - skb_shinfo(skb)->gso_size += len_diff; + skb_increase_gso_size(shinfo, len_diff); /* Header must be checked, and gso_segs recomputed. */ - skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY; - skb_shinfo(skb)->gso_segs = 0; + shinfo->gso_type |= SKB_GSO_DODGY; + shinfo->gso_segs = 0; } return 0; From 74c12c630fe310eb7fcae1b292257d47781fff0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20L=C3=BCssing?= Date: Sun, 4 Mar 2018 13:08:17 +0100 Subject: [PATCH 445/942] batman-adv: Fix multicast packet loss with a single WANT_ALL_IPV4/6 flag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As the kernel doc describes too the code is supposed to skip adding multicast TT entries if both the WANT_ALL_IPV4 and WANT_ALL_IPV6 flags are present. Unfortunately, the current code even skips adding multicast TT entries if only either the WANT_ALL_IPV4 or WANT_ALL_IPV6 is present. This could lead to IPv6 multicast packet loss if only an IGMP but not an MLD querier is present for instance or vice versa. Fixes: 687937ab3489 ("batman-adv: Add multicast optimization support for bridged setups") Signed-off-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/multicast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index cbdeb47ec3f6..d70640135e3a 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -543,8 +543,8 @@ update: bat_priv->mcast.enabled = true; } - return !(mcast_data.flags & - (BATADV_MCAST_WANT_ALL_IPV4 | BATADV_MCAST_WANT_ALL_IPV6)); + return !(mcast_data.flags & BATADV_MCAST_WANT_ALL_IPV4 && + mcast_data.flags & BATADV_MCAST_WANT_ALL_IPV6); } /** From 28b2182dad43f6f8fcbd167539a26714fd12bd64 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 2 Mar 2018 11:36:32 +0100 Subject: [PATCH 446/942] ahci: Add PCI-id for the Highpoint Rocketraid 644L card Like the Highpoint Rocketraid 642L and cards using a Marvel 88SE9235 controller in general, this RAID card also supports AHCI mode and short of a custom driver, this is the only way to make it work under Linux. Note that even though the card is called to 644L, it has a product-id of 0x0645. Cc: stable@vger.kernel.org BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1534106 Signed-off-by: Hans de Goede Signed-off-by: Tejun Heo Acked-by: Bjorn Helgaas --- drivers/ata/ahci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index 355a95a83a34..1ff17799769d 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c @@ -550,7 +550,9 @@ static const struct pci_device_id ahci_pci_tbl[] = { .driver_data = board_ahci_yes_fbs }, { PCI_DEVICE(PCI_VENDOR_ID_MARVELL_EXT, 0x9230), .driver_data = board_ahci_yes_fbs }, - { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), + { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0642), /* highpoint rocketraid 642L */ + .driver_data = board_ahci_yes_fbs }, + { PCI_DEVICE(PCI_VENDOR_ID_TTI, 0x0645), /* highpoint rocketraid 644L */ .driver_data = board_ahci_yes_fbs }, /* Promise */ From 1903be8222b7c278ca897c129ce477c1dd6403a8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 2 Mar 2018 11:36:33 +0100 Subject: [PATCH 447/942] PCI: Add function 1 DMA alias quirk for Highpoint RocketRAID 644L The Highpoint RocketRAID 644L uses a Marvel 88SE9235 controller, as with other Marvel controllers this needs a function 1 DMA alias quirk. Note the RocketRAID 642L uses the same Marvel 88SE9235 controller and already is listed with a function 1 DMA alias quirk. Cc: stable@vger.kernel.org BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1534106 Signed-off-by: Hans de Goede Acked-by: Bjorn Helgaas Signed-off-by: Tejun Heo --- drivers/pci/quirks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index fc734014206f..b1a3a36073b4 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -3901,6 +3901,8 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9230, quirk_dma_func1_alias); DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0642, quirk_dma_func1_alias); +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TTI, 0x0645, + quirk_dma_func1_alias); /* https://bugs.gentoo.org/show_bug.cgi?id=497630 */ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_JMICRON, PCI_DEVICE_ID_JMICRON_JMB388_ESD, From c7151602255a36ba07c84fe2baeef846fdb988b8 Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Wed, 28 Feb 2018 14:53:18 +0300 Subject: [PATCH 448/942] mmc: dw_mmc: Fix the DTO/CTO timeout overflow calculation for 32-bit systems The commit 9d9491a7da2a ("mmc: dw_mmc: Fix the DTO timeout calculation") and commit 4c2357f57dd5 ("mmc: dw_mmc: Fix the CTO timeout calculation") made changes, which cause multiply overflow for 32-bit systems. The broken timeout calculations leads to unexpected ETIMEDOUT errors and causes stacktrace splat (such as below) during normal data exchange with SD-card. | Running : 4M-check-reassembly-tcp-cmykw2-rotatew2.out -v0 -w1 | - Info: Finished target initialization. | mmcblk0: error -110 transferring data, sector 320544, nr 2048, cmd | response 0x900, card status 0x0 DIV_ROUND_UP_ULL helps to escape usage of __udivdi3() from libgcc and so code gets compiled on all 32-bit platforms as opposed to usage of DIV_ROUND_UP when we may only compile stuff on a very few arches. Lets cast this multiply to u64 type to prevent the overflow. Fixes: 9d9491a7da2a ("mmc: dw_mmc: Fix the DTO timeout calculation") Fixes: 4c2357f57dd5 ("mmc: dw_mmc: Fix the CTO timeout calculation") Tested-by: Vineet Gupta Reported-by: Vineet Gupta # ARC STAR 9001306872 HSDK, sdio: board crashes when copying big files Signed-off-by: Evgeniy Didin Cc: # 4.14 Reviewed-by: Andy Shevchenko Reviewed-by: Douglas Anderson Reviewed-by: Shawn Lin Reviewed-by: Jisheng Zhang Acked-by: Jaehoon Chung Signed-off-by: Ulf Hansson --- drivers/mmc/host/dw_mmc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index d9b4acefed31..545550591389 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -413,7 +413,9 @@ static inline void dw_mci_set_cto(struct dw_mci *host) cto_div = (mci_readl(host, CLKDIV) & 0xff) * 2; if (cto_div == 0) cto_div = 1; - cto_ms = DIV_ROUND_UP(MSEC_PER_SEC * cto_clks * cto_div, host->bus_hz); + + cto_ms = DIV_ROUND_UP_ULL((u64)MSEC_PER_SEC * cto_clks * cto_div, + host->bus_hz); /* add a bit spare time */ cto_ms += 10; @@ -1948,8 +1950,9 @@ static void dw_mci_set_drto(struct dw_mci *host) drto_div = (mci_readl(host, CLKDIV) & 0xff) * 2; if (drto_div == 0) drto_div = 1; - drto_ms = DIV_ROUND_UP(MSEC_PER_SEC * drto_clks * drto_div, - host->bus_hz); + + drto_ms = DIV_ROUND_UP_ULL((u64)MSEC_PER_SEC * drto_clks * drto_div, + host->bus_hz); /* add a bit spare time */ drto_ms += 10; From 1a087f032111a88e826877449dfb93ceb22b78b9 Mon Sep 17 00:00:00 2001 From: Xinyong Date: Fri, 2 Mar 2018 19:20:07 +0800 Subject: [PATCH 449/942] usb: gadget: f_fs: Fix use-after-free in ffs_fs_kill_sb() When I debug a kernel crash issue in funcitonfs, found ffs_data.ref overflowed, While functionfs is unmounting, ffs_data is put twice. Commit 43938613c6fd ("drivers, usb: convert ffs_data.ref from atomic_t to refcount_t") can avoid refcount overflow, but that is risk some situations. So no need put ffs data in ffs_fs_kill_sb, already put in ffs_data_closed. The issue can be reproduced in Mediatek mt6763 SoC, ffs for ADB device. KASAN enabled configuration reports use-after-free errro. BUG: KASAN: use-after-free in refcount_dec_and_test+0x14/0xe0 at addr ffffffc0579386a0 Read of size 4 by task umount/4650 ==================================================== BUG kmalloc-512 (Tainted: P W O ): kasan: bad access detected ----------------------------------------------------------------------------- INFO: Allocated in ffs_fs_mount+0x194/0x844 age=22856 cpu=2 pid=566 alloc_debug_processing+0x1ac/0x1e8 ___slab_alloc.constprop.63+0x640/0x648 __slab_alloc.isra.57.constprop.62+0x24/0x34 kmem_cache_alloc_trace+0x1a8/0x2bc ffs_fs_mount+0x194/0x844 mount_fs+0x6c/0x1d0 vfs_kern_mount+0x50/0x1b4 do_mount+0x258/0x1034 INFO: Freed in ffs_data_put+0x25c/0x320 age=0 cpu=3 pid=4650 free_debug_processing+0x22c/0x434 __slab_free+0x2d8/0x3a0 kfree+0x254/0x264 ffs_data_put+0x25c/0x320 ffs_data_closed+0x124/0x15c ffs_fs_kill_sb+0xb8/0x110 deactivate_locked_super+0x6c/0x98 deactivate_super+0xb0/0xbc INFO: Object 0xffffffc057938600 @offset=1536 fp=0x (null) ...... Call trace: [] dump_backtrace+0x0/0x250 [] show_stack+0x14/0x1c [] dump_stack+0xa0/0xc8 [] print_trailer+0x158/0x260 [] object_err+0x3c/0x40 [] kasan_report_error+0x2a8/0x754 [] kasan_report+0x5c/0x60 [] __asan_load4+0x70/0x88 [] refcount_dec_and_test+0x14/0xe0 [] ffs_data_put+0x80/0x320 [] ffs_fs_kill_sb+0xc8/0x110 [] deactivate_locked_super+0x6c/0x98 [] deactivate_super+0xb0/0xbc [] cleanup_mnt+0x64/0xec [] __cleanup_mnt+0x10/0x18 [] task_work_run+0xcc/0x124 [] do_notify_resume+0x60/0x70 [] work_pending+0x10/0x14 Cc: stable@vger.kernel.org Signed-off-by: Xinyong Signed-off-by: Felipe Balbi --- drivers/usb/gadget/function/f_fs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c index c2592d883f67..d2428a9e8900 100644 --- a/drivers/usb/gadget/function/f_fs.c +++ b/drivers/usb/gadget/function/f_fs.c @@ -1538,7 +1538,6 @@ ffs_fs_kill_sb(struct super_block *sb) if (sb->s_fs_info) { ffs_release_dev(sb->s_fs_info); ffs_data_closed(sb->s_fs_info); - ffs_data_put(sb->s_fs_info); } } From 4c437920fa216f66f6a5d469cae2a0360cc2d9c7 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Thu, 1 Mar 2018 11:05:34 +0100 Subject: [PATCH 450/942] dt-bindings: usb: fix the STM32F7 DWC2 OTG HS core binding This patch fixes binding documentation for DWC2 controller in HS mode found on STMicroelectronics STM32F7 SoC. The v2 former patch [1] had been acked by Rob Herring, but v1 was merged. [1] https://patchwork.kernel.org/patch/9925575/ Fixes: 000777dadc7e ("dt-bindings: usb: Document the STM32F7xx DWC2 ...") Signed-off-by: Amelie Delaunay Reviewed-by: Rob Herring Signed-off-by: Felipe Balbi --- Documentation/devicetree/bindings/usb/dwc2.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/usb/dwc2.txt b/Documentation/devicetree/bindings/usb/dwc2.txt index e64d903bcbe8..46da5f184460 100644 --- a/Documentation/devicetree/bindings/usb/dwc2.txt +++ b/Documentation/devicetree/bindings/usb/dwc2.txt @@ -19,7 +19,7 @@ Required properties: configured in FS mode; - "st,stm32f4x9-hsotg": The DWC2 USB HS controller instance in STM32F4x9 SoCs configured in HS mode; - - "st,stm32f7xx-hsotg": The DWC2 USB HS controller instance in STM32F7xx SoCs + - "st,stm32f7-hsotg": The DWC2 USB HS controller instance in STM32F7 SoCs configured in HS mode; - reg : Should contain 1 register range (address and length) - interrupts : Should contain 1 interrupt From 1a149e3554e0324a3d551dfb327bdb67b150a320 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay Date: Thu, 1 Mar 2018 11:05:35 +0100 Subject: [PATCH 451/942] usb: dwc2: fix STM32F7 USB OTG HS compatible This patch fixes compatible for STM32F7 USB OTG HS and consistently rename dw2_set_params function. The v2 former patch [1] had been acked by Paul Young, but v1 was merged. [1] https://patchwork.kernel.org/patch/9925573/ Fixes: d8fae8b93682 ("usb: dwc2: add support for STM32F7xx USB OTG HS") Signed-off-by: Amelie Delaunay Signed-off-by: Felipe Balbi --- drivers/usb/dwc2/params.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 03fd20f0b496..c4a47496d2fb 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -137,7 +137,7 @@ static void dwc2_set_stm32f4x9_fsotg_params(struct dwc2_hsotg *hsotg) p->activate_stm_fs_transceiver = true; } -static void dwc2_set_stm32f7xx_hsotg_params(struct dwc2_hsotg *hsotg) +static void dwc2_set_stm32f7_hsotg_params(struct dwc2_hsotg *hsotg) { struct dwc2_core_params *p = &hsotg->params; @@ -164,8 +164,8 @@ const struct of_device_id dwc2_of_match_table[] = { { .compatible = "st,stm32f4x9-fsotg", .data = dwc2_set_stm32f4x9_fsotg_params }, { .compatible = "st,stm32f4x9-hsotg" }, - { .compatible = "st,stm32f7xx-hsotg", - .data = dwc2_set_stm32f7xx_hsotg_params }, + { .compatible = "st,stm32f7-hsotg", + .data = dwc2_set_stm32f7_hsotg_params }, {}, }; MODULE_DEVICE_TABLE(of, dwc2_of_match_table); From 54f02945f703404cdf17c9618316b3d3387fa072 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 27 Feb 2018 17:16:02 +0900 Subject: [PATCH 452/942] usb: renesas_usbhs: add binding for r8a77965 This patch adds binding for r8a77965 (R-Car M3-N). Signed-off-by: Yoshihiro Shimoda Signed-off-by: Felipe Balbi --- Documentation/devicetree/bindings/usb/renesas_usbhs.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt index d060172f1529..43960faf5a88 100644 --- a/Documentation/devicetree/bindings/usb/renesas_usbhs.txt +++ b/Documentation/devicetree/bindings/usb/renesas_usbhs.txt @@ -12,6 +12,7 @@ Required properties: - "renesas,usbhs-r8a7794" for r8a7794 (R-Car E2) compatible device - "renesas,usbhs-r8a7795" for r8a7795 (R-Car H3) compatible device - "renesas,usbhs-r8a7796" for r8a7796 (R-Car M3-W) compatible device + - "renesas,usbhs-r8a77965" for r8a77965 (R-Car M3-N) compatible device - "renesas,usbhs-r8a77995" for r8a77995 (R-Car D3) compatible device - "renesas,usbhs-r7s72100" for r7s72100 (RZ/A1) compatible device - "renesas,rcar-gen2-usbhs" for R-Car Gen2 or RZ/G1 compatible devices From c6ba5084ce0d00d4a005b0577d9e764d39b638e1 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 27 Feb 2018 17:16:03 +0900 Subject: [PATCH 453/942] usb: gadget: udc: renesas_usb3: add binging for r8a77965 This patch adds binding for r8a77965 (R-Car M3-N). Signed-off-by: Yoshihiro Shimoda Signed-off-by: Felipe Balbi --- Documentation/devicetree/bindings/usb/renesas_usb3.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/usb/renesas_usb3.txt b/Documentation/devicetree/bindings/usb/renesas_usb3.txt index 87a45e2f9b7f..2c071bb5801e 100644 --- a/Documentation/devicetree/bindings/usb/renesas_usb3.txt +++ b/Documentation/devicetree/bindings/usb/renesas_usb3.txt @@ -4,6 +4,7 @@ Required properties: - compatible: Must contain one of the following: - "renesas,r8a7795-usb3-peri" - "renesas,r8a7796-usb3-peri" + - "renesas,r8a77965-usb3-peri" - "renesas,rcar-gen3-usb3-peri" for a generic R-Car Gen3 compatible device From 2fe4c22c53fc2e3f35be2cd0033cb3d15ebd41b1 Mon Sep 17 00:00:00 2001 From: Sean Young Date: Tue, 27 Feb 2018 08:03:56 -0500 Subject: [PATCH 454/942] media: rc: lirc does not use LIRC_CAN_SEND_SCANCODE feature Since commit 02d742f4b209 ("media: lirc: lirc daemon fails to detect raw IR device"), the feature LIRC_CAN_SEND_SCANCODE is no longer used as it tripped up lircd. The ability to send scancodes for IR Tx is implied by LIRC_CAN_SEND_PULSE (i.e. any device that can send can use IR Tx encoders). So, remove LIRC_CAN_SEND_SCANCODE since it never used. This fixes: Documentation/output/lirc.h.rst:6: WARNING: undefined label: lirc-can-send-scancode (if the link has no caption the label must precede a section header As this flag was added for kernel 4.16, let's remove it, while not too late. Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab --- include/uapi/linux/lirc.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/uapi/linux/lirc.h b/include/uapi/linux/lirc.h index 4fe580d36e41..f5bf06ecd87d 100644 --- a/include/uapi/linux/lirc.h +++ b/include/uapi/linux/lirc.h @@ -54,7 +54,6 @@ #define LIRC_CAN_SEND_RAW LIRC_MODE2SEND(LIRC_MODE_RAW) #define LIRC_CAN_SEND_PULSE LIRC_MODE2SEND(LIRC_MODE_PULSE) #define LIRC_CAN_SEND_MODE2 LIRC_MODE2SEND(LIRC_MODE_MODE2) -#define LIRC_CAN_SEND_SCANCODE LIRC_MODE2SEND(LIRC_MODE_SCANCODE) #define LIRC_CAN_SEND_LIRCCODE LIRC_MODE2SEND(LIRC_MODE_LIRCCODE) #define LIRC_CAN_SEND_MASK 0x0000003f From e113d65ae417ae6d9be229649b81d404c47ade79 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 28 Feb 2018 05:47:07 -0500 Subject: [PATCH 455/942] media: tegra-cec: reset rx_buf_cnt when start bit detected If a start bit is detected, then reset the receive buffer counter to 0. This ensures that no stale data is in the buffer if a message is broken off midstream due to e.g. a Low Drive condition and then retransmitted. The only Rx interrupts we need to listen to are RX_REGISTER_FULL (i.e. a valid byte was received) and RX_START_BIT_DETECTED (i.e. a new message starts and we need to reset the counter). Signed-off-by: Hans Verkuil Cc: # for v4.15 and up Signed-off-by: Mauro Carvalho Chehab --- drivers/media/platform/tegra-cec/tegra_cec.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/tegra-cec/tegra_cec.c b/drivers/media/platform/tegra-cec/tegra_cec.c index 92f93a880015..aba488cd0e64 100644 --- a/drivers/media/platform/tegra-cec/tegra_cec.c +++ b/drivers/media/platform/tegra-cec/tegra_cec.c @@ -172,16 +172,13 @@ static irqreturn_t tegra_cec_irq_handler(int irq, void *data) } } - if (status & (TEGRA_CEC_INT_STAT_RX_REGISTER_OVERRUN | - TEGRA_CEC_INT_STAT_RX_BUS_ANOMALY_DETECTED | - TEGRA_CEC_INT_STAT_RX_START_BIT_DETECTED | - TEGRA_CEC_INT_STAT_RX_BUS_ERROR_DETECTED)) { + if (status & TEGRA_CEC_INT_STAT_RX_START_BIT_DETECTED) { cec_write(cec, TEGRA_CEC_INT_STAT, - (TEGRA_CEC_INT_STAT_RX_REGISTER_OVERRUN | - TEGRA_CEC_INT_STAT_RX_BUS_ANOMALY_DETECTED | - TEGRA_CEC_INT_STAT_RX_START_BIT_DETECTED | - TEGRA_CEC_INT_STAT_RX_BUS_ERROR_DETECTED)); - } else if (status & TEGRA_CEC_INT_STAT_RX_REGISTER_FULL) { + TEGRA_CEC_INT_STAT_RX_START_BIT_DETECTED); + cec->rx_done = false; + cec->rx_buf_cnt = 0; + } + if (status & TEGRA_CEC_INT_STAT_RX_REGISTER_FULL) { u32 v; cec_write(cec, TEGRA_CEC_INT_STAT, @@ -255,7 +252,7 @@ static int tegra_cec_adap_enable(struct cec_adapter *adap, bool enable) TEGRA_CEC_INT_MASK_TX_BUS_ANOMALY_DETECTED | TEGRA_CEC_INT_MASK_TX_FRAME_TRANSMITTED | TEGRA_CEC_INT_MASK_RX_REGISTER_FULL | - TEGRA_CEC_INT_MASK_RX_REGISTER_OVERRUN); + TEGRA_CEC_INT_MASK_RX_START_BIT_DETECTED); cec_write(cec, TEGRA_CEC_HW_CONTROL, TEGRA_CEC_HWCTRL_TX_RX_MODE); return 0; From 2c27476e398bfd9fa2572ff80a0de16f0becc900 Mon Sep 17 00:00:00 2001 From: Michael Ira Krufky Date: Tue, 16 Jan 2018 22:16:12 -0500 Subject: [PATCH 456/942] media: dvb: fix a Kconfig typo drivers/media/Kconfig: typo: replace `with` with `which` Signed-off-by: Michael Ira Krufky Signed-off-by: Mauro Carvalho Chehab --- drivers/media/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/Kconfig b/drivers/media/Kconfig index 372c074bb1b9..86c1a190d946 100644 --- a/drivers/media/Kconfig +++ b/drivers/media/Kconfig @@ -151,7 +151,7 @@ config DVB_MMAP select VIDEOBUF2_VMALLOC default n help - This option enables DVB experimental memory-mapped API, with + This option enables DVB experimental memory-mapped API, which reduces the number of context switches to read DVB buffers, as the buffers can use mmap() syscalls. From 12af5004145a3fa53246cca4cbb2c57d18dde202 Mon Sep 17 00:00:00 2001 From: Abhijeet Kumar Date: Sun, 4 Mar 2018 01:16:39 +0530 Subject: [PATCH 457/942] ASoC: Intel: Skylake: Fix typo Spelling mistake in state. So fixing it. Signed-off-by: Abhijeet Kumar Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index 60d76adade43..f161907859f3 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -1210,7 +1210,7 @@ out: static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe, enum skl_ipc_pipeline_state state) { - dev_dbg(ctx->dev, "%s: pipe_satate = %d\n", __func__, state); + dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state); return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state); } From 745d0bd3af99ccc8c5f5822f808cd133eadad6ac Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Wed, 31 Jan 2018 16:26:27 +0900 Subject: [PATCH 458/942] e1000e: Remove Other from EIAC It was reported that emulated e1000e devices in vmware esxi 6.5 Build 7526125 do not link up after commit 4aea7a5c5e94 ("e1000e: Avoid receiver overrun interrupt bursts", v4.15-rc1). Some tracing shows that after e1000e_trigger_lsc() is called, ICR reads out as 0x0 in e1000_msix_other() on emulated e1000e devices. In comparison, on real e1000e 82574 hardware, icr=0x80000004 (_INT_ASSERTED | _LSC) in the same situation. Some experimentation showed that this flaw in vmware e1000e emulation can be worked around by not setting Other in EIAC. This is how it was before 16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt", v4.5-rc1). Fixes: 4aea7a5c5e94 ("e1000e: Avoid receiver overrun interrupt bursts") Signed-off-by: Benjamin Poirier Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 1298b69f990b..153ad406c65e 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1918,6 +1918,8 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) bool enable = true; icr = er32(ICR); + ew32(ICR, E1000_ICR_OTHER); + if (icr & E1000_ICR_RXO) { ew32(ICR, E1000_ICR_RXO); enable = false; @@ -2040,7 +2042,6 @@ static void e1000_configure_msix(struct e1000_adapter *adapter) hw->hw_addr + E1000_EITR_82574(vector)); else writel(1, hw->hw_addr + E1000_EITR_82574(vector)); - adapter->eiac_mask |= E1000_IMS_OTHER; /* Cause Tx interrupts on every write back */ ivar |= BIT(31); @@ -2265,7 +2266,7 @@ static void e1000_irq_enable(struct e1000_adapter *adapter) if (adapter->msix_entries) { ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574); - ew32(IMS, adapter->eiac_mask | E1000_IMS_LSC); + ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC); } else if (hw->mac.type >= e1000_pch_lpt) { ew32(IMS, IMS_ENABLE_MASK | E1000_IMS_ECCER); } else { From 1f0ea19722ef9dfa229a9540f70b8d1c34a98a6a Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 8 Feb 2018 15:47:12 +0900 Subject: [PATCH 459/942] Partial revert "e1000e: Avoid receiver overrun interrupt bursts" This partially reverts commit 4aea7a5c5e940c1723add439f4088844cd26196d. We keep the fix for the first part of the problem (1) described in the log of that commit, that is to read ICR in the other interrupt handler. We remove the fix for the second part of the problem (2), Other interrupt throttling. Bursts of "Other" interrupts may once again occur during rxo (receive overflow) traffic conditions. This is deemed acceptable in the interest of avoiding unforeseen fallout from changes that are not strictly necessary. As discussed, the e1000e driver should be in "maintenance mode". Link: https://www.spinics.net/lists/netdev/msg480675.html Signed-off-by: Benjamin Poirier Acked-by: Alexander Duyck Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 153ad406c65e..3b36efa6228d 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1915,21 +1915,10 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; u32 icr; - bool enable = true; icr = er32(ICR); ew32(ICR, E1000_ICR_OTHER); - if (icr & E1000_ICR_RXO) { - ew32(ICR, E1000_ICR_RXO); - enable = false; - /* napi poll will re-enable Other, make sure it runs */ - if (napi_schedule_prep(&adapter->napi)) { - adapter->total_rx_bytes = 0; - adapter->total_rx_packets = 0; - __napi_schedule(&adapter->napi); - } - } if (icr & E1000_ICR_LSC) { ew32(ICR, E1000_ICR_LSC); hw->mac.get_link_status = true; @@ -1938,7 +1927,7 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) mod_timer(&adapter->watchdog_timer, jiffies + 1); } - if (enable && !test_bit(__E1000_DOWN, &adapter->state)) + if (!test_bit(__E1000_DOWN, &adapter->state)) ew32(IMS, E1000_IMS_OTHER); return IRQ_HANDLED; @@ -2708,8 +2697,7 @@ static int e1000e_poll(struct napi_struct *napi, int weight) napi_complete_done(napi, work_done); if (!test_bit(__E1000_DOWN, &adapter->state)) { if (adapter->msix_entries) - ew32(IMS, adapter->rx_ring->ims_val | - E1000_IMS_OTHER); + ew32(IMS, adapter->rx_ring->ims_val); else e1000_irq_enable(adapter); } From 361a954e6a7215de11a6179ad9bdc07d7e394b04 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 8 Feb 2018 15:47:13 +0900 Subject: [PATCH 460/942] e1000e: Fix queue interrupt re-raising in Other interrupt Restores the ICS write for Rx/Tx queue interrupts which was present before commit 16ecba59bc33 ("e1000e: Do not read ICR in Other interrupt", v4.5-rc1) but was not restored in commit 4aea7a5c5e94 ("e1000e: Avoid receiver overrun interrupt bursts", v4.15-rc1). This re-raises the queue interrupts in case the txq or rxq bits were set in ICR and the Other interrupt handler read and cleared ICR before the queue interrupt was raised. Fixes: 4aea7a5c5e94 ("e1000e: Avoid receiver overrun interrupt bursts") Signed-off-by: Benjamin Poirier Acked-by: Alexander Duyck Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 3b36efa6228d..2c9609bee2ae 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1919,6 +1919,9 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) icr = er32(ICR); ew32(ICR, E1000_ICR_OTHER); + if (icr & adapter->eiac_mask) + ew32(ICS, (icr & adapter->eiac_mask)); + if (icr & E1000_ICR_LSC) { ew32(ICR, E1000_ICR_LSC); hw->mac.get_link_status = true; From 116f4a640b3197401bc93b8adc6c35040308ceff Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Thu, 8 Feb 2018 15:47:14 +0900 Subject: [PATCH 461/942] e1000e: Avoid missed interrupts following ICR read The 82574 specification update errata 12 states that interrupts may be missed if ICR is read while INT_ASSERTED is not set. Avoid that problem by setting all bits related to events that can trigger the Other interrupt in IMS. The Other interrupt is raised for such events regardless of whether or not they are set in IMS. However, only when they are set is the INT_ASSERTED bit also set in ICR. By doing this, we ensure that INT_ASSERTED is always set when we read ICR in e1000_msix_other() and steer clear of the errata. This also ensures that ICR will automatically be cleared on read, therefore we no longer need to clear bits explicitly. Signed-off-by: Benjamin Poirier Acked-by: Alexander Duyck Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/defines.h | 21 ++++++++++++++++++++- drivers/net/ethernet/intel/e1000e/netdev.c | 11 ++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h index afb7ebe20b24..824fd44e25f0 100644 --- a/drivers/net/ethernet/intel/e1000e/defines.h +++ b/drivers/net/ethernet/intel/e1000e/defines.h @@ -400,6 +400,10 @@ #define E1000_ICR_RXDMT0 0x00000010 /* Rx desc min. threshold (0) */ #define E1000_ICR_RXO 0x00000040 /* Receiver Overrun */ #define E1000_ICR_RXT0 0x00000080 /* Rx timer intr (ring 0) */ +#define E1000_ICR_MDAC 0x00000200 /* MDIO Access Complete */ +#define E1000_ICR_SRPD 0x00010000 /* Small Receive Packet Detected */ +#define E1000_ICR_ACK 0x00020000 /* Receive ACK Frame Detected */ +#define E1000_ICR_MNG 0x00040000 /* Manageability Event Detected */ #define E1000_ICR_ECCER 0x00400000 /* Uncorrectable ECC Error */ /* If this bit asserted, the driver should claim the interrupt */ #define E1000_ICR_INT_ASSERTED 0x80000000 @@ -407,7 +411,7 @@ #define E1000_ICR_RXQ1 0x00200000 /* Rx Queue 1 Interrupt */ #define E1000_ICR_TXQ0 0x00400000 /* Tx Queue 0 Interrupt */ #define E1000_ICR_TXQ1 0x00800000 /* Tx Queue 1 Interrupt */ -#define E1000_ICR_OTHER 0x01000000 /* Other Interrupts */ +#define E1000_ICR_OTHER 0x01000000 /* Other Interrupt */ /* PBA ECC Register */ #define E1000_PBA_ECC_COUNTER_MASK 0xFFF00000 /* ECC counter mask */ @@ -431,12 +435,27 @@ E1000_IMS_RXSEQ | \ E1000_IMS_LSC) +/* These are all of the events related to the OTHER interrupt. + */ +#define IMS_OTHER_MASK ( \ + E1000_IMS_LSC | \ + E1000_IMS_RXO | \ + E1000_IMS_MDAC | \ + E1000_IMS_SRPD | \ + E1000_IMS_ACK | \ + E1000_IMS_MNG) + /* Interrupt Mask Set */ #define E1000_IMS_TXDW E1000_ICR_TXDW /* Transmit desc written back */ #define E1000_IMS_LSC E1000_ICR_LSC /* Link Status Change */ #define E1000_IMS_RXSEQ E1000_ICR_RXSEQ /* Rx sequence error */ #define E1000_IMS_RXDMT0 E1000_ICR_RXDMT0 /* Rx desc min. threshold */ +#define E1000_IMS_RXO E1000_ICR_RXO /* Receiver Overrun */ #define E1000_IMS_RXT0 E1000_ICR_RXT0 /* Rx timer intr */ +#define E1000_IMS_MDAC E1000_ICR_MDAC /* MDIO Access Complete */ +#define E1000_IMS_SRPD E1000_ICR_SRPD /* Small Receive Packet */ +#define E1000_IMS_ACK E1000_ICR_ACK /* Receive ACK Frame Detected */ +#define E1000_IMS_MNG E1000_ICR_MNG /* Manageability Event */ #define E1000_IMS_ECCER E1000_ICR_ECCER /* Uncorrectable ECC Error */ #define E1000_IMS_RXQ0 E1000_ICR_RXQ0 /* Rx Queue 0 Interrupt */ #define E1000_IMS_RXQ1 E1000_ICR_RXQ1 /* Rx Queue 1 Interrupt */ diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 2c9609bee2ae..9fd4050a91ca 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1914,16 +1914,12 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) struct net_device *netdev = data; struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; - u32 icr; - - icr = er32(ICR); - ew32(ICR, E1000_ICR_OTHER); + u32 icr = er32(ICR); if (icr & adapter->eiac_mask) ew32(ICS, (icr & adapter->eiac_mask)); if (icr & E1000_ICR_LSC) { - ew32(ICR, E1000_ICR_LSC); hw->mac.get_link_status = true; /* guard against interrupt when we're going down */ if (!test_bit(__E1000_DOWN, &adapter->state)) @@ -1931,7 +1927,7 @@ static irqreturn_t e1000_msix_other(int __always_unused irq, void *data) } if (!test_bit(__E1000_DOWN, &adapter->state)) - ew32(IMS, E1000_IMS_OTHER); + ew32(IMS, E1000_IMS_OTHER | IMS_OTHER_MASK); return IRQ_HANDLED; } @@ -2258,7 +2254,8 @@ static void e1000_irq_enable(struct e1000_adapter *adapter) if (adapter->msix_entries) { ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574); - ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC); + ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | + IMS_OTHER_MASK); } else if (hw->mac.type >= e1000_pch_lpt) { ew32(IMS, IMS_ENABLE_MASK | E1000_IMS_ECCER); } else { From 4e7dc08e57c95673d2edaba8983c3de4dd1f65f5 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Tue, 20 Feb 2018 15:12:00 +0900 Subject: [PATCH 462/942] e1000e: Fix check_for_link return value with autoneg off When autoneg is off, the .check_for_link callback functions clear the get_link_status flag and systematically return a "pseudo-error". This means that the link is not detected as up until the next execution of the e1000_watchdog_task() 2 seconds later. Fixes: 19110cfbb34d ("e1000e: Separate signaling for link check/link up") Signed-off-by: Benjamin Poirier Acked-by: Sasha Neftin Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 2 +- drivers/net/ethernet/intel/e1000e/mac.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 31277d3bb7dc..ff308b05d68c 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1602,7 +1602,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) * we have already determined whether we have link or not. */ if (!mac->autoneg) - return -E1000_ERR_CONFIG; + return 1; /* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index f457c5703d0c..db735644b312 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -450,7 +450,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) * we have already determined whether we have link or not. */ if (!mac->autoneg) - return -E1000_ERR_CONFIG; + return 1; /* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to From aea3fca005fb45f80869f2e8d56fd4e64c1d1fdb Mon Sep 17 00:00:00 2001 From: Pierre-Yves Kerbrat Date: Fri, 26 Jan 2018 11:24:12 +0100 Subject: [PATCH 463/942] e1000e: allocate ring descriptors with dma_zalloc_coherent Descriptor rings were not initialized at zero when allocated When area contained garbage data, it caused skb_over_panic in e1000_clean_rx_irq (if data had E1000_RXD_STAT_DD bit set) This patch makes use of dma_zalloc_coherent to make sure the ring is memset at 0 to prevent the area from containing garbage. Following is the signature of the panic: IODDR0@0.0: skbuff: skb_over_panic: text:80407b20 len:64010 put:64010 head:ab46d800 data:ab46d842 tail:0xab47d24c end:0xab46df40 dev:eth0 IODDR0@0.0: BUG: failure at net/core/skbuff.c:105/skb_panic()! IODDR0@0.0: Kernel panic - not syncing: BUG! IODDR0@0.0: IODDR0@0.0: Process swapper/0 (pid: 0, threadinfo=81728000, task=8173cc00 ,cpu: 0) IODDR0@0.0: SP = <815a1c0c> IODDR0@0.0: Stack: 00000001 IODDR0@0.0: b2d89800 815e33ac IODDR0@0.0: ea73c040 00000001 IODDR0@0.0: 60040003 0000fa0a IODDR0@0.0: 00000002 IODDR0@0.0: IODDR0@0.0: 804540c0 815a1c70 IODDR0@0.0: b2744000 602ac070 IODDR0@0.0: 815a1c44 b2d89800 IODDR0@0.0: 8173cc00 815a1c08 IODDR0@0.0: IODDR0@0.0: 00000006 IODDR0@0.0: 815a1b50 00000000 IODDR0@0.0: 80079434 00000001 IODDR0@0.0: ab46df40 b2744000 IODDR0@0.0: b2d89800 IODDR0@0.0: IODDR0@0.0: 0000fa0a 8045745c IODDR0@0.0: 815a1c88 0000fa0a IODDR0@0.0: 80407b20 b2789f80 IODDR0@0.0: 00000005 80407b20 IODDR0@0.0: IODDR0@0.0: IODDR0@0.0: Call Trace: IODDR0@0.0: [<804540bc>] skb_panic+0xa4/0xa8 IODDR0@0.0: [<80079430>] console_unlock+0x2f8/0x6d0 IODDR0@0.0: [<80457458>] skb_put+0xa0/0xc0 IODDR0@0.0: [<80407b1c>] e1000_clean_rx_irq+0x2dc/0x3e8 IODDR0@0.0: [<80407b1c>] e1000_clean_rx_irq+0x2dc/0x3e8 IODDR0@0.0: [<804079c8>] e1000_clean_rx_irq+0x188/0x3e8 IODDR0@0.0: [<80407b1c>] e1000_clean_rx_irq+0x2dc/0x3e8 IODDR0@0.0: [<80468b48>] __dev_kfree_skb_any+0x88/0xa8 IODDR0@0.0: [<804101ac>] e1000e_poll+0x94/0x288 IODDR0@0.0: [<8046e9d4>] net_rx_action+0x19c/0x4e8 IODDR0@0.0: ... IODDR0@0.0: Maximum depth to print reached. Use kstack= To specify a custom value (where 0 means to display the full backtrace) IODDR0@0.0: ---[ end Kernel panic - not syncing: BUG! Signed-off-by: Pierre-Yves Kerbrat Signed-off-by: Marius Gligor Tested-by: Aaron Brown Reviewed-by: Alexander Duyck Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/netdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index 9fd4050a91ca..c0f23446bf26 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -2323,8 +2323,8 @@ static int e1000_alloc_ring_dma(struct e1000_adapter *adapter, { struct pci_dev *pdev = adapter->pdev; - ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma, - GFP_KERNEL); + ring->desc = dma_zalloc_coherent(&pdev->dev, ring->size, &ring->dma, + GFP_KERNEL); if (!ring->desc) return -ENOMEM; From 0d3601d2994a4ad9edf0b44f2ea34c68ff494ea5 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 5 Mar 2018 16:07:38 +0100 Subject: [PATCH 464/942] netfilter: nft_set_hash: skip fixed hash if timeout is specified Fixed hash supports to timeouts, so skip it. Otherwise, userspace hits EOPNOTSUPP. Fixes: 6c03ae210ce3 ("netfilter: nft_set_hash: add non-resizable hashtable implementation") Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nft_set_hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netfilter/nft_set_hash.c b/net/netfilter/nft_set_hash.c index 3f1624ee056f..d40591fe1b2f 100644 --- a/net/netfilter/nft_set_hash.c +++ b/net/netfilter/nft_set_hash.c @@ -674,7 +674,7 @@ static const struct nft_set_ops * nft_hash_select_ops(const struct nft_ctx *ctx, const struct nft_set_desc *desc, u32 flags) { - if (desc->size) { + if (desc->size && !(flags & NFT_SET_TIMEOUT)) { switch (desc->klen) { case 4: return &nft_hash_fast_ops; From a42ae5905140c324362fe5036ae1dbb16e4d359c Mon Sep 17 00:00:00 2001 From: Frank Mori Hess Date: Thu, 15 Feb 2018 15:13:42 -0500 Subject: [PATCH 465/942] staging: comedi: fix comedi_nsamples_left. A rounding error was causing comedi_nsamples_left to return the wrong value when nsamples was not a multiple of the scan length. Cc: # v4.4+ Signed-off-by: Frank Mori Hess Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c index e618a87521a3..9d733471ca2e 100644 --- a/drivers/staging/comedi/drivers.c +++ b/drivers/staging/comedi/drivers.c @@ -475,8 +475,7 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s, struct comedi_cmd *cmd = &async->cmd; if (cmd->stop_src == TRIG_COUNT) { - unsigned int nscans = nsamples / cmd->scan_end_arg; - unsigned int scans_left = __comedi_nscans_left(s, nscans); + unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg); unsigned int scan_pos = comedi_bytes_to_samples(s, async->scan_progress); unsigned long long samples_left = 0; From 740a5759bf222332fbb5eda42f89aa25ba38f9b2 Mon Sep 17 00:00:00 2001 From: Yisheng Xie Date: Wed, 28 Feb 2018 14:59:22 +0800 Subject: [PATCH 466/942] staging: android: ashmem: Fix possible deadlock in ashmem_ioctl ashmem_mutex may create a chain of dependencies like: CPU0 CPU1 mmap syscall ioctl syscall -> mmap_sem (acquired) -> ashmem_ioctl -> ashmem_mmap -> ashmem_mutex (acquired) -> ashmem_mutex (try to acquire) -> copy_from_user -> mmap_sem (try to acquire) There is a lock odering problem between mmap_sem and ashmem_mutex causing a lockdep splat[1] during a syzcaller test. This patch fixes the problem by move copy_from_user out of ashmem_mutex. [1] https://www.spinics.net/lists/kernel/msg2733200.html Fixes: ce8a3a9e76d0 (staging: android: ashmem: Fix a race condition in pin ioctls) Reported-by: syzbot+d7a918a7a8e1c952bc36@syzkaller.appspotmail.com Signed-off-by: Yisheng Xie Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index d5450365769c..86580b6df33d 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -701,16 +701,14 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd, size_t pgstart, pgend; int ret = -EINVAL; + if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) + return -EFAULT; + mutex_lock(&ashmem_mutex); if (unlikely(!asma->file)) goto out_unlock; - if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) { - ret = -EFAULT; - goto out_unlock; - } - /* per custom, you can pass zero for len to mean "everything onward" */ if (!pin.len) pin.len = PAGE_ALIGN(asma->size) - pin.offset; From cd526676de1ece03a8ea7cea726cf879a2dba2b8 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Fri, 2 Mar 2018 15:08:36 -0800 Subject: [PATCH 467/942] net: dsa: b53: Use strlcpy() for ethtool::get_strings Our statistics strings are allocated at initialization without being bound to a specific size, yet, we would copy ETH_GSTRING_LEN bytes using memcpy() which would create out of bounds accesses, this was flagged by KASAN. Replace this with strlcpy() to make sure we are bound the source buffer size and we also always NUL-terminate strings. Fixes: 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/dsa/b53/b53_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index db830a1141d9..63e02a54d537 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -814,8 +814,8 @@ void b53_get_strings(struct dsa_switch *ds, int port, uint8_t *data) unsigned int i; for (i = 0; i < mib_size; i++) - memcpy(data + i * ETH_GSTRING_LEN, - mibs[i].name, ETH_GSTRING_LEN); + strlcpy(data + i * ETH_GSTRING_LEN, + mibs[i].name, ETH_GSTRING_LEN); } EXPORT_SYMBOL(b53_get_strings); From 98409b2bbca36b578be8e66758e6acb96e4c91da Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Fri, 2 Mar 2018 15:08:37 -0800 Subject: [PATCH 468/942] net: phy: marvell: Use strlcpy() for ethtool::get_strings Our statistics strings are allocated at initialization without being bound to a specific size, yet, we would copy ETH_GSTRING_LEN bytes using memcpy() which would create out of bounds accesses, this was flagged by KASAN. Replace this with strlcpy() to make sure we are bound the source buffer size and we also always NUL-terminate strings. Fixes: d2fa47d9dd5c ("phy: marvell: Add ethtool statistics counters") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/phy/marvell.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 22d9bc9c33a4..0e0978d8a0eb 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -1452,8 +1452,8 @@ static void marvell_get_strings(struct phy_device *phydev, u8 *data) int i; for (i = 0; i < ARRAY_SIZE(marvell_hw_stats); i++) { - memcpy(data + i * ETH_GSTRING_LEN, - marvell_hw_stats[i].string, ETH_GSTRING_LEN); + strlcpy(data + i * ETH_GSTRING_LEN, + marvell_hw_stats[i].string, ETH_GSTRING_LEN); } } From 55f53567afe5f0cd2fd9e006b174c08c31c466f8 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Fri, 2 Mar 2018 15:08:38 -0800 Subject: [PATCH 469/942] net: phy: micrel: Use strlcpy() for ethtool::get_strings Our statistics strings are allocated at initialization without being bound to a specific size, yet, we would copy ETH_GSTRING_LEN bytes using memcpy() which would create out of bounds accesses, this was flagged by KASAN. Replace this with strlcpy() to make sure we are bound the source buffer size and we also always NUL-terminate strings. Fixes: 2b2427d06426 ("phy: micrel: Add ethtool statistics counters") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/phy/micrel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 0f45310300f6..49be85afbea9 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -664,8 +664,8 @@ static void kszphy_get_strings(struct phy_device *phydev, u8 *data) int i; for (i = 0; i < ARRAY_SIZE(kszphy_hw_stats); i++) { - memcpy(data + i * ETH_GSTRING_LEN, - kszphy_hw_stats[i].string, ETH_GSTRING_LEN); + strlcpy(data + i * ETH_GSTRING_LEN, + kszphy_hw_stats[i].string, ETH_GSTRING_LEN); } } From 8a17eefa235f73b60c0ca7d397d2e4f66f85f413 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Fri, 2 Mar 2018 15:08:39 -0800 Subject: [PATCH 470/942] net: phy: broadcom: Use strlcpy() for ethtool::get_strings Our statistics strings are allocated at initialization without being bound to a specific size, yet, we would copy ETH_GSTRING_LEN bytes using memcpy() which would create out of bounds accesses, this was flagged by KASAN. Replace this with strlcpy() to make sure we are bound the source buffer size and we also always NUL-terminate strings. Fixes: 820ee17b8d3b ("net: phy: broadcom: Add support code for reading PHY counters") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/phy/bcm-phy-lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index 171010eb4d9c..5ad130c3da43 100644 --- a/drivers/net/phy/bcm-phy-lib.c +++ b/drivers/net/phy/bcm-phy-lib.c @@ -341,8 +341,8 @@ void bcm_phy_get_strings(struct phy_device *phydev, u8 *data) unsigned int i; for (i = 0; i < ARRAY_SIZE(bcm_phy_hw_stats); i++) - memcpy(data + i * ETH_GSTRING_LEN, - bcm_phy_hw_stats[i].string, ETH_GSTRING_LEN); + strlcpy(data + i * ETH_GSTRING_LEN, + bcm_phy_hw_stats[i].string, ETH_GSTRING_LEN); } EXPORT_SYMBOL_GPL(bcm_phy_get_strings); From 22b8d8115d1b940d548a5fddcbce4cdd30083cfc Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Fri, 2 Mar 2018 16:34:22 -0800 Subject: [PATCH 471/942] ethernet: natsemi: correct spelling Correct spelling of National Semi-conductor (no hyphen) in drivers/net/ethernet/. Signed-off-by: Randy Dunlap Signed-off-by: David S. Miller --- drivers/net/ethernet/8390/Kconfig | 2 +- drivers/net/ethernet/natsemi/Kconfig | 6 +++--- drivers/net/ethernet/natsemi/Makefile | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig index 29c3075bfb05..fdc673484add 100644 --- a/drivers/net/ethernet/8390/Kconfig +++ b/drivers/net/ethernet/8390/Kconfig @@ -3,7 +3,7 @@ # config NET_VENDOR_8390 - bool "National Semi-conductor 8390 devices" + bool "National Semiconductor 8390 devices" default y depends on NET_VENDOR_NATSEMI ---help--- diff --git a/drivers/net/ethernet/natsemi/Kconfig b/drivers/net/ethernet/natsemi/Kconfig index a10ef50e4f12..017fb2322589 100644 --- a/drivers/net/ethernet/natsemi/Kconfig +++ b/drivers/net/ethernet/natsemi/Kconfig @@ -1,16 +1,16 @@ # -# National Semi-conductor device configuration +# National Semiconductor device configuration # config NET_VENDOR_NATSEMI - bool "National Semi-conductor devices" + bool "National Semiconductor devices" default y ---help--- If you have a network (Ethernet) card belonging to this class, say Y. Note that the answer to this question doesn't directly affect the kernel: saying N will just cause the configurator to skip all - the questions about National Semi-conductor devices. If you say Y, + the questions about National Semiconductor devices. If you say Y, you will be asked for your specific card in the following questions. if NET_VENDOR_NATSEMI diff --git a/drivers/net/ethernet/natsemi/Makefile b/drivers/net/ethernet/natsemi/Makefile index cc664977596e..a759aa09ef59 100644 --- a/drivers/net/ethernet/natsemi/Makefile +++ b/drivers/net/ethernet/natsemi/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # -# Makefile for the National Semi-conductor Sonic devices. +# Makefile for the National Semiconductor Sonic devices. # obj-$(CONFIG_MACSONIC) += macsonic.o From 9a513c905bb95bef79d96feb08621c1ec8d8c4bb Mon Sep 17 00:00:00 2001 From: Oliver Neukum Date: Tue, 6 Mar 2018 15:04:24 +0100 Subject: [PATCH 472/942] uas: fix comparison for error code A typo broke the comparison. Fixes: cbeef22fd611 ("usb: uas: unconditionally bring back host after reset") Signed-off-by: Oliver Neukum CC: stable@kernel.org Acked-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/uas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index 3b1b9695177a..6034c39b67d1 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c @@ -1076,7 +1076,7 @@ static int uas_post_reset(struct usb_interface *intf) return 0; err = uas_configure_endpoints(devinfo); - if (err && err != ENODEV) + if (err && err != -ENODEV) shost_printk(KERN_ERR, shost, "%s: alloc streams error %d after reset", __func__, err); From cb88a0588717ba6c756cb5972d75766b273a6817 Mon Sep 17 00:00:00 2001 From: Danilo Krummrich Date: Tue, 6 Mar 2018 09:38:49 +0100 Subject: [PATCH 473/942] usb: quirks: add control message delay for 1b1c:1b20 Corsair Strafe RGB keyboard does not respond to usb control messages sometimes and hence generates timeouts. Commit de3af5bf259d ("usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard") tried to fix those timeouts by adding USB_QUIRK_DELAY_INIT. Unfortunately, even with this quirk timeouts of usb_control_msg() can still be seen, but with a lower frequency (approx. 1 out of 15): [ 29.103520] usb 1-8: string descriptor 0 read error: -110 [ 34.363097] usb 1-8: can't set config #1, error -110 Adding further delays to different locations where usb control messages are issued just moves the timeouts to other locations, e.g.: [ 35.400533] usbhid 1-8:1.0: can't add hid device: -110 [ 35.401014] usbhid: probe of 1-8:1.0 failed with error -110 The only way to reliably avoid those issues is having a pause after each usb control message. In approx. 200 boot cycles no more timeouts were seen. Addionaly, keep USB_QUIRK_DELAY_INIT as it turned out to be necessary to have the delay in hub_port_connect() after hub_port_init(). The overall boot time seems not to be influenced by these additional delays, even on fast machines and lightweight distributions. Fixes: de3af5bf259d ("usb: quirks: add delay init quirk for Corsair Strafe RGB keyboard") Cc: stable@vger.kernel.org Signed-off-by: Danilo Krummrich Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/message.c | 4 ++++ drivers/usb/core/quirks.c | 3 ++- include/linux/usb/quirks.h | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index c64cf6c4a83d..0c11d40a12bc 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c @@ -151,6 +151,10 @@ int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, ret = usb_internal_control_msg(dev, pipe, dr, data, size, timeout); + /* Linger a bit, prior to the next control message. */ + if (dev->quirks & USB_QUIRK_DELAY_CTRL_MSG) + msleep(200); + kfree(dr); return ret; diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index f4a548471f0f..54b019e267c5 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c @@ -230,7 +230,8 @@ static const struct usb_device_id usb_quirk_list[] = { { USB_DEVICE(0x1b1c, 0x1b13), .driver_info = USB_QUIRK_DELAY_INIT }, /* Corsair Strafe RGB */ - { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT }, + { USB_DEVICE(0x1b1c, 0x1b20), .driver_info = USB_QUIRK_DELAY_INIT | + USB_QUIRK_DELAY_CTRL_MSG }, /* Corsair K70 LUX */ { USB_DEVICE(0x1b1c, 0x1b36), .driver_info = USB_QUIRK_DELAY_INIT }, diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h index f1fcec2fd5f8..b7a99ce56bc9 100644 --- a/include/linux/usb/quirks.h +++ b/include/linux/usb/quirks.h @@ -63,4 +63,7 @@ */ #define USB_QUIRK_DISCONNECT_SUSPEND BIT(12) +/* Device needs a pause after every control message. */ +#define USB_QUIRK_DELAY_CTRL_MSG BIT(13) + #endif /* __LINUX_USB_QUIRKS_H */ From df6b074dbe248d8c43a82131e8fd429e401841a5 Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Mon, 5 Mar 2018 11:35:10 -0600 Subject: [PATCH 474/942] usb: musb: call pm_runtime_{get,put}_sync before reading vbus registers Without pm_runtime_{get,put}_sync calls in place, reading vbus status via /sys causes the following error: Unhandled fault: external abort on non-linefetch (0x1028) at 0xfa0ab060 pgd = b333e822 [fa0ab060] *pgd=48011452(bad) [] (musb_default_readb) from [] (musb_vbus_show+0x58/0xe4) [] (musb_vbus_show) from [] (dev_attr_show+0x20/0x44) [] (dev_attr_show) from [] (sysfs_kf_seq_show+0x80/0xdc) [] (sysfs_kf_seq_show) from [] (seq_read+0x250/0x448) [] (seq_read) from [] (__vfs_read+0x1c/0x118) [] (__vfs_read) from [] (vfs_read+0x90/0x144) [] (vfs_read) from [] (SyS_read+0x3c/0x74) [] (SyS_read) from [] (ret_fast_syscall+0x0/0x54) Solution was suggested by Tony Lindgren . Signed-off-by: Merlijn Wajer Acked-by: Tony Lindgren Signed-off-by: Bin Liu Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index eef4ad578b31..c344ef4e5355 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1756,6 +1756,7 @@ vbus_show(struct device *dev, struct device_attribute *attr, char *buf) int vbus; u8 devctl; + pm_runtime_get_sync(dev); spin_lock_irqsave(&musb->lock, flags); val = musb->a_wait_bcon; vbus = musb_platform_get_vbus_status(musb); @@ -1769,6 +1770,7 @@ vbus_show(struct device *dev, struct device_attribute *attr, char *buf) vbus = 0; } spin_unlock_irqrestore(&musb->lock, flags); + pm_runtime_put_sync(dev); return sprintf(buf, "Vbus %s, timeout %lu msec\n", vbus ? "on" : "off", val); From 6f566af3462897fc743e3af6ea8cc790a13148ba Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 6 Mar 2018 10:50:05 +0100 Subject: [PATCH 475/942] Revert "typec: tcpm: Only request matching pdos" Commit 57e6f0d7b804 ("typec: tcpm: Only request matching pdos") is causing a regression, before this commit e.g. the GPD win and GPD pocket devices were charging at 9V 3A with a PD charger, now they are instead slowly discharging at 5V 0.4A, as this commit causes the ports max_snk_mv/ma/mw settings to be completely ignored. Arguably the way to fix this would be to add a PDO_VAR() describing the voltage range to the snk_caps of boards which can handle any voltage in their range, but the "typec: tcpm: Only request matching pdos" commit looks at the type of PDO advertised by the source/charger and if that is fixed (as it typically is) only compairs against PDO_FIXED entries in the snk_caps so supporting a range of voltage would require adding a PDO_FIXED entry for *every possible* voltage to snk_caps. AFAICT there is no reason why a fixed source_cap cannot be matched against a variable snk_cap, so at a minimum the commit should be rewritten to support that. For now lets revert the "typec: tcpm: Only request matching pdos" commit, fixing the regression. Fixes: 57e6f0d7b804 ("typec: tcpm: Only request matching pdos") Cc: Badhri Jagan Sridharan Signed-off-by: Hans de Goede Acked-by: Heikki Krogerus Acked-by: Adam Thomson Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/tcpm.c | 163 ++++++++++----------------------------- 1 file changed, 42 insertions(+), 121 deletions(-) diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index f4d563ee7690..8b637a4b474b 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -252,9 +252,6 @@ struct tcpm_port { unsigned int nr_src_pdo; u32 snk_pdo[PDO_MAX_OBJECTS]; unsigned int nr_snk_pdo; - unsigned int nr_fixed; /* number of fixed sink PDOs */ - unsigned int nr_var; /* number of variable sink PDOs */ - unsigned int nr_batt; /* number of battery sink PDOs */ u32 snk_vdo[VDO_MAX_OBJECTS]; unsigned int nr_snk_vdo; @@ -1770,90 +1767,39 @@ static int tcpm_pd_check_request(struct tcpm_port *port) return 0; } -#define min_power(x, y) min(pdo_max_power(x), pdo_max_power(y)) -#define min_current(x, y) min(pdo_max_current(x), pdo_max_current(y)) - -static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, - int *src_pdo) +static int tcpm_pd_select_pdo(struct tcpm_port *port) { - unsigned int i, j, max_mw = 0, max_mv = 0, mw = 0, mv = 0, ma = 0; + unsigned int i, max_mw = 0, max_mv = 0; int ret = -EINVAL; /* - * Select the source PDO providing the most power which has a - * matchig sink cap. + * Select the source PDO providing the most power while staying within + * the board's voltage limits. Prefer PDO providing exp */ for (i = 0; i < port->nr_source_caps; i++) { u32 pdo = port->source_caps[i]; enum pd_pdo_type type = pdo_type(pdo); + unsigned int mv, ma, mw; - if (type == PDO_TYPE_FIXED) { - for (j = 0; j < port->nr_fixed; j++) { - if (pdo_fixed_voltage(pdo) == - pdo_fixed_voltage(port->snk_pdo[j])) { - ma = min_current(pdo, port->snk_pdo[j]); - mv = pdo_fixed_voltage(pdo); - mw = ma * mv / 1000; - if (mw > max_mw || - (mw == max_mw && mv > max_mv)) { - ret = 0; - *src_pdo = i; - *sink_pdo = j; - max_mw = mw; - max_mv = mv; - } - /* There could only be one fixed pdo - * at a specific voltage level. - * So breaking here. - */ - break; - } - } - } else if (type == PDO_TYPE_BATT) { - for (j = port->nr_fixed; - j < port->nr_fixed + - port->nr_batt; - j++) { - if (pdo_min_voltage(pdo) >= - pdo_min_voltage(port->snk_pdo[j]) && - pdo_max_voltage(pdo) <= - pdo_max_voltage(port->snk_pdo[j])) { - mw = min_power(pdo, port->snk_pdo[j]); - mv = pdo_min_voltage(pdo); - if (mw > max_mw || - (mw == max_mw && mv > max_mv)) { - ret = 0; - *src_pdo = i; - *sink_pdo = j; - max_mw = mw; - max_mv = mv; - } - } - } - } else if (type == PDO_TYPE_VAR) { - for (j = port->nr_fixed + - port->nr_batt; - j < port->nr_fixed + - port->nr_batt + - port->nr_var; - j++) { - if (pdo_min_voltage(pdo) >= - pdo_min_voltage(port->snk_pdo[j]) && - pdo_max_voltage(pdo) <= - pdo_max_voltage(port->snk_pdo[j])) { - ma = min_current(pdo, port->snk_pdo[j]); - mv = pdo_min_voltage(pdo); - mw = ma * mv / 1000; - if (mw > max_mw || - (mw == max_mw && mv > max_mv)) { - ret = 0; - *src_pdo = i; - *sink_pdo = j; - max_mw = mw; - max_mv = mv; - } - } - } + if (type == PDO_TYPE_FIXED) + mv = pdo_fixed_voltage(pdo); + else + mv = pdo_min_voltage(pdo); + + if (type == PDO_TYPE_BATT) { + mw = pdo_max_power(pdo); + } else { + ma = min(pdo_max_current(pdo), + port->max_snk_ma); + mw = ma * mv / 1000; + } + + /* Perfer higher voltages if available */ + if ((mw > max_mw || (mw == max_mw && mv > max_mv)) && + mv <= port->max_snk_mv) { + ret = i; + max_mw = mw; + max_mv = mv; } } @@ -1865,14 +1811,13 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) unsigned int mv, ma, mw, flags; unsigned int max_ma, max_mw; enum pd_pdo_type type; - int src_pdo_index, snk_pdo_index; - u32 pdo, matching_snk_pdo; + int index; + u32 pdo; - if (tcpm_pd_select_pdo(port, &snk_pdo_index, &src_pdo_index) < 0) + index = tcpm_pd_select_pdo(port); + if (index < 0) return -EINVAL; - - pdo = port->source_caps[src_pdo_index]; - matching_snk_pdo = port->snk_pdo[snk_pdo_index]; + pdo = port->source_caps[index]; type = pdo_type(pdo); if (type == PDO_TYPE_FIXED) @@ -1880,28 +1825,26 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) else mv = pdo_min_voltage(pdo); - /* Select maximum available current within the sink pdo's limit */ + /* Select maximum available current within the board's power limit */ if (type == PDO_TYPE_BATT) { - mw = min_power(pdo, matching_snk_pdo); - ma = 1000 * mw / mv; + mw = pdo_max_power(pdo); + ma = 1000 * min(mw, port->max_snk_mw) / mv; } else { - ma = min_current(pdo, matching_snk_pdo); - mw = ma * mv / 1000; + ma = min(pdo_max_current(pdo), + 1000 * port->max_snk_mw / mv); } + ma = min(ma, port->max_snk_ma); flags = RDO_USB_COMM | RDO_NO_SUSPEND; /* Set mismatch bit if offered power is less than operating power */ + mw = ma * mv / 1000; max_ma = ma; max_mw = mw; if (mw < port->operating_snk_mw) { flags |= RDO_CAP_MISMATCH; - if (type == PDO_TYPE_BATT && - (pdo_max_power(matching_snk_pdo) > pdo_max_power(pdo))) - max_mw = pdo_max_power(matching_snk_pdo); - else if (pdo_max_current(matching_snk_pdo) > - pdo_max_current(pdo)) - max_ma = pdo_max_current(matching_snk_pdo); + max_mw = port->operating_snk_mw; + max_ma = max_mw * 1000 / mv; } tcpm_log(port, "cc=%d cc1=%d cc2=%d vbus=%d vconn=%s polarity=%d", @@ -1910,16 +1853,16 @@ static int tcpm_pd_build_request(struct tcpm_port *port, u32 *rdo) port->polarity); if (type == PDO_TYPE_BATT) { - *rdo = RDO_BATT(src_pdo_index + 1, mw, max_mw, flags); + *rdo = RDO_BATT(index + 1, mw, max_mw, flags); tcpm_log(port, "Requesting PDO %d: %u mV, %u mW%s", - src_pdo_index, mv, mw, + index, mv, mw, flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); } else { - *rdo = RDO_FIXED(src_pdo_index + 1, ma, max_ma, flags); + *rdo = RDO_FIXED(index + 1, ma, max_ma, flags); tcpm_log(port, "Requesting PDO %d: %u mV, %u mA%s", - src_pdo_index, mv, ma, + index, mv, ma, flags & RDO_CAP_MISMATCH ? " [mismatch]" : ""); } @@ -3650,19 +3593,6 @@ int tcpm_update_sink_capabilities(struct tcpm_port *port, const u32 *pdo, } EXPORT_SYMBOL_GPL(tcpm_update_sink_capabilities); -static int nr_type_pdos(const u32 *pdo, unsigned int nr_pdo, - enum pd_pdo_type type) -{ - int count = 0; - int i; - - for (i = 0; i < nr_pdo; i++) { - if (pdo_type(pdo[i]) == type) - count++; - } - return count; -} - struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) { struct tcpm_port *port; @@ -3708,15 +3638,6 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) tcpc->config->nr_src_pdo); port->nr_snk_pdo = tcpm_copy_pdos(port->snk_pdo, tcpc->config->snk_pdo, tcpc->config->nr_snk_pdo); - port->nr_fixed = nr_type_pdos(port->snk_pdo, - port->nr_snk_pdo, - PDO_TYPE_FIXED); - port->nr_var = nr_type_pdos(port->snk_pdo, - port->nr_snk_pdo, - PDO_TYPE_VAR); - port->nr_batt = nr_type_pdos(port->snk_pdo, - port->nr_snk_pdo, - PDO_TYPE_BATT); port->nr_snk_vdo = tcpm_copy_vdos(port->snk_vdo, tcpc->config->snk_vdo, tcpc->config->nr_snk_vdo); From 655296c8bbeffcf020558c4455305d597a73bde1 Mon Sep 17 00:00:00 2001 From: Michael Kelley Date: Sun, 4 Mar 2018 22:24:08 -0700 Subject: [PATCH 476/942] Drivers: hv: vmbus: Fix ring buffer signaling Fix bugs in signaling the Hyper-V host when freeing space in the host->guest ring buffer: 1. The interrupt_mask must not be used to determine whether to signal on the host->guest ring buffer 2. The ring buffer write_index must be read (via hv_get_bytes_to_write) *after* pending_send_sz is read in order to avoid a race condition 3. Comparisons with pending_send_sz must treat the "equals" case as not-enough-space 4. Don't signal if the pending_send_sz feature is not present. Older versions of Hyper-V that don't implement this feature will poll. Fixes: 03bad714a161 ("vmbus: more host signalling avoidance") Cc: Stable # 4.14 and above Signed-off-by: Michael Kelley Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman --- drivers/hv/ring_buffer.c | 52 +++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 50e071444a5c..8699bb969e7e 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c @@ -417,13 +417,24 @@ __hv_pkt_iter_next(struct vmbus_channel *channel, } EXPORT_SYMBOL_GPL(__hv_pkt_iter_next); +/* How many bytes were read in this iterator cycle */ +static u32 hv_pkt_iter_bytes_read(const struct hv_ring_buffer_info *rbi, + u32 start_read_index) +{ + if (rbi->priv_read_index >= start_read_index) + return rbi->priv_read_index - start_read_index; + else + return rbi->ring_datasize - start_read_index + + rbi->priv_read_index; +} + /* * Update host ring buffer after iterating over packets. */ void hv_pkt_iter_close(struct vmbus_channel *channel) { struct hv_ring_buffer_info *rbi = &channel->inbound; - u32 orig_write_sz = hv_get_bytes_to_write(rbi); + u32 curr_write_sz, pending_sz, bytes_read, start_read_index; /* * Make sure all reads are done before we update the read index since @@ -431,8 +442,12 @@ void hv_pkt_iter_close(struct vmbus_channel *channel) * is updated. */ virt_rmb(); + start_read_index = rbi->ring_buffer->read_index; rbi->ring_buffer->read_index = rbi->priv_read_index; + if (!rbi->ring_buffer->feature_bits.feat_pending_send_sz) + return; + /* * Issue a full memory barrier before making the signaling decision. * Here is the reason for having this barrier: @@ -446,26 +461,29 @@ void hv_pkt_iter_close(struct vmbus_channel *channel) */ virt_mb(); - /* If host has disabled notifications then skip */ - if (rbi->ring_buffer->interrupt_mask) + pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); + if (!pending_sz) return; - if (rbi->ring_buffer->feature_bits.feat_pending_send_sz) { - u32 pending_sz = READ_ONCE(rbi->ring_buffer->pending_send_sz); + /* + * Ensure the read of write_index in hv_get_bytes_to_write() + * happens after the read of pending_send_sz. + */ + virt_rmb(); + curr_write_sz = hv_get_bytes_to_write(rbi); + bytes_read = hv_pkt_iter_bytes_read(rbi, start_read_index); - /* - * If there was space before we began iteration, - * then host was not blocked. Also handles case where - * pending_sz is zero then host has nothing pending - * and does not need to be signaled. - */ - if (orig_write_sz > pending_sz) - return; + /* + * If there was space before we began iteration, + * then host was not blocked. + */ - /* If pending write will not fit, don't give false hope. */ - if (hv_get_bytes_to_write(rbi) < pending_sz) - return; - } + if (curr_write_sz - bytes_read > pending_sz) + return; + + /* If pending write will not fit, don't give false hope. */ + if (curr_write_sz <= pending_sz) + return; vmbus_setevent(channel); } From 167f5594b5efa20a26ff03b3424f793887e6b448 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Tue, 6 Mar 2018 15:56:47 +1100 Subject: [PATCH 477/942] kernel/memremap: Remove stale devres_free() call devm_memremap_pages() was re-worked in e8d513483300 "memremap: change devm_memremap_pages interface to use struct dev_pagemap" to take a caller allocated struct dev_pagemap as a function parameter. A call to devres_free() was left in the error cleanup path which results in a kernel panic if the remap fails for some reason. Remove it to fix the panic and let devm_memremap_pages() fail gracefully. Fixes: e8d513483300 ("memremap: change devm_memremap_pages interface...") Signed-off-by: Oliver O'Halloran Reviewed-by: Christoph Hellwig Reviewed-by: Logan Gunthorpe Signed-off-by: Dan Williams --- kernel/memremap.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/memremap.c b/kernel/memremap.c index 4dd4274cabe2..895e6b76b25e 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -427,7 +427,6 @@ void *devm_memremap_pages(struct device *dev, struct dev_pagemap *pgmap) err_pfn_remap: err_radix: pgmap_radix_release(res, pgoff); - devres_free(pgmap); return ERR_PTR(error); } EXPORT_SYMBOL(devm_memremap_pages); From 2cbb4ea7de167b02ffa63e9cdfdb07a7e7094615 Mon Sep 17 00:00:00 2001 From: David Ahern Date: Fri, 16 Feb 2018 11:03:03 -0800 Subject: [PATCH 478/942] net: Only honor ifindex in IP_PKTINFO if non-0 Only allow ifindex from IP_PKTINFO to override SO_BINDTODEVICE settings if the index is actually set in the message. Signed-off-by: David Ahern Signed-off-by: David S. Miller --- net/ipv4/ip_sockglue.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 9c41a0cef1a5..74c962b9b09c 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -258,7 +258,8 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, src_info = (struct in6_pktinfo *)CMSG_DATA(cmsg); if (!ipv6_addr_v4mapped(&src_info->ipi6_addr)) return -EINVAL; - ipc->oif = src_info->ipi6_ifindex; + if (src_info->ipi6_ifindex) + ipc->oif = src_info->ipi6_ifindex; ipc->addr = src_info->ipi6_addr.s6_addr32[3]; continue; } @@ -288,7 +289,8 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, if (cmsg->cmsg_len != CMSG_LEN(sizeof(struct in_pktinfo))) return -EINVAL; info = (struct in_pktinfo *)CMSG_DATA(cmsg); - ipc->oif = info->ipi_ifindex; + if (info->ipi_ifindex) + ipc->oif = info->ipi_ifindex; ipc->addr = info->ipi_spec_dst.s_addr; break; } From 20d5de51e7052ae3fb645d8c5c584ee7383b2a93 Mon Sep 17 00:00:00 2001 From: Jiri Benc Date: Tue, 6 Mar 2018 14:50:10 +0100 Subject: [PATCH 479/942] tools: bpftool: fix compilation with older headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compilation of bpftool on a distro that lacks eBPF support in the installed kernel headers fails with: common.c: In function ‘is_bpffs’: common.c:96:40: error: ‘BPF_FS_MAGIC’ undeclared (first use in this function) return (unsigned long)st_fs.f_type == BPF_FS_MAGIC; ^ Fix this the same way it is already in tools/lib/bpf/libbpf.c and tools/lib/api/fs/fs.c. Signed-off-by: Jiri Benc Signed-off-by: Daniel Borkmann --- tools/bpf/bpftool/common.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c index 0b482c0070e0..465995281dcd 100644 --- a/tools/bpf/bpftool/common.c +++ b/tools/bpf/bpftool/common.c @@ -55,6 +55,10 @@ #include "main.h" +#ifndef BPF_FS_MAGIC +#define BPF_FS_MAGIC 0xcafe4a11 +#endif + void p_err(const char *fmt, ...) { va_list ap; From 864449eea7c600596e305ffdc4a6a846414b222c Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 26 Feb 2018 15:26:01 +0100 Subject: [PATCH 480/942] scsi: mpt3sas: Do not mark fw_event workqueue as WQ_MEM_RECLAIM The firmware event workqueue should not be marked as WQ_MEM_RECLAIM as it's doesn't need to make forward progress under memory pressure. In the current state it will result in a deadlock if the device had been forcefully removed. Cc: Sreekanth Reddy Cc: Suganath Prabu Subramani Acked-by: Sreekanth Reddy Signed-off-by: Hannes Reinecke Signed-off-by: Martin K. Petersen --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index c2ea13c7e37e..a1cb0236c550 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -10558,7 +10558,7 @@ _scsih_probe(struct pci_dev *pdev, const struct pci_device_id *id) snprintf(ioc->firmware_event_name, sizeof(ioc->firmware_event_name), "fw_event_%s%d", ioc->driver_name, ioc->id); ioc->firmware_event_thread = alloc_ordered_workqueue( - ioc->firmware_event_name, WQ_MEM_RECLAIM); + ioc->firmware_event_name, 0); if (!ioc->firmware_event_thread) { pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n", ioc->name, __FILE__, __LINE__, __func__); From 4b433924b2755a94f99258c178684a0e05c344de Mon Sep 17 00:00:00 2001 From: Damien Le Moal Date: Fri, 2 Mar 2018 07:19:28 +0900 Subject: [PATCH 481/942] scsi: sd_zbc: Fix potential memory leak Rework sd_zbc_check_zone_size() to avoid a memory leak due to an early return if sd_zbc_report_zones() fails. Reported-by: David.butterfield Signed-off-by: Damien Le Moal Cc: stable@vger.kernel.org Reviewed-by: Bart Van Assche Signed-off-by: Martin K. Petersen --- drivers/scsi/sd_zbc.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 27793b9f54c0..9049a189c8e5 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c @@ -486,7 +486,7 @@ static int sd_zbc_check_capacity(struct scsi_disk *sdkp, unsigned char *buf) */ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) { - u64 zone_blocks; + u64 zone_blocks = 0; sector_t block = 0; unsigned char *buf; unsigned char *rec; @@ -504,10 +504,8 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) /* Do a report zone to get the same field */ ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0); - if (ret) { - zone_blocks = 0; - goto out; - } + if (ret) + goto out_free; same = buf[4] & 0x0f; if (same > 0) { @@ -547,7 +545,7 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, block); if (ret) - return ret; + goto out_free; } } while (block < sdkp->capacity); @@ -555,35 +553,32 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp) zone_blocks = sdkp->zone_blocks; out: - kfree(buf); - if (!zone_blocks) { if (sdkp->first_scan) sd_printk(KERN_NOTICE, sdkp, "Devices with non constant zone " "size are not supported\n"); - return -ENODEV; - } - - if (!is_power_of_2(zone_blocks)) { + ret = -ENODEV; + } else if (!is_power_of_2(zone_blocks)) { if (sdkp->first_scan) sd_printk(KERN_NOTICE, sdkp, "Devices with non power of 2 zone " "size are not supported\n"); - return -ENODEV; - } - - if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) { + ret = -ENODEV; + } else if (logical_to_sectors(sdkp->device, zone_blocks) > UINT_MAX) { if (sdkp->first_scan) sd_printk(KERN_NOTICE, sdkp, "Zone size too large\n"); - return -ENODEV; + ret = -ENODEV; + } else { + sdkp->zone_blocks = zone_blocks; + sdkp->zone_shift = ilog2(zone_blocks); } - sdkp->zone_blocks = zone_blocks; - sdkp->zone_shift = ilog2(zone_blocks); +out_free: + kfree(buf); - return 0; + return ret; } static int sd_zbc_setup(struct scsi_disk *sdkp) From 6a2cf8d3663e13e19af636c2a8d92e766261dc45 Mon Sep 17 00:00:00 2001 From: Bill Kuzeja Date: Mon, 5 Mar 2018 00:02:55 -0500 Subject: [PATCH 482/942] scsi: qla2xxx: Fix crashes in qla2x00_probe_one on probe failure Because of the shifting around of code in qla2x00_probe_one recently, failures during adapter initialization can lead to problems, i.e. NULL pointer crashes and doubly freed data structures which cause eventual panics. This V2 version makes the relevant memory free routines idempotent, so repeat calls won't cause any harm. I also removed the problematic probe_init_failed exit point as it is not needed. Fixes: d64d6c5671db ("scsi: qla2xxx: Fix NULL pointer crash due to probe failure") Signed-off-by: Bill Kuzeja Acked-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen --- drivers/scsi/qla2xxx/qla_os.c | 59 ++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 285911e81728..5c5dcca4d1da 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -454,7 +454,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, ha->req_q_map[0] = req; set_bit(0, ha->rsp_qid_map); set_bit(0, ha->req_qid_map); - return 1; + return 0; fail_qpair_map: kfree(ha->base_qpair); @@ -471,6 +471,9 @@ fail_req_map: static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req) { + if (!ha->req_q_map) + return; + if (IS_QLAFX00(ha)) { if (req && req->ring_fx00) dma_free_coherent(&ha->pdev->dev, @@ -481,14 +484,17 @@ static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req) (req->length + 1) * sizeof(request_t), req->ring, req->dma); - if (req) + if (req) { kfree(req->outstanding_cmds); - - kfree(req); + kfree(req); + } } static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) { + if (!ha->rsp_q_map) + return; + if (IS_QLAFX00(ha)) { if (rsp && rsp->ring) dma_free_coherent(&ha->pdev->dev, @@ -499,7 +505,8 @@ static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) (rsp->length + 1) * sizeof(response_t), rsp->ring, rsp->dma); } - kfree(rsp); + if (rsp) + kfree(rsp); } static void qla2x00_free_queues(struct qla_hw_data *ha) @@ -1723,6 +1730,8 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res) struct qla_tgt_cmd *cmd; uint8_t trace = 0; + if (!ha->req_q_map) + return; spin_lock_irqsave(qp->qp_lock_ptr, flags); req = qp->req; for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { @@ -3095,14 +3104,14 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) /* Set up the irqs */ ret = qla2x00_request_irqs(ha, rsp); if (ret) - goto probe_hw_failed; + goto probe_failed; /* Alloc arrays of request and response ring ptrs */ - if (!qla2x00_alloc_queues(ha, req, rsp)) { + if (qla2x00_alloc_queues(ha, req, rsp)) { ql_log(ql_log_fatal, base_vha, 0x003d, "Failed to allocate memory for queue pointers..." "aborting.\n"); - goto probe_init_failed; + goto probe_failed; } if (ha->mqenable && shost_use_blk_mq(host)) { @@ -3387,15 +3396,6 @@ skip_dpc: return 0; -probe_init_failed: - qla2x00_free_req_que(ha, req); - ha->req_q_map[0] = NULL; - clear_bit(0, ha->req_qid_map); - qla2x00_free_rsp_que(ha, rsp); - ha->rsp_q_map[0] = NULL; - clear_bit(0, ha->rsp_qid_map); - ha->max_req_queues = ha->max_rsp_queues = 0; - probe_failed: if (base_vha->timer_active) qla2x00_stop_timer(base_vha); @@ -4508,11 +4508,17 @@ qla2x00_mem_free(struct qla_hw_data *ha) if (ha->init_cb) dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, ha->init_cb_dma); - vfree(ha->optrom_buffer); - kfree(ha->nvram); - kfree(ha->npiv_info); - kfree(ha->swl); - kfree(ha->loop_id_map); + + if (ha->optrom_buffer) + vfree(ha->optrom_buffer); + if (ha->nvram) + kfree(ha->nvram); + if (ha->npiv_info) + kfree(ha->npiv_info); + if (ha->swl) + kfree(ha->swl); + if (ha->loop_id_map) + kfree(ha->loop_id_map); ha->srb_mempool = NULL; ha->ctx_mempool = NULL; @@ -4528,6 +4534,15 @@ qla2x00_mem_free(struct qla_hw_data *ha) ha->ex_init_cb_dma = 0; ha->async_pd = NULL; ha->async_pd_dma = 0; + ha->loop_id_map = NULL; + ha->npiv_info = NULL; + ha->optrom_buffer = NULL; + ha->swl = NULL; + ha->nvram = NULL; + ha->mctp_dump = NULL; + ha->dcbx_tlv = NULL; + ha->xgmac_data = NULL; + ha->sfp_data = NULL; ha->s_dma_pool = NULL; ha->dl_dma_pool = NULL; From 20bd1d026aacc5399464f8328f305985c493cde3 Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Tue, 6 Mar 2018 21:47:32 +0000 Subject: [PATCH 483/942] scsi: sd: Keep disk read-only when re-reading partition If the read-only flag is true on a SCSI disk, re-reading the partition table sets the flag back to false. To observe this bug, you can run: 1. blockdev --setro /dev/sda 2. blockdev --rereadpt /dev/sda 3. blockdev --getro /dev/sda This commit reads the disk's old state and combines it with the device disk-reported state rather than unconditionally marking it as RW. Reported-by: Li Ning Signed-off-by: Jeremy Cline Signed-off-by: Martin K. Petersen --- drivers/scsi/sd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ab75ebd518a7..3b45f7fc5620 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2624,6 +2624,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) int res; struct scsi_device *sdp = sdkp->device; struct scsi_mode_data data; + int disk_ro = get_disk_ro(sdkp->disk); int old_wp = sdkp->write_prot; set_disk_ro(sdkp->disk, 0); @@ -2664,7 +2665,7 @@ sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer) "Test WP failed, assume Write Enabled\n"); } else { sdkp->write_prot = ((data.device_specific & 0x80) != 0); - set_disk_ro(sdkp->disk, sdkp->write_prot); + set_disk_ro(sdkp->disk, sdkp->write_prot || disk_ro); if (sdkp->first_scan || old_wp != sdkp->write_prot) { sd_printk(KERN_NOTICE, sdkp, "Write Protect is %s\n", sdkp->write_prot ? "on" : "off"); From 87cdf3148b11d46382dbce2754ae7036aba96380 Mon Sep 17 00:00:00 2001 From: Yossi Kuperman Date: Sun, 4 Mar 2018 21:03:52 +0200 Subject: [PATCH 484/942] xfrm: Verify MAC header exists before overwriting eth_hdr(skb)->h_proto Artem Savkov reported that commit 5efec5c655dd leads to a packet loss under IPSec configuration. It appears that his setup consists of a TUN device, which does not have a MAC header. Make sure MAC header exists. Note: TUN device sets a MAC header pointer, although it does not have one. Fixes: 5efec5c655dd ("xfrm: Fix eth_hdr(skb)->h_proto to reflect inner IP version") Reported-by: Artem Savkov Tested-by: Artem Savkov Signed-off-by: Yossi Kuperman Signed-off-by: Steffen Klassert --- net/ipv4/xfrm4_mode_tunnel.c | 3 ++- net/ipv6/xfrm6_mode_tunnel.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/ipv4/xfrm4_mode_tunnel.c b/net/ipv4/xfrm4_mode_tunnel.c index 63faeee989a9..2a9764bd1719 100644 --- a/net/ipv4/xfrm4_mode_tunnel.c +++ b/net/ipv4/xfrm4_mode_tunnel.c @@ -92,7 +92,8 @@ static int xfrm4_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) skb_reset_network_header(skb); skb_mac_header_rebuild(skb); - eth_hdr(skb)->h_proto = skb->protocol; + if (skb->mac_len) + eth_hdr(skb)->h_proto = skb->protocol; err = 0; diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c index bb935a3b7fea..de1b0b8c53b0 100644 --- a/net/ipv6/xfrm6_mode_tunnel.c +++ b/net/ipv6/xfrm6_mode_tunnel.c @@ -92,7 +92,8 @@ static int xfrm6_mode_tunnel_input(struct xfrm_state *x, struct sk_buff *skb) skb_reset_network_header(skb); skb_mac_header_rebuild(skb); - eth_hdr(skb)->h_proto = skb->protocol; + if (skb->mac_len) + eth_hdr(skb)->h_proto = skb->protocol; err = 0; From 1cf5b50426136fe54380a7dd1ca7eb49973cae5a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:49 +0100 Subject: [PATCH 485/942] ASoC: rt5651: Make rt5651_apply_properties() private The idea behind exporting rt5651_apply_properties(), was for it to be used on platforms where the platform code may need to add device-properties, rather then relying only on properties set by the firmware. The platform code could then call rt5651_apply_properties() after adding properties to make sure that the codec driver was aware of the new properties. But this is not necessary, as long as we do all property parsing from the codec component-driver's probe function (or later) then the machine driver can attach properties before calling snd_soc_register_card and calling rt5651_apply_properties() for ordering reasons is not necessary. This commit makes rt5651_apply_properties() private and adds 2 comments documenting that all property parsing must be done from the codec component-driver's probe function. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 14 ++++++++++++-- sound/soc/codecs/rt5651.h | 2 -- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 55bcc74e344f..767a05e009df 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1666,7 +1666,14 @@ static int rt5651_set_jack(struct snd_soc_component *component, return 0; } -void rt5651_apply_properties(struct snd_soc_component *component) +/* + * Note on some platforms the platform code may need to add device-properties, + * rather then relying only on properties set by the firmware. Therefor the + * property parsing MUST be done from the component driver's probe function, + * rather then from the i2c driver's probe function, so that the platform-code + * can attach extra properties before calling snd_soc_register_card(). + */ +static void rt5651_apply_properties(struct snd_soc_component *component) { if (device_property_read_bool(component->dev, "realtek,in2-differential")) snd_soc_component_update_bits(component, RT5651_IN1_IN2, @@ -1676,7 +1683,6 @@ void rt5651_apply_properties(struct snd_soc_component *component) snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); } -EXPORT_SYMBOL_GPL(rt5651_apply_properties); static int rt5651_probe(struct snd_soc_component *component) { @@ -1893,6 +1899,10 @@ static void rt5651_jack_detect_work(struct work_struct *work) snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } +/* + * Note this function MUST not look at device-properties, see the comment + * above rt5651_apply_properties(). + */ static int rt5651_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 7d9d5fa09d6f..f3158488fc89 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2080,6 +2080,4 @@ struct rt5651_priv { bool hp_mute; }; -void rt5651_apply_properties(struct snd_soc_component *component); - #endif /* __RT5651_H__ */ From 9db7d4b32cbccb5807e2e1f22e2fafc80034ee6d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:50 +0100 Subject: [PATCH 486/942] ASoC: rt5651: Add devicetree-bindings for jack-detect Add new properties to the rt5651 dt-bindings for configuring the jack-detect source and over-current detect settings. Cc: devicetree@vger.kernel.org Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/rt5651.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rt5651.txt b/Documentation/devicetree/bindings/sound/rt5651.txt index 3875233095f5..7890aa9477f8 100644 --- a/Documentation/devicetree/bindings/sound/rt5651.txt +++ b/Documentation/devicetree/bindings/sound/rt5651.txt @@ -16,6 +16,23 @@ Optional properties: - realtek,dmic-en Boolean. true if dmic is used. +- realtek,jack-detect-source + u32. Valid values: + 1: Use JD1_1 pin for jack-dectect + 2: Use JD1_2 pin for jack-dectect + 3: Use JD2 pin for jack-dectect + +- realtek,over-current-threshold-microamp + u32, micbias over-current detection threshold in µA, valid values are + 600, 1500 and 2000µA. + +- realtek,over-current-scale-factor + u32, micbias over-current detection scale-factor, valid values are: + 0: Scale current by 0.5 + 1: Scale current by 0.75 + 2: Scale current by 1.0 + 3: Scale current by 1.5 + Pins on the device (for linking into audio routes) for RT5651: * DMIC L1 From f0c2a330d99ef81519dc809d8b6a7dafe39b0933 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:51 +0100 Subject: [PATCH 487/942] ASoC: rt5651: Configure jack-detect source through a device-property Configure the jack-detect source through a device-property which can be set by code outside of the codec driver. Rather then putting platform specific DMI quirks inside the generic codec driver. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/sound/rt5651.h | 4 ++++ sound/soc/codecs/rt5651.c | 33 +++++++-------------------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 1612462bf5ad..725b36c329d0 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -11,6 +11,10 @@ #ifndef __LINUX_SND_RT5651_H #define __LINUX_SND_RT5651_H +/* + * Note these MUST match the values from the DT binding: + * Documentation/devicetree/bindings/sound/rt5651.txt + */ enum rt5651_jd_src { RT5651_JD_NULL, RT5651_JD1_1, diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 767a05e009df..50e1c501b6b9 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -32,8 +31,6 @@ #include "rl6231.h" #include "rt5651.h" -#define RT5651_JD_MAP(quirk) ((quirk) & GENMASK(7, 0)) - #define RT5651_DEVICE_ID_VALUE 0x6281 #define RT5651_PR_RANGE_BASE (0xff + 1) @@ -41,8 +38,6 @@ #define RT5651_PR_BASE (RT5651_PR_RANGE_BASE + (0 * RT5651_PR_SPACING)) -static unsigned long rt5651_quirk; - static const struct regmap_range_cfg rt5651_ranges[] = { { .name = "PR", .range_min = RT5651_PR_BASE, .range_max = RT5651_PR_BASE + 0xb4, @@ -1675,6 +1670,9 @@ static int rt5651_set_jack(struct snd_soc_component *component, */ static void rt5651_apply_properties(struct snd_soc_component *component) { + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + u32 val; + if (device_property_read_bool(component->dev, "realtek,in2-differential")) snd_soc_component_update_bits(component, RT5651_IN1_IN2, RT5651_IN_DF2, RT5651_IN_DF2); @@ -1682,6 +1680,10 @@ static void rt5651_apply_properties(struct snd_soc_component *component) if (device_property_read_bool(component->dev, "realtek,dmic-en")) snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, RT5651_GP2_PIN_MASK, RT5651_GP2_PIN_DMIC1_SCL); + + if (device_property_read_u32(component->dev, + "realtek,jack-detect-source", &val) == 0) + rt5651->jd_src = val; } static int rt5651_probe(struct snd_soc_component *component) @@ -1831,24 +1833,6 @@ static const struct i2c_device_id rt5651_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); -static int rt5651_quirk_cb(const struct dmi_system_id *id) -{ - rt5651_quirk = (unsigned long) id->driver_data; - return 1; -} - -static const struct dmi_system_id rt5651_quirk_table[] = { - { - .callback = rt5651_quirk_cb, - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "KIANO"), - DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), - }, - .driver_data = (unsigned long *) RT5651_JD1_1, - }, - {} -}; - static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) { int jack_type; @@ -1916,9 +1900,6 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, i2c_set_clientdata(i2c, rt5651); - dmi_check_system(rt5651_quirk_table); - rt5651->jd_src = RT5651_JD_MAP(rt5651_quirk); - rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); if (IS_ERR(rt5651->regmap)) { ret = PTR_ERR(rt5651->regmap); From 583a9debd71e21a317b1fc7b293c22c49b33d9e4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:52 +0100 Subject: [PATCH 488/942] ASoC: rt5651: Allow specifying over-current threshold through a device-property OVer-Current-Detection (OVCD) for the micbias current is used to detect if an inserted jack is a headset or headphones (mic shorted to ground). Some boards may need different values for the OVCD current threshold because of a resistor on the board in serial with or parallel to the jack mic contact. This commit adds support for configuring the OCVD current threshold through the "realtek,over-current-threshold-microamp" device-property. Note this commit changes the default value from 600uA to 2000uA, because testing has shown 600uA to be a poor default. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 22 +++++++++++++++++++++- sound/soc/codecs/rt5651.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 50e1c501b6b9..7ff1bc892cfd 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1638,7 +1638,7 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_PWR_CLK12M_MASK | RT5651_PWR_MB_MASK, RT5651_MIC1_OVCD_EN | - RT5651_MIC1_OVTH_600UA | + rt5651->ovcd_th | RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); @@ -1684,6 +1684,26 @@ static void rt5651_apply_properties(struct snd_soc_component *component) if (device_property_read_u32(component->dev, "realtek,jack-detect-source", &val) == 0) rt5651->jd_src = val; + + rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + + if (device_property_read_u32(component->dev, + "realtek,over-current-threshold-microamp", &val) == 0) { + switch (val) { + case 600: + rt5651->ovcd_th = RT5651_MIC1_OVTH_600UA; + break; + case 1500: + rt5651->ovcd_th = RT5651_MIC1_OVTH_1500UA; + break; + case 2000: + rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + break; + default: + dev_warn(component->dev, "Warning: Invalid over-current-threshold-microamp value: %d, defaulting to 2000uA\n", + val); + } + } } static int rt5651_probe(struct snd_soc_component *component) diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index f3158488fc89..9cd5c279d0d6 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2064,6 +2064,7 @@ struct rt5651_priv { struct snd_soc_jack *hp_jack; struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src; + unsigned int ovcd_th; int irq; int sysclk; From e6eb0207597afa1cdd4914a17a727b101cc859ff Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:53 +0100 Subject: [PATCH 489/942] ASoC: rt5651: Allow specifying the OVCD scale-factor through a device-property OVer-Current-Detection (OVCD) for the micbias current is used to detect if an inserted jack is a headset or headphones (mic shorted to ground). The threshold for at which current the OVCD triggers on the rt5651 is not only controlled by setting the absolute current limit, but also by setting a scale factor which applies to the limit. Testing has shown that we need to set both (depending on the board). This commit adds support for the sofar unused OVCD scale-factor register and adds support for specifying non-default values for it through the "realtek,over-current-scale-factor" device-property. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/sound/rt5651.h | 11 +++++++++++ sound/soc/codecs/rt5651.c | 19 +++++++++++++++++++ sound/soc/codecs/rt5651.h | 11 +++++++++++ 3 files changed, 41 insertions(+) diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h index 725b36c329d0..6403b862fb9a 100644 --- a/include/sound/rt5651.h +++ b/include/sound/rt5651.h @@ -22,4 +22,15 @@ enum rt5651_jd_src { RT5651_JD2, }; +/* + * Note these MUST match the values from the DT binding: + * Documentation/devicetree/bindings/sound/rt5651.txt + */ +enum rt5651_ovcd_sf { + RT5651_OVCD_SF_0P5, + RT5651_OVCD_SF_0P75, + RT5651_OVCD_SF_1P0, + RT5651_OVCD_SF_1P5, +}; + #endif diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 7ff1bc892cfd..486817809b7b 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1632,6 +1632,10 @@ static int rt5651_set_jack(struct snd_soc_component *component, snd_soc_component_update_bits(component, RT5651_PWR_ANLG2, RT5651_PWR_JD_M, RT5651_PWR_JD_M); + /* Set OVCD threshold current and scale-factor */ + snd_soc_component_write(component, RT5651_PR_BASE + RT5651_BIAS_CUR4, + 0xa800 | rt5651->ovcd_sf); + snd_soc_component_update_bits(component, RT5651_MICBIAS, RT5651_MIC1_OVCD_MASK | RT5651_MIC1_OVTH_MASK | @@ -1685,7 +1689,13 @@ static void rt5651_apply_properties(struct snd_soc_component *component) "realtek,jack-detect-source", &val) == 0) rt5651->jd_src = val; + /* + * Testing on various boards has shown that good defaults for the OVCD + * threshold and scale-factor are 2000µA and 0.75. For an effective + * limit of 1500µA, this seems to be more reliable then 1500µA and 1.0. + */ rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; + rt5651->ovcd_sf = RT5651_MIC_OVCD_SF_0P75; if (device_property_read_u32(component->dev, "realtek,over-current-threshold-microamp", &val) == 0) { @@ -1704,6 +1714,15 @@ static void rt5651_apply_properties(struct snd_soc_component *component) val); } } + + if (device_property_read_u32(component->dev, + "realtek,over-current-scale-factor", &val) == 0) { + if (val <= RT5651_OVCD_SF_1P5) + rt5651->ovcd_sf = val << RT5651_MIC_OVCD_SF_SFT; + else + dev_warn(component->dev, "Warning: Invalid over-current-scale-factor value: %d, defaulting to 0.75\n", + val); + } } static int rt5651_probe(struct snd_soc_component *component) diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 9cd5c279d0d6..71738ab93fb9 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -138,6 +138,7 @@ /* Index of Codec Private Register definition */ #define RT5651_BIAS_CUR1 0x12 #define RT5651_BIAS_CUR3 0x14 +#define RT5651_BIAS_CUR4 0x15 #define RT5651_CLSD_INT_REG1 0x1c #define RT5651_CHPUMP_INT_REG1 0x24 #define RT5651_MAMP_INT_REG2 0x37 @@ -1966,6 +1967,15 @@ #define RT5651_D_GATE_EN_SFT 0 /* Codec Private Register definition */ + +/* MIC Over current threshold scale factor (0x15) */ +#define RT5651_MIC_OVCD_SF_MASK (0x3 << 8) +#define RT5651_MIC_OVCD_SF_SFT 8 +#define RT5651_MIC_OVCD_SF_0P5 (0x0 << 8) +#define RT5651_MIC_OVCD_SF_0P75 (0x1 << 8) +#define RT5651_MIC_OVCD_SF_1P0 (0x2 << 8) +#define RT5651_MIC_OVCD_SF_1P5 (0x3 << 8) + /* 3D Speaker Control (0x63) */ #define RT5651_3D_SPK_MASK (0x1 << 15) #define RT5651_3D_SPK_SFT 15 @@ -2065,6 +2075,7 @@ struct rt5651_priv { struct delayed_work jack_detect_work; enum rt5651_jd_src jd_src; unsigned int ovcd_th; + unsigned int ovcd_sf; int irq; int sysclk; From 1b1ad83539a701a6bdcb25dc9160386e71f6016e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:54 +0100 Subject: [PATCH 490/942] ASoC: rt5651: Enable sticky mode for OVCD When the mic-gnd contacts are short-circuited by a headphones plug, the hardware periodically retries if it can apply the bias-current leading to the OVCD status flip-flopping 1-0-1 with it being 0 about 10% of the time. This commit enables the sticky bit for the OVCD status to deal with this. This commit also introduces 2 helper functions to deal with the OVCD status bit, this may seem a bit overkill now, but these will also be used in future patches. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 486817809b7b..62918f7e8270 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1578,6 +1578,22 @@ static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component snd_soc_dapm_mutex_unlock(dapm); } +static void rt5651_clear_micbias1_ovcd(struct snd_soc_component *component) +{ + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, + RT5651_MB1_OC_CLR, 0); +} + +static bool rt5651_micbias1_ovcd(struct snd_soc_component *component) +{ + int val; + + val = snd_soc_component_read32(component, RT5651_IRQ_CTRL2); + dev_dbg(component->dev, "irq ctrl2 %#04x\n", val); + + return (val & RT5651_MB1_OC_CLR); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1646,6 +1662,18 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_PWR_MB_PU | RT5651_PWR_CLK12M_PU); + /* + * The over-current-detect is only reliable in detecting the absence + * of over-current, when the mic-contact in the jack is short-circuited, + * the hardware periodically retries if it can apply the bias-current + * leading to the ovcd status flip-flopping 1-0-1 with it being 0 about + * 10% of the time, as we poll the ovcd status bit we might hit that + * 10%, so we enable sticky mode and when checking OVCD we clear the + * status, msleep() a bit and then check to get a reliable reading. + */ + snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, + RT5651_MB1_OC_STKY_MASK, RT5651_MB1_OC_STKY_EN); + rt5651->hp_jack = hp_jack; ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, @@ -1878,13 +1906,12 @@ static int rt5651_jack_detect(struct snd_soc_component *component, int jack_inse if (jack_insert) { rt5651_enable_micbias1_for_ovcd(component); + rt5651_clear_micbias1_ovcd(component); msleep(100); - if (snd_soc_component_read32(component, RT5651_IRQ_CTRL2) & RT5651_MB1_OC_CLR) + if (rt5651_micbias1_ovcd(component)) jack_type = SND_JACK_HEADPHONE; else jack_type = SND_JACK_HEADSET; - snd_soc_component_update_bits(component, RT5651_IRQ_CTRL2, - RT5651_MB1_OC_CLR, 0); rt5651_disable_micbias1_for_ovcd(component); } else { /* jack out */ jack_type = 0; From 4b4a373c0212e084045530e47071374a87a3761e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:55 +0100 Subject: [PATCH 491/942] ASoC: rt5651: Enable Platform Clock during jack-type detect When using RCCLK instead of MCLK / PLL1 the OVCD status often gets stuck at its last value, which breaks jack-type detection. This commit fixes this by force-enabling the platform clock when doing jack-type detection. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 62918f7e8270..873af6798d7a 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1563,6 +1563,8 @@ static void rt5651_enable_micbias1_for_ovcd(struct snd_soc_component *component) snd_soc_dapm_mutex_lock(dapm); snd_soc_dapm_force_enable_pin_unlocked(dapm, "LDO"); snd_soc_dapm_force_enable_pin_unlocked(dapm, "micbias1"); + /* OVCD is unreliable when used with RCCLK as sysclk-source */ + snd_soc_dapm_force_enable_pin_unlocked(dapm, "Platform Clock"); snd_soc_dapm_sync_unlocked(dapm); snd_soc_dapm_mutex_unlock(dapm); } @@ -1572,6 +1574,7 @@ static void rt5651_disable_micbias1_for_ovcd(struct snd_soc_component *component struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); snd_soc_dapm_mutex_lock(dapm); + snd_soc_dapm_disable_pin_unlocked(dapm, "Platform Clock"); snd_soc_dapm_disable_pin_unlocked(dapm, "micbias1"); snd_soc_dapm_disable_pin_unlocked(dapm, "LDO"); snd_soc_dapm_sync_unlocked(dapm); From 0fe9474598890b4bd8a7228c9b1872ed7fe3c2c5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:56 +0100 Subject: [PATCH 492/942] ASoC: rt5651: Add rt5651_jack_inserted() helper Add rt5651_jack_inserted() helper to get the jack-detect switch status, This is a preparation patch for rewriting the jack type-detection to make it more reliable. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 45 ++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 873af6798d7a..41fc574dbc3d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1597,6 +1597,31 @@ static bool rt5651_micbias1_ovcd(struct snd_soc_component *component) return (val & RT5651_MB1_OC_CLR); } +static bool rt5651_jack_inserted(struct snd_soc_component *component) +{ + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + int val; + + val = snd_soc_component_read32(component, RT5651_INT_IRQ_ST); + dev_dbg(component->dev, "irq status %#04x\n", val); + + switch (rt5651->jd_src) { + case RT5651_JD1_1: + val &= 0x1000; + break; + case RT5651_JD1_2: + val &= 0x2000; + break; + case RT5651_JD2: + val &= 0x4000; + break; + default: + break; + } + + return val == 0; +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; @@ -1927,27 +1952,13 @@ static void rt5651_jack_detect_work(struct work_struct *work) { struct rt5651_priv *rt5651 = container_of(work, struct rt5651_priv, jack_detect_work.work); - - int report, val = 0; + int report, jack_inserted; if (!rt5651->component) return; - switch (rt5651->jd_src) { - case RT5651_JD1_1: - val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x1000; - break; - case RT5651_JD1_2: - val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x2000; - break; - case RT5651_JD2: - val = snd_soc_component_read32(rt5651->component, RT5651_INT_IRQ_ST) & 0x4000; - break; - default: - break; - } - - report = rt5651_jack_detect(rt5651->component, !val); + jack_inserted = rt5651_jack_inserted(rt5651->component); + report = rt5651_jack_detect(rt5651->component, jack_inserted); snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); } From ee68096826fa16bca2f7bb555b3e0cbbe798d330 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:57 +0100 Subject: [PATCH 493/942] ASoC: rt5651: Rewrite jack-type detection We get the insertion event before the jack is fully inserted at which point the second ring on a TRRS connector may short the 2nd ring and sleeve contacts. Testing has shown that this short-circuit may happen as late as 500ms after the insertion event, but it never lasts longer then 300ms. This commit changes the detection algorithm to require 5 identical OVCD values in a row at 100 ms intervals to fix the jack-type sometimes getting mis-detected. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 110 ++++++++++++++++++++++++-------------- sound/soc/codecs/rt5651.h | 2 +- 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 41fc574dbc3d..3b9f5384fe7d 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1622,12 +1622,76 @@ static bool rt5651_jack_inserted(struct snd_soc_component *component) return val == 0; } +/* Jack detect timings */ +#define JACK_SETTLE_TIME 100 /* milli seconds */ +#define JACK_DETECT_COUNT 5 +#define JACK_DETECT_MAXCOUNT 20 /* Aprox. 2 seconds worth of tries */ + +static int rt5651_detect_headset(struct snd_soc_component *component) +{ + int i, headset_count = 0, headphone_count = 0; + + /* + * We get the insertion event before the jack is fully inserted at which + * point the second ring on a TRRS connector may short the 2nd ring and + * sleeve contacts, also the overcurrent detection is not entirely + * reliable. So we try several times with a wait in between until we + * detect the same type JACK_DETECT_COUNT times in a row. + */ + for (i = 0; i < JACK_DETECT_MAXCOUNT; i++) { + /* Clear any previous over-current status flag */ + rt5651_clear_micbias1_ovcd(component); + + msleep(JACK_SETTLE_TIME); + + /* Check the jack is still connected before checking ovcd */ + if (!rt5651_jack_inserted(component)) + return 0; + + if (rt5651_micbias1_ovcd(component)) { + /* + * Over current detected, there is a short between the + * 2nd ring contact and the ground, so a TRS connector + * without a mic contact and thus plain headphones. + */ + dev_dbg(component->dev, "mic-gnd shorted\n"); + headset_count = 0; + headphone_count++; + if (headphone_count == JACK_DETECT_COUNT) + return SND_JACK_HEADPHONE; + } else { + dev_dbg(component->dev, "mic-gnd open\n"); + headphone_count = 0; + headset_count++; + if (headset_count == JACK_DETECT_COUNT) + return SND_JACK_HEADSET; + } + } + + dev_err(component->dev, "Error detecting headset vs headphones, bad contact?, assuming headphones\n"); + return SND_JACK_HEADPHONE; +} + +static void rt5651_jack_detect_work(struct work_struct *work) +{ + struct rt5651_priv *rt5651 = + container_of(work, struct rt5651_priv, jack_detect_work); + int report = 0; + + if (rt5651_jack_inserted(rt5651->component)) { + rt5651_enable_micbias1_for_ovcd(rt5651->component); + report = rt5651_detect_headset(rt5651->component); + rt5651_disable_micbias1_for_ovcd(rt5651->component); + } + + snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); +} + static irqreturn_t rt5651_irq(int irq, void *data) { struct rt5651_priv *rt5651 = data; - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, msecs_to_jiffies(250)); + queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); return IRQ_HANDLED; } @@ -1715,8 +1779,7 @@ static int rt5651_set_jack(struct snd_soc_component *component, } /* sync initial jack state */ - queue_delayed_work(system_power_efficient_wq, - &rt5651->jack_detect_work, 0); + queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); return 0; } @@ -1928,41 +1991,6 @@ static const struct i2c_device_id rt5651_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, rt5651_i2c_id); -static int rt5651_jack_detect(struct snd_soc_component *component, int jack_insert) -{ - int jack_type; - - if (jack_insert) { - rt5651_enable_micbias1_for_ovcd(component); - rt5651_clear_micbias1_ovcd(component); - msleep(100); - if (rt5651_micbias1_ovcd(component)) - jack_type = SND_JACK_HEADPHONE; - else - jack_type = SND_JACK_HEADSET; - rt5651_disable_micbias1_for_ovcd(component); - } else { /* jack out */ - jack_type = 0; - } - - return jack_type; -} - -static void rt5651_jack_detect_work(struct work_struct *work) -{ - struct rt5651_priv *rt5651 = - container_of(work, struct rt5651_priv, jack_detect_work.work); - int report, jack_inserted; - - if (!rt5651->component) - return; - - jack_inserted = rt5651_jack_inserted(rt5651->component); - report = rt5651_jack_detect(rt5651->component, jack_inserted); - - snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); -} - /* * Note this function MUST not look at device-properties, see the comment * above rt5651_apply_properties(). @@ -2005,7 +2033,7 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, rt5651->irq = i2c->irq; rt5651->hp_mute = 1; - INIT_DELAYED_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); + INIT_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5651, @@ -2018,7 +2046,7 @@ static int rt5651_i2c_remove(struct i2c_client *i2c) { struct rt5651_priv *rt5651 = i2c_get_clientdata(i2c); - cancel_delayed_work_sync(&rt5651->jack_detect_work); + cancel_work_sync(&rt5651->jack_detect_work); return 0; } diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index 71738ab93fb9..f20c9be94fb2 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -2072,7 +2072,7 @@ struct rt5651_priv { struct snd_soc_component *component; struct regmap *regmap; struct snd_soc_jack *hp_jack; - struct delayed_work jack_detect_work; + struct work_struct jack_detect_work; enum rt5651_jd_src jd_src; unsigned int ovcd_th; unsigned int ovcd_sf; From e39cacc1b7de2a6d72ce49043c9cfd7dd129135a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:58 +0100 Subject: [PATCH 494/942] ASoC: Intel: bytcr_rt5651: Not being able to find the codec ACPI-dev is an error If we cannot find the codec ACPI-dev, then the snd-soc-core will not be able to find the codec either and snd_soc_register_card() will just keep exiting with -EPROBE_DEFER, filling the log with errors each time the probe gets retried. Instead simply log an error from the machine driver and exit with -ENODEV. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 456526a93dd5..105339c5b693 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -540,12 +540,13 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* fixup codec name based on HID */ i2c_name = acpi_dev_get_first_match_name(mach->id, NULL, -1); - if (i2c_name) { - snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), - "%s%s", "i2c-", i2c_name); - - byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; + if (!i2c_name) { + dev_err(&pdev->dev, "Error cannot find '%s' dev\n", mach->id); + return -ENODEV; } + snprintf(byt_rt5651_codec_name, sizeof(byt_rt5651_codec_name), + "%s%s", "i2c-", i2c_name); + byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); From 09f7fcfa727966361d576fcfdb9c5ad77ddf5092 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 7 Mar 2018 00:24:13 -0300 Subject: [PATCH 495/942] ASoC: wm8524: Remove unit address WM8524 does not use I2C nor SPI, hence no 'reg' property is used, so remove the unit address from the bindings example to conform. This avoids users getting dtc warnings when they copy the binding example to a real dts file. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/wm8524.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/wm8524.txt b/Documentation/devicetree/bindings/sound/wm8524.txt index 20c62002cbcd..0f0553563fc1 100644 --- a/Documentation/devicetree/bindings/sound/wm8524.txt +++ b/Documentation/devicetree/bindings/sound/wm8524.txt @@ -10,7 +10,7 @@ Required properties: Example: -codec: wm8524@0 { +codec: wm8524 { compatible = "wlf,wm8524"; wlf,mute-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>; }; From 46058aeb6b10ab6620caa25984a3a4ee37d0fd56 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:35:59 +0100 Subject: [PATCH 496/942] ASoC: Intel: bytcr_rt5651: Pass jack-src info via device-properties This commit add support for a new BYT_RT5651_JDSRC quirk, sets this quirk for the KIANO SlimNote 14.2 laptop and uses the new "realtek, jack-detect-source" property to pass this info to the codec driver. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 54 +++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 4 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 6288c27d87ce..499e405e591b 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -18,8 +18,10 @@ */ #include +#include #include #include +#include #include #include #include @@ -42,10 +44,21 @@ enum { BYT_RT5651_IN3_MAP, }; -#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(7, 0)) -#define BYT_RT5651_DMIC_EN BIT(16) -#define BYT_RT5651_MCLK_EN BIT(17) -#define BYT_RT5651_MCLK_25MHZ BIT(18) +enum { + BYT_RT5651_JD_NULL = (RT5651_JD_NULL << 4), + BYT_RT5651_JD1_1 = (RT5651_JD1_1 << 4), + BYT_RT5651_JD1_2 = (RT5651_JD1_2 << 4), + BYT_RT5651_JD2 = (RT5651_JD2 << 4), +}; + +#define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(3, 0)) +#define BYT_RT5651_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) +#define BYT_RT5651_DMIC_EN BIT(16) +#define BYT_RT5651_MCLK_EN BIT(17) +#define BYT_RT5651_MCLK_25MHZ BIT(18) + +/* jack-detect-source + terminating empty entry */ +#define MAX_NO_PROPS 2 struct byt_rt5651_private { struct clk *mclk; @@ -66,6 +79,9 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) dev_info(dev, "quirk IN3_MAP enabled"); + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) + dev_info(dev, "quirk realtek,jack-detect-source %ld\n", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) dev_info(dev, "quirk DMIC enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) @@ -288,11 +304,35 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "KIANO SlimNote 14.2"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | BYT_RT5651_IN1_IN2_MAP), }, {} }; +/* + * Note this MUST be called before snd_soc_register_card(), so that the props + * are in place before the codec component driver's probe function parses them. + */ +static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) +{ + struct property_entry props[MAX_NO_PROPS] = {}; + struct device *i2c_dev; + int ret, cnt = 0; + + i2c_dev = bus_find_device_by_name(&i2c_bus_type, NULL, i2c_dev_name); + if (!i2c_dev) + return -EPROBE_DEFER; + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", + BYT_RT5651_JDSRC(byt_rt5651_quirk)); + + ret = device_add_properties(i2c_dev, props); + put_device(i2c_dev); + + return ret; +} + static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; @@ -550,6 +590,12 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); + + /* Must be called before register_card, also see declaration comment. */ + ret_val = byt_rt5651_add_codec_device_props(byt_rt5651_codec_name); + if (ret_val) + return ret_val; + log_quirks(&pdev->dev); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) { From c2f26938d2a456dcf429385617e58cfd510a64a8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:00 +0100 Subject: [PATCH 497/942] ASoC: Intel: bytcr_rt5651: Actually honor the DMIC_EN quirk if specified Before this commit it was possible to set the DMIC_EN quirk in the machine driver, but it would never be passed to the codec driver so it was a nop. This commit adds code to actually pass the quirk to the codec driver. Since the DMIC_EN quirk was ignored before, this commit removes it from the default quirk settings, to avoid this causing an unexpected functional change. If we really want the DMIC_EN behavior anywhere it should be specifically enabled by follow up commits. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 499e405e591b..a874bba3aec0 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -57,8 +57,8 @@ enum { #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18) -/* jack-detect-source + terminating empty entry */ -#define MAX_NO_PROPS 2 +/* jack-detect-source + dmic-en + terminating empty entry */ +#define MAX_NO_PROPS 3 struct byt_rt5651_private { struct clk *mclk; @@ -66,7 +66,6 @@ struct byt_rt5651_private { }; static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP | - BYT_RT5651_DMIC_EN | BYT_RT5651_MCLK_EN; static void log_quirks(struct device *dev) @@ -327,6 +326,9 @@ static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", BYT_RT5651_JDSRC(byt_rt5651_quirk)); + if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) + props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,dmic-en"); + ret = device_add_properties(i2c_dev, props); put_device(i2c_dev); From aed859a2c7ac8c44ba9b3a6f82b5f08da8a0a975 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:01 +0100 Subject: [PATCH 498/942] ASoC: Intel: bytcr_rt5651: Only create jack if we have a jack-detect source Only create the jack if we have a valid jack-detect source and properly check the snd_soc_component_set_jack() return value. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index a874bba3aec0..56f1f076d92c 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -404,17 +404,21 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) dev_err(card->dev, "unable to set MCLK rate\n"); } - ret = snd_soc_card_jack_new(runtime->card, "Headset", + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { + ret = snd_soc_card_jack_new(runtime->card, "Headset", SND_JACK_HEADSET, &priv->jack, bytcr_jack_pins, ARRAY_SIZE(bytcr_jack_pins)); - if (ret) { - dev_err(runtime->dev, "Headset jack creation failed %d\n", ret); - return ret; + if (ret) { + dev_err(runtime->dev, "jack creation failed %d\n", ret); + return ret; + } + + ret = snd_soc_component_set_jack(codec, &priv->jack, NULL); + if (ret) + return ret; } - snd_soc_component_set_jack(codec, &priv->jack, NULL); - - return ret; + return 0; } static const struct snd_soc_pcm_stream byt_rt5651_dai_params = { From 8ffaa6a136e6f30e053e78fb9742c7748bef8576 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:02 +0100 Subject: [PATCH 499/942] ASoC: Intel: bytcr_rt5651: Add quirk micbias OVCD configuration Add support for setting the micbias OVCD limits device-properties through quirks. And set the limits for this to 2000uA with a scale-factor of 0.75 for the KIANO SlimNote 14.2 device, which is the only device on which jack-detection is currently enabled. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 34 ++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 56f1f076d92c..91b5841af622 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -51,14 +51,29 @@ enum { BYT_RT5651_JD2 = (RT5651_JD2 << 4), }; +enum { + BYT_RT5651_OVCD_TH_600UA = (6 << 8), + BYT_RT5651_OVCD_TH_1500UA = (15 << 8), + BYT_RT5651_OVCD_TH_2000UA = (20 << 8), +}; + +enum { + BYT_RT5651_OVCD_SF_0P5 = (RT5651_OVCD_SF_0P5 << 13), + BYT_RT5651_OVCD_SF_0P75 = (RT5651_OVCD_SF_0P75 << 13), + BYT_RT5651_OVCD_SF_1P0 = (RT5651_OVCD_SF_1P0 << 13), + BYT_RT5651_OVCD_SF_1P5 = (RT5651_OVCD_SF_1P5 << 13), +}; + #define BYT_RT5651_MAP(quirk) ((quirk) & GENMASK(3, 0)) #define BYT_RT5651_JDSRC(quirk) (((quirk) & GENMASK(7, 4)) >> 4) +#define BYT_RT5651_OVCD_TH(quirk) (((quirk) & GENMASK(12, 8)) >> 8) +#define BYT_RT5651_OVCD_SF(quirk) (((quirk) & GENMASK(14, 13)) >> 13) #define BYT_RT5651_DMIC_EN BIT(16) #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18) -/* jack-detect-source + dmic-en + terminating empty entry */ -#define MAX_NO_PROPS 3 +/* jack-detect-source + dmic-en + ovcd-th + -sf + terminating empty entry */ +#define MAX_NO_PROPS 5 struct byt_rt5651_private { struct clk *mclk; @@ -78,9 +93,14 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) dev_info(dev, "quirk IN3_MAP enabled"); - if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) + if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { dev_info(dev, "quirk realtek,jack-detect-source %ld\n", BYT_RT5651_JDSRC(byt_rt5651_quirk)); + dev_info(dev, "quirk realtek,over-current-threshold-microamp %ld\n", + BYT_RT5651_OVCD_TH(byt_rt5651_quirk) * 100); + dev_info(dev, "quirk realtek,over-current-scale-factor %ld\n", + BYT_RT5651_OVCD_SF(byt_rt5651_quirk)); + } if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) dev_info(dev, "quirk DMIC enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) @@ -304,6 +324,8 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | BYT_RT5651_IN1_IN2_MAP), }, {} @@ -326,6 +348,12 @@ static int byt_rt5651_add_codec_device_props(const char *i2c_dev_name) props[cnt++] = PROPERTY_ENTRY_U32("realtek,jack-detect-source", BYT_RT5651_JDSRC(byt_rt5651_quirk)); + props[cnt++] = PROPERTY_ENTRY_U32("realtek,over-current-threshold-microamp", + BYT_RT5651_OVCD_TH(byt_rt5651_quirk) * 100); + + props[cnt++] = PROPERTY_ENTRY_U32("realtek,over-current-scale-factor", + BYT_RT5651_OVCD_SF(byt_rt5651_quirk)); + if (byt_rt5651_quirk & BYT_RT5651_DMIC_EN) props[cnt++] = PROPERTY_ENTRY_BOOL("realtek,dmic-en"); From aeec6cc0821573920d559f7d6297ea5dd3fbbd17 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:03 +0100 Subject: [PATCH 500/942] ASoC: Intel: bytcr_rt5651: Configure PLL1 before using it When platform_clock_control() first selects PLL1 as sysclk the PLL_CTRL registers have not been setup yet and we effectively have an invalid clock configuration until byt_rt5651_aif1_hw_params() gets called. Add a new byt_rt5651_prepare_and_enable_pll1() helper and use that from both platform_clock_control() and byt_rt5651_aif1_hw_params() to fix this. Tested-by: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 73 +++++++++++++-------------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 91b5841af622..af30c730f432 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -111,6 +111,38 @@ static void log_quirks(struct device *dev) #define BYT_CODEC_DAI1 "rt5651-aif1" +static int byt_rt5651_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, + int rate, int bclk_ratio) +{ + int clk_id, clk_freq, ret; + + /* Configure the PLL before selecting it */ + if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) { + clk_id = RT5651_PLL1_S_BCLK1, + clk_freq = rate * bclk_ratio; + } else { + clk_id = RT5651_PLL1_S_MCLK; + if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) + clk_freq = 25000000; + else + clk_freq = 19200000; + } + ret = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, rate * 512); + if (ret < 0) { + dev_err(codec_dai->codec->dev, "can't set pll: %d\n", ret); + return ret; + } + + ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, + rate * 512, SND_SOC_CLOCK_IN); + if (ret < 0) { + dev_err(codec_dai->codec->dev, "can't set clock %d\n", ret); + return ret; + } + + return 0; +} + static int platform_clock_control(struct snd_soc_dapm_widget *w, struct snd_kcontrol *k, int event) { @@ -136,9 +168,7 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, return ret; } } - ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, - 48000 * 512, - SND_SOC_CLOCK_IN); + ret = byt_rt5651_prepare_and_enable_pll1(codec_dai, 48000, 50); } else { /* * Set codec clock source to internal clock before @@ -252,44 +282,11 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; + int rate = params_rate(params); snd_soc_dai_set_bclk_ratio(codec_dai, 50); - ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, - params_rate(params) * 512, - SND_SOC_CLOCK_IN); - if (ret < 0) { - dev_err(rtd->dev, "can't set codec clock %d\n", ret); - return ret; - } - - if (!(byt_rt5651_quirk & BYT_RT5651_MCLK_EN)) { - /* 2x25 bit slots on SSP2 */ - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_BCLK1, - params_rate(params) * 50, - params_rate(params) * 512); - } else { - if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) { - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_MCLK, - 25000000, - params_rate(params) * 512); - } else { - ret = snd_soc_dai_set_pll(codec_dai, 0, - RT5651_PLL1_S_MCLK, - 19200000, - params_rate(params) * 512); - } - } - - if (ret < 0) { - dev_err(rtd->dev, "can't set codec pll: %d\n", ret); - return ret; - } - - return 0; + return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, 50); } static int byt_rt5651_quirk_cb(const struct dmi_system_id *id) From 3fdae070e6fcd9f9ca0745fd69d40085625a45f5 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:04 +0100 Subject: [PATCH 501/942] ASoC: Intel: bytcr_rt5651: Drop snd_soc_dai_set_bclk_ratio() call Drop the snd_soc_dai_set_bclk_ratio() call, the rt5651 dai does not have a set_bclk_ratio() op, so it is a nop (and returns -EINVAL). Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index af30c730f432..1c771930772d 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -284,8 +284,6 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = rtd->codec_dai; int rate = params_rate(params); - snd_soc_dai_set_bclk_ratio(codec_dai, 50); - return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, 50); } From 7f2e2299cf169d8c517fbe2bcff3ca7bc8fa5f5c Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:05 +0100 Subject: [PATCH 502/942] ASoC: Intel: bytcr_rt5651: Rename IN3_MAP to IN1_HS_IN3_MAP All the mappings are named for where the internal mic is routed and in that sense the newly added in3_map really is the same as in1_map, what makes it different is that it maps the headset mic at IN3 rather then at IN2. Rename in3_map to in1_hs_in3_map to better reflect what it actually does. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 1c771930772d..7d5764d23c51 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -41,7 +41,7 @@ enum { BYT_RT5651_IN1_MAP, BYT_RT5651_IN2_MAP, BYT_RT5651_IN1_IN2_MAP, - BYT_RT5651_IN3_MAP, + BYT_RT5651_IN1_HS_IN3_MAP, }; enum { @@ -91,8 +91,8 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN1_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_MAP) dev_info(dev, "quirk IN2_MAP enabled"); - if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN3_MAP) - dev_info(dev, "quirk IN3_MAP enabled"); + if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN1_HS_IN3_MAP) + dev_info(dev, "quirk IN1_HS_IN3_MAP enabled"); if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { dev_info(dev, "quirk realtek,jack-detect-source %ld\n", BYT_RT5651_JDSRC(byt_rt5651_quirk)); @@ -235,8 +235,8 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic_map[] = { static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = { {"Internal Mic", NULL, "micbias1"}, - {"IN2P", NULL, "Headset Mic"}, {"IN1P", NULL, "Internal Mic"}, + {"IN2P", NULL, "Headset Mic"}, }; static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_map[] = { @@ -252,10 +252,10 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_in2_map[] = { {"IN3P", NULL, "Headset Mic"}, }; -static const struct snd_soc_dapm_route byt_rt5651_intmic_in3_map[] = { +static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_hs_in3_map[] = { {"Internal Mic", NULL, "micbias1"}, - {"IN3P", NULL, "Headset Mic"}, {"IN1P", NULL, "Internal Mic"}, + {"IN3P", NULL, "Headset Mic"}, }; static const struct snd_kcontrol_new byt_rt5651_controls[] = { @@ -300,7 +300,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"), DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Max B3 PLATFORM"), }, - .driver_data = (void *)(BYT_RT5651_IN3_MAP), + .driver_data = (void *)(BYT_RT5651_IN1_HS_IN3_MAP), }, { .callback = byt_rt5651_quirk_cb, @@ -309,7 +309,7 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Turbot"), }, .driver_data = (void *)(BYT_RT5651_MCLK_EN | - BYT_RT5651_IN3_MAP), + BYT_RT5651_IN1_HS_IN3_MAP), }, { .callback = byt_rt5651_quirk_cb, @@ -382,9 +382,9 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) custom_map = byt_rt5651_intmic_in1_in2_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_in2_map); break; - case BYT_RT5651_IN3_MAP: - custom_map = byt_rt5651_intmic_in3_map; - num_routes = ARRAY_SIZE(byt_rt5651_intmic_in3_map); + case BYT_RT5651_IN1_HS_IN3_MAP: + custom_map = byt_rt5651_intmic_in1_hs_in3_map; + num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_hs_in3_map); break; default: custom_map = byt_rt5651_intmic_dmic_map; From f026e06317804f305d4665d266191e07e2bf6394 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:06 +0100 Subject: [PATCH 503/942] ASoC: Intel: bytcr_rt5651: Add new IN2_HS_IN3 input map and a quirk using it Add a new IN2_HS_IN3 input map and add a quirk for the input mapping and jack-detect source for the Chuwi Vi8 Plus tablet, which uses this new map. Note the Chuwi Vi8 Plus lists an extra GPIO in its codecs ACPI resources which needs to be driven high to enable the external speaker amplifier, this is not supported yet and will be fixed in a future patch. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 7d5764d23c51..b798ebb18bf1 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -42,6 +42,7 @@ enum { BYT_RT5651_IN2_MAP, BYT_RT5651_IN1_IN2_MAP, BYT_RT5651_IN1_HS_IN3_MAP, + BYT_RT5651_IN2_HS_IN3_MAP, }; enum { @@ -93,6 +94,8 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk IN2_MAP enabled"); if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN1_HS_IN3_MAP) dev_info(dev, "quirk IN1_HS_IN3_MAP enabled"); + if (BYT_RT5651_MAP(byt_rt5651_quirk) == BYT_RT5651_IN2_HS_IN3_MAP) + dev_info(dev, "quirk IN2_HS_IN3_MAP enabled"); if (BYT_RT5651_JDSRC(byt_rt5651_quirk)) { dev_info(dev, "quirk realtek,jack-detect-source %ld\n", BYT_RT5651_JDSRC(byt_rt5651_quirk)); @@ -258,6 +261,12 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_hs_in3_map[] = { {"IN3P", NULL, "Headset Mic"}, }; +static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_hs_in3_map[] = { + {"Internal Mic", NULL, "micbias1"}, + {"IN2P", NULL, "Internal Mic"}, + {"IN3P", NULL, "Headset Mic"}, +}; + static const struct snd_kcontrol_new byt_rt5651_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), @@ -323,6 +332,19 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { BYT_RT5651_OVCD_SF_0P75 | BYT_RT5651_IN1_IN2_MAP), }, + { + /* Chuwi Vi8 Plus (CWI519) */ + .callback = byt_rt5651_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Hampoo"), + DMI_MATCH(DMI_PRODUCT_NAME, "D2D3_Vi8A1"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP), + }, {} }; @@ -386,6 +408,10 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) custom_map = byt_rt5651_intmic_in1_hs_in3_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_hs_in3_map); break; + case BYT_RT5651_IN2_HS_IN3_MAP: + custom_map = byt_rt5651_intmic_in2_hs_in3_map; + num_routes = ARRAY_SIZE(byt_rt5651_intmic_in2_hs_in3_map); + break; default: custom_map = byt_rt5651_intmic_dmic_map; num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic_map); From 8a880a2014e3ab50e66252335bd71d61b0487a30 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:07 +0100 Subject: [PATCH 504/942] ASoC: Intel: bytcr_rt5651: Add support for Bay Trail CR / SSP0 using boards Despite its name being prefixed with bytcr, before this commit the bytcr_rt5651 machine driver could not work with Bay Trail CR boards, as those only have SSP0 and it only supported SSP0-AIF1 setups. This commit adds support for this, autodetecting AIF1 vs AIF2 based on BIOS tables. While at it also add support for SSP2-AIF2 setups, as that requires only minimal extra code on top of the code adding SSP0-AIF1 / SSP0-AIF2 support. Note this code is all copy-pasted from bytcr_rt5640.c. I've looked into merging the 2 machine drivers into 1 to avoid copy-pasting, but there are enough subtile differences to make this hard *and* with all the quirks the machine driver already is full with if (variant-foo) then ... else ... constructs adding more of these is going to make the code unreadable. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 217 ++++++++++++++++++++++++-- 1 file changed, 201 insertions(+), 16 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index b798ebb18bf1..103c4b0e6505 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,9 @@ enum { #define BYT_RT5651_DMIC_EN BIT(16) #define BYT_RT5651_MCLK_EN BIT(17) #define BYT_RT5651_MCLK_25MHZ BIT(18) +#define BYT_RT5651_SSP2_AIF2 BIT(19) /* default is using AIF1 */ +#define BYT_RT5651_SSP0_AIF1 BIT(20) +#define BYT_RT5651_SSP0_AIF2 BIT(21) /* jack-detect-source + dmic-en + ovcd-th + -sf + terminating empty entry */ #define MAX_NO_PROPS 5 @@ -81,8 +85,7 @@ struct byt_rt5651_private { struct snd_soc_jack jack; }; -static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC_MAP | - BYT_RT5651_MCLK_EN; +static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN; static void log_quirks(struct device *dev) { @@ -110,9 +113,16 @@ static void log_quirks(struct device *dev) dev_info(dev, "quirk MCLK_EN enabled"); if (byt_rt5651_quirk & BYT_RT5651_MCLK_25MHZ) dev_info(dev, "quirk MCLK_25MHZ enabled"); + if (byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) + dev_info(dev, "quirk SSP2_AIF2 enabled\n"); + if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) + dev_info(dev, "quirk SSP0_AIF1 enabled\n"); + if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2) + dev_info(dev, "quirk SSP0_AIF2 enabled\n"); } #define BYT_CODEC_DAI1 "rt5651-aif1" +#define BYT_CODEC_DAI2 "rt5651-aif2" static int byt_rt5651_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, int rate, int bclk_ratio) @@ -156,6 +166,8 @@ static int platform_clock_control(struct snd_soc_dapm_widget *w, int ret; codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI1); + if (!codec_dai) + codec_dai = snd_soc_card_get_codec_dai(card, BYT_CODEC_DAI2); if (!codec_dai) { dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n"); @@ -213,13 +225,6 @@ static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = { {"Speaker", NULL, "Platform Clock"}, {"Line In", NULL, "Platform Clock"}, - {"AIF1 Playback", NULL, "ssp2 Tx"}, - {"ssp2 Tx", NULL, "codec_out0"}, - {"ssp2 Tx", NULL, "codec_out1"}, - {"codec_in0", NULL, "ssp2 Rx"}, - {"codec_in1", NULL, "ssp2 Rx"}, - {"ssp2 Rx", NULL, "AIF1 Capture"}, - {"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */ {"Headphone", NULL, "HPOL"}, {"Headphone", NULL, "HPOR"}, @@ -267,6 +272,42 @@ static const struct snd_soc_dapm_route byt_rt5651_intmic_in2_hs_in3_map[] = { {"IN3P", NULL, "Headset Mic"}, }; +static const struct snd_soc_dapm_route byt_rt5651_ssp0_aif1_map[] = { + {"ssp0 Tx", NULL, "modem_out"}, + {"modem_in", NULL, "ssp0 Rx"}, + + {"AIF1 Playback", NULL, "ssp0 Tx"}, + {"ssp0 Rx", NULL, "AIF1 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp0_aif2_map[] = { + {"ssp0 Tx", NULL, "modem_out"}, + {"modem_in", NULL, "ssp0 Rx"}, + + {"AIF2 Playback", NULL, "ssp0 Tx"}, + {"ssp0 Rx", NULL, "AIF2 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp2_aif1_map[] = { + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + + {"AIF1 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Rx", NULL, "AIF1 Capture"}, +}; + +static const struct snd_soc_dapm_route byt_rt5651_ssp2_aif2_map[] = { + {"ssp2 Tx", NULL, "codec_out0"}, + {"ssp2 Tx", NULL, "codec_out1"}, + {"codec_in0", NULL, "ssp2 Rx"}, + {"codec_in1", NULL, "ssp2 Rx"}, + + {"AIF2 Playback", NULL, "ssp2 Tx"}, + {"ssp2 Rx", NULL, "AIF2 Capture"}, +}; + static const struct snd_kcontrol_new byt_rt5651_controls[] = { SOC_DAPM_PIN_SWITCH("Headphone"), SOC_DAPM_PIN_SWITCH("Headset Mic"), @@ -291,9 +332,16 @@ static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; + snd_pcm_format_t format = params_format(params); int rate = params_rate(params); + int bclk_ratio; - return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, 50); + if (format == SNDRV_PCM_FORMAT_S16_LE) + bclk_ratio = 32; + else + bclk_ratio = 50; + + return byt_rt5651_prepare_and_enable_pll1(codec_dai, rate, bclk_ratio); } static int byt_rt5651_quirk_cb(const struct dmi_system_id *id) @@ -420,6 +468,26 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) if (ret) return ret; + if (byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp2_aif2_map, + ARRAY_SIZE(byt_rt5651_ssp2_aif2_map)); + } else if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp0_aif1_map, + ARRAY_SIZE(byt_rt5651_ssp0_aif1_map)); + } else if (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2) { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp0_aif2_map, + ARRAY_SIZE(byt_rt5651_ssp0_aif2_map)); + } else { + ret = snd_soc_dapm_add_routes(&card->dapm, + byt_rt5651_ssp2_aif1_map, + ARRAY_SIZE(byt_rt5651_ssp2_aif1_map)); + } + if (ret) + return ret; + ret = snd_soc_add_card_controls(card, byt_rt5651_controls, ARRAY_SIZE(byt_rt5651_controls)); if (ret) { @@ -485,18 +553,26 @@ static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, SNDRV_PCM_HW_PARAM_RATE); struct snd_interval *channels = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - int ret; + int ret, bits; - /* The DSP will covert the FE rate to 48k, stereo, 24bits */ + /* The DSP will covert the FE rate to 48k, stereo */ rate->min = rate->max = 48000; channels->min = channels->max = 2; - /* set SSP2 to 24-bit */ - params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* set SSP0 to 16-bit */ + params_set_format(params, SNDRV_PCM_FORMAT_S16_LE); + bits = 16; + } else { + /* set SSP2 to 24-bit */ + params_set_format(params, SNDRV_PCM_FORMAT_S24_LE); + bits = 24; + } /* * Default mode for SSP configuration is TDM 4 slot, override config - * with explicit setting to I2S 2ch 24-bit. The word length is set with + * with explicit setting to I2S 2ch. The word length is set with * dai_set_tdm_slot() since there is no other API exposed */ ret = snd_soc_dai_set_fmt(rtd->cpu_dai, @@ -510,7 +586,7 @@ static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd, return ret; } - ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24); + ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, bits); if (ret < 0) { dev_err(rtd->dev, "can't set I2S config, err %d\n", ret); return ret; @@ -605,12 +681,32 @@ static struct snd_soc_card byt_rt5651_card = { }; static char byt_rt5651_codec_name[SND_ACPI_I2C_ID_LEN]; +static char byt_rt5651_codec_aif_name[12]; /* = "rt5651-aif[1|2]" */ +static char byt_rt5651_cpu_dai_name[10]; /* = "ssp[0|2]-port" */ + +static bool is_valleyview(void) +{ + static const struct x86_cpu_id cpu_ids[] = { + { X86_VENDOR_INTEL, 6, 55 }, /* Valleyview, Bay Trail */ + {} + }; + + if (!x86_match_cpu(cpu_ids)) + return false; + return true; +} + +struct acpi_chan_package { /* ACPICA seems to require 64 bit integers */ + u64 aif_value; /* 1: AIF1, 2: AIF2 */ + u64 mclock_value; /* usually 25MHz (0x17d7940), ignored */ +}; static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) { struct byt_rt5651_private *priv; struct snd_soc_acpi_mach *mach; const char *i2c_name = NULL; + bool is_bytcr = false; int ret_val = 0; int dai_index = 0; int i; @@ -643,6 +739,73 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) "%s%s", "i2c-", i2c_name); byt_rt5651_dais[dai_index].codec_name = byt_rt5651_codec_name; + /* + * swap SSP0 if bytcr is detected + * (will be overridden if DMI quirk is detected) + */ + if (is_valleyview()) { + struct sst_platform_info *p_info = mach->pdata; + const struct sst_res_info *res_info = p_info->res_info; + + if (res_info->acpi_ipc_irq_index == 0) + is_bytcr = true; + } + + if (is_bytcr) { + /* + * Baytrail CR platforms may have CHAN package in BIOS, try + * to find relevant routing quirk based as done on Windows + * platforms. We have to read the information directly from the + * BIOS, at this stage the card is not created and the links + * with the codec driver/pdata are non-existent + */ + + struct acpi_chan_package chan_package; + + /* format specified: 2 64-bit integers */ + struct acpi_buffer format = {sizeof("NN"), "NN"}; + struct acpi_buffer state = {0, NULL}; + struct snd_soc_acpi_package_context pkg_ctx; + bool pkg_found = false; + + state.length = sizeof(chan_package); + state.pointer = &chan_package; + + pkg_ctx.name = "CHAN"; + pkg_ctx.length = 2; + pkg_ctx.format = &format; + pkg_ctx.state = &state; + pkg_ctx.data_valid = false; + + pkg_found = snd_soc_acpi_find_package_from_hid(mach->id, + &pkg_ctx); + if (pkg_found) { + if (chan_package.aif_value == 1) { + dev_info(&pdev->dev, "BIOS Routing: AIF1 connected\n"); + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF1; + } else if (chan_package.aif_value == 2) { + dev_info(&pdev->dev, "BIOS Routing: AIF2 connected\n"); + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; + } else { + dev_info(&pdev->dev, "BIOS Routing isn't valid, ignored\n"); + pkg_found = false; + } + } + + if (!pkg_found) { + /* no BIOS indications, assume SSP0-AIF2 connection */ + byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; + } + + /* change defaults for Baytrail-CR capture */ + byt_rt5651_quirk |= BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP; + } else { + byt_rt5651_quirk |= BYT_RT5651_DMIC_MAP; + } + /* check quirks before creating card */ dmi_check_system(byt_rt5651_quirk_table); @@ -653,6 +816,28 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) log_quirks(&pdev->dev); + if ((byt_rt5651_quirk & BYT_RT5651_SSP2_AIF2) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* fixup codec aif name */ + snprintf(byt_rt5651_codec_aif_name, + sizeof(byt_rt5651_codec_aif_name), + "%s", "rt5651-aif2"); + + byt_rt5651_dais[dai_index].codec_dai_name = + byt_rt5651_codec_aif_name; + } + + if ((byt_rt5651_quirk & BYT_RT5651_SSP0_AIF1) || + (byt_rt5651_quirk & BYT_RT5651_SSP0_AIF2)) { + /* fixup cpu dai name name */ + snprintf(byt_rt5651_cpu_dai_name, + sizeof(byt_rt5651_cpu_dai_name), + "%s", "ssp0-port"); + + byt_rt5651_dais[dai_index].cpu_dai_name = + byt_rt5651_cpu_dai_name; + } + if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) { priv->mclk = devm_clk_get(&pdev->dev, "pmc_plt_clk_3"); if (IS_ERR(priv->mclk)) { From f9877eb598d5bd2e6d9b4dc28068b66c464d1e5f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:08 +0100 Subject: [PATCH 505/942] ASoC: Intel: bytcr_rt5651: Add quirk for the VIOS LTH17 laptop Add a quirk setting up jack-detect and input routing for the VIOS LTH17 laptop. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 103c4b0e6505..d5a3d48294d2 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -393,6 +393,19 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { BYT_RT5651_OVCD_SF_0P75 | BYT_RT5651_IN2_HS_IN3_MAP), }, + { + /* VIOS LTH17 */ + .callback = byt_rt5651_quirk_cb, + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "VIOS"), + DMI_MATCH(DMI_PRODUCT_NAME, "LTH17"), + }, + .driver_data = (void *)(BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_1P0 | + BYT_RT5651_IN1_IN2_MAP), + }, {} }; From b4b6377e07727df8292539062d9a56e6bd83ba89 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:09 +0100 Subject: [PATCH 506/942] ASoC: Intel: bytcr_rt5651: Change defaults to enable jack-detect, analog mics Change the default quirk settings to enable jack-detect, analog mics. The old default input mapping of DMIC for non Bay Trail CR devices seems like a poor default as I'm not aware of any Intel SST + rt5651 using devices with a DMIC. All Cherry Trail devices using the bytcr_rt5651 machine driver seem to be modelled after BYT-CR devices, And the only non CR Bay Trail devices with a rt5651 codec I'm aware of are the Minnow boards for which we already have board specific quirks. So it seems better to me to use the BYT-CR defaults everywhere. This e.g. makes the Chuwi Hi8 Pro (CWI513) work ootb without needing a quirk. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index d5a3d48294d2..6efd7c9e7407 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -85,7 +85,12 @@ struct byt_rt5651_private { struct snd_soc_jack jack; }; -static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN; +/* Default: jack-detect on JD1_1, internal mic on in2, headsetmic on in3 */ +static unsigned long byt_rt5651_quirk = BYT_RT5651_MCLK_EN | + BYT_RT5651_JD1_1 | + BYT_RT5651_OVCD_TH_2000UA | + BYT_RT5651_OVCD_SF_0P75 | + BYT_RT5651_IN2_HS_IN3_MAP; static void log_quirks(struct device *dev) { @@ -809,14 +814,6 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev) /* no BIOS indications, assume SSP0-AIF2 connection */ byt_rt5651_quirk |= BYT_RT5651_SSP0_AIF2; } - - /* change defaults for Baytrail-CR capture */ - byt_rt5651_quirk |= BYT_RT5651_JD1_1 | - BYT_RT5651_OVCD_TH_2000UA | - BYT_RT5651_OVCD_SF_0P75 | - BYT_RT5651_IN2_HS_IN3_MAP; - } else { - byt_rt5651_quirk |= BYT_RT5651_DMIC_MAP; } /* check quirks before creating card */ From c22969d70fc9253112e88da55116e04074cdeac4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 4 Mar 2018 15:36:10 +0100 Subject: [PATCH 507/942] ASoC: Intel: bytcr_rt5651: Select RCCLK on init() When the BYT_RT5651_MCLK_EN quirk is set, we disable the MCLK from byt_rt5651_init(), we need to select the RCCLK as sysclk before doing this to make sure that jack-detect works directly after boot. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 6efd7c9e7407..53ce313024f1 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -457,6 +457,11 @@ static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime) card->dapm.idle_bias_off = true; + /* Start with RC clk for jack-detect (we disable MCLK below) */ + if (byt_rt5651_quirk & BYT_RT5651_MCLK_EN) + snd_soc_component_update_bits(codec, RT5651_GLB_CLK, + RT5651_SCLK_SRC_MASK, RT5651_SCLK_SRC_RCCLK); + switch (BYT_RT5651_MAP(byt_rt5651_quirk)) { case BYT_RT5651_IN1_MAP: custom_map = byt_rt5651_intmic_in1_map; From 933897342d0714ae1c10729cbaeecea0c6178db5 Mon Sep 17 00:00:00 2001 From: Arend Van Spriel Date: Wed, 28 Feb 2018 21:15:19 +0100 Subject: [PATCH 508/942] brcmfmac: add possibility to obtain firmware error The feature module needs to evaluate the actual firmware error return upon a control command. This adds a flag to struct brcmf_if that the caller can set. This flag is checked to determine the error code that needs to be returned. Fixes: b69c1df47281 ("brcmfmac: separate firmware errors from i/o errors") Reviewed-by: Hante Meuleman Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Kalle Valo --- .../net/wireless/broadcom/brcm80211/brcmfmac/core.h | 2 ++ .../net/wireless/broadcom/brcm80211/brcmfmac/feature.c | 10 ++++++++++ .../net/wireless/broadcom/brcm80211/brcmfmac/fwil.c | 3 +++ 3 files changed, 15 insertions(+) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h index df8a1ecb9924..232dcbb83311 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.h @@ -181,6 +181,7 @@ enum brcmf_netif_stop_reason { * @netif_stop_lock: spinlock for update netif_stop from multiple sources. * @pend_8021x_cnt: tracks outstanding number of 802.1x frames. * @pend_8021x_wait: used for signalling change in count. + * @fwil_fwerr: flag indicating fwil layer should return firmware error codes. */ struct brcmf_if { struct brcmf_pub *drvr; @@ -198,6 +199,7 @@ struct brcmf_if { wait_queue_head_t pend_8021x_wait; struct in6_addr ipv6_addr_tbl[NDOL_MAX_ENTRIES]; u8 ipv6addr_idx; + bool fwil_fwerr; }; int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp); diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c index 47de35a33853..bede7b7fd996 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c @@ -104,6 +104,9 @@ static void brcmf_feat_iovar_int_get(struct brcmf_if *ifp, u32 data; int err; + /* we need to know firmware error */ + ifp->fwil_fwerr = true; + err = brcmf_fil_iovar_int_get(ifp, name, &data); if (err == 0) { brcmf_dbg(INFO, "enabling feature: %s\n", brcmf_feat_names[id]); @@ -112,6 +115,8 @@ static void brcmf_feat_iovar_int_get(struct brcmf_if *ifp, brcmf_dbg(TRACE, "%s feature check failed: %d\n", brcmf_feat_names[id], err); } + + ifp->fwil_fwerr = false; } static void brcmf_feat_iovar_data_set(struct brcmf_if *ifp, @@ -120,6 +125,9 @@ static void brcmf_feat_iovar_data_set(struct brcmf_if *ifp, { int err; + /* we need to know firmware error */ + ifp->fwil_fwerr = true; + err = brcmf_fil_iovar_data_set(ifp, name, data, len); if (err != -BRCMF_FW_UNSUPPORTED) { brcmf_dbg(INFO, "enabling feature: %s\n", brcmf_feat_names[id]); @@ -128,6 +136,8 @@ static void brcmf_feat_iovar_data_set(struct brcmf_if *ifp, brcmf_dbg(TRACE, "%s feature check failed: %d\n", brcmf_feat_names[id], err); } + + ifp->fwil_fwerr = false; } #define MAX_CAPS_BUFFER_SIZE 512 diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c index f2cfdd3b2bf1..fc5751116d99 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c @@ -131,6 +131,9 @@ brcmf_fil_cmd_data(struct brcmf_if *ifp, u32 cmd, void *data, u32 len, bool set) brcmf_fil_get_errstr((u32)(-fwerr)), fwerr); err = -EBADE; } + if (ifp->fwil_fwerr) + return fwerr; + return err; } From 455f3e76cfc0d893585a5f358b9ddbe9c1e1e53b Mon Sep 17 00:00:00 2001 From: Arend Van Spriel Date: Wed, 28 Feb 2018 21:15:20 +0100 Subject: [PATCH 509/942] brcmfmac: fix P2P_DEVICE ethernet address generation The firmware has a requirement that the P2P_DEVICE address should be different from the address of the primary interface. When not specified by user-space, the driver generates the MAC address for the P2P_DEVICE interface using the MAC address of the primary interface and setting the locally administered bit. However, the MAC address of the primary interface may already have that bit set causing the creation of the P2P_DEVICE interface to fail with -EBUSY. Fix this by using a random address instead to determine the P2P_DEVICE address. Cc: stable@vger.kernel.org # 3.10.y Reported-by: Hans de Goede Reviewed-by: Hante Meuleman Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky Lin Signed-off-by: Arend van Spriel Signed-off-by: Kalle Valo --- .../broadcom/brcm80211/brcmfmac/p2p.c | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c index 2ee54133efa1..82064e909784 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c @@ -462,25 +462,23 @@ static int brcmf_p2p_set_firmware(struct brcmf_if *ifp, u8 *p2p_mac) * @dev_addr: optional device address. * * P2P needs mac addresses for P2P device and interface. If no device - * address it specified, these are derived from the primary net device, ie. - * the permanent ethernet address of the device. + * address it specified, these are derived from a random ethernet + * address. */ static void brcmf_p2p_generate_bss_mac(struct brcmf_p2p_info *p2p, u8 *dev_addr) { - struct brcmf_if *pri_ifp = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif->ifp; - bool local_admin = false; + bool random_addr = false; - if (!dev_addr || is_zero_ether_addr(dev_addr)) { - dev_addr = pri_ifp->mac_addr; - local_admin = true; - } + if (!dev_addr || is_zero_ether_addr(dev_addr)) + random_addr = true; - /* Generate the P2P Device Address. This consists of the device's - * primary MAC address with the locally administered bit set. + /* Generate the P2P Device Address obtaining a random ethernet + * address with the locally administered bit set. */ - memcpy(p2p->dev_addr, dev_addr, ETH_ALEN); - if (local_admin) - p2p->dev_addr[0] |= 0x02; + if (random_addr) + eth_random_addr(p2p->dev_addr); + else + memcpy(p2p->dev_addr, dev_addr, ETH_ALEN); /* Generate the P2P Interface Address. If the discovery and connection * BSSCFGs need to simultaneously co-exist, then this address must be From 25b5cdfcce1b57971840505dfc78556bd12dea6d Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 2 Mar 2018 16:01:48 +0100 Subject: [PATCH 510/942] dt-bindings: net: renesas-ravb: Make stream buffer optional The Stream Buffer for EtherAVB-IF (STBE) is an optional component, and is not present on all SoCs. Document this in the DT bindings, including a list of SoCs that do have it. Fixes: 785ec87483d1e24a ("ravb: document R8A77970 bindings") Fixes: f231c4178a655b09 ("dt-bindings: net: renesas-ravb: Add support for R8A77995 RAVB") Signed-off-by: Geert Uytterhoeven Reviewed-by: Simon Horman Acked-by: Sergei Shtylyov Reviewed-by: Rob Herring Signed-off-by: David S. Miller --- Documentation/devicetree/bindings/net/renesas,ravb.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/net/renesas,ravb.txt b/Documentation/devicetree/bindings/net/renesas,ravb.txt index 92fd4b2f17b2..b4dc455eb155 100644 --- a/Documentation/devicetree/bindings/net/renesas,ravb.txt +++ b/Documentation/devicetree/bindings/net/renesas,ravb.txt @@ -27,7 +27,11 @@ Required properties: SoC-specific version corresponding to the platform first followed by the generic version. -- reg: offset and length of (1) the register block and (2) the stream buffer. +- reg: Offset and length of (1) the register block and (2) the stream buffer. + The region for the register block is mandatory. + The region for the stream buffer is optional, as it is only present on + R-Car Gen2 and RZ/G1 SoCs, and on R-Car H3 (R8A7795), M3-W (R8A7796), + and M3-N (R8A77965). - interrupts: A list of interrupt-specifiers, one for each entry in interrupt-names. If interrupt-names is not present, an interrupt specifier From d3dcf8eb615537526bd42ff27a081d46d337816e Mon Sep 17 00:00:00 2001 From: Paul Blakey Date: Sun, 4 Mar 2018 17:29:48 +0200 Subject: [PATCH 511/942] rhashtable: Fix rhlist duplicates insertion When inserting duplicate objects (those with the same key), current rhlist implementation messes up the chain pointers by updating the bucket pointer instead of prev next pointer to the newly inserted node. This causes missing elements on removal and travesal. Fix that by properly updating pprev pointer to point to the correct rhash_head next pointer. Issue: 1241076 Change-Id: I86b2c140bcb4aeb10b70a72a267ff590bb2b17e7 Fixes: ca26893f05e8 ('rhashtable: Add rhlist interface') Signed-off-by: Paul Blakey Acked-by: Herbert Xu Signed-off-by: David S. Miller --- include/linux/rhashtable.h | 4 +++- lib/rhashtable.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index c9df2527e0cd..668a21f04b09 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h @@ -766,8 +766,10 @@ slow_path: if (!key || (params.obj_cmpfn ? params.obj_cmpfn(&arg, rht_obj(ht, head)) : - rhashtable_compare(&arg, rht_obj(ht, head)))) + rhashtable_compare(&arg, rht_obj(ht, head)))) { + pprev = &head->next; continue; + } data = rht_obj(ht, head); diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 3825c30aaa36..47de025b6245 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c @@ -506,8 +506,10 @@ static void *rhashtable_lookup_one(struct rhashtable *ht, if (!key || (ht->p.obj_cmpfn ? ht->p.obj_cmpfn(&arg, rht_obj(ht, head)) : - rhashtable_compare(&arg, rht_obj(ht, head)))) + rhashtable_compare(&arg, rht_obj(ht, head)))) { + pprev = &head->next; continue; + } if (!ht->rhlist) return rht_obj(ht, head); From 499ac3b60f657dae82055fc81c7b01e6242ac9bc Mon Sep 17 00:00:00 2001 From: Paul Blakey Date: Sun, 4 Mar 2018 17:29:49 +0200 Subject: [PATCH 512/942] test_rhashtable: add test case for rhltable with duplicate objects Tries to insert duplicates in the middle of bucket's chain: bucket 1: [[val 21 (tid=1)]] -> [[ val 1 (tid=2), val 1 (tid=0) ]] Reuses tid to distinguish the elements insertion order. Signed-off-by: Paul Blakey Acked-by: Herbert Xu Signed-off-by: David S. Miller --- lib/test_rhashtable.c | 134 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c index 76d3667fdea2..f4000c137dbe 100644 --- a/lib/test_rhashtable.c +++ b/lib/test_rhashtable.c @@ -79,6 +79,21 @@ struct thread_data { struct test_obj *objs; }; +static u32 my_hashfn(const void *data, u32 len, u32 seed) +{ + const struct test_obj_rhl *obj = data; + + return (obj->value.id % 10) << RHT_HASH_RESERVED_SPACE; +} + +static int my_cmpfn(struct rhashtable_compare_arg *arg, const void *obj) +{ + const struct test_obj_rhl *test_obj = obj; + const struct test_obj_val *val = arg->key; + + return test_obj->value.id - val->id; +} + static struct rhashtable_params test_rht_params = { .head_offset = offsetof(struct test_obj, node), .key_offset = offsetof(struct test_obj, value), @@ -87,6 +102,17 @@ static struct rhashtable_params test_rht_params = { .nulls_base = (3U << RHT_BASE_SHIFT), }; +static struct rhashtable_params test_rht_params_dup = { + .head_offset = offsetof(struct test_obj_rhl, list_node), + .key_offset = offsetof(struct test_obj_rhl, value), + .key_len = sizeof(struct test_obj_val), + .hashfn = jhash, + .obj_hashfn = my_hashfn, + .obj_cmpfn = my_cmpfn, + .nelem_hint = 128, + .automatic_shrinking = false, +}; + static struct semaphore prestart_sem; static struct semaphore startup_sem = __SEMAPHORE_INITIALIZER(startup_sem, 0); @@ -465,6 +491,112 @@ static int __init test_rhashtable_max(struct test_obj *array, return err; } +static unsigned int __init print_ht(struct rhltable *rhlt) +{ + struct rhashtable *ht; + const struct bucket_table *tbl; + char buff[512] = ""; + unsigned int i, cnt = 0; + + ht = &rhlt->ht; + tbl = rht_dereference(ht->tbl, ht); + for (i = 0; i < tbl->size; i++) { + struct rhash_head *pos, *next; + struct test_obj_rhl *p; + + pos = rht_dereference(tbl->buckets[i], ht); + next = !rht_is_a_nulls(pos) ? rht_dereference(pos->next, ht) : NULL; + + if (!rht_is_a_nulls(pos)) { + sprintf(buff, "%s\nbucket[%d] -> ", buff, i); + } + + while (!rht_is_a_nulls(pos)) { + struct rhlist_head *list = container_of(pos, struct rhlist_head, rhead); + sprintf(buff, "%s[[", buff); + do { + pos = &list->rhead; + list = rht_dereference(list->next, ht); + p = rht_obj(ht, pos); + + sprintf(buff, "%s val %d (tid=%d)%s", buff, p->value.id, p->value.tid, + list? ", " : " "); + cnt++; + } while (list); + + pos = next, + next = !rht_is_a_nulls(pos) ? + rht_dereference(pos->next, ht) : NULL; + + sprintf(buff, "%s]]%s", buff, !rht_is_a_nulls(pos) ? " -> " : ""); + } + } + printk(KERN_ERR "\n---- ht: ----%s\n-------------\n", buff); + + return cnt; +} + +static int __init test_insert_dup(struct test_obj_rhl *rhl_test_objects, + int cnt, bool slow) +{ + struct rhltable rhlt; + unsigned int i, ret; + const char *key; + int err = 0; + + err = rhltable_init(&rhlt, &test_rht_params_dup); + if (WARN_ON(err)) + return err; + + for (i = 0; i < cnt; i++) { + rhl_test_objects[i].value.tid = i; + key = rht_obj(&rhlt.ht, &rhl_test_objects[i].list_node.rhead); + key += test_rht_params_dup.key_offset; + + if (slow) { + err = PTR_ERR(rhashtable_insert_slow(&rhlt.ht, key, + &rhl_test_objects[i].list_node.rhead)); + if (err == -EAGAIN) + err = 0; + } else + err = rhltable_insert(&rhlt, + &rhl_test_objects[i].list_node, + test_rht_params_dup); + if (WARN(err, "error %d on element %d/%d (%s)\n", err, i, cnt, slow? "slow" : "fast")) + goto skip_print; + } + + ret = print_ht(&rhlt); + WARN(ret != cnt, "missing rhltable elements (%d != %d, %s)\n", ret, cnt, slow? "slow" : "fast"); + +skip_print: + rhltable_destroy(&rhlt); + + return 0; +} + +static int __init test_insert_duplicates_run(void) +{ + struct test_obj_rhl rhl_test_objects[3] = {}; + + pr_info("test inserting duplicates\n"); + + /* two different values that map to same bucket */ + rhl_test_objects[0].value.id = 1; + rhl_test_objects[1].value.id = 21; + + /* and another duplicate with same as [0] value + * which will be second on the bucket list */ + rhl_test_objects[2].value.id = rhl_test_objects[0].value.id; + + test_insert_dup(rhl_test_objects, 2, false); + test_insert_dup(rhl_test_objects, 3, false); + test_insert_dup(rhl_test_objects, 2, true); + test_insert_dup(rhl_test_objects, 3, true); + + return 0; +} + static int thread_lookup_test(struct thread_data *tdata) { unsigned int entries = tdata->entries; @@ -613,6 +745,8 @@ static int __init test_rht_init(void) do_div(total_time, runs); pr_info("Average test time: %llu\n", total_time); + test_insert_duplicates_run(); + if (!tcount) return 0; From 803fafbe0cd522fa6b9e41ca3b96cfb2e2a2222d Mon Sep 17 00:00:00 2001 From: Denis Kirjanov Date: Sun, 4 Mar 2018 21:48:17 +0300 Subject: [PATCH 513/942] fsl/fman: avoid sleeping in atomic context while adding an address __dev_mc_add grabs an adress spinlock so use atomic context in kmalloc. / # ifconfig eth0 inet 192.168.0.111 [ 89.331622] BUG: sleeping function called from invalid context at mm/slab.h:420 [ 89.339002] in_atomic(): 1, irqs_disabled(): 0, pid: 1035, name: ifconfig [ 89.345799] 2 locks held by ifconfig/1035: [ 89.349908] #0: (rtnl_mutex){+.+.}, at: [<(ptrval)>] devinet_ioctl+0xc0/0x8a0 [ 89.357258] #1: (_xmit_ETHER){+...}, at: [<(ptrval)>] __dev_mc_add+0x28/0x80 [ 89.364520] CPU: 1 PID: 1035 Comm: ifconfig Not tainted 4.16.0-rc3-dirty #8 [ 89.371464] Call Trace: [ 89.373908] [e959db60] [c066f948] dump_stack+0xa4/0xfc (unreliable) [ 89.380177] [e959db80] [c00671d8] ___might_sleep+0x248/0x280 [ 89.385833] [e959dba0] [c01aec34] kmem_cache_alloc_trace+0x174/0x320 [ 89.392179] [e959dbd0] [c04ab920] dtsec_add_hash_mac_address+0x130/0x240 [ 89.398874] [e959dc00] [c04a9d74] set_multi+0x174/0x1b0 [ 89.404093] [e959dc30] [c04afb68] dpaa_set_rx_mode+0x68/0xe0 [ 89.409745] [e959dc40] [c057baf8] __dev_mc_add+0x58/0x80 [ 89.415052] [e959dc60] [c060fd64] igmp_group_added+0x164/0x190 [ 89.420878] [e959dca0] [c060ffa8] ip_mc_inc_group+0x218/0x460 [ 89.426617] [e959dce0] [c06120fc] ip_mc_up+0x3c/0x190 [ 89.431662] [e959dd10] [c0607270] inetdev_event+0x250/0x620 [ 89.437227] [e959dd50] [c005f190] notifier_call_chain+0x80/0xf0 [ 89.443138] [e959dd80] [c0573a74] __dev_notify_flags+0x54/0xf0 [ 89.448964] [e959dda0] [c05743f8] dev_change_flags+0x48/0x60 [ 89.454615] [e959ddc0] [c0606744] devinet_ioctl+0x544/0x8a0 [ 89.460180] [e959de10] [c060987c] inet_ioctl+0x9c/0x1f0 [ 89.465400] [e959de80] [c05479a8] sock_ioctl+0x168/0x460 [ 89.470708] [e959ded0] [c01cf3ec] do_vfs_ioctl+0xac/0x8c0 [ 89.476099] [e959df20] [c01cfc40] SyS_ioctl+0x40/0xc0 [ 89.481147] [e959df40] [c0011318] ret_from_syscall+0x0/0x3c [ 89.486715] --- interrupt: c01 at 0x1006943c [ 89.486715] LR = 0x100c45ec Signed-off-by: Denis Kirjanov Acked-by: Madalin Bucur Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/fman/fman_dtsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fman/fman_dtsec.c b/drivers/net/ethernet/freescale/fman/fman_dtsec.c index ea43b4974149..7af31ddd093f 100644 --- a/drivers/net/ethernet/freescale/fman/fman_dtsec.c +++ b/drivers/net/ethernet/freescale/fman/fman_dtsec.c @@ -1100,7 +1100,7 @@ int dtsec_add_hash_mac_address(struct fman_mac *dtsec, enet_addr_t *eth_addr) set_bucket(dtsec->regs, bucket, true); /* Create element to be added to the driver hash table */ - hash_entry = kmalloc(sizeof(*hash_entry), GFP_KERNEL); + hash_entry = kmalloc(sizeof(*hash_entry), GFP_ATOMIC); if (!hash_entry) return -ENOMEM; hash_entry->addr = addr; From 35d889d10b649fda66121891ec05eca88150059d Mon Sep 17 00:00:00 2001 From: Alexey Kodanev Date: Mon, 5 Mar 2018 20:52:54 +0300 Subject: [PATCH 514/942] sch_netem: fix skb leak in netem_enqueue() When we exceed current packets limit and we have more than one segment in the list returned by skb_gso_segment(), netem drops only the first one, skipping the rest, hence kmemleak reports: unreferenced object 0xffff880b5d23b600 (size 1024): comm "softirq", pid 0, jiffies 4384527763 (age 2770.629s) hex dump (first 32 bytes): 00 80 23 5d 0b 88 ff ff 00 00 00 00 00 00 00 00 ..#]............ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<00000000d8a19b9d>] __alloc_skb+0xc9/0x520 [<000000001709b32f>] skb_segment+0x8c8/0x3710 [<00000000c7b9bb88>] tcp_gso_segment+0x331/0x1830 [<00000000c921cba1>] inet_gso_segment+0x476/0x1370 [<000000008b762dd4>] skb_mac_gso_segment+0x1f9/0x510 [<000000002182660a>] __skb_gso_segment+0x1dd/0x620 [<00000000412651b9>] netem_enqueue+0x1536/0x2590 [sch_netem] [<0000000005d3b2a9>] __dev_queue_xmit+0x1167/0x2120 [<00000000fc5f7327>] ip_finish_output2+0x998/0xf00 [<00000000d309e9d3>] ip_output+0x1aa/0x2c0 [<000000007ecbd3a4>] tcp_transmit_skb+0x18db/0x3670 [<0000000042d2a45f>] tcp_write_xmit+0x4d4/0x58c0 [<0000000056a44199>] tcp_tasklet_func+0x3d9/0x540 [<0000000013d06d02>] tasklet_action+0x1ca/0x250 [<00000000fcde0b8b>] __do_softirq+0x1b4/0x5a3 [<00000000e7ed027c>] irq_exit+0x1e2/0x210 Fix it by adding the rest of the segments, if any, to skb 'to_free' list. Add new __qdisc_drop_all() and qdisc_drop_all() functions because they can be useful in the future if we need to drop segmented GSO packets in other places. Fixes: 6071bd1aa13e ("netem: Segment GSO packets on enqueue") Signed-off-by: Alexey Kodanev Acked-by: Neil Horman Signed-off-by: David S. Miller --- include/net/sch_generic.h | 19 +++++++++++++++++++ net/sched/sch_netem.c | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index e2ab13687fb9..2092d33194dd 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -824,6 +824,16 @@ static inline void __qdisc_drop(struct sk_buff *skb, struct sk_buff **to_free) *to_free = skb; } +static inline void __qdisc_drop_all(struct sk_buff *skb, + struct sk_buff **to_free) +{ + if (skb->prev) + skb->prev->next = *to_free; + else + skb->next = *to_free; + *to_free = skb; +} + static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch, struct qdisc_skb_head *qh, struct sk_buff **to_free) @@ -956,6 +966,15 @@ static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch, return NET_XMIT_DROP; } +static inline int qdisc_drop_all(struct sk_buff *skb, struct Qdisc *sch, + struct sk_buff **to_free) +{ + __qdisc_drop_all(skb, to_free); + qdisc_qstats_drop(sch); + + return NET_XMIT_DROP; +} + /* Length to Time (L2T) lookup in a qdisc_rate_table, to determine how long it will take to send a packet given its size. */ diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index 7c179addebcd..7d6801fc5340 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -509,7 +509,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch, } if (unlikely(sch->q.qlen >= sch->limit)) - return qdisc_drop(skb, sch, to_free); + return qdisc_drop_all(skb, sch, to_free); qdisc_qstats_backlog_inc(sch, skb); From 2695578b896aea472b2c0dcbe9d92daa71738484 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 5 Mar 2018 11:41:13 -0800 Subject: [PATCH 515/942] net: usbnet: fix potential deadlock on 32bit hosts Marek reported a LOCKDEP issue occurring on 32bit host, that we tracked down to the fact that usbnet could either run from soft or hard irqs. This patch adds u64_stats_update_begin_irqsave() and u64_stats_update_end_irqrestore() helpers to solve this case. [ 17.768040] ================================ [ 17.772239] WARNING: inconsistent lock state [ 17.776511] 4.16.0-rc3-next-20180227-00007-g876c53a7493c #453 Not tainted [ 17.783329] -------------------------------- [ 17.787580] inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. [ 17.793607] swapper/0/0 [HC0[0]:SC1[1]:HE1:SE0] takes: [ 17.798751] (&syncp->seq#5){?.-.}, at: [<9b22e5f0>] asix_rx_fixup_internal+0x188/0x288 [ 17.806790] {IN-HARDIRQ-W} state was registered at: [ 17.811677] tx_complete+0x100/0x208 [ 17.815319] __usb_hcd_giveback_urb+0x60/0xf0 [ 17.819770] xhci_giveback_urb_in_irq+0xa8/0x240 [ 17.824469] xhci_td_cleanup+0xf4/0x16c [ 17.828367] xhci_irq+0xe74/0x2240 [ 17.831827] usb_hcd_irq+0x24/0x38 [ 17.835343] __handle_irq_event_percpu+0x98/0x510 [ 17.840111] handle_irq_event_percpu+0x1c/0x58 [ 17.844623] handle_irq_event+0x38/0x5c [ 17.848519] handle_fasteoi_irq+0xa4/0x138 [ 17.852681] generic_handle_irq+0x18/0x28 [ 17.856760] __handle_domain_irq+0x6c/0xe4 [ 17.860941] gic_handle_irq+0x54/0xa0 [ 17.864666] __irq_svc+0x70/0xb0 [ 17.867964] arch_cpu_idle+0x20/0x3c [ 17.871578] arch_cpu_idle+0x20/0x3c [ 17.875190] do_idle+0x144/0x218 [ 17.878468] cpu_startup_entry+0x18/0x1c [ 17.882454] start_kernel+0x394/0x400 [ 17.886177] irq event stamp: 161912 [ 17.889616] hardirqs last enabled at (161912): [<7bedfacf>] __netdev_alloc_skb+0xcc/0x140 [ 17.897893] hardirqs last disabled at (161911): [] __netdev_alloc_skb+0x94/0x140 [ 17.904903] exynos5-hsi2c 12ca0000.i2c: tx timeout [ 17.906116] softirqs last enabled at (161904): [<387102ff>] irq_enter+0x78/0x80 [ 17.906123] softirqs last disabled at (161905): [] irq_exit+0x134/0x158 [ 17.925722]. [ 17.925722] other info that might help us debug this: [ 17.933435] Possible unsafe locking scenario: [ 17.933435]. [ 17.940331] CPU0 [ 17.942488] ---- [ 17.944894] lock(&syncp->seq#5); [ 17.948274] [ 17.950847] lock(&syncp->seq#5); [ 17.954386]. [ 17.954386] *** DEADLOCK *** [ 17.954386]. [ 17.962422] no locks held by swapper/0/0. Fixes: c8b5d129ee29 ("net: usbnet: support 64bit stats") Signed-off-by: Eric Dumazet Reported-by: Marek Szyprowski Cc: Greg Ungerer Signed-off-by: David S. Miller --- drivers/net/usb/usbnet.c | 10 ++++++---- include/linux/u64_stats_sync.h | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 8a22ff67b026..d9eea8cfe6cb 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -315,6 +315,7 @@ static void __usbnet_status_stop_force(struct usbnet *dev) void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) { struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); + unsigned long flags; int status; if (test_bit(EVENT_RX_PAUSED, &dev->flags)) { @@ -326,10 +327,10 @@ void usbnet_skb_return (struct usbnet *dev, struct sk_buff *skb) if (skb->protocol == 0) skb->protocol = eth_type_trans (skb, dev->net); - u64_stats_update_begin(&stats64->syncp); + flags = u64_stats_update_begin_irqsave(&stats64->syncp); stats64->rx_packets++; stats64->rx_bytes += skb->len; - u64_stats_update_end(&stats64->syncp); + u64_stats_update_end_irqrestore(&stats64->syncp, flags); netif_dbg(dev, rx_status, dev->net, "< rx, len %zu, type 0x%x\n", skb->len + sizeof (struct ethhdr), skb->protocol); @@ -1248,11 +1249,12 @@ static void tx_complete (struct urb *urb) if (urb->status == 0) { struct pcpu_sw_netstats *stats64 = this_cpu_ptr(dev->stats64); + unsigned long flags; - u64_stats_update_begin(&stats64->syncp); + flags = u64_stats_update_begin_irqsave(&stats64->syncp); stats64->tx_packets += entry->packets; stats64->tx_bytes += entry->length; - u64_stats_update_end(&stats64->syncp); + u64_stats_update_end_irqrestore(&stats64->syncp, flags); } else { dev->net->stats.tx_errors++; diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h index 5bdbd9f49395..07ee0f84a46c 100644 --- a/include/linux/u64_stats_sync.h +++ b/include/linux/u64_stats_sync.h @@ -90,6 +90,28 @@ static inline void u64_stats_update_end(struct u64_stats_sync *syncp) #endif } +static inline unsigned long +u64_stats_update_begin_irqsave(struct u64_stats_sync *syncp) +{ + unsigned long flags = 0; + +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + local_irq_save(flags); + write_seqcount_begin(&syncp->seq); +#endif + return flags; +} + +static inline void +u64_stats_update_end_irqrestore(struct u64_stats_sync *syncp, + unsigned long flags) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + write_seqcount_end(&syncp->seq); + local_irq_restore(flags); +#endif +} + static inline void u64_stats_update_begin_raw(struct u64_stats_sync *syncp) { #if BITS_PER_LONG==32 && defined(CONFIG_SMP) From 9de506a547c0d172d13a91d69b1a399e6a2c0efa Mon Sep 17 00:00:00 2001 From: Michal Kalderon Date: Mon, 5 Mar 2018 23:50:46 +0200 Subject: [PATCH 516/942] qed: Free RoCE ILT Memory on rmmod qedr Rdma requires ILT Memory to be allocated for it's QPs. Each ILT entry points to a page used by several Rdma QPs. To avoid allocating all the memory in advance, the rdma implementation dynamically allocates memory as more QPs are added, however it does not dynamically free the memory. The memory should have been freed on rmmod qedr, but isn't. This patch adds the memory freeing on rmmod qedr (currently it will be freed with qed is removed). An outcome of this bug, is that if qedr is unloaded and loaded without unloaded qed, there will be no more RoCE traffic. The reason these are related, is that the logic of detecting the first QP ever opened is by asking whether ILT memory for RoCE has been allocated. In addition, this patch modifies freeing of the Task context to always use the PROTOCOLID_ROCE and not the protocol passed, this is because task context for iWARP and ROCE both use the ROCE protocol id, as opposed to the connection context. Fixes: dbb799c39717 ("qed: Initialize hardware for new protocols") Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qed/qed_cxt.c | 5 ++++- drivers/net/ethernet/qlogic/qed/qed_rdma.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_cxt.c b/drivers/net/ethernet/qlogic/qed/qed_cxt.c index 6f546e869d8d..00f41c145d4d 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_cxt.c +++ b/drivers/net/ethernet/qlogic/qed/qed_cxt.c @@ -2480,7 +2480,10 @@ int qed_cxt_free_proto_ilt(struct qed_hwfn *p_hwfn, enum protocol_type proto) if (rc) return rc; - /* Free Task CXT */ + /* Free Task CXT ( Intentionally RoCE as task-id is shared between + * RoCE and iWARP ) + */ + proto = PROTOCOLID_ROCE; rc = qed_cxt_free_ilt_range(p_hwfn, QED_ELEM_TASK, 0, qed_cxt_get_proto_tid_count(p_hwfn, proto)); if (rc) diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c index 5d040b873137..f3ee6538b553 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c +++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c @@ -380,6 +380,7 @@ static void qed_rdma_free(struct qed_hwfn *p_hwfn) qed_rdma_free_reserved_lkey(p_hwfn); qed_rdma_resc_free(p_hwfn); + qed_cxt_free_proto_ilt(p_hwfn, p_hwfn->p_rdma_info->proto); } static void qed_rdma_get_guid(struct qed_hwfn *p_hwfn, u8 *guid) From cc5db3150e87fe7f7e947bf333b6c1c97f848ecb Mon Sep 17 00:00:00 2001 From: Hemanth Puranik Date: Tue, 6 Mar 2018 08:18:06 +0530 Subject: [PATCH 517/942] net: qcom/emac: Use proper free methods during TX This patch fixes the warning messages/call traces seen if DMA debug is enabled, In case of fragmented skb's memory was allocated using dma_map_page but freed using dma_unmap_single. This patch modifies buffer allocations in TX path to use dma_map_page in all the places and dma_unmap_page while freeing the buffers. Signed-off-by: Hemanth Puranik Acked-by: Timur Tabi Signed-off-by: David S. Miller --- drivers/net/ethernet/qualcomm/emac/emac-mac.c | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/emac/emac-mac.c b/drivers/net/ethernet/qualcomm/emac/emac-mac.c index 9cbb27263742..d5a32b7c7dc5 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac-mac.c +++ b/drivers/net/ethernet/qualcomm/emac/emac-mac.c @@ -1194,9 +1194,9 @@ void emac_mac_tx_process(struct emac_adapter *adpt, struct emac_tx_queue *tx_q) while (tx_q->tpd.consume_idx != hw_consume_idx) { tpbuf = GET_TPD_BUFFER(tx_q, tx_q->tpd.consume_idx); if (tpbuf->dma_addr) { - dma_unmap_single(adpt->netdev->dev.parent, - tpbuf->dma_addr, tpbuf->length, - DMA_TO_DEVICE); + dma_unmap_page(adpt->netdev->dev.parent, + tpbuf->dma_addr, tpbuf->length, + DMA_TO_DEVICE); tpbuf->dma_addr = 0; } @@ -1353,9 +1353,11 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt, tpbuf = GET_TPD_BUFFER(tx_q, tx_q->tpd.produce_idx); tpbuf->length = mapped_len; - tpbuf->dma_addr = dma_map_single(adpt->netdev->dev.parent, - skb->data, tpbuf->length, - DMA_TO_DEVICE); + tpbuf->dma_addr = dma_map_page(adpt->netdev->dev.parent, + virt_to_page(skb->data), + offset_in_page(skb->data), + tpbuf->length, + DMA_TO_DEVICE); ret = dma_mapping_error(adpt->netdev->dev.parent, tpbuf->dma_addr); if (ret) @@ -1371,9 +1373,12 @@ static void emac_tx_fill_tpd(struct emac_adapter *adpt, if (mapped_len < len) { tpbuf = GET_TPD_BUFFER(tx_q, tx_q->tpd.produce_idx); tpbuf->length = len - mapped_len; - tpbuf->dma_addr = dma_map_single(adpt->netdev->dev.parent, - skb->data + mapped_len, - tpbuf->length, DMA_TO_DEVICE); + tpbuf->dma_addr = dma_map_page(adpt->netdev->dev.parent, + virt_to_page(skb->data + + mapped_len), + offset_in_page(skb->data + + mapped_len), + tpbuf->length, DMA_TO_DEVICE); ret = dma_mapping_error(adpt->netdev->dev.parent, tpbuf->dma_addr); if (ret) From e9fa1495d738e34fcec88a3d2ec9101a9ee5b310 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 6 Mar 2018 11:10:19 +0100 Subject: [PATCH 518/942] ipv6: Reflect MTU changes on PMTU of exceptions for MTU-less routes Currently, administrative MTU changes on a given netdevice are not reflected on route exceptions for MTU-less routes, with a set PMTU value, for that device: # ip -6 route get 2001:db8::b 2001:db8::b from :: dev vti_a proto kernel src 2001:db8::a metric 256 pref medium # ping6 -c 1 -q -s10000 2001:db8::b > /dev/null # ip netns exec a ip -6 route get 2001:db8::b 2001:db8::b from :: dev vti_a src 2001:db8::a metric 0 cache expires 571sec mtu 4926 pref medium # ip link set dev vti_a mtu 3000 # ip -6 route get 2001:db8::b 2001:db8::b from :: dev vti_a src 2001:db8::a metric 0 cache expires 571sec mtu 4926 pref medium # ip link set dev vti_a mtu 9000 # ip -6 route get 2001:db8::b 2001:db8::b from :: dev vti_a src 2001:db8::a metric 0 cache expires 571sec mtu 4926 pref medium The first issue is that since commit fb56be83e43d ("net-ipv6: on device mtu change do not add mtu to mtu-less routes") we don't call rt6_exceptions_update_pmtu() from rt6_mtu_change_route(), which handles administrative MTU changes, if the regular route is MTU-less. However, PMTU exceptions should be always updated, as long as RTAX_MTU is not locked. Keep the check for MTU-less main route, as introduced by that commit, but, for exceptions, call rt6_exceptions_update_pmtu() regardless of that check. Once that is fixed, one problem remains: MTU changes are not reflected if the new MTU is higher than the previous one, because rt6_exceptions_update_pmtu() doesn't allow that. We should instead allow PMTU increase if the old PMTU matches the local MTU, as that implies that the old MTU was the lowest in the path, and PMTU discovery might lead to different results. The existing check in rt6_mtu_change_route() correctly took that case into account (for regular routes only), so factor it out and re-use it also in rt6_exceptions_update_pmtu(). While at it, fix comments style and grammar, and try to be a bit more descriptive. Reported-by: Xiumei Mu Fixes: fb56be83e43d ("net-ipv6: on device mtu change do not add mtu to mtu-less routes") Fixes: f5bbe7ee79c2 ("ipv6: prepare rt6_mtu_change() for exception table") Signed-off-by: Stefano Brivio Acked-by: David Ahern Signed-off-by: David S. Miller --- net/ipv6/route.c | 71 ++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 29 deletions(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 9dcfadddd800..0db4218c9186 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -1509,7 +1509,30 @@ static void rt6_exceptions_remove_prefsrc(struct rt6_info *rt) } } -static void rt6_exceptions_update_pmtu(struct rt6_info *rt, int mtu) +static bool rt6_mtu_change_route_allowed(struct inet6_dev *idev, + struct rt6_info *rt, int mtu) +{ + /* If the new MTU is lower than the route PMTU, this new MTU will be the + * lowest MTU in the path: always allow updating the route PMTU to + * reflect PMTU decreases. + * + * If the new MTU is higher, and the route PMTU is equal to the local + * MTU, this means the old MTU is the lowest in the path, so allow + * updating it: if other nodes now have lower MTUs, PMTU discovery will + * handle this. + */ + + if (dst_mtu(&rt->dst) >= mtu) + return true; + + if (dst_mtu(&rt->dst) == idev->cnf.mtu6) + return true; + + return false; +} + +static void rt6_exceptions_update_pmtu(struct inet6_dev *idev, + struct rt6_info *rt, int mtu) { struct rt6_exception_bucket *bucket; struct rt6_exception *rt6_ex; @@ -1518,20 +1541,22 @@ static void rt6_exceptions_update_pmtu(struct rt6_info *rt, int mtu) bucket = rcu_dereference_protected(rt->rt6i_exception_bucket, lockdep_is_held(&rt6_exception_lock)); - if (bucket) { - for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) { - hlist_for_each_entry(rt6_ex, &bucket->chain, hlist) { - struct rt6_info *entry = rt6_ex->rt6i; - /* For RTF_CACHE with rt6i_pmtu == 0 - * (i.e. a redirected route), - * the metrics of its rt->dst.from has already - * been updated. - */ - if (entry->rt6i_pmtu && entry->rt6i_pmtu > mtu) - entry->rt6i_pmtu = mtu; - } - bucket++; + if (!bucket) + return; + + for (i = 0; i < FIB6_EXCEPTION_BUCKET_SIZE; i++) { + hlist_for_each_entry(rt6_ex, &bucket->chain, hlist) { + struct rt6_info *entry = rt6_ex->rt6i; + + /* For RTF_CACHE with rt6i_pmtu == 0 (i.e. a redirected + * route), the metrics of its rt->dst.from have already + * been updated. + */ + if (entry->rt6i_pmtu && + rt6_mtu_change_route_allowed(idev, entry, mtu)) + entry->rt6i_pmtu = mtu; } + bucket++; } } @@ -3809,25 +3834,13 @@ static int rt6_mtu_change_route(struct rt6_info *rt, void *p_arg) Since RFC 1981 doesn't include administrative MTU increase update PMTU increase is a MUST. (i.e. jumbo frame) */ - /* - If new MTU is less than route PMTU, this new MTU will be the - lowest MTU in the path, update the route PMTU to reflect PMTU - decreases; if new MTU is greater than route PMTU, and the - old MTU is the lowest MTU in the path, update the route PMTU - to reflect the increase. In this case if the other nodes' MTU - also have the lowest MTU, TOO BIG MESSAGE will be lead to - PMTU discovery. - */ if (rt->dst.dev == arg->dev && - dst_metric_raw(&rt->dst, RTAX_MTU) && !dst_metric_locked(&rt->dst, RTAX_MTU)) { spin_lock_bh(&rt6_exception_lock); - if (dst_mtu(&rt->dst) >= arg->mtu || - (dst_mtu(&rt->dst) < arg->mtu && - dst_mtu(&rt->dst) == idev->cnf.mtu6)) { + if (dst_metric_raw(&rt->dst, RTAX_MTU) && + rt6_mtu_change_route_allowed(idev, rt, arg->mtu)) dst_metric_set(&rt->dst, RTAX_MTU, arg->mtu); - } - rt6_exceptions_update_pmtu(rt, arg->mtu); + rt6_exceptions_update_pmtu(idev, rt, arg->mtu); spin_unlock_bh(&rt6_exception_lock); } return 0; From e06513d78d54e6c7026c9043a39e2c01ee25bdbe Mon Sep 17 00:00:00 2001 From: Jeremy Linton Date: Tue, 6 Mar 2018 09:00:06 -0600 Subject: [PATCH 519/942] net: smsc911x: Fix unload crash when link is up The smsc911x driver will crash if it is rmmod'ed while the netdev is up like: Call trace: phy_detach+0x94/0x150 phy_disconnect+0x40/0x50 smsc911x_stop+0x104/0x128 [smsc911x] __dev_close_many+0xb4/0x138 dev_close_many+0xbc/0x190 rollback_registered_many+0x140/0x460 rollback_registered+0x68/0xb0 unregister_netdevice_queue+0x100/0x118 unregister_netdev+0x28/0x38 smsc911x_drv_remove+0x58/0x130 [smsc911x] platform_drv_remove+0x30/0x50 device_release_driver_internal+0x15c/0x1f8 driver_detach+0x54/0x98 bus_remove_driver+0x64/0xe8 driver_unregister+0x34/0x60 platform_driver_unregister+0x20/0x30 smsc911x_cleanup_module+0x14/0xbca8 [smsc911x] SyS_delete_module+0x1e8/0x238 __sys_trace_return+0x0/0x4 This is caused by the mdiobus being unregistered/free'd and the code in phy_detach() attempting to manipulate mdio related structures from unregister_netdev() calling close() To fix this, we delay the mdiobus teardown until after the netdev is deregistered. Reported-by: Matt Sealey Signed-off-by: Jeremy Linton Reviewed-by: Andrew Lunn Signed-off-by: David S. Miller --- drivers/net/ethernet/smsc/smsc911x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 012fb66eed8d..f0afb88d7bc2 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2335,14 +2335,14 @@ static int smsc911x_drv_remove(struct platform_device *pdev) pdata = netdev_priv(dev); BUG_ON(!pdata); BUG_ON(!pdata->ioaddr); - WARN_ON(dev->phydev); SMSC_TRACE(pdata, ifdown, "Stopping driver"); + unregister_netdev(dev); + mdiobus_unregister(pdata->mii_bus); mdiobus_free(pdata->mii_bus); - unregister_netdev(dev); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "smsc911x-memory"); if (!res) From a560002437d3646dafccecb1bf32d1685112ddda Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Tue, 6 Mar 2018 18:46:39 +0300 Subject: [PATCH 520/942] net: Fix hlist corruptions in inet_evict_bucket() inet_evict_bucket() iterates global list, and several tasks may call it in parallel. All of them hash the same fq->list_evictor to different lists, which leads to list corruption. This patch makes fq be hashed to expired list only if this has not been made yet by another task. Since inet_frag_alloc() allocates fq using kmem_cache_zalloc(), we may rely on list_evictor is initially unhashed. The problem seems to exist before async pernet_operations, as there was possible to have exit method to be executed in parallel with inet_frags::frags_work, so I add two Fixes tags. This also may go to stable. Fixes: d1fe19444d82 "inet: frag: don't re-use chainlist for evictor" Fixes: f84c6821aa54 "net: Convert pernet_subsys, registered from inet_init()" Signed-off-by: Kirill Tkhai Signed-off-by: David S. Miller --- net/ipv4/inet_fragment.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 26a3d0315728..e8ec28999f5c 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -119,6 +119,9 @@ out: static bool inet_fragq_should_evict(const struct inet_frag_queue *q) { + if (!hlist_unhashed(&q->list_evictor)) + return false; + return q->net->low_thresh == 0 || frag_mem_limit(q->net) >= q->net->low_thresh; } From 17cfe79a65f98abe535261856c5aef14f306dff7 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Tue, 6 Mar 2018 07:54:53 -0800 Subject: [PATCH 521/942] l2tp: do not accept arbitrary sockets syzkaller found an issue caused by lack of sufficient checks in l2tp_tunnel_create() RAW sockets can not be considered as UDP ones for instance. In another patch, we shall replace all pr_err() by less intrusive pr_debug() so that syzkaller can find other bugs faster. Acked-by: Guillaume Nault Acked-by: James Chapman ================================================================== BUG: KASAN: slab-out-of-bounds in setup_udp_tunnel_sock+0x3ee/0x5f0 net/ipv4/udp_tunnel.c:69 dst_release: dst:00000000d53d0d0f refcnt:-1 Write of size 1 at addr ffff8801d013b798 by task syz-executor3/6242 CPU: 1 PID: 6242 Comm: syz-executor3 Not tainted 4.16.0-rc2+ #253 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23b/0x360 mm/kasan/report.c:412 __asan_report_store1_noabort+0x17/0x20 mm/kasan/report.c:435 setup_udp_tunnel_sock+0x3ee/0x5f0 net/ipv4/udp_tunnel.c:69 l2tp_tunnel_create+0x1354/0x17f0 net/l2tp/l2tp_core.c:1596 pppol2tp_connect+0x14b1/0x1dd0 net/l2tp/l2tp_ppp.c:707 SYSC_connect+0x213/0x4a0 net/socket.c:1640 SyS_connect+0x24/0x30 net/socket.c:1621 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 Fixes: fd558d186df2 ("l2tp: Split pppol2tp patch into separate l2tp and ppp parts") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: David S. Miller --- net/l2tp/l2tp_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index 83421c6f0bef..e22512e32827 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -1457,9 +1457,14 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 encap = cfg->encap; /* Quick sanity checks */ + err = -EPROTONOSUPPORT; + if (sk->sk_type != SOCK_DGRAM) { + pr_debug("tunl %hu: fd %d wrong socket type\n", + tunnel_id, fd); + goto err; + } switch (encap) { case L2TP_ENCAPTYPE_UDP: - err = -EPROTONOSUPPORT; if (sk->sk_protocol != IPPROTO_UDP) { pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n", tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP); @@ -1467,7 +1472,6 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 } break; case L2TP_ENCAPTYPE_IP: - err = -EPROTONOSUPPORT; if (sk->sk_protocol != IPPROTO_L2TP) { pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n", tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP); From 67f93df79aeefc3add4e4b31a752600f834236e2 Mon Sep 17 00:00:00 2001 From: Alexey Kodanev Date: Tue, 6 Mar 2018 22:57:01 +0300 Subject: [PATCH 522/942] dccp: check sk for closed state in dccp_sendmsg() dccp_disconnect() sets 'dp->dccps_hc_tx_ccid' tx handler to NULL, therefore if DCCP socket is disconnected and dccp_sendmsg() is called after it, it will cause a NULL pointer dereference in dccp_write_xmit(). This crash and the reproducer was reported by syzbot. Looks like it is reproduced if commit 69c64866ce07 ("dccp: CVE-2017-8824: use-after-free in DCCP code") is applied. Reported-by: syzbot+f99ab3887ab65d70f816@syzkaller.appspotmail.com Signed-off-by: Alexey Kodanev Signed-off-by: David S. Miller --- net/dccp/proto.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 15bdc002d90c..84cd4e3fd01b 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -794,6 +794,11 @@ int dccp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) if (skb == NULL) goto out_release; + if (sk->sk_state == DCCP_CLOSED) { + rc = -ENOTCONN; + goto out_discard; + } + skb_reserve(skb, sk->sk_prot->max_header); rc = memcpy_from_msg(skb_put(skb, len), msg, len); if (rc != 0) From e05836ac07c77dd90377f8c8140bce2a44af5fe7 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Tue, 6 Mar 2018 17:15:12 -0500 Subject: [PATCH 523/942] tcp: purge write queue upon aborting the connection When the connection is aborted, there is no point in keeping the packets on the write queue until the connection is closed. Similar to a27fd7a8ed38 ('tcp: purge write queue upon RST'), this is essential for a correct MSG_ZEROCOPY implementation, because userspace cannot call close(fd) before receiving zerocopy signals even when the connection is aborted. Fixes: f214f915e7db ("tcp: enable MSG_ZEROCOPY") Signed-off-by: Soheil Hassas Yeganeh Signed-off-by: Neal Cardwell Reviewed-by: Eric Dumazet Signed-off-by: Yuchung Cheng Signed-off-by: David S. Miller --- net/ipv4/tcp.c | 1 + net/ipv4/tcp_timer.c | 1 + 2 files changed, 2 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 48636aee23c3..8b8059b7af4d 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3566,6 +3566,7 @@ int tcp_abort(struct sock *sk, int err) bh_unlock_sock(sk); local_bh_enable(); + tcp_write_queue_purge(sk); release_sock(sk); return 0; } diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index 71fc60f1b326..f7d944855f8e 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c @@ -34,6 +34,7 @@ static void tcp_write_err(struct sock *sk) sk->sk_err = sk->sk_err_soft ? : ETIMEDOUT; sk->sk_error_report(sk); + tcp_write_queue_purge(sk); tcp_done(sk); __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONTIMEOUT); } From b51f26b14683838825170387457176c1ffaea9f5 Mon Sep 17 00:00:00 2001 From: Paul Moore Date: Tue, 6 Mar 2018 17:27:44 -0500 Subject: [PATCH 524/942] net: don't unnecessarily load kernel modules in dev_ioctl() Starting with v4.16-rc1 we've been seeing a higher than usual number of requests for the kernel to load networking modules, even on events which shouldn't trigger a module load (e.g. ioctl(TCGETS)). Stephen Smalley suggested the problem may lie in commit 44c02a2c3dc5 ("dev_ioctl(): move copyin/copyout to callers") which moves changes the network dev_ioctl() function to always call dev_load(), regardless of the requested ioctl. This patch moves the dev_load() calls back into the individual ioctls while preserving the rest of the original patch. Reported-by: Dominick Grift Suggested-by: Stephen Smalley Signed-off-by: Paul Moore Signed-off-by: David S. Miller --- net/core/dev_ioctl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c index 0ab1af04296c..a04e1e88bf3a 100644 --- a/net/core/dev_ioctl.c +++ b/net/core/dev_ioctl.c @@ -402,8 +402,6 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c if (colon) *colon = 0; - dev_load(net, ifr->ifr_name); - /* * See which interface the caller is talking about. */ @@ -423,6 +421,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c case SIOCGIFMAP: case SIOCGIFINDEX: case SIOCGIFTXQLEN: + dev_load(net, ifr->ifr_name); rcu_read_lock(); ret = dev_ifsioc_locked(net, ifr, cmd); rcu_read_unlock(); @@ -431,6 +430,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c return ret; case SIOCETHTOOL: + dev_load(net, ifr->ifr_name); rtnl_lock(); ret = dev_ethtool(net, ifr); rtnl_unlock(); @@ -447,6 +447,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c case SIOCGMIIPHY: case SIOCGMIIREG: case SIOCSIFNAME: + dev_load(net, ifr->ifr_name); if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) return -EPERM; rtnl_lock(); @@ -494,6 +495,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c /* fall through */ case SIOCBONDSLAVEINFOQUERY: case SIOCBONDINFOQUERY: + dev_load(net, ifr->ifr_name); rtnl_lock(); ret = dev_ifsioc(net, ifr, cmd); rtnl_unlock(); @@ -518,6 +520,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c cmd == SIOCGHWTSTAMP || (cmd >= SIOCDEVPRIVATE && cmd <= SIOCDEVPRIVATE + 15)) { + dev_load(net, ifr->ifr_name); rtnl_lock(); ret = dev_ifsioc(net, ifr, cmd); rtnl_unlock(); From 016764de8b0d17e946832d7b6530434daa82df0e Mon Sep 17 00:00:00 2001 From: Ganesh Goudar Date: Wed, 7 Mar 2018 13:08:45 +0530 Subject: [PATCH 525/942] cxgb4: copy adap index to PF0-3 adapter instances instantiation of VF's on different adapters fails, copy adapter index and chip type to PF0-3 adapter instances to fix the issue. Signed-off-by: Ganesh Goudar Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 7b452e85de2a..33bc84185b82 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -5181,6 +5181,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) adapter->name = pci_name(pdev); adapter->mbox = func; adapter->pf = func; + adapter->params.chip = chip; + adapter->adap_idx = adap_idx; adapter->msg_enable = DFLT_MSG_ENABLE; adapter->mbox_log = kzalloc(sizeof(*adapter->mbox_log) + (sizeof(struct mbox_cmd) * From b06ef18a4c255609388ed6e068a1c69c797545e0 Mon Sep 17 00:00:00 2001 From: Ganesh Goudar Date: Wed, 7 Mar 2018 13:10:24 +0530 Subject: [PATCH 526/942] cxgb4: do not set needs_free_netdev for mgmt dev's Do not set 'needs_free_netdev' as we do call free_netdev for mgmt net devices, doing both hits BUG_ON. Signed-off-by: Ganesh Goudar Signed-off-by: David S. Miller --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 33bc84185b82..61022b5f6743 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c @@ -4970,7 +4970,6 @@ static void cxgb4_mgmt_setup(struct net_device *dev) /* Initialize the device structure. */ dev->netdev_ops = &cxgb4_mgmt_netdev_ops; dev->ethtool_ops = &cxgb4_mgmt_ethtool_ops; - dev->needs_free_netdev = true; } static int cxgb4_iov_configure(struct pci_dev *pdev, int num_vfs) From 3ffb0ba9b567a8efb9a04ed3d1ec15ff333ada22 Mon Sep 17 00:00:00 2001 From: Vishal Verma Date: Mon, 5 Mar 2018 16:56:13 -0700 Subject: [PATCH 527/942] libnvdimm, {btt, blk}: do integrity setup before add_disk() Prior to 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk") we needed to temporarily add a zero-capacity disk before registering for blk-integrity. But adding a zero-capacity disk caused the partition table scanning to bail early, and this resulted in partitions not coming up after a probe of the BTT or blk namespaces. We can now register for integrity before the disk has been added, and this fixes the rescan problems. Fixes: 25520d55cdb6 ("block: Inline blk_integrity in struct gendisk") Reported-by: Dariusz Dokupil Cc: Signed-off-by: Vishal Verma Signed-off-by: Dan Williams --- drivers/nvdimm/blk.c | 3 +-- drivers/nvdimm/btt.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvdimm/blk.c b/drivers/nvdimm/blk.c index 345acca576b3..1bd7b3734751 100644 --- a/drivers/nvdimm/blk.c +++ b/drivers/nvdimm/blk.c @@ -278,8 +278,6 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) disk->queue = q; disk->flags = GENHD_FL_EXT_DEVT; nvdimm_namespace_disk_name(&nsblk->common, disk->disk_name); - set_capacity(disk, 0); - device_add_disk(dev, disk); if (devm_add_action_or_reset(dev, nd_blk_release_disk, disk)) return -ENOMEM; @@ -292,6 +290,7 @@ static int nsblk_attach_disk(struct nd_namespace_blk *nsblk) } set_capacity(disk, available_disk_size >> SECTOR_SHIFT); + device_add_disk(dev, disk); revalidate_disk(disk); return 0; } diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c index 2ef544f10ec8..4b95ac513de2 100644 --- a/drivers/nvdimm/btt.c +++ b/drivers/nvdimm/btt.c @@ -1545,8 +1545,6 @@ static int btt_blk_init(struct btt *btt) queue_flag_set_unlocked(QUEUE_FLAG_NONROT, btt->btt_queue); btt->btt_queue->queuedata = btt; - set_capacity(btt->btt_disk, 0); - device_add_disk(&btt->nd_btt->dev, btt->btt_disk); if (btt_meta_size(btt)) { int rc = nd_integrity_init(btt->btt_disk, btt_meta_size(btt)); @@ -1558,6 +1556,7 @@ static int btt_blk_init(struct btt *btt) } } set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9); + device_add_disk(&btt->nd_btt->dev, btt->btt_disk); btt->nd_btt->size = btt->nlba * (u64)btt->sector_size; revalidate_disk(btt->btt_disk); From 6007b080d2e2adb7af22bf29165f0594ea12b34c Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 7 Mar 2018 22:10:01 +0100 Subject: [PATCH 528/942] bpf, x64: increase number of passes In Cilium some of the main programs we run today are hitting 9 passes on x64's JIT compiler, and we've had cases already where we surpassed the limit where the JIT then punts the program to the interpreter instead, leading to insertion failures due to CONFIG_BPF_JIT_ALWAYS_ON or insertion failures due to the prog array owner being JITed but the program to insert not (both must have the same JITed/non-JITed property). One concrete case the program image shrunk from 12,767 bytes down to 10,288 bytes where the image converged after 16 steps. I've measured that this took 340us in the JIT until it converges on my i7-6600U. Thus, increase the original limit we had from day one where the JIT covered cBPF only back then before we run into the case (as similar with the complexity limit) where we trip over this and hit program rejections. Also add a cond_resched() into the compilation loop, the JIT process runs without any locks and may sleep anyway. Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov Reviewed-by: Eric Dumazet Signed-off-by: Alexei Starovoitov --- arch/x86/net/bpf_jit_comp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 45e4eb5bcbb2..ce5b2ebd5701 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c @@ -1188,7 +1188,7 @@ skip_init_addrs: * may converge on the last pass. In such case do one more * pass to emit the final image */ - for (pass = 0; pass < 10 || image; pass++) { + for (pass = 0; pass < 20 || image; pass++) { proglen = do_jit(prog, addrs, image, oldproglen, &ctx); if (proglen <= 0) { image = NULL; @@ -1215,6 +1215,7 @@ skip_init_addrs: } } oldproglen = proglen; + cond_resched(); } if (bpf_jit_enable > 1) From 49159a9dc3da83f17be00acbc7b2ab84ffec1aa7 Mon Sep 17 00:00:00 2001 From: Tero Kristo Date: Fri, 23 Feb 2018 14:28:21 +0200 Subject: [PATCH 529/942] clk: ti: clkctrl: add support for CLK_SET_RATE_PARENT flag Certain clkctrl clocks, notably the display ones, use the CLK_SET_RATE_PARENT feature extensively. Add support for this flag to the clkctrl clocks. Signed-off-by: Tero Kristo Reported-by: Jyri Sarha Acked-by: Tony Lindgren Tested-by: Jyri Sarha --- drivers/clk/ti/clkctrl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c index afa0d6bfc5c1..421b05392220 100644 --- a/drivers/clk/ti/clkctrl.c +++ b/drivers/clk/ti/clkctrl.c @@ -537,6 +537,8 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node) init.parent_names = ®_data->parent; init.num_parents = 1; init.flags = 0; + if (reg_data->flags & CLKF_SET_RATE_PARENT) + init.flags |= CLK_SET_RATE_PARENT; init.name = kasprintf(GFP_KERNEL, "%s:%s:%04x:%d", node->parent->name, node->name, reg_data->offset, 0); From c083dc5f3738d394223baa0f90705397b0844acd Mon Sep 17 00:00:00 2001 From: Tero Kristo Date: Fri, 23 Feb 2018 14:29:19 +0200 Subject: [PATCH 530/942] clk: ti: am33xx: add set-rate-parent support for display clkctrl clock Display driver assumes it can use clk_set_rate for the display clock via set-rate-parent mechanism, so add the flag for this to it. Signed-off-by: Tero Kristo Reported-by: Jyri Sarha Acked-by: Tony Lindgren Tested-by: Jyri Sarha --- drivers/clk/ti/clk-33xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/ti/clk-33xx.c b/drivers/clk/ti/clk-33xx.c index 612491a26070..12e0a2d19911 100644 --- a/drivers/clk/ti/clk-33xx.c +++ b/drivers/clk/ti/clk-33xx.c @@ -45,7 +45,7 @@ static const struct omap_clkctrl_bit_data am3_gpio4_bit_data[] __initconst = { static const struct omap_clkctrl_reg_data am3_l4_per_clkctrl_regs[] __initconst = { { AM3_CPGMAC0_CLKCTRL, NULL, CLKF_SW_SUP, "cpsw_125mhz_gclk", "cpsw_125mhz_clkdm" }, - { AM3_LCDC_CLKCTRL, NULL, CLKF_SW_SUP, "lcd_gclk", "lcdc_clkdm" }, + { AM3_LCDC_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_SET_RATE_PARENT, "lcd_gclk", "lcdc_clkdm" }, { AM3_USB_OTG_HS_CLKCTRL, NULL, CLKF_SW_SUP, "usbotg_fck", "l3s_clkdm" }, { AM3_TPTC0_CLKCTRL, NULL, CLKF_SW_SUP, "l3_gclk", "l3_clkdm" }, { AM3_EMIF_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_ddr_m2_div2_ck", "l3_clkdm" }, From 762790b75210f5219c6896565f811271405a9632 Mon Sep 17 00:00:00 2001 From: Tero Kristo Date: Mon, 26 Feb 2018 14:40:37 +0200 Subject: [PATCH 531/942] clk: ti: am43xx: add set-rate-parent support for display clkctrl clock Display driver assumes it can use clk_set_rate for the display clock via set-rate-parent mechanism, so add the flag for this to id. Signed-off-by: Tero Kristo Acked-by: Tony Lindgren --- drivers/clk/ti/clk-43xx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/ti/clk-43xx.c b/drivers/clk/ti/clk-43xx.c index 2b7c2e017665..63c5ddb50187 100644 --- a/drivers/clk/ti/clk-43xx.c +++ b/drivers/clk/ti/clk-43xx.c @@ -187,7 +187,7 @@ static const struct omap_clkctrl_reg_data am4_l4_per_clkctrl_regs[] __initconst { AM4_OCP2SCP0_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" }, { AM4_OCP2SCP1_CLKCTRL, NULL, CLKF_SW_SUP, "l4ls_gclk" }, { AM4_EMIF_CLKCTRL, NULL, CLKF_SW_SUP, "dpll_ddr_m2_ck", "emif_clkdm" }, - { AM4_DSS_CORE_CLKCTRL, NULL, CLKF_SW_SUP, "disp_clk", "dss_clkdm" }, + { AM4_DSS_CORE_CLKCTRL, NULL, CLKF_SW_SUP | CLKF_SET_RATE_PARENT, "disp_clk", "dss_clkdm" }, { AM4_CPGMAC0_CLKCTRL, NULL, CLKF_SW_SUP, "cpsw_125mhz_gclk", "cpsw_125mhz_clkdm" }, { 0 }, }; From d2b9430771cae7edc9927b36ce0e76a336fd952c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 8 Mar 2018 17:09:29 +0900 Subject: [PATCH 532/942] ASoC: uniphier: remove superfluous inclusion None of aio-compress.c depends on the syscon header. Signed-off-by: Masahiro Yamada Acked-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-compress.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/uniphier/aio-compress.c b/sound/soc/uniphier/aio-compress.c index 4751c8bdabec..4c1027aa615e 100644 --- a/sound/soc/uniphier/aio-compress.c +++ b/sound/soc/uniphier/aio-compress.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include From 625504aeff11eeb95f78ad9dde22d911c6839c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 22 Feb 2018 00:32:50 +0100 Subject: [PATCH 533/942] pinctrl: sh-pfc: r8a7795: remove duplicate of CLKOUT pin in pinmux_pins[] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When adding GP-1-28 port pin support it was forgotten to remove the CLKOUT pin from the list of pins that are not associated with a GPIO port in pinmux_pins[]. This results in a warning when reading the pinctrl files in sysfs as the CLKOUT pin is still added as a none GPIO pin. Fix this by removing the duplicated entry which is no longer needed. ~ # cat /sys/kernel/debug/pinctrl/e6060000.pin-controller/pinconf-pins [ 89.432081] ------------[ cut here ]------------ [ 89.436904] Pin 496 is not in bias info list [ 89.441252] WARNING: CPU: 1 PID: 456 at drivers/pinctrl/sh-pfc/core.c:408 sh_pfc_pin_to_bias_reg+0xb0/0xb8 [ 89.451002] CPU: 1 PID: 456 Comm: cat Not tainted 4.16.0-rc1-arm64-renesas-00048-gdfafc344a4f24dde #12 [ 89.460394] Hardware name: Renesas Salvator-X 2nd version board based on r8a7795 ES2.0+ (DT) [ 89.468910] pstate: 80000085 (Nzcv daIf -PAN -UAO) [ 89.473747] pc : sh_pfc_pin_to_bias_reg+0xb0/0xb8 [ 89.478495] lr : sh_pfc_pin_to_bias_reg+0xb0/0xb8 [ 89.483241] sp : ffff00000aff3ab0 [ 89.486587] x29: ffff00000aff3ab0 x28: ffff00000893c698 [ 89.491955] x27: ffff000008ad7d98 x26: 0000000000000000 [ 89.497323] x25: ffff8006fb3f5028 x24: ffff8006fb3f5018 [ 89.502690] x23: 0000000000000001 x22: 00000000000001f0 [ 89.508057] x21: ffff8006fb3f5018 x20: ffff000008bef000 [ 89.513423] x19: 0000000000000000 x18: ffffffffffffffff [ 89.518790] x17: 0000000000006c4a x16: ffff000008d67c98 [ 89.524157] x15: 0000000000000001 x14: ffff00000896ca98 [ 89.529524] x13: 00000000cce5f611 x12: ffff8006f8d3b5a8 [ 89.534891] x11: ffff00000981e000 x10: ffff000008befa08 [ 89.540258] x9 : ffff8006f9b987a0 x8 : ffff000008befa08 [ 89.545625] x7 : ffff000008137094 x6 : 0000000000000000 [ 89.550991] x5 : 0000000000000000 x4 : 0000000000000001 [ 89.556357] x3 : 0000000000000007 x2 : 0000000000000007 [ 89.561723] x1 : 1ff24f80f1818600 x0 : 0000000000000000 [ 89.567091] Call trace: [ 89.569561] sh_pfc_pin_to_bias_reg+0xb0/0xb8 [ 89.573960] r8a7795_pinmux_get_bias+0x30/0xc0 [ 89.578445] sh_pfc_pinconf_get+0x1e0/0x2d8 [ 89.582669] pin_config_get_for_pin+0x20/0x30 [ 89.587067] pinconf_generic_dump_one+0x180/0x1c8 [ 89.591815] pinconf_generic_dump_pins+0x84/0xd8 [ 89.596476] pinconf_pins_show+0xc8/0x130 [ 89.600528] seq_read+0xe4/0x510 [ 89.603789] full_proxy_read+0x60/0x90 [ 89.607576] __vfs_read+0x30/0x140 [ 89.611010] vfs_read+0x90/0x170 [ 89.614269] SyS_read+0x60/0xd8 [ 89.617443] __sys_trace_return+0x0/0x4 [ 89.621314] ---[ end trace 99c8d0d39c13e794 ]--- Fixes: 82d2de5a4f646f72 ("pinctrl: sh-pfc: r8a7795: Add GP-1-28 port pin support") Reviewed-and-tested-by: Geert Uytterhoeven Signed-off-by: Niklas Söderlund Signed-off-by: Linus Walleij --- drivers/pinctrl/sh-pfc/pfc-r8a7795.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/pinctrl/sh-pfc/pfc-r8a7795.c b/drivers/pinctrl/sh-pfc/pfc-r8a7795.c index 18aeee592fdc..35951e7b89d2 100644 --- a/drivers/pinctrl/sh-pfc/pfc-r8a7795.c +++ b/drivers/pinctrl/sh-pfc/pfc-r8a7795.c @@ -1538,7 +1538,6 @@ static const struct sh_pfc_pin pinmux_pins[] = { SH_PFC_PIN_NAMED_CFG('B', 18, AVB_TD1, CFG_FLAGS), SH_PFC_PIN_NAMED_CFG('B', 19, AVB_RXC, CFG_FLAGS), SH_PFC_PIN_NAMED_CFG('C', 1, PRESETOUT#, CFG_FLAGS), - SH_PFC_PIN_NAMED_CFG('F', 1, CLKOUT, CFG_FLAGS), SH_PFC_PIN_NAMED_CFG('H', 37, MLB_REF, CFG_FLAGS), SH_PFC_PIN_NAMED_CFG('V', 3, QSPI1_SPCLK, CFG_FLAGS), SH_PFC_PIN_NAMED_CFG('V', 5, QSPI1_SSL, CFG_FLAGS), From 93b0beae721b3344923b4b8317e9d83b542f4ca6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Tue, 20 Feb 2018 19:17:51 +0100 Subject: [PATCH 534/942] pinctrl: samsung: Validate alias coming from DT Driver uses alias from Device Tree as an index of pin controller data array. In case of a wrong DTB or an out-of-tree DTB, the alias could be outside of this data array leading to out-of-bounds access. Depending on binary and memory layout, this could be handled properly (showing error like "samsung-pinctrl 3860000.pinctrl: driver data not available") or could lead to exceptions. Reported-by: Geert Uytterhoeven Cc: Fixes: 30574f0db1b1 ("pinctrl: add samsung pinctrl and gpiolib driver") Signed-off-by: Krzysztof Kozlowski Reviewed-by: Geert Uytterhoeven Acked-by: Tomasz Figa Signed-off-by: Linus Walleij --- drivers/pinctrl/samsung/pinctrl-exynos-arm.c | 56 ++++++++++++++--- .../pinctrl/samsung/pinctrl-exynos-arm64.c | 14 ++++- drivers/pinctrl/samsung/pinctrl-s3c24xx.c | 28 +++++++-- drivers/pinctrl/samsung/pinctrl-s3c64xx.c | 7 ++- drivers/pinctrl/samsung/pinctrl-samsung.c | 61 ++++++++++++------- drivers/pinctrl/samsung/pinctrl-samsung.h | 40 +++++++----- 6 files changed, 154 insertions(+), 52 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c index c32399faff57..90c274490181 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm.c @@ -124,7 +124,7 @@ static const struct samsung_pin_bank_data s5pv210_pin_bank[] __initconst = { EXYNOS_PIN_BANK_EINTW(8, 0xc60, "gph3", 0x0c), }; -const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = s5pv210_pin_bank, @@ -137,6 +137,11 @@ const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data s5pv210_of_data __initconst = { + .ctrl = s5pv210_pin_ctrl, + .num_ctrl = ARRAY_SIZE(s5pv210_pin_ctrl), +}; + /* Pad retention control code for accessing PMU regmap */ static atomic_t exynos_shared_retention_refcnt; @@ -199,7 +204,7 @@ static const struct samsung_retention_data exynos3250_retention_data __initconst * Samsung pinctrl driver data for Exynos3250 SoC. Exynos3250 SoC includes * two gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos3250_pin_banks0, @@ -220,6 +225,11 @@ const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos3250_of_data __initconst = { + .ctrl = exynos3250_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos3250_pin_ctrl), +}; + /* pin banks of exynos4210 pin-controller 0 */ static const struct samsung_pin_bank_data exynos4210_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), @@ -303,7 +313,7 @@ static const struct samsung_retention_data exynos4_audio_retention_data __initco * Samsung pinctrl driver data for Exynos4210 SoC. Exynos4210 SoC includes * three gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos4210_pin_banks0, @@ -329,6 +339,11 @@ const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos4210_of_data __initconst = { + .ctrl = exynos4210_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos4210_pin_ctrl), +}; + /* pin banks of exynos4x12 pin-controller 0 */ static const struct samsung_pin_bank_data exynos4x12_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), @@ -391,7 +406,7 @@ static const struct samsung_pin_bank_data exynos4x12_pin_banks3[] __initconst = * Samsung pinctrl driver data for Exynos4x12 SoC. Exynos4x12 SoC includes * four gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos4x12_pin_banks0, @@ -427,6 +442,11 @@ const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos4x12_of_data __initconst = { + .ctrl = exynos4x12_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos4x12_pin_ctrl), +}; + /* pin banks of exynos5250 pin-controller 0 */ static const struct samsung_pin_bank_data exynos5250_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), @@ -487,7 +507,7 @@ static const struct samsung_pin_bank_data exynos5250_pin_banks3[] __initconst = * Samsung pinctrl driver data for Exynos5250 SoC. Exynos5250 SoC includes * four gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos5250_pin_banks0, @@ -523,6 +543,11 @@ const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos5250_of_data __initconst = { + .ctrl = exynos5250_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos5250_pin_ctrl), +}; + /* pin banks of exynos5260 pin-controller 0 */ static const struct samsung_pin_bank_data exynos5260_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTG(4, 0x000, "gpa0", 0x00), @@ -567,7 +592,7 @@ static const struct samsung_pin_bank_data exynos5260_pin_banks2[] __initconst = * Samsung pinctrl driver data for Exynos5260 SoC. Exynos5260 SoC includes * three gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos5260_pin_banks0, @@ -587,6 +612,11 @@ const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos5260_of_data __initconst = { + .ctrl = exynos5260_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos5260_pin_ctrl), +}; + /* pin banks of exynos5410 pin-controller 0 */ static const struct samsung_pin_bank_data exynos5410_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), @@ -657,7 +687,7 @@ static const struct samsung_pin_bank_data exynos5410_pin_banks3[] __initconst = * Samsung pinctrl driver data for Exynos5410 SoC. Exynos5410 SoC includes * four gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos5410_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos5410_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos5410_pin_banks0, @@ -690,6 +720,11 @@ const struct samsung_pin_ctrl exynos5410_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos5410_of_data __initconst = { + .ctrl = exynos5410_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos5410_pin_ctrl), +}; + /* pin banks of exynos5420 pin-controller 0 */ static const struct samsung_pin_bank_data exynos5420_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpy7", 0x00), @@ -774,7 +809,7 @@ static const struct samsung_retention_data exynos5420_retention_data __initconst * Samsung pinctrl driver data for Exynos5420 SoC. Exynos5420 SoC includes * four gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos5420_pin_banks0, @@ -808,3 +843,8 @@ const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = { .retention_data = &exynos4_audio_retention_data, }, }; + +const struct samsung_pinctrl_of_match_data exynos5420_of_data __initconst = { + .ctrl = exynos5420_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos5420_pin_ctrl), +}; diff --git a/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c b/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c index fc8f7833bec0..71c9d1d9f345 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos-arm64.c @@ -175,7 +175,7 @@ static const struct samsung_retention_data exynos5433_fsys_retention_data __init * Samsung pinctrl driver data for Exynos5433 SoC. Exynos5433 SoC includes * ten gpio/pin-mux/pinconfig controllers. */ -const struct samsung_pin_ctrl exynos5433_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos5433_pin_ctrl[] __initconst = { { /* pin-controller instance 0 data */ .pin_banks = exynos5433_pin_banks0, @@ -260,6 +260,11 @@ const struct samsung_pin_ctrl exynos5433_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data exynos5433_of_data __initconst = { + .ctrl = exynos5433_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos5433_pin_ctrl), +}; + /* pin banks of exynos7 pin-controller - ALIVE */ static const struct samsung_pin_bank_data exynos7_pin_banks0[] __initconst = { EXYNOS_PIN_BANK_EINTW(8, 0x000, "gpa0", 0x00), @@ -339,7 +344,7 @@ static const struct samsung_pin_bank_data exynos7_pin_banks9[] __initconst = { EXYNOS_PIN_BANK_EINTG(4, 0x020, "gpz1", 0x04), }; -const struct samsung_pin_ctrl exynos7_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl exynos7_pin_ctrl[] __initconst = { { /* pin-controller instance 0 Alive data */ .pin_banks = exynos7_pin_banks0, @@ -392,3 +397,8 @@ const struct samsung_pin_ctrl exynos7_pin_ctrl[] __initconst = { .eint_gpio_init = exynos_eint_gpio_init, }, }; + +const struct samsung_pinctrl_of_match_data exynos7_of_data __initconst = { + .ctrl = exynos7_pin_ctrl, + .num_ctrl = ARRAY_SIZE(exynos7_pin_ctrl), +}; diff --git a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c index 10187cb0e9b9..7e824e4d20f4 100644 --- a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c +++ b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c @@ -565,7 +565,7 @@ static const struct samsung_pin_bank_data s3c2412_pin_banks[] __initconst = { PIN_BANK_2BIT(13, 0x080, "gpj"), }; -const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = { { .pin_banks = s3c2412_pin_banks, .nr_banks = ARRAY_SIZE(s3c2412_pin_banks), @@ -573,6 +573,11 @@ const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data s3c2412_of_data __initconst = { + .ctrl = s3c2412_pin_ctrl, + .num_ctrl = ARRAY_SIZE(s3c2412_pin_ctrl), +}; + static const struct samsung_pin_bank_data s3c2416_pin_banks[] __initconst = { PIN_BANK_A(27, 0x000, "gpa"), PIN_BANK_2BIT(11, 0x010, "gpb"), @@ -587,7 +592,7 @@ static const struct samsung_pin_bank_data s3c2416_pin_banks[] __initconst = { PIN_BANK_2BIT(2, 0x100, "gpm"), }; -const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = { { .pin_banks = s3c2416_pin_banks, .nr_banks = ARRAY_SIZE(s3c2416_pin_banks), @@ -595,6 +600,11 @@ const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data s3c2416_of_data __initconst = { + .ctrl = s3c2416_pin_ctrl, + .num_ctrl = ARRAY_SIZE(s3c2416_pin_ctrl), +}; + static const struct samsung_pin_bank_data s3c2440_pin_banks[] __initconst = { PIN_BANK_A(25, 0x000, "gpa"), PIN_BANK_2BIT(11, 0x010, "gpb"), @@ -607,7 +617,7 @@ static const struct samsung_pin_bank_data s3c2440_pin_banks[] __initconst = { PIN_BANK_2BIT(13, 0x0d0, "gpj"), }; -const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = { { .pin_banks = s3c2440_pin_banks, .nr_banks = ARRAY_SIZE(s3c2440_pin_banks), @@ -615,6 +625,11 @@ const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = { }, }; +const struct samsung_pinctrl_of_match_data s3c2440_of_data __initconst = { + .ctrl = s3c2440_pin_ctrl, + .num_ctrl = ARRAY_SIZE(s3c2440_pin_ctrl), +}; + static const struct samsung_pin_bank_data s3c2450_pin_banks[] __initconst = { PIN_BANK_A(28, 0x000, "gpa"), PIN_BANK_2BIT(11, 0x010, "gpb"), @@ -630,10 +645,15 @@ static const struct samsung_pin_bank_data s3c2450_pin_banks[] __initconst = { PIN_BANK_2BIT(2, 0x100, "gpm"), }; -const struct samsung_pin_ctrl s3c2450_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl s3c2450_pin_ctrl[] __initconst = { { .pin_banks = s3c2450_pin_banks, .nr_banks = ARRAY_SIZE(s3c2450_pin_banks), .eint_wkup_init = s3c24xx_eint_init, }, }; + +const struct samsung_pinctrl_of_match_data s3c2450_of_data __initconst = { + .ctrl = s3c2450_pin_ctrl, + .num_ctrl = ARRAY_SIZE(s3c2450_pin_ctrl), +}; diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c index 679628ac4b31..288e6567ceb1 100644 --- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c +++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c @@ -789,7 +789,7 @@ static const struct samsung_pin_bank_data s3c64xx_pin_banks0[] __initconst = { * Samsung pinctrl driver data for S3C64xx SoC. S3C64xx SoC includes * one gpio/pin-mux/pinconfig controller. */ -const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = { +static const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = { { /* pin-controller instance 1 data */ .pin_banks = s3c64xx_pin_banks0, @@ -798,3 +798,8 @@ const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = { .eint_wkup_init = s3c64xx_eint_eint0_init, }, }; + +const struct samsung_pinctrl_of_match_data s3c64xx_of_data __initconst = { + .ctrl = s3c64xx_pin_ctrl, + .num_ctrl = ARRAY_SIZE(s3c64xx_pin_ctrl), +}; diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index da58e4554137..336e88d7bdb9 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -942,12 +942,33 @@ static int samsung_gpiolib_register(struct platform_device *pdev, return 0; } +static const struct samsung_pin_ctrl * +samsung_pinctrl_get_soc_data_for_of_alias(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + const struct samsung_pinctrl_of_match_data *of_data; + int id; + + id = of_alias_get_id(node, "pinctrl"); + if (id < 0) { + dev_err(&pdev->dev, "failed to get alias id\n"); + return NULL; + } + + of_data = of_device_get_match_data(&pdev->dev); + if (id >= of_data->num_ctrl) { + dev_err(&pdev->dev, "invalid alias id %d\n", id); + return NULL; + } + + return &(of_data->ctrl[id]); +} + /* retrieve the soc specific data */ static const struct samsung_pin_ctrl * samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d, struct platform_device *pdev) { - int id; struct device_node *node = pdev->dev.of_node; struct device_node *np; const struct samsung_pin_bank_data *bdata; @@ -957,13 +978,9 @@ samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d, void __iomem *virt_base[SAMSUNG_PINCTRL_NUM_RESOURCES]; unsigned int i; - id = of_alias_get_id(node, "pinctrl"); - if (id < 0) { - dev_err(&pdev->dev, "failed to get alias id\n"); + ctrl = samsung_pinctrl_get_soc_data_for_of_alias(pdev); + if (!ctrl) return ERR_PTR(-ENOENT); - } - ctrl = of_device_get_match_data(&pdev->dev); - ctrl += id; d->suspend = ctrl->suspend; d->resume = ctrl->resume; @@ -1188,41 +1205,41 @@ static int __maybe_unused samsung_pinctrl_resume(struct device *dev) static const struct of_device_id samsung_pinctrl_dt_match[] = { #ifdef CONFIG_PINCTRL_EXYNOS_ARM { .compatible = "samsung,exynos3250-pinctrl", - .data = exynos3250_pin_ctrl }, + .data = &exynos3250_of_data }, { .compatible = "samsung,exynos4210-pinctrl", - .data = exynos4210_pin_ctrl }, + .data = &exynos4210_of_data }, { .compatible = "samsung,exynos4x12-pinctrl", - .data = exynos4x12_pin_ctrl }, + .data = &exynos4x12_of_data }, { .compatible = "samsung,exynos5250-pinctrl", - .data = exynos5250_pin_ctrl }, + .data = &exynos5250_of_data }, { .compatible = "samsung,exynos5260-pinctrl", - .data = exynos5260_pin_ctrl }, + .data = &exynos5260_of_data }, { .compatible = "samsung,exynos5410-pinctrl", - .data = exynos5410_pin_ctrl }, + .data = &exynos5410_of_data }, { .compatible = "samsung,exynos5420-pinctrl", - .data = exynos5420_pin_ctrl }, + .data = &exynos5420_of_data }, { .compatible = "samsung,s5pv210-pinctrl", - .data = s5pv210_pin_ctrl }, + .data = &s5pv210_of_data }, #endif #ifdef CONFIG_PINCTRL_EXYNOS_ARM64 { .compatible = "samsung,exynos5433-pinctrl", - .data = exynos5433_pin_ctrl }, + .data = &exynos5433_of_data }, { .compatible = "samsung,exynos7-pinctrl", - .data = exynos7_pin_ctrl }, + .data = &exynos7_of_data }, #endif #ifdef CONFIG_PINCTRL_S3C64XX { .compatible = "samsung,s3c64xx-pinctrl", - .data = s3c64xx_pin_ctrl }, + .data = &s3c64xx_of_data }, #endif #ifdef CONFIG_PINCTRL_S3C24XX { .compatible = "samsung,s3c2412-pinctrl", - .data = s3c2412_pin_ctrl }, + .data = &s3c2412_of_data }, { .compatible = "samsung,s3c2416-pinctrl", - .data = s3c2416_pin_ctrl }, + .data = &s3c2416_of_data }, { .compatible = "samsung,s3c2440-pinctrl", - .data = s3c2440_pin_ctrl }, + .data = &s3c2440_of_data }, { .compatible = "samsung,s3c2450-pinctrl", - .data = s3c2450_pin_ctrl }, + .data = &s3c2450_of_data }, #endif {}, }; diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h index e204f609823b..f0cda9424dfe 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.h +++ b/drivers/pinctrl/samsung/pinctrl-samsung.h @@ -281,6 +281,16 @@ struct samsung_pinctrl_drv_data { void (*resume)(struct samsung_pinctrl_drv_data *); }; +/** + * struct samsung_pinctrl_of_match_data: OF match device specific configuration data. + * @ctrl: array of pin controller data. + * @num_ctrl: size of array @ctrl. + */ +struct samsung_pinctrl_of_match_data { + const struct samsung_pin_ctrl *ctrl; + unsigned int num_ctrl; +}; + /** * struct samsung_pin_group: represent group of pins of a pinmux function. * @name: name of the pin group, used to lookup the group. @@ -309,20 +319,20 @@ struct samsung_pmx_func { }; /* list of all exported SoC specific data */ -extern const struct samsung_pin_ctrl exynos3250_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos4210_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos4x12_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos5250_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos5260_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos5410_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos5420_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos5433_pin_ctrl[]; -extern const struct samsung_pin_ctrl exynos7_pin_ctrl[]; -extern const struct samsung_pin_ctrl s3c64xx_pin_ctrl[]; -extern const struct samsung_pin_ctrl s3c2412_pin_ctrl[]; -extern const struct samsung_pin_ctrl s3c2416_pin_ctrl[]; -extern const struct samsung_pin_ctrl s3c2440_pin_ctrl[]; -extern const struct samsung_pin_ctrl s3c2450_pin_ctrl[]; -extern const struct samsung_pin_ctrl s5pv210_pin_ctrl[]; +extern const struct samsung_pinctrl_of_match_data exynos3250_of_data; +extern const struct samsung_pinctrl_of_match_data exynos4210_of_data; +extern const struct samsung_pinctrl_of_match_data exynos4x12_of_data; +extern const struct samsung_pinctrl_of_match_data exynos5250_of_data; +extern const struct samsung_pinctrl_of_match_data exynos5260_of_data; +extern const struct samsung_pinctrl_of_match_data exynos5410_of_data; +extern const struct samsung_pinctrl_of_match_data exynos5420_of_data; +extern const struct samsung_pinctrl_of_match_data exynos5433_of_data; +extern const struct samsung_pinctrl_of_match_data exynos7_of_data; +extern const struct samsung_pinctrl_of_match_data s3c64xx_of_data; +extern const struct samsung_pinctrl_of_match_data s3c2412_of_data; +extern const struct samsung_pinctrl_of_match_data s3c2416_of_data; +extern const struct samsung_pinctrl_of_match_data s3c2440_of_data; +extern const struct samsung_pinctrl_of_match_data s3c2450_of_data; +extern const struct samsung_pinctrl_of_match_data s5pv210_of_data; #endif /* __PINCTRL_SAMSUNG_H */ From 0338753a57aaf331cb7016bbfdba6086bf93149c Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 8 Mar 2018 14:32:49 +0100 Subject: [PATCH 535/942] ASoC: cygnus: remove redundant assignment to pointer 'res' The pointer res is being initialized with a value that is never read and re-assigned immediately after, hence the initialization is redundant and can be removed. Cleans up clang warning: sound/soc/bcm/cygnus-ssp.c:1284:19: warning: Value stored to 'res' during its initialization is never read Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/bcm/cygnus-ssp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c index abafadc0b534..b733f1446353 100644 --- a/sound/soc/bcm/cygnus-ssp.c +++ b/sound/soc/bcm/cygnus-ssp.c @@ -1281,7 +1281,7 @@ static int cygnus_ssp_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *child_node; - struct resource *res = pdev->resource; + struct resource *res; struct cygnus_audio *cygaud; int err = -EINVAL; int node_count; From d9e575127b4169061d94c9982c4f0e8aae208c78 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 7 Mar 2018 18:46:25 +0100 Subject: [PATCH 536/942] ASoC: Use proper DT compatible string for Hardkernel Odroid boards The Odroid boards are manufactured by Hardkernel, not Samsung. New compatible string entries are added, with "hardkernel," instead of "samsung," vendor prefix. Support for the old compatible strings is going to be removed after some time. Signed-off-by: Sylwester Nawrocki Reviewed-by: Rob Herring Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/samsung,odroid.txt | 6 +++--- sound/soc/samsung/odroid.c | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/samsung,odroid.txt b/Documentation/devicetree/bindings/sound/samsung,odroid.txt index 625b1b18fd02..f35a2694eb04 100644 --- a/Documentation/devicetree/bindings/sound/samsung,odroid.txt +++ b/Documentation/devicetree/bindings/sound/samsung,odroid.txt @@ -2,8 +2,8 @@ Samsung Exynos Odroid XU3/XU4 audio complex with MAX98090 codec Required properties: - - compatible - "samsung,odroidxu3-audio" - for Odroid XU3 board, - "samsung,odroidxu4-audio" - for Odroid XU4 board + - compatible - "hardkernel,odroid-xu3-audio" - for Odroid XU3 board, + "hardkernel,odroid-xu4-audio" - for Odroid XU4 board - model - the user-visible name of this sound complex - clocks - should contain entries matching clock names in the clock-names property @@ -35,7 +35,7 @@ Required sub-nodes: Example: sound { - compatible = "samsung,odroidxu3-audio"; + compatible = "hardkernel,odroid-xu3-audio"; model = "Odroid-XU3"; samsung,audio-routing = "Headphone Jack", "HPL", diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index 44b6de5a331a..92d750806d1d 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -213,8 +213,10 @@ static int odroid_audio_remove(struct platform_device *pdev) } static const struct of_device_id odroid_audio_of_match[] = { + { .compatible = "hardkernel,odroid-xu3-audio" }, + { .compatible = "hardkernel,odroid-xu4-audio" }, { .compatible = "samsung,odroid-xu3-audio" }, - { .compatible = "samsung,odroid-xu4-audio"}, + { .compatible = "samsung,odroid-xu4-audio" }, { }, }; MODULE_DEVICE_TABLE(of, odroid_audio_of_match); From cbcc607e18422555db569b593608aec26111cb0b Mon Sep 17 00:00:00 2001 From: Arkadi Sharshevsky Date: Thu, 8 Mar 2018 12:42:10 +0200 Subject: [PATCH 537/942] team: Fix double free in error path The __send_and_alloc_skb() receives a skb ptr as a parameter but in case it fails the skb is not valid: - Send failed and released the skb internally. - Allocation failed. The current code tries to release the skb in case of failure which causes redundant freeing. Fixes: 9b00cf2d1024 ("team: implement multipart netlink messages for options transfers") Signed-off-by: Arkadi Sharshevsky Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/team/team.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index a468439969df..56c701b73c12 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c @@ -2395,7 +2395,7 @@ send_done: if (!nlh) { err = __send_and_alloc_skb(&skb, team, portid, send_func); if (err) - goto errout; + return err; goto send_done; } @@ -2681,7 +2681,7 @@ send_done: if (!nlh) { err = __send_and_alloc_skb(&skb, team, portid, send_func); if (err) - goto errout; + return err; goto send_done; } From 3d07e0746fbbbe107e611d35719c009742e21b94 Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Thu, 8 Mar 2018 23:34:35 +1100 Subject: [PATCH 538/942] docs: segmentation-offloads.txt: Correct TCP gso_types Pretty minor: just SKB_GSO_TCP -> SKB_GSO_TCPV4 and SKB_GSO_TCP6 -> SKB_GSO_TCPV6. Signed-off-by: Daniel Axtens Signed-off-by: David S. Miller --- Documentation/networking/segmentation-offloads.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/segmentation-offloads.txt b/Documentation/networking/segmentation-offloads.txt index 23a8dd91a9ec..fc0c949e7f9c 100644 --- a/Documentation/networking/segmentation-offloads.txt +++ b/Documentation/networking/segmentation-offloads.txt @@ -20,8 +20,8 @@ TCP Segmentation Offload TCP segmentation allows a device to segment a single frame into multiple frames with a data payload size specified in skb_shinfo()->gso_size. -When TCP segmentation requested the bit for either SKB_GSO_TCP or -SKB_GSO_TCP6 should be set in skb_shinfo()->gso_type and +When TCP segmentation requested the bit for either SKB_GSO_TCPV4 or +SKB_GSO_TCPV6 should be set in skb_shinfo()->gso_type and skb_shinfo()->gso_size should be set to a non-zero value. TCP segmentation is dependent on support for the use of partial checksum From 97ef0faf575e03b352553f92c9430cb4c0431436 Mon Sep 17 00:00:00 2001 From: Mathias Nyman Date: Thu, 8 Mar 2018 17:17:14 +0200 Subject: [PATCH 539/942] xhci: fix endpoint context tracer output Fix incorrent values showed for max Primary stream and Linear stream array (LSA) values in the endpoint context decoder. Fixes: 19a7d0d65c4a ("usb: host: xhci: add Slot and EP Context tracers") Cc: # v4.12+ Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index e4d7d3d06a75..d20e57b35d32 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -718,11 +718,12 @@ struct xhci_ep_ctx { /* bits 10:14 are Max Primary Streams */ /* bit 15 is Linear Stream Array */ /* Interval - period between requests to an endpoint - 125u increments. */ -#define EP_INTERVAL(p) (((p) & 0xff) << 16) -#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) -#define CTX_TO_EP_INTERVAL(p) (((p) >> 16) & 0xff) -#define EP_MAXPSTREAMS_MASK (0x1f << 10) -#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) +#define EP_INTERVAL(p) (((p) & 0xff) << 16) +#define EP_INTERVAL_TO_UFRAMES(p) (1 << (((p) >> 16) & 0xff)) +#define CTX_TO_EP_INTERVAL(p) (((p) >> 16) & 0xff) +#define EP_MAXPSTREAMS_MASK (0x1f << 10) +#define EP_MAXPSTREAMS(p) (((p) << 10) & EP_MAXPSTREAMS_MASK) +#define CTX_TO_EP_MAXPSTREAMS(p) (((p) & EP_MAXPSTREAMS_MASK) >> 10) /* Endpoint is set up with a Linear Stream Array (vs. Secondary Stream Array) */ #define EP_HAS_LSA (1 << 15) /* hosts with LEC=1 use bits 31:24 as ESIT high bits. */ @@ -2549,21 +2550,22 @@ static inline const char *xhci_decode_ep_context(u32 info, u32 info2, u64 deq, u8 burst; u8 cerr; u8 mult; - u8 lsa; - u8 hid; + + bool lsa; + bool hid; esit = CTX_TO_MAX_ESIT_PAYLOAD_HI(info) << 16 | CTX_TO_MAX_ESIT_PAYLOAD(tx_info); ep_state = info & EP_STATE_MASK; - max_pstr = info & EP_MAXPSTREAMS_MASK; + max_pstr = CTX_TO_EP_MAXPSTREAMS(info); interval = CTX_TO_EP_INTERVAL(info); mult = CTX_TO_EP_MULT(info) + 1; - lsa = info & EP_HAS_LSA; + lsa = !!(info & EP_HAS_LSA); cerr = (info2 & (3 << 1)) >> 1; ep_type = CTX_TO_EP_TYPE(info2); - hid = info2 & (1 << 7); + hid = !!(info2 & (1 << 7)); burst = CTX_TO_MAX_BURST(info2); maxp = MAX_PACKET_DECODED(info2); From a098dc8b03d1c7284ed98d921224fffa15b13ece Mon Sep 17 00:00:00 2001 From: Lu Baolu Date: Thu, 8 Mar 2018 17:17:15 +0200 Subject: [PATCH 540/942] usb: xhci: dbc: Fix lockdep warning The xHCI DbC implementation might enter a deadlock situation because there is no sufficient protection against the shared data between process and softirq contexts. This can lead to the following lockdep warnings. This patch changes to use spin_{,un}lock_irq{save,restore} to avoid potential deadlock. [ 528.248084] ================================ [ 528.252914] WARNING: inconsistent lock state [ 528.257756] 4.15.0-rc1+ #1630 Not tainted [ 528.262305] -------------------------------- [ 528.267145] inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. [ 528.273953] ksoftirqd/1/17 [HC0[0]:SC1[1]:HE0:SE0] takes: [ 528.280075] (&(&port->port_lock)->rlock){+.?.}, at: [] dbc_rx_push+0x38/0x1c0 [ 528.290043] {SOFTIRQ-ON-W} state was registered at: [ 528.295570] _raw_spin_lock+0x2f/0x40 [ 528.299818] dbc_write_complete+0x27/0xa0 [ 528.304458] xhci_dbc_giveback+0xd1/0x200 [ 528.309098] xhci_dbc_flush_endpoint_requests+0x50/0x70 [ 528.315116] xhci_dbc_handle_events+0x696/0x7b0 [ 528.320349] process_one_work+0x1ee/0x6e0 [ 528.324988] worker_thread+0x4a/0x430 [ 528.329236] kthread+0x13e/0x170 [ 528.332992] ret_from_fork+0x24/0x30 [ 528.337141] irq event stamp: 2861 [ 528.340897] hardirqs last enabled at (2860): [] tasklet_action+0x6a/0x250 [ 528.350460] hardirqs last disabled at (2861): [] _raw_spin_lock_irq+0xf/0x40 [ 528.360219] softirqs last enabled at (2852): [] __do_softirq+0x3dc/0x4f9 [ 528.369683] softirqs last disabled at (2857): [] run_ksoftirqd+0x1b/0x60 [ 528.379048] [ 528.379048] other info that might help us debug this: [ 528.386443] Possible unsafe locking scenario: [ 528.386443] [ 528.393150] CPU0 [ 528.395917] ---- [ 528.398687] lock(&(&port->port_lock)->rlock); [ 528.403821] [ 528.406786] lock(&(&port->port_lock)->rlock); [ 528.412116] [ 528.412116] *** DEADLOCK *** [ 528.412116] [ 528.418825] no locks held by ksoftirqd/1/17. [ 528.423662] [ 528.423662] stack backtrace: [ 528.428598] CPU: 1 PID: 17 Comm: ksoftirqd/1 Not tainted 4.15.0-rc1+ #1630 [ 528.436387] Call Trace: [ 528.439158] dump_stack+0x5e/0x8e [ 528.442914] print_usage_bug+0x1fc/0x220 [ 528.447357] mark_lock+0x4db/0x5a0 [ 528.451210] __lock_acquire+0x726/0x1130 [ 528.455655] ? __lock_acquire+0x557/0x1130 [ 528.460296] lock_acquire+0xa2/0x200 [ 528.464347] ? dbc_rx_push+0x38/0x1c0 [ 528.468496] _raw_spin_lock_irq+0x35/0x40 [ 528.473038] ? dbc_rx_push+0x38/0x1c0 [ 528.477186] dbc_rx_push+0x38/0x1c0 [ 528.481139] tasklet_action+0x1d2/0x250 [ 528.485483] __do_softirq+0x1dc/0x4f9 [ 528.489630] run_ksoftirqd+0x1b/0x60 [ 528.493682] smpboot_thread_fn+0x179/0x270 [ 528.498324] kthread+0x13e/0x170 [ 528.501981] ? sort_range+0x20/0x20 [ 528.505933] ? kthread_delayed_work_timer_fn+0x80/0x80 [ 528.511755] ret_from_fork+0x24/0x30 Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver") Signed-off-by: Lu Baolu Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-dbgcap.c | 20 ++++++++++++-------- drivers/usb/host/xhci-dbgtty.c | 20 ++++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index a1ab8acf39ba..c359bae7b754 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -328,13 +328,14 @@ dbc_ep_do_queue(struct dbc_ep *dep, struct dbc_request *req) int dbc_ep_queue(struct dbc_ep *dep, struct dbc_request *req, gfp_t gfp_flags) { + unsigned long flags; struct xhci_dbc *dbc = dep->dbc; int ret = -ESHUTDOWN; - spin_lock(&dbc->lock); + spin_lock_irqsave(&dbc->lock, flags); if (dbc->state == DS_CONFIGURED) ret = dbc_ep_do_queue(dep, req); - spin_unlock(&dbc->lock); + spin_unlock_irqrestore(&dbc->lock, flags); mod_delayed_work(system_wq, &dbc->event_work, 0); @@ -521,15 +522,16 @@ static void xhci_do_dbc_stop(struct xhci_hcd *xhci) static int xhci_dbc_start(struct xhci_hcd *xhci) { int ret; + unsigned long flags; struct xhci_dbc *dbc = xhci->dbc; WARN_ON(!dbc); pm_runtime_get_sync(xhci_to_hcd(xhci)->self.controller); - spin_lock(&dbc->lock); + spin_lock_irqsave(&dbc->lock, flags); ret = xhci_do_dbc_start(xhci); - spin_unlock(&dbc->lock); + spin_unlock_irqrestore(&dbc->lock, flags); if (ret) { pm_runtime_put(xhci_to_hcd(xhci)->self.controller); @@ -541,6 +543,7 @@ static int xhci_dbc_start(struct xhci_hcd *xhci) static void xhci_dbc_stop(struct xhci_hcd *xhci) { + unsigned long flags; struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; @@ -551,9 +554,9 @@ static void xhci_dbc_stop(struct xhci_hcd *xhci) if (port->registered) xhci_dbc_tty_unregister_device(xhci); - spin_lock(&dbc->lock); + spin_lock_irqsave(&dbc->lock, flags); xhci_do_dbc_stop(xhci); - spin_unlock(&dbc->lock); + spin_unlock_irqrestore(&dbc->lock, flags); pm_runtime_put_sync(xhci_to_hcd(xhci)->self.controller); } @@ -779,14 +782,15 @@ static void xhci_dbc_handle_events(struct work_struct *work) int ret; enum evtreturn evtr; struct xhci_dbc *dbc; + unsigned long flags; struct xhci_hcd *xhci; dbc = container_of(to_delayed_work(work), struct xhci_dbc, event_work); xhci = dbc->xhci; - spin_lock(&dbc->lock); + spin_lock_irqsave(&dbc->lock, flags); evtr = xhci_dbc_do_handle_events(dbc); - spin_unlock(&dbc->lock); + spin_unlock_irqrestore(&dbc->lock, flags); switch (evtr) { case EVT_GSER: diff --git a/drivers/usb/host/xhci-dbgtty.c b/drivers/usb/host/xhci-dbgtty.c index 8d47b6fbf973..75f0b92694ba 100644 --- a/drivers/usb/host/xhci-dbgtty.c +++ b/drivers/usb/host/xhci-dbgtty.c @@ -92,21 +92,23 @@ static void dbc_start_rx(struct dbc_port *port) static void dbc_read_complete(struct xhci_hcd *xhci, struct dbc_request *req) { + unsigned long flags; struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; - spin_lock(&port->port_lock); + spin_lock_irqsave(&port->port_lock, flags); list_add_tail(&req->list_pool, &port->read_queue); tasklet_schedule(&port->push); - spin_unlock(&port->port_lock); + spin_unlock_irqrestore(&port->port_lock, flags); } static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req) { + unsigned long flags; struct xhci_dbc *dbc = xhci->dbc; struct dbc_port *port = &dbc->port; - spin_lock(&port->port_lock); + spin_lock_irqsave(&port->port_lock, flags); list_add(&req->list_pool, &port->write_pool); switch (req->status) { case 0: @@ -119,7 +121,7 @@ static void dbc_write_complete(struct xhci_hcd *xhci, struct dbc_request *req) req->status); break; } - spin_unlock(&port->port_lock); + spin_unlock_irqrestore(&port->port_lock, flags); } static void xhci_dbc_free_req(struct dbc_ep *dep, struct dbc_request *req) @@ -327,12 +329,13 @@ static void dbc_rx_push(unsigned long _port) { struct dbc_request *req; struct tty_struct *tty; + unsigned long flags; bool do_push = false; bool disconnect = false; struct dbc_port *port = (void *)_port; struct list_head *queue = &port->read_queue; - spin_lock_irq(&port->port_lock); + spin_lock_irqsave(&port->port_lock, flags); tty = port->port.tty; while (!list_empty(queue)) { req = list_first_entry(queue, struct dbc_request, list_pool); @@ -392,16 +395,17 @@ static void dbc_rx_push(unsigned long _port) if (!disconnect) dbc_start_rx(port); - spin_unlock_irq(&port->port_lock); + spin_unlock_irqrestore(&port->port_lock, flags); } static int dbc_port_activate(struct tty_port *_port, struct tty_struct *tty) { + unsigned long flags; struct dbc_port *port = container_of(_port, struct dbc_port, port); - spin_lock_irq(&port->port_lock); + spin_lock_irqsave(&port->port_lock, flags); dbc_start_rx(port); - spin_unlock_irq(&port->port_lock); + spin_unlock_irqrestore(&port->port_lock, flags); return 0; } From de3d50aadd40bf68614db9fd157b275ce9c2d467 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 7 Mar 2018 13:49:09 -0800 Subject: [PATCH 541/942] hv_netvsc: fix filter flags The recent change to not always enable all multicast and broadcast was broken; meant to set filter, not change flags. Fixes: 009f766ca238 ("hv_netvsc: filter multicast/broadcast") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/rndis_filter.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 8927c483c217..411a3aee39b2 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -861,9 +861,9 @@ static void rndis_set_multicast(struct work_struct *w) filter = NDIS_PACKET_TYPE_PROMISCUOUS; } else { if (flags & IFF_ALLMULTI) - flags |= NDIS_PACKET_TYPE_ALL_MULTICAST; + filter |= NDIS_PACKET_TYPE_ALL_MULTICAST; if (flags & IFF_BROADCAST) - flags |= NDIS_PACKET_TYPE_BROADCAST; + filter |= NDIS_PACKET_TYPE_BROADCAST; } rndis_filter_set_packet_filter(rdev, filter); From 7eeb4a6ee4820c4e84895d252079a797f27fc80d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 7 Mar 2018 13:49:10 -0800 Subject: [PATCH 542/942] hv_netvsc: avoid repeated updates of packet filter The netvsc driver can get repeated calls to netvsc_rx_mode during network setup; each of these calls ends up scheduling the lower layers to update tha packet filter. This update requires an request/response to the host. So avoid doing this if we already know that the correct packet filter value is set. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/hyperv_net.h | 1 + drivers/net/hyperv/rndis_filter.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 0db3bd1ea06f..cd538d5a7986 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -173,6 +173,7 @@ struct rndis_device { struct list_head req_list; struct work_struct mcast_work; + u32 filter; bool link_state; /* 0 - link up, 1 - link down */ diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 411a3aee39b2..00ec80c23fe5 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -825,13 +825,15 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, struct rndis_set_request *set; int ret; + if (dev->filter == new_filter) + return 0; + request = get_rndis_request(dev, RNDIS_MSG_SET, RNDIS_MESSAGE_SIZE(struct rndis_set_request) + sizeof(u32)); if (!request) return -ENOMEM; - /* Setup the rndis set */ set = &request->request_msg.msg.set_req; set->oid = RNDIS_OID_GEN_CURRENT_PACKET_FILTER; @@ -842,8 +844,10 @@ static int rndis_filter_set_packet_filter(struct rndis_device *dev, &new_filter, sizeof(u32)); ret = rndis_filter_send_request(dev, request); - if (ret == 0) + if (ret == 0) { wait_for_completion(&request->wait_event); + dev->filter = new_filter; + } put_rndis_request(dev, request); From 35a57b7fef136fa3d5b735ba773f191b95110fa0 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 7 Mar 2018 13:49:11 -0800 Subject: [PATCH 543/942] hv_netvsc: fix locking for rx_mode The rx_mode operation handler is different than other callbacks in that is not always called with rtnl held. Therefore use RCU to ensure that references are valid. Fixes: bee9d41b37ea ("hv_netvsc: propagate rx filters to VF") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc_drv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index cdb78eefab67..48d9fa7a66c2 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -89,15 +89,20 @@ static void netvsc_change_rx_flags(struct net_device *net, int change) static void netvsc_set_rx_mode(struct net_device *net) { struct net_device_context *ndev_ctx = netdev_priv(net); - struct net_device *vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev); - struct netvsc_device *nvdev = rtnl_dereference(ndev_ctx->nvdev); + struct net_device *vf_netdev; + struct netvsc_device *nvdev; + rcu_read_lock(); + vf_netdev = rcu_dereference(ndev_ctx->vf_netdev); if (vf_netdev) { dev_uc_sync(vf_netdev, net); dev_mc_sync(vf_netdev, net); } - rndis_filter_update(nvdev); + nvdev = rcu_dereference(ndev_ctx->nvdev); + if (nvdev) + rndis_filter_update(nvdev); + rcu_read_unlock(); } static int netvsc_open(struct net_device *net) From b0dee7910317f41f398838992516af6a3b981d86 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 7 Mar 2018 13:49:12 -0800 Subject: [PATCH 544/942] hv_netvsc: fix locking during VF setup The dev_uc/mc_sync calls need to have the device address list locked. This was spotted by running with lockdep enabled. Fixes: bee9d41b37ea ("hv_netvsc: propagate rx filters to VF") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc_drv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 48d9fa7a66c2..faea0be18924 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1851,8 +1851,12 @@ static void __netvsc_vf_setup(struct net_device *ndev, /* set multicast etc flags on VF */ dev_change_flags(vf_netdev, ndev->flags | IFF_SLAVE); + + /* sync address list from ndev to VF */ + netif_addr_lock_bh(ndev); dev_uc_sync(vf_netdev, ndev); dev_mc_sync(vf_netdev, ndev); + netif_addr_unlock_bh(ndev); if (netif_running(ndev)) { ret = dev_open(vf_netdev); From d9ee65539d3eabd9ade46cca1780e3309ad0f907 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Tue, 6 Mar 2018 12:47:08 -0500 Subject: [PATCH 545/942] NFS: Fix an incorrect type in struct nfs_direct_req The start offset needs to be of type loff_t. Fixed: 5fadeb47dcc5c ("nfs: count DIO good bytes correctly with mirroring") Cc: stable@vger.kernel.org # v4.0+ Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 8c10b0562e75..621c517b325c 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -86,10 +86,10 @@ struct nfs_direct_req { struct nfs_direct_mirror mirrors[NFS_PAGEIO_DESCRIPTOR_MIRROR_MAX]; int mirror_count; + loff_t io_start; /* Start offset for I/O */ ssize_t count, /* bytes actually processed */ max_count, /* max expected count */ bytes_left, /* bytes left to be sent */ - io_start, /* start of IO */ error; /* any reported error */ struct completion completion; /* wait for i/o completion */ From 9c6376ebddad585da4238532dd6d90ae23ffee67 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 7 Mar 2018 14:49:06 -0500 Subject: [PATCH 546/942] pNFS: Prevent the layout header refcount going to zero in pnfs_roc() Ensure that we hold a reference to the layout header when processing the pNFS return-on-close so that the refcount value does not inadvertently go to zero. Reported-by: Tigran Mkrtchyan Signed-off-by: Trond Myklebust Cc: stable@vger.kernel.org # v4.10+ Tested-by: Tigran Mkrtchyan --- fs/nfs/pnfs.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index c13e826614b5..ee723aa153a3 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -292,8 +292,11 @@ pnfs_detach_layout_hdr(struct pnfs_layout_hdr *lo) void pnfs_put_layout_hdr(struct pnfs_layout_hdr *lo) { - struct inode *inode = lo->plh_inode; + struct inode *inode; + if (!lo) + return; + inode = lo->plh_inode; pnfs_layoutreturn_before_put_layout_hdr(lo); if (refcount_dec_and_lock(&lo->plh_refcount, &inode->i_lock)) { @@ -1241,10 +1244,12 @@ retry: spin_lock(&ino->i_lock); lo = nfsi->layout; if (!lo || !pnfs_layout_is_valid(lo) || - test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) + test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags)) { + lo = NULL; goto out_noroc; + } + pnfs_get_layout_hdr(lo); if (test_bit(NFS_LAYOUT_RETURN_LOCK, &lo->plh_flags)) { - pnfs_get_layout_hdr(lo); spin_unlock(&ino->i_lock); wait_on_bit(&lo->plh_flags, NFS_LAYOUT_RETURN, TASK_UNINTERRUPTIBLE); @@ -1312,10 +1317,12 @@ out_noroc: struct pnfs_layoutdriver_type *ld = NFS_SERVER(ino)->pnfs_curr_ld; if (ld->prepare_layoutreturn) ld->prepare_layoutreturn(args); + pnfs_put_layout_hdr(lo); return true; } if (layoutreturn) pnfs_send_layoutreturn(lo, &stateid, iomode, true); + pnfs_put_layout_hdr(lo); return false; } From c4f24df942a181699c5bab01b8e5e82b925f77f3 Mon Sep 17 00:00:00 2001 From: Trond Myklebust Date: Wed, 7 Mar 2018 15:22:31 -0500 Subject: [PATCH 547/942] NFS: Fix unstable write completion We do want to respect the FLUSH_SYNC argument to nfs_commit_inode() to ensure that all outstanding COMMIT requests to the inode in question are complete. Currently we may exit early from both nfs_commit_inode() and nfs_write_inode() even if there are COMMIT requests in flight, or unstable writes on the commit list. In order to get the right semantics w.r.t. sync_inode(), we don't need to have nfs_commit_inode() reset the inode dirty flags when called from nfs_wb_page() and/or nfs_wb_all(). We just need to ensure that nfs_write_inode() leaves them in the right state if there are outstanding commits, or stable pages. Reported-by: Scott Mayhew Fixes: dc4fd9ab01ab ("nfs: don't wait on commit in nfs_commit_inode()...") Cc: stable@vger.kernel.org # v4.14+ Signed-off-by: Trond Myklebust --- fs/nfs/write.c | 83 ++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 40 deletions(-) diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 7428a669d7a7..e7d8ceae8f26 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1876,40 +1876,43 @@ int nfs_generic_commit_list(struct inode *inode, struct list_head *head, return status; } -int nfs_commit_inode(struct inode *inode, int how) +static int __nfs_commit_inode(struct inode *inode, int how, + struct writeback_control *wbc) { LIST_HEAD(head); struct nfs_commit_info cinfo; int may_wait = how & FLUSH_SYNC; - int error = 0; - int res; + int ret, nscan; nfs_init_cinfo_from_inode(&cinfo, inode); nfs_commit_begin(cinfo.mds); - res = nfs_scan_commit(inode, &head, &cinfo); - if (res) - error = nfs_generic_commit_list(inode, &head, how, &cinfo); + for (;;) { + ret = nscan = nfs_scan_commit(inode, &head, &cinfo); + if (ret <= 0) + break; + ret = nfs_generic_commit_list(inode, &head, how, &cinfo); + if (ret < 0) + break; + ret = 0; + if (wbc && wbc->sync_mode == WB_SYNC_NONE) { + if (nscan < wbc->nr_to_write) + wbc->nr_to_write -= nscan; + else + wbc->nr_to_write = 0; + } + if (nscan < INT_MAX) + break; + cond_resched(); + } nfs_commit_end(cinfo.mds); - if (res == 0) - return res; - if (error < 0) - goto out_error; - if (!may_wait) - goto out_mark_dirty; - error = wait_on_commit(cinfo.mds); - if (error < 0) - return error; - return res; -out_error: - res = error; - /* Note: If we exit without ensuring that the commit is complete, - * we must mark the inode as dirty. Otherwise, future calls to - * sync_inode() with the WB_SYNC_ALL flag set will fail to ensure - * that the data is on the disk. - */ -out_mark_dirty: - __mark_inode_dirty(inode, I_DIRTY_DATASYNC); - return res; + if (ret || !may_wait) + return ret; + return wait_on_commit(cinfo.mds); +} + +int nfs_commit_inode(struct inode *inode, int how) +{ + return __nfs_commit_inode(inode, how, NULL); } EXPORT_SYMBOL_GPL(nfs_commit_inode); @@ -1919,11 +1922,11 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc) int flags = FLUSH_SYNC; int ret = 0; - /* no commits means nothing needs to be done */ - if (!atomic_long_read(&nfsi->commit_info.ncommit)) - return ret; - if (wbc->sync_mode == WB_SYNC_NONE) { + /* no commits means nothing needs to be done */ + if (!atomic_long_read(&nfsi->commit_info.ncommit)) + goto check_requests_outstanding; + /* Don't commit yet if this is a non-blocking flush and there * are a lot of outstanding writes for this mapping. */ @@ -1934,16 +1937,16 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc) flags = 0; } - ret = nfs_commit_inode(inode, flags); - if (ret >= 0) { - if (wbc->sync_mode == WB_SYNC_NONE) { - if (ret < wbc->nr_to_write) - wbc->nr_to_write -= ret; - else - wbc->nr_to_write = 0; - } - return 0; - } + ret = __nfs_commit_inode(inode, flags, wbc); + if (!ret) { + if (flags & FLUSH_SYNC) + return 0; + } else if (atomic_long_read(&nfsi->commit_info.ncommit)) + goto out_mark_dirty; + +check_requests_outstanding: + if (!atomic_read(&nfsi->commit_info.rpcs_out)) + return ret; out_mark_dirty: __mark_inode_dirty(inode, I_DIRTY_DATASYNC); return ret; From 5126a504b63d82785eaece3a9c30c660b313785a Mon Sep 17 00:00:00 2001 From: Teijo Kinnunen Date: Thu, 1 Mar 2018 19:34:29 +0200 Subject: [PATCH 548/942] USB: storage: Add JMicron bridge 152d:2567 to unusual_devs.h This USB-SATA controller seems to be similar with JMicron bridge 152d:2566 already on the list. Adding it here fixes "Invalid field in cdb" errors. Signed-off-by: Teijo Kinnunen Cc: stable@vger.kernel.org Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/storage/unusual_devs.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index 264af199aec8..747d3a9596d9 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h @@ -2118,6 +2118,13 @@ UNUSUAL_DEV( 0x152d, 0x2566, 0x0114, 0x0114, USB_SC_DEVICE, USB_PR_DEVICE, NULL, US_FL_BROKEN_FUA ), +/* Reported by Teijo Kinnunen */ +UNUSUAL_DEV( 0x152d, 0x2567, 0x0117, 0x0117, + "JMicron", + "USB to ATA/ATAPI Bridge", + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_BROKEN_FUA ), + /* Reported-by George Cherian */ UNUSUAL_DEV(0x152d, 0x9561, 0x0000, 0x9999, "JMicron", From 015dbeb2282030bf56762e21d25f09422edfd750 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Tue, 27 Feb 2018 17:15:20 +0900 Subject: [PATCH 549/942] usb: host: xhci-rcar: add support for r8a77965 This patch adds support for r8a77965 (R-Car M3-N). Signed-off-by: Yoshihiro Shimoda Reviewed-by: Simon Horman Reviewed-by: Rob Herring Cc: stable Signed-off-by: Greg Kroah-Hartman --- Documentation/devicetree/bindings/usb/usb-xhci.txt | 1 + drivers/usb/host/xhci-rcar.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/usb/usb-xhci.txt b/Documentation/devicetree/bindings/usb/usb-xhci.txt index e2ea59bbca93..1651483a7048 100644 --- a/Documentation/devicetree/bindings/usb/usb-xhci.txt +++ b/Documentation/devicetree/bindings/usb/usb-xhci.txt @@ -13,6 +13,7 @@ Required properties: - "renesas,xhci-r8a7793" for r8a7793 SoC - "renesas,xhci-r8a7795" for r8a7795 SoC - "renesas,xhci-r8a7796" for r8a7796 SoC + - "renesas,xhci-r8a77965" for r8a77965 SoC - "renesas,rcar-gen2-xhci" for a generic R-Car Gen2 or RZ/G1 compatible device - "renesas,rcar-gen3-xhci" for a generic R-Car Gen3 compatible device diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index f0b559660007..f33ffc2bc4ed 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -83,6 +83,10 @@ static const struct soc_device_attribute rcar_quirks_match[] = { .soc_id = "r8a7796", .data = (void *)RCAR_XHCI_FIRMWARE_V3, }, + { + .soc_id = "r8a77965", + .data = (void *)RCAR_XHCI_FIRMWARE_V3, + }, { /* sentinel */ }, }; From 3f553b308bb004eb730da8e00a28150c157c7724 Mon Sep 17 00:00:00 2001 From: Leon Yu Date: Tue, 6 Mar 2018 23:16:24 +0800 Subject: [PATCH 550/942] module: propagate error in modules_open() otherwise kernel can oops later in seq_release() due to dereferencing null file->private_data which is only set if seq_open() succeeds. BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 IP: seq_release+0xc/0x30 Call Trace: close_pdeo+0x37/0xd0 proc_reg_release+0x5d/0x60 __fput+0x9d/0x1d0 ____fput+0x9/0x10 task_work_run+0x75/0x90 do_exit+0x252/0xa00 do_group_exit+0x36/0xb0 SyS_exit_group+0xf/0x10 Fixes: 516fb7f2e73d ("/proc/module: use the same logic as /proc/kallsyms for address exposure") Cc: Jessica Yu Cc: Linus Torvalds Cc: stable@vger.kernel.org # 4.15+ Signed-off-by: Leon Yu Signed-off-by: Jessica Yu --- kernel/module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/module.c b/kernel/module.c index ad2d420024f6..e42764acedb4 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -4228,7 +4228,7 @@ static int modules_open(struct inode *inode, struct file *file) m->private = kallsyms_show_value() ? NULL : (void *)8ul; } - return 0; + return err; } static const struct file_operations proc_modules_operations = { From f7e73b26aea58003931e2f3925d9c01f6b6c4c4d Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Fri, 9 Mar 2018 12:46:27 +0000 Subject: [PATCH 551/942] ASoC: core: Fix typo roup->group Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e1f047de599e..4cd32f1bceb4 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -221,14 +221,14 @@ static const struct attribute_group soc_dapm_dev_group = { .is_visible = soc_dev_attr_is_visible, }; -static const struct attribute_group soc_dev_roup = { +static const struct attribute_group soc_dev_group = { .attrs = soc_dev_attrs, .is_visible = soc_dev_attr_is_visible, }; static const struct attribute_group *soc_dev_attr_groups[] = { &soc_dapm_dev_group, - &soc_dev_roup, + &soc_dev_group, NULL }; From 641eea3f8b95a47d5e5db28dd92a0f586cd85390 Mon Sep 17 00:00:00 2001 From: Steven Eckhoff Date: Thu, 8 Mar 2018 21:13:40 -0600 Subject: [PATCH 552/942] ASoC: TSCS42xx: Add missing headers Add missing headers Signed-off-by: Steven Eckhoff Signed-off-by: Mark Brown --- sound/soc/codecs/tscs42xx.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c index e915261fa1cb..cfc71b5411ee 100644 --- a/sound/soc/codecs/tscs42xx.c +++ b/sound/soc/codecs/tscs42xx.c @@ -3,14 +3,19 @@ // Copyright 2017 Tempo Semiconductor, Inc. // Author: Steven Eckhoff -#include -#include -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include #include "tscs42xx.h" From b24881e0b0b69155b092c525b7fded258d78a46d Mon Sep 17 00:00:00 2001 From: Xiong Zhang Date: Mon, 26 Feb 2018 10:40:18 +0800 Subject: [PATCH 553/942] drm/i915/gvt: Add runtime_pm_get/put into gvt_switch_mmio If user continuously create vgpu, boot guest, shoutdown guest and destroy vgpu from remote, the following calltrace exists in dmesg sometimes: [ 6412.954721] RPM wakelock ref not held during HW access [ 6412.954795] WARNING: CPU: 7 PID: 11941 at linux/drivers/gpu/drm/i915/intel_drv.h:1800 intel_uncore_forcewake_get.part.7+0x96/0xa0 [i915] [ 6412.954915] Call Trace: [ 6412.954951] intel_uncore_forcewake_get+0x18/0x20 [i915] [ 6412.954989] intel_gvt_switch_mmio+0x8e/0x770 [i915] [ 6412.954996] ? __slab_free+0x14d/0x2c0 [ 6412.955001] ? __slab_free+0x14d/0x2c0 [ 6412.955006] ? __slab_free+0x14d/0x2c0 [ 6412.955041] intel_vgpu_stop_schedule+0x92/0xd0 [i915] [ 6412.955073] intel_gvt_deactivate_vgpu+0x48/0x60 [i915] [ 6412.955078] __intel_vgpu_release+0x55/0x260 [kvmgt] when this happens, gvt_switch_mmio is called at vgpu destroy, host i915 is idle and doesn't hold RPM wakelock, igd is in powersave mode, but gvt_switch_mmio require igd power on to access register, so intel_runtime_pm_get should be added to make sure igd power on before gvt_switch_mmio. v2: Move runtime_pm_get/put into gvt_switch_mmio.(Zhenyu) Signed-off-by: Xiong Zhang Signed-off-by: Zhi Wang --- drivers/gpu/drm/i915/gvt/mmio_context.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/i915/gvt/mmio_context.c b/drivers/gpu/drm/i915/gvt/mmio_context.c index 256f1bb522b7..152df3d0291e 100644 --- a/drivers/gpu/drm/i915/gvt/mmio_context.c +++ b/drivers/gpu/drm/i915/gvt/mmio_context.c @@ -394,9 +394,11 @@ void intel_gvt_switch_mmio(struct intel_vgpu *pre, * performace for batch mmio read/write, so we need * handle forcewake mannually. */ + intel_runtime_pm_get(dev_priv); intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL); switch_mmio(pre, next, ring_id); intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL); + intel_runtime_pm_put(dev_priv); } /** From fa3dd623e559e8e7004179f9594b090318df0d05 Mon Sep 17 00:00:00 2001 From: Min He Date: Fri, 2 Mar 2018 10:00:25 +0800 Subject: [PATCH 554/942] drm/i915/gvt: keep oa config in shadow ctx When populating shadow ctx from guest, we should handle oa related registers in hw ctx, so that they will not be overlapped by guest oa configs. This patch made it possible to capture oa data from host for both host and guests. Signed-off-by: Min He Signed-off-by: Zhi Wang --- drivers/gpu/drm/i915/gvt/scheduler.c | 50 ++++++++++++++++++++++++++++ drivers/gpu/drm/i915/gvt/scheduler.h | 4 +++ 2 files changed, 54 insertions(+) diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index b55b3580ca1d..8caf72c1e794 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c @@ -52,6 +52,54 @@ static void set_context_pdp_root_pointer( pdp_pair[i].val = pdp[7 - i]; } +/* + * when populating shadow ctx from guest, we should not overrride oa related + * registers, so that they will not be overlapped by guest oa configs. Thus + * made it possible to capture oa data from host for both host and guests. + */ +static void sr_oa_regs(struct intel_vgpu_workload *workload, + u32 *reg_state, bool save) +{ + struct drm_i915_private *dev_priv = workload->vgpu->gvt->dev_priv; + u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset; + u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset; + int i = 0; + u32 flex_mmio[] = { + i915_mmio_reg_offset(EU_PERF_CNTL0), + i915_mmio_reg_offset(EU_PERF_CNTL1), + i915_mmio_reg_offset(EU_PERF_CNTL2), + i915_mmio_reg_offset(EU_PERF_CNTL3), + i915_mmio_reg_offset(EU_PERF_CNTL4), + i915_mmio_reg_offset(EU_PERF_CNTL5), + i915_mmio_reg_offset(EU_PERF_CNTL6), + }; + + if (!workload || !reg_state || workload->ring_id != RCS) + return; + + if (save) { + workload->oactxctrl = reg_state[ctx_oactxctrl + 1]; + + for (i = 0; i < ARRAY_SIZE(workload->flex_mmio); i++) { + u32 state_offset = ctx_flexeu0 + i * 2; + + workload->flex_mmio[i] = reg_state[state_offset + 1]; + } + } else { + reg_state[ctx_oactxctrl] = + i915_mmio_reg_offset(GEN8_OACTXCONTROL); + reg_state[ctx_oactxctrl + 1] = workload->oactxctrl; + + for (i = 0; i < ARRAY_SIZE(workload->flex_mmio); i++) { + u32 state_offset = ctx_flexeu0 + i * 2; + u32 mmio = flex_mmio[i]; + + reg_state[state_offset] = mmio; + reg_state[state_offset + 1] = workload->flex_mmio[i]; + } + } +} + static int populate_shadow_context(struct intel_vgpu_workload *workload) { struct intel_vgpu *vgpu = workload->vgpu; @@ -98,6 +146,7 @@ static int populate_shadow_context(struct intel_vgpu_workload *workload) page = i915_gem_object_get_page(ctx_obj, LRC_STATE_PN); shadow_ring_context = kmap(page); + sr_oa_regs(workload, (u32 *)shadow_ring_context, true); #define COPY_REG(name) \ intel_gvt_hypervisor_read_gpa(vgpu, workload->ring_context_gpa \ + RING_CTX_OFF(name.val), &shadow_ring_context->name.val, 4) @@ -122,6 +171,7 @@ static int populate_shadow_context(struct intel_vgpu_workload *workload) sizeof(*shadow_ring_context), I915_GTT_PAGE_SIZE - sizeof(*shadow_ring_context)); + sr_oa_regs(workload, (u32 *)shadow_ring_context, false); kunmap(page); return 0; } diff --git a/drivers/gpu/drm/i915/gvt/scheduler.h b/drivers/gpu/drm/i915/gvt/scheduler.h index ff175a98b19e..2603336b7c6d 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.h +++ b/drivers/gpu/drm/i915/gvt/scheduler.h @@ -110,6 +110,10 @@ struct intel_vgpu_workload { /* shadow batch buffer */ struct list_head shadow_bb; struct intel_shadow_wa_ctx wa_ctx; + + /* oa registers */ + u32 oactxctrl; + u32 flex_mmio[7]; }; struct intel_vgpu_shadow_bb { From a5f596830e27e15f7a0ecd6be55e433d776986d8 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Fri, 9 Mar 2018 00:21:14 -0600 Subject: [PATCH 555/942] usb: usbmon: Read text within supplied buffer size This change fixes buffer overflows and silent data corruption with the usbmon device driver text file read operations. Signed-off-by: Fredrik Noring Signed-off-by: Pete Zaitcev Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mon/mon_text.c | 138 ++++++++++++++++++++++--------------- 1 file changed, 84 insertions(+), 54 deletions(-) diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index f5e1bb5e5217..984f7e12a6a5 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -85,6 +85,8 @@ struct mon_reader_text { wait_queue_head_t wait; int printf_size; + size_t printf_offset; + size_t printf_togo; char *printf_buf; struct mutex printf_lock; @@ -376,75 +378,103 @@ err_alloc: return rc; } -/* - * For simplicity, we read one record in one system call and throw out - * what does not fit. This means that the following does not work: - * dd if=/dbg/usbmon/0t bs=10 - * Also, we do not allow seeks and do not bother advancing the offset. - */ -static ssize_t mon_text_read_t(struct file *file, char __user *buf, - size_t nbytes, loff_t *ppos) +static ssize_t mon_text_copy_to_user(struct mon_reader_text *rp, + char __user * const buf, const size_t nbytes) { - struct mon_reader_text *rp = file->private_data; - struct mon_event_text *ep; - struct mon_text_ptr ptr; + const size_t togo = min(nbytes, rp->printf_togo); - ep = mon_text_read_wait(rp, file); - if (IS_ERR(ep)) - return PTR_ERR(ep); - mutex_lock(&rp->printf_lock); - ptr.cnt = 0; - ptr.pbuf = rp->printf_buf; - ptr.limit = rp->printf_size; - - mon_text_read_head_t(rp, &ptr, ep); - mon_text_read_statset(rp, &ptr, ep); - ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, - " %d", ep->length); - mon_text_read_data(rp, &ptr, ep); - - if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) - ptr.cnt = -EFAULT; - mutex_unlock(&rp->printf_lock); - kmem_cache_free(rp->e_slab, ep); - return ptr.cnt; + if (copy_to_user(buf, &rp->printf_buf[rp->printf_offset], togo)) + return -EFAULT; + rp->printf_togo -= togo; + rp->printf_offset += togo; + return togo; } -static ssize_t mon_text_read_u(struct file *file, char __user *buf, - size_t nbytes, loff_t *ppos) +/* ppos is not advanced since the llseek operation is not permitted. */ +static ssize_t mon_text_read_t(struct file *file, char __user *buf, + size_t nbytes, loff_t *ppos) { struct mon_reader_text *rp = file->private_data; struct mon_event_text *ep; struct mon_text_ptr ptr; + ssize_t ret; - ep = mon_text_read_wait(rp, file); - if (IS_ERR(ep)) - return PTR_ERR(ep); mutex_lock(&rp->printf_lock); - ptr.cnt = 0; - ptr.pbuf = rp->printf_buf; - ptr.limit = rp->printf_size; - mon_text_read_head_u(rp, &ptr, ep); - if (ep->type == 'E') { - mon_text_read_statset(rp, &ptr, ep); - } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) { - mon_text_read_isostat(rp, &ptr, ep); - mon_text_read_isodesc(rp, &ptr, ep); - } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) { - mon_text_read_intstat(rp, &ptr, ep); - } else { + if (rp->printf_togo == 0) { + + ep = mon_text_read_wait(rp, file); + if (IS_ERR(ep)) { + mutex_unlock(&rp->printf_lock); + return PTR_ERR(ep); + } + ptr.cnt = 0; + ptr.pbuf = rp->printf_buf; + ptr.limit = rp->printf_size; + + mon_text_read_head_t(rp, &ptr, ep); mon_text_read_statset(rp, &ptr, ep); + ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, + " %d", ep->length); + mon_text_read_data(rp, &ptr, ep); + + rp->printf_togo = ptr.cnt; + rp->printf_offset = 0; + + kmem_cache_free(rp->e_slab, ep); } - ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, - " %d", ep->length); - mon_text_read_data(rp, &ptr, ep); - if (copy_to_user(buf, rp->printf_buf, ptr.cnt)) - ptr.cnt = -EFAULT; + ret = mon_text_copy_to_user(rp, buf, nbytes); mutex_unlock(&rp->printf_lock); - kmem_cache_free(rp->e_slab, ep); - return ptr.cnt; + return ret; +} + +/* ppos is not advanced since the llseek operation is not permitted. */ +static ssize_t mon_text_read_u(struct file *file, char __user *buf, + size_t nbytes, loff_t *ppos) +{ + struct mon_reader_text *rp = file->private_data; + struct mon_event_text *ep; + struct mon_text_ptr ptr; + ssize_t ret; + + mutex_lock(&rp->printf_lock); + + if (rp->printf_togo == 0) { + + ep = mon_text_read_wait(rp, file); + if (IS_ERR(ep)) { + mutex_unlock(&rp->printf_lock); + return PTR_ERR(ep); + } + ptr.cnt = 0; + ptr.pbuf = rp->printf_buf; + ptr.limit = rp->printf_size; + + mon_text_read_head_u(rp, &ptr, ep); + if (ep->type == 'E') { + mon_text_read_statset(rp, &ptr, ep); + } else if (ep->xfertype == USB_ENDPOINT_XFER_ISOC) { + mon_text_read_isostat(rp, &ptr, ep); + mon_text_read_isodesc(rp, &ptr, ep); + } else if (ep->xfertype == USB_ENDPOINT_XFER_INT) { + mon_text_read_intstat(rp, &ptr, ep); + } else { + mon_text_read_statset(rp, &ptr, ep); + } + ptr.cnt += snprintf(ptr.pbuf + ptr.cnt, ptr.limit - ptr.cnt, + " %d", ep->length); + mon_text_read_data(rp, &ptr, ep); + + rp->printf_togo = ptr.cnt; + rp->printf_offset = 0; + + kmem_cache_free(rp->e_slab, ep); + } + + ret = mon_text_copy_to_user(rp, buf, nbytes); + mutex_unlock(&rp->printf_lock); + return ret; } static struct mon_event_text *mon_text_read_wait(struct mon_reader_text *rp, From 17aa9521d0c2856808c54ca1144d5c708e748928 Mon Sep 17 00:00:00 2001 From: Vijendar Mukunda Date: Fri, 9 Mar 2018 20:51:32 +0530 Subject: [PATCH 556/942] ASoC: amd: modifications in dma stop sequence As per design, non-circular dma also need to be stopped explicitly for both playback and capture scenarios. Signed-off-by: Vijendar Mukunda Signed-off-by: Mark Brown --- sound/soc/amd/acp-pcm-dma.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 935c8fd42a7a..a1c6534455e6 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -949,12 +949,16 @@ static int acp_dma_trigger(struct snd_pcm_substream *substream, int cmd) * completes : SYSRAM_TO_ACP_CH_NUM / ACP_TO_SYSRAM_CH_NUM */ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = acp_dma_stop(rtd->acp_mmio, + SYSRAM_TO_ACP_CH_NUM); ret = acp_dma_stop(rtd->acp_mmio, ACP_TO_I2S_DMA_CH_NUM); rtd->i2ssp_renderbytescount = 0; } else { ret = acp_dma_stop(rtd->acp_mmio, I2S_TO_ACP_DMA_CH_NUM); + ret = acp_dma_stop(rtd->acp_mmio, + ACP_TO_SYSRAM_CH_NUM); rtd->i2ssp_capturebytescount = 0; } break; From 8413b9e00aa33604aa661d7271c3c02c86beb994 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 9 Mar 2018 22:21:16 +0900 Subject: [PATCH 557/942] ASoC: uniphier: add support for UniPhier PXs2 AIO This patch adds support for UniPhier AIO sound driver which is included in UniPhier PXs2 SoCs. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- .../bindings/sound/uniphier,aio.txt | 1 + sound/soc/uniphier/Kconfig | 11 + sound/soc/uniphier/Makefile | 2 + sound/soc/uniphier/aio-ld11.c | 2 +- sound/soc/uniphier/aio-pxs2.c | 320 ++++++++++++++++++ sound/soc/uniphier/aio.h | 2 + 6 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 sound/soc/uniphier/aio-pxs2.c diff --git a/Documentation/devicetree/bindings/sound/uniphier,aio.txt b/Documentation/devicetree/bindings/sound/uniphier,aio.txt index 73f6c27ae4f7..65d71cf6ef0f 100644 --- a/Documentation/devicetree/bindings/sound/uniphier,aio.txt +++ b/Documentation/devicetree/bindings/sound/uniphier,aio.txt @@ -7,6 +7,7 @@ Required properties: - compatible : should be one of the following: "socionext,uniphier-ld11-aio" "socionext,uniphier-ld20-aio" + "socionext,uniphier-pxs2-aio" - reg : offset and length of the register set for the device. - interrupts : should contain I2S or S/PDIF interrupt. - pinctrl-names : should be "default". diff --git a/sound/soc/uniphier/Kconfig b/sound/soc/uniphier/Kconfig index 5da545b9bf2a..aa3592ee1358 100644 --- a/sound/soc/uniphier/Kconfig +++ b/sound/soc/uniphier/Kconfig @@ -30,6 +30,17 @@ config SND_SOC_UNIPHIER_LD11 Select Y if you use such device. If unsure select "N". +config SND_SOC_UNIPHIER_PXS2 + tristate "UniPhier PXs2 Device Driver" + depends on SND_SOC_UNIPHIER + select SND_SOC_UNIPHIER_AIO + select SND_SOC_UNIPHIER_AIO_DMA + help + This adds ASoC driver for Socionext UniPhier PXs2 + input and output that can be used with other codecs. + Select Y if you use such device. + If unsure select "N". + config SND_SOC_UNIPHIER_EVEA_CODEC tristate "UniPhier SoC internal audio codec" depends on SND_SOC_UNIPHIER diff --git a/sound/soc/uniphier/Makefile b/sound/soc/uniphier/Makefile index 587a89700950..88169395f68a 100644 --- a/sound/soc/uniphier/Makefile +++ b/sound/soc/uniphier/Makefile @@ -1,9 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 snd-soc-uniphier-aio-cpu-objs := aio-core.o aio-dma.o aio-cpu.o aio-compress.o snd-soc-uniphier-aio-ld11-objs := aio-ld11.o +snd-soc-uniphier-aio-pxs2-objs := aio-pxs2.o obj-$(CONFIG_SND_SOC_UNIPHIER_AIO) += snd-soc-uniphier-aio-cpu.o obj-$(CONFIG_SND_SOC_UNIPHIER_LD11) += snd-soc-uniphier-aio-ld11.o +obj-$(CONFIG_SND_SOC_UNIPHIER_PXS2) += snd-soc-uniphier-aio-pxs2.o snd-soc-uniphier-evea-objs := evea.o obj-$(CONFIG_SND_SOC_UNIPHIER_EVEA_CODEC) += snd-soc-uniphier-evea.o diff --git a/sound/soc/uniphier/aio-ld11.c b/sound/soc/uniphier/aio-ld11.c index 8e40e6c2e42f..4c4dd3dd4dee 100644 --- a/sound/soc/uniphier/aio-ld11.c +++ b/sound/soc/uniphier/aio-ld11.c @@ -418,7 +418,7 @@ MODULE_DEVICE_TABLE(of, uniphier_aio_of_match); static struct platform_driver uniphier_aio_driver = { .driver = { - .name = "snd-uniphier-aio", + .name = "snd-uniphier-aio-ld11", .of_match_table = of_match_ptr(uniphier_aio_of_match), }, .probe = uniphier_aio_probe, diff --git a/sound/soc/uniphier/aio-pxs2.c b/sound/soc/uniphier/aio-pxs2.c new file mode 100644 index 000000000000..69cd5b0af948 --- /dev/null +++ b/sound/soc/uniphier/aio-pxs2.c @@ -0,0 +1,320 @@ +// SPDX-License-Identifier: GPL-2.0 +// +// Socionext UniPhier AIO ALSA driver for PXs2. +// +// Copyright (c) 2018 Socionext Inc. + +#include + +#include "aio.h" + +static const struct uniphier_aio_spec uniphier_aio_pxs2[] = { + /* for Line PCM In, Pin:AI1Dx */ + { + .name = AUD_NAME_PCMIN1, + .gname = AUD_GNAME_LINE, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_INPUT, + .rb = { 16, 11, }, + .ch = { 16, 11, }, + .iif = { 0, 0, }, + .iport = { 0, AUD_HW_PCMIN1, }, + }, + }, + + /* for Speaker/Headphone/Mic PCM In, Pin:AI2Dx */ + { + .name = AUD_NAME_PCMIN2, + .gname = AUD_GNAME_AUX, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_INPUT, + .rb = { 17, 12, }, + .ch = { 17, 12, }, + .iif = { 1, 1, }, + .iport = { 1, AUD_HW_PCMIN2, }, + }, + }, + + /* for HDMI PCM Out, Pin:AO1Dx (inner) */ + { + .name = AUD_NAME_HPCMOUT1, + .gname = AUD_GNAME_HDMI, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_OUTPUT, + .rb = { 0, 0, }, + .ch = { 0, 0, }, + .oif = { 0, 0, }, + .oport = { 3, AUD_HW_HPCMOUT1, }, + }, + }, + + /* for Line PCM Out, Pin:AO2Dx */ + { + .name = AUD_NAME_PCMOUT1, + .gname = AUD_GNAME_LINE, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_OUTPUT, + .rb = { 1, 1, }, + .ch = { 1, 1, }, + .oif = { 1, 1, }, + .oport = { 0, AUD_HW_PCMOUT1, }, + }, + }, + + /* for Speaker/Headphone/Mic PCM Out, Pin:AO3Dx */ + { + .name = AUD_NAME_PCMOUT2, + .gname = AUD_GNAME_AUX, + .swm = { + .type = PORT_TYPE_I2S, + .dir = PORT_DIR_OUTPUT, + .rb = { 2, 2, }, + .ch = { 2, 2, }, + .oif = { 2, 2, }, + .oport = { 1, AUD_HW_PCMOUT2, }, + }, + }, + + /* for HDMI Out, Pin:AO1IEC */ + { + .name = AUD_NAME_HIECOUT1, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_OUTPUT, + .rb = { 6, 4, }, + .ch = { 6, 4, }, + .oif = { 6, 4, }, + .oport = { 12, AUD_HW_HIECOUT1, }, + }, + }, + + /* for HDMI Out, Pin:AO1IEC, Compress */ + { + .name = AUD_NAME_HIECCOMPOUT1, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_OUTPUT, + .rb = { 6, 4, }, + .ch = { 6, 4, }, + .oif = { 6, 4, }, + .oport = { 12, AUD_HW_HIECOUT1, }, + }, + }, + + /* for S/PDIF Out, Pin:AO2IEC */ + { + .name = AUD_NAME_IECOUT1, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_OUTPUT, + .rb = { 7, 5, }, + .ch = { 7, 5, }, + .oif = { 7, 5, }, + .oport = { 13, AUD_HW_IECOUT1, }, + }, + }, + + /* for S/PDIF Out, Pin:AO2IEC */ + { + .name = AUD_NAME_IECCOMPOUT1, + .swm = { + .type = PORT_TYPE_SPDIF, + .dir = PORT_DIR_OUTPUT, + .rb = { 7, 5, }, + .ch = { 7, 5, }, + .oif = { 7, 5, }, + .oport = { 13, AUD_HW_IECOUT1, }, + }, + }, +}; + +static const struct uniphier_aio_pll uniphier_aio_pll_pxs2[] = { + [AUD_PLL_A1] = { .enable = true, }, + [AUD_PLL_F1] = { .enable = true, }, + [AUD_PLL_A2] = { .enable = true, }, + [AUD_PLL_F2] = { .enable = true, }, + [AUD_PLL_APLL] = { .enable = true, }, + [AUD_PLL_HSC0] = { .enable = true, }, +}; + +static int uniphier_aio_pxs2_probe(struct snd_soc_dai *dai) +{ + int ret; + + ret = uniphier_aio_dai_probe(dai); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_pll(dai, AUD_PLL_A1, 0, 0, 36864000); + if (ret < 0) + return ret; + ret = snd_soc_dai_set_pll(dai, AUD_PLL_F1, 0, 0, 36864000); + if (ret < 0) + return ret; + + ret = snd_soc_dai_set_pll(dai, AUD_PLL_A2, 0, 0, 33868800); + if (ret < 0) + return ret; + ret = snd_soc_dai_set_pll(dai, AUD_PLL_F2, 0, 0, 33868800); + if (ret < 0) + return ret; + + return 0; +} + +static struct snd_soc_dai_driver uniphier_aio_dai_pxs2[] = { + { + .name = AUD_GNAME_HDMI, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_HPCMOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_GNAME_LINE, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_PCMOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .capture = { + .stream_name = AUD_NAME_PCMIN1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_GNAME_AUX, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_PCMOUT2, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .capture = { + .stream_name = AUD_NAME_PCMIN2, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_i2s_ops, + }, + { + .name = AUD_NAME_HIECOUT1, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_HIECOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_spdif_ops, + }, + { + .name = AUD_NAME_IECOUT1, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .playback = { + .stream_name = AUD_NAME_IECOUT1, + .formats = SNDRV_PCM_FMTBIT_S32_LE, + .rates = SNDRV_PCM_RATE_48000, + .channels_min = 2, + .channels_max = 2, + }, + .ops = &uniphier_aio_spdif_ops, + }, + { + .name = AUD_NAME_HIECCOMPOUT1, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .compress_new = snd_soc_new_compress, + .playback = { + .stream_name = AUD_NAME_HIECCOMPOUT1, + .channels_min = 1, + .channels_max = 1, + }, + .ops = &uniphier_aio_spdif_ops, + }, + { + .name = AUD_NAME_IECCOMPOUT1, + .probe = uniphier_aio_pxs2_probe, + .remove = uniphier_aio_dai_remove, + .suspend = uniphier_aio_dai_suspend, + .resume = uniphier_aio_dai_resume, + .compress_new = snd_soc_new_compress, + .playback = { + .stream_name = AUD_NAME_IECCOMPOUT1, + .channels_min = 1, + .channels_max = 1, + }, + .ops = &uniphier_aio_spdif_ops, + }, +}; + +static const struct uniphier_aio_chip_spec uniphier_aio_pxs2_spec = { + .specs = uniphier_aio_pxs2, + .num_specs = ARRAY_SIZE(uniphier_aio_pxs2), + .dais = uniphier_aio_dai_pxs2, + .num_dais = ARRAY_SIZE(uniphier_aio_dai_pxs2), + .plls = uniphier_aio_pll_pxs2, + .num_plls = ARRAY_SIZE(uniphier_aio_pll_pxs2), + .addr_ext = 0, +}; + +static const struct of_device_id uniphier_aio_of_match[] = { + { + .compatible = "socionext,uniphier-pxs2-aio", + .data = &uniphier_aio_pxs2_spec, + }, + {}, +}; +MODULE_DEVICE_TABLE(of, uniphier_aio_of_match); + +static struct platform_driver uniphier_aio_driver = { + .driver = { + .name = "snd-uniphier-aio-pxs2", + .of_match_table = of_match_ptr(uniphier_aio_of_match), + }, + .probe = uniphier_aio_probe, + .remove = uniphier_aio_remove, +}; +module_platform_driver(uniphier_aio_driver); + +MODULE_AUTHOR("Katsuhiro Suzuki "); +MODULE_DESCRIPTION("UniPhier PXs2 AIO driver."); +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index 2cd64273fb5b..793334675cb3 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -110,9 +110,11 @@ enum IEC61937_PC { #define AUD_NAME_IECOUT1 "aio-iecout1" #define AUD_NAME_CMASTER "aio-cmaster" #define AUD_NAME_HIECCOMPOUT1 "aio-hieccompout1" +#define AUD_NAME_IECCOMPOUT1 "aio-ieccompout1" #define AUD_GNAME_HDMI "aio-hdmi" #define AUD_GNAME_LINE "aio-line" +#define AUD_GNAME_AUX "aio-aux" #define AUD_GNAME_IEC "aio-iec" #define AUD_CLK_IO 0 From 9f62c15f28b0d1d746734666d88a79f08ba1e43e Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Thu, 8 Mar 2018 17:00:02 +0100 Subject: [PATCH 558/942] ipv6: fix access to non-linear packet in ndisc_fill_redirect_hdr_option() Fix the following slab-out-of-bounds kasan report in ndisc_fill_redirect_hdr_option when the incoming ipv6 packet is not linear and the accessed data are not in the linear data region of orig_skb. [ 1503.122508] ================================================================== [ 1503.122832] BUG: KASAN: slab-out-of-bounds in ndisc_send_redirect+0x94e/0x990 [ 1503.123036] Read of size 1184 at addr ffff8800298ab6b0 by task netperf/1932 [ 1503.123220] CPU: 0 PID: 1932 Comm: netperf Not tainted 4.16.0-rc2+ #124 [ 1503.123347] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.10.2-2.fc27 04/01/2014 [ 1503.123527] Call Trace: [ 1503.123579] [ 1503.123638] print_address_description+0x6e/0x280 [ 1503.123849] kasan_report+0x233/0x350 [ 1503.123946] memcpy+0x1f/0x50 [ 1503.124037] ndisc_send_redirect+0x94e/0x990 [ 1503.125150] ip6_forward+0x1242/0x13b0 [...] [ 1503.153890] Allocated by task 1932: [ 1503.153982] kasan_kmalloc+0x9f/0xd0 [ 1503.154074] __kmalloc_track_caller+0xb5/0x160 [ 1503.154198] __kmalloc_reserve.isra.41+0x24/0x70 [ 1503.154324] __alloc_skb+0x130/0x3e0 [ 1503.154415] sctp_packet_transmit+0x21a/0x1810 [ 1503.154533] sctp_outq_flush+0xc14/0x1db0 [ 1503.154624] sctp_do_sm+0x34e/0x2740 [ 1503.154715] sctp_primitive_SEND+0x57/0x70 [ 1503.154807] sctp_sendmsg+0xaa6/0x1b10 [ 1503.154897] sock_sendmsg+0x68/0x80 [ 1503.154987] ___sys_sendmsg+0x431/0x4b0 [ 1503.155078] __sys_sendmsg+0xa4/0x130 [ 1503.155168] do_syscall_64+0x171/0x3f0 [ 1503.155259] entry_SYSCALL_64_after_hwframe+0x42/0xb7 [ 1503.155436] Freed by task 1932: [ 1503.155527] __kasan_slab_free+0x134/0x180 [ 1503.155618] kfree+0xbc/0x180 [ 1503.155709] skb_release_data+0x27f/0x2c0 [ 1503.155800] consume_skb+0x94/0xe0 [ 1503.155889] sctp_chunk_put+0x1aa/0x1f0 [ 1503.155979] sctp_inq_pop+0x2f8/0x6e0 [ 1503.156070] sctp_assoc_bh_rcv+0x6a/0x230 [ 1503.156164] sctp_inq_push+0x117/0x150 [ 1503.156255] sctp_backlog_rcv+0xdf/0x4a0 [ 1503.156346] __release_sock+0x142/0x250 [ 1503.156436] release_sock+0x80/0x180 [ 1503.156526] sctp_sendmsg+0xbb0/0x1b10 [ 1503.156617] sock_sendmsg+0x68/0x80 [ 1503.156708] ___sys_sendmsg+0x431/0x4b0 [ 1503.156799] __sys_sendmsg+0xa4/0x130 [ 1503.156889] do_syscall_64+0x171/0x3f0 [ 1503.156980] entry_SYSCALL_64_after_hwframe+0x42/0xb7 [ 1503.157158] The buggy address belongs to the object at ffff8800298ab600 which belongs to the cache kmalloc-1024 of size 1024 [ 1503.157444] The buggy address is located 176 bytes inside of 1024-byte region [ffff8800298ab600, ffff8800298aba00) [ 1503.157702] The buggy address belongs to the page: [ 1503.157820] page:ffffea0000a62a00 count:1 mapcount:0 mapping:0000000000000000 index:0x0 compound_mapcount: 0 [ 1503.158053] flags: 0x4000000000008100(slab|head) [ 1503.158171] raw: 4000000000008100 0000000000000000 0000000000000000 00000001800e000e [ 1503.158350] raw: dead000000000100 dead000000000200 ffff880036002600 0000000000000000 [ 1503.158523] page dumped because: kasan: bad access detected [ 1503.158698] Memory state around the buggy address: [ 1503.158816] ffff8800298ab900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 1503.158988] ffff8800298ab980: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 1503.159165] >ffff8800298aba00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 1503.159338] ^ [ 1503.159436] ffff8800298aba80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 1503.159610] ffff8800298abb00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb [ 1503.159785] ================================================================== [ 1503.159964] Disabling lock debugging due to kernel taint The test scenario to trigger the issue consists of 4 devices: - H0: data sender, connected to LAN0 - H1: data receiver, connected to LAN1 - GW0 and GW1: routers between LAN0 and LAN1. Both of them have an ethernet connection on LAN0 and LAN1 On H{0,1} set GW0 as default gateway while on GW0 set GW1 as next hop for data from LAN0 to LAN1. Moreover create an ip6ip6 tunnel between H0 and H1 and send 3 concurrent data streams (TCP/UDP/SCTP) from H0 to H1 through ip6ip6 tunnel (send buffer size is set to 16K). While data streams are active flush the route cache on HA multiple times. I have not been able to identify a given commit that introduced the issue since, using the reproducer described above, the kasan report has been triggered from 4.14 and I have not gone back further. Reported-by: Jianlin Shi Reviewed-by: Stefano Brivio Reviewed-by: Eric Dumazet Signed-off-by: Lorenzo Bianconi Signed-off-by: David S. Miller --- net/ipv6/ndisc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index f61a5b613b52..ba5e04c6ae17 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c @@ -1554,7 +1554,8 @@ static void ndisc_fill_redirect_hdr_option(struct sk_buff *skb, *(opt++) = (rd_len >> 3); opt += 6; - memcpy(opt, ipv6_hdr(orig_skb), rd_len - 8); + skb_copy_bits(orig_skb, skb_network_offset(orig_skb), opt, + rd_len - 8); } void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target) From ca0edb131bdf1e6beaeb2b8289fd6b374b74147d Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Mon, 5 Mar 2018 08:51:03 -0800 Subject: [PATCH 559/942] ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event() A tun device type can trivially be set to arbitrary value using TUNSETLINK ioctl(). Therefore, lowpan_device_event() must really check that ieee802154_ptr is not NULL. Fixes: 2c88b5283f60d ("ieee802154: 6lowpan: remove check on null") Signed-off-by: Eric Dumazet Cc: Alexander Aring Cc: Stefan Schmidt Reported-by: syzbot Acked-by: Stefan Schmidt Signed-off-by: David S. Miller --- net/ieee802154/6lowpan/core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/net/ieee802154/6lowpan/core.c b/net/ieee802154/6lowpan/core.c index 974765b7d92a..e9f0489e4229 100644 --- a/net/ieee802154/6lowpan/core.c +++ b/net/ieee802154/6lowpan/core.c @@ -206,9 +206,13 @@ static inline void lowpan_netlink_fini(void) static int lowpan_device_event(struct notifier_block *unused, unsigned long event, void *ptr) { - struct net_device *wdev = netdev_notifier_info_to_dev(ptr); + struct net_device *ndev = netdev_notifier_info_to_dev(ptr); + struct wpan_dev *wpan_dev; - if (wdev->type != ARPHRD_IEEE802154) + if (ndev->type != ARPHRD_IEEE802154) + return NOTIFY_DONE; + wpan_dev = ndev->ieee802154_ptr; + if (!wpan_dev) return NOTIFY_DONE; switch (event) { @@ -217,8 +221,8 @@ static int lowpan_device_event(struct notifier_block *unused, * also delete possible lowpan interfaces which belongs * to the wpan interface. */ - if (wdev->ieee802154_ptr->lowpan_dev) - lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL); + if (wpan_dev->lowpan_dev) + lowpan_dellink(wpan_dev->lowpan_dev, NULL); break; default: return NOTIFY_DONE; From 1dd27cde30e85774c77349c804229431616d594a Mon Sep 17 00:00:00 2001 From: Daniel Axtens Date: Fri, 9 Mar 2018 14:06:09 +1100 Subject: [PATCH 560/942] net: use skb_is_gso_sctp() instead of open-coding As well as the basic conversion, I noticed that a lot of the SCTP code checks gso_type without first checking skb_is_gso() so I have added that where appropriate. Also, document the helper. Cc: Daniel Borkmann Cc: Marcelo Ricardo Leitner Signed-off-by: Daniel Axtens Signed-off-by: David S. Miller --- Documentation/networking/segmentation-offloads.txt | 5 ++++- net/core/skbuff.c | 2 +- net/sched/act_csum.c | 2 +- net/sctp/input.c | 8 ++++---- net/sctp/inqueue.c | 2 +- net/sctp/offload.c | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/segmentation-offloads.txt b/Documentation/networking/segmentation-offloads.txt index fc0c949e7f9c..aca542ec125c 100644 --- a/Documentation/networking/segmentation-offloads.txt +++ b/Documentation/networking/segmentation-offloads.txt @@ -155,7 +155,10 @@ Therefore, any code in the core networking stack must be aware of the possibility that gso_size will be GSO_BY_FRAGS and handle that case appropriately. -There are a couple of helpers to make this easier: +There are some helpers to make this easier: + + - skb_is_gso(skb) && skb_is_gso_sctp(skb) is the best way to see if + an skb is an SCTP GSO skb. - For size checks, the skb_gso_validate_*_len family of helpers correctly considers GSO_BY_FRAGS. diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 0bb0d8877954..baf990528943 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4904,7 +4904,7 @@ static unsigned int skb_gso_transport_seglen(const struct sk_buff *skb) thlen += inner_tcp_hdrlen(skb); } else if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6))) { thlen = tcp_hdrlen(skb); - } else if (unlikely(shinfo->gso_type & SKB_GSO_SCTP)) { + } else if (unlikely(skb_is_gso_sctp(skb))) { thlen = sizeof(struct sctphdr); } /* UFO sets gso_size to the size of the fragmentation diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index b7ba9b06b147..24b2e8e681cf 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -350,7 +350,7 @@ static int tcf_csum_sctp(struct sk_buff *skb, unsigned int ihl, { struct sctphdr *sctph; - if (skb_is_gso(skb) && skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) + if (skb_is_gso(skb) && skb_is_gso_sctp(skb)) return 1; sctph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*sctph)); diff --git a/net/sctp/input.c b/net/sctp/input.c index 0247cc432e02..b381d78548ac 100644 --- a/net/sctp/input.c +++ b/net/sctp/input.c @@ -106,6 +106,7 @@ int sctp_rcv(struct sk_buff *skb) int family; struct sctp_af *af; struct net *net = dev_net(skb->dev); + bool is_gso = skb_is_gso(skb) && skb_is_gso_sctp(skb); if (skb->pkt_type != PACKET_HOST) goto discard_it; @@ -123,8 +124,7 @@ int sctp_rcv(struct sk_buff *skb) * it's better to just linearize it otherwise crc computing * takes longer. */ - if ((!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) && - skb_linearize(skb)) || + if ((!is_gso && skb_linearize(skb)) || !pskb_may_pull(skb, sizeof(struct sctphdr))) goto discard_it; @@ -135,7 +135,7 @@ int sctp_rcv(struct sk_buff *skb) if (skb_csum_unnecessary(skb)) __skb_decr_checksum_unnecessary(skb); else if (!sctp_checksum_disable && - !(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) && + !is_gso && sctp_rcv_checksum(net, skb) < 0) goto discard_it; skb->csum_valid = 1; @@ -1218,7 +1218,7 @@ static struct sctp_association *__sctp_rcv_lookup_harder(struct net *net, * issue as packets hitting this are mostly INIT or INIT-ACK and * those cannot be on GSO-style anyway. */ - if ((skb_shinfo(skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) + if (skb_is_gso(skb) && skb_is_gso_sctp(skb)) return NULL; ch = (struct sctp_chunkhdr *)skb->data; diff --git a/net/sctp/inqueue.c b/net/sctp/inqueue.c index 48392552ee7c..23ebc5318edc 100644 --- a/net/sctp/inqueue.c +++ b/net/sctp/inqueue.c @@ -170,7 +170,7 @@ next_chunk: chunk = list_entry(entry, struct sctp_chunk, list); - if ((skb_shinfo(chunk->skb)->gso_type & SKB_GSO_SCTP) == SKB_GSO_SCTP) { + if (skb_is_gso(chunk->skb) && skb_is_gso_sctp(chunk->skb)) { /* GSO-marked skbs but without frags, handle * them normally */ diff --git a/net/sctp/offload.c b/net/sctp/offload.c index 35bc7106d182..123e9f2dc226 100644 --- a/net/sctp/offload.c +++ b/net/sctp/offload.c @@ -45,7 +45,7 @@ static struct sk_buff *sctp_gso_segment(struct sk_buff *skb, struct sk_buff *segs = ERR_PTR(-EINVAL); struct sctphdr *sh; - if (!(skb_shinfo(skb)->gso_type & SKB_GSO_SCTP)) + if (!skb_is_gso_sctp(skb)) goto out; sh = sctp_hdr(skb); From d06cbe9cbb8905df21b11d1cf789c9b2947688e9 Mon Sep 17 00:00:00 2001 From: Kunihiko Hayashi Date: Fri, 9 Mar 2018 15:27:20 +0900 Subject: [PATCH 561/942] net: ethernet: ave: enable Rx drop interrupt This enables AVE_GI_RXDROP interrupt factor. This factor indicates depletion of Rx descriptors and the handler counts the number of dropped packets. Signed-off-by: Kunihiko Hayashi Signed-off-by: David S. Miller --- drivers/net/ethernet/socionext/sni_ave.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/socionext/sni_ave.c b/drivers/net/ethernet/socionext/sni_ave.c index 111e7ca9df56..f5c5984afefb 100644 --- a/drivers/net/ethernet/socionext/sni_ave.c +++ b/drivers/net/ethernet/socionext/sni_ave.c @@ -1295,7 +1295,7 @@ static int ave_open(struct net_device *ndev) val |= AVE_IIRQC_EN0 | (AVE_INTM_COUNT << 16); writel(val, priv->base + AVE_IIRQC); - val = AVE_GI_RXIINT | AVE_GI_RXOVF | AVE_GI_TX; + val = AVE_GI_RXIINT | AVE_GI_RXOVF | AVE_GI_TX | AVE_GI_RXDROP; ave_irq_restore(ndev, val); napi_enable(&priv->napi_rx); From ab7e34b3431c5d29817c503ad4d3bf2732f92ad3 Mon Sep 17 00:00:00 2001 From: Alexander Potapenko Date: Fri, 9 Mar 2018 14:50:32 +0800 Subject: [PATCH 562/942] vhost_net: initialize rx_ring in vhost_net_open() KMSAN reported a use of uninit memory in vhost_net_buf_unproduce() while trying to access n->vqs[VHOST_NET_VQ_TX].rx_ring: ================================================================== BUG: KMSAN: use of uninitialized memory in vhost_net_buf_unproduce+0x7bb/0x9a0 drivers/vho et.c:170 CPU: 0 PID: 3021 Comm: syz-fuzzer Not tainted 4.16.0-rc4+ #3853 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x185/0x1d0 lib/dump_stack.c:53 kmsan_report+0x142/0x1f0 mm/kmsan/kmsan.c:1093 __msan_warning_32+0x6c/0xb0 mm/kmsan/kmsan_instr.c:676 vhost_net_buf_unproduce+0x7bb/0x9a0 drivers/vhost/net.c:170 vhost_net_stop_vq drivers/vhost/net.c:974 [inline] vhost_net_stop+0x146/0x380 drivers/vhost/net.c:982 vhost_net_release+0xb1/0x4f0 drivers/vhost/net.c:1015 __fput+0x49f/0xa00 fs/file_table.c:209 ____fput+0x37/0x40 fs/file_table.c:243 task_work_run+0x243/0x2c0 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:191 [inline] exit_to_usermode_loop arch/x86/entry/common.c:166 [inline] prepare_exit_to_usermode+0x349/0x3b0 arch/x86/entry/common.c:196 syscall_return_slowpath+0xf3/0x6d0 arch/x86/entry/common.c:265 do_syscall_64+0x34d/0x450 arch/x86/entry/common.c:292 ... origin: kmsan_save_stack_with_flags mm/kmsan/kmsan.c:303 [inline] kmsan_internal_poison_shadow+0xb8/0x1b0 mm/kmsan/kmsan.c:213 kmsan_kmalloc_large+0x6f/0xd0 mm/kmsan/kmsan.c:392 kmalloc_large_node_hook mm/slub.c:1366 [inline] kmalloc_large_node mm/slub.c:3808 [inline] __kmalloc_node+0x100e/0x1290 mm/slub.c:3818 kmalloc_node include/linux/slab.h:554 [inline] kvmalloc_node+0x1a5/0x2e0 mm/util.c:419 kvmalloc include/linux/mm.h:541 [inline] vhost_net_open+0x64/0x5f0 drivers/vhost/net.c:921 misc_open+0x7b5/0x8b0 drivers/char/misc.c:154 chrdev_open+0xc28/0xd90 fs/char_dev.c:417 do_dentry_open+0xccb/0x1430 fs/open.c:752 vfs_open+0x272/0x2e0 fs/open.c:866 do_last fs/namei.c:3378 [inline] path_openat+0x49ad/0x6580 fs/namei.c:3519 do_filp_open+0x267/0x640 fs/namei.c:3553 do_sys_open+0x6ad/0x9c0 fs/open.c:1059 SYSC_openat+0xc7/0xe0 fs/open.c:1086 SyS_openat+0x63/0x90 fs/open.c:1080 do_syscall_64+0x2f1/0x450 arch/x86/entry/common.c:287 ================================================================== Fixes: c67df11f6e480 ("vhost_net: try batch dequing from skb array") Signed-off-by: Alexander Potapenko Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller --- drivers/vhost/net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 610cba276d47..60f1080bffc7 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -948,6 +948,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) n->vqs[i].done_idx = 0; n->vqs[i].vhost_hlen = 0; n->vqs[i].sock_hlen = 0; + n->vqs[i].rx_ring = NULL; vhost_net_buf_init(&n->vqs[i].rxq); } vhost_dev_init(dev, vqs, VHOST_NET_VQ_MAX); From 303fd71b37fb710b26f5ff5444029d62cfd627bd Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Fri, 9 Mar 2018 14:50:33 +0800 Subject: [PATCH 563/942] vhost_net: keep private_data and rx_ring synced We get pointer ring from the exported sock, this means we should keep rx_ring and vq->private synced during both vq stop and backend set, otherwise we may see stale rx_ring. Fixes: c67df11f6e480 ("vhost_net: try batch dequing from skb array") Signed-off-by: Michael S. Tsirkin Signed-off-by: Jason Wang Acked-by: Michael S. Tsirkin Signed-off-by: David S. Miller --- drivers/vhost/net.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index 60f1080bffc7..efb93063fda1 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -973,6 +973,7 @@ static struct socket *vhost_net_stop_vq(struct vhost_net *n, vhost_net_disable_vq(n, vq); vq->private_data = NULL; vhost_net_buf_unproduce(nvq); + nvq->rx_ring = NULL; mutex_unlock(&vq->mutex); return sock; } @@ -1162,14 +1163,14 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) vhost_net_disable_vq(n, vq); vq->private_data = sock; vhost_net_buf_unproduce(nvq); - if (index == VHOST_NET_VQ_RX) - nvq->rx_ring = get_tap_ptr_ring(fd); r = vhost_vq_init_access(vq); if (r) goto err_used; r = vhost_net_enable_vq(n, vq); if (r) goto err_used; + if (index == VHOST_NET_VQ_RX) + nvq->rx_ring = get_tap_ptr_ring(fd); oldubufs = nvq->ubufs; nvq->ubufs = ubufs; From 3a4030761ea88ff439030ca98e3094b9900e96b7 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Fri, 9 Mar 2018 14:50:34 +0800 Subject: [PATCH 564/942] vhost_net: examine pointer types during un-producing After commit fc72d1d54dd9 ("tuntap: XDP transmission"), we can actually queueing XDP pointers in the pointer ring, so we should examine the pointer type before freeing the pointer. Fixes: fc72d1d54dd9 ("tuntap: XDP transmission") Reported-by: Michael S. Tsirkin Acked-by: Michael S. Tsirkin Signed-off-by: Jason Wang Signed-off-by: David S. Miller --- drivers/net/tun.c | 3 ++- drivers/vhost/net.c | 2 +- include/linux/if_tun.h | 4 ++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 7433bb2e4451..28cfa642e39a 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -655,7 +655,7 @@ static struct tun_struct *tun_enable_queue(struct tun_file *tfile) return tun; } -static void tun_ptr_free(void *ptr) +void tun_ptr_free(void *ptr) { if (!ptr) return; @@ -667,6 +667,7 @@ static void tun_ptr_free(void *ptr) __skb_array_destroy_skb(ptr); } } +EXPORT_SYMBOL_GPL(tun_ptr_free); static void tun_queue_purge(struct tun_file *tfile) { diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index efb93063fda1..8139bc70ad7d 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -170,7 +170,7 @@ static void vhost_net_buf_unproduce(struct vhost_net_virtqueue *nvq) if (nvq->rx_ring && !vhost_net_buf_is_empty(rxq)) { ptr_ring_unconsume(nvq->rx_ring, rxq->queue + rxq->head, vhost_net_buf_get_size(rxq), - __skb_array_destroy_skb); + tun_ptr_free); rxq->head = rxq->tail = 0; } } diff --git a/include/linux/if_tun.h b/include/linux/if_tun.h index c5b0a75a7812..fd00170b494f 100644 --- a/include/linux/if_tun.h +++ b/include/linux/if_tun.h @@ -25,6 +25,7 @@ struct ptr_ring *tun_get_tx_ring(struct file *file); bool tun_is_xdp_buff(void *ptr); void *tun_xdp_to_ptr(void *ptr); void *tun_ptr_to_xdp(void *ptr); +void tun_ptr_free(void *ptr); #else #include #include @@ -50,5 +51,8 @@ static inline void *tun_ptr_to_xdp(void *ptr) { return NULL; } +static inline void tun_ptr_free(void *ptr) +{ +} #endif /* CONFIG_TUN */ #endif /* __IF_TUN_H */ From d56e57ca030c8b4296944a2ae61ac167bf979c07 Mon Sep 17 00:00:00 2001 From: Yoshihiro Shimoda Date: Thu, 8 Mar 2018 17:17:16 +0200 Subject: [PATCH 565/942] usb: host: xhci-plat: revert "usb: host: xhci-plat: enable clk in resume timing" This patch reverts the commit 835e4241e714 ("usb: host: xhci-plat: enable clk in resume timing") because this driver also has runtime PM and the commit 560869100b99 ("clk: renesas: cpg-mssr: Restore module clocks during resume") will restore the clock on R-Car H3 environment. If the xhci_plat_suspend() disables the clk, the system cannot enable the clk in resume like the following behavior: < In resume > - genpd_resume_noirq() runs and enable the clk (enable_count = 1) - cpg_mssr_resume_noirq() restores the clk register. -- Since the clk was disabled in suspend, cpg_mssr_resume_noirq() will disable the clk and keep the enable_count. - Even if xhci_plat_resume() calls clk_prepare_enable(), since the enable_count is 1, the clk will be not enabled. After this patch is applied, the cpg-mssr driver will save the clk as enable, so the clk will be enabled in resume. Fixes: 835e4241e714 ("usb: host: xhci-plat: enable clk in resume timing") Signed-off-by: Yoshihiro Shimoda Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-plat.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 6f038306c14d..6652e2d5bd2e 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c @@ -360,7 +360,6 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) { struct usb_hcd *hcd = dev_get_drvdata(dev); struct xhci_hcd *xhci = hcd_to_xhci(hcd); - int ret; /* * xhci_suspend() needs `do_wakeup` to know whether host is allowed @@ -370,12 +369,7 @@ static int __maybe_unused xhci_plat_suspend(struct device *dev) * reconsider this when xhci_plat_suspend enlarges its scope, e.g., * also applies to runtime suspend. */ - ret = xhci_suspend(xhci, device_may_wakeup(dev)); - - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) - clk_disable_unprepare(xhci->clk); - - return ret; + return xhci_suspend(xhci, device_may_wakeup(dev)); } static int __maybe_unused xhci_plat_resume(struct device *dev) @@ -384,9 +378,6 @@ static int __maybe_unused xhci_plat_resume(struct device *dev) struct xhci_hcd *xhci = hcd_to_xhci(hcd); int ret; - if (!device_may_wakeup(dev) && !IS_ERR(xhci->clk)) - clk_prepare_enable(xhci->clk); - ret = xhci_priv_resume_quirk(hcd); if (ret) return ret; From 191edc5e2e515aab1075a3f0ef23599e80be5f59 Mon Sep 17 00:00:00 2001 From: Kai-Heng Feng Date: Thu, 8 Mar 2018 17:17:17 +0200 Subject: [PATCH 566/942] xhci: Fix front USB ports on ASUS PRIME B350M-A When a USB device gets plugged on ASUS PRIME B350M-A's front ports, the xHC stops working: [ 549.114587] xhci_hcd 0000:02:00.0: WARN: xHC CMD_RUN timeout [ 549.114608] suspend_common(): xhci_pci_suspend+0x0/0xc0 returns -110 [ 549.114638] xhci_hcd 0000:02:00.0: can't suspend (hcd_pci_runtime_suspend returned -110) Delay before running xHC command CMD_RUN can workaround the issue. Use a new quirk to make the delay only targets to the affected xHC. Signed-off-by: Kai-Heng Feng Signed-off-by: Mathias Nyman Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci-pci.c | 3 +++ drivers/usb/host/xhci.c | 3 +++ drivers/usb/host/xhci.h | 1 + 3 files changed, 7 insertions(+) diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 5262fa571a5d..d9f831b67e57 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c @@ -126,6 +126,9 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) if (pdev->vendor == PCI_VENDOR_ID_AMD && usb_amd_find_chipset_info()) xhci->quirks |= XHCI_AMD_PLL_FIX; + if (pdev->vendor == PCI_VENDOR_ID_AMD && pdev->device == 0x43bb) + xhci->quirks |= XHCI_SUSPEND_DELAY; + if (pdev->vendor == PCI_VENDOR_ID_AMD) xhci->quirks |= XHCI_TRUST_TX_LENGTH; diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 25d4b748a56f..5d37700ae4b0 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -877,6 +877,9 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) clear_bit(HCD_FLAG_POLL_RH, &xhci->shared_hcd->flags); del_timer_sync(&xhci->shared_hcd->rh_timer); + if (xhci->quirks & XHCI_SUSPEND_DELAY) + usleep_range(1000, 1500); + spin_lock_irq(&xhci->lock); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); clear_bit(HCD_FLAG_HW_ACCESSIBLE, &xhci->shared_hcd->flags); diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index d20e57b35d32..866e141d4972 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -1826,6 +1826,7 @@ struct xhci_hcd { #define XHCI_U2_DISABLE_WAKE (1 << 27) #define XHCI_ASMEDIA_MODIFY_FLOWCONTROL (1 << 28) #define XHCI_HW_LPM_DISABLE (1 << 29) +#define XHCI_SUSPEND_DELAY (1 << 30) unsigned int num_active_eps; unsigned int limit_active_eps; From fc8f7ea2d6c074baaad202c9187962bfa493ef13 Mon Sep 17 00:00:00 2001 From: Adam Thomson Date: Fri, 9 Mar 2018 16:25:43 +0000 Subject: [PATCH 567/942] ASoC: da7219: Add common clock usage for providing DAI clks There is a need to use DA7219 as DAI clock master for other codecs within a system, which means that the DAI clocks are required to remain, regardless of whether the codec is actually running playback/capture. To be able to expose control of the DAI clocking the common clock framework has been employed. The current implementation adds a simple clock gate for enabling and disabling the DAI clocks, with no rate control supported (this is still handled through standard hw_params() functions as before). If DT is enabled then the clock is added to the OF providers list, otherwise a clkdev lookup is used. Signed-off-by: Adam Thomson Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/da7219.txt | 6 + include/sound/da7219.h | 2 + sound/soc/codecs/da7219.c | 129 ++++++++++++++++-- sound/soc/codecs/da7219.h | 9 ++ 4 files changed, 138 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/da7219.txt b/Documentation/devicetree/bindings/sound/da7219.txt index 5b54d2d045c3..c3df92d31c4b 100644 --- a/Documentation/devicetree/bindings/sound/da7219.txt +++ b/Documentation/devicetree/bindings/sound/da7219.txt @@ -25,6 +25,9 @@ Optional properties: interrupt is to be used to wake system, otherwise "irq" should be used. - wakeup-source: Flag to indicate this device can wake system (suspend/resume). +- #clock-cells : Should be set to '<0>', only one clock source provided; +- clock-output-names : Name given for DAI clocks output; + - clocks : phandle and clock specifier for codec MCLK. - clock-names : Clock name string for 'clocks' attribute, should be "mclk". @@ -83,6 +86,9 @@ Example: VDDMIC-supply = <®_audio>; VDDIO-supply = <®_audio>; + #clock-cells = <0>; + clock-output-names = "dai-clks"; + clocks = <&clks 201>; clock-names = "mclk"; diff --git a/include/sound/da7219.h b/include/sound/da7219.h index 409ef1397fd3..1bfcb16f2d10 100644 --- a/include/sound/da7219.h +++ b/include/sound/da7219.h @@ -36,6 +36,8 @@ struct da7219_aad_pdata; struct da7219_pdata { bool wakeup_source; + const char *dai_clks_name; + /* Mic */ enum da7219_micbias_voltage micbias_lvl; enum da7219_mic_amp_in_sel mic_amp_in_sel; diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 5e043d082f4b..441215997273 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -13,6 +13,8 @@ #include #include +#include +#include #include #include #include @@ -772,16 +774,27 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); u8 pll_ctrl, pll_status; - int i = 0; + int i = 0, ret; bool srm_lock = false; switch (event) { case SND_SOC_DAPM_PRE_PMU: - if (da7219->master) + if (da7219->master) { /* Enable DAI clks for master mode */ - snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, - DA7219_DAI_CLK_EN_MASK, - DA7219_DAI_CLK_EN_MASK); + if (da7219->dai_clks) { + ret = clk_prepare_enable(da7219->dai_clks); + if (ret) { + dev_err(component->dev, + "Failed to enable dai_clks\n"); + return ret; + } + } else { + snd_soc_component_update_bits(component, + DA7219_DAI_CLK_MODE, + DA7219_DAI_CLK_EN_MASK, + DA7219_DAI_CLK_EN_MASK); + } + } /* PC synchronised to DAI */ snd_soc_component_update_bits(component, DA7219_PC_COUNT, @@ -814,9 +827,16 @@ static int da7219_dai_event(struct snd_soc_dapm_widget *w, DA7219_PC_FREERUN_MASK); /* Disable DAI clks if in master mode */ - if (da7219->master) - snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, - DA7219_DAI_CLK_EN_MASK, 0); + if (da7219->master) { + if (da7219->dai_clks) + clk_disable_unprepare(da7219->dai_clks); + else + snd_soc_component_update_bits(component, + DA7219_DAI_CLK_MODE, + DA7219_DAI_CLK_EN_MASK, + 0); + } + return 0; default: return -EINVAL; @@ -1598,6 +1618,12 @@ static struct da7219_pdata *da7219_fw_to_pdata(struct snd_soc_component *compone pdata->wakeup_source = device_property_read_bool(dev, "wakeup-source"); + pdata->dai_clks_name = "da7219-dai-clks"; + if (device_property_read_string(dev, "clock-output-names", + &pdata->dai_clks_name)) + dev_warn(dev, "Using default clk name: %s\n", + pdata->dai_clks_name); + if (device_property_read_u32(dev, "dlg,micbias-lvl", &of_val32) >= 0) pdata->micbias_lvl = da7219_fw_micbias_lvl(dev, of_val32); else @@ -1712,6 +1738,88 @@ static int da7219_handle_supplies(struct snd_soc_component *component) return 0; } +#ifdef CONFIG_COMMON_CLK +static int da7219_dai_clks_prepare(struct clk_hw *hw) +{ + struct da7219_priv *da7219 = + container_of(hw, struct da7219_priv, dai_clks_hw); + struct snd_soc_component *component = da7219->aad->component; + + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, + DA7219_DAI_CLK_EN_MASK, + DA7219_DAI_CLK_EN_MASK); + + return 0; +} + +static void da7219_dai_clks_unprepare(struct clk_hw *hw) +{ + struct da7219_priv *da7219 = + container_of(hw, struct da7219_priv, dai_clks_hw); + struct snd_soc_component *component = da7219->aad->component; + + snd_soc_component_update_bits(component, DA7219_DAI_CLK_MODE, + DA7219_DAI_CLK_EN_MASK, 0); +} + +static int da7219_dai_clks_is_prepared(struct clk_hw *hw) +{ + struct da7219_priv *da7219 = + container_of(hw, struct da7219_priv, dai_clks_hw); + struct snd_soc_component *component = da7219->aad->component; + u8 clk_reg; + + clk_reg = snd_soc_component_read32(component, DA7219_DAI_CLK_MODE); + + return !!(clk_reg & DA7219_DAI_CLK_EN_MASK); +} + +const struct clk_ops da7219_dai_clks_ops = { + .prepare = da7219_dai_clks_prepare, + .unprepare = da7219_dai_clks_unprepare, + .is_prepared = da7219_dai_clks_is_prepared, +}; + +static void da7219_register_dai_clks(struct snd_soc_component *component) +{ + struct device *dev = component->dev; + struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); + struct da7219_pdata *pdata = da7219->pdata; + struct clk_init_data init = {}; + struct clk *dai_clks; + struct clk_lookup *dai_clks_lookup; + + init.parent_names = NULL; + init.num_parents = 0; + init.name = pdata->dai_clks_name; + init.ops = &da7219_dai_clks_ops; + da7219->dai_clks_hw.init = &init; + + dai_clks = devm_clk_register(dev, &da7219->dai_clks_hw); + if (IS_ERR(dai_clks)) { + dev_warn(dev, "Failed to register DAI clocks: %ld\n", + PTR_ERR(dai_clks)); + return; + } + da7219->dai_clks = dai_clks; + + /* If we're using DT, then register as provider accordingly */ + if (dev->of_node) { + devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, + &da7219->dai_clks_hw); + } else { + dai_clks_lookup = clkdev_create(dai_clks, pdata->dai_clks_name, + "%s", dev_name(dev)); + if (!dai_clks_lookup) + dev_warn(dev, "Failed to create DAI clkdev"); + else + da7219->dai_clks_lookup = dai_clks_lookup; + } +} +#else +static inline void da7219_register_dai_clks(struct snd_soc_component *component) {} +#endif /* CONFIG_COMMON_CLK */ + static void da7219_handle_pdata(struct snd_soc_component *component) { struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component); @@ -1722,6 +1830,8 @@ static void da7219_handle_pdata(struct snd_soc_component *component) da7219->wakeup_source = pdata->wakeup_source; + da7219_register_dai_clks(component); + /* Mic Bias voltages */ switch (pdata->micbias_lvl) { case DA7219_MICBIAS_1_6V: @@ -1856,6 +1966,9 @@ static void da7219_remove(struct snd_soc_component *component) da7219_aad_exit(component); + if (da7219->dai_clks_lookup) + clkdev_drop(da7219->dai_clks_lookup); + /* Supplies */ regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); } diff --git a/sound/soc/codecs/da7219.h b/sound/soc/codecs/da7219.h index 1acb34cd12ad..1b00023e33cd 100644 --- a/sound/soc/codecs/da7219.h +++ b/sound/soc/codecs/da7219.h @@ -14,6 +14,9 @@ #ifndef __DA7219_H #define __DA7219_H +#include +#include +#include #include #include #include @@ -813,6 +816,12 @@ struct da7219_priv { struct mutex ctrl_lock; struct mutex pll_lock; +#ifdef CONFIG_COMMON_CLK + struct clk_hw dai_clks_hw; +#endif + struct clk_lookup *dai_clks_lookup; + struct clk *dai_clks; + struct clk *mclk; unsigned int mclk_rate; int clk_src; From df3334c223a033f562645712e832ca4cbb326bbf Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 22 Feb 2018 17:39:17 +0000 Subject: [PATCH 568/942] usbip: vudc: fix null pointer dereference on udc->lock Currently the driver attempts to spin lock on udc->lock before a NULL pointer check is performed on udc, hence there is a potential null pointer dereference on udc->lock. Fix this by moving the null check on udc before the lock occurs. Fixes: ea6873a45a22 ("usbip: vudc: Add SysFS infrastructure for VUDC") Signed-off-by: Colin Ian King Acked-by: Shuah Khan Reviewed-by: Krzysztof Opasiak Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/vudc_sysfs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c index d86f72bbbb91..6dcd3ff655c3 100644 --- a/drivers/usb/usbip/vudc_sysfs.c +++ b/drivers/usb/usbip/vudc_sysfs.c @@ -105,10 +105,14 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a if (rv != 0) return -EINVAL; + if (!udc) { + dev_err(dev, "no device"); + return -ENODEV; + } spin_lock_irqsave(&udc->lock, flags); /* Don't export what we don't have */ - if (!udc || !udc->driver || !udc->pullup) { - dev_err(dev, "no device or gadget not bound"); + if (!udc->driver || !udc->pullup) { + dev_err(dev, "gadget not bound"); ret = -ENODEV; goto unlock; } From 49bae2f3093b0a7bc5e1a158d89697a73cdb0243 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Fri, 9 Mar 2018 15:33:52 +0200 Subject: [PATCH 569/942] mlxsw: spectrum: Fix gact_ok offloading For ok GACT action, TERMINATE binding_cmd should be used in action set passed down to HW. Fixes: b2925957ec1a9 ("mlxsw: spectrum_flower: Offload "ok" termination action") Signed-off-by: Jiri Pirko Reported-by: Alexander Petrovskiy Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller --- .../ethernet/mellanox/mlxsw/core_acl_flex_actions.c | 11 +++++++++++ .../ethernet/mellanox/mlxsw/core_acl_flex_actions.h | 1 + drivers/net/ethernet/mellanox/mlxsw/spectrum.h | 1 + drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c | 5 +++++ drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 2 +- 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c index b698fb481b2e..996dc099cd58 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c @@ -443,6 +443,17 @@ int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id) } EXPORT_SYMBOL(mlxsw_afa_block_jump); +int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block) +{ + if (block->finished) + return -EINVAL; + mlxsw_afa_set_goto_set(block->cur_set, + MLXSW_AFA_SET_GOTO_BINDING_CMD_TERM, 0); + block->finished = true; + return 0; +} +EXPORT_SYMBOL(mlxsw_afa_block_terminate); + static struct mlxsw_afa_fwd_entry * mlxsw_afa_fwd_entry_create(struct mlxsw_afa *mlxsw_afa, u8 local_port) { diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h index 43132293475c..b91f2b0829b0 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h @@ -65,6 +65,7 @@ char *mlxsw_afa_block_first_set(struct mlxsw_afa_block *block); u32 mlxsw_afa_block_first_set_kvdl_index(struct mlxsw_afa_block *block); int mlxsw_afa_block_continue(struct mlxsw_afa_block *block); int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id); +int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block); int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block); int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id); int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 4ec1ca3c96c8..386861773476 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -553,6 +553,7 @@ void mlxsw_sp_acl_rulei_keymask_buf(struct mlxsw_sp_acl_rule_info *rulei, int mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, u16 group_id); +int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c index 0897a5435cc2..92d90ed7207e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c @@ -528,6 +528,11 @@ int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, return mlxsw_afa_block_jump(rulei->act_block, group_id); } +int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei) +{ + return mlxsw_afa_block_terminate(rulei->act_block); +} + int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei) { return mlxsw_afa_block_append_drop(rulei->act_block); diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c index 6ce00e28d4ea..89dbf569dff5 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c @@ -65,7 +65,7 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, tcf_exts_to_list(exts, &actions); list_for_each_entry(a, &actions, list) { if (is_tcf_gact_ok(a)) { - err = mlxsw_sp_acl_rulei_act_continue(rulei); + err = mlxsw_sp_acl_rulei_act_terminate(rulei); if (err) return err; } else if (is_tcf_gact_shot(a)) { From 663f1b26f9c129aa2912c1a1d3359e3ecd88e814 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Fri, 9 Mar 2018 15:33:53 +0200 Subject: [PATCH 570/942] mlxsw: spectrum: Prevent duplicate mirrors The Spectrum ASIC doesn't support mirroring more than once from a single binding point (which is a port-direction pair). Therefore detect that a second binding of a given binding point is attempted. To that end, extend struct mlxsw_sp_span_inspected_port to track whether a given binding point is bound or not. Extend mlxsw_sp_span_entry_port_find() to look for ports based on the full unique key: port number, direction, and boundness. Besides fixing the overt bug where configured mirrors are not offloaded, this also fixes a more subtle bug: mlxsw_sp_span_inspected_port_del() just defers to mlxsw_sp_span_entry_bound_port_find(), and that used to find the first port with the right number (disregarding the type). Thus by adding and removing egress and ingress mirrors in the right order, one could trick the system into believing it has no egress mirrors when in fact it did have some. That then caused that mlxsw_sp_span_port_mtu_update() didn't update mirroring buffer when MTU was changed. Fixes: 763b4b70afcd ("mlxsw: spectrum: Add support in matchall mirror TC offloading") Signed-off-by: Petr Machata Signed-off-by: Ido Schimmel Signed-off-by: David S. Miller --- .../net/ethernet/mellanox/mlxsw/spectrum.c | 28 ++++++++++++++++--- .../net/ethernet/mellanox/mlxsw/spectrum.h | 3 ++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c index c7e941aecc2a..bf400c75fcc8 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c @@ -655,13 +655,17 @@ static int mlxsw_sp_span_port_mtu_update(struct mlxsw_sp_port *port, u16 mtu) } static struct mlxsw_sp_span_inspected_port * -mlxsw_sp_span_entry_bound_port_find(struct mlxsw_sp_port *port, - struct mlxsw_sp_span_entry *span_entry) +mlxsw_sp_span_entry_bound_port_find(struct mlxsw_sp_span_entry *span_entry, + enum mlxsw_sp_span_type type, + struct mlxsw_sp_port *port, + bool bind) { struct mlxsw_sp_span_inspected_port *p; list_for_each_entry(p, &span_entry->bound_ports_list, list) - if (port->local_port == p->local_port) + if (type == p->type && + port->local_port == p->local_port && + bind == p->bound) return p; return NULL; } @@ -691,8 +695,22 @@ mlxsw_sp_span_inspected_port_add(struct mlxsw_sp_port *port, struct mlxsw_sp_span_inspected_port *inspected_port; struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp; char sbib_pl[MLXSW_REG_SBIB_LEN]; + int i; int err; + /* A given (source port, direction) can only be bound to one analyzer, + * so if a binding is requested, check for conflicts. + */ + if (bind) + for (i = 0; i < mlxsw_sp->span.entries_count; i++) { + struct mlxsw_sp_span_entry *curr = + &mlxsw_sp->span.entries[i]; + + if (mlxsw_sp_span_entry_bound_port_find(curr, type, + port, bind)) + return -EEXIST; + } + /* if it is an egress SPAN, bind a shared buffer to it */ if (type == MLXSW_SP_SPAN_EGRESS) { u32 buffsize = mlxsw_sp_span_mtu_to_buffsize(mlxsw_sp, @@ -720,6 +738,7 @@ mlxsw_sp_span_inspected_port_add(struct mlxsw_sp_port *port, } inspected_port->local_port = port->local_port; inspected_port->type = type; + inspected_port->bound = bind; list_add_tail(&inspected_port->list, &span_entry->bound_ports_list); return 0; @@ -746,7 +765,8 @@ mlxsw_sp_span_inspected_port_del(struct mlxsw_sp_port *port, struct mlxsw_sp *mlxsw_sp = port->mlxsw_sp; char sbib_pl[MLXSW_REG_SBIB_LEN]; - inspected_port = mlxsw_sp_span_entry_bound_port_find(port, span_entry); + inspected_port = mlxsw_sp_span_entry_bound_port_find(span_entry, type, + port, bind); if (!inspected_port) return; diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h index 386861773476..92064db2ae44 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h @@ -120,6 +120,9 @@ struct mlxsw_sp_span_inspected_port { struct list_head list; enum mlxsw_sp_span_type type; u8 local_port; + + /* Whether this is a directly bound mirror (port-to-port) or an ACL. */ + bool bound; }; struct mlxsw_sp_span_entry { From 3b04caab81649a9e8d5375b919b6653d791951df Mon Sep 17 00:00:00 2001 From: William Tu Date: Fri, 9 Mar 2018 07:34:40 -0800 Subject: [PATCH 571/942] ip6gre: add erspan v2 to tunnel lookup The patch adds the erspan v2 proto in ip6gre_tunnel_lookup so the erspan v2 tunnel can be found correctly. Signed-off-by: William Tu Signed-off-by: David S. Miller --- net/ipv6/ip6_gre.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 3c353125546d..83c2fffd40be 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -126,7 +126,8 @@ static struct ip6_tnl *ip6gre_tunnel_lookup(struct net_device *dev, struct ip6_tnl *t, *cand = NULL; struct ip6gre_net *ign = net_generic(net, ip6gre_net_id); int dev_type = (gre_proto == htons(ETH_P_TEB) || - gre_proto == htons(ETH_P_ERSPAN)) ? + gre_proto == htons(ETH_P_ERSPAN) || + gre_proto == htons(ETH_P_ERSPAN2)) ? ARPHRD_ETHER : ARPHRD_IP6GRE; int score, cand_score = 4; From d6aa71197ffcb68850bfebfc3fc160abe41df53b Mon Sep 17 00:00:00 2001 From: William Tu Date: Fri, 9 Mar 2018 07:34:41 -0800 Subject: [PATCH 572/942] ip6erspan: improve error handling for erspan version number. When users fill in incorrect erspan version number through the struct erspan_metadata uapi, current code skips pushing the erspan header but continue pushing the gre header, which is incorrect. The patch fixes it by returning error. Signed-off-by: William Tu Signed-off-by: David S. Miller --- net/ipv6/ip6_gre.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index 83c2fffd40be..a299f5424e16 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -945,6 +945,8 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, md->u.md2.dir, get_hwid(&md->u.md2), truncate, false); + } else { + goto tx_err; } } else { switch (skb->protocol) { From e41c7c68ea771683cae5a7f81c268f38d7912ecb Mon Sep 17 00:00:00 2001 From: William Tu Date: Fri, 9 Mar 2018 07:34:42 -0800 Subject: [PATCH 573/942] ip6erspan: make sure enough headroom at xmit. The patch adds skb_cow_header() to ensure enough headroom at ip6erspan_tunnel_xmit before pushing the erspan header to the skb. Signed-off-by: William Tu Signed-off-by: David S. Miller --- net/ipv6/ip6_gre.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c index a299f5424e16..1bbd0930063e 100644 --- a/net/ipv6/ip6_gre.c +++ b/net/ipv6/ip6_gre.c @@ -903,6 +903,9 @@ static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb, truncate = true; } + if (skb_cow_head(skb, dev->needed_headroom)) + goto tx_err; + t->parms.o_flags &= ~TUNNEL_KEY; IPCB(skb)->flags = 0; From d6c931ea32dc08ac2665bb5f009f9c40ad1bbdb3 Mon Sep 17 00:00:00 2001 From: Fredrik Noring Date: Fri, 9 Mar 2018 18:34:34 +0100 Subject: [PATCH 574/942] USB: OHCI: Fix NULL dereference in HCDs using HCD_LOCAL_MEM Scatter-gather needs to be disabled when using dma_declare_coherent_memory and HCD_LOCAL_MEM. Andrea Righi made the equivalent fix for EHCI drivers in commit 4307a28eb01284 "USB: EHCI: fix NULL pointer dererence in HCDs that use HCD_LOCAL_MEM". The following NULL pointer WARN_ON_ONCE triggered with OHCI drivers: ------------[ cut here ]------------ WARNING: CPU: 0 PID: 49 at drivers/usb/core/hcd.c:1379 hcd_alloc_coherent+0x4c/0xc8 Modules linked in: CPU: 0 PID: 49 Comm: usb-storage Not tainted 4.15.0+ #1014 Stack : 00000000 00000000 805a78d2 0000003a 81f5c2cc 8053d367 804d77fc 00000031 805a3a08 00000563 81ee9400 805a0000 00000000 10058c00 81f61b10 805c0000 00000000 00000000 805a0000 00d9038e 00000004 803ee818 00000006 312e3420 805c0000 00000000 00000073 81f61958 00000000 00000000 802eb380 804fd538 00000009 00000563 81ee9400 805a0000 00000002 80056148 00000000 805a0000 ... Call Trace: [<578af360>] show_stack+0x74/0x104 [<2f3702c6>] __warn+0x118/0x120 [] warn_slowpath_null+0x44/0x58 [] hcd_alloc_coherent+0x4c/0xc8 [<3578fa36>] usb_hcd_map_urb_for_dma+0x4d8/0x534 [<110bc94c>] usb_hcd_submit_urb+0x82c/0x834 [<02eb5baf>] usb_sg_wait+0x14c/0x1a0 [] usb_stor_bulk_transfer_sglist.part.1+0xac/0x124 [<87a5c34c>] usb_stor_bulk_srb+0x40/0x60 [] usb_stor_Bulk_transport+0x160/0x37c [] usb_stor_invoke_transport+0x3c/0x500 [<004754f4>] usb_stor_control_thread+0x258/0x28c [<22edf42e>] kthread+0x134/0x13c [] ret_from_kernel_thread+0x14/0x1c ---[ end trace bcdb825805eefdcc ]--- Signed-off-by: Fredrik Noring Acked-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/ohci-hcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 84f88fa411cd..d088c340e4d0 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -447,7 +447,8 @@ static int ohci_init (struct ohci_hcd *ohci) struct usb_hcd *hcd = ohci_to_hcd(ohci); /* Accept arbitrarily long scatter-gather lists */ - hcd->self.sg_tablesize = ~0; + if (!(hcd->driver->flags & HCD_LOCAL_MEM)) + hcd->self.sg_tablesize = ~0; if (distrust_firmware) ohci->flags |= OHCI_QUIRK_HUB_POWER; From 7832f6d12fa25cd4cfc18eaae67eb5e2dbaa2c34 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Sun, 25 Feb 2018 16:20:01 +0100 Subject: [PATCH 575/942] usb: typec: tcpm: fusb302: Do not log an error on -EPROBE_DEFER Do not log an error if tcpm_register_port() fails with -EPROBE_DEFER. Fixes: cf140a356971 ("typec: fusb302: Use dev_err during probe") Signed-off-by: Hans de Goede Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/fusb302/fusb302.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/typec/fusb302/fusb302.c b/drivers/usb/typec/fusb302/fusb302.c index 9ce4756adad6..dcd8ef085b30 100644 --- a/drivers/usb/typec/fusb302/fusb302.c +++ b/drivers/usb/typec/fusb302/fusb302.c @@ -1857,7 +1857,8 @@ static int fusb302_probe(struct i2c_client *client, chip->tcpm_port = tcpm_register_port(&client->dev, &chip->tcpc_dev); if (IS_ERR(chip->tcpm_port)) { ret = PTR_ERR(chip->tcpm_port); - dev_err(dev, "cannot register tcpm port, ret=%d", ret); + if (ret != -EPROBE_DEFER) + dev_err(dev, "cannot register tcpm port, ret=%d", ret); goto destroy_workqueue; } From 3c3e4b3a708a9d6451052e348981f37d2b3e92b0 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 8 Mar 2018 12:31:53 +0300 Subject: [PATCH 576/942] iio: adc: meson-saradc: unlock on error in meson_sar_adc_lock() The meson_sar_adc_lock() function is not supposed to hold the "indio_dev->mlock" on the error path. Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs") Signed-off-by: Dan Carpenter Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 29fa7736d80c..ede955d9b2a4 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -462,8 +462,10 @@ static int meson_sar_adc_lock(struct iio_dev *indio_dev) regmap_read(priv->regmap, MESON_SAR_ADC_DELAY, &val); } while (val & MESON_SAR_ADC_DELAY_BL30_BUSY && timeout--); - if (timeout < 0) + if (timeout < 0) { + mutex_unlock(&indio_dev->mlock); return -ETIMEDOUT; + } } return 0; From cc4e0036311fbb0b2cab7dc8f142f84ebd8b388b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 10 Mar 2018 16:21:32 +0000 Subject: [PATCH 577/942] Revert "iio: accel: st_accel: remove redundant pointer pdata" This reverts commit 585ed27d06151f98e39238298f43ee261314ae74. This removed code which was unused due to a bug in commit 7383d44b. To fix this bug the code is needed. Thus this revert. Signed-off-by: Michael Nosthoff Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 6fe995cf16a6..460aa58e0159 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -920,6 +920,8 @@ static const struct iio_trigger_ops st_accel_trigger_ops = { int st_accel_common_probe(struct iio_dev *indio_dev) { struct st_sensor_data *adata = iio_priv(indio_dev); + struct st_sensors_platform_data *pdata = + (struct st_sensors_platform_data *)adata->dev->platform_data; int irq = adata->get_irq_data_ready(indio_dev); int err; @@ -946,6 +948,9 @@ int st_accel_common_probe(struct iio_dev *indio_dev) &adata->sensor_settings->fs.fs_avl[0]; adata->odr = adata->sensor_settings->odr.odr_avl[0].hz; + if (!pdata) + pdata = (struct st_sensors_platform_data *)&default_accel_pdata; + err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); if (err < 0) goto st_accel_power_off; From 8b438686a001db64c21782d04ef68111e53c45d9 Mon Sep 17 00:00:00 2001 From: Michael Nosthoff Date: Fri, 9 Mar 2018 10:02:45 +0100 Subject: [PATCH 578/942] iio: st_pressure: st_accel: pass correct platform data to init Commit 7383d44b added a pointer pdata which get set to the default platform_data when non was defined in the device. But it did not pass this pointer to the st_sensors_init_sensor call but still used the maybe uninitialized platform_data from dev. This breaks initialization when no platform_data is given and the optional st,drdy-int-pin devicetree option is not set. This commit fixes this. Cc: stable@vger.kernel.org Fixes: 7383d44b ("iio: st_pressure: st_accel: Initialise sensor platform data properly") Signed-off-by: Michael Nosthoff Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_core.c | 2 +- drivers/iio/pressure/st_pressure_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 460aa58e0159..3e6fd5a8ac5b 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -951,7 +951,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) if (!pdata) pdata = (struct st_sensors_platform_data *)&default_accel_pdata; - err = st_sensors_init_sensor(indio_dev, adata->dev->platform_data); + err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) goto st_accel_power_off; diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c index 349e5c713c03..4ddb6cf7d401 100644 --- a/drivers/iio/pressure/st_pressure_core.c +++ b/drivers/iio/pressure/st_pressure_core.c @@ -640,7 +640,7 @@ int st_press_common_probe(struct iio_dev *indio_dev) press_data->sensor_settings->drdy_irq.int2.addr)) pdata = (struct st_sensors_platform_data *)&default_press_pdata; - err = st_sensors_init_sensor(indio_dev, press_data->dev->platform_data); + err = st_sensors_init_sensor(indio_dev, pdata); if (err < 0) goto st_press_power_off; From 4f2c7583e33eb08dc09dd2e25574b80175ba7d93 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 6 Mar 2018 15:51:32 +0000 Subject: [PATCH 579/942] irqchip/gic-v3-its: Ensure nr_ites >= nr_lpis When struct its_device instances are created, the nr_ites member will be set to a power of 2 that equals or exceeds the requested number of MSIs passed to the msi_prepare() callback. At the same time, the LPI map is allocated to be some multiple of 32 in size, where the allocated size may be less than the requested size depending on whether a contiguous range of sufficient size is available in the global LPI bitmap. This may result in the situation where the nr_ites < nr_lpis, and since nr_ites is what we program into the hardware when we map the device, the additional LPIs will be non-functional. For bog standard hardware, this does not really matter. However, in cases where ITS device IDs are shared between different PCIe devices, we may end up allocating these additional LPIs without taking into account that they don't actually work. So let's make nr_ites at least 32. This ensures that all allocated LPIs are 'live', and that its_alloc_device_irq() will fail when attempts are made to allocate MSIs beyond what was allocated in the first place. Signed-off-by: Ard Biesheuvel [maz: updated comment] Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic-v3-its.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 94b7d74d519f..2cbb19cddbf8 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -1412,7 +1412,7 @@ static struct irq_chip its_irq_chip = { * This gives us (((1UL << id_bits) - 8192) >> 5) possible allocations. */ #define IRQS_PER_CHUNK_SHIFT 5 -#define IRQS_PER_CHUNK (1 << IRQS_PER_CHUNK_SHIFT) +#define IRQS_PER_CHUNK (1UL << IRQS_PER_CHUNK_SHIFT) #define ITS_MAX_LPI_NRBITS 16 /* 64K LPIs */ static unsigned long *lpi_bitmap; @@ -2119,11 +2119,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, dev = kzalloc(sizeof(*dev), GFP_KERNEL); /* - * At least one bit of EventID is being used, hence a minimum - * of two entries. No, the architecture doesn't let you - * express an ITT with a single entry. + * We allocate at least one chunk worth of LPIs bet device, + * and thus that many ITEs. The device may require less though. */ - nr_ites = max(2UL, roundup_pow_of_two(nvecs)); + nr_ites = max(IRQS_PER_CHUNK, roundup_pow_of_two(nvecs)); sz = nr_ites * its->ite_size; sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1; itt = kzalloc(sz, GFP_KERNEL); From 61b8b22858b9cfa5df52fc0e4893aebfe0bbb804 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 12 Feb 2018 11:12:56 -0200 Subject: [PATCH 580/942] irqchip/irq-imx-gpcv2: Remove unused function imx_gpcv2_get_wakeup_source() is not used anywhere, so remove it. This fixes the following sparse warning: drivers/irqchip/irq-imx-gpcv2.c:34:5: warning: symbol 'imx_gpcv2_get_wakeup_source' was not declared. Should it be static? Fixes: e324c4dc4a59 ("irqchip/imx-gpcv2: IMX GPCv2 driver for wakeup sources") Signed-off-by: Fabio Estevam Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-imx-gpcv2.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c index 675eda5ff2b8..4760307ab43f 100644 --- a/drivers/irqchip/irq-imx-gpcv2.c +++ b/drivers/irqchip/irq-imx-gpcv2.c @@ -28,20 +28,6 @@ struct gpcv2_irqchip_data { static struct gpcv2_irqchip_data *imx_gpcv2_instance; -/* - * Interface for the low level wakeup code. - */ -u32 imx_gpcv2_get_wakeup_source(u32 **sources) -{ - if (!imx_gpcv2_instance) - return 0; - - if (sources) - *sources = imx_gpcv2_instance->wakeup_sources; - - return IMR_NUM; -} - static int gpcv2_wakeup_source_save(void) { struct gpcv2_irqchip_data *cd; From 932909d9b28d27e807ff8eecb68c7748f6701628 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Thu, 8 Mar 2018 12:54:19 +0100 Subject: [PATCH 581/942] netfilter: ebtables: fix erroneous reject of last rule The last rule in the blob has next_entry offset that is same as total size. This made "ebtables32 -A OUTPUT -d de:ad:be:ef:01:02" fail on 64 bit kernel. Fixes: b71812168571fa ("netfilter: ebtables: CONFIG_COMPAT: don't trust userland offsets") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- net/bridge/netfilter/ebtables.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 254ef9f49567..a94d23b0a9af 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -2119,8 +2119,12 @@ static int size_entry_mwt(struct ebt_entry *entry, const unsigned char *base, * offsets are relative to beginning of struct ebt_entry (i.e., 0). */ for (i = 0; i < 4 ; ++i) { - if (offsets[i] >= *total) + if (offsets[i] > *total) return -EINVAL; + + if (i < 3 && offsets[i] == *total) + return -EINVAL; + if (i == 0) continue; if (offsets[i-1] > offsets[i]) From b1d0a5d0cba4597c0394997b2d5fced3e3841b4e Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Sat, 10 Mar 2018 01:15:45 +0100 Subject: [PATCH 582/942] netfilter: x_tables: add and use xt_check_proc_name recent and hashlimit both create /proc files, but only check that name is 0 terminated. This can trigger WARN() from procfs when name is "" or "/". Add helper for this and then use it for both. Cc: Eric Dumazet Reported-by: Eric Dumazet Reported-by: Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- include/linux/netfilter/x_tables.h | 2 ++ net/netfilter/x_tables.c | 30 ++++++++++++++++++++++++++++++ net/netfilter/xt_hashlimit.c | 16 ++++++++++------ net/netfilter/xt_recent.c | 6 +++--- 4 files changed, 45 insertions(+), 9 deletions(-) diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 1313b35c3ab7..14529511c4b8 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h @@ -285,6 +285,8 @@ unsigned int *xt_alloc_entry_offsets(unsigned int size); bool xt_find_jump_offset(const unsigned int *offsets, unsigned int target, unsigned int size); +int xt_check_proc_name(const char *name, unsigned int size); + int xt_check_match(struct xt_mtchk_param *, unsigned int size, u_int8_t proto, bool inv_proto); int xt_check_target(struct xt_tgchk_param *, unsigned int size, u_int8_t proto, diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index fa1655aff8d3..4aa01c90e9d1 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c @@ -423,6 +423,36 @@ textify_hooks(char *buf, size_t size, unsigned int mask, uint8_t nfproto) return buf; } +/** + * xt_check_proc_name - check that name is suitable for /proc file creation + * + * @name: file name candidate + * @size: length of buffer + * + * some x_tables modules wish to create a file in /proc. + * This function makes sure that the name is suitable for this + * purpose, it checks that name is NUL terminated and isn't a 'special' + * name, like "..". + * + * returns negative number on error or 0 if name is useable. + */ +int xt_check_proc_name(const char *name, unsigned int size) +{ + if (name[0] == '\0') + return -EINVAL; + + if (strnlen(name, size) == size) + return -ENAMETOOLONG; + + if (strcmp(name, ".") == 0 || + strcmp(name, "..") == 0 || + strchr(name, '/')) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL(xt_check_proc_name); + int xt_check_match(struct xt_mtchk_param *par, unsigned int size, u_int8_t proto, bool inv_proto) { diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 66f5aca62a08..3360f13dc208 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c @@ -917,8 +917,9 @@ static int hashlimit_mt_check_v1(const struct xt_mtchk_param *par) struct hashlimit_cfg3 cfg = {}; int ret; - if (info->name[sizeof(info->name) - 1] != '\0') - return -EINVAL; + ret = xt_check_proc_name(info->name, sizeof(info->name)); + if (ret) + return ret; ret = cfg_copy(&cfg, (void *)&info->cfg, 1); @@ -935,8 +936,9 @@ static int hashlimit_mt_check_v2(const struct xt_mtchk_param *par) struct hashlimit_cfg3 cfg = {}; int ret; - if (info->name[sizeof(info->name) - 1] != '\0') - return -EINVAL; + ret = xt_check_proc_name(info->name, sizeof(info->name)); + if (ret) + return ret; ret = cfg_copy(&cfg, (void *)&info->cfg, 2); @@ -950,9 +952,11 @@ static int hashlimit_mt_check_v2(const struct xt_mtchk_param *par) static int hashlimit_mt_check(const struct xt_mtchk_param *par) { struct xt_hashlimit_mtinfo3 *info = par->matchinfo; + int ret; - if (info->name[sizeof(info->name) - 1] != '\0') - return -EINVAL; + ret = xt_check_proc_name(info->name, sizeof(info->name)); + if (ret) + return ret; return hashlimit_mt_check_common(par, &info->hinfo, &info->cfg, info->name, 3); diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c index 6d232d18faff..81ee1d6543b2 100644 --- a/net/netfilter/xt_recent.c +++ b/net/netfilter/xt_recent.c @@ -361,9 +361,9 @@ static int recent_mt_check(const struct xt_mtchk_param *par, info->hit_count, XT_RECENT_MAX_NSTAMPS - 1); return -EINVAL; } - if (info->name[0] == '\0' || - strnlen(info->name, XT_RECENT_NAME_LEN) == XT_RECENT_NAME_LEN) - return -EINVAL; + ret = xt_check_proc_name(info->name, sizeof(info->name)); + if (ret) + return ret; if (ip_pkt_list_tot && info->hit_count < ip_pkt_list_tot) nstamp_mask = roundup_pow_of_two(ip_pkt_list_tot) - 1; From c8d70a700a5b486bfa8e5a7d33d805389f6e59f9 Mon Sep 17 00:00:00 2001 From: Florian Westphal Date: Fri, 9 Mar 2018 14:27:31 +0100 Subject: [PATCH 583/942] netfilter: bridge: ebt_among: add more missing match size checks ebt_among is special, it has a dynamic match size and is exempt from the central size checks. commit c4585a2823edf ("bridge: ebt_among: add missing match size checks") added validation for pool size, but missed fact that the macros ebt_among_wh_src/dst can already return out-of-bound result because they do not check value of wh_src/dst_ofs (an offset) vs. the size of the match that userspace gave to us. v2: check that offset has correct alignment. Paolo Abeni points out that we should also check that src/dst wormhash arrays do not overlap, and src + length lines up with start of dst (or vice versa). v3: compact wormhash_sizes_valid() part NB: Fixes tag is intentionally wrong, this bug exists from day one when match was added for 2.6 kernel. Tag is there so stable maintainers will notice this one too. Tested with same rules from the earlier patch. Fixes: c4585a2823edf ("bridge: ebt_among: add missing match size checks") Reported-by: Signed-off-by: Florian Westphal Reviewed-by: Eric Dumazet Signed-off-by: Pablo Neira Ayuso --- net/bridge/netfilter/ebt_among.c | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/net/bridge/netfilter/ebt_among.c b/net/bridge/netfilter/ebt_among.c index c5afb4232ecb..620e54f08296 100644 --- a/net/bridge/netfilter/ebt_among.c +++ b/net/bridge/netfilter/ebt_among.c @@ -177,6 +177,28 @@ static bool poolsize_invalid(const struct ebt_mac_wormhash *w) return w && w->poolsize >= (INT_MAX / sizeof(struct ebt_mac_wormhash_tuple)); } +static bool wormhash_offset_invalid(int off, unsigned int len) +{ + if (off == 0) /* not present */ + return false; + + if (off < (int)sizeof(struct ebt_among_info) || + off % __alignof__(struct ebt_mac_wormhash)) + return true; + + off += sizeof(struct ebt_mac_wormhash); + + return off > len; +} + +static bool wormhash_sizes_valid(const struct ebt_mac_wormhash *wh, int a, int b) +{ + if (a == 0) + a = sizeof(struct ebt_among_info); + + return ebt_mac_wormhash_size(wh) + a == b; +} + static int ebt_among_mt_check(const struct xt_mtchk_param *par) { const struct ebt_among_info *info = par->matchinfo; @@ -189,6 +211,10 @@ static int ebt_among_mt_check(const struct xt_mtchk_param *par) if (expected_length > em->match_size) return -EINVAL; + if (wormhash_offset_invalid(info->wh_dst_ofs, em->match_size) || + wormhash_offset_invalid(info->wh_src_ofs, em->match_size)) + return -EINVAL; + wh_dst = ebt_among_wh_dst(info); if (poolsize_invalid(wh_dst)) return -EINVAL; @@ -201,6 +227,14 @@ static int ebt_among_mt_check(const struct xt_mtchk_param *par) if (poolsize_invalid(wh_src)) return -EINVAL; + if (info->wh_src_ofs < info->wh_dst_ofs) { + if (!wormhash_sizes_valid(wh_src, info->wh_src_ofs, info->wh_dst_ofs)) + return -EINVAL; + } else { + if (!wormhash_sizes_valid(wh_dst, info->wh_dst_ofs, info->wh_src_ofs)) + return -EINVAL; + } + expected_length += ebt_mac_wormhash_size(wh_src); if (em->match_size != EBT_ALIGN(expected_length)) { From c04a3f730021c304c7cc4bc30ee57ee70ad98d57 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Fri, 9 Mar 2018 18:56:26 +0100 Subject: [PATCH 584/942] netfilter: nf_tables: release flowtable hooks Otherwise we leak this array. Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_tables_api.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index 558593e6a0a3..c4acc7340eb1 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c @@ -5423,6 +5423,7 @@ err: static void nf_tables_flowtable_destroy(struct nft_flowtable *flowtable) { cancel_delayed_work_sync(&flowtable->data.gc_work); + kfree(flowtable->ops); kfree(flowtable->name); flowtable->data.type->free(&flowtable->data); rhashtable_destroy(&flowtable->data.rhashtable); From 7f95beea36089918335eb1810ddd7ba8cf9d09cc Mon Sep 17 00:00:00 2001 From: Shawn Lin Date: Thu, 8 Mar 2018 14:49:41 +0800 Subject: [PATCH 585/942] clk: update cached phase to respect the fact when setting phase It's found that the final phase set by driver doesn't match that of the output from clk_summary: dwmmc_rockchip fe310000.dwmmc: Successfully tuned phase to 346 mmc0: new ultra high speed SDR104 SDIO card at address 0001 cat /sys/kernel/debug/clk/clk_summary | grep sdio_sample sdio_sample 0 1 0 50000000 0 0 It seems the cached core->phase isn't updated after the clk was registered. So fix this issue by updating the core->phase if setting phase successfully. Fixes: 9e4d04adeb1a ("clk: add clk_core_set_phase_nolock function") Cc: Stable Cc: Jerome Brunet Signed-off-by: Shawn Lin Reviewed-by: Jerome Brunet Tested-by: Jerome Brunet Signed-off-by: Michael Turquette --- drivers/clk/clk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f686a9dac3e..617e56268b18 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2309,8 +2309,11 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees) trace_clk_set_phase(core, degrees); - if (core->ops->set_phase) + if (core->ops->set_phase) { ret = core->ops->set_phase(core->hw, degrees); + if (!ret) + core->phase = degrees; + } trace_clk_set_phase_complete(core, degrees); From 13fbcc8dc573482dd3f27568257fd7087f8935f4 Mon Sep 17 00:00:00 2001 From: Shannon Nelson Date: Thu, 8 Mar 2018 16:17:23 -0800 Subject: [PATCH 586/942] macvlan: filter out unsupported feature flags Adding a macvlan device on top of a lowerdev that supports the xfrm offloads fails with a new regression: # ip link add link ens1f0 mv0 type macvlan RTNETLINK answers: Operation not permitted Tracing down the failure shows that the macvlan device inherits the NETIF_F_HW_ESP and NETIF_F_HW_ESP_TX_CSUM feature flags from the lowerdev, but with no dev->xfrmdev_ops API filled in, it doesn't actually support xfrm. When the request is made to add the new macvlan device, the XFRM listener for NETDEV_REGISTER calls xfrm_api_check() which fails the new registration because dev->xfrmdev_ops is NULL. The macvlan creation succeeds when we filter out the ESP feature flags in macvlan_fix_features(), so let's filter them out like we're already filtering out ~NETIF_F_NETNS_LOCAL. When XFRM support is added in the future, we can add the flags into MACVLAN_FEATURES. This same problem could crop up in the future with any other new feature flags, so let's filter out any flags that aren't defined as supported in macvlan. Fixes: d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API") Reported-by: Alexey Kodanev Signed-off-by: Shannon Nelson Signed-off-by: David S. Miller --- drivers/net/macvlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 8fc02d9db3d0..725f4b4afc6d 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -1036,7 +1036,7 @@ static netdev_features_t macvlan_fix_features(struct net_device *dev, lowerdev_features &= (features | ~NETIF_F_LRO); features = netdev_increment_features(lowerdev_features, features, mask); features |= ALWAYS_ON_FEATURES; - features &= ~NETIF_F_NETNS_LOCAL; + features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES); return features; } From ddc502dfed600bff0b61d899f70d95b76223fdfc Mon Sep 17 00:00:00 2001 From: zhangliping Date: Fri, 9 Mar 2018 10:08:50 +0800 Subject: [PATCH 587/942] openvswitch: meter: fix the incorrect calculation of max delta_t Max delat_t should be the full_bucket/rate instead of the full_bucket. Also report EINVAL if the rate is zero. Fixes: 96fbc13d7e77 ("openvswitch: Add meter infrastructure") Cc: Andy Zhou Signed-off-by: zhangliping Acked-by: Pravin B Shelar Signed-off-by: David S. Miller --- net/openvswitch/meter.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c index 04b94281a30b..b891a91577f8 100644 --- a/net/openvswitch/meter.c +++ b/net/openvswitch/meter.c @@ -242,14 +242,20 @@ static struct dp_meter *dp_meter_create(struct nlattr **a) band->type = nla_get_u32(attr[OVS_BAND_ATTR_TYPE]); band->rate = nla_get_u32(attr[OVS_BAND_ATTR_RATE]); + if (band->rate == 0) { + err = -EINVAL; + goto exit_free_meter; + } + band->burst_size = nla_get_u32(attr[OVS_BAND_ATTR_BURST]); /* Figure out max delta_t that is enough to fill any bucket. * Keep max_delta_t size to the bucket units: * pkts => 1/1000 packets, kilobits => bits. + * + * Start with a full bucket. */ - band_max_delta_t = (band->burst_size + band->rate) * 1000; - /* Start with a full bucket. */ - band->bucket = band_max_delta_t; + band->bucket = (band->burst_size + band->rate) * 1000; + band_max_delta_t = band->bucket / band->rate; if (band_max_delta_t > meter->max_delta_t) meter->max_delta_t = band_max_delta_t; band++; From b7db978ac283b237835129ac87f26cbac94d04e7 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Tue, 6 Feb 2018 09:52:07 +0100 Subject: [PATCH 588/942] can: m_can: change comparison to bitshift when dealing with a mask Due to a typo, the mask was destroyed by a comparison instead of a bit shift. Reported-by: Geert Uytterhoeven Signed-off-by: Wolfram Sang Signed-off-by: Marc Kleine-Budde --- drivers/net/can/m_can/m_can.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 2594f7779c6f..74170b0d23cf 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -253,7 +253,7 @@ enum m_can_mram_cfg { /* Rx FIFO 0/1 Configuration (RXF0C/RXF1C) */ #define RXFC_FWM_SHIFT 24 -#define RXFC_FWM_MASK (0x7f < RXFC_FWM_SHIFT) +#define RXFC_FWM_MASK (0x7f << RXFC_FWM_SHIFT) #define RXFC_FS_SHIFT 16 #define RXFC_FS_MASK (0x7f << RXFC_FS_SHIFT) From 591d65d5b15496af8d05e252bc1da611c66c0b79 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Mon, 5 Mar 2018 21:29:52 +0100 Subject: [PATCH 589/942] can: ifi: Check core revision upon probe Older versions of the core are not compatible with the driver due to various intrusive fixes of the core. Read out the VER register, check the core revision bitfield and verify if the core in use is new enough (rev 2.1 or newer) to work correctly with this driver. Signed-off-by: Marek Vasut Cc: Heiko Schocher Cc: Markus Marb Cc: Marc Kleine-Budde Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/ifi_canfd/ifi_canfd.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index 2772d05ff11c..9fd396c3569a 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -136,6 +136,8 @@ #define IFI_CANFD_SYSCLOCK 0x50 #define IFI_CANFD_VER 0x54 +#define IFI_CANFD_VER_REV_MASK 0xff +#define IFI_CANFD_VER_REV_MIN_SUPPORTED 0x15 #define IFI_CANFD_IP_ID 0x58 #define IFI_CANFD_IP_ID_VALUE 0xD073CAFD @@ -933,7 +935,7 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev) struct resource *res; void __iomem *addr; int irq, ret; - u32 id; + u32 id, rev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); addr = devm_ioremap_resource(dev, res); @@ -947,6 +949,13 @@ static int ifi_canfd_plat_probe(struct platform_device *pdev) return -EINVAL; } + rev = readl(addr + IFI_CANFD_VER) & IFI_CANFD_VER_REV_MASK; + if (rev < IFI_CANFD_VER_REV_MIN_SUPPORTED) { + dev_err(dev, "This block is too old (rev %i), minimum supported is rev %i\n", + rev, IFI_CANFD_VER_REV_MIN_SUPPORTED); + return -EINVAL; + } + ndev = alloc_candev(sizeof(*priv), 1); if (!ndev) return -ENOMEM; From 880dd464b4304583c557c4e5f5ecebfd55d232b1 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Thu, 1 Mar 2018 19:34:00 +0100 Subject: [PATCH 590/942] can: ifi: Repair the error handling The new version of the IFI CANFD core has significantly less complex error state indication logic. In particular, the warning/error state bits are no longer all over the place, but are all present in the STATUS register. Moreover, there is a new IRQ register bit indicating transition between error states (active/warning/passive/busoff). This patch makes use of this bit to weed out the obscure selective INTERRUPT register clearing, which was used to carry over the error state indication into the poll function. While at it, this patch fixes the handling of the ACTIVE state, since the hardware provides indication of the core being in ACTIVE state and that in turn fixes the state transition indication toward userspace. Finally, register reads in the poll function are moved to the matching subfunctions since those are also no longer needed in the poll function. Signed-off-by: Marek Vasut Cc: Heiko Schocher Cc: Markus Marb Cc: Marc Kleine-Budde Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/ifi_canfd/ifi_canfd.c | 64 ++++++++++++++++----------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/net/can/ifi_canfd/ifi_canfd.c b/drivers/net/can/ifi_canfd/ifi_canfd.c index 9fd396c3569a..fedd927ba6ed 100644 --- a/drivers/net/can/ifi_canfd/ifi_canfd.c +++ b/drivers/net/can/ifi_canfd/ifi_canfd.c @@ -30,6 +30,7 @@ #define IFI_CANFD_STCMD_ERROR_ACTIVE BIT(2) #define IFI_CANFD_STCMD_ERROR_PASSIVE BIT(3) #define IFI_CANFD_STCMD_BUSOFF BIT(4) +#define IFI_CANFD_STCMD_ERROR_WARNING BIT(5) #define IFI_CANFD_STCMD_BUSMONITOR BIT(16) #define IFI_CANFD_STCMD_LOOPBACK BIT(18) #define IFI_CANFD_STCMD_DISABLE_CANFD BIT(24) @@ -52,7 +53,10 @@ #define IFI_CANFD_TXSTCMD_OVERFLOW BIT(13) #define IFI_CANFD_INTERRUPT 0xc +#define IFI_CANFD_INTERRUPT_ERROR_BUSOFF BIT(0) #define IFI_CANFD_INTERRUPT_ERROR_WARNING BIT(1) +#define IFI_CANFD_INTERRUPT_ERROR_STATE_CHG BIT(2) +#define IFI_CANFD_INTERRUPT_ERROR_REC_TEC_INC BIT(3) #define IFI_CANFD_INTERRUPT_ERROR_COUNTER BIT(10) #define IFI_CANFD_INTERRUPT_TXFIFO_EMPTY BIT(16) #define IFI_CANFD_INTERRUPT_TXFIFO_REMOVE BIT(22) @@ -61,6 +65,10 @@ #define IFI_CANFD_INTERRUPT_SET_IRQ ((u32)BIT(31)) #define IFI_CANFD_IRQMASK 0x10 +#define IFI_CANFD_IRQMASK_ERROR_BUSOFF BIT(0) +#define IFI_CANFD_IRQMASK_ERROR_WARNING BIT(1) +#define IFI_CANFD_IRQMASK_ERROR_STATE_CHG BIT(2) +#define IFI_CANFD_IRQMASK_ERROR_REC_TEC_INC BIT(3) #define IFI_CANFD_IRQMASK_SET_ERR BIT(7) #define IFI_CANFD_IRQMASK_SET_TS BIT(15) #define IFI_CANFD_IRQMASK_TXFIFO_EMPTY BIT(16) @@ -222,7 +230,10 @@ static void ifi_canfd_irq_enable(struct net_device *ndev, bool enable) if (enable) { enirq = IFI_CANFD_IRQMASK_TXFIFO_EMPTY | - IFI_CANFD_IRQMASK_RXFIFO_NEMPTY; + IFI_CANFD_IRQMASK_RXFIFO_NEMPTY | + IFI_CANFD_IRQMASK_ERROR_STATE_CHG | + IFI_CANFD_IRQMASK_ERROR_WARNING | + IFI_CANFD_IRQMASK_ERROR_BUSOFF; if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) enirq |= IFI_CANFD_INTERRUPT_ERROR_COUNTER; } @@ -363,12 +374,13 @@ static int ifi_canfd_handle_lost_msg(struct net_device *ndev) return 1; } -static int ifi_canfd_handle_lec_err(struct net_device *ndev, const u32 errctr) +static int ifi_canfd_handle_lec_err(struct net_device *ndev) { struct ifi_canfd_priv *priv = netdev_priv(ndev); struct net_device_stats *stats = &ndev->stats; struct can_frame *cf; struct sk_buff *skb; + u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR); const u32 errmask = IFI_CANFD_ERROR_CTR_OVERLOAD_FIRST | IFI_CANFD_ERROR_CTR_ACK_ERROR_FIRST | IFI_CANFD_ERROR_CTR_BIT0_ERROR_FIRST | @@ -451,6 +463,11 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev, switch (new_state) { case CAN_STATE_ERROR_ACTIVE: + /* error active state */ + priv->can.can_stats.error_warning++; + priv->can.state = CAN_STATE_ERROR_ACTIVE; + break; + case CAN_STATE_ERROR_WARNING: /* error warning state */ priv->can.can_stats.error_warning++; priv->can.state = CAN_STATE_ERROR_WARNING; @@ -479,7 +496,7 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev, ifi_canfd_get_berr_counter(ndev, &bec); switch (new_state) { - case CAN_STATE_ERROR_ACTIVE: + case CAN_STATE_ERROR_WARNING: /* error warning state */ cf->can_id |= CAN_ERR_CRTL; cf->data[1] = (bec.txerr > bec.rxerr) ? @@ -512,22 +529,21 @@ static int ifi_canfd_handle_state_change(struct net_device *ndev, return 1; } -static int ifi_canfd_handle_state_errors(struct net_device *ndev, u32 stcmd) +static int ifi_canfd_handle_state_errors(struct net_device *ndev) { struct ifi_canfd_priv *priv = netdev_priv(ndev); + u32 stcmd = readl(priv->base + IFI_CANFD_STCMD); int work_done = 0; - u32 isr; - /* - * The ErrWarn condition is a little special, since the bit is - * located in the INTERRUPT register instead of STCMD register. - */ - isr = readl(priv->base + IFI_CANFD_INTERRUPT); - if ((isr & IFI_CANFD_INTERRUPT_ERROR_WARNING) && + if ((stcmd & IFI_CANFD_STCMD_ERROR_ACTIVE) && + (priv->can.state != CAN_STATE_ERROR_ACTIVE)) { + netdev_dbg(ndev, "Error, entered active state\n"); + work_done += ifi_canfd_handle_state_change(ndev, + CAN_STATE_ERROR_ACTIVE); + } + + if ((stcmd & IFI_CANFD_STCMD_ERROR_WARNING) && (priv->can.state != CAN_STATE_ERROR_WARNING)) { - /* Clear the interrupt */ - writel(IFI_CANFD_INTERRUPT_ERROR_WARNING, - priv->base + IFI_CANFD_INTERRUPT); netdev_dbg(ndev, "Error, entered warning state\n"); work_done += ifi_canfd_handle_state_change(ndev, CAN_STATE_ERROR_WARNING); @@ -554,18 +570,11 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota) { struct net_device *ndev = napi->dev; struct ifi_canfd_priv *priv = netdev_priv(ndev); - const u32 stcmd_state_mask = IFI_CANFD_STCMD_ERROR_PASSIVE | - IFI_CANFD_STCMD_BUSOFF; + u32 rxstcmd = readl(priv->base + IFI_CANFD_RXSTCMD); int work_done = 0; - u32 stcmd = readl(priv->base + IFI_CANFD_STCMD); - u32 rxstcmd = readl(priv->base + IFI_CANFD_RXSTCMD); - u32 errctr = readl(priv->base + IFI_CANFD_ERROR_CTR); - /* Handle bus state changes */ - if ((stcmd & stcmd_state_mask) || - ((stcmd & IFI_CANFD_STCMD_ERROR_ACTIVE) == 0)) - work_done += ifi_canfd_handle_state_errors(ndev, stcmd); + work_done += ifi_canfd_handle_state_errors(ndev); /* Handle lost messages on RX */ if (rxstcmd & IFI_CANFD_RXSTCMD_OVERFLOW) @@ -573,7 +582,7 @@ static int ifi_canfd_poll(struct napi_struct *napi, int quota) /* Handle lec errors on the bus */ if (priv->can.ctrlmode & CAN_CTRLMODE_BERR_REPORTING) - work_done += ifi_canfd_handle_lec_err(ndev, errctr); + work_done += ifi_canfd_handle_lec_err(ndev); /* Handle normal messages on RX */ if (!(rxstcmd & IFI_CANFD_RXSTCMD_EMPTY)) @@ -594,12 +603,13 @@ static irqreturn_t ifi_canfd_isr(int irq, void *dev_id) struct net_device_stats *stats = &ndev->stats; const u32 rx_irq_mask = IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY | IFI_CANFD_INTERRUPT_RXFIFO_NEMPTY_PER | + IFI_CANFD_INTERRUPT_ERROR_COUNTER | + IFI_CANFD_INTERRUPT_ERROR_STATE_CHG | IFI_CANFD_INTERRUPT_ERROR_WARNING | - IFI_CANFD_INTERRUPT_ERROR_COUNTER; + IFI_CANFD_INTERRUPT_ERROR_BUSOFF; const u32 tx_irq_mask = IFI_CANFD_INTERRUPT_TXFIFO_EMPTY | IFI_CANFD_INTERRUPT_TXFIFO_REMOVE; - const u32 clr_irq_mask = ~((u32)(IFI_CANFD_INTERRUPT_SET_IRQ | - IFI_CANFD_INTERRUPT_ERROR_WARNING)); + const u32 clr_irq_mask = ~((u32)IFI_CANFD_INTERRUPT_SET_IRQ); u32 isr; isr = readl(priv->base + IFI_CANFD_INTERRUPT); From e6048a00cfd0863d32f53b226e0b9a3633fc3332 Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Thu, 8 Mar 2018 09:30:28 +0100 Subject: [PATCH 591/942] can: peak/pcie_fd: fix echo_skb is occupied! bug This patch makes atomic the handling of the linux-can echo_skb array and the network tx queue. This prevents from the "BUG! echo_skb is occupied!" message to be printed by the linux-can core, in SMP environments. Reported-by: Diana Burgess Signed-off-by: Stephane Grosjean Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/peak_canfd/peak_canfd.c | 12 ++++++------ drivers/net/can/peak_canfd/peak_pciefd_main.c | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c index 55513411a82e..6fa66231ed8e 100644 --- a/drivers/net/can/peak_canfd/peak_canfd.c +++ b/drivers/net/can/peak_canfd/peak_canfd.c @@ -262,7 +262,6 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv, spin_lock_irqsave(&priv->echo_lock, flags); can_get_echo_skb(priv->ndev, msg->client); - spin_unlock_irqrestore(&priv->echo_lock, flags); /* count bytes of the echo instead of skb */ stats->tx_bytes += cf_len; @@ -271,6 +270,7 @@ static int pucan_handle_can_rx(struct peak_canfd_priv *priv, /* restart tx queue (a slot is free) */ netif_wake_queue(priv->ndev); + spin_unlock_irqrestore(&priv->echo_lock, flags); return 0; } @@ -726,11 +726,6 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb, */ should_stop_tx_queue = !!(priv->can.echo_skb[priv->echo_idx]); - spin_unlock_irqrestore(&priv->echo_lock, flags); - - /* write the skb on the interface */ - priv->write_tx_msg(priv, msg); - /* stop network tx queue if not enough room to save one more msg too */ if (priv->can.ctrlmode & CAN_CTRLMODE_FD) should_stop_tx_queue |= (room_left < @@ -742,6 +737,11 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb, if (should_stop_tx_queue) netif_stop_queue(ndev); + spin_unlock_irqrestore(&priv->echo_lock, flags); + + /* write the skb on the interface */ + priv->write_tx_msg(priv, msg); + return NETDEV_TX_OK; } diff --git a/drivers/net/can/peak_canfd/peak_pciefd_main.c b/drivers/net/can/peak_canfd/peak_pciefd_main.c index 788c3464a3b0..3c51a884db87 100644 --- a/drivers/net/can/peak_canfd/peak_pciefd_main.c +++ b/drivers/net/can/peak_canfd/peak_pciefd_main.c @@ -349,8 +349,12 @@ static irqreturn_t pciefd_irq_handler(int irq, void *arg) priv->tx_pages_free++; spin_unlock_irqrestore(&priv->tx_lock, flags); - /* wake producer up */ - netif_wake_queue(priv->ucan.ndev); + /* wake producer up (only if enough room in echo_skb array) */ + spin_lock_irqsave(&priv->ucan.echo_lock, flags); + if (!priv->ucan.can.echo_skb[priv->ucan.echo_idx]) + netif_wake_queue(priv->ucan.ndev); + + spin_unlock_irqrestore(&priv->ucan.echo_lock, flags); } /* re-enable Rx DMA transfer for this CAN */ From ffd137f7043cb30067e1bff6fe62a073ae190b23 Mon Sep 17 00:00:00 2001 From: Stephane Grosjean Date: Thu, 8 Mar 2018 09:30:29 +0100 Subject: [PATCH 592/942] can: peak/pcie_fd: remove useless code when interface starts When an interface starts, the echo_skb array is empty and the network queue should be started only. This patch replaces useless code and locks when the internal RX_BARRIER message is received from the IP core, telling the driver that tx may start. Signed-off-by: Stephane Grosjean Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/peak_canfd/peak_canfd.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/can/peak_canfd/peak_canfd.c b/drivers/net/can/peak_canfd/peak_canfd.c index 6fa66231ed8e..ed8561d4a90f 100644 --- a/drivers/net/can/peak_canfd/peak_canfd.c +++ b/drivers/net/can/peak_canfd/peak_canfd.c @@ -333,7 +333,6 @@ static int pucan_handle_status(struct peak_canfd_priv *priv, /* this STATUS is the CNF of the RX_BARRIER: Tx path can be setup */ if (pucan_status_is_rx_barrier(msg)) { - unsigned long flags; if (priv->enable_tx_path) { int err = priv->enable_tx_path(priv); @@ -342,16 +341,8 @@ static int pucan_handle_status(struct peak_canfd_priv *priv, return err; } - /* restart network queue only if echo skb array is free */ - spin_lock_irqsave(&priv->echo_lock, flags); - - if (!priv->can.echo_skb[priv->echo_idx]) { - spin_unlock_irqrestore(&priv->echo_lock, flags); - - netif_wake_queue(ndev); - } else { - spin_unlock_irqrestore(&priv->echo_lock, flags); - } + /* start network queue (echo_skb array is empty) */ + netif_start_queue(ndev); return 0; } From 7035046d6d02d455325c5d0328bcc8a0b5dd96b0 Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Sat, 10 Mar 2018 12:05:11 +0100 Subject: [PATCH 593/942] drm/sun4i: Fix exclusivity of the TCON clocks Currently the exclusivity is enabled when the rate is set by the mode setting functions. These functions are called by mode_set_nofb callback of drm_crc_helper. Then exclusivity is disabled when tcon is disabled by atomic_disable callback. What happens is that mode_set_nofb can be called once when mode changes, and afterwards the system can call atomic_enable and atomic_disable multiple times without further calls to mode_set_nofb. This happens: mode_set_nofb - clk exclusivity is enabled atomic_enable atomic_disable - clk exclusivity is disabled atomic_enable atomic_disable - clk exclusivity is already disabled, leading to WARN in clk_rate_exclusive_put Solution is to enable exclusivity in sun4i_tcon_channel_set_status. Signed-off-by: Ondrej Jirman Cc: Jernej Skrabec Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/20180310110511.14697-1-megous@megous.com --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 2de586b7c98b..a818ca491605 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -103,6 +103,7 @@ static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel, if (enabled) { clk_prepare_enable(clk); + clk_rate_exclusive_get(clk); } else { clk_rate_exclusive_put(clk); clk_disable_unprepare(clk); @@ -262,7 +263,7 @@ static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon, const struct drm_display_mode *mode) { /* Configure the dot clock */ - clk_set_rate_exclusive(tcon->dclk, mode->crtc_clock * 1000); + clk_set_rate(tcon->dclk, mode->crtc_clock * 1000); /* Set the resolution */ regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG, @@ -423,7 +424,7 @@ static void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, WARN_ON(!tcon->quirks->has_channel_1); /* Configure the dot clock */ - clk_set_rate_exclusive(tcon->sclk1, mode->crtc_clock * 1000); + clk_set_rate(tcon->sclk1, mode->crtc_clock * 1000); /* Adjust clock delay */ clk_delay = sun4i_tcon_get_clk_delay(mode, 1); From c9b3bce18da4a0aebc27853052dea39aa64b7d75 Mon Sep 17 00:00:00 2001 From: Bich HEMON Date: Mon, 12 Mar 2018 08:52:37 +0000 Subject: [PATCH 594/942] can: m_can: select pinctrl state in each suspend/resume function Make sure to apply the correct pin state in suspend/resume callbacks. Putting pins in sleep state saves power. Signed-off-by: Bich Hemon Signed-off-by: Marc Kleine-Budde --- drivers/net/can/m_can/m_can.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 74170b0d23cf..b397a33f3d32 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -26,6 +26,7 @@ #include #include #include +#include /* napi related */ #define M_CAN_NAPI_WEIGHT 64 @@ -1700,6 +1701,8 @@ static __maybe_unused int m_can_suspend(struct device *dev) m_can_clk_stop(priv); } + pinctrl_pm_select_sleep_state(dev); + priv->can.state = CAN_STATE_SLEEPING; return 0; @@ -1710,6 +1713,8 @@ static __maybe_unused int m_can_resume(struct device *dev) struct net_device *ndev = dev_get_drvdata(dev); struct m_can_priv *priv = netdev_priv(ndev); + pinctrl_pm_select_default_state(dev); + m_can_init_ram(priv); priv->can.state = CAN_STATE_ERROR_ACTIVE; From 59fba0869acae06ff594dd7e9808ed673f53538a Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 10 Jan 2018 17:35:43 +0100 Subject: [PATCH 595/942] phy: qcom-ufs: add MODULE_LICENSE tag While the specific UFS PHY drivers (14nm and 20nm) have a module license, the common base module does not, leading to a Kbuild failure: WARNING: modpost: missing MODULE_LICENSE() in drivers/phy/qualcomm/phy-qcom-ufs.o FATAL: modpost: GPL-incompatible module phy-qcom-ufs.ko uses GPL-only symbol 'clk_enable' This adds a module description and license tag to fix the build. I added both Yaniv and Vivek as authors here, as Yaniv sent the initial submission, while Vivek did most of the work since. Signed-off-by: Arnd Bergmann Acked-by: Bjorn Andersson Signed-off-by: Kishon Vijay Abraham I --- drivers/phy/qualcomm/phy-qcom-ufs.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-ufs.c b/drivers/phy/qualcomm/phy-qcom-ufs.c index c5ff4525edef..c5493ea51282 100644 --- a/drivers/phy/qualcomm/phy-qcom-ufs.c +++ b/drivers/phy/qualcomm/phy-qcom-ufs.c @@ -675,3 +675,8 @@ int ufs_qcom_phy_power_off(struct phy *generic_phy) return 0; } EXPORT_SYMBOL_GPL(ufs_qcom_phy_power_off); + +MODULE_AUTHOR("Yaniv Gardi "); +MODULE_AUTHOR("Vivek Gautam "); +MODULE_DESCRIPTION("Universal Flash Storage (UFS) QCOM PHY"); +MODULE_LICENSE("GPL v2"); From 9ca8614980d4593dcff649f8aefe604079cfafe1 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Mon, 12 Mar 2018 00:19:09 +0100 Subject: [PATCH 596/942] drm/sun4i: Fix an error handling path in 'sun4i_drv_bind()' Commit 070badfab767 ("drm/sun4i: call drm_vblank_init with correct number of crtcs") has moved some code without updating the error handling gotos accordingly. Branch to the correct label and remove a now unused lablel. Fixes: 070badfab767 ("drm/sun4i: call drm_vblank_init with correct number of crtcs") Signed-off-by: Christophe JAILLET Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/20180311231909.5381-1-christophe.jaillet@wanadoo.fr --- drivers/gpu/drm/sun4i/sun4i_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 4570da0227b4..d9a71f361b14 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -111,7 +111,7 @@ static int sun4i_drv_bind(struct device *dev) /* drm_vblank_init calls kcalloc, which can fail */ ret = drm_vblank_init(drm, drm->mode_config.num_crtc); if (ret) - goto free_mem_region; + goto cleanup_mode_config; drm->irq_enabled = true; @@ -139,7 +139,6 @@ finish_poll: sun4i_framebuffer_free(drm); cleanup_mode_config: drm_mode_config_cleanup(drm); -free_mem_region: of_reserved_mem_device_release(dev); free_drm: drm_dev_unref(drm); From 1da961d72ab0cfbe8b7c26cba731dc2bb6b9494b Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Mon, 5 Mar 2018 19:25:49 +0300 Subject: [PATCH 597/942] x86/cpufeatures: Add Intel Total Memory Encryption cpufeature CPUID.0x7.0x0:ECX[13] indicates whether CPU supports Intel Total Memory Encryption. Signed-off-by: Kirill A. Shutemov Cc: Dave Hansen Cc: Kai Huang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tom Lendacky Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180305162610.37510-2-kirill.shutemov@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index f41079da38c5..16898eb813f5 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -316,6 +316,7 @@ #define X86_FEATURE_VPCLMULQDQ (16*32+10) /* Carry-Less Multiplication Double Quadword */ #define X86_FEATURE_AVX512_VNNI (16*32+11) /* Vector Neural Network Instructions */ #define X86_FEATURE_AVX512_BITALG (16*32+12) /* Support for VPOPCNT[B,W] and VPSHUF-BITQMB instructions */ +#define X86_FEATURE_TME (16*32+13) /* Intel Total Memory Encryption */ #define X86_FEATURE_AVX512_VPOPCNTDQ (16*32+14) /* POPCNT for vectors of DW/QW */ #define X86_FEATURE_LA57 (16*32+16) /* 5-level page tables */ #define X86_FEATURE_RDPID (16*32+22) /* RDPID instruction */ From 7958b2246fadf54b7ff820a2a5a2c5ca1554716f Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Mon, 5 Mar 2018 19:25:51 +0300 Subject: [PATCH 598/942] x86/cpufeatures: Add Intel PCONFIG cpufeature CPUID.0x7.0x0:EDX[18] indicates whether Intel CPU support PCONFIG instruction. Signed-off-by: Kirill A. Shutemov Cc: Dave Hansen Cc: Kai Huang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tom Lendacky Cc: linux-mm@kvack.org Link: http://lkml.kernel.org/r/20180305162610.37510-4-kirill.shutemov@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h index 16898eb813f5..d554c11e01ff 100644 --- a/arch/x86/include/asm/cpufeatures.h +++ b/arch/x86/include/asm/cpufeatures.h @@ -329,6 +329,7 @@ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */ #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */ +#define X86_FEATURE_PCONFIG (18*32+18) /* Intel PCONFIG */ #define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */ #define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */ #define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */ From a2c054a896b8ac794ddcfc7c92e2dc7ec4ed4ed5 Mon Sep 17 00:00:00 2001 From: Brad Mouring Date: Thu, 8 Mar 2018 16:23:03 -0600 Subject: [PATCH 599/942] net: phy: Tell caller result of phy_change() In 664fcf123a30e (net: phy: Threaded interrupts allow some simplification) the phy_interrupt system was changed to use a traditional threaded interrupt scheme instead of a workqueue approach. With this change, the phy status check moved into phy_change, which did not report back to the caller whether or not the interrupt was handled. This means that, in the case of a shared phy interrupt, only the first phydev's interrupt registers are checked (since phy_interrupt() would always return IRQ_HANDLED). This leads to interrupt storms when it is a secondary device that's actually the interrupt source. Signed-off-by: Brad Mouring Signed-off-by: David S. Miller --- drivers/net/phy/phy.c | 155 +++++++++++++++++++++--------------------- include/linux/phy.h | 1 - 2 files changed, 77 insertions(+), 79 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index a6f924fee584..9aabfa1a455a 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -617,40 +617,6 @@ static void phy_error(struct phy_device *phydev) phy_trigger_machine(phydev, false); } -/** - * phy_interrupt - PHY interrupt handler - * @irq: interrupt line - * @phy_dat: phy_device pointer - * - * Description: When a PHY interrupt occurs, the handler disables - * interrupts, and uses phy_change to handle the interrupt. - */ -static irqreturn_t phy_interrupt(int irq, void *phy_dat) -{ - struct phy_device *phydev = phy_dat; - - if (PHY_HALTED == phydev->state) - return IRQ_NONE; /* It can't be ours. */ - - phy_change(phydev); - - return IRQ_HANDLED; -} - -/** - * phy_enable_interrupts - Enable the interrupts from the PHY side - * @phydev: target phy_device struct - */ -static int phy_enable_interrupts(struct phy_device *phydev) -{ - int err = phy_clear_interrupt(phydev); - - if (err < 0) - return err; - - return phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); -} - /** * phy_disable_interrupts - Disable the PHY interrupts from the PHY side * @phydev: target phy_device struct @@ -677,6 +643,83 @@ phy_err: return err; } +/** + * phy_change - Called by the phy_interrupt to handle PHY changes + * @phydev: phy_device struct that interrupted + */ +static irqreturn_t phy_change(struct phy_device *phydev) +{ + if (phy_interrupt_is_valid(phydev)) { + if (phydev->drv->did_interrupt && + !phydev->drv->did_interrupt(phydev)) + return IRQ_NONE; + + if (phydev->state == PHY_HALTED) + if (phy_disable_interrupts(phydev)) + goto phy_err; + } + + mutex_lock(&phydev->lock); + if ((PHY_RUNNING == phydev->state) || (PHY_NOLINK == phydev->state)) + phydev->state = PHY_CHANGELINK; + mutex_unlock(&phydev->lock); + + /* reschedule state queue work to run as soon as possible */ + phy_trigger_machine(phydev, true); + + if (phy_interrupt_is_valid(phydev) && phy_clear_interrupt(phydev)) + goto phy_err; + return IRQ_HANDLED; + +phy_err: + phy_error(phydev); + return IRQ_NONE; +} + +/** + * phy_change_work - Scheduled by the phy_mac_interrupt to handle PHY changes + * @work: work_struct that describes the work to be done + */ +void phy_change_work(struct work_struct *work) +{ + struct phy_device *phydev = + container_of(work, struct phy_device, phy_queue); + + phy_change(phydev); +} + +/** + * phy_interrupt - PHY interrupt handler + * @irq: interrupt line + * @phy_dat: phy_device pointer + * + * Description: When a PHY interrupt occurs, the handler disables + * interrupts, and uses phy_change to handle the interrupt. + */ +static irqreturn_t phy_interrupt(int irq, void *phy_dat) +{ + struct phy_device *phydev = phy_dat; + + if (PHY_HALTED == phydev->state) + return IRQ_NONE; /* It can't be ours. */ + + return phy_change(phydev); +} + +/** + * phy_enable_interrupts - Enable the interrupts from the PHY side + * @phydev: target phy_device struct + */ +static int phy_enable_interrupts(struct phy_device *phydev) +{ + int err = phy_clear_interrupt(phydev); + + if (err < 0) + return err; + + return phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); +} + /** * phy_start_interrupts - request and enable interrupts for a PHY device * @phydev: target phy_device struct @@ -719,50 +762,6 @@ int phy_stop_interrupts(struct phy_device *phydev) } EXPORT_SYMBOL(phy_stop_interrupts); -/** - * phy_change - Called by the phy_interrupt to handle PHY changes - * @phydev: phy_device struct that interrupted - */ -void phy_change(struct phy_device *phydev) -{ - if (phy_interrupt_is_valid(phydev)) { - if (phydev->drv->did_interrupt && - !phydev->drv->did_interrupt(phydev)) - return; - - if (phydev->state == PHY_HALTED) - if (phy_disable_interrupts(phydev)) - goto phy_err; - } - - mutex_lock(&phydev->lock); - if ((PHY_RUNNING == phydev->state) || (PHY_NOLINK == phydev->state)) - phydev->state = PHY_CHANGELINK; - mutex_unlock(&phydev->lock); - - /* reschedule state queue work to run as soon as possible */ - phy_trigger_machine(phydev, true); - - if (phy_interrupt_is_valid(phydev) && phy_clear_interrupt(phydev)) - goto phy_err; - return; - -phy_err: - phy_error(phydev); -} - -/** - * phy_change_work - Scheduled by the phy_mac_interrupt to handle PHY changes - * @work: work_struct that describes the work to be done - */ -void phy_change_work(struct work_struct *work) -{ - struct phy_device *phydev = - container_of(work, struct phy_device, phy_queue); - - phy_change(phydev); -} - /** * phy_stop - Bring down the PHY link, and stop checking the status * @phydev: target phy_device struct diff --git a/include/linux/phy.h b/include/linux/phy.h index d7069539f351..b260fb336b25 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1012,7 +1012,6 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner); int phy_drivers_register(struct phy_driver *new_driver, int n, struct module *owner); void phy_state_machine(struct work_struct *work); -void phy_change(struct phy_device *phydev); void phy_change_work(struct work_struct *work); void phy_mac_interrupt(struct phy_device *phydev); void phy_start_machine(struct phy_device *phydev); From 4ed50ef4da4d113fe65d9f9d049c1ce7468e3ac1 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 9 Mar 2018 23:46:03 -0500 Subject: [PATCH 600/942] bnxt_en: Refactor the functions to reserve hardware rings. The bnxt_hwrm_reserve_{pf|vf}_rings() functions are very similar to the bnxt_hwrm_check_{pf|vf}_rings() functions. Refactor the former so that the latter can make use of common code in the next patch. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 85 ++++++++++++++--------- 1 file changed, 53 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1500243b9886..377fcebadffc 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4558,18 +4558,17 @@ int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings) return rc; } -static int -bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, - int ring_grps, int cp_rings, int vnics) +static void +__bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, struct hwrm_func_cfg_input *req, + int tx_rings, int rx_rings, int ring_grps, + int cp_rings, int vnics) { - struct hwrm_func_cfg_input req = {0}; u32 enables = 0; - int rc; - bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); - req.fid = cpu_to_le16(0xffff); + bnxt_hwrm_cmd_hdr_init(bp, req, HWRM_FUNC_CFG, -1, -1); + req->fid = cpu_to_le16(0xffff); enables |= tx_rings ? FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; - req.num_tx_rings = cpu_to_le16(tx_rings); + req->num_tx_rings = cpu_to_le16(tx_rings); if (bp->flags & BNXT_FLAG_NEW_RM) { enables |= rx_rings ? FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS : 0; enables |= cp_rings ? FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS | @@ -4578,16 +4577,53 @@ bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS : 0; enables |= vnics ? FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS : 0; - req.num_rx_rings = cpu_to_le16(rx_rings); - req.num_hw_ring_grps = cpu_to_le16(ring_grps); - req.num_cmpl_rings = cpu_to_le16(cp_rings); - req.num_stat_ctxs = req.num_cmpl_rings; - req.num_vnics = cpu_to_le16(vnics); + req->num_rx_rings = cpu_to_le16(rx_rings); + req->num_hw_ring_grps = cpu_to_le16(ring_grps); + req->num_cmpl_rings = cpu_to_le16(cp_rings); + req->num_stat_ctxs = req->num_cmpl_rings; + req->num_vnics = cpu_to_le16(vnics); } - if (!enables) + req->enables = cpu_to_le32(enables); +} + +static void +__bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, + struct hwrm_func_vf_cfg_input *req, int tx_rings, + int rx_rings, int ring_grps, int cp_rings, + int vnics) +{ + u32 enables = 0; + + bnxt_hwrm_cmd_hdr_init(bp, req, HWRM_FUNC_VF_CFG, -1, -1); + enables |= tx_rings ? FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; + enables |= rx_rings ? FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS : 0; + enables |= cp_rings ? FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS | + FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; + enables |= ring_grps ? FUNC_VF_CFG_REQ_ENABLES_NUM_HW_RING_GRPS : 0; + enables |= vnics ? FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS : 0; + + req->num_tx_rings = cpu_to_le16(tx_rings); + req->num_rx_rings = cpu_to_le16(rx_rings); + req->num_hw_ring_grps = cpu_to_le16(ring_grps); + req->num_cmpl_rings = cpu_to_le16(cp_rings); + req->num_stat_ctxs = req->num_cmpl_rings; + req->num_vnics = cpu_to_le16(vnics); + + req->enables = cpu_to_le32(enables); +} + +static int +bnxt_hwrm_reserve_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, + int ring_grps, int cp_rings, int vnics) +{ + struct hwrm_func_cfg_input req = {0}; + int rc; + + __bnxt_hwrm_reserve_pf_rings(bp, &req, tx_rings, rx_rings, ring_grps, + cp_rings, vnics); + if (!req.enables) return 0; - req.enables = cpu_to_le32(enables); rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (rc) return -ENOMEM; @@ -4604,7 +4640,6 @@ bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, int ring_grps, int cp_rings, int vnics) { struct hwrm_func_vf_cfg_input req = {0}; - u32 enables = 0; int rc; if (!(bp->flags & BNXT_FLAG_NEW_RM)) { @@ -4612,22 +4647,8 @@ bnxt_hwrm_reserve_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, return 0; } - bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1); - enables |= tx_rings ? FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS : 0; - enables |= rx_rings ? FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS : 0; - enables |= cp_rings ? FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS | - FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS : 0; - enables |= ring_grps ? FUNC_VF_CFG_REQ_ENABLES_NUM_HW_RING_GRPS : 0; - enables |= vnics ? FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS : 0; - - req.num_tx_rings = cpu_to_le16(tx_rings); - req.num_rx_rings = cpu_to_le16(rx_rings); - req.num_hw_ring_grps = cpu_to_le16(ring_grps); - req.num_cmpl_rings = cpu_to_le16(cp_rings); - req.num_stat_ctxs = req.num_cmpl_rings; - req.num_vnics = cpu_to_le16(vnics); - - req.enables = cpu_to_le32(enables); + __bnxt_hwrm_reserve_vf_rings(bp, &req, tx_rings, rx_rings, ring_grps, + cp_rings, vnics); rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (rc) return -ENOMEM; From 6fc2ffdf1001ae4fb485b3ba95ff757ae54565c9 Mon Sep 17 00:00:00 2001 From: Eddie Wai Date: Fri, 9 Mar 2018 23:46:04 -0500 Subject: [PATCH 601/942] bnxt_en: Fix vnic accounting in the bnxt_check_rings() path. The number of vnics to check must be determined ahead of time because only standard RX rings require vnics to support RFS. The logic is similar to the ring reservation logic and we can now use the refactored common functions to do most of the work in setting up the firmware message. Fixes: 8f23d638b36b ("bnxt_en: Expand bnxt_check_rings() to check all resources.") Signed-off-by: Eddie Wai Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 64 +++++++---------------- 1 file changed, 20 insertions(+), 44 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 377fcebadffc..b847d54504ed 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4764,39 +4764,25 @@ static bool bnxt_need_reserve_rings(struct bnxt *bp) } static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, - int ring_grps, int cp_rings) + int ring_grps, int cp_rings, int vnics) { struct hwrm_func_vf_cfg_input req = {0}; - u32 flags, enables; + u32 flags; int rc; if (!(bp->flags & BNXT_FLAG_NEW_RM)) return 0; - bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1); + __bnxt_hwrm_reserve_vf_rings(bp, &req, tx_rings, rx_rings, ring_grps, + cp_rings, vnics); flags = FUNC_VF_CFG_REQ_FLAGS_TX_ASSETS_TEST | FUNC_VF_CFG_REQ_FLAGS_RX_ASSETS_TEST | FUNC_VF_CFG_REQ_FLAGS_CMPL_ASSETS_TEST | FUNC_VF_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST | FUNC_VF_CFG_REQ_FLAGS_STAT_CTX_ASSETS_TEST | FUNC_VF_CFG_REQ_FLAGS_VNIC_ASSETS_TEST; - enables = FUNC_VF_CFG_REQ_ENABLES_NUM_TX_RINGS | - FUNC_VF_CFG_REQ_ENABLES_NUM_RX_RINGS | - FUNC_VF_CFG_REQ_ENABLES_NUM_CMPL_RINGS | - FUNC_VF_CFG_REQ_ENABLES_NUM_HW_RING_GRPS | - FUNC_VF_CFG_REQ_ENABLES_NUM_STAT_CTXS | - FUNC_VF_CFG_REQ_ENABLES_NUM_VNICS; req.flags = cpu_to_le32(flags); - req.enables = cpu_to_le32(enables); - req.num_tx_rings = cpu_to_le16(tx_rings); - req.num_rx_rings = cpu_to_le16(rx_rings); - req.num_cmpl_rings = cpu_to_le16(cp_rings); - req.num_hw_ring_grps = cpu_to_le16(ring_grps); - req.num_stat_ctxs = cpu_to_le16(cp_rings); - req.num_vnics = cpu_to_le16(1); - if (bp->flags & BNXT_FLAG_RFS) - req.num_vnics = cpu_to_le16(rx_rings + 1); rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (rc) return -ENOMEM; @@ -4804,38 +4790,23 @@ static int bnxt_hwrm_check_vf_rings(struct bnxt *bp, int tx_rings, int rx_rings, } static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, - int ring_grps, int cp_rings) + int ring_grps, int cp_rings, int vnics) { struct hwrm_func_cfg_input req = {0}; - u32 flags, enables; + u32 flags; int rc; - bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_CFG, -1, -1); - req.fid = cpu_to_le16(0xffff); + __bnxt_hwrm_reserve_pf_rings(bp, &req, tx_rings, rx_rings, ring_grps, + cp_rings, vnics); flags = FUNC_CFG_REQ_FLAGS_TX_ASSETS_TEST; - enables = FUNC_CFG_REQ_ENABLES_NUM_TX_RINGS; - req.num_tx_rings = cpu_to_le16(tx_rings); - if (bp->flags & BNXT_FLAG_NEW_RM) { + if (bp->flags & BNXT_FLAG_NEW_RM) flags |= FUNC_CFG_REQ_FLAGS_RX_ASSETS_TEST | FUNC_CFG_REQ_FLAGS_CMPL_ASSETS_TEST | FUNC_CFG_REQ_FLAGS_RING_GRP_ASSETS_TEST | FUNC_CFG_REQ_FLAGS_STAT_CTX_ASSETS_TEST | FUNC_CFG_REQ_FLAGS_VNIC_ASSETS_TEST; - enables |= FUNC_CFG_REQ_ENABLES_NUM_RX_RINGS | - FUNC_CFG_REQ_ENABLES_NUM_CMPL_RINGS | - FUNC_CFG_REQ_ENABLES_NUM_HW_RING_GRPS | - FUNC_CFG_REQ_ENABLES_NUM_STAT_CTXS | - FUNC_CFG_REQ_ENABLES_NUM_VNICS; - req.num_rx_rings = cpu_to_le16(rx_rings); - req.num_cmpl_rings = cpu_to_le16(cp_rings); - req.num_hw_ring_grps = cpu_to_le16(ring_grps); - req.num_stat_ctxs = cpu_to_le16(cp_rings); - req.num_vnics = cpu_to_le16(1); - if (bp->flags & BNXT_FLAG_RFS) - req.num_vnics = cpu_to_le16(rx_rings + 1); - } + req.flags = cpu_to_le32(flags); - req.enables = cpu_to_le32(enables); rc = hwrm_send_message_silent(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (rc) return -ENOMEM; @@ -4843,17 +4814,17 @@ static int bnxt_hwrm_check_pf_rings(struct bnxt *bp, int tx_rings, int rx_rings, } static int bnxt_hwrm_check_rings(struct bnxt *bp, int tx_rings, int rx_rings, - int ring_grps, int cp_rings) + int ring_grps, int cp_rings, int vnics) { if (bp->hwrm_spec_code < 0x10801) return 0; if (BNXT_PF(bp)) return bnxt_hwrm_check_pf_rings(bp, tx_rings, rx_rings, - ring_grps, cp_rings); + ring_grps, cp_rings, vnics); return bnxt_hwrm_check_vf_rings(bp, tx_rings, rx_rings, ring_grps, - cp_rings); + cp_rings, vnics); } static void bnxt_hwrm_set_coal_params(struct bnxt_coal *hw_coal, @@ -7552,7 +7523,7 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, int max_rx, max_tx, tx_sets = 1; int tx_rings_needed; int rx_rings = rx; - int cp, rc; + int cp, vnics, rc; if (tcs) tx_sets = tcs; @@ -7568,10 +7539,15 @@ int bnxt_check_rings(struct bnxt *bp, int tx, int rx, bool sh, int tcs, if (max_tx < tx_rings_needed) return -ENOMEM; + vnics = 1; + if (bp->flags & BNXT_FLAG_RFS) + vnics += rx_rings; + if (bp->flags & BNXT_FLAG_AGG_RINGS) rx_rings <<= 1; cp = sh ? max_t(int, tx_rings_needed, rx) : tx_rings_needed + rx; - return bnxt_hwrm_check_rings(bp, tx_rings_needed, rx_rings, rx, cp); + return bnxt_hwrm_check_rings(bp, tx_rings_needed, rx_rings, rx, cp, + vnics); } static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev) From b9ecc3400bc418af3ba9e56ea852f4ad69c23454 Mon Sep 17 00:00:00 2001 From: Sriharsha Basavapatna Date: Fri, 9 Mar 2018 23:46:05 -0500 Subject: [PATCH 602/942] bnxt_en: Remove unwanted ovs-offload messages in some conditions In some conditions when the driver fails to add a flow in HW and returns an error back to the stack, the stack continues to invoke get_flow_stats() and/or del_flow() on it. The driver fails these APIs with an error message "no flow_node for cookie". The message gets logged repeatedly as long as the stack keeps invoking these functions. Fix this by removing the corresponding netdev_info() calls from these functions. Fixes: d7bc73053024 ("bnxt_en: add code to query TC flower offload stats") Signed-off-by: Sriharsha Basavapatna Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c index fbe6e208e17b..2049d4356df4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c @@ -1269,11 +1269,8 @@ static int bnxt_tc_del_flow(struct bnxt *bp, flow_node = rhashtable_lookup_fast(&tc_info->flow_table, &tc_flow_cmd->cookie, tc_info->flow_ht_params); - if (!flow_node) { - netdev_info(bp->dev, "ERROR: no flow_node for cookie %lx", - tc_flow_cmd->cookie); + if (!flow_node) return -EINVAL; - } return __bnxt_tc_del_flow(bp, flow_node); } @@ -1290,11 +1287,8 @@ static int bnxt_tc_get_flow_stats(struct bnxt *bp, flow_node = rhashtable_lookup_fast(&tc_info->flow_table, &tc_flow_cmd->cookie, tc_info->flow_ht_params); - if (!flow_node) { - netdev_info(bp->dev, "Error: no flow_node for cookie %lx", - tc_flow_cmd->cookie); + if (!flow_node) return -1; - } flow = &flow_node->flow; curr_stats = &flow->stats; From ed7bc602f60a653e5dea488e6917d9a75d6ac0dd Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 9 Mar 2018 23:46:06 -0500 Subject: [PATCH 603/942] bnxt_en: Pass complete VLAN TCI to the stack. When receiving a packet with VLAN tag, pass the entire 16-bit TCI to the stack when calling __vlan_hwaccel_put_tag(). The current code is only passing the 12-bit tag and it is missing the priority bits. Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++-- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b847d54504ed..35099c83f847 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -1439,7 +1439,7 @@ static inline struct sk_buff *bnxt_tpa_end(struct bnxt *bp, (skb->dev->features & NETIF_F_HW_VLAN_CTAG_RX)) { u16 vlan_proto = tpa_info->metadata >> RX_CMP_FLAGS2_METADATA_TPID_SFT; - u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_VID_MASK; + u16 vtag = tpa_info->metadata & RX_CMP_FLAGS2_METADATA_TCI_MASK; __vlan_hwaccel_put_tag(skb, htons(vlan_proto), vtag); } @@ -1623,7 +1623,7 @@ static int bnxt_rx_pkt(struct bnxt *bp, struct bnxt_napi *bnapi, u32 *raw_cons, cpu_to_le32(RX_CMP_FLAGS2_META_FORMAT_VLAN)) && (skb->dev->features & NETIF_F_HW_VLAN_CTAG_RX)) { u32 meta_data = le32_to_cpu(rxcmp1->rx_cmp_meta_data); - u16 vtag = meta_data & RX_CMP_FLAGS2_METADATA_VID_MASK; + u16 vtag = meta_data & RX_CMP_FLAGS2_METADATA_TCI_MASK; u16 vlan_proto = meta_data >> RX_CMP_FLAGS2_METADATA_TPID_SFT; __vlan_hwaccel_put_tag(skb, htons(vlan_proto), vtag); diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 1989c470172c..5e3d62189cab 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -189,6 +189,7 @@ struct rx_cmp_ext { #define RX_CMP_FLAGS2_T_L4_CS_CALC (0x1 << 3) #define RX_CMP_FLAGS2_META_FORMAT_VLAN (0x1 << 4) __le32 rx_cmp_meta_data; + #define RX_CMP_FLAGS2_METADATA_TCI_MASK 0xffff #define RX_CMP_FLAGS2_METADATA_VID_MASK 0xfff #define RX_CMP_FLAGS2_METADATA_TPID_MASK 0xffff0000 #define RX_CMP_FLAGS2_METADATA_TPID_SFT 16 From 832aed16ce7af2a43dafe9d4bc9080322e042cde Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 9 Mar 2018 23:46:07 -0500 Subject: [PATCH 604/942] bnxt_en: Fix regressions when setting up MQPRIO TX rings. Recent changes added the bnxt_init_int_mode() call in the driver's open path whenever ring reservations are changed. This call was previously only called in the probe path. In the open path, if MQPRIO TC has been setup, the bnxt_init_int_mode() call would reset and mess up the MQPRIO per TC rings. Fix it by not re-initilizing bp->tx_nr_rings_per_tc in bnxt_init_int_mode(). Instead, initialize it in the probe path only after the bnxt_init_int_mode() call. Fixes: 674f50a5b026 ("bnxt_en: Implement new method to reserve rings.") Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 35099c83f847..cbdb54f61855 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5857,7 +5857,6 @@ static int bnxt_init_msix(struct bnxt *bp) if (rc) goto msix_setup_exit; - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; bp->cp_nr_rings = (min == 1) ? max_t(int, bp->tx_nr_rings, bp->rx_nr_rings) : bp->tx_nr_rings + bp->rx_nr_rings; @@ -5889,7 +5888,6 @@ static int bnxt_init_inta(struct bnxt *bp) bp->rx_nr_rings = 1; bp->tx_nr_rings = 1; bp->cp_nr_rings = 1; - bp->tx_nr_rings_per_tc = bp->tx_nr_rings; bp->flags |= BNXT_FLAG_SHARED_RINGS; bp->irq_tbl[0].vector = bp->pdev->irq; return 0; @@ -8661,6 +8659,11 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) if (rc) goto init_err_pci_clean; + /* No TC has been set yet and rings may have been trimmed due to + * limited MSIX, so we re-initialize the TX rings per TC. + */ + bp->tx_nr_rings_per_tc = bp->tx_nr_rings; + bnxt_get_wol_settings(bp); if (bp->flags & BNXT_FLAG_WOL_CAP) device_set_wakeup_enable(&pdev->dev, bp->wol); From 6ae777eab2f53b50d84a5d75a48d2d149f787da8 Mon Sep 17 00:00:00 2001 From: Venkat Duvvuru Date: Fri, 9 Mar 2018 23:46:08 -0500 Subject: [PATCH 605/942] bnxt_en: Return standard Linux error codes for hwrm flow cmds. Currently, internal error value is returned by the driver, when hwrm_cfa_flow_alloc() fails due lack of resources. We should be returning Linux errno value -ENOSPC instead. This patch also converts other similar command errors to standard Linux errno code (-EIO) in bnxt_tc.c Fixes: db1d36a27324 ("bnxt_en: add TC flower offload flow_alloc/free FW cmds") Signed-off-by: Venkat Duvvuru Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c | 23 +++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c index 2049d4356df4..65c2cee35766 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c @@ -349,6 +349,9 @@ static int bnxt_hwrm_cfa_flow_free(struct bnxt *bp, __le16 flow_handle) if (rc) netdev_info(bp->dev, "Error: %s: flow_handle=0x%x rc=%d", __func__, flow_handle, rc); + + if (rc) + rc = -EIO; return rc; } @@ -484,13 +487,15 @@ static int bnxt_hwrm_cfa_flow_alloc(struct bnxt *bp, struct bnxt_tc_flow *flow, req.action_flags = cpu_to_le16(action_flags); mutex_lock(&bp->hwrm_cmd_lock); - rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (!rc) *flow_handle = resp->flow_handle; - mutex_unlock(&bp->hwrm_cmd_lock); + if (rc == HWRM_ERR_CODE_RESOURCE_ALLOC_ERROR) + rc = -ENOSPC; + else if (rc) + rc = -EIO; return rc; } @@ -561,6 +566,8 @@ static int hwrm_cfa_decap_filter_alloc(struct bnxt *bp, netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc); mutex_unlock(&bp->hwrm_cmd_lock); + if (rc) + rc = -EIO; return rc; } @@ -576,6 +583,9 @@ static int hwrm_cfa_decap_filter_free(struct bnxt *bp, rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (rc) netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc); + + if (rc) + rc = -EIO; return rc; } @@ -624,6 +634,8 @@ static int hwrm_cfa_encap_record_alloc(struct bnxt *bp, netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc); mutex_unlock(&bp->hwrm_cmd_lock); + if (rc) + rc = -EIO; return rc; } @@ -639,6 +651,9 @@ static int hwrm_cfa_encap_record_free(struct bnxt *bp, rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); if (rc) netdev_info(bp->dev, "%s: Error rc=%d", __func__, rc); + + if (rc) + rc = -EIO; return rc; } @@ -1338,8 +1353,10 @@ bnxt_hwrm_cfa_flow_stats_get(struct bnxt *bp, int num_flows, } else { netdev_info(bp->dev, "error rc=%d", rc); } - mutex_unlock(&bp->hwrm_cmd_lock); + + if (rc) + rc = -EIO; return rc; } From 1a037782e79047ec3386d8ba94c103cbdfb851d0 Mon Sep 17 00:00:00 2001 From: Venkat Duvvuru Date: Fri, 9 Mar 2018 23:46:09 -0500 Subject: [PATCH 606/942] bnxt_en: close & open NIC, only when the interface is in running state. bnxt_restore_pf_fw_resources routine frees PF resources by calling close_nic and allocates the resources back, by doing open_nic. However, this is not needed, if the PF is already in closed state. This bug causes the driver to call open the device and call request_irq() when it is not needed. Ultimately, pci_disable_msix() will crash when bnxt_en is unloaded. This patch fixes the problem by skipping __bnxt_close_nic and __bnxt_open_nic inside bnxt_restore_pf_fw_resources routine, if the interface is not running. Fixes: 80fcaf46c092 ("bnxt_en: Restore MSIX after disabling SRIOV.") Signed-off-by: Venkat Duvvuru Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index cbdb54f61855..cc9569f474f5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -8432,13 +8432,20 @@ int bnxt_restore_pf_fw_resources(struct bnxt *bp) return 0; bnxt_hwrm_func_qcaps(bp); - __bnxt_close_nic(bp, true, false); + + if (netif_running(bp->dev)) + __bnxt_close_nic(bp, true, false); + bnxt_clear_int_mode(bp); rc = bnxt_init_int_mode(bp); - if (rc) - dev_close(bp->dev); - else - rc = bnxt_open_nic(bp, true, false); + + if (netif_running(bp->dev)) { + if (rc) + dev_close(bp->dev); + else + rc = bnxt_open_nic(bp, true, false); + } + return rc; } From 3c4fe80b32c685bdc02b280814d0cfe80d441c72 Mon Sep 17 00:00:00 2001 From: Michael Chan Date: Fri, 9 Mar 2018 23:46:10 -0500 Subject: [PATCH 607/942] bnxt_en: Check valid VNIC ID in bnxt_hwrm_vnic_set_tpa(). During initialization, if we encounter errors, there is a code path that calls bnxt_hwrm_vnic_set_tpa() with invalid VNIC ID. This may cause a warning in firmware logs. Fixes: c0c050c58d84 ("bnxt_en: New Broadcom ethernet driver.") Signed-off-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index cc9569f474f5..c7e5e6f09647 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -3847,6 +3847,9 @@ static int bnxt_hwrm_vnic_set_tpa(struct bnxt *bp, u16 vnic_id, u32 tpa_flags) struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; struct hwrm_vnic_tpa_cfg_input req = {0}; + if (vnic->fw_vnic_id == INVALID_HW_RING_ID) + return 0; + bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_VNIC_TPA_CFG, -1, -1); if (tpa_flags) { From bf2ae2e4bf9360e07c0cdfa166bcdc0afd92f4ce Mon Sep 17 00:00:00 2001 From: Xin Long Date: Sat, 10 Mar 2018 18:57:50 +0800 Subject: [PATCH 608/942] sock_diag: request _diag module only when the family or proto has been registered Now when using 'ss' in iproute, kernel would try to load all _diag modules, which also causes corresponding family and proto modules to be loaded as well due to module dependencies. Like after running 'ss', sctp, dccp, af_packet (if it works as a module) would be loaded. For example: $ lsmod|grep sctp $ ss $ lsmod|grep sctp sctp_diag 16384 0 sctp 323584 5 sctp_diag inet_diag 24576 4 raw_diag,tcp_diag,sctp_diag,udp_diag libcrc32c 16384 3 nf_conntrack,nf_nat,sctp As these family and proto modules are loaded unintentionally, it could cause some problems, like: - Some debug tools use 'ss' to collect the socket info, which loads all those diag and family and protocol modules. It's noisy for identifying issues. - Users usually expect to drop sctp init packet silently when they have no sense of sctp protocol instead of sending abort back. - It wastes resources (especially with multiple netns), and SCTP module can't be unloaded once it's loaded. ... In short, it's really inappropriate to have these family and proto modules loaded unexpectedly when just doing debugging with inet_diag. This patch is to introduce sock_load_diag_module() where it loads the _diag module only when it's corresponding family or proto has been already registered. Note that we can't just load _diag module without the family or proto loaded, as some symbols used in _diag module are from the family or proto module. v1->v2: - move inet proto check to inet_diag to avoid a compiling err. v2->v3: - define sock_load_diag_module in sock.c and export one symbol only. - improve the changelog. Reported-by: Sabrina Dubroca Acked-by: Marcelo Ricardo Leitner Acked-by: Phil Sutter Acked-by: Sabrina Dubroca Signed-off-by: Xin Long Signed-off-by: David S. Miller --- include/linux/net.h | 1 + include/net/sock.h | 1 + net/core/sock.c | 21 +++++++++++++++++++++ net/core/sock_diag.c | 12 ++++-------- net/ipv4/inet_diag.c | 3 +-- net/socket.c | 5 +++++ 6 files changed, 33 insertions(+), 10 deletions(-) diff --git a/include/linux/net.h b/include/linux/net.h index 91216b16feb7..2a0391eea05c 100644 --- a/include/linux/net.h +++ b/include/linux/net.h @@ -222,6 +222,7 @@ enum { int sock_wake_async(struct socket_wq *sk_wq, int how, int band); int sock_register(const struct net_proto_family *fam); void sock_unregister(int family); +bool sock_is_registered(int family); int __sock_create(struct net *net, int family, int type, int proto, struct socket **res, int kern); int sock_create(int family, int type, int proto, struct socket **res); diff --git a/include/net/sock.h b/include/net/sock.h index 169c92afcafa..ae23f3b389ca 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1137,6 +1137,7 @@ struct proto { int proto_register(struct proto *prot, int alloc_slab); void proto_unregister(struct proto *prot); +int sock_load_diag_module(int family, int protocol); #ifdef SOCK_REFCNT_DEBUG static inline void sk_refcnt_debug_inc(struct sock *sk) diff --git a/net/core/sock.c b/net/core/sock.c index c501499a04fe..85b0b64e7f9d 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3261,6 +3261,27 @@ void proto_unregister(struct proto *prot) } EXPORT_SYMBOL(proto_unregister); +int sock_load_diag_module(int family, int protocol) +{ + if (!protocol) { + if (!sock_is_registered(family)) + return -ENOENT; + + return request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, + NETLINK_SOCK_DIAG, family); + } + +#ifdef CONFIG_INET + if (family == AF_INET && + !rcu_access_pointer(inet_protos[protocol])) + return -ENOENT; +#endif + + return request_module("net-pf-%d-proto-%d-type-%d-%d", PF_NETLINK, + NETLINK_SOCK_DIAG, family, protocol); +} +EXPORT_SYMBOL(sock_load_diag_module); + #ifdef CONFIG_PROC_FS static void *proto_seq_start(struct seq_file *seq, loff_t *pos) __acquires(proto_list_mutex) diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c index 146b50e30659..c37b5be7c5e4 100644 --- a/net/core/sock_diag.c +++ b/net/core/sock_diag.c @@ -220,8 +220,7 @@ static int __sock_diag_cmd(struct sk_buff *skb, struct nlmsghdr *nlh) return -EINVAL; if (sock_diag_handlers[req->sdiag_family] == NULL) - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, - NETLINK_SOCK_DIAG, req->sdiag_family); + sock_load_diag_module(req->sdiag_family, 0); mutex_lock(&sock_diag_table_mutex); hndl = sock_diag_handlers[req->sdiag_family]; @@ -247,8 +246,7 @@ static int sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, case TCPDIAG_GETSOCK: case DCCPDIAG_GETSOCK: if (inet_rcv_compat == NULL) - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, - NETLINK_SOCK_DIAG, AF_INET); + sock_load_diag_module(AF_INET, 0); mutex_lock(&sock_diag_table_mutex); if (inet_rcv_compat != NULL) @@ -281,14 +279,12 @@ static int sock_diag_bind(struct net *net, int group) case SKNLGRP_INET_TCP_DESTROY: case SKNLGRP_INET_UDP_DESTROY: if (!sock_diag_handlers[AF_INET]) - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, - NETLINK_SOCK_DIAG, AF_INET); + sock_load_diag_module(AF_INET, 0); break; case SKNLGRP_INET6_TCP_DESTROY: case SKNLGRP_INET6_UDP_DESTROY: if (!sock_diag_handlers[AF_INET6]) - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, - NETLINK_SOCK_DIAG, AF_INET6); + sock_load_diag_module(AF_INET6, 0); break; } return 0; diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index a383f299ce24..4e5bc4b2f14e 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c @@ -53,8 +53,7 @@ static DEFINE_MUTEX(inet_diag_table_mutex); static const struct inet_diag_handler *inet_diag_lock_handler(int proto) { if (!inet_diag_table[proto]) - request_module("net-pf-%d-proto-%d-type-%d-%d", PF_NETLINK, - NETLINK_SOCK_DIAG, AF_INET, proto); + sock_load_diag_module(AF_INET, proto); mutex_lock(&inet_diag_table_mutex); if (!inet_diag_table[proto]) diff --git a/net/socket.c b/net/socket.c index a93c99b518ca..08847c3b8c39 100644 --- a/net/socket.c +++ b/net/socket.c @@ -2587,6 +2587,11 @@ void sock_unregister(int family) } EXPORT_SYMBOL(sock_unregister); +bool sock_is_registered(int family) +{ + return family < NPROTO && rcu_access_pointer(net_families[family]); +} + static int __init sock_init(void) { int err; From b6b76dd62c56f257cdd30900ed22668c42a74030 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Mon, 12 Mar 2018 19:00:49 +0900 Subject: [PATCH 609/942] error-injection: Fix to prohibit jump optimization Since the kprobe which was optimized by jump can not change the execution path, the kprobe for error-injection must not be optimized. To prohibit it, set a dummy post-handler as officially stated in Documentation/kprobes.txt. Fixes: 4b1a29a7f542 ("error-injection: Support fault injection framework") Signed-off-by: Masami Hiramatsu Signed-off-by: Daniel Borkmann --- kernel/fail_function.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/fail_function.c b/kernel/fail_function.c index 21b0122cb39c..1d5632d8bbcc 100644 --- a/kernel/fail_function.c +++ b/kernel/fail_function.c @@ -14,6 +14,15 @@ static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs); +static void fei_post_handler(struct kprobe *kp, struct pt_regs *regs, + unsigned long flags) +{ + /* + * A dummy post handler is required to prohibit optimizing, because + * jump optimization does not support execution path overriding. + */ +} + struct fei_attr { struct list_head list; struct kprobe kp; @@ -56,6 +65,7 @@ static struct fei_attr *fei_attr_new(const char *sym, unsigned long addr) return NULL; } attr->kp.pre_handler = fei_kprobe_handler; + attr->kp.post_handler = fei_post_handler; attr->retval = adjust_error_retval(addr, 0); INIT_LIST_HEAD(&attr->list); } From 9849ef555c7212f4ae93d752cfa1232488ec7c83 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 12 Mar 2018 19:50:07 +0800 Subject: [PATCH 610/942] ASoC: rt5659: fix wrong bit define for ADC L2 power. RT5659_PWR_ADC_L2_BIT should be 2. Signed-off-by: Zhong An Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5659.h b/sound/soc/codecs/rt5659.h index 8f1aeef08489..3ae2d74861ef 100644 --- a/sound/soc/codecs/rt5659.h +++ b/sound/soc/codecs/rt5659.h @@ -1008,7 +1008,7 @@ #define RT5659_PWR_ADC_R1 (0x1 << 3) #define RT5659_PWR_ADC_R1_BIT 3 #define RT5659_PWR_ADC_L2 (0x1 << 2) -#define RT5659_PWR_ADC_L2_BIT 4 +#define RT5659_PWR_ADC_L2_BIT 2 #define RT5659_PWR_ADC_R2 (0x1 << 1) #define RT5659_PWR_ADC_R2_BIT 1 #define RT5659_PWR_CLS_D (0x1) From 3795e0c7d5c8b81d4ae32129b860aaa169945ce3 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 12 Mar 2018 19:50:08 +0800 Subject: [PATCH 611/942] ASoC: rt5659: fix wrong control register for ADC2 power The control register for ADC L2 and R2 is RT5659_PWR_DIG_1 not RT5659_PWR_DIG_2. Signed-off-by: Zhong An Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index 07e7757417bc..ebadc3da0aaf 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -2500,9 +2500,9 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { RT5659_PWR_ADC_L1_BIT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ADC1 R Power", RT5659_PWR_DIG_1, RT5659_PWR_ADC_R1_BIT, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("ADC2 L Power", RT5659_PWR_DIG_2, + SND_SOC_DAPM_SUPPLY("ADC2 L Power", RT5659_PWR_DIG_1, RT5659_PWR_ADC_L2_BIT, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("ADC2 R Power", RT5659_PWR_DIG_2, + SND_SOC_DAPM_SUPPLY("ADC2 R Power", RT5659_PWR_DIG_1, RT5659_PWR_ADC_R2_BIT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ADC1 clock", SND_SOC_NOPM, 0, 0, set_adc_clk, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), From ce571b80e2b2411d5cdfa78888a6865f918621c6 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 12 Mar 2018 19:50:09 +0800 Subject: [PATCH 612/942] ASoC: rt5659: Separate adc 1/2 clock control The control bits of ADC 1 and 2 clock are different. We have to separate it. Signed-off-by: Zhong An Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt5659.c | 38 ++++++++++++++++++++++++++++++++------ sound/soc/codecs/rt5659.h | 12 ++++++++---- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c index a81e248dfdcd..1c1a521c73cb 100644 --- a/sound/soc/codecs/rt5659.c +++ b/sound/soc/codecs/rt5659.c @@ -1622,7 +1622,7 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, return idx; } -static int set_adc_clk(struct snd_soc_dapm_widget *w, +static int set_adc1_clk(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); @@ -1630,13 +1630,39 @@ static int set_adc_clk(struct snd_soc_dapm_widget *w, switch (event) { case SND_SOC_DAPM_POST_PMU: snd_soc_component_update_bits(component, RT5659_CHOP_ADC, - RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK, - RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK); + RT5659_CKXEN_ADC1_MASK | RT5659_CKGEN_ADC1_MASK, + RT5659_CKXEN_ADC1_MASK | RT5659_CKGEN_ADC1_MASK); break; case SND_SOC_DAPM_PRE_PMD: snd_soc_component_update_bits(component, RT5659_CHOP_ADC, - RT5659_CKXEN_ADCC_MASK | RT5659_CKGEN_ADCC_MASK, 0); + RT5659_CKXEN_ADC1_MASK | RT5659_CKGEN_ADC1_MASK, 0); + break; + + default: + return 0; + } + + return 0; + +} + +static int set_adc2_clk(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_component *component = + snd_soc_dapm_to_component(w->dapm); + + switch (event) { + case SND_SOC_DAPM_POST_PMU: + snd_soc_component_update_bits(component, RT5659_CHOP_ADC, + RT5659_CKXEN_ADC2_MASK | RT5659_CKGEN_ADC2_MASK, + RT5659_CKXEN_ADC2_MASK | RT5659_CKGEN_ADC2_MASK); + break; + + case SND_SOC_DAPM_PRE_PMD: + snd_soc_component_update_bits(component, RT5659_CHOP_ADC, + RT5659_CKXEN_ADC2_MASK | RT5659_CKGEN_ADC2_MASK, 0); break; default: @@ -2559,9 +2585,9 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { RT5659_PWR_ADC_L2_BIT, 0, NULL, 0), SND_SOC_DAPM_SUPPLY("ADC2 R Power", RT5659_PWR_DIG_1, RT5659_PWR_ADC_R2_BIT, 0, NULL, 0), - SND_SOC_DAPM_SUPPLY("ADC1 clock", SND_SOC_NOPM, 0, 0, set_adc_clk, + SND_SOC_DAPM_SUPPLY("ADC1 clock", SND_SOC_NOPM, 0, 0, set_adc1_clk, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), - SND_SOC_DAPM_SUPPLY("ADC2 clock", SND_SOC_NOPM, 0, 0, set_adc_clk, + SND_SOC_DAPM_SUPPLY("ADC2 clock", SND_SOC_NOPM, 0, 0, set_adc2_clk, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD), /* ADC Mux */ diff --git a/sound/soc/codecs/rt5659.h b/sound/soc/codecs/rt5659.h index 3b51c8a46e6e..8b576d768744 100644 --- a/sound/soc/codecs/rt5659.h +++ b/sound/soc/codecs/rt5659.h @@ -1743,10 +1743,14 @@ #define RT5659_CKGEN_DAC2_SFT 4 /* Chopper and Clock control for ADC (0x013b)*/ -#define RT5659_CKXEN_ADCC_MASK (0x1 << 13) -#define RT5659_CKXEN_ADCC_SFT 13 -#define RT5659_CKGEN_ADCC_MASK (0x1 << 12) -#define RT5659_CKGEN_ADCC_SFT 12 +#define RT5659_CKXEN_ADC1_MASK (0x1 << 13) +#define RT5659_CKXEN_ADC1_SFT 13 +#define RT5659_CKGEN_ADC1_MASK (0x1 << 12) +#define RT5659_CKGEN_ADC1_SFT 12 +#define RT5659_CKXEN_ADC2_MASK (0x1 << 5) +#define RT5659_CKXEN_ADC2_SFT 5 +#define RT5659_CKGEN_ADC2_MASK (0x1 << 4) +#define RT5659_CKGEN_ADC2_SFT 4 /* Test Mode Control 1 (0x0145) */ #define RT5659_AD2DA_LB_MASK (0x1 << 9) From c9d066650cd5adf4ed4bf5734386699e765222b7 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 12 Mar 2018 16:24:22 +0200 Subject: [PATCH 613/942] ASoC: twl6040: Add back missing write callback We need to have the write callback to use the code. Fixes: 7480389fb0d8 ("ASoC: twl6040: replace codec to component") Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 9bf23f8e7162..b56a6471f9c4 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -1157,6 +1157,7 @@ static const struct snd_soc_component_driver soc_component_dev_twl6040 = { .probe = twl6040_probe, .remove = twl6040_remove, .read = twl6040_read, + .write = twl6040_write, .remove = twl6040_remove, .set_bias_level = twl6040_set_bias_level, .controls = twl6040_snd_controls, From b50c32bd28e399cd4672a1e43645399e5bd1eb85 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 9 Mar 2018 18:48:52 +0100 Subject: [PATCH 614/942] ASoC: max98090: Add #sound-dai-cells property documentation MAX98090 CODEC supports 1 input DAI, adding the #sound-dai-cells property helps to reference the DAI in DT in a standard way. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/max98090.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt index 4e3be6682c98..7e1bbd5c27fd 100644 --- a/Documentation/devicetree/bindings/sound/max98090.txt +++ b/Documentation/devicetree/bindings/sound/max98090.txt @@ -16,6 +16,8 @@ Optional properties: - clock-names: Should be "mclk" +- #sound-dai-cells : should be 0. + - maxim,dmic-freq: Frequency at which to clock DMIC - maxim,micbias: Micbias voltage applies to the analog mic, valid voltages value are: From dead99e8579b6e2ebdf1e9c819e67d7f4a5cedbb Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 12 Mar 2018 16:24:23 +0200 Subject: [PATCH 615/942] ASoC: soc-io: Fix snd_soc_component_update_bits_legacy After the codec to component conversion codecs with custom read/write function will no longer able to use update_bits as their io callbacks are registered at component->driver level and not in component level. To not complicate the code further, lets just use the snd_soc_component_read/snd_soc_component_write function and let them sort out the correct io function to call. Fixes: d0ff8ba57d965 ("ASoC: add Component level .read/.write") Signed-off-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/soc-io.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 2bc1c4c17896..d36a192fbece 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c @@ -88,19 +88,16 @@ static int snd_soc_component_update_bits_legacy( unsigned int old, new; int ret; - if (!component->read || !component->write) - return -EIO; - mutex_lock(&component->io_mutex); - ret = component->read(component, reg, &old); + ret = snd_soc_component_read(component, reg, &old); if (ret < 0) goto out_unlock; new = (old & ~mask) | (val & mask); *change = old != new; if (*change) - ret = component->write(component, reg, new); + ret = snd_soc_component_write(component, reg, new); out_unlock: mutex_unlock(&component->io_mutex); From 946857636d279486eaa47c930930185631f28fce Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 9 Mar 2018 18:48:54 +0100 Subject: [PATCH 616/942] ASoC: Add snd_soc_of_put_dai_link_codecs() helper function The code for dereferencing device nodes in the 'codecs' array is moved to a separate function so we can avoid open coding that in drivers. Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- include/sound/soc.h | 1 + sound/soc/soc-core.c | 32 +++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 747fd583b9dc..4a387f0b3d56 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1807,6 +1807,7 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, int snd_soc_of_get_dai_link_codecs(struct device *dev, struct device_node *of_node, struct snd_soc_dai_link *dai_link); +void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link); int snd_soc_add_dai_link(struct snd_soc_card *card, struct snd_soc_dai_link *dai_link); diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 96c44f6576c9..a1f86e85bff9 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4397,6 +4397,26 @@ int snd_soc_of_get_dai_name(struct device_node *of_node, } EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); +/* + * snd_soc_of_put_dai_link_codecs - Dereference device nodes in the codecs array + * @dai_link: DAI link + * + * Dereference device nodes acquired by snd_soc_of_get_dai_link_codecs(). + */ +void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link) +{ + struct snd_soc_dai_link_component *component = dai_link->codecs; + int index; + + for (index = 0; index < dai_link->num_codecs; index++, component++) { + if (!component->of_node) + break; + of_node_put(component->of_node); + component->of_node = NULL; + } +} +EXPORT_SYMBOL_GPL(snd_soc_of_put_dai_link_codecs); + /* * snd_soc_of_get_dai_link_codecs - Parse a list of CODECs in the devicetree * @dev: Card device @@ -4406,7 +4426,8 @@ EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); * Builds an array of CODEC DAI components from the DAI link property * 'sound-dai'. * The array is set in the DAI link and the number of DAIs is set accordingly. - * The device nodes in the array (of_node) must be dereferenced by the caller. + * The device nodes in the array (of_node) must be dereferenced by calling + * snd_soc_of_put_dai_link_codecs() on @dai_link. * * Returns 0 for success */ @@ -4454,14 +4475,7 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, } return 0; err: - for (index = 0, component = dai_link->codecs; - index < dai_link->num_codecs; - index++, component++) { - if (!component->of_node) - break; - of_node_put(component->of_node); - component->of_node = NULL; - } + snd_soc_of_put_dai_link_codecs(dai_link); dai_link->codecs = NULL; dai_link->num_codecs = 0; return ret; From 995e73e55f46dcfae863d72de674447008a85887 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 9 Mar 2018 18:48:55 +0100 Subject: [PATCH 617/942] ASoC: samsung: i2s: Fix rclk_srcrate handling As the RCLK clock may be updated through the common clk API before each snd_soc_dai_ops::trigger call, it is not enough to update i2s->rclk_srcrate only once after it has been initially set to 0. To avoid wrong PSR values we always get RCLK frequency from the CLK_I2S_RCLK_SRC clock, when that clock is available. Fixes: e1417fdf3011 "ASoC: samsung: i2s: Ensure the RCLK rate is properly determined" Signed-off-by: Sylwester Nawrocki Signed-off-by: Mark Brown --- sound/soc/samsung/i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index b6407fbabdd1..f914ed45db7d 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -887,7 +887,7 @@ static int config_setup(struct i2s_dai *i2s) if (!(i2s->quirks & QUIRK_NO_MUXPSR)) { struct clk *rclksrc = i2s->clk_table[CLK_I2S_RCLK_SRC]; - if (i2s->rclk_srcrate == 0 && rclksrc && !IS_ERR(rclksrc)) + if (rclksrc && !IS_ERR(rclksrc)) i2s->rclk_srcrate = clk_get_rate(rclksrc); psr = i2s->rclk_srcrate / i2s->frmclk / rfs; From ca7796683ff63fb1917d205d4e0173c5dadfb37d Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 9 Mar 2018 18:48:57 +0100 Subject: [PATCH 618/942] ASoC: samsung: Drop uneeded RCLKSRC setting in the Snow driver The RCLKSRC mux input 0 is a default configuration after reset, so there is no need for this explicit snd_soc_dai_set_sysclk() call. Also, this static mux clock configuration can be specified in DT. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/snow.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c index d8ac907bbb0d..fc62110f500f 100644 --- a/sound/soc/samsung/snow.c +++ b/sound/soc/samsung/snow.c @@ -50,11 +50,6 @@ static int snow_late_probe(struct snd_soc_card *card) if (ret < 0) return ret; - /* Select I2S Bus clock to set RCLK and BCLK */ - ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_RCLKSRC_0, - 0, SND_SOC_CLOCK_IN); - if (ret < 0) - return ret; return 0; } From bde8b3887add8368ecf0ca71117baf2fd56a6fc9 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 9 Mar 2018 11:11:17 -0800 Subject: [PATCH 619/942] ASoC: topology: create TLV data for dapm widgets This patch adds the change required to create the TLV data for dapm widget kcontrols from topology. This also fixes the following TLV read error shown in amixer while showing the card control contents. "amixer: Control hw:1 element TLV read error: No such device or address" Signed-off-by: Ranjani Sridharan Signed-off-by: Mark Brown --- sound/soc/soc-topology.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 01a50413c66f..e81b52600d58 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -1272,6 +1272,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( kfree(sm); continue; } + + /* create any TLV data */ + soc_tplg_create_tlv(tplg, &kc[i], &mc->hdr); } return kc; From 99652a469df19086d594e8e89757d4081a812789 Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Wed, 14 Feb 2018 14:43:36 +0100 Subject: [PATCH 620/942] clk: migrate the count of orphaned clocks at init The orphan clocks reparents should migrate any existing count from the orphan clock to its new acestor clocks, otherwise we may have inconsistent counts in the tree and end-up with gated critical clocks Assuming we have two clocks, A and B. * Clock A has CLK_IS_CRITICAL flag set. * Clock B is an ancestor of A which can gate. Clock B gate is left enabled by the bootloader. Step 1: Clock A is registered. Since it is a critical clock, it is enabled. The clock being still an orphan, no parent are enabled. Step 2: Clock B is registered and reparented to clock A (potentially through several other clocks). We are now in situation where the enable count of clock A is 1 while the enable count of its ancestors is 0, which is not good. Step 3: in lateinit, clk_disable_unused() is called, the enable_count of clock B being 0, clock B is gated and and critical clock A actually gets disabled. This situation was found while adding fdiv_clk gates to the meson8b platform. These clocks parent clk81 critical clock, which is the mother of all peripheral clocks in this system. Because of the issue described here, the system is crashing when clk_disable_unused() is called. The situation is solved by reverting commit f8f8f1d04494 ("clk: Don't touch hardware when reparenting during registration"). To avoid breaking again the situation described in this commit description, enabling critical clock should be done before walking the orphan list. This way, a parent critical clock may not be accidentally disabled due to the CLK_OPS_PARENT_ENABLE mechanism. Fixes: f8f8f1d04494 ("clk: Don't touch hardware when reparenting during registration") Cc: Stephen Boyd Cc: Shawn Guo Cc: Dong Aisheng Signed-off-by: Jerome Brunet Tested-by: Marek Szyprowski Tested-by: Heiko Stuebner Signed-off-by: Michael Turquette --- drivers/clk/clk.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 0f686a9dac3e..6d54e933c901 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2967,23 +2967,38 @@ static int __clk_core_init(struct clk_core *core) rate = 0; core->rate = core->req_rate = rate; + /* + * Enable CLK_IS_CRITICAL clocks so newly added critical clocks + * don't get accidentally disabled when walking the orphan tree and + * reparenting clocks + */ + if (core->flags & CLK_IS_CRITICAL) { + unsigned long flags; + + clk_core_prepare(core); + + flags = clk_enable_lock(); + clk_core_enable(core); + clk_enable_unlock(flags); + } + /* * walk the list of orphan clocks and reparent any that newly finds a * parent. */ hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) { struct clk_core *parent = __clk_init_parent(orphan); - unsigned long flags; /* - * we could call __clk_set_parent, but that would result in a - * redundant call to the .set_rate op, if it exists + * We need to use __clk_set_parent_before() and _after() to + * to properly migrate any prepare/enable count of the orphan + * clock. This is important for CLK_IS_CRITICAL clocks, which + * are enabled during init but might not have a parent yet. */ if (parent) { /* update the clk tree topology */ - flags = clk_enable_lock(); - clk_reparent(orphan, parent); - clk_enable_unlock(flags); + __clk_set_parent_before(orphan, parent); + __clk_set_parent_after(orphan, parent, NULL); __clk_recalc_accuracies(orphan); __clk_recalc_rates(orphan, 0); } @@ -3000,16 +3015,6 @@ static int __clk_core_init(struct clk_core *core) if (core->ops->init) core->ops->init(core->hw); - if (core->flags & CLK_IS_CRITICAL) { - unsigned long flags; - - clk_core_prepare(core); - - flags = clk_enable_lock(); - clk_core_enable(core); - clk_enable_unlock(flags); - } - kref_init(&core->ref); out: clk_pm_runtime_put(core); From e8cd7143e269ab58344ff10d9729da144e17fed2 Mon Sep 17 00:00:00 2001 From: Mustamin B Mustaffa Date: Tue, 27 Feb 2018 11:07:34 +0800 Subject: [PATCH 621/942] drm/i915: Enable VBT based BL control for DP Currently, BXT_PP is hardcoded with value '0'. It practically disabled eDP backlight on MRB (BXT) platform. This patch will tell which BXT_PP registers (there are two set of PP_CONTROL in the spec) to be used as defined in VBT (Video Bios Timing table) and this will enabled eDP backlight controller on MRB (BXT) platform. v2: - Remove unnecessary information in commit message. - Assign vbt.backlight.controller to a backlight_controller variable and return the variable value. v3: - Rebased to latest code base. - updated commit title. Signed-off-by: Mustamin B Mustaffa Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20180227030734.37901-1-mustamin.b.mustaffa@intel.com (cherry picked from commit 73c0fcac97bf7f4a6a61b825b205d1cf127cfca7) Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/intel_dp.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 35c5299feab6..a29868cd30c7 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -620,19 +620,15 @@ static int bxt_power_sequencer_idx(struct intel_dp *intel_dp) { struct drm_i915_private *dev_priv = to_i915(intel_dp_to_dev(intel_dp)); + int backlight_controller = dev_priv->vbt.backlight.controller; lockdep_assert_held(&dev_priv->pps_mutex); /* We should never land here with regular DP ports */ WARN_ON(!intel_dp_is_edp(intel_dp)); - /* - * TODO: BXT has 2 PPS instances. The correct port->PPS instance - * mapping needs to be retrieved from VBT, for now just hard-code to - * use instance #0 always. - */ if (!intel_dp->pps_reset) - return 0; + return backlight_controller; intel_dp->pps_reset = false; @@ -642,7 +638,7 @@ bxt_power_sequencer_idx(struct intel_dp *intel_dp) */ intel_dp_init_panel_power_sequencer_registers(intel_dp, false); - return 0; + return backlight_controller; } typedef bool (*vlv_pipe_check)(struct drm_i915_private *dev_priv, From 82813ba9b4b31cd445a2ec1a1404de6e78f32b35 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 7 Mar 2018 17:13:03 +0000 Subject: [PATCH 622/942] drm/i915: Only prune fences after wait-for-all Currently, we only allow ourselves to prune the fences so long as all the waits completed (i.e. all the fences we checked were signaled), and that the reservation snapshot did not change across the wait. However, if we only waited for a subset of the reservation object, i.e. just waiting for the last writer to complete as opposed to all readers as well, then we would erroneously conclude we could prune the fences as indeed although all of our waits were successful, they did not represent the totality of the reservation object. v2: We only need to check the shared fences due to construction (i.e. all of the shared fences will be later than the exclusive fence, if any). Fixes: e54ca9774777 ("drm/i915: Remove completed fences after a wait") Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Matthew Auld Reviewed-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20180307171303.29466-1-chris@chris-wilson.co.uk (cherry picked from commit fa73055b8442c97b3ba7cd0aa57cd2ad32124201) Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/i915_gem.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 66ee9d888d16..6ff5d655c202 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -434,20 +434,28 @@ i915_gem_object_wait_reservation(struct reservation_object *resv, dma_fence_put(shared[i]); kfree(shared); + /* + * If both shared fences and an exclusive fence exist, + * then by construction the shared fences must be later + * than the exclusive fence. If we successfully wait for + * all the shared fences, we know that the exclusive fence + * must all be signaled. If all the shared fences are + * signaled, we can prune the array and recover the + * floating references on the fences/requests. + */ prune_fences = count && timeout >= 0; } else { excl = reservation_object_get_excl_rcu(resv); } - if (excl && timeout >= 0) { + if (excl && timeout >= 0) timeout = i915_gem_object_wait_fence(excl, flags, timeout, rps_client); - prune_fences = timeout >= 0; - } dma_fence_put(excl); - /* Oportunistically prune the fences iff we know they have *all* been + /* + * Opportunistically prune the fences iff we know they have *all* been * signaled and that the reservation object has not been changed (i.e. * no new fences have been added). */ From f1430f145eefcab2bddb9e836d427c4aac067faa Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 8 Mar 2018 14:26:47 +0000 Subject: [PATCH 623/942] drm/i915: Kick the rps worker when changing the boost frequency The boost frequency is only applied from the RPS worker while someone is waiting on a request and requested a boost. As such, when the user wishes to change the frequency, we have to kick the worker in order to re-evaluate whether to apply the boost frequency. v2: Check num_waiters to decide if we should kick the worker to handle boosting. Fixes: 29ecd78d3b79 ("drm/i915: Define a separate variable and control for RPS waitboost frequency") Signed-off-by: Chris Wilson Cc: Mika Kuoppala Reviewed-by: Mika Kuoppala Link: https://patchwork.freedesktop.org/patch/msgid/20180308142648.4016-1-chris@chris-wilson.co.uk (cherry picked from commit 59cd31f177b34deb834a5c97478502741be1cf2e) Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/i915_sysfs.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c index b33d2158c234..e5e6f6bb2b05 100644 --- a/drivers/gpu/drm/i915/i915_sysfs.c +++ b/drivers/gpu/drm/i915/i915_sysfs.c @@ -304,8 +304,9 @@ static ssize_t gt_boost_freq_mhz_store(struct device *kdev, { struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev); struct intel_rps *rps = &dev_priv->gt_pm.rps; - u32 val; + bool boost = false; ssize_t ret; + u32 val; ret = kstrtou32(buf, 0, &val); if (ret) @@ -317,8 +318,13 @@ static ssize_t gt_boost_freq_mhz_store(struct device *kdev, return -EINVAL; mutex_lock(&dev_priv->pcu_lock); - rps->boost_freq = val; + if (val != rps->boost_freq) { + rps->boost_freq = val; + boost = atomic_read(&rps->num_waiters); + } mutex_unlock(&dev_priv->pcu_lock); + if (boost) + schedule_work(&rps->work); return count; } From 3016e0a0c91246e55418825ba9aae271be267522 Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Tue, 6 Mar 2018 10:55:52 +0900 Subject: [PATCH 624/942] Revert "e1000e: Separate signaling for link check/link up" This reverts commit 19110cfbb34d4af0cdfe14cd243f3b09dc95b013. This reverts commit 4110e02eb45ea447ec6f5459c9934de0a273fb91. This reverts commit d3604515c9eda464a92e8e67aae82dfe07fe3c98. Commit 19110cfbb34d ("e1000e: Separate signaling for link check/link up") changed what happens to the link status when there is an error which happens after "get_link_status = false" in the copper check_for_link callbacks. Previously, such an error would be ignored and the link considered up. After that commit, any error implies that the link is down. Revert commit 19110cfbb34d ("e1000e: Separate signaling for link check/link up") and its followups. After reverting, the race condition described in the log of commit 19110cfbb34d is reintroduced. It may still be triggered by LSC events but this should keep the link down in case the link is electrically unstable, as discussed. The race may no longer be triggered by RXO events because commit 4aea7a5c5e94 ("e1000e: Avoid receiver overrun interrupt bursts") restored reading icr in the Other handler. Link: https://lkml.org/lkml/2018/3/1/789 Signed-off-by: Benjamin Poirier Acked-by: Alexander Duyck Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 13 ++++--------- drivers/net/ethernet/intel/e1000e/mac.c | 13 ++++--------- drivers/net/ethernet/intel/e1000e/netdev.c | 2 +- 3 files changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index ff308b05d68c..d6d4ed7acf03 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1367,9 +1367,6 @@ out: * Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. - * - * Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link - * up). **/ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) { @@ -1385,7 +1382,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) * Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) - return 1; + return 0; /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex @@ -1602,7 +1599,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) * we have already determined whether we have link or not. */ if (!mac->autoneg) - return 1; + return -E1000_ERR_CONFIG; /* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to @@ -1616,12 +1613,10 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) * different link partner. */ ret_val = e1000e_config_fc_after_link_up(hw); - if (ret_val) { + if (ret_val) e_dbg("Error configuring flow control\n"); - return ret_val; - } - return 1; + return ret_val; } static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index db735644b312..b322011ec282 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -410,9 +410,6 @@ void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw) * Checks to see of the link status of the hardware has changed. If a * change in link status has been detected, then we read the PHY registers * to get the current speed/duplex if link exists. - * - * Returns a negative error code (-E1000_ERR_*) or 0 (link down) or 1 (link - * up). **/ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) { @@ -426,7 +423,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) * Change or Rx Sequence Error interrupt. */ if (!mac->get_link_status) - return 1; + return 0; /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex @@ -450,7 +447,7 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) * we have already determined whether we have link or not. */ if (!mac->autoneg) - return 1; + return -E1000_ERR_CONFIG; /* Auto-Neg is enabled. Auto Speed Detection takes care * of MAC speed/duplex configuration. So we only need to @@ -464,12 +461,10 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) * different link partner. */ ret_val = e1000e_config_fc_after_link_up(hw); - if (ret_val) { + if (ret_val) e_dbg("Error configuring flow control\n"); - return ret_val; - } - return 1; + return ret_val; } /** diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index c0f23446bf26..dc853b0863af 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -5090,7 +5090,7 @@ static bool e1000e_has_link(struct e1000_adapter *adapter) case e1000_media_type_copper: if (hw->mac.get_link_status) { ret_val = hw->mac.ops.check_for_link(hw); - link_active = ret_val > 0; + link_active = !hw->mac.get_link_status; } else { link_active = true; } From e2710dbf0dc1e37d85368e2404049dadda848d5a Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Tue, 6 Mar 2018 10:55:53 +0900 Subject: [PATCH 625/942] e1000e: Fix link check race condition Alex reported the following race condition: /* link goes up... interrupt... schedule watchdog */ \ e1000_watchdog_task \ e1000e_has_link \ hw->mac.ops.check_for_link() === e1000e_check_for_copper_link \ e1000e_phy_has_link_generic(..., &link) link = true /* link goes down... interrupt */ \ e1000_msix_other hw->mac.get_link_status = true /* link is up */ mac->get_link_status = false link_active = true /* link_active is true, wrongly, and stays so because * get_link_status is false */ Avoid this problem by making sure that we don't set get_link_status = false after having checked the link. It seems this problem has been present since the introduction of e1000e. Link: https://lkml.org/lkml/2018/1/29/338 Reported-by: Alexander Duyck Signed-off-by: Benjamin Poirier Acked-by: Alexander Duyck Tested-by: Aaron Brown Signed-off-by: Jeff Kirsher --- drivers/net/ethernet/intel/e1000e/ich8lan.c | 31 +++++++++++---------- drivers/net/ethernet/intel/e1000e/mac.c | 14 +++++----- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index d6d4ed7acf03..1dddfb7b2de6 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1383,6 +1383,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) */ if (!mac->get_link_status) return 0; + mac->get_link_status = false; /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex @@ -1390,12 +1391,12 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) */ ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); if (ret_val) - return ret_val; + goto out; if (hw->mac.type == e1000_pchlan) { ret_val = e1000_k1_gig_workaround_hv(hw, link); if (ret_val) - return ret_val; + goto out; } /* When connected at 10Mbps half-duplex, some parts are excessively @@ -1428,7 +1429,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) ret_val = hw->phy.ops.acquire(hw); if (ret_val) - return ret_val; + goto out; if (hw->mac.type == e1000_pch2lan) emi_addr = I82579_RX_CONFIG; @@ -1450,7 +1451,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) hw->phy.ops.release(hw); if (ret_val) - return ret_val; + goto out; if (hw->mac.type >= e1000_pch_spt) { u16 data; @@ -1459,14 +1460,14 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) if (speed == SPEED_1000) { ret_val = hw->phy.ops.acquire(hw); if (ret_val) - return ret_val; + goto out; ret_val = e1e_rphy_locked(hw, PHY_REG(776, 20), &data); if (ret_val) { hw->phy.ops.release(hw); - return ret_val; + goto out; } ptr_gap = (data & (0x3FF << 2)) >> 2; @@ -1480,18 +1481,18 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) } hw->phy.ops.release(hw); if (ret_val) - return ret_val; + goto out; } else { ret_val = hw->phy.ops.acquire(hw); if (ret_val) - return ret_val; + goto out; ret_val = e1e_wphy_locked(hw, PHY_REG(776, 20), 0xC023); hw->phy.ops.release(hw); if (ret_val) - return ret_val; + goto out; } } @@ -1518,7 +1519,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) (hw->adapter->pdev->device == E1000_DEV_ID_PCH_I218_V3)) { ret_val = e1000_k1_workaround_lpt_lp(hw, link); if (ret_val) - return ret_val; + goto out; } if (hw->mac.type >= e1000_pch_lpt) { /* Set platform power management values for @@ -1526,7 +1527,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) */ ret_val = e1000_platform_pm_pch_lpt(hw, link); if (ret_val) - return ret_val; + goto out; } /* Clear link partner's EEE ability */ @@ -1549,9 +1550,7 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) } if (!link) - return 0; /* No link detected */ - - mac->get_link_status = false; + goto out; switch (hw->mac.type) { case e1000_pch2lan: @@ -1617,6 +1616,10 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw) e_dbg("Error configuring flow control\n"); return ret_val; + +out: + mac->get_link_status = true; + return ret_val; } static s32 e1000_get_variants_ich8lan(struct e1000_adapter *adapter) diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index b322011ec282..5bdc3a2d4fd7 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -424,19 +424,15 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) */ if (!mac->get_link_status) return 0; + mac->get_link_status = false; /* First we want to see if the MII Status Register reports * link. If so, then we want to get the current speed/duplex * of the PHY. */ ret_val = e1000e_phy_has_link_generic(hw, 1, 0, &link); - if (ret_val) - return ret_val; - - if (!link) - return 0; /* No link detected */ - - mac->get_link_status = false; + if (ret_val || !link) + goto out; /* Check if there was DownShift, must be checked * immediately after link-up @@ -465,6 +461,10 @@ s32 e1000e_check_for_copper_link(struct e1000_hw *hw) e_dbg("Error configuring flow control\n"); return ret_val; + +out: + mac->get_link_status = true; + return ret_val; } /** From 2f987a76a97773beafbc615b9c4d8fe79129a7f4 Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Mon, 12 Mar 2018 14:54:23 +0100 Subject: [PATCH 626/942] net: ipv6: keep sk status consistent after datagram connect failure On unsuccesful ip6_datagram_connect(), if the failure is caused by ip6_datagram_dst_update(), the sk peer information are cleared, but the sk->sk_state is preserved. If the socket was already in an established status, the overall sk status is inconsistent and fouls later checks in datagram code. Fix this saving the old peer information and restoring them in case of failure. This also aligns ipv6 datagram connect() behavior with ipv4. v1 -> v2: - added missing Fixes tag Fixes: 85cb73ff9b74 ("net: ipv6: reset daddr and dport in sk if connect() fails") Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller --- net/ipv6/datagram.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index fbf08ce3f5ab..8a9ac2d0f5d3 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -146,10 +146,12 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, struct sockaddr_in6 *usin = (struct sockaddr_in6 *) uaddr; struct inet_sock *inet = inet_sk(sk); struct ipv6_pinfo *np = inet6_sk(sk); - struct in6_addr *daddr; + struct in6_addr *daddr, old_daddr; + __be32 fl6_flowlabel = 0; + __be32 old_fl6_flowlabel; + __be32 old_dport; int addr_type; int err; - __be32 fl6_flowlabel = 0; if (usin->sin6_family == AF_INET) { if (__ipv6_only_sock(sk)) @@ -238,9 +240,13 @@ ipv4_connected: } } + /* save the current peer information before updating it */ + old_daddr = sk->sk_v6_daddr; + old_fl6_flowlabel = np->flow_label; + old_dport = inet->inet_dport; + sk->sk_v6_daddr = *daddr; np->flow_label = fl6_flowlabel; - inet->inet_dport = usin->sin6_port; /* @@ -250,11 +256,12 @@ ipv4_connected: err = ip6_datagram_dst_update(sk, true); if (err) { - /* Reset daddr and dport so that udp_v6_early_demux() - * fails to find this socket + /* Restore the socket peer info, to keep it consistent with + * the old socket state */ - memset(&sk->sk_v6_daddr, 0, sizeof(sk->sk_v6_daddr)); - inet->inet_dport = 0; + sk->sk_v6_daddr = old_daddr; + np->flow_label = old_fl6_flowlabel; + inet->inet_dport = old_dport; goto out; } From b954f94023dcc61388c8384f0f14eb8e42c863c5 Mon Sep 17 00:00:00 2001 From: Paolo Abeni Date: Mon, 12 Mar 2018 14:54:24 +0100 Subject: [PATCH 627/942] l2tp: fix races with ipv4-mapped ipv6 addresses The l2tp_tunnel_create() function checks for v4mapped ipv6 sockets and cache that flag, so that l2tp core code can reusing it at xmit time. If the socket is provided by the userspace, the connection status of the tunnel sockets can change between the tunnel creation and the xmit call, so that syzbot is able to trigger the following splat: BUG: KASAN: use-after-free in ip6_dst_idev include/net/ip6_fib.h:192 [inline] BUG: KASAN: use-after-free in ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264 Read of size 8 at addr ffff8801bd949318 by task syz-executor4/23448 CPU: 0 PID: 23448 Comm: syz-executor4 Not tainted 4.16.0-rc4+ #65 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23c/0x360 mm/kasan/report.c:412 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433 ip6_dst_idev include/net/ip6_fib.h:192 [inline] ip6_xmit+0x1f76/0x2260 net/ipv6/ip6_output.c:264 inet6_csk_xmit+0x2fc/0x580 net/ipv6/inet6_connection_sock.c:139 l2tp_xmit_core net/l2tp/l2tp_core.c:1053 [inline] l2tp_xmit_skb+0x105f/0x1410 net/l2tp/l2tp_core.c:1148 pppol2tp_sendmsg+0x470/0x670 net/l2tp/l2tp_ppp.c:341 sock_sendmsg_nosec net/socket.c:630 [inline] sock_sendmsg+0xca/0x110 net/socket.c:640 ___sys_sendmsg+0x767/0x8b0 net/socket.c:2046 __sys_sendmsg+0xe5/0x210 net/socket.c:2080 SYSC_sendmsg net/socket.c:2091 [inline] SyS_sendmsg+0x2d/0x50 net/socket.c:2087 do_syscall_64+0x281/0x940 arch/x86/entry/common.c:287 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x453e69 RSP: 002b:00007f819593cc68 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007f819593d6d4 RCX: 0000000000453e69 RDX: 0000000000000081 RSI: 000000002037ffc8 RDI: 0000000000000004 RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff R13: 00000000000004c3 R14: 00000000006f72e8 R15: 0000000000000000 This change addresses the issues: * explicitly checking for TCP_ESTABLISHED for user space provided sockets * dropping the v4mapped flag usage - it can become outdated - and explicitly invoking ipv6_addr_v4mapped() instead The issue is apparently there since ancient times. v1 -> v2: (many thanks to Guillaume) - with csum issue introduced in v1 - replace pr_err with pr_debug - fix build issue with IPV6 disabled - move l2tp_sk_is_v4mapped in l2tp_core.c v2 -> v3: - don't update inet_daddr for v4mapped address, unneeded - drop rendundant check at creation time Reported-and-tested-by: syzbot+92fa328176eb07e4ac1a@syzkaller.appspotmail.com Fixes: 3557baabf280 ("[L2TP]: PPP over L2TP driver core") Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller --- net/l2tp/l2tp_core.c | 38 ++++++++++++++++++-------------------- net/l2tp/l2tp_core.h | 3 --- 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index e22512e32827..14b67dfacc4b 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -111,6 +111,13 @@ struct l2tp_net { spinlock_t l2tp_session_hlist_lock; }; +#if IS_ENABLED(CONFIG_IPV6) +static bool l2tp_sk_is_v6(struct sock *sk) +{ + return sk->sk_family == PF_INET6 && + !ipv6_addr_v4mapped(&sk->sk_v6_daddr); +} +#endif static inline struct l2tp_tunnel *l2tp_tunnel(struct sock *sk) { @@ -1049,7 +1056,7 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb, /* Queue the packet to IP for output */ skb->ignore_df = 1; #if IS_ENABLED(CONFIG_IPV6) - if (tunnel->sock->sk_family == PF_INET6 && !tunnel->v4mapped) + if (l2tp_sk_is_v6(tunnel->sock)) error = inet6_csk_xmit(tunnel->sock, skb, NULL); else #endif @@ -1112,6 +1119,15 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len goto out_unlock; } + /* The user-space may change the connection status for the user-space + * provided socket at run time: we must check it under the socket lock + */ + if (tunnel->fd >= 0 && sk->sk_state != TCP_ESTABLISHED) { + kfree_skb(skb); + ret = NET_XMIT_DROP; + goto out_unlock; + } + /* Get routing info from the tunnel socket */ skb_dst_drop(skb); skb_dst_set(skb, dst_clone(__sk_dst_check(sk, 0))); @@ -1131,7 +1147,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_len /* Calculate UDP checksum if configured to do so */ #if IS_ENABLED(CONFIG_IPV6) - if (sk->sk_family == PF_INET6 && !tunnel->v4mapped) + if (l2tp_sk_is_v6(sk)) udp6_set_csum(udp_get_no_check6_tx(sk), skb, &inet6_sk(sk)->saddr, &sk->sk_v6_daddr, udp_len); @@ -1511,24 +1527,6 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32 if (cfg != NULL) tunnel->debug = cfg->debug; -#if IS_ENABLED(CONFIG_IPV6) - if (sk->sk_family == PF_INET6) { - struct ipv6_pinfo *np = inet6_sk(sk); - - if (ipv6_addr_v4mapped(&np->saddr) && - ipv6_addr_v4mapped(&sk->sk_v6_daddr)) { - struct inet_sock *inet = inet_sk(sk); - - tunnel->v4mapped = true; - inet->inet_saddr = np->saddr.s6_addr32[3]; - inet->inet_rcv_saddr = sk->sk_v6_rcv_saddr.s6_addr32[3]; - inet->inet_daddr = sk->sk_v6_daddr.s6_addr32[3]; - } else { - tunnel->v4mapped = false; - } - } -#endif - /* Mark socket as an encapsulation socket. See net/ipv4/udp.c */ tunnel->encap = encap; if (encap == L2TP_ENCAPTYPE_UDP) { diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index a1aa9550f04e..2718d0b284d0 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h @@ -188,9 +188,6 @@ struct l2tp_tunnel { struct sock *sock; /* Parent socket */ int fd; /* Parent fd, if tunnel socket * was created by userspace */ -#if IS_ENABLED(CONFIG_IPV6) - bool v4mapped; -#endif struct work_struct del_work; From 0f2d4f162f4f54b431420df23122901a6ccd641e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 12 Mar 2018 20:34:35 +0100 Subject: [PATCH 628/942] ASoC: rt5651: move definitions of dt-binding constants to include/dt-bindings Move the definitions of constants used in the dt-bindings from include/sound/rt5651.h to include/dt-bindings/sound/rt5651.h. As dt-bindings headers may also be parsed by the dt-compiler, they cannot use enums, only defines, so this commit also changes the code declaring the constants to use defines. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- include/dt-bindings/sound/rt5651.h | 15 +++++++++++++ include/sound/rt5651.h | 36 ------------------------------ sound/soc/codecs/rt5651.h | 4 ++-- 3 files changed, 17 insertions(+), 38 deletions(-) create mode 100644 include/dt-bindings/sound/rt5651.h delete mode 100644 include/sound/rt5651.h diff --git a/include/dt-bindings/sound/rt5651.h b/include/dt-bindings/sound/rt5651.h new file mode 100644 index 000000000000..2f2dac915168 --- /dev/null +++ b/include/dt-bindings/sound/rt5651.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __DT_RT5651_H +#define __DT_RT5651_H + +#define RT5651_JD_NULL 0 +#define RT5651_JD1_1 1 +#define RT5651_JD1_2 2 +#define RT5651_JD2 3 + +#define RT5651_OVCD_SF_0P5 0 +#define RT5651_OVCD_SF_0P75 1 +#define RT5651_OVCD_SF_1P0 2 +#define RT5651_OVCD_SF_1P5 3 + +#endif /* __DT_RT5651_H */ diff --git a/include/sound/rt5651.h b/include/sound/rt5651.h deleted file mode 100644 index 6403b862fb9a..000000000000 --- a/include/sound/rt5651.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * linux/sound/rt286.h -- Platform data for RT286 - * - * Copyright 2013 Realtek Microelectronics - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef __LINUX_SND_RT5651_H -#define __LINUX_SND_RT5651_H - -/* - * Note these MUST match the values from the DT binding: - * Documentation/devicetree/bindings/sound/rt5651.txt - */ -enum rt5651_jd_src { - RT5651_JD_NULL, - RT5651_JD1_1, - RT5651_JD1_2, - RT5651_JD2, -}; - -/* - * Note these MUST match the values from the DT binding: - * Documentation/devicetree/bindings/sound/rt5651.txt - */ -enum rt5651_ovcd_sf { - RT5651_OVCD_SF_0P5, - RT5651_OVCD_SF_0P75, - RT5651_OVCD_SF_1P0, - RT5651_OVCD_SF_1P5, -}; - -#endif diff --git a/sound/soc/codecs/rt5651.h b/sound/soc/codecs/rt5651.h index f20c9be94fb2..3a0968c53fde 100644 --- a/sound/soc/codecs/rt5651.h +++ b/sound/soc/codecs/rt5651.h @@ -12,7 +12,7 @@ #ifndef __RT5651_H__ #define __RT5651_H__ -#include +#include /* Info */ #define RT5651_RESET 0x00 @@ -2073,7 +2073,7 @@ struct rt5651_priv { struct regmap *regmap; struct snd_soc_jack *hp_jack; struct work_struct jack_detect_work; - enum rt5651_jd_src jd_src; + unsigned int jd_src; unsigned int ovcd_th; unsigned int ovcd_sf; From 6b2d99247b62d288b5b320fcea46c164ab733e49 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 12 Mar 2018 20:34:36 +0100 Subject: [PATCH 629/942] ASoC: rt5651: Fix jack-dectect typo in the dt-bindings documentation Fix the jack-dectect typo in the dt-bindings documentation. Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/rt5651.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/rt5651.txt b/Documentation/devicetree/bindings/sound/rt5651.txt index 7890aa9477f8..b85221864cec 100644 --- a/Documentation/devicetree/bindings/sound/rt5651.txt +++ b/Documentation/devicetree/bindings/sound/rt5651.txt @@ -18,9 +18,9 @@ Optional properties: - realtek,jack-detect-source u32. Valid values: - 1: Use JD1_1 pin for jack-dectect - 2: Use JD1_2 pin for jack-dectect - 3: Use JD2 pin for jack-dectect + 1: Use JD1_1 pin for jack-detect + 2: Use JD1_2 pin for jack-detect + 3: Use JD2 pin for jack-detect - realtek,over-current-threshold-microamp u32, micbias over-current detection threshold in µA, valid values are From c4e50b1d87fbbeabb2d7f286af673666f507acb9 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 12 Mar 2018 18:28:09 -0300 Subject: [PATCH 630/942] ASoC: sgtl5000: Pass the required '#sound-dai-cells' DTC now warns about missing #sound-dai-cells: arch/arm/boot/dts/imx6ul-geam.dtb: Warning (sound_dai_property): /sound/simple-audio-card,codec: Missing property '#sound-dai-cells' in node /soc/aips-bus@2100000/i2c@21a0000/codec@a or bad phandle (referred from sound-dai[0]) Pass the required '#sound-dai-cells' property to improve the documentation. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/sgtl5000.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/sgtl5000.txt b/Documentation/devicetree/bindings/sound/sgtl5000.txt index 060cb4a3b47e..9a36c7e2a143 100644 --- a/Documentation/devicetree/bindings/sound/sgtl5000.txt +++ b/Documentation/devicetree/bindings/sound/sgtl5000.txt @@ -5,6 +5,8 @@ Required properties: - reg : the I2C address of the device +- #sound-dai-cells: must be equal to 0 + - clocks : the clock provider of SYS_MCLK - VDDA-supply : the regulator provider of VDDA @@ -40,6 +42,7 @@ Example: codec: sgtl5000@a { compatible = "fsl,sgtl5000"; reg = <0x0a>; + #sound-dai-cells = <0>; clocks = <&clks 150>; micbias-resistor-k-ohms = <2>; micbias-voltage-m-volts = <2250>; From 04bf9ab3359ff89059509ee5c35446c45b9cdaaa Mon Sep 17 00:00:00 2001 From: Jerome Brunet Date: Wed, 14 Feb 2018 14:43:35 +0100 Subject: [PATCH 631/942] clk: fix determine rate error with pass-through clock If we try to determine the rate of a pass-through clock (a clock which does not implement .round_rate() nor .determine_rate()), clk_core_round_rate_nolock() will directly forward the call to the parent clock. In the particular case where the pass-through actually does not have a parent, clk_core_round_rate_nolock() will directly return 0 with the requested rate still set to the initial request structure. This is interpreted as if the rate could be exactly achieved while it actually cannot be adjusted. This become a real problem when this particular pass-through clock is the parent of a mux with the flag CLK_SET_RATE_PARENT set. The pass-through clock will always report an exact match, get picked and finally error when the rate is actually getting set. This is fixed by setting the rate inside the req to 0 when core is NULL in clk_core_round_rate_nolock() (same as in __clk_determine_rate() when hw is NULL) Fixes: 0f6cc2b8e94d ("clk: rework calls to round and determine rate callbacks") Signed-off-by: Jerome Brunet Signed-off-by: Michael Turquette Signed-off-by: Stephen Boyd --- drivers/clk/clk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 6d54e933c901..cca05ea2c058 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -1125,8 +1125,10 @@ static int clk_core_round_rate_nolock(struct clk_core *core, { lockdep_assert_held(&prepare_lock); - if (!core) + if (!core) { + req->rate = 0; return 0; + } clk_core_init_rate_req(core, req); From 9903e41ae1f5d50c93f268ca3304d4d7c64b9311 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 4 Jan 2018 06:36:34 +0000 Subject: [PATCH 632/942] =?UTF-8?q?clk:=20hisilicon:=20hi3660=EF=BC=9AFix?= =?UTF-8?q?=20potential=20NULL=20dereference=20in=20hi3660=5Fstub=5Fclk=5F?= =?UTF-8?q?probe()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit platform_get_resource() may return NULL, add proper check to avoid potential NULL dereferencing. This is detected by Coccinelle semantic patch. @@ expression pdev, res, n, t, e, e1, e2; @@ res = platform_get_resource(pdev, t, n); + if (!res) + return -EINVAL; ... when != res == NULL e = devm_ioremap(e1, res->start, e2); Fixes: 4f16f7ff3bc0 ("clk: hisilicon: Add support for Hi3660 stub clocks") Signed-off-by: Wei Yongjun Signed-off-by: Stephen Boyd --- drivers/clk/hisilicon/clk-hi3660-stub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/hisilicon/clk-hi3660-stub.c b/drivers/clk/hisilicon/clk-hi3660-stub.c index 9b6c72bbddf9..e8b2c43b1bb8 100644 --- a/drivers/clk/hisilicon/clk-hi3660-stub.c +++ b/drivers/clk/hisilicon/clk-hi3660-stub.c @@ -149,6 +149,8 @@ static int hi3660_stub_clk_probe(struct platform_device *pdev) return PTR_ERR(stub_clk_chan.mbox); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) + return -EINVAL; freq_reg = devm_ioremap(dev, res->start, resource_size(res)); if (!freq_reg) return -ENOMEM; From 55c19eee3b471e7ca7e38783836f7b7137c9d14f Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Thu, 4 Jan 2018 06:34:43 +0000 Subject: [PATCH 633/942] clk: qcom: msm8916: Fix return value check in qcom_apcs_msm8916_clk_probe() In case of error, the function dev_get_regmap() returns NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Fixes: 81ac38847a1d ("clk: qcom: Add APCS clock controller support") Signed-off-by: Wei Yongjun Signed-off-by: Stephen Boyd --- drivers/clk/qcom/apcs-msm8916.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/clk/qcom/apcs-msm8916.c b/drivers/clk/qcom/apcs-msm8916.c index 246957f1a413..b1cc8dbcd327 100644 --- a/drivers/clk/qcom/apcs-msm8916.c +++ b/drivers/clk/qcom/apcs-msm8916.c @@ -49,11 +49,10 @@ static int qcom_apcs_msm8916_clk_probe(struct platform_device *pdev) struct clk_regmap_mux_div *a53cc; struct regmap *regmap; struct clk_init_data init = { }; - int ret; + int ret = -ENODEV; regmap = dev_get_regmap(parent, NULL); - if (IS_ERR(regmap)) { - ret = PTR_ERR(regmap); + if (!regmap) { dev_err(dev, "failed to get regmap: %d\n", ret); return ret; } From 5a9f8df68ee6927f21dd3f2c75c16feb8b53a9e8 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Mon, 12 Mar 2018 16:00:40 -0700 Subject: [PATCH 634/942] net: dsa: Fix dsa_is_user_port() test inversion During the conversion to dsa_is_user_port(), a condition ended up being reversed, which would prevent the creation of any user port when using the legacy binding and/or platform data, fix that. Fixes: 4a5b85ffe2a0 ("net: dsa: use dsa_is_user_port everywhere") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- net/dsa/legacy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c index cb54b81d0bd9..42a7b85b84e1 100644 --- a/net/dsa/legacy.c +++ b/net/dsa/legacy.c @@ -194,7 +194,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, ds->ports[i].dn = cd->port_dn[i]; ds->ports[i].cpu_dp = dst->cpu_dp; - if (dsa_is_user_port(ds, i)) + if (!dsa_is_user_port(ds, i)) continue; ret = dsa_slave_create(&ds->ports[i]); From 318aaf34f1179b39fa9c30fa0f3288b645beee39 Mon Sep 17 00:00:00 2001 From: Jason Yan Date: Thu, 8 Mar 2018 10:34:53 +0800 Subject: [PATCH 635/942] scsi: libsas: defer ata device eh commands to libata When ata device doing EH, some commands still attached with tasks are not passed to libata when abort failed or recover failed, so libata did not handle these commands. After these commands done, sas task is freed, but ata qc is not freed. This will cause ata qc leak and trigger a warning like below: WARNING: CPU: 0 PID: 28512 at drivers/ata/libata-eh.c:4037 ata_eh_finish+0xb4/0xcc CPU: 0 PID: 28512 Comm: kworker/u32:2 Tainted: G W OE 4.14.0#1 ...... Call trace: [] ata_eh_finish+0xb4/0xcc [] ata_do_eh+0xc4/0xd8 [] ata_std_error_handler+0x44/0x8c [] ata_scsi_port_error_handler+0x480/0x694 [] async_sas_ata_eh+0x4c/0x80 [] async_run_entry_fn+0x4c/0x170 [] process_one_work+0x144/0x390 [] worker_thread+0x144/0x418 [] kthread+0x10c/0x138 [] ret_from_fork+0x10/0x18 If ata qc leaked too many, ata tag allocation will fail and io blocked for ever. As suggested by Dan Williams, defer ata device commands to libata and merge sas_eh_finish_cmd() with sas_eh_defer_cmd(). libata will handle ata qcs correctly after this. Signed-off-by: Jason Yan CC: Xiaofei Tan CC: John Garry CC: Dan Williams Reviewed-by: Dan Williams Signed-off-by: Martin K. Petersen --- drivers/scsi/libsas/sas_scsi_host.c | 33 ++++++++++++----------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 626727207889..a372af68d9a9 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -223,6 +223,7 @@ out_done: static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) { struct sas_ha_struct *sas_ha = SHOST_TO_SAS_HA(cmd->device->host); + struct domain_device *dev = cmd_to_domain_dev(cmd); struct sas_task *task = TO_SAS_TASK(cmd); /* At this point, we only get called following an actual abort @@ -231,6 +232,14 @@ static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) */ sas_end_task(cmd, task); + if (dev_is_sata(dev)) { + /* defer commands to libata so that libata EH can + * handle ata qcs correctly + */ + list_move_tail(&cmd->eh_entry, &sas_ha->eh_ata_q); + return; + } + /* now finish the command and move it on to the error * handler done list, this also takes it off the * error handler pending list. @@ -238,22 +247,6 @@ static void sas_eh_finish_cmd(struct scsi_cmnd *cmd) scsi_eh_finish_cmd(cmd, &sas_ha->eh_done_q); } -static void sas_eh_defer_cmd(struct scsi_cmnd *cmd) -{ - struct domain_device *dev = cmd_to_domain_dev(cmd); - struct sas_ha_struct *ha = dev->port->ha; - struct sas_task *task = TO_SAS_TASK(cmd); - - if (!dev_is_sata(dev)) { - sas_eh_finish_cmd(cmd); - return; - } - - /* report the timeout to libata */ - sas_end_task(cmd, task); - list_move_tail(&cmd->eh_entry, &ha->eh_ata_q); -} - static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd *my_cmd) { struct scsi_cmnd *cmd, *n; @@ -261,7 +254,7 @@ static void sas_scsi_clear_queue_lu(struct list_head *error_q, struct scsi_cmnd list_for_each_entry_safe(cmd, n, error_q, eh_entry) { if (cmd->device->sdev_target == my_cmd->device->sdev_target && cmd->device->lun == my_cmd->device->lun) - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); } } @@ -618,12 +611,12 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head * case TASK_IS_DONE: SAS_DPRINTK("%s: task 0x%p is done\n", __func__, task); - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); continue; case TASK_IS_ABORTED: SAS_DPRINTK("%s: task 0x%p is aborted\n", __func__, task); - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); continue; case TASK_IS_AT_LU: SAS_DPRINTK("task 0x%p is at LU: lu recover\n", task); @@ -634,7 +627,7 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head * "recovered\n", SAS_ADDR(task->dev), cmd->device->lun); - sas_eh_defer_cmd(cmd); + sas_eh_finish_cmd(cmd); sas_scsi_clear_queue_lu(work_q, cmd); goto Again; } From 14bc1dff74277408f08661d03e785710a46e0699 Mon Sep 17 00:00:00 2001 From: Himanshu Madhani Date: Wed, 7 Mar 2018 10:49:26 -0800 Subject: [PATCH 636/942] scsi: qla2xxx: Remove FC_NO_LOOP_ID for FCP and FC-NVMe Discovery Commit 7d64c39e64310 fixed regression of FCP discovery when Nport Handle is in-use and relogin is triggered. However, during FCP and FC-NVMe discovery this resulted into only discovering NVMe LUNs. This patch fixes issue where FCP and FC-NVMe protocol is used on same port where assigning FC_NO_LOOP_ID will result into discovery failure for FCP LUNs. Fixes: a084fd68e1d26 ("scsi: qla2xxx: Fix re-login for Nport Handle in use") Signed-off-by: Himanshu Madhani Reviewed-by: Hannes Reinecke Signed-off-by: Martin K. Petersen --- drivers/scsi/qla2xxx/qla_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 00329dda6179..8d7fab3cd01d 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c @@ -1719,7 +1719,6 @@ qla24xx_handle_plogi_done_event(struct scsi_qla_host *vha, struct event_arg *ea) set_bit(ea->fcport->loop_id, vha->hw->loop_id_map); spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); - ea->fcport->loop_id = FC_NO_LOOP_ID; ea->fcport->chip_reset = vha->hw->base_qpair->chip_reset; ea->fcport->logout_on_delete = 1; ea->fcport->send_els_logo = 0; From 0dcd7876029b58770f769cbb7b484e88e4a305e5 Mon Sep 17 00:00:00 2001 From: Greg Hackmann Date: Wed, 7 Mar 2018 14:42:53 -0800 Subject: [PATCH 637/942] net: xfrm: use preempt-safe this_cpu_read() in ipcomp_alloc_tfms() f7c83bcbfaf5 ("net: xfrm: use __this_cpu_read per-cpu helper") added a __this_cpu_read() call inside ipcomp_alloc_tfms(). At the time, __this_cpu_read() required the caller to either not care about races or to handle preemption/interrupt issues. 3.15 tightened the rules around some per-cpu operations, and now __this_cpu_read() should never be used in a preemptible context. On 3.15 and later, we need to use this_cpu_read() instead. syzkaller reported this leading to the following kernel BUG while fuzzing sendmsg: BUG: using __this_cpu_read() in preemptible [00000000] code: repro/3101 caller is ipcomp_init_state+0x185/0x990 CPU: 3 PID: 3101 Comm: repro Not tainted 4.16.0-rc4-00123-g86f84779d8e9 #154 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 Call Trace: dump_stack+0xb9/0x115 check_preemption_disabled+0x1cb/0x1f0 ipcomp_init_state+0x185/0x990 ? __xfrm_init_state+0x876/0xc20 ? lock_downgrade+0x5e0/0x5e0 ipcomp4_init_state+0xaa/0x7c0 __xfrm_init_state+0x3eb/0xc20 xfrm_init_state+0x19/0x60 pfkey_add+0x20df/0x36f0 ? pfkey_broadcast+0x3dd/0x600 ? pfkey_sock_destruct+0x340/0x340 ? pfkey_seq_stop+0x80/0x80 ? __skb_clone+0x236/0x750 ? kmem_cache_alloc+0x1f6/0x260 ? pfkey_sock_destruct+0x340/0x340 ? pfkey_process+0x62a/0x6f0 pfkey_process+0x62a/0x6f0 ? pfkey_send_new_mapping+0x11c0/0x11c0 ? mutex_lock_io_nested+0x1390/0x1390 pfkey_sendmsg+0x383/0x750 ? dump_sp+0x430/0x430 sock_sendmsg+0xc0/0x100 ___sys_sendmsg+0x6c8/0x8b0 ? copy_msghdr_from_user+0x3b0/0x3b0 ? pagevec_lru_move_fn+0x144/0x1f0 ? find_held_lock+0x32/0x1c0 ? do_huge_pmd_anonymous_page+0xc43/0x11e0 ? lock_downgrade+0x5e0/0x5e0 ? get_kernel_page+0xb0/0xb0 ? _raw_spin_unlock+0x29/0x40 ? do_huge_pmd_anonymous_page+0x400/0x11e0 ? __handle_mm_fault+0x553/0x2460 ? __fget_light+0x163/0x1f0 ? __sys_sendmsg+0xc7/0x170 __sys_sendmsg+0xc7/0x170 ? SyS_shutdown+0x1a0/0x1a0 ? __do_page_fault+0x5a0/0xca0 ? lock_downgrade+0x5e0/0x5e0 SyS_sendmsg+0x27/0x40 ? __sys_sendmsg+0x170/0x170 do_syscall_64+0x19f/0x640 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x7f0ee73dfb79 RSP: 002b:00007ffe14fc15a8 EFLAGS: 00000207 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0ee73dfb79 RDX: 0000000000000000 RSI: 00000000208befc8 RDI: 0000000000000004 RBP: 00007ffe14fc15b0 R08: 00007ffe14fc15c0 R09: 00007ffe14fc15c0 R10: 0000000000000000 R11: 0000000000000207 R12: 0000000000400440 R13: 00007ffe14fc16b0 R14: 0000000000000000 R15: 0000000000000000 Signed-off-by: Greg Hackmann Signed-off-by: Steffen Klassert --- net/xfrm/xfrm_ipcomp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c index ccfdc7115a83..a00ec715aa46 100644 --- a/net/xfrm/xfrm_ipcomp.c +++ b/net/xfrm/xfrm_ipcomp.c @@ -283,7 +283,7 @@ static struct crypto_comp * __percpu *ipcomp_alloc_tfms(const char *alg_name) struct crypto_comp *tfm; /* This can be any valid CPU ID so we don't need locking. */ - tfm = __this_cpu_read(*pos->tfms); + tfm = this_cpu_read(*pos->tfms); if (!strcmp(crypto_comp_name(tfm), alg_name)) { pos->users++; From 79832f0b5f718e0023d9dd73e6845310609a564d Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 13 Mar 2018 14:09:21 +0000 Subject: [PATCH 638/942] efi/libstub/tpm: Initialize pointer variables to zero for mixed mode As reported by Jeremy Cline, running the new TPM libstub code in mixed mode (i.e., 64-bit kernel on 32-bit UEFI) results in hangs when invoking the TCG2 protocol, or when accessing the log_tbl pool allocation. The reason turns out to be that in both cases, the 64-bit pointer variables are not fully initialized by the 32-bit EFI code, and so we should take care to zero initialize these variables beforehand, or we'll end up dereferencing bogus pointers. Reported-by: Jeremy Cline Signed-off-by: Ard Biesheuvel Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: hdegoede@redhat.com Cc: jarkko.sakkinen@linux.intel.com Cc: javierm@redhat.com Cc: linux-efi@vger.kernel.org Cc: tweek@google.com Link: http://lkml.kernel.org/r/20180313140922.17266-2-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/libstub/tpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index da661bf8cb96..13c1edd37e96 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -68,11 +68,11 @@ void efi_retrieve_tpm2_eventlog_1_2(efi_system_table_t *sys_table_arg) efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; efi_status_t status; efi_physical_addr_t log_location, log_last_entry; - struct linux_efi_tpm_eventlog *log_tbl; + struct linux_efi_tpm_eventlog *log_tbl = NULL; unsigned long first_entry_addr, last_entry_addr; size_t log_size, last_entry_size; efi_bool_t truncated; - void *tcg2_protocol; + void *tcg2_protocol = NULL; status = efi_call_early(locate_protocol, &tcg2_guid, NULL, &tcg2_protocol); From f89782c2d131e6eae0d1ea2569ba76bc4c5875fe Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 13 Mar 2018 12:09:38 +0300 Subject: [PATCH 639/942] qed: Use after free in qed_rdma_free() We're dereferencing "p_hwfn->p_rdma_info" but that is freed on the line before in qed_rdma_resc_free(p_hwfn). Fixes: 9de506a547c0 ("qed: Free RoCE ILT Memory on rmmod qedr") Signed-off-by: Dan Carpenter Acked-by: Michal Kalderon Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qed/qed_rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_rdma.c b/drivers/net/ethernet/qlogic/qed/qed_rdma.c index f3ee6538b553..a411f9c702a1 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_rdma.c +++ b/drivers/net/ethernet/qlogic/qed/qed_rdma.c @@ -379,8 +379,8 @@ static void qed_rdma_free(struct qed_hwfn *p_hwfn) DP_VERBOSE(p_hwfn, QED_MSG_RDMA, "Freeing RDMA\n"); qed_rdma_free_reserved_lkey(p_hwfn); - qed_rdma_resc_free(p_hwfn); qed_cxt_free_proto_ilt(p_hwfn, p_hwfn->p_rdma_info->proto); + qed_rdma_resc_free(p_hwfn); } static void qed_rdma_get_guid(struct qed_hwfn *p_hwfn, u8 *guid) From 94e46a4f2d5eb14059e42f313c098d4854847376 Mon Sep 17 00:00:00 2001 From: Merlijn Wajer Date: Tue, 13 Mar 2018 09:48:40 -0500 Subject: [PATCH 640/942] usb: musb: Fix external abort in musb_remove on omap2430 This fixes an oops on unbind / module unload (on the musb omap2430 platform). musb_remove function now calls musb_platform_exit before disabling runtime pm. Signed-off-by: Merlijn Wajer Signed-off-by: Bin Liu Signed-off-by: Greg Kroah-Hartman --- drivers/usb/musb/musb_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index c344ef4e5355..4d723077be2b 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -2473,11 +2473,11 @@ static int musb_remove(struct platform_device *pdev) musb_disable_interrupts(musb); musb_writeb(musb->mregs, MUSB_DEVCTL, 0); spin_unlock_irqrestore(&musb->lock, flags); + musb_platform_exit(musb); pm_runtime_dont_use_autosuspend(musb->controller); pm_runtime_put_sync(musb->controller); pm_runtime_disable(musb->controller); - musb_platform_exit(musb); musb_phy_callback = NULL; if (musb->dma_controller) musb_dma_controller_destroy(musb->dma_controller); From 0f9d0e355d7c3fa5756313765a77961074017845 Mon Sep 17 00:00:00 2001 From: Adam Thomson Date: Tue, 13 Mar 2018 09:07:54 +0000 Subject: [PATCH 641/942] ASoC: da7219: clkdev_drop usage depends on CONFIG_COMMON_CLK Fixes: ASoC: da7219: Add common clock usage for providing DAI clks clkdev_drop usage in the codec remove function should be dependent on if CONFIG_COMMON_CLK is defined for the platform, otherwise it can cause build failures for platforms that do not support this. The clkdev_* functions are still defined for those platforms, in headers and source but the functions are not linked in. This patch resolves this issue, so clkdev_drop is only used if CONFIG_COMMON_CLK is defined. Signed-off-by: Adam Thomson Signed-off-by: Mark Brown --- sound/soc/codecs/da7219.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 441215997273..08f55d7a11ba 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -1966,8 +1966,10 @@ static void da7219_remove(struct snd_soc_component *component) da7219_aad_exit(component); +#ifdef CONFIG_COMMON_CLK if (da7219->dai_clks_lookup) clkdev_drop(da7219->dai_clks_lookup); +#endif /* Supplies */ regulator_bulk_disable(DA7219_NUM_SUPPLIES, da7219->supplies); From ea3f79e2c40172b8c476260c1e33dbb419789d85 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Mar 2018 19:49:38 +0100 Subject: [PATCH 642/942] ASoC: samsung: Snow DT bindings update The new DT bindings are introduced so sound on the HDMI interface can also be supported. The exisiting CPU and CODEC DAI phandle properties are marked as deprecated. Signed-off-by: Sylwester Nawrocki Reviewed-by: Rob Herring Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/snow.txt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/sound/snow.txt b/Documentation/devicetree/bindings/sound/snow.txt index 6df74f15687f..80fd9a87bb3f 100644 --- a/Documentation/devicetree/bindings/sound/snow.txt +++ b/Documentation/devicetree/bindings/sound/snow.txt @@ -5,8 +5,17 @@ Required properties: "google,snow-audio-max98090" or "google,snow-audio-max98091" or "google,snow-audio-max98095" -- samsung,i2s-controller: The phandle of the Samsung I2S controller -- samsung,audio-codec: The phandle of the audio codec +- samsung,i2s-controller (deprecated): The phandle of the Samsung I2S controller +- samsung,audio-codec (deprecated): The phandle of the audio codec + +Required sub-nodes: + + - 'cpu' subnode with a 'sound-dai' property containing the phandle of the I2S + controller + - 'codec' subnode with a 'sound-dai' property containing list of phandles + to the CODEC nodes, first entry must be the phandle of the MAX98090, + MAX98091 or MAX98095 CODEC (exact device type is indicated by the compatible + string) and the second entry must be the phandle of the HDMI IP block node Optional: - samsung,model: The name of the sound-card From aff8d2bed9e5a33f40611063de62003c0f3abe9f Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Mon, 12 Mar 2018 19:49:39 +0100 Subject: [PATCH 643/942] ASoC: samsung: Add HDMI audio support for Snow This patch updates the driver so, in addition to current DT bindings, it also can also use the new DT bindings with cpu, codec subnodes which allow to support sound on the HDMI interface. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/snow.c | 226 ++++++++++++++++++++++++++++++--------- 1 file changed, 178 insertions(+), 48 deletions(-) diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c index fc62110f500f..5d8efc2d5c38 100644 --- a/sound/soc/samsung/snow.c +++ b/sound/soc/samsung/snow.c @@ -11,92 +11,207 @@ * General Public License for more details. */ +#include #include #include #include #include - +#include #include #include "i2s.h" #define FIN_PLL_RATE 24000000 -static struct snd_soc_dai_link snow_dai[] = { - { - .name = "Primary", - .stream_name = "Primary", - .codec_dai_name = "HiFi", - .dai_fmt = SND_SOC_DAIFMT_I2S | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBS_CFS, - }, +struct snow_priv { + struct snd_soc_dai_link dai_link; + struct clk *clk_i2s_bus; +}; + +static int snow_card_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + static const unsigned int pll_rate[] = { + 73728000U, 67737602U, 49152000U, 45158401U, 32768001U + }; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snow_priv *priv = snd_soc_card_get_drvdata(rtd->card); + int bfs, psr, rfs, bitwidth; + unsigned long int rclk; + long int freq = -EINVAL; + int ret, i; + + bitwidth = snd_pcm_format_width(params_format(params)); + if (bitwidth < 0) { + dev_err(rtd->card->dev, "Invalid bit-width: %d\n", bitwidth); + return bitwidth; + } + + if (bitwidth != 16 && bitwidth != 24) { + dev_err(rtd->card->dev, "Unsupported bit-width: %d\n", bitwidth); + return -EINVAL; + } + + bfs = 2 * bitwidth; + + switch (params_rate(params)) { + case 16000: + case 22050: + case 24000: + case 32000: + case 44100: + case 48000: + case 88200: + case 96000: + rfs = 8 * bfs; + break; + case 64000: + rfs = 384; + break; + case 8000: + case 11025: + case 12000: + rfs = 16 * bfs; + break; + default: + return -EINVAL; + } + + rclk = params_rate(params) * rfs; + + for (psr = 8; psr > 0; psr /= 2) { + for (i = 0; i < ARRAY_SIZE(pll_rate); i++) { + if ((pll_rate[i] - rclk * psr) <= 2) { + freq = pll_rate[i]; + break; + } + } + } + if (freq < 0) { + dev_err(rtd->card->dev, "Unsupported RCLK rate: %lu\n", rclk); + return -EINVAL; + } + + ret = clk_set_rate(priv->clk_i2s_bus, freq); + if (ret < 0) { + dev_err(rtd->card->dev, "I2S bus clock rate set failed\n"); + return ret; + } + + return 0; +} + +static const struct snd_soc_ops snow_card_ops = { + .hw_params = snow_card_hw_params, }; static int snow_late_probe(struct snd_soc_card *card) { struct snd_soc_pcm_runtime *rtd; struct snd_soc_dai *codec_dai; - struct snd_soc_dai *cpu_dai; - int ret; rtd = snd_soc_get_pcm_runtime(card, card->dai_link[0].name); - codec_dai = rtd->codec_dai; - cpu_dai = rtd->cpu_dai; + + /* In the multi-codec case codec_dais 0 is MAX98095 and 1 is HDMI. */ + if (rtd->num_codecs > 1) + codec_dai = rtd->codec_dais[0]; + else + codec_dai = rtd->codec_dai; /* Set the MCLK rate for the codec */ - ret = snd_soc_dai_set_sysclk(codec_dai, 0, - FIN_PLL_RATE, SND_SOC_CLOCK_IN); - if (ret < 0) - return ret; - - - return 0; + return snd_soc_dai_set_sysclk(codec_dai, 0, + FIN_PLL_RATE, SND_SOC_CLOCK_IN); } static struct snd_soc_card snow_snd = { .name = "Snow-I2S", .owner = THIS_MODULE, - .dai_link = snow_dai, - .num_links = ARRAY_SIZE(snow_dai), - .late_probe = snow_late_probe, }; static int snow_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct snd_soc_card *card = &snow_snd; - struct device_node *i2s_node, *codec_node; - int i, ret; + struct device_node *cpu, *codec; + struct snd_soc_dai_link *link; + struct snow_priv *priv; + int ret; - i2s_node = of_parse_phandle(pdev->dev.of_node, - "samsung,i2s-controller", 0); - if (!i2s_node) { - dev_err(&pdev->dev, - "Property 'i2s-controller' missing or invalid\n"); - return -EINVAL; + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + link = &priv->dai_link; + + link->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_CBS_CFS; + + link->name = "Primary"; + link->stream_name = link->name; + + card->dai_link = link; + card->num_links = 1; + card->dev = dev; + + /* Try new DT bindings with HDMI support first. */ + cpu = of_get_child_by_name(dev->of_node, "cpu"); + + if (cpu) { + link->ops = &snow_card_ops; + + link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); + of_node_put(cpu); + + if (!link->cpu_of_node) { + dev_err(dev, "Failed parsing cpu/sound-dai property\n"); + return -EINVAL; + } + + codec = of_get_child_by_name(dev->of_node, "codec"); + ret = snd_soc_of_get_dai_link_codecs(dev, codec, link); + of_node_put(codec); + + if (ret < 0) { + of_node_put(link->cpu_of_node); + dev_err(dev, "Failed parsing codec node\n"); + return ret; + } + + priv->clk_i2s_bus = of_clk_get_by_name(link->cpu_of_node, + "i2s_opclk0"); + if (IS_ERR(priv->clk_i2s_bus)) { + snd_soc_of_put_dai_link_codecs(link); + of_node_put(link->cpu_of_node); + return PTR_ERR(priv->clk_i2s_bus); + } + } else { + link->codec_dai_name = "HiFi", + + link->cpu_of_node = of_parse_phandle(dev->of_node, + "samsung,i2s-controller", 0); + if (!link->cpu_of_node) { + dev_err(dev, "i2s-controller property parse error\n"); + return -EINVAL; + } + + link->codec_of_node = of_parse_phandle(dev->of_node, + "samsung,audio-codec", 0); + if (!link->codec_of_node) { + of_node_put(link->cpu_of_node); + dev_err(dev, "audio-codec property parse error\n"); + return -EINVAL; + } } - codec_node = of_parse_phandle(pdev->dev.of_node, - "samsung,audio-codec", 0); - if (!codec_node) { - dev_err(&pdev->dev, - "Property 'audio-codec' missing or invalid\n"); - return -EINVAL; - } - - for (i = 0; i < ARRAY_SIZE(snow_dai); i++) { - snow_dai[i].codec_of_node = codec_node; - snow_dai[i].cpu_of_node = i2s_node; - snow_dai[i].platform_of_node = i2s_node; - } - - card->dev = &pdev->dev; + link->platform_of_node = link->cpu_of_node; /* Update card-name if provided through DT, else use default name */ snd_soc_of_parse_card_name(card, "samsung,model"); - ret = devm_snd_soc_register_card(&pdev->dev, card); + snd_soc_card_set_drvdata(card, priv); + + ret = devm_snd_soc_register_card(dev, card); if (ret) { dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); return ret; @@ -105,6 +220,20 @@ static int snow_probe(struct platform_device *pdev) return ret; } +static int snow_remove(struct platform_device *pdev) +{ + struct snow_priv *priv = platform_get_drvdata(pdev); + struct snd_soc_dai_link *link = &priv->dai_link; + + of_node_put(link->cpu_of_node); + of_node_put(link->codec_of_node); + snd_soc_of_put_dai_link_codecs(link); + + clk_put(priv->clk_i2s_bus); + + return 0; +} + static const struct of_device_id snow_of_match[] = { { .compatible = "google,snow-audio-max98090", }, { .compatible = "google,snow-audio-max98091", }, @@ -120,6 +249,7 @@ static struct platform_driver snow_driver = { .of_match_table = snow_of_match, }, .probe = snow_probe, + .remove = snow_remove, }; module_platform_driver(snow_driver); From fc9fdd61c4809b14faa9b84fe3d8f4167a836326 Mon Sep 17 00:00:00 2001 From: Sanyog Kale Date: Tue, 13 Mar 2018 09:02:25 +0530 Subject: [PATCH 644/942] ASoC: Intel: Skylake: Disable clock and power gating during FW/LIB download In order to achieve better DMA performance and reduce download time for firmware and library, it is recommended to disable dynamic clock and power gating. In some scenarios, DMA may wait to accumulate more data and last chunk of data never gets completed if dynamic clock and power gating is kept enabled. This patch adds support to disable/enable dynamic clock and power gating and use it during firmware and library download. Signed-off-by: Rakesh Ughreja Signed-off-by: Sanyog Kale Signed-off-by: Guneshwor Singh Signed-off-by: Mark Brown --- sound/soc/intel/skylake/skl-messages.c | 7 ++++++- sound/soc/intel/skylake/skl-pcm.c | 7 ++++++- sound/soc/intel/skylake/skl-sst-ipc.h | 3 +++ sound/soc/intel/skylake/skl.c | 27 ++++++++++++++++++++++++++ sound/soc/intel/skylake/skl.h | 4 ++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c index f161907859f3..57d4a58522a6 100644 --- a/sound/soc/intel/skylake/skl-messages.c +++ b/sound/soc/intel/skylake/skl-messages.c @@ -417,11 +417,16 @@ int skl_resume_dsp(struct skl *skl) if (skl->skl_sst->is_first_boot == true) return 0; - /* disable dynamic clock gating during fw and lib download */ + /* + * Disable dynamic clock and power gating during firmware + * and library download + */ ctx->enable_miscbdcge(ctx->dev, false); + ctx->clock_power_gating(ctx->dev, false); ret = skl_dsp_wake(ctx->dsp); ctx->enable_miscbdcge(ctx->dev, true); + ctx->clock_power_gating(ctx->dev, true); if (ret < 0) return ret; diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 84e40faeb869..15cb8ac3e374 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1356,11 +1356,16 @@ static int skl_platform_soc_probe(struct snd_soc_component *component) return -EIO; } - /* disable dynamic clock gating during fw and lib download */ + /* + * Disable dynamic clock and power gating during firmware + * and library download + */ skl->skl_sst->enable_miscbdcge(component->dev, false); + skl->skl_sst->clock_power_gating(component->dev, false); ret = ops->init_fw(component->dev, skl->skl_sst); skl->skl_sst->enable_miscbdcge(component->dev, true); + skl->skl_sst->clock_power_gating(component->dev, true); if (ret < 0) { dev_err(component->dev, "Failed to boot first fw: %d\n", ret); return ret; diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h index 55f2d2ce09df..f74f040dfd83 100644 --- a/sound/soc/intel/skylake/skl-sst-ipc.h +++ b/sound/soc/intel/skylake/skl-sst-ipc.h @@ -118,6 +118,9 @@ struct skl_sst { struct skl_d0i3_data d0i3; const struct skl_dsp_ops *dsp_ops; + + /* Callback to update dynamic clock and power gating registers */ + void (*clock_power_gating)(struct device *dev, bool enable); }; struct skl_ipc_init_instance_msg { diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c index aa9edc84eefb..abf324747b29 100644 --- a/sound/soc/intel/skylake/skl.c +++ b/sound/soc/intel/skylake/skl.c @@ -94,6 +94,32 @@ static void skl_enable_miscbdcge(struct device *dev, bool enable) update_pci_dword(pci, AZX_PCIREG_CGCTL, AZX_CGCTL_MISCBDCGE_MASK, val); } +/** + * skl_clock_power_gating: Enable/Disable clock and power gating + * + * @dev: Device pointer + * @enable: Enable/Disable flag + */ +static void skl_clock_power_gating(struct device *dev, bool enable) +{ + struct pci_dev *pci = to_pci_dev(dev); + struct hdac_ext_bus *ebus = pci_get_drvdata(pci); + struct hdac_bus *bus = ebus_to_hbus(ebus); + u32 val; + + /* Update PDCGE bit of CGCTL register */ + val = enable ? AZX_CGCTL_ADSPDCGE : 0; + update_pci_dword(pci, AZX_PCIREG_CGCTL, AZX_CGCTL_ADSPDCGE, val); + + /* Update L1SEN bit of EM2 register */ + val = enable ? AZX_REG_VS_EM2_L1SEN : 0; + snd_hdac_chip_updatel(bus, VS_EM2, AZX_REG_VS_EM2_L1SEN, val); + + /* Update ADSPPGD bit of PGCTL register */ + val = enable ? 0 : AZX_PGCTL_ADSPPGD; + update_pci_dword(pci, AZX_PCIREG_PGCTL, AZX_PGCTL_ADSPPGD, val); +} + /* * While performing reset, controller may not come back properly causing * issues, so recommendation is to set CGCTL.MISCBDCGE to 0 then do reset @@ -916,6 +942,7 @@ static int skl_probe(struct pci_dev *pci, goto out_nhlt_free; } skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; + skl->skl_sst->clock_power_gating = skl_clock_power_gating; } if (bus->mlcap) snd_hdac_ext_bus_get_ml_capabilities(ebus); diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h index ca46ad1d0a08..0d5375cbcf6e 100644 --- a/sound/soc/intel/skylake/skl.h +++ b/sound/soc/intel/skylake/skl.h @@ -33,8 +33,10 @@ #define AZX_PCIREG_PGCTL 0x44 #define AZX_PGCTL_LSRMD_MASK (1 << 4) +#define AZX_PGCTL_ADSPPGD BIT(2) #define AZX_PCIREG_CGCTL 0x48 #define AZX_CGCTL_MISCBDCGE_MASK (1 << 6) +#define AZX_CGCTL_ADSPDCGE BIT(1) /* D0I3C Register fields */ #define AZX_REG_VS_D0I3C_CIP 0x1 /* Command in progress */ #define AZX_REG_VS_D0I3C_I3 0x4 /* D0i3 enable */ @@ -43,6 +45,8 @@ #define DMA_TRANSMITION_START 2 #define DMA_TRANSMITION_STOP 3 +#define AZX_REG_VS_EM2_L1SEN BIT(13) + struct skl_dsp_resource { u32 max_mcps; u32 max_mem; From 2e78a5562ebc2e4bbdfd7f7729385b3acc94c36e Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Tue, 13 Mar 2018 17:27:08 +0100 Subject: [PATCH 645/942] ASoC: dmaengine_pcm: document process callback Add missing description of process callback. Fixes: 78648092ef46 ("ASoC: dmaengine_pcm: add processing support") Signed-off-by: Olivier Moysan Signed-off-by: Mark Brown --- include/sound/dmaengine_pcm.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index 47ef486852ed..e3481eebdd98 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h @@ -118,6 +118,8 @@ void snd_dmaengine_pcm_set_config_from_dai_data( * PCM substream. Will be called from the PCM drivers hwparams callback. * @compat_request_channel: Callback to request a DMA channel for platforms * which do not use devicetree. + * @process: Callback used to apply processing on samples transferred from/to + * user space. * @compat_filter_fn: Will be used as the filter function when requesting a * channel for platforms which do not use devicetree. The filter parameter * will be the DAI's DMA data. From 5b2d15bbd1eeb3d787c8e6459a8cb2645f336050 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Sat, 10 Mar 2018 02:37:27 +0000 Subject: [PATCH 646/942] ASoC: dapm: add support to pinctrl dapm Purpose of having pinctrl dapm is to dynamically put the pins in low power state when they are not actively used by the audio and saving power. Without this each driver has to set the pinctrl states, either during probe or dynamically depending on the callbacks received from ASoC core. Signed-off-by: Srinivas Kandagatla Signed-off-by: Mark Brown --- include/sound/soc-dapm.h | 16 +++++++++++++++ sound/soc/soc-dapm.c | 42 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 344b96c206a3..a6ce2de4e20a 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h @@ -269,6 +269,13 @@ struct device; .reg = SND_SOC_NOPM, .shift = wdelay, .event = dapm_regulator_event, \ .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \ .on_val = wflags} +#define SND_SOC_DAPM_PINCTRL(wname, active, sleep) \ +{ .id = snd_soc_dapm_pinctrl, .name = wname, \ + .priv = (&(struct snd_soc_dapm_pinctrl_priv) \ + { .active_state = active, .sleep_state = sleep,}), \ + .reg = SND_SOC_NOPM, .event = dapm_pinctrl_event, \ + .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD } + /* dapm kcontrol types */ @@ -374,6 +381,8 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); int dapm_clock_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event); +int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event); /* dapm controls */ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, @@ -500,6 +509,7 @@ enum snd_soc_dapm_type { snd_soc_dapm_pre, /* machine specific pre widget - exec first */ snd_soc_dapm_post, /* machine specific post widget - exec last */ snd_soc_dapm_supply, /* power/clock supply */ + snd_soc_dapm_pinctrl, /* pinctrl */ snd_soc_dapm_regulator_supply, /* external regulator */ snd_soc_dapm_clock_supply, /* external clock */ snd_soc_dapm_aif_in, /* audio interface input */ @@ -581,6 +591,7 @@ struct snd_soc_dapm_widget { void *priv; /* widget specific data */ struct regulator *regulator; /* attached regulator */ + struct pinctrl *pinctrl; /* attached pinctrl */ const struct snd_soc_pcm_stream *params; /* params for dai links */ unsigned int num_params; /* number of params for dai links */ unsigned int params_select; /* currently selected param for dai link */ @@ -683,6 +694,11 @@ struct snd_soc_dapm_stats { int neighbour_checks; }; +struct snd_soc_dapm_pinctrl_priv { + const char *active_state; + const char *sleep_state; +}; + /** * snd_soc_dapm_init_bias_level() - Initialize DAPM bias level * @dapm: The DAPM context to initialize diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 92894d9cac19..a5fb4d404c99 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -72,6 +73,7 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, static int dapm_up_seq[] = { [snd_soc_dapm_pre] = 0, [snd_soc_dapm_regulator_supply] = 1, + [snd_soc_dapm_pinctrl] = 1, [snd_soc_dapm_clock_supply] = 1, [snd_soc_dapm_supply] = 2, [snd_soc_dapm_micbias] = 3, @@ -121,6 +123,7 @@ static int dapm_down_seq[] = { [snd_soc_dapm_dai_link] = 11, [snd_soc_dapm_supply] = 12, [snd_soc_dapm_clock_supply] = 13, + [snd_soc_dapm_pinctrl] = 13, [snd_soc_dapm_regulator_supply] = 13, [snd_soc_dapm_post] = 14, }; @@ -1289,6 +1292,31 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w, } EXPORT_SYMBOL_GPL(dapm_regulator_event); +/* + * Handler for pinctrl widget. + */ +int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, + struct snd_kcontrol *kcontrol, int event) +{ + struct snd_soc_dapm_pinctrl_priv *priv = w->priv; + struct pinctrl *p = w->pinctrl; + struct pinctrl_state *s; + + if (!p || !priv) + return -EIO; + + if (SND_SOC_DAPM_EVENT_ON(event)) + s = pinctrl_lookup_state(p, priv->active_state); + else + s = pinctrl_lookup_state(p, priv->sleep_state); + + if (IS_ERR(s)) + return PTR_ERR(s); + + return pinctrl_select_state(p, s); +} +EXPORT_SYMBOL_GPL(dapm_pinctrl_event); + /* * Handler for clock supply widget. */ @@ -1902,6 +1930,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) break; case snd_soc_dapm_supply: case snd_soc_dapm_regulator_supply: + case snd_soc_dapm_pinctrl: case snd_soc_dapm_clock_supply: case snd_soc_dapm_micbias: if (d->target_bias_level < SND_SOC_BIAS_STANDBY) @@ -2315,6 +2344,7 @@ static ssize_t dapm_widget_show_component(struct snd_soc_component *cmpnt, case snd_soc_dapm_mixer_named_ctl: case snd_soc_dapm_supply: case snd_soc_dapm_regulator_supply: + case snd_soc_dapm_pinctrl: case snd_soc_dapm_clock_supply: if (w->name) count += sprintf(buf + count, "%s: %s\n", @@ -3464,6 +3494,17 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, w->name, ret); } break; + case snd_soc_dapm_pinctrl: + w->pinctrl = devm_pinctrl_get(dapm->dev); + if (IS_ERR_OR_NULL(w->pinctrl)) { + ret = PTR_ERR(w->pinctrl); + if (ret == -EPROBE_DEFER) + return ERR_PTR(ret); + dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n", + w->name, ret); + return NULL; + } + break; case snd_soc_dapm_clock_supply: #ifdef CONFIG_CLKDEV_LOOKUP w->clk = devm_clk_get(dapm->dev, w->name); @@ -3543,6 +3584,7 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, break; case snd_soc_dapm_supply: case snd_soc_dapm_regulator_supply: + case snd_soc_dapm_pinctrl: case snd_soc_dapm_clock_supply: case snd_soc_dapm_kcontrol: w->is_supply = 1; From 5617c599bbb09bfbee370e1cdb479d08bcd07559 Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Mon, 19 Feb 2018 16:02:48 +0100 Subject: [PATCH 647/942] auxdisplay: panel: Change comments to silence fallthrough warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compiling with W=1 with gcc 7.2.0 gives 3 warnings like: drivers/auxdisplay/panel.c: In function ‘panel_process_inputs’: drivers/auxdisplay/panel.c:1374:17: warning: this statement may fall through [-Wimplicit-fallthrough=] Cc: Willy Tarreau Cc: Geert Uytterhoeven Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/panel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/auxdisplay/panel.c b/drivers/auxdisplay/panel.c index ea7869c0d7f9..ec5e8800f8ad 100644 --- a/drivers/auxdisplay/panel.c +++ b/drivers/auxdisplay/panel.c @@ -1372,7 +1372,7 @@ static void panel_process_inputs(void) break; input->rise_timer = 0; input->state = INPUT_ST_RISING; - /* no break here, fall through */ + /* fall through */ case INPUT_ST_RISING: if ((phys_curr & input->mask) != input->value) { input->state = INPUT_ST_LOW; @@ -1385,11 +1385,11 @@ static void panel_process_inputs(void) } input->high_timer = 0; input->state = INPUT_ST_HIGH; - /* no break here, fall through */ + /* fall through */ case INPUT_ST_HIGH: if (input_state_high(input)) break; - /* no break here, fall through */ + /* fall through */ case INPUT_ST_FALLING: input_state_falling(input); } From 6a78b4dde1057f89a1e25ec81ed646c4f8077311 Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Mon, 19 Feb 2018 16:14:17 +0100 Subject: [PATCH 648/942] auxdisplay: img-ascii-lcd: Fix doc comment to silence warnings Compiling with W=1 with gcc 7.2.0 gives 2 warnings: drivers/auxdisplay/img-ascii-lcd.c:233: warning: Function parameter or member 't' not described in 'img_ascii_lcd_scroll' drivers/auxdisplay/img-ascii-lcd.c:233: warning: Excess function parameter 'arg' description in 'img_ascii_lcd_scroll' Cc: Paul Burton Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/img-ascii-lcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c index 9180b9bd5821..d8133024fd5d 100644 --- a/drivers/auxdisplay/img-ascii-lcd.c +++ b/drivers/auxdisplay/img-ascii-lcd.c @@ -224,7 +224,7 @@ MODULE_DEVICE_TABLE(of, img_ascii_lcd_matches); /** * img_ascii_lcd_scroll() - scroll the display by a character - * @arg: really a pointer to the private data structure + * @t: really a pointer to the private data structure * * Scroll the current message along the LCD by one character, rearming the * timer if required. From 26a2c54d03bd514fb3d3520706f911b3ca56b011 Mon Sep 17 00:00:00 2001 From: Miguel Ojeda Date: Mon, 19 Feb 2018 16:47:52 +0100 Subject: [PATCH 649/942] auxdisplay: img-ascii-lcd: Silence 2 uninitialized warnings The warnings are: drivers/auxdisplay/img-ascii-lcd.c: warning: 'err' may be used uninitialized in this function [-Wuninitialized] At lines 109 and 207. Reported by Geert using the build service several times, e.g.: https://lkml.org/lkml/2018/2/19/303 They are two false positives, since num_chars > 0 in the three present configurations (boston, malta, sead3). Initialize to 0 in order to silence the warning. Cc: Geert Uytterhoeven Cc: Paul Burton Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/img-ascii-lcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c index d8133024fd5d..834509506ef6 100644 --- a/drivers/auxdisplay/img-ascii-lcd.c +++ b/drivers/auxdisplay/img-ascii-lcd.c @@ -97,7 +97,7 @@ static struct img_ascii_lcd_config boston_config = { static void malta_update(struct img_ascii_lcd_ctx *ctx) { unsigned int i; - int err; + int err = 0; for (i = 0; i < ctx->cfg->num_chars; i++) { err = regmap_write(ctx->regmap, @@ -180,7 +180,7 @@ static int sead3_wait_lcd_idle(struct img_ascii_lcd_ctx *ctx) static void sead3_update(struct img_ascii_lcd_ctx *ctx) { unsigned int i; - int err; + int err = 0; for (i = 0; i < ctx->cfg->num_chars; i++) { err = sead3_wait_lcd_idle(ctx); From c37366742baa2bb3225be507d283baef151c5f8a Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Mon, 12 Mar 2018 20:30:43 -0400 Subject: [PATCH 650/942] dm mpath: fix uninitialized 'pg_init_wait' waitqueue_head NULL pointer Initialize all the scsi_dh related 'struct multipath' members regardless of whether a scsi_dh is in use or not. The subtle (and fragile) SCSI-assuming legacy code clearly needs further decoupling from non-SCSI (and/or developer understanding). Fixes: 8d47e65948dd ("dm mpath: remove unnecessary NVMe branching in favor of scsi_dh checks") Reported-by: Bart Van Assche Signed-off-by: Mike Snitzer --- drivers/md/dm-mpath.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 3fde9e9faddd..87c404eebe9f 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -223,6 +223,16 @@ static int alloc_multipath_stage2(struct dm_target *ti, struct multipath *m) dm_table_set_type(ti->table, m->queue_mode); + /* + * Init fields that are only used when a scsi_dh is attached + * - must do this unconditionally (really doesn't hurt non-SCSI uses) + */ + set_bit(MPATHF_QUEUE_IO, &m->flags); + atomic_set(&m->pg_init_in_progress, 0); + atomic_set(&m->pg_init_count, 0); + m->pg_init_delay_msecs = DM_PG_INIT_DELAY_DEFAULT; + init_waitqueue_head(&m->pg_init_wait); + return 0; } @@ -331,7 +341,6 @@ static void __switch_pg(struct multipath *m, struct priority_group *pg) set_bit(MPATHF_PG_INIT_REQUIRED, &m->flags); set_bit(MPATHF_QUEUE_IO, &m->flags); } else { - /* FIXME: not needed if no scsi_dh is attached */ clear_bit(MPATHF_PG_INIT_REQUIRED, &m->flags); clear_bit(MPATHF_QUEUE_IO, &m->flags); } @@ -823,16 +832,6 @@ retain: */ kfree(m->hw_handler_name); m->hw_handler_name = attached_handler_name; - - /* - * Init fields that are only used when a scsi_dh is attached - */ - if (!test_and_set_bit(MPATHF_QUEUE_IO, &m->flags)) { - atomic_set(&m->pg_init_in_progress, 0); - atomic_set(&m->pg_init_count, 0); - m->pg_init_delay_msecs = DM_PG_INIT_DELAY_DEFAULT; - init_waitqueue_head(&m->pg_init_wait); - } } } From e8f74a0f00113d74ac18d6de13096f9e2f95618a Mon Sep 17 00:00:00 2001 From: Mike Snitzer Date: Mon, 12 Mar 2018 19:49:25 -0400 Subject: [PATCH 651/942] dm mpath: eliminate need to use scsi_device_from_queue Instead of scsi_device_from_queue(), use scsi_dh_attached_handler_name() -- whose implementation uses scsi_device_from_queue() to avoid trying to access SCSI-specific resources from non-SCSI devices. Fixes buildbot reported issue when CONFIG_SCSI isn't set: ERROR: "scsi_device_from_queue" [drivers/md/dm-multipath.ko] undefined! Fixes: 8d47e65948dd ("dm mpath: remove unnecessary NVMe branching in favor of scsi_dh checks") Signed-off-by: Mike Snitzer --- drivers/md/dm-mpath.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 87c404eebe9f..2481c4794ed6 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -805,15 +804,14 @@ static int parse_path_selector(struct dm_arg_set *as, struct priority_group *pg, return 0; } -static int setup_scsi_dh(struct block_device *bdev, struct multipath *m, char **error) +static int setup_scsi_dh(struct block_device *bdev, struct multipath *m, + const char *attached_handler_name, char **error) { struct request_queue *q = bdev_get_queue(bdev); - const char *attached_handler_name; int r; if (test_bit(MPATHF_RETAIN_ATTACHED_HW_HANDLER, &m->flags)) { retain: - attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL); if (attached_handler_name) { /* * Clear any hw_handler_params associated with a @@ -867,7 +865,8 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps int r; struct pgpath *p; struct multipath *m = ti->private; - struct scsi_device *sdev; + struct request_queue *q; + const char *attached_handler_name; /* we need at least a path arg */ if (as->argc < 1) { @@ -886,11 +885,11 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps goto bad; } - sdev = scsi_device_from_queue(bdev_get_queue(p->path.dev->bdev)); - if (sdev) { - put_device(&sdev->sdev_gendev); + q = bdev_get_queue(p->path.dev->bdev); + attached_handler_name = scsi_dh_attached_handler_name(q, GFP_KERNEL); + if (attached_handler_name) { INIT_DELAYED_WORK(&p->activate_path, activate_path_work); - r = setup_scsi_dh(p->path.dev->bdev, m, &ti->error); + r = setup_scsi_dh(p->path.dev->bdev, m, attached_handler_name, &ti->error); if (r) { dm_put_device(ti, p->path.dev); goto bad; From 537f4146c53c95aac977852b371bafb9c6755ee1 Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 6 Mar 2018 15:35:43 +0530 Subject: [PATCH 652/942] workqueue: use put_device() instead of kfree() Never directly free @dev after calling device_register(), even if it returned an error! Always use put_device() to give up the reference initialized in this function instead. Signed-off-by: Arvind Yadav Signed-off-by: Tejun Heo --- kernel/workqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index bb9a519cbf50..ccd1080dd6e7 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -5337,7 +5337,7 @@ int workqueue_sysfs_register(struct workqueue_struct *wq) ret = device_register(&wq_dev->dev); if (ret) { - kfree(wq_dev); + put_device(&wq_dev->dev); wq->wq_dev = NULL; return ret; } From 2c292dbb398ee46fc1343daf6c3cf9715a75688e Mon Sep 17 00:00:00 2001 From: Boris Pismenny Date: Thu, 8 Mar 2018 15:51:40 +0200 Subject: [PATCH 653/942] IB/mlx5: Fix out-of-bounds read in create_raw_packet_qp_rq Add a check for the length of the qpin structure to prevent out-of-bounds reads BUG: KASAN: slab-out-of-bounds in create_raw_packet_qp+0x114c/0x15e2 Read of size 8192 at addr ffff880066b99290 by task syz-executor3/549 CPU: 3 PID: 549 Comm: syz-executor3 Not tainted 4.15.0-rc2+ #27 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 Call Trace: dump_stack+0x8d/0xd4 print_address_description+0x73/0x290 kasan_report+0x25c/0x370 ? create_raw_packet_qp+0x114c/0x15e2 memcpy+0x1f/0x50 create_raw_packet_qp+0x114c/0x15e2 ? create_raw_packet_qp_tis.isra.28+0x13d/0x13d ? lock_acquire+0x370/0x370 create_qp_common+0x2245/0x3b50 ? destroy_qp_user.isra.47+0x100/0x100 ? kasan_kmalloc+0x13d/0x170 ? sched_clock_cpu+0x18/0x180 ? fs_reclaim_acquire.part.15+0x5/0x30 ? __lock_acquire+0xa11/0x1da0 ? sched_clock_cpu+0x18/0x180 ? kmem_cache_alloc_trace+0x17e/0x310 ? mlx5_ib_create_qp+0x30e/0x17b0 mlx5_ib_create_qp+0x33d/0x17b0 ? sched_clock_cpu+0x18/0x180 ? create_qp_common+0x3b50/0x3b50 ? lock_acquire+0x370/0x370 ? __radix_tree_lookup+0x180/0x220 ? uverbs_try_lock_object+0x68/0xc0 ? rdma_lookup_get_uobject+0x114/0x240 create_qp.isra.5+0xce4/0x1e20 ? ib_uverbs_ex_create_cq_cb+0xa0/0xa0 ? copy_ah_attr_from_uverbs.isra.2+0xa00/0xa00 ? ib_uverbs_cq_event_handler+0x160/0x160 ? __might_fault+0x17c/0x1c0 ib_uverbs_create_qp+0x21b/0x2a0 ? ib_uverbs_destroy_cq+0x2e0/0x2e0 ib_uverbs_write+0x55a/0xad0 ? ib_uverbs_destroy_cq+0x2e0/0x2e0 ? ib_uverbs_destroy_cq+0x2e0/0x2e0 ? ib_uverbs_open+0x760/0x760 ? futex_wake+0x147/0x410 ? check_prev_add+0x1680/0x1680 ? do_futex+0x3d3/0xa60 ? sched_clock_cpu+0x18/0x180 __vfs_write+0xf7/0x5c0 ? ib_uverbs_open+0x760/0x760 ? kernel_read+0x110/0x110 ? lock_acquire+0x370/0x370 ? __fget+0x264/0x3b0 vfs_write+0x18a/0x460 SyS_write+0xc7/0x1a0 ? SyS_read+0x1a0/0x1a0 ? trace_hardirqs_on_thunk+0x1a/0x1c entry_SYSCALL_64_fastpath+0x18/0x85 RIP: 0033:0x4477b9 RSP: 002b:00007f1822cadc18 EFLAGS: 00000292 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00000000004477b9 RDX: 0000000000000070 RSI: 000000002000a000 RDI: 0000000000000005 RBP: 0000000000708000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000292 R12: 00000000ffffffff R13: 0000000000005d70 R14: 00000000006e6e30 R15: 0000000020010ff0 Allocated by task 549: __kmalloc+0x15e/0x340 kvmalloc_node+0xa1/0xd0 create_user_qp.isra.46+0xd42/0x1610 create_qp_common+0x2e63/0x3b50 mlx5_ib_create_qp+0x33d/0x17b0 create_qp.isra.5+0xce4/0x1e20 ib_uverbs_create_qp+0x21b/0x2a0 ib_uverbs_write+0x55a/0xad0 __vfs_write+0xf7/0x5c0 vfs_write+0x18a/0x460 SyS_write+0xc7/0x1a0 entry_SYSCALL_64_fastpath+0x18/0x85 Freed by task 368: kfree+0xeb/0x2f0 kernfs_fop_release+0x140/0x180 __fput+0x266/0x700 task_work_run+0x104/0x180 exit_to_usermode_loop+0xf7/0x110 syscall_return_slowpath+0x298/0x370 entry_SYSCALL_64_fastpath+0x83/0x85 The buggy address belongs to the object at ffff880066b99180 which belongs to the cache kmalloc-512 of size 512 The buggy address is located 272 bytes inside of 512-byte region [ffff880066b99180, ffff880066b99380) The buggy address belongs to the page: page:000000006040eedd count:1 mapcount:0 mapping: (null) index:0x0 compound_mapcount: 0 flags: 0x4000000000008100(slab|head) raw: 4000000000008100 0000000000000000 0000000000000000 0000000180190019 raw: ffffea00019a7500 0000000b0000000b ffff88006c403080 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff880066b99180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff880066b99200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 >ffff880066b99280: 00 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff880066b99300: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff880066b99380: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc Cc: syzkaller Fixes: 0fb2ed66a14c ("IB/mlx5: Add create and destroy functionality for Raw Packet QP") Signed-off-by: Boris Pismenny Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford --- drivers/infiniband/hw/mlx5/qp.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 36197fbac63a..a2e1aa86e133 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c @@ -1161,7 +1161,7 @@ static void destroy_raw_packet_qp_sq(struct mlx5_ib_dev *dev, ib_umem_release(sq->ubuffer.umem); } -static int get_rq_pas_size(void *qpc) +static size_t get_rq_pas_size(void *qpc) { u32 log_page_size = MLX5_GET(qpc, qpc, log_page_size) + 12; u32 log_rq_stride = MLX5_GET(qpc, qpc, log_rq_stride); @@ -1177,7 +1177,8 @@ static int get_rq_pas_size(void *qpc) } static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev, - struct mlx5_ib_rq *rq, void *qpin) + struct mlx5_ib_rq *rq, void *qpin, + size_t qpinlen) { struct mlx5_ib_qp *mqp = rq->base.container_mibqp; __be64 *pas; @@ -1186,9 +1187,12 @@ static int create_raw_packet_qp_rq(struct mlx5_ib_dev *dev, void *rqc; void *wq; void *qpc = MLX5_ADDR_OF(create_qp_in, qpin, qpc); - int inlen; + size_t rq_pas_size = get_rq_pas_size(qpc); + size_t inlen; int err; - u32 rq_pas_size = get_rq_pas_size(qpc); + + if (qpinlen < rq_pas_size + MLX5_BYTE_OFF(create_qp_in, pas)) + return -EINVAL; inlen = MLX5_ST_SZ_BYTES(create_rq_in) + rq_pas_size; in = kvzalloc(inlen, GFP_KERNEL); @@ -1277,7 +1281,7 @@ static void destroy_raw_packet_qp_tir(struct mlx5_ib_dev *dev, } static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, - u32 *in, + u32 *in, size_t inlen, struct ib_pd *pd) { struct mlx5_ib_raw_packet_qp *raw_packet_qp = &qp->raw_packet_qp; @@ -1309,7 +1313,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp, rq->flags |= MLX5_IB_RQ_CVLAN_STRIPPING; if (qp->flags & MLX5_IB_QP_PCI_WRITE_END_PADDING) rq->flags |= MLX5_IB_RQ_PCI_WRITE_END_PADDING; - err = create_raw_packet_qp_rq(dev, rq, in); + err = create_raw_packet_qp_rq(dev, rq, in, inlen); if (err) goto err_destroy_sq; @@ -1872,11 +1876,16 @@ static int create_qp_common(struct mlx5_ib_dev *dev, struct ib_pd *pd, } } + if (inlen < 0) { + err = -EINVAL; + goto err; + } + if (init_attr->qp_type == IB_QPT_RAW_PACKET || qp->flags & MLX5_IB_QP_UNDERLAY) { qp->raw_packet_qp.sq.ubuffer.buf_addr = ucmd.sq_buf_addr; raw_packet_qp_copy_info(qp, &qp->raw_packet_qp); - err = create_raw_packet_qp(dev, qp, in, pd); + err = create_raw_packet_qp(dev, qp, in, inlen, pd); } else { err = mlx5_core_create_qp(dev->mdev, &base->mqp, in, inlen); } From c2b37f76485f073f020e60b5954b6dc4e55f693c Mon Sep 17 00:00:00 2001 From: Boris Pismenny Date: Thu, 8 Mar 2018 15:51:41 +0200 Subject: [PATCH 654/942] IB/mlx5: Fix integer overflows in mlx5_ib_create_srq This patch validates user provided input to prevent integer overflow due to integer manipulation in the mlx5_ib_create_srq function. Cc: syzkaller Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Signed-off-by: Boris Pismenny Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford --- drivers/infiniband/hw/mlx5/srq.c | 15 +++++++++------ include/linux/mlx5/driver.h | 4 ++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index 6d5fadad9090..3c7522d025f2 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c @@ -241,8 +241,8 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, { struct mlx5_ib_dev *dev = to_mdev(pd->device); struct mlx5_ib_srq *srq; - int desc_size; - int buf_size; + size_t desc_size; + size_t buf_size; int err; struct mlx5_srq_attr in = {0}; __u32 max_srq_wqes = 1 << MLX5_CAP_GEN(dev->mdev, log_max_srq_sz); @@ -266,15 +266,18 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, desc_size = sizeof(struct mlx5_wqe_srq_next_seg) + srq->msrq.max_gs * sizeof(struct mlx5_wqe_data_seg); + if (desc_size == 0 || srq->msrq.max_gs > desc_size) + return ERR_PTR(-EINVAL); desc_size = roundup_pow_of_two(desc_size); - desc_size = max_t(int, 32, desc_size); + desc_size = max_t(size_t, 32, desc_size); + if (desc_size < sizeof(struct mlx5_wqe_srq_next_seg)) + return ERR_PTR(-EINVAL); srq->msrq.max_avail_gather = (desc_size - sizeof(struct mlx5_wqe_srq_next_seg)) / sizeof(struct mlx5_wqe_data_seg); srq->msrq.wqe_shift = ilog2(desc_size); buf_size = srq->msrq.max * desc_size; - mlx5_ib_dbg(dev, "desc_size 0x%x, req wr 0x%x, srq size 0x%x, max_gs 0x%x, max_avail_gather 0x%x\n", - desc_size, init_attr->attr.max_wr, srq->msrq.max, srq->msrq.max_gs, - srq->msrq.max_avail_gather); + if (buf_size < desc_size) + return ERR_PTR(-EINVAL); in.type = init_attr->srq_type; if (pd->uobject) diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 6ed79a8a8318..9d3a03364e6e 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h @@ -453,8 +453,8 @@ struct mlx5_core_srq { struct mlx5_core_rsc_common common; /* must be first */ u32 srqn; int max; - int max_gs; - int max_avail_gather; + size_t max_gs; + size_t max_avail_gather; int wqe_shift; void (*event) (struct mlx5_core_srq *, enum mlx5_event); From 6417250d3f894e66a68ba1cd93676143f2376a6f Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 6 Mar 2018 19:34:42 -0800 Subject: [PATCH 655/942] workqueue: remove unused cancel_work() Found this by accident. There are no usages of bare cancel_work() in current kernel source. Signed-off-by: Stephen Hemminger Signed-off-by: Tejun Heo --- include/linux/workqueue.h | 1 - kernel/workqueue.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index bc0cda180c8b..0c3301421c57 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -456,7 +456,6 @@ extern int schedule_on_each_cpu(work_func_t func); int execute_in_process_context(work_func_t fn, struct execute_work *); extern bool flush_work(struct work_struct *work); -extern bool cancel_work(struct work_struct *work); extern bool cancel_work_sync(struct work_struct *work); extern bool flush_delayed_work(struct delayed_work *dwork); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index ccd1080dd6e7..6ec6ba65127b 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -3018,14 +3018,6 @@ static bool __cancel_work(struct work_struct *work, bool is_dwork) return ret; } -/* - * See cancel_delayed_work() - */ -bool cancel_work(struct work_struct *work) -{ - return __cancel_work(work, false); -} - /** * cancel_delayed_work - cancel a delayed work * @dwork: delayed_work to cancel From a8b48a4dccea77e29462e59f1dbf0d5aa1ff167c Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Wed, 7 Mar 2018 22:17:20 +1100 Subject: [PATCH 656/942] KVM: PPC: Book3S HV: Fix trap number return from __kvmppc_vcore_entry This fixes a bug where the trap number that is returned by __kvmppc_vcore_entry gets corrupted. The effect of the corruption is that IPIs get ignored on POWER9 systems when the IPI is sent via a doorbell interrupt to a CPU which is executing in a KVM guest. The effect of the IPI being ignored is often that another CPU locks up inside smp_call_function_many() (and if that CPU is holding a spinlock, other CPUs then lock up inside raw_spin_lock()). The trap number is currently held in register r12 for most of the assembly-language part of the guest exit path. In that path, we call kvmppc_subcore_exit_guest(), which is a C function, without restoring r12 afterwards. Depending on the kernel config and the compiler, it may modify r12 or it may not, so some config/compiler combinations see the bug and others don't. To fix this, we arrange for the trap number to be stored on the stack from the 'guest_bypass:' label until the end of the function, then the trap number is loaded and returned in r12 as before. Cc: stable@vger.kernel.org # v4.8+ Fixes: fd7bacbca47a ("KVM: PPC: Book3S HV: Fix TB corruption in guest exit path on HMI interrupt") Signed-off-by: Paul Mackerras --- arch/powerpc/kvm/book3s_hv_rmhandlers.S | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index f31f357b8c5a..d33264697a31 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S @@ -320,7 +320,6 @@ kvm_novcpu_exit: stw r12, STACK_SLOT_TRAP(r1) bl kvmhv_commence_exit nop - lwz r12, STACK_SLOT_TRAP(r1) b kvmhv_switch_to_host /* @@ -1220,6 +1219,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) secondary_too_late: li r12, 0 + stw r12, STACK_SLOT_TRAP(r1) cmpdi r4, 0 beq 11f stw r12, VCPU_TRAP(r4) @@ -1558,12 +1558,12 @@ mc_cont: 3: stw r5,VCPU_SLB_MAX(r9) guest_bypass: + stw r12, STACK_SLOT_TRAP(r1) mr r3, r12 /* Increment exit count, poke other threads to exit */ bl kvmhv_commence_exit nop ld r9, HSTATE_KVM_VCPU(r13) - lwz r12, VCPU_TRAP(r9) /* Stop others sending VCPU interrupts to this physical CPU */ li r0, -1 @@ -1898,6 +1898,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_POWER9_DD1) * POWER7/POWER8 guest -> host partition switch code. * We don't have to lock against tlbies but we do * have to coordinate the hardware threads. + * Here STACK_SLOT_TRAP(r1) contains the trap number. */ kvmhv_switch_to_host: /* Secondary threads wait for primary to do partition switch */ @@ -1950,12 +1951,12 @@ BEGIN_FTR_SECTION END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) /* If HMI, call kvmppc_realmode_hmi_handler() */ + lwz r12, STACK_SLOT_TRAP(r1) cmpwi r12, BOOK3S_INTERRUPT_HMI bne 27f bl kvmppc_realmode_hmi_handler nop cmpdi r3, 0 - li r12, BOOK3S_INTERRUPT_HMI /* * At this point kvmppc_realmode_hmi_handler may have resync-ed * the TB, and if it has, we must not subtract the guest timebase @@ -2008,10 +2009,8 @@ BEGIN_FTR_SECTION lwz r8, KVM_SPLIT_DO_RESTORE(r3) cmpwi r8, 0 beq 47f - stw r12, STACK_SLOT_TRAP(r1) bl kvmhv_p9_restore_lpcr nop - lwz r12, STACK_SLOT_TRAP(r1) b 48f 47: END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300) @@ -2049,6 +2048,7 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_RADIX) li r0, KVM_GUEST_MODE_NONE stb r0, HSTATE_IN_GUEST(r13) + lwz r12, STACK_SLOT_TRAP(r1) /* return trap # in r12 */ ld r0, SFS+PPC_LR_STKOFF(r1) addi r1, r1, SFS mtlr r0 From 0cbfeef230571b132d2ac2ea4346b200b311258f Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 5 Feb 2018 14:08:52 +0000 Subject: [PATCH 657/942] libnvdimm: remove redundant assignment to pointer 'dev' Pointer dev is being assigned a value that is never read, it is being re-assigned the same value later on, hence the initialization is redundant and can be removed. Cleans up clang warning: drivers/nvdimm/pfn_devs.c:307:17: warning: Value stored to 'dev' during its initialization is never read Signed-off-by: Colin Ian King Reviewed-by: Ross Zwisler Signed-off-by: Dan Williams --- drivers/nvdimm/pfn_devs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvdimm/pfn_devs.c b/drivers/nvdimm/pfn_devs.c index f5c4e8c6e29d..2f4d18752c97 100644 --- a/drivers/nvdimm/pfn_devs.c +++ b/drivers/nvdimm/pfn_devs.c @@ -304,7 +304,7 @@ static const struct attribute_group *nd_pfn_attribute_groups[] = { struct device *nd_pfn_devinit(struct nd_pfn *nd_pfn, struct nd_namespace_common *ndns) { - struct device *dev = &nd_pfn->dev; + struct device *dev; if (!nd_pfn) return NULL; From 327d53d005ca47b10eae940616ed11c569f75a9b Mon Sep 17 00:00:00 2001 From: Andy Lutomirski Date: Tue, 13 Mar 2018 22:03:10 -0700 Subject: [PATCH 658/942] selftests/x86/entry_from_vm86: Exit with 1 if we fail Fix a logic error that caused the test to exit with 0 even if test cases failed. Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stas Sergeev Cc: Thomas Gleixner Cc: bartoldeman@gmail.com Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/b1cc37144038958a469c8f70a5f47a6a5638636a.1521003603.git.luto@kernel.org Signed-off-by: Ingo Molnar --- tools/testing/selftests/x86/entry_from_vm86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c index 361466a2eaef..6e85f0d0498d 100644 --- a/tools/testing/selftests/x86/entry_from_vm86.c +++ b/tools/testing/selftests/x86/entry_from_vm86.c @@ -318,7 +318,7 @@ int main(void) clearhandler(SIGSEGV); /* Make sure nothing explodes if we fork. */ - if (fork() > 0) + if (fork() == 0) return 0; return (nerrs == 0 ? 0 : 1); From 78393fdde2a456cafa414b171c90f26a3df98b20 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski Date: Tue, 13 Mar 2018 22:03:11 -0700 Subject: [PATCH 659/942] selftests/x86/entry_from_vm86: Add test cases for POPF POPF is currently broken -- add tests to catch the error. This results in: [RUN] POPF with VIP set and IF clear from vm86 mode [INFO] Exited vm86 mode due to STI [FAIL] Incorrect return reason (started at eip = 0xd, ended at eip = 0xf) because POPF currently fails to check IF before reporting a pending interrupt. This patch also makes the FAIL message a bit more informative. Reported-by: Bart Oldeman Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stas Sergeev Cc: Thomas Gleixner Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/a16270b5cfe7832d6d00c479d0f871066cbdb52b.1521003603.git.luto@kernel.org Signed-off-by: Ingo Molnar --- tools/testing/selftests/x86/entry_from_vm86.c | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/x86/entry_from_vm86.c b/tools/testing/selftests/x86/entry_from_vm86.c index 6e85f0d0498d..ade443a88421 100644 --- a/tools/testing/selftests/x86/entry_from_vm86.c +++ b/tools/testing/selftests/x86/entry_from_vm86.c @@ -95,6 +95,10 @@ asm ( "int3\n\t" "vmcode_int80:\n\t" "int $0x80\n\t" + "vmcode_popf_hlt:\n\t" + "push %ax\n\t" + "popf\n\t" + "hlt\n\t" "vmcode_umip:\n\t" /* addressing via displacements */ "smsw (2052)\n\t" @@ -124,8 +128,8 @@ asm ( extern unsigned char vmcode[], end_vmcode[]; extern unsigned char vmcode_bound[], vmcode_sysenter[], vmcode_syscall[], - vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_umip[], - vmcode_umip_str[], vmcode_umip_sldt[]; + vmcode_sti[], vmcode_int3[], vmcode_int80[], vmcode_popf_hlt[], + vmcode_umip[], vmcode_umip_str[], vmcode_umip_sldt[]; /* Returns false if the test was skipped. */ static bool do_test(struct vm86plus_struct *v86, unsigned long eip, @@ -175,7 +179,7 @@ static bool do_test(struct vm86plus_struct *v86, unsigned long eip, (VM86_TYPE(ret) == rettype && VM86_ARG(ret) == retarg)) { printf("[OK]\tReturned correctly\n"); } else { - printf("[FAIL]\tIncorrect return reason\n"); + printf("[FAIL]\tIncorrect return reason (started at eip = 0x%lx, ended at eip = 0x%lx)\n", eip, v86->regs.eip); nerrs++; } @@ -264,6 +268,9 @@ int main(void) v86.regs.ds = load_addr / 16; v86.regs.es = load_addr / 16; + /* Use the end of the page as our stack. */ + v86.regs.esp = 4096; + assert((v86.regs.cs & 3) == 0); /* Looks like RPL = 0 */ /* #BR -- should deliver SIG??? */ @@ -295,6 +302,23 @@ int main(void) v86.regs.eflags &= ~X86_EFLAGS_IF; do_test(&v86, vmcode_sti - vmcode, VM86_STI, 0, "STI with VIP set"); + /* POPF with VIP set but IF clear: should not trap */ + v86.regs.eflags = X86_EFLAGS_VIP; + v86.regs.eax = 0; + do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP set and IF clear"); + + /* POPF with VIP set and IF set: should trap */ + v86.regs.eflags = X86_EFLAGS_VIP; + v86.regs.eax = X86_EFLAGS_IF; + do_test(&v86, vmcode_popf_hlt - vmcode, VM86_STI, 0, "POPF with VIP and IF set"); + + /* POPF with VIP clear and IF set: should not trap */ + v86.regs.eflags = 0; + v86.regs.eax = X86_EFLAGS_IF; + do_test(&v86, vmcode_popf_hlt - vmcode, VM86_UNKNOWN, 0, "POPF with VIP clear and IF set"); + + v86.regs.eflags = 0; + /* INT3 -- should cause #BP */ do_test(&v86, vmcode_int3 - vmcode, VM86_TRAP, 3, "INT3"); From b5069782453459f6ec1fdeb495d9901a4545fcb5 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski Date: Tue, 13 Mar 2018 22:03:12 -0700 Subject: [PATCH 660/942] x86/vm86/32: Fix POPF emulation POPF would trap if VIP was set regardless of whether IF was set. Fix it. Suggested-by: Stas Sergeev Reported-by: Bart Oldeman Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: H. Peter Anvin Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: stable@vger.kernel.org Fixes: 5ed92a8ab71f ("x86/vm86: Use the normal pt_regs area for vm86") Link: http://lkml.kernel.org/r/ce95f40556e7b2178b6bc06ee9557827ff94bd28.1521003603.git.luto@kernel.org Signed-off-by: Ingo Molnar --- arch/x86/kernel/vm86_32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c index 5edb27f1a2c4..9d0b5af7db91 100644 --- a/arch/x86/kernel/vm86_32.c +++ b/arch/x86/kernel/vm86_32.c @@ -727,7 +727,8 @@ void handle_vm86_fault(struct kernel_vm86_regs *regs, long error_code) return; check_vip: - if (VEFLAGS & X86_EFLAGS_VIP) { + if ((VEFLAGS & (X86_EFLAGS_VIP | X86_EFLAGS_VIF)) == + (X86_EFLAGS_VIP | X86_EFLAGS_VIF)) { save_v86_state(regs, VM86_STI); return; } From f4353daf4905c0099fd25fa742e2ffd4a4bab26a Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Wed, 14 Mar 2018 11:52:56 +0000 Subject: [PATCH 661/942] can: cc770: Fix stalls on rt-linux, remove redundant IRQ ack This has been reported to cause stalls on rt-linux. Suggested-by: Richard Weinberger Tested-by: Richard Weinberger Signed-off-by: Andri Yngvason Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/cc770/cc770.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/net/can/cc770/cc770.c b/drivers/net/can/cc770/cc770.c index 1e37313054f3..9fed163262e0 100644 --- a/drivers/net/can/cc770/cc770.c +++ b/drivers/net/can/cc770/cc770.c @@ -447,15 +447,6 @@ static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev) stats->tx_bytes += dlc; - - /* - * HM: We had some cases of repeated IRQs so make sure the - * INT is acknowledged I know it's already further up, but - * doing again fixed the issue - */ - cc770_write_reg(priv, msgobj[mo].ctrl0, - MSGVAL_UNC | TXIE_UNC | RXIE_UNC | INTPND_RES); - return NETDEV_TX_OK; } @@ -684,12 +675,6 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o) /* Nothing more to send, switch off interrupts */ cc770_write_reg(priv, msgobj[mo].ctrl0, MSGVAL_RES | TXIE_RES | RXIE_RES | INTPND_RES); - /* - * We had some cases of repeated IRQ so make sure the - * INT is acknowledged - */ - cc770_write_reg(priv, msgobj[mo].ctrl0, - MSGVAL_UNC | TXIE_UNC | RXIE_UNC | INTPND_RES); stats->tx_packets++; can_get_echo_skb(dev, 0); From 746201235b3f876792099079f4c6fea941d76183 Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Wed, 14 Mar 2018 11:52:57 +0000 Subject: [PATCH 662/942] can: cc770: Fix queue stall & dropped RTR reply While waiting for the TX object to send an RTR, an external message with a matching id can overwrite the TX data. In this case we must call the rx routine and then try transmitting the message that was overwritten again. The queue was being stalled because the RX event did not generate an interrupt to wake up the queue again and the TX event did not happen because the TXRQST flag is reset by the chip when new data is received. According to the CC770 datasheet the id of a message object should not be changed while the MSGVAL bit is set. This has been fixed by resetting the MSGVAL bit before modifying the object in the transmit function and setting it after. It is not enough to set & reset CPUUPD. It is important to keep the MSGVAL bit reset while the message object is being modified. Otherwise, during RTR transmission, a frame with matching id could trigger an rx-interrupt, which would cause a race condition between the interrupt routine and the transmit function. Signed-off-by: Andri Yngvason Tested-by: Richard Weinberger Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/cc770/cc770.c | 94 ++++++++++++++++++++++++----------- drivers/net/can/cc770/cc770.h | 2 + 2 files changed, 68 insertions(+), 28 deletions(-) diff --git a/drivers/net/can/cc770/cc770.c b/drivers/net/can/cc770/cc770.c index 9fed163262e0..2743d82d4424 100644 --- a/drivers/net/can/cc770/cc770.c +++ b/drivers/net/can/cc770/cc770.c @@ -390,37 +390,23 @@ static int cc770_get_berr_counter(const struct net_device *dev, return 0; } -static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev) +static void cc770_tx(struct net_device *dev, int mo) { struct cc770_priv *priv = netdev_priv(dev); - struct net_device_stats *stats = &dev->stats; - struct can_frame *cf = (struct can_frame *)skb->data; - unsigned int mo = obj2msgobj(CC770_OBJ_TX); + struct can_frame *cf = (struct can_frame *)priv->tx_skb->data; u8 dlc, rtr; u32 id; int i; - if (can_dropped_invalid_skb(dev, skb)) - return NETDEV_TX_OK; - - if ((cc770_read_reg(priv, - msgobj[mo].ctrl1) & TXRQST_UNC) == TXRQST_SET) { - netdev_err(dev, "TX register is still occupied!\n"); - return NETDEV_TX_BUSY; - } - - netif_stop_queue(dev); - dlc = cf->can_dlc; id = cf->can_id; - if (cf->can_id & CAN_RTR_FLAG) - rtr = 0; - else - rtr = MSGCFG_DIR; + rtr = cf->can_id & CAN_RTR_FLAG ? 0 : MSGCFG_DIR; + + cc770_write_reg(priv, msgobj[mo].ctrl0, + MSGVAL_RES | TXIE_RES | RXIE_RES | INTPND_RES); cc770_write_reg(priv, msgobj[mo].ctrl1, RMTPND_RES | TXRQST_RES | CPUUPD_SET | NEWDAT_RES); - cc770_write_reg(priv, msgobj[mo].ctrl0, - MSGVAL_SET | TXIE_SET | RXIE_RES | INTPND_RES); + if (id & CAN_EFF_FLAG) { id &= CAN_EFF_MASK; cc770_write_reg(priv, msgobj[mo].config, @@ -439,13 +425,30 @@ static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev) for (i = 0; i < dlc; i++) cc770_write_reg(priv, msgobj[mo].data[i], cf->data[i]); - /* Store echo skb before starting the transfer */ - can_put_echo_skb(skb, dev, 0); - cc770_write_reg(priv, msgobj[mo].ctrl1, - RMTPND_RES | TXRQST_SET | CPUUPD_RES | NEWDAT_UNC); + RMTPND_UNC | TXRQST_SET | CPUUPD_RES | NEWDAT_UNC); + cc770_write_reg(priv, msgobj[mo].ctrl0, + MSGVAL_SET | TXIE_SET | RXIE_SET | INTPND_UNC); +} - stats->tx_bytes += dlc; +static netdev_tx_t cc770_start_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct cc770_priv *priv = netdev_priv(dev); + unsigned int mo = obj2msgobj(CC770_OBJ_TX); + + if (can_dropped_invalid_skb(dev, skb)) + return NETDEV_TX_OK; + + netif_stop_queue(dev); + + if ((cc770_read_reg(priv, + msgobj[mo].ctrl1) & TXRQST_UNC) == TXRQST_SET) { + netdev_err(dev, "TX register is still occupied!\n"); + return NETDEV_TX_BUSY; + } + + priv->tx_skb = skb; + cc770_tx(dev, mo); return NETDEV_TX_OK; } @@ -671,13 +674,47 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o) struct cc770_priv *priv = netdev_priv(dev); struct net_device_stats *stats = &dev->stats; unsigned int mo = obj2msgobj(o); + struct can_frame *cf; + u8 ctrl1; + + ctrl1 = cc770_read_reg(priv, msgobj[mo].ctrl1); - /* Nothing more to send, switch off interrupts */ cc770_write_reg(priv, msgobj[mo].ctrl0, MSGVAL_RES | TXIE_RES | RXIE_RES | INTPND_RES); + cc770_write_reg(priv, msgobj[mo].ctrl1, + RMTPND_RES | TXRQST_RES | MSGLST_RES | NEWDAT_RES); - stats->tx_packets++; + if (unlikely(!priv->tx_skb)) { + netdev_err(dev, "missing tx skb in tx interrupt\n"); + return; + } + + if (unlikely(ctrl1 & MSGLST_SET)) { + stats->rx_over_errors++; + stats->rx_errors++; + } + + /* When the CC770 is sending an RTR message and it receives a regular + * message that matches the id of the RTR message, it will overwrite the + * outgoing message in the TX register. When this happens we must + * process the received message and try to transmit the outgoing skb + * again. + */ + if (unlikely(ctrl1 & NEWDAT_SET)) { + cc770_rx(dev, mo, ctrl1); + cc770_tx(dev, mo); + return; + } + + can_put_echo_skb(priv->tx_skb, dev, 0); can_get_echo_skb(dev, 0); + + cf = (struct can_frame *)priv->tx_skb->data; + stats->tx_bytes += cf->can_dlc; + stats->tx_packets++; + + priv->tx_skb = NULL; + netif_wake_queue(dev); } @@ -789,6 +826,7 @@ struct net_device *alloc_cc770dev(int sizeof_priv) priv->can.do_set_bittiming = cc770_set_bittiming; priv->can.do_set_mode = cc770_set_mode; priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES; + priv->tx_skb = NULL; memcpy(priv->obj_flags, cc770_obj_flags, sizeof(cc770_obj_flags)); diff --git a/drivers/net/can/cc770/cc770.h b/drivers/net/can/cc770/cc770.h index a1739db98d91..95752e1d1283 100644 --- a/drivers/net/can/cc770/cc770.h +++ b/drivers/net/can/cc770/cc770.h @@ -193,6 +193,8 @@ struct cc770_priv { u8 cpu_interface; /* CPU interface register */ u8 clkout; /* Clock out register */ u8 bus_config; /* Bus conffiguration register */ + + struct sk_buff *tx_skb; }; struct net_device *alloc_cc770dev(int sizeof_priv); From a14bff131108faf50cc0cf864589fd71ee216c96 Mon Sep 17 00:00:00 2001 From: Andy Whitcroft Date: Wed, 14 Mar 2018 11:24:27 +0000 Subject: [PATCH 663/942] x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels In the following commit: 9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool") ... we added annotations for CALL_NOSPEC/JMP_NOSPEC on 64-bit x86 kernels, but we did not annotate the 32-bit path. Annotate it similarly. Signed-off-by: Andy Whitcroft Acked-by: Peter Zijlstra (Intel) Cc: Andy Lutomirski Cc: Arjan van de Ven Cc: Borislav Petkov Cc: Dan Williams Cc: Dave Hansen Cc: David Woodhouse Cc: David Woodhouse Cc: Greg Kroah-Hartman Cc: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/20180314112427.22351-1-apw@canonical.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/nospec-branch.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h index b7063cfa19f9..b3996d60f981 100644 --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -183,7 +183,10 @@ * otherwise we'll run out of registers. We don't care about CET * here, anyway. */ -# define CALL_NOSPEC ALTERNATIVE("call *%[thunk_target]\n", \ +# define CALL_NOSPEC \ + ALTERNATIVE( \ + ANNOTATE_RETPOLINE_SAFE \ + "call *%[thunk_target]\n", \ " jmp 904f;\n" \ " .align 16\n" \ "901: call 903f;\n" \ From ca6bfcb2f6d9deab3924bf901e73622a94900473 Mon Sep 17 00:00:00 2001 From: Ju Hyung Park Date: Sun, 11 Mar 2018 02:28:35 +0900 Subject: [PATCH 664/942] libata: Enable queued TRIM for Samsung SSD 860 Samsung explicitly states that queued TRIM is supported for Linux with 860 PRO and 860 EVO. Make the previous blacklist to cover only 840 and 850 series. Signed-off-by: Park Ju Hyung Reviewed-by: Martin K. Petersen Signed-off-by: Tejun Heo Cc: stable@vger.kernel.org --- drivers/ata/libata-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index cb789f8849ae..aec609f80c4e 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4549,7 +4549,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { ATA_HORKAGE_ZERO_AFTER_TRIM, }, { "Crucial_CT*MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, - { "Samsung SSD 8*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + { "Samsung SSD 840*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, + { "Samsung SSD 850*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, { "FCCT*M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, From af1d830bf32b27b387b97c8b29dc09e306a9ff7f Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Wed, 14 Mar 2018 10:24:20 -0500 Subject: [PATCH 665/942] jump_label: Fix sparc64 warning The kbuild test robot reported the following warning on sparc64: kernel/jump_label.c: In function '__jump_label_update': kernel/jump_label.c:376:51: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] WARN_ONCE(1, "can't patch jump_label at %pS", (void *)entry->code); On sparc64, the jump_label entry->code field is of type u32, but pointers are 64-bit. Silence the warning by casting entry->code to an unsigned long before casting it to a pointer. This is also what the sparc jump label code does. Fixes: dc1dd184c2f0 ("jump_label: Warn on failed jump_label patching attempt") Reported-by: kbuild test robot Signed-off-by: Josh Poimboeuf Signed-off-by: Thomas Gleixner Cc: Peter Zijlstra Cc: Jason Baron Cc: Borislav Petkov Cc: "David S . Miller" Link: https://lkml.kernel.org/r/c966fed42be6611254a62d46579ec7416548d572.1521041026.git.jpoimboe@redhat.com --- kernel/jump_label.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/jump_label.c b/kernel/jump_label.c index 52a0a7af8640..e7214093dcd1 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -373,7 +373,8 @@ static void __jump_label_update(struct static_key *key, if (kernel_text_address(entry->code)) arch_jump_label_transform(entry, jump_label_type(entry)); else - WARN_ONCE(1, "can't patch jump_label at %pS", (void *)entry->code); + WARN_ONCE(1, "can't patch jump_label at %pS", + (void *)(unsigned long)entry->code); } } } From 90e0fb05e5c1b1cf6a59c4f888f500e2b1feffc4 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Wed, 14 Mar 2018 21:39:00 +0900 Subject: [PATCH 666/942] ASoC: uniphier: evea: add switch for changing source of line-in This patch adds mixer switch for changing audio source of line-in. We can choose one of LIN1, 2, 3, default is LIN1. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/evea.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/uniphier/evea.c b/sound/soc/uniphier/evea.c index 439f14f91b23..73fd6730095c 100644 --- a/sound/soc/uniphier/evea.c +++ b/sound/soc/uniphier/evea.c @@ -18,6 +18,8 @@ #define AADCPOW(n) (0x0078 + 0x04 * (n)) #define AADCPOW_AADC_POWD BIT(0) +#define ALINSW1 0x0088 +#define ALINSW1_SEL1_SHIFT 3 #define AHPOUTPOW 0x0098 #define AHPOUTPOW_HP_ON BIT(4) #define ALINEPOW 0x009c @@ -278,7 +280,16 @@ static int evea_set_switch_hp(struct snd_kcontrol *kcontrol, return evea_update_switch_hp(evea); } +static const char * const linsw1_sel1_text[] = { + "LIN1", "LIN2", "LIN3" +}; + +static SOC_ENUM_SINGLE_DECL(linsw1_sel1_enum, + ALINSW1, ALINSW1_SEL1_SHIFT, + linsw1_sel1_text); + static const struct snd_kcontrol_new evea_controls[] = { + SOC_ENUM("Line Capture Source", linsw1_sel1_enum), SOC_SINGLE_BOOL_EXT("Line Capture Switch", 0, evea_get_switch_lin, evea_set_switch_lin), SOC_SINGLE_BOOL_EXT("Line Playback Switch", 0, From 1d37ce929c71f430389db3042a8b23536cede1e5 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 14 Mar 2018 14:28:25 +0000 Subject: [PATCH 667/942] ASoC: da7219: make structure da7219_dai_clks_ops static structure da7219_dai_clks_ops is local to the source and does not need to be in global scope, so make it static. Cleans up sparse warning: sound/soc/codecs/da7219.c:1777:22: warning: symbol 'da7219_dai_clks_ops' was not declared. Should it be static? Signed-off-by: Colin Ian King Signed-off-by: Mark Brown --- sound/soc/codecs/da7219.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c index 08f55d7a11ba..980a6a8bf56d 100644 --- a/sound/soc/codecs/da7219.c +++ b/sound/soc/codecs/da7219.c @@ -1774,7 +1774,7 @@ static int da7219_dai_clks_is_prepared(struct clk_hw *hw) return !!(clk_reg & DA7219_DAI_CLK_EN_MASK); } -const struct clk_ops da7219_dai_clks_ops = { +static const struct clk_ops da7219_dai_clks_ops = { .prepare = da7219_dai_clks_prepare, .unprepare = da7219_dai_clks_unprepare, .is_prepared = da7219_dai_clks_is_prepared, From 6ca1118551ca5bb267e75faa6b944679ca195423 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Wed, 14 Mar 2018 17:26:06 +0100 Subject: [PATCH 668/942] ASoC: remove blackfin drivers The blackfin architecture is getting removed, so the ASoC drivers are all obsolete as well. Signed-off-by: Arnd Bergmann Signed-off-by: Mark Brown --- MAINTAINERS | 7 - sound/soc/Kconfig | 1 - sound/soc/Makefile | 1 - sound/soc/blackfin/Kconfig | 205 ----- sound/soc/blackfin/Makefile | 40 - sound/soc/blackfin/bf5xx-ac97-pcm.c | 480 ---------- sound/soc/blackfin/bf5xx-ac97.c | 388 -------- sound/soc/blackfin/bf5xx-ac97.h | 57 -- sound/soc/blackfin/bf5xx-ad1836.c | 109 --- sound/soc/blackfin/bf5xx-ad193x.c | 131 --- sound/soc/blackfin/bf5xx-ad1980.c | 109 --- sound/soc/blackfin/bf5xx-ad73311.c | 212 ----- sound/soc/blackfin/bf5xx-i2s-pcm.c | 373 -------- sound/soc/blackfin/bf5xx-i2s-pcm.h | 17 - sound/soc/blackfin/bf5xx-i2s.c | 391 -------- sound/soc/blackfin/bf5xx-sport.c | 1102 ----------------------- sound/soc/blackfin/bf5xx-sport.h | 174 ---- sound/soc/blackfin/bf5xx-ssm2602.c | 126 --- sound/soc/blackfin/bf6xx-i2s.c | 239 ----- sound/soc/blackfin/bf6xx-sport.c | 425 --------- sound/soc/blackfin/bf6xx-sport.h | 82 -- sound/soc/blackfin/bfin-eval-adau1373.c | 173 ---- sound/soc/blackfin/bfin-eval-adau1701.c | 113 --- sound/soc/blackfin/bfin-eval-adau1x61.c | 142 --- sound/soc/blackfin/bfin-eval-adau1x81.c | 129 --- sound/soc/blackfin/bfin-eval-adav80x.c | 145 --- 26 files changed, 5371 deletions(-) delete mode 100644 sound/soc/blackfin/Kconfig delete mode 100644 sound/soc/blackfin/Makefile delete mode 100644 sound/soc/blackfin/bf5xx-ac97-pcm.c delete mode 100644 sound/soc/blackfin/bf5xx-ac97.c delete mode 100644 sound/soc/blackfin/bf5xx-ac97.h delete mode 100644 sound/soc/blackfin/bf5xx-ad1836.c delete mode 100644 sound/soc/blackfin/bf5xx-ad193x.c delete mode 100644 sound/soc/blackfin/bf5xx-ad1980.c delete mode 100644 sound/soc/blackfin/bf5xx-ad73311.c delete mode 100644 sound/soc/blackfin/bf5xx-i2s-pcm.c delete mode 100644 sound/soc/blackfin/bf5xx-i2s-pcm.h delete mode 100644 sound/soc/blackfin/bf5xx-i2s.c delete mode 100644 sound/soc/blackfin/bf5xx-sport.c delete mode 100644 sound/soc/blackfin/bf5xx-sport.h delete mode 100644 sound/soc/blackfin/bf5xx-ssm2602.c delete mode 100644 sound/soc/blackfin/bf6xx-i2s.c delete mode 100644 sound/soc/blackfin/bf6xx-sport.c delete mode 100644 sound/soc/blackfin/bf6xx-sport.h delete mode 100644 sound/soc/blackfin/bfin-eval-adau1373.c delete mode 100644 sound/soc/blackfin/bfin-eval-adau1701.c delete mode 100644 sound/soc/blackfin/bfin-eval-adau1x61.c delete mode 100644 sound/soc/blackfin/bfin-eval-adau1x81.c delete mode 100644 sound/soc/blackfin/bfin-eval-adav80x.c diff --git a/MAINTAINERS b/MAINTAINERS index 3bdc260e36b7..dd2c3435b308 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -841,13 +841,6 @@ F: sound/soc/codecs/ad7* F: sound/soc/codecs/ssm* F: sound/soc/codecs/sigmadsp.* -ANALOG DEVICES INC ASOC DRIVERS -L: adi-buildroot-devel@lists.sourceforge.net (moderated for non-subscribers) -L: alsa-devel@alsa-project.org (moderated for non-subscribers) -W: http://blackfin.uclinux.org/ -S: Supported -F: sound/soc/blackfin/* - ANALOG DEVICES INC DMA DRIVERS M: Lars-Peter Clausen W: http://ez.analog.com/community/linux-device-drivers diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 84c3582f3982..41af6b9cc350 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig @@ -45,7 +45,6 @@ source "sound/soc/amd/Kconfig" source "sound/soc/atmel/Kconfig" source "sound/soc/au1x/Kconfig" source "sound/soc/bcm/Kconfig" -source "sound/soc/blackfin/Kconfig" source "sound/soc/cirrus/Kconfig" source "sound/soc/davinci/Kconfig" source "sound/soc/dwc/Kconfig" diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 74cd1858d38b..8d92492183d2 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile @@ -29,7 +29,6 @@ obj-$(CONFIG_SND_SOC) += amd/ obj-$(CONFIG_SND_SOC) += atmel/ obj-$(CONFIG_SND_SOC) += au1x/ obj-$(CONFIG_SND_SOC) += bcm/ -obj-$(CONFIG_SND_SOC) += blackfin/ obj-$(CONFIG_SND_SOC) += cirrus/ obj-$(CONFIG_SND_SOC) += davinci/ obj-$(CONFIG_SND_SOC) += dwc/ diff --git a/sound/soc/blackfin/Kconfig b/sound/soc/blackfin/Kconfig deleted file mode 100644 index 6410aa2cc2cf..000000000000 --- a/sound/soc/blackfin/Kconfig +++ /dev/null @@ -1,205 +0,0 @@ -config SND_BF5XX_I2S - tristate "SoC I2S Audio for the ADI Blackfin chip" - depends on BLACKFIN - select SND_BF5XX_SOC_SPORT if !BF60x - select SND_BF6XX_SOC_SPORT if BF60x - help - Say Y or M if you want to add support for codecs attached to - the Blackfin SPORT (synchronous serial ports) interface in I2S - mode (supports single stereo In/Out). - You will also need to select the audio interfaces to support below. - -config SND_BF5XX_SOC_SSM2602 - tristate "SoC SSM2602 Audio Codec Add-On Card support" - depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI - select SND_BF5XX_SOC_I2S if !BF60x - select SND_BF6XX_SOC_I2S if BF60x - select SND_SOC_SSM2602_SPI if SPI_MASTER - select SND_SOC_SSM2602_I2C if I2C - help - Say Y if you want to add support for the Analog Devices - SSM2602 Audio Codec Add-On Card. - -config SND_SOC_BFIN_EVAL_ADAU1701 - tristate "Support for the EVAL-ADAU1701MINIZ board on Blackfin eval boards" - depends on SND_BF5XX_I2S && I2C - select SND_BF5XX_SOC_I2S - select SND_SOC_ADAU1701 - help - Say Y if you want to add support for the Analog Devices EVAL-ADAU1701MINIZ - board connected to one of the Blackfin evaluation boards like the - BF5XX-STAMP or BF5XX-EZKIT. - -config SND_SOC_BFIN_EVAL_ADAU1373 - tristate "Support for the EVAL-ADAU1373 board on Blackfin eval boards" - depends on SND_BF5XX_I2S && I2C - select SND_BF5XX_SOC_I2S - select SND_SOC_ADAU1373 - help - Say Y if you want to add support for the Analog Devices EVAL-ADAU1373 - board connected to one of the Blackfin evaluation boards like the - BF5XX-STAMP or BF5XX-EZKIT. - - Note: This driver assumes that first ADAU1373 DAI is connected to the - first SPORT port on the BF5XX board. - -config SND_SOC_BFIN_EVAL_ADAU1X61 - tristate "Support for the EVAL-ADAU1X61 board on Blackfin eval boards" - depends on SND_BF5XX_I2S && I2C - select SND_BF5XX_SOC_I2S - select SND_SOC_ADAU1761_I2C - help - Say Y if you want to add support for the Analog Devices EVAL-ADAU1X61 - board connected to one of the Blackfin evaluation boards like the - BF5XX-STAMP or BF5XX-EZKIT. - - Note: This driver assumes that the ADAU1X61 is connected to the - first SPORT port on the BF5XX board. - -config SND_SOC_BFIN_EVAL_ADAU1X81 - tristate "Support for the EVAL-ADAU1X81 boards on Blackfin eval boards" - depends on SND_BF5XX_I2S && I2C - select SND_BF5XX_SOC_I2S - select SND_SOC_ADAU1781_I2C - help - Say Y if you want to add support for the Analog Devices EVAL-ADAU1X81 - board connected to one of the Blackfin evaluation boards like the - BF5XX-STAMP or BF5XX-EZKIT. - - Note: This driver assumes that the ADAU1X81 is connected to the - first SPORT port on the BF5XX board. - -config SND_SOC_BFIN_EVAL_ADAV80X - tristate "Support for the EVAL-ADAV80X boards on Blackfin eval boards" - depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI - select SND_BF5XX_SOC_I2S - select SND_SOC_ADAV801 if SPI_MASTER - select SND_SOC_ADAV803 if I2C - help - Say Y if you want to add support for the Analog Devices EVAL-ADAV801 or - EVAL-ADAV803 board connected to one of the Blackfin evaluation boards - like the BF5XX-STAMP or BF5XX-EZKIT. - - Note: This driver assumes that the ADAV80X digital record and playback - interfaces are connected to the first SPORT port on the BF5XX board. - -config SND_BF5XX_SOC_AD1836 - tristate "SoC AD1836 Audio support for BF5xx" - depends on SND_BF5XX_I2S && SPI_MASTER - select SND_BF5XX_SOC_I2S - select SND_SOC_AD1836 - help - Say Y if you want to add support for SoC audio on BF5xx STAMP/EZKIT. - -config SND_BF5XX_SOC_AD193X - tristate "SoC AD193X Audio support for Blackfin" - depends on SND_BF5XX_I2S && SND_SOC_I2C_AND_SPI - select SND_BF5XX_SOC_I2S - select SND_SOC_AD193X_I2C if I2C - select SND_SOC_AD193X_SPI if SPI_MASTER - help - Say Y if you want to add support for AD193X codec on Blackfin. - This driver supports AD1936, AD1937, AD1938 and AD1939. - -config SND_BF5XX_SOC_AD73311 - tristate "SoC AD73311 Audio support for Blackfin" - depends on SND_BF5XX_I2S - select SND_BF5XX_SOC_I2S - select SND_SOC_AD73311 - help - Say Y if you want to add support for AD73311 codec on Blackfin. - -config SND_BFIN_AD73311_SE - int "PF pin for AD73311L Chip Select" - depends on SND_BF5XX_SOC_AD73311 - default 4 - help - Enter the GPIO used to control AD73311's SE pin. Acceptable - values are 0 to 7 - -config SND_BF5XX_AC97 - tristate "SoC AC97 Audio for the ADI BF5xx chip" - depends on BLACKFIN - select AC97_BUS - select SND_SOC_AC97_BUS - select SND_BF5XX_SOC_SPORT - select SND_BF5XX_SOC_AC97 - help - Say Y or M if you want to add support for codecs attached to - the Blackfin SPORT (synchronous serial ports) interface in slot 16 - mode (pseudo AC97 interface). - You will also need to select the audio interfaces to support below. - - Note: - AC97 codecs which do not implement the slot-16 mode will not function - properly with this driver. This driver is known to work with the - Analog Devices line of AC97 codecs. - -config SND_BF5XX_MMAP_SUPPORT - bool "Enable MMAP Support" - depends on SND_BF5XX_AC97 - default y - help - Say y if you want AC97 driver to support mmap mode. - We introduce an intermediate buffer to simulate mmap. - -config SND_BF5XX_MULTICHAN_SUPPORT - bool "Enable Multichannel Support" - depends on SND_BF5XX_AC97 - default n - help - Say y if you want AC97 driver to support up to 5.1 channel audio. - this mode will consume much more memory for DMA. - -config SND_BF5XX_HAVE_COLD_RESET - bool "BOARD has COLD Reset GPIO" - depends on SND_BF5XX_AC97 - default y if BFIN548_EZKIT - default n if !BFIN548_EZKIT - -config SND_BF5XX_RESET_GPIO_NUM - int "Set a GPIO for cold reset" - depends on SND_BF5XX_HAVE_COLD_RESET - range 0 159 - default 19 if BFIN548_EZKIT - default 5 if BFIN537_STAMP - default 0 - help - Set the correct GPIO for RESET the sound chip. - -config SND_BF5XX_SOC_AD1980 - tristate "SoC AD1980/1 Audio support for BF5xx (Obsolete)" - depends on SND_BF5XX_AC97 - select SND_BF5XX_SOC_AC97 - select SND_SOC_AD1980 - help - Say Y if you want to add support for SoC audio on BF5xx STAMP/EZKIT. - - Warning: - Because Analog Devices Inc. discontinued the ad1980 sound chip since - Sep. 2009, this ad1980 driver is not maintained, tested and supported - by ADI now. - -config SND_BF5XX_SOC_SPORT - tristate - -config SND_BF6XX_SOC_SPORT - tristate - -config SND_BF5XX_SOC_I2S - tristate - -config SND_BF6XX_SOC_I2S - tristate - -config SND_BF5XX_SOC_AC97 - tristate - -config SND_BF5XX_SPORT_NUM - int "Set a SPORT for Sound chip" - depends on (SND_BF5XX_SOC_SPORT || SND_BF6XX_SOC_SPORT) - range 0 3 if BF54x - range 0 1 if !BF54x - default 0 - help - Set the correct SPORT for sound chip. diff --git a/sound/soc/blackfin/Makefile b/sound/soc/blackfin/Makefile deleted file mode 100644 index ebeb6a9cedd2..000000000000 --- a/sound/soc/blackfin/Makefile +++ /dev/null @@ -1,40 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# Blackfin Platform Support -snd-bf5xx-ac97-objs := bf5xx-ac97-pcm.o -snd-bf5xx-i2s-objs := bf5xx-i2s-pcm.o -snd-soc-bf5xx-sport-objs := bf5xx-sport.o -snd-soc-bf6xx-sport-objs := bf6xx-sport.o -snd-soc-bf5xx-ac97-objs := bf5xx-ac97.o -snd-soc-bf5xx-i2s-objs := bf5xx-i2s.o -snd-soc-bf6xx-i2s-objs := bf6xx-i2s.o - -obj-$(CONFIG_SND_BF5XX_AC97) += snd-bf5xx-ac97.o -obj-$(CONFIG_SND_BF5XX_I2S) += snd-bf5xx-i2s.o -obj-$(CONFIG_SND_BF5XX_SOC_SPORT) += snd-soc-bf5xx-sport.o -obj-$(CONFIG_SND_BF6XX_SOC_SPORT) += snd-soc-bf6xx-sport.o -obj-$(CONFIG_SND_BF5XX_SOC_AC97) += snd-soc-bf5xx-ac97.o -obj-$(CONFIG_SND_BF5XX_SOC_I2S) += snd-soc-bf5xx-i2s.o -obj-$(CONFIG_SND_BF6XX_SOC_I2S) += snd-soc-bf6xx-i2s.o - -# Blackfin Machine Support -snd-ad1836-objs := bf5xx-ad1836.o -snd-ad1980-objs := bf5xx-ad1980.o -snd-ssm2602-objs := bf5xx-ssm2602.o -snd-ad73311-objs := bf5xx-ad73311.o -snd-ad193x-objs := bf5xx-ad193x.o -snd-soc-bfin-eval-adau1373-objs := bfin-eval-adau1373.o -snd-soc-bfin-eval-adau1x61-objs := bfin-eval-adau1x61.o -snd-soc-bfin-eval-adau1x81-objs := bfin-eval-adau1x81.o -snd-soc-bfin-eval-adau1701-objs := bfin-eval-adau1701.o -snd-soc-bfin-eval-adav80x-objs := bfin-eval-adav80x.o - -obj-$(CONFIG_SND_BF5XX_SOC_AD1836) += snd-ad1836.o -obj-$(CONFIG_SND_BF5XX_SOC_AD1980) += snd-ad1980.o -obj-$(CONFIG_SND_BF5XX_SOC_SSM2602) += snd-ssm2602.o -obj-$(CONFIG_SND_BF5XX_SOC_AD73311) += snd-ad73311.o -obj-$(CONFIG_SND_BF5XX_SOC_AD193X) += snd-ad193x.o -obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1373) += snd-soc-bfin-eval-adau1373.o -obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X61) += snd-soc-bfin-eval-adau1x61.o -obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1X81) += snd-soc-bfin-eval-adau1x81.o -obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAU1701) += snd-soc-bfin-eval-adau1701.o -obj-$(CONFIG_SND_SOC_BFIN_EVAL_ADAV80X) += snd-soc-bfin-eval-adav80x.o diff --git a/sound/soc/blackfin/bf5xx-ac97-pcm.c b/sound/soc/blackfin/bf5xx-ac97-pcm.c deleted file mode 100644 index 08bceb519c29..000000000000 --- a/sound/soc/blackfin/bf5xx-ac97-pcm.c +++ /dev/null @@ -1,480 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-ac97-pcm.c - * Author: Cliff Cai - * - * Created: Tue June 06 2008 - * Description: DMA Driver for AC97 sound chip - * - * Modified: - * Copyright 2008 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "bf5xx-ac97.h" -#include "bf5xx-sport.h" - -static unsigned int ac97_chan_mask[] = { - SP_FL, /* Mono */ - SP_STEREO, /* Stereo */ - SP_2DOT1, /* 2.1*/ - SP_QUAD,/*Quadraquic*/ - SP_FL | SP_FR | SP_FC | SP_SL | SP_SR,/*5 channels */ - SP_5DOT1, /* 5.1 */ -}; - -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) -static void bf5xx_mmap_copy(struct snd_pcm_substream *substream, - snd_pcm_uframes_t count) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - unsigned int chan_mask = ac97_chan_mask[runtime->channels - 1]; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - bf5xx_pcm_to_ac97((struct ac97_frame *)sport->tx_dma_buf + - sport->tx_pos, (__u16 *)runtime->dma_area + sport->tx_pos * - runtime->channels, count, chan_mask); - sport->tx_pos += runtime->period_size; - if (sport->tx_pos >= runtime->buffer_size) - sport->tx_pos %= runtime->buffer_size; - sport->tx_delay_pos = sport->tx_pos; - } else { - bf5xx_ac97_to_pcm((struct ac97_frame *)sport->rx_dma_buf + - sport->rx_pos, (__u16 *)runtime->dma_area + sport->rx_pos * - runtime->channels, count); - sport->rx_pos += runtime->period_size; - if (sport->rx_pos >= runtime->buffer_size) - sport->rx_pos %= runtime->buffer_size; - } -} -#endif - -static void bf5xx_dma_irq(void *data) -{ - struct snd_pcm_substream *pcm = data; -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - struct snd_pcm_runtime *runtime = pcm->runtime; - struct sport_device *sport = runtime->private_data; - bf5xx_mmap_copy(pcm, runtime->period_size); - if (pcm->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (sport->once == 0) { - snd_pcm_period_elapsed(pcm); - bf5xx_mmap_copy(pcm, runtime->period_size); - sport->once = 1; - } - } -#endif - snd_pcm_period_elapsed(pcm); -} - -/* The memory size for pure pcm data is 128*1024 = 0x20000 bytes. - * The total rx/tx buffer is for ac97 frame to hold all pcm data - * is 0x20000 * sizeof(struct ac97_frame) / 4. - */ -static const struct snd_pcm_hardware bf5xx_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED | -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - SNDRV_PCM_INFO_MMAP | - SNDRV_PCM_INFO_MMAP_VALID | -#endif - SNDRV_PCM_INFO_BLOCK_TRANSFER, - - .period_bytes_min = 32, - .period_bytes_max = 0x10000, - .periods_min = 1, - .periods_max = PAGE_SIZE/32, - .buffer_bytes_max = 0x20000, /* 128 kbytes */ - .fifo_size = 16, -}; - -static int bf5xx_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - size_t size = bf5xx_pcm_hardware.buffer_bytes_max - * sizeof(struct ac97_frame) / 4; - - snd_pcm_lib_malloc_pages(substream, size); - - return 0; -} - -static int bf5xx_pcm_hw_free(struct snd_pcm_substream *substream) -{ -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - sport->once = 0; - if (runtime->dma_area) - memset(runtime->dma_area, 0, runtime->buffer_size); - memset(sport->tx_dma_buf, 0, runtime->buffer_size * - sizeof(struct ac97_frame)); - } else - memset(sport->rx_dma_buf, 0, runtime->buffer_size * - sizeof(struct ac97_frame)); -#endif - snd_pcm_lib_free_pages(substream); - return 0; -} - -static int bf5xx_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - - /* An intermediate buffer is introduced for implementing mmap for - * SPORT working in TMD mode(include AC97). - */ -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - sport_set_tx_callback(sport, bf5xx_dma_irq, substream); - sport_config_tx_dma(sport, sport->tx_dma_buf, runtime->periods, - runtime->period_size * sizeof(struct ac97_frame)); - } else { - sport_set_rx_callback(sport, bf5xx_dma_irq, substream); - sport_config_rx_dma(sport, sport->rx_dma_buf, runtime->periods, - runtime->period_size * sizeof(struct ac97_frame)); - } -#else - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - sport_set_tx_callback(sport, bf5xx_dma_irq, substream); - sport_config_tx_dma(sport, runtime->dma_area, runtime->periods, - runtime->period_size * sizeof(struct ac97_frame)); - } else { - sport_set_rx_callback(sport, bf5xx_dma_irq, substream); - sport_config_rx_dma(sport, runtime->dma_area, runtime->periods, - runtime->period_size * sizeof(struct ac97_frame)); - } -#endif - return 0; -} - -static int bf5xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - int ret = 0; - - pr_debug("%s enter\n", __func__); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - bf5xx_mmap_copy(substream, runtime->period_size); - sport->tx_delay_pos = 0; -#endif - sport_tx_start(sport); - } else - sport_rx_start(sport); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - sport->tx_pos = 0; -#endif - sport_tx_stop(sport); - } else { -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - sport->rx_pos = 0; -#endif - sport_rx_stop(sport); - } - break; - default: - ret = -EINVAL; - } - return ret; -} - -static snd_pcm_uframes_t bf5xx_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - unsigned int curr; - -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - curr = sport->tx_delay_pos; - else - curr = sport->rx_pos; -#else - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - curr = sport_curr_offset_tx(sport) / sizeof(struct ac97_frame); - else - curr = sport_curr_offset_rx(sport) / sizeof(struct ac97_frame); - -#endif - return curr; -} - -static int bf5xx_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai); - struct snd_pcm_runtime *runtime = substream->runtime; - int ret; - - pr_debug("%s enter\n", __func__); - snd_soc_set_runtime_hwparams(substream, &bf5xx_pcm_hardware); - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - goto out; - - if (sport_handle != NULL) - runtime->private_data = sport_handle; - else { - pr_err("sport_handle is NULL\n"); - return -1; - } - return 0; - - out: - return ret; -} - -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) -static int bf5xx_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - size_t size = vma->vm_end - vma->vm_start; - vma->vm_start = (unsigned long)runtime->dma_area; - vma->vm_end = vma->vm_start + size; - vma->vm_flags |= VM_SHARED; - return 0 ; -} -#else -static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void *buf, unsigned long count) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - unsigned int chan_mask = ac97_chan_mask[runtime->channels - 1]; - struct ac97_frame *dst; - - pr_debug("%s copy pos:0x%lx count:0x%lx\n", - substream->stream ? "Capture" : "Playback", pos, count); - dst = (struct ac97_frame *)runtime->dma_area + - bytes_to_frames(runtime, pos); - count = bytes_to_frames(runtime, count); - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - bf5xx_pcm_to_ac97(dst, buf, count, chan_mask); - else - bf5xx_ac97_to_pcm(dst, buf, count); - return 0; -} - -static int bf5xx_pcm_copy_user(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void __user *buf, unsigned long count) -{ - return bf5xx_pcm_copy(substream, channel, pos, (void *)buf, count); -} -#endif - -static const struct snd_pcm_ops bf5xx_pcm_ac97_ops = { - .open = bf5xx_pcm_open, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = bf5xx_pcm_hw_params, - .hw_free = bf5xx_pcm_hw_free, - .prepare = bf5xx_pcm_prepare, - .trigger = bf5xx_pcm_trigger, - .pointer = bf5xx_pcm_pointer, -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - .mmap = bf5xx_pcm_mmap, -#else - .copy_user = bf5xx_pcm_copy_user, - .copy_kernel = bf5xx_pcm_copy, -#endif -}; - -static int bf5xx_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, int stream) -{ - struct snd_soc_pcm_runtime *rtd = pcm->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai); - struct snd_pcm_substream *substream = pcm->streams[stream].substream; - struct snd_dma_buffer *buf = &substream->dma_buffer; - size_t size = bf5xx_pcm_hardware.buffer_bytes_max - * sizeof(struct ac97_frame) / 4; - - buf->dev.type = SNDRV_DMA_TYPE_DEV; - buf->dev.dev = pcm->card->dev; - buf->private_data = NULL; - buf->area = dma_alloc_coherent(pcm->card->dev, size, - &buf->addr, GFP_KERNEL); - if (!buf->area) { - pr_err("Failed to allocate dma memory\n"); - pr_err("Please increase uncached DMA memory region\n"); - return -ENOMEM; - } - buf->bytes = size; - - pr_debug("%s, area:%p, size:0x%08lx\n", __func__, - buf->area, buf->bytes); - - if (stream == SNDRV_PCM_STREAM_PLAYBACK) - sport_handle->tx_buf = buf->area; - else - sport_handle->rx_buf = buf->area; - -/* - * Need to allocate local buffer when enable - * MMAP for SPORT working in TMD mode (include AC97). - */ -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (!sport_handle->tx_dma_buf) { - sport_handle->tx_dma_buf = dma_alloc_coherent(NULL, \ - size, &sport_handle->tx_dma_phy, GFP_KERNEL); - if (!sport_handle->tx_dma_buf) { - pr_err("Failed to allocate memory for tx dma buf - Please increase uncached DMA memory region\n"); - return -ENOMEM; - } else - memset(sport_handle->tx_dma_buf, 0, size); - } else - memset(sport_handle->tx_dma_buf, 0, size); - } else { - if (!sport_handle->rx_dma_buf) { - sport_handle->rx_dma_buf = dma_alloc_coherent(NULL, \ - size, &sport_handle->rx_dma_phy, GFP_KERNEL); - if (!sport_handle->rx_dma_buf) { - pr_err("Failed to allocate memory for rx dma buf - Please increase uncached DMA memory region\n"); - return -ENOMEM; - } else - memset(sport_handle->rx_dma_buf, 0, size); - } else - memset(sport_handle->rx_dma_buf, 0, size); - } -#endif - return 0; -} - -static void bf5xx_pcm_free_dma_buffers(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - struct snd_dma_buffer *buf; - int stream; -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - struct snd_soc_pcm_runtime *rtd = pcm->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai); - size_t size = bf5xx_pcm_hardware.buffer_bytes_max * - sizeof(struct ac97_frame) / 4; -#endif - for (stream = 0; stream < 2; stream++) { - substream = pcm->streams[stream].substream; - if (!substream) - continue; - - buf = &substream->dma_buffer; - if (!buf->area) - continue; - dma_free_coherent(NULL, buf->bytes, buf->area, 0); - buf->area = NULL; -#if defined(CONFIG_SND_BF5XX_MMAP_SUPPORT) - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (sport_handle->tx_dma_buf) - dma_free_coherent(NULL, size, \ - sport_handle->tx_dma_buf, 0); - sport_handle->tx_dma_buf = NULL; - } else { - - if (sport_handle->rx_dma_buf) - dma_free_coherent(NULL, size, \ - sport_handle->rx_dma_buf, 0); - sport_handle->rx_dma_buf = NULL; - } -#endif - } -} - -static int bf5xx_pcm_ac97_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - struct snd_pcm *pcm = rtd->pcm; - int ret; - - pr_debug("%s enter\n", __func__); - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; - - if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { - ret = bf5xx_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_PLAYBACK); - if (ret) - goto out; - } - - if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { - ret = bf5xx_pcm_preallocate_dma_buffer(pcm, - SNDRV_PCM_STREAM_CAPTURE); - if (ret) - goto out; - } - out: - return ret; -} - -static struct snd_soc_component_driver bf5xx_ac97_soc_component = { - .ops = &bf5xx_pcm_ac97_ops, - .pcm_new = bf5xx_pcm_ac97_new, - .pcm_free = bf5xx_pcm_free_dma_buffers, -}; - -static int bf5xx_soc_platform_probe(struct platform_device *pdev) -{ - return devm_snd_soc_register_component(&pdev->dev, - &bf5xx_ac97_soc_component, NULL, 0); -} - -static struct platform_driver bf5xx_pcm_driver = { - .driver = { - .name = "bfin-ac97-pcm-audio", - }, - - .probe = bf5xx_soc_platform_probe, -}; - -module_platform_driver(bf5xx_pcm_driver); - -MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("ADI Blackfin AC97 PCM DMA module"); -MODULE_LICENSE("GPL"); diff --git a/sound/soc/blackfin/bf5xx-ac97.c b/sound/soc/blackfin/bf5xx-ac97.c deleted file mode 100644 index a040cfe29fc0..000000000000 --- a/sound/soc/blackfin/bf5xx-ac97.c +++ /dev/null @@ -1,388 +0,0 @@ -/* - * bf5xx-ac97.c -- AC97 support for the ADI blackfin chip. - * - * Author: Roy Huang - * Created: 11th. June 2007 - * Copyright: Analog Device Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "bf5xx-sport.h" -#include "bf5xx-ac97.h" - -/* Anomaly notes: - * 05000250 - AD1980 is running in TDM mode and RFS/TFS are generated by SPORT - * contrtoller. But, RFSDIV and TFSDIV are always set to 16*16-1, - * while the max AC97 data size is 13*16. The DIV is always larger - * than data size. AD73311 and ad2602 are not running in TDM mode. - * AD1836 and AD73322 depend on external RFS/TFS only. So, this - * anomaly does not affect blackfin sound drivers. -*/ - -static struct sport_device *ac97_sport_handle; - -void bf5xx_pcm_to_ac97(struct ac97_frame *dst, const __u16 *src, - size_t count, unsigned int chan_mask) -{ - while (count--) { - dst->ac97_tag = TAG_VALID; - if (chan_mask & SP_FL) { - dst->ac97_pcm_r = *src++; - dst->ac97_tag |= TAG_PCM_RIGHT; - } - if (chan_mask & SP_FR) { - dst->ac97_pcm_l = *src++; - dst->ac97_tag |= TAG_PCM_LEFT; - - } -#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) - if (chan_mask & SP_SR) { - dst->ac97_sl = *src++; - dst->ac97_tag |= TAG_PCM_SL; - } - if (chan_mask & SP_SL) { - dst->ac97_sr = *src++; - dst->ac97_tag |= TAG_PCM_SR; - } - if (chan_mask & SP_LFE) { - dst->ac97_lfe = *src++; - dst->ac97_tag |= TAG_PCM_LFE; - } - if (chan_mask & SP_FC) { - dst->ac97_center = *src++; - dst->ac97_tag |= TAG_PCM_CENTER; - } -#endif - dst++; - } -} -EXPORT_SYMBOL(bf5xx_pcm_to_ac97); - -void bf5xx_ac97_to_pcm(const struct ac97_frame *src, __u16 *dst, - size_t count) -{ - while (count--) { - *(dst++) = src->ac97_pcm_l; - *(dst++) = src->ac97_pcm_r; - src++; - } -} -EXPORT_SYMBOL(bf5xx_ac97_to_pcm); - -static unsigned int sport_tx_curr_frag(struct sport_device *sport) -{ - return sport->tx_curr_frag = sport_curr_offset_tx(sport) / - sport->tx_fragsize; -} - -static void enqueue_cmd(struct snd_ac97 *ac97, __u16 addr, __u16 data) -{ - struct sport_device *sport = ac97_sport_handle; - int *cmd_count = sport->private_data; - int nextfrag = sport_tx_curr_frag(sport); - struct ac97_frame *nextwrite; - - sport_incfrag(sport, &nextfrag, 1); - - nextwrite = (struct ac97_frame *)(sport->tx_buf + - nextfrag * sport->tx_fragsize); - pr_debug("sport->tx_buf:%p, nextfrag:0x%x nextwrite:%p, cmd_count:%d\n", - sport->tx_buf, nextfrag, nextwrite, cmd_count[nextfrag]); - nextwrite[cmd_count[nextfrag]].ac97_tag |= TAG_CMD; - nextwrite[cmd_count[nextfrag]].ac97_addr = addr; - nextwrite[cmd_count[nextfrag]].ac97_data = data; - ++cmd_count[nextfrag]; - pr_debug("ac97_sport: Inserting %02x/%04x into fragment %d\n", - addr >> 8, data, nextfrag); -} - -static unsigned short bf5xx_ac97_read(struct snd_ac97 *ac97, - unsigned short reg) -{ - struct sport_device *sport_handle = ac97_sport_handle; - struct ac97_frame out_frame[2], in_frame[2]; - - pr_debug("%s enter 0x%x\n", __func__, reg); - - /* When dma descriptor is enabled, the register should not be read */ - if (sport_handle->tx_run || sport_handle->rx_run) { - pr_err("Could you send a mail to cliff.cai@analog.com " - "to report this?\n"); - return -EFAULT; - } - - memset(&out_frame, 0, 2 * sizeof(struct ac97_frame)); - memset(&in_frame, 0, 2 * sizeof(struct ac97_frame)); - out_frame[0].ac97_tag = TAG_VALID | TAG_CMD; - out_frame[0].ac97_addr = ((reg << 8) | 0x8000); - sport_send_and_recv(sport_handle, (unsigned char *)&out_frame, - (unsigned char *)&in_frame, - 2 * sizeof(struct ac97_frame)); - return in_frame[1].ac97_data; -} - -void bf5xx_ac97_write(struct snd_ac97 *ac97, unsigned short reg, - unsigned short val) -{ - struct sport_device *sport_handle = ac97_sport_handle; - - pr_debug("%s enter 0x%x:0x%04x\n", __func__, reg, val); - - if (sport_handle->tx_run) { - enqueue_cmd(ac97, (reg << 8), val); /* write */ - enqueue_cmd(ac97, (reg << 8) | 0x8000, 0); /* read back */ - } else { - struct ac97_frame frame; - memset(&frame, 0, sizeof(struct ac97_frame)); - frame.ac97_tag = TAG_VALID | TAG_CMD; - frame.ac97_addr = (reg << 8); - frame.ac97_data = val; - sport_send_and_recv(sport_handle, (unsigned char *)&frame, \ - NULL, sizeof(struct ac97_frame)); - } -} - -static void bf5xx_ac97_warm_reset(struct snd_ac97 *ac97) -{ - struct sport_device *sport_handle = ac97_sport_handle; - u16 gpio = P_IDENT(sport_handle->pin_req[3]); - - pr_debug("%s enter\n", __func__); - - peripheral_free_list(sport_handle->pin_req); - gpio_request(gpio, "bf5xx-ac97"); - gpio_direction_output(gpio, 1); - udelay(2); - gpio_set_value(gpio, 0); - udelay(1); - gpio_free(gpio); - peripheral_request_list(sport_handle->pin_req, "soc-audio"); -} - -static void bf5xx_ac97_cold_reset(struct snd_ac97 *ac97) -{ -#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET - pr_debug("%s enter\n", __func__); - - /* It is specified for bf548-ezkit */ - gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 0); - /* Keep reset pin low for 1 ms */ - mdelay(1); - gpio_set_value(CONFIG_SND_BF5XX_RESET_GPIO_NUM, 1); - /* Wait for bit clock recover */ - mdelay(1); -#else - pr_info("%s: Not implemented\n", __func__); -#endif -} - -static struct snd_ac97_bus_ops bf5xx_ac97_ops = { - .read = bf5xx_ac97_read, - .write = bf5xx_ac97_write, - .warm_reset = bf5xx_ac97_warm_reset, - .reset = bf5xx_ac97_cold_reset, -}; - -#ifdef CONFIG_PM -static int bf5xx_ac97_suspend(struct snd_soc_dai *dai) -{ - struct sport_device *sport = snd_soc_dai_get_drvdata(dai); - - pr_debug("%s : sport %d\n", __func__, dai->id); - if (!dai->active) - return 0; - if (dai->capture_active) - sport_rx_stop(sport); - if (dai->playback_active) - sport_tx_stop(sport); - return 0; -} - -static int bf5xx_ac97_resume(struct snd_soc_dai *dai) -{ - int ret; - struct sport_device *sport = snd_soc_dai_get_drvdata(dai); - - pr_debug("%s : sport %d\n", __func__, dai->id); - if (!dai->active) - return 0; - -#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) - ret = sport_set_multichannel(sport, 16, 0x3FF, 0x3FF, 1); -#else - ret = sport_set_multichannel(sport, 16, 0x1F, 0x1F, 1); -#endif - if (ret) { - pr_err("SPORT is busy!\n"); - return -EBUSY; - } - - ret = sport_config_rx(sport, IRFS, 0xF, 0, (16*16-1)); - if (ret) { - pr_err("SPORT is busy!\n"); - return -EBUSY; - } - - ret = sport_config_tx(sport, ITFS, 0xF, 0, (16*16-1)); - if (ret) { - pr_err("SPORT is busy!\n"); - return -EBUSY; - } - - return 0; -} - -#else -#define bf5xx_ac97_suspend NULL -#define bf5xx_ac97_resume NULL -#endif - -static struct snd_soc_dai_driver bfin_ac97_dai = { - .bus_control = true, - .suspend = bf5xx_ac97_suspend, - .resume = bf5xx_ac97_resume, - .playback = { - .stream_name = "AC97 Playback", - .channels_min = 2, -#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) - .channels_max = 6, -#else - .channels_max = 2, -#endif - .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, }, - .capture = { - .stream_name = "AC97 Capture", - .channels_min = 2, - .channels_max = 2, - .rates = SNDRV_PCM_RATE_48000, - .formats = SNDRV_PCM_FMTBIT_S16_LE, }, -}; - -static const struct snd_soc_component_driver bfin_ac97_component = { - .name = "bfin-ac97", -}; - -static int asoc_bfin_ac97_probe(struct platform_device *pdev) -{ - struct sport_device *sport_handle; - int ret; - -#ifdef CONFIG_SND_BF5XX_HAVE_COLD_RESET - /* Request PB3 as reset pin */ - ret = devm_gpio_request_one(&pdev->dev, - CONFIG_SND_BF5XX_RESET_GPIO_NUM, - GPIOF_OUT_INIT_HIGH, "SND_AD198x RESET"); - if (ret) { - dev_err(&pdev->dev, - "Failed to request GPIO_%d for reset: %d\n", - CONFIG_SND_BF5XX_RESET_GPIO_NUM, ret); - return ret; - } -#endif - - sport_handle = sport_init(pdev, 2, sizeof(struct ac97_frame), - PAGE_SIZE); - if (!sport_handle) { - ret = -ENODEV; - goto sport_err; - } - - /*SPORT works in TDM mode to simulate AC97 transfers*/ -#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) - ret = sport_set_multichannel(sport_handle, 16, 0x3FF, 0x3FF, 1); -#else - ret = sport_set_multichannel(sport_handle, 16, 0x1F, 0x1F, 1); -#endif - if (ret) { - pr_err("SPORT is busy!\n"); - ret = -EBUSY; - goto sport_config_err; - } - - ret = sport_config_rx(sport_handle, IRFS, 0xF, 0, (16*16-1)); - if (ret) { - pr_err("SPORT is busy!\n"); - ret = -EBUSY; - goto sport_config_err; - } - - ret = sport_config_tx(sport_handle, ITFS, 0xF, 0, (16*16-1)); - if (ret) { - pr_err("SPORT is busy!\n"); - ret = -EBUSY; - goto sport_config_err; - } - - ret = snd_soc_set_ac97_ops(&bf5xx_ac97_ops); - if (ret != 0) { - dev_err(&pdev->dev, "Failed to set AC'97 ops: %d\n", ret); - goto sport_config_err; - } - - ret = snd_soc_register_component(&pdev->dev, &bfin_ac97_component, - &bfin_ac97_dai, 1); - if (ret) { - pr_err("Failed to register DAI: %d\n", ret); - goto sport_config_err; - } - - ac97_sport_handle = sport_handle; - - return 0; - -sport_config_err: - sport_done(sport_handle); -sport_err: - snd_soc_set_ac97_ops(NULL); - - return ret; -} - -static int asoc_bfin_ac97_remove(struct platform_device *pdev) -{ - struct sport_device *sport_handle = platform_get_drvdata(pdev); - - snd_soc_unregister_component(&pdev->dev); - sport_done(sport_handle); - snd_soc_set_ac97_ops(NULL); - - return 0; -} - -static struct platform_driver asoc_bfin_ac97_driver = { - .driver = { - .name = "bfin-ac97", - }, - - .probe = asoc_bfin_ac97_probe, - .remove = asoc_bfin_ac97_remove, -}; - -module_platform_driver(asoc_bfin_ac97_driver); - -MODULE_AUTHOR("Roy Huang"); -MODULE_DESCRIPTION("AC97 driver for ADI Blackfin"); -MODULE_LICENSE("GPL"); diff --git a/sound/soc/blackfin/bf5xx-ac97.h b/sound/soc/blackfin/bf5xx-ac97.h deleted file mode 100644 index a680fdc9bb42..000000000000 --- a/sound/soc/blackfin/bf5xx-ac97.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * sound/soc/blackfin/bf5xx-ac97.h - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef _BF5XX_AC97_H -#define _BF5XX_AC97_H - -/* Frame format in memory, only support stereo currently */ -struct ac97_frame { - u16 ac97_tag; /* slot 0 */ - u16 ac97_addr; /* slot 1 */ - u16 ac97_data; /* slot 2 */ - u16 ac97_pcm_l; /*slot 3:front left*/ - u16 ac97_pcm_r; /*slot 4:front left*/ -#if defined(CONFIG_SND_BF5XX_MULTICHAN_SUPPORT) - u16 ac97_mdm_l1; - u16 ac97_center; /*slot 6:center*/ - u16 ac97_sl; /*slot 7:surround left*/ - u16 ac97_sr; /*slot 8:surround right*/ - u16 ac97_lfe; /*slot 9:lfe*/ -#endif -} __attribute__ ((packed)); - -/* Speaker location */ -#define SP_FL 0x0001 -#define SP_FR 0x0010 -#define SP_FC 0x0002 -#define SP_LFE 0x0020 -#define SP_SL 0x0004 -#define SP_SR 0x0040 - -#define SP_STEREO (SP_FL | SP_FR) -#define SP_2DOT1 (SP_FL | SP_FR | SP_LFE) -#define SP_QUAD (SP_FL | SP_FR | SP_SL | SP_SR) -#define SP_5DOT1 (SP_FL | SP_FR | SP_FC | SP_LFE | SP_SL | SP_SR) - -#define TAG_VALID 0x8000 -#define TAG_CMD 0x6000 -#define TAG_PCM_LEFT 0x1000 -#define TAG_PCM_RIGHT 0x0800 -#define TAG_PCM_MDM_L1 0x0400 -#define TAG_PCM_CENTER 0x0200 -#define TAG_PCM_SL 0x0100 -#define TAG_PCM_SR 0x0080 -#define TAG_PCM_LFE 0x0040 - -void bf5xx_pcm_to_ac97(struct ac97_frame *dst, const __u16 *src, \ - size_t count, unsigned int chan_mask); - -void bf5xx_ac97_to_pcm(const struct ac97_frame *src, __u16 *dst, \ - size_t count); - -#endif diff --git a/sound/soc/blackfin/bf5xx-ad1836.c b/sound/soc/blackfin/bf5xx-ad1836.c deleted file mode 100644 index 864df2616e10..000000000000 --- a/sound/soc/blackfin/bf5xx-ad1836.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-ad1836.c - * Author: Barry Song - * - * Created: Aug 4 2009 - * Description: Board driver for ad1836 sound chip - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "../codecs/ad1836.h" - -static struct snd_soc_card bf5xx_ad1836; - -static int bf5xx_ad1836_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - unsigned int channel_map[] = {0, 4, 1, 5, 2, 6, 3, 7}; - int ret = 0; - - /* set cpu DAI channel mapping */ - ret = snd_soc_dai_set_channel_map(cpu_dai, ARRAY_SIZE(channel_map), - channel_map, ARRAY_SIZE(channel_map), channel_map); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xFF, 0xFF, 8, 32); - if (ret < 0) - return ret; - - return 0; -} - -#define BF5XX_AD1836_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \ - SND_SOC_DAIFMT_CBM_CFM) - -static struct snd_soc_dai_link bf5xx_ad1836_dai = { - .name = "ad1836", - .stream_name = "AD1836", - .codec_dai_name = "ad1836-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .dai_fmt = BF5XX_AD1836_DAIFMT, - .init = bf5xx_ad1836_init, -}; - -static struct snd_soc_card bf5xx_ad1836 = { - .name = "bfin-ad1836", - .owner = THIS_MODULE, - .dai_link = &bf5xx_ad1836_dai, - .num_links = 1, -}; - -static int bf5xx_ad1836_driver_probe(struct platform_device *pdev) -{ - struct snd_soc_card *card = &bf5xx_ad1836; - const char **link_name; - int ret; - - link_name = pdev->dev.platform_data; - if (!link_name) { - dev_err(&pdev->dev, "No platform data supplied\n"); - return -EINVAL; - } - bf5xx_ad1836_dai.cpu_dai_name = link_name[0]; - bf5xx_ad1836_dai.codec_name = link_name[1]; - - card->dev = &pdev->dev; - platform_set_drvdata(pdev, card); - - ret = devm_snd_soc_register_card(&pdev->dev, card); - if (ret) - dev_err(&pdev->dev, "Failed to register card\n"); - return ret; -} - -static struct platform_driver bf5xx_ad1836_driver = { - .driver = { - .name = "bfin-snd-ad1836", - .pm = &snd_soc_pm_ops, - }, - .probe = bf5xx_ad1836_driver_probe, -}; -module_platform_driver(bf5xx_ad1836_driver); - -/* Module information */ -MODULE_AUTHOR("Barry Song"); -MODULE_DESCRIPTION("ALSA SoC AD1836 board driver"); -MODULE_LICENSE("GPL"); - diff --git a/sound/soc/blackfin/bf5xx-ad193x.c b/sound/soc/blackfin/bf5xx-ad193x.c deleted file mode 100644 index 603ad1f2b9b9..000000000000 --- a/sound/soc/blackfin/bf5xx-ad193x.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-ad193x.c - * Author: Barry Song - * - * Created: Thur June 4 2009 - * Description: Board driver for ad193x sound chip - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "../codecs/ad193x.h" - -static struct snd_soc_card bf5xx_ad193x; - -static int bf5xx_ad193x_link_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; - - /* set the codec system clock for DAC and ADC */ - ret = snd_soc_dai_set_sysclk(codec_dai, 0, 24576000, SND_SOC_CLOCK_IN); - if (ret < 0) - return ret; - - /* set codec DAI slots, 8 channels, all channels are enabled */ - ret = snd_soc_dai_set_tdm_slot(codec_dai, 0xFF, 0xFF, 8, 32); - if (ret < 0) - return ret; - - ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xFF, 0xFF, 8, 32); - if (ret < 0) - return ret; - - return 0; -} - -#define BF5XX_AD193X_DAIFMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_IF | \ - SND_SOC_DAIFMT_CBM_CFM) - -static struct snd_soc_dai_link bf5xx_ad193x_dai[] = { - { - .name = "ad193x", - .stream_name = "AD193X", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name ="ad193x-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "spi0.5", - .dai_fmt = BF5XX_AD193X_DAIFMT, - .init = bf5xx_ad193x_link_init, - }, - { - .name = "ad193x", - .stream_name = "AD193X", - .cpu_dai_name = "bfin-i2s.1", - .codec_dai_name ="ad193x-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "spi0.5", - .dai_fmt = BF5XX_AD193X_DAIFMT, - .init = bf5xx_ad193x_link_init, - }, -}; - -static struct snd_soc_card bf5xx_ad193x = { - .name = "bfin-ad193x", - .owner = THIS_MODULE, - .dai_link = &bf5xx_ad193x_dai[CONFIG_SND_BF5XX_SPORT_NUM], - .num_links = 1, -}; - -static struct platform_device *bfxx_ad193x_snd_device; - -static int __init bf5xx_ad193x_init(void) -{ - int ret; - - bfxx_ad193x_snd_device = platform_device_alloc("soc-audio", -1); - if (!bfxx_ad193x_snd_device) - return -ENOMEM; - - platform_set_drvdata(bfxx_ad193x_snd_device, &bf5xx_ad193x); - ret = platform_device_add(bfxx_ad193x_snd_device); - - if (ret) - platform_device_put(bfxx_ad193x_snd_device); - - return ret; -} - -static void __exit bf5xx_ad193x_exit(void) -{ - platform_device_unregister(bfxx_ad193x_snd_device); -} - -module_init(bf5xx_ad193x_init); -module_exit(bf5xx_ad193x_exit); - -/* Module information */ -MODULE_AUTHOR("Barry Song"); -MODULE_DESCRIPTION("ALSA SoC AD193X board driver"); -MODULE_LICENSE("GPL"); - diff --git a/sound/soc/blackfin/bf5xx-ad1980.c b/sound/soc/blackfin/bf5xx-ad1980.c deleted file mode 100644 index 0fa81a523b8a..000000000000 --- a/sound/soc/blackfin/bf5xx-ad1980.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-ad1980.c - * Author: Cliff Cai - * - * Created: Tue June 06 2008 - * Description: Board driver for AD1980/1 audio codec - * - * Modified: - * Copyright 2008 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/* - * WARNING: - * - * Because Analog Devices Inc. discontinued the ad1980 sound chip since - * Sep. 2009, this ad1980 driver is not maintained, tested and supported - * by ADI now. - */ - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include "bf5xx-ac97.h" - -static struct snd_soc_card bf5xx_board; - -static struct snd_soc_dai_link bf5xx_board_dai[] = { - { - .name = "AC97", - .stream_name = "AC97 HiFi", - .cpu_dai_name = "bfin-ac97.0", - .codec_dai_name = "ad1980-hifi", - .platform_name = "bfin-ac97-pcm-audio", - .codec_name = "ad1980", - }, - { - .name = "AC97", - .stream_name = "AC97 HiFi", - .cpu_dai_name = "bfin-ac97.1", - .codec_dai_name = "ad1980-hifi", - .platform_name = "bfin-ac97-pcm-audio", - .codec_name = "ad1980", - }, -}; - -static struct snd_soc_card bf5xx_board = { - .name = "bfin-ad1980", - .owner = THIS_MODULE, - .dai_link = &bf5xx_board_dai[CONFIG_SND_BF5XX_SPORT_NUM], - .num_links = 1, -}; - -static struct platform_device *bf5xx_board_snd_device; - -static int __init bf5xx_board_init(void) -{ - int ret; - - bf5xx_board_snd_device = platform_device_alloc("soc-audio", -1); - if (!bf5xx_board_snd_device) - return -ENOMEM; - - platform_set_drvdata(bf5xx_board_snd_device, &bf5xx_board); - ret = platform_device_add(bf5xx_board_snd_device); - - if (ret) - platform_device_put(bf5xx_board_snd_device); - - return ret; -} - -static void __exit bf5xx_board_exit(void) -{ - platform_device_unregister(bf5xx_board_snd_device); -} - -module_init(bf5xx_board_init); -module_exit(bf5xx_board_exit); - -/* Module information */ -MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("ALSA SoC AD1980/1 BF5xx board (Obsolete)"); -MODULE_LICENSE("GPL"); diff --git a/sound/soc/blackfin/bf5xx-ad73311.c b/sound/soc/blackfin/bf5xx-ad73311.c deleted file mode 100644 index 786bbdd96e7c..000000000000 --- a/sound/soc/blackfin/bf5xx-ad73311.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-ad73311.c - * Author: Cliff Cai - * - * Created: Thur Sep 25 2008 - * Description: Board driver for ad73311 sound chip - * - * Modified: - * Copyright 2008 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "../codecs/ad73311.h" -#include "bf5xx-sport.h" - -#if CONFIG_SND_BF5XX_SPORT_NUM == 0 -#define bfin_write_SPORT_TCR1 bfin_write_SPORT0_TCR1 -#define bfin_read_SPORT_TCR1 bfin_read_SPORT0_TCR1 -#define bfin_write_SPORT_TCR2 bfin_write_SPORT0_TCR2 -#define bfin_write_SPORT_TX16 bfin_write_SPORT0_TX16 -#define bfin_read_SPORT_STAT bfin_read_SPORT0_STAT -#else -#define bfin_write_SPORT_TCR1 bfin_write_SPORT1_TCR1 -#define bfin_read_SPORT_TCR1 bfin_read_SPORT1_TCR1 -#define bfin_write_SPORT_TCR2 bfin_write_SPORT1_TCR2 -#define bfin_write_SPORT_TX16 bfin_write_SPORT1_TX16 -#define bfin_read_SPORT_STAT bfin_read_SPORT1_STAT -#endif - -#define GPIO_SE CONFIG_SND_BFIN_AD73311_SE - -static struct snd_soc_card bf5xx_ad73311; - -static int snd_ad73311_startup(void) -{ - pr_debug("%s enter\n", __func__); - - /* Pull up SE pin on AD73311L */ - gpio_set_value(GPIO_SE, 1); - return 0; -} - -static int snd_ad73311_configure(void) -{ - unsigned short ctrl_regs[6]; - unsigned short status = 0; - int count = 0; - - /* DMCLK = MCLK = 16.384 MHz - * SCLK = DMCLK/8 = 2.048 MHz - * Sample Rate = DMCLK/2048 = 8 KHz - */ - ctrl_regs[0] = AD_CONTROL | AD_WRITE | CTRL_REG_B | REGB_MCDIV(0) | \ - REGB_SCDIV(0) | REGB_DIRATE(0); - ctrl_regs[1] = AD_CONTROL | AD_WRITE | CTRL_REG_C | REGC_PUDEV | \ - REGC_PUADC | REGC_PUDAC | REGC_PUREF | REGC_REFUSE ; - ctrl_regs[2] = AD_CONTROL | AD_WRITE | CTRL_REG_D | REGD_OGS(2) | \ - REGD_IGS(2); - ctrl_regs[3] = AD_CONTROL | AD_WRITE | CTRL_REG_E | REGE_DA(0x1f); - ctrl_regs[4] = AD_CONTROL | AD_WRITE | CTRL_REG_F | REGF_SEEN ; - ctrl_regs[5] = AD_CONTROL | AD_WRITE | CTRL_REG_A | REGA_MODE_DATA; - - local_irq_disable(); - snd_ad73311_startup(); - udelay(1); - - bfin_write_SPORT_TCR1(TFSR); - bfin_write_SPORT_TCR2(0xF); - SSYNC(); - - /* SPORT Tx Register is a 8 x 16 FIFO, all the data can be put to - * FIFO before enable SPORT to transfer the data - */ - for (count = 0; count < 6; count++) - bfin_write_SPORT_TX16(ctrl_regs[count]); - SSYNC(); - bfin_write_SPORT_TCR1(bfin_read_SPORT_TCR1() | TSPEN); - SSYNC(); - - /* When TUVF is set, the data is already send out */ - while (!(status & TUVF) && ++count < 10000) { - udelay(1); - status = bfin_read_SPORT_STAT(); - SSYNC(); - } - bfin_write_SPORT_TCR1(bfin_read_SPORT_TCR1() & ~TSPEN); - SSYNC(); - local_irq_enable(); - - if (count >= 10000) { - printk(KERN_ERR "ad73311: failed to configure codec\n"); - return -1; - } - return 0; -} - -static int bf5xx_probe(struct snd_soc_card *card) -{ - int err; - if (gpio_request(GPIO_SE, "AD73311_SE")) { - printk(KERN_ERR "%s: Failed ro request GPIO_%d\n", __func__, GPIO_SE); - return -EBUSY; - } - - gpio_direction_output(GPIO_SE, 0); - - err = snd_ad73311_configure(); - if (err < 0) - return -EFAULT; - - return 0; -} - -#define BF5XX_AD7311_DAI_FMT (SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_NB_NF | \ - SND_SOC_DAIFMT_CBM_CFM) - -static struct snd_soc_dai_link bf5xx_ad73311_dai[] = { - { - .name = "ad73311", - .stream_name = "AD73311", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "ad73311-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "ad73311", - .dai_fmt = BF5XX_AD7311_DAI_FMT, - }, - { - .name = "ad73311", - .stream_name = "AD73311", - .cpu_dai_name = "bfin-i2s.1", - .codec_dai_name = "ad73311-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "ad73311", - .dai_fmt = BF5XX_AD7311_DAI_FMT, - }, -}; - -static struct snd_soc_card bf5xx_ad73311 = { - .name = "bfin-ad73311", - .owner = THIS_MODULE, - .probe = bf5xx_probe, - .dai_link = &bf5xx_ad73311_dai[CONFIG_SND_BF5XX_SPORT_NUM], - .num_links = 1, -}; - -static struct platform_device *bf5xx_ad73311_snd_device; - -static int __init bf5xx_ad73311_init(void) -{ - int ret; - - pr_debug("%s enter\n", __func__); - bf5xx_ad73311_snd_device = platform_device_alloc("soc-audio", -1); - if (!bf5xx_ad73311_snd_device) - return -ENOMEM; - - platform_set_drvdata(bf5xx_ad73311_snd_device, &bf5xx_ad73311); - ret = platform_device_add(bf5xx_ad73311_snd_device); - - if (ret) - platform_device_put(bf5xx_ad73311_snd_device); - - return ret; -} - -static void __exit bf5xx_ad73311_exit(void) -{ - pr_debug("%s enter\n", __func__); - platform_device_unregister(bf5xx_ad73311_snd_device); -} - -module_init(bf5xx_ad73311_init); -module_exit(bf5xx_ad73311_exit); - -/* Module information */ -MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("ALSA SoC AD73311 Blackfin"); -MODULE_LICENSE("GPL"); - diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c deleted file mode 100644 index 6712b01dabd1..000000000000 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ /dev/null @@ -1,373 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-i2s-pcm.c - * Author: Cliff Cai - * - * Created: Tue June 06 2008 - * Description: DMA driver for i2s codec - * - * Modified: - * Copyright 2008 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "bf5xx-sport.h" -#include "bf5xx-i2s-pcm.h" - -static void bf5xx_dma_irq(void *data) -{ - struct snd_pcm_substream *pcm = data; - snd_pcm_period_elapsed(pcm); -} - -static const struct snd_pcm_hardware bf5xx_pcm_hardware = { - .info = SNDRV_PCM_INFO_INTERLEAVED | - SNDRV_PCM_INFO_MMAP_VALID | - SNDRV_PCM_INFO_BLOCK_TRANSFER, - .period_bytes_min = 32, - .period_bytes_max = 0x10000, - .periods_min = 1, - .periods_max = PAGE_SIZE/32, - .buffer_bytes_max = 0x20000, /* 128 kbytes */ - .fifo_size = 16, -}; - -static int bf5xx_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - unsigned int buffer_size = params_buffer_bytes(params); - struct bf5xx_i2s_pcm_data *dma_data; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - if (dma_data->tdm_mode) - buffer_size = buffer_size / params_channels(params) * 8; - - return snd_pcm_lib_malloc_pages(substream, buffer_size); -} - -static int bf5xx_pcm_hw_free(struct snd_pcm_substream *substream) -{ - snd_pcm_lib_free_pages(substream); - - return 0; -} - -static int bf5xx_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - int period_bytes = frames_to_bytes(runtime, runtime->period_size); - struct bf5xx_i2s_pcm_data *dma_data; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - if (dma_data->tdm_mode) - period_bytes = period_bytes / runtime->channels * 8; - - pr_debug("%s enter\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - sport_set_tx_callback(sport, bf5xx_dma_irq, substream); - sport_config_tx_dma(sport, runtime->dma_area, - runtime->periods, period_bytes); - } else { - sport_set_rx_callback(sport, bf5xx_dma_irq, substream); - sport_config_rx_dma(sport, runtime->dma_area, - runtime->periods, period_bytes); - } - - return 0; -} - -static int bf5xx_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - int ret = 0; - - pr_debug("%s enter\n", __func__); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - sport_tx_start(sport); - else - sport_rx_start(sport); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - sport_tx_stop(sport); - else - sport_rx_stop(sport); - break; - default: - ret = -EINVAL; - } - - return ret; -} - -static snd_pcm_uframes_t bf5xx_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; - struct sport_device *sport = runtime->private_data; - unsigned int diff; - snd_pcm_uframes_t frames; - struct bf5xx_i2s_pcm_data *dma_data; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - pr_debug("%s enter\n", __func__); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - diff = sport_curr_offset_tx(sport); - } else { - diff = sport_curr_offset_rx(sport); - } - - /* - * TX at least can report one frame beyond the end of the - * buffer if we hit the wraparound case - clamp to within the - * buffer as the ALSA APIs require. - */ - if (diff == snd_pcm_lib_buffer_bytes(substream)) - diff = 0; - - frames = bytes_to_frames(substream->runtime, diff); - if (dma_data->tdm_mode) - frames = frames * runtime->channels / 8; - - return frames; -} - -static int bf5xx_pcm_open(struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *cpu_dai = rtd->cpu_dai; - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai); - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dma_buffer *buf = &substream->dma_buffer; - struct bf5xx_i2s_pcm_data *dma_data; - int ret; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - pr_debug("%s enter\n", __func__); - - snd_soc_set_runtime_hwparams(substream, &bf5xx_pcm_hardware); - if (dma_data->tdm_mode) - runtime->hw.buffer_bytes_max /= 4; - else - runtime->hw.info |= SNDRV_PCM_INFO_MMAP; - - ret = snd_pcm_hw_constraint_integer(runtime, - SNDRV_PCM_HW_PARAM_PERIODS); - if (ret < 0) - goto out; - - if (sport_handle != NULL) { - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - sport_handle->tx_buf = buf->area; - else - sport_handle->rx_buf = buf->area; - - runtime->private_data = sport_handle; - } else { - pr_err("sport_handle is NULL\n"); - return -1; - } - return 0; - - out: - return ret; -} - -static int bf5xx_pcm_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *vma) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - size_t size = vma->vm_end - vma->vm_start; - vma->vm_start = (unsigned long)runtime->dma_area; - vma->vm_end = vma->vm_start + size; - vma->vm_flags |= VM_SHARED; - - return 0 ; -} - -static int bf5xx_pcm_copy(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void *buf, unsigned long count) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; - unsigned int sample_size = runtime->sample_bits / 8; - struct bf5xx_i2s_pcm_data *dma_data; - unsigned int i; - void *src, *dst; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - if (dma_data->tdm_mode) { - pos = bytes_to_frames(runtime, pos); - count = bytes_to_frames(runtime, count); - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - src = buf; - dst = runtime->dma_area; - dst += pos * sample_size * 8; - - while (count--) { - for (i = 0; i < runtime->channels; i++) { - memcpy(dst + dma_data->map[i] * - sample_size, src, sample_size); - src += sample_size; - } - dst += 8 * sample_size; - } - } else { - src = runtime->dma_area; - src += pos * sample_size * 8; - dst = buf; - - while (count--) { - for (i = 0; i < runtime->channels; i++) { - memcpy(dst, src + dma_data->map[i] * - sample_size, sample_size); - dst += sample_size; - } - src += 8 * sample_size; - } - } - } else { - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - src = buf; - dst = runtime->dma_area; - dst += pos; - } else { - src = runtime->dma_area; - src += pos; - dst = buf; - } - - memcpy(dst, src, count); - } - - return 0; -} - -static int bf5xx_pcm_copy_user(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - void __user *buf, unsigned long count) -{ - return bf5xx_pcm_copy(substream, channel, pos, (void *)buf, count); -} - -static int bf5xx_pcm_silence(struct snd_pcm_substream *substream, - int channel, unsigned long pos, - unsigned long count) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_pcm_runtime *runtime = substream->runtime; - unsigned int sample_size = runtime->sample_bits / 8; - void *buf = runtime->dma_area; - struct bf5xx_i2s_pcm_data *dma_data; - unsigned int offset, samples; - - dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); - - if (dma_data->tdm_mode) { - offset = bytes_to_frames(runtime, pos) * 8 * sample_size; - samples = bytes_to_frames(runtime, count) * 8; - } else { - offset = pos; - samples = bytes_to_samples(runtime, count); - } - - snd_pcm_format_set_silence(runtime->format, buf + offset, samples); - - return 0; -} - -static const struct snd_pcm_ops bf5xx_pcm_i2s_ops = { - .open = bf5xx_pcm_open, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = bf5xx_pcm_hw_params, - .hw_free = bf5xx_pcm_hw_free, - .prepare = bf5xx_pcm_prepare, - .trigger = bf5xx_pcm_trigger, - .pointer = bf5xx_pcm_pointer, - .mmap = bf5xx_pcm_mmap, - .copy_user = bf5xx_pcm_copy_user, - .copy_kernel = bf5xx_pcm_copy, - .fill_silence = bf5xx_pcm_silence, -}; - -static int bf5xx_pcm_i2s_new(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_card *card = rtd->card->snd_card; - size_t size = bf5xx_pcm_hardware.buffer_bytes_max; - int ret; - - pr_debug("%s enter\n", __func__); - ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); - if (ret) - return ret; - - return snd_pcm_lib_preallocate_pages_for_all(rtd->pcm, - SNDRV_DMA_TYPE_DEV, card->dev, size, size); -} - -static struct snd_soc_component_driver bf5xx_i2s_soc_component = { - .ops = &bf5xx_pcm_i2s_ops, - .pcm_new = bf5xx_pcm_i2s_new, -}; - -static int bfin_i2s_soc_platform_probe(struct platform_device *pdev) -{ - return devm_snd_soc_register_component(&pdev->dev, - &bf5xx_i2s_soc_component, NULL, 0); -} - -static struct platform_driver bfin_i2s_pcm_driver = { - .driver = { - .name = "bfin-i2s-pcm-audio", - }, - - .probe = bfin_i2s_soc_platform_probe, -}; - -module_platform_driver(bfin_i2s_pcm_driver); - -MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("ADI Blackfin I2S PCM DMA module"); -MODULE_LICENSE("GPL"); diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.h b/sound/soc/blackfin/bf5xx-i2s-pcm.h deleted file mode 100644 index 1f0435249f88..000000000000 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ - -#ifndef _BF5XX_TDM_PCM_H -#define _BF5XX_TDM_PCM_H - -#define BFIN_TDM_DAI_MAX_SLOTS 8 - -struct bf5xx_i2s_pcm_data { - unsigned int map[BFIN_TDM_DAI_MAX_SLOTS]; - bool tdm_mode; -}; - -#endif diff --git a/sound/soc/blackfin/bf5xx-i2s.c b/sound/soc/blackfin/bf5xx-i2s.c deleted file mode 100644 index b69aeef6418e..000000000000 --- a/sound/soc/blackfin/bf5xx-i2s.c +++ /dev/null @@ -1,391 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-i2s.c - * Author: Cliff Cai - * - * Created: Tue June 06 2008 - * Description: Blackfin I2S CPU DAI driver - * - * Modified: - * Copyright 2008 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "bf5xx-sport.h" -#include "bf5xx-i2s-pcm.h" - -struct bf5xx_i2s_port { - u16 tcr1; - u16 rcr1; - u16 tcr2; - u16 rcr2; - int configured; - - unsigned int slots; - unsigned int tx_mask; - unsigned int rx_mask; - - struct bf5xx_i2s_pcm_data tx_dma_data; - struct bf5xx_i2s_pcm_data rx_dma_data; -}; - -static int bf5xx_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, - unsigned int fmt) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(cpu_dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - int ret = 0; - - /* interface format:support I2S,slave mode */ - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - bf5xx_i2s->tcr1 |= TFSR | TCKFE; - bf5xx_i2s->rcr1 |= RFSR | RCKFE; - bf5xx_i2s->tcr2 |= TSFSE; - bf5xx_i2s->rcr2 |= RSFSE; - break; - case SND_SOC_DAIFMT_DSP_A: - bf5xx_i2s->tcr1 |= TFSR; - bf5xx_i2s->rcr1 |= RFSR; - break; - case SND_SOC_DAIFMT_LEFT_J: - ret = -EINVAL; - break; - default: - dev_err(cpu_dai->dev, "%s: Unknown DAI format type\n", - __func__); - ret = -EINVAL; - break; - } - - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFM: - break; - case SND_SOC_DAIFMT_CBS_CFS: - case SND_SOC_DAIFMT_CBM_CFS: - case SND_SOC_DAIFMT_CBS_CFM: - ret = -EINVAL; - break; - default: - dev_err(cpu_dai->dev, "%s: Unknown DAI master type\n", - __func__); - ret = -EINVAL; - break; - } - - return ret; -} - -static int bf5xx_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - int ret = 0; - - bf5xx_i2s->tcr2 &= ~0x1f; - bf5xx_i2s->rcr2 &= ~0x1f; - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S8: - bf5xx_i2s->tcr2 |= 7; - bf5xx_i2s->rcr2 |= 7; - sport_handle->wdsize = 1; - break; - case SNDRV_PCM_FORMAT_S16_LE: - bf5xx_i2s->tcr2 |= 15; - bf5xx_i2s->rcr2 |= 15; - sport_handle->wdsize = 2; - break; - case SNDRV_PCM_FORMAT_S24_LE: - bf5xx_i2s->tcr2 |= 23; - bf5xx_i2s->rcr2 |= 23; - sport_handle->wdsize = 3; - break; - case SNDRV_PCM_FORMAT_S32_LE: - bf5xx_i2s->tcr2 |= 31; - bf5xx_i2s->rcr2 |= 31; - sport_handle->wdsize = 4; - break; - } - - if (!bf5xx_i2s->configured) { - /* - * TX and RX are not independent,they are enabled at the - * same time, even if only one side is running. So, we - * need to configure both of them at the time when the first - * stream is opened. - * - * CPU DAI:slave mode. - */ - bf5xx_i2s->configured = 1; - ret = sport_config_rx(sport_handle, bf5xx_i2s->rcr1, - bf5xx_i2s->rcr2, 0, 0); - if (ret) { - dev_err(dai->dev, "SPORT is busy!\n"); - return -EBUSY; - } - - ret = sport_config_tx(sport_handle, bf5xx_i2s->tcr1, - bf5xx_i2s->tcr2, 0, 0); - if (ret) { - dev_err(dai->dev, "SPORT is busy!\n"); - return -EBUSY; - } - } - - return 0; -} - -static void bf5xx_i2s_shutdown(struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - - dev_dbg(dai->dev, "%s enter\n", __func__); - /* No active stream, SPORT is allowed to be configured again. */ - if (!dai->active) - bf5xx_i2s->configured = 0; -} - -static int bf5xx_i2s_set_channel_map(struct snd_soc_dai *dai, - unsigned int tx_num, unsigned int *tx_slot, - unsigned int rx_num, unsigned int *rx_slot) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - unsigned int tx_mapped = 0, rx_mapped = 0; - unsigned int slot; - int i; - - if ((tx_num > BFIN_TDM_DAI_MAX_SLOTS) || - (rx_num > BFIN_TDM_DAI_MAX_SLOTS)) - return -EINVAL; - - for (i = 0; i < tx_num; i++) { - slot = tx_slot[i]; - if ((slot < BFIN_TDM_DAI_MAX_SLOTS) && - (!(tx_mapped & (1 << slot)))) { - bf5xx_i2s->tx_dma_data.map[i] = slot; - tx_mapped |= 1 << slot; - } else - return -EINVAL; - } - for (i = 0; i < rx_num; i++) { - slot = rx_slot[i]; - if ((slot < BFIN_TDM_DAI_MAX_SLOTS) && - (!(rx_mapped & (1 << slot)))) { - bf5xx_i2s->rx_dma_data.map[i] = slot; - rx_mapped |= 1 << slot; - } else - return -EINVAL; - } - - return 0; -} - -static int bf5xx_i2s_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, - unsigned int rx_mask, int slots, int width) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - - if (slots % 8 != 0 || slots > 8) - return -EINVAL; - - if (width != 32) - return -EINVAL; - - bf5xx_i2s->slots = slots; - bf5xx_i2s->tx_mask = tx_mask; - bf5xx_i2s->rx_mask = rx_mask; - - bf5xx_i2s->tx_dma_data.tdm_mode = slots != 0; - bf5xx_i2s->rx_dma_data.tdm_mode = slots != 0; - - return sport_set_multichannel(sport_handle, slots, tx_mask, rx_mask, 0); -} - -#ifdef CONFIG_PM -static int bf5xx_i2s_suspend(struct snd_soc_dai *dai) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - - dev_dbg(dai->dev, "%s : sport %d\n", __func__, dai->id); - - if (dai->capture_active) - sport_rx_stop(sport_handle); - if (dai->playback_active) - sport_tx_stop(sport_handle); - return 0; -} - -static int bf5xx_i2s_resume(struct snd_soc_dai *dai) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - int ret; - - dev_dbg(dai->dev, "%s : sport %d\n", __func__, dai->id); - - ret = sport_config_rx(sport_handle, bf5xx_i2s->rcr1, - bf5xx_i2s->rcr2, 0, 0); - if (ret) { - dev_err(dai->dev, "SPORT is busy!\n"); - return -EBUSY; - } - - ret = sport_config_tx(sport_handle, bf5xx_i2s->tcr1, - bf5xx_i2s->tcr2, 0, 0); - if (ret) { - dev_err(dai->dev, "SPORT is busy!\n"); - return -EBUSY; - } - - return sport_set_multichannel(sport_handle, bf5xx_i2s->slots, - bf5xx_i2s->tx_mask, bf5xx_i2s->rx_mask, 0); -} - -#else -#define bf5xx_i2s_suspend NULL -#define bf5xx_i2s_resume NULL -#endif - -static int bf5xx_i2s_dai_probe(struct snd_soc_dai *dai) -{ - struct sport_device *sport_handle = snd_soc_dai_get_drvdata(dai); - struct bf5xx_i2s_port *bf5xx_i2s = sport_handle->private_data; - unsigned int i; - - for (i = 0; i < BFIN_TDM_DAI_MAX_SLOTS; i++) { - bf5xx_i2s->tx_dma_data.map[i] = i; - bf5xx_i2s->rx_dma_data.map[i] = i; - } - - dai->playback_dma_data = &bf5xx_i2s->tx_dma_data; - dai->capture_dma_data = &bf5xx_i2s->rx_dma_data; - - return 0; -} - -#define BF5XX_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ - SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \ - SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | \ - SNDRV_PCM_RATE_96000) - -#define BF5XX_I2S_FORMATS \ - (SNDRV_PCM_FMTBIT_S8 | \ - SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S24_LE | \ - SNDRV_PCM_FMTBIT_S32_LE) - -static const struct snd_soc_dai_ops bf5xx_i2s_dai_ops = { - .shutdown = bf5xx_i2s_shutdown, - .hw_params = bf5xx_i2s_hw_params, - .set_fmt = bf5xx_i2s_set_dai_fmt, - .set_tdm_slot = bf5xx_i2s_set_tdm_slot, - .set_channel_map = bf5xx_i2s_set_channel_map, -}; - -static struct snd_soc_dai_driver bf5xx_i2s_dai = { - .probe = bf5xx_i2s_dai_probe, - .suspend = bf5xx_i2s_suspend, - .resume = bf5xx_i2s_resume, - .playback = { - .channels_min = 2, - .channels_max = 8, - .rates = BF5XX_I2S_RATES, - .formats = BF5XX_I2S_FORMATS,}, - .capture = { - .channels_min = 2, - .channels_max = 8, - .rates = BF5XX_I2S_RATES, - .formats = BF5XX_I2S_FORMATS,}, - .ops = &bf5xx_i2s_dai_ops, -}; - -static const struct snd_soc_component_driver bf5xx_i2s_component = { - .name = "bf5xx-i2s", -}; - -static int bf5xx_i2s_probe(struct platform_device *pdev) -{ - struct sport_device *sport_handle; - int ret; - - /* configure SPORT for I2S */ - sport_handle = sport_init(pdev, 4, 8 * sizeof(u32), - sizeof(struct bf5xx_i2s_port)); - if (!sport_handle) - return -ENODEV; - - /* register with the ASoC layers */ - ret = snd_soc_register_component(&pdev->dev, &bf5xx_i2s_component, - &bf5xx_i2s_dai, 1); - if (ret) { - dev_err(&pdev->dev, "Failed to register DAI: %d\n", ret); - sport_done(sport_handle); - return ret; - } - - return 0; -} - -static int bf5xx_i2s_remove(struct platform_device *pdev) -{ - struct sport_device *sport_handle = platform_get_drvdata(pdev); - - dev_dbg(&pdev->dev, "%s enter\n", __func__); - - snd_soc_unregister_component(&pdev->dev); - sport_done(sport_handle); - - return 0; -} - -static struct platform_driver bfin_i2s_driver = { - .probe = bf5xx_i2s_probe, - .remove = bf5xx_i2s_remove, - .driver = { - .name = "bfin-i2s", - }, -}; - -module_platform_driver(bfin_i2s_driver); - -/* Module information */ -MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("I2S driver for ADI Blackfin"); -MODULE_LICENSE("GPL"); - diff --git a/sound/soc/blackfin/bf5xx-sport.c b/sound/soc/blackfin/bf5xx-sport.c deleted file mode 100644 index 9dfa1241ea66..000000000000 --- a/sound/soc/blackfin/bf5xx-sport.c +++ /dev/null @@ -1,1102 +0,0 @@ -/* - * File: bf5xx_sport.c - * Based on: - * Author: Roy Huang - * - * Created: Tue Sep 21 10:52:42 CEST 2004 - * Description: - * Blackfin SPORT Driver - * - * Copyright 2004-2007 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bf5xx-sport.h" -/* delay between frame sync pulse and first data bit in multichannel mode */ -#define FRAME_DELAY (1<<12) - -/* note: multichannel is in units of 8 channels, - * tdm_count is # channels NOT / 8 ! */ -int sport_set_multichannel(struct sport_device *sport, - int tdm_count, u32 tx_mask, u32 rx_mask, int packed) -{ - pr_debug("%s tdm_count=%d tx_mask:0x%08x rx_mask:0x%08x packed=%d\n", - __func__, tdm_count, tx_mask, rx_mask, packed); - - if ((sport->regs->tcr1 & TSPEN) || (sport->regs->rcr1 & RSPEN)) - return -EBUSY; - - if (tdm_count & 0x7) - return -EINVAL; - - if (tdm_count > 32) - return -EINVAL; /* Only support less than 32 channels now */ - - if (tdm_count) { - sport->regs->mcmc1 = ((tdm_count>>3)-1) << 12; - sport->regs->mcmc2 = FRAME_DELAY | MCMEN | \ - (packed ? (MCDTXPE|MCDRXPE) : 0); - - sport->regs->mtcs0 = tx_mask; - sport->regs->mrcs0 = rx_mask; - sport->regs->mtcs1 = 0; - sport->regs->mrcs1 = 0; - sport->regs->mtcs2 = 0; - sport->regs->mrcs2 = 0; - sport->regs->mtcs3 = 0; - sport->regs->mrcs3 = 0; - } else { - sport->regs->mcmc1 = 0; - sport->regs->mcmc2 = 0; - - sport->regs->mtcs0 = 0; - sport->regs->mrcs0 = 0; - } - - sport->regs->mtcs1 = 0; sport->regs->mtcs2 = 0; sport->regs->mtcs3 = 0; - sport->regs->mrcs1 = 0; sport->regs->mrcs2 = 0; sport->regs->mrcs3 = 0; - - SSYNC(); - - return 0; -} -EXPORT_SYMBOL(sport_set_multichannel); - -int sport_config_rx(struct sport_device *sport, unsigned int rcr1, - unsigned int rcr2, unsigned int clkdiv, unsigned int fsdiv) -{ - if ((sport->regs->tcr1 & TSPEN) || (sport->regs->rcr1 & RSPEN)) - return -EBUSY; - - sport->regs->rcr1 = rcr1; - sport->regs->rcr2 = rcr2; - sport->regs->rclkdiv = clkdiv; - sport->regs->rfsdiv = fsdiv; - - SSYNC(); - - return 0; -} -EXPORT_SYMBOL(sport_config_rx); - -int sport_config_tx(struct sport_device *sport, unsigned int tcr1, - unsigned int tcr2, unsigned int clkdiv, unsigned int fsdiv) -{ - if ((sport->regs->tcr1 & TSPEN) || (sport->regs->rcr1 & RSPEN)) - return -EBUSY; - - sport->regs->tcr1 = tcr1; - sport->regs->tcr2 = tcr2; - sport->regs->tclkdiv = clkdiv; - sport->regs->tfsdiv = fsdiv; - - SSYNC(); - - return 0; -} -EXPORT_SYMBOL(sport_config_tx); - -static void setup_desc(struct dmasg *desc, void *buf, int fragcount, - size_t fragsize, unsigned int cfg, - unsigned int x_count, unsigned int ycount, size_t wdsize) -{ - - int i; - - for (i = 0; i < fragcount; ++i) { - desc[i].next_desc_addr = &(desc[i + 1]); - desc[i].start_addr = (unsigned long)buf + i*fragsize; - desc[i].cfg = cfg; - desc[i].x_count = x_count; - desc[i].x_modify = wdsize; - desc[i].y_count = ycount; - desc[i].y_modify = wdsize; - } - - /* make circular */ - desc[fragcount-1].next_desc_addr = desc; - - pr_debug("setup desc: desc0=%p, next0=%p, desc1=%p," - "next1=%p\nx_count=%x,y_count=%x,addr=0x%lx,cfs=0x%x\n", - desc, desc[0].next_desc_addr, - desc+1, desc[1].next_desc_addr, - desc[0].x_count, desc[0].y_count, - desc[0].start_addr, desc[0].cfg); -} - -static int sport_start(struct sport_device *sport) -{ - enable_dma(sport->dma_rx_chan); - enable_dma(sport->dma_tx_chan); - sport->regs->rcr1 |= RSPEN; - sport->regs->tcr1 |= TSPEN; - SSYNC(); - - return 0; -} - -static int sport_stop(struct sport_device *sport) -{ - sport->regs->tcr1 &= ~TSPEN; - sport->regs->rcr1 &= ~RSPEN; - SSYNC(); - - disable_dma(sport->dma_rx_chan); - disable_dma(sport->dma_tx_chan); - return 0; -} - -static inline int sport_hook_rx_dummy(struct sport_device *sport) -{ - struct dmasg *desc, temp_desc; - unsigned long flags; - - if (WARN_ON(!sport->dummy_rx_desc) || - WARN_ON(sport->curr_rx_desc == sport->dummy_rx_desc)) - return -EINVAL; - - /* Maybe the dummy buffer descriptor ring is damaged */ - sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc + 1; - - local_irq_save(flags); - desc = get_dma_next_desc_ptr(sport->dma_rx_chan); - /* Copy the descriptor which will be damaged to backup */ - temp_desc = *desc; - desc->x_count = sport->dummy_count / 2; - desc->y_count = 0; - desc->next_desc_addr = sport->dummy_rx_desc; - local_irq_restore(flags); - /* Waiting for dummy buffer descriptor is already hooked*/ - while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - - sizeof(struct dmasg)) != sport->dummy_rx_desc) - continue; - sport->curr_rx_desc = sport->dummy_rx_desc; - /* Restore the damaged descriptor */ - *desc = temp_desc; - - return 0; -} - -static inline int sport_rx_dma_start(struct sport_device *sport, int dummy) -{ - if (dummy) { - sport->dummy_rx_desc->next_desc_addr = sport->dummy_rx_desc; - sport->curr_rx_desc = sport->dummy_rx_desc; - } else - sport->curr_rx_desc = sport->dma_rx_desc; - - set_dma_next_desc_addr(sport->dma_rx_chan, sport->curr_rx_desc); - set_dma_x_count(sport->dma_rx_chan, 0); - set_dma_x_modify(sport->dma_rx_chan, 0); - set_dma_config(sport->dma_rx_chan, (DMAFLOW_LARGE | NDSIZE_9 | \ - WDSIZE_32 | WNR)); - set_dma_curr_addr(sport->dma_rx_chan, sport->curr_rx_desc->start_addr); - SSYNC(); - - return 0; -} - -static inline int sport_tx_dma_start(struct sport_device *sport, int dummy) -{ - if (dummy) { - sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc; - sport->curr_tx_desc = sport->dummy_tx_desc; - } else - sport->curr_tx_desc = sport->dma_tx_desc; - - set_dma_next_desc_addr(sport->dma_tx_chan, sport->curr_tx_desc); - set_dma_x_count(sport->dma_tx_chan, 0); - set_dma_x_modify(sport->dma_tx_chan, 0); - set_dma_config(sport->dma_tx_chan, - (DMAFLOW_LARGE | NDSIZE_9 | WDSIZE_32)); - set_dma_curr_addr(sport->dma_tx_chan, sport->curr_tx_desc->start_addr); - SSYNC(); - - return 0; -} - -int sport_rx_start(struct sport_device *sport) -{ - unsigned long flags; - pr_debug("%s enter\n", __func__); - if (sport->rx_run) - return -EBUSY; - if (sport->tx_run) { - /* tx is running, rx is not running */ - if (WARN_ON(!sport->dma_rx_desc) || - WARN_ON(sport->curr_rx_desc != sport->dummy_rx_desc)) - return -EINVAL; - local_irq_save(flags); - while ((get_dma_curr_desc_ptr(sport->dma_rx_chan) - - sizeof(struct dmasg)) != sport->dummy_rx_desc) - continue; - sport->dummy_rx_desc->next_desc_addr = sport->dma_rx_desc; - local_irq_restore(flags); - sport->curr_rx_desc = sport->dma_rx_desc; - } else { - sport_tx_dma_start(sport, 1); - sport_rx_dma_start(sport, 0); - sport_start(sport); - } - - sport->rx_run = 1; - - return 0; -} -EXPORT_SYMBOL(sport_rx_start); - -int sport_rx_stop(struct sport_device *sport) -{ - pr_debug("%s enter\n", __func__); - - if (!sport->rx_run) - return 0; - if (sport->tx_run) { - /* TX dma is still running, hook the dummy buffer */ - sport_hook_rx_dummy(sport); - } else { - /* Both rx and tx dma will be stopped */ - sport_stop(sport); - sport->curr_rx_desc = NULL; - sport->curr_tx_desc = NULL; - } - - sport->rx_run = 0; - - return 0; -} -EXPORT_SYMBOL(sport_rx_stop); - -static inline int sport_hook_tx_dummy(struct sport_device *sport) -{ - struct dmasg *desc, temp_desc; - unsigned long flags; - - if (WARN_ON(!sport->dummy_tx_desc) || - WARN_ON(sport->curr_tx_desc == sport->dummy_tx_desc)) - return -EINVAL; - - sport->dummy_tx_desc->next_desc_addr = sport->dummy_tx_desc + 1; - - /* Shorten the time on last normal descriptor */ - local_irq_save(flags); - desc = get_dma_next_desc_ptr(sport->dma_tx_chan); - /* Store the descriptor which will be damaged */ - temp_desc = *desc; - desc->x_count = sport->dummy_count / 2; - desc->y_count = 0; - desc->next_desc_addr = sport->dummy_tx_desc; - local_irq_restore(flags); - /* Waiting for dummy buffer descriptor is already hooked*/ - while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - \ - sizeof(struct dmasg)) != sport->dummy_tx_desc) - continue; - sport->curr_tx_desc = sport->dummy_tx_desc; - /* Restore the damaged descriptor */ - *desc = temp_desc; - - return 0; -} - -int sport_tx_start(struct sport_device *sport) -{ - unsigned long flags; - pr_debug("%s: tx_run:%d, rx_run:%d\n", __func__, - sport->tx_run, sport->rx_run); - if (sport->tx_run) - return -EBUSY; - if (sport->rx_run) { - if (WARN_ON(!sport->dma_tx_desc) || - WARN_ON(sport->curr_tx_desc != sport->dummy_tx_desc)) - return -EINVAL; - /* Hook the normal buffer descriptor */ - local_irq_save(flags); - while ((get_dma_curr_desc_ptr(sport->dma_tx_chan) - - sizeof(struct dmasg)) != sport->dummy_tx_desc) - continue; - sport->dummy_tx_desc->next_desc_addr = sport->dma_tx_desc; - local_irq_restore(flags); - sport->curr_tx_desc = sport->dma_tx_desc; - } else { - - sport_tx_dma_start(sport, 0); - /* Let rx dma run the dummy buffer */ - sport_rx_dma_start(sport, 1); - sport_start(sport); - } - sport->tx_run = 1; - return 0; -} -EXPORT_SYMBOL(sport_tx_start); - -int sport_tx_stop(struct sport_device *sport) -{ - if (!sport->tx_run) - return 0; - if (sport->rx_run) { - /* RX is still running, hook the dummy buffer */ - sport_hook_tx_dummy(sport); - } else { - /* Both rx and tx dma stopped */ - sport_stop(sport); - sport->curr_rx_desc = NULL; - sport->curr_tx_desc = NULL; - } - - sport->tx_run = 0; - - return 0; -} -EXPORT_SYMBOL(sport_tx_stop); - -static inline int compute_wdsize(size_t wdsize) -{ - switch (wdsize) { - case 1: - return WDSIZE_8; - case 2: - return WDSIZE_16; - case 4: - default: - return WDSIZE_32; - } -} - -int sport_config_rx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize) -{ - unsigned int x_count; - unsigned int y_count; - unsigned int cfg; - dma_addr_t addr; - - pr_debug("%s buf:%p, frag:%d, fragsize:0x%lx\n", __func__, \ - buf, fragcount, fragsize); - - x_count = fragsize / sport->wdsize; - y_count = 0; - - /* for fragments larger than 64k words we use 2d dma, - * denote fragecount as two numbers' mutliply and both of them - * are less than 64k.*/ - if (x_count >= 0x10000) { - int i, count = x_count; - - for (i = 16; i > 0; i--) { - x_count = 1 << i; - if ((count & (x_count - 1)) == 0) { - y_count = count >> i; - if (y_count < 0x10000) - break; - } - } - if (i == 0) - return -EINVAL; - } - pr_debug("%s(x_count:0x%x, y_count:0x%x)\n", __func__, - x_count, y_count); - - if (sport->dma_rx_desc) - dma_free_coherent(NULL, sport->rx_desc_bytes, - sport->dma_rx_desc, 0); - - /* Allocate a new descritor ring as current one. */ - sport->dma_rx_desc = dma_alloc_coherent(NULL, \ - fragcount * sizeof(struct dmasg), &addr, 0); - sport->rx_desc_bytes = fragcount * sizeof(struct dmasg); - - if (!sport->dma_rx_desc) { - pr_err("Failed to allocate memory for rx desc\n"); - return -ENOMEM; - } - - sport->rx_buf = buf; - sport->rx_fragsize = fragsize; - sport->rx_frags = fragcount; - - cfg = 0x7000 | DI_EN | compute_wdsize(sport->wdsize) | WNR | \ - (DESC_ELEMENT_COUNT << 8); /* large descriptor mode */ - - if (y_count != 0) - cfg |= DMA2D; - - setup_desc(sport->dma_rx_desc, buf, fragcount, fragsize, - cfg|DMAEN, x_count, y_count, sport->wdsize); - - return 0; -} -EXPORT_SYMBOL(sport_config_rx_dma); - -int sport_config_tx_dma(struct sport_device *sport, void *buf, \ - int fragcount, size_t fragsize) -{ - unsigned int x_count; - unsigned int y_count; - unsigned int cfg; - dma_addr_t addr; - - pr_debug("%s buf:%p, fragcount:%d, fragsize:0x%lx\n", - __func__, buf, fragcount, fragsize); - - x_count = fragsize/sport->wdsize; - y_count = 0; - - /* for fragments larger than 64k words we use 2d dma, - * denote fragecount as two numbers' mutliply and both of them - * are less than 64k.*/ - if (x_count >= 0x10000) { - int i, count = x_count; - - for (i = 16; i > 0; i--) { - x_count = 1 << i; - if ((count & (x_count - 1)) == 0) { - y_count = count >> i; - if (y_count < 0x10000) - break; - } - } - if (i == 0) - return -EINVAL; - } - pr_debug("%s x_count:0x%x, y_count:0x%x\n", __func__, - x_count, y_count); - - - if (sport->dma_tx_desc) { - dma_free_coherent(NULL, sport->tx_desc_bytes, \ - sport->dma_tx_desc, 0); - } - - sport->dma_tx_desc = dma_alloc_coherent(NULL, \ - fragcount * sizeof(struct dmasg), &addr, 0); - sport->tx_desc_bytes = fragcount * sizeof(struct dmasg); - if (!sport->dma_tx_desc) { - pr_err("Failed to allocate memory for tx desc\n"); - return -ENOMEM; - } - - sport->tx_buf = buf; - sport->tx_fragsize = fragsize; - sport->tx_frags = fragcount; - cfg = 0x7000 | DI_EN | compute_wdsize(sport->wdsize) | \ - (DESC_ELEMENT_COUNT << 8); /* large descriptor mode */ - - if (y_count != 0) - cfg |= DMA2D; - - setup_desc(sport->dma_tx_desc, buf, fragcount, fragsize, - cfg|DMAEN, x_count, y_count, sport->wdsize); - - return 0; -} -EXPORT_SYMBOL(sport_config_tx_dma); - -/* setup dummy dma descriptor ring, which don't generate interrupts, - * the x_modify is set to 0 */ -static int sport_config_rx_dummy(struct sport_device *sport) -{ - struct dmasg *desc; - unsigned config; - - pr_debug("%s entered\n", __func__); - if (L1_DATA_A_LENGTH) - desc = l1_data_sram_zalloc(2 * sizeof(*desc)); - else { - dma_addr_t addr; - desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); - memset(desc, 0, 2 * sizeof(*desc)); - } - if (desc == NULL) { - pr_err("Failed to allocate memory for dummy rx desc\n"); - return -ENOMEM; - } - sport->dummy_rx_desc = desc; - desc->start_addr = (unsigned long)sport->dummy_buf; - config = DMAFLOW_LARGE | NDSIZE_9 | compute_wdsize(sport->wdsize) - | WNR | DMAEN; - desc->cfg = config; - desc->x_count = sport->dummy_count/sport->wdsize; - desc->x_modify = sport->wdsize; - desc->y_count = 0; - desc->y_modify = 0; - memcpy(desc+1, desc, sizeof(*desc)); - desc->next_desc_addr = desc + 1; - desc[1].next_desc_addr = desc; - return 0; -} - -static int sport_config_tx_dummy(struct sport_device *sport) -{ - struct dmasg *desc; - unsigned int config; - - pr_debug("%s entered\n", __func__); - - if (L1_DATA_A_LENGTH) - desc = l1_data_sram_zalloc(2 * sizeof(*desc)); - else { - dma_addr_t addr; - desc = dma_alloc_coherent(NULL, 2 * sizeof(*desc), &addr, 0); - memset(desc, 0, 2 * sizeof(*desc)); - } - if (!desc) { - pr_err("Failed to allocate memory for dummy tx desc\n"); - return -ENOMEM; - } - sport->dummy_tx_desc = desc; - desc->start_addr = (unsigned long)sport->dummy_buf + \ - sport->dummy_count; - config = DMAFLOW_LARGE | NDSIZE_9 | - compute_wdsize(sport->wdsize) | DMAEN; - desc->cfg = config; - desc->x_count = sport->dummy_count/sport->wdsize; - desc->x_modify = sport->wdsize; - desc->y_count = 0; - desc->y_modify = 0; - memcpy(desc+1, desc, sizeof(*desc)); - desc->next_desc_addr = desc + 1; - desc[1].next_desc_addr = desc; - return 0; -} - -unsigned long sport_curr_offset_rx(struct sport_device *sport) -{ - unsigned long curr = get_dma_curr_addr(sport->dma_rx_chan); - - return (unsigned char *)curr - sport->rx_buf; -} -EXPORT_SYMBOL(sport_curr_offset_rx); - -unsigned long sport_curr_offset_tx(struct sport_device *sport) -{ - unsigned long curr = get_dma_curr_addr(sport->dma_tx_chan); - - return (unsigned char *)curr - sport->tx_buf; -} -EXPORT_SYMBOL(sport_curr_offset_tx); - -void sport_incfrag(struct sport_device *sport, int *frag, int tx) -{ - ++(*frag); - if (tx == 1 && *frag == sport->tx_frags) - *frag = 0; - - if (tx == 0 && *frag == sport->rx_frags) - *frag = 0; -} -EXPORT_SYMBOL(sport_incfrag); - -void sport_decfrag(struct sport_device *sport, int *frag, int tx) -{ - --(*frag); - if (tx == 1 && *frag == 0) - *frag = sport->tx_frags; - - if (tx == 0 && *frag == 0) - *frag = sport->rx_frags; -} -EXPORT_SYMBOL(sport_decfrag); - -static int sport_check_status(struct sport_device *sport, - unsigned int *sport_stat, - unsigned int *rx_stat, - unsigned int *tx_stat) -{ - int status = 0; - - if (sport_stat) { - SSYNC(); - status = sport->regs->stat; - if (status & (TOVF|TUVF|ROVF|RUVF)) - sport->regs->stat = (status & (TOVF|TUVF|ROVF|RUVF)); - SSYNC(); - *sport_stat = status; - } - - if (rx_stat) { - SSYNC(); - status = get_dma_curr_irqstat(sport->dma_rx_chan); - if (status & (DMA_DONE|DMA_ERR)) - clear_dma_irqstat(sport->dma_rx_chan); - SSYNC(); - *rx_stat = status; - } - - if (tx_stat) { - SSYNC(); - status = get_dma_curr_irqstat(sport->dma_tx_chan); - if (status & (DMA_DONE|DMA_ERR)) - clear_dma_irqstat(sport->dma_tx_chan); - SSYNC(); - *tx_stat = status; - } - - return 0; -} - -int sport_dump_stat(struct sport_device *sport, char *buf, size_t len) -{ - int ret; - - ret = snprintf(buf, len, - "sts: 0x%04x\n" - "rx dma %d sts: 0x%04x tx dma %d sts: 0x%04x\n", - sport->regs->stat, - sport->dma_rx_chan, - get_dma_curr_irqstat(sport->dma_rx_chan), - sport->dma_tx_chan, - get_dma_curr_irqstat(sport->dma_tx_chan)); - buf += ret; - len -= ret; - - ret += snprintf(buf, len, - "curr_rx_desc:0x%p, curr_tx_desc:0x%p\n" - "dma_rx_desc:0x%p, dma_tx_desc:0x%p\n" - "dummy_rx_desc:0x%p, dummy_tx_desc:0x%p\n", - sport->curr_rx_desc, sport->curr_tx_desc, - sport->dma_rx_desc, sport->dma_tx_desc, - sport->dummy_rx_desc, sport->dummy_tx_desc); - - return ret; -} - -static irqreturn_t rx_handler(int irq, void *dev_id) -{ - unsigned int rx_stat; - struct sport_device *sport = dev_id; - - pr_debug("%s enter\n", __func__); - sport_check_status(sport, NULL, &rx_stat, NULL); - if (!(rx_stat & DMA_DONE)) - pr_err("rx dma is already stopped\n"); - - if (sport->rx_callback) { - sport->rx_callback(sport->rx_data); - return IRQ_HANDLED; - } - - return IRQ_NONE; -} - -static irqreturn_t tx_handler(int irq, void *dev_id) -{ - unsigned int tx_stat; - struct sport_device *sport = dev_id; - pr_debug("%s enter\n", __func__); - sport_check_status(sport, NULL, NULL, &tx_stat); - if (!(tx_stat & DMA_DONE)) { - pr_err("tx dma is already stopped\n"); - return IRQ_HANDLED; - } - if (sport->tx_callback) { - sport->tx_callback(sport->tx_data); - return IRQ_HANDLED; - } - - return IRQ_NONE; -} - -static irqreturn_t err_handler(int irq, void *dev_id) -{ - unsigned int status = 0; - struct sport_device *sport = dev_id; - - pr_debug("%s\n", __func__); - if (sport_check_status(sport, &status, NULL, NULL)) { - pr_err("error checking status ??"); - return IRQ_NONE; - } - - if (status & (TOVF|TUVF|ROVF|RUVF)) { - pr_info("sport status error:%s%s%s%s\n", - status & TOVF ? " TOVF" : "", - status & TUVF ? " TUVF" : "", - status & ROVF ? " ROVF" : "", - status & RUVF ? " RUVF" : ""); - if (status & TOVF || status & TUVF) { - disable_dma(sport->dma_tx_chan); - if (sport->tx_run) - sport_tx_dma_start(sport, 0); - else - sport_tx_dma_start(sport, 1); - enable_dma(sport->dma_tx_chan); - } else { - disable_dma(sport->dma_rx_chan); - if (sport->rx_run) - sport_rx_dma_start(sport, 0); - else - sport_rx_dma_start(sport, 1); - enable_dma(sport->dma_rx_chan); - } - } - status = sport->regs->stat; - if (status & (TOVF|TUVF|ROVF|RUVF)) - sport->regs->stat = (status & (TOVF|TUVF|ROVF|RUVF)); - SSYNC(); - - if (sport->err_callback) - sport->err_callback(sport->err_data); - - return IRQ_HANDLED; -} - -int sport_set_rx_callback(struct sport_device *sport, - void (*rx_callback)(void *), void *rx_data) -{ - if (WARN_ON(!rx_callback)) - return -EINVAL; - sport->rx_callback = rx_callback; - sport->rx_data = rx_data; - - return 0; -} -EXPORT_SYMBOL(sport_set_rx_callback); - -int sport_set_tx_callback(struct sport_device *sport, - void (*tx_callback)(void *), void *tx_data) -{ - if (WARN_ON(!tx_callback)) - return -EINVAL; - sport->tx_callback = tx_callback; - sport->tx_data = tx_data; - - return 0; -} -EXPORT_SYMBOL(sport_set_tx_callback); - -int sport_set_err_callback(struct sport_device *sport, - void (*err_callback)(void *), void *err_data) -{ - if (WARN_ON(!err_callback)) - return -EINVAL; - sport->err_callback = err_callback; - sport->err_data = err_data; - - return 0; -} -EXPORT_SYMBOL(sport_set_err_callback); - -static int sport_config_pdev(struct platform_device *pdev, struct sport_param *param) -{ - /* Extract settings from platform data */ - struct device *dev = &pdev->dev; - struct bfin_snd_platform_data *pdata = dev->platform_data; - struct resource *res; - - param->num = pdev->id; - - if (!pdata) { - dev_err(dev, "no platform_data\n"); - return -ENODEV; - } - param->pin_req = pdata->pin_req; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "no MEM resource\n"); - return -ENODEV; - } - param->regs = (struct sport_register *)res->start; - - /* first RX, then TX */ - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!res) { - dev_err(dev, "no rx DMA resource\n"); - return -ENODEV; - } - param->dma_rx_chan = res->start; - - res = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!res) { - dev_err(dev, "no tx DMA resource\n"); - return -ENODEV; - } - param->dma_tx_chan = res->start; - - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!res) { - dev_err(dev, "no irq resource\n"); - return -ENODEV; - } - param->err_irq = res->start; - - return 0; -} - -struct sport_device *sport_init(struct platform_device *pdev, - unsigned int wdsize, unsigned int dummy_count, size_t priv_size) -{ - struct device *dev = &pdev->dev; - struct sport_param param; - struct sport_device *sport; - int ret; - - dev_dbg(dev, "%s enter\n", __func__); - - param.wdsize = wdsize; - param.dummy_count = dummy_count; - if (WARN_ON(param.wdsize == 0 || param.dummy_count == 0)) - return NULL; - - ret = sport_config_pdev(pdev, ¶m); - if (ret) - return NULL; - - if (peripheral_request_list(param.pin_req, "soc-audio")) { - dev_err(dev, "requesting Peripherals failed\n"); - return NULL; - } - - sport = kzalloc(sizeof(*sport), GFP_KERNEL); - if (!sport) { - dev_err(dev, "failed to allocate for sport device\n"); - goto __init_err0; - } - - sport->num = param.num; - sport->dma_rx_chan = param.dma_rx_chan; - sport->dma_tx_chan = param.dma_tx_chan; - sport->err_irq = param.err_irq; - sport->regs = param.regs; - sport->pin_req = param.pin_req; - - if (request_dma(sport->dma_rx_chan, "SPORT RX Data") == -EBUSY) { - dev_err(dev, "failed to request RX dma %d\n", sport->dma_rx_chan); - goto __init_err1; - } - if (set_dma_callback(sport->dma_rx_chan, rx_handler, sport) != 0) { - dev_err(dev, "failed to request RX irq %d\n", sport->dma_rx_chan); - goto __init_err2; - } - - if (request_dma(sport->dma_tx_chan, "SPORT TX Data") == -EBUSY) { - dev_err(dev, "failed to request TX dma %d\n", sport->dma_tx_chan); - goto __init_err2; - } - - if (set_dma_callback(sport->dma_tx_chan, tx_handler, sport) != 0) { - dev_err(dev, "failed to request TX irq %d\n", sport->dma_tx_chan); - goto __init_err3; - } - - if (request_irq(sport->err_irq, err_handler, IRQF_SHARED, "SPORT err", - sport) < 0) { - dev_err(dev, "failed to request err irq %d\n", sport->err_irq); - goto __init_err3; - } - - dev_info(dev, "dma rx:%d tx:%d, err irq:%d, regs:%p\n", - sport->dma_rx_chan, sport->dma_tx_chan, - sport->err_irq, sport->regs); - - sport->wdsize = param.wdsize; - sport->dummy_count = param.dummy_count; - - sport->private_data = kzalloc(priv_size, GFP_KERNEL); - if (!sport->private_data) { - dev_err(dev, "could not alloc priv data %zu bytes\n", priv_size); - goto __init_err4; - } - - if (L1_DATA_A_LENGTH) - sport->dummy_buf = l1_data_sram_zalloc(param.dummy_count * 2); - else - sport->dummy_buf = kzalloc(param.dummy_count * 2, GFP_KERNEL); - if (sport->dummy_buf == NULL) { - dev_err(dev, "failed to allocate dummy buffer\n"); - goto __error1; - } - - ret = sport_config_rx_dummy(sport); - if (ret) { - dev_err(dev, "failed to config rx dummy ring\n"); - goto __error2; - } - ret = sport_config_tx_dummy(sport); - if (ret) { - dev_err(dev, "failed to config tx dummy ring\n"); - goto __error3; - } - - platform_set_drvdata(pdev, sport); - - return sport; -__error3: - if (L1_DATA_A_LENGTH) - l1_data_sram_free(sport->dummy_rx_desc); - else - dma_free_coherent(NULL, 2*sizeof(struct dmasg), - sport->dummy_rx_desc, 0); -__error2: - if (L1_DATA_A_LENGTH) - l1_data_sram_free(sport->dummy_buf); - else - kfree(sport->dummy_buf); -__error1: - kfree(sport->private_data); -__init_err4: - free_irq(sport->err_irq, sport); -__init_err3: - free_dma(sport->dma_tx_chan); -__init_err2: - free_dma(sport->dma_rx_chan); -__init_err1: - kfree(sport); -__init_err0: - peripheral_free_list(param.pin_req); - return NULL; -} -EXPORT_SYMBOL(sport_init); - -void sport_done(struct sport_device *sport) -{ - if (sport == NULL) - return; - - sport_stop(sport); - if (sport->dma_rx_desc) - dma_free_coherent(NULL, sport->rx_desc_bytes, - sport->dma_rx_desc, 0); - if (sport->dma_tx_desc) - dma_free_coherent(NULL, sport->tx_desc_bytes, - sport->dma_tx_desc, 0); - -#if L1_DATA_A_LENGTH != 0 - l1_data_sram_free(sport->dummy_rx_desc); - l1_data_sram_free(sport->dummy_tx_desc); - l1_data_sram_free(sport->dummy_buf); -#else - dma_free_coherent(NULL, 2*sizeof(struct dmasg), - sport->dummy_rx_desc, 0); - dma_free_coherent(NULL, 2*sizeof(struct dmasg), - sport->dummy_tx_desc, 0); - kfree(sport->dummy_buf); -#endif - free_dma(sport->dma_rx_chan); - free_dma(sport->dma_tx_chan); - free_irq(sport->err_irq, sport); - - kfree(sport->private_data); - peripheral_free_list(sport->pin_req); - kfree(sport); -} -EXPORT_SYMBOL(sport_done); - -/* -* It is only used to send several bytes when dma is not enabled - * sport controller is configured but not enabled. - * Multichannel cannot works with pio mode */ -/* Used by ac97 to write and read codec register */ -int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \ - u8 *in_data, int len) -{ - unsigned short dma_config; - unsigned short status; - unsigned long flags; - unsigned long wait = 0; - - pr_debug("%s enter, out_data:%p, in_data:%p len:%d\n", \ - __func__, out_data, in_data, len); - pr_debug("tcr1:0x%04x, tcr2:0x%04x, tclkdiv:0x%04x, tfsdiv:0x%04x\n" - "mcmc1:0x%04x, mcmc2:0x%04x\n", - sport->regs->tcr1, sport->regs->tcr2, - sport->regs->tclkdiv, sport->regs->tfsdiv, - sport->regs->mcmc1, sport->regs->mcmc2); - flush_dcache_range((unsigned)out_data, (unsigned)(out_data + len)); - - /* Enable tx dma */ - dma_config = (RESTART | WDSIZE_16 | DI_EN); - set_dma_start_addr(sport->dma_tx_chan, (unsigned long)out_data); - set_dma_x_count(sport->dma_tx_chan, len/2); - set_dma_x_modify(sport->dma_tx_chan, 2); - set_dma_config(sport->dma_tx_chan, dma_config); - enable_dma(sport->dma_tx_chan); - - if (in_data != NULL) { - invalidate_dcache_range((unsigned)in_data, \ - (unsigned)(in_data + len)); - /* Enable rx dma */ - dma_config = (RESTART | WDSIZE_16 | WNR | DI_EN); - set_dma_start_addr(sport->dma_rx_chan, (unsigned long)in_data); - set_dma_x_count(sport->dma_rx_chan, len/2); - set_dma_x_modify(sport->dma_rx_chan, 2); - set_dma_config(sport->dma_rx_chan, dma_config); - enable_dma(sport->dma_rx_chan); - } - - local_irq_save(flags); - sport->regs->tcr1 |= TSPEN; - sport->regs->rcr1 |= RSPEN; - SSYNC(); - - status = get_dma_curr_irqstat(sport->dma_tx_chan); - while (status & DMA_RUN) { - udelay(1); - status = get_dma_curr_irqstat(sport->dma_tx_chan); - pr_debug("DMA status:0x%04x\n", status); - if (wait++ > 100) - goto __over; - } - status = sport->regs->stat; - wait = 0; - - while (!(status & TXHRE)) { - pr_debug("sport status:0x%04x\n", status); - udelay(1); - status = *(unsigned short *)&sport->regs->stat; - if (wait++ > 1000) - goto __over; - } - /* Wait for the last byte sent out */ - udelay(20); - pr_debug("sport status:0x%04x\n", status); - -__over: - sport->regs->tcr1 &= ~TSPEN; - sport->regs->rcr1 &= ~RSPEN; - SSYNC(); - disable_dma(sport->dma_tx_chan); - /* Clear the status */ - clear_dma_irqstat(sport->dma_tx_chan); - if (in_data != NULL) { - disable_dma(sport->dma_rx_chan); - clear_dma_irqstat(sport->dma_rx_chan); - } - SSYNC(); - local_irq_restore(flags); - - return 0; -} -EXPORT_SYMBOL(sport_send_and_recv); - -MODULE_AUTHOR("Roy Huang"); -MODULE_DESCRIPTION("SPORT driver for ADI Blackfin"); -MODULE_LICENSE("GPL"); diff --git a/sound/soc/blackfin/bf5xx-sport.h b/sound/soc/blackfin/bf5xx-sport.h deleted file mode 100644 index 9fc2192feb3b..000000000000 --- a/sound/soc/blackfin/bf5xx-sport.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * File: bf5xx_sport.h - * Based on: - * Author: Roy Huang - * - * Created: - * Description: - * - * Copyright 2004-2007 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#ifndef __BF5XX_SPORT_H__ -#define __BF5XX_SPORT_H__ - -#include -#include -#include -#include -#include -#include - -#define DESC_ELEMENT_COUNT 9 - -struct sport_device { - int num; - int dma_rx_chan; - int dma_tx_chan; - int err_irq; - const unsigned short *pin_req; - struct sport_register *regs; - - unsigned char *rx_buf; - unsigned char *tx_buf; - unsigned int rx_fragsize; - unsigned int tx_fragsize; - unsigned int rx_frags; - unsigned int tx_frags; - unsigned int wdsize; - - /* for dummy dma transfer */ - void *dummy_buf; - unsigned int dummy_count; - - /* DMA descriptor ring head of current audio stream*/ - struct dmasg *dma_rx_desc; - struct dmasg *dma_tx_desc; - unsigned int rx_desc_bytes; - unsigned int tx_desc_bytes; - - unsigned int rx_run:1; /* rx is running */ - unsigned int tx_run:1; /* tx is running */ - - struct dmasg *dummy_rx_desc; - struct dmasg *dummy_tx_desc; - - struct dmasg *curr_rx_desc; - struct dmasg *curr_tx_desc; - - int rx_curr_frag; - int tx_curr_frag; - - unsigned int rcr1; - unsigned int rcr2; - int rx_tdm_count; - - unsigned int tcr1; - unsigned int tcr2; - int tx_tdm_count; - - void (*rx_callback)(void *data); - void *rx_data; - void (*tx_callback)(void *data); - void *tx_data; - void (*err_callback)(void *data); - void *err_data; - unsigned char *tx_dma_buf; - unsigned char *rx_dma_buf; -#ifdef CONFIG_SND_BF5XX_MMAP_SUPPORT - dma_addr_t tx_dma_phy; - dma_addr_t rx_dma_phy; - int tx_pos;/*pcm sample count*/ - int rx_pos; - unsigned int tx_buffer_size; - unsigned int rx_buffer_size; - int tx_delay_pos; - int once; -#endif - void *private_data; -}; - -struct sport_param { - int num; - int dma_rx_chan; - int dma_tx_chan; - int err_irq; - const unsigned short *pin_req; - struct sport_register *regs; - unsigned int wdsize; - unsigned int dummy_count; - void *private_data; -}; - -struct sport_device *sport_init(struct platform_device *pdev, - unsigned int wdsize, unsigned int dummy_count, size_t priv_size); - -void sport_done(struct sport_device *sport); - -/* first use these ...*/ - -/* note: multichannel is in units of 8 channels, tdm_count is number of channels - * NOT / 8 ! all channels are enabled by default */ -int sport_set_multichannel(struct sport_device *sport, int tdm_count, - u32 tx_mask, u32 rx_mask, int packed); - -int sport_config_rx(struct sport_device *sport, - unsigned int rcr1, unsigned int rcr2, - unsigned int clkdiv, unsigned int fsdiv); - -int sport_config_tx(struct sport_device *sport, - unsigned int tcr1, unsigned int tcr2, - unsigned int clkdiv, unsigned int fsdiv); - -/* ... then these: */ - -/* buffer size (in bytes) == fragcount * fragsize_bytes */ - -/* this is not a very general api, it sets the dma to 2d autobuffer mode */ - -int sport_config_rx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize_bytes); - -int sport_config_tx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize_bytes); - -int sport_tx_start(struct sport_device *sport); -int sport_tx_stop(struct sport_device *sport); -int sport_rx_start(struct sport_device *sport); -int sport_rx_stop(struct sport_device *sport); - -/* for use in interrupt handler */ -unsigned long sport_curr_offset_rx(struct sport_device *sport); -unsigned long sport_curr_offset_tx(struct sport_device *sport); - -void sport_incfrag(struct sport_device *sport, int *frag, int tx); -void sport_decfrag(struct sport_device *sport, int *frag, int tx); - -int sport_set_rx_callback(struct sport_device *sport, - void (*rx_callback)(void *), void *rx_data); -int sport_set_tx_callback(struct sport_device *sport, - void (*tx_callback)(void *), void *tx_data); -int sport_set_err_callback(struct sport_device *sport, - void (*err_callback)(void *), void *err_data); - -int sport_send_and_recv(struct sport_device *sport, u8 *out_data, \ - u8 *in_data, int len); -#endif /* BF53X_SPORT_H */ diff --git a/sound/soc/blackfin/bf5xx-ssm2602.c b/sound/soc/blackfin/bf5xx-ssm2602.c deleted file mode 100644 index 9c19ccc936e2..000000000000 --- a/sound/soc/blackfin/bf5xx-ssm2602.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * File: sound/soc/blackfin/bf5xx-ssm2602.c - * Author: Cliff Cai - * - * Created: Tue June 06 2008 - * Description: board driver for SSM2602 sound chip - * - * Modified: - * Copyright 2008 Analog Devices Inc. - * - * Bugs: Enter bugs at http://blackfin.uclinux.org/ - * - * 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. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, see the file COPYING, or write - * to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include "../codecs/ssm2602.h" -#include "bf5xx-sport.h" - -static struct snd_soc_card bf5xx_ssm2602; - -static int bf5xx_ssm2602_dai_init(struct snd_soc_pcm_runtime *rtd) -{ - /* - * If you are using a crystal source which frequency is not 12MHz - * then modify the below case statement with frequency of the crystal. - * - * If you are using the SPORT to generate clocking then this is - * where to do it. - */ - return snd_soc_dai_set_sysclk(rtd->codec_dai, SSM2602_SYSCLK, 12000000, - SND_SOC_CLOCK_IN); -} - -/* CODEC is master for BCLK and LRC in this configuration. */ -#define BF5XX_SSM2602_DAIFMT (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | \ - SND_SOC_DAIFMT_CBM_CFM) - -static struct snd_soc_dai_link bf5xx_ssm2602_dai[] = { - { - .name = "ssm2602", - .stream_name = "SSM2602", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "ssm2602-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "ssm2602.0-001b", - .init = bf5xx_ssm2602_dai_init, - .dai_fmt = BF5XX_SSM2602_DAIFMT, - }, - { - .name = "ssm2602", - .stream_name = "SSM2602", - .cpu_dai_name = "bfin-i2s.1", - .codec_dai_name = "ssm2602-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "ssm2602.0-001b", - .init = bf5xx_ssm2602_dai_init, - .dai_fmt = BF5XX_SSM2602_DAIFMT, - }, -}; - -static struct snd_soc_card bf5xx_ssm2602 = { - .name = "bfin-ssm2602", - .owner = THIS_MODULE, - .dai_link = &bf5xx_ssm2602_dai[CONFIG_SND_BF5XX_SPORT_NUM], - .num_links = 1, -}; - -static struct platform_device *bf5xx_ssm2602_snd_device; - -static int __init bf5xx_ssm2602_init(void) -{ - int ret; - - pr_debug("%s enter\n", __func__); - bf5xx_ssm2602_snd_device = platform_device_alloc("soc-audio", -1); - if (!bf5xx_ssm2602_snd_device) - return -ENOMEM; - - platform_set_drvdata(bf5xx_ssm2602_snd_device, &bf5xx_ssm2602); - ret = platform_device_add(bf5xx_ssm2602_snd_device); - - if (ret) - platform_device_put(bf5xx_ssm2602_snd_device); - - return ret; -} - -static void __exit bf5xx_ssm2602_exit(void) -{ - pr_debug("%s enter\n", __func__); - platform_device_unregister(bf5xx_ssm2602_snd_device); -} - -module_init(bf5xx_ssm2602_init); -module_exit(bf5xx_ssm2602_exit); - -/* Module information */ -MODULE_AUTHOR("Cliff Cai"); -MODULE_DESCRIPTION("ALSA SoC SSM2602 BF527-EZKIT"); -MODULE_LICENSE("GPL"); - diff --git a/sound/soc/blackfin/bf6xx-i2s.c b/sound/soc/blackfin/bf6xx-i2s.c deleted file mode 100644 index 819cff149a25..000000000000 --- a/sound/soc/blackfin/bf6xx-i2s.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * bf6xx-i2s.c - Analog Devices BF6XX i2s interface driver - * - * Copyright (c) 2012 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "bf6xx-sport.h" - -struct sport_params param; - -static int bfin_i2s_set_dai_fmt(struct snd_soc_dai *cpu_dai, - unsigned int fmt) -{ - struct sport_device *sport = snd_soc_dai_get_drvdata(cpu_dai); - struct device *dev = &sport->pdev->dev; - int ret = 0; - - param.spctl &= ~(SPORT_CTL_OPMODE | SPORT_CTL_CKRE | SPORT_CTL_FSR - | SPORT_CTL_LFS | SPORT_CTL_LAFS); - switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { - case SND_SOC_DAIFMT_I2S: - param.spctl |= SPORT_CTL_OPMODE | SPORT_CTL_CKRE - | SPORT_CTL_LFS; - break; - case SND_SOC_DAIFMT_DSP_A: - param.spctl |= SPORT_CTL_FSR; - break; - case SND_SOC_DAIFMT_LEFT_J: - param.spctl |= SPORT_CTL_OPMODE | SPORT_CTL_LFS - | SPORT_CTL_LAFS; - break; - default: - dev_err(dev, "%s: Unknown DAI format type\n", __func__); - ret = -EINVAL; - break; - } - - param.spctl &= ~(SPORT_CTL_ICLK | SPORT_CTL_IFS); - switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { - case SND_SOC_DAIFMT_CBM_CFM: - break; - case SND_SOC_DAIFMT_CBS_CFS: - case SND_SOC_DAIFMT_CBM_CFS: - case SND_SOC_DAIFMT_CBS_CFM: - ret = -EINVAL; - break; - default: - dev_err(dev, "%s: Unknown DAI master type\n", __func__); - ret = -EINVAL; - break; - } - - return ret; -} - -static int bfin_i2s_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) -{ - struct sport_device *sport = snd_soc_dai_get_drvdata(dai); - struct device *dev = &sport->pdev->dev; - int ret = 0; - - param.spctl &= ~SPORT_CTL_SLEN; - switch (params_format(params)) { - case SNDRV_PCM_FORMAT_S8: - param.spctl |= 0x70; - sport->wdsize = 1; - break; - case SNDRV_PCM_FORMAT_S16_LE: - param.spctl |= 0xf0; - sport->wdsize = 2; - break; - case SNDRV_PCM_FORMAT_S24_LE: - param.spctl |= 0x170; - sport->wdsize = 3; - break; - case SNDRV_PCM_FORMAT_S32_LE: - param.spctl |= 0x1f0; - sport->wdsize = 4; - break; - } - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - ret = sport_set_tx_params(sport, ¶m); - if (ret) { - dev_err(dev, "SPORT tx is busy!\n"); - return ret; - } - } else { - ret = sport_set_rx_params(sport, ¶m); - if (ret) { - dev_err(dev, "SPORT rx is busy!\n"); - return ret; - } - } - return 0; -} - -#ifdef CONFIG_PM -static int bfin_i2s_suspend(struct snd_soc_dai *dai) -{ - struct sport_device *sport = snd_soc_dai_get_drvdata(dai); - - if (dai->capture_active) - sport_rx_stop(sport); - if (dai->playback_active) - sport_tx_stop(sport); - return 0; -} - -static int bfin_i2s_resume(struct snd_soc_dai *dai) -{ - struct sport_device *sport = snd_soc_dai_get_drvdata(dai); - struct device *dev = &sport->pdev->dev; - int ret; - - ret = sport_set_tx_params(sport, ¶m); - if (ret) { - dev_err(dev, "SPORT tx is busy!\n"); - return ret; - } - ret = sport_set_rx_params(sport, ¶m); - if (ret) { - dev_err(dev, "SPORT rx is busy!\n"); - return ret; - } - - return 0; -} - -#else -#define bfin_i2s_suspend NULL -#define bfin_i2s_resume NULL -#endif - -#define BFIN_I2S_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ - SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | \ - SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | \ - SNDRV_PCM_RATE_96000) - -#define BFIN_I2S_FORMATS (SNDRV_PCM_FMTBIT_S8 | SNDRV_PCM_FMTBIT_S16_LE | \ - SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) - -static const struct snd_soc_dai_ops bfin_i2s_dai_ops = { - .hw_params = bfin_i2s_hw_params, - .set_fmt = bfin_i2s_set_dai_fmt, -}; - -static struct snd_soc_dai_driver bfin_i2s_dai = { - .suspend = bfin_i2s_suspend, - .resume = bfin_i2s_resume, - .playback = { - .channels_min = 1, - .channels_max = 2, - .rates = BFIN_I2S_RATES, - .formats = BFIN_I2S_FORMATS, - }, - .capture = { - .channels_min = 1, - .channels_max = 2, - .rates = BFIN_I2S_RATES, - .formats = BFIN_I2S_FORMATS, - }, - .ops = &bfin_i2s_dai_ops, -}; - -static const struct snd_soc_component_driver bfin_i2s_component = { - .name = "bfin-i2s", -}; - -static int bfin_i2s_probe(struct platform_device *pdev) -{ - struct sport_device *sport; - struct device *dev = &pdev->dev; - int ret; - - sport = sport_create(pdev); - if (!sport) - return -ENODEV; - - /* register with the ASoC layers */ - ret = snd_soc_register_component(dev, &bfin_i2s_component, - &bfin_i2s_dai, 1); - if (ret) { - dev_err(dev, "Failed to register DAI: %d\n", ret); - sport_delete(sport); - return ret; - } - platform_set_drvdata(pdev, sport); - - return 0; -} - -static int bfin_i2s_remove(struct platform_device *pdev) -{ - struct sport_device *sport = platform_get_drvdata(pdev); - - snd_soc_unregister_component(&pdev->dev); - sport_delete(sport); - - return 0; -} - -static struct platform_driver bfin_i2s_driver = { - .probe = bfin_i2s_probe, - .remove = bfin_i2s_remove, - .driver = { - .name = "bfin-i2s", - }, -}; - -module_platform_driver(bfin_i2s_driver); - -MODULE_DESCRIPTION("Analog Devices BF6XX i2s interface driver"); -MODULE_AUTHOR("Scott Jiang "); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/blackfin/bf6xx-sport.c b/sound/soc/blackfin/bf6xx-sport.c deleted file mode 100644 index d2caadfe7b6d..000000000000 --- a/sound/soc/blackfin/bf6xx-sport.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - * bf6xx_sport.c Analog Devices BF6XX SPORT driver - * - * Copyright (c) 2012 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "bf6xx-sport.h" - -int sport_set_tx_params(struct sport_device *sport, - struct sport_params *params) -{ - if (sport->tx_regs->spctl & SPORT_CTL_SPENPRI) - return -EBUSY; - sport->tx_regs->spctl = params->spctl | SPORT_CTL_SPTRAN; - sport->tx_regs->div = params->div; - SSYNC(); - return 0; -} -EXPORT_SYMBOL(sport_set_tx_params); - -int sport_set_rx_params(struct sport_device *sport, - struct sport_params *params) -{ - if (sport->rx_regs->spctl & SPORT_CTL_SPENPRI) - return -EBUSY; - sport->rx_regs->spctl = params->spctl & ~SPORT_CTL_SPTRAN; - sport->rx_regs->div = params->div; - SSYNC(); - return 0; -} -EXPORT_SYMBOL(sport_set_rx_params); - -static int compute_wdsize(size_t wdsize) -{ - switch (wdsize) { - case 1: - return WDSIZE_8 | PSIZE_8; - case 2: - return WDSIZE_16 | PSIZE_16; - default: - return WDSIZE_32 | PSIZE_32; - } -} - -void sport_tx_start(struct sport_device *sport) -{ - set_dma_next_desc_addr(sport->tx_dma_chan, sport->tx_desc); - set_dma_config(sport->tx_dma_chan, DMAFLOW_LIST | DI_EN - | compute_wdsize(sport->wdsize) | NDSIZE_6); - enable_dma(sport->tx_dma_chan); - sport->tx_regs->spctl |= SPORT_CTL_SPENPRI; - SSYNC(); -} -EXPORT_SYMBOL(sport_tx_start); - -void sport_rx_start(struct sport_device *sport) -{ - set_dma_next_desc_addr(sport->rx_dma_chan, sport->rx_desc); - set_dma_config(sport->rx_dma_chan, DMAFLOW_LIST | DI_EN | WNR - | compute_wdsize(sport->wdsize) | NDSIZE_6); - enable_dma(sport->rx_dma_chan); - sport->rx_regs->spctl |= SPORT_CTL_SPENPRI; - SSYNC(); -} -EXPORT_SYMBOL(sport_rx_start); - -void sport_tx_stop(struct sport_device *sport) -{ - sport->tx_regs->spctl &= ~SPORT_CTL_SPENPRI; - SSYNC(); - disable_dma(sport->tx_dma_chan); -} -EXPORT_SYMBOL(sport_tx_stop); - -void sport_rx_stop(struct sport_device *sport) -{ - sport->rx_regs->spctl &= ~SPORT_CTL_SPENPRI; - SSYNC(); - disable_dma(sport->rx_dma_chan); -} -EXPORT_SYMBOL(sport_rx_stop); - -void sport_set_tx_callback(struct sport_device *sport, - void (*tx_callback)(void *), void *tx_data) -{ - sport->tx_callback = tx_callback; - sport->tx_data = tx_data; -} -EXPORT_SYMBOL(sport_set_tx_callback); - -void sport_set_rx_callback(struct sport_device *sport, - void (*rx_callback)(void *), void *rx_data) -{ - sport->rx_callback = rx_callback; - sport->rx_data = rx_data; -} -EXPORT_SYMBOL(sport_set_rx_callback); - -static void setup_desc(struct dmasg *desc, void *buf, int fragcount, - size_t fragsize, unsigned int cfg, - unsigned int count, size_t wdsize) -{ - - int i; - - for (i = 0; i < fragcount; ++i) { - desc[i].next_desc_addr = &(desc[i + 1]); - desc[i].start_addr = (unsigned long)buf + i * fragsize; - desc[i].cfg = cfg; - desc[i].x_count = count; - desc[i].x_modify = wdsize; - desc[i].y_count = 0; - desc[i].y_modify = 0; - } - - /* make circular */ - desc[fragcount - 1].next_desc_addr = desc; -} - -int sport_config_tx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize) -{ - unsigned int count; - unsigned int cfg; - dma_addr_t addr; - - count = fragsize / sport->wdsize; - - if (sport->tx_desc) - dma_free_coherent(NULL, sport->tx_desc_size, - sport->tx_desc, 0); - - sport->tx_desc = dma_alloc_coherent(NULL, - fragcount * sizeof(struct dmasg), &addr, 0); - sport->tx_desc_size = fragcount * sizeof(struct dmasg); - if (!sport->tx_desc) - return -ENOMEM; - - sport->tx_buf = buf; - sport->tx_fragsize = fragsize; - sport->tx_frags = fragcount; - cfg = DMAFLOW_LIST | DI_EN | compute_wdsize(sport->wdsize) | NDSIZE_6; - - setup_desc(sport->tx_desc, buf, fragcount, fragsize, - cfg | DMAEN, count, sport->wdsize); - return 0; -} -EXPORT_SYMBOL(sport_config_tx_dma); - -int sport_config_rx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize) -{ - unsigned int count; - unsigned int cfg; - dma_addr_t addr; - - count = fragsize / sport->wdsize; - - if (sport->rx_desc) - dma_free_coherent(NULL, sport->rx_desc_size, - sport->rx_desc, 0); - - sport->rx_desc = dma_alloc_coherent(NULL, - fragcount * sizeof(struct dmasg), &addr, 0); - sport->rx_desc_size = fragcount * sizeof(struct dmasg); - if (!sport->rx_desc) - return -ENOMEM; - - sport->rx_buf = buf; - sport->rx_fragsize = fragsize; - sport->rx_frags = fragcount; - cfg = DMAFLOW_LIST | DI_EN | compute_wdsize(sport->wdsize) - | WNR | NDSIZE_6; - - setup_desc(sport->rx_desc, buf, fragcount, fragsize, - cfg | DMAEN, count, sport->wdsize); - return 0; -} -EXPORT_SYMBOL(sport_config_rx_dma); - -unsigned long sport_curr_offset_tx(struct sport_device *sport) -{ - unsigned long curr = get_dma_curr_addr(sport->tx_dma_chan); - - return (unsigned char *)curr - sport->tx_buf; -} -EXPORT_SYMBOL(sport_curr_offset_tx); - -unsigned long sport_curr_offset_rx(struct sport_device *sport) -{ - unsigned long curr = get_dma_curr_addr(sport->rx_dma_chan); - - return (unsigned char *)curr - sport->rx_buf; -} -EXPORT_SYMBOL(sport_curr_offset_rx); - -static irqreturn_t sport_tx_irq(int irq, void *dev_id) -{ - struct sport_device *sport = dev_id; - static unsigned long status; - - status = get_dma_curr_irqstat(sport->tx_dma_chan); - if (status & (DMA_DONE | DMA_ERR)) { - clear_dma_irqstat(sport->tx_dma_chan); - SSYNC(); - } - if (sport->tx_callback) - sport->tx_callback(sport->tx_data); - return IRQ_HANDLED; -} - -static irqreturn_t sport_rx_irq(int irq, void *dev_id) -{ - struct sport_device *sport = dev_id; - unsigned long status; - - status = get_dma_curr_irqstat(sport->rx_dma_chan); - if (status & (DMA_DONE | DMA_ERR)) { - clear_dma_irqstat(sport->rx_dma_chan); - SSYNC(); - } - if (sport->rx_callback) - sport->rx_callback(sport->rx_data); - return IRQ_HANDLED; -} - -static irqreturn_t sport_err_irq(int irq, void *dev_id) -{ - struct sport_device *sport = dev_id; - struct device *dev = &sport->pdev->dev; - - if (sport->tx_regs->spctl & SPORT_CTL_DERRPRI) - dev_err(dev, "sport error: TUVF\n"); - if (sport->rx_regs->spctl & SPORT_CTL_DERRPRI) - dev_err(dev, "sport error: ROVF\n"); - - return IRQ_HANDLED; -} - -static int sport_get_resource(struct sport_device *sport) -{ - struct platform_device *pdev = sport->pdev; - struct device *dev = &pdev->dev; - struct bfin_snd_platform_data *pdata = dev->platform_data; - struct resource *res; - - if (!pdata) { - dev_err(dev, "No platform data\n"); - return -ENODEV; - } - sport->pin_req = pdata->pin_req; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "No tx MEM resource\n"); - return -ENODEV; - } - sport->tx_regs = (struct sport_register *)res->start; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!res) { - dev_err(dev, "No rx MEM resource\n"); - return -ENODEV; - } - sport->rx_regs = (struct sport_register *)res->start; - - res = platform_get_resource(pdev, IORESOURCE_DMA, 0); - if (!res) { - dev_err(dev, "No tx DMA resource\n"); - return -ENODEV; - } - sport->tx_dma_chan = res->start; - - res = platform_get_resource(pdev, IORESOURCE_DMA, 1); - if (!res) { - dev_err(dev, "No rx DMA resource\n"); - return -ENODEV; - } - sport->rx_dma_chan = res->start; - - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); - if (!res) { - dev_err(dev, "No tx error irq resource\n"); - return -ENODEV; - } - sport->tx_err_irq = res->start; - - res = platform_get_resource(pdev, IORESOURCE_IRQ, 1); - if (!res) { - dev_err(dev, "No rx error irq resource\n"); - return -ENODEV; - } - sport->rx_err_irq = res->start; - - return 0; -} - -static int sport_request_resource(struct sport_device *sport) -{ - struct device *dev = &sport->pdev->dev; - int ret; - - ret = peripheral_request_list(sport->pin_req, "soc-audio"); - if (ret) { - dev_err(dev, "Unable to request sport pin\n"); - return ret; - } - - ret = request_dma(sport->tx_dma_chan, "SPORT TX Data"); - if (ret) { - dev_err(dev, "Unable to allocate DMA channel for sport tx\n"); - goto err_tx_dma; - } - set_dma_callback(sport->tx_dma_chan, sport_tx_irq, sport); - - ret = request_dma(sport->rx_dma_chan, "SPORT RX Data"); - if (ret) { - dev_err(dev, "Unable to allocate DMA channel for sport rx\n"); - goto err_rx_dma; - } - set_dma_callback(sport->rx_dma_chan, sport_rx_irq, sport); - - ret = request_irq(sport->tx_err_irq, sport_err_irq, - 0, "SPORT TX ERROR", sport); - if (ret) { - dev_err(dev, "Unable to allocate tx error IRQ for sport\n"); - goto err_tx_irq; - } - - ret = request_irq(sport->rx_err_irq, sport_err_irq, - 0, "SPORT RX ERROR", sport); - if (ret) { - dev_err(dev, "Unable to allocate rx error IRQ for sport\n"); - goto err_rx_irq; - } - - return 0; -err_rx_irq: - free_irq(sport->tx_err_irq, sport); -err_tx_irq: - free_dma(sport->rx_dma_chan); -err_rx_dma: - free_dma(sport->tx_dma_chan); -err_tx_dma: - peripheral_free_list(sport->pin_req); - return ret; -} - -static void sport_free_resource(struct sport_device *sport) -{ - free_irq(sport->rx_err_irq, sport); - free_irq(sport->tx_err_irq, sport); - free_dma(sport->rx_dma_chan); - free_dma(sport->tx_dma_chan); - peripheral_free_list(sport->pin_req); -} - -struct sport_device *sport_create(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct sport_device *sport; - int ret; - - sport = kzalloc(sizeof(*sport), GFP_KERNEL); - if (!sport) - return NULL; - - sport->pdev = pdev; - - ret = sport_get_resource(sport); - if (ret) - goto free_data; - - ret = sport_request_resource(sport); - if (ret) - goto free_data; - - dev_dbg(dev, "SPORT create success\n"); - return sport; -free_data: - kfree(sport); - return NULL; -} -EXPORT_SYMBOL(sport_create); - -void sport_delete(struct sport_device *sport) -{ - if (sport->tx_desc) - dma_free_coherent(NULL, sport->tx_desc_size, - sport->tx_desc, 0); - if (sport->rx_desc) - dma_free_coherent(NULL, sport->rx_desc_size, - sport->rx_desc, 0); - sport_free_resource(sport); - kfree(sport); -} -EXPORT_SYMBOL(sport_delete); - -MODULE_DESCRIPTION("Analog Devices BF6XX SPORT driver"); -MODULE_AUTHOR("Scott Jiang "); -MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/blackfin/bf6xx-sport.h b/sound/soc/blackfin/bf6xx-sport.h deleted file mode 100644 index 307d193cfcef..000000000000 --- a/sound/soc/blackfin/bf6xx-sport.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * bf6xx_sport - Analog Devices BF6XX SPORT driver - * - * Copyright (c) 2012 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef _BF6XX_SPORT_H_ -#define _BF6XX_SPORT_H_ - -#include -#include - -struct sport_device { - struct platform_device *pdev; - const unsigned short *pin_req; - struct sport_register *tx_regs; - struct sport_register *rx_regs; - int tx_dma_chan; - int rx_dma_chan; - int tx_err_irq; - int rx_err_irq; - - void (*tx_callback)(void *data); - void *tx_data; - void (*rx_callback)(void *data); - void *rx_data; - - struct dmasg *tx_desc; - struct dmasg *rx_desc; - unsigned int tx_desc_size; - unsigned int rx_desc_size; - unsigned char *tx_buf; - unsigned char *rx_buf; - unsigned int tx_fragsize; - unsigned int rx_fragsize; - unsigned int tx_frags; - unsigned int rx_frags; - unsigned int wdsize; -}; - -struct sport_params { - u32 spctl; - u32 div; -}; - -struct sport_device *sport_create(struct platform_device *pdev); -void sport_delete(struct sport_device *sport); -int sport_set_tx_params(struct sport_device *sport, - struct sport_params *params); -int sport_set_rx_params(struct sport_device *sport, - struct sport_params *params); -void sport_tx_start(struct sport_device *sport); -void sport_rx_start(struct sport_device *sport); -void sport_tx_stop(struct sport_device *sport); -void sport_rx_stop(struct sport_device *sport); -void sport_set_tx_callback(struct sport_device *sport, - void (*tx_callback)(void *), void *tx_data); -void sport_set_rx_callback(struct sport_device *sport, - void (*rx_callback)(void *), void *rx_data); -int sport_config_tx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize); -int sport_config_rx_dma(struct sport_device *sport, void *buf, - int fragcount, size_t fragsize); -unsigned long sport_curr_offset_tx(struct sport_device *sport); -unsigned long sport_curr_offset_rx(struct sport_device *sport); - - - -#endif diff --git a/sound/soc/blackfin/bfin-eval-adau1373.c b/sound/soc/blackfin/bfin-eval-adau1373.c deleted file mode 100644 index 64b88fdc1f6c..000000000000 --- a/sound/soc/blackfin/bfin-eval-adau1373.c +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Machine driver for EVAL-ADAU1373 on Analog Devices bfin - * evaluation boards. - * - * Copyright 2011 Analog Devices Inc. - * Author: Lars-Peter Clausen - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include - -#include "../codecs/adau1373.h" - -static const struct snd_soc_dapm_widget bfin_eval_adau1373_dapm_widgets[] = { - SND_SOC_DAPM_LINE("Line In1", NULL), - SND_SOC_DAPM_LINE("Line In2", NULL), - SND_SOC_DAPM_LINE("Line In3", NULL), - SND_SOC_DAPM_LINE("Line In4", NULL), - - SND_SOC_DAPM_LINE("Line Out1", NULL), - SND_SOC_DAPM_LINE("Line Out2", NULL), - SND_SOC_DAPM_LINE("Stereo Out", NULL), - SND_SOC_DAPM_HP("Headphone", NULL), - SND_SOC_DAPM_HP("Earpiece", NULL), - SND_SOC_DAPM_SPK("Speaker", NULL), -}; - -static const struct snd_soc_dapm_route bfin_eval_adau1373_dapm_routes[] = { - { "AIN1L", NULL, "Line In1" }, - { "AIN1R", NULL, "Line In1" }, - { "AIN2L", NULL, "Line In2" }, - { "AIN2R", NULL, "Line In2" }, - { "AIN3L", NULL, "Line In3" }, - { "AIN3R", NULL, "Line In3" }, - { "AIN4L", NULL, "Line In4" }, - { "AIN4R", NULL, "Line In4" }, - - /* MICBIAS can be connected via a jumper to the line-in jack, since w - don't know which one is going to be used, just power both. */ - { "Line In1", NULL, "MICBIAS1" }, - { "Line In2", NULL, "MICBIAS1" }, - { "Line In3", NULL, "MICBIAS1" }, - { "Line In4", NULL, "MICBIAS1" }, - { "Line In1", NULL, "MICBIAS2" }, - { "Line In2", NULL, "MICBIAS2" }, - { "Line In3", NULL, "MICBIAS2" }, - { "Line In4", NULL, "MICBIAS2" }, - - { "Line Out1", NULL, "LOUT1L" }, - { "Line Out1", NULL, "LOUT1R" }, - { "Line Out2", NULL, "LOUT2L" }, - { "Line Out2", NULL, "LOUT2R" }, - { "Headphone", NULL, "HPL" }, - { "Headphone", NULL, "HPR" }, - { "Earpiece", NULL, "EP" }, - { "Speaker", NULL, "SPKL" }, - { "Stereo Out", NULL, "SPKR" }, -}; - -static int bfin_eval_adau1373_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; - int pll_rate; - - switch (params_rate(params)) { - case 48000: - case 8000: - case 12000: - case 16000: - case 24000: - case 32000: - pll_rate = 48000 * 1024; - break; - case 44100: - case 7350: - case 11025: - case 14700: - case 22050: - case 29400: - pll_rate = 44100 * 1024; - break; - default: - return -EINVAL; - } - - ret = snd_soc_dai_set_pll(codec_dai, ADAU1373_PLL1, - ADAU1373_PLL_SRC_MCLK1, 12288000, pll_rate); - if (ret) - return ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1373_CLK_SRC_PLL1, pll_rate, - SND_SOC_CLOCK_IN); - - return ret; -} - -static int bfin_eval_adau1373_codec_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai *codec_dai = rtd->codec_dai; - unsigned int pll_rate = 48000 * 1024; - int ret; - - ret = snd_soc_dai_set_pll(codec_dai, ADAU1373_PLL1, - ADAU1373_PLL_SRC_MCLK1, 12288000, pll_rate); - if (ret) - return ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1373_CLK_SRC_PLL1, pll_rate, - SND_SOC_CLOCK_IN); - - return ret; -} -static const struct snd_soc_ops bfin_eval_adau1373_ops = { - .hw_params = bfin_eval_adau1373_hw_params, -}; - -static struct snd_soc_dai_link bfin_eval_adau1373_dai = { - .name = "adau1373", - .stream_name = "adau1373", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "adau1373-aif1", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "adau1373.0-001a", - .ops = &bfin_eval_adau1373_ops, - .init = bfin_eval_adau1373_codec_init, - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM, -}; - -static struct snd_soc_card bfin_eval_adau1373 = { - .name = "bfin-eval-adau1373", - .owner = THIS_MODULE, - .dai_link = &bfin_eval_adau1373_dai, - .num_links = 1, - - .dapm_widgets = bfin_eval_adau1373_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1373_dapm_widgets), - .dapm_routes = bfin_eval_adau1373_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1373_dapm_routes), -}; - -static int bfin_eval_adau1373_probe(struct platform_device *pdev) -{ - struct snd_soc_card *card = &bfin_eval_adau1373; - - card->dev = &pdev->dev; - - return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1373); -} - -static struct platform_driver bfin_eval_adau1373_driver = { - .driver = { - .name = "bfin-eval-adau1373", - .pm = &snd_soc_pm_ops, - }, - .probe = bfin_eval_adau1373_probe, -}; - -module_platform_driver(bfin_eval_adau1373_driver); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("ALSA SoC bfin adau1373 driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:bfin-eval-adau1373"); diff --git a/sound/soc/blackfin/bfin-eval-adau1701.c b/sound/soc/blackfin/bfin-eval-adau1701.c deleted file mode 100644 index 5c67f72cf9a9..000000000000 --- a/sound/soc/blackfin/bfin-eval-adau1701.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Machine driver for EVAL-ADAU1701MINIZ on Analog Devices bfin - * evaluation boards. - * - * Copyright 2011 Analog Devices Inc. - * Author: Lars-Peter Clausen - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include - -#include "../codecs/adau1701.h" - -static const struct snd_soc_dapm_widget bfin_eval_adau1701_dapm_widgets[] = { - SND_SOC_DAPM_SPK("Speaker", NULL), - SND_SOC_DAPM_LINE("Line Out", NULL), - SND_SOC_DAPM_LINE("Line In", NULL), -}; - -static const struct snd_soc_dapm_route bfin_eval_adau1701_dapm_routes[] = { - { "Speaker", NULL, "OUT0" }, - { "Speaker", NULL, "OUT1" }, - { "Line Out", NULL, "OUT2" }, - { "Line Out", NULL, "OUT3" }, - - { "IN0", NULL, "Line In" }, - { "IN1", NULL, "Line In" }, -}; - -static int bfin_eval_adau1701_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, ADAU1701_CLK_SRC_OSC, 12288000, - SND_SOC_CLOCK_IN); - - return ret; -} - -static struct snd_soc_ops bfin_eval_adau1701_ops = { - .hw_params = bfin_eval_adau1701_hw_params, -}; - -#define BFIN_EVAL_ADAU1701_DAI_FMT (SND_SOC_DAIFMT_I2S | \ - SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM) - -static struct snd_soc_dai_link bfin_eval_adau1701_dai[] = { - { - .name = "adau1701", - .stream_name = "adau1701", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "adau1701", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "adau1701.0-0034", - .ops = &bfin_eval_adau1701_ops, - .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT, - }, - { - .name = "adau1701", - .stream_name = "adau1701", - .cpu_dai_name = "bfin-i2s.1", - .codec_dai_name = "adau1701", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "adau1701.0-0034", - .ops = &bfin_eval_adau1701_ops, - .dai_fmt = BFIN_EVAL_ADAU1701_DAI_FMT, - }, -}; - -static struct snd_soc_card bfin_eval_adau1701 = { - .name = "bfin-eval-adau1701", - .owner = THIS_MODULE, - .dai_link = &bfin_eval_adau1701_dai[CONFIG_SND_BF5XX_SPORT_NUM], - .num_links = 1, - - .dapm_widgets = bfin_eval_adau1701_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1701_dapm_widgets), - .dapm_routes = bfin_eval_adau1701_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1701_dapm_routes), -}; - -static int bfin_eval_adau1701_probe(struct platform_device *pdev) -{ - struct snd_soc_card *card = &bfin_eval_adau1701; - - card->dev = &pdev->dev; - - return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1701); -} - -static struct platform_driver bfin_eval_adau1701_driver = { - .driver = { - .name = "bfin-eval-adau1701", - .pm = &snd_soc_pm_ops, - }, - .probe = bfin_eval_adau1701_probe, -}; - -module_platform_driver(bfin_eval_adau1701_driver); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("ALSA SoC bfin ADAU1701 driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:bfin-eval-adau1701"); diff --git a/sound/soc/blackfin/bfin-eval-adau1x61.c b/sound/soc/blackfin/bfin-eval-adau1x61.c deleted file mode 100644 index fddfe00c9d69..000000000000 --- a/sound/soc/blackfin/bfin-eval-adau1x61.c +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Machine driver for EVAL-ADAU1x61MINIZ on Analog Devices bfin - * evaluation boards. - * - * Copyright 2011-2014 Analog Devices Inc. - * Author: Lars-Peter Clausen - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../codecs/adau17x1.h" - -static const struct snd_soc_dapm_widget bfin_eval_adau1x61_dapm_widgets[] = { - SND_SOC_DAPM_LINE("In 1", NULL), - SND_SOC_DAPM_LINE("In 2", NULL), - SND_SOC_DAPM_LINE("In 3-4", NULL), - - SND_SOC_DAPM_LINE("Diff Out L", NULL), - SND_SOC_DAPM_LINE("Diff Out R", NULL), - SND_SOC_DAPM_LINE("Stereo Out", NULL), - SND_SOC_DAPM_HP("Capless HP Out", NULL), -}; - -static const struct snd_soc_dapm_route bfin_eval_adau1x61_dapm_routes[] = { - { "LAUX", NULL, "In 3-4" }, - { "RAUX", NULL, "In 3-4" }, - { "LINP", NULL, "In 1" }, - { "LINN", NULL, "In 1"}, - { "RINP", NULL, "In 2" }, - { "RINN", NULL, "In 2" }, - - { "In 1", NULL, "MICBIAS" }, - { "In 2", NULL, "MICBIAS" }, - - { "Capless HP Out", NULL, "LHP" }, - { "Capless HP Out", NULL, "RHP" }, - { "Diff Out L", NULL, "LOUT" }, - { "Diff Out R", NULL, "ROUT" }, - { "Stereo Out", NULL, "LOUT" }, - { "Stereo Out", NULL, "ROUT" }, -}; - -static int bfin_eval_adau1x61_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int pll_rate; - int ret; - - switch (params_rate(params)) { - case 48000: - case 8000: - case 12000: - case 16000: - case 24000: - case 32000: - case 96000: - pll_rate = 48000 * 1024; - break; - case 44100: - case 7350: - case 11025: - case 14700: - case 22050: - case 29400: - case 88200: - pll_rate = 44100 * 1024; - break; - default: - return -EINVAL; - } - - ret = snd_soc_dai_set_pll(codec_dai, ADAU17X1_PLL, - ADAU17X1_PLL_SRC_MCLK, 12288000, pll_rate); - if (ret) - return ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, ADAU17X1_CLK_SRC_PLL, pll_rate, - SND_SOC_CLOCK_IN); - - return ret; -} - -static const struct snd_soc_ops bfin_eval_adau1x61_ops = { - .hw_params = bfin_eval_adau1x61_hw_params, -}; - -static struct snd_soc_dai_link bfin_eval_adau1x61_dai = { - .name = "adau1x61", - .stream_name = "adau1x61", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "adau-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "adau1761.0-0038", - .ops = &bfin_eval_adau1x61_ops, - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM, -}; - -static struct snd_soc_card bfin_eval_adau1x61 = { - .name = "bfin-eval-adau1x61", - .owner = THIS_MODULE, - .driver_name = "eval-adau1x61", - .dai_link = &bfin_eval_adau1x61_dai, - .num_links = 1, - - .dapm_widgets = bfin_eval_adau1x61_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1x61_dapm_widgets), - .dapm_routes = bfin_eval_adau1x61_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1x61_dapm_routes), - .fully_routed = true, -}; - -static int bfin_eval_adau1x61_probe(struct platform_device *pdev) -{ - bfin_eval_adau1x61.dev = &pdev->dev; - - return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1x61); -} - -static struct platform_driver bfin_eval_adau1x61_driver = { - .driver = { - .name = "bfin-eval-adau1x61", - .pm = &snd_soc_pm_ops, - }, - .probe = bfin_eval_adau1x61_probe, -}; -module_platform_driver(bfin_eval_adau1x61_driver); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("ALSA SoC bfin adau1x61 driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:bfin-eval-adau1x61"); diff --git a/sound/soc/blackfin/bfin-eval-adau1x81.c b/sound/soc/blackfin/bfin-eval-adau1x81.c deleted file mode 100644 index 3e01cbe53fc7..000000000000 --- a/sound/soc/blackfin/bfin-eval-adau1x81.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Machine driver for EVAL-ADAU1x81 on Analog Devices bfin - * evaluation boards. - * - * Copyright 2011-2014 Analog Devices Inc. - * Author: Lars-Peter Clausen - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "../codecs/adau17x1.h" - -static const struct snd_soc_dapm_widget bfin_eval_adau1x81_dapm_widgets[] = { - SND_SOC_DAPM_LINE("Stereo In", NULL), - SND_SOC_DAPM_LINE("Beep", NULL), - - SND_SOC_DAPM_SPK("Speaker", NULL), - SND_SOC_DAPM_HP("Headphone", NULL), -}; - -static const struct snd_soc_dapm_route bfin_eval_adau1x81_dapm_routes[] = { - { "BEEP", NULL, "Beep" }, - { "LMIC", NULL, "Stereo In" }, - { "LMIC", NULL, "Stereo In" }, - - { "Headphone", NULL, "AOUTL" }, - { "Headphone", NULL, "AOUTR" }, - { "Speaker", NULL, "SP" }, -}; - -static int bfin_eval_adau1x81_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int pll_rate; - int ret; - - switch (params_rate(params)) { - case 48000: - case 8000: - case 12000: - case 16000: - case 24000: - case 32000: - case 96000: - pll_rate = 48000 * 1024; - break; - case 44100: - case 7350: - case 11025: - case 14700: - case 22050: - case 29400: - case 88200: - pll_rate = 44100 * 1024; - break; - default: - return -EINVAL; - } - - ret = snd_soc_dai_set_pll(codec_dai, ADAU17X1_PLL, - ADAU17X1_PLL_SRC_MCLK, 12288000, pll_rate); - if (ret) - return ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, ADAU17X1_CLK_SRC_PLL, pll_rate, - SND_SOC_CLOCK_IN); - - return ret; -} - -static const struct snd_soc_ops bfin_eval_adau1x81_ops = { - .hw_params = bfin_eval_adau1x81_hw_params, -}; - -static struct snd_soc_dai_link bfin_eval_adau1x81_dai = { - .name = "adau1x81", - .stream_name = "adau1x81", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "adau-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .codec_name = "adau1781.0-0038", - .ops = &bfin_eval_adau1x81_ops, - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM, -}; - -static struct snd_soc_card bfin_eval_adau1x81 = { - .name = "bfin-eval-adau1x81", - .driver_name = "eval-adau1x81", - .dai_link = &bfin_eval_adau1x81_dai, - .num_links = 1, - - .dapm_widgets = bfin_eval_adau1x81_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adau1x81_dapm_widgets), - .dapm_routes = bfin_eval_adau1x81_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(bfin_eval_adau1x81_dapm_routes), - .fully_routed = true, -}; - -static int bfin_eval_adau1x81_probe(struct platform_device *pdev) -{ - bfin_eval_adau1x81.dev = &pdev->dev; - - return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adau1x81); -} - -static struct platform_driver bfin_eval_adau1x81_driver = { - .driver = { - .name = "bfin-eval-adau1x81", - .pm = &snd_soc_pm_ops, - }, - .probe = bfin_eval_adau1x81_probe, -}; -module_platform_driver(bfin_eval_adau1x81_driver); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("ALSA SoC bfin adau1x81 driver"); -MODULE_LICENSE("GPL"); -MODULE_ALIAS("platform:bfin-eval-adau1x81"); diff --git a/sound/soc/blackfin/bfin-eval-adav80x.c b/sound/soc/blackfin/bfin-eval-adav80x.c deleted file mode 100644 index 99e5ecabdcda..000000000000 --- a/sound/soc/blackfin/bfin-eval-adav80x.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Machine driver for EVAL-ADAV801 and EVAL-ADAV803 on Analog Devices bfin - * evaluation boards. - * - * Copyright 2011 Analog Devices Inc. - * Author: Lars-Peter Clausen - * - * Licensed under the GPL-2 or later. - */ - -#include -#include -#include -#include -#include -#include - -#include "../codecs/adav80x.h" - -static const struct snd_soc_dapm_widget bfin_eval_adav80x_dapm_widgets[] = { - SND_SOC_DAPM_LINE("Line Out", NULL), - SND_SOC_DAPM_LINE("Line In", NULL), -}; - -static const struct snd_soc_dapm_route bfin_eval_adav80x_dapm_routes[] = { - { "Line Out", NULL, "VOUTL" }, - { "Line Out", NULL, "VOUTR" }, - - { "VINL", NULL, "Line In" }, - { "VINR", NULL, "Line In" }, -}; - -static int bfin_eval_adav80x_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_dai *codec_dai = rtd->codec_dai; - int ret; - - ret = snd_soc_dai_set_pll(codec_dai, ADAV80X_PLL1, ADAV80X_PLL_SRC_XTAL, - 27000000, params_rate(params) * 256); - if (ret) - return ret; - - ret = snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_PLL1, - params_rate(params) * 256, SND_SOC_CLOCK_IN); - - return ret; -} - -static int bfin_eval_adav80x_codec_init(struct snd_soc_pcm_runtime *rtd) -{ - struct snd_soc_dai *codec_dai = rtd->codec_dai; - - snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK1, 0, - SND_SOC_CLOCK_OUT); - snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK2, 0, - SND_SOC_CLOCK_OUT); - snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_SYSCLK3, 0, - SND_SOC_CLOCK_OUT); - - snd_soc_dai_set_sysclk(codec_dai, ADAV80X_CLK_XTAL, 2700000, 0); - - return 0; -} - -static const struct snd_soc_ops bfin_eval_adav80x_ops = { - .hw_params = bfin_eval_adav80x_hw_params, -}; - -static struct snd_soc_dai_link bfin_eval_adav80x_dais[] = { - { - .name = "adav80x", - .stream_name = "ADAV80x HiFi", - .cpu_dai_name = "bfin-i2s.0", - .codec_dai_name = "adav80x-hifi", - .platform_name = "bfin-i2s-pcm-audio", - .init = bfin_eval_adav80x_codec_init, - .ops = &bfin_eval_adav80x_ops, - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_CBM_CFM, - }, -}; - -static struct snd_soc_card bfin_eval_adav80x = { - .name = "bfin-eval-adav80x", - .owner = THIS_MODULE, - .dai_link = bfin_eval_adav80x_dais, - .num_links = ARRAY_SIZE(bfin_eval_adav80x_dais), - - .dapm_widgets = bfin_eval_adav80x_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(bfin_eval_adav80x_dapm_widgets), - .dapm_routes = bfin_eval_adav80x_dapm_routes, - .num_dapm_routes = ARRAY_SIZE(bfin_eval_adav80x_dapm_routes), -}; - -enum bfin_eval_adav80x_type { - BFIN_EVAL_ADAV801, - BFIN_EVAL_ADAV803, -}; - -static int bfin_eval_adav80x_probe(struct platform_device *pdev) -{ - struct snd_soc_card *card = &bfin_eval_adav80x; - const char *codec_name; - - switch (platform_get_device_id(pdev)->driver_data) { - case BFIN_EVAL_ADAV801: - codec_name = "spi0.1"; - break; - case BFIN_EVAL_ADAV803: - codec_name = "adav803.0-0034"; - break; - default: - return -EINVAL; - } - - bfin_eval_adav80x_dais[0].codec_name = codec_name; - - card->dev = &pdev->dev; - - return devm_snd_soc_register_card(&pdev->dev, &bfin_eval_adav80x); -} - -static const struct platform_device_id bfin_eval_adav80x_ids[] = { - { "bfin-eval-adav801", BFIN_EVAL_ADAV801 }, - { "bfin-eval-adav803", BFIN_EVAL_ADAV803 }, - { }, -}; -MODULE_DEVICE_TABLE(platform, bfin_eval_adav80x_ids); - -static struct platform_driver bfin_eval_adav80x_driver = { - .driver = { - .name = "bfin-eval-adav80x", - .pm = &snd_soc_pm_ops, - }, - .probe = bfin_eval_adav80x_probe, - .id_table = bfin_eval_adav80x_ids, -}; - -module_platform_driver(bfin_eval_adav80x_driver); - -MODULE_AUTHOR("Lars-Peter Clausen "); -MODULE_DESCRIPTION("ALSA SoC bfin adav80x driver"); -MODULE_LICENSE("GPL"); From 4dcb31d4649df36297296b819437709f5407059c Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 14 Mar 2018 09:04:16 -0700 Subject: [PATCH 669/942] net: use skb_to_full_sk() in skb_update_prio() Andrei Vagin reported a KASAN: slab-out-of-bounds error in skb_update_prio() Since SYNACK might be attached to a request socket, we need to get back to the listener socket. Since this listener is manipulated without locks, add const qualifiers to sock_cgroup_prioidx() so that the const can also be used in skb_update_prio() Also add the const qualifier to sock_cgroup_classid() for consistency. Fixes: ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener") Signed-off-by: Eric Dumazet Reported-by: Andrei Vagin Signed-off-by: David S. Miller --- include/linux/cgroup-defs.h | 4 ++-- net/core/dev.c | 22 +++++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index 9f242b876fde..f8e76d01a5ad 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -755,13 +755,13 @@ struct sock_cgroup_data { * updaters and return part of the previous pointer as the prioidx or * classid. Such races are short-lived and the result isn't critical. */ -static inline u16 sock_cgroup_prioidx(struct sock_cgroup_data *skcd) +static inline u16 sock_cgroup_prioidx(const struct sock_cgroup_data *skcd) { /* fallback to 1 which is always the ID of the root cgroup */ return (skcd->is_data & 1) ? skcd->prioidx : 1; } -static inline u32 sock_cgroup_classid(struct sock_cgroup_data *skcd) +static inline u32 sock_cgroup_classid(const struct sock_cgroup_data *skcd) { /* fallback to 0 which is the unconfigured default classid */ return (skcd->is_data & 1) ? skcd->classid : 0; diff --git a/net/core/dev.c b/net/core/dev.c index 2cedf520cb28..12be20535714 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3278,15 +3278,23 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, #if IS_ENABLED(CONFIG_CGROUP_NET_PRIO) static void skb_update_prio(struct sk_buff *skb) { - struct netprio_map *map = rcu_dereference_bh(skb->dev->priomap); + const struct netprio_map *map; + const struct sock *sk; + unsigned int prioidx; - if (!skb->priority && skb->sk && map) { - unsigned int prioidx = - sock_cgroup_prioidx(&skb->sk->sk_cgrp_data); + if (skb->priority) + return; + map = rcu_dereference_bh(skb->dev->priomap); + if (!map) + return; + sk = skb_to_full_sk(skb); + if (!sk) + return; - if (prioidx < map->priomap_len) - skb->priority = map->priomap[prioidx]; - } + prioidx = sock_cgroup_prioidx(&sk->sk_cgrp_data); + + if (prioidx < map->priomap_len) + skb->priority = map->priomap[prioidx]; } #else #define skb_update_prio(skb) From 96f413f47677366e0ae03797409bfcc4151dbf9e Mon Sep 17 00:00:00 2001 From: Madalin Bucur Date: Wed, 14 Mar 2018 08:37:28 -0500 Subject: [PATCH 670/942] soc/fsl/qbman: fix issue in qman_delete_cgr_safe() The wait_for_completion() call in qman_delete_cgr_safe() was triggering a scheduling while atomic bug, replacing the kthread with a smp_call_function_single() call to fix it. Signed-off-by: Madalin Bucur Signed-off-by: Roy Pledge Signed-off-by: David S. Miller --- drivers/soc/fsl/qbman/qman.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index e4f5bb056fd2..ba3cfa8e279b 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -2443,39 +2443,21 @@ struct cgr_comp { struct completion completion; }; -static int qman_delete_cgr_thread(void *p) +static void qman_delete_cgr_smp_call(void *p) { - struct cgr_comp *cgr_comp = (struct cgr_comp *)p; - int ret; - - ret = qman_delete_cgr(cgr_comp->cgr); - complete(&cgr_comp->completion); - - return ret; + qman_delete_cgr((struct qman_cgr *)p); } void qman_delete_cgr_safe(struct qman_cgr *cgr) { - struct task_struct *thread; - struct cgr_comp cgr_comp; - preempt_disable(); if (qman_cgr_cpus[cgr->cgrid] != smp_processor_id()) { - init_completion(&cgr_comp.completion); - cgr_comp.cgr = cgr; - thread = kthread_create(qman_delete_cgr_thread, &cgr_comp, - "cgr_del"); - - if (IS_ERR(thread)) - goto out; - - kthread_bind(thread, qman_cgr_cpus[cgr->cgrid]); - wake_up_process(thread); - wait_for_completion(&cgr_comp.completion); + smp_call_function_single(qman_cgr_cpus[cgr->cgrid], + qman_delete_cgr_smp_call, cgr, true); preempt_enable(); return; } -out: + qman_delete_cgr(cgr); preempt_enable(); } From 88075256ee817041d68c2387f29065b5cb2b342a Mon Sep 17 00:00:00 2001 From: Madalin Bucur Date: Wed, 14 Mar 2018 08:37:29 -0500 Subject: [PATCH 671/942] dpaa_eth: fix error in dpaa_remove() The recent changes that make the driver probing compatible with DSA were not propagated in the dpa_remove() function, breaking the module unload function. Using the proper device to address the issue. Signed-off-by: Madalin Bucur Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 7caa8da48421..3af5e0c08233 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2860,7 +2860,7 @@ static int dpaa_remove(struct platform_device *pdev) struct device *dev; int err; - dev = &pdev->dev; + dev = pdev->dev.parent; net_dev = dev_get_drvdata(dev); priv = netdev_priv(net_dev); From 565186362b73226a288830abe595f05f0cec0bbc Mon Sep 17 00:00:00 2001 From: Camelia Groza Date: Wed, 14 Mar 2018 08:37:30 -0500 Subject: [PATCH 672/942] dpaa_eth: remove duplicate initialization The fd_format has already been initialized at this point. Signed-off-by: Camelia Groza Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 3af5e0c08233..627f7f714b18 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2278,7 +2278,6 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, vaddr = phys_to_virt(addr); prefetch(vaddr + qm_fd_get_offset(fd)); - fd_format = qm_fd_get_format(fd); /* The only FD types that we may receive are contig and S/G */ WARN_ON((fd_format != qm_fd_contig) && (fd_format != qm_fd_sg)); From e4d1b37c17d000a3da9368a3e260fb9ea4927c25 Mon Sep 17 00:00:00 2001 From: Camelia Groza Date: Wed, 14 Mar 2018 08:37:31 -0500 Subject: [PATCH 673/942] dpaa_eth: increment the RX dropped counter when needed Signed-off-by: Camelia Groza Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 627f7f714b18..6c0679fd78b8 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2310,8 +2310,10 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal, skb_len = skb->len; - if (unlikely(netif_receive_skb(skb) == NET_RX_DROP)) + if (unlikely(netif_receive_skb(skb) == NET_RX_DROP)) { + percpu_stats->rx_dropped++; return qman_cb_dqrr_consume; + } percpu_stats->rx_packets++; percpu_stats->rx_bytes += skb_len; From 82d141cd19d088ee41feafde4a6f86eeb40d93c5 Mon Sep 17 00:00:00 2001 From: Camelia Groza Date: Wed, 14 Mar 2018 08:37:32 -0500 Subject: [PATCH 674/942] dpaa_eth: remove duplicate increment of the tx_errors counter The tx_errors counter is incremented by the dpaa_xmit caller. Signed-off-by: Camelia Groza Signed-off-by: Madalin Bucur Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 6c0679fd78b8..e4ec32a9ca15 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2008,7 +2008,6 @@ static inline int dpaa_xmit(struct dpaa_priv *priv, } if (unlikely(err < 0)) { - percpu_stats->tx_errors++; percpu_stats->tx_fifo_errors++; return err; } From d52e5a7e7ca49457dd31fc8b42fb7c0d58a31221 Mon Sep 17 00:00:00 2001 From: Sabrina Dubroca Date: Wed, 14 Mar 2018 10:21:14 +0100 Subject: [PATCH 675/942] ipv4: lock mtu in fnhe when received PMTU < net.ipv4.route.min_pmtu Prior to the rework of PMTU information storage in commit 2c8cec5c10bc ("ipv4: Cache learned PMTU information in inetpeer."), when a PMTU event advertising a PMTU smaller than net.ipv4.route.min_pmtu was received, we would disable setting the DF flag on packets by locking the MTU metric, and set the PMTU to net.ipv4.route.min_pmtu. Since then, we don't disable DF, and set PMTU to net.ipv4.route.min_pmtu, so the intermediate router that has this link with a small MTU will have to drop the packets. This patch reestablishes pre-2.6.39 behavior by splitting rtable->rt_pmtu into a bitfield with rt_mtu_locked and rt_pmtu. rt_mtu_locked indicates that we shouldn't set the DF bit on that path, and is checked in ip_dont_fragment(). One possible workaround is to set net.ipv4.route.min_pmtu to a value low enough to accommodate the lowest MTU encountered. Fixes: 2c8cec5c10bc ("ipv4: Cache learned PMTU information in inetpeer.") Signed-off-by: Sabrina Dubroca Reviewed-by: Stefano Brivio Signed-off-by: David S. Miller --- include/net/ip.h | 11 +++++++++-- include/net/ip_fib.h | 1 + include/net/route.h | 3 ++- net/ipv4/route.c | 26 +++++++++++++++++++------- net/ipv4/xfrm4_policy.c | 1 + 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/include/net/ip.h b/include/net/ip.h index 746abff9ce51..f49b3a576bec 100644 --- a/include/net/ip.h +++ b/include/net/ip.h @@ -328,6 +328,13 @@ int ip_decrease_ttl(struct iphdr *iph) return --iph->ttl; } +static inline int ip_mtu_locked(const struct dst_entry *dst) +{ + const struct rtable *rt = (const struct rtable *)dst; + + return rt->rt_mtu_locked || dst_metric_locked(dst, RTAX_MTU); +} + static inline int ip_dont_fragment(const struct sock *sk, const struct dst_entry *dst) { @@ -335,7 +342,7 @@ int ip_dont_fragment(const struct sock *sk, const struct dst_entry *dst) return pmtudisc == IP_PMTUDISC_DO || (pmtudisc == IP_PMTUDISC_WANT && - !(dst_metric_locked(dst, RTAX_MTU))); + !ip_mtu_locked(dst)); } static inline bool ip_sk_accept_pmtu(const struct sock *sk) @@ -361,7 +368,7 @@ static inline unsigned int ip_dst_mtu_maybe_forward(const struct dst_entry *dst, struct net *net = dev_net(dst->dev); if (net->ipv4.sysctl_ip_fwd_use_pmtu || - dst_metric_locked(dst, RTAX_MTU) || + ip_mtu_locked(dst) || !forwarding) return dst_mtu(dst); diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index f80524396c06..77d0a78cf7d2 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h @@ -59,6 +59,7 @@ struct fib_nh_exception { int fnhe_genid; __be32 fnhe_daddr; u32 fnhe_pmtu; + bool fnhe_mtu_locked; __be32 fnhe_gw; unsigned long fnhe_expires; struct rtable __rcu *fnhe_rth_input; diff --git a/include/net/route.h b/include/net/route.h index 40b870d58f38..20a92ca9e115 100644 --- a/include/net/route.h +++ b/include/net/route.h @@ -63,7 +63,8 @@ struct rtable { __be32 rt_gateway; /* Miscellaneous cached information */ - u32 rt_pmtu; + u32 rt_mtu_locked:1, + rt_pmtu:31; u32 rt_table_id; diff --git a/net/ipv4/route.c b/net/ipv4/route.c index f9dbb8cb66bf..299e247b2032 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -634,6 +634,7 @@ static inline u32 fnhe_hashfun(__be32 daddr) static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) { rt->rt_pmtu = fnhe->fnhe_pmtu; + rt->rt_mtu_locked = fnhe->fnhe_mtu_locked; rt->dst.expires = fnhe->fnhe_expires; if (fnhe->fnhe_gw) { @@ -644,7 +645,7 @@ static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnh } static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, - u32 pmtu, unsigned long expires) + u32 pmtu, bool lock, unsigned long expires) { struct fnhe_hash_bucket *hash; struct fib_nh_exception *fnhe; @@ -681,8 +682,10 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, fnhe->fnhe_genid = genid; if (gw) fnhe->fnhe_gw = gw; - if (pmtu) + if (pmtu) { fnhe->fnhe_pmtu = pmtu; + fnhe->fnhe_mtu_locked = lock; + } fnhe->fnhe_expires = max(1UL, expires); /* Update all cached dsts too */ rt = rcu_dereference(fnhe->fnhe_rth_input); @@ -706,6 +709,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, fnhe->fnhe_daddr = daddr; fnhe->fnhe_gw = gw; fnhe->fnhe_pmtu = pmtu; + fnhe->fnhe_mtu_locked = lock; fnhe->fnhe_expires = expires; /* Exception created; mark the cached routes for the nexthop @@ -787,7 +791,8 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow struct fib_nh *nh = &FIB_RES_NH(res); update_or_create_fnhe(nh, fl4->daddr, new_gw, - 0, jiffies + ip_rt_gc_timeout); + 0, false, + jiffies + ip_rt_gc_timeout); } if (kill_route) rt->dst.obsolete = DST_OBSOLETE_KILL; @@ -1009,15 +1014,18 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) { struct dst_entry *dst = &rt->dst; struct fib_result res; + bool lock = false; - if (dst_metric_locked(dst, RTAX_MTU)) + if (ip_mtu_locked(dst)) return; if (ipv4_mtu(dst) < mtu) return; - if (mtu < ip_rt_min_pmtu) + if (mtu < ip_rt_min_pmtu) { + lock = true; mtu = ip_rt_min_pmtu; + } if (rt->rt_pmtu == mtu && time_before(jiffies, dst->expires - ip_rt_mtu_expires / 2)) @@ -1027,7 +1035,7 @@ static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) if (fib_lookup(dev_net(dst->dev), fl4, &res, 0) == 0) { struct fib_nh *nh = &FIB_RES_NH(res); - update_or_create_fnhe(nh, fl4->daddr, 0, mtu, + update_or_create_fnhe(nh, fl4->daddr, 0, mtu, lock, jiffies + ip_rt_mtu_expires); } rcu_read_unlock(); @@ -1280,7 +1288,7 @@ static unsigned int ipv4_mtu(const struct dst_entry *dst) mtu = READ_ONCE(dst->dev->mtu); - if (unlikely(dst_metric_locked(dst, RTAX_MTU))) { + if (unlikely(ip_mtu_locked(dst))) { if (rt->rt_uses_gateway && mtu > 576) mtu = 576; } @@ -1521,6 +1529,7 @@ struct rtable *rt_dst_alloc(struct net_device *dev, rt->rt_is_input = 0; rt->rt_iif = 0; rt->rt_pmtu = 0; + rt->rt_mtu_locked = 0; rt->rt_gateway = 0; rt->rt_uses_gateway = 0; rt->rt_table_id = 0; @@ -2546,6 +2555,7 @@ struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_or rt->rt_is_input = ort->rt_is_input; rt->rt_iif = ort->rt_iif; rt->rt_pmtu = ort->rt_pmtu; + rt->rt_mtu_locked = ort->rt_mtu_locked; rt->rt_genid = rt_genid_ipv4(net); rt->rt_flags = ort->rt_flags; @@ -2648,6 +2658,8 @@ static int rt_fill_info(struct net *net, __be32 dst, __be32 src, u32 table_id, memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); if (rt->rt_pmtu && expires) metrics[RTAX_MTU - 1] = rt->rt_pmtu; + if (rt->rt_mtu_locked && expires) + metrics[RTAX_LOCK - 1] |= BIT(RTAX_MTU); if (rtnetlink_put_metrics(skb, metrics) < 0) goto nla_put_failure; diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 8d33f7b311f4..fbebda67ac1b 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c @@ -100,6 +100,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, xdst->u.rt.rt_gateway = rt->rt_gateway; xdst->u.rt.rt_uses_gateway = rt->rt_uses_gateway; xdst->u.rt.rt_pmtu = rt->rt_pmtu; + xdst->u.rt.rt_mtu_locked = rt->rt_mtu_locked; xdst->u.rt.rt_table_id = rt->rt_table_id; INIT_LIST_HEAD(&xdst->u.rt.rt_uncached); rt_add_uncached_list(&xdst->u.rt); From ea91df6d8a55836c7401eb6d5d4d828b659d8d67 Mon Sep 17 00:00:00 2001 From: Jonathan Toppins Date: Wed, 14 Mar 2018 12:36:25 -0400 Subject: [PATCH 676/942] tg3: prevent scheduling while atomic splat The problem was introduced in commit 506b0a395f26 ("[netdrv] tg3: APE heartbeat changes"). The bug occurs because tp->lock spinlock is held which is obtained in tg3_start by way of tg3_full_lock(), line 11571. The documentation for usleep_range() specifically states it cannot be used inside a spinlock. Fixes: 506b0a395f26 ("[netdrv] tg3: APE heartbeat changes") Signed-off-by: Jonathan Toppins Acked-by: Michael Chan Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/tg3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index c1841db1b500..f2593978ae75 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c @@ -820,7 +820,7 @@ static int tg3_ape_event_lock(struct tg3 *tp, u32 timeout_us) tg3_ape_unlock(tp, TG3_APE_LOCK_MEM); - usleep_range(10, 20); + udelay(10); timeout_us -= (timeout_us > 10) ? 10 : timeout_us; } From cf55612a945039476abfd73e39064b2e721c3272 Mon Sep 17 00:00:00 2001 From: Cathy Zhou Date: Wed, 14 Mar 2018 10:56:07 -0700 Subject: [PATCH 677/942] sunvnet: does not support GSO for sctp The NETIF_F_GSO_SOFTWARE implies support for GSO on SCTP, but the sunvnet driver does not support GSO for sctp. Here we remove the NETIF_F_GSO_SOFTWARE feature flag and only report NETIF_F_ALL_TSO instead. Signed-off-by: Cathy Zhou Signed-off-by: Shannon Nelson Signed-off-by: David S. Miller --- drivers/net/ethernet/sun/sunvnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c index 63d3d6b215f3..a94f50442613 100644 --- a/drivers/net/ethernet/sun/sunvnet.c +++ b/drivers/net/ethernet/sun/sunvnet.c @@ -312,7 +312,7 @@ static struct vnet *vnet_new(const u64 *local_mac, dev->ethtool_ops = &vnet_ethtool_ops; dev->watchdog_timeo = VNET_TX_TIMEOUT; - dev->hw_features = NETIF_F_TSO | NETIF_F_GSO | NETIF_F_GSO_SOFTWARE | + dev->hw_features = NETIF_F_TSO | NETIF_F_GSO | NETIF_F_ALL_TSO | NETIF_F_HW_CSUM | NETIF_F_SG; dev->features = dev->hw_features; From 75073a64a98cecf4b2a81567b31b5a52dd3518bc Mon Sep 17 00:00:00 2001 From: Darren Hart Date: Sat, 10 Mar 2018 16:12:16 -0800 Subject: [PATCH 678/942] platform/x86: dell-smbios: Resolve dependency error on ACPI_WMI Similarly to DCDBAS for DELL_SMBIOS_SMM, if DELL_SMBIOS_WMI is enabled, DELL_SMBIOS becomes dependent on ACPI_WMI. Update the depends lines to prevent a configuration where DELL_SMBIOS=y and either backend dependency =m. Update the comment accordingly. Cc: Mario Limonciello Cc: Andy Shevchenko Cc: Dominik Brodowski Signed-off-by: Darren Hart (VMware) --- drivers/platform/x86/Kconfig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig index d10ffe51da24..51ebc5a6053f 100644 --- a/drivers/platform/x86/Kconfig +++ b/drivers/platform/x86/Kconfig @@ -106,13 +106,14 @@ config ASUS_LAPTOP If you have an ACPI-compatible ASUS laptop, say Y or M here. # -# If the DELL_SMBIOS_SMM feature is enabled, the DELL_SMBIOS driver -# becomes dependent on the DCDBAS driver. The "depends" line prevents a -# configuration where DELL_SMBIOS=y while DCDBAS=m. +# The DELL_SMBIOS driver depends on ACPI_WMI and/or DCDBAS if those +# backends are selected. The "depends" line prevents a configuration +# where DELL_SMBIOS=y while either of those dependencies =m. # config DELL_SMBIOS tristate "Dell SMBIOS driver" depends on DCDBAS || DCDBAS=n + depends on ACPI_WMI || ACPI_WMI=n ---help--- This provides support for the Dell SMBIOS calling interface. If you have a Dell computer you should enable this option. From 49368c13217f3b4d2e2d168e88b16c74910ad0ae Mon Sep 17 00:00:00 2001 From: "Darren Hart (VMware)" Date: Mon, 12 Mar 2018 23:28:00 -0700 Subject: [PATCH 679/942] platform/x86: Fix dell driver init order Update the initcall ordering to satisfy the following dependency ordering: 1. DCDBAS, ACPI_WMI 2. DELL_SMBIOS, DELL_RBTN 3. DELL_LAPTOP, DELL_WMI By assigning them to the following initcall levels: subsys_initcall: DCDBAS, ACPI_WMI module_init: DELL_SMBIOS, DELL_RBTN late_initcall: DELL_LAPTOP, DELL_WMI Cc: Dominik Brodowski Cc: Mario.Limonciello@dell.com Signed-off-by: Darren Hart (VMware) --- drivers/firmware/dcdbas.c | 2 +- drivers/platform/x86/dell-smbios-base.c | 2 +- drivers/platform/x86/dell-wmi.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c index c16600f30611..0bdea60c65dd 100644 --- a/drivers/firmware/dcdbas.c +++ b/drivers/firmware/dcdbas.c @@ -639,7 +639,7 @@ static void __exit dcdbas_exit(void) platform_driver_unregister(&dcdbas_driver); } -module_init(dcdbas_init); +subsys_initcall_sync(dcdbas_init); module_exit(dcdbas_exit); MODULE_DESCRIPTION(DRIVER_DESCRIPTION " (version " DRIVER_VERSION ")"); diff --git a/drivers/platform/x86/dell-smbios-base.c b/drivers/platform/x86/dell-smbios-base.c index 5bcf8a18f785..2485c80a9fdd 100644 --- a/drivers/platform/x86/dell-smbios-base.c +++ b/drivers/platform/x86/dell-smbios-base.c @@ -637,7 +637,7 @@ static void __exit dell_smbios_exit(void) mutex_unlock(&smbios_mutex); } -subsys_initcall(dell_smbios_init); +module_init(dell_smbios_init); module_exit(dell_smbios_exit); MODULE_AUTHOR("Matthew Garrett "); diff --git a/drivers/platform/x86/dell-wmi.c b/drivers/platform/x86/dell-wmi.c index 2c9927430d85..8d102195a392 100644 --- a/drivers/platform/x86/dell-wmi.c +++ b/drivers/platform/x86/dell-wmi.c @@ -714,7 +714,7 @@ static int __init dell_wmi_init(void) return wmi_driver_register(&dell_wmi_driver); } -module_init(dell_wmi_init); +late_initcall(dell_wmi_init); static void __exit dell_wmi_exit(void) { From 62b06f8f429cd233e4e2e7bbd21081ad60c9018f Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Tue, 6 Mar 2018 09:21:06 +0000 Subject: [PATCH 680/942] KVM: arm/arm64: vgic: Add missing irq_lock to vgic_mmio_read_pending Our irq_is_pending() helper function accesses multiple members of the vgic_irq struct, so we need to hold the lock when calling it. Add that requirement as a comment to the definition and take the lock around the call in vgic_mmio_read_pending(), where we were missing it before. Fixes: 96b298000db4 ("KVM: arm/arm64: vgic-new: Add PENDING registers handlers") Signed-off-by: Andre Przywara Signed-off-by: Marc Zyngier --- virt/kvm/arm/vgic/vgic-mmio.c | 3 +++ virt/kvm/arm/vgic/vgic.h | 1 + 2 files changed, 4 insertions(+) diff --git a/virt/kvm/arm/vgic/vgic-mmio.c b/virt/kvm/arm/vgic/vgic-mmio.c index 83d82bd7dc4e..dbe99d635c80 100644 --- a/virt/kvm/arm/vgic/vgic-mmio.c +++ b/virt/kvm/arm/vgic/vgic-mmio.c @@ -113,9 +113,12 @@ unsigned long vgic_mmio_read_pending(struct kvm_vcpu *vcpu, /* Loop over all IRQs affected by this read */ for (i = 0; i < len * 8; i++) { struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i); + unsigned long flags; + spin_lock_irqsave(&irq->irq_lock, flags); if (irq_is_pending(irq)) value |= (1U << i); + spin_unlock_irqrestore(&irq->irq_lock, flags); vgic_put_irq(vcpu->kvm, irq); } diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 12c37b89f7a3..5b11859a1a1e 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h @@ -96,6 +96,7 @@ /* we only support 64 kB translation table page size */ #define KVM_ITS_L1E_ADDR_MASK GENMASK_ULL(51, 16) +/* Requires the irq_lock to be held by the caller. */ static inline bool irq_is_pending(struct vgic_irq *irq) { if (irq->config == VGIC_CONFIG_EDGE) From e21a4f3a930cda6e4902cb5b3213365e5ff3ce7c Mon Sep 17 00:00:00 2001 From: Christoffer Dall Date: Tue, 27 Feb 2018 12:33:50 +0100 Subject: [PATCH 681/942] KVM: arm/arm64: Avoid vcpu_load for other vcpu ioctls than KVM_RUN Calling vcpu_load() registers preempt notifiers for this vcpu and calls kvm_arch_vcpu_load(). The latter will soon be doing a lot of heavy lifting on arm/arm64 and will try to do things such as enabling the virtual timer and setting us up to handle interrupts from the timer hardware. Loading state onto hardware registers and enabling hardware to signal interrupts can be problematic when we're not actually about to run the VCPU, because it makes it difficult to establish the right context when handling interrupts from the timer, and it makes the register access code difficult to reason about. Luckily, now when we call vcpu_load in each ioctl implementation, we can simply remove the call from the non-KVM_RUN vcpu ioctls, and our kvm_arch_vcpu_load() is only used for loading vcpu content to the physical CPU when we're actually going to run the vcpu. Cc: stable@vger.kernel.org Fixes: 9b062471e52a ("KVM: Move vcpu_load to arch-specific kvm_arch_vcpu_ioctl") Reviewed-by: Julien Grall Reviewed-by: Marc Zyngier Reviewed-by: Andrew Jones Signed-off-by: Christoffer Dall Signed-off-by: Marc Zyngier --- arch/arm64/kvm/guest.c | 3 --- virt/kvm/arm/arm.c | 9 --------- 2 files changed, 12 deletions(-) diff --git a/arch/arm64/kvm/guest.c b/arch/arm64/kvm/guest.c index d7e3299a7734..959e50d2588c 100644 --- a/arch/arm64/kvm/guest.c +++ b/arch/arm64/kvm/guest.c @@ -363,8 +363,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, { int ret = 0; - vcpu_load(vcpu); - trace_kvm_set_guest_debug(vcpu, dbg->control); if (dbg->control & ~KVM_GUESTDBG_VALID_MASK) { @@ -386,7 +384,6 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu, } out: - vcpu_put(vcpu); return ret; } diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c index 86941f6181bb..53572304843b 100644 --- a/virt/kvm/arm/arm.c +++ b/virt/kvm/arm/arm.c @@ -384,14 +384,11 @@ static void vcpu_power_off(struct kvm_vcpu *vcpu) int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu, struct kvm_mp_state *mp_state) { - vcpu_load(vcpu); - if (vcpu->arch.power_off) mp_state->mp_state = KVM_MP_STATE_STOPPED; else mp_state->mp_state = KVM_MP_STATE_RUNNABLE; - vcpu_put(vcpu); return 0; } @@ -400,8 +397,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, { int ret = 0; - vcpu_load(vcpu); - switch (mp_state->mp_state) { case KVM_MP_STATE_RUNNABLE: vcpu->arch.power_off = false; @@ -413,7 +408,6 @@ int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu, ret = -EINVAL; } - vcpu_put(vcpu); return ret; } @@ -1036,8 +1030,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, struct kvm_device_attr attr; long r; - vcpu_load(vcpu); - switch (ioctl) { case KVM_ARM_VCPU_INIT: { struct kvm_vcpu_init init; @@ -1114,7 +1106,6 @@ long kvm_arch_vcpu_ioctl(struct file *filp, r = -EINVAL; } - vcpu_put(vcpu); return r; } From 413aa807ae39fed7e387c175d2d0ae9fcf6c0c9d Mon Sep 17 00:00:00 2001 From: Christoffer Dall Date: Mon, 5 Mar 2018 11:36:38 +0100 Subject: [PATCH 682/942] KVM: arm/arm64: Reset mapped IRQs on VM reset We currently don't allow resetting mapped IRQs from userspace, because their state is controlled by the hardware. But we do need to reset the state when the VM is reset, so we provide a function for the 'owner' of the mapped interrupt to reset the interrupt state. Currently only the timer uses mapped interrupts, so we call this function from the timer reset logic. Cc: stable@vger.kernel.org Fixes: 4c60e360d6df ("KVM: arm/arm64: Provide a get_input_level for the arch timer") Signed-off-by: Christoffer Dall Signed-off-by: Marc Zyngier --- include/kvm/arm_vgic.h | 1 + virt/kvm/arm/arch_timer.c | 4 ++++ virt/kvm/arm/vgic/vgic.c | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index cdbd142ca7f2..02924ae2527e 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -360,6 +360,7 @@ void kvm_vgic_put(struct kvm_vcpu *vcpu); bool kvm_vcpu_has_pending_irqs(struct kvm_vcpu *vcpu); void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu); void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu); +void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid); void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg); diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 70f4c30918eb..3945021510a9 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -581,6 +581,7 @@ void kvm_timer_sync_hwstate(struct kvm_vcpu *vcpu) int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu) { + struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; struct arch_timer_context *vtimer = vcpu_vtimer(vcpu); struct arch_timer_context *ptimer = vcpu_ptimer(vcpu); @@ -594,6 +595,9 @@ int kvm_timer_vcpu_reset(struct kvm_vcpu *vcpu) ptimer->cnt_ctl = 0; kvm_timer_update_state(vcpu); + if (timer->enabled && irqchip_in_kernel(vcpu->kvm)) + kvm_vgic_reset_mapped_irq(vcpu, vtimer->irq.irq); + return 0; } diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index c7c5ef190afa..0001858a2c23 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -495,6 +495,32 @@ int kvm_vgic_map_phys_irq(struct kvm_vcpu *vcpu, unsigned int host_irq, return ret; } +/** + * kvm_vgic_reset_mapped_irq - Reset a mapped IRQ + * @vcpu: The VCPU pointer + * @vintid: The INTID of the interrupt + * + * Reset the active and pending states of a mapped interrupt. Kernel + * subsystems injecting mapped interrupts should reset their interrupt lines + * when we are doing a reset of the VM. + */ +void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid) +{ + struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, vintid); + unsigned long flags; + + if (!irq->hw) + goto out; + + spin_lock_irqsave(&irq->irq_lock, flags); + irq->active = false; + irq->pending_latch = false; + irq->line_level = false; + spin_unlock_irqrestore(&irq->irq_lock, flags); +out: + vgic_put_irq(vcpu->kvm, irq); +} + int kvm_vgic_unmap_phys_irq(struct kvm_vcpu *vcpu, unsigned int vintid) { struct vgic_irq *irq; From 76600428c3677659e3c3633bb4f2ea302220a275 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 2 Mar 2018 08:16:30 +0000 Subject: [PATCH 683/942] KVM: arm/arm64: Reduce verbosity of KVM init log On my GICv3 system, the following is printed to the kernel log at boot: kvm [1]: 8-bit VMID kvm [1]: IDMAP page: d20e35000 kvm [1]: HYP VA range: 800000000000:ffffffffffff kvm [1]: vgic-v2@2c020000 kvm [1]: GIC system register CPU interface enabled kvm [1]: vgic interrupt IRQ1 kvm [1]: virtual timer IRQ4 kvm [1]: Hyp mode initialized successfully The KVM IDMAP is a mapping of a statically allocated kernel structure, and so printing its physical address leaks the physical placement of the kernel when physical KASLR in effect. So change the kvm_info() to kvm_debug() to remove it from the log output. While at it, trim the output a bit more: IRQ numbers can be found in /proc/interrupts, and the HYP VA and vgic-v2 lines are not highly informational either. Cc: Acked-by: Will Deacon Acked-by: Christoffer Dall Signed-off-by: Ard Biesheuvel Signed-off-by: Marc Zyngier --- virt/kvm/arm/arch_timer.c | 2 +- virt/kvm/arm/mmu.c | 6 +++--- virt/kvm/arm/vgic/vgic-v2.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/virt/kvm/arm/arch_timer.c b/virt/kvm/arm/arch_timer.c index 3945021510a9..282389eb204f 100644 --- a/virt/kvm/arm/arch_timer.c +++ b/virt/kvm/arm/arch_timer.c @@ -771,7 +771,7 @@ int kvm_timer_hyp_init(bool has_gic) static_branch_enable(&has_gic_active_state); } - kvm_info("virtual timer IRQ%d\n", host_vtimer_irq); + kvm_debug("virtual timer IRQ%d\n", host_vtimer_irq); cpuhp_setup_state(CPUHP_AP_KVM_ARM_TIMER_STARTING, "kvm/arm/timer:starting", kvm_timer_starting_cpu, diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c index ec62d1cccab7..b960acdd0c05 100644 --- a/virt/kvm/arm/mmu.c +++ b/virt/kvm/arm/mmu.c @@ -1810,9 +1810,9 @@ int kvm_mmu_init(void) */ BUG_ON((hyp_idmap_start ^ (hyp_idmap_end - 1)) & PAGE_MASK); - kvm_info("IDMAP page: %lx\n", hyp_idmap_start); - kvm_info("HYP VA range: %lx:%lx\n", - kern_hyp_va(PAGE_OFFSET), kern_hyp_va(~0UL)); + kvm_debug("IDMAP page: %lx\n", hyp_idmap_start); + kvm_debug("HYP VA range: %lx:%lx\n", + kern_hyp_va(PAGE_OFFSET), kern_hyp_va(~0UL)); if (hyp_idmap_start >= kern_hyp_va(PAGE_OFFSET) && hyp_idmap_start < kern_hyp_va(~0UL) && diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c index c32d7b93ffd1..e9d840a75e7b 100644 --- a/virt/kvm/arm/vgic/vgic-v2.c +++ b/virt/kvm/arm/vgic/vgic-v2.c @@ -410,7 +410,7 @@ int vgic_v2_probe(const struct gic_kvm_info *info) kvm_vgic_global_state.type = VGIC_V2; kvm_vgic_global_state.max_gic_vcpus = VGIC_V2_MAX_CPUS; - kvm_info("vgic-v2@%llx\n", info->vctrl.start); + kvm_debug("vgic-v2@%llx\n", info->vctrl.start); return 0; out: From 16ca6a607d84bef0129698d8d808f501afd08d43 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Mar 2018 21:48:01 +0000 Subject: [PATCH 684/942] KVM: arm/arm64: vgic: Don't populate multiple LRs with the same vintid The vgic code is trying to be clever when injecting GICv2 SGIs, and will happily populate LRs with the same interrupt number if they come from multiple vcpus (after all, they are distinct interrupt sources). Unfortunately, this is against the letter of the architecture, and the GICv2 architecture spec says "Each valid interrupt stored in the List registers must have a unique VirtualID for that virtual CPU interface.". GICv3 has similar (although slightly ambiguous) restrictions. This results in guests locking up when using GICv2-on-GICv3, for example. The obvious fix is to stop trying so hard, and inject a single vcpu per SGI per guest entry. After all, pending SGIs with multiple source vcpus are pretty rare, and are mostly seen in scenario where the physical CPUs are severely overcomitted. But as we now only inject a single instance of a multi-source SGI per vcpu entry, we may delay those interrupts for longer than strictly necessary, and run the risk of injecting lower priority interrupts in the meantime. In order to address this, we adopt a three stage strategy: - If we encounter a multi-source SGI in the AP list while computing its depth, we force the list to be sorted - When populating the LRs, we prevent the injection of any interrupt of lower priority than that of the first multi-source SGI we've injected. - Finally, the injection of a multi-source SGI triggers the request of a maintenance interrupt when there will be no pending interrupt in the LRs (HCR_NPIE). At the point where the last pending interrupt in the LRs switches from Pending to Active, the maintenance interrupt will be delivered, allowing us to add the remaining SGIs using the same process. Cc: stable@vger.kernel.org Fixes: 0919e84c0fc1 ("KVM: arm/arm64: vgic-new: Add IRQ sync/flush framework") Acked-by: Christoffer Dall Signed-off-by: Marc Zyngier --- include/linux/irqchip/arm-gic-v3.h | 1 + include/linux/irqchip/arm-gic.h | 1 + virt/kvm/arm/vgic/vgic-v2.c | 9 ++++- virt/kvm/arm/vgic/vgic-v3.c | 9 ++++- virt/kvm/arm/vgic/vgic.c | 63 +++++++++++++++++++++++------- virt/kvm/arm/vgic/vgic.h | 2 + 6 files changed, 68 insertions(+), 17 deletions(-) diff --git a/include/linux/irqchip/arm-gic-v3.h b/include/linux/irqchip/arm-gic-v3.h index c00c4c33e432..b26eccc78fb1 100644 --- a/include/linux/irqchip/arm-gic-v3.h +++ b/include/linux/irqchip/arm-gic-v3.h @@ -503,6 +503,7 @@ #define ICH_HCR_EN (1 << 0) #define ICH_HCR_UIE (1 << 1) +#define ICH_HCR_NPIE (1 << 3) #define ICH_HCR_TC (1 << 10) #define ICH_HCR_TALL0 (1 << 11) #define ICH_HCR_TALL1 (1 << 12) diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h index d3453ee072fc..68d8b1f73682 100644 --- a/include/linux/irqchip/arm-gic.h +++ b/include/linux/irqchip/arm-gic.h @@ -84,6 +84,7 @@ #define GICH_HCR_EN (1 << 0) #define GICH_HCR_UIE (1 << 1) +#define GICH_HCR_NPIE (1 << 3) #define GICH_LR_VIRTUALID (0x3ff << 0) #define GICH_LR_PHYSID_CPUID_SHIFT (10) diff --git a/virt/kvm/arm/vgic/vgic-v2.c b/virt/kvm/arm/vgic/vgic-v2.c index e9d840a75e7b..29556f71b691 100644 --- a/virt/kvm/arm/vgic/vgic-v2.c +++ b/virt/kvm/arm/vgic/vgic-v2.c @@ -37,6 +37,13 @@ void vgic_v2_init_lrs(void) vgic_v2_write_lr(i, 0); } +void vgic_v2_set_npie(struct kvm_vcpu *vcpu) +{ + struct vgic_v2_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v2; + + cpuif->vgic_hcr |= GICH_HCR_NPIE; +} + void vgic_v2_set_underflow(struct kvm_vcpu *vcpu) { struct vgic_v2_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v2; @@ -64,7 +71,7 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu) int lr; unsigned long flags; - cpuif->vgic_hcr &= ~GICH_HCR_UIE; + cpuif->vgic_hcr &= ~(GICH_HCR_UIE | GICH_HCR_NPIE); for (lr = 0; lr < vgic_cpu->used_lrs; lr++) { u32 val = cpuif->vgic_lr[lr]; diff --git a/virt/kvm/arm/vgic/vgic-v3.c b/virt/kvm/arm/vgic/vgic-v3.c index 6b329414e57a..0ff2006f3781 100644 --- a/virt/kvm/arm/vgic/vgic-v3.c +++ b/virt/kvm/arm/vgic/vgic-v3.c @@ -26,6 +26,13 @@ static bool group1_trap; static bool common_trap; static bool gicv4_enable; +void vgic_v3_set_npie(struct kvm_vcpu *vcpu) +{ + struct vgic_v3_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v3; + + cpuif->vgic_hcr |= ICH_HCR_NPIE; +} + void vgic_v3_set_underflow(struct kvm_vcpu *vcpu) { struct vgic_v3_cpu_if *cpuif = &vcpu->arch.vgic_cpu.vgic_v3; @@ -47,7 +54,7 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu) int lr; unsigned long flags; - cpuif->vgic_hcr &= ~ICH_HCR_UIE; + cpuif->vgic_hcr &= ~(ICH_HCR_UIE | ICH_HCR_NPIE); for (lr = 0; lr < vgic_cpu->used_lrs; lr++) { u64 val = cpuif->vgic_lr[lr]; diff --git a/virt/kvm/arm/vgic/vgic.c b/virt/kvm/arm/vgic/vgic.c index 0001858a2c23..8201899126f6 100644 --- a/virt/kvm/arm/vgic/vgic.c +++ b/virt/kvm/arm/vgic/vgic.c @@ -710,22 +710,37 @@ static inline void vgic_set_underflow(struct kvm_vcpu *vcpu) vgic_v3_set_underflow(vcpu); } +static inline void vgic_set_npie(struct kvm_vcpu *vcpu) +{ + if (kvm_vgic_global_state.type == VGIC_V2) + vgic_v2_set_npie(vcpu); + else + vgic_v3_set_npie(vcpu); +} + /* Requires the ap_list_lock to be held. */ -static int compute_ap_list_depth(struct kvm_vcpu *vcpu) +static int compute_ap_list_depth(struct kvm_vcpu *vcpu, + bool *multi_sgi) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; struct vgic_irq *irq; int count = 0; + *multi_sgi = false; + DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu->ap_list_lock)); list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) { spin_lock(&irq->irq_lock); /* GICv2 SGIs can count for more than one... */ - if (vgic_irq_is_sgi(irq->intid) && irq->source) - count += hweight8(irq->source); - else + if (vgic_irq_is_sgi(irq->intid) && irq->source) { + int w = hweight8(irq->source); + + count += w; + *multi_sgi |= (w > 1); + } else { count++; + } spin_unlock(&irq->irq_lock); } return count; @@ -736,28 +751,43 @@ static void vgic_flush_lr_state(struct kvm_vcpu *vcpu) { struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; struct vgic_irq *irq; - int count = 0; + int count; + bool npie = false; + bool multi_sgi; + u8 prio = 0xff; DEBUG_SPINLOCK_BUG_ON(!spin_is_locked(&vgic_cpu->ap_list_lock)); - if (compute_ap_list_depth(vcpu) > kvm_vgic_global_state.nr_lr) + count = compute_ap_list_depth(vcpu, &multi_sgi); + if (count > kvm_vgic_global_state.nr_lr || multi_sgi) vgic_sort_ap_list(vcpu); + count = 0; + list_for_each_entry(irq, &vgic_cpu->ap_list_head, ap_list) { spin_lock(&irq->irq_lock); - if (unlikely(vgic_target_oracle(irq) != vcpu)) - goto next; - /* - * If we get an SGI with multiple sources, try to get - * them in all at once. + * If we have multi-SGIs in the pipeline, we need to + * guarantee that they are all seen before any IRQ of + * lower priority. In that case, we need to filter out + * these interrupts by exiting early. This is easy as + * the AP list has been sorted already. */ - do { - vgic_populate_lr(vcpu, irq, count++); - } while (irq->source && count < kvm_vgic_global_state.nr_lr); + if (multi_sgi && irq->priority > prio) { + spin_unlock(&irq->irq_lock); + break; + } + + if (likely(vgic_target_oracle(irq) == vcpu)) { + vgic_populate_lr(vcpu, irq, count++); + + if (irq->source) { + npie = true; + prio = irq->priority; + } + } -next: spin_unlock(&irq->irq_lock); if (count == kvm_vgic_global_state.nr_lr) { @@ -768,6 +798,9 @@ next: } } + if (npie) + vgic_set_npie(vcpu); + vcpu->arch.vgic_cpu.used_lrs = count; /* Nuke remaining LRs */ diff --git a/virt/kvm/arm/vgic/vgic.h b/virt/kvm/arm/vgic/vgic.h index 5b11859a1a1e..f5b8519e5546 100644 --- a/virt/kvm/arm/vgic/vgic.h +++ b/virt/kvm/arm/vgic/vgic.h @@ -160,6 +160,7 @@ void vgic_v2_fold_lr_state(struct kvm_vcpu *vcpu); void vgic_v2_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr); void vgic_v2_clear_lr(struct kvm_vcpu *vcpu, int lr); void vgic_v2_set_underflow(struct kvm_vcpu *vcpu); +void vgic_v2_set_npie(struct kvm_vcpu *vcpu); int vgic_v2_has_attr_regs(struct kvm_device *dev, struct kvm_device_attr *attr); int vgic_v2_dist_uaccess(struct kvm_vcpu *vcpu, bool is_write, int offset, u32 *val); @@ -189,6 +190,7 @@ void vgic_v3_fold_lr_state(struct kvm_vcpu *vcpu); void vgic_v3_populate_lr(struct kvm_vcpu *vcpu, struct vgic_irq *irq, int lr); void vgic_v3_clear_lr(struct kvm_vcpu *vcpu, int lr); void vgic_v3_set_underflow(struct kvm_vcpu *vcpu); +void vgic_v3_set_npie(struct kvm_vcpu *vcpu); void vgic_v3_set_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); void vgic_v3_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr); void vgic_v3_enable(struct kvm_vcpu *vcpu); From 27e91ad1e746e341ca2312f29bccb9736be7b476 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Tue, 6 Mar 2018 21:44:37 +0000 Subject: [PATCH 685/942] kvm: arm/arm64: vgic-v3: Tighten synchronization for guests using v2 on v3 On guest exit, and when using GICv2 on GICv3, we use a dsb(st) to force synchronization between the memory-mapped guest view and the system-register view that the hypervisor uses. This is incorrect, as the spec calls out the need for "a DSB whose required access type is both loads and stores with any Shareability attribute", while we're only synchronizing stores. We also lack an isb after the dsb to ensure that the latter has actually been executed before we start reading stuff from the sysregs. The fix is pretty easy: turn dsb(st) into dsb(sy), and slap an isb() just after. Cc: stable@vger.kernel.org Fixes: f68d2b1b73cc ("arm64: KVM: Implement vgic-v3 save/restore") Acked-by: Christoffer Dall Reviewed-by: Andre Przywara Signed-off-by: Marc Zyngier --- virt/kvm/arm/hyp/vgic-v3-sr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/arm/hyp/vgic-v3-sr.c b/virt/kvm/arm/hyp/vgic-v3-sr.c index f5c3d6d7019e..b89ce5432214 100644 --- a/virt/kvm/arm/hyp/vgic-v3-sr.c +++ b/virt/kvm/arm/hyp/vgic-v3-sr.c @@ -215,7 +215,8 @@ void __hyp_text __vgic_v3_save_state(struct kvm_vcpu *vcpu) * are now visible to the system register interface. */ if (!cpu_if->vgic_sre) { - dsb(st); + dsb(sy); + isb(); cpu_if->vgic_vmcr = read_gicreg(ICH_VMCR_EL2); } From a6d7cff472eea87d96899a20fa718d2bab7109f3 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 14 Mar 2018 12:10:17 -0700 Subject: [PATCH 686/942] fs/aio: Add explicit RCU grace period when freeing kioctx While fixing refcounting, e34ecee2ae79 ("aio: Fix a trinity splat") incorrectly removed explicit RCU grace period before freeing kioctx. The intention seems to be depending on the internal RCU grace periods of percpu_ref; however, percpu_ref uses a different flavor of RCU, sched-RCU. This can lead to kioctx being freed while RCU read protected dereferences are still in progress. Fix it by updating free_ioctx() to go through call_rcu() explicitly. v2: Comment added to explain double bouncing. Signed-off-by: Tejun Heo Reported-by: Jann Horn Fixes: e34ecee2ae79 ("aio: Fix a trinity splat") Cc: Kent Overstreet Cc: Linus Torvalds Cc: stable@vger.kernel.org # v3.13+ --- fs/aio.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index a062d75109cb..eb2e0cfbe2d2 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -115,7 +115,8 @@ struct kioctx { struct page **ring_pages; long nr_pages; - struct work_struct free_work; + struct rcu_head free_rcu; + struct work_struct free_work; /* see free_ioctx() */ /* * signals when all in-flight requests are done @@ -588,6 +589,12 @@ static int kiocb_cancel(struct aio_kiocb *kiocb) return cancel(&kiocb->common); } +/* + * free_ioctx() should be RCU delayed to synchronize against the RCU + * protected lookup_ioctx() and also needs process context to call + * aio_free_ring(), so the double bouncing through kioctx->free_rcu and + * ->free_work. + */ static void free_ioctx(struct work_struct *work) { struct kioctx *ctx = container_of(work, struct kioctx, free_work); @@ -601,6 +608,14 @@ static void free_ioctx(struct work_struct *work) kmem_cache_free(kioctx_cachep, ctx); } +static void free_ioctx_rcufn(struct rcu_head *head) +{ + struct kioctx *ctx = container_of(head, struct kioctx, free_rcu); + + INIT_WORK(&ctx->free_work, free_ioctx); + schedule_work(&ctx->free_work); +} + static void free_ioctx_reqs(struct percpu_ref *ref) { struct kioctx *ctx = container_of(ref, struct kioctx, reqs); @@ -609,8 +624,8 @@ static void free_ioctx_reqs(struct percpu_ref *ref) if (ctx->rq_wait && atomic_dec_and_test(&ctx->rq_wait->count)) complete(&ctx->rq_wait->comp); - INIT_WORK(&ctx->free_work, free_ioctx); - schedule_work(&ctx->free_work); + /* Synchronize against RCU protected table->table[] dereferences */ + call_rcu(&ctx->free_rcu, free_ioctx_rcufn); } /* @@ -838,7 +853,7 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx, table->table[ctx->id] = NULL; spin_unlock(&mm->ioctx_lock); - /* percpu_ref_kill() will do the necessary call_rcu() */ + /* free_ioctx_reqs() will do the necessary RCU synchronization */ wake_up_all(&ctx->wait); /* From d0264c01e7587001a8c4608a5d1818dba9a4c11a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 14 Mar 2018 12:10:17 -0700 Subject: [PATCH 687/942] fs/aio: Use RCU accessors for kioctx_table->table[] While converting ioctx index from a list to a table, db446a08c23d ("aio: convert the ioctx list to table lookup v3") missed tagging kioctx_table->table[] as an array of RCU pointers and using the appropriate RCU accessors. This introduces a small window in the lookup path where init and access may race. Mark kioctx_table->table[] with __rcu and use the approriate RCU accessors when using the field. Signed-off-by: Tejun Heo Reported-by: Jann Horn Fixes: db446a08c23d ("aio: convert the ioctx list to table lookup v3") Cc: Benjamin LaHaise Cc: Linus Torvalds Cc: stable@vger.kernel.org # v3.12+ --- fs/aio.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index eb2e0cfbe2d2..6bcd3fb5265a 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -68,9 +68,9 @@ struct aio_ring { #define AIO_RING_PAGES 8 struct kioctx_table { - struct rcu_head rcu; - unsigned nr; - struct kioctx *table[]; + struct rcu_head rcu; + unsigned nr; + struct kioctx __rcu *table[]; }; struct kioctx_cpu { @@ -330,7 +330,7 @@ static int aio_ring_mremap(struct vm_area_struct *vma) for (i = 0; i < table->nr; i++) { struct kioctx *ctx; - ctx = table->table[i]; + ctx = rcu_dereference(table->table[i]); if (ctx && ctx->aio_ring_file == file) { if (!atomic_read(&ctx->dead)) { ctx->user_id = ctx->mmap_base = vma->vm_start; @@ -666,9 +666,9 @@ static int ioctx_add_table(struct kioctx *ctx, struct mm_struct *mm) while (1) { if (table) for (i = 0; i < table->nr; i++) - if (!table->table[i]) { + if (!rcu_access_pointer(table->table[i])) { ctx->id = i; - table->table[i] = ctx; + rcu_assign_pointer(table->table[i], ctx); spin_unlock(&mm->ioctx_lock); /* While kioctx setup is in progress, @@ -849,8 +849,8 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx *ctx, } table = rcu_dereference_raw(mm->ioctx_table); - WARN_ON(ctx != table->table[ctx->id]); - table->table[ctx->id] = NULL; + WARN_ON(ctx != rcu_access_pointer(table->table[ctx->id])); + RCU_INIT_POINTER(table->table[ctx->id], NULL); spin_unlock(&mm->ioctx_lock); /* free_ioctx_reqs() will do the necessary RCU synchronization */ @@ -895,7 +895,8 @@ void exit_aio(struct mm_struct *mm) skipped = 0; for (i = 0; i < table->nr; ++i) { - struct kioctx *ctx = table->table[i]; + struct kioctx *ctx = + rcu_dereference_protected(table->table[i], true); if (!ctx) { skipped++; @@ -1084,7 +1085,7 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id) if (!table || id >= table->nr) goto out; - ctx = table->table[id]; + ctx = rcu_dereference(table->table[id]); if (ctx && ctx->user_id == ctx_id) { percpu_ref_get(&ctx->users); ret = ctx; From 74b44bbe80b4c62113ac1501482ea1ee40eb9d67 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 14 Mar 2018 12:10:18 -0700 Subject: [PATCH 688/942] RDMAVT: Fix synchronization around percpu_ref rvt_mregion uses percpu_ref for reference counting and RCU to protect accesses from lkey_table. When a rvt_mregion needs to be freed, it first gets unregistered from lkey_table and then rvt_check_refs() is called to wait for in-flight usages before the rvt_mregion is freed. rvt_check_refs() seems to have a couple issues. * It has a fast exit path which tests percpu_ref_is_zero(). However, a percpu_ref reading zero doesn't mean that the object can be released. In fact, the ->release() callback might not even have started executing yet. Proceeding with freeing can lead to use-after-free. * lkey_table is RCU protected but there is no RCU grace period in the free path. percpu_ref uses RCU internally but it's sched-RCU whose grace periods are different from regular RCU. Also, it generally isn't a good idea to depend on internal behaviors like this. To address the above issues, this patch removes the fast exit and adds an explicit synchronize_rcu(). Signed-off-by: Tejun Heo Acked-by: Dennis Dalessandro Cc: Mike Marciniszyn Cc: linux-rdma@vger.kernel.org Cc: Linus Torvalds --- drivers/infiniband/sw/rdmavt/mr.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c index 1b2e5362a3ff..cc429b567d0a 100644 --- a/drivers/infiniband/sw/rdmavt/mr.c +++ b/drivers/infiniband/sw/rdmavt/mr.c @@ -489,11 +489,13 @@ static int rvt_check_refs(struct rvt_mregion *mr, const char *t) unsigned long timeout; struct rvt_dev_info *rdi = ib_to_rvt(mr->pd->device); - if (percpu_ref_is_zero(&mr->refcount)) - return 0; - /* avoid dma mr */ - if (mr->lkey) + if (mr->lkey) { + /* avoid dma mr */ rvt_dereg_clean_qps(mr); + /* @mr was indexed on rcu protected @lkey_table */ + synchronize_rcu(); + } + timeout = wait_for_completion_timeout(&mr->comp, 5 * HZ); if (!timeout) { rvt_pr_err(rdi, From 18a955219bf7d9008ce480d4451b6b8bf4483a22 Mon Sep 17 00:00:00 2001 From: Toshi Kani Date: Tue, 13 Mar 2018 11:03:46 -0600 Subject: [PATCH 689/942] x86/mm: Fix vmalloc_fault to use pXd_large Gratian Crisan reported that vmalloc_fault() crashes when CONFIG_HUGETLBFS is not set since the function inadvertently uses pXn_huge(), which always return 0 in this case. ioremap() does not depend on CONFIG_HUGETLBFS. Fix vmalloc_fault() to call pXd_large() instead. Fixes: f4eafd8bcd52 ("x86/mm: Fix vmalloc_fault() to handle large pages properly") Reported-by: Gratian Crisan Signed-off-by: Toshi Kani Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org Cc: linux-mm@kvack.org Cc: Borislav Petkov Cc: Andy Lutomirski Link: https://lkml.kernel.org/r/20180313170347.3829-2-toshi.kani@hpe.com --- arch/x86/mm/fault.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index c88573d90f3e..25a30b5d6582 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -330,7 +330,7 @@ static noinline int vmalloc_fault(unsigned long address) if (!pmd_k) return -1; - if (pmd_huge(*pmd_k)) + if (pmd_large(*pmd_k)) return 0; pte_k = pte_offset_kernel(pmd_k, address); @@ -475,7 +475,7 @@ static noinline int vmalloc_fault(unsigned long address) if (pud_none(*pud) || pud_pfn(*pud) != pud_pfn(*pud_ref)) BUG(); - if (pud_huge(*pud)) + if (pud_large(*pud)) return 0; pmd = pmd_offset(pud, address); @@ -486,7 +486,7 @@ static noinline int vmalloc_fault(unsigned long address) if (pmd_none(*pmd) || pmd_pfn(*pmd) != pmd_pfn(*pmd_ref)) BUG(); - if (pmd_huge(*pmd)) + if (pmd_large(*pmd)) return 0; pte_ref = pte_offset_kernel(pmd_ref, address); From f3f134f5260ae9ee1f5a4d0a8cc625c6c77655b4 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Mon, 12 Mar 2018 21:26:37 +0200 Subject: [PATCH 690/942] RDMA/mlx5: Fix crash while accessing garbage pointer and freed memory The failure in rereg_mr flow caused to set garbage value (error value) into mr->umem pointer. This pointer is accessed at the release stage and it causes to the following crash. There is not enough to simply change umem to point to NULL, because the MR struct is needed to be accessed during MR deregistration phase, so delay kfree too. [ 6.237617] BUG: unable to handle kernel NULL pointer dereference a 0000000000000228 [ 6.238756] IP: ib_dereg_mr+0xd/0x30 [ 6.239264] PGD 80000000167eb067 P4D 80000000167eb067 PUD 167f9067 PMD 0 [ 6.240320] Oops: 0000 [#1] SMP PTI [ 6.240782] CPU: 0 PID: 367 Comm: dereg Not tainted 4.16.0-rc1-00029-gc198fafe0453 #183 [ 6.242120] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.7.5-0-ge51488c-20140602_164612-nilsson.home.kraxel.org 04/01/2014 [ 6.244504] RIP: 0010:ib_dereg_mr+0xd/0x30 [ 6.245253] RSP: 0018:ffffaf5d001d7d68 EFLAGS: 00010246 [ 6.246100] RAX: 0000000000000000 RBX: ffff95d4172daf00 RCX: 0000000000000000 [ 6.247414] RDX: 00000000ffffffff RSI: 0000000000000001 RDI: ffff95d41a317600 [ 6.248591] RBP: 0000000000000001 R08: 0000000000000000 R09: 0000000000000000 [ 6.249810] R10: ffff95d417033c10 R11: 0000000000000000 R12: ffff95d4172c3a80 [ 6.251121] R13: ffff95d4172c3720 R14: ffff95d4172c3a98 R15: 00000000ffffffff [ 6.252437] FS: 0000000000000000(0000) GS:ffff95d41fc00000(0000) knlGS:0000000000000000 [ 6.253887] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6.254814] CR2: 0000000000000228 CR3: 00000000172b4000 CR4: 00000000000006b0 [ 6.255943] Call Trace: [ 6.256368] remove_commit_idr_uobject+0x1b/0x80 [ 6.257118] uverbs_cleanup_ucontext+0xe4/0x190 [ 6.257855] ib_uverbs_cleanup_ucontext.constprop.14+0x19/0x40 [ 6.258857] ib_uverbs_close+0x2a/0x100 [ 6.259494] __fput+0xca/0x1c0 [ 6.259938] task_work_run+0x84/0xa0 [ 6.260519] do_exit+0x312/0xb40 [ 6.261023] ? __do_page_fault+0x24d/0x490 [ 6.261707] do_group_exit+0x3a/0xa0 [ 6.262267] SyS_exit_group+0x10/0x10 [ 6.262802] do_syscall_64+0x75/0x180 [ 6.263391] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 6.264253] RIP: 0033:0x7f1b39c49488 [ 6.264827] RSP: 002b:00007ffe2de05b68 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 [ 6.266049] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f1b39c49488 [ 6.267187] RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000 [ 6.268377] RBP: 00007f1b39f258e0 R08: 00000000000000e7 R09: ffffffffffffff98 [ 6.269640] R10: 00007f1b3a147260 R11: 0000000000000246 R12: 00007f1b39f258e0 [ 6.270783] R13: 00007f1b39f2ac20 R14: 0000000000000000 R15: 0000000000000000 [ 6.271943] Code: 74 07 31 d2 e9 25 d8 6c 00 b8 da ff ff ff c3 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 8b 07 53 48 8b 5f 08 <48> 8b 80 28 02 00 00 e8 f7 d7 6c 00 85 c0 75 04 3e ff 4b 18 5b [ 6.274927] RIP: ib_dereg_mr+0xd/0x30 RSP: ffffaf5d001d7d68 [ 6.275760] CR2: 0000000000000228 [ 6.276200] ---[ end trace a35641f1c474bd20 ]--- Fixes: e126ba97dba9 ("mlx5: Add driver for Mellanox Connect-IB adapters") Cc: syzkaller Cc: Reported-by: Noa Osherovich Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford --- drivers/infiniband/hw/mlx5/mr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index 1961c6a45437..c51c602f06d6 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c @@ -838,7 +838,8 @@ static int mr_umem_get(struct ib_pd *pd, u64 start, u64 length, *umem = ib_umem_get(pd->uobject->context, start, length, access_flags, 0); err = PTR_ERR_OR_ZERO(*umem); - if (err < 0) { + if (err) { + *umem = NULL; mlx5_ib_err(dev, "umem get failed (%d)\n", err); return err; } @@ -1415,6 +1416,7 @@ int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start, if (err) { mlx5_ib_warn(dev, "Failed to rereg UMR\n"); ib_umem_release(mr->umem); + mr->umem = NULL; clean_mr(dev, mr); return err; } @@ -1498,14 +1500,11 @@ static int clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) u32 key = mr->mmkey.key; err = destroy_mkey(dev, mr); - kfree(mr); if (err) { mlx5_ib_warn(dev, "failed to destroy mkey 0x%x (%d)\n", key, err); return err; } - } else { - mlx5_mr_cache_free(dev, mr); } return 0; @@ -1548,6 +1547,11 @@ static int dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) atomic_sub(npages, &dev->mdev->priv.reg_pages); } + if (!mr->allocated_from_cache) + kfree(mr); + else + mlx5_mr_cache_free(dev, mr); + return 0; } From 8c5c147339d2e201108169327b1f99aa6d57d2cd Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 14 Mar 2018 15:33:06 +0100 Subject: [PATCH 691/942] dm mpath: fix passing integrity data After v4.12 commit e2460f2a4bc7 ("dm: mark targets that pass integrity data"), dm-multipath, e.g. on DIF+DIX SCSI disk paths, does not support block integrity any more. So add it to the whitelist. This is also a pre-requisite to use block integrity with other dm layer(s) on top of multipath, such as kpartx partitions (dm-linear) or LVM. Also, bump target version to reflect this fix. Fixes: e2460f2a4bc7 ("dm: mark targets that pass integrity data") Cc: #4.12+ Bisected-by: Fedor Loshakov Signed-off-by: Steffen Maier Reviewed-by: Hannes Reinecke Reviewed-by: Martin K. Petersen Signed-off-by: Mike Snitzer --- drivers/md/dm-mpath.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 2481c4794ed6..a05a560d3cba 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c @@ -2020,8 +2020,9 @@ static int multipath_busy(struct dm_target *ti) *---------------------------------------------------------------*/ static struct target_type multipath_target = { .name = "multipath", - .version = {1, 12, 0}, - .features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE, + .version = {1, 13, 0}, + .features = DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE | + DM_TARGET_PASSES_INTEGRITY, .module = THIS_MODULE, .ctr = multipath_ctr, .dtr = multipath_dtr, From 9dea9a2ff61c5efb4d4937ae23b14babd25a5547 Mon Sep 17 00:00:00 2001 From: Tatyana Nikolova Date: Mon, 12 Mar 2018 17:14:02 -0500 Subject: [PATCH 692/942] RDMA/core: Do not use invalid destination in determining port reuse cma_port_is_unique() allows local port reuse if the quad (source address and port, destination address and port) for this connection is unique. However, if the destination info is zero or unspecified, it can't make a correct decision but still allows port reuse. For example, sometimes rdma_bind_addr() is called with unspecified destination and reusing the port can lead to creating a connection with a duplicate quad, after the destination is resolved. The issue manifests when MPI scale-up tests hang after the duplicate quad is used. Set the destination address family and add checks for zero destination address and port to prevent source port reuse based on invalid destination. Fixes: 19b752a19dce ("IB/cma: Allow port reuse for rdma_id") Reviewed-by: Sean Hefty Signed-off-by: Tatyana Nikolova Signed-off-by: Shiraz Saleem Signed-off-by: Doug Ledford --- drivers/infiniband/core/cma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index e66963ca58bd..0e7b913254cc 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -3069,7 +3069,8 @@ static int cma_port_is_unique(struct rdma_bind_list *bind_list, continue; /* different dest port -> unique */ - if (!cma_any_port(cur_daddr) && + if (!cma_any_port(daddr) && + !cma_any_port(cur_daddr) && (dport != cur_dport)) continue; @@ -3080,7 +3081,8 @@ static int cma_port_is_unique(struct rdma_bind_list *bind_list, continue; /* different dst address -> unique */ - if (!cma_any_addr(cur_daddr) && + if (!cma_any_addr(daddr) && + !cma_any_addr(cur_daddr) && cma_addr_cmp(daddr, cur_daddr)) continue; @@ -3378,13 +3380,13 @@ int rdma_bind_addr(struct rdma_cm_id *id, struct sockaddr *addr) } #endif } + daddr = cma_dst_addr(id_priv); + daddr->sa_family = addr->sa_family; + ret = cma_get_port(id_priv); if (ret) goto err2; - daddr = cma_dst_addr(id_priv); - daddr->sa_family = addr->sa_family; - return 0; err2: if (id_priv->cma_dev) From 7688f2c3bbf55e52388e37ac5d63ca471a7712e1 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Tue, 13 Mar 2018 11:43:23 +0200 Subject: [PATCH 693/942] RDMA/ucma: Fix access to non-initialized CM_ID object The attempt to join multicast group without ensuring that CMA device exists will lead to the following crash reported by syzkaller. [ 64.076794] BUG: KASAN: null-ptr-deref in rdma_join_multicast+0x26e/0x12c0 [ 64.076797] Read of size 8 at addr 00000000000000b0 by task join/691 [ 64.076797] [ 64.076800] CPU: 1 PID: 691 Comm: join Not tainted 4.16.0-rc1-00219-gb97853b65b93 #23 [ 64.076802] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-proj4 [ 64.076803] Call Trace: [ 64.076809] dump_stack+0x5c/0x77 [ 64.076817] kasan_report+0x163/0x380 [ 64.085859] ? rdma_join_multicast+0x26e/0x12c0 [ 64.086634] rdma_join_multicast+0x26e/0x12c0 [ 64.087370] ? rdma_disconnect+0xf0/0xf0 [ 64.088579] ? __radix_tree_replace+0xc3/0x110 [ 64.089132] ? node_tag_clear+0x81/0xb0 [ 64.089606] ? idr_alloc_u32+0x12e/0x1a0 [ 64.090517] ? __fprop_inc_percpu_max+0x150/0x150 [ 64.091768] ? tracing_record_taskinfo+0x10/0xc0 [ 64.092340] ? idr_alloc+0x76/0xc0 [ 64.092951] ? idr_alloc_u32+0x1a0/0x1a0 [ 64.093632] ? ucma_process_join+0x23d/0x460 [ 64.094510] ucma_process_join+0x23d/0x460 [ 64.095199] ? ucma_migrate_id+0x440/0x440 [ 64.095696] ? futex_wake+0x10b/0x2a0 [ 64.096159] ucma_join_multicast+0x88/0xe0 [ 64.096660] ? ucma_process_join+0x460/0x460 [ 64.097540] ? _copy_from_user+0x5e/0x90 [ 64.098017] ucma_write+0x174/0x1f0 [ 64.098640] ? ucma_resolve_route+0xf0/0xf0 [ 64.099343] ? rb_erase_cached+0x6c7/0x7f0 [ 64.099839] __vfs_write+0xc4/0x350 [ 64.100622] ? perf_syscall_enter+0xe4/0x5f0 [ 64.101335] ? kernel_read+0xa0/0xa0 [ 64.103525] ? perf_sched_cb_inc+0xc0/0xc0 [ 64.105510] ? syscall_exit_register+0x2a0/0x2a0 [ 64.107359] ? __switch_to+0x351/0x640 [ 64.109285] ? fsnotify+0x899/0x8f0 [ 64.111610] ? fsnotify_unmount_inodes+0x170/0x170 [ 64.113876] ? __fsnotify_update_child_dentry_flags+0x30/0x30 [ 64.115813] ? ring_buffer_record_is_on+0xd/0x20 [ 64.117824] ? __fget+0xa8/0xf0 [ 64.119869] vfs_write+0xf7/0x280 [ 64.122001] SyS_write+0xa1/0x120 [ 64.124213] ? SyS_read+0x120/0x120 [ 64.126644] ? SyS_read+0x120/0x120 [ 64.128563] do_syscall_64+0xeb/0x250 [ 64.130732] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 64.132984] RIP: 0033:0x7f5c994ade99 [ 64.135699] RSP: 002b:00007f5c99b97d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 64.138740] RAX: ffffffffffffffda RBX: 00000000200001e4 RCX: 00007f5c994ade99 [ 64.141056] RDX: 00000000000000a0 RSI: 00000000200001c0 RDI: 0000000000000015 [ 64.143536] RBP: 00007f5c99b97ec0 R08: 0000000000000000 R09: 0000000000000000 [ 64.146017] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c99b97fc0 [ 64.148608] R13: 0000000000000000 R14: 00007fff660e1c40 R15: 00007f5c99b989c0 [ 64.151060] [ 64.153703] Disabling lock debugging due to kernel taint [ 64.156032] BUG: unable to handle kernel NULL pointer dereference at 00000000000000b0 [ 64.159066] IP: rdma_join_multicast+0x26e/0x12c0 [ 64.161451] PGD 80000001d0298067 P4D 80000001d0298067 PUD 1dea39067 PMD 0 [ 64.164442] Oops: 0000 [#1] SMP KASAN PTI [ 64.166817] CPU: 1 PID: 691 Comm: join Tainted: G B 4.16.0-rc1-00219-gb97853b65b93 #23 [ 64.170004] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-proj4 [ 64.174985] RIP: 0010:rdma_join_multicast+0x26e/0x12c0 [ 64.177246] RSP: 0018:ffff8801c8207860 EFLAGS: 00010282 [ 64.179901] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffffff94789522 [ 64.183344] RDX: 1ffffffff2d50fa5 RSI: 0000000000000297 RDI: 0000000000000297 [ 64.186237] RBP: ffff8801c8207a50 R08: 0000000000000000 R09: ffffed0039040ea7 [ 64.189328] R10: 0000000000000001 R11: ffffed0039040ea6 R12: 0000000000000000 [ 64.192634] R13: 0000000000000000 R14: ffff8801e2022800 R15: ffff8801d4ac2400 [ 64.196105] FS: 00007f5c99b98700(0000) GS:ffff8801e5d00000(0000) knlGS:0000000000000000 [ 64.199211] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 64.202046] CR2: 00000000000000b0 CR3: 00000001d1c48004 CR4: 00000000003606a0 [ 64.205032] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 64.208221] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 64.211554] Call Trace: [ 64.213464] ? rdma_disconnect+0xf0/0xf0 [ 64.216124] ? __radix_tree_replace+0xc3/0x110 [ 64.219337] ? node_tag_clear+0x81/0xb0 [ 64.222140] ? idr_alloc_u32+0x12e/0x1a0 [ 64.224422] ? __fprop_inc_percpu_max+0x150/0x150 [ 64.226588] ? tracing_record_taskinfo+0x10/0xc0 [ 64.229763] ? idr_alloc+0x76/0xc0 [ 64.232186] ? idr_alloc_u32+0x1a0/0x1a0 [ 64.234505] ? ucma_process_join+0x23d/0x460 [ 64.237024] ucma_process_join+0x23d/0x460 [ 64.240076] ? ucma_migrate_id+0x440/0x440 [ 64.243284] ? futex_wake+0x10b/0x2a0 [ 64.245302] ucma_join_multicast+0x88/0xe0 [ 64.247783] ? ucma_process_join+0x460/0x460 [ 64.250841] ? _copy_from_user+0x5e/0x90 [ 64.253878] ucma_write+0x174/0x1f0 [ 64.257008] ? ucma_resolve_route+0xf0/0xf0 [ 64.259877] ? rb_erase_cached+0x6c7/0x7f0 [ 64.262746] __vfs_write+0xc4/0x350 [ 64.265537] ? perf_syscall_enter+0xe4/0x5f0 [ 64.267792] ? kernel_read+0xa0/0xa0 [ 64.270358] ? perf_sched_cb_inc+0xc0/0xc0 [ 64.272575] ? syscall_exit_register+0x2a0/0x2a0 [ 64.275367] ? __switch_to+0x351/0x640 [ 64.277700] ? fsnotify+0x899/0x8f0 [ 64.280530] ? fsnotify_unmount_inodes+0x170/0x170 [ 64.283156] ? __fsnotify_update_child_dentry_flags+0x30/0x30 [ 64.286182] ? ring_buffer_record_is_on+0xd/0x20 [ 64.288749] ? __fget+0xa8/0xf0 [ 64.291136] vfs_write+0xf7/0x280 [ 64.292972] SyS_write+0xa1/0x120 [ 64.294965] ? SyS_read+0x120/0x120 [ 64.297474] ? SyS_read+0x120/0x120 [ 64.299751] do_syscall_64+0xeb/0x250 [ 64.301826] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 64.304352] RIP: 0033:0x7f5c994ade99 [ 64.306711] RSP: 002b:00007f5c99b97d98 EFLAGS: 00000246 ORIG_RAX: 0000000000000001 [ 64.309577] RAX: ffffffffffffffda RBX: 00000000200001e4 RCX: 00007f5c994ade99 [ 64.312334] RDX: 00000000000000a0 RSI: 00000000200001c0 RDI: 0000000000000015 [ 64.315783] RBP: 00007f5c99b97ec0 R08: 0000000000000000 R09: 0000000000000000 [ 64.318365] R10: 0000000000000000 R11: 0000000000000246 R12: 00007f5c99b97fc0 [ 64.320980] R13: 0000000000000000 R14: 00007fff660e1c40 R15: 00007f5c99b989c0 [ 64.323515] Code: e8 e8 79 08 ff 4c 89 ff 45 0f b6 a7 b8 01 00 00 e8 68 7c 08 ff 49 8b 1f 4d 89 e5 49 c1 e4 04 48 8 [ 64.330753] RIP: rdma_join_multicast+0x26e/0x12c0 RSP: ffff8801c8207860 [ 64.332979] CR2: 00000000000000b0 [ 64.335550] ---[ end trace 0c00c17a408849c1 ]--- Reported-by: Fixes: c8f6a362bf3e ("RDMA/cma: Add multicast communication support") Signed-off-by: Leon Romanovsky Reviewed-by: Sean Hefty Signed-off-by: Doug Ledford --- drivers/infiniband/core/cma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 0e7b913254cc..a5367c5efbe7 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -4175,6 +4175,9 @@ int rdma_join_multicast(struct rdma_cm_id *id, struct sockaddr *addr, struct cma_multicast *mc; int ret; + if (!id->device) + return -EINVAL; + id_priv = container_of(id, struct rdma_id_private, id); if (!cma_comp(id_priv, RDMA_CM_ADDR_BOUND) && !cma_comp(id_priv, RDMA_CM_ADDR_RESOLVED)) From 0c81ffc60d5280991773d17e84bda605387148b1 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Tue, 13 Mar 2018 18:37:27 +0200 Subject: [PATCH 694/942] RDMA/ucma: Don't allow join attempts for unsupported AF family Users can provide garbage while calling to ucma_join_ip_multicast(), it will indirectly cause to rdma_addr_size() return 0, making the call to ucma_process_join(), which had the right checks, but it is better to check the input as early as possible. The following crash from syzkaller revealed it. kernel BUG at lib/string.c:1052! invalid opcode: 0000 [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 0 PID: 4113 Comm: syz-executor0 Not tainted 4.16.0-rc5+ #261 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 RIP: 0010:fortify_panic+0x13/0x20 lib/string.c:1051 RSP: 0018:ffff8801ca81f8f0 EFLAGS: 00010286 RAX: 0000000000000022 RBX: 1ffff10039503f23 RCX: 0000000000000000 RDX: 0000000000000022 RSI: 1ffff10039503ed3 RDI: ffffed0039503f12 RBP: ffff8801ca81f8f0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000006 R11: 0000000000000000 R12: ffff8801ca81f998 R13: ffff8801ca81f938 R14: ffff8801ca81fa58 R15: 000000000000fa00 FS: 0000000000000000(0000) GS:ffff8801db200000(0063) knlGS:000000000a12a900 CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 CR2: 0000000008138024 CR3: 00000001cbb58004 CR4: 00000000001606f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: memcpy include/linux/string.h:344 [inline] ucma_join_ip_multicast+0x36b/0x3b0 drivers/infiniband/core/ucma.c:1421 ucma_write+0x2d6/0x3d0 drivers/infiniband/core/ucma.c:1633 __vfs_write+0xef/0x970 fs/read_write.c:480 vfs_write+0x189/0x510 fs/read_write.c:544 SYSC_write fs/read_write.c:589 [inline] SyS_write+0xef/0x220 fs/read_write.c:581 do_syscall_32_irqs_on arch/x86/entry/common.c:330 [inline] do_fast_syscall_32+0x3ec/0xf9f arch/x86/entry/common.c:392 entry_SYSENTER_compat+0x70/0x7f arch/x86/entry/entry_64_compat.S:139 RIP: 0023:0xf7f9ec99 RSP: 002b:00000000ff8172cc EFLAGS: 00000282 ORIG_RAX: 0000000000000004 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 0000000020000100 RDX: 0000000000000063 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Code: 08 5b 41 5c 41 5d 41 5e 41 5f 5d c3 0f 0b 48 89 df e8 42 2c e3 fb eb de 55 48 89 fe 48 c7 c7 80 75 98 86 48 89 e5 e8 85 95 94 fb <0f> 0b 90 90 90 90 90 90 90 90 90 90 90 55 48 89 e5 41 57 41 56 RIP: fortify_panic+0x13/0x20 lib/string.c:1051 RSP: ffff8801ca81f8f0 Fixes: 5bc2b7b397b0 ("RDMA/ucma: Allow user space to specify AF_IB when joining multicast") Reported-by: Signed-off-by: Leon Romanovsky Reviewed-by: Sean Hefty Signed-off-by: Doug Ledford --- drivers/infiniband/core/ucma.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 3a9d0f5b5881..699a46d4c0c5 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -1349,7 +1349,7 @@ static ssize_t ucma_process_join(struct ucma_file *file, return -ENOSPC; addr = (struct sockaddr *) &cmd->addr; - if (!cmd->addr_size || (cmd->addr_size != rdma_addr_size(addr))) + if (cmd->addr_size != rdma_addr_size(addr)) return -EINVAL; if (cmd->join_flags == RDMA_MC_JOIN_FLAG_FULLMEMBER) @@ -1417,6 +1417,9 @@ static ssize_t ucma_join_ip_multicast(struct ucma_file *file, join_cmd.uid = cmd.uid; join_cmd.id = cmd.id; join_cmd.addr_size = rdma_addr_size((struct sockaddr *) &cmd.addr); + if (!join_cmd.addr_size) + return -EINVAL; + join_cmd.join_flags = RDMA_MC_JOIN_FLAG_FULLMEMBER; memcpy(&join_cmd.addr, &cmd.addr, join_cmd.addr_size); @@ -1432,6 +1435,9 @@ static ssize_t ucma_join_multicast(struct ucma_file *file, if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; + if (!rdma_addr_size((struct sockaddr *)&cmd.addr)) + return -EINVAL; + return ucma_process_join(file, &cmd, out_len); } From 342038d92403b3efa1138a8599666b9f026279d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 9 Mar 2018 14:42:54 +0100 Subject: [PATCH 695/942] drm/amdgpu: fix prime teardown order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere. Signed-off-by: Christian König Reviewed-by: Michel Dänzer CC: stable@vger.kernel.org Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 2 -- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index e48b4ec88c8c..ca6c931dabfa 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -36,8 +36,6 @@ void amdgpu_gem_object_free(struct drm_gem_object *gobj) struct amdgpu_bo *robj = gem_to_amdgpu_bo(gobj); if (robj) { - if (robj->gem_base.import_attach) - drm_prime_gem_destroy(&robj->gem_base, robj->tbo.sg); amdgpu_mn_unregister(robj); amdgpu_bo_unref(&robj); } diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c index 5c4c3e0d527b..1220322c1680 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c @@ -56,6 +56,8 @@ static void amdgpu_ttm_bo_destroy(struct ttm_buffer_object *tbo) amdgpu_bo_kunmap(bo); + if (bo->gem_base.import_attach) + drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg); drm_gem_object_release(&bo->gem_base); amdgpu_bo_unref(&bo->parent); if (!list_empty(&bo->shadow_list)) { From 0f4f715bc6bed3bf14c5cd7d5fe88d443e756b14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 9 Mar 2018 14:44:32 +0100 Subject: [PATCH 696/942] drm/radeon: fix prime teardown order MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We unmapped imported DMA-bufs when the GEM handle was dropped, not when the hardware was done with the buffere. Signed-off-by: Christian König Reviewed-by: Michel Dänzer CC: stable@vger.kernel.org Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_gem.c | 2 -- drivers/gpu/drm/radeon/radeon_object.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index a9962ffba720..27d8e7dd2d06 100644 --- a/drivers/gpu/drm/radeon/radeon_gem.c +++ b/drivers/gpu/drm/radeon/radeon_gem.c @@ -34,8 +34,6 @@ void radeon_gem_object_free(struct drm_gem_object *gobj) struct radeon_bo *robj = gem_to_radeon_bo(gobj); if (robj) { - if (robj->gem_base.import_attach) - drm_prime_gem_destroy(&robj->gem_base, robj->tbo.sg); radeon_mn_unregister(robj); radeon_bo_unref(&robj); } diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c index 15404af9d740..31f5ad605e59 100644 --- a/drivers/gpu/drm/radeon/radeon_object.c +++ b/drivers/gpu/drm/radeon/radeon_object.c @@ -82,6 +82,8 @@ static void radeon_ttm_bo_destroy(struct ttm_buffer_object *tbo) mutex_unlock(&bo->rdev->gem.mutex); radeon_bo_clear_surface_reg(bo); WARN_ON_ONCE(!list_empty(&bo->va)); + if (bo->gem_base.import_attach) + drm_prime_gem_destroy(&bo->gem_base, bo->tbo.sg); drm_gem_object_release(&bo->gem_base); kfree(bo); } From b5e3241316973b9f01228d2fa5b8b2bb157d44aa Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Thu, 8 Mar 2018 09:56:01 -0500 Subject: [PATCH 697/942] drm/amdgpu: save/restore backlight level in legacy dce code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Save/restore the backlight level scratch register in S3/S4 so the backlight level comes back at the previously requested level. Bug: https://bugzilla.kernel.org/show_bug.cgi?id=199047 Fixes: 4ec6ecf48c64d (drm/amdgpu: drop scratch regs save and restore from S3/S4 handling) Acked-by: Michel Dänzer Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 1 + drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/atombios_encoders.h | 5 +++++ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 8 ++++++++ drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 8 ++++++++ 7 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h index 54f06c959340..2264c5c97009 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h @@ -352,6 +352,7 @@ struct amdgpu_mode_info { u16 firmware_flags; /* pointer to backlight encoder */ struct amdgpu_encoder *bl_encoder; + u8 bl_level; /* saved backlight level */ struct amdgpu_audio audio; /* audio stuff */ int num_crtc; /* number of crtcs */ int num_hpd; /* number of hpd pins */ diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c index 2af26d2da127..d702fb8e3427 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.c @@ -34,7 +34,7 @@ #include #include "bif/bif_4_1_d.h" -static u8 +u8 amdgpu_atombios_encoder_get_backlight_level_from_reg(struct amdgpu_device *adev) { u8 backlight_level; @@ -48,7 +48,7 @@ amdgpu_atombios_encoder_get_backlight_level_from_reg(struct amdgpu_device *adev) return backlight_level; } -static void +void amdgpu_atombios_encoder_set_backlight_level_to_reg(struct amdgpu_device *adev, u8 backlight_level) { diff --git a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h index 2bdec40515ce..f77cbdef679e 100644 --- a/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h +++ b/drivers/gpu/drm/amd/amdgpu/atombios_encoders.h @@ -24,6 +24,11 @@ #ifndef __ATOMBIOS_ENCODER_H__ #define __ATOMBIOS_ENCODER_H__ +u8 +amdgpu_atombios_encoder_get_backlight_level_from_reg(struct amdgpu_device *adev); +void +amdgpu_atombios_encoder_set_backlight_level_to_reg(struct amdgpu_device *adev, + u8 backlight_level); u8 amdgpu_atombios_encoder_get_backlight_level(struct amdgpu_encoder *amdgpu_encoder); void diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c index f34bc68aadfb..022f303463fc 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v10_0.c @@ -2921,6 +2921,11 @@ static int dce_v10_0_hw_fini(void *handle) static int dce_v10_0_suspend(void *handle) { + struct amdgpu_device *adev = (struct amdgpu_device *)handle; + + adev->mode_info.bl_level = + amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); + return dce_v10_0_hw_fini(handle); } @@ -2929,6 +2934,9 @@ static int dce_v10_0_resume(void *handle) struct amdgpu_device *adev = (struct amdgpu_device *)handle; int ret; + amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, + adev->mode_info.bl_level); + ret = dce_v10_0_hw_init(handle); /* turn on the BL */ diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c index 26378bd6aba4..800a9f36ab4f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v11_0.c @@ -3047,6 +3047,11 @@ static int dce_v11_0_hw_fini(void *handle) static int dce_v11_0_suspend(void *handle) { + struct amdgpu_device *adev = (struct amdgpu_device *)handle; + + adev->mode_info.bl_level = + amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); + return dce_v11_0_hw_fini(handle); } @@ -3055,6 +3060,9 @@ static int dce_v11_0_resume(void *handle) struct amdgpu_device *adev = (struct amdgpu_device *)handle; int ret; + amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, + adev->mode_info.bl_level); + ret = dce_v11_0_hw_init(handle); /* turn on the BL */ diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c index a712f4b285f6..b8368f69ce1f 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v6_0.c @@ -2787,6 +2787,11 @@ static int dce_v6_0_hw_fini(void *handle) static int dce_v6_0_suspend(void *handle) { + struct amdgpu_device *adev = (struct amdgpu_device *)handle; + + adev->mode_info.bl_level = + amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); + return dce_v6_0_hw_fini(handle); } @@ -2795,6 +2800,9 @@ static int dce_v6_0_resume(void *handle) struct amdgpu_device *adev = (struct amdgpu_device *)handle; int ret; + amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, + adev->mode_info.bl_level); + ret = dce_v6_0_hw_init(handle); /* turn on the BL */ diff --git a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c index c008dc030687..012e0a9ae0ff 100644 --- a/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c +++ b/drivers/gpu/drm/amd/amdgpu/dce_v8_0.c @@ -2819,6 +2819,11 @@ static int dce_v8_0_hw_fini(void *handle) static int dce_v8_0_suspend(void *handle) { + struct amdgpu_device *adev = (struct amdgpu_device *)handle; + + adev->mode_info.bl_level = + amdgpu_atombios_encoder_get_backlight_level_from_reg(adev); + return dce_v8_0_hw_fini(handle); } @@ -2827,6 +2832,9 @@ static int dce_v8_0_resume(void *handle) struct amdgpu_device *adev = (struct amdgpu_device *)handle; int ret; + amdgpu_atombios_encoder_set_backlight_level_to_reg(adev, + adev->mode_info.bl_level); + ret = dce_v8_0_hw_init(handle); /* turn on the BL */ From 7d617264eb22b18d979eac6e85877a141253034e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Fri, 9 Mar 2018 18:26:18 +0100 Subject: [PATCH 698/942] drm/amdgpu/dce: Don't turn off DP sink when disconnected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turning off the sink in this case causes various issues, because userspace expects it to stay on until it turns it off explicitly. Instead, turn the sink off and back on when a display is connected again. This dance seems necessary for link training to work correctly. Bugzilla: https://bugs.freedesktop.org/105308 Cc: stable@vger.kernel.org Reviewed-by: Alex Deucher Signed-off-by: Michel Dänzer Signed-off-by: Alex Deucher --- .../gpu/drm/amd/amdgpu/amdgpu_connectors.c | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c index 74d2efaec52f..7a073ac5f9c6 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c @@ -69,25 +69,18 @@ void amdgpu_connector_hotplug(struct drm_connector *connector) /* don't do anything if sink is not display port, i.e., * passive dp->(dvi|hdmi) adaptor */ - if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { - int saved_dpms = connector->dpms; - /* Only turn off the display if it's physically disconnected */ - if (!amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd)) { - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); - } else if (amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) { - /* Don't try to start link training before we - * have the dpcd */ - if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector)) - return; + if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT && + amdgpu_display_hpd_sense(adev, amdgpu_connector->hpd.hpd) && + amdgpu_atombios_dp_needs_link_train(amdgpu_connector)) { + /* Don't start link training before we have the DPCD */ + if (amdgpu_atombios_dp_get_dpcd(amdgpu_connector)) + return; - /* set it to OFF so that drm_helper_connector_dpms() - * won't return immediately since the current state - * is ON at this point. - */ - connector->dpms = DRM_MODE_DPMS_OFF; - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); - } - connector->dpms = saved_dpms; + /* Turn the connector off and back on immediately, which + * will trigger link training + */ + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); } } } From 42cea83f952499f31e2671c4917be8627617db81 Mon Sep 17 00:00:00 2001 From: Mark Bloch Date: Wed, 14 Mar 2018 09:14:15 +0200 Subject: [PATCH 699/942] IB/mlx5: Fix cleanup order on unload On load we create private CQ/QP/PD in order to be used by UMR, we create those resources after we register ourself as an IB device, and we destroy them after we unregister as an IB device. This was changed by commit 16c1975f1032 ("IB/mlx5: Create profile infrastructure to add and remove stages") which moved the destruction before we unregistration. This allowed to trigger an invalid memory access when unloading mlx5_ib while there are open resources: BUG: unable to handle kernel paging request at 00000001002c012c ... Call Trace: mlx5_ib_post_send_wait+0x75/0x110 [mlx5_ib] __slab_free+0x9a/0x2d0 delay_time_func+0x10/0x10 [mlx5_ib] unreg_umr.isra.15+0x4b/0x50 [mlx5_ib] mlx5_mr_cache_free+0x46/0x150 [mlx5_ib] clean_mr+0xc9/0x190 [mlx5_ib] dereg_mr+0xba/0xf0 [mlx5_ib] ib_dereg_mr+0x13/0x20 [ib_core] remove_commit_idr_uobject+0x16/0x70 [ib_uverbs] uverbs_cleanup_ucontext+0xe8/0x1a0 [ib_uverbs] ib_uverbs_cleanup_ucontext.isra.9+0x19/0x40 [ib_uverbs] ib_uverbs_remove_one+0x162/0x2e0 [ib_uverbs] ib_unregister_device+0xd4/0x190 [ib_core] __mlx5_ib_remove+0x2e/0x40 [mlx5_ib] mlx5_remove_device+0xf5/0x120 [mlx5_core] mlx5_unregister_interface+0x37/0x90 [mlx5_core] mlx5_ib_cleanup+0xc/0x225 [mlx5_ib] SyS_delete_module+0x153/0x230 do_syscall_64+0x62/0x110 entry_SYSCALL_64_after_hwframe+0x21/0x86 ... We restore the original behavior by breaking the UMR stage into two parts, pre and post IB registration stages, this way we can restore the original functionality and maintain clean separation of logic between stages. Fixes: 16c1975f1032 ("IB/mlx5: Create profile infrastructure to add and remove stages") Signed-off-by: Mark Bloch Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford --- drivers/infiniband/hw/mlx5/main.c | 21 ++++++++++++--------- drivers/infiniband/hw/mlx5/mlx5_ib.h | 3 ++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 033b6af90de9..da091de4e69d 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -4860,21 +4860,21 @@ static int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev) return ib_register_device(&dev->ib_dev, NULL); } +static void mlx5_ib_stage_pre_ib_reg_umr_cleanup(struct mlx5_ib_dev *dev) +{ + destroy_umrc_res(dev); +} + static void mlx5_ib_stage_ib_reg_cleanup(struct mlx5_ib_dev *dev) { ib_unregister_device(&dev->ib_dev); } -static int mlx5_ib_stage_umr_res_init(struct mlx5_ib_dev *dev) +static int mlx5_ib_stage_post_ib_reg_umr_init(struct mlx5_ib_dev *dev) { return create_umr_res(dev); } -static void mlx5_ib_stage_umr_res_cleanup(struct mlx5_ib_dev *dev) -{ - destroy_umrc_res(dev); -} - static int mlx5_ib_stage_delay_drop_init(struct mlx5_ib_dev *dev) { init_delay_drop(dev); @@ -4982,12 +4982,15 @@ static const struct mlx5_ib_profile pf_profile = { STAGE_CREATE(MLX5_IB_STAGE_BFREG, mlx5_ib_stage_bfrag_init, mlx5_ib_stage_bfrag_cleanup), + STAGE_CREATE(MLX5_IB_STAGE_PRE_IB_REG_UMR, + NULL, + mlx5_ib_stage_pre_ib_reg_umr_cleanup), STAGE_CREATE(MLX5_IB_STAGE_IB_REG, mlx5_ib_stage_ib_reg_init, mlx5_ib_stage_ib_reg_cleanup), - STAGE_CREATE(MLX5_IB_STAGE_UMR_RESOURCES, - mlx5_ib_stage_umr_res_init, - mlx5_ib_stage_umr_res_cleanup), + STAGE_CREATE(MLX5_IB_STAGE_POST_IB_REG_UMR, + mlx5_ib_stage_post_ib_reg_umr_init, + NULL), STAGE_CREATE(MLX5_IB_STAGE_DELAY_DROP, mlx5_ib_stage_delay_drop_init, mlx5_ib_stage_delay_drop_cleanup), diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h b/drivers/infiniband/hw/mlx5/mlx5_ib.h index 139385129973..a5272499b600 100644 --- a/drivers/infiniband/hw/mlx5/mlx5_ib.h +++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h @@ -739,8 +739,9 @@ enum mlx5_ib_stages { MLX5_IB_STAGE_CONG_DEBUGFS, MLX5_IB_STAGE_UAR, MLX5_IB_STAGE_BFREG, + MLX5_IB_STAGE_PRE_IB_REG_UMR, MLX5_IB_STAGE_IB_REG, - MLX5_IB_STAGE_UMR_RESOURCES, + MLX5_IB_STAGE_POST_IB_REG_UMR, MLX5_IB_STAGE_DELAY_DROP, MLX5_IB_STAGE_CLASS_ATTR, MLX5_IB_STAGE_MAX, From 047fdea6341966a0898e3b16c51f54d4f5ba030a Mon Sep 17 00:00:00 2001 From: Dmitriy Gorokh Date: Fri, 16 Feb 2018 19:51:38 +0000 Subject: [PATCH 700/942] btrfs: Fix NULL pointer exception in find_bio_stripe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On detaching of a disk which is a part of a RAID6 filesystem, the following kernel OOPS may happen: [63122.680461] BTRFS error (device sdo): bdev /dev/sdo errs: wr 0, rd 0, flush 1, corrupt 0, gen 0 [63122.719584] BTRFS warning (device sdo): lost page write due to IO error on /dev/sdo [63122.719587] BTRFS error (device sdo): bdev /dev/sdo errs: wr 1, rd 0, flush 1, corrupt 0, gen 0 [63122.803516] BTRFS warning (device sdo): lost page write due to IO error on /dev/sdo [63122.803519] BTRFS error (device sdo): bdev /dev/sdo errs: wr 2, rd 0, flush 1, corrupt 0, gen 0 [63122.863902] BTRFS critical (device sdo): fatal error on device /dev/sdo [63122.935338] BUG: unable to handle kernel NULL pointer dereference at 0000000000000080 [63122.946554] IP: fail_bio_stripe+0x58/0xa0 [btrfs] [63122.958185] PGD 9ecda067 P4D 9ecda067 PUD b2b37067 PMD 0 [63122.971202] Oops: 0000 [#1] SMP [63123.006760] CPU: 0 PID: 3979 Comm: kworker/u8:9 Tainted: G W 4.14.2-16-scst34x+ #8 [63123.007091] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 [63123.007402] Workqueue: btrfs-worker btrfs_worker_helper [btrfs] [63123.007595] task: ffff880036ea4040 task.stack: ffffc90006384000 [63123.007796] RIP: 0010:fail_bio_stripe+0x58/0xa0 [btrfs] [63123.007968] RSP: 0018:ffffc90006387ad8 EFLAGS: 00010287 [63123.008140] RAX: 0000000000000002 RBX: ffff88004beaa0b8 RCX: ffff8800b2bd5690 [63123.008359] RDX: 0000000000000000 RSI: ffff88007bb43500 RDI: ffff88004beaa000 [63123.008621] RBP: ffffc90006387ae8 R08: 0000000099100000 R09: ffff8800b2bd5600 [63123.008840] R10: 0000000000000004 R11: 0000000000010000 R12: ffff88007bb43500 [63123.009059] R13: 00000000fffffffb R14: ffff880036fc5180 R15: 0000000000000004 [63123.009278] FS: 0000000000000000(0000) GS:ffff8800b7000000(0000) knlGS:0000000000000000 [63123.009564] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [63123.009748] CR2: 0000000000000080 CR3: 00000000b0866000 CR4: 00000000000406f0 [63123.009969] Call Trace: [63123.010085] raid_write_end_io+0x7e/0x80 [btrfs] [63123.010251] bio_endio+0xa1/0x120 [63123.010378] generic_make_request+0x218/0x270 [63123.010921] submit_bio+0x66/0x130 [63123.011073] finish_rmw+0x3fc/0x5b0 [btrfs] [63123.011245] full_stripe_write+0x96/0xc0 [btrfs] [63123.011428] raid56_parity_write+0x117/0x170 [btrfs] [63123.011604] btrfs_map_bio+0x2ec/0x320 [btrfs] [63123.011759] ? ___cache_free+0x1c5/0x300 [63123.011909] __btrfs_submit_bio_done+0x26/0x50 [btrfs] [63123.012087] run_one_async_done+0x9c/0xc0 [btrfs] [63123.012257] normal_work_helper+0x19e/0x300 [btrfs] [63123.012429] btrfs_worker_helper+0x12/0x20 [btrfs] [63123.012656] process_one_work+0x14d/0x350 [63123.012888] worker_thread+0x4d/0x3a0 [63123.013026] ? _raw_spin_unlock_irqrestore+0x15/0x20 [63123.013192] kthread+0x109/0x140 [63123.013315] ? process_scheduled_works+0x40/0x40 [63123.013472] ? kthread_stop+0x110/0x110 [63123.013610] ret_from_fork+0x25/0x30 [63123.014469] RIP: fail_bio_stripe+0x58/0xa0 [btrfs] RSP: ffffc90006387ad8 [63123.014678] CR2: 0000000000000080 [63123.016590] ---[ end trace a295ea7259c17880 ]— This is reproducible in a cycle, where a series of writes is followed by SCSI device delete command. The test may take up to few minutes. Fixes: 74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer and partitions index") [ no signed-off-by provided ] Author: Dmitriy Gorokh Reviewed-by: Liu Bo Reviewed-by: David Sterba Signed-off-by: David Sterba --- fs/btrfs/raid56.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c index dec0907dfb8a..fcfc20de2df3 100644 --- a/fs/btrfs/raid56.c +++ b/fs/btrfs/raid56.c @@ -1370,6 +1370,7 @@ static int find_bio_stripe(struct btrfs_raid_bio *rbio, stripe_start = stripe->physical; if (physical >= stripe_start && physical < stripe_start + rbio->stripe_len && + stripe->dev->bdev && bio->bi_disk == stripe->dev->bdev->bd_disk && bio->bi_partno == stripe->dev->bdev->bd_partno) { return i; From 18bf591ba9753e3e5ba91f38f756a800693408f4 Mon Sep 17 00:00:00 2001 From: Edmund Nadolski Date: Wed, 14 Mar 2018 09:03:11 -0600 Subject: [PATCH 701/942] btrfs: add missing initialization in btrfs_check_shared This patch addresses an issue that causes fiemap to falsely report a shared extent. The test case is as follows: xfs_io -f -d -c "pwrite -b 16k 0 64k" -c "fiemap -v" /media/scratch/file5 sync xfs_io -c "fiemap -v" /media/scratch/file5 which gives the resulting output: wrote 65536/65536 bytes at offset 0 64 KiB, 4 ops; 0.0000 sec (121.359 MiB/sec and 7766.9903 ops/sec) /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x2001 /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x1 This is because btrfs_check_shared calls find_parent_nodes repeatedly in a loop, passing a share_check struct to report the count of shared extent. But btrfs_check_shared does not re-initialize the count value to zero for subsequent calls from the loop, resulting in a false share count value. This is a regressive behavior from 4.13. With proper re-initialization the test result is as follows: wrote 65536/65536 bytes at offset 0 64 KiB, 4 ops; 0.0000 sec (110.035 MiB/sec and 7042.2535 ops/sec) /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x1 /media/scratch/file5: EXT: FILE-OFFSET BLOCK-RANGE TOTAL FLAGS 0: [0..127]: 24576..24703 128 0x1 which corrects the regression. Fixes: 3ec4d3238ab ("btrfs: allow backref search checks for shared extents") Signed-off-by: Edmund Nadolski [ add text from cover letter to changelog ] Signed-off-by: David Sterba --- fs/btrfs/backref.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index f94b2d8c744a..26484648d090 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -1519,6 +1519,7 @@ int btrfs_check_shared(struct btrfs_root *root, u64 inum, u64 bytenr) if (!node) break; bytenr = node->val; + shared.share_count = 0; cond_resched(); } From a7e6c7015bf3e0cb467a2f6c0e1de985ee1a0ecb Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 13 Mar 2018 21:36:22 -0700 Subject: [PATCH 702/942] x86, memremap: fix altmap accounting at free Commit 24b6d4164348 "mm: pass the vmem_altmap to vmemmap_free" converted the vmemmap_free() path to pass the altmap argument all the way through the call chain rather than looking it up based on the page. Unfortunately that ends up over freeing altmap allocated pages in some cases since free_pagetable() is used to free both memmap space and pte space, where only the memmap stored in huge pages uses altmap allocations. Given that altmap allocations for memmap space are special cased in vmemmap_populate_hugepages() add a symmetric / special case free_hugepage_table() to handle altmap freeing, and cleanup the unneeded passing of altmap to leaf functions that do not require it. Without this change the sanity check accounting in devm_memremap_pages_release() will throw a warning with the following signature. nd_pmem pfn10.1: devm_memremap_pages_release: failed to free all reserved pages WARNING: CPU: 44 PID: 3539 at kernel/memremap.c:310 devm_memremap_pages_release+0x1c7/0x220 CPU: 44 PID: 3539 Comm: ndctl Tainted: G L 4.16.0-rc1-linux-stable #7 RIP: 0010:devm_memremap_pages_release+0x1c7/0x220 [..] Call Trace: release_nodes+0x225/0x270 device_release_driver_internal+0x15d/0x210 bus_remove_device+0xe2/0x160 device_del+0x130/0x310 ? klist_release+0x56/0x100 ? nd_region_notify+0xc0/0xc0 [libnvdimm] device_unregister+0x16/0x60 This was missed in testing since not all configurations will trigger this warning. Fixes: 24b6d4164348 ("mm: pass the vmem_altmap to vmemmap_free") Reported-by: Jane Chu Cc: Ross Zwisler Reviewed-by: Christoph Hellwig Signed-off-by: Dan Williams --- arch/x86/mm/init_64.c | 60 ++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 8b72923f1d35..af11a2890235 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -800,17 +800,11 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, #define PAGE_INUSE 0xFD -static void __meminit free_pagetable(struct page *page, int order, - struct vmem_altmap *altmap) +static void __meminit free_pagetable(struct page *page, int order) { unsigned long magic; unsigned int nr_pages = 1 << order; - if (altmap) { - vmem_altmap_free(altmap, nr_pages); - return; - } - /* bootmem page has reserved flag */ if (PageReserved(page)) { __ClearPageReserved(page); @@ -826,8 +820,16 @@ static void __meminit free_pagetable(struct page *page, int order, free_pages((unsigned long)page_address(page), order); } -static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd, +static void __meminit free_hugepage_table(struct page *page, struct vmem_altmap *altmap) +{ + if (altmap) + vmem_altmap_free(altmap, PMD_SIZE / PAGE_SIZE); + else + free_pagetable(page, get_order(PMD_SIZE)); +} + +static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd) { pte_t *pte; int i; @@ -839,14 +841,13 @@ static void __meminit free_pte_table(pte_t *pte_start, pmd_t *pmd, } /* free a pte talbe */ - free_pagetable(pmd_page(*pmd), 0, altmap); + free_pagetable(pmd_page(*pmd), 0); spin_lock(&init_mm.page_table_lock); pmd_clear(pmd); spin_unlock(&init_mm.page_table_lock); } -static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud, - struct vmem_altmap *altmap) +static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud) { pmd_t *pmd; int i; @@ -858,14 +859,13 @@ static void __meminit free_pmd_table(pmd_t *pmd_start, pud_t *pud, } /* free a pmd talbe */ - free_pagetable(pud_page(*pud), 0, altmap); + free_pagetable(pud_page(*pud), 0); spin_lock(&init_mm.page_table_lock); pud_clear(pud); spin_unlock(&init_mm.page_table_lock); } -static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d, - struct vmem_altmap *altmap) +static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d) { pud_t *pud; int i; @@ -877,7 +877,7 @@ static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d, } /* free a pud talbe */ - free_pagetable(p4d_page(*p4d), 0, altmap); + free_pagetable(p4d_page(*p4d), 0); spin_lock(&init_mm.page_table_lock); p4d_clear(p4d); spin_unlock(&init_mm.page_table_lock); @@ -885,7 +885,7 @@ static void __meminit free_pud_table(pud_t *pud_start, p4d_t *p4d, static void __meminit remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end, - struct vmem_altmap *altmap, bool direct) + bool direct) { unsigned long next, pages = 0; pte_t *pte; @@ -916,7 +916,7 @@ remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end, * freed when offlining, or simplely not in use. */ if (!direct) - free_pagetable(pte_page(*pte), 0, altmap); + free_pagetable(pte_page(*pte), 0); spin_lock(&init_mm.page_table_lock); pte_clear(&init_mm, addr, pte); @@ -939,7 +939,7 @@ remove_pte_table(pte_t *pte_start, unsigned long addr, unsigned long end, page_addr = page_address(pte_page(*pte)); if (!memchr_inv(page_addr, PAGE_INUSE, PAGE_SIZE)) { - free_pagetable(pte_page(*pte), 0, altmap); + free_pagetable(pte_page(*pte), 0); spin_lock(&init_mm.page_table_lock); pte_clear(&init_mm, addr, pte); @@ -974,9 +974,8 @@ remove_pmd_table(pmd_t *pmd_start, unsigned long addr, unsigned long end, if (IS_ALIGNED(addr, PMD_SIZE) && IS_ALIGNED(next, PMD_SIZE)) { if (!direct) - free_pagetable(pmd_page(*pmd), - get_order(PMD_SIZE), - altmap); + free_hugepage_table(pmd_page(*pmd), + altmap); spin_lock(&init_mm.page_table_lock); pmd_clear(pmd); @@ -989,9 +988,8 @@ remove_pmd_table(pmd_t *pmd_start, unsigned long addr, unsigned long end, page_addr = page_address(pmd_page(*pmd)); if (!memchr_inv(page_addr, PAGE_INUSE, PMD_SIZE)) { - free_pagetable(pmd_page(*pmd), - get_order(PMD_SIZE), - altmap); + free_hugepage_table(pmd_page(*pmd), + altmap); spin_lock(&init_mm.page_table_lock); pmd_clear(pmd); @@ -1003,8 +1001,8 @@ remove_pmd_table(pmd_t *pmd_start, unsigned long addr, unsigned long end, } pte_base = (pte_t *)pmd_page_vaddr(*pmd); - remove_pte_table(pte_base, addr, next, altmap, direct); - free_pte_table(pte_base, pmd, altmap); + remove_pte_table(pte_base, addr, next, direct); + free_pte_table(pte_base, pmd); } /* Call free_pmd_table() in remove_pud_table(). */ @@ -1033,8 +1031,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end, IS_ALIGNED(next, PUD_SIZE)) { if (!direct) free_pagetable(pud_page(*pud), - get_order(PUD_SIZE), - altmap); + get_order(PUD_SIZE)); spin_lock(&init_mm.page_table_lock); pud_clear(pud); @@ -1048,8 +1045,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end, if (!memchr_inv(page_addr, PAGE_INUSE, PUD_SIZE)) { free_pagetable(pud_page(*pud), - get_order(PUD_SIZE), - altmap); + get_order(PUD_SIZE)); spin_lock(&init_mm.page_table_lock); pud_clear(pud); @@ -1062,7 +1058,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end, pmd_base = pmd_offset(pud, 0); remove_pmd_table(pmd_base, addr, next, direct, altmap); - free_pmd_table(pmd_base, pud, altmap); + free_pmd_table(pmd_base, pud); } if (direct) @@ -1094,7 +1090,7 @@ remove_p4d_table(p4d_t *p4d_start, unsigned long addr, unsigned long end, * to adapt for boot-time switching between 4 and 5 level page tables. */ if (CONFIG_PGTABLE_LEVELS == 5) - free_pud_table(pud_base, p4d, altmap); + free_pud_table(pud_base, p4d); } if (direct) From 5388a508479d8b7e6d24fe5ca2645806d8e3d0f1 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 Feb 2018 21:56:26 +0100 Subject: [PATCH 703/942] infiniband: qplib_fp: fix pointer cast Building for a 32-bit target results in a couple of warnings from casting between a 32-bit pointer and a 64-bit integer: drivers/infiniband/hw/bnxt_re/qplib_fp.c: In function 'bnxt_qplib_service_nq': drivers/infiniband/hw/bnxt_re/qplib_fp.c:333:23: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] bnxt_qplib_arm_srq((struct bnxt_qplib_srq *)q_handle, ^ drivers/infiniband/hw/bnxt_re/qplib_fp.c:336:12: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] (struct bnxt_qplib_srq *)q_handle, ^ In file included from include/linux/byteorder/little_endian.h:5, from arch/arm/include/uapi/asm/byteorder.h:22, from include/asm-generic/bitops/le.h:6, from arch/arm/include/asm/bitops.h:342, from include/linux/bitops.h:38, from include/linux/kernel.h:11, from include/linux/interrupt.h:6, from drivers/infiniband/hw/bnxt_re/qplib_fp.c:39: drivers/infiniband/hw/bnxt_re/qplib_fp.c: In function 'bnxt_qplib_create_srq': include/uapi/linux/byteorder/little_endian.h:31:43: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] #define __cpu_to_le64(x) ((__force __le64)(__u64)(x)) ^ include/linux/byteorder/generic.h:86:21: note: in expansion of macro '__cpu_to_le64' #define cpu_to_le64 __cpu_to_le64 ^~~~~~~~~~~~~ drivers/infiniband/hw/bnxt_re/qplib_fp.c:569:19: note: in expansion of macro 'cpu_to_le64' req.srq_handle = cpu_to_le64(srq); Using a uintptr_t as an intermediate works on all architectures. Fixes: 37cb11acf1f7 ("RDMA/bnxt_re: Add SRQ support for Broadcom adapters") Signed-off-by: Arnd Bergmann Signed-off-by: Jason Gunthorpe --- drivers/infiniband/hw/bnxt_re/qplib_fp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index 06b42c880fd4..3a78faba8d91 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c @@ -243,7 +243,7 @@ static void bnxt_qplib_service_nq(unsigned long data) u32 sw_cons, raw_cons; u16 type; int budget = nq->budget; - u64 q_handle; + uintptr_t q_handle; /* Service the NQ until empty */ raw_cons = hwq->cons; @@ -526,7 +526,7 @@ int bnxt_qplib_create_srq(struct bnxt_qplib_res *res, /* Configure the request */ req.dpi = cpu_to_le32(srq->dpi->dpi); - req.srq_handle = cpu_to_le64(srq); + req.srq_handle = cpu_to_le64((uintptr_t)srq); req.srq_size = cpu_to_le16((u16)srq->hwq.max_elements); pbl = &srq->hwq.pbl[PBL_LVL_0]; From bd8602ca42f6d8b25392a8f2a0e7be34e1206618 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 Feb 2018 21:56:27 +0100 Subject: [PATCH 704/942] infiniband: bnxt_re: use BIT_ULL() for 64-bit bit masks On 32-bit targets, we otherwise get a warning about an impossible constant integer expression: In file included from include/linux/kernel.h:11, from include/linux/interrupt.h:6, from drivers/infiniband/hw/bnxt_re/ib_verbs.c:39: drivers/infiniband/hw/bnxt_re/ib_verbs.c: In function 'bnxt_re_query_device': include/linux/bitops.h:7:24: error: left shift count >= width of type [-Werror=shift-count-overflow] #define BIT(nr) (1UL << (nr)) ^~ drivers/infiniband/hw/bnxt_re/bnxt_re.h:61:34: note: in expansion of macro 'BIT' #define BNXT_RE_MAX_MR_SIZE_HIGH BIT(39) ^~~ drivers/infiniband/hw/bnxt_re/bnxt_re.h:62:30: note: in expansion of macro 'BNXT_RE_MAX_MR_SIZE_HIGH' #define BNXT_RE_MAX_MR_SIZE BNXT_RE_MAX_MR_SIZE_HIGH ^~~~~~~~~~~~~~~~~~~~~~~~ drivers/infiniband/hw/bnxt_re/ib_verbs.c:149:25: note: in expansion of macro 'BNXT_RE_MAX_MR_SIZE' ib_attr->max_mr_size = BNXT_RE_MAX_MR_SIZE; ^~~~~~~~~~~~~~~~~~~ Fixes: 872f3578241d ("RDMA/bnxt_re: Add support for MRs with Huge pages") Signed-off-by: Arnd Bergmann Signed-off-by: Jason Gunthorpe --- drivers/infiniband/hw/bnxt_re/bnxt_re.h | 4 ++-- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h index 3eb7a8387116..96f76896488d 100644 --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h @@ -57,8 +57,8 @@ #define BNXT_RE_PAGE_SIZE_8M BIT(BNXT_RE_PAGE_SHIFT_8M) #define BNXT_RE_PAGE_SIZE_1G BIT(BNXT_RE_PAGE_SHIFT_1G) -#define BNXT_RE_MAX_MR_SIZE_LOW BIT(BNXT_RE_PAGE_SHIFT_1G) -#define BNXT_RE_MAX_MR_SIZE_HIGH BIT(39) +#define BNXT_RE_MAX_MR_SIZE_LOW BIT_ULL(BNXT_RE_PAGE_SHIFT_1G) +#define BNXT_RE_MAX_MR_SIZE_HIGH BIT_ULL(39) #define BNXT_RE_MAX_MR_SIZE BNXT_RE_MAX_MR_SIZE_HIGH #define BNXT_RE_MAX_QPC_COUNT (64 * 1024) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 0dd75f449872..8301d7e5fa8c 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -3598,7 +3598,7 @@ struct ib_mr *bnxt_re_reg_user_mr(struct ib_pd *ib_pd, u64 start, u64 length, int umem_pgs, page_shift, rc; if (length > BNXT_RE_MAX_MR_SIZE) { - dev_err(rdev_to_dev(rdev), "MR Size: %lld > Max supported:%ld\n", + dev_err(rdev_to_dev(rdev), "MR Size: %lld > Max supported:%lld\n", length, BNXT_RE_MAX_MR_SIZE); return ERR_PTR(-ENOMEM); } From 3e04040df6d4613a8af5a80882d5f7f298f49810 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 14 Mar 2018 19:29:37 +0000 Subject: [PATCH 705/942] Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment" This reverts commit 864b75f9d6b0100bb24fdd9a20d156e7cda9b5ae. Commit 864b75f9d6b0 ("mm/page_alloc: fix memmap_init_zone pageblock alignment") modified the logic in memmap_init_zone() to initialize struct pages associated with invalid PFNs, to appease a VM_BUG_ON() in move_freepages(), which is redundant by its own admission, and dereferences struct page fields to obtain the zone without checking whether the struct pages in question are valid to begin with. Commit 864b75f9d6b0 only makes it worse, since the rounding it does may cause pfn assume the same value it had in a prior iteration of the loop, resulting in an infinite loop and a hang very early in the boot. Also, since it doesn't perform the same rounding on start_pfn itself but only on intermediate values following an invalid PFN, we may still hit the same VM_BUG_ON() as before. So instead, let's fix this at the core, and ensure that the BUG check doesn't dereference struct page fields of invalid pages. Fixes: 864b75f9d6b0 ("mm/page_alloc: fix memmap_init_zone pageblock alignment") Tested-by: Jan Glauber Tested-by: Shanker Donthineni Cc: Daniel Vacek Cc: Mel Gorman Cc: Michal Hocko Cc: Paul Burton Cc: Pavel Tatashin Cc: Vlastimil Babka Cc: Andrew Morton Signed-off-by: Ard Biesheuvel Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3d974cb2a1a1..635d7dd29d7f 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1910,7 +1910,9 @@ static int move_freepages(struct zone *zone, * Remove at a later date when no bug reports exist related to * grouping pages by mobility */ - VM_BUG_ON(page_zone(start_page) != page_zone(end_page)); + VM_BUG_ON(pfn_valid(page_to_pfn(start_page)) && + pfn_valid(page_to_pfn(end_page)) && + page_zone(start_page) != page_zone(end_page)); #endif if (num_movable) @@ -5359,14 +5361,9 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, /* * Skip to the pfn preceding the next valid one (or * end_pfn), such that we hit a valid pfn (or end_pfn) - * on our next iteration of the loop. Note that it needs - * to be pageblock aligned even when the region itself - * is not. move_freepages_block() can shift ahead of - * the valid region but still depends on correct page - * metadata. + * on our next iteration of the loop. */ - pfn = (memblock_next_valid_pfn(pfn, end_pfn) & - ~(pageblock_nr_pages-1)) - 1; + pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; #endif continue; } From 8df3aaaf9b5f8bdfc4036695fa22f35b45b4d92f Mon Sep 17 00:00:00 2001 From: Joern Engel Date: Tue, 13 Mar 2018 11:36:49 -0700 Subject: [PATCH 706/942] btree: avoid variable-length allocations geo->keylen cannot be larger than 4. So we might as well make fixed-size allocations. Given the one remaining user, geo->keylen cannot even be larger than 1. Logfs used to have 64bit and 128bit keys, tcm_qla2xxx only has 32bit keys. But let's not break the code if we don't have to. Signed-off-by: Joern Engel Signed-off-by: Linus Torvalds --- lib/btree.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/btree.c b/lib/btree.c index f93a945274af..590facba2c50 100644 --- a/lib/btree.c +++ b/lib/btree.c @@ -3,7 +3,7 @@ * * As should be obvious for Linux kernel code, license is GPLv2 * - * Copyright (c) 2007-2008 Joern Engel + * Copyright (c) 2007-2008 Joern Engel * Bits and pieces stolen from Peter Zijlstra's code, which is * Copyright 2007, Red Hat Inc. Peter Zijlstra * GPLv2 @@ -76,6 +76,8 @@ struct btree_geo btree_geo128 = { }; EXPORT_SYMBOL_GPL(btree_geo128); +#define MAX_KEYLEN (2 * LONG_PER_U64) + static struct kmem_cache *btree_cachep; void *btree_alloc(gfp_t gfp_mask, void *pool_data) @@ -313,7 +315,7 @@ void *btree_get_prev(struct btree_head *head, struct btree_geo *geo, { int i, height; unsigned long *node, *oldnode; - unsigned long *retry_key = NULL, key[geo->keylen]; + unsigned long *retry_key = NULL, key[MAX_KEYLEN]; if (keyzero(geo, __key)) return NULL; @@ -639,8 +641,8 @@ EXPORT_SYMBOL_GPL(btree_remove); int btree_merge(struct btree_head *target, struct btree_head *victim, struct btree_geo *geo, gfp_t gfp) { - unsigned long key[geo->keylen]; - unsigned long dup[geo->keylen]; + unsigned long key[MAX_KEYLEN]; + unsigned long dup[MAX_KEYLEN]; void *val; int err; From ef75c685869ea2059f85855a7dc00148a704c36c Mon Sep 17 00:00:00 2001 From: fred gao Date: Thu, 15 Mar 2018 13:21:10 +0800 Subject: [PATCH 707/942] drm/i915/gvt: Correct the privilege shadow batch buffer address Once the ring buffer is copied to ring_scan_buffer and scanned, the shadow batch buffer start address is only updated into ring_scan_buffer, not the real ring address allocated through intel_ring_begin in later copy_workload_to_ring_buffer. This patch is only to set the right shadow batch buffer address from Ring buffer, not include the shadow_wa_ctx. v2: - refine some comments. (Zhenyu) v3: - fix typo in title. (Zhenyu) v4: - remove the unnecessary comments. (Zhenyu) - add comments in bb_start_cmd_va update. (Zhenyu) Fixes: 0a53bc07f044 ("drm/i915/gvt: Separate cmd scan from request allocation") Cc: stable@vger.kernel.org # v4.15 Cc: Zhenyu Wang Cc: Yulei Zhang Signed-off-by: fred gao Signed-off-by: Zhenyu Wang --- drivers/gpu/drm/i915/gvt/cmd_parser.c | 8 ++++++++ drivers/gpu/drm/i915/gvt/scheduler.c | 11 +++++++++++ drivers/gpu/drm/i915/gvt/scheduler.h | 1 + 3 files changed, 20 insertions(+) diff --git a/drivers/gpu/drm/i915/gvt/cmd_parser.c b/drivers/gpu/drm/i915/gvt/cmd_parser.c index c8454ac43fae..db6b94dda5df 100644 --- a/drivers/gpu/drm/i915/gvt/cmd_parser.c +++ b/drivers/gpu/drm/i915/gvt/cmd_parser.c @@ -471,6 +471,7 @@ struct parser_exec_state { * used when ret from 2nd level batch buffer */ int saved_buf_addr_type; + bool is_ctx_wa; struct cmd_info *info; @@ -1715,6 +1716,11 @@ static int perform_bb_shadow(struct parser_exec_state *s) bb->accessing = true; bb->bb_start_cmd_va = s->ip_va; + if ((s->buf_type == BATCH_BUFFER_INSTRUCTION) && (!s->is_ctx_wa)) + bb->bb_offset = s->ip_va - s->rb_va; + else + bb->bb_offset = 0; + /* * ip_va saves the virtual address of the shadow batch buffer, while * ip_gma saves the graphics address of the original batch buffer. @@ -2571,6 +2577,7 @@ static int scan_workload(struct intel_vgpu_workload *workload) s.ring_tail = gma_tail; s.rb_va = workload->shadow_ring_buffer_va; s.workload = workload; + s.is_ctx_wa = false; if ((bypass_scan_mask & (1 << workload->ring_id)) || gma_head == gma_tail) @@ -2624,6 +2631,7 @@ static int scan_wa_ctx(struct intel_shadow_wa_ctx *wa_ctx) s.ring_tail = gma_tail; s.rb_va = wa_ctx->indirect_ctx.shadow_va; s.workload = workload; + s.is_ctx_wa = true; if (!intel_gvt_ggtt_validate_range(s.vgpu, s.ring_start, s.ring_size)) { ret = -EINVAL; diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index 8caf72c1e794..fdf1c0bf0d55 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c @@ -426,6 +426,17 @@ static int prepare_shadow_batch_buffer(struct intel_vgpu_workload *workload) goto err; } + /* For privilge batch buffer and not wa_ctx, the bb_start_cmd_va + * is only updated into ring_scan_buffer, not real ring address + * allocated in later copy_workload_to_ring_buffer. pls be noted + * shadow_ring_buffer_va is now pointed to real ring buffer va + * in copy_workload_to_ring_buffer. + */ + + if (bb->bb_offset) + bb->bb_start_cmd_va = workload->shadow_ring_buffer_va + + bb->bb_offset; + /* relocate shadow batch buffer */ bb->bb_start_cmd_va[1] = i915_ggtt_offset(bb->vma); if (gmadr_bytes == 8) diff --git a/drivers/gpu/drm/i915/gvt/scheduler.h b/drivers/gpu/drm/i915/gvt/scheduler.h index 2603336b7c6d..a79a4f60637e 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.h +++ b/drivers/gpu/drm/i915/gvt/scheduler.h @@ -124,6 +124,7 @@ struct intel_vgpu_shadow_bb { u32 *bb_start_cmd_va; unsigned int clflush; bool accessing; + unsigned long bb_offset; }; #define workload_q_head(vgpu, ring_id) \ From 850555d1d31e45fc3e9a2982f81717387e8d5e1b Mon Sep 17 00:00:00 2001 From: Zhenyu Wang Date: Wed, 14 Feb 2018 11:35:01 +0800 Subject: [PATCH 708/942] drm/i915/gvt: fix user copy warning by whitelist workload rb_tail field This is to fix warning got as: [ 6730.476938] ------------[ cut here ]------------ [ 6730.476979] Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLAB object 'gvt-g_vgpu_workload' (offset 120, size 4)! [ 6730.477021] WARNING: CPU: 2 PID: 441 at mm/usercopy.c:81 usercopy_warn+0x7e/0xa0 [ 6730.477042] Modules linked in: tun(E) bridge(E) stp(E) llc(E) kvmgt(E) x86_pkg_temp_thermal(E) vfio_mdev(E) intel_powerclamp(E) mdev(E) coretemp(E) vfio_iommu_type1(E) vfio(E) kvm_intel(E) kvm(E) hid_generic(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) usbhid(E) i915(E) crc32c_intel(E) hid(E) ghash_clmulni_intel(E) pcbc(E) aesni_intel(E) aes_x86_64(E) crypto_simd(E) cryptd(E) glue_helper(E) intel_cstate(E) idma64(E) evdev(E) virt_dma(E) iTCO_wdt(E) intel_uncore(E) intel_rapl_perf(E) intel_lpss_pci(E) sg(E) shpchp(E) mei_me(E) pcspkr(E) iTCO_vendor_support(E) intel_lpss(E) intel_pch_thermal(E) prime_numbers(E) mei(E) mfd_core(E) video(E) acpi_pad(E) button(E) binfmt_misc(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc16(E) mbcache(E) jbd2(E) fscrypto(E) sd_mod(E) e1000e(E) xhci_pci(E) sdhci_pci(E) [ 6730.477244] ptp(E) cqhci(E) xhci_hcd(E) pps_core(E) sdhci(E) mmc_core(E) i2c_i801(E) usbcore(E) thermal(E) fan(E) [ 6730.477276] CPU: 2 PID: 441 Comm: gvt workload 0 Tainted: G E 4.16.0-rc1-gvt-staging-0213+ #127 [ 6730.477303] Hardware name: /NUC6i5SYB, BIOS SYSKLi35.86A.0039.2016.0316.1747 03/16/2016 [ 6730.477326] RIP: 0010:usercopy_warn+0x7e/0xa0 [ 6730.477340] RSP: 0018:ffffba6301223d18 EFLAGS: 00010286 [ 6730.477355] RAX: 0000000000000000 RBX: ffff8f41caae9838 RCX: 0000000000000006 [ 6730.477375] RDX: 0000000000000007 RSI: 0000000000000082 RDI: ffff8f41dad166f0 [ 6730.477395] RBP: 0000000000000004 R08: 0000000000000576 R09: 0000000000000000 [ 6730.477415] R10: ffffffffb1293fb2 R11: 00000000ffffffff R12: 0000000000000001 [ 6730.477447] R13: ffff8f41caae983c R14: ffff8f41caae9838 R15: 00007f183ca2b000 [ 6730.477467] FS: 0000000000000000(0000) GS:ffff8f41dad00000(0000) knlGS:0000000000000000 [ 6730.477489] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 6730.477506] CR2: 0000559462817291 CR3: 000000028b46c006 CR4: 00000000003626e0 [ 6730.477526] Call Trace: [ 6730.477537] __check_object_size+0x9c/0x1a0 [ 6730.477562] __kvm_write_guest_page+0x45/0x90 [kvm] [ 6730.477585] kvm_write_guest+0x46/0x80 [kvm] [ 6730.477599] kvmgt_rw_gpa+0x9b/0xf0 [kvmgt] [ 6730.477642] workload_thread+0xa38/0x1040 [i915] [ 6730.477659] ? do_wait_intr_irq+0xc0/0xc0 [ 6730.477673] ? finish_wait+0x80/0x80 [ 6730.477707] ? clean_workloads+0x120/0x120 [i915] [ 6730.477722] kthread+0x111/0x130 [ 6730.477733] ? _kthread_create_worker_on_cpu+0x60/0x60 [ 6730.477750] ? exit_to_usermode_loop+0x6f/0xb0 [ 6730.477766] ret_from_fork+0x35/0x40 [ 6730.477777] Code: 48 c7 c0 20 e3 25 b1 48 0f 44 c2 41 50 51 41 51 48 89 f9 49 89 f1 4d 89 d8 4c 89 d2 48 89 c6 48 c7 c7 78 e3 25 b1 e8 b2 bc e4 ff <0f> ff 48 83 c4 18 c3 48 c7 c6 09 d0 26 b1 49 89 f1 49 89 f3 eb [ 6730.477849] ---[ end trace cae869c1c323e45a ]--- By whitelist guest page write from workload struct allocated from kmem cache. Reviewed-by: Hang Yuan Signed-off-by: Zhenyu Wang (cherry picked from commit 5627705406874df57fdfad3b4e0c9aedd3b007df) --- drivers/gpu/drm/i915/gvt/scheduler.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index fdf1c0bf0d55..d74d6f05c62c 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++ b/drivers/gpu/drm/i915/gvt/scheduler.c @@ -1105,10 +1105,12 @@ int intel_vgpu_setup_submission(struct intel_vgpu *vgpu) bitmap_zero(s->shadow_ctx_desc_updated, I915_NUM_ENGINES); - s->workloads = kmem_cache_create("gvt-g_vgpu_workload", - sizeof(struct intel_vgpu_workload), 0, - SLAB_HWCACHE_ALIGN, - NULL); + s->workloads = kmem_cache_create_usercopy("gvt-g_vgpu_workload", + sizeof(struct intel_vgpu_workload), 0, + SLAB_HWCACHE_ALIGN, + offsetof(struct intel_vgpu_workload, rb_tail), + sizeof_field(struct intel_vgpu_workload, rb_tail), + NULL); if (!s->workloads) { ret = -ENOMEM; From e74ef2194b41ba5e511fab29fe5ff00e72d2f42a Mon Sep 17 00:00:00 2001 From: Bastian Stender Date: Thu, 8 Mar 2018 15:08:11 +0100 Subject: [PATCH 709/942] mmc: block: fix updating ext_csd caches on ioctl call PARTITION_CONFIG is cached in mmc_card->ext_csd.part_config and the currently active partition in mmc_blk_data->part_curr. These caches do not always reflect changes if the ioctl call modifies the PARTITION_CONFIG registers, e.g. by changing BOOT_PARTITION_ENABLE. Write the PARTITION_CONFIG value extracted from the ioctl call to the cache and update the currently active partition accordingly. This ensures that the user space cannot change the values behind the kernel's back. The next call to mmc_blk_part_switch() will operate on the data set by the ioctl and reflect the changes appropriately. Signed-off-by: Bastian Stender Signed-off-by: Jan Luebbe Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- drivers/mmc/core/block.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 20135a5de748..2cfb963d9f37 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -72,6 +72,7 @@ MODULE_ALIAS("mmc:block"); #define MMC_BLK_TIMEOUT_MS (10 * 1000) #define MMC_SANITIZE_REQ_TIMEOUT 240000 #define MMC_EXTRACT_INDEX_FROM_ARG(x) ((x & 0x00FF0000) >> 16) +#define MMC_EXTRACT_VALUE_FROM_ARG(x) ((x & 0x0000FF00) >> 8) #define mmc_req_rel_wr(req) ((req->cmd_flags & REQ_FUA) && \ (rq_data_dir(req) == WRITE)) @@ -586,6 +587,24 @@ static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md, return data.error; } + /* + * Make sure the cache of the PARTITION_CONFIG register and + * PARTITION_ACCESS bits is updated in case the ioctl ext_csd write + * changed it successfully. + */ + if ((MMC_EXTRACT_INDEX_FROM_ARG(cmd.arg) == EXT_CSD_PART_CONFIG) && + (cmd.opcode == MMC_SWITCH)) { + struct mmc_blk_data *main_md = dev_get_drvdata(&card->dev); + u8 value = MMC_EXTRACT_VALUE_FROM_ARG(cmd.arg); + + /* + * Update cache so the next mmc_blk_part_switch call operates + * on up-to-date data. + */ + card->ext_csd.part_config = value; + main_md->part_curr = value & EXT_CSD_PART_CONFIG_ACC_MASK; + } + /* * According to the SD specs, some commands require a delay after * issuing the command. From e22842dd64bf86753d3f2b6ea474d73fc1e6ca24 Mon Sep 17 00:00:00 2001 From: Jaehoon Chung Date: Fri, 9 Mar 2018 15:10:21 +0900 Subject: [PATCH 710/942] mmc: dw_mmc: exynos: fix the suspend/resume issue for exynos5433 Before enabling the clock, dwmmc exynos driver is trying to access the register. Then the kernel panic can be occurred. Signed-off-by: Jaehoon Chung Reviewed-by: Chanwoo Choi Tested-by: Chanwoo Choi Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- drivers/mmc/host/dw_mmc-exynos.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c index fa41d9422d57..a84aa3f1ae85 100644 --- a/drivers/mmc/host/dw_mmc-exynos.c +++ b/drivers/mmc/host/dw_mmc-exynos.c @@ -165,9 +165,15 @@ static void dw_mci_exynos_set_clksel_timing(struct dw_mci *host, u32 timing) static int dw_mci_exynos_runtime_resume(struct device *dev) { struct dw_mci *host = dev_get_drvdata(dev); + int ret; + + ret = dw_mci_runtime_resume(dev); + if (ret) + return ret; dw_mci_exynos_config_smu(host); - return dw_mci_runtime_resume(dev); + + return ret; } /** From dbe7dc6b9b28f5b012b0bedc372aa0c52521f3e4 Mon Sep 17 00:00:00 2001 From: Dirk Behme Date: Wed, 14 Mar 2018 14:50:09 +0000 Subject: [PATCH 711/942] mmc: core: Disable HPI for certain Micron (Numonyx) eMMC cards Certain Micron eMMC v4.5 cards might get broken when HPI feature is used and hence this patch disables the HPI feature for such buggy cards. In U-Boot, these cards are reported as Manufacturer: Micron (ID: 0xFE) OEM: 0x4E Name: MMC32G Revision: 19 (0x13) Serial: 959241022 Manufact. date: 8/2015 (0x82) CRC: 0x00 Tran Speed: 52000000 Rd Block Len: 512 MMC version 4.5 High Capacity: Yes Capacity: 29.1 GiB Boot Partition Size: 16 MiB Bus Width: 8-bit According to JEDEC JEP106 manufacturer 0xFE is Numonyx, which was bought by Micron. Signed-off-by: Dirk Behme Signed-off-by: Mark Craske Cc: # 4.8+ Signed-off-by: Ulf Hansson --- drivers/mmc/core/card.h | 1 + drivers/mmc/core/quirks.h | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/drivers/mmc/core/card.h b/drivers/mmc/core/card.h index 79a5b985ccf5..9c821eedd156 100644 --- a/drivers/mmc/core/card.h +++ b/drivers/mmc/core/card.h @@ -82,6 +82,7 @@ struct mmc_fixup { #define CID_MANFID_APACER 0x27 #define CID_MANFID_KINGSTON 0x70 #define CID_MANFID_HYNIX 0x90 +#define CID_MANFID_NUMONYX 0xFE #define END_FIXUP { NULL } diff --git a/drivers/mmc/core/quirks.h b/drivers/mmc/core/quirks.h index 75d317623852..5153577754f0 100644 --- a/drivers/mmc/core/quirks.h +++ b/drivers/mmc/core/quirks.h @@ -109,6 +109,12 @@ static const struct mmc_fixup mmc_ext_csd_fixups[] = { */ MMC_FIXUP_EXT_CSD_REV(CID_NAME_ANY, CID_MANFID_HYNIX, 0x014a, add_quirk, MMC_QUIRK_BROKEN_HPI, 5), + /* + * Certain Micron (Numonyx) eMMC 4.5 cards might get broken when HPI + * feature is used so disable the HPI feature for such buggy cards. + */ + MMC_FIXUP_EXT_CSD_REV(CID_NAME_ANY, CID_MANFID_NUMONYX, + 0x014e, add_quirk, MMC_QUIRK_BROKEN_HPI, 6), END_FIXUP }; From c658dc58c7eaa8569ceb0edd1ddbdfda84fe8aa5 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Thu, 15 Mar 2018 11:22:28 +0200 Subject: [PATCH 712/942] mmc: core: Fix tracepoint print of blk_addr and blksz Swap the positions of blk_addr and blksz in the tracepoint print arguments so that they match the print format. Signed-off-by: Adrian Hunter Fixes: d2f82254e4e8 ("mmc: core: Add members to mmc_request and mmc_data for CQE's") Cc: # 4.14+ Signed-off-by: Ulf Hansson --- include/trace/events/mmc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/trace/events/mmc.h b/include/trace/events/mmc.h index 200f731be557..7b706ff21335 100644 --- a/include/trace/events/mmc.h +++ b/include/trace/events/mmc.h @@ -86,8 +86,8 @@ TRACE_EVENT(mmc_request_start, __entry->stop_flags, __entry->stop_retries, __entry->sbc_opcode, __entry->sbc_arg, __entry->sbc_flags, __entry->sbc_retries, - __entry->blocks, __entry->blk_addr, - __entry->blksz, __entry->data_flags, __entry->tag, + __entry->blocks, __entry->blksz, + __entry->blk_addr, __entry->data_flags, __entry->tag, __entry->can_retune, __entry->doing_retune, __entry->retune_now, __entry->need_retune, __entry->hold_retune, __entry->retune_period) From 8a927d648c2ee20f2fd746d733c5cd76d0fbb0c1 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 15 Mar 2018 11:09:35 +0100 Subject: [PATCH 713/942] drm/tegra: plane: Fix RGB565 format on older Tegra The opaque/alpha format conversion code is currently only looking at XRGB formats because they have an equivalent ARGB format. The opaque format for RGB565 is RGB565 itself, much like the YUV formats map to themselves. Reported-by: Dmitry Osipenko Fixes: ebae8d07435a ("drm/tegra: dc: Implement legacy blending") Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/plane.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c index 36a06a993698..eddaa2f05ed6 100644 --- a/drivers/gpu/drm/tegra/plane.c +++ b/drivers/gpu/drm/tegra/plane.c @@ -297,6 +297,10 @@ int tegra_plane_format_get_alpha(unsigned int opaque, unsigned int *alpha) case WIN_COLOR_DEPTH_B8G8R8X8: *alpha = WIN_COLOR_DEPTH_B8G8R8A8; return 0; + + case WIN_COLOR_DEPTH_B5G6R5: + *alpha = opaque; + return 0; } return -EINVAL; From 3d502067599f0db12e74e6646aee8728efe3e5be Mon Sep 17 00:00:00 2001 From: Ursula Braun Date: Tue, 13 Mar 2018 10:41:54 +0100 Subject: [PATCH 714/942] net/smc: simplify wait when closing listen socket Closing of a listen socket wakes up kernel_accept() of smc_tcp_listen_worker(), and then has to wait till smc_tcp_listen_worker() gives up the internal clcsock. The wait logic introduced with commit 127f49705823 ("net/smc: release clcsock from tcp_listen_worker") might wait longer than necessary. This patch implements the idea to implement the wait just with flush_work(), and gets rid of the extra smc_close_wait_listen_clcsock() function. Fixes: 127f49705823 ("net/smc: release clcsock from tcp_listen_worker") Reported-by: Hans Wippel Signed-off-by: Ursula Braun Signed-off-by: David S. Miller --- net/smc/af_smc.c | 4 ---- net/smc/smc_close.c | 25 +++---------------------- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 8cc97834d4f6..1e0d780855c3 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -978,10 +978,6 @@ out: lsmc->clcsock = NULL; } release_sock(lsk); - /* no more listening, wake up smc_close_wait_listen_clcsock and - * accept - */ - lsk->sk_state_change(lsk); sock_put(&lsmc->sk); /* sock_hold in smc_listen */ } diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c index e339c0186dcf..fa41d9881741 100644 --- a/net/smc/smc_close.c +++ b/net/smc/smc_close.c @@ -30,27 +30,6 @@ static void smc_close_cleanup_listen(struct sock *parent) smc_close_non_accepted(sk); } -static void smc_close_wait_listen_clcsock(struct smc_sock *smc) -{ - DEFINE_WAIT_FUNC(wait, woken_wake_function); - struct sock *sk = &smc->sk; - signed long timeout; - - timeout = SMC_CLOSE_WAIT_LISTEN_CLCSOCK_TIME; - add_wait_queue(sk_sleep(sk), &wait); - do { - release_sock(sk); - if (smc->clcsock) - timeout = wait_woken(&wait, TASK_UNINTERRUPTIBLE, - timeout); - sched_annotate_sleep(); - lock_sock(sk); - if (!smc->clcsock) - break; - } while (timeout); - remove_wait_queue(sk_sleep(sk), &wait); -} - /* wait for sndbuf data being transmitted */ static void smc_close_stream_wait(struct smc_sock *smc, long timeout) { @@ -204,9 +183,11 @@ again: rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR); /* wake up kernel_accept of smc_tcp_listen_worker */ smc->clcsock->sk->sk_data_ready(smc->clcsock->sk); - smc_close_wait_listen_clcsock(smc); } smc_close_cleanup_listen(sk); + release_sock(sk); + flush_work(&smc->tcp_listen_work); + lock_sock(sk); break; case SMC_ACTIVE: smc_close_stream_wait(smc, timeout); From 48519232bea9230d1c5dbbb680d9257d4861bb4c Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko Date: Thu, 15 Mar 2018 04:00:24 +0300 Subject: [PATCH 715/942] drm/tegra: plane: Correct legacy blending Keep old 'dependent' state of unaffected planes, this way new state takes into account current state of unaffected planes. Fixes: ebae8d07435a ("drm/tegra: dc: Implement legacy blending") Signed-off-by: Dmitry Osipenko Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/plane.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tegra/plane.c b/drivers/gpu/drm/tegra/plane.c index eddaa2f05ed6..94dac79ac3c9 100644 --- a/drivers/gpu/drm/tegra/plane.c +++ b/drivers/gpu/drm/tegra/plane.c @@ -334,9 +334,6 @@ void tegra_plane_check_dependent(struct tegra_plane *tegra, unsigned int zpos[2]; unsigned int i; - for (i = 0; i < 3; i++) - state->dependent[i] = false; - for (i = 0; i < 2; i++) zpos[i] = 0; @@ -350,6 +347,8 @@ void tegra_plane_check_dependent(struct tegra_plane *tegra, index = tegra_plane_get_overlap_index(tegra, p); + state->dependent[index] = false; + /* * If any of the other planes is on top of this plane and uses * a format with an alpha component, mark this plane as being From 2681bc79eeb640562c932007bfebbbdc55bf6a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 14 Mar 2018 18:14:04 +0100 Subject: [PATCH 716/942] drm/radeon: Don't turn off DP sink when disconnected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Turning off the sink in this case causes various issues, because userspace expects it to stay on until it turns it off explicitly. Instead, turn the sink off and back on when a display is connected again. This dance seems necessary for link training to work correctly. Bugzilla: https://bugs.freedesktop.org/105308 Cc: stable@vger.kernel.org Reviewed-by: Alex Deucher Signed-off-by: Michel Dänzer Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/radeon_connectors.c | 29 ++++++++-------------- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c index 2e2ca3c6b47d..df9469a8fdb1 100644 --- a/drivers/gpu/drm/radeon/radeon_connectors.c +++ b/drivers/gpu/drm/radeon/radeon_connectors.c @@ -90,25 +90,18 @@ void radeon_connector_hotplug(struct drm_connector *connector) /* don't do anything if sink is not display port, i.e., * passive dp->(dvi|hdmi) adaptor */ - if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) { - int saved_dpms = connector->dpms; - /* Only turn off the display if it's physically disconnected */ - if (!radeon_hpd_sense(rdev, radeon_connector->hpd.hpd)) { - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); - } else if (radeon_dp_needs_link_train(radeon_connector)) { - /* Don't try to start link training before we - * have the dpcd */ - if (!radeon_dp_getdpcd(radeon_connector)) - return; + if (dig_connector->dp_sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT && + radeon_hpd_sense(rdev, radeon_connector->hpd.hpd) && + radeon_dp_needs_link_train(radeon_connector)) { + /* Don't start link training before we have the DPCD */ + if (!radeon_dp_getdpcd(radeon_connector)) + return; - /* set it to OFF so that drm_helper_connector_dpms() - * won't return immediately since the current state - * is ON at this point. - */ - connector->dpms = DRM_MODE_DPMS_OFF; - drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); - } - connector->dpms = saved_dpms; + /* Turn the connector off and back on immediately, which + * will trigger link training + */ + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF); + drm_helper_connector_dpms(connector, DRM_MODE_DPMS_ON); } } } From d1bb88e078c2aec6a8456d7eb28ca572c06e12f3 Mon Sep 17 00:00:00 2001 From: Mikita Lipski Date: Wed, 14 Mar 2018 13:41:29 -0400 Subject: [PATCH 717/942] drm/amdgpu: Use atomic function to disable crtcs with dc enabled This change fixes the deadlock when unloading the driver with displays connected. Signed-off-by: Mikita Lipski Reviewed-by: Andrey Grodzovsky Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index af1b879a9ee9..66cb10cdc7c3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2063,9 +2063,12 @@ void amdgpu_device_fini(struct amdgpu_device *adev) DRM_INFO("amdgpu: finishing device.\n"); adev->shutdown = true; - if (adev->mode_info.mode_config_initialized) - drm_crtc_force_disable_all(adev->ddev); - + if (adev->mode_info.mode_config_initialized){ + if (!amdgpu_device_has_dc_support(adev)) + drm_crtc_force_disable_all(adev->ddev); + else + drm_atomic_helper_shutdown(adev->ddev); + } amdgpu_ib_pool_fini(adev); amdgpu_fence_driver_fini(adev); amdgpu_fbdev_fini(adev); From 746d024c3211813946b319411aeb2b47767f8fb0 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 15 Mar 2018 17:19:57 +0100 Subject: [PATCH 718/942] gpu: ipu-v3: prg: avoid possible array underflow gcc-8 reports that we access an array with a negative index in an error case: drivers/gpu/ipu-v3/ipu-prg.c: In function 'ipu_prg_channel_disable': drivers/gpu/ipu-v3/ipu-prg.c:252:43: error: array subscript -22 is below array bounds of 'struct ipu_prg_channel[3]' [-Werror=array-bounds] This moves the range check in front of the first time that variable gets used. Signed-off-by: Arnd Bergmann Signed-off-by: Philipp Zabel --- drivers/gpu/ipu-v3/ipu-prg.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-prg.c b/drivers/gpu/ipu-v3/ipu-prg.c index 97b99500153d..83f9dd934a5d 100644 --- a/drivers/gpu/ipu-v3/ipu-prg.c +++ b/drivers/gpu/ipu-v3/ipu-prg.c @@ -250,10 +250,14 @@ void ipu_prg_channel_disable(struct ipuv3_channel *ipu_chan) { int prg_chan = ipu_prg_ipu_to_prg_chan(ipu_chan->num); struct ipu_prg *prg = ipu_chan->ipu->prg_priv; - struct ipu_prg_channel *chan = &prg->chan[prg_chan]; + struct ipu_prg_channel *chan; u32 val; - if (!chan->enabled || prg_chan < 0) + if (prg_chan < 0) + return; + + chan = &prg->chan[prg_chan]; + if (!chan->enabled) return; pm_runtime_get_sync(prg->dev); @@ -280,13 +284,15 @@ int ipu_prg_channel_configure(struct ipuv3_channel *ipu_chan, { int prg_chan = ipu_prg_ipu_to_prg_chan(ipu_chan->num); struct ipu_prg *prg = ipu_chan->ipu->prg_priv; - struct ipu_prg_channel *chan = &prg->chan[prg_chan]; + struct ipu_prg_channel *chan; u32 val; int ret; if (prg_chan < 0) return prg_chan; + chan = &prg->chan[prg_chan]; + if (chan->enabled) { ipu_pre_update(prg->pres[chan->used_pre], *eba); return 0; From 2ead44a5984b30fad7e6da507cdddb97f0401075 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 13 Feb 2018 17:11:34 -0200 Subject: [PATCH 719/942] drm/imx: ipuv3-plane: Make functions static when possible ipu_plane_state_reset(), ipu_plane_duplicate_state() and ipu_plane_destroy_state() are only used in this file, so make them static. This fixes the following sparse warnings: drivers/gpu/drm/imx/ipuv3-plane.c:275:6: warning: symbol 'ipu_plane_state_reset' was not declared. Should it be static? drivers/gpu/drm/imx/ipuv3-plane.c:295:24: warning: symbol 'ipu_plane_duplicate_state' was not declared. Should it be static? drivers/gpu/drm/imx/ipuv3-plane.c:309:6: warning: symbol 'ipu_plane_destroy_state' was not declared. Should it be static? Signed-off-by: Fabio Estevam Signed-off-by: Philipp Zabel --- drivers/gpu/drm/imx/ipuv3-plane.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index 57ed56d8623f..d9f0a7684ec8 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -272,7 +272,7 @@ static void ipu_plane_destroy(struct drm_plane *plane) kfree(ipu_plane); } -void ipu_plane_state_reset(struct drm_plane *plane) +static void ipu_plane_state_reset(struct drm_plane *plane) { struct ipu_plane_state *ipu_state; @@ -292,7 +292,8 @@ void ipu_plane_state_reset(struct drm_plane *plane) plane->state = &ipu_state->base; } -struct drm_plane_state *ipu_plane_duplicate_state(struct drm_plane *plane) +static struct drm_plane_state * +ipu_plane_duplicate_state(struct drm_plane *plane) { struct ipu_plane_state *state; @@ -306,8 +307,8 @@ struct drm_plane_state *ipu_plane_duplicate_state(struct drm_plane *plane) return &state->base; } -void ipu_plane_destroy_state(struct drm_plane *plane, - struct drm_plane_state *state) +static void ipu_plane_destroy_state(struct drm_plane *plane, + struct drm_plane_state *state) { struct ipu_plane_state *ipu_state = to_ipu_plane_state(state); From a71d3241db6b9430e613cff168611bad97297ba2 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 13 Feb 2018 17:11:35 -0200 Subject: [PATCH 720/942] drm/imx: ipuv3-plane: Include "imx-drm.h" header file ipu_planes_assign_pre() prototype is in "imx-drm.h" header file, so include it to fix the following sparse warning: drivers/gpu/drm/imx/ipuv3-plane.c:729:5: warning: symbol 'ipu_planes_assign_pre' was not declared. Should it be static? Signed-off-by: Fabio Estevam Signed-off-by: Philipp Zabel --- drivers/gpu/drm/imx/ipuv3-plane.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index d9f0a7684ec8..d9113faaa62f 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -22,6 +22,7 @@ #include #include "video/imx-ipu-v3.h" +#include "imx-drm.h" #include "ipuv3-plane.h" struct ipu_plane_state { From 6a055b92de15af987b4027826d43aa103c65a3c4 Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Thu, 15 Mar 2018 10:11:59 +0100 Subject: [PATCH 721/942] drm/imx: move arming of the vblank event to atomic_flush Right now the vblank event completion is racing with the atomic update, which is especially bad when the PRE is in use, as one of the hardware issue workaround might extend the atomic commit for quite some time. If the vblank IRQ happens to trigger during that time, we will prematurely signal the atomic commit completion to userspace, which causes tearing when userspace re-uses a framebuffer we haven't managed to flip away from yet. Signed-off-by: Lucas Stach Signed-off-by: Philipp Zabel --- drivers/gpu/drm/imx/ipuv3-crtc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c index 9a9961802f5c..e83af0f2be86 100644 --- a/drivers/gpu/drm/imx/ipuv3-crtc.c +++ b/drivers/gpu/drm/imx/ipuv3-crtc.c @@ -225,7 +225,11 @@ static void ipu_crtc_atomic_begin(struct drm_crtc *crtc, struct drm_crtc_state *old_crtc_state) { drm_crtc_vblank_on(crtc); +} +static void ipu_crtc_atomic_flush(struct drm_crtc *crtc, + struct drm_crtc_state *old_crtc_state) +{ spin_lock_irq(&crtc->dev->event_lock); if (crtc->state->event) { WARN_ON(drm_crtc_vblank_get(crtc)); @@ -293,6 +297,7 @@ static const struct drm_crtc_helper_funcs ipu_helper_funcs = { .mode_set_nofb = ipu_crtc_mode_set_nofb, .atomic_check = ipu_crtc_atomic_check, .atomic_begin = ipu_crtc_atomic_begin, + .atomic_flush = ipu_crtc_atomic_flush, .atomic_disable = ipu_crtc_atomic_disable, .atomic_enable = ipu_crtc_atomic_enable, }; From d90c76bb61128ed9022b9418c31c4749764b6cd9 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Mar 2018 14:57:19 -0600 Subject: [PATCH 722/942] clk: aspeed: Fix is_enabled for certain clocks Some of the Aspeed clocks are disabled by setting the relevant bit in the "clock stop control" register to one, while others are disabled by setting their bit to zero. The driver already uses a flag per gate to identify this behavior, but doesn't apply it in the clock is_enabled function. Use the existing gate flag to correctly return whether or not a clock is enabled in the aspeed_clk_is_enabled function. Signed-off-by: Eddie James Fixes: 6671507f0fbd ("clk: aspeed: Handle inverse polarity of USB port 1 clock gate") Reviewed-by: Joel Stanley Signed-off-by: Stephen Boyd --- drivers/clk/clk-aspeed.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c index 9f7f931d6b2f..168777175cd1 100644 --- a/drivers/clk/clk-aspeed.c +++ b/drivers/clk/clk-aspeed.c @@ -259,11 +259,12 @@ static int aspeed_clk_is_enabled(struct clk_hw *hw) { struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw); u32 clk = BIT(gate->clock_idx); + u32 enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk; u32 reg; regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); - return (reg & clk) ? 0 : 1; + return ((reg & clk) == enval) ? 1 : 0; } static const struct clk_ops aspeed_clk_gate_ops = { From 8a53fc511c5ec81347b981b438f68c3dde421608 Mon Sep 17 00:00:00 2001 From: Eddie James Date: Thu, 8 Mar 2018 14:57:20 -0600 Subject: [PATCH 723/942] clk: aspeed: Prevent reset if clock is enabled According to the Aspeed specification, the reset and enable sequence should be done when the clock is stopped. The specification doesn't define behavior if the reset is done while the clock is enabled. From testing on the AST2500, the LPC Controller has problems if the clock is reset while enabled. Therefore, check whether the clock is enabled or not before performing the reset and enable sequence in the Aspeed clock driver. Reported-by: Lei Yu Signed-off-by: Eddie James Fixes: 15ed8ce5f84e ("clk: aspeed: Register gated clocks") Reviewed-by: Joel Stanley Signed-off-by: Stephen Boyd --- drivers/clk/clk-aspeed.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/drivers/clk/clk-aspeed.c b/drivers/clk/clk-aspeed.c index 168777175cd1..5eb50c31e455 100644 --- a/drivers/clk/clk-aspeed.c +++ b/drivers/clk/clk-aspeed.c @@ -205,6 +205,18 @@ static const struct aspeed_clk_soc_data ast2400_data = { .calc_pll = aspeed_ast2400_calc_pll, }; +static int aspeed_clk_is_enabled(struct clk_hw *hw) +{ + struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw); + u32 clk = BIT(gate->clock_idx); + u32 enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk; + u32 reg; + + regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); + + return ((reg & clk) == enval) ? 1 : 0; +} + static int aspeed_clk_enable(struct clk_hw *hw) { struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw); @@ -215,6 +227,11 @@ static int aspeed_clk_enable(struct clk_hw *hw) spin_lock_irqsave(gate->lock, flags); + if (aspeed_clk_is_enabled(hw)) { + spin_unlock_irqrestore(gate->lock, flags); + return 0; + } + if (gate->reset_idx >= 0) { /* Put IP in reset */ regmap_update_bits(gate->map, ASPEED_RESET_CTRL, rst, rst); @@ -255,18 +272,6 @@ static void aspeed_clk_disable(struct clk_hw *hw) spin_unlock_irqrestore(gate->lock, flags); } -static int aspeed_clk_is_enabled(struct clk_hw *hw) -{ - struct aspeed_clk_gate *gate = to_aspeed_clk_gate(hw); - u32 clk = BIT(gate->clock_idx); - u32 enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk; - u32 reg; - - regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); - - return ((reg & clk) == enval) ? 1 : 0; -} - static const struct clk_ops aspeed_clk_gate_ops = { .enable = aspeed_clk_enable, .disable = aspeed_clk_disable, From f44cb4b19ed40b655c2d422c9021ab2c2625adb6 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 15 Mar 2018 17:02:34 +0100 Subject: [PATCH 724/942] Bluetooth: btusb: Fix quirk for Atheros 1525/QCA6174 The Atheros 1525/QCA6174 BT doesn't seem working properly on the recent kernels, as it tries to load a wrong firmware ar3k/AthrBT_0x00000200.dfu and it fails. This seems to have been a problem for some time, and the known workaround is to apply BTUSB_QCA_ROM quirk instead of BTUSB_ATH3012. The device in question is: T: Bus=01 Lev=01 Prnt=01 Port=09 Cnt=03 Dev#= 4 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=3004 Rev= 0.01 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1082504 Reported-by: Ivan Levshin Tested-by: Ivan Levshin Cc: Signed-off-by: Takashi Iwai Signed-off-by: Marcel Holtmann --- drivers/bluetooth/btusb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 382be00a8329..366a49c7c08f 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -231,7 +231,6 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x0930, 0x0227), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 }, - { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, { USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 }, @@ -264,6 +263,7 @@ static const struct usb_device_id blacklist_table[] = { { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 }, /* QCA ROME chipset */ + { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0cf3, 0xe007), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0cf3, 0xe009), .driver_info = BTUSB_QCA_ROME }, { USB_DEVICE(0x0cf3, 0xe010), .driver_info = BTUSB_QCA_ROME }, From b09c61522c81886c34966825f9e5afcbfafac446 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 14 Mar 2018 23:06:02 +0100 Subject: [PATCH 725/942] Revert "Bluetooth: hci_bcm: Streamline runtime PM code" This reverts commit 43fff7683468 ("Bluetooth: hci_bcm: Streamline runtime PM code"). The commit msg for this commit states "No functional change intended.", but replacing: pm_runtime_get(); pm_runtime_mark_last_busy(); pm_runtime_put_autosuspend(); with: pm_request_resume(); Does result in a functional change, pm_request_resume() only calls pm_runtime_mark_last_busy() if the device was suspended before the call. This results in the following happening: 1) Device is runtime suspended 2) Device drives host_wake IRQ logically high as it starts receiving data 3) bcm_host_wake() gets called, causes the device to runtime-resume, current time gets marked as last_busy time 4) After 5 seconds the autosuspend timer expires and the dev autosuspends as no one has been calling pm_runtime_mark_last_busy(), the device was resumed during those 5 seconds, so all the pm_request_resume() calls while receiving data and/or bcm_host_wake() calls were nops 5) If 4) happens while the device has (just received) data in its buffer to be read by the host the IRQ line is *already* / still logically high when we autosuspend and since we use an edge triggered IRQ, the IRQ will never trigger, causing the device to get stuck in suspend Therefor this commit has to be reverted, so that we avoid the device getting stuck in suspend. Signed-off-by: Hans de Goede Acked-by: Lukas Wunner Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_bcm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index 6314dfb02969..af5658121601 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -244,7 +244,9 @@ static irqreturn_t bcm_host_wake(int irq, void *data) bt_dev_dbg(bdev, "Host wake IRQ"); - pm_request_resume(bdev->dev); + pm_runtime_get(bdev->dev); + pm_runtime_mark_last_busy(bdev->dev); + pm_runtime_put_autosuspend(bdev->dev); return IRQ_HANDLED; } @@ -586,8 +588,11 @@ static int bcm_recv(struct hci_uart *hu, const void *data, int count) } else if (!bcm->rx_skb) { /* Delay auto-suspend when receiving completed packet */ mutex_lock(&bcm_device_lock); - if (bcm->dev && bcm_device_exists(bcm->dev)) - pm_request_resume(bcm->dev->dev); + if (bcm->dev && bcm_device_exists(bcm->dev)) { + pm_runtime_get(bcm->dev->dev); + pm_runtime_mark_last_busy(bcm->dev->dev); + pm_runtime_put_autosuspend(bcm->dev->dev); + } mutex_unlock(&bcm_device_lock); } From e07c99b07ae85255d5c5bc2480fbd4c4e77f71bc Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Wed, 14 Mar 2018 23:06:03 +0100 Subject: [PATCH 726/942] Bluetooth: hci_bcm: Set pulsed_host_wake flag in sleep parameters The IRQ output of the bcm bt-device is really a level IRQ signal, which signals a logical high as long as the device's buffer contains data. Since the draining in the buffer is done in the tty driver, we cannot (easily) wait in a threaded interrupt handler for the draining, after which the IRQ should go low again. So instead we treat the IRQ as an edge interrupt. This opens the window for a theoretical race where we wakeup, read some data and then autosuspend *before* the IRQ has gone (logical) low, followed by the device just at that moment receiving more data, causing the IRQ to stay high and we never see an edge. Since we call pm_runtime_mark_last_busy() on every received byte, there should be plenty time for the IRQ to go (logical) low before we ever suspend, so this should never happen, but after commit 43fff7683468 ("Bluetooth: hci_bcm: Streamline runtime PM code"), which has been reverted since, this was actually happening causing the device to get stuck in runtime suspend. The bcm bt-device actually has a workaround for this, if we set the pulsed_host_wake flag in the sleep parameters, then the device monitors if the host is draining the buffer and if not then after a timeout the device will pulse the IRQ line, causing us to see an edge, fixing the stuck in suspend condition. This commit sets the pulsed_host_wake flag to fix the (mostly theoretical) race caused by us treating the IRQ as an edge IRQ. Signed-off-by: Hans de Goede Reviewed-by: Lukas Wunner Signed-off-by: Marcel Holtmann --- drivers/bluetooth/hci_bcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c index af5658121601..40b9fb247010 100644 --- a/drivers/bluetooth/hci_bcm.c +++ b/drivers/bluetooth/hci_bcm.c @@ -303,7 +303,7 @@ static const struct bcm_set_sleep_mode default_sleep_params = { .usb_auto_sleep = 0, .usb_resume_timeout = 0, .break_to_host = 0, - .pulsed_host_wake = 0, + .pulsed_host_wake = 1, }; static int bcm_setup_sleep(struct hci_uart *hu) From 51d4740f88affd85d49c04e3c9cd129c0e33bcb9 Mon Sep 17 00:00:00 2001 From: Roman Mashak Date: Mon, 12 Mar 2018 16:20:58 -0400 Subject: [PATCH 727/942] net sched actions: return explicit error when tunnel_key mode is not specified If set/unset mode of the tunnel_key action is not provided, ->init() still returns 0, and the caller proceeds with bogus 'struct tc_action *' object, this results in crash: % tc actions add action tunnel_key src_ip 1.1.1.1 dst_ip 2.2.2.1 id 7 index 1 [ 35.805515] general protection fault: 0000 [#1] SMP PTI [ 35.806161] Modules linked in: act_tunnel_key kvm_intel kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 crypto_simd glue_helper cryptd serio_raw [ 35.808233] CPU: 1 PID: 428 Comm: tc Not tainted 4.16.0-rc4+ #286 [ 35.808929] RIP: 0010:tcf_action_init+0x90/0x190 [ 35.809457] RSP: 0018:ffffb8edc068b9a0 EFLAGS: 00010206 [ 35.810053] RAX: 1320c000000a0003 RBX: 0000000000000001 RCX: 0000000000000000 [ 35.810866] RDX: 0000000000000070 RSI: 0000000000007965 RDI: ffffb8edc068b910 [ 35.811660] RBP: ffffb8edc068b9d0 R08: 0000000000000000 R09: ffffb8edc068b808 [ 35.812463] R10: ffffffffc02bf040 R11: 0000000000000040 R12: ffffb8edc068bb38 [ 35.813235] R13: 0000000000000000 R14: 0000000000000000 R15: ffffb8edc068b910 [ 35.814006] FS: 00007f3d0d8556c0(0000) GS:ffff91d1dbc40000(0000) knlGS:0000000000000000 [ 35.814881] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 35.815540] CR2: 000000000043f720 CR3: 0000000019248001 CR4: 00000000001606a0 [ 35.816457] Call Trace: [ 35.817158] tc_ctl_action+0x11a/0x220 [ 35.817795] rtnetlink_rcv_msg+0x23d/0x2e0 [ 35.818457] ? __slab_alloc+0x1c/0x30 [ 35.819079] ? __kmalloc_node_track_caller+0xb1/0x2b0 [ 35.819544] ? rtnl_calcit.isra.30+0xe0/0xe0 [ 35.820231] netlink_rcv_skb+0xce/0x100 [ 35.820744] netlink_unicast+0x164/0x220 [ 35.821500] netlink_sendmsg+0x293/0x370 [ 35.822040] sock_sendmsg+0x30/0x40 [ 35.822508] ___sys_sendmsg+0x2c5/0x2e0 [ 35.823149] ? pagecache_get_page+0x27/0x220 [ 35.823714] ? filemap_fault+0xa2/0x640 [ 35.824423] ? page_add_file_rmap+0x108/0x200 [ 35.825065] ? alloc_set_pte+0x2aa/0x530 [ 35.825585] ? finish_fault+0x4e/0x70 [ 35.826140] ? __handle_mm_fault+0xbc1/0x10d0 [ 35.826723] ? __sys_sendmsg+0x41/0x70 [ 35.827230] __sys_sendmsg+0x41/0x70 [ 35.827710] do_syscall_64+0x68/0x120 [ 35.828195] entry_SYSCALL_64_after_hwframe+0x3d/0xa2 [ 35.828859] RIP: 0033:0x7f3d0ca4da67 [ 35.829331] RSP: 002b:00007ffc9f284338 EFLAGS: 00000246 ORIG_RAX: 000000000000002e [ 35.830304] RAX: ffffffffffffffda RBX: 00007ffc9f284460 RCX: 00007f3d0ca4da67 [ 35.831247] RDX: 0000000000000000 RSI: 00007ffc9f2843b0 RDI: 0000000000000003 [ 35.832167] RBP: 000000005aa6a7a9 R08: 0000000000000001 R09: 0000000000000000 [ 35.833075] R10: 00000000000005f1 R11: 0000000000000246 R12: 0000000000000000 [ 35.833997] R13: 00007ffc9f2884c0 R14: 0000000000000001 R15: 0000000000674640 [ 35.834923] Code: 24 30 bb 01 00 00 00 45 31 f6 eb 5e 8b 50 08 83 c2 07 83 e2 fc 83 c2 70 49 8b 07 48 8b 40 70 48 85 c0 74 10 48 89 14 24 4c 89 ff d0 48 8b 14 24 48 01 c2 49 01 d6 45 85 ed 74 05 41 83 47 2c [ 35.837442] RIP: tcf_action_init+0x90/0x190 RSP: ffffb8edc068b9a0 [ 35.838291] ---[ end trace a095c06ee4b97a26 ]--- Fixes: d0f6dd8a914f ("net/sched: Introduce act_tunnel_key") Signed-off-by: Roman Mashak Acked-by: Cong Wang Signed-off-by: David S. Miller --- net/sched/act_tunnel_key.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index 0e23aac09ad6..fea772e66e62 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -153,6 +153,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX; break; default: + ret = -EINVAL; goto err_out; } From cfb61b5e3e09f8b49bc4d685429df75f45127adc Mon Sep 17 00:00:00 2001 From: "David S. Miller" Date: Thu, 15 Mar 2018 14:18:00 -0700 Subject: [PATCH 728/942] sparc64: Fix regression in pmdp_invalidate(). pmdp_invalidate() was changed to update the pmd atomically (to not lose dirty/access bits) and return the original pmd value. However, in doing so, we lost a lot of the essential work that set_pmd_at() does, namely to update hugepage mapping counts and queuing up the batched TLB flush entry. Thus we were not flushing entries out of the TLB when making such PMD changes. Fix this by abstracting the accounting work of set_pmd_at() out into a separate function, and call it from pmdp_establish(). Fixes: a8e654f01cb7 ("sparc64: update pmdp_invalidate() to return old pmd value") Signed-off-by: David S. Miller --- arch/sparc/mm/tlb.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 847ddffbf38a..b5cfab711651 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -163,13 +163,10 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, pte_unmap(pte); } -void set_pmd_at(struct mm_struct *mm, unsigned long addr, - pmd_t *pmdp, pmd_t pmd) + +static void __set_pmd_acct(struct mm_struct *mm, unsigned long addr, + pmd_t orig, pmd_t pmd) { - pmd_t orig = *pmdp; - - *pmdp = pmd; - if (mm == &init_mm) return; @@ -219,6 +216,15 @@ void set_pmd_at(struct mm_struct *mm, unsigned long addr, } } +void set_pmd_at(struct mm_struct *mm, unsigned long addr, + pmd_t *pmdp, pmd_t pmd) +{ + pmd_t orig = *pmdp; + + *pmdp = pmd; + __set_pmd_acct(mm, addr, orig, pmd); +} + static inline pmd_t pmdp_establish(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t pmd) { @@ -227,6 +233,7 @@ static inline pmd_t pmdp_establish(struct vm_area_struct *vma, do { old = *pmdp; } while (cmpxchg64(&pmdp->pmd, old.pmd, pmd.pmd) != old.pmd); + __set_pmd_acct(vma->vm_mm, address, old, pmd); return old; } From 95dd77580ccd66a0da96e6d4696945b8cea39431 Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Wed, 14 Mar 2018 18:20:29 -0500 Subject: [PATCH 729/942] fs: Teach path_connected to handle nfs filesystems with multiple roots. On nfsv2 and nfsv3 the nfs server can export subsets of the same filesystem and report the same filesystem identifier, so that the nfs client can know they are the same filesystem. The subsets can be from disjoint directory trees. The nfsv2 and nfsv3 filesystems provides no way to find the common root of all directory trees exported form the server with the same filesystem identifier. The practical result is that in struct super s_root for nfs s_root is not necessarily the root of the filesystem. The nfs mount code sets s_root to the root of the first subset of the nfs filesystem that the kernel mounts. This effects the dcache invalidation code in generic_shutdown_super currently called shrunk_dcache_for_umount and that code for years has gone through an additional list of dentries that might be dentry trees that need to be freed to accomodate nfs. When I wrote path_connected I did not realize nfs was so special, and it's hueristic for avoiding calling is_subdir can fail. The practical case where this fails is when there is a move of a directory from the subtree exposed by one nfs mount to the subtree exposed by another nfs mount. This move can happen either locally or remotely. With the remote case requiring that the move directory be cached before the move and that after the move someone walks the path to where the move directory now exists and in so doing causes the already cached directory to be moved in the dcache through the magic of d_splice_alias. If someone whose working directory is in the move directory or a subdirectory and now starts calling .. from the initial mount of nfs (where s_root == mnt_root), then path_connected as a heuristic will not bother with the is_subdir check. As s_root really is not the root of the nfs filesystem this heuristic is wrong, and the path may actually not be connected and path_connected can fail. The is_subdir function might be cheap enough that we can call it unconditionally. Verifying that will take some benchmarking and the result may not be the same on all kernels this fix needs to be backported to. So I am avoiding that for now. Filesystems with snapshots such as nilfs and btrfs do something similar. But as the directory tree of the snapshots are disjoint from one another and from the main directory tree rename won't move things between them and this problem will not occur. Cc: stable@vger.kernel.org Reported-by: Al Viro Fixes: 397d425dc26d ("vfs: Test for and handle paths that are unreachable from their mnt_root") Signed-off-by: "Eric W. Biederman" Signed-off-by: Al Viro --- fs/namei.c | 5 +++-- fs/nfs/super.c | 2 ++ include/linux/fs.h | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 921ae32dbc80..cafa365eeb70 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -559,9 +559,10 @@ static int __nd_alloc_stack(struct nameidata *nd) static bool path_connected(const struct path *path) { struct vfsmount *mnt = path->mnt; + struct super_block *sb = mnt->mnt_sb; - /* Only bind mounts can have disconnected paths */ - if (mnt->mnt_root == mnt->mnt_sb->s_root) + /* Bind mounts and multi-root filesystems can have disconnected paths */ + if (!(sb->s_iflags & SB_I_MULTIROOT) && (mnt->mnt_root == sb->s_root)) return true; return is_subdir(path->dentry, mnt->mnt_root); diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 29bacdc56f6a..5e470e233c83 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -2631,6 +2631,8 @@ struct dentry *nfs_fs_mount_common(struct nfs_server *server, /* initial superblock/root creation */ mount_info->fill_super(s, mount_info); nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned); + if (!(server->flags & NFS_MOUNT_UNSHARED)) + s->s_iflags |= SB_I_MULTIROOT; } mntroot = nfs_get_root(s, mount_info->mntfh, dev_name); diff --git a/include/linux/fs.h b/include/linux/fs.h index 2a815560fda0..0430e03febaa 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1317,6 +1317,7 @@ extern int send_sigurg(struct fown_struct *fown); #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ #define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ +#define SB_I_MULTIROOT 0x00000008 /* Multiple roots to the dentry tree */ /* sb->s_iflags to limit user namespace mounts */ #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ From da5e45e619b3f101420c38b3006a9ae4f3ad19b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81ris=20Narti=C5=A1s?= Date: Fri, 16 Mar 2018 11:38:43 +1000 Subject: [PATCH 730/942] drm/nouveau/mmu: ALIGN_DOWN correct variable Commit 7110c89bb8852ff8b0f88ce05b332b3fe22bd11e ("mmu: swap out round for ALIGN") replaced two calls to round/rounddown with ALIGN/ALIGN_DOWN, but erroneously applied ALIGN_DOWN to a different variable (addr) and left intended variable (tail) not rounded/ALIGNed. As a result screen corruption, X lockups are observable. An example of kernel log of affected system with NV98 card where it was bisected: nouveau 0000:01:00.0: gr: TRAP_M2MF 00000002 [IN] nouveau 0000:01:00.0: gr: TRAP_M2MF 00320951 400007c0 00000000 04000000 nouveau 0000:01:00.0: gr: 00200000 [] ch 1 [000fbbe000 DRM] subc 4 class 5039 mthd 0100 data 00000000 nouveau 0000:01:00.0: fb: trapped read at 0040000000 on channel 1 [0fbbe000 DRM] engine 00 [PGRAPH] client 03 [DISPATCH] subclient 04 [M2M_IN] reason 00000006 [NULL_DMAOBJ] Fixes bug 105173 ("[MCP79][Regression] Unhandled NULL pointer dereference in nvkm_object_unmap since kernel 4.15") https://bugs.freedesktop.org/show_bug.cgi?id=105173 Fixes: 7110c89bb885 ("mmu: swap out round for ALIGN ") Tested-by: Pierre Moreau Reviewed-by: Pierre Moreau Signed-off-by: Maris Nartiss Signed-off-by: Ben Skeggs Cc: stable@vger.kernel.org # v4.15+ --- drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c index 93946dcee319..1c12e58f44c2 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c @@ -1354,7 +1354,7 @@ nvkm_vmm_get_locked(struct nvkm_vmm *vmm, bool getref, bool mapref, bool sparse, tail = this->addr + this->size; if (vmm->func->page_block && next && next->page != p) - tail = ALIGN_DOWN(addr, vmm->func->page_block); + tail = ALIGN_DOWN(tail, vmm->func->page_block); if (addr <= tail && tail - addr >= size) { rb_erase(&this->tree, &vmm->free); From 76f2e2bc627f7d08360ac731b6277d744d4eb599 Mon Sep 17 00:00:00 2001 From: Lukas Wunner Date: Sat, 17 Feb 2018 13:40:23 +0100 Subject: [PATCH 731/942] drm/nouveau/bl: Fix oops on driver unbind Unbinding nouveau on a dual GPU MacBook Pro oopses because we iterate over the bl_connectors list in nouveau_backlight_exit() but skipped initializing it in nouveau_backlight_init(). Stacktrace for posterity: BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: nouveau_backlight_exit+0x2b/0x70 [nouveau] nouveau_display_destroy+0x29/0x80 [nouveau] nouveau_drm_unload+0x65/0xe0 [nouveau] drm_dev_unregister+0x3c/0xe0 [drm] drm_put_dev+0x2e/0x60 [drm] nouveau_drm_device_remove+0x47/0x70 [nouveau] pci_device_remove+0x36/0xb0 device_release_driver_internal+0x157/0x220 driver_detach+0x39/0x70 bus_remove_driver+0x51/0xd0 pci_unregister_driver+0x2a/0xa0 nouveau_drm_exit+0x15/0xfb0 [nouveau] SyS_delete_module+0x18c/0x290 system_call_fast_compare_end+0xc/0x6f Fixes: b53ac1ee12a3 ("drm/nouveau/bl: Do not register interface if Apple GMUX detected") Cc: stable@vger.kernel.org # v4.10+ Cc: Pierre Moreau Signed-off-by: Lukas Wunner Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c index 380f340204e8..f56f60f695e1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c @@ -268,13 +268,13 @@ nouveau_backlight_init(struct drm_device *dev) struct nvif_device *device = &drm->client.device; struct drm_connector *connector; + INIT_LIST_HEAD(&drm->bl_connectors); + if (apple_gmux_present()) { NV_INFO(drm, "Apple GMUX detected: not registering Nouveau backlight interface\n"); return 0; } - INIT_LIST_HEAD(&drm->bl_connectors); - list_for_each_entry(connector, &dev->mode_config.connector_list, head) { if (connector->connector_type != DRM_MODE_CONNECTOR_LVDS && connector->connector_type != DRM_MODE_CONNECTOR_eDP) From 9e75dc61eaa9acd1bff83c3b814ac2af6dc1f64c Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 19 Feb 2018 17:09:45 +0100 Subject: [PATCH 732/942] drm/nouveau/bl: fix backlight regression Fixes: 3c66c87dc9 ("drm/nouveau/disp: remove hw-specific customisation of output paths") Suggested-by: Ben Skeggs Signed-off-by: Karol Herbst Signed-off-by: Ben Skeggs --- drivers/gpu/drm/nouveau/nouveau_backlight.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c index f56f60f695e1..debbbf0fd4bd 100644 --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c @@ -134,7 +134,7 @@ nv50_get_intensity(struct backlight_device *bd) struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nvif_object *device = &drm->client.device.object; - int or = nv_encoder->or; + int or = ffs(nv_encoder->dcb->or) - 1; u32 div = 1025; u32 val; @@ -149,7 +149,7 @@ nv50_set_intensity(struct backlight_device *bd) struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nvif_object *device = &drm->client.device.object; - int or = nv_encoder->or; + int or = ffs(nv_encoder->dcb->or) - 1; u32 div = 1025; u32 val = (bd->props.brightness * div) / 100; @@ -170,7 +170,7 @@ nva3_get_intensity(struct backlight_device *bd) struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nvif_object *device = &drm->client.device.object; - int or = nv_encoder->or; + int or = ffs(nv_encoder->dcb->or) - 1; u32 div, val; div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); @@ -188,7 +188,7 @@ nva3_set_intensity(struct backlight_device *bd) struct nouveau_encoder *nv_encoder = bl_get_data(bd); struct nouveau_drm *drm = nouveau_drm(nv_encoder->base.base.dev); struct nvif_object *device = &drm->client.device.object; - int or = nv_encoder->or; + int or = ffs(nv_encoder->dcb->or) - 1; u32 div, val; div = nvif_rd32(device, NV50_PDISP_SOR_PWM_DIV(or)); @@ -228,7 +228,7 @@ nv50_backlight_init(struct drm_connector *connector) return -ENODEV; } - if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(nv_encoder->or))) + if (!nvif_rd32(device, NV50_PDISP_SOR_PWM_CTL(ffs(nv_encoder->dcb->or) - 1))) return 0; if (drm->client.device.info.chipset <= 0xa0 || From 2975d5de6428ff6d9317e9948f0968f7d42e5d74 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Thu, 15 Mar 2018 15:33:02 +0200 Subject: [PATCH 733/942] RDMA/ucma: Check AF family prior resolving address Garbage supplied by user will cause to UCMA module provide zero memory size for memcpy(), because it wasn't checked, it will produce unpredictable results in rdma_resolve_addr(). [ 42.873814] BUG: KASAN: null-ptr-deref in rdma_resolve_addr+0xc8/0xfb0 [ 42.874816] Write of size 28 at addr 00000000000000a0 by task resaddr/1044 [ 42.876765] [ 42.876960] CPU: 1 PID: 1044 Comm: resaddr Not tainted 4.16.0-rc1-00057-gaa56a5293d7e #34 [ 42.877840] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 42.879691] Call Trace: [ 42.880236] dump_stack+0x5c/0x77 [ 42.880664] kasan_report+0x163/0x380 [ 42.881354] ? rdma_resolve_addr+0xc8/0xfb0 [ 42.881864] memcpy+0x34/0x50 [ 42.882692] rdma_resolve_addr+0xc8/0xfb0 [ 42.883366] ? deref_stack_reg+0x88/0xd0 [ 42.883856] ? vsnprintf+0x31a/0x770 [ 42.884686] ? rdma_bind_addr+0xc40/0xc40 [ 42.885327] ? num_to_str+0x130/0x130 [ 42.885773] ? deref_stack_reg+0x88/0xd0 [ 42.886217] ? __read_once_size_nocheck.constprop.6+0x10/0x10 [ 42.887698] ? unwind_get_return_address_ptr+0x50/0x50 [ 42.888302] ? replace_slot+0x147/0x170 [ 42.889176] ? delete_node+0x12c/0x340 [ 42.890223] ? __radix_tree_lookup+0xa9/0x160 [ 42.891196] ? ucma_resolve_ip+0xb7/0x110 [ 42.891917] ucma_resolve_ip+0xb7/0x110 [ 42.893003] ? ucma_resolve_addr+0x190/0x190 [ 42.893531] ? _copy_from_user+0x5e/0x90 [ 42.894204] ucma_write+0x174/0x1f0 [ 42.895162] ? ucma_resolve_route+0xf0/0xf0 [ 42.896309] ? dequeue_task_fair+0x67e/0xd90 [ 42.897192] ? put_prev_entity+0x7d/0x170 [ 42.897870] ? ring_buffer_record_is_on+0xd/0x20 [ 42.898439] ? tracing_record_taskinfo_skip+0x20/0x50 [ 42.899686] __vfs_write+0xc4/0x350 [ 42.900142] ? kernel_read+0xa0/0xa0 [ 42.900602] ? firmware_map_remove+0xdf/0xdf [ 42.901135] ? do_task_dead+0x5d/0x60 [ 42.901598] ? do_exit+0xcc6/0x1220 [ 42.902789] ? __fget+0xa8/0xf0 [ 42.903190] vfs_write+0xf7/0x280 [ 42.903600] SyS_write+0xa1/0x120 [ 42.904206] ? SyS_read+0x120/0x120 [ 42.905710] ? compat_start_thread+0x60/0x60 [ 42.906423] ? SyS_read+0x120/0x120 [ 42.908716] do_syscall_64+0xeb/0x250 [ 42.910760] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 42.912735] RIP: 0033:0x7f138b0afe99 [ 42.914734] RSP: 002b:00007f138b799e98 EFLAGS: 00000287 ORIG_RAX: 0000000000000001 [ 42.917134] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f138b0afe99 [ 42.919487] RDX: 000000000000002e RSI: 0000000020000c40 RDI: 0000000000000004 [ 42.922393] RBP: 00007f138b799ec0 R08: 00007f138b79a700 R09: 0000000000000000 [ 42.925266] R10: 00007f138b79a700 R11: 0000000000000287 R12: 00007f138b799fc0 [ 42.927570] R13: 0000000000000000 R14: 00007ffdbae757c0 R15: 00007f138b79a9c0 [ 42.930047] [ 42.932681] Disabling lock debugging due to kernel taint [ 42.934795] BUG: unable to handle kernel NULL pointer dereference at 00000000000000a0 [ 42.936939] IP: memcpy_erms+0x6/0x10 [ 42.938864] PGD 80000001bea92067 P4D 80000001bea92067 PUD 1bea96067 PMD 0 [ 42.941576] Oops: 0002 [#1] SMP KASAN PTI [ 42.943952] CPU: 1 PID: 1044 Comm: resaddr Tainted: G B 4.16.0-rc1-00057-gaa56a5293d7e #34 [ 42.946964] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 42.952336] RIP: 0010:memcpy_erms+0x6/0x10 [ 42.954707] RSP: 0018:ffff8801c8b479c8 EFLAGS: 00010286 [ 42.957227] RAX: 00000000000000a0 RBX: ffff8801c8b47ba0 RCX: 000000000000001c [ 42.960543] RDX: 000000000000001c RSI: ffff8801c8b47bbc RDI: 00000000000000a0 [ 42.963867] RBP: ffff8801c8b47b60 R08: 0000000000000000 R09: ffffed0039168ed1 [ 42.967303] R10: 0000000000000001 R11: ffffed0039168ed0 R12: ffff8801c8b47bbc [ 42.970685] R13: 00000000000000a0 R14: 1ffff10039168f4a R15: 0000000000000000 [ 42.973631] FS: 00007f138b79a700(0000) GS:ffff8801e5d00000(0000) knlGS:0000000000000000 [ 42.976831] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 42.979239] CR2: 00000000000000a0 CR3: 00000001be908002 CR4: 00000000003606a0 [ 42.982060] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 42.984877] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 42.988033] Call Trace: [ 42.990487] rdma_resolve_addr+0xc8/0xfb0 [ 42.993202] ? deref_stack_reg+0x88/0xd0 [ 42.996055] ? vsnprintf+0x31a/0x770 [ 42.998707] ? rdma_bind_addr+0xc40/0xc40 [ 43.000985] ? num_to_str+0x130/0x130 [ 43.003410] ? deref_stack_reg+0x88/0xd0 [ 43.006302] ? __read_once_size_nocheck.constprop.6+0x10/0x10 [ 43.008780] ? unwind_get_return_address_ptr+0x50/0x50 [ 43.011178] ? replace_slot+0x147/0x170 [ 43.013517] ? delete_node+0x12c/0x340 [ 43.016019] ? __radix_tree_lookup+0xa9/0x160 [ 43.018755] ? ucma_resolve_ip+0xb7/0x110 [ 43.021270] ucma_resolve_ip+0xb7/0x110 [ 43.023968] ? ucma_resolve_addr+0x190/0x190 [ 43.026312] ? _copy_from_user+0x5e/0x90 [ 43.029384] ucma_write+0x174/0x1f0 [ 43.031861] ? ucma_resolve_route+0xf0/0xf0 [ 43.034782] ? dequeue_task_fair+0x67e/0xd90 [ 43.037483] ? put_prev_entity+0x7d/0x170 [ 43.040215] ? ring_buffer_record_is_on+0xd/0x20 [ 43.042990] ? tracing_record_taskinfo_skip+0x20/0x50 [ 43.045595] __vfs_write+0xc4/0x350 [ 43.048624] ? kernel_read+0xa0/0xa0 [ 43.051604] ? firmware_map_remove+0xdf/0xdf [ 43.055379] ? do_task_dead+0x5d/0x60 [ 43.058000] ? do_exit+0xcc6/0x1220 [ 43.060783] ? __fget+0xa8/0xf0 [ 43.063133] vfs_write+0xf7/0x280 [ 43.065677] SyS_write+0xa1/0x120 [ 43.068647] ? SyS_read+0x120/0x120 [ 43.071179] ? compat_start_thread+0x60/0x60 [ 43.074025] ? SyS_read+0x120/0x120 [ 43.076705] do_syscall_64+0xeb/0x250 [ 43.079006] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 43.081606] RIP: 0033:0x7f138b0afe99 [ 43.083679] RSP: 002b:00007f138b799e98 EFLAGS: 00000287 ORIG_RAX: 0000000000000001 [ 43.086802] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f138b0afe99 [ 43.089989] RDX: 000000000000002e RSI: 0000000020000c40 RDI: 0000000000000004 [ 43.092866] RBP: 00007f138b799ec0 R08: 00007f138b79a700 R09: 0000000000000000 [ 43.096233] R10: 00007f138b79a700 R11: 0000000000000287 R12: 00007f138b799fc0 [ 43.098913] R13: 0000000000000000 R14: 00007ffdbae757c0 R15: 00007f138b79a9c0 [ 43.101809] Code: 90 90 90 90 90 eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 [ 43.107950] RIP: memcpy_erms+0x6/0x10 RSP: ffff8801c8b479c8 Reported-by: Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Signed-off-by: Leon Romanovsky Reviewed-by: Sean Hefty Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/ucma.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 699a46d4c0c5..3f3f7bbc4528 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -664,19 +664,23 @@ static ssize_t ucma_resolve_ip(struct ucma_file *file, int in_len, int out_len) { struct rdma_ucm_resolve_ip cmd; + struct sockaddr *src, *dst; struct ucma_context *ctx; int ret; if (copy_from_user(&cmd, inbuf, sizeof(cmd))) return -EFAULT; + src = (struct sockaddr *) &cmd.src_addr; + dst = (struct sockaddr *) &cmd.dst_addr; + if (!rdma_addr_size(src) || !rdma_addr_size(dst)) + return -EINVAL; + ctx = ucma_get_ctx(file, cmd.id); if (IS_ERR(ctx)) return PTR_ERR(ctx); - ret = rdma_resolve_addr(ctx->cm_id, (struct sockaddr *) &cmd.src_addr, - (struct sockaddr *) &cmd.dst_addr, - cmd.timeout_ms); + ret = rdma_resolve_addr(ctx->cm_id, src, dst, cmd.timeout_ms); ucma_put_ctx(ctx); return ret; } From dc9e0a9347e932e3fd3cd03e7ff241022ed6ea8a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 15 Mar 2018 19:49:14 -0700 Subject: [PATCH 734/942] acpi, numa: fix pxm to online numa node associations Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added support for mapping a given proximity to its nearest, by SLIT distance, online node. However, it sometimes returns unexpected results due to the fact that it switches from comparing the PXM node to the last node that was closer than the current max. for_each_online_node(n) { dist = node_distance(node, n); if (dist < min_dist) { min_dist = dist; node = n; <---- from this point we're using the wrong node for node_distance() Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()") Cc: Reviewed-by: Toshi Kani Acked-by: Rafael J. Wysocki > Signed-off-by: Dan Williams --- drivers/acpi/numa.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 8ccaae3550d2..85167603b9c9 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm) */ int acpi_map_pxm_to_online_node(int pxm) { - int node, n, dist, min_dist; + int node, min_node; node = acpi_map_pxm_to_node(pxm); if (node == NUMA_NO_NODE) node = 0; + min_node = node; if (!node_online(node)) { - min_dist = INT_MAX; + int min_dist = INT_MAX, dist, n; + for_each_online_node(n) { dist = node_distance(node, n); if (dist < min_dist) { min_dist = dist; - node = n; + min_node = n; } } } - return node; + return min_node; } EXPORT_SYMBOL(acpi_map_pxm_to_online_node); From 47b7de2f6c18f75d1f2716efe752cba43f32a626 Mon Sep 17 00:00:00 2001 From: Evgeniy Didin Date: Wed, 14 Mar 2018 22:30:51 +0300 Subject: [PATCH 735/942] mmc: dw_mmc: fix falling from idmac to PIO mode when dw_mci_reset occurs It was found that in IDMAC mode after soft-reset driver switches to PIO mode. That's what happens in case of DTO timeout overflow calculation failure: 1. soft-reset is called 2. driver restarts dma 3. descriptors states are checked, one of descriptor is owned by the IDMAC. 4. driver can't use DMA and then switches to PIO mode. Failure was already fixed in: https://www.spinics.net/lists/linux-mmc/msg48125.html. Behaviour while soft-reset is not something we except or even want to happen. So we switch from dw_mci_idmac_reset to dw_mci_idmac_init, so descriptors are cleaned before starting dma. And while at it explicitly zero des0 which otherwise might contain garbage as being allocated by dmam_alloc_coherent(). Signed-off-by: Evgeniy Didin Cc: Jaehoon Chung Cc: Ulf Hansson Cc: Andy Shevchenko Cc: Jisheng Zhang Cc: Shawn Lin Cc: Alexey Brodkin Cc: Eugeniy Paltsev Cc: linux-snps-arc@lists.infradead.org Cc: # 4.4+ Signed-off-by: Ulf Hansson --- drivers/mmc/host/dw_mmc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 545550591389..06d47414d0c1 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -564,6 +564,7 @@ static int dw_mci_idmac_init(struct dw_mci *host) (sizeof(struct idmac_desc_64addr) * (i + 1))) >> 32; /* Initialize reserved and buffer size fields to "0" */ + p->des0 = 0; p->des1 = 0; p->des2 = 0; p->des3 = 0; @@ -586,6 +587,7 @@ static int dw_mci_idmac_init(struct dw_mci *host) i++, p++) { p->des3 = cpu_to_le32(host->sg_dma + (sizeof(struct idmac_desc) * (i + 1))); + p->des0 = 0; p->des1 = 0; } @@ -1801,8 +1803,8 @@ static bool dw_mci_reset(struct dw_mci *host) } if (host->use_dma == TRANS_MODE_IDMAC) - /* It is also recommended that we reset and reprogram idmac */ - dw_mci_idmac_reset(host); + /* It is also required that we reinit idmac */ + dw_mci_idmac_init(host); ret = true; From e3b3121fa8da94cb20f9e0c64ab7981ae47fd085 Mon Sep 17 00:00:00 2001 From: Alexander Sergeyev Date: Tue, 13 Mar 2018 22:38:56 +0300 Subject: [PATCH 736/942] x86/speculation: Remove Skylake C2 from Speculation Control microcode blacklist In accordance with Intel's microcode revision guidance from March 6 MCU rev 0xc2 is cleared on both Skylake H/S and Skylake Xeon E3 processors that share CPUID 506E3. Signed-off-by: Alexander Sergeyev Signed-off-by: Thomas Gleixner Cc: Jia Zhang Cc: Greg Kroah-Hartman Cc: Kyle Huey Cc: David Woodhouse Link: https://lkml.kernel.org/r/20180313193856.GA8580@localhost.localdomain --- arch/x86/kernel/cpu/intel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index 4aa9fd379390..c3af167d0a70 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -105,7 +105,7 @@ static void probe_xeon_phi_r3mwait(struct cpuinfo_x86 *c) /* * Early microcode releases for the Spectre v2 mitigation were broken. * Information taken from; - * - https://newsroom.intel.com/wp-content/uploads/sites/11/2018/01/microcode-update-guidance.pdf + * - https://newsroom.intel.com/wp-content/uploads/sites/11/2018/03/microcode-update-guidance.pdf * - https://kb.vmware.com/s/article/52345 * - Microcode revisions observed in the wild * - Release note from 20180108 microcode release @@ -123,7 +123,6 @@ static const struct sku_microcode spectre_bad_microcodes[] = { { INTEL_FAM6_KABYLAKE_MOBILE, 0x09, 0x80 }, { INTEL_FAM6_SKYLAKE_X, 0x03, 0x0100013e }, { INTEL_FAM6_SKYLAKE_X, 0x04, 0x0200003c }, - { INTEL_FAM6_SKYLAKE_DESKTOP, 0x03, 0xc2 }, { INTEL_FAM6_BROADWELL_CORE, 0x04, 0x28 }, { INTEL_FAM6_BROADWELL_GT3E, 0x01, 0x1b }, { INTEL_FAM6_BROADWELL_XEON_D, 0x02, 0x14 }, From 18ffc0cce4ff947a2acc9b2e06ae5309a6e6fb43 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Thu, 22 Feb 2018 15:19:37 +0100 Subject: [PATCH 737/942] microblaze: Setup dependencies for ASM optimized lib functions The patch: "microblaze: Setup proper dependency for optimized lib functions" (sha1: 7b6ce52be3f86520524711a6f33f3866f9339694) didn't setup all dependencies properly. Optimized lib functions in C are also present for little endian and optimized library functions in assembler are implemented only for big endian version. Reported-by: kbuild test robot Signed-off-by: Michal Simek --- arch/microblaze/Kconfig.platform | 2 +- arch/microblaze/lib/fastcopy.S | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/arch/microblaze/Kconfig.platform b/arch/microblaze/Kconfig.platform index 6996f397c16c..f7f1739c11b9 100644 --- a/arch/microblaze/Kconfig.platform +++ b/arch/microblaze/Kconfig.platform @@ -8,7 +8,6 @@ menu "Platform options" config OPT_LIB_FUNCTION bool "Optimalized lib function" - depends on CPU_LITTLE_ENDIAN default y help Allows turn on optimalized library function (memcpy and memmove). @@ -21,6 +20,7 @@ config OPT_LIB_FUNCTION config OPT_LIB_ASM bool "Optimalized lib function ASM" depends on OPT_LIB_FUNCTION && (XILINX_MICROBLAZE0_USE_BARREL = 1) + depends on CPU_BIG_ENDIAN default n help Allows turn on optimalized library function (memcpy and memmove). diff --git a/arch/microblaze/lib/fastcopy.S b/arch/microblaze/lib/fastcopy.S index 62021d7e249e..fdc48bb065d8 100644 --- a/arch/microblaze/lib/fastcopy.S +++ b/arch/microblaze/lib/fastcopy.S @@ -29,10 +29,6 @@ * between mem locations with size of xfer spec'd in bytes */ -#ifdef __MICROBLAZEEL__ -#error Microblaze LE not support ASM optimized lib func. Disable OPT_LIB_ASM. -#endif - #include .text .globl memcpy From cd4dfee6a8bfbbe404e9905aff85e267ec99f5fa Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 9 Mar 2018 09:52:55 -0600 Subject: [PATCH 738/942] microblaze: remove unused alloc_maybe_bootmem alloc_maybe_bootmem is unused, so remove it. Signed-off-by: Rob Herring Signed-off-by: Michal Simek --- arch/microblaze/include/asm/setup.h | 1 - arch/microblaze/mm/init.c | 8 -------- 2 files changed, 9 deletions(-) diff --git a/arch/microblaze/include/asm/setup.h b/arch/microblaze/include/asm/setup.h index be84a4d3917f..7c968c1d1729 100644 --- a/arch/microblaze/include/asm/setup.h +++ b/arch/microblaze/include/asm/setup.h @@ -44,7 +44,6 @@ void machine_shutdown(void); void machine_halt(void); void machine_power_off(void); -extern void *alloc_maybe_bootmem(size_t size, gfp_t mask); extern void *zalloc_maybe_bootmem(size_t size, gfp_t mask); # endif /* __ASSEMBLY__ */ diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index 434639f9a3a6..5bc9c7fbb541 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -414,14 +414,6 @@ void __init *early_get_page(void) #endif /* CONFIG_MMU */ -void * __ref alloc_maybe_bootmem(size_t size, gfp_t mask) -{ - if (mem_init_done) - return kmalloc(size, mask); - else - return alloc_bootmem(size); -} - void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask) { void *p; From 101646a24a2f9cdb61d7732459fbf068a7bbb542 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 9 Mar 2018 09:54:07 -0600 Subject: [PATCH 739/942] microblaze: switch to NO_BOOTMEM Microblaze doesn't set CONFIG_NO_BOOTMEM and so memblock_virt_alloc() doesn't work for CONFIG_HAVE_MEMBLOCK && !CONFIG_NO_BOOTMEM. Similar change was already done by others architectures "ARM: mm: Remove bootmem code and switch to NO_BOOTMEM" (sha1: 84f452b1e8fc73ac0e31254c66e3e2260ce5263d) or "openrisc: Consolidate setup to use memblock instead of bootmem" (sha1: 266c7fad157265bb54d17db1c9545f2aaa488643) or "parisc: Drop bootmem and switch to memblock" (sha1: 4fe9e1d957e45ad8eba9885ee860a0e93d13a7c7) or "powerpc: Remove bootmem allocator" (sha1: 10239733ee8617bac3f1c1769af43a88ed979324) or "s390/mm: Convert bootmem to memblock" (sha1: 50be634507284eea38df78154d22615d21200b42) or "sparc64: Convert over to NO_BOOTMEM." (sha1: 625d693e9784f988371e69c2b41a2172c0be6c11) or "xtensa: drop sysmem and switch to memblock" (sha1: 0e46c1115f5816949220d62dd3ff04aa68e7ac6b) Issue was introduced by: "of/fdt: use memblock_virt_alloc for early alloc" (sha1: 0fa1c579349fdd90173381712ad78aa99c09d38b) Signed-off-by: Rob Herring Tested-by: Alvaro Gamez Machado Tested-by: Michal Simek Signed-off-by: Michal Simek --- arch/microblaze/Kconfig | 1 + arch/microblaze/mm/init.c | 56 +++++---------------------------------- 2 files changed, 7 insertions(+), 50 deletions(-) diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig index 4f798aa671dd..3817a3e2146c 100644 --- a/arch/microblaze/Kconfig +++ b/arch/microblaze/Kconfig @@ -24,6 +24,7 @@ config MICROBLAZE select HAVE_FTRACE_MCOUNT_RECORD select HAVE_FUNCTION_GRAPH_TRACER select HAVE_FUNCTION_TRACER + select NO_BOOTMEM select HAVE_MEMBLOCK select HAVE_MEMBLOCK_NODE_MAP select HAVE_OPROFILE diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index 5bc9c7fbb541..df6de7ccdc2e 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c @@ -32,9 +32,6 @@ int mem_init_done; #ifndef CONFIG_MMU unsigned int __page_offset; EXPORT_SYMBOL(__page_offset); - -#else -static int init_bootmem_done; #endif /* CONFIG_MMU */ char *klimit = _end; @@ -117,7 +114,6 @@ static void __init paging_init(void) void __init setup_memory(void) { - unsigned long map_size; struct memblock_region *reg; #ifndef CONFIG_MMU @@ -174,17 +170,6 @@ void __init setup_memory(void) pr_info("%s: max_low_pfn: %#lx\n", __func__, max_low_pfn); pr_info("%s: max_pfn: %#lx\n", __func__, max_pfn); - /* - * Find an area to use for the bootmem bitmap. - * We look for the first area which is at least - * 128kB in length (128kB is enough for a bitmap - * for 4GB of memory, using 4kB pages), plus 1 page - * (in case the address isn't page-aligned). - */ - map_size = init_bootmem_node(NODE_DATA(0), - PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn); - memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size); - /* Add active regions with valid PFNs */ for_each_memblock(memory, reg) { unsigned long start_pfn, end_pfn; @@ -196,32 +181,9 @@ void __init setup_memory(void) &memblock.memory, 0); } - /* free bootmem is whole main memory */ - free_bootmem_with_active_regions(0, max_low_pfn); - - /* reserve allocate blocks */ - for_each_memblock(reserved, reg) { - unsigned long top = reg->base + reg->size - 1; - - pr_debug("reserved - 0x%08x-0x%08x, %lx, %lx\n", - (u32) reg->base, (u32) reg->size, top, - memory_start + lowmem_size - 1); - - if (top <= (memory_start + lowmem_size - 1)) { - reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); - } else if (reg->base < (memory_start + lowmem_size - 1)) { - unsigned long trunc_size = memory_start + lowmem_size - - reg->base; - reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT); - } - } - /* XXX need to clip this if using highmem? */ sparse_memory_present_with_active_regions(0); -#ifdef CONFIG_MMU - init_bootmem_done = 1; -#endif paging_init(); } @@ -398,18 +360,12 @@ asmlinkage void __init mmu_init(void) /* This is only called until mem_init is done. */ void __init *early_get_page(void) { - void *p; - if (init_bootmem_done) { - p = alloc_bootmem_pages(PAGE_SIZE); - } else { - /* - * Mem start + kernel_tlb -> here is limit - * because of mem mapping from head.S - */ - p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, - memory_start + kernel_tlb)); - } - return p; + /* + * Mem start + kernel_tlb -> here is limit + * because of mem mapping from head.S + */ + return __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE, + memory_start + kernel_tlb)); } #endif /* CONFIG_MMU */ From daaf216c06fba4ee4dc3f62715667da929d68774 Mon Sep 17 00:00:00 2001 From: Tom Lendacky Date: Thu, 8 Mar 2018 17:17:31 -0600 Subject: [PATCH 740/942] KVM: x86: Fix device passthrough when SME is active When using device passthrough with SME active, the MMIO range that is mapped for the device should not be mapped encrypted. Add a check in set_spte() to insure that a page is not mapped encrypted if that page is a device MMIO page as indicated by kvm_is_mmio_pfn(). Cc: # 4.14.x- Signed-off-by: Tom Lendacky Signed-off-by: Paolo Bonzini --- arch/x86/kvm/mmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index f551962ac294..763bb3bade63 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -2770,8 +2770,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, else pte_access &= ~ACC_WRITE_MASK; + if (!kvm_is_mmio_pfn(pfn)) + spte |= shadow_me_mask; + spte |= (u64)pfn << PAGE_SHIFT; - spte |= shadow_me_mask; if (pte_access & ACC_WRITE_MASK) { From 093e037ca88e1767693bc6bcb2df3f49c6be68c7 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 16 Mar 2018 14:31:43 +0100 Subject: [PATCH 741/942] Revert "btrfs: use proper endianness accessors for super_copy" This reverts commit 3c181c12c431fe33b669410d663beb9cceefcd1b. The offending patch was merged in 4.16-rc4 and was promptly applied to stable kernels 4.14.25 and 4.15.8. The patch causes a corruption in several superblock items on big-endian machines because of messed up endianity conversions. The damage is manually repairable. A filesystem cannot be mounted again after it has been unmounted once. We do a full revert and not a fixup so stable can pick that patch ASAP. Fixes: 3c181c12c431 ("btrfs: use proper endianness accessors for super_copy") Link: https://lkml.kernel.org/r/1521139304@msgid.manchmal.in-ulm.de CC: stable@vger.kernel.org # 4.14+ Reported-by: Christoph Biedl Signed-off-by: David Sterba --- fs/btrfs/sysfs.c | 8 +++++--- fs/btrfs/transaction.c | 20 ++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index d11c70bff5a9..a8bafed931f4 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -423,7 +423,7 @@ static ssize_t btrfs_nodesize_show(struct kobject *kobj, { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->nodesize); + return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->super_copy->nodesize); } BTRFS_ATTR(, nodesize, btrfs_nodesize_show); @@ -433,7 +433,8 @@ static ssize_t btrfs_sectorsize_show(struct kobject *kobj, { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->sectorsize); + return snprintf(buf, PAGE_SIZE, "%u\n", + fs_info->super_copy->sectorsize); } BTRFS_ATTR(, sectorsize, btrfs_sectorsize_show); @@ -443,7 +444,8 @@ static ssize_t btrfs_clone_alignment_show(struct kobject *kobj, { struct btrfs_fs_info *fs_info = to_fs_info(kobj); - return snprintf(buf, PAGE_SIZE, "%u\n", fs_info->sectorsize); + return snprintf(buf, PAGE_SIZE, "%u\n", + fs_info->super_copy->sectorsize); } BTRFS_ATTR(, clone_alignment, btrfs_clone_alignment_show); diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 9220f004001c..04f07144b45c 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c @@ -1722,23 +1722,19 @@ static void update_super_roots(struct btrfs_fs_info *fs_info) super = fs_info->super_copy; - /* update latest btrfs_super_block::chunk_root refs */ root_item = &fs_info->chunk_root->root_item; - btrfs_set_super_chunk_root(super, root_item->bytenr); - btrfs_set_super_chunk_root_generation(super, root_item->generation); - btrfs_set_super_chunk_root_level(super, root_item->level); + super->chunk_root = root_item->bytenr; + super->chunk_root_generation = root_item->generation; + super->chunk_root_level = root_item->level; - /* update latest btrfs_super_block::root refs */ root_item = &fs_info->tree_root->root_item; - btrfs_set_super_root(super, root_item->bytenr); - btrfs_set_super_generation(super, root_item->generation); - btrfs_set_super_root_level(super, root_item->level); - + super->root = root_item->bytenr; + super->generation = root_item->generation; + super->root_level = root_item->level; if (btrfs_test_opt(fs_info, SPACE_CACHE)) - btrfs_set_super_cache_generation(super, root_item->generation); + super->cache_generation = root_item->generation; if (test_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags)) - btrfs_set_super_uuid_tree_generation(super, - root_item->generation); + super->uuid_tree_generation = root_item->generation; } int btrfs_transaction_in_commit(struct btrfs_fs_info *info) From 4bbb3e0e8239f9079bf1fe20b3c0cb598714ae61 Mon Sep 17 00:00:00 2001 From: Toshiaki Makita Date: Tue, 13 Mar 2018 14:51:27 +0900 Subject: [PATCH 742/942] net: Fix vlan untag for bridge and vlan_dev with reorder_hdr off When we have a bridge with vlan_filtering on and a vlan device on top of it, packets would be corrupted in skb_vlan_untag() called from br_dev_xmit(). The problem sits in skb_reorder_vlan_header() used in skb_vlan_untag(), which makes use of skb->mac_len. In this function mac_len is meant for handling rx path with vlan devices with reorder_header disabled, but in tx path mac_len is typically 0 and cannot be used, which is the problem in this case. The current code even does not properly handle rx path (skb_vlan_untag() called from __netif_receive_skb_core()) with reorder_header off actually. In rx path single tag case, it works as follows: - Before skb_reorder_vlan_header() mac_header data v v +-------------------+-------------+------+---- | ETH | VLAN | ETH | | ADDRS | TPID | TCI | TYPE | +-------------------+-------------+------+---- <-------- mac_len ---------> <-------------> to be removed - After skb_reorder_vlan_header() mac_header data v v +-------------------+------+---- | ETH | ETH | | ADDRS | TYPE | +-------------------+------+---- <-------- mac_len ---------> This is ok, but in rx double tag case, it corrupts packets: - Before skb_reorder_vlan_header() mac_header data v v +-------------------+-------------+-------------+------+---- | ETH | VLAN | VLAN | ETH | | ADDRS | TPID | TCI | TPID | TCI | TYPE | +-------------------+-------------+-------------+------+---- <--------------- mac_len ----------------> <-------------> should be removed <---------------------------> actually will be removed - After skb_reorder_vlan_header() mac_header data v v +-------------------+------+---- | ETH | ETH | | ADDRS | TYPE | +-------------------+------+---- <--------------- mac_len ----------------> So, two of vlan tags are both removed while only inner one should be removed and mac_header (and mac_len) is broken. skb_vlan_untag() is meant for removing the vlan header at (skb->data - 2), so use skb->data and skb->mac_header to calculate the right offset. Reported-by: Brandon Carpenter Fixes: a6e18ff11170 ("vlan: Fix untag operations of stacked vlans with REORDER_HEADER off") Signed-off-by: Toshiaki Makita Signed-off-by: David S. Miller --- include/uapi/linux/if_ether.h | 1 + net/core/skbuff.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h index 8bbbcb5cd94b..820de5d222d2 100644 --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -30,6 +30,7 @@ */ #define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_TLEN 2 /* Octets in ethernet type field */ #define ETH_HLEN 14 /* Total octets in header. */ #define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ #define ETH_DATA_LEN 1500 /* Max. octets in payload */ diff --git a/net/core/skbuff.c b/net/core/skbuff.c index baf990528943..b103f46ec512 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5020,13 +5020,16 @@ EXPORT_SYMBOL_GPL(skb_gso_validate_mac_len); static struct sk_buff *skb_reorder_vlan_header(struct sk_buff *skb) { + int mac_len; + if (skb_cow(skb, skb_headroom(skb)) < 0) { kfree_skb(skb); return NULL; } - memmove(skb->data - ETH_HLEN, skb->data - skb->mac_len - VLAN_HLEN, - 2 * ETH_ALEN); + mac_len = skb->data - skb_mac_header(skb); + memmove(skb_mac_header(skb) + VLAN_HLEN, skb_mac_header(skb), + mac_len - VLAN_HLEN - ETH_TLEN); skb->mac_header += VLAN_HLEN; return skb; } From cbe7128c4b92e2004984f477fd38dfa81662f02e Mon Sep 17 00:00:00 2001 From: Toshiaki Makita Date: Tue, 13 Mar 2018 14:51:28 +0900 Subject: [PATCH 743/942] vlan: Fix out of order vlan headers with reorder header off With reorder header off, received packets are untagged in skb_vlan_untag() called from within __netif_receive_skb_core(), and later the tag will be inserted back in vlan_do_receive(). This caused out of order vlan headers when we create a vlan device on top of another vlan device, because vlan_do_receive() inserts a tag as the outermost vlan tag. E.g. the outer tag is first removed in skb_vlan_untag() and inserted back in vlan_do_receive(), then the inner tag is next removed and inserted back as the outermost tag. This patch fixes the behaviour by inserting the inner tag at the right position. Signed-off-by: Toshiaki Makita Signed-off-by: David S. Miller --- include/linux/if_vlan.h | 92 ++++++++++++++++++++++++++++++----------- net/8021q/vlan_core.c | 4 +- 2 files changed, 70 insertions(+), 26 deletions(-) diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index 5e6a2d4dc366..c4a1cff9c768 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -299,6 +299,44 @@ static inline bool vlan_hw_offload_capable(netdev_features_t features, return false; } +/** + * __vlan_insert_inner_tag - inner VLAN tag inserting + * @skb: skbuff to tag + * @vlan_proto: VLAN encapsulation protocol + * @vlan_tci: VLAN TCI to insert + * @mac_len: MAC header length including outer vlan headers + * + * Inserts the VLAN tag into @skb as part of the payload at offset mac_len + * Returns error if skb_cow_head failes. + * + * Does not change skb->protocol so this function can be used during receive. + */ +static inline int __vlan_insert_inner_tag(struct sk_buff *skb, + __be16 vlan_proto, u16 vlan_tci, + unsigned int mac_len) +{ + struct vlan_ethhdr *veth; + + if (skb_cow_head(skb, VLAN_HLEN) < 0) + return -ENOMEM; + + skb_push(skb, VLAN_HLEN); + + /* Move the mac header sans proto to the beginning of the new header. */ + memmove(skb->data, skb->data + VLAN_HLEN, mac_len - ETH_TLEN); + skb->mac_header -= VLAN_HLEN; + + veth = (struct vlan_ethhdr *)(skb->data + mac_len - ETH_HLEN); + + /* first, the ethernet type */ + veth->h_vlan_proto = vlan_proto; + + /* now, the TCI */ + veth->h_vlan_TCI = htons(vlan_tci); + + return 0; +} + /** * __vlan_insert_tag - regular VLAN tag inserting * @skb: skbuff to tag @@ -313,24 +351,37 @@ static inline bool vlan_hw_offload_capable(netdev_features_t features, static inline int __vlan_insert_tag(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) { - struct vlan_ethhdr *veth; + return __vlan_insert_inner_tag(skb, vlan_proto, vlan_tci, ETH_HLEN); +} - if (skb_cow_head(skb, VLAN_HLEN) < 0) - return -ENOMEM; +/** + * vlan_insert_inner_tag - inner VLAN tag inserting + * @skb: skbuff to tag + * @vlan_proto: VLAN encapsulation protocol + * @vlan_tci: VLAN TCI to insert + * @mac_len: MAC header length including outer vlan headers + * + * Inserts the VLAN tag into @skb as part of the payload at offset mac_len + * Returns a VLAN tagged skb. If a new skb is created, @skb is freed. + * + * Following the skb_unshare() example, in case of error, the calling function + * doesn't have to worry about freeing the original skb. + * + * Does not change skb->protocol so this function can be used during receive. + */ +static inline struct sk_buff *vlan_insert_inner_tag(struct sk_buff *skb, + __be16 vlan_proto, + u16 vlan_tci, + unsigned int mac_len) +{ + int err; - veth = skb_push(skb, VLAN_HLEN); - - /* Move the mac addresses to the beginning of the new header. */ - memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN); - skb->mac_header -= VLAN_HLEN; - - /* first, the ethernet type */ - veth->h_vlan_proto = vlan_proto; - - /* now, the TCI */ - veth->h_vlan_TCI = htons(vlan_tci); - - return 0; + err = __vlan_insert_inner_tag(skb, vlan_proto, vlan_tci, mac_len); + if (err) { + dev_kfree_skb_any(skb); + return NULL; + } + return skb; } /** @@ -350,14 +401,7 @@ static inline int __vlan_insert_tag(struct sk_buff *skb, static inline struct sk_buff *vlan_insert_tag(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci) { - int err; - - err = __vlan_insert_tag(skb, vlan_proto, vlan_tci); - if (err) { - dev_kfree_skb_any(skb); - return NULL; - } - return skb; + return vlan_insert_inner_tag(skb, vlan_proto, vlan_tci, ETH_HLEN); } /** diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 64aa9f755e1d..45c9bf5ff3a0 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c @@ -48,8 +48,8 @@ bool vlan_do_receive(struct sk_buff **skbp) * original position later */ skb_push(skb, offset); - skb = *skbp = vlan_insert_tag(skb, skb->vlan_proto, - skb->vlan_tci); + skb = *skbp = vlan_insert_inner_tag(skb, skb->vlan_proto, + skb->vlan_tci, skb->mac_len); if (!skb) return false; skb_pull(skb, offset + VLAN_HLEN); From 2cc683e88c0c993ac3721d9b702cb0630abe2879 Mon Sep 17 00:00:00 2001 From: Tom Herbert Date: Tue, 13 Mar 2018 12:01:43 -0700 Subject: [PATCH 744/942] kcm: lock lower socket in kcm_attach Need to lock lower socket in order to provide mutual exclusion with kcm_unattach. v2: Add Reported-by for syzbot Fixes: ab7ac4eb9832e32a09f4e804 ("kcm: Kernel Connection Multiplexor module") Reported-by: syzbot+ea75c0ffcd353d32515f064aaebefc5279e6161e@syzkaller.appspotmail.com Signed-off-by: Tom Herbert Signed-off-by: David S. Miller --- net/kcm/kcmsock.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index f297d53a11aa..34355fd19f27 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -1381,24 +1381,32 @@ static int kcm_attach(struct socket *sock, struct socket *csock, .parse_msg = kcm_parse_func_strparser, .read_sock_done = kcm_read_sock_done, }; - int err; + int err = 0; csk = csock->sk; if (!csk) return -EINVAL; + lock_sock(csk); + /* Only allow TCP sockets to be attached for now */ if ((csk->sk_family != AF_INET && csk->sk_family != AF_INET6) || - csk->sk_protocol != IPPROTO_TCP) - return -EOPNOTSUPP; + csk->sk_protocol != IPPROTO_TCP) { + err = -EOPNOTSUPP; + goto out; + } /* Don't allow listeners or closed sockets */ - if (csk->sk_state == TCP_LISTEN || csk->sk_state == TCP_CLOSE) - return -EOPNOTSUPP; + if (csk->sk_state == TCP_LISTEN || csk->sk_state == TCP_CLOSE) { + err = -EOPNOTSUPP; + goto out; + } psock = kmem_cache_zalloc(kcm_psockp, GFP_KERNEL); - if (!psock) - return -ENOMEM; + if (!psock) { + err = -ENOMEM; + goto out; + } psock->mux = mux; psock->sk = csk; @@ -1407,7 +1415,7 @@ static int kcm_attach(struct socket *sock, struct socket *csock, err = strp_init(&psock->strp, csk, &cb); if (err) { kmem_cache_free(kcm_psockp, psock); - return err; + goto out; } write_lock_bh(&csk->sk_callback_lock); @@ -1419,7 +1427,8 @@ static int kcm_attach(struct socket *sock, struct socket *csock, write_unlock_bh(&csk->sk_callback_lock); strp_done(&psock->strp); kmem_cache_free(kcm_psockp, psock); - return -EALREADY; + err = -EALREADY; + goto out; } psock->save_data_ready = csk->sk_data_ready; @@ -1455,7 +1464,10 @@ static int kcm_attach(struct socket *sock, struct socket *csock, /* Schedule RX work in case there are already bytes queued */ strp_check_rcv(&psock->strp); - return 0; +out: + release_sock(csk); + + return err; } static int kcm_attach_ioctl(struct socket *sock, struct kcm_attach *info) @@ -1507,6 +1519,7 @@ static void kcm_unattach(struct kcm_psock *psock) if (WARN_ON(psock->rx_kcm)) { write_unlock_bh(&csk->sk_callback_lock); + release_sock(csk); return; } From 484d802d0f2f29c335563fcac2a8facf174a1bbc Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 13 Mar 2018 14:45:07 -0700 Subject: [PATCH 745/942] net: systemport: Rewrite __bcm_sysport_tx_reclaim() There is no need for complex checking between the last consumed index and current consumed index, a simple subtraction will do. This also eliminates the possibility of a permanent transmit queue stall under the following conditions: - one CPU bursts ring->size worth of traffic (up to 256 buffers), to the point where we run out of free descriptors, so we stop the transmit queue at the end of bcm_sysport_xmit() - because of our locking, we have the transmit process disable interrupts which means we can be blocking the TX reclamation process - when TX reclamation finally runs, we will be computing the difference between ring->c_index (last consumed index by SW) and what the HW reports through its register - this register is masked with (ring->size - 1) = 0xff, which will lead to stripping the upper bits of the index (register is 16-bits wide) - we will be computing last_tx_cn as 0, which means there is no work to be done, and we never wake-up the transmit queue, leaving it permanently disabled A practical example is e.g: ring->c_index aka last_c_index = 12, we pushed 256 entries, HW consumer index = 268, we mask it with 0xff = 12, so last_tx_cn == 0, nothing happens. Fixes: 80105befdb4b ("net: systemport: add Broadcom SYSTEMPORT Ethernet MAC driver") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bcmsysport.c | 33 ++++++++++------------ drivers/net/ethernet/broadcom/bcmsysport.h | 2 +- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index f15a8fc6dfc9..3fc549b88c43 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c @@ -855,10 +855,12 @@ static void bcm_sysport_tx_reclaim_one(struct bcm_sysport_tx_ring *ring, static unsigned int __bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv, struct bcm_sysport_tx_ring *ring) { - unsigned int c_index, last_c_index, last_tx_cn, num_tx_cbs; unsigned int pkts_compl = 0, bytes_compl = 0; struct net_device *ndev = priv->netdev; + unsigned int txbds_processed = 0; struct bcm_sysport_cb *cb; + unsigned int txbds_ready; + unsigned int c_index; u32 hw_ind; /* Clear status before servicing to reduce spurious interrupts */ @@ -871,29 +873,23 @@ static unsigned int __bcm_sysport_tx_reclaim(struct bcm_sysport_priv *priv, /* Compute how many descriptors have been processed since last call */ hw_ind = tdma_readl(priv, TDMA_DESC_RING_PROD_CONS_INDEX(ring->index)); c_index = (hw_ind >> RING_CONS_INDEX_SHIFT) & RING_CONS_INDEX_MASK; - ring->p_index = (hw_ind & RING_PROD_INDEX_MASK); - - last_c_index = ring->c_index; - num_tx_cbs = ring->size; - - c_index &= (num_tx_cbs - 1); - - if (c_index >= last_c_index) - last_tx_cn = c_index - last_c_index; - else - last_tx_cn = num_tx_cbs - last_c_index + c_index; + txbds_ready = (c_index - ring->c_index) & RING_CONS_INDEX_MASK; netif_dbg(priv, tx_done, ndev, - "ring=%d c_index=%d last_tx_cn=%d last_c_index=%d\n", - ring->index, c_index, last_tx_cn, last_c_index); + "ring=%d old_c_index=%u c_index=%u txbds_ready=%u\n", + ring->index, ring->c_index, c_index, txbds_ready); - while (last_tx_cn-- > 0) { - cb = ring->cbs + last_c_index; + while (txbds_processed < txbds_ready) { + cb = &ring->cbs[ring->clean_index]; bcm_sysport_tx_reclaim_one(ring, cb, &bytes_compl, &pkts_compl); ring->desc_count++; - last_c_index++; - last_c_index &= (num_tx_cbs - 1); + txbds_processed++; + + if (likely(ring->clean_index < ring->size - 1)) + ring->clean_index++; + else + ring->clean_index = 0; } u64_stats_update_begin(&priv->syncp); @@ -1394,6 +1390,7 @@ static int bcm_sysport_init_tx_ring(struct bcm_sysport_priv *priv, netif_tx_napi_add(priv->netdev, &ring->napi, bcm_sysport_tx_poll, 64); ring->index = index; ring->size = size; + ring->clean_index = 0; ring->alloc_size = ring->size; ring->desc_cpu = p; ring->desc_count = ring->size; diff --git a/drivers/net/ethernet/broadcom/bcmsysport.h b/drivers/net/ethernet/broadcom/bcmsysport.h index f5a984c1c986..19c91c76e327 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.h +++ b/drivers/net/ethernet/broadcom/bcmsysport.h @@ -706,7 +706,7 @@ struct bcm_sysport_tx_ring { unsigned int desc_count; /* Number of descriptors */ unsigned int curr_desc; /* Current descriptor */ unsigned int c_index; /* Last consumer index */ - unsigned int p_index; /* Current producer index */ + unsigned int clean_index; /* Current clean index */ struct bcm_sysport_cb *cbs; /* Transmit control blocks */ struct dma_desc *desc_cpu; /* CPU view of the descriptor */ struct bcm_sysport_priv *priv; /* private context backpointer */ From fa6a91e9b907231d2e38ea5ed89c537b3525df3d Mon Sep 17 00:00:00 2001 From: Arvind Yadav Date: Tue, 13 Mar 2018 16:50:06 +0100 Subject: [PATCH 746/942] net/iucv: Free memory obtained by kzalloc Free memory by calling put_device(), if afiucv_iucv_init is not successful. Signed-off-by: Arvind Yadav Reviewed-by: Cornelia Huck Signed-off-by: Ursula Braun Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller --- net/iucv/af_iucv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index 1e8cc7bcbca3..9e2643ab4ccb 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -2433,9 +2433,11 @@ static int afiucv_iucv_init(void) af_iucv_dev->driver = &af_iucv_driver; err = device_register(af_iucv_dev); if (err) - goto out_driver; + goto out_iucv_dev; return 0; +out_iucv_dev: + put_device(af_iucv_dev); out_driver: driver_unregister(&af_iucv_driver); out_iucv: From 933e8c91b9f5a2f504f6da1f069c410449b9f4b9 Mon Sep 17 00:00:00 2001 From: Michal Kalderon Date: Wed, 14 Mar 2018 14:49:27 +0200 Subject: [PATCH 747/942] qed: Fix MPA unalign flow in case header is split across two packets. There is a corner case in the MPA unalign flow where a FPDU header is split over two tcp segments. The length of the first fragment in this case was not initialized properly and should be '1' Fixes: c7d1d839 ("qed: Add support for MPA header being split over two tcp packets") Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c index ca4a81dc1ace..fefe5277f20d 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c @@ -1928,8 +1928,8 @@ qed_iwarp_update_fpdu_length(struct qed_hwfn *p_hwfn, /* Missing lower byte is now available */ mpa_len = fpdu->fpdu_length | *mpa_data; fpdu->fpdu_length = QED_IWARP_FPDU_LEN_WITH_PAD(mpa_len); - fpdu->mpa_frag_len = fpdu->fpdu_length; /* one byte of hdr */ + fpdu->mpa_frag_len = 1; fpdu->incomplete_bytes = fpdu->fpdu_length - 1; DP_VERBOSE(p_hwfn, QED_MSG_RDMA, From 16da09047d3fb991dc48af41f6d255fd578e8ca2 Mon Sep 17 00:00:00 2001 From: Michal Kalderon Date: Wed, 14 Mar 2018 14:49:28 +0200 Subject: [PATCH 748/942] qed: Fix non TCP packets should be dropped on iWARP ll2 connection FW workaround. The iWARP LL2 connection did not expect TCP packets to arrive on it's connection. The fix drops any non-tcp packets Fixes b5c29ca ("qed: iWARP CM - setup a ll2 connection for handling SYN packets") Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qed/qed_iwarp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c index fefe5277f20d..d5d02be72947 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c @@ -1703,6 +1703,13 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn, iph = (struct iphdr *)((u8 *)(ethh) + eth_hlen); if (eth_type == ETH_P_IP) { + if (iph->protocol != IPPROTO_TCP) { + DP_NOTICE(p_hwfn, + "Unexpected ip protocol on ll2 %x\n", + iph->protocol); + return -EINVAL; + } + cm_info->local_ip[0] = ntohl(iph->daddr); cm_info->remote_ip[0] = ntohl(iph->saddr); cm_info->ip_version = TCP_IPV4; @@ -1711,6 +1718,14 @@ qed_iwarp_parse_rx_pkt(struct qed_hwfn *p_hwfn, *payload_len = ntohs(iph->tot_len) - ip_hlen; } else if (eth_type == ETH_P_IPV6) { ip6h = (struct ipv6hdr *)iph; + + if (ip6h->nexthdr != IPPROTO_TCP) { + DP_NOTICE(p_hwfn, + "Unexpected ip protocol on ll2 %x\n", + iph->protocol); + return -EINVAL; + } + for (i = 0; i < 4; i++) { cm_info->local_ip[i] = ntohl(ip6h->daddr.in6_u.u6_addr32[i]); From 4609adc27175839408359822523de7247d56c87f Mon Sep 17 00:00:00 2001 From: Michal Kalderon Date: Wed, 14 Mar 2018 14:56:53 +0200 Subject: [PATCH 749/942] qede: Fix qedr link update Link updates were not reported to qedr correctly. Leading to cases where a link could be down, but qedr would see it as up. In addition, once qede was loaded, link state would be up, regardless of the actual link state. Signed-off-by: Michal Kalderon Signed-off-by: Ariel Elior Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qede/qede_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c index 2db70eabddfe..5c28209e97d0 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c @@ -2067,8 +2067,6 @@ static int qede_load(struct qede_dev *edev, enum qede_load_mode mode, link_params.link_up = true; edev->ops->common->set_link(edev->cdev, &link_params); - qede_rdma_dev_event_open(edev); - edev->state = QEDE_STATE_OPEN; DP_INFO(edev, "Ending successfully qede load\n"); @@ -2169,12 +2167,14 @@ static void qede_link_update(void *dev, struct qed_link_output *link) DP_NOTICE(edev, "Link is up\n"); netif_tx_start_all_queues(edev->ndev); netif_carrier_on(edev->ndev); + qede_rdma_dev_event_open(edev); } } else { if (netif_carrier_ok(edev->ndev)) { DP_NOTICE(edev, "Link is down\n"); netif_tx_disable(edev->ndev); netif_carrier_off(edev->ndev); + qede_rdma_dev_event_close(edev); } } } From 02a2385f37a7c6594c9d89b64c4a1451276f08eb Mon Sep 17 00:00:00 2001 From: Nicolas Dichtel Date: Wed, 14 Mar 2018 21:10:23 +0100 Subject: [PATCH 750/942] netlink: avoid a double skb free in genlmsg_mcast() nlmsg_multicast() consumes always the skb, thus the original skb must be freed only when this function is called with a clone. Fixes: cb9f7a9a5c96 ("netlink: ensure to loop over all netns in genlmsg_multicast_allns()") Reported-by: Ben Hutchings Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller --- net/netlink/genetlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 6f02499ef007..b9ce82c9440f 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -1106,7 +1106,7 @@ static int genlmsg_mcast(struct sk_buff *skb, u32 portid, unsigned long group, if (!err) delivered = true; else if (err != -ESRCH) - goto error; + return err; return delivered ? 0 : -ESRCH; error: kfree_skb(skb); From 6e5d58fdc9bedd0255a8781b258f10bbdc63e975 Mon Sep 17 00:00:00 2001 From: Vinicius Costa Gomes Date: Wed, 14 Mar 2018 13:32:09 -0700 Subject: [PATCH 751/942] skbuff: Fix not waking applications when errors are enqueued When errors are enqueued to the error queue via sock_queue_err_skb() function, it is possible that the waiting application is not notified. Calling 'sk->sk_data_ready()' would not notify applications that selected only POLLERR events in poll() (for example). Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-by: Randy E. Witt Reviewed-by: Eric Dumazet Signed-off-by: Vinicius Costa Gomes Signed-off-by: David S. Miller --- net/core/skbuff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b103f46ec512..1e7acdc30732 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -4179,7 +4179,7 @@ int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb) skb_queue_tail(&sk->sk_error_queue, skb); if (!sock_flag(sk, SOCK_DEAD)) - sk->sk_data_ready(sk); + sk->sk_error_report(sk); return 0; } EXPORT_SYMBOL(sock_queue_err_skb); From 7b7ef57c0dd2bb367ad41a77e5136c5579ae4026 Mon Sep 17 00:00:00 2001 From: Andrew Lunn Date: Fri, 16 Mar 2018 18:03:46 +0100 Subject: [PATCH 752/942] net: dsa: mv88e6xxx: Fix binding documentation for MDIO busses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MDIO busses are switch properties and so should be inside the switch node. Fix the examples in the binding document. Reported-by: 尤晓杰 Signed-off-by: Andrew Lunn Fixes: a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO busses") Signed-off-by: David S. Miller --- .../devicetree/bindings/net/dsa/marvell.txt | 50 ++++++++++--------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/Documentation/devicetree/bindings/net/dsa/marvell.txt b/Documentation/devicetree/bindings/net/dsa/marvell.txt index 1d4d0f49c9d0..8c033d48e2ba 100644 --- a/Documentation/devicetree/bindings/net/dsa/marvell.txt +++ b/Documentation/devicetree/bindings/net/dsa/marvell.txt @@ -50,14 +50,15 @@ Example: compatible = "marvell,mv88e6085"; reg = <0>; reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>; - }; - mdio { - #address-cells = <1>; - #size-cells = <0>; - switch1phy0: switch1phy0@0 { - reg = <0>; - interrupt-parent = <&switch0>; - interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + switch1phy0: switch1phy0@0 { + reg = <0>; + interrupt-parent = <&switch0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; }; }; }; @@ -74,23 +75,24 @@ Example: compatible = "marvell,mv88e6390"; reg = <0>; reset-gpios = <&gpio5 1 GPIO_ACTIVE_LOW>; - }; - mdio { - #address-cells = <1>; - #size-cells = <0>; - switch1phy0: switch1phy0@0 { - reg = <0>; - interrupt-parent = <&switch0>; - interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; - }; - }; - mdio1 { - compatible = "marvell,mv88e6xxx-mdio-external"; - #address-cells = <1>; - #size-cells = <0>; - switch1phy9: switch1phy0@9 { - reg = <9>; + mdio { + #address-cells = <1>; + #size-cells = <0>; + switch1phy0: switch1phy0@0 { + reg = <0>; + interrupt-parent = <&switch0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; + }; + + mdio1 { + compatible = "marvell,mv88e6xxx-mdio-external"; + #address-cells = <1>; + #size-cells = <0>; + switch1phy9: switch1phy0@9 { + reg = <9>; + }; }; }; }; From bc44b78157f621ff2a2618fe287a827bcb094ac4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 16 Mar 2018 11:29:09 +0100 Subject: [PATCH 753/942] batman-adv: update data pointers after skb_cow() batadv_check_unicast_ttvn() calls skb_cow(), so pointers into the SKB data must be (re)set after calling it. The ethhdr variable is dropped altogether. Fixes: 7cdcf6dddc42 ("batman-adv: add UNICAST_4ADDR packet type") Signed-off-by: Matthias Schiffer Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/routing.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index b6891e8b741c..6a9242658c8d 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -968,14 +968,10 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, struct batadv_orig_node *orig_node = NULL, *orig_node_gw = NULL; int check, hdr_size = sizeof(*unicast_packet); enum batadv_subtype subtype; - struct ethhdr *ethhdr; int ret = NET_RX_DROP; bool is4addr, is_gw; unicast_packet = (struct batadv_unicast_packet *)skb->data; - unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; - ethhdr = eth_hdr(skb); - is4addr = unicast_packet->packet_type == BATADV_UNICAST_4ADDR; /* the caller function should have already pulled 2 bytes */ if (is4addr) @@ -995,12 +991,14 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, if (!batadv_check_unicast_ttvn(bat_priv, skb, hdr_size)) goto free_skb; + unicast_packet = (struct batadv_unicast_packet *)skb->data; + /* packet for me */ if (batadv_is_my_mac(bat_priv, unicast_packet->dest)) { /* If this is a unicast packet from another backgone gw, * drop it. */ - orig_addr_gw = ethhdr->h_source; + orig_addr_gw = eth_hdr(skb)->h_source; orig_node_gw = batadv_orig_hash_find(bat_priv, orig_addr_gw); if (orig_node_gw) { is_gw = batadv_bla_is_backbone_gw(skb, orig_node_gw, @@ -1015,6 +1013,8 @@ int batadv_recv_unicast_packet(struct sk_buff *skb, } if (is4addr) { + unicast_4addr_packet = + (struct batadv_unicast_4addr_packet *)skb->data; subtype = unicast_4addr_packet->subtype; batadv_dat_inc_counter(bat_priv, subtype); From 6f27d2c2a8c236d296201c19abb8533ec20d212b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 16 Mar 2018 11:29:10 +0100 Subject: [PATCH 754/942] batman-adv: fix header size check in batadv_dbg_arp() Checking for 0 is insufficient: when an SKB without a batadv header, but with a VLAN header is received, hdr_size will be 4, making the following code interpret the Ethernet header as a batadv header. Fixes: be1db4f6615b ("batman-adv: make the Distributed ARP Table vlan aware") Signed-off-by: Matthias Schiffer Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/distributed-arp-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 9703c791ffc5..87cd962d28d5 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -393,7 +393,7 @@ static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb, batadv_arp_hw_src(skb, hdr_size), &ip_src, batadv_arp_hw_dst(skb, hdr_size), &ip_dst); - if (hdr_size == 0) + if (hdr_size < sizeof(struct batadv_unicast_packet)) return; unicast_4addr_packet = (struct batadv_unicast_4addr_packet *)skb->data; From 2613f36ed965d0e5a595a1d931fd3b480e82d6fd Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Wed, 14 Mar 2018 19:36:14 +0100 Subject: [PATCH 755/942] x86/microcode: Attempt late loading only when new microcode is present Return UCODE_NEW from the scanning functions to denote that new microcode was found and only then attempt the expensive synchronization dance. Reported-by: Emanuel Czirai Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Tested-by: Emanuel Czirai Tested-by: Ashok Raj Tested-by: Tom Lendacky Link: https://lkml.kernel.org/r/20180314183615.17629-1-bp@alien8.de --- arch/x86/include/asm/microcode.h | 1 + arch/x86/kernel/cpu/microcode/amd.c | 36 ++++++++++++++++----------- arch/x86/kernel/cpu/microcode/core.c | 8 +++--- arch/x86/kernel/cpu/microcode/intel.c | 4 ++- 4 files changed, 29 insertions(+), 20 deletions(-) diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index 7fb1047d61c7..6cf0e4cb7b97 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h @@ -39,6 +39,7 @@ struct device; enum ucode_state { UCODE_OK = 0, + UCODE_NEW, UCODE_UPDATED, UCODE_NFOUND, UCODE_ERROR, diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index a998e1a7d46f..48179928ff38 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -339,7 +339,7 @@ int __init save_microcode_in_initrd_amd(unsigned int cpuid_1_eax) return -EINVAL; ret = load_microcode_amd(true, x86_family(cpuid_1_eax), desc.data, desc.size); - if (ret != UCODE_OK) + if (ret > UCODE_UPDATED) return -EINVAL; return 0; @@ -683,27 +683,35 @@ static enum ucode_state __load_microcode_amd(u8 family, const u8 *data, static enum ucode_state load_microcode_amd(bool save, u8 family, const u8 *data, size_t size) { + struct ucode_patch *p; enum ucode_state ret; /* free old equiv table */ free_equiv_cpu_table(); ret = __load_microcode_amd(family, data, size); - - if (ret != UCODE_OK) + if (ret != UCODE_OK) { cleanup(); - -#ifdef CONFIG_X86_32 - /* save BSP's matching patch for early load */ - if (save) { - struct ucode_patch *p = find_patch(0); - if (p) { - memset(amd_ucode_patch, 0, PATCH_MAX_SIZE); - memcpy(amd_ucode_patch, p->data, min_t(u32, ksize(p->data), - PATCH_MAX_SIZE)); - } + return ret; } -#endif + + p = find_patch(0); + if (!p) { + return ret; + } else { + if (boot_cpu_data.microcode == p->patch_id) + return ret; + + ret = UCODE_NEW; + } + + /* save BSP's matching patch for early load */ + if (!save) + return ret; + + memset(amd_ucode_patch, 0, PATCH_MAX_SIZE); + memcpy(amd_ucode_patch, p->data, min_t(u32, ksize(p->data), PATCH_MAX_SIZE)); + return ret; } diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 70ecbc8099c9..9f0fe5bb450d 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -607,7 +607,7 @@ static ssize_t reload_store(struct device *dev, return size; tmp_ret = microcode_ops->request_microcode_fw(bsp, µcode_pdev->dev, true); - if (tmp_ret != UCODE_OK) + if (tmp_ret != UCODE_NEW) return size; get_online_cpus(); @@ -691,10 +691,8 @@ static enum ucode_state microcode_init_cpu(int cpu, bool refresh_fw) if (system_state != SYSTEM_RUNNING) return UCODE_NFOUND; - ustate = microcode_ops->request_microcode_fw(cpu, µcode_pdev->dev, - refresh_fw); - - if (ustate == UCODE_OK) { + ustate = microcode_ops->request_microcode_fw(cpu, µcode_pdev->dev, refresh_fw); + if (ustate == UCODE_NEW) { pr_debug("CPU%d updated upon init\n", cpu); apply_microcode_on_target(cpu); } diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 2aded9db1d42..32b8e5724f96 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -862,6 +862,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, unsigned int leftover = size; unsigned int curr_mc_size = 0, new_mc_size = 0; unsigned int csig, cpf; + enum ucode_state ret = UCODE_OK; while (leftover) { struct microcode_header_intel mc_header; @@ -903,6 +904,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, new_mc = mc; new_mc_size = mc_size; mc = NULL; /* trigger new vmalloc */ + ret = UCODE_NEW; } ucode_ptr += mc_size; @@ -932,7 +934,7 @@ static enum ucode_state generic_load_microcode(int cpu, void *data, size_t size, pr_debug("CPU%d found a matching microcode update with version 0x%x (current=0x%x)\n", cpu, new_rev, uci->cpu_sig.rev); - return UCODE_OK; + return ret; } static int get_ucode_fw(void *to, const void *from, size_t n) From bb8c13d61a629276a162c1d2b1a20a815cbcfbb7 Mon Sep 17 00:00:00 2001 From: Borislav Petkov Date: Wed, 14 Mar 2018 19:36:15 +0100 Subject: [PATCH 756/942] x86/microcode: Fix CPU synchronization routine Emanuel reported an issue with a hang during microcode update because my dumb idea to use one atomic synchronization variable for both rendezvous - before and after update - was simply bollocks: microcode: microcode_reload_late: late_cpus: 4 microcode: __reload_late: cpu 2 entered microcode: __reload_late: cpu 1 entered microcode: __reload_late: cpu 3 entered microcode: __reload_late: cpu 0 entered microcode: __reload_late: cpu 1 left microcode: Timeout while waiting for CPUs rendezvous, remaining: 1 CPU1 above would finish, leave and the others will still spin waiting for it to join. So do two synchronization atomics instead, which makes the code a lot more straightforward. Also, since the update is serialized and it also takes quite some time per microcode engine, increase the exit timeout by the number of CPUs on the system. That's ok because the moment all CPUs are done, that timeout will be cut short. Furthermore, panic when some of the CPUs timeout when returning from a microcode update: we can't allow a system with not all cores updated. Also, as an optimization, do not do the exit sync if microcode wasn't updated. Reported-by: Emanuel Czirai Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Tested-by: Emanuel Czirai Tested-by: Ashok Raj Tested-by: Tom Lendacky Link: https://lkml.kernel.org/r/20180314183615.17629-2-bp@alien8.de --- arch/x86/kernel/cpu/microcode/core.c | 68 +++++++++++++++++----------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 9f0fe5bb450d..10c4fc2c91f8 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -517,7 +517,29 @@ static int check_online_cpus(void) return -EINVAL; } -static atomic_t late_cpus; +static atomic_t late_cpus_in; +static atomic_t late_cpus_out; + +static int __wait_for_cpus(atomic_t *t, long long timeout) +{ + int all_cpus = num_online_cpus(); + + atomic_inc(t); + + while (atomic_read(t) < all_cpus) { + if (timeout < SPINUNIT) { + pr_err("Timeout while waiting for CPUs rendezvous, remaining: %d\n", + all_cpus - atomic_read(t)); + return 1; + } + + ndelay(SPINUNIT); + timeout -= SPINUNIT; + + touch_nmi_watchdog(); + } + return 0; +} /* * Returns: @@ -527,30 +549,16 @@ static atomic_t late_cpus; */ static int __reload_late(void *info) { - unsigned int timeout = NSEC_PER_SEC; - int all_cpus = num_online_cpus(); int cpu = smp_processor_id(); enum ucode_state err; int ret = 0; - atomic_dec(&late_cpus); - /* * Wait for all CPUs to arrive. A load will not be attempted unless all * CPUs show up. * */ - while (atomic_read(&late_cpus)) { - if (timeout < SPINUNIT) { - pr_err("Timeout while waiting for CPUs rendezvous, remaining: %d\n", - atomic_read(&late_cpus)); - return -1; - } - - ndelay(SPINUNIT); - timeout -= SPINUNIT; - - touch_nmi_watchdog(); - } + if (__wait_for_cpus(&late_cpus_in, NSEC_PER_SEC)) + return -1; spin_lock(&update_lock); apply_microcode_local(&err); @@ -558,15 +566,22 @@ static int __reload_late(void *info) if (err > UCODE_NFOUND) { pr_warn("Error reloading microcode on CPU %d\n", cpu); - ret = -1; - } else if (err == UCODE_UPDATED) { + return -1; + /* siblings return UCODE_OK because their engine got updated already */ + } else if (err == UCODE_UPDATED || err == UCODE_OK) { ret = 1; + } else { + return ret; } - atomic_inc(&late_cpus); - - while (atomic_read(&late_cpus) != all_cpus) - cpu_relax(); + /* + * Increase the wait timeout to a safe value here since we're + * serializing the microcode update and that could take a while on a + * large number of CPUs. And that is fine as the *actual* timeout will + * be determined by the last CPU finished updating and thus cut short. + */ + if (__wait_for_cpus(&late_cpus_out, NSEC_PER_SEC * num_online_cpus())) + panic("Timeout during microcode update!\n"); return ret; } @@ -579,12 +594,11 @@ static int microcode_reload_late(void) { int ret; - atomic_set(&late_cpus, num_online_cpus()); + atomic_set(&late_cpus_in, 0); + atomic_set(&late_cpus_out, 0); ret = stop_machine_cpuslocked(__reload_late, NULL, cpu_online_mask); - if (ret < 0) - return ret; - else if (ret > 0) + if (ret > 0) microcode_check(); return ret; From 9ef0f88fe5466c2ca1d2975549ba6be502c464c1 Mon Sep 17 00:00:00 2001 From: John David Anglin Date: Wed, 7 Mar 2018 08:18:05 -0500 Subject: [PATCH 757/942] parisc: Handle case where flush_cache_range is called with no context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just when I had decided that flush_cache_range() was always called with a valid context, Helge reported two cases where the "BUG_ON(!vma->vm_mm->context);" was hit on the phantom buildd: kernel BUG at /mnt/sdb6/linux/linux-4.15.4/arch/parisc/kernel/cache.c:587! CPU: 1 PID: 3254 Comm: kworker/1:2 Tainted: G D 4.15.0-1-parisc64-smp #1 Debian 4.15.4-1+b1 Workqueue: events free_ioctx   IAOQ[0]: flush_cache_range+0x164/0x168   IAOQ[1]: flush_cache_page+0x0/0x1c8   RP(r2): unmap_page_range+0xae8/0xb88 Backtrace:   [<00000000404a6980>] unmap_page_range+0xae8/0xb88   [<00000000404a6ae0>] unmap_single_vma+0xc0/0x188   [<00000000404a6cdc>] zap_page_range_single+0x134/0x1f8   [<00000000404a702c>] unmap_mapping_range+0x1cc/0x208   [<0000000040461518>] truncate_pagecache+0x98/0x108   [<0000000040461624>] truncate_setsize+0x9c/0xb8   [<00000000405d7f30>] put_aio_ring_file+0x80/0x100   [<00000000405d803c>] aio_free_ring+0x8c/0x290   [<00000000405d82c0>] free_ioctx+0x80/0x180   [<0000000040284e6c>] process_one_work+0x21c/0x668   [<00000000402854c4>] worker_thread+0x20c/0x778   [<0000000040291d44>] kthread+0x2d4/0x2e0   [<0000000040204020>] end_fault_vector+0x20/0xc0 This indicates that we need to handle the no context case in flush_cache_range() as we do in flush_cache_mm(). In thinking about this, I realized that we don't need to flush the TLB when there is no context. So, I added context checks to the large flush cases in flush_cache_mm() and flush_cache_range(). The large flush case occurs frequently in flush_cache_mm() and the change should improve fork performance. The v2 version of this change removes the BUG_ON from flush_cache_page() by skipping the TLB flush when there is no context.  I also added code to flush the TLB in flush_cache_mm() and flush_cache_range() when we have a context that's not current.  Now all three routines handle TLB flushes in a similar manner. Signed-off-by: John David Anglin Cc: stable@vger.kernel.org # 4.9+ Signed-off-by: Helge Deller --- arch/parisc/kernel/cache.c | 41 +++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index 79089778725b..e3b45546d589 100644 --- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -543,7 +543,8 @@ void flush_cache_mm(struct mm_struct *mm) rp3440, etc. So, avoid it if the mm isn't too big. */ if ((!IS_ENABLED(CONFIG_SMP) || !arch_irqs_disabled()) && mm_total_size(mm) >= parisc_cache_flush_threshold) { - flush_tlb_all(); + if (mm->context) + flush_tlb_all(); flush_cache_all(); return; } @@ -571,6 +572,8 @@ void flush_cache_mm(struct mm_struct *mm) pfn = pte_pfn(*ptep); if (!pfn_valid(pfn)) continue; + if (unlikely(mm->context)) + flush_tlb_page(vma, addr); __flush_cache_page(vma, addr, PFN_PHYS(pfn)); } } @@ -579,26 +582,46 @@ void flush_cache_mm(struct mm_struct *mm) void flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) { + pgd_t *pgd; + unsigned long addr; + if ((!IS_ENABLED(CONFIG_SMP) || !arch_irqs_disabled()) && end - start >= parisc_cache_flush_threshold) { - flush_tlb_range(vma, start, end); + if (vma->vm_mm->context) + flush_tlb_range(vma, start, end); flush_cache_all(); return; } - flush_user_dcache_range_asm(start, end); - if (vma->vm_flags & VM_EXEC) - flush_user_icache_range_asm(start, end); - flush_tlb_range(vma, start, end); + if (vma->vm_mm->context == mfsp(3)) { + flush_user_dcache_range_asm(start, end); + if (vma->vm_flags & VM_EXEC) + flush_user_icache_range_asm(start, end); + flush_tlb_range(vma, start, end); + return; + } + + pgd = vma->vm_mm->pgd; + for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) { + unsigned long pfn; + pte_t *ptep = get_ptep(pgd, addr); + if (!ptep) + continue; + pfn = pte_pfn(*ptep); + if (pfn_valid(pfn)) { + if (unlikely(vma->vm_mm->context)) + flush_tlb_page(vma, addr); + __flush_cache_page(vma, addr, PFN_PHYS(pfn)); + } + } } void flush_cache_page(struct vm_area_struct *vma, unsigned long vmaddr, unsigned long pfn) { - BUG_ON(!vma->vm_mm->context); - if (pfn_valid(pfn)) { - flush_tlb_page(vma, vmaddr); + if (likely(vma->vm_mm->context)) + flush_tlb_page(vma, vmaddr); __flush_cache_page(vma, vmaddr, PFN_PHYS(pfn)); } } From cce6294cc2eaa083482e1d85d8db5845c82a7e14 Mon Sep 17 00:00:00 2001 From: Eric Dumazet Date: Wed, 14 Mar 2018 18:53:00 -0700 Subject: [PATCH 758/942] net: sched: fix uses after free syzbot reported one use-after-free in pfifo_fast_enqueue() [1] Issue here is that we can not reuse skb after a successful skb_array_produce() since another cpu might have consumed it already. I believe a similar problem exists in try_bulk_dequeue_skb_slow() in case we put an skb into qdisc_enqueue_skb_bad_txq() for lockless qdisc. [1] BUG: KASAN: use-after-free in qdisc_pkt_len include/net/sch_generic.h:610 [inline] BUG: KASAN: use-after-free in qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline] BUG: KASAN: use-after-free in pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639 Read of size 4 at addr ffff8801cede37e8 by task syzkaller717588/5543 CPU: 1 PID: 5543 Comm: syzkaller717588 Not tainted 4.16.0-rc4+ #265 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Call Trace: __dump_stack lib/dump_stack.c:17 [inline] dump_stack+0x194/0x24d lib/dump_stack.c:53 print_address_description+0x73/0x250 mm/kasan/report.c:256 kasan_report_error mm/kasan/report.c:354 [inline] kasan_report+0x23c/0x360 mm/kasan/report.c:412 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432 qdisc_pkt_len include/net/sch_generic.h:610 [inline] qdisc_qstats_cpu_backlog_inc include/net/sch_generic.h:712 [inline] pfifo_fast_enqueue+0x4bc/0x5e0 net/sched/sch_generic.c:639 __dev_xmit_skb net/core/dev.c:3216 [inline] Fixes: c5ad119fb6c0 ("net: sched: pfifo_fast use skb_array") Signed-off-by: Eric Dumazet Reported-by: syzbot+ed43b6903ab968b16f54@syzkaller.appspotmail.com Cc: John Fastabend Cc: Jamal Hadi Salim Cc: Cong Wang Cc: Jiri Pirko Acked-by: John Fastabend Signed-off-by: David S. Miller --- net/sched/sch_generic.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index 190570f21b20..7e3fbe9cc936 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c @@ -106,6 +106,14 @@ static inline void qdisc_enqueue_skb_bad_txq(struct Qdisc *q, __skb_queue_tail(&q->skb_bad_txq, skb); + if (qdisc_is_percpu_stats(q)) { + qdisc_qstats_cpu_backlog_inc(q, skb); + qdisc_qstats_cpu_qlen_inc(q); + } else { + qdisc_qstats_backlog_inc(q, skb); + q->q.qlen++; + } + if (lock) spin_unlock(lock); } @@ -196,14 +204,6 @@ static void try_bulk_dequeue_skb_slow(struct Qdisc *q, break; if (unlikely(skb_get_queue_mapping(nskb) != mapping)) { qdisc_enqueue_skb_bad_txq(q, nskb); - - if (qdisc_is_percpu_stats(q)) { - qdisc_qstats_cpu_backlog_inc(q, nskb); - qdisc_qstats_cpu_qlen_inc(q); - } else { - qdisc_qstats_backlog_inc(q, nskb); - q->q.qlen++; - } break; } skb->next = nskb; @@ -628,6 +628,7 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc, int band = prio2band[skb->priority & TC_PRIO_MAX]; struct pfifo_fast_priv *priv = qdisc_priv(qdisc); struct skb_array *q = band2list(priv, band); + unsigned int pkt_len = qdisc_pkt_len(skb); int err; err = skb_array_produce(q, skb); @@ -636,7 +637,10 @@ static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc *qdisc, return qdisc_drop_cpu(skb, qdisc, to_free); qdisc_qstats_cpu_qlen_inc(qdisc); - qdisc_qstats_cpu_backlog_inc(qdisc, skb); + /* Note: skb can not be used after skb_array_produce(), + * so we better not use qdisc_qstats_cpu_backlog_inc() + */ + this_cpu_add(qdisc->cpu_qstats->backlog, pkt_len); return NET_XMIT_SUCCESS; } From bcdd5de80a2275f7879dc278bfc747f1caf94442 Mon Sep 17 00:00:00 2001 From: Ido Schimmel Date: Thu, 15 Mar 2018 14:49:56 +0200 Subject: [PATCH 759/942] mlxsw: spectrum_buffers: Set a minimum quota for CPU port traffic In commit 9ffcc3725f09 ("mlxsw: spectrum: Allow packets to be trapped from any PG") I fixed a problem where packets could not be trapped to the CPU due to exceeded shared buffer quotas. The mentioned commit explains the problem in detail. The problem was fixed by assigning a minimum quota for the CPU port and the traffic class used for scheduling traffic to the CPU. However, commit 117b0dad2d54 ("mlxsw: Create a different trap group list for each device") assigned different traffic classes to different packet types and rendered the fix useless. Fix the problem by assigning a minimum quota for the CPU port and all the traffic classes that are currently in use. Fixes: 117b0dad2d54 ("mlxsw: Create a different trap group list for each device") Signed-off-by: Ido Schimmel Reported-by: Eddie Shklaer Tested-by: Eddie Shklaer Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- .../net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c index 93728c694e6d..0a9adc5962fb 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c @@ -385,13 +385,13 @@ static const struct mlxsw_sp_sb_cm mlxsw_sp_sb_cms_egress[] = { static const struct mlxsw_sp_sb_cm mlxsw_sp_cpu_port_sb_cms[] = { MLXSW_SP_CPU_PORT_SB_CM, + MLXSW_SP_SB_CM(MLXSW_PORT_MAX_MTU, 0, 0), + MLXSW_SP_SB_CM(MLXSW_PORT_MAX_MTU, 0, 0), + MLXSW_SP_SB_CM(MLXSW_PORT_MAX_MTU, 0, 0), + MLXSW_SP_SB_CM(MLXSW_PORT_MAX_MTU, 0, 0), + MLXSW_SP_SB_CM(MLXSW_PORT_MAX_MTU, 0, 0), MLXSW_SP_CPU_PORT_SB_CM, - MLXSW_SP_CPU_PORT_SB_CM, - MLXSW_SP_CPU_PORT_SB_CM, - MLXSW_SP_CPU_PORT_SB_CM, - MLXSW_SP_CPU_PORT_SB_CM, - MLXSW_SP_CPU_PORT_SB_CM, - MLXSW_SP_SB_CM(10000, 0, 0), + MLXSW_SP_SB_CM(MLXSW_PORT_MAX_MTU, 0, 0), MLXSW_SP_CPU_PORT_SB_CM, MLXSW_SP_CPU_PORT_SB_CM, MLXSW_SP_CPU_PORT_SB_CM, From d61d263c8d82db7c4404a29ebc29674b1c0c05c9 Mon Sep 17 00:00:00 2001 From: Matthias Brugger Date: Thu, 15 Mar 2018 17:54:20 +0100 Subject: [PATCH 760/942] net: hns: Fix ethtool private flags The driver implementation returns support for private flags, while no private flags are present. When asked for the number of private flags it returns the number of statistic flag names. Fix this by returning EOPNOTSUPP for not implemented ethtool flags. Signed-off-by: Matthias Brugger Signed-off-by: David S. Miller --- drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c | 2 +- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c index 86944bc3b273..74bd260ca02a 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_gmac.c @@ -666,7 +666,7 @@ static void hns_gmac_get_strings(u32 stringset, u8 *data) static int hns_gmac_get_sset_count(int stringset) { - if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS) + if (stringset == ETH_SS_STATS) return ARRAY_SIZE(g_gmac_stats_string); return 0; diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c index b62816c1574e..93e71e27401b 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.c @@ -422,7 +422,7 @@ void hns_ppe_update_stats(struct hns_ppe_cb *ppe_cb) int hns_ppe_get_sset_count(int stringset) { - if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS) + if (stringset == ETH_SS_STATS) return ETH_PPE_STATIC_NUM; return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c index 6f3570cfb501..e2e28532e4dc 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.c @@ -876,7 +876,7 @@ void hns_rcb_get_stats(struct hnae_queue *queue, u64 *data) */ int hns_rcb_get_ring_sset_count(int stringset) { - if (stringset == ETH_SS_STATS || stringset == ETH_SS_PRIV_FLAGS) + if (stringset == ETH_SS_STATS) return HNS_RING_STATIC_REG_NUM; return 0; diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c index 7ea7f8a4aa2a..2e14a3ae1d8b 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c @@ -993,8 +993,10 @@ int hns_get_sset_count(struct net_device *netdev, int stringset) cnt--; return cnt; - } else { + } else if (stringset == ETH_SS_STATS) { return (HNS_NET_STATS_CNT + ops->get_sset_count(h, stringset)); + } else { + return -EOPNOTSUPP; } } From f9db50691db4a7d860fce985f080bb3fc23a7ede Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZ=20Lin=20=28=E6=9E=97=E4=B8=8A=E6=99=BA=29?= Date: Fri, 16 Mar 2018 00:56:01 +0800 Subject: [PATCH 761/942] net: ethernet: ti: cpsw: add check for in-band mode setting with RGMII PHY interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to AM335x TRM[1] 14.3.6.2, AM437x TRM[2] 15.3.6.2 and DRA7 TRM[3] 24.11.4.8.7.3.3, in-band mode in EXT_EN(bit18) register is only available when PHY is configured in RGMII mode with 10Mbps speed. It will cause some networking issues without RGMII mode, such as carrier sense errors and low throughput. TI also mentioned this issue in their forum[4]. This patch adds the check mechanism for PHY interface with RGMII interface type, the in-band mode can only be set in RGMII mode with 10Mbps speed. References: [1]: https://www.ti.com/lit/ug/spruh73p/spruh73p.pdf [2]: http://www.ti.com/lit/ug/spruhl7h/spruhl7h.pdf [3]: http://www.ti.com/lit/ug/spruic2b/spruic2b.pdf [4]: https://e2e.ti.com/support/arm/sitara_arm/f/791/p/640765/2392155 Suggested-by: Holsety Chen (陳憲輝) Signed-off-by: SZ Lin (林上智) Signed-off-by: Schuyler Patton Reviewed-by: Grygorii Strashko Signed-off-by: David S. Miller --- drivers/net/ethernet/ti/cpsw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 1b1b78fdc138..b2b30c9df037 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1014,7 +1014,8 @@ static void _cpsw_adjust_link(struct cpsw_slave *slave, /* set speed_in input in case RMII mode is used in 100Mbps */ if (phy->speed == 100) mac_control |= BIT(15); - else if (phy->speed == 10) + /* in band mode only works in 10Mbps RGMII mode */ + else if ((phy->speed == 10) && phy_interface_is_rgmii(phy)) mac_control |= BIT(18); /* In Band mode */ if (priv->rx_pause) From 1edf8abe04090c4f41a85e42c66638be1ee69156 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Fri, 16 Mar 2018 00:00:53 +0100 Subject: [PATCH 762/942] net/sched: fix NULL dereference in the error path of tcf_vlan_init() when the following command # tc actions replace action vlan pop index 100 is run for the first time, and tcf_vlan_init() fails allocating struct tcf_vlan_params, tcf_vlan_cleanup() calls kfree_rcu(NULL, ...). This causes the following error: BUG: unable to handle kernel NULL pointer dereference at 0000000000000018 IP: __call_rcu+0x23/0x2b0 PGD 80000000760a2067 P4D 80000000760a2067 PUD 742c1067 PMD 0 Oops: 0002 [#1] SMP PTI Modules linked in: act_vlan(E) ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 snd_hda_codec_generic snd_hda_intel mbcache snd_hda_codec jbd2 snd_hda_core crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc snd_hwdep snd_seq snd_seq_device snd_pcm aesni_intel crypto_simd snd_timer glue_helper snd cryptd joydev soundcore virtio_balloon pcspkr i2c_piix4 nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm virtio_console virtio_blk virtio_net ata_piix crc32c_intel libata virtio_pci i2c_core virtio_ring serio_raw virtio floppy dm_mirror dm_region_hash dm_log dm_mod [last unloaded: act_vlan] CPU: 3 PID: 3119 Comm: tc Tainted: G E 4.16.0-rc4.act_vlan.orig+ #403 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:__call_rcu+0x23/0x2b0 RSP: 0018:ffffaac3005fb798 EFLAGS: 00010246 RAX: ffffffffc0704080 RBX: ffff97f2b4bbe900 RCX: 00000000ffffffff RDX: ffffffffabca5f00 RSI: 0000000000000010 RDI: 0000000000000010 RBP: 0000000000000010 R08: 0000000000000001 R09: 0000000000000044 R10: 00000000fd003000 R11: ffff97f2faab5b91 R12: 0000000000000000 R13: ffffffffabca5f00 R14: ffff97f2fb80202c R15: 00000000fffffff4 FS: 00007f68f75b4740(0000) GS:ffff97f2ffd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000018 CR3: 0000000072b52001 CR4: 00000000001606e0 Call Trace: __tcf_idr_release+0x79/0xf0 tcf_vlan_init+0x168/0x270 [act_vlan] tcf_action_init_1+0x2cc/0x430 tcf_action_init+0xd3/0x1b0 tc_ctl_action+0x18b/0x240 rtnetlink_rcv_msg+0x29c/0x310 ? _cond_resched+0x15/0x30 ? __kmalloc_node_track_caller+0x1b9/0x270 ? rtnl_calcit.isra.28+0x100/0x100 netlink_rcv_skb+0xd2/0x110 netlink_unicast+0x17c/0x230 netlink_sendmsg+0x2cd/0x3c0 sock_sendmsg+0x30/0x40 ___sys_sendmsg+0x27a/0x290 ? filemap_map_pages+0x34a/0x3a0 ? __handle_mm_fault+0xbfd/0xe20 __sys_sendmsg+0x51/0x90 do_syscall_64+0x6e/0x1a0 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x7f68f69c5ba0 RSP: 002b:00007fffd79c1118 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fffd79c1240 RCX: 00007f68f69c5ba0 RDX: 0000000000000000 RSI: 00007fffd79c1190 RDI: 0000000000000003 RBP: 000000005aaa708e R08: 0000000000000002 R09: 0000000000000000 R10: 00007fffd79c0ba0 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fffd79c1254 R14: 0000000000000001 R15: 0000000000669f60 Code: 5d e9 42 da ff ff 66 90 0f 1f 44 00 00 41 57 41 56 41 55 49 89 d5 41 54 55 48 89 fd 53 48 83 ec 08 40 f6 c7 07 0f 85 19 02 00 00 <48> 89 75 08 48 c7 45 00 00 00 00 00 9c 58 0f 1f 44 00 00 49 89 RIP: __call_rcu+0x23/0x2b0 RSP: ffffaac3005fb798 CR2: 0000000000000018 fix this in tcf_vlan_cleanup(), ensuring that kfree_rcu(p, ...) is called only when p is not NULL. Fixes: 4c5b9d9642c8 ("act_vlan: VLAN action rewrite to use RCU lock/unlock and update") Acked-by: Jiri Pirko Acked-by: Manish Kurup Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_vlan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index e1a1b3f3983a..c2914e9a4a6f 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -225,7 +225,8 @@ static void tcf_vlan_cleanup(struct tc_action *a) struct tcf_vlan_params *p; p = rcu_dereference_protected(v->vlan_p, 1); - kfree_rcu(p, rcu); + if (p) + kfree_rcu(p, rcu); } static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a, From aab378a7eda21941c4b678b21aea8867b6817f59 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Fri, 16 Mar 2018 00:00:54 +0100 Subject: [PATCH 763/942] net/sched: fix NULL dereference in the error path of tcf_csum_init() when the following command # tc action add action csum udp continue index 100 is run for the first time, and tcf_csum_init() fails allocating struct tcf_csum, tcf_csum_cleanup() calls kfree_rcu(NULL,...). This causes the following error: BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: __call_rcu+0x23/0x2b0 PGD 80000000740b4067 P4D 80000000740b4067 PUD 32e7f067 PMD 0 Oops: 0002 [#1] SMP PTI Modules linked in: act_csum(E) act_vlan ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 mbcache jbd2 crct10dif_pclmul crc32_pclmul ghash_clmulni_intel snd_hda_codec_generic pcbc snd_hda_intel snd_hda_codec snd_hda_core snd_hwdep snd_seq snd_seq_device snd_pcm snd_timer aesni_intel crypto_simd glue_helper cryptd snd joydev pcspkr virtio_balloon i2c_piix4 soundcore nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm virtio_blk drm virtio_net virtio_console ata_piix crc32c_intel libata virtio_pci serio_raw i2c_core virtio_ring virtio floppy dm_mirror dm_region_hash dm_log dm_mod [last unloaded: act_vlan] CPU: 2 PID: 5763 Comm: tc Tainted: G E 4.16.0-rc4.act_vlan.orig+ #403 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:__call_rcu+0x23/0x2b0 RSP: 0018:ffffb275803e77c0 EFLAGS: 00010246 RAX: ffffffffc057b080 RBX: ffff9674bc6f5240 RCX: 00000000ffffffff RDX: ffffffff928a5f00 RSI: 0000000000000008 RDI: 0000000000000008 RBP: 0000000000000008 R08: 0000000000000001 R09: 0000000000000044 R10: 0000000000000220 R11: ffff9674b9ab4821 R12: 0000000000000000 R13: ffffffff928a5f00 R14: 0000000000000000 R15: 0000000000000001 FS: 00007fa6368d8740(0000) GS:ffff9674bfd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 0000000073dec001 CR4: 00000000001606e0 Call Trace: __tcf_idr_release+0x79/0xf0 tcf_csum_init+0xfb/0x180 [act_csum] tcf_action_init_1+0x2cc/0x430 tcf_action_init+0xd3/0x1b0 tc_ctl_action+0x18b/0x240 rtnetlink_rcv_msg+0x29c/0x310 ? _cond_resched+0x15/0x30 ? __kmalloc_node_track_caller+0x1b9/0x270 ? rtnl_calcit.isra.28+0x100/0x100 netlink_rcv_skb+0xd2/0x110 netlink_unicast+0x17c/0x230 netlink_sendmsg+0x2cd/0x3c0 sock_sendmsg+0x30/0x40 ___sys_sendmsg+0x27a/0x290 ? filemap_map_pages+0x34a/0x3a0 ? __handle_mm_fault+0xbfd/0xe20 __sys_sendmsg+0x51/0x90 do_syscall_64+0x6e/0x1a0 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x7fa635ce9ba0 RSP: 002b:00007ffc185b0fc8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007ffc185b10f0 RCX: 00007fa635ce9ba0 RDX: 0000000000000000 RSI: 00007ffc185b1040 RDI: 0000000000000003 RBP: 000000005aaa85e0 R08: 0000000000000002 R09: 0000000000000000 R10: 00007ffc185b0a20 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffc185b1104 R14: 0000000000000001 R15: 0000000000669f60 Code: 5d e9 42 da ff ff 66 90 0f 1f 44 00 00 41 57 41 56 41 55 49 89 d5 41 54 55 48 89 fd 53 48 83 ec 08 40 f6 c7 07 0f 85 19 02 00 00 <48> 89 75 08 48 c7 45 00 00 00 00 00 9c 58 0f 1f 44 00 00 49 89 RIP: __call_rcu+0x23/0x2b0 RSP: ffffb275803e77c0 CR2: 0000000000000010 fix this in tcf_csum_cleanup(), ensuring that kfree_rcu(param, ...) is called only when param is not NULL. Fixes: 9c5f69bbd75a ("net/sched: act_csum: don't use spinlock in the fast path") Signed-off-by: Davide Caratti Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- net/sched/act_csum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sched/act_csum.c b/net/sched/act_csum.c index 24b2e8e681cf..2a5c8fd860cf 100644 --- a/net/sched/act_csum.c +++ b/net/sched/act_csum.c @@ -626,7 +626,8 @@ static void tcf_csum_cleanup(struct tc_action *a) struct tcf_csum_params *params; params = rcu_dereference_protected(p->params, 1); - kfree_rcu(params, rcu); + if (params) + kfree_rcu(params, rcu); } static int tcf_csum_walker(struct net *net, struct sk_buff *skb, From abdadd3cfd3e7ea3da61ac774f84777d1f702058 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Fri, 16 Mar 2018 00:00:55 +0100 Subject: [PATCH 764/942] net/sched: fix NULL dereference in the error path of tunnel_key_init() when the following command # tc action add action tunnel_key unset index 100 is run for the first time, and tunnel_key_init() fails to allocate struct tcf_tunnel_key_params, tunnel_key_release() dereferences NULL pointers. This causes the following error: BUG: unable to handle kernel NULL pointer dereference at 0000000000000010 IP: tunnel_key_release+0xd/0x40 [act_tunnel_key] PGD 8000000033787067 P4D 8000000033787067 PUD 74646067 PMD 0 Oops: 0000 [#1] SMP PTI Modules linked in: act_tunnel_key(E) act_csum ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 mbcache jbd2 crct10dif_pclmul crc32_pclmul snd_hda_codec_generic ghash_clmulni_intel snd_hda_intel pcbc snd_hda_codec snd_hda_core snd_hwdep snd_seq aesni_intel snd_seq_device crypto_simd glue_helper snd_pcm cryptd joydev snd_timer pcspkr virtio_balloon snd i2c_piix4 soundcore nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm virtio_net virtio_blk drm virtio_console crc32c_intel ata_piix serio_raw i2c_core virtio_pci libata virtio_ring virtio floppy dm_mirror dm_region_hash dm_log dm_mod CPU: 2 PID: 3101 Comm: tc Tainted: G E 4.16.0-rc4.act_vlan.orig+ #403 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:tunnel_key_release+0xd/0x40 [act_tunnel_key] RSP: 0018:ffffba46803b7768 EFLAGS: 00010286 RAX: ffffffffc09010a0 RBX: 0000000000000000 RCX: 0000000000000024 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff99ee336d7480 RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000044 R10: 0000000000000220 R11: ffff99ee79d73131 R12: 0000000000000000 R13: ffff99ee32d67610 R14: ffff99ee7671dc38 R15: 00000000fffffff4 FS: 00007febcb2cd740(0000) GS:ffff99ee7fd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000010 CR3: 000000007c8e4005 CR4: 00000000001606e0 Call Trace: __tcf_idr_release+0x79/0xf0 tunnel_key_init+0xd9/0x460 [act_tunnel_key] tcf_action_init_1+0x2cc/0x430 tcf_action_init+0xd3/0x1b0 tc_ctl_action+0x18b/0x240 rtnetlink_rcv_msg+0x29c/0x310 ? _cond_resched+0x15/0x30 ? __kmalloc_node_track_caller+0x1b9/0x270 ? rtnl_calcit.isra.28+0x100/0x100 netlink_rcv_skb+0xd2/0x110 netlink_unicast+0x17c/0x230 netlink_sendmsg+0x2cd/0x3c0 sock_sendmsg+0x30/0x40 ___sys_sendmsg+0x27a/0x290 __sys_sendmsg+0x51/0x90 do_syscall_64+0x6e/0x1a0 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x7febca6deba0 RSP: 002b:00007ffe7b0dd128 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007ffe7b0dd250 RCX: 00007febca6deba0 RDX: 0000000000000000 RSI: 00007ffe7b0dd1a0 RDI: 0000000000000003 RBP: 000000005aaa90cb R08: 0000000000000002 R09: 0000000000000000 R10: 00007ffe7b0dcba0 R11: 0000000000000246 R12: 0000000000000000 R13: 00007ffe7b0dd264 R14: 0000000000000001 R15: 0000000000669f60 Code: 44 00 00 8b 0d b5 23 00 00 48 8b 87 48 10 00 00 48 8b 3c c8 e9 a5 e5 d8 c3 0f 1f 44 00 00 0f 1f 44 00 00 53 48 8b 9f b0 00 00 00 <83> 7b 10 01 74 0b 48 89 df 31 f6 5b e9 f2 fa 7f c3 48 8b 7b 18 RIP: tunnel_key_release+0xd/0x40 [act_tunnel_key] RSP: ffffba46803b7768 CR2: 0000000000000010 Fix this in tunnel_key_release(), ensuring 'param' is not NULL before dereferencing it. Fixes: d0f6dd8a914f ("net/sched: Introduce act_tunnel_key") Signed-off-by: Davide Caratti Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- net/sched/act_tunnel_key.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c index fea772e66e62..1281ca463727 100644 --- a/net/sched/act_tunnel_key.c +++ b/net/sched/act_tunnel_key.c @@ -208,11 +208,12 @@ static void tunnel_key_release(struct tc_action *a) struct tcf_tunnel_key_params *params; params = rcu_dereference_protected(t->params, 1); + if (params) { + if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET) + dst_release(¶ms->tcft_enc_metadata->dst); - if (params->tcft_action == TCA_TUNNEL_KEY_ACT_SET) - dst_release(¶ms->tcft_enc_metadata->dst); - - kfree_rcu(params, rcu); + kfree_rcu(params, rcu); + } } static int tunnel_key_dump_addresses(struct sk_buff *skb, From 1f110e7cae09e6c6a144616480d1a9dd99c5208a Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Fri, 16 Mar 2018 00:00:56 +0100 Subject: [PATCH 765/942] net/sched: fix NULL dereference in the error path of tcf_sample_init() when the following command # tc action add action sample rate 100 group 100 index 100 is run for the first time, and psample_group_get(100) fails to create a new group, tcf_sample_cleanup() calls psample_group_put(NULL), thus causing the following error: BUG: unable to handle kernel NULL pointer dereference at 000000000000001c IP: psample_group_put+0x15/0x71 [psample] PGD 8000000075775067 P4D 8000000075775067 PUD 7453c067 PMD 0 Oops: 0002 [#1] SMP PTI Modules linked in: act_sample(E) psample ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 snd_hda_codec_generic snd_hda_intel snd_hda_codec snd_hda_core mbcache jbd2 crct10dif_pclmul snd_hwdep crc32_pclmul snd_seq ghash_clmulni_intel pcbc snd_seq_device snd_pcm aesni_intel crypto_simd snd_timer glue_helper snd cryptd joydev pcspkr i2c_piix4 soundcore virtio_balloon nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm virtio_net ata_piix virtio_console virtio_blk libata serio_raw crc32c_intel virtio_pci i2c_core virtio_ring virtio floppy dm_mirror dm_region_hash dm_log dm_mod [last unloaded: act_tunnel_key] CPU: 2 PID: 5740 Comm: tc Tainted: G E 4.16.0-rc4.act_vlan.orig+ #403 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:psample_group_put+0x15/0x71 [psample] RSP: 0018:ffffb8a80032f7d0 EFLAGS: 00010246 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000024 RDX: 0000000000000001 RSI: 0000000000000000 RDI: ffffffffc06d93c0 RBP: 0000000000000000 R08: 0000000000000001 R09: 0000000000000044 R10: 00000000bd003000 R11: ffff979fba04aa59 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: ffff979fbba3f22c FS: 00007f7638112740(0000) GS:ffff979fbfd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000000000000001c CR3: 00000000734ea001 CR4: 00000000001606e0 Call Trace: __tcf_idr_release+0x79/0xf0 tcf_sample_init+0x125/0x1d0 [act_sample] tcf_action_init_1+0x2cc/0x430 tcf_action_init+0xd3/0x1b0 tc_ctl_action+0x18b/0x240 rtnetlink_rcv_msg+0x29c/0x310 ? _cond_resched+0x15/0x30 ? __kmalloc_node_track_caller+0x1b9/0x270 ? rtnl_calcit.isra.28+0x100/0x100 netlink_rcv_skb+0xd2/0x110 netlink_unicast+0x17c/0x230 netlink_sendmsg+0x2cd/0x3c0 sock_sendmsg+0x30/0x40 ___sys_sendmsg+0x27a/0x290 ? filemap_map_pages+0x34a/0x3a0 ? __handle_mm_fault+0xbfd/0xe20 __sys_sendmsg+0x51/0x90 do_syscall_64+0x6e/0x1a0 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x7f7637523ba0 RSP: 002b:00007fff0473ef58 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fff0473f080 RCX: 00007f7637523ba0 RDX: 0000000000000000 RSI: 00007fff0473efd0 RDI: 0000000000000003 RBP: 000000005aaaac80 R08: 0000000000000002 R09: 0000000000000000 R10: 00007fff0473e9e0 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff0473f094 R14: 0000000000000001 R15: 0000000000669f60 Code: be 02 00 00 00 48 89 df e8 a9 fe ff ff e9 7c ff ff ff 0f 1f 40 00 0f 1f 44 00 00 53 48 89 fb 48 c7 c7 c0 93 6d c0 e8 db 20 8c ef <83> 6b 1c 01 74 10 48 c7 c7 c0 93 6d c0 ff 14 25 e8 83 83 b0 5b RIP: psample_group_put+0x15/0x71 [psample] RSP: ffffb8a80032f7d0 CR2: 000000000000001c Fix it in tcf_sample_cleanup(), ensuring that calls to psample_group_put(p) are done only when p is not NULL. Fixes: cadb9c9fdbc6 ("net/sched: act_sample: Fix error path in init") Signed-off-by: Davide Caratti Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- net/sched/act_sample.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sched/act_sample.c b/net/sched/act_sample.c index 1ba0df238756..74c5d7e6a0fa 100644 --- a/net/sched/act_sample.c +++ b/net/sched/act_sample.c @@ -103,7 +103,8 @@ static void tcf_sample_cleanup(struct tc_action *a) psample_group = rtnl_dereference(s->psample_group); RCU_INIT_POINTER(s->psample_group, NULL); - psample_group_put(psample_group); + if (psample_group) + psample_group_put(psample_group); } static bool tcf_sample_dev_ok_push(struct net_device *dev) From 2d433610176d6569e8b3a28f67bc72235bf69efc Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Fri, 16 Mar 2018 00:00:57 +0100 Subject: [PATCH 766/942] net/sched: fix NULL dereference on the error path of tcf_skbmod_init() when the following command # tc action replace action skbmod swap mac index 100 is run for the first time, and tcf_skbmod_init() fails to allocate struct tcf_skbmod_params, tcf_skbmod_cleanup() calls kfree_rcu(NULL), thus causing the following error: BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 IP: __call_rcu+0x23/0x2b0 PGD 8000000034057067 P4D 8000000034057067 PUD 74937067 PMD 0 Oops: 0002 [#1] SMP PTI Modules linked in: act_skbmod(E) psample ip6table_filter ip6_tables iptable_filter binfmt_misc ext4 snd_hda_codec_generic snd_hda_intel snd_hda_codec crct10dif_pclmul mbcache jbd2 crc32_pclmul snd_hda_core ghash_clmulni_intel snd_hwdep pcbc snd_seq snd_seq_device snd_pcm aesni_intel snd_timer crypto_simd glue_helper snd cryptd virtio_balloon joydev soundcore pcspkr i2c_piix4 nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c ata_generic pata_acpi qxl drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm drm virtio_console virtio_net virtio_blk ata_piix libata crc32c_intel virtio_pci serio_raw virtio_ring virtio i2c_core floppy dm_mirror dm_region_hash dm_log dm_mod [last unloaded: act_skbmod] CPU: 3 PID: 3144 Comm: tc Tainted: G E 4.16.0-rc4.act_vlan.orig+ #403 Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011 RIP: 0010:__call_rcu+0x23/0x2b0 RSP: 0018:ffffbd2e403e7798 EFLAGS: 00010246 RAX: ffffffffc0872080 RBX: ffff981d34bff780 RCX: 00000000ffffffff RDX: ffffffff922a5f00 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000001 R09: 000000000000021f R10: 000000003d003000 R11: 0000000000aaaaaa R12: 0000000000000000 R13: ffffffff922a5f00 R14: 0000000000000001 R15: ffff981d3b698c2c FS: 00007f3678292740(0000) GS:ffff981d3fd80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000008 CR3: 000000007c57a006 CR4: 00000000001606e0 Call Trace: __tcf_idr_release+0x79/0xf0 tcf_skbmod_init+0x1d1/0x210 [act_skbmod] tcf_action_init_1+0x2cc/0x430 tcf_action_init+0xd3/0x1b0 tc_ctl_action+0x18b/0x240 rtnetlink_rcv_msg+0x29c/0x310 ? _cond_resched+0x15/0x30 ? __kmalloc_node_track_caller+0x1b9/0x270 ? rtnl_calcit.isra.28+0x100/0x100 netlink_rcv_skb+0xd2/0x110 netlink_unicast+0x17c/0x230 netlink_sendmsg+0x2cd/0x3c0 sock_sendmsg+0x30/0x40 ___sys_sendmsg+0x27a/0x290 ? filemap_map_pages+0x34a/0x3a0 ? __handle_mm_fault+0xbfd/0xe20 __sys_sendmsg+0x51/0x90 do_syscall_64+0x6e/0x1a0 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 RIP: 0033:0x7f36776a3ba0 RSP: 002b:00007fff4703b618 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fff4703b740 RCX: 00007f36776a3ba0 RDX: 0000000000000000 RSI: 00007fff4703b690 RDI: 0000000000000003 RBP: 000000005aaaba36 R08: 0000000000000002 R09: 0000000000000000 R10: 00007fff4703b0a0 R11: 0000000000000246 R12: 0000000000000000 R13: 00007fff4703b754 R14: 0000000000000001 R15: 0000000000669f60 Code: 5d e9 42 da ff ff 66 90 0f 1f 44 00 00 41 57 41 56 41 55 49 89 d5 41 54 55 48 89 fd 53 48 83 ec 08 40 f6 c7 07 0f 85 19 02 00 00 <48> 89 75 08 48 c7 45 00 00 00 00 00 9c 58 0f 1f 44 00 00 49 89 RIP: __call_rcu+0x23/0x2b0 RSP: ffffbd2e403e7798 CR2: 0000000000000008 Fix it in tcf_skbmod_cleanup(), ensuring that kfree_rcu(p, ...) is called only when p is not NULL. Fixes: 86da71b57383 ("net_sched: Introduce skbmod action") Signed-off-by: Davide Caratti Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- net/sched/act_skbmod.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index fa975262dbac..d09565d6433e 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c @@ -190,7 +190,8 @@ static void tcf_skbmod_cleanup(struct tc_action *a) struct tcf_skbmod_params *p; p = rcu_dereference_protected(d->skbmod_p, 1); - kfree_rcu(p, rcu); + if (p) + kfree_rcu(p, rcu); } static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a, From 7a4c003d6921e2af215f4790aa43a292bdc78be0 Mon Sep 17 00:00:00 2001 From: Ronak Doshi Date: Fri, 16 Mar 2018 14:47:54 -0700 Subject: [PATCH 767/942] vmxnet3: avoid xmit reset due to a race in vmxnet3 The field txNumDeferred is used by the driver to keep track of the number of packets it has pushed to the emulation. The driver increments it on pushing the packet to the emulation and the emulation resets it to 0 at the end of the transmit. There is a possibility of a race either when (a) ESX is under heavy load or (b) workload inside VM is of low packet rate. This race results in xmit hangs when network coalescing is disabled. This change creates a local copy of txNumDeferred and uses it to perform ring arithmetic. Reported-by: Noriho Tanaka Signed-off-by: Ronak Doshi Acked-by: Shrikrishna Khare Signed-off-by: David S. Miller --- drivers/net/vmxnet3/vmxnet3_drv.c | 13 ++++++++----- drivers/net/vmxnet3/vmxnet3_int.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index 8b39c160743d..b466a422b72d 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -977,6 +977,8 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, { int ret; u32 count; + int num_pkts; + int tx_num_deferred; unsigned long flags; struct vmxnet3_tx_ctx ctx; union Vmxnet3_GenericDesc *gdesc; @@ -1075,12 +1077,12 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, #else gdesc = ctx.sop_txd; #endif + tx_num_deferred = le32_to_cpu(tq->shared->txNumDeferred); if (ctx.mss) { gdesc->txd.hlen = ctx.eth_ip_hdr_size + ctx.l4_hdr_size; gdesc->txd.om = VMXNET3_OM_TSO; gdesc->txd.msscof = ctx.mss; - le32_add_cpu(&tq->shared->txNumDeferred, (skb->len - - gdesc->txd.hlen + ctx.mss - 1) / ctx.mss); + num_pkts = (skb->len - gdesc->txd.hlen + ctx.mss - 1) / ctx.mss; } else { if (skb->ip_summed == CHECKSUM_PARTIAL) { gdesc->txd.hlen = ctx.eth_ip_hdr_size; @@ -1091,8 +1093,10 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, gdesc->txd.om = 0; gdesc->txd.msscof = 0; } - le32_add_cpu(&tq->shared->txNumDeferred, 1); + num_pkts = 1; } + le32_add_cpu(&tq->shared->txNumDeferred, num_pkts); + tx_num_deferred += num_pkts; if (skb_vlan_tag_present(skb)) { gdesc->txd.ti = 1; @@ -1118,8 +1122,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq, spin_unlock_irqrestore(&tq->tx_lock, flags); - if (le32_to_cpu(tq->shared->txNumDeferred) >= - le32_to_cpu(tq->shared->txThreshold)) { + if (tx_num_deferred >= le32_to_cpu(tq->shared->txThreshold)) { tq->shared->txNumDeferred = 0; VMXNET3_WRITE_BAR0_REG(adapter, VMXNET3_REG_TXPROD + tq->qid * 8, diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 5ba222920e80..b94fdfd0b6f1 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -69,10 +69,10 @@ /* * Version numbers */ -#define VMXNET3_DRIVER_VERSION_STRING "1.4.11.0-k" +#define VMXNET3_DRIVER_VERSION_STRING "1.4.12.0-k" /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ -#define VMXNET3_DRIVER_VERSION_NUM 0x01040b00 +#define VMXNET3_DRIVER_VERSION_NUM 0x01040c00 #if defined(CONFIG_PCI_MSI) /* RSS only makes sense if MSI-X is supported. */ From 034f405793897a3c8f642935f5494b86c340cde7 Mon Sep 17 00:00:00 2001 From: Ronak Doshi Date: Fri, 16 Mar 2018 14:49:19 -0700 Subject: [PATCH 768/942] vmxnet3: use correct flag to indicate LRO feature 'Commit 45dac1d6ea04 ("vmxnet3: Changes for vmxnet3 adapter version 2 (fwd)")' introduced a flag "lro" in structure vmxnet3_adapter which is used to indicate whether LRO is enabled or not. However, the patch did not set the flag and hence it was never exercised. So, when LRO is enabled, it resulted in poor TCP performance due to delayed acks. This issue is seen with packets which are larger than the mss getting a delayed ack rather than an immediate ack, thus resulting in high latency. This patch removes the lro flag and directly uses device features against NETIF_F_LRO to check if lro is enabled. Fixes: 45dac1d6ea04 ("vmxnet3: Changes for vmxnet3 adapter version 2 (fwd)") Reported-by: Rachel Lunnon Signed-off-by: Ronak Doshi Acked-by: Shrikrishna Khare Signed-off-by: David S. Miller --- drivers/net/vmxnet3/vmxnet3_drv.c | 3 ++- drivers/net/vmxnet3/vmxnet3_int.h | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index b466a422b72d..e04937f44f33 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -1473,7 +1473,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq, vmxnet3_rx_csum(adapter, skb, (union Vmxnet3_GenericDesc *)rcd); skb->protocol = eth_type_trans(skb, adapter->netdev); - if (!rcd->tcp || !adapter->lro) + if (!rcd->tcp || + !(adapter->netdev->features & NETIF_F_LRO)) goto not_lro; if (segCnt != 0 && mss != 0) { diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index b94fdfd0b6f1..99387a4a20a8 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -69,10 +69,10 @@ /* * Version numbers */ -#define VMXNET3_DRIVER_VERSION_STRING "1.4.12.0-k" +#define VMXNET3_DRIVER_VERSION_STRING "1.4.13.0-k" /* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ -#define VMXNET3_DRIVER_VERSION_NUM 0x01040c00 +#define VMXNET3_DRIVER_VERSION_NUM 0x01040d00 #if defined(CONFIG_PCI_MSI) /* RSS only makes sense if MSI-X is supported. */ @@ -343,7 +343,6 @@ struct vmxnet3_adapter { u8 version; bool rxcsum; - bool lro; #ifdef VMXNET3_RSS struct UPT1_RSSConf *rss_conf; From 48881ed56b395bdf2cff6c102039016223ca4da6 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Sun, 18 Mar 2018 09:48:03 +0100 Subject: [PATCH 769/942] batman-adv: Add missing include for EPOLL* constants Fixes: a9a08845e9ac ("vfs: do bulk POLL* -> EPOLL* replacement") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/icmp_socket.c | 1 + net/batman-adv/log.c | 1 + 2 files changed, 2 insertions(+) diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index e91f29c7c638..5daa3d50da17 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c index dc9fa37ddd14..cdbe0e5e208b 100644 --- a/net/batman-adv/log.c +++ b/net/batman-adv/log.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include From fc04fdb2c8a894283259f5621d31d75610701091 Mon Sep 17 00:00:00 2001 From: Sven Eckelmann Date: Fri, 16 Mar 2018 21:14:32 +0100 Subject: [PATCH 770/942] batman-adv: Fix skbuff rcsum on packet reroute batadv_check_unicast_ttvn may redirect a packet to itself or another originator. This involves rewriting the ttvn and the destination address in the batadv unicast header. These field were not yet pulled (with skb rcsum update) and thus any change to them also requires a change in the receive checksum. Reported-by: Matthias Schiffer Fixes: a73105b8d4c7 ("batman-adv: improved client announcement mechanism") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich --- net/batman-adv/routing.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 6a9242658c8d..e61dc1293bb5 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c @@ -759,6 +759,7 @@ free_skb: /** * batadv_reroute_unicast_packet() - update the unicast header for re-routing * @bat_priv: the bat priv with all the soft interface information + * @skb: unicast packet to process * @unicast_packet: the unicast header to be updated * @dst_addr: the payload destination * @vid: VLAN identifier @@ -770,7 +771,7 @@ free_skb: * Return: true if the packet header has been updated, false otherwise */ static bool -batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, +batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, struct sk_buff *skb, struct batadv_unicast_packet *unicast_packet, u8 *dst_addr, unsigned short vid) { @@ -799,8 +800,10 @@ batadv_reroute_unicast_packet(struct batadv_priv *bat_priv, } /* update the packet header */ + skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ether_addr_copy(unicast_packet->dest, orig_addr); unicast_packet->ttvn = orig_ttvn; + skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ret = true; out: @@ -841,7 +844,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, * the packet to */ if (batadv_tt_local_client_is_roaming(bat_priv, ethhdr->h_dest, vid)) { - if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, + if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet, ethhdr->h_dest, vid)) batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv, @@ -887,7 +890,7 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, * destination can possibly be updated and forwarded towards the new * target host */ - if (batadv_reroute_unicast_packet(bat_priv, unicast_packet, + if (batadv_reroute_unicast_packet(bat_priv, skb, unicast_packet, ethhdr->h_dest, vid)) { batadv_dbg_ratelimited(BATADV_DBG_TT, bat_priv, "Rerouting unicast packet to %pM (dst=%pM): TTVN mismatch old_ttvn=%u new_ttvn=%u\n", @@ -910,12 +913,14 @@ static bool batadv_check_unicast_ttvn(struct batadv_priv *bat_priv, if (!primary_if) return false; + /* update the packet header */ + skb_postpull_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); ether_addr_copy(unicast_packet->dest, primary_if->net_dev->dev_addr); + unicast_packet->ttvn = curr_ttvn; + skb_postpush_rcsum(skb, unicast_packet, sizeof(*unicast_packet)); batadv_hardif_put(primary_if); - unicast_packet->ttvn = curr_ttvn; - return true; } From a069215cf5985f3aa1bba550264907d6bd05c5f7 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Sun, 18 Mar 2018 12:49:51 -0700 Subject: [PATCH 771/942] net: fec: Fix unbalanced PM runtime calls When unbinding/removing the driver, we will run into the following warnings: [ 259.655198] fec 400d1000.ethernet: 400d1000.ethernet supply phy not found, using dummy regulator [ 259.665065] fec 400d1000.ethernet: Unbalanced pm_runtime_enable! [ 259.672770] fec 400d1000.ethernet (unnamed net_device) (uninitialized): Invalid MAC address: 00:00:00:00:00:00 [ 259.683062] fec 400d1000.ethernet (unnamed net_device) (uninitialized): Using random MAC address: f2:3e:93:b7:29:c1 [ 259.696239] libphy: fec_enet_mii_bus: probed Avoid these warnings by balancing the runtime PM calls during fec_drv_remove(). Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/ethernet/freescale/fec_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 7a7f3a42b2aa..d4604bc8eb5b 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3600,6 +3600,8 @@ fec_drv_remove(struct platform_device *pdev) fec_enet_mii_remove(fep); if (fep->reg_phy) regulator_disable(fep->reg_phy); + pm_runtime_put(&pdev->dev); + pm_runtime_disable(&pdev->dev); if (of_phy_is_fixed_link(np)) of_phy_deregister_fixed_link(np); of_node_put(fep->phy_node); From c15619a88ad43f215bbfb6ee163aa26ba9cc2573 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Fri, 9 Mar 2018 16:40:16 +0100 Subject: [PATCH 772/942] dt-bindings: exynos: Document #sound-dai-cells property of the HDMI node The #sound-dai-cells DT property is required to describe link between the HDMI IP block and the SoC's audio subsystem. Signed-off-by: Sylwester Nawrocki Reviewed-by: Rob Herring Signed-off-by: Inki Dae --- Documentation/devicetree/bindings/display/exynos/exynos_hdmi.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/display/exynos/exynos_hdmi.txt b/Documentation/devicetree/bindings/display/exynos/exynos_hdmi.txt index 6394ea9e3b9e..58b12e25bbb1 100644 --- a/Documentation/devicetree/bindings/display/exynos/exynos_hdmi.txt +++ b/Documentation/devicetree/bindings/display/exynos/exynos_hdmi.txt @@ -16,6 +16,7 @@ Required properties: - ddc: phandle to the hdmi ddc node - phy: phandle to the hdmi phy node - samsung,syscon-phandle: phandle for system controller node for PMU. +- #sound-dai-cells: should be 0. Required properties for Exynos 4210, 4212, 5420 and 5433: - clocks: list of clock IDs from SoC clock driver. From c698ca5278934c0ae32297a8725ced2e27585d7f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 18 Mar 2018 17:48:42 -0700 Subject: [PATCH 773/942] Linux 4.16-rc6 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e02d092bc2d6..d65e2e229017 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION = 4 PATCHLEVEL = 16 SUBLEVEL = 0 -EXTRAVERSION = -rc5 +EXTRAVERSION = -rc6 NAME = Fearless Coyote # *DOCUMENTATION* From 8bde8fd64d1b8f8bc1577e28ff412553597b6adb Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 16 Mar 2018 16:08:12 +0900 Subject: [PATCH 774/942] ASoC: uniphier: add syscon property to binding document This patch adds syscon property for specifying soc-glue core into DT binding documentation. Currently, soc-glue core is used for changing the state of S/PDIF signal output pin to signal output state or Hi-Z state. If you don't need to use features on soc-glue described above you can ommit this property. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/uniphier,aio.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/uniphier,aio.txt b/Documentation/devicetree/bindings/sound/uniphier,aio.txt index 65d71cf6ef0f..4ce68ed6f2f2 100644 --- a/Documentation/devicetree/bindings/sound/uniphier,aio.txt +++ b/Documentation/devicetree/bindings/sound/uniphier,aio.txt @@ -22,6 +22,12 @@ Required properties: entry in reset-names. - #sound-dai-cells: should be 1. +Optional properties: +- socionext,syscon: a phandle, should contain soc-glue. + The soc-glue is used for changing mode of S/PDIF signal pin + to Output from Hi-Z. This property is optional if you use + I2S signal pins only. + Example: audio { compatible = "socionext,uniphier-ld20-aio"; @@ -34,4 +40,6 @@ Example: reset-names = "aio"; resets = <&sys_rst 40>; #sound-dai-cells = <1>; + + socionext,syscon = <&sg>; }; From 7c3c20f2bec1e8bdaadd551a4b75f1834a7cb974 Mon Sep 17 00:00:00 2001 From: Katsuhiro Suzuki Date: Fri, 16 Mar 2018 16:08:13 +0900 Subject: [PATCH 775/942] ASoC: uniphier: add syscon property for UniPhier sound system This patch adds syscon property for specifying soc-glue core. Currently, soc-glue core is used for changing the state of S/PDIF signal output pin to signal output state or Hi-Z state. After resetting of SoC Hi-Z state is selected. This driver set to signal output state when syscon property is available. Signed-off-by: Katsuhiro Suzuki Signed-off-by: Mark Brown --- sound/soc/uniphier/aio-core.c | 21 +++++++++++++++++++++ sound/soc/uniphier/aio-cpu.c | 11 +++++++++++ sound/soc/uniphier/aio-reg.h | 3 +++ sound/soc/uniphier/aio.h | 2 ++ 4 files changed, 37 insertions(+) diff --git a/sound/soc/uniphier/aio-core.c b/sound/soc/uniphier/aio-core.c index 1711361fc0c2..6d50042a4571 100644 --- a/sound/soc/uniphier/aio-core.c +++ b/sound/soc/uniphier/aio-core.c @@ -83,6 +83,27 @@ u64 aio_rb_space_to_end(struct uniphier_aio_sub *sub) return rb_space_to_end(sub->wr_offs, sub->rd_offs, sub->compr_bytes); } +/** + * aio_iecout_set_enable - setup IEC output via SoC glue + * @chip: the AIO chip pointer + * @enable: false to stop the output, true to start + * + * Set enabled or disabled S/PDIF signal output to out of SoC via AOnIEC pins. + * This function need to call at driver startup. + * + * The regmap of SoC glue is specified by 'socionext,syscon' optional property + * of DT. This function has no effect if no property. + */ +void aio_iecout_set_enable(struct uniphier_aio_chip *chip, bool enable) +{ + struct regmap *r = chip->regmap_sg; + + if (!r) + return; + + regmap_write(r, SG_AOUTEN, (enable) ? ~0 : 0); +} + /** * aio_chip_set_pll - set frequency to audio PLL * @chip : the AIO chip pointer diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c index 7cf2316c69a2..1e5eb8e6f8c7 100644 --- a/sound/soc/uniphier/aio-cpu.c +++ b/sound/soc/uniphier/aio-cpu.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -387,6 +388,7 @@ int uniphier_aio_dai_probe(struct snd_soc_dai *dai) sub->spec = spec; } + aio_iecout_set_enable(aio->chip, true); aio_chip_init(aio->chip); aio->chip->active = 1; @@ -431,6 +433,7 @@ int uniphier_aio_dai_resume(struct snd_soc_dai *dai) if (ret) goto err_out_clock; + aio_iecout_set_enable(aio->chip, true); aio_chip_init(aio->chip); for (i = 0; i < ARRAY_SIZE(aio->sub); i++) { @@ -477,6 +480,14 @@ int uniphier_aio_probe(struct platform_device *pdev) if (!chip->chip_spec) return -EINVAL; + chip->regmap_sg = syscon_regmap_lookup_by_phandle(dev->of_node, + "socionext,syscon"); + if (IS_ERR(chip->regmap_sg)) { + if (PTR_ERR(chip->regmap_sg) == -EPROBE_DEFER) + return -EPROBE_DEFER; + chip->regmap_sg = NULL; + } + chip->clk = devm_clk_get(dev, "aio"); if (IS_ERR(chip->clk)) return PTR_ERR(chip->clk); diff --git a/sound/soc/uniphier/aio-reg.h b/sound/soc/uniphier/aio-reg.h index eaf2c65acf14..136d3563cf44 100644 --- a/sound/soc/uniphier/aio-reg.h +++ b/sound/soc/uniphier/aio-reg.h @@ -23,6 +23,9 @@ #include +/* soc-glue */ +#define SG_AOUTEN 0x1c04 + /* SW view */ #define A2CHNMAPCTR0(n) (0x00000 + 0x40 * (n)) #define A2RBNMAPCTR0(n) (0x01000 + 0x40 * (n)) diff --git a/sound/soc/uniphier/aio.h b/sound/soc/uniphier/aio.h index 793334675cb3..8cab4a553a97 100644 --- a/sound/soc/uniphier/aio.h +++ b/sound/soc/uniphier/aio.h @@ -296,6 +296,7 @@ struct uniphier_aio_chip { struct clk *clk; struct reset_control *rst; struct regmap *regmap; + struct regmap *regmap_sg; int active; }; @@ -323,6 +324,7 @@ u64 aio_rbt_cnt_to_end(struct uniphier_aio_sub *sub); u64 aio_rb_space(struct uniphier_aio_sub *sub); u64 aio_rb_space_to_end(struct uniphier_aio_sub *sub); +void aio_iecout_set_enable(struct uniphier_aio_chip *chip, bool enable); int aio_chip_set_pll(struct uniphier_aio_chip *chip, int pll_id, unsigned int freq); void aio_chip_init(struct uniphier_aio_chip *chip); From 66717d787a092c1438d2ce7b31d47fe88b6b93ea Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Fri, 16 Mar 2018 07:31:56 +0000 Subject: [PATCH 776/942] ASoC: mediatek: mt2701: drop unnessary snd_soc_unregister_component() It's not necessary to unregister a component registered with devm_snd_soc_register_component(). Fixes: f1b5bf07365d ("ASoC: mt2701/mt8173: replace platform to componen") Signed-off-by: Wei Yongjun Signed-off-by: Mark Brown --- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index f7e0702d92f8..43837a3bf1ca 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -1561,8 +1561,6 @@ static int mt2701_afe_pcm_dev_remove(struct platform_device *pdev) if (!pm_runtime_status_suspended(&pdev->dev)) mt2701_afe_runtime_suspend(&pdev->dev); - snd_soc_unregister_component(&pdev->dev); - return 0; } From 822e70a8210b7038e1f54c43ca6c76c3b9f89803 Mon Sep 17 00:00:00 2001 From: "weiyongjun (A)" Date: Fri, 16 Mar 2018 07:32:07 +0000 Subject: [PATCH 777/942] ASoC: wm8400: Use devm_snd_soc_register_component() Since the remove callback is removed, the snd_soc_unregister_component() is missing when remove device. Using devm_snd_soc_register_component() instead of snd_soc_register_component(). Fixes: 10dc44c6462d ("ASoC: wm8400: replace codec to component") Signed-off-by: Wei Yongjun Acked-by: Charles Keepax Signed-off-by: Mark Brown --- sound/soc/codecs/wm8400.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index c237365d1184..57b22065a45d 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c @@ -1343,7 +1343,7 @@ static const struct snd_soc_component_driver soc_component_dev_wm8400 = { static int wm8400_probe(struct platform_device *pdev) { - return snd_soc_register_component(&pdev->dev, + return devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8400, &wm8400_dai, 1); } From 3b84574d95c020f01410ff2ca0a38dd8fd7b644b Mon Sep 17 00:00:00 2001 From: Krzysztof Kozlowski Date: Sun, 18 Mar 2018 16:35:12 +0100 Subject: [PATCH 778/942] ASoC: samsung: Mark unused Odroid compatibles as deprecated Compatible for XU4 audio is not being used. Instead the board uses the same compatible as XU3. The devices are now just compatible so they should use the same value. Mark "hardkernel,odroid-xu4-audio" as being deprecated so in this future could be removed to limit useless properties. Additionally add older compatibles appearing in the bindings. Signed-off-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/samsung,odroid.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/samsung,odroid.txt b/Documentation/devicetree/bindings/sound/samsung,odroid.txt index f35a2694eb04..e9da2200e173 100644 --- a/Documentation/devicetree/bindings/sound/samsung,odroid.txt +++ b/Documentation/devicetree/bindings/sound/samsung,odroid.txt @@ -3,7 +3,9 @@ Samsung Exynos Odroid XU3/XU4 audio complex with MAX98090 codec Required properties: - compatible - "hardkernel,odroid-xu3-audio" - for Odroid XU3 board, - "hardkernel,odroid-xu4-audio" - for Odroid XU4 board + "hardkernel,odroid-xu4-audio" - for Odroid XU4 board (deprecated), + "samsung,odroid-xu3-audio" - for Odroid XU3 board (deprecated), + "samsung,odroid-xu4-audio" - for Odroid XU4 board (deprecated) - model - the user-visible name of this sound complex - clocks - should contain entries matching clock names in the clock-names property From c0153b126cc6e14335b142a799c9aa8990e28669 Mon Sep 17 00:00:00 2001 From: "weiyongjun (A)" Date: Fri, 16 Mar 2018 07:32:14 +0000 Subject: [PATCH 779/942] ASoC: da7210: Use devm_snd_soc_register_component() Since the remove callback is removed, the snd_soc_unregister_component() is missing when remove device. Using devm_snd_soc_register_component() instead of snd_soc_register_component(). Fixes: d06f33aed85c ("ASoC: da7210: replace codec to component") Signed-off-by: Wei Yongjun Signed-off-by: Mark Brown --- sound/soc/codecs/da7210.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/da7210.c b/sound/soc/codecs/da7210.c index 07153be52c52..a664111b7184 100644 --- a/sound/soc/codecs/da7210.c +++ b/sound/soc/codecs/da7210.c @@ -1233,7 +1233,7 @@ static int da7210_i2c_probe(struct i2c_client *i2c, if (ret != 0) dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); - ret = snd_soc_register_component(&i2c->dev, + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_da7210, &da7210_dai, 1); if (ret < 0) dev_err(&i2c->dev, "Failed to register component: %d\n", ret); From da263026c013412110da464537e1c5532f0714ee Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 16 Mar 2018 14:59:45 +0100 Subject: [PATCH 780/942] ASoC: rsnd: Document R-Car M3-W support Document support for the sound modules in the Renesas M3-W (r8a7796) SoC. No driver update is needed. Signed-off-by: Geert Uytterhoeven Reviewed-by: Rob Herring Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/renesas,rsnd.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt index 5bed9a595772..b86d790f630f 100644 --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt @@ -351,6 +351,7 @@ Required properties: - "renesas,rcar_sound-r8a7793" (R-Car M2-N) - "renesas,rcar_sound-r8a7794" (R-Car E2) - "renesas,rcar_sound-r8a7795" (R-Car H3) + - "renesas,rcar_sound-r8a7796" (R-Car M3-W) - reg : Should contain the register physical address. required register is SRU/ADG/SSI if generation1 From 4ae340d1be36378505498606e6c640dd0507ad61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= Date: Thu, 15 Mar 2018 17:18:24 +0100 Subject: [PATCH 781/942] ASoC: codecs: Add support for PCM1789 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Texas Instruments's PCM1789 DAC support. It is a simple DAC and does not have many registers. One particularity about this DAC is that the clocks must be always enabled. Also, an entire software reset is necessary while starting to play a sound otherwise, the clocks are not synchronized (so the DAC is not able to send data). Signed-off-by: Mylène Josserand Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 12 ++ sound/soc/codecs/Makefile | 4 + sound/soc/codecs/pcm1789-i2c.c | 62 ++++++++ sound/soc/codecs/pcm1789.c | 274 +++++++++++++++++++++++++++++++++ sound/soc/codecs/pcm1789.h | 17 ++ 5 files changed, 369 insertions(+) create mode 100644 sound/soc/codecs/pcm1789-i2c.c create mode 100644 sound/soc/codecs/pcm1789.c create mode 100644 sound/soc/codecs/pcm1789.h diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..c2480c3c8b98 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -108,6 +108,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_NAU8825 if I2C select SND_SOC_HDMI_CODEC select SND_SOC_PCM1681 if I2C + select SND_SOC_PCM1789_I2C if I2C select SND_SOC_PCM179X_I2C if I2C select SND_SOC_PCM179X_SPI if SPI_MASTER select SND_SOC_PCM186X_I2C if I2C @@ -650,6 +651,17 @@ config SND_SOC_PCM1681 tristate "Texas Instruments PCM1681 CODEC" depends on I2C +config SND_SOC_PCM1789 + tristate + +config SND_SOC_PCM1789_I2C + tristate "Texas Instruments PCM1789 CODEC (I2C)" + depends on I2C + select SND_SOC_PCM1789 + help + Enable support for Texas Instruments PCM1789 CODEC. + Select this if your PCM1789 is connected via an I2C bus. + config SND_SOC_PCM179X tristate diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..e59c93512314 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -103,6 +103,8 @@ snd-soc-nau8824-objs := nau8824.o snd-soc-nau8825-objs := nau8825.o snd-soc-hdmi-codec-objs := hdmi-codec.o snd-soc-pcm1681-objs := pcm1681.o +snd-soc-pcm1789-codec-objs := pcm1789.o +snd-soc-pcm1789-i2c-objs := pcm1789-i2c.o snd-soc-pcm179x-codec-objs := pcm179x.o snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o snd-soc-pcm179x-spi-objs := pcm179x-spi.o @@ -349,6 +351,8 @@ obj-$(CONFIG_SND_SOC_NAU8825) += snd-soc-nau8825.o obj-$(CONFIG_SND_SOC_HDMI_CODEC) += snd-soc-hdmi-codec.o obj-$(CONFIG_SND_SOC_PCM1681) += snd-soc-pcm1681.o obj-$(CONFIG_SND_SOC_PCM179X) += snd-soc-pcm179x-codec.o +obj-$(CONFIG_SND_SOC_PCM1789_I2C) += snd-soc-pcm1789-i2c.o +obj-$(CONFIG_SND_SOC_PCM1789) += snd-soc-pcm1789-codec.o obj-$(CONFIG_SND_SOC_PCM179X_I2C) += snd-soc-pcm179x-i2c.o obj-$(CONFIG_SND_SOC_PCM179X_SPI) += snd-soc-pcm179x-spi.o obj-$(CONFIG_SND_SOC_PCM186X) += snd-soc-pcm186x.o diff --git a/sound/soc/codecs/pcm1789-i2c.c b/sound/soc/codecs/pcm1789-i2c.c new file mode 100644 index 000000000000..327ec584f240 --- /dev/null +++ b/sound/soc/codecs/pcm1789-i2c.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0 +// Audio driver for PCM1789 I2C +// Copyright (C) 2018 Bootlin +// Mylène Josserand + +#include +#include +#include +#include +#include +#include + +#include "pcm1789.h" + +static int pcm1789_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct regmap *regmap; + int ret; + + regmap = devm_regmap_init_i2c(client, &pcm1789_regmap_config); + if (IS_ERR(regmap)) { + ret = PTR_ERR(regmap); + dev_err(&client->dev, "Failed to allocate regmap: %d\n", ret); + return ret; + } + + return pcm1789_common_init(&client->dev, regmap); +} + +static int pcm1789_i2c_remove(struct i2c_client *client) +{ + return pcm1789_common_exit(&client->dev); +} + +static const struct of_device_id pcm1789_of_match[] = { + { .compatible = "ti,pcm1789", }, + { } +}; +MODULE_DEVICE_TABLE(of, pcm1789_of_match); + +static const struct i2c_device_id pcm1789_i2c_ids[] = { + { "pcm1789", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, pcm1789_i2c_ids); + +static struct i2c_driver pcm1789_i2c_driver = { + .driver = { + .name = "pcm1789", + .of_match_table = of_match_ptr(pcm1789_of_match), + }, + .id_table = pcm1789_i2c_ids, + .probe = pcm1789_i2c_probe, + .remove = pcm1789_i2c_remove, +}; + +module_i2c_driver(pcm1789_i2c_driver); + +MODULE_DESCRIPTION("ASoC PCM1789 I2C driver"); +MODULE_AUTHOR("Mylène Josserand "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/pcm1789.c b/sound/soc/codecs/pcm1789.c new file mode 100644 index 000000000000..507ac9412d6c --- /dev/null +++ b/sound/soc/codecs/pcm1789.c @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: GPL-2.0 +// Audio driver for PCM1789 +// Copyright (C) 2018 Bootlin +// Mylène Josserand + +#include +#include +#include + +#include +#include +#include + +#include "pcm1789.h" + +#define PCM1789_MUTE_CONTROL 0x10 +#define PCM1789_FMT_CONTROL 0x11 +#define PCM1789_SOFT_MUTE 0x14 +#define PCM1789_DAC_VOL_LEFT 0x18 +#define PCM1789_DAC_VOL_RIGHT 0x19 + +#define PCM1789_FMT_MASK 0x07 +#define PCM1789_MUTE_MASK 0x03 +#define PCM1789_MUTE_SRET 0x06 + +struct pcm1789_private { + struct regmap *regmap; + unsigned int format; + unsigned int rate; + struct gpio_desc *reset; + struct work_struct work; + struct device *dev; +}; + +static const struct reg_default pcm1789_reg_defaults[] = { + { PCM1789_FMT_CONTROL, 0x00 }, + { PCM1789_SOFT_MUTE, 0x00 }, + { PCM1789_DAC_VOL_LEFT, 0xff }, + { PCM1789_DAC_VOL_RIGHT, 0xff }, +}; + +static bool pcm1789_accessible_reg(struct device *dev, unsigned int reg) +{ + return reg >= PCM1789_MUTE_CONTROL && reg <= PCM1789_DAC_VOL_RIGHT; +} + +static bool pcm1789_writeable_reg(struct device *dev, unsigned int reg) +{ + return pcm1789_accessible_reg(dev, reg); +} + +static int pcm1789_set_dai_fmt(struct snd_soc_dai *codec_dai, + unsigned int format) +{ + struct snd_soc_component *component = codec_dai->component; + struct pcm1789_private *priv = snd_soc_component_get_drvdata(component); + + priv->format = format; + + return 0; +} + +static int pcm1789_digital_mute(struct snd_soc_dai *codec_dai, int mute) +{ + struct snd_soc_component *component = codec_dai->component; + struct pcm1789_private *priv = snd_soc_component_get_drvdata(component); + + return regmap_update_bits(priv->regmap, PCM1789_SOFT_MUTE, + PCM1789_MUTE_MASK, + mute ? 0 : PCM1789_MUTE_MASK); +} + +static int pcm1789_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *codec_dai) +{ + struct snd_soc_component *component = codec_dai->component; + struct pcm1789_private *priv = snd_soc_component_get_drvdata(component); + int val = 0, ret; + + priv->rate = params_rate(params); + + switch (priv->format & SND_SOC_DAIFMT_FORMAT_MASK) { + case SND_SOC_DAIFMT_RIGHT_J: + switch (params_width(params)) { + case 24: + val = 2; + break; + case 16: + val = 3; + break; + default: + return -EINVAL; + } + break; + case SND_SOC_DAIFMT_I2S: + switch (params_width(params)) { + case 16: + case 24: + case 32: + val = 0; + break; + default: + return -EINVAL; + } + break; + case SND_SOC_DAIFMT_LEFT_J: + switch (params_width(params)) { + case 16: + case 24: + case 32: + val = 1; + break; + default: + return -EINVAL; + } + break; + default: + dev_err(component->dev, "Invalid DAI format\n"); + return -EINVAL; + } + + ret = regmap_update_bits(priv->regmap, PCM1789_FMT_CONTROL, + PCM1789_FMT_MASK, val); + if (ret < 0) + return ret; + + return 0; +} + +static void pcm1789_work_queue(struct work_struct *work) +{ + struct pcm1789_private *priv = container_of(work, + struct pcm1789_private, + work); + + /* Perform a software reset to remove codec from desynchronized state */ + if (regmap_update_bits(priv->regmap, PCM1789_MUTE_CONTROL, + 0x3 << PCM1789_MUTE_SRET, 0) < 0) + dev_err(priv->dev, "Error while setting SRET"); +} + +static int pcm1789_trigger(struct snd_pcm_substream *substream, int cmd, + struct snd_soc_dai *dai) +{ + struct snd_soc_component *component = dai->component; + struct pcm1789_private *priv = snd_soc_component_get_drvdata(component); + int ret = 0; + + switch (cmd) { + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: + schedule_work(&priv->work); + break; + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: + break; + default: + ret = -EINVAL; + } + + return ret; +} + +static const struct snd_soc_dai_ops pcm1789_dai_ops = { + .set_fmt = pcm1789_set_dai_fmt, + .hw_params = pcm1789_hw_params, + .digital_mute = pcm1789_digital_mute, + .trigger = pcm1789_trigger, +}; + +static const DECLARE_TLV_DB_SCALE(pcm1789_dac_tlv, -12000, 50, 1); + +static const struct snd_kcontrol_new pcm1789_controls[] = { + SOC_DOUBLE_R_RANGE_TLV("DAC Playback Volume", PCM1789_DAC_VOL_LEFT, + PCM1789_DAC_VOL_RIGHT, 0, 0xf, 0xff, 0, + pcm1789_dac_tlv), +}; + +static const struct snd_soc_dapm_widget pcm1789_dapm_widgets[] = { + SND_SOC_DAPM_OUTPUT("IOUTL+"), + SND_SOC_DAPM_OUTPUT("IOUTL-"), + SND_SOC_DAPM_OUTPUT("IOUTR+"), + SND_SOC_DAPM_OUTPUT("IOUTR-"), +}; + +static const struct snd_soc_dapm_route pcm1789_dapm_routes[] = { + { "IOUTL+", NULL, "Playback" }, + { "IOUTL-", NULL, "Playback" }, + { "IOUTR+", NULL, "Playback" }, + { "IOUTR-", NULL, "Playback" }, +}; + +static struct snd_soc_dai_driver pcm1789_dai = { + .name = "pcm1789-hifi", + .playback = { + .stream_name = "Playback", + .channels_min = 2, + .channels_max = 2, + .rates = SNDRV_PCM_RATE_CONTINUOUS, + .rate_min = 10000, + .rate_max = 200000, + .formats = PCM1789_FORMATS, + }, + .ops = &pcm1789_dai_ops, +}; + +const struct regmap_config pcm1789_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = PCM1789_DAC_VOL_RIGHT, + .reg_defaults = pcm1789_reg_defaults, + .num_reg_defaults = ARRAY_SIZE(pcm1789_reg_defaults), + .writeable_reg = pcm1789_writeable_reg, + .readable_reg = pcm1789_accessible_reg, +}; +EXPORT_SYMBOL_GPL(pcm1789_regmap_config); + +static const struct snd_soc_component_driver soc_component_dev_pcm1789 = { + .controls = pcm1789_controls, + .num_controls = ARRAY_SIZE(pcm1789_controls), + .dapm_widgets = pcm1789_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(pcm1789_dapm_widgets), + .dapm_routes = pcm1789_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(pcm1789_dapm_routes), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, +}; + +int pcm1789_common_init(struct device *dev, struct regmap *regmap) +{ + struct pcm1789_private *pcm1789; + + pcm1789 = devm_kzalloc(dev, sizeof(struct pcm1789_private), + GFP_KERNEL); + if (!pcm1789) + return -ENOMEM; + + pcm1789->regmap = regmap; + pcm1789->dev = dev; + dev_set_drvdata(dev, pcm1789); + + pcm1789->reset = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); + if (IS_ERR(pcm1789->reset)) + return PTR_ERR(pcm1789->reset); + + gpiod_set_value_cansleep(pcm1789->reset, 0); + msleep(300); + + INIT_WORK(&pcm1789->work, pcm1789_work_queue); + + return devm_snd_soc_register_component(dev, &soc_component_dev_pcm1789, + &pcm1789_dai, 1); +} +EXPORT_SYMBOL_GPL(pcm1789_common_init); + +int pcm1789_common_exit(struct device *dev) +{ + struct pcm1789_private *priv = dev_get_drvdata(dev); + + if (&priv->work) + flush_work(&priv->work); + + return 0; +} +EXPORT_SYMBOL_GPL(pcm1789_common_exit); + +MODULE_DESCRIPTION("ASoC PCM1789 driver"); +MODULE_AUTHOR("Mylène Josserand "); +MODULE_LICENSE("GPL"); diff --git a/sound/soc/codecs/pcm1789.h b/sound/soc/codecs/pcm1789.h new file mode 100644 index 000000000000..c446d789ed48 --- /dev/null +++ b/sound/soc/codecs/pcm1789.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0 +// Definitions for PCM1789 audio driver +// Copyright (C) 2018 Bootlin +// Mylène Josserand + +#ifndef __PCM1789_H__ +#define __PCM1789_H__ + +#define PCM1789_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ + SNDRV_PCM_FMTBIT_S16_LE) + +extern const struct regmap_config pcm1789_regmap_config; + +int pcm1789_common_init(struct device *dev, struct regmap *regmap); +int pcm1789_common_exit(struct device *dev); + +#endif From e4fe156ae8ec5227e6cbdbca61a0f72e77a67c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= Date: Thu, 15 Mar 2018 17:18:25 +0100 Subject: [PATCH 782/942] ASoC: Add bindings for PCM1789 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a device-tree binding for Texas Instrument's PCM1789 codec. For the moment, only I2C bus is supported but SPI could be added in future. Signed-off-by: Mylène Josserand Reviewed-by: Rob Herring Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/pcm1789.txt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/pcm1789.txt diff --git a/Documentation/devicetree/bindings/sound/pcm1789.txt b/Documentation/devicetree/bindings/sound/pcm1789.txt new file mode 100644 index 000000000000..3c74ed220ac2 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/pcm1789.txt @@ -0,0 +1,22 @@ +Texas Instruments pcm1789 DT bindings + +PCM1789 is a simple audio codec that can be connected via +I2C or SPI. Currently, only I2C bus is supported. + +Required properties: + + - compatible: "ti,pcm1789" + +Required properties on I2C: + + - reg: the I2C address + - reset-gpios: GPIO to control the RESET pin + +Examples: + + audio-codec@4c { + compatible = "ti,pcm1789"; + reg = <0x4c>; + reset-gpios = <&gpio2 14 GPIO_ACTIVE_LOW>; + #sound-dai-cells = <0>; + }; From 050a0e1f539448474250f441332c0a7d9714d3b5 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Sun, 18 Mar 2018 13:22:37 -0400 Subject: [PATCH 783/942] ASoC: add tda7419 audio processor binding DeviceTree binding for the tda7419 audio processor. Signed-off-by: Matt Porter Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/tda7419.txt | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/tda7419.txt diff --git a/Documentation/devicetree/bindings/sound/tda7419.txt b/Documentation/devicetree/bindings/sound/tda7419.txt new file mode 100644 index 000000000000..6b85ec38dd56 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tda7419.txt @@ -0,0 +1,38 @@ +TDA7419 audio processor + +This device supports I2C only. + +Required properties: + +- compatible : "st,tda7419" +- reg : the I2C address of the device. +- vdd-supply : a regulator spec for the common power supply (8-10V) + +Optional properties: + +- st,mute-gpios : a GPIO spec for the MUTE pin. + +Pins on the device (for linking into audio routes): + + * SE3L + * SE3R + * SE2L + * SE2R + * SE1L + * SE1R + * DIFFL + * DIFFR + * MIX + * OUTLF + * OUTRF + * OUTLR + * OUTRR + * OUTSW + +Example: + +ap: tda7419@44 { + compatible = "st,tda7419"; + reg = <0x44>; + vdd-supply = <&vdd_9v0_reg>; +}; From 3d3db9432853b8b198722768ba0788b1bc586049 Mon Sep 17 00:00:00 2001 From: Matt Porter Date: Sun, 18 Mar 2018 13:22:38 -0400 Subject: [PATCH 784/942] ASoC: add tda7419 audio processor driver Component driver for the tda7419 audio processor. Signed-off-by: Matt Porter Signed-off-by: Mark Brown --- sound/soc/codecs/Kconfig | 6 + sound/soc/codecs/Makefile | 2 + sound/soc/codecs/tda7419.c | 654 +++++++++++++++++++++++++++++++++++++ 3 files changed, 662 insertions(+) create mode 100644 sound/soc/codecs/tda7419.c diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 2b331f7266ab..1553cf2b9445 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig @@ -151,6 +151,7 @@ config SND_SOC_ALL_CODECS select SND_SOC_TAS571X if I2C select SND_SOC_TAS5720 if I2C select SND_SOC_TAS6424 if I2C + select SND_SOC_TDA7419 if I2C select SND_SOC_TFA9879 if I2C select SND_SOC_TLV320AIC23_I2C if I2C select SND_SOC_TLV320AIC23_SPI if SPI_MASTER @@ -910,6 +911,11 @@ config SND_SOC_TAS6424 Enable support for Texas Instruments TAS6424 high-efficiency digital input quad-channel Class-D audio power amplifiers. +config SND_SOC_TDA7419 + tristate "ST TDA7419 audio processor" + depends on I2C + select REGMAP_I2C + config SND_SOC_TFA9879 tristate "NXP Semiconductors TFA9879 amplifier" depends on I2C diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index da1571336f1e..6cf3c3b92cb5 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile @@ -160,6 +160,7 @@ snd-soc-tas5086-objs := tas5086.o snd-soc-tas571x-objs := tas571x.o snd-soc-tas5720-objs := tas5720.o snd-soc-tas6424-objs := tas6424.o +snd-soc-tda7419-objs := tda7419.o snd-soc-tfa9879-objs := tfa9879.o snd-soc-tlv320aic23-objs := tlv320aic23.o snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o @@ -405,6 +406,7 @@ obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o obj-$(CONFIG_SND_SOC_TAS6424) += snd-soc-tas6424.o +obj-$(CONFIG_SND_SOC_TDA7419) += snd-soc-tda7419.o obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o diff --git a/sound/soc/codecs/tda7419.c b/sound/soc/codecs/tda7419.c new file mode 100644 index 000000000000..225c210ac38f --- /dev/null +++ b/sound/soc/codecs/tda7419.c @@ -0,0 +1,654 @@ +/* + * TDA7419 audio processor driver + * + * Copyright 2018 Konsulko Group + * + * Author: Matt Porter + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define TDA7419_MAIN_SRC_REG 0x00 +#define TDA7419_LOUDNESS_REG 0x01 +#define TDA7419_MUTE_CLK_REG 0x02 +#define TDA7419_VOLUME_REG 0x03 +#define TDA7419_TREBLE_REG 0x04 +#define TDA7419_MIDDLE_REG 0x05 +#define TDA7419_BASS_REG 0x06 +#define TDA7419_SECOND_SRC_REG 0x07 +#define TDA7419_SUB_MID_BASS_REG 0x08 +#define TDA7419_MIXING_GAIN_REG 0x09 +#define TDA7419_ATTENUATOR_LF_REG 0x0a +#define TDA7419_ATTENUATOR_RF_REG 0x0b +#define TDA7419_ATTENUATOR_LR_REG 0x0c +#define TDA7419_ATTENUATOR_RR_REG 0x0d +#define TDA7419_MIXING_LEVEL_REG 0x0e +#define TDA7419_ATTENUATOR_SUB_REG 0x0f +#define TDA7419_SA_CLK_AC_REG 0x10 +#define TDA7419_TESTING_REG 0x11 + +#define TDA7419_MAIN_SRC_SEL 0 +#define TDA7419_MAIN_SRC_GAIN 3 +#define TDA7419_MAIN_SRC_AUTOZERO 7 + +#define TDA7419_LOUDNESS_ATTEN 0 +#define TDA7419_LOUDNESS_CENTER_FREQ 4 +#define TDA7419_LOUDNESS_BOOST 6 +#define TDA7419_LOUDNESS_SOFT_STEP 7 + +#define TDA7419_VOLUME_SOFT_STEP 7 + +#define TDA7419_SOFT_MUTE 0 +#define TDA7419_MUTE_INFLUENCE 1 +#define TDA7419_SOFT_MUTE_TIME 2 +#define TDA7419_SOFT_STEP_TIME 4 +#define TDA7419_CLK_FAST_MODE 7 + +#define TDA7419_TREBLE_CENTER_FREQ 5 +#define TDA7419_REF_OUT_SELECT 7 + +#define TDA7419_MIDDLE_Q_FACTOR 5 +#define TDA7419_MIDDLE_SOFT_STEP 7 + +#define TDA7419_BASS_Q_FACTOR 5 +#define TDA7419_BASS_SOFT_STEP 7 + +#define TDA7419_SECOND_SRC_SEL 0 +#define TDA7419_SECOND_SRC_GAIN 3 +#define TDA7419_REAR_SPKR_SRC 7 + +#define TDA7419_SUB_CUT_OFF_FREQ 0 +#define TDA7419_MIDDLE_CENTER_FREQ 2 +#define TDA7419_BASS_CENTER_FREQ 4 +#define TDA7419_BASS_DC_MODE 6 +#define TDA7419_SMOOTHING_FILTER 7 + +#define TDA7419_MIX_LF 0 +#define TDA7419_MIX_RF 1 +#define TDA7419_MIX_ENABLE 2 +#define TDA7419_SUB_ENABLE 3 +#define TDA7419_HPF_GAIN 4 + +#define TDA7419_SA_Q_FACTOR 0 +#define TDA7419_RESET_MODE 1 +#define TDA7419_SA_SOURCE 2 +#define TDA7419_SA_RUN 3 +#define TDA7419_RESET 4 +#define TDA7419_CLK_SOURCE 5 +#define TDA7419_COUPLING_MODE 6 + +struct tda7419_data { + struct regmap *regmap; +}; + +static bool tda7419_readable_reg(struct device *dev, unsigned int reg) +{ + return false; +} + +static const struct reg_default tda7419_regmap_defaults[] = { + { TDA7419_MAIN_SRC_REG, 0xfe }, + { TDA7419_LOUDNESS_REG, 0xfe }, + { TDA7419_MUTE_CLK_REG, 0xfe }, + { TDA7419_VOLUME_REG, 0xfe }, + { TDA7419_TREBLE_REG, 0xfe }, + { TDA7419_MIDDLE_REG, 0xfe }, + { TDA7419_BASS_REG, 0xfe }, + { TDA7419_SECOND_SRC_REG, 0xfe }, + { TDA7419_SUB_MID_BASS_REG, 0xfe }, + { TDA7419_MIXING_GAIN_REG, 0xfe }, + { TDA7419_ATTENUATOR_LF_REG, 0xfe }, + { TDA7419_ATTENUATOR_RF_REG, 0xfe }, + { TDA7419_ATTENUATOR_LR_REG, 0xfe }, + { TDA7419_ATTENUATOR_RR_REG, 0xfe }, + { TDA7419_MIXING_LEVEL_REG, 0xfe }, + { TDA7419_ATTENUATOR_SUB_REG, 0xfe }, + { TDA7419_SA_CLK_AC_REG, 0xfe }, + { TDA7419_TESTING_REG, 0xfe }, +}; + +static const struct regmap_config tda7419_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .max_register = TDA7419_TESTING_REG, + .cache_type = REGCACHE_RBTREE, + .readable_reg = tda7419_readable_reg, + .reg_defaults = tda7419_regmap_defaults, + .num_reg_defaults = ARRAY_SIZE(tda7419_regmap_defaults), +}; + +struct tda7419_vol_control { + int min, max; + unsigned int reg, rreg, mask, thresh; + unsigned int invert:1; +}; + +static inline bool tda7419_vol_is_stereo(struct tda7419_vol_control *tvc) +{ + if (tvc->reg == tvc->rreg) + return 0; + + return 1; +} + +static int tda7419_vol_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *uinfo) +{ + struct tda7419_vol_control *tvc = + (struct tda7419_vol_control *)kcontrol->private_value; + + uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + uinfo->count = tda7419_vol_is_stereo(tvc) ? 2 : 1; + uinfo->value.integer.min = tvc->min; + uinfo->value.integer.max = tvc->max; + + return 0; +} + +static inline int tda7419_vol_get_value(int val, unsigned int mask, + int min, int thresh, + unsigned int invert) +{ + val &= mask; + if (val < thresh) { + if (invert) + val = 0 - val; + } else if (val > thresh) { + if (invert) + val = val - thresh; + else + val = thresh - val; + } + + if (val < min) + val = min; + + return val; +} + +static int tda7419_vol_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = snd_kcontrol_chip(kcontrol); + struct tda7419_vol_control *tvc = + (struct tda7419_vol_control *)kcontrol->private_value; + unsigned int reg = tvc->reg; + unsigned int rreg = tvc->rreg; + unsigned int mask = tvc->mask; + int min = tvc->min; + int thresh = tvc->thresh; + unsigned int invert = tvc->invert; + int val; + int ret; + + ret = snd_soc_component_read(component, reg, &val); + if (ret < 0) + return ret; + ucontrol->value.integer.value[0] = + tda7419_vol_get_value(val, mask, min, thresh, invert); + + if (tda7419_vol_is_stereo(tvc)) { + ret = snd_soc_component_read(component, rreg, &val); + if (ret < 0) + return ret; + ucontrol->value.integer.value[1] = + tda7419_vol_get_value(val, mask, min, thresh, invert); + } + + return 0; +} + +static inline int tda7419_vol_put_value(int val, int thresh, + unsigned int invert) +{ + if (val < 0) { + if (invert) + val = abs(val); + else + val = thresh - val; + } else if ((val > 0) && invert) { + val += thresh; + } + + return val; +} + +static int tda7419_vol_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct snd_soc_component *component = + snd_kcontrol_chip(kcontrol); + struct tda7419_vol_control *tvc = + (struct tda7419_vol_control *)kcontrol->private_value; + unsigned int reg = tvc->reg; + unsigned int rreg = tvc->rreg; + unsigned int mask = tvc->mask; + int thresh = tvc->thresh; + unsigned int invert = tvc->invert; + int val; + int ret; + + val = tda7419_vol_put_value(ucontrol->value.integer.value[0], + thresh, invert); + ret = snd_soc_component_update_bits(component, reg, + mask, val); + if (ret < 0) + return ret; + + if (tda7419_vol_is_stereo(tvc)) { + val = tda7419_vol_put_value(ucontrol->value.integer.value[1], + thresh, invert); + ret = snd_soc_component_update_bits(component, rreg, + mask, val); + } + + return ret; +} + +#define TDA7419_SINGLE_VALUE(xreg, xmask, xmin, xmax, xthresh, xinvert) \ + ((unsigned long)&(struct tda7419_vol_control) \ + {.reg = xreg, .rreg = xreg, .mask = xmask, .min = xmin, \ + .max = xmax, .thresh = xthresh, .invert = xinvert}) + +#define TDA7419_DOUBLE_R_VALUE(xregl, xregr, xmask, xmin, xmax, xthresh, \ + xinvert) \ + ((unsigned long)&(struct tda7419_vol_control) \ + {.reg = xregl, .rreg = xregr, .mask = xmask, .min = xmin, \ + .max = xmax, .thresh = xthresh, .invert = xinvert}) + +#define TDA7419_SINGLE_TLV(xname, xreg, xmask, xmin, xmax, xthresh, \ + xinvert, xtlv_array) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ + SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .tlv.p = (xtlv_array), \ + .info = tda7419_vol_info, \ + .get = tda7419_vol_get, \ + .put = tda7419_vol_put, \ + .private_value = TDA7419_SINGLE_VALUE(xreg, xmask, xmin, \ + xmax, xthresh, xinvert), \ +} + +#define TDA7419_DOUBLE_R_TLV(xname, xregl, xregr, xmask, xmin, xmax, \ + xthresh, xinvert, xtlv_array) \ +{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ + .name = xname, \ + .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \ + SNDRV_CTL_ELEM_ACCESS_READWRITE, \ + .tlv.p = (xtlv_array), \ + .info = tda7419_vol_info, \ + .get = tda7419_vol_get, \ + .put = tda7419_vol_put, \ + .private_value = TDA7419_DOUBLE_R_VALUE(xregl, xregr, xmask, \ + xmin, xmax, xthresh, \ + xinvert), \ +} + +static const char * const enum_src_sel[] = { + "QD", "SE1", "SE2", "SE3", "SE", "Mute", "Mute", "Mute"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_main_src_sel, + TDA7419_MAIN_SRC_REG, TDA7419_MAIN_SRC_SEL, enum_src_sel); +static const struct snd_kcontrol_new soc_mux_main_src_sel = + SOC_DAPM_ENUM("Main Source Select", soc_enum_main_src_sel); +static DECLARE_TLV_DB_SCALE(tlv_src_gain, 0, 100, 0); +static DECLARE_TLV_DB_SCALE(tlv_loudness_atten, -1500, 100, 0); +static const char * const enum_loudness_center_freq[] = { + "Flat", "400 Hz", "800 Hz", "2400 Hz"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_loudness_center_freq, + TDA7419_LOUDNESS_REG, TDA7419_LOUDNESS_CENTER_FREQ, + enum_loudness_center_freq); +static const char * const enum_mute_influence[] = { + "Pin and IIC", "IIC"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_mute_influence, + TDA7419_MUTE_CLK_REG, TDA7419_MUTE_INFLUENCE, enum_mute_influence); +static const char * const enum_soft_mute_time[] = { + "0.48 ms", "0.96 ms", "123 ms", "123 ms"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_soft_mute_time, + TDA7419_MUTE_CLK_REG, TDA7419_SOFT_MUTE_TIME, enum_soft_mute_time); +static const char * const enum_soft_step_time[] = { + "0.160 ms", "0.321 ms", "0.642 ms", "1.28 ms", + "2.56 ms", "5.12 ms", "10.24 ms", "20.48 ms"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_soft_step_time, + TDA7419_MUTE_CLK_REG, TDA7419_SOFT_STEP_TIME, enum_soft_step_time); +static DECLARE_TLV_DB_SCALE(tlv_volume, -8000, 100, 1); +static const char * const enum_treble_center_freq[] = { + "10.0 kHz", "12.5 kHz", "15.0 kHz", "17.5 kHz"}; +static DECLARE_TLV_DB_SCALE(tlv_filter, -1500, 100, 0); +static SOC_ENUM_SINGLE_DECL(soc_enum_treble_center_freq, + TDA7419_TREBLE_REG, TDA7419_TREBLE_CENTER_FREQ, + enum_treble_center_freq); +static const char * const enum_ref_out_select[] = { + "External Vref (4 V)", "Internal Vref (3.3 V)"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_ref_out_select, + TDA7419_TREBLE_REG, TDA7419_REF_OUT_SELECT, enum_ref_out_select); +static const char * const enum_middle_q_factor[] = { + "0.5", "0.75", "1.0", "1.25"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_middle_q_factor, + TDA7419_MIDDLE_REG, TDA7419_MIDDLE_Q_FACTOR, enum_middle_q_factor); +static const char * const enum_bass_q_factor[] = { + "1.0", "1.25", "1.5", "2.0"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_bass_q_factor, + TDA7419_BASS_REG, TDA7419_BASS_Q_FACTOR, enum_bass_q_factor); +static SOC_ENUM_SINGLE_DECL(soc_enum_second_src_sel, + TDA7419_SECOND_SRC_REG, TDA7419_SECOND_SRC_SEL, enum_src_sel); +static const struct snd_kcontrol_new soc_mux_second_src_sel = + SOC_DAPM_ENUM("Second Source Select", soc_enum_second_src_sel); +static const char * const enum_rear_spkr_src[] = { + "Main", "Second"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_rear_spkr_src, + TDA7419_SECOND_SRC_REG, TDA7419_REAR_SPKR_SRC, enum_rear_spkr_src); +static const struct snd_kcontrol_new soc_mux_rear_spkr_src = + SOC_DAPM_ENUM("Rear Speaker Source", soc_enum_rear_spkr_src); +static const char * const enum_sub_cut_off_freq[] = { + "Flat", "80 Hz", "120 Hz", "160 Hz"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_sub_cut_off_freq, + TDA7419_SUB_MID_BASS_REG, TDA7419_SUB_CUT_OFF_FREQ, + enum_sub_cut_off_freq); +static const char * const enum_middle_center_freq[] = { + "500 Hz", "1000 Hz", "1500 Hz", "2500 Hz"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_middle_center_freq, + TDA7419_SUB_MID_BASS_REG, TDA7419_MIDDLE_CENTER_FREQ, + enum_middle_center_freq); +static const char * const enum_bass_center_freq[] = { + "60 Hz", "80 Hz", "100 Hz", "200 Hz"}; +static SOC_ENUM_SINGLE_DECL(soc_enum_bass_center_freq, + TDA7419_SUB_MID_BASS_REG, TDA7419_BASS_CENTER_FREQ, + enum_bass_center_freq); +static const char * const enum_sa_q_factor[] = { + "3.5", "1.75" }; +static SOC_ENUM_SINGLE_DECL(soc_enum_sa_q_factor, + TDA7419_SA_CLK_AC_REG, TDA7419_SA_Q_FACTOR, enum_sa_q_factor); +static const char * const enum_reset_mode[] = { + "IIC", "Auto" }; +static SOC_ENUM_SINGLE_DECL(soc_enum_reset_mode, + TDA7419_SA_CLK_AC_REG, TDA7419_RESET_MODE, enum_reset_mode); +static const char * const enum_sa_src[] = { + "Bass", "In Gain" }; +static SOC_ENUM_SINGLE_DECL(soc_enum_sa_src, + TDA7419_SA_CLK_AC_REG, TDA7419_SA_SOURCE, enum_sa_src); +static const char * const enum_clk_src[] = { + "Internal", "External" }; +static SOC_ENUM_SINGLE_DECL(soc_enum_clk_src, + TDA7419_SA_CLK_AC_REG, TDA7419_CLK_SOURCE, enum_clk_src); +static const char * const enum_coupling_mode[] = { + "DC Coupling (without HPF)", "AC Coupling after In Gain", + "DC Coupling (with HPF)", "AC Coupling after Bass" }; +static SOC_ENUM_SINGLE_DECL(soc_enum_coupling_mode, + TDA7419_SA_CLK_AC_REG, TDA7419_COUPLING_MODE, enum_coupling_mode); + +/* ASoC Controls */ +static struct snd_kcontrol_new tda7419_controls[] = { +SOC_SINGLE_TLV("Main Source Capture Volume", TDA7419_MAIN_SRC_REG, + TDA7419_MAIN_SRC_GAIN, 15, 0, tlv_src_gain), +SOC_SINGLE("Main Source AutoZero Switch", TDA7419_MAIN_SRC_REG, + TDA7419_MAIN_SRC_AUTOZERO, 1, 1), +SOC_SINGLE_TLV("Loudness Playback Volume", TDA7419_LOUDNESS_REG, + TDA7419_LOUDNESS_ATTEN, 15, 1, tlv_loudness_atten), +SOC_ENUM("Loudness Center Frequency", soc_enum_loudness_center_freq), +SOC_SINGLE("Loudness High Boost Switch", TDA7419_LOUDNESS_REG, + TDA7419_LOUDNESS_BOOST, 1, 1), +SOC_SINGLE("Loudness Soft Step Switch", TDA7419_LOUDNESS_REG, + TDA7419_LOUDNESS_SOFT_STEP, 1, 1), +SOC_SINGLE("Soft Mute Switch", TDA7419_MUTE_CLK_REG, TDA7419_SOFT_MUTE, 1, 1), +SOC_ENUM("Mute Influence", soc_enum_mute_influence), +SOC_ENUM("Soft Mute Time", soc_enum_soft_mute_time), +SOC_ENUM("Soft Step Time", soc_enum_soft_step_time), +SOC_SINGLE("Clock Fast Mode Switch", TDA7419_MUTE_CLK_REG, + TDA7419_CLK_FAST_MODE, 1, 1), +TDA7419_SINGLE_TLV("Master Playback Volume", TDA7419_VOLUME_REG, + 0x7f, -80, 15, 0x10, 0, tlv_volume), +SOC_SINGLE("Volume Soft Step Switch", TDA7419_VOLUME_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +TDA7419_SINGLE_TLV("Treble Playback Volume", TDA7419_TREBLE_REG, + 0x1f, -15, 15, 0x10, 1, tlv_filter), +SOC_ENUM("Treble Center Frequency", soc_enum_treble_center_freq), +SOC_ENUM("Reference Output Select", soc_enum_ref_out_select), +TDA7419_SINGLE_TLV("Middle Playback Volume", TDA7419_MIDDLE_REG, + 0x1f, -15, 15, 0x10, 1, tlv_filter), +SOC_ENUM("Middle Q Factor", soc_enum_middle_q_factor), +SOC_SINGLE("Middle Soft Step Switch", TDA7419_MIDDLE_REG, + TDA7419_MIDDLE_SOFT_STEP, 1, 1), +TDA7419_SINGLE_TLV("Bass Playback Volume", TDA7419_BASS_REG, + 0x1f, -15, 15, 0x10, 1, tlv_filter), +SOC_ENUM("Bass Q Factor", soc_enum_bass_q_factor), +SOC_SINGLE("Bass Soft Step Switch", TDA7419_BASS_REG, + TDA7419_BASS_SOFT_STEP, 1, 1), +SOC_SINGLE_TLV("Second Source Capture Volume", TDA7419_SECOND_SRC_REG, + TDA7419_SECOND_SRC_GAIN, 15, 0, tlv_src_gain), +SOC_ENUM("Subwoofer Cut-off Frequency", soc_enum_sub_cut_off_freq), +SOC_ENUM("Middle Center Frequency", soc_enum_middle_center_freq), +SOC_ENUM("Bass Center Frequency", soc_enum_bass_center_freq), +SOC_SINGLE("Bass DC Mode Switch", TDA7419_SUB_MID_BASS_REG, + TDA7419_BASS_DC_MODE, 1, 1), +SOC_SINGLE("Smoothing Filter Switch", TDA7419_SUB_MID_BASS_REG, + TDA7419_SMOOTHING_FILTER, 1, 1), +TDA7419_DOUBLE_R_TLV("Front Speaker Playback Volume", TDA7419_ATTENUATOR_LF_REG, + TDA7419_ATTENUATOR_RF_REG, 0x7f, -80, 15, 0x10, 0, + tlv_volume), +SOC_SINGLE("Left Front Soft Step Switch", TDA7419_ATTENUATOR_LF_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +SOC_SINGLE("Right Front Soft Step Switch", TDA7419_ATTENUATOR_RF_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +TDA7419_DOUBLE_R_TLV("Rear Speaker Playback Volume", TDA7419_ATTENUATOR_LR_REG, + TDA7419_ATTENUATOR_RR_REG, 0x7f, -80, 15, 0x10, 0, + tlv_volume), +SOC_SINGLE("Left Rear Soft Step Switch", TDA7419_ATTENUATOR_LR_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +SOC_SINGLE("Right Rear Soft Step Switch", TDA7419_ATTENUATOR_RR_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +TDA7419_SINGLE_TLV("Mixing Capture Volume", TDA7419_MIXING_LEVEL_REG, + 0x7f, -80, 15, 0x10, 0, tlv_volume), +SOC_SINGLE("Mixing Level Soft Step Switch", TDA7419_MIXING_LEVEL_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +TDA7419_SINGLE_TLV("Subwoofer Playback Volume", TDA7419_ATTENUATOR_SUB_REG, + 0x7f, -80, 15, 0x10, 0, tlv_volume), +SOC_SINGLE("Subwoofer Soft Step Switch", TDA7419_ATTENUATOR_SUB_REG, + TDA7419_VOLUME_SOFT_STEP, 1, 1), +SOC_ENUM("Spectrum Analyzer Q Factor", soc_enum_sa_q_factor), +SOC_ENUM("Spectrum Analyzer Reset Mode", soc_enum_reset_mode), +SOC_ENUM("Spectrum Analyzer Source", soc_enum_sa_src), +SOC_SINGLE("Spectrum Analyzer Run Switch", TDA7419_SA_CLK_AC_REG, + TDA7419_SA_RUN, 1, 1), +SOC_SINGLE("Spectrum Analyzer Reset Switch", TDA7419_SA_CLK_AC_REG, + TDA7419_RESET, 1, 1), +SOC_ENUM("Clock Source", soc_enum_clk_src), +SOC_ENUM("Coupling Mode", soc_enum_coupling_mode), +}; + +static const struct snd_kcontrol_new soc_mixer_lf_output_controls[] = { + SOC_DAPM_SINGLE("Mix to LF Speaker Switch", + TDA7419_MIXING_GAIN_REG, + TDA7419_MIX_LF, 1, 1), +}; + +static const struct snd_kcontrol_new soc_mixer_rf_output_controls[] = { + SOC_DAPM_SINGLE("Mix to RF Speaker Switch", + TDA7419_MIXING_GAIN_REG, + TDA7419_MIX_RF, 1, 1), +}; + +static const struct snd_kcontrol_new soc_mix_enable_switch_controls[] = { + SOC_DAPM_SINGLE("Switch", TDA7419_MIXING_GAIN_REG, + TDA7419_MIX_ENABLE, 1, 1), +}; + +static const struct snd_kcontrol_new soc_sub_enable_switch_controls[] = { + SOC_DAPM_SINGLE("Switch", TDA7419_MIXING_GAIN_REG, + TDA7419_MIX_ENABLE, 1, 1), +}; + +static const struct snd_soc_dapm_widget tda7419_dapm_widgets[] = { + SND_SOC_DAPM_INPUT("SE3L"), + SND_SOC_DAPM_INPUT("SE3R"), + SND_SOC_DAPM_INPUT("SE2L"), + SND_SOC_DAPM_INPUT("SE2R"), + SND_SOC_DAPM_INPUT("SE1L"), + SND_SOC_DAPM_INPUT("SE1R"), + SND_SOC_DAPM_INPUT("DIFFL"), + SND_SOC_DAPM_INPUT("DIFFR"), + SND_SOC_DAPM_INPUT("MIX"), + + SND_SOC_DAPM_MUX("Main Source Select", SND_SOC_NOPM, + 0, 0, &soc_mux_main_src_sel), + SND_SOC_DAPM_MUX("Second Source Select", SND_SOC_NOPM, + 0, 0, &soc_mux_second_src_sel), + SND_SOC_DAPM_MUX("Rear Speaker Source", SND_SOC_NOPM, + 0, 0, &soc_mux_rear_spkr_src), + + SND_SOC_DAPM_SWITCH("Mix Enable", SND_SOC_NOPM, + 0, 0, &soc_mix_enable_switch_controls[0]), + SND_SOC_DAPM_MIXER_NAMED_CTL("LF Output Mixer", SND_SOC_NOPM, + 0, 0, &soc_mixer_lf_output_controls[0], + ARRAY_SIZE(soc_mixer_lf_output_controls)), + SND_SOC_DAPM_MIXER_NAMED_CTL("RF Output Mixer", SND_SOC_NOPM, + 0, 0, &soc_mixer_rf_output_controls[0], + ARRAY_SIZE(soc_mixer_rf_output_controls)), + + SND_SOC_DAPM_SWITCH("Subwoofer Enable", + SND_SOC_NOPM, 0, 0, + &soc_sub_enable_switch_controls[0]), + + SND_SOC_DAPM_OUTPUT("OUTLF"), + SND_SOC_DAPM_OUTPUT("OUTRF"), + SND_SOC_DAPM_OUTPUT("OUTLR"), + SND_SOC_DAPM_OUTPUT("OUTRR"), + SND_SOC_DAPM_OUTPUT("OUTSW"), +}; + +static const struct snd_soc_dapm_route tda7419_dapm_routes[] = { + {"Main Source Select", "SE3", "SE3L"}, + {"Main Source Select", "SE3", "SE3R"}, + {"Main Source Select", "SE2", "SE2L"}, + {"Main Source Select", "SE2", "SE2R"}, + {"Main Source Select", "SE1", "SE1L"}, + {"Main Source Select", "SE1", "SE1R"}, + {"Main Source Select", "SE", "DIFFL"}, + {"Main Source Select", "SE", "DIFFR"}, + {"Main Source Select", "QD", "DIFFL"}, + {"Main Source Select", "QD", "DIFFR"}, + + {"Second Source Select", "SE3", "SE3L"}, + {"Second Source Select", "SE3", "SE3R"}, + {"Second Source Select", "SE2", "SE2L"}, + {"Second Source Select", "SE2", "SE2R"}, + {"Second Source Select", "SE1", "SE1L"}, + {"Second Source Select", "SE1", "SE1R"}, + {"Second Source Select", "SE", "DIFFL"}, + {"Second Source Select", "SE", "DIFFR"}, + {"Second Source Select", "QD", "DIFFL"}, + {"Second Source Select", "QD", "DIFFR"}, + + {"Rear Speaker Source", "Main", "Main Source Select"}, + {"Rear Speaker Source", "Second", "Second Source Select"}, + + {"Subwoofer Enable", "Switch", "Main Source Select"}, + + {"Mix Enable", "Switch", "MIX"}, + + {"LF Output Mixer", NULL, "Main Source Select"}, + {"LF Output Mixer", "Mix to LF Speaker Switch", "Mix Enable"}, + {"RF Output Mixer", NULL, "Main Source Select"}, + {"RF Output Mixer", "Mix to RF Speaker Switch", "Mix Enable"}, + + {"OUTLF", NULL, "LF Output Mixer"}, + {"OUTRF", NULL, "RF Output Mixer"}, + {"OUTLR", NULL, "Rear Speaker Source"}, + {"OUTRR", NULL, "Rear Speaker Source"}, + {"OUTSW", NULL, "Subwoofer Enable"}, +}; + +static const struct snd_soc_component_driver tda7419_component_driver = { + .name = "tda7419", + .controls = tda7419_controls, + .num_controls = ARRAY_SIZE(tda7419_controls), + .dapm_widgets = tda7419_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(tda7419_dapm_widgets), + .dapm_routes = tda7419_dapm_routes, + .num_dapm_routes = ARRAY_SIZE(tda7419_dapm_routes), +}; + +static int tda7419_probe(struct i2c_client *i2c, + const struct i2c_device_id *id) +{ + struct tda7419_data *tda7419; + int i, ret; + + tda7419 = devm_kzalloc(&i2c->dev, + sizeof(struct tda7419_data), + GFP_KERNEL); + if (tda7419 == NULL) + return -ENOMEM; + + i2c_set_clientdata(i2c, tda7419); + + tda7419->regmap = devm_regmap_init_i2c(i2c, &tda7419_regmap_config); + if (IS_ERR(tda7419->regmap)) { + ret = PTR_ERR(tda7419->regmap); + dev_err(&i2c->dev, "error initializing regmap: %d\n", + ret); + return ret; + } + + /* + * Reset registers to power-on defaults. The part does not provide a + * soft-reset function and the registers are not readable. This ensures + * that the cache matches register contents even if the registers have + * been previously initialized and not power cycled before probe. + */ + for (i = 0; i < ARRAY_SIZE(tda7419_regmap_defaults); i++) + regmap_write(tda7419->regmap, + tda7419_regmap_defaults[i].reg, + tda7419_regmap_defaults[i].def); + + ret = devm_snd_soc_register_component(&i2c->dev, + &tda7419_component_driver, NULL, 0); + if (ret < 0) { + dev_err(&i2c->dev, "error registering component: %d\n", + ret); + } + + return ret; +} + +static const struct i2c_device_id tda7419_i2c_id[] = { + { "tda7419", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, tda7419_i2c_id); + +static const struct of_device_id tda7419_of_match[] = { + { .compatible = "st,tda7419" }, + { }, +}; + +static struct i2c_driver tda7419_driver = { + .driver = { + .name = "tda7419", + .of_match_table = tda7419_of_match, + }, + .probe = tda7419_probe, + .id_table = tda7419_i2c_id, +}; + +module_i2c_driver(tda7419_driver); + +MODULE_AUTHOR("Matt Porter "); +MODULE_DESCRIPTION("TDA7419 audio processor driver"); +MODULE_LICENSE("GPL"); From 1d22c337dc8f3a25638f7262e7bcb5729a34d140 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Mar 2018 17:41:13 +0100 Subject: [PATCH 785/942] ASoC: samsung: odroid: Fix 32000 sample rate handling In case of sample rates lower than 44100 currently there is too low MCLK frequency set for the CODEC. Playback fails with following errors: $ speaker-test -c2 -t sine -f 1500 -l2 -r 32000 Sine wave rate is 1500.0000Hz Rate set to 32000Hz (requested 32000Hz) Buffer size range from 128 to 131072 Period size range from 64 to 65536 Using max buffer size 131072 Periods = 4 Unable to set hw params for playback: Invalid argument Setting of hwparams failed: Invalid argument [ 497.883700] max98090 1-0010: Invalid master clock frequency To fix this the I2S root clock's frequency is increased, depending on sampling rate. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/odroid.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index 92d750806d1d..e698e67f5f84 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -36,23 +36,26 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct odroid_priv *priv = snd_soc_card_get_drvdata(rtd->card); - unsigned int pll_freq, rclk_freq; + unsigned int pll_freq, rclk_freq, rfs; int ret; switch (params_rate(params)) { - case 32000: case 64000: - pll_freq = 131072006U; + pll_freq = 196608001U; + rfs = 384; break; case 44100: case 88200: case 176400: pll_freq = 180633609U; + rfs = 512; break; + case 32000: case 48000: case 96000: case 192000: pll_freq = 196608001U; + rfs = 512; break; default: return -EINVAL; @@ -67,7 +70,7 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, * frequency values due to the EPLL output frequency not being exact * multiple of the audio sampling rate. */ - rclk_freq = params_rate(params) * 256 + 1; + rclk_freq = params_rate(params) * rfs + 1; ret = clk_set_rate(priv->sclk_i2s, rclk_freq); if (ret < 0) From 23952006ace5a54caddcda3de6f7676dfe520e86 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Mar 2018 17:41:14 +0100 Subject: [PATCH 786/942] ASoC: samsung: odroid: Drop sample rates that cannot be supported from hw_params() The I2S controller can handle sample rates only up to 96000 and the CPU DAI has already related constraint set so drop the impossible 176400, 192000 switch cases. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/odroid.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index e698e67f5f84..e1b59457a327 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -46,14 +46,12 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream, break; case 44100: case 88200: - case 176400: pll_freq = 180633609U; rfs = 512; break; case 32000: case 48000: case 96000: - case 192000: pll_freq = 196608001U; rfs = 512; break; From 4718840e76f74e5868d2001f0ca3a0e5c4292ea0 Mon Sep 17 00:00:00 2001 From: Sylwester Nawrocki Date: Wed, 14 Mar 2018 17:41:15 +0100 Subject: [PATCH 787/942] ASoC: samsung: Use snd_soc_of_put_dai_link_codecs() in odroid.c Now when a helper for unreferencing device nodes is available we can get rid of the local implementation. Signed-off-by: Sylwester Nawrocki Acked-by: Krzysztof Kozlowski Signed-off-by: Mark Brown --- sound/soc/samsung/odroid.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c index e1b59457a327..e7b371b07230 100644 --- a/sound/soc/samsung/odroid.c +++ b/sound/soc/samsung/odroid.c @@ -91,18 +91,6 @@ static const struct snd_soc_ops odroid_card_ops = { .hw_params = odroid_card_hw_params, }; -static void odroid_put_codec_of_nodes(struct snd_soc_dai_link *link) -{ - struct snd_soc_dai_link_component *component = link->codecs; - int i; - - for (i = 0; i < link->num_codecs; i++, component++) { - if (!component->of_node) - break; - of_node_put(component->of_node); - } -} - static int odroid_audio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -197,7 +185,7 @@ err_put_sclk: err_put_i2s_n: of_node_put(link->cpu_of_node); err_put_codec_n: - odroid_put_codec_of_nodes(link); + snd_soc_of_put_dai_link_codecs(link); return ret; } @@ -206,7 +194,7 @@ static int odroid_audio_remove(struct platform_device *pdev) struct odroid_priv *priv = platform_get_drvdata(pdev); of_node_put(priv->dai_link.cpu_of_node); - odroid_put_codec_of_nodes(&priv->dai_link); + snd_soc_of_put_dai_link_codecs(&priv->dai_link); clk_put(priv->sclk_i2s); clk_put(priv->clk_i2s_bus); From 3c1464658ec642309453db33364e82291d98acc2 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 14 Mar 2018 20:43:51 +0000 Subject: [PATCH 788/942] ASoC: pcm: improve debug output for DPCM BE searching. Improve the DPCM BE search debug output to make it easier to debug issues in topologies. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/soc-pcm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 084125463d10..68d9dc930096 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1392,12 +1392,18 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, struct snd_soc_pcm_runtime *be; int i; + dev_dbg(card->dev, "ASoC: find BE for widget %s\n", widget->name); + if (stream == SNDRV_PCM_STREAM_PLAYBACK) { list_for_each_entry(be, &card->rtd_list, list) { if (!be->dai_link->no_pcm) continue; + dev_dbg(card->dev, "ASoC: try BE : %s\n", + be->cpu_dai->playback_widget ? + be->cpu_dai->playback_widget->name : "(not set)"); + if (be->cpu_dai->playback_widget == widget) return be; @@ -1414,6 +1420,10 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, if (!be->dai_link->no_pcm) continue; + dev_dbg(card->dev, "ASoC: try BE %s\n", + be->cpu_dai->capture_widget ? + be->cpu_dai->capture_widget->name : "(not set)"); + if (be->cpu_dai->capture_widget == widget) return be; @@ -1425,6 +1435,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, } } + /* dai link name and stream name set correctly ? */ dev_err(card->dev, "ASoC: can't get %s BE for %s\n", stream ? "capture" : "playback", widget->name); return NULL; From 05bdcf12905533b8628627b6634608cd3b57c607 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 14 Mar 2018 20:42:40 +0000 Subject: [PATCH 789/942] ASoC: topology: Check widget kcontrols before deref. Validate the topology input before we dereference the pointer. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown --- sound/soc/soc-topology.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index e81b52600d58..b363f2409f72 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -504,6 +504,9 @@ static void remove_widget(struct snd_soc_component *comp, if (dobj->ops && dobj->ops->widget_unload) dobj->ops->widget_unload(comp, dobj); + if (!w->kcontrols) + goto free_news; + /* * Dynamic Widgets either have 1..N enum kcontrols or mixers. * The enum may either have an array of values or strings. @@ -524,7 +527,6 @@ static void remove_widget(struct snd_soc_component *comp, kfree(se); } - kfree(w->kcontrol_news); } else { /* volume mixer or bytes controls */ for (i = 0; i < w->num_kcontrols; i++) { @@ -541,8 +543,11 @@ static void remove_widget(struct snd_soc_component *comp, kfree((void *)kcontrol->private_value); snd_ctl_remove(card, kcontrol); } - kfree(w->kcontrol_news); } + +free_news: + kfree(w->kcontrol_news); + /* widget w is freed by soc-dapm.c */ } From 4b0b37d4cc54b21a6ecad7271cbc850555869c62 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski Date: Sat, 17 Mar 2018 08:25:07 -0700 Subject: [PATCH 790/942] selftests/x86/ptrace_syscall: Fix for yet more glibc interference glibc keeps getting cleverer, and my version now turns raise() into more than one syscall. Since the test relies on ptrace seeing an exact set of syscalls, this breaks the test. Replace raise(SIGSTOP) with syscall(SYS_tgkill, ...) to force glibc to get out of our way. Signed-off-by: Andy Lutomirski Cc: Borislav Petkov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-kselftest@vger.kernel.org Cc: stable@vger.kernel.org Link: http://lkml.kernel.org/r/bc80338b453afa187bc5f895bd8e2c8d6e264da2.1521300271.git.luto@kernel.org Signed-off-by: Ingo Molnar --- tools/testing/selftests/x86/ptrace_syscall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/x86/ptrace_syscall.c b/tools/testing/selftests/x86/ptrace_syscall.c index 1ae1c5a7392e..6f22238f3217 100644 --- a/tools/testing/selftests/x86/ptrace_syscall.c +++ b/tools/testing/selftests/x86/ptrace_syscall.c @@ -183,8 +183,10 @@ static void test_ptrace_syscall_restart(void) if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0) err(1, "PTRACE_TRACEME"); + pid_t pid = getpid(), tid = syscall(SYS_gettid); + printf("\tChild will make one syscall\n"); - raise(SIGSTOP); + syscall(SYS_tgkill, pid, tid, SIGSTOP); syscall(SYS_gettid, 10, 11, 12, 13, 14, 15); _exit(0); @@ -301,9 +303,11 @@ static void test_restart_under_ptrace(void) if (ptrace(PTRACE_TRACEME, 0, 0, 0) != 0) err(1, "PTRACE_TRACEME"); + pid_t pid = getpid(), tid = syscall(SYS_gettid); + printf("\tChild will take a nap until signaled\n"); setsigign(SIGUSR1, SA_RESTART); - raise(SIGSTOP); + syscall(SYS_tgkill, pid, tid, SIGSTOP); syscall(SYS_pause, 0, 0, 0, 0, 0, 0); _exit(0); From 7ecbd6a91b1e9bb90a4f3be641669347aacc5ab5 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Mar 2018 07:27:17 +0000 Subject: [PATCH 791/942] soc-core: don't call kfree() for component When driver register its component to ALSA SoC, almost all drivers are using snd_soc_register_component(), but soc-generic-dmaengine-pcm is using snd_soc_add_component(). Existing component function had been assumed that registered component was allocated, and it calling kfree() for it. But, the user who used snd_soc_add_component() doesn't. This patch uses devm_kzalloc() instead of kzalloc() for component, and doesn't call kree() anymore. This patch fixes commit be7ee5f32a9a ("ASoC: soc-generic-dmaengine-pcm: replace platform to component"). Allwinner H3 SoC will crash without this patch. Thanks Jernej report. Reported-by: Jernej Skrabec Signed-off-by: Kuninori Morimoto Tested-by: Jernej Skrabec Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9558125b448d..8b1ef90f7b57 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3454,7 +3454,6 @@ int snd_soc_add_component(struct device *dev, err_cleanup: snd_soc_component_cleanup(component); err_free: - kfree(component); return ret; } EXPORT_SYMBOL_GPL(snd_soc_add_component); @@ -3466,7 +3465,7 @@ int snd_soc_register_component(struct device *dev, { struct snd_soc_component *component; - component = kzalloc(sizeof(*component), GFP_KERNEL); + component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL); if (!component) return -ENOMEM; @@ -3501,7 +3500,6 @@ static int __snd_soc_unregister_component(struct device *dev) if (found) { snd_soc_component_cleanup(component); - kfree(component); } return found; From b1d0b34b748c9e5e67a91c545cb48711cfde119c Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Sat, 17 Mar 2018 01:52:38 +0100 Subject: [PATCH 792/942] drm/tegra: dc: Detach IOMMU group from domain only once Detaching from an IOMMU group multiple times can lead to a crash. This could potentially be fixed in the IOMMU driver, but it's easy to avoid the subsequent detach operations in this driver, so do that as well. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/dc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c index b8403ed48285..fbffe1948b3b 100644 --- a/drivers/gpu/drm/tegra/dc.c +++ b/drivers/gpu/drm/tegra/dc.c @@ -1903,8 +1903,12 @@ cleanup: if (!IS_ERR(primary)) drm_plane_cleanup(primary); - if (group && tegra->domain) { - iommu_detach_group(tegra->domain, group); + if (group && dc->domain) { + if (group == tegra->group) { + iommu_detach_group(dc->domain, group); + tegra->group = NULL; + } + dc->domain = NULL; } @@ -1913,8 +1917,10 @@ cleanup: static int tegra_dc_exit(struct host1x_client *client) { + struct drm_device *drm = dev_get_drvdata(client->parent); struct iommu_group *group = iommu_group_get(client->dev); struct tegra_dc *dc = host1x_client_to_dc(client); + struct tegra_drm *tegra = drm->dev_private; int err; devm_free_irq(dc->dev, dc->irq, dc); @@ -1926,7 +1932,11 @@ static int tegra_dc_exit(struct host1x_client *client) } if (group && dc->domain) { - iommu_detach_group(dc->domain, group); + if (group == tegra->group) { + iommu_detach_group(dc->domain, group); + tegra->group = NULL; + } + dc->domain = NULL; } From 8dafb8301cae1a3fc8407f5da62b491bfcfdf04b Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Sat, 17 Mar 2018 02:48:34 +0100 Subject: [PATCH 793/942] drm/tegra: dsi: Don't disable regulator on ->exit() The regulator is controlled as part of runtime PM, so it should not be additionally disabled from the ->exit() callback. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/dsi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index 4d2ed966f9e3..87c5d89bc9ba 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -1072,7 +1072,6 @@ static int tegra_dsi_exit(struct host1x_client *client) struct tegra_dsi *dsi = host1x_client_to_dsi(client); tegra_output_exit(&dsi->output); - regulator_disable(dsi->vdd); return 0; } From 192b4af6cd28cdad9b42fd79c21a90a2aeb0bec7 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Sun, 18 Mar 2018 01:13:39 +0100 Subject: [PATCH 794/942] drm/tegra: Shutdown on driver unbind Since commit 846c7dfc1193 ("drm/atomic: Try to preserve the crtc enabled state in drm_atomic_remove_fb, v2."), removing the last framebuffer will no longer disable the corresponding pipeline, which causes the KMS core to complain about leaked connectors on driver unbind. Fix this by calling drm_atomic_helper_shutdown() on driver unbind, which will cause all display pipelines to be shut down and therefore drop the extra references on the connectors. Signed-off-by: Thierry Reding --- drivers/gpu/drm/tegra/drm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index d50bddb2e447..7fcf4a242840 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -250,6 +250,7 @@ static void tegra_drm_unload(struct drm_device *drm) drm_kms_helper_poll_fini(drm); tegra_drm_fb_exit(drm); + drm_atomic_helper_shutdown(drm); drm_mode_config_cleanup(drm); err = host1x_device_exit(device); From 82bf43b291888599b4079244d12195d214086fa4 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Wed, 14 Mar 2018 16:42:17 +0800 Subject: [PATCH 795/942] Revert "ACPI / battery: Add quirk for Asus GL502VSK and UX305LA" Revert commit c68f0676ef7d ("ACPI / battery: Add quirk for Asus GL502VSK and UX305LA") and commit 4446823e2573 ("ACPI / battery: Add quirk for Asus UX360UA and UX410UAK"). On many many Asus products, the battery is sometimes reported as charging or discharging even when it is full and you are on AC power. This change quirked the kernel to avoid advertising the discharging state when this happens on 4 laptop models, under the belief that this was incorrect information. I presume it originates from user reports who are confused that their battery status icon says that it is discharging. However, the reported information is indeed correct, and the quirk approach taken is inadequate and more thought is needed first. Specifically: 1. It only quirks discharging state, not charging 2. There are so many different Asus products and DMI naming variants within those product families that behave this way; Linux could grow to quirk hundreds of products and still not even be close at "winning" this battle. 3. Asus previously clarified that this behaviour is intentional. The platform will periodically do a partial discharge/charge cycle when the battery is full, because this is one way to extend the lifetime of the battery (leaving a battery at 100% charge and unused will decrease its usable capacity over time). My understanding is that any decent consumer product will have this behaviour, but it appears that Asus is different in that they expose this info through ACPI. However, the behaviour seems correct. The ACPI spec does not suggest in that the platform should hide the truth. It lets you report that the battery is full of charge, and discharging, and with external power connected; and Asus does this. 4. In terms of not confusing the user, this seems like something that could/should be handled by userspace, which can also detect these same (accurate) conditions in the general case. Revert this quirk before it gets included in a release, while we look for better approaches. Signed-off-by: Daniel Drake Acked-by: Kai-Heng Feng Signed-off-by: Rafael J. Wysocki --- drivers/acpi/battery.c | 48 +++--------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 7128488a3a72..f2eb6c37ea0a 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -70,7 +70,6 @@ static async_cookie_t async_cookie; static bool battery_driver_registered; static int battery_bix_broken_package; static int battery_notification_delay_ms; -static int battery_full_discharging; static unsigned int cache_time = 1000; module_param(cache_time, uint, 0644); MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); @@ -215,12 +214,9 @@ static int acpi_battery_get_property(struct power_supply *psy, return -ENODEV; switch (psp) { case POWER_SUPPLY_PROP_STATUS: - if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) { - if (battery_full_discharging && battery->rate_now == 0) - val->intval = POWER_SUPPLY_STATUS_FULL; - else - val->intval = POWER_SUPPLY_STATUS_DISCHARGING; - } else if (battery->state & ACPI_BATTERY_STATE_CHARGING) + if (battery->state & ACPI_BATTERY_STATE_DISCHARGING) + val->intval = POWER_SUPPLY_STATUS_DISCHARGING; + else if (battery->state & ACPI_BATTERY_STATE_CHARGING) val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (acpi_battery_is_charged(battery)) val->intval = POWER_SUPPLY_STATUS_FULL; @@ -1170,12 +1166,6 @@ battery_notification_delay_quirk(const struct dmi_system_id *d) return 0; } -static int __init battery_full_discharging_quirk(const struct dmi_system_id *d) -{ - battery_full_discharging = 1; - return 0; -} - static const struct dmi_system_id bat_dmi_table[] __initconst = { { .callback = battery_bix_broken_package_quirk, @@ -1193,38 +1183,6 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"), }, }, - { - .callback = battery_full_discharging_quirk, - .ident = "ASUS GL502VSK", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "GL502VSK"), - }, - }, - { - .callback = battery_full_discharging_quirk, - .ident = "ASUS UX305LA", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "UX305LA"), - }, - }, - { - .callback = battery_full_discharging_quirk, - .ident = "ASUS UX360UA", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "UX360UA"), - }, - }, - { - .callback = battery_full_discharging_quirk, - .ident = "ASUS UX410UAK", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_PRODUCT_NAME, "UX410UAK"), - }, - }, {}, }; From 6de564939e14327148e31ddcf769e34105176447 Mon Sep 17 00:00:00 2001 From: OuYang ZhiZhong Date: Sun, 11 Mar 2018 15:59:07 +0800 Subject: [PATCH 796/942] mtdchar: fix usage of mtd_ooblayout_ecc() Section was not properly computed. The value of OOB region definition is always ECC section 0 information in the OOB area, but we want to get all the ECC bytes information, so we should call mtd_ooblayout_ecc(mtd, section++, &oobregion) until it returns -ERANGE. Fixes: c2b78452a9db ("mtd: use mtd_ooblayout_xxx() helpers where appropriate") Cc: Signed-off-by: OuYang ZhiZhong Signed-off-by: Boris Brezillon --- drivers/mtd/mtdchar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index de8c902059b8..7d80a8bb96fe 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -479,7 +479,7 @@ static int shrink_ecclayout(struct mtd_info *mtd, for (i = 0; i < MTD_MAX_ECCPOS_ENTRIES;) { u32 eccpos; - ret = mtd_ooblayout_ecc(mtd, section, &oobregion); + ret = mtd_ooblayout_ecc(mtd, section++, &oobregion); if (ret < 0) { if (ret != -ERANGE) return ret; @@ -526,7 +526,7 @@ static int get_oobinfo(struct mtd_info *mtd, struct nand_oobinfo *to) for (i = 0; i < ARRAY_SIZE(to->eccpos);) { u32 eccpos; - ret = mtd_ooblayout_ecc(mtd, section, &oobregion); + ret = mtd_ooblayout_ecc(mtd, section++, &oobregion); if (ret < 0) { if (ret != -ERANGE) return ret; From 9ffd7503944ec7c0ef41c3245d1306c221aef2be Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Thu, 15 Mar 2018 18:23:17 +0000 Subject: [PATCH 797/942] can: cc770: Fix use after free in cc770_tx_interrupt() This fixes use after free introduced by the last cc770 patch. Signed-off-by: Andri Yngvason Fixes: 746201235b3f ("can: cc770: Fix queue stall & dropped RTR reply") Cc: linux-stable Signed-off-by: Marc Kleine-Budde --- drivers/net/can/cc770/cc770.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/cc770/cc770.c b/drivers/net/can/cc770/cc770.c index 2743d82d4424..6da69af103e6 100644 --- a/drivers/net/can/cc770/cc770.c +++ b/drivers/net/can/cc770/cc770.c @@ -706,13 +706,12 @@ static void cc770_tx_interrupt(struct net_device *dev, unsigned int o) return; } - can_put_echo_skb(priv->tx_skb, dev, 0); - can_get_echo_skb(dev, 0); - cf = (struct can_frame *)priv->tx_skb->data; stats->tx_bytes += cf->can_dlc; stats->tx_packets++; + can_put_echo_skb(priv->tx_skb, dev, 0); + can_get_echo_skb(dev, 0); priv->tx_skb = NULL; netif_wake_queue(dev); From 4c41aa24baa4ed338241d05494f2c595c885af8f Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 19 Mar 2018 14:07:45 +0300 Subject: [PATCH 798/942] staging: ncpfs: memory corruption in ncp_read_kernel() If the server is malicious then *bytes_read could be larger than the size of the "target" buffer. It would lead to memory corruption when we do the memcpy(). Reported-by: Dr Silvio Cesare of InfoSect Signed-off-by: Dan Carpenter Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ncpfs/ncplib_kernel.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/ncpfs/ncplib_kernel.c b/drivers/staging/ncpfs/ncplib_kernel.c index 804adfebba2f..3e047eb4cc7c 100644 --- a/drivers/staging/ncpfs/ncplib_kernel.c +++ b/drivers/staging/ncpfs/ncplib_kernel.c @@ -981,6 +981,10 @@ ncp_read_kernel(struct ncp_server *server, const char *file_id, goto out; } *bytes_read = ncp_reply_be16(server, 0); + if (*bytes_read > to_read) { + result = -EINVAL; + goto out; + } source = ncp_reply_data(server, 2 + (offset & 1)); memcpy(target, source, *bytes_read); From 62ac3f7305470e3f52f159de448bc1a771717e88 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 19 Mar 2018 16:33:58 +0100 Subject: [PATCH 799/942] libata: Apply NOLPM quirk to Crucial M500 480 and 960GB SSDs There have been reports of the Crucial M500 480GB model not working with LPM set to min_power / med_power_with_dipm level. It has not been tested with medium_power, but that typically has no measurable power-savings. Note the reporters Crucial_CT480M500SSD3 has a firmware version of MU03 and there is a MU05 update available, but that update does not mention any LPM fixes in its changelog, so the quirk matches all firmware versions. In my experience the LPM problems with (older) Crucial SSDs seem to be limited to higher capacity versions of the SSDs (different firmware?), so this commit adds a NOLPM quirk for the 480 and 960GB versions of the M500, to avoid LPM causing issues with these SSDs. Cc: stable@vger.kernel.org Reported-and-tested-by: Martin Steigerwald Signed-off-by: Hans de Goede Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index aec609f80c4e..53400ce09818 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4538,6 +4538,14 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { ATA_HORKAGE_ZERO_AFTER_TRIM | ATA_HORKAGE_NOLPM, }, + /* 480GB+ M500 SSDs have both queued TRIM and LPM issues */ + { "Crucial_CT480M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM | + ATA_HORKAGE_NOLPM, }, + { "Crucial_CT960M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM | + ATA_HORKAGE_NOLPM, }, + /* devices that don't properly handle queued TRIM commands */ { "Micron_M500_*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM, }, From 3bf7b5d6d017c27e0d3b160aafb35a8e7cfeda1f Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 19 Mar 2018 16:33:59 +0100 Subject: [PATCH 800/942] libata: Make Crucial BX100 500GB LPM quirk apply to all firmware versions Commit b17e5729a630 ("libata: disable LPM for Crucial BX100 SSD 500GB drive"), introduced a ATA_HORKAGE_NOLPM quirk for Crucial BX100 500GB SSDs but limited this to the MU02 firmware version, according to: http://www.crucial.com/usa/en/support-ssd-firmware MU02 is the last version, so there are no newer possibly fixed versions and if the MU02 version has broken LPM then the MU01 almost certainly also has broken LPM, so this commit changes the quirk to apply to all firmware versions. Fixes: b17e5729a630 ("libata: disable LPM for Crucial BX100 SSD 500GB...") Cc: stable@vger.kernel.org Cc: Kai-Heng Feng Signed-off-by: Hans de Goede Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 53400ce09818..bce9840526da 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4531,7 +4531,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { { "PIONEER DVD-RW DVR-216D", NULL, ATA_HORKAGE_NOSETXFER }, /* Crucial BX100 SSD 500GB has broken LPM support */ - { "CT500BX100SSD1", "MU02", ATA_HORKAGE_NOLPM }, + { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM }, /* The 512GB version of the MX100 has both queued TRIM and LPM issues */ { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | From d418ff56b8f2d2b296daafa8da151fe27689b757 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 19 Mar 2018 16:34:00 +0100 Subject: [PATCH 801/942] libata: Modify quirks for MX100 to limit NCQ_TRIM quirk to MU01 version When commit 9c7be59fc519af ("libata: Apply NOLPM quirk to Crucial MX100 512GB SSDs") was added it inherited the ATA_HORKAGE_NO_NCQ_TRIM quirk from the existing "Crucial_CT*MX100*" entry, but that entry sets model_rev to "MU01", where as the entry adding the NOLPM quirk sets it to NULL. This means that after this commit we no apply the NO_NCQ_TRIM quirk to all "Crucial_CT512MX100*" SSDs even if they have the fixed "MU02" firmware. This commit splits the "Crucial_CT512MX100*" quirk into 2 quirks, one for the "MU01" firmware and one for all other firmware versions, so that we once again only apply the NO_NCQ_TRIM quirk to the "MU01" firmware version. Fixes: 9c7be59fc519af ("libata: Apply NOLPM quirk to ... MX100 512GB SSDs") Cc: stable@vger.kernel.org Signed-off-by: Hans de Goede Signed-off-by: Tejun Heo --- drivers/ata/libata-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index bce9840526da..7431ccd03316 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -4533,10 +4533,13 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { /* Crucial BX100 SSD 500GB has broken LPM support */ { "CT500BX100SSD1", NULL, ATA_HORKAGE_NOLPM }, - /* The 512GB version of the MX100 has both queued TRIM and LPM issues */ - { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + /* 512GB MX100 with MU01 firmware has both queued TRIM and LPM issues */ + { "Crucial_CT512MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | ATA_HORKAGE_ZERO_AFTER_TRIM | ATA_HORKAGE_NOLPM, }, + /* 512GB MX100 with newer firmware has only LPM issues */ + { "Crucial_CT512MX100*", NULL, ATA_HORKAGE_ZERO_AFTER_TRIM | + ATA_HORKAGE_NOLPM, }, /* 480GB+ M500 SSDs have both queued TRIM and LPM issues */ { "Crucial_CT480M500*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | From 219be9dda6137bc9759c449bbff5d4394fe73382 Mon Sep 17 00:00:00 2001 From: Clark Zheng Date: Thu, 15 Mar 2018 14:02:06 +0800 Subject: [PATCH 802/942] drm/amd/display: Refine disable VGA bad case won't follow normal sense, it will not enable vga1 as usual, but vga2,3,4 is on. Signed-off-by: Clark Zheng Reviewed-by: Tony Cheng Acked-by: Alex Deucher Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h | 8 +++++++- .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 16 +++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h index a993279a8f2d..f11f17fe08f9 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h @@ -496,6 +496,9 @@ struct dce_hwseq_registers { HWS_SF(, DOMAIN7_PG_STATUS, DOMAIN7_PGFSM_PWR_STATUS, mask_sh), \ HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh), \ HWS_SF(, D1VGA_CONTROL, D1VGA_MODE_ENABLE, mask_sh),\ + HWS_SF(, D2VGA_CONTROL, D2VGA_MODE_ENABLE, mask_sh),\ + HWS_SF(, D3VGA_CONTROL, D3VGA_MODE_ENABLE, mask_sh),\ + HWS_SF(, D4VGA_CONTROL, D4VGA_MODE_ENABLE, mask_sh),\ HWS_SF(, VGA_TEST_CONTROL, VGA_TEST_ENABLE, mask_sh),\ HWS_SF(, VGA_TEST_CONTROL, VGA_TEST_RENDER_START, mask_sh),\ HWS_SF(, LVTMA_PWRSEQ_CNTL, LVTMA_BLON, mask_sh), \ @@ -591,7 +594,10 @@ struct dce_hwseq_registers { type DENTIST_DISPCLK_WDIVIDER; \ type VGA_TEST_ENABLE; \ type VGA_TEST_RENDER_START; \ - type D1VGA_MODE_ENABLE; + type D1VGA_MODE_ENABLE; \ + type D2VGA_MODE_ENABLE; \ + type D3VGA_MODE_ENABLE; \ + type D4VGA_MODE_ENABLE; struct dce_hwseq_shift { HWSEQ_REG_FIELD_LIST(uint8_t) diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c index 072e4485e85e..dc1e010725c1 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c +++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c @@ -238,14 +238,24 @@ static void enable_power_gating_plane( static void disable_vga( struct dce_hwseq *hws) { - unsigned int in_vga_mode = 0; + unsigned int in_vga1_mode = 0; + unsigned int in_vga2_mode = 0; + unsigned int in_vga3_mode = 0; + unsigned int in_vga4_mode = 0; - REG_GET(D1VGA_CONTROL, D1VGA_MODE_ENABLE, &in_vga_mode); + REG_GET(D1VGA_CONTROL, D1VGA_MODE_ENABLE, &in_vga1_mode); + REG_GET(D2VGA_CONTROL, D2VGA_MODE_ENABLE, &in_vga2_mode); + REG_GET(D3VGA_CONTROL, D3VGA_MODE_ENABLE, &in_vga3_mode); + REG_GET(D4VGA_CONTROL, D4VGA_MODE_ENABLE, &in_vga4_mode); - if (in_vga_mode == 0) + if (in_vga1_mode == 0 && in_vga2_mode == 0 && + in_vga3_mode == 0 && in_vga4_mode == 0) return; REG_WRITE(D1VGA_CONTROL, 0); + REG_WRITE(D2VGA_CONTROL, 0); + REG_WRITE(D3VGA_CONTROL, 0); + REG_WRITE(D4VGA_CONTROL, 0); /* HW Engineer's Notes: * During switch from vga->extended, if we set the VGA_TEST_ENABLE and From cd2d6c92a8e39d7e50a5af9fcc67d07e6a89e91d Mon Sep 17 00:00:00 2001 From: Shirish S Date: Thu, 15 Mar 2018 16:01:00 +0530 Subject: [PATCH 803/942] drm/amd/display: fix dereferencing possible ERR_PTR() This patch fixes static checker warning caused by "36cc549d5986: "drm/amd/display: disable CRTCs with NULL FB on their primary plane (V2)" Reported-by: Dan Carpenter Signed-off-by: Shirish S Reviewed-by: Harry Wentland Acked-by: Alex Deucher Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index c345e645f1d7..95b639eddcb6 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -4794,6 +4794,9 @@ static int dm_atomic_check_plane_state_fb(struct drm_atomic_state *state, return -EDEADLK; crtc_state = drm_atomic_get_crtc_state(plane_state->state, crtc); + if (IS_ERR(crtc_state)) + return PTR_ERR(crtc_state); + if (crtc->primary == plane && crtc_state->active) { if (!plane_state->fb) return -EINVAL; From 49012d1bf5f78782d398adb984a080a88ba42965 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 8 Feb 2018 14:43:35 +0100 Subject: [PATCH 804/942] clk: bcm2835: Fix ana->maskX definitions ana->maskX values are already '~'-ed in bcm2835_pll_set_rate(). Remove the '~' in the definition to fix ANA setup. Note that this commit fixes a long standing bug preventing one from using an HDMI display if it's plugged after the FW has booted Linux. This is because PLLH is used by the HDMI encoder to generate the pixel clock. Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the audio domain clocks") Cc: Signed-off-by: Boris Brezillon Reviewed-by: Eric Anholt Signed-off-by: Stephen Boyd --- drivers/clk/bcm/clk-bcm2835.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 44301a3d9963..2108a274185a 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -449,17 +449,17 @@ struct bcm2835_pll_ana_bits { static const struct bcm2835_pll_ana_bits bcm2835_ana_default = { .mask0 = 0, .set0 = 0, - .mask1 = (u32)~(A2W_PLL_KI_MASK | A2W_PLL_KP_MASK), + .mask1 = A2W_PLL_KI_MASK | A2W_PLL_KP_MASK, .set1 = (2 << A2W_PLL_KI_SHIFT) | (8 << A2W_PLL_KP_SHIFT), - .mask3 = (u32)~A2W_PLL_KA_MASK, + .mask3 = A2W_PLL_KA_MASK, .set3 = (2 << A2W_PLL_KA_SHIFT), .fb_prediv_mask = BIT(14), }; static const struct bcm2835_pll_ana_bits bcm2835_ana_pllh = { - .mask0 = (u32)~(A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK), + .mask0 = A2W_PLLH_KA_MASK | A2W_PLLH_KI_LOW_MASK, .set0 = (2 << A2W_PLLH_KA_SHIFT) | (2 << A2W_PLLH_KI_LOW_SHIFT), - .mask1 = (u32)~(A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK), + .mask1 = A2W_PLLH_KI_HIGH_MASK | A2W_PLLH_KP_MASK, .set1 = (6 << A2W_PLLH_KP_SHIFT), .mask3 = 0, .set3 = 0, From 7997f3b2df751aab0b8e60149b226a32966c41ac Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 8 Feb 2018 14:43:36 +0100 Subject: [PATCH 805/942] clk: bcm2835: Protect sections updating shared registers CM_PLLx and A2W_XOSC_CTRL registers are accessed by different clock handlers and must be accessed with ->regs_lock held. Update the sections where this protection is missing. Fixes: 41691b8862e2 ("clk: bcm2835: Add support for programming the audio domain clocks") Cc: Signed-off-by: Boris Brezillon Reviewed-by: Eric Anholt Signed-off-by: Stephen Boyd --- drivers/clk/bcm/clk-bcm2835.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 2108a274185a..a07f6451694a 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -623,8 +623,10 @@ static int bcm2835_pll_on(struct clk_hw *hw) ~A2W_PLL_CTRL_PWRDN); /* Take the PLL out of reset. */ + spin_lock(&cprman->regs_lock); cprman_write(cprman, data->cm_ctrl_reg, cprman_read(cprman, data->cm_ctrl_reg) & ~CM_PLL_ANARST); + spin_unlock(&cprman->regs_lock); /* Wait for the PLL to lock. */ timeout = ktime_add_ns(ktime_get(), LOCK_TIMEOUT_NS); @@ -701,9 +703,11 @@ static int bcm2835_pll_set_rate(struct clk_hw *hw, } /* Unmask the reference clock from the oscillator. */ + spin_lock(&cprman->regs_lock); cprman_write(cprman, A2W_XOSC_CTRL, cprman_read(cprman, A2W_XOSC_CTRL) | data->reference_enable_mask); + spin_unlock(&cprman->regs_lock); if (do_ana_setup_first) bcm2835_pll_write_ana(cprman, data->ana_reg_base, ana); From 71546d100422bcc2c543dadeb9328728997cd23a Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 14 Mar 2018 08:27:26 -0700 Subject: [PATCH 806/942] percpu: include linux/sched.h for cond_resched() microblaze build broke due to missing declaration of the cond_resched() invocation added recently. Let's include linux/sched.h explicitly. Signed-off-by: Tejun Heo Reported-by: kbuild test robot --- mm/percpu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/percpu.c b/mm/percpu.c index 36e7b65ba6cf..15a398c00791 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -80,6 +80,7 @@ #include #include #include +#include #include #include From f52ba1fef7b92e74d58efef8eae7b6f48c6d218d Mon Sep 17 00:00:00 2001 From: Kirill Tkhai Date: Mon, 19 Mar 2018 18:32:10 +0300 Subject: [PATCH 807/942] mm: Allow to kill tasks doing pcpu_alloc() and waiting for pcpu_balance_workfn() In case of memory deficit and low percpu memory pages, pcpu_balance_workfn() takes pcpu_alloc_mutex for a long time (as it makes memory allocations itself and waits for memory reclaim). If tasks doing pcpu_alloc() are choosen by OOM killer, they can't exit, because they are waiting for the mutex. The patch makes pcpu_alloc() to care about killing signal and use mutex_lock_killable(), when it's allowed by GFP flags. This guarantees, a task does not miss SIGKILL from OOM killer. Signed-off-by: Kirill Tkhai Signed-off-by: Tejun Heo --- mm/percpu.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 15a398c00791..9297098519a6 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1373,8 +1373,17 @@ static void __percpu *pcpu_alloc(size_t size, size_t align, bool reserved, return NULL; } - if (!is_atomic) - mutex_lock(&pcpu_alloc_mutex); + if (!is_atomic) { + /* + * pcpu_balance_workfn() allocates memory under this mutex, + * and it may wait for memory reclaim. Allow current task + * to become OOM victim, in case of memory pressure. + */ + if (gfp & __GFP_NOFAIL) + mutex_lock(&pcpu_alloc_mutex); + else if (mutex_lock_killable(&pcpu_alloc_mutex)) + return NULL; + } spin_lock_irqsave(&pcpu_lock, flags); From b3a5d111994450909158929560906f2c1c6c1d85 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Wed, 14 Mar 2018 12:45:12 -0700 Subject: [PATCH 808/942] percpu_ref: Update doc to dissuade users from depending on internal RCU grace periods percpu_ref internally uses sched-RCU to implement the percpu -> atomic mode switching and the documentation suggested that this could be depended upon. This doesn't seem like a good idea. * percpu_ref uses sched-RCU which has different grace periods regular RCU. Users may combine percpu_ref with regular RCU usage and incorrectly believe that regular RCU grace periods are performed by percpu_ref. This can lead to, for example, use-after-free due to premature freeing. * percpu_ref has a grace period when switching from percpu to atomic mode. It doesn't have one between the last put and release. This distinction is subtle and can lead to surprising bugs. * percpu_ref allows starting in and switching to atomic mode manually for debugging and other purposes. This means that there may not be any grace periods from kill to release. This patch makes it clear that the grace periods are percpu_ref's internal implementation detail and can't be depended upon by the users. Signed-off-by: Tejun Heo Cc: Kent Overstreet Cc: Linus Torvalds Signed-off-by: Tejun Heo --- include/linux/percpu-refcount.h | 18 ++++++++++++------ lib/percpu-refcount.c | 2 ++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/linux/percpu-refcount.h b/include/linux/percpu-refcount.h index 864d167a1073..009cdf3d65b6 100644 --- a/include/linux/percpu-refcount.h +++ b/include/linux/percpu-refcount.h @@ -30,10 +30,14 @@ * calls io_destroy() or the process exits. * * In the aio code, kill_ioctx() is called when we wish to destroy a kioctx; it - * calls percpu_ref_kill(), then hlist_del_rcu() and synchronize_rcu() to remove - * the kioctx from the proccess's list of kioctxs - after that, there can't be - * any new users of the kioctx (from lookup_ioctx()) and it's then safe to drop - * the initial ref with percpu_ref_put(). + * removes the kioctx from the proccess's table of kioctxs and kills percpu_ref. + * After that, there can't be any new users of the kioctx (from lookup_ioctx()) + * and it's then safe to drop the initial ref with percpu_ref_put(). + * + * Note that the free path, free_ioctx(), needs to go through explicit call_rcu() + * to synchronize with RCU protected lookup_ioctx(). percpu_ref operations don't + * imply RCU grace periods of any kind and if a user wants to combine percpu_ref + * with RCU protection, it must be done explicitly. * * Code that does a two stage shutdown like this often needs some kind of * explicit synchronization to ensure the initial refcount can only be dropped @@ -113,8 +117,10 @@ void percpu_ref_reinit(struct percpu_ref *ref); * Must be used to drop the initial ref on a percpu refcount; must be called * precisely once before shutdown. * - * Puts @ref in non percpu mode, then does a call_rcu() before gathering up the - * percpu counters and dropping the initial ref. + * Switches @ref into atomic mode before gathering up the percpu counters + * and dropping the initial ref. + * + * There are no implied RCU grace periods between kill and release. */ static inline void percpu_ref_kill(struct percpu_ref *ref) { diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index 30e7dd88148b..9f96fa7bc000 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c @@ -322,6 +322,8 @@ EXPORT_SYMBOL_GPL(percpu_ref_switch_to_percpu); * This function normally doesn't block and can be called from any context * but it may block if @confirm_kill is specified and @ref is in the * process of switching to atomic mode by percpu_ref_switch_to_atomic(). + * + * There are no implied RCU grace periods between kill and release. */ void percpu_ref_kill_and_confirm(struct percpu_ref *ref, percpu_ref_func_t *confirm_kill) From ed65a4dc22083e73bac599ded6a262318cad7baf Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Mon, 19 Mar 2018 14:20:15 +0200 Subject: [PATCH 809/942] RDMA/ucma: Fix use-after-free access in ucma_close The error in ucma_create_id() left ctx in the list of contexts belong to ucma file descriptor. The attempt to close this file descriptor causes to use-after-free accesses while iterating over such list. Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Reported-by: Signed-off-by: Leon Romanovsky Reviewed-by: Sean Hefty Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/ucma.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 3f3f7bbc4528..14c260ed63cb 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -497,6 +497,9 @@ err1: mutex_lock(&mut); idr_remove(&ctx_idr, ctx->id); mutex_unlock(&mut); + mutex_lock(&file->mut); + list_del(&ctx->list); + mutex_unlock(&file->mut); kfree(ctx); return ret; } From 80cf79ae4f688ead1dca8878990709c0446c3992 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Mon, 19 Mar 2018 12:21:43 +0200 Subject: [PATCH 810/942] RDMA/verbs: Remove restrack entry from XRCD structure XRCD object is not implemented in the restrack, so lets remove it. Fixes: 02d8883f520e ("RDMA/restrack: Add general infrastructure to track RDMA resources") Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe --- include/rdma/ib_verbs.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 73b2387e3f74..ff3ed435701f 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -1537,10 +1537,6 @@ struct ib_xrcd { struct mutex tgt_qp_mutex; struct list_head tgt_qp_list; - /* - * Implementation details of the RDMA core, don't use in drivers: - */ - struct rdma_restrack_entry res; }; struct ib_ah { From 68ef3bc3166468678d5e1fdd216628c35bd1186f Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Fri, 16 Mar 2018 11:32:02 -0400 Subject: [PATCH 811/942] nfsd: remove blocked locks on client teardown We had some reports of panics in nfsd4_lm_notify, and that showed a nfs4_lockowner that had outlived its so_client. Ensure that we walk any leftover lockowners after tearing down all of the stateids, and remove any blocked locks that they hold. With this change, we also don't need to walk the nbl_lru on nfsd_net shutdown, as that will happen naturally when we tear down the clients. Fixes: 76d348fadff5 (nfsd: have nfsd4_lock use blocking locks for v4.1+ locks) Reported-by: Frank Sorenson Signed-off-by: Jeff Layton Cc: stable@vger.kernel.org # 4.9 Signed-off-by: J. Bruce Fields --- fs/nfsd/nfs4state.c | 62 +++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 150521c9671b..61b770e39809 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -268,6 +268,35 @@ free_blocked_lock(struct nfsd4_blocked_lock *nbl) kfree(nbl); } +static void +remove_blocked_locks(struct nfs4_lockowner *lo) +{ + struct nfs4_client *clp = lo->lo_owner.so_client; + struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); + struct nfsd4_blocked_lock *nbl; + LIST_HEAD(reaplist); + + /* Dequeue all blocked locks */ + spin_lock(&nn->blocked_locks_lock); + while (!list_empty(&lo->lo_blocked)) { + nbl = list_first_entry(&lo->lo_blocked, + struct nfsd4_blocked_lock, + nbl_list); + list_del_init(&nbl->nbl_list); + list_move(&nbl->nbl_lru, &reaplist); + } + spin_unlock(&nn->blocked_locks_lock); + + /* Now free them */ + while (!list_empty(&reaplist)) { + nbl = list_first_entry(&reaplist, struct nfsd4_blocked_lock, + nbl_lru); + list_del_init(&nbl->nbl_lru); + posix_unblock_lock(&nbl->nbl_lock); + free_blocked_lock(nbl); + } +} + static int nfsd4_cb_notify_lock_done(struct nfsd4_callback *cb, struct rpc_task *task) { @@ -1866,6 +1895,7 @@ static __be32 mark_client_expired_locked(struct nfs4_client *clp) static void __destroy_client(struct nfs4_client *clp) { + int i; struct nfs4_openowner *oo; struct nfs4_delegation *dp; struct list_head reaplist; @@ -1895,6 +1925,16 @@ __destroy_client(struct nfs4_client *clp) nfs4_get_stateowner(&oo->oo_owner); release_openowner(oo); } + for (i = 0; i < OWNER_HASH_SIZE; i++) { + struct nfs4_stateowner *so, *tmp; + + list_for_each_entry_safe(so, tmp, &clp->cl_ownerstr_hashtbl[i], + so_strhash) { + /* Should be no openowners at this point */ + WARN_ON_ONCE(so->so_is_open_owner); + remove_blocked_locks(lockowner(so)); + } + } nfsd4_return_all_client_layouts(clp); nfsd4_shutdown_callback(clp); if (clp->cl_cb_conn.cb_xprt) @@ -6355,6 +6395,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, } spin_unlock(&clp->cl_lock); free_ol_stateid_reaplist(&reaplist); + remove_blocked_locks(lo); nfs4_put_stateowner(&lo->lo_owner); return status; @@ -7140,6 +7181,8 @@ nfs4_state_destroy_net(struct net *net) } } + WARN_ON(!list_empty(&nn->blocked_locks_lru)); + for (i = 0; i < CLIENT_HASH_SIZE; i++) { while (!list_empty(&nn->unconf_id_hashtbl[i])) { clp = list_entry(nn->unconf_id_hashtbl[i].next, struct nfs4_client, cl_idhash); @@ -7206,7 +7249,6 @@ nfs4_state_shutdown_net(struct net *net) struct nfs4_delegation *dp = NULL; struct list_head *pos, *next, reaplist; struct nfsd_net *nn = net_generic(net, nfsd_net_id); - struct nfsd4_blocked_lock *nbl; cancel_delayed_work_sync(&nn->laundromat_work); locks_end_grace(&nn->nfsd4_manager); @@ -7227,24 +7269,6 @@ nfs4_state_shutdown_net(struct net *net) nfs4_put_stid(&dp->dl_stid); } - BUG_ON(!list_empty(&reaplist)); - spin_lock(&nn->blocked_locks_lock); - while (!list_empty(&nn->blocked_locks_lru)) { - nbl = list_first_entry(&nn->blocked_locks_lru, - struct nfsd4_blocked_lock, nbl_lru); - list_move(&nbl->nbl_lru, &reaplist); - list_del_init(&nbl->nbl_list); - } - spin_unlock(&nn->blocked_locks_lock); - - while (!list_empty(&reaplist)) { - nbl = list_first_entry(&reaplist, - struct nfsd4_blocked_lock, nbl_lru); - list_del_init(&nbl->nbl_lru); - posix_unblock_lock(&nbl->nbl_lock); - free_blocked_lock(nbl); - } - nfsd4_client_tracking_exit(net); nfs4_state_destroy_net(net); } From b1abf6fc49829d89660c961fafe3f90f3d843c55 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 19 Mar 2018 14:51:49 +0100 Subject: [PATCH 812/942] ACPI / watchdog: Fix off-by-one error at resource assignment The resource allocation in WDAT watchdog has off-one-by error, it sets one byte more than the actual end address. This may eventually lead to unexpected resource conflicts. Fixes: 058dfc767008 (ACPI / watchdog: Add support for WDAT hardware watchdog) Cc: 4.9+ # 4.9+ Signed-off-by: Takashi Iwai Acked-by: Mika Westerberg Acked-by: Guenter Roeck Signed-off-by: Rafael J. Wysocki --- drivers/acpi/acpi_watchdog.c | 4 ++-- drivers/watchdog/wdat_wdt.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c index 11b113f8e367..ebb626ffb5fa 100644 --- a/drivers/acpi/acpi_watchdog.c +++ b/drivers/acpi/acpi_watchdog.c @@ -74,10 +74,10 @@ void __init acpi_watchdog_init(void) res.start = gas->address; if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { res.flags = IORESOURCE_MEM; - res.end = res.start + ALIGN(gas->access_width, 4); + res.end = res.start + ALIGN(gas->access_width, 4) - 1; } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { res.flags = IORESOURCE_IO; - res.end = res.start + gas->access_width; + res.end = res.start + gas->access_width - 1; } else { pr_warn("Unsupported address space: %u\n", gas->space_id); diff --git a/drivers/watchdog/wdat_wdt.c b/drivers/watchdog/wdat_wdt.c index 6d1fbda0f461..0da9943d405f 100644 --- a/drivers/watchdog/wdat_wdt.c +++ b/drivers/watchdog/wdat_wdt.c @@ -392,7 +392,7 @@ static int wdat_wdt_probe(struct platform_device *pdev) memset(&r, 0, sizeof(r)); r.start = gas->address; - r.end = r.start + gas->access_width; + r.end = r.start + gas->access_width - 1; if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) { r.flags = IORESOURCE_MEM; } else if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { From b1e314462bba76660eec62760bb2e87f28f58866 Mon Sep 17 00:00:00 2001 From: Dhinakaran Pandiyan Date: Tue, 13 Mar 2018 22:48:25 -0700 Subject: [PATCH 813/942] drm/i915/dp: Write to SET_POWER dpcd to enable MST hub. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If bios sets up an MST output and hardware state readout code sees this is an SST configuration, when disabling the encoder we end up calling ->post_disable_dp() hook instead of the MST version. Consequently, we write to the DP_SET_POWER dpcd to set it D3 state. Further along when we try enable the encoder in MST mode, POWER_UP_PHY transaction fails to power up the MST hub. This results in continuous link training failures which keep the system busy delaying boot. We could identify bios MST boot discrepancy and handle it accordingly but a simple way to solve this is to write to the DP_SET_POWER dpcd for MST too. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105470 Cc: Ville Syrjälä Cc: Jani Nikula Reviewed-by: Ville Syrjälä Reported-by: Laura Abbott Cc: stable@vger.kernel.org Fixes: 5ea2355a100a ("drm/i915/mst: Use MST sideband message transactions for dpms control") Tested-by: Laura Abbott Signed-off-by: Dhinakaran Pandiyan Signed-off-by: Jani Nikula Link: https://patchwork.freedesktop.org/patch/msgid/20180314054825.1718-1-dhinakaran.pandiyan@intel.com (cherry picked from commit ad260ab32a4d94fa974f58262f8000472d34fd5b) Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/intel_ddi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c index f51645a08dca..6aff9d096e13 100644 --- a/drivers/gpu/drm/i915/intel_ddi.c +++ b/drivers/gpu/drm/i915/intel_ddi.c @@ -2175,8 +2175,7 @@ static void intel_ddi_pre_enable_dp(struct intel_encoder *encoder, intel_prepare_dp_ddi_buffers(encoder, crtc_state); intel_ddi_init_dp_buf_reg(encoder); - if (!is_mst) - intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); + intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON); intel_dp_start_link_train(intel_dp); if (port != PORT_A || INTEL_GEN(dev_priv) >= 9) intel_dp_stop_link_train(intel_dp); @@ -2274,14 +2273,12 @@ static void intel_ddi_post_disable_dp(struct intel_encoder *encoder, struct drm_i915_private *dev_priv = to_i915(encoder->base.dev); struct intel_digital_port *dig_port = enc_to_dig_port(&encoder->base); struct intel_dp *intel_dp = &dig_port->dp; - bool is_mst = intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_DP_MST); /* * Power down sink before disabling the port, otherwise we end * up getting interrupts from the sink on detecting link loss. */ - if (!is_mst) - intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); + intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF); intel_disable_ddi_buf(encoder); From a01df75ce737951ad13a08d101306e88c3f57cb2 Mon Sep 17 00:00:00 2001 From: James Kelly Date: Mon, 19 Mar 2018 21:29:50 +1100 Subject: [PATCH 814/942] ASoC: ssm2602: Replace reg_default_raw with reg_default SSM2602 driver is broken on recent kernels (at least since 4.9). User space applications such as amixer or alsamixer get EIO when attempting to access codec controls via the relevant IOCTLs. Root cause of these failures is the regcache_hw_init function in drivers/base/regmap/regcache.c, which prevents regmap cache initalization from the reg_defaults_raw element of the regmap_config structure when registers are write only. It also disables the regmap cache entirely when all registers are write only or volatile as is the case for the SSM2602 driver. Using the reg_defaults element of the regmap_config structure rather than the reg_defaults_raw element to initalize the regmap cache avoids the logic in the regcache_hw_init function entirely. It also makes this driver consistent with other ASoC codec drivers, as this driver was the ONLY codec driver that used the reg_defaults_raw element to initalize the cache. Tested on Digilent Zybo Z7 development board which has a SSM2603 codec chip connected to a Xilinx Zynq SoC. Signed-off-by: James Kelly Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/codecs/ssm2602.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 9b341c23f62b..5e80867d09ef 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c @@ -54,10 +54,17 @@ struct ssm2602_priv { * using 2 wire for device control, so we cache them instead. * There is no point in caching the reset register */ -static const u16 ssm2602_reg[SSM2602_CACHEREGNUM] = { - 0x0097, 0x0097, 0x0079, 0x0079, - 0x000a, 0x0008, 0x009f, 0x000a, - 0x0000, 0x0000 +static const struct reg_default ssm2602_reg[SSM2602_CACHEREGNUM] = { + { .reg = 0x00, .def = 0x0097 }, + { .reg = 0x01, .def = 0x0097 }, + { .reg = 0x02, .def = 0x0079 }, + { .reg = 0x03, .def = 0x0079 }, + { .reg = 0x04, .def = 0x000a }, + { .reg = 0x05, .def = 0x0008 }, + { .reg = 0x06, .def = 0x009f }, + { .reg = 0x07, .def = 0x000a }, + { .reg = 0x08, .def = 0x0000 }, + { .reg = 0x09, .def = 0x0000 } }; @@ -620,8 +627,8 @@ const struct regmap_config ssm2602_regmap_config = { .volatile_reg = ssm2602_register_volatile, .cache_type = REGCACHE_RBTREE, - .reg_defaults_raw = ssm2602_reg, - .num_reg_defaults_raw = ARRAY_SIZE(ssm2602_reg), + .reg_defaults = ssm2602_reg, + .num_reg_defaults = ARRAY_SIZE(ssm2602_reg), }; EXPORT_SYMBOL_GPL(ssm2602_regmap_config); From 8153362e757a7b971aa73e7747bdc2ca2acbe84b Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 19 Mar 2018 18:07:12 +0800 Subject: [PATCH 815/942] ASoC: rt286: don't turn off HV and VREF if headset is detected "HV" and "VREF" will be powered up when jack type detection process is started and will be powered off when jack type detection process is finished. It will generate an unexpected interrupt signal when they are powered up during the capture process. Codec driver will do the jack type detection process and we can't capture properly before the jack detection process is finished. This patch will not power off the "HV" and "VREF" widgets if headset is detected and it will solve the unexpected interrupt issue. As a result, it will also solve the silence data captured at the beginning in headset mic recording issue. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt286.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c index af6325c78292..e5c9d59c3967 100644 --- a/sound/soc/codecs/rt286.c +++ b/sound/soc/codecs/rt286.c @@ -275,9 +275,10 @@ static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf); *mic = buf & 0x80000000; } - - snd_soc_dapm_disable_pin(dapm, "HV"); - snd_soc_dapm_disable_pin(dapm, "VREF"); + if (!*mic) { + snd_soc_dapm_disable_pin(dapm, "HV"); + snd_soc_dapm_disable_pin(dapm, "VREF"); + } if (!*hp) snd_soc_dapm_disable_pin(dapm, "LDO1"); snd_soc_dapm_sync(dapm); From 40d2677bdadbd221f3e398877586a30d8065140c Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Mon, 19 Mar 2018 18:07:29 +0800 Subject: [PATCH 816/942] ASoC: rt298: don't turn off HV and VREF if headset is detected "HV" and "VREF" will be powered up when jack type detection process is started and will be powered off when jack type detection process is finished. It will generate an unexpected interrupt signal when they are powered up during the capture process. Codec driver will do the jack type detection process and we can't capture properly before the jack detection process is finished. This patch will not power off the "HV" and "VREF" widgets if headset is detected and it will solve the unexpected interrupt issue. As a result, it will also solve the silence data captured at the beginning in headset mic recording issue. Signed-off-by: Bard Liao Signed-off-by: Mark Brown --- sound/soc/codecs/rt298.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/codecs/rt298.c b/sound/soc/codecs/rt298.c index ce963768449f..ff52d0365cfa 100644 --- a/sound/soc/codecs/rt298.c +++ b/sound/soc/codecs/rt298.c @@ -290,9 +290,10 @@ static int rt298_jack_detect(struct rt298_priv *rt298, bool *hp, bool *mic) regmap_read(rt298->regmap, RT298_GET_MIC1_SENSE, &buf); *mic = buf & 0x80000000; } - - snd_soc_dapm_disable_pin(dapm, "HV"); - snd_soc_dapm_disable_pin(dapm, "VREF"); + if (!*mic) { + snd_soc_dapm_disable_pin(dapm, "HV"); + snd_soc_dapm_disable_pin(dapm, "VREF"); + } if (!*hp) snd_soc_dapm_disable_pin(dapm, "LDO1"); snd_soc_dapm_sync(dapm); From 83eca9f5eda6efff71515cb9c1a373b26d2d4c5b Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Mon, 19 Mar 2018 07:50:48 +0000 Subject: [PATCH 817/942] ASoC: twl6040: remove duplicated remove callback We don't need 2 .remove callback Fixes: 7480389fb0d8 ("ASoC: twl6040: replace codec to component") Reported-by: Julia Lawall Reported-by: kbuild test robot Signed-off-by: Kuninori Morimoto Acked-by: Peter Ujfalusi Signed-off-by: Mark Brown --- sound/soc/codecs/twl6040.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index b56a6471f9c4..bfd1abd72253 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c @@ -1158,7 +1158,6 @@ static const struct snd_soc_component_driver soc_component_dev_twl6040 = { .remove = twl6040_remove, .read = twl6040_read, .write = twl6040_write, - .remove = twl6040_remove, .set_bias_level = twl6040_set_bias_level, .controls = twl6040_snd_controls, .num_controls = ARRAY_SIZE(twl6040_snd_controls), From 2399ac42e762ab25c58420e25359b2921afdc55f Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Fri, 16 Mar 2018 17:08:34 -0500 Subject: [PATCH 818/942] sysfs: symlink: export sysfs_create_link_nowarn() The sysfs_create_link_nowarn() is going to be used in phylib framework in subsequent patch which can be built as module. Hence, export sysfs_create_link_nowarn() to avoid build errors. Cc: Florian Fainelli Cc: Andrew Lunn Fixes: a3995460491d ("net: phy: Relax error checking on sysfs_create_link()") Signed-off-by: Grygorii Strashko Acked-by: Greg Kroah-Hartman Signed-off-by: David S. Miller --- fs/sysfs/symlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index 8664db25a9a6..215c225b2ca1 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c @@ -106,6 +106,7 @@ int sysfs_create_link_nowarn(struct kobject *kobj, struct kobject *target, { return sysfs_do_create_link(kobj, target, name, 0); } +EXPORT_SYMBOL_GPL(sysfs_create_link_nowarn); /** * sysfs_delete_link - remove symlink in object's directory. From 4414b3ed74be0e205e04e12cd83542a727d88255 Mon Sep 17 00:00:00 2001 From: Grygorii Strashko Date: Fri, 16 Mar 2018 17:08:35 -0500 Subject: [PATCH 819/942] net: phy: relax error checking when creating sysfs link netdev->phydev Some ethernet drivers (like TI CPSW) may connect and manage >1 Net PHYs per one netdevice, as result such drivers will produce warning during system boot and fail to connect second phy to netdevice when PHYLIB framework will try to create sysfs link netdev->phydev for second PHY in phy_attach_direct(), because sysfs link with the same name has been created already for the first PHY. As result, second CPSW external port will became unusable. Fix it by relaxing error checking when PHYLIB framework is creating sysfs link netdev->phydev in phy_attach_direct(), suppressing warning by using sysfs_create_link_nowarn() and adding error message instead. After this change links (phy->netdev and netdev->phy) creation failure is not fatal any more and system can continue working, which fixes TI CPSW issue. Cc: Florian Fainelli Cc: Andrew Lunn Fixes: a3995460491d ("net: phy: Relax error checking on sysfs_create_link()") Signed-off-by: Grygorii Strashko Signed-off-by: David S. Miller --- drivers/net/phy/phy_device.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 478405e544cc..fe16f5894092 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1012,10 +1012,17 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, err = sysfs_create_link(&phydev->mdio.dev.kobj, &dev->dev.kobj, "attached_dev"); if (!err) { - err = sysfs_create_link(&dev->dev.kobj, &phydev->mdio.dev.kobj, - "phydev"); - if (err) - goto error; + err = sysfs_create_link_nowarn(&dev->dev.kobj, + &phydev->mdio.dev.kobj, + "phydev"); + if (err) { + dev_err(&dev->dev, "could not add device link to %s err %d\n", + kobject_name(&phydev->mdio.dev.kobj), + err); + /* non-fatal - some net drivers can use one netdevice + * with more then one phy + */ + } phydev->sysfs_links = true; } From f155181d23608acd3fb46d0d6b1507b68ffa436b Mon Sep 17 00:00:00 2001 From: Akshu Agrawal Date: Mon, 19 Mar 2018 11:07:41 +0530 Subject: [PATCH 820/942] ASoC: amd: Use single dai for da7219 playback and capture BT I2S is a bi-directional dai, we will use the same cpu dai for playback and capture. TEST=aplay -D hw:0,0 -vv arecord -D hw:0,0 -f dat -d 5 -vv Signed-off-by: Akshu Agrawal Signed-off-by: Mark Brown --- sound/soc/amd/acp-da7219-max98357a.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index bbe0f103e6a8..d07c2a1d5d9e 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -124,8 +124,8 @@ static struct snd_soc_ops cz_da7219_cap_ops = { static struct snd_soc_dai_link cz_dai_7219_98357[] = { { - .name = "amd-da7219-play", - .stream_name = "Playback", + .name = "amd-da7219-play-cap", + .stream_name = "Playback and Capture", .platform_name = "acp_audio_dma.0.auto", .cpu_dai_name = "designware-i2s.3.auto", .codec_dai_name = "da7219-hifi", @@ -134,16 +134,6 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { | SND_SOC_DAIFMT_CBM_CFM, .init = cz_da7219_init, .dpcm_playback = 1, - }, - { - .name = "amd-da7219-cap", - .stream_name = "Capture", - .platform_name = "acp_audio_dma.0.auto", - .cpu_dai_name = "designware-i2s.4.auto", - .codec_dai_name = "da7219-hifi", - .codec_name = "i2c-DLGS7219:00", - .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF - | SND_SOC_DAIFMT_CBM_CFM, .dpcm_capture = 1, .ops = &cz_da7219_cap_ops, }, From c88d311533563e6dadc244930a36125d592f5ec5 Mon Sep 17 00:00:00 2001 From: Akshu Agrawal Date: Mon, 19 Mar 2018 11:07:42 +0530 Subject: [PATCH 821/942] ASoC: amd: Enable da7219 master clock using common clock framework DA7219 is clock master for other codecs. DA7219 has exposed clock control by using common clock framework and same is used to enable and disable clock for all codecs in the system. TEST=aplay -D hw:0,0 -vv arecord -D hw:0,0 -f dat -d 5 -vv aplay -D hw:0,1 -vv Signed-off-by: Akshu Agrawal Signed-off-by: Mark Brown --- sound/soc/amd/acp-da7219-max98357a.c | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index d07c2a1d5d9e..99c6b5ce5c6c 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -42,11 +43,13 @@ #define DUAL_CHANNEL 2 static struct snd_soc_jack cz_jack; +struct clk *da7219_dai_clk; static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_card *card = rtd->card; + struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_component *component = codec_dai->component; @@ -66,6 +69,8 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) return ret; } + da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks"); + ret = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | @@ -81,6 +86,28 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) return 0; } +static int cz_da7219_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + int ret = 0; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + + ret = clk_prepare_enable(da7219_dai_clk); + if (ret < 0) { + dev_err(rtd->dev, "can't enable master clock %d\n", ret); + return ret; + } + + return ret; +} + +static int cz_da7219_hw_free(struct snd_pcm_substream *substream) +{ + clk_disable_unprepare(da7219_dai_clk); + + return 0; +} + static const unsigned int channels[] = { DUAL_CHANNEL, }; @@ -119,9 +146,21 @@ static int cz_fe_startup(struct snd_pcm_substream *substream) } static struct snd_soc_ops cz_da7219_cap_ops = { + .hw_params = cz_da7219_hw_params, + .hw_free = cz_da7219_hw_free, .startup = cz_fe_startup, }; +static struct snd_soc_ops cz_max_play_ops = { + .hw_params = cz_da7219_hw_params, + .hw_free = cz_da7219_hw_free, +}; + +static struct snd_soc_ops cz_dmic_cap_ops = { + .hw_params = cz_da7219_hw_params, + .hw_free = cz_da7219_hw_free, +}; + static struct snd_soc_dai_link cz_dai_7219_98357[] = { { .name = "amd-da7219-play-cap", @@ -147,6 +186,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM, .dpcm_playback = 1, + .ops = &cz_max_play_ops, }, { .name = "dmic", @@ -158,6 +198,7 @@ static struct snd_soc_dai_link cz_dai_7219_98357[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM, .dpcm_capture = 1, + .ops = &cz_dmic_cap_ops, }, }; From e3d03598e8ae7d195af5d3d049596dec336f569f Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 19 Mar 2018 13:57:46 -0700 Subject: [PATCH 822/942] x86/build/64: Force the linker to use 2MB page size Binutils 2.31 will enable -z separate-code by default for x86 to avoid mixing code pages with data to improve cache performance as well as security. To reduce x86-64 executable and shared object sizes, the maximum page size is reduced from 2MB to 4KB. But x86-64 kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to linker to force 2MB page size regardless of the default page size used by linker. Tested with Linux kernel 4.15.6 on x86-64. Signed-off-by: H.J. Lu Cc: Andy Shevchenko Cc: Eric Biederman Cc: H. Peter Anvin Cc: Juergen Gross Cc: Kees Cook Cc: Kirill A. Shutemov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/CAMe9rOp4_%3D_8twdpTyAP2DhONOCeaTOsniJLoppzhoNptL8xzA@mail.gmail.com Signed-off-by: Ingo Molnar --- arch/x86/Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 498c1b812300..1c4d012550ec 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -223,6 +223,15 @@ KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) LDFLAGS := -m elf_$(UTS_MACHINE) +# +# The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to +# the linker to force 2MB page size regardless of the default page size used +# by the linker. +# +ifdef CONFIG_X86_64 +LDFLAGS += $(call ld-option, -z max-page-size=0x200000) +endif + # Speed up the build KBUILD_CFLAGS += -pipe # Workaround for a gcc prelease that unfortunately was shipped in a suse release From c55b8550fa57ba4f5e507be406ff9fc2845713e8 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 19 Mar 2018 14:08:11 -0700 Subject: [PATCH 823/942] x86/boot/64: Verify alignment of the LOAD segment Since the x86-64 kernel must be aligned to 2MB, refuse to boot the kernel if the alignment of the LOAD segment isn't a multiple of 2MB. Signed-off-by: H.J. Lu Cc: Andy Shevchenko Cc: Eric Biederman Cc: H. Peter Anvin Cc: Juergen Gross Cc: Kees Cook Cc: Kirill A. Shutemov Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/CAMe9rOrR7xSJgUfiCoZLuqWUwymRxXPoGBW38%2BpN%3D9g%2ByKNhZw@mail.gmail.com Signed-off-by: Ingo Molnar --- arch/x86/boot/compressed/misc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 98761a1576ce..252fee320816 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -309,6 +309,10 @@ static void parse_elf(void *output) switch (phdr->p_type) { case PT_LOAD: +#ifdef CONFIG_X86_64 + if ((phdr->p_align % 0x200000) != 0) + error("Alignment of LOAD segment isn't multiple of 2MB"); +#endif #ifdef CONFIG_RELOCATABLE dest = output; dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR); From 45dbac0e288350f9a4226a5b4b651ed434dd9f85 Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Thu, 15 Mar 2018 04:58:12 -0700 Subject: [PATCH 824/942] locking/mutex: Improve documentation On Wed, Mar 14, 2018 at 01:56:31PM -0700, Andrew Morton wrote: > My memory is weak and our documentation is awful. What does > mutex_lock_killable() actually do and how does it differ from > mutex_lock_interruptible()? Add kernel-doc for mutex_lock_killable() and mutex_lock_io(). Reword the kernel-doc for mutex_lock_interruptible(). Signed-off-by: Matthew Wilcox Signed-off-by: Peter Zijlstra (Intel) Cc: Andrew Morton Cc: Jonathan Corbet Cc: Kirill Tkhai Cc: Linus Torvalds Cc: Mauro Carvalho Chehab Cc: Paul E. McKenney Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: cl@linux.com Cc: tj@kernel.org Link: http://lkml.kernel.org/r/20180315115812.GA9949@bombadil.infradead.org Signed-off-by: Ingo Molnar --- kernel/locking/mutex.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index 858a07590e39..2048359f33d2 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c @@ -1082,15 +1082,16 @@ static noinline int __sched __mutex_lock_interruptible_slowpath(struct mutex *lock); /** - * mutex_lock_interruptible - acquire the mutex, interruptible - * @lock: the mutex to be acquired + * mutex_lock_interruptible() - Acquire the mutex, interruptible by signals. + * @lock: The mutex to be acquired. * - * Lock the mutex like mutex_lock(), and return 0 if the mutex has - * been acquired or sleep until the mutex becomes available. If a - * signal arrives while waiting for the lock then this function - * returns -EINTR. + * Lock the mutex like mutex_lock(). If a signal is delivered while the + * process is sleeping, this function will return without acquiring the + * mutex. * - * This function is similar to (but not equivalent to) down_interruptible(). + * Context: Process context. + * Return: 0 if the lock was successfully acquired or %-EINTR if a + * signal arrived. */ int __sched mutex_lock_interruptible(struct mutex *lock) { @@ -1104,6 +1105,18 @@ int __sched mutex_lock_interruptible(struct mutex *lock) EXPORT_SYMBOL(mutex_lock_interruptible); +/** + * mutex_lock_killable() - Acquire the mutex, interruptible by fatal signals. + * @lock: The mutex to be acquired. + * + * Lock the mutex like mutex_lock(). If a signal which will be fatal to + * the current process is delivered while the process is sleeping, this + * function will return without acquiring the mutex. + * + * Context: Process context. + * Return: 0 if the lock was successfully acquired or %-EINTR if a + * fatal signal arrived. + */ int __sched mutex_lock_killable(struct mutex *lock) { might_sleep(); @@ -1115,6 +1128,16 @@ int __sched mutex_lock_killable(struct mutex *lock) } EXPORT_SYMBOL(mutex_lock_killable); +/** + * mutex_lock_io() - Acquire the mutex and mark the process as waiting for I/O + * @lock: The mutex to be acquired. + * + * Lock the mutex like mutex_lock(). While the task is waiting for this + * mutex, it will be accounted as being in the IO wait state by the + * scheduler. + * + * Context: Process context. + */ void __sched mutex_lock_io(struct mutex *lock) { int token; From 2c2a9bbe7fecb2ad4981b6f4a56cacbfb849f848 Mon Sep 17 00:00:00 2001 From: Kan Liang Date: Mon, 12 Feb 2018 14:20:35 -0800 Subject: [PATCH 825/942] perf/x86/intel: Disable userspace RDPMC usage for large PEBS Userspace RDPMC cannot possibly work for large PEBS, which was introduced in: b8241d20699e ("perf/x86/intel: Implement batched PEBS interrupt handling (large PEBS interrupt threshold)") When the PEBS interrupt threshold is larger than one, there is no way to get exact auto-reload times and value for userspace RDPMC. Disable the userspace RDPMC usage when large PEBS is enabled. The only exception is when the PEBS interrupt threshold is 1, in which case user-space RDPMC works well even with auto-reload events. Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: acme@kernel.org Fixes: b8241d20699e ("perf/x86/intel: Implement batched PEBS interrupt handling (large PEBS interrupt threshold)") Link: http://lkml.kernel.org/r/1518474035-21006-6-git-send-email-kan.liang@linux.intel.com Signed-off-by: Ingo Molnar (cherry picked from commit 1af22eba248efe2de25658041a80a3d40fb3e92e) --- arch/x86/events/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 140d33288e78..3d24edfef3e4 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2118,7 +2118,8 @@ static int x86_pmu_event_init(struct perf_event *event) event->destroy(event); } - if (READ_ONCE(x86_pmu.attr_rdpmc)) + if (READ_ONCE(x86_pmu.attr_rdpmc) && + !(event->hw.flags & PERF_X86_EVENT_FREERUNNING)) event->hw.flags |= PERF_X86_EVENT_RDPMC_ALLOWED; return err; From e5ea9b54a055619160bbfe527ebb7d7191823d66 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Sat, 17 Mar 2018 14:52:16 +0300 Subject: [PATCH 826/942] perf/x86/intel: Don't accidentally clear high bits in bdw_limit_period() We intended to clear the lowest 6 bits but because of a type bug we clear the high 32 bits as well. Andi says that periods are rarely more than U32_MAX so this bug probably doesn't have a huge runtime impact. Signed-off-by: Dan Carpenter Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: H. Peter Anvin Cc: Jiri Olsa Cc: Kan Liang Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Sebastian Andrzej Siewior Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Fixes: 294fe0f52a44 ("perf/x86/intel: Add INST_RETIRED.ALL workarounds") Link: http://lkml.kernel.org/r/20180317115216.GB4035@mwanda Signed-off-by: Ingo Molnar --- arch/x86/events/intel/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 56457cb73448..9b18a227fff7 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3194,7 +3194,7 @@ static unsigned bdw_limit_period(struct perf_event *event, unsigned left) X86_CONFIG(.event=0xc0, .umask=0x01)) { if (left < 128) left = 128; - left &= ~0x3fu; + left &= ~0x3fULL; } return left; } From e340895c9ed0b44548f08bbaaee4afc7bfacd354 Mon Sep 17 00:00:00 2001 From: Stephane Eranian Date: Mon, 12 Mar 2018 08:41:34 -0700 Subject: [PATCH 827/942] perf/x86/intel/uncore: Add missing filter constraint for SKX CHA event Adding a filter constraint for Intel Skylake CHA event UNC_CHA_UPI_CREDITS_ACQUIRED (0x38). The event supports core-id/thread-id and link filtering. Signed-off-by: Stephane Eranian Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Vince Weaver Link: http://lkml.kernel.org/r/1520869294-14176-1-git-send-email-kan.liang@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/events/intel/uncore_snbep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 22ec65bc033a..0876798f2ac9 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3343,6 +3343,7 @@ static struct extra_reg skx_uncore_cha_extra_regs[] = { SNBEP_CBO_EVENT_EXTRA_REG(0x9134, 0xffff, 0x4), SNBEP_CBO_EVENT_EXTRA_REG(0x35, 0xff, 0x8), SNBEP_CBO_EVENT_EXTRA_REG(0x36, 0xff, 0x8), + SNBEP_CBO_EVENT_EXTRA_REG(0x38, 0xff, 0x3), EVENT_EXTRA_END }; From 578ae447e7e5d78c90ac40a06406c1741f79ba96 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Mon, 19 Mar 2018 13:18:57 -0500 Subject: [PATCH 828/942] jump_label: Disable jump labels in __exit code With the following commit: 333522447063 ("jump_label: Explicitly disable jump labels in __init code") ... we explicitly disabled jump labels in __init code, so they could be detected and not warned about in the following commit: dc1dd184c2f0 ("jump_label: Warn on failed jump_label patching attempt") In-kernel __exit code has the same issue. It's never used, so it's freed along with the rest of initmem. But jump label entries in __exit code aren't explicitly disabled, so we get the following warning when enabling pr_debug() in __exit code: can't patch jump_label at dmi_sysfs_exit+0x0/0x2d WARNING: CPU: 0 PID: 22572 at kernel/jump_label.c:376 __jump_label_update+0x9d/0xb0 Fix the warning by disabling all jump labels in initmem (which includes both __init and __exit code). Reported-and-tested-by: Li Wang Signed-off-by: Josh Poimboeuf Cc: Borislav Petkov Cc: Jason Baron Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: dc1dd184c2f0 ("jump_label: Warn on failed jump_label patching attempt") Link: http://lkml.kernel.org/r/7121e6e595374f06616c505b6e690e275c0054d1.1521483452.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar --- include/linux/jump_label.h | 4 ++-- init/main.c | 2 +- kernel/jump_label.c | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/include/linux/jump_label.h b/include/linux/jump_label.h index 2168cc6b8b30..b46b541c67c4 100644 --- a/include/linux/jump_label.h +++ b/include/linux/jump_label.h @@ -151,7 +151,7 @@ extern struct jump_entry __start___jump_table[]; extern struct jump_entry __stop___jump_table[]; extern void jump_label_init(void); -extern void jump_label_invalidate_init(void); +extern void jump_label_invalidate_initmem(void); extern void jump_label_lock(void); extern void jump_label_unlock(void); extern void arch_jump_label_transform(struct jump_entry *entry, @@ -199,7 +199,7 @@ static __always_inline void jump_label_init(void) static_key_initialized = true; } -static inline void jump_label_invalidate_init(void) {} +static inline void jump_label_invalidate_initmem(void) {} static __always_inline bool static_key_false(struct static_key *key) { diff --git a/init/main.c b/init/main.c index 969eaf140ef0..21efbf6ace93 100644 --- a/init/main.c +++ b/init/main.c @@ -1001,7 +1001,7 @@ static int __ref kernel_init(void *unused) /* need to finish all async __init code before freeing the memory */ async_synchronize_full(); ftrace_free_init_mem(); - jump_label_invalidate_init(); + jump_label_invalidate_initmem(); free_initmem(); mark_readonly(); system_state = SYSTEM_RUNNING; diff --git a/kernel/jump_label.c b/kernel/jump_label.c index e7214093dcd1..01ebdf1f9f40 100644 --- a/kernel/jump_label.c +++ b/kernel/jump_label.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef HAVE_JUMP_LABEL @@ -421,15 +422,15 @@ void __init jump_label_init(void) cpus_read_unlock(); } -/* Disable any jump label entries in __init code */ -void __init jump_label_invalidate_init(void) +/* Disable any jump label entries in __init/__exit code */ +void __init jump_label_invalidate_initmem(void) { struct jump_entry *iter_start = __start___jump_table; struct jump_entry *iter_stop = __stop___jump_table; struct jump_entry *iter; for (iter = iter_start; iter < iter_stop; iter++) { - if (init_kernel_text(iter->code)) + if (init_section_contains((void *)(unsigned long)iter->code, 1)) iter->code = 0; } } From 174afc3e7dd7823df8218e16e7768b834097184e Mon Sep 17 00:00:00 2001 From: Kan Liang Date: Mon, 12 Mar 2018 10:45:37 -0400 Subject: [PATCH 829/942] perf/x86/intel: Rename confusing 'freerunning PEBS' API and implementation to 'large PEBS' The 'freerunning PEBS' and 'large PEBS' are the same thing. Both of these names appear in the code and in the API, which causes confusion. Rename 'freerunning PEBS' to 'large PEBS' to unify the code, which eliminates the confusion. No functional change. Reported-by: Vince Weaver Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1520865937-22910-1-git-send-email-kan.liang@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/events/core.c | 2 +- arch/x86/events/intel/core.c | 12 ++++++------ arch/x86/events/intel/ds.c | 6 +++--- arch/x86/events/perf_event.h | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 3d24edfef3e4..88797c80b3e0 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -2119,7 +2119,7 @@ static int x86_pmu_event_init(struct perf_event *event) } if (READ_ONCE(x86_pmu.attr_rdpmc) && - !(event->hw.flags & PERF_X86_EVENT_FREERUNNING)) + !(event->hw.flags & PERF_X86_EVENT_LARGE_PEBS)) event->hw.flags |= PERF_X86_EVENT_RDPMC_ALLOWED; return err; diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index 9b18a227fff7..1e41d7508d99 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -2952,9 +2952,9 @@ static void intel_pebs_aliases_skl(struct perf_event *event) return intel_pebs_aliases_precdist(event); } -static unsigned long intel_pmu_free_running_flags(struct perf_event *event) +static unsigned long intel_pmu_large_pebs_flags(struct perf_event *event) { - unsigned long flags = x86_pmu.free_running_flags; + unsigned long flags = x86_pmu.large_pebs_flags; if (event->attr.use_clockid) flags &= ~PERF_SAMPLE_TIME; @@ -2976,8 +2976,8 @@ static int intel_pmu_hw_config(struct perf_event *event) if (!event->attr.freq) { event->hw.flags |= PERF_X86_EVENT_AUTO_RELOAD; if (!(event->attr.sample_type & - ~intel_pmu_free_running_flags(event))) - event->hw.flags |= PERF_X86_EVENT_FREERUNNING; + ~intel_pmu_large_pebs_flags(event))) + event->hw.flags |= PERF_X86_EVENT_LARGE_PEBS; } if (x86_pmu.pebs_aliases) x86_pmu.pebs_aliases(event); @@ -3460,7 +3460,7 @@ static __initconst const struct x86_pmu core_pmu = { .event_map = intel_pmu_event_map, .max_events = ARRAY_SIZE(intel_perfmon_event_map), .apic = 1, - .free_running_flags = PEBS_FREERUNNING_FLAGS, + .large_pebs_flags = LARGE_PEBS_FLAGS, /* * Intel PMCs cannot be accessed sanely above 32-bit width, @@ -3502,7 +3502,7 @@ static __initconst const struct x86_pmu intel_pmu = { .event_map = intel_pmu_event_map, .max_events = ARRAY_SIZE(intel_perfmon_event_map), .apic = 1, - .free_running_flags = PEBS_FREERUNNING_FLAGS, + .large_pebs_flags = LARGE_PEBS_FLAGS, /* * Intel PMCs cannot be accessed sanely above 32 bit width, * so we install an artificial 1<<31 period regardless of diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c index 18c25ab28557..d8015235ba76 100644 --- a/arch/x86/events/intel/ds.c +++ b/arch/x86/events/intel/ds.c @@ -935,7 +935,7 @@ void intel_pmu_pebs_add(struct perf_event *event) bool needed_cb = pebs_needs_sched_cb(cpuc); cpuc->n_pebs++; - if (hwc->flags & PERF_X86_EVENT_FREERUNNING) + if (hwc->flags & PERF_X86_EVENT_LARGE_PEBS) cpuc->n_large_pebs++; pebs_update_state(needed_cb, cpuc, event->ctx->pmu); @@ -975,7 +975,7 @@ void intel_pmu_pebs_del(struct perf_event *event) bool needed_cb = pebs_needs_sched_cb(cpuc); cpuc->n_pebs--; - if (hwc->flags & PERF_X86_EVENT_FREERUNNING) + if (hwc->flags & PERF_X86_EVENT_LARGE_PEBS) cpuc->n_large_pebs--; pebs_update_state(needed_cb, cpuc, event->ctx->pmu); @@ -1530,7 +1530,7 @@ void __init intel_ds_init(void) x86_pmu.pebs_record_size = sizeof(struct pebs_record_skl); x86_pmu.drain_pebs = intel_pmu_drain_pebs_nhm; - x86_pmu.free_running_flags |= PERF_SAMPLE_TIME; + x86_pmu.large_pebs_flags |= PERF_SAMPLE_TIME; break; default: diff --git a/arch/x86/events/perf_event.h b/arch/x86/events/perf_event.h index 78f91ec1056e..39cd0615f04f 100644 --- a/arch/x86/events/perf_event.h +++ b/arch/x86/events/perf_event.h @@ -69,7 +69,7 @@ struct event_constraint { #define PERF_X86_EVENT_RDPMC_ALLOWED 0x0100 /* grant rdpmc permission */ #define PERF_X86_EVENT_EXCL_ACCT 0x0200 /* accounted EXCL event */ #define PERF_X86_EVENT_AUTO_RELOAD 0x0400 /* use PEBS auto-reload */ -#define PERF_X86_EVENT_FREERUNNING 0x0800 /* use freerunning PEBS */ +#define PERF_X86_EVENT_LARGE_PEBS 0x0800 /* use large PEBS */ struct amd_nb { @@ -88,7 +88,7 @@ struct amd_nb { * REGS_USER can be handled for events limited to ring 3. * */ -#define PEBS_FREERUNNING_FLAGS \ +#define LARGE_PEBS_FLAGS \ (PERF_SAMPLE_IP | PERF_SAMPLE_TID | PERF_SAMPLE_ADDR | \ PERF_SAMPLE_ID | PERF_SAMPLE_CPU | PERF_SAMPLE_STREAM_ID | \ PERF_SAMPLE_DATA_SRC | PERF_SAMPLE_IDENTIFIER | \ @@ -608,7 +608,7 @@ struct x86_pmu { struct event_constraint *pebs_constraints; void (*pebs_aliases)(struct perf_event *event); int max_pebs_events; - unsigned long free_running_flags; + unsigned long large_pebs_flags; /* * Intel LBR From 320b0651f32b830add6497fcdcfdcb6ae8c7b8a0 Mon Sep 17 00:00:00 2001 From: Kan Liang Date: Tue, 13 Mar 2018 11:51:34 -0700 Subject: [PATCH 830/942] perf/x86/intel/uncore: Fix multi-domain PCI CHA enumeration bug on Skylake servers The number of CHAs is miscalculated on multi-domain PCI Skylake server systems, resulting in an uncore driver initialization error. Gary Kroening explains: "For systems with a single PCI segment, it is sufficient to look for the bus number to change in order to determine that all of the CHa's have been counted for a single socket. However, for multi PCI segment systems, each socket is given a new segment and the bus number does NOT change. So looking only for the bus number to change ends up counting all of the CHa's on all sockets in the system. This leads to writing CPU MSRs beyond a valid range and causes an error in ivbep_uncore_msr_init_box()." To fix this bug, query the number of CHAs from the CAPID6 register: it should read bits 27:0 in the CAPID6 register located at Device 30, Function 3, Offset 0x9C. These 28 bits form a bit vector of available LLC slices and the CHAs that manage those slices. Reported-by: Kroening, Gary Tested-by: Kroening, Gary Signed-off-by: Kan Liang Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Andy Shevchenko Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Cc: abanman@hpe.com Cc: dimitri.sivanich@hpe.com Cc: hpa@zytor.com Cc: mike.travis@hpe.com Cc: russ.anderson@hpe.com Fixes: cd34cd97b7b4 ("perf/x86/intel/uncore: Add Skylake server uncore support") Link: http://lkml.kernel.org/r/1520967094-13219-1-git-send-email-kan.liang@linux.intel.com Signed-off-by: Ingo Molnar --- arch/x86/events/intel/uncore_snbep.c | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c index 0876798f2ac9..c98b943e58b4 100644 --- a/arch/x86/events/intel/uncore_snbep.c +++ b/arch/x86/events/intel/uncore_snbep.c @@ -3563,24 +3563,27 @@ static struct intel_uncore_type *skx_msr_uncores[] = { NULL, }; +/* + * To determine the number of CHAs, it should read bits 27:0 in the CAPID6 + * register which located at Device 30, Function 3, Offset 0x9C. PCI ID 0x2083. + */ +#define SKX_CAPID6 0x9c +#define SKX_CHA_BIT_MASK GENMASK(27, 0) + static int skx_count_chabox(void) { - struct pci_dev *chabox_dev = NULL; - int bus, count = 0; + struct pci_dev *dev = NULL; + u32 val = 0; - while (1) { - chabox_dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x208d, chabox_dev); - if (!chabox_dev) - break; - if (count == 0) - bus = chabox_dev->bus->number; - if (bus != chabox_dev->bus->number) - break; - count++; - } + dev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2083, dev); + if (!dev) + goto out; - pci_dev_put(chabox_dev); - return count; + pci_read_config_dword(dev, SKX_CAPID6, &val); + val &= SKX_CHA_BIT_MASK; +out: + pci_dev_put(dev); + return hweight32(val); } void skx_uncore_cpu_init(void) From c917e0f259908e75bd2a65877e25f9d90c22c848 Mon Sep 17 00:00:00 2001 From: Song Liu Date: Mon, 12 Mar 2018 09:59:43 -0700 Subject: [PATCH 831/942] perf/cgroup: Fix child event counting bug When a perf_event is attached to parent cgroup, it should count events for all children cgroups: parent_group <---- perf_event \ - child_group <---- process(es) However, in our tests, we found this perf_event cannot report reliable results. Here is an example case: # create cgroups mkdir -p /sys/fs/cgroup/p/c # start perf for parent group perf stat -e instructions -G "p" # on another console, run test process in child cgroup: stressapptest -s 2 -M 1000 & echo $! > /sys/fs/cgroup/p/c/cgroup.procs # after the test process is done, stop perf in the first console shows instructions p The instruction should not be "not counted" as the process runs in the child cgroup. We found this is because perf_event->cgrp and cpuctx->cgrp are not identical, thus perf_event->cgrp are not updated properly. This patch fixes this by updating perf_cgroup properly for ancestor cgroup(s). Reported-by: Ephraim Park Signed-off-by: Song Liu Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Cc: Alexander Shishkin Cc: Arnaldo Carvalho de Melo Cc: Jiri Olsa Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Thomas Gleixner Cc: Vince Weaver Link: http://lkml.kernel.org/r/20180312165943.1057894-1-songliubraving@fb.com Signed-off-by: Ingo Molnar --- kernel/events/core.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/events/core.c b/kernel/events/core.c index 4b838470fac4..709a55b9ad97 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -724,9 +724,15 @@ static inline void __update_cgrp_time(struct perf_cgroup *cgrp) static inline void update_cgrp_time_from_cpuctx(struct perf_cpu_context *cpuctx) { - struct perf_cgroup *cgrp_out = cpuctx->cgrp; - if (cgrp_out) - __update_cgrp_time(cgrp_out); + struct perf_cgroup *cgrp = cpuctx->cgrp; + struct cgroup_subsys_state *css; + + if (cgrp) { + for (css = &cgrp->css; css; css = css->parent) { + cgrp = container_of(css, struct perf_cgroup, css); + __update_cgrp_time(cgrp); + } + } } static inline void update_cgrp_time_from_event(struct perf_event *event) @@ -754,6 +760,7 @@ perf_cgroup_set_timestamp(struct task_struct *task, { struct perf_cgroup *cgrp; struct perf_cgroup_info *info; + struct cgroup_subsys_state *css; /* * ctx->lock held by caller @@ -764,8 +771,12 @@ perf_cgroup_set_timestamp(struct task_struct *task, return; cgrp = perf_cgroup_from_task(task, ctx); - info = this_cpu_ptr(cgrp->info); - info->timestamp = ctx->timestamp; + + for (css = &cgrp->css; css; css = css->parent) { + cgrp = container_of(css, struct perf_cgroup, css); + info = this_cpu_ptr(cgrp->info); + info->timestamp = ctx->timestamp; + } } static DEFINE_PER_CPU(struct list_head, cgrp_cpuctx_list); From a8c024cd9b9683d25ae1f459525dd2c6bec75e79 Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Mon, 19 Mar 2018 14:35:54 -0400 Subject: [PATCH 832/942] sched/debug: Fix per-task line continuation for console output When the SEQ_printf() macro prints to the console, it runs a simple printk() without KERN_CONT "continued" line printing. The result of this is oddly wrapped task info, for example: % echo t > /proc/sysrq-trigger % dmesg ... runnable tasks: ... [ 29.608611] I [ 29.608613] rcu_sched 8 3252.013846 4087 120 [ 29.608614] 0.000000 29.090111 0.000000 [ 29.608615] 0 0 [ 29.608616] / Modify SEQ_printf to use pr_cont() for expected one-line results: % echo t > /proc/sysrq-trigger % dmesg ... runnable tasks: ... [ 106.716329] S cpuhp/5 37 2006.315026 14 120 0.000000 0.496893 0.000000 0 0 / Signed-off-by: Joe Lawrence Acked-by: Peter Zijlstra Cc: Linus Torvalds Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1521484555-8620-2-git-send-email-joe.lawrence@redhat.com Signed-off-by: Ingo Molnar --- kernel/sched/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 1ca0130ed4f9..50026aa2d81e 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -32,7 +32,7 @@ static DEFINE_SPINLOCK(sched_debug_lock); if (m) \ seq_printf(m, x); \ else \ - printk(x); \ + pr_cont(x); \ } while (0) /* From e9ca267096674eadd1fd479279bcb58df1486049 Mon Sep 17 00:00:00 2001 From: Joe Lawrence Date: Mon, 19 Mar 2018 14:35:55 -0400 Subject: [PATCH 833/942] sched/debug: Adjust newlines for better alignment Scheduler debug stats include newlines that display out of alignment when prefixed by timestamps. For example, the dmesg utility: % echo t > /proc/sysrq-trigger % dmesg ... [ 83.124251] runnable tasks: S task PID tree-key switches prio wait-time sum-exec sum-sleep ----------------------------------------------------------------------------------------------------------- At the same time, some syslog utilities (like rsyslog by default) don't like the additional newlines control characters, saving lines like this to /var/log/messages: Mar 16 16:02:29 localhost kernel: #012runnable tasks:#012 S task PID tree-key ... ^^^^ ^^^^ Clean these up by moving newline characters to their own SEQ_printf invocation. This leaves the /proc/sched_debug unchanged, but brings the entire output into alignment when prefixed: % echo t > /proc/sysrq-trigger % dmesg ... [ 62.410368] runnable tasks: [ 62.410368] S task PID tree-key switches prio wait-time sum-exec sum-sleep [ 62.410369] ----------------------------------------------------------------------------------------------------------- [ 62.410369] I kworker/u12:0 5 1932.215593 332 120 0.000000 3.621252 0.000000 0 0 / and no escaped control characters from rsyslog in /var/log/messages: Mar 16 16:15:06 localhost kernel: runnable tasks: Mar 16 16:15:06 localhost kernel: S task PID tree-key ... Signed-off-by: Joe Lawrence Acked-by: Peter Zijlstra Cc: Linus Torvalds Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1521484555-8620-3-git-send-email-joe.lawrence@redhat.com Signed-off-by: Ingo Molnar --- kernel/sched/debug.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 50026aa2d81e..72c401b3b15c 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -501,12 +501,12 @@ static void print_rq(struct seq_file *m, struct rq *rq, int rq_cpu) { struct task_struct *g, *p; - SEQ_printf(m, - "\nrunnable tasks:\n" - " S task PID tree-key switches prio" - " wait-time sum-exec sum-sleep\n" - "-------------------------------------------------------" - "----------------------------------------------------\n"); + SEQ_printf(m, "\n"); + SEQ_printf(m, "runnable tasks:\n"); + SEQ_printf(m, " S task PID tree-key switches prio" + " wait-time sum-exec sum-sleep\n"); + SEQ_printf(m, "-------------------------------------------------------" + "----------------------------------------------------\n"); rcu_read_lock(); for_each_process_thread(g, p) { @@ -527,9 +527,11 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) unsigned long flags; #ifdef CONFIG_FAIR_GROUP_SCHED - SEQ_printf(m, "\ncfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg)); + SEQ_printf(m, "\n"); + SEQ_printf(m, "cfs_rq[%d]:%s\n", cpu, task_group_path(cfs_rq->tg)); #else - SEQ_printf(m, "\ncfs_rq[%d]:\n", cpu); + SEQ_printf(m, "\n"); + SEQ_printf(m, "cfs_rq[%d]:\n", cpu); #endif SEQ_printf(m, " .%-30s: %Ld.%06ld\n", "exec_clock", SPLIT_NS(cfs_rq->exec_clock)); @@ -595,9 +597,11 @@ void print_cfs_rq(struct seq_file *m, int cpu, struct cfs_rq *cfs_rq) void print_rt_rq(struct seq_file *m, int cpu, struct rt_rq *rt_rq) { #ifdef CONFIG_RT_GROUP_SCHED - SEQ_printf(m, "\nrt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg)); + SEQ_printf(m, "\n"); + SEQ_printf(m, "rt_rq[%d]:%s\n", cpu, task_group_path(rt_rq->tg)); #else - SEQ_printf(m, "\nrt_rq[%d]:\n", cpu); + SEQ_printf(m, "\n"); + SEQ_printf(m, "rt_rq[%d]:\n", cpu); #endif #define P(x) \ @@ -624,7 +628,8 @@ void print_dl_rq(struct seq_file *m, int cpu, struct dl_rq *dl_rq) { struct dl_bw *dl_bw; - SEQ_printf(m, "\ndl_rq[%d]:\n", cpu); + SEQ_printf(m, "\n"); + SEQ_printf(m, "dl_rq[%d]:\n", cpu); #define PU(x) \ SEQ_printf(m, " .%-30s: %lu\n", #x, (unsigned long)(dl_rq->x)) From 5927145efd5de71976e62e2822511b13014d7e56 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 19 Mar 2018 11:38:13 +0100 Subject: [PATCH 834/942] x86/cpu: Remove the CONFIG_X86_PPRO_FENCE=y quirk There were only a few Pentium Pro multiprocessors systems where this errata applied. They are more than 20 years old now, and we've slowly dropped places which put the workarounds in and discouraged anyone from enabling the workaround. Get rid of it for good. Tested-by: Tom Lendacky Signed-off-by: Christoph Hellwig Reviewed-by: Thomas Gleixner Reviewed-by: Konrad Rzeszutek Wilk Cc: David Woodhouse Cc: Joerg Roedel Cc: Jon Mason Cc: Linus Torvalds Cc: Muli Ben-Yehuda Cc: Peter Zijlstra Cc: iommu@lists.linux-foundation.org Link: http://lkml.kernel.org/r/20180319103826.12853-2-hch@lst.de Signed-off-by: Ingo Molnar --- arch/x86/Kconfig.cpu | 13 --------- arch/x86/entry/vdso/vdso32/vclock_gettime.c | 2 -- arch/x86/include/asm/barrier.h | 30 --------------------- arch/x86/include/asm/io.h | 15 ----------- arch/x86/kernel/pci-nommu.c | 19 ------------- arch/x86/um/asm/barrier.h | 4 --- 6 files changed, 83 deletions(-) diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu index 65a9a4716e34..f0c5ef578153 100644 --- a/arch/x86/Kconfig.cpu +++ b/arch/x86/Kconfig.cpu @@ -315,19 +315,6 @@ config X86_L1_CACHE_SHIFT default "4" if MELAN || M486 || MGEODEGX1 default "5" if MWINCHIP3D || MWINCHIPC6 || MCRUSOE || MEFFICEON || MCYRIXIII || MK6 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || MVIAC3_2 || MGEODE_LX -config X86_PPRO_FENCE - bool "PentiumPro memory ordering errata workaround" - depends on M686 || M586MMX || M586TSC || M586 || M486 || MGEODEGX1 - ---help--- - Old PentiumPro multiprocessor systems had errata that could cause - memory operations to violate the x86 ordering standard in rare cases. - Enabling this option will attempt to work around some (but not all) - occurrences of this problem, at the cost of much heavier spinlock and - memory barrier operations. - - If unsure, say n here. Even distro kernels should think twice before - enabling this: there are few systems, and an unlikely bug. - config X86_F00F_BUG def_bool y depends on M586MMX || M586TSC || M586 || M486 diff --git a/arch/x86/entry/vdso/vdso32/vclock_gettime.c b/arch/x86/entry/vdso/vdso32/vclock_gettime.c index 7780bbfb06ef..9242b28418d5 100644 --- a/arch/x86/entry/vdso/vdso32/vclock_gettime.c +++ b/arch/x86/entry/vdso/vdso32/vclock_gettime.c @@ -5,8 +5,6 @@ #undef CONFIG_OPTIMIZE_INLINING #endif -#undef CONFIG_X86_PPRO_FENCE - #ifdef CONFIG_X86_64 /* diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h index e1259f043ae9..042b5e892ed1 100644 --- a/arch/x86/include/asm/barrier.h +++ b/arch/x86/include/asm/barrier.h @@ -52,11 +52,7 @@ static inline unsigned long array_index_mask_nospec(unsigned long index, #define barrier_nospec() alternative_2("", "mfence", X86_FEATURE_MFENCE_RDTSC, \ "lfence", X86_FEATURE_LFENCE_RDTSC) -#ifdef CONFIG_X86_PPRO_FENCE -#define dma_rmb() rmb() -#else #define dma_rmb() barrier() -#endif #define dma_wmb() barrier() #ifdef CONFIG_X86_32 @@ -68,30 +64,6 @@ static inline unsigned long array_index_mask_nospec(unsigned long index, #define __smp_wmb() barrier() #define __smp_store_mb(var, value) do { (void)xchg(&var, value); } while (0) -#if defined(CONFIG_X86_PPRO_FENCE) - -/* - * For this option x86 doesn't have a strong TSO memory - * model and we should fall back to full barriers. - */ - -#define __smp_store_release(p, v) \ -do { \ - compiletime_assert_atomic_type(*p); \ - __smp_mb(); \ - WRITE_ONCE(*p, v); \ -} while (0) - -#define __smp_load_acquire(p) \ -({ \ - typeof(*p) ___p1 = READ_ONCE(*p); \ - compiletime_assert_atomic_type(*p); \ - __smp_mb(); \ - ___p1; \ -}) - -#else /* regular x86 TSO memory ordering */ - #define __smp_store_release(p, v) \ do { \ compiletime_assert_atomic_type(*p); \ @@ -107,8 +79,6 @@ do { \ ___p1; \ }) -#endif - /* Atomic operations are already serializing on x86 */ #define __smp_mb__before_atomic() barrier() #define __smp_mb__after_atomic() barrier() diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 95e948627fd0..f6e5b9375d8c 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -232,21 +232,6 @@ extern void set_iounmap_nonlazy(void); */ #define __ISA_IO_base ((char __iomem *)(PAGE_OFFSET)) -/* - * Cache management - * - * This needed for two cases - * 1. Out of order aware processors - * 2. Accidentally out of order processors (PPro errata #51) - */ - -static inline void flush_write_buffers(void) -{ -#if defined(CONFIG_X86_PPRO_FENCE) - asm volatile("lock; addl $0,0(%%esp)": : :"memory"); -#endif -} - #endif /* __KERNEL__ */ extern void native_io_delay(void); diff --git a/arch/x86/kernel/pci-nommu.c b/arch/x86/kernel/pci-nommu.c index 618285e475c6..ac7ea3a8242f 100644 --- a/arch/x86/kernel/pci-nommu.c +++ b/arch/x86/kernel/pci-nommu.c @@ -37,7 +37,6 @@ static dma_addr_t nommu_map_page(struct device *dev, struct page *page, WARN_ON(size == 0); if (!check_addr("map_single", dev, bus, size)) return NOMMU_MAPPING_ERROR; - flush_write_buffers(); return bus; } @@ -72,25 +71,9 @@ static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg, return 0; s->dma_length = s->length; } - flush_write_buffers(); return nents; } -static void nommu_sync_single_for_device(struct device *dev, - dma_addr_t addr, size_t size, - enum dma_data_direction dir) -{ - flush_write_buffers(); -} - - -static void nommu_sync_sg_for_device(struct device *dev, - struct scatterlist *sg, int nelems, - enum dma_data_direction dir) -{ - flush_write_buffers(); -} - static int nommu_mapping_error(struct device *dev, dma_addr_t dma_addr) { return dma_addr == NOMMU_MAPPING_ERROR; @@ -101,8 +84,6 @@ const struct dma_map_ops nommu_dma_ops = { .free = dma_generic_free_coherent, .map_sg = nommu_map_sg, .map_page = nommu_map_page, - .sync_single_for_device = nommu_sync_single_for_device, - .sync_sg_for_device = nommu_sync_sg_for_device, .is_phys = 1, .mapping_error = nommu_mapping_error, .dma_supported = x86_dma_supported, diff --git a/arch/x86/um/asm/barrier.h b/arch/x86/um/asm/barrier.h index b7d73400ea29..f31e5d903161 100644 --- a/arch/x86/um/asm/barrier.h +++ b/arch/x86/um/asm/barrier.h @@ -30,11 +30,7 @@ #endif /* CONFIG_X86_32 */ -#ifdef CONFIG_X86_PPRO_FENCE -#define dma_rmb() rmb() -#else /* CONFIG_X86_PPRO_FENCE */ #define dma_rmb() barrier() -#endif /* CONFIG_X86_PPRO_FENCE */ #define dma_wmb() barrier() #include From 8250e6cadceddefb8ab32eb7a011b3201adebbb3 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 18 Mar 2018 23:48:09 +0100 Subject: [PATCH 835/942] drm/sun4i: hdmi: Fix an error handling path in 'sun4i_hdmi_bind()' If we can not allocate the HDMI encoder regmap, we still need to free some resources before returning. Fixes: 4b1c924b1fc1 ("drm/sun4i: hdmi: create a regmap for later use") Reviewed-by: Chen-Yu Tsai Signed-off-by: Christophe JAILLET Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/14c42391e1b562c7495bda6ad6fa1d24ec8dc052.1521413031.git.christophe.jaillet@wanadoo.fr --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 500b6fb3e028..d2839727bb0b 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -538,7 +538,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master, &sun4i_hdmi_regmap_config); if (IS_ERR(hdmi->regmap)) { dev_err(dev, "Couldn't create HDMI encoder regmap\n"); - return PTR_ERR(hdmi->regmap); + ret = PTR_ERR(hdmi->regmap); + goto err_disable_mod_clk; } ret = sun4i_tmds_create(hdmi); From 1bc659eb2369ab795a401ff82f7e3a87a46bc864 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 18 Mar 2018 23:48:10 +0100 Subject: [PATCH 836/942] drm/sun4i: hdmi: Fix another error handling path in 'sun4i_hdmi_bind()' If we can not get the HDMI DDC clock, we still need to free some resources before returning. Fixes: 939d749ad664 ("drm/sun4i: hdmi: Add support for controller hardware variants") Reviewed-by: Chen-Yu Tsai Signed-off-by: Christophe JAILLET Signed-off-by: Maxime Ripard Link: https://patchwork.freedesktop.org/patch/msgid/5e0084af4ad57e9eea3bca5bd8e2e95970cd6714.1521413031.git.christophe.jaillet@wanadoo.fr --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index d2839727bb0b..fa4bcd092eaf 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -552,7 +552,8 @@ static int sun4i_hdmi_bind(struct device *dev, struct device *master, hdmi->ddc_parent_clk = devm_clk_get(dev, "ddc"); if (IS_ERR(hdmi->ddc_parent_clk)) { dev_err(dev, "Couldn't get the HDMI DDC clock\n"); - return PTR_ERR(hdmi->ddc_parent_clk); + ret = PTR_ERR(hdmi->ddc_parent_clk); + goto err_disable_mod_clk; } } else { hdmi->ddc_parent_clk = hdmi->tmds_clk; From 31ad7f8e7dc94d3b85ccf9b6141ce6dfd35a1781 Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Mon, 19 Mar 2018 10:31:54 -0400 Subject: [PATCH 837/942] x86/vsyscall/64: Use proper accessor to update P4D entry Writing to it directly does not work for Xen PV guests. Fixes: 49275fef986a ("x86/vsyscall/64: Explicitly set _PAGE_USER in the pagetable hierarchy") Signed-off-by: Boris Ostrovsky Signed-off-by: Thomas Gleixner Reviewed-by: Juergen Gross Acked-by: Andy Lutomirski Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20180319143154.3742-1-boris.ostrovsky@oracle.com Signed-off-by: Ingo Molnar --- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c index 8560ef68a9d6..317be365bce3 100644 --- a/arch/x86/entry/vsyscall/vsyscall_64.c +++ b/arch/x86/entry/vsyscall/vsyscall_64.c @@ -347,7 +347,7 @@ void __init set_vsyscall_pgtable_user_bits(pgd_t *root) set_pgd(pgd, __pgd(pgd_val(*pgd) | _PAGE_USER)); p4d = p4d_offset(pgd, VSYSCALL_ADDR); #if CONFIG_PGTABLE_LEVELS >= 5 - p4d->p4d |= _PAGE_USER; + set_p4d(p4d, __p4d(p4d_val(*p4d) | _PAGE_USER)); #endif pud = pud_offset(p4d, VSYSCALL_ADDR); set_pud(pud, __pud(pud_val(*pud) | _PAGE_USER)); From 8137a8e2190975ed9060111ce13000792360aba3 Mon Sep 17 00:00:00 2001 From: Igor Pylypiv Date: Sat, 17 Mar 2018 18:17:58 -0700 Subject: [PATCH 838/942] vmxnet3: remove unused flag "rxcsum" from struct vmxnet3_adapter Signed-off-by: Igor Pylypiv Signed-off-by: David S. Miller --- drivers/net/vmxnet3/vmxnet3_int.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 99387a4a20a8..59ec34052a65 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -342,8 +342,6 @@ struct vmxnet3_adapter { u8 __iomem *hw_addr1; /* for BAR 1 */ u8 version; - bool rxcsum; - #ifdef VMXNET3_RSS struct UPT1_RSSConf *rss_conf; bool rss; From 7fe4d6dcbcb43fe0282d4213fc52be178bb30e91 Mon Sep 17 00:00:00 2001 From: Arkadi Sharshevsky Date: Sun, 18 Mar 2018 17:37:22 +0200 Subject: [PATCH 839/942] devlink: Remove redundant free on error path The current code performs unneeded free. Remove the redundant skb freeing during the error path. Fixes: 1555d204e743 ("devlink: Support for pipeline debug (dpipe)") Signed-off-by: Arkadi Sharshevsky Acked-by: Jiri Pirko Signed-off-by: David S. Miller --- net/core/devlink.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/net/core/devlink.c b/net/core/devlink.c index 2f2307d94787..effd4848c2b4 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -1798,7 +1798,7 @@ send_done: if (!nlh) { err = devlink_dpipe_send_and_alloc_skb(&skb, info); if (err) - goto err_skb_send_alloc; + return err; goto send_done; } @@ -1807,7 +1807,6 @@ send_done: nla_put_failure: err = -EMSGSIZE; err_table_put: -err_skb_send_alloc: genlmsg_cancel(skb, hdr); nlmsg_free(skb); return err; @@ -2073,7 +2072,7 @@ static int devlink_dpipe_entries_fill(struct genl_info *info, table->counters_enabled, &dump_ctx); if (err) - goto err_entries_dump; + return err; send_done: nlh = nlmsg_put(dump_ctx.skb, info->snd_portid, info->snd_seq, @@ -2081,16 +2080,10 @@ send_done: if (!nlh) { err = devlink_dpipe_send_and_alloc_skb(&dump_ctx.skb, info); if (err) - goto err_skb_send_alloc; + return err; goto send_done; } return genlmsg_reply(dump_ctx.skb, info); - -err_entries_dump: -err_skb_send_alloc: - genlmsg_cancel(dump_ctx.skb, dump_ctx.hdr); - nlmsg_free(dump_ctx.skb); - return err; } static int devlink_nl_cmd_dpipe_entries_get(struct sk_buff *skb, @@ -2229,7 +2222,7 @@ send_done: if (!nlh) { err = devlink_dpipe_send_and_alloc_skb(&skb, info); if (err) - goto err_skb_send_alloc; + return err; goto send_done; } return genlmsg_reply(skb, info); @@ -2237,7 +2230,6 @@ send_done: nla_put_failure: err = -EMSGSIZE; err_table_put: -err_skb_send_alloc: genlmsg_cancel(skb, hdr); nlmsg_free(skb); return err; From 00777fac28ba3e126b9e63e789a613e8bd2cab25 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Sun, 18 Mar 2018 23:59:36 +0100 Subject: [PATCH 840/942] net: ethernet: arc: Fix a potential memory leak if an optional regulator is deferred If the optional regulator is deferred, we must release some resources. They will be re-allocated when the probe function will be called again. Fixes: 6eacf31139bf ("ethernet: arc: Add support for Rockchip SoC layer device tree bindings") Signed-off-by: Christophe JAILLET Signed-off-by: David S. Miller --- drivers/net/ethernet/arc/emac_rockchip.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/arc/emac_rockchip.c b/drivers/net/ethernet/arc/emac_rockchip.c index 16f9bee992fe..0f6576802607 100644 --- a/drivers/net/ethernet/arc/emac_rockchip.c +++ b/drivers/net/ethernet/arc/emac_rockchip.c @@ -169,8 +169,10 @@ static int emac_rockchip_probe(struct platform_device *pdev) /* Optional regulator for PHY */ priv->regulator = devm_regulator_get_optional(dev, "phy"); if (IS_ERR(priv->regulator)) { - if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (PTR_ERR(priv->regulator) == -EPROBE_DEFER) { + err = -EPROBE_DEFER; + goto out_clk_disable; + } dev_err(dev, "no regulator found\n"); priv->regulator = NULL; } From 44caebd368a5174f8aa7b80076350385eb2c2f42 Mon Sep 17 00:00:00 2001 From: Igor Pylypiv Date: Sun, 18 Mar 2018 23:40:51 -0700 Subject: [PATCH 841/942] net: gemini: fix memory leak cppcheck report: [drivers/net/ethernet/cortina/gemini.c:543]: (error) Memory leak: skb_tab Signed-off-by: Igor Pylypiv Acked-by: Linus Walleij Signed-off-by: David S. Miller --- drivers/net/ethernet/cortina/gemini.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index 5eb999af2c40..bd3f6e4d1341 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c @@ -540,6 +540,7 @@ static int gmac_setup_txqs(struct net_device *netdev) if (port->txq_dma_base & ~DMA_Q_BASE_MASK) { dev_warn(geth->dev, "TX queue base it not aligned\n"); + kfree(skb_tab); return -ENOMEM; } From 5f2fb802eee1df0810b47ea251942fe3fd36589a Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Mon, 19 Mar 2018 11:24:58 +0100 Subject: [PATCH 842/942] ipv6: old_dport should be a __be16 in __ip6_datagram_connect() Fixes: 2f987a76a977 ("net: ipv6: keep sk status consistent after datagram connect failure") Signed-off-by: Stefano Brivio Acked-by: Paolo Abeni Acked-by: Guillaume Nault Signed-off-by: David S. Miller --- net/ipv6/datagram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index 8a9ac2d0f5d3..a9f7eca0b6a3 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c @@ -149,7 +149,7 @@ int __ip6_datagram_connect(struct sock *sk, struct sockaddr *uaddr, struct in6_addr *daddr, old_daddr; __be32 fl6_flowlabel = 0; __be32 old_fl6_flowlabel; - __be32 old_dport; + __be16 old_dport; int addr_type; int err; From e8980d67d6017c8eee8f9c35f782c4bd68e004c9 Mon Sep 17 00:00:00 2001 From: Leon Romanovsky Date: Tue, 20 Mar 2018 17:05:13 +0200 Subject: [PATCH 843/942] RDMA/ucma: Ensure that CM_ID exists prior to access it Prior to access UCMA commands, the context should be initialized and connected to CM_ID with ucma_create_id(). In case user skips this step, he can provide non-valid ctx without CM_ID and cause to multiple NULL dereferences. Also there are situations where the create_id can be raced with other user access, ensure that the context is only shared to other threads once it is fully initialized to avoid the races. [ 109.088108] BUG: unable to handle kernel NULL pointer dereference at 0000000000000020 [ 109.090315] IP: ucma_connect+0x138/0x1d0 [ 109.092595] PGD 80000001dc02d067 P4D 80000001dc02d067 PUD 1da9ef067 PMD 0 [ 109.095384] Oops: 0000 [#1] SMP KASAN PTI [ 109.097834] CPU: 0 PID: 663 Comm: uclose Tainted: G B 4.16.0-rc1-00062-g2975d5de6428 #45 [ 109.100816] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.11.0-0-g63451fca13-prebuilt.qemu-project.org 04/01/2014 [ 109.105943] RIP: 0010:ucma_connect+0x138/0x1d0 [ 109.108850] RSP: 0018:ffff8801c8567a80 EFLAGS: 00010246 [ 109.111484] RAX: 0000000000000000 RBX: 1ffff100390acf50 RCX: ffffffff9d7812e2 [ 109.114496] RDX: 1ffffffff3f507a5 RSI: 0000000000000297 RDI: 0000000000000297 [ 109.117490] RBP: ffff8801daa15600 R08: 0000000000000000 R09: ffffed00390aceeb [ 109.120429] R10: 0000000000000001 R11: ffffed00390aceea R12: 0000000000000000 [ 109.123318] R13: 0000000000000120 R14: ffff8801de6459c0 R15: 0000000000000118 [ 109.126221] FS: 00007fabb68d6700(0000) GS:ffff8801e5c00000(0000) knlGS:0000000000000000 [ 109.129468] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 109.132523] CR2: 0000000000000020 CR3: 00000001d45d8003 CR4: 00000000003606b0 [ 109.135573] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 109.138716] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 109.142057] Call Trace: [ 109.144160] ? ucma_listen+0x110/0x110 [ 109.146386] ? wake_up_q+0x59/0x90 [ 109.148853] ? futex_wake+0x10b/0x2a0 [ 109.151297] ? save_stack+0x89/0xb0 [ 109.153489] ? _copy_from_user+0x5e/0x90 [ 109.155500] ucma_write+0x174/0x1f0 [ 109.157933] ? ucma_resolve_route+0xf0/0xf0 [ 109.160389] ? __mod_node_page_state+0x1d/0x80 [ 109.162706] __vfs_write+0xc4/0x350 [ 109.164911] ? kernel_read+0xa0/0xa0 [ 109.167121] ? path_openat+0x1b10/0x1b10 [ 109.169355] ? fsnotify+0x899/0x8f0 [ 109.171567] ? fsnotify_unmount_inodes+0x170/0x170 [ 109.174145] ? __fget+0xa8/0xf0 [ 109.177110] vfs_write+0xf7/0x280 [ 109.179532] SyS_write+0xa1/0x120 [ 109.181885] ? SyS_read+0x120/0x120 [ 109.184482] ? compat_start_thread+0x60/0x60 [ 109.187124] ? SyS_read+0x120/0x120 [ 109.189548] do_syscall_64+0xeb/0x250 [ 109.192178] entry_SYSCALL_64_after_hwframe+0x21/0x86 [ 109.194725] RIP: 0033:0x7fabb61ebe99 [ 109.197040] RSP: 002b:00007fabb68d5e98 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 [ 109.200294] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007fabb61ebe99 [ 109.203399] RDX: 0000000000000120 RSI: 00000000200001c0 RDI: 0000000000000004 [ 109.206548] RBP: 00007fabb68d5ec0 R08: 0000000000000000 R09: 0000000000000000 [ 109.209902] R10: 0000000000000000 R11: 0000000000000202 R12: 00007fabb68d5fc0 [ 109.213327] R13: 0000000000000000 R14: 00007fff40ab2430 R15: 00007fabb68d69c0 [ 109.216613] Code: 88 44 24 2c 0f b6 84 24 6e 01 00 00 88 44 24 2d 0f b6 84 24 69 01 00 00 88 44 24 2e 8b 44 24 60 89 44 24 30 e8 da f6 06 ff 31 c0 <66> 41 83 7c 24 20 1b 75 04 8b 44 24 64 48 8d 74 24 20 4c 89 e7 [ 109.223602] RIP: ucma_connect+0x138/0x1d0 RSP: ffff8801c8567a80 [ 109.226256] CR2: 0000000000000020 Fixes: 75216638572f ("RDMA/cma: Export rdma cm interface to userspace") Reported-by: Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe --- drivers/infiniband/core/ucma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index 14c260ed63cb..e5a1e7d81326 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c @@ -132,7 +132,7 @@ static inline struct ucma_context *_ucma_find_context(int id, ctx = idr_find(&ctx_idr, id); if (!ctx) ctx = ERR_PTR(-ENOENT); - else if (ctx->file != file) + else if (ctx->file != file || !ctx->cm_id) ctx = ERR_PTR(-EINVAL); return ctx; } @@ -456,6 +456,7 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf, struct rdma_ucm_create_id cmd; struct rdma_ucm_create_id_resp resp; struct ucma_context *ctx; + struct rdma_cm_id *cm_id; enum ib_qp_type qp_type; int ret; @@ -476,10 +477,10 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf, return -ENOMEM; ctx->uid = cmd.uid; - ctx->cm_id = rdma_create_id(current->nsproxy->net_ns, - ucma_event_handler, ctx, cmd.ps, qp_type); - if (IS_ERR(ctx->cm_id)) { - ret = PTR_ERR(ctx->cm_id); + cm_id = rdma_create_id(current->nsproxy->net_ns, + ucma_event_handler, ctx, cmd.ps, qp_type); + if (IS_ERR(cm_id)) { + ret = PTR_ERR(cm_id); goto err1; } @@ -489,10 +490,12 @@ static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf, ret = -EFAULT; goto err2; } + + ctx->cm_id = cm_id; return 0; err2: - rdma_destroy_id(ctx->cm_id); + rdma_destroy_id(cm_id); err1: mutex_lock(&mut); idr_remove(&ctx_idr, ctx->id); From 32d43cd391bacb5f0814c2624399a5dad3501d09 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 20 Mar 2018 12:16:59 -0700 Subject: [PATCH 844/942] kvm/x86: fix icebp instruction handling The undocumented 'icebp' instruction (aka 'int1') works pretty much like 'int3' in the absense of in-circuit probing equipment (except, obviously, that it raises #DB instead of raising #BP), and is used by some validation test-suites as such. But Andy Lutomirski noticed that his test suite acted differently in kvm than on bare hardware. The reason is that kvm used an inexact test for the icebp instruction: it just assumed that an all-zero VM exit qualification value meant that the VM exit was due to icebp. That is not unlike the guess that do_debug() does for the actual exception handling case, but it's purely a heuristic, not an absolute rule. do_debug() does it because it wants to ascribe _some_ reasons to the #DB that happened, and an empty %dr6 value means that 'icebp' is the most likely casue and we have no better information. But kvm can just do it right, because unlike the do_debug() case, kvm actually sees the real reason for the #DB in the VM-exit interruption information field. So instead of relying on an inexact heuristic, just use the actual VM exit information that says "it was 'icebp'". Right now the 'icebp' instruction isn't technically documented by Intel, but that will hopefully change. The special "privileged software exception" information _is_ actually mentioned in the Intel SDM, even though the cause of it isn't enumerated. Reported-by: Andy Lutomirski Tested-by: Paolo Bonzini Signed-off-by: Linus Torvalds --- arch/x86/include/asm/vmx.h | 1 + arch/x86/kvm/vmx.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/vmx.h b/arch/x86/include/asm/vmx.h index 8b6780751132..5db8b0b10766 100644 --- a/arch/x86/include/asm/vmx.h +++ b/arch/x86/include/asm/vmx.h @@ -352,6 +352,7 @@ enum vmcs_field { #define INTR_TYPE_NMI_INTR (2 << 8) /* NMI */ #define INTR_TYPE_HARD_EXCEPTION (3 << 8) /* processor exception */ #define INTR_TYPE_SOFT_INTR (4 << 8) /* software interrupt */ +#define INTR_TYPE_PRIV_SW_EXCEPTION (5 << 8) /* ICE breakpoint - undocumented */ #define INTR_TYPE_SOFT_EXCEPTION (6 << 8) /* software exception */ /* GUEST_INTERRUPTIBILITY_INFO flags. */ diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 051dab74e4e9..2d87603f9179 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1045,6 +1045,13 @@ static inline bool is_machine_check(u32 intr_info) (INTR_TYPE_HARD_EXCEPTION | MC_VECTOR | INTR_INFO_VALID_MASK); } +/* Undocumented: icebp/int1 */ +static inline bool is_icebp(u32 intr_info) +{ + return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VALID_MASK)) + == (INTR_TYPE_PRIV_SW_EXCEPTION | INTR_INFO_VALID_MASK); +} + static inline bool cpu_has_vmx_msr_bitmap(void) { return vmcs_config.cpu_based_exec_ctrl & CPU_BASED_USE_MSR_BITMAPS; @@ -6179,7 +6186,7 @@ static int handle_exception(struct kvm_vcpu *vcpu) (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP))) { vcpu->arch.dr6 &= ~15; vcpu->arch.dr6 |= dr6 | DR6_RTM; - if (!(dr6 & ~DR6_RESERVED)) /* icebp */ + if (is_icebp(intr_info)) skip_emulated_instruction(vcpu); kvm_queue_exception(vcpu, DB_VECTOR); From 52fda36d63bfc8c8e8ae5eda8eb5ac6f52cd67ed Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Tue, 20 Mar 2018 09:58:51 -0300 Subject: [PATCH 845/942] test_bpf: Fix testing with CONFIG_BPF_JIT_ALWAYS_ON=y on other arches Function bpf_fill_maxinsns11 is designed to not be able to be JITed on x86_64. So, it fails when CONFIG_BPF_JIT_ALWAYS_ON=y, and commit 09584b406742 ("bpf: fix selftests/bpf test_kmod.sh failure when CONFIG_BPF_JIT_ALWAYS_ON=y") makes sure that failure is detected on that case. However, it does not fail on other architectures, which have a different JIT compiler design. So, test_bpf has started to fail to load on those. After this fix, test_bpf loads fine on both x86_64 and ppc64el. Fixes: 09584b406742 ("bpf: fix selftests/bpf test_kmod.sh failure when CONFIG_BPF_JIT_ALWAYS_ON=y") Signed-off-by: Thadeu Lima de Souza Cascardo Reviewed-by: Yonghong Song Signed-off-by: Daniel Borkmann --- lib/test_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index 2efb213716fa..3e9335493fe4 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -5467,7 +5467,7 @@ static struct bpf_test tests[] = { { "BPF_MAXINSNS: Jump, gap, jump, ...", { }, -#ifdef CONFIG_BPF_JIT_ALWAYS_ON +#if defined(CONFIG_BPF_JIT_ALWAYS_ON) && defined(CONFIG_X86) CLASSIC | FLAG_NO_DATA | FLAG_EXPECTED_FAIL, #else CLASSIC | FLAG_NO_DATA, From f005afede992e265bb98534b86912bb669ccd0d2 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Tue, 20 Mar 2018 11:19:17 -0700 Subject: [PATCH 846/942] trace/bpf: remove helper bpf_perf_prog_read_value from tracepoint type programs Commit 4bebdc7a85aa ("bpf: add helper bpf_perf_prog_read_value") added helper bpf_perf_prog_read_value so that perf_event type program can read event counter and enabled/running time. This commit, however, introduced a bug which allows this helper for tracepoint type programs. This is incorrect as bpf_perf_prog_read_value needs to access perf_event through its bpf_perf_event_data_kern type context, which is not available for tracepoint type program. This patch fixed the issue by separating bpf_func_proto between tracepoint and perf_event type programs and removed bpf_perf_prog_read_value from tracepoint func prototype. Fixes: 4bebdc7a85aa ("bpf: add helper bpf_perf_prog_read_value") Reported-by: Alexei Starovoitov Signed-off-by: Yonghong Song Signed-off-by: Daniel Borkmann --- kernel/trace/bpf_trace.c | 70 +++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index c0a9e310d715..01e6b3a38871 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -661,32 +661,6 @@ static const struct bpf_func_proto bpf_get_stackid_proto_tp = { .arg3_type = ARG_ANYTHING, }; -BPF_CALL_3(bpf_perf_prog_read_value_tp, struct bpf_perf_event_data_kern *, ctx, - struct bpf_perf_event_value *, buf, u32, size) -{ - int err = -EINVAL; - - if (unlikely(size != sizeof(struct bpf_perf_event_value))) - goto clear; - err = perf_event_read_local(ctx->event, &buf->counter, &buf->enabled, - &buf->running); - if (unlikely(err)) - goto clear; - return 0; -clear: - memset(buf, 0, size); - return err; -} - -static const struct bpf_func_proto bpf_perf_prog_read_value_proto_tp = { - .func = bpf_perf_prog_read_value_tp, - .gpl_only = true, - .ret_type = RET_INTEGER, - .arg1_type = ARG_PTR_TO_CTX, - .arg2_type = ARG_PTR_TO_UNINIT_MEM, - .arg3_type = ARG_CONST_SIZE, -}; - static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id) { switch (func_id) { @@ -694,8 +668,6 @@ static const struct bpf_func_proto *tp_prog_func_proto(enum bpf_func_id func_id) return &bpf_perf_event_output_proto_tp; case BPF_FUNC_get_stackid: return &bpf_get_stackid_proto_tp; - case BPF_FUNC_perf_prog_read_value: - return &bpf_perf_prog_read_value_proto_tp; default: return tracing_func_proto(func_id); } @@ -723,6 +695,46 @@ const struct bpf_verifier_ops tracepoint_verifier_ops = { const struct bpf_prog_ops tracepoint_prog_ops = { }; +BPF_CALL_3(bpf_perf_prog_read_value, struct bpf_perf_event_data_kern *, ctx, + struct bpf_perf_event_value *, buf, u32, size) +{ + int err = -EINVAL; + + if (unlikely(size != sizeof(struct bpf_perf_event_value))) + goto clear; + err = perf_event_read_local(ctx->event, &buf->counter, &buf->enabled, + &buf->running); + if (unlikely(err)) + goto clear; + return 0; +clear: + memset(buf, 0, size); + return err; +} + +static const struct bpf_func_proto bpf_perf_prog_read_value_proto = { + .func = bpf_perf_prog_read_value, + .gpl_only = true, + .ret_type = RET_INTEGER, + .arg1_type = ARG_PTR_TO_CTX, + .arg2_type = ARG_PTR_TO_UNINIT_MEM, + .arg3_type = ARG_CONST_SIZE, +}; + +static const struct bpf_func_proto *pe_prog_func_proto(enum bpf_func_id func_id) +{ + switch (func_id) { + case BPF_FUNC_perf_event_output: + return &bpf_perf_event_output_proto_tp; + case BPF_FUNC_get_stackid: + return &bpf_get_stackid_proto_tp; + case BPF_FUNC_perf_prog_read_value: + return &bpf_perf_prog_read_value_proto; + default: + return tracing_func_proto(func_id); + } +} + static bool pe_prog_is_valid_access(int off, int size, enum bpf_access_type type, struct bpf_insn_access_aux *info) { @@ -779,7 +791,7 @@ static u32 pe_prog_convert_ctx_access(enum bpf_access_type type, } const struct bpf_verifier_ops perf_event_verifier_ops = { - .get_func_proto = tp_prog_func_proto, + .get_func_proto = pe_prog_func_proto, .is_valid_access = pe_prog_is_valid_access, .convert_ctx_access = pe_prog_convert_ctx_access, }; From 0fa4fe85f4724fff89b09741c437cbee9cf8b008 Mon Sep 17 00:00:00 2001 From: Chenbo Feng Date: Mon, 19 Mar 2018 17:57:27 -0700 Subject: [PATCH 847/942] bpf: skip unnecessary capability check The current check statement in BPF syscall will do a capability check for CAP_SYS_ADMIN before checking sysctl_unprivileged_bpf_disabled. This code path will trigger unnecessary security hooks on capability checking and cause false alarms on unprivileged process trying to get CAP_SYS_ADMIN access. This can be resolved by simply switch the order of the statement and CAP_SYS_ADMIN is not required anyway if unprivileged bpf syscall is allowed. Signed-off-by: Chenbo Feng Acked-by: Lorenzo Colitti Signed-off-by: Daniel Borkmann --- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index e24aa3241387..43f95d190eea 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -1845,7 +1845,7 @@ SYSCALL_DEFINE3(bpf, int, cmd, union bpf_attr __user *, uattr, unsigned int, siz union bpf_attr attr = {}; int err; - if (!capable(CAP_SYS_ADMIN) && sysctl_unprivileged_bpf_disabled) + if (sysctl_unprivileged_bpf_disabled && !capable(CAP_SYS_ADMIN)) return -EPERM; err = check_uarg_tail_zero(uattr, sizeof(attr), size); From 87e0d4f0f37fb0c8c4aeeac46fff5e957738df79 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 21 Mar 2018 01:18:24 +0100 Subject: [PATCH 848/942] kbuild: disable clang's default use of -fmerge-all-constants Prasad reported that he has seen crashes in BPF subsystem with netd on Android with arm64 in the form of (note, the taint is unrelated): [ 4134.721483] Unable to handle kernel paging request at virtual address 800000001 [ 4134.820925] Mem abort info: [ 4134.901283] Exception class = DABT (current EL), IL = 32 bits [ 4135.016736] SET = 0, FnV = 0 [ 4135.119820] EA = 0, S1PTW = 0 [ 4135.201431] Data abort info: [ 4135.301388] ISV = 0, ISS = 0x00000021 [ 4135.359599] CM = 0, WnR = 0 [ 4135.470873] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffe39b946000 [ 4135.499757] [0000000800000001] *pgd=0000000000000000, *pud=0000000000000000 [ 4135.660725] Internal error: Oops: 96000021 [#1] PREEMPT SMP [ 4135.674610] Modules linked in: [ 4135.682883] CPU: 5 PID: 1260 Comm: netd Tainted: G S W 4.14.19+ #1 [ 4135.716188] task: ffffffe39f4aa380 task.stack: ffffff801d4e0000 [ 4135.731599] PC is at bpf_prog_add+0x20/0x68 [ 4135.741746] LR is at bpf_prog_inc+0x20/0x2c [ 4135.751788] pc : [] lr : [] pstate: 60400145 [ 4135.769062] sp : ffffff801d4e3ce0 [...] [ 4136.258315] Process netd (pid: 1260, stack limit = 0xffffff801d4e0000) [ 4136.273746] Call trace: [...] [ 4136.442494] 3ca0: ffffff94ab7ad584 0000000060400145 ffffffe3a01bf8f8 0000000000000006 [ 4136.460936] 3cc0: 0000008000000000 ffffff94ab844204 ffffff801d4e3cf0 ffffff94ab7ad584 [ 4136.479241] [] bpf_prog_add+0x20/0x68 [ 4136.491767] [] bpf_prog_inc+0x20/0x2c [ 4136.504536] [] bpf_obj_get_user+0x204/0x22c [ 4136.518746] [] SyS_bpf+0x5a8/0x1a88 Android's netd was basically pinning the uid cookie BPF map in BPF fs (/sys/fs/bpf/traffic_cookie_uid_map) and later on retrieving it again resulting in above panic. Issue is that the map was wrongly identified as a prog! Above kernel was compiled with clang 4.0, and it turns out that clang decided to merge the bpf_prog_iops and bpf_map_iops into a single memory location, such that the two i_ops could then not be distinguished anymore. Reason for this miscompilation is that clang has the more aggressive -fmerge-all-constants enabled by default. In fact, clang source code has a comment about it in lib/AST/ExprConstant.cpp on why it is okay to do so: Pointers with different bases cannot represent the same object. (Note that clang defaults to -fmerge-all-constants, which can lead to inconsistent results for comparisons involving the address of a constant; this generally doesn't matter in practice.) The issue never appeared with gcc however, since gcc does not enable -fmerge-all-constants by default and even *explicitly* states in it's option description that using this flag results in non-conforming behavior, quote from man gcc: Languages like C or C++ require each variable, including multiple instances of the same variable in recursive calls, to have distinct locations, so using this option results in non-conforming behavior. There are also various clang bug reports open on that matter [1], where clang developers acknowledge the non-conforming behavior, and refer to disabling it with -fno-merge-all-constants. But even if this gets fixed in clang today, there are already users out there that triggered this. Thus, fix this issue by explicitly adding -fno-merge-all-constants to the kernel's Makefile to generically disable this optimization, since potentially other places in the kernel could subtly break as well. Note, there is also a flag called -fmerge-constants (not supported by clang), which is more conservative and only applies to strings and it's enabled in gcc's -O/-O2/-O3/-Os optimization levels. In gcc's code, the two flags -fmerge-{all-,}constants share the same variable internally, so when disabling it via -fno-merge-all-constants, then we really don't merge any const data (e.g. strings), and text size increases with gcc (14,927,214 -> 14,942,646 for vmlinux.o). $ gcc -fverbose-asm -O2 foo.c -S -o foo.S -> foo.S lists -fmerge-constants under options enabled $ gcc -fverbose-asm -O2 -fno-merge-all-constants foo.c -S -o foo.S -> foo.S doesn't list -fmerge-constants under options enabled $ gcc -fverbose-asm -O2 -fno-merge-all-constants -fmerge-constants foo.c -S -o foo.S -> foo.S lists -fmerge-constants under options enabled Thus, as a workaround we need to set both -fno-merge-all-constants *and* -fmerge-constants in the Makefile in order for text size to stay as is. [1] https://bugs.llvm.org/show_bug.cgi?id=18538 Reported-by: Prasad Sodagudi Signed-off-by: Daniel Borkmann Cc: Linus Torvalds Cc: Chenbo Feng Cc: Richard Smith Cc: Chandler Carruth Cc: linux-kernel@vger.kernel.org Tested-by: Prasad Sodagudi Acked-by: Alexei Starovoitov Signed-off-by: Alexei Starovoitov --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index c4322dea3ca2..af07bf5bb238 100644 --- a/Makefile +++ b/Makefile @@ -826,6 +826,15 @@ KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) +# clang sets -fmerge-all-constants by default as optimization, but this +# is non-conforming behavior for C and in fact breaks the kernel, so we +# need to disable it here generally. +KBUILD_CFLAGS += $(call cc-option,-fno-merge-all-constants) + +# for gcc -fno-merge-all-constants disables everything, but it is fine +# to have actual conforming behavior enabled. +KBUILD_CFLAGS += $(call cc-option,-fmerge-constants) + # Make sure -fstack-check isn't enabled (like gentoo apparently did) KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) From f8a9a29c4fe9dd0dd2206cc4368efec95dc9defb Mon Sep 17 00:00:00 2001 From: Nikita Yushchenko Date: Tue, 20 Mar 2018 11:41:15 +0300 Subject: [PATCH 849/942] ASoC: rsnd: set pm_ops in hibernate-compatible way Use SET_SYSTEM_SLEEP_PM_OPS() macro instead of direct assignment to .suspend and .resume fields. This makes driver working after restore from hibernation. Signed-off-by: Nikita Yushchenko Signed-off-by: Mark Brown --- sound/soc/sh/rcar/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 5aafc37f5119..96526c91a94b 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1569,8 +1569,7 @@ static int rsnd_resume(struct device *dev) } static const struct dev_pm_ops rsnd_pm_ops = { - .suspend = rsnd_suspend, - .resume = rsnd_resume, + SET_SYSTEM_SLEEP_PM_OPS(rsnd_suspend, rsnd_resume) }; static struct platform_driver rsnd_driver = { From 9260f873684fb1cfb9ea10a10be3e8b888da3c0e Mon Sep 17 00:00:00 2001 From: Masanari Iida Date: Tue, 20 Mar 2018 21:33:09 +0900 Subject: [PATCH 850/942] ASoC: mediatek: mt2701: Fix a typo in printk This patch fixes a spelling typo in printk Signed-off-by: Masanari Iida Signed-off-by: Mark Brown --- sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index d68b53f7cefe..e96028c06557 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c @@ -336,7 +336,7 @@ static int mt2701_btmrg_hw_params(struct snd_pcm_substream *substream, stream_fs = params_rate(params); if ((stream_fs != 8000) && (stream_fs != 16000)) { - dev_err(afe->dev, "%s() btmgr not supprt this stream_fs %d\n", + dev_err(afe->dev, "%s() btmgr not support this stream_fs %d\n", __func__, stream_fs); return -EINVAL; } From a5ad3b4b240b0335f9ea7d474efa79ba8463ade7 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 20 Mar 2018 13:03:30 -0300 Subject: [PATCH 851/942] ASoC: rockchip: Fix dai_name for HDMI codec Commit 24069b589b02 ("ASoC: hdmi-codec: remove multi detection support") changed the dai_name for the HDMI Codec, breaking the rk3288_hdmi_analog driver, which fails to register with a: rk3288-snd-hdmi-analog sound: ASoC: CODEC DAI hdmi-hifi.0 not registered This commit fixes the dai_name, fixing the issue. Fixes: 24069b589b02 ("ASoC: hdmi-codec: remove multi detection support") Signed-off-by: Ezequiel Garcia Signed-off-by: Mark Brown --- sound/soc/rockchip/rk3288_hdmi_analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/rockchip/rk3288_hdmi_analog.c b/sound/soc/rockchip/rk3288_hdmi_analog.c index fa44e3901336..929b3fe289b0 100644 --- a/sound/soc/rockchip/rk3288_hdmi_analog.c +++ b/sound/soc/rockchip/rk3288_hdmi_analog.c @@ -155,7 +155,7 @@ static struct snd_soc_dai_link_component rk_codecs[] = { { }, { .name = "hdmi-audio-codec.2.auto", - .dai_name = "hdmi-hifi.0", + .dai_name = "i2s-hifi", }, }; From 279df1917d3e7817983bf5b3476643ec6dfd6f22 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 20 Mar 2018 13:03:32 -0300 Subject: [PATCH 852/942] ASoC: rockchip: Fix compatible string in example Use the correct compatible string in the example devicetree snippet, which was probably overlooked. Signed-off-by: Ezequiel Garcia Signed-off-by: Mark Brown --- .../devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt b/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt index 2539e1d68107..e5430d1d34e4 100644 --- a/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt +++ b/Documentation/devicetree/bindings/sound/rockchip,rk3288-hdmi-analog.txt @@ -22,7 +22,7 @@ Optionnal properties: Example: sound { - compatible = "rockchip,rockchip-audio-es8388"; + compatible = "rockchip,rk3288-hdmi-analog"; rockchip,model = "Analog audio output"; rockchip,i2s-controller = <&i2s>; rockchip,audio-codec = <&es8388>; From b1d0db067fbe2598d62b248beea5d705a0ea7642 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Tue, 20 Mar 2018 13:03:31 -0300 Subject: [PATCH 853/942] ASoC: rockchip: rk3288-hdmi-analog: Select needed codecs The driver does not select all the codec drivers that needs. Fix it by selecting the analog and HDMI codecs. Cc: Sjoerd Simons Signed-off-by: Ezequiel Garcia Signed-off-by: Mark Brown --- sound/soc/rockchip/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig index b0825370d262..957046ac6c8c 100644 --- a/sound/soc/rockchip/Kconfig +++ b/sound/soc/rockchip/Kconfig @@ -56,6 +56,9 @@ config SND_SOC_RK3288_HDMI_ANALOG depends on SND_SOC_ROCKCHIP && I2C && GPIOLIB && CLKDEV_LOOKUP select SND_SOC_ROCKCHIP_I2S select SND_SOC_HDMI_CODEC + select SND_SOC_ES8328_I2C + select SND_SOC_ES8328_SPI if SPI_MASTER + select DRM_DW_HDMI_I2S_AUDIO if DRM_DW_HDMI help Say Y or M here if you want to add support for SoC audio on Rockchip RK3288 boards using an analog output and the built-in HDMI audio. From 8bfac12f88dbafff40af72c7990b7d14e0158545 Mon Sep 17 00:00:00 2001 From: Mikita Lipski Date: Wed, 7 Mar 2018 10:49:23 -0500 Subject: [PATCH 854/942] drm/amd/display: Allow truncation to 10 bits The truncation isn't being programmed if the truncation depth is set to 2, it causes an issue with dce11.2 asic using 6bit eDP panel. It required to truncate 12:10 in order to perform spatial dither 10:6. This change will allow 12:10 truncation to be enabled. Signed-off-by: Mikita Lipski Reviewed-by: Jun Lei Acked-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_opp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c b/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c index 3931412ab6d3..f19de13024f8 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c @@ -128,8 +128,7 @@ static void set_truncation( return; } /* on other format-to do */ - if (params->flags.TRUNCATE_ENABLED == 0 || - params->flags.TRUNCATE_DEPTH == 2) + if (params->flags.TRUNCATE_ENABLED == 0) return; /*Set truncation depth and Enable truncation*/ REG_UPDATE_3(FMT_BIT_DEPTH_CONTROL, @@ -144,7 +143,7 @@ static void set_truncation( /** * set_spatial_dither * 1) set spatial dithering mode: pattern of seed - * 2) set spatical dithering depth: 0 for 18bpp or 1 for 24bpp + * 2) set spatial dithering depth: 0 for 18bpp or 1 for 24bpp * 3) set random seed * 4) set random mode * lfsr is reset every frame or not reset From 4407a29bad96a773e1ddd380ecab0828b5656b0a Mon Sep 17 00:00:00 2001 From: Mikita Lipski Date: Wed, 7 Mar 2018 11:12:20 -0500 Subject: [PATCH 855/942] drm/amd/display: Fix FMT truncation programming Switch the order of parameters being set for depth and mode of truncation, as it previously was not correct Signed-off-by: Mikita Lipski Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/dce/dce_opp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c b/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c index f19de13024f8..87093894ea9e 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_opp.c @@ -134,9 +134,9 @@ static void set_truncation( REG_UPDATE_3(FMT_BIT_DEPTH_CONTROL, FMT_TRUNCATE_EN, 1, FMT_TRUNCATE_DEPTH, - params->flags.TRUNCATE_MODE, + params->flags.TRUNCATE_DEPTH, FMT_TRUNCATE_MODE, - params->flags.TRUNCATE_DEPTH); + params->flags.TRUNCATE_MODE); } From 509648fcf0ce8650184649b43ad039f78dde155f Mon Sep 17 00:00:00 2001 From: Harry Wentland Date: Tue, 6 Mar 2018 11:14:12 -0500 Subject: [PATCH 856/942] drm/amd/display: We shouldn't set format_default on plane as atomic driver This is still a leftover from early atomic brinup days. Signed-off-by: Harry Wentland Reviewed-by: Tony Cheng Acked-by: Harry Wentland Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 95b639eddcb6..63c67346d316 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -3134,8 +3134,6 @@ static int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm, switch (aplane->base.type) { case DRM_PLANE_TYPE_PRIMARY: - aplane->base.format_default = true; - res = drm_universal_plane_init( dm->adev->ddev, &aplane->base, From 731a373698c9675d5aed8a30d8c9861bea9c41a2 Mon Sep 17 00:00:00 2001 From: Harry Wentland Date: Wed, 7 Mar 2018 13:45:33 -0500 Subject: [PATCH 857/942] drm/amd/display: Add one to EDID's audio channel count when passing to DC DC takes channel count to mean the actual count. cea_sad's channels represent it as number of channels - 1. Signed-off-by: Harry Wentland Reviewed-by: Tony Cheng Acked-by: Harry Wentland Signed-off-by: Alex Deucher Cc: stable@vger.kernel.org --- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index 9bd142f65f9b..e1acc10e35a2 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c @@ -109,7 +109,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps( struct cea_sad *sad = &sads[i]; edid_caps->audio_modes[i].format_code = sad->format; - edid_caps->audio_modes[i].channel_count = sad->channels; + edid_caps->audio_modes[i].channel_count = sad->channels + 1; edid_caps->audio_modes[i].sample_rate = sad->freq; edid_caps->audio_modes[i].sample_size = sad->byte2; } From fa8e6d58c5bc260f4369c6699683d69695daed0a Mon Sep 17 00:00:00 2001 From: Jagdish Gediya Date: Wed, 21 Mar 2018 04:31:36 +0530 Subject: [PATCH 858/942] mtd: nand: fsl_ifc: Fix nand waitfunc return value As per the IFC hardware manual, Most significant 2 bytes in nand_fsr register are the outcome of NAND READ STATUS command. So status value need to be shifted and aligned as per the nand framework requirement. Fixes: 82771882d960 ("NAND Machine support for Integrated Flash Controller") Cc: stable@vger.kernel.org # v3.18+ Signed-off-by: Jagdish Gediya Reviewed-by: Prabhakar Kushwaha Signed-off-by: Boris Brezillon --- drivers/mtd/nand/fsl_ifc_nand.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index 4872a7ba6503..b6a3ba445cfb 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -626,6 +626,7 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs; u32 nand_fsr; + int status; /* Use READ_STATUS command, but wait for the device to be ready */ ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | @@ -640,12 +641,12 @@ static int fsl_ifc_wait(struct mtd_info *mtd, struct nand_chip *chip) fsl_ifc_run_command(mtd); nand_fsr = ifc_in32(&ifc->ifc_nand.nand_fsr); - + status = nand_fsr >> 24; /* * The chip always seems to report that it is * write-protected, even when it is not. */ - return nand_fsr | NAND_STATUS_WP; + return status | NAND_STATUS_WP; } /* From 843c3a59997f18060848b8632607dd04781b52d1 Mon Sep 17 00:00:00 2001 From: Jagdish Gediya Date: Wed, 21 Mar 2018 05:51:46 +0530 Subject: [PATCH 859/942] mtd: nand: fsl_ifc: Fix eccstat array overflow for IFC ver >= 2.0.0 Number of ECC status registers i.e. (ECCSTATx) has been increased in IFC version 2.0.0 due to increase in SRAM size. This is causing eccstat array to over flow. So, replace eccstat array with u32 variable to make it fail-safe and independent of number of ECC status registers or SRAM size. Fixes: bccb06c353af ("mtd: nand: ifc: update bufnum mask for ver >= 2.0.0") Cc: stable@vger.kernel.org # 3.18+ Signed-off-by: Prabhakar Kushwaha Signed-off-by: Jagdish Gediya Signed-off-by: Boris Brezillon --- drivers/mtd/nand/fsl_ifc_nand.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index b6a3ba445cfb..fae01b04abc7 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -173,14 +173,9 @@ static void set_addr(struct mtd_info *mtd, int column, int page_addr, int oob) /* returns nonzero if entire page is blank */ static int check_read_ecc(struct mtd_info *mtd, struct fsl_ifc_ctrl *ctrl, - u32 *eccstat, unsigned int bufnum) + u32 eccstat, unsigned int bufnum) { - u32 reg = eccstat[bufnum / 4]; - int errors; - - errors = (reg >> ((3 - bufnum % 4) * 8)) & 15; - - return errors; + return (eccstat >> ((3 - bufnum % 4) * 8)) & 15; } /* @@ -193,7 +188,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) struct fsl_ifc_ctrl *ctrl = priv->ctrl; struct fsl_ifc_nand_ctrl *nctrl = ifc_nand_ctrl; struct fsl_ifc_runtime __iomem *ifc = ctrl->rregs; - u32 eccstat[4]; + u32 eccstat; int i; /* set the chip select for NAND Transaction */ @@ -228,8 +223,8 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) if (nctrl->eccread) { int errors; int bufnum = nctrl->page & priv->bufnum_mask; - int sector = bufnum * chip->ecc.steps; - int sector_end = sector + chip->ecc.steps - 1; + int sector_start = bufnum * chip->ecc.steps; + int sector_end = sector_start + chip->ecc.steps - 1; __be32 *eccstat_regs; if (ctrl->version >= FSL_IFC_VERSION_2_0_0) @@ -237,10 +232,12 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) else eccstat_regs = ifc->ifc_nand.v1_nand_eccstat; - for (i = sector / 4; i <= sector_end / 4; i++) - eccstat[i] = ifc_in32(&eccstat_regs[i]); + eccstat = ifc_in32(&eccstat_regs[sector_start / 4]); + + for (i = sector_start; i <= sector_end; i++) { + if (i != sector_start && !(i % 4)) + eccstat = ifc_in32(&eccstat_regs[i / 4]); - for (i = sector; i <= sector_end; i++) { errors = check_read_ecc(mtd, ctrl, eccstat, i); if (errors == 15) { From 6b00c35138b404be98b85f4a703be594cbed501c Mon Sep 17 00:00:00 2001 From: Jagdish Gediya Date: Thu, 22 Mar 2018 01:08:10 +0530 Subject: [PATCH 860/942] mtd: nand: fsl_ifc: Read ECCSTAT0 and ECCSTAT1 registers for IFC 2.0 Due to missing information in Hardware manual, current implementation doesn't read ECCSTAT0 and ECCSTAT1 registers for IFC 2.0. Add support to read ECCSTAT0 and ECCSTAT1 registers during ecccheck for IFC 2.0. Fixes: 656441478ed5 ("mtd: nand: ifc: Fix location of eccstat registers for IFC V1.0") Cc: stable@vger.kernel.org # v3.18+ Signed-off-by: Jagdish Gediya Reviewed-by: Prabhakar Kushwaha Signed-off-by: Boris Brezillon --- drivers/mtd/nand/fsl_ifc_nand.c | 6 +----- include/linux/fsl_ifc.h | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index fae01b04abc7..5a9c2f0020c2 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -227,11 +227,7 @@ static void fsl_ifc_run_command(struct mtd_info *mtd) int sector_end = sector_start + chip->ecc.steps - 1; __be32 *eccstat_regs; - if (ctrl->version >= FSL_IFC_VERSION_2_0_0) - eccstat_regs = ifc->ifc_nand.v2_nand_eccstat; - else - eccstat_regs = ifc->ifc_nand.v1_nand_eccstat; - + eccstat_regs = ifc->ifc_nand.nand_eccstat; eccstat = ifc_in32(&eccstat_regs[sector_start / 4]); for (i = sector_start; i <= sector_end; i++) { diff --git a/include/linux/fsl_ifc.h b/include/linux/fsl_ifc.h index c332f0a45607..3fdfede2f0f3 100644 --- a/include/linux/fsl_ifc.h +++ b/include/linux/fsl_ifc.h @@ -734,11 +734,7 @@ struct fsl_ifc_nand { u32 res19[0x10]; __be32 nand_fsr; u32 res20; - /* The V1 nand_eccstat is actually 4 words that overlaps the - * V2 nand_eccstat. - */ - __be32 v1_nand_eccstat[2]; - __be32 v2_nand_eccstat[6]; + __be32 nand_eccstat[8]; u32 res21[0x1c]; __be32 nanndcr; u32 res22[0x2]; From b24791fe00f8b089d5b10cb7bcc4e1ae88b4831b Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Tue, 20 Mar 2018 22:58:39 +0000 Subject: [PATCH 861/942] drm: Reject getfb for multi-plane framebuffers getfb can only return a single plane, so reject attempts to use it with multi-plane framebuffers. Signed-off-by: Daniel Stone Reported-by: Daniel van Vugt Reviewed-by: Rob Clark Reviewed-by: Daniel Vetter Fixes: 308e5bcbdb10 ("drm: add an fb creation ioctl that takes a pixel format v5") Cc: stable@vger.kernel.org # v3.3+ Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105518 Link: https://patchwork.freedesktop.org/patch/msgid/20180320225839.30905-1-daniels@collabora.com --- drivers/gpu/drm/drm_framebuffer.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index c0530a1af5e3..2dc5e8bed172 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c @@ -461,6 +461,12 @@ int drm_mode_getfb(struct drm_device *dev, if (!fb) return -ENOENT; + /* Multi-planar framebuffers need getfb2. */ + if (fb->format->num_planes > 1) { + ret = -EINVAL; + goto out; + } + r->height = fb->height; r->width = fb->width; r->depth = fb->format->depth; @@ -484,6 +490,7 @@ int drm_mode_getfb(struct drm_device *dev, ret = -ENODEV; } +out: drm_framebuffer_put(fb); return ret; From 140bcaa23a1c37b694910424075a15e009120dbe Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 8 Mar 2018 10:07:37 +0100 Subject: [PATCH 862/942] drm/vmwgfx: Fix black screen and device errors when running without fbdev When we are running without fbdev, transitioning from the login screen to X or gnome-shell/wayland will cause a vt switch and the driver will disable svga mode, losing all modesetting resources. However, the kms atomic state does not reflect that and may think that a crtc is still turned on, which will cause device errors when we try to bind an fb to the crtc, and the screen will remain black. Fix this by turning off all kms resources before disabling svga mode. Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 +++++++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 11 +++++++++++ drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 1 - 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c index 184340d486c3..86d25f18aa99 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.c @@ -1337,6 +1337,19 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv) */ void vmw_svga_disable(struct vmw_private *dev_priv) { + /* + * Disabling SVGA will turn off device modesetting capabilities, so + * notify KMS about that so that it doesn't cache atomic state that + * isn't valid anymore, for example crtcs turned on. + * Strictly we'd want to do this under the SVGA lock (or an SVGA mutex), + * but vmw_kms_lost_device() takes the reservation sem and thus we'll + * end up with lock order reversal. Thus, a master may actually perform + * a new modeset just after we call vmw_kms_lost_device() and race with + * vmw_svga_disable(), but that should at worst cause atomic KMS state + * to be inconsistent with the device, causing modesetting problems. + * + */ + vmw_kms_lost_device(dev_priv->dev); ttm_write_lock(&dev_priv->reservation_sem, false); spin_lock(&dev_priv->svga_lock); if (dev_priv->bdev.man[TTM_PL_VRAM].use_type) { diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h index d08753e8fd94..9116fe8baebc 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h @@ -938,6 +938,7 @@ int vmw_kms_present(struct vmw_private *dev_priv, int vmw_kms_update_layout_ioctl(struct drm_device *dev, void *data, struct drm_file *file_priv); void vmw_kms_legacy_hotspot_clear(struct vmw_private *dev_priv); +void vmw_kms_lost_device(struct drm_device *dev); int vmw_dumb_create(struct drm_file *file_priv, struct drm_device *dev, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index ead61015cd79..b3d62aa01a9b 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -2851,3 +2851,14 @@ int vmw_kms_set_config(struct drm_mode_set *set, return drm_atomic_helper_set_config(set, ctx); } + + +/** + * vmw_kms_lost_device - Notify kms that modesetting capabilities will be lost + * + * @dev: Pointer to the drm device + */ +void vmw_kms_lost_device(struct drm_device *dev) +{ + drm_atomic_helper_shutdown(dev); +} diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h index cd9da2dd79af..948362c43c73 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h @@ -439,5 +439,4 @@ int vmw_kms_stdu_dma(struct vmw_private *dev_priv, int vmw_kms_set_config(struct drm_mode_set *set, struct drm_modeset_acquire_ctx *ctx); - #endif From 73a88250b70954a8f27c2444e1c2411bba3c29d9 Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Wed, 21 Mar 2018 10:18:38 +0100 Subject: [PATCH 863/942] drm/vmwgfx: Fix a destoy-while-held mutex problem. When validating legacy surfaces, the backup bo might be destroyed at surface validate time. However, the kms resource validation code may have the bo reserved, so we will destroy a locked mutex. While there shouldn't be any other users of that mutex when it is destroyed, it causes a lock leak and thus throws a lockdep error. Fix this by having the kms resource validation code hold a reference to the bo while we have it reserved. We do this by introducing a validation context which might come in handy when the kms code is extended to validate multiple resources or buffers. Cc: Signed-off-by: Thomas Hellstrom Reviewed-by: Brian Paul Reviewed-by: Sinclair Yeh --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 28 +++++++++++++++++++--------- drivers/gpu/drm/vmwgfx/vmwgfx_kms.h | 12 +++++++++--- drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c | 5 +++-- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 5 +++-- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index b3d62aa01a9b..3c824fd7cbf3 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -31,7 +31,6 @@ #include #include - /* Might need a hrtimer here? */ #define VMWGFX_PRESENT_RATE ((HZ / 60 > 0) ? HZ / 60 : 1) @@ -2517,9 +2516,12 @@ void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, * Helper to be used if an error forces the caller to undo the actions of * vmw_kms_helper_resource_prepare. */ -void vmw_kms_helper_resource_revert(struct vmw_resource *res) +void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx) { - vmw_kms_helper_buffer_revert(res->backup); + struct vmw_resource *res = ctx->res; + + vmw_kms_helper_buffer_revert(ctx->buf); + vmw_dmabuf_unreference(&ctx->buf); vmw_resource_unreserve(res, false, NULL, 0); mutex_unlock(&res->dev_priv->cmdbuf_mutex); } @@ -2536,10 +2538,14 @@ void vmw_kms_helper_resource_revert(struct vmw_resource *res) * interrupted by a signal. */ int vmw_kms_helper_resource_prepare(struct vmw_resource *res, - bool interruptible) + bool interruptible, + struct vmw_validation_ctx *ctx) { int ret = 0; + ctx->buf = NULL; + ctx->res = res; + if (interruptible) ret = mutex_lock_interruptible(&res->dev_priv->cmdbuf_mutex); else @@ -2558,6 +2564,8 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res, res->dev_priv->has_mob); if (ret) goto out_unreserve; + + ctx->buf = vmw_dmabuf_reference(res->backup); } ret = vmw_resource_validate(res); if (ret) @@ -2565,7 +2573,7 @@ int vmw_kms_helper_resource_prepare(struct vmw_resource *res, return 0; out_revert: - vmw_kms_helper_buffer_revert(res->backup); + vmw_kms_helper_buffer_revert(ctx->buf); out_unreserve: vmw_resource_unreserve(res, false, NULL, 0); out_unlock: @@ -2581,11 +2589,13 @@ out_unlock: * @out_fence: Optional pointer to a fence pointer. If non-NULL, a * ref-counted fence pointer is returned here. */ -void vmw_kms_helper_resource_finish(struct vmw_resource *res, - struct vmw_fence_obj **out_fence) +void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx, + struct vmw_fence_obj **out_fence) { - if (res->backup || out_fence) - vmw_kms_helper_buffer_finish(res->dev_priv, NULL, res->backup, + struct vmw_resource *res = ctx->res; + + if (ctx->buf || out_fence) + vmw_kms_helper_buffer_finish(res->dev_priv, NULL, ctx->buf, out_fence, NULL); vmw_resource_unreserve(res, false, NULL, 0); diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h index 948362c43c73..3d2ca280eaa7 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.h @@ -240,6 +240,11 @@ struct vmw_display_unit { int set_gui_y; }; +struct vmw_validation_ctx { + struct vmw_resource *res; + struct vmw_dma_buffer *buf; +}; + #define vmw_crtc_to_du(x) \ container_of(x, struct vmw_display_unit, crtc) #define vmw_connector_to_du(x) \ @@ -296,9 +301,10 @@ void vmw_kms_helper_buffer_finish(struct vmw_private *dev_priv, struct drm_vmw_fence_rep __user * user_fence_rep); int vmw_kms_helper_resource_prepare(struct vmw_resource *res, - bool interruptible); -void vmw_kms_helper_resource_revert(struct vmw_resource *res); -void vmw_kms_helper_resource_finish(struct vmw_resource *res, + bool interruptible, + struct vmw_validation_ctx *ctx); +void vmw_kms_helper_resource_revert(struct vmw_validation_ctx *ctx); +void vmw_kms_helper_resource_finish(struct vmw_validation_ctx *ctx, struct vmw_fence_obj **out_fence); int vmw_kms_readback(struct vmw_private *dev_priv, struct drm_file *file_priv, diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c index 63a4cd794b73..3ec9eae831b8 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_scrn.c @@ -909,12 +909,13 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv, struct vmw_framebuffer_surface *vfbs = container_of(framebuffer, typeof(*vfbs), base); struct vmw_kms_sou_surface_dirty sdirty; + struct vmw_validation_ctx ctx; int ret; if (!srf) srf = &vfbs->surface->res; - ret = vmw_kms_helper_resource_prepare(srf, true); + ret = vmw_kms_helper_resource_prepare(srf, true, &ctx); if (ret) return ret; @@ -933,7 +934,7 @@ int vmw_kms_sou_do_surface_dirty(struct vmw_private *dev_priv, ret = vmw_kms_helper_dirty(dev_priv, framebuffer, clips, vclips, dest_x, dest_y, num_clips, inc, &sdirty.base); - vmw_kms_helper_resource_finish(srf, out_fence); + vmw_kms_helper_resource_finish(&ctx, out_fence); return ret; } diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c index b68d74888ab1..6b969e5dea2a 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c @@ -980,12 +980,13 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, struct vmw_framebuffer_surface *vfbs = container_of(framebuffer, typeof(*vfbs), base); struct vmw_stdu_dirty sdirty; + struct vmw_validation_ctx ctx; int ret; if (!srf) srf = &vfbs->surface->res; - ret = vmw_kms_helper_resource_prepare(srf, true); + ret = vmw_kms_helper_resource_prepare(srf, true, &ctx); if (ret) return ret; @@ -1008,7 +1009,7 @@ int vmw_kms_stdu_surface_dirty(struct vmw_private *dev_priv, dest_x, dest_y, num_clips, inc, &sdirty.base); out_finish: - vmw_kms_helper_resource_finish(srf, out_fence); + vmw_kms_helper_resource_finish(&ctx, out_fence); return ret; } From 7c181f4fcdc62e5dc7a87fd33387d322262c3b52 Mon Sep 17 00:00:00 2001 From: Ben Caradoc-Davies Date: Mon, 19 Mar 2018 12:57:44 +1300 Subject: [PATCH 864/942] mac80211: add ieee80211_hw flag for QoS NDP support Commit 7b6ddeaf27ec ("mac80211: use QoS NDP for AP probing") added an argument qos_ok to ieee80211_nullfunc_get to support QoS NDP. Despite the claim in the commit log "Change all the drivers to *not* allow QoS NDP for now, even though it looks like most of them should be OK with that", this commit enables QoS NDP in response to beacons (see change to mlme.c:ieee80211_send_nullfunc), causing ath9k_htc to lose IP connectivity. See: https://patchwork.kernel.org/patch/10241109/ https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891060 Introduce a hardware flag to allow such buggy drivers to override the correct default behaviour of mac80211 of sending QoS NDP packets. Signed-off-by: Ben Caradoc-Davies Signed-off-by: Johannes Berg --- include/net/mac80211.h | 4 ++++ net/mac80211/debugfs.c | 1 + net/mac80211/mlme.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index c96511fa9198..2b581bd93812 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -2063,6 +2063,9 @@ struct ieee80211_txq { * @IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA: Hardware supports buffer STA on * TDLS links. * + * @IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP: The driver (or firmware) doesn't + * support QoS NDP for AP probing - that's most likely a driver bug. + * * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags { @@ -2106,6 +2109,7 @@ enum ieee80211_hw_flags { IEEE80211_HW_REPORTS_LOW_ACK, IEEE80211_HW_SUPPORTS_TX_FRAG, IEEE80211_HW_SUPPORTS_TDLS_BUFFER_STA, + IEEE80211_HW_DOESNT_SUPPORT_QOS_NDP, /* keep last, obviously */ NUM_IEEE80211_HW_FLAGS diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 1f466d12a6bc..94c7ee9df33b 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -212,6 +212,7 @@ static const char *hw_flag_names[] = { FLAG(REPORTS_LOW_ACK), FLAG(SUPPORTS_TX_FRAG), FLAG(SUPPORTS_TDLS_BUFFER_STA), + FLAG(DOESNT_SUPPORT_QOS_NDP), #undef FLAG }; diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 39b660b9a908..5f303abac5ad 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -896,7 +896,8 @@ void ieee80211_send_nullfunc(struct ieee80211_local *local, struct ieee80211_hdr_3addr *nullfunc; struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; - skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif, true); + skb = ieee80211_nullfunc_get(&local->hw, &sdata->vif, + !ieee80211_hw_check(&local->hw, DOESNT_SUPPORT_QOS_NDP)); if (!skb) return; From d58ac803cfbb92ede501409dd6afe9abb111d4f1 Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Wed, 21 Mar 2018 11:49:40 +0200 Subject: [PATCH 865/942] mmc: sdhci-acpi: Fix IRQ 0 Zero is a valid IRQ number and is being used on some CHT tablets. Stop treating it as an error. Reported-by: Luke Ross Fixes: 1b7ba57ecc86 ("mmc: sdhci-acpi: Handle return value of platform_get_irq") Cc: Arvind Yadav Signed-off-by: Adrian Hunter Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson --- drivers/mmc/host/sdhci-acpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c index 4065da58789d..32321bd596d8 100644 --- a/drivers/mmc/host/sdhci-acpi.c +++ b/drivers/mmc/host/sdhci-acpi.c @@ -680,7 +680,7 @@ static int sdhci_acpi_probe(struct platform_device *pdev) host->hw_name = "ACPI"; host->ops = &sdhci_acpi_ops_dflt; host->irq = platform_get_irq(pdev, 0); - if (host->irq <= 0) { + if (host->irq < 0) { err = -EINVAL; goto err_free; } From 4ea5aca27eab1c495985eb2a30b65b78cbf99404 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Wed, 21 Mar 2018 08:05:18 +0100 Subject: [PATCH 866/942] mac80211_hwsim: Set wmediumd for new radios Set the wmediumd to the net's wmediumd when the radio gets created. Radios created after HWSIM_CMD_REGISTER don't currently get their data->wmediumd set and the userspace would need to reconnect to netlink to be able to call HWSIM_CMD_REGISTER again. Alternatively I think data->netgroup and data->wmedium could be replaced with a pointer to hwsim_net. Signed-off-by: Andrew Zaborowski Signed-off-by: Johannes Berg --- drivers/net/wireless/mac80211_hwsim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index 6e0af815f25e..35b21f8152bb 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c @@ -2727,6 +2727,7 @@ static int mac80211_hwsim_new_radio(struct genl_info *info, mutex_init(&data->mutex); data->netgroup = hwsim_net_get_netgroup(net); + data->wmediumd = hwsim_net_get_wmediumd(net); /* Enable frame retransmissions for lossy channels */ hw->max_rates = 4; From 60b01bcce97191f473fa869df2713143936d6ef4 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 21 Mar 2018 11:00:14 +0100 Subject: [PATCH 867/942] ath9k_htc: use non-QoS NDP for AP probing When switching mac80211 to use QoS NDP, it turned out that ath9k_htc is somehow broken by this, e.g. see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=891060. Fix this by using the new mac80211 flag to go back to the old, incorrect, behaviour for this driver. Fixes: 7b6ddeaf27ec ("mac80211: use QoS NDP for AP probing") Reported-by: Ben Caradoc-Davies Acked-by: Kalle Valo Signed-off-by: Johannes Berg --- drivers/net/wireless/ath/ath9k/htc_drv_init.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c index e89e5ef2c2a4..f246e9ed4a81 100644 --- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c +++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c @@ -729,6 +729,7 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv, ieee80211_hw_set(hw, SPECTRUM_MGMT); ieee80211_hw_set(hw, SIGNAL_DBM); ieee80211_hw_set(hw, AMPDU_AGGREGATION); + ieee80211_hw_set(hw, DOESNT_SUPPORT_QOS_NDP); if (ath9k_ps_enable) ieee80211_hw_set(hw, SUPPORTS_PS); From 3a088dd1b72dc0fc2e7ee1fca76e26290c5261a0 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 20 Mar 2018 10:04:48 +0000 Subject: [PATCH 868/942] drm/i915: Specify which engines to reset following semaphore/event lockups If the GPU is stuck waiting for an event or for a semaphore, we need to reset the GPU in order to recover. We have to tell the reset routine which engines we want reset, but we were still using the old interface and declaring it as "not-fatal". Fixes: 14b730fcb8d9 ("drm/i915/tdr: Prepare error handler to accept mask of hung engines") Signed-off-by: Chris Wilson Cc: Mika Kuoppala Cc: Michel Thierry Reviewed-by: Michel Thierry Link: https://patchwork.freedesktop.org/patch/msgid/20180320100449.1360-1-chris@chris-wilson.co.uk (cherry picked from commit ca98317b89428e6ac17be0938b467ed78654dd56) Signed-off-by: Rodrigo Vivi --- drivers/gpu/drm/i915/intel_hangcheck.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_hangcheck.c b/drivers/gpu/drm/i915/intel_hangcheck.c index 348a4f7ffb67..53747318f4a7 100644 --- a/drivers/gpu/drm/i915/intel_hangcheck.c +++ b/drivers/gpu/drm/i915/intel_hangcheck.c @@ -246,7 +246,7 @@ engine_stuck(struct intel_engine_cs *engine, u64 acthd) */ tmp = I915_READ_CTL(engine); if (tmp & RING_WAIT) { - i915_handle_error(dev_priv, 0, + i915_handle_error(dev_priv, BIT(engine->id), "Kicking stuck wait on %s", engine->name); I915_WRITE_CTL(engine, tmp); @@ -258,7 +258,7 @@ engine_stuck(struct intel_engine_cs *engine, u64 acthd) default: return ENGINE_DEAD; case 1: - i915_handle_error(dev_priv, 0, + i915_handle_error(dev_priv, ALL_ENGINES, "Kicking stuck semaphore on %s", engine->name); I915_WRITE_CTL(engine, tmp); From 896196dc4e419a9d0782404e0befac17d638fc01 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 21 Mar 2018 14:06:23 -0700 Subject: [PATCH 869/942] libnvdimm, region: hide persistence_domain when unknown Similar to other region attributes, do not emit the persistence_domain attribute if its contents are empty. Fixes: 96c3a239054a ("libnvdimm: expose platform persistence attr...") Cc: Dave Jiang Reviewed-by: Ross Zwisler Signed-off-by: Dan Williams --- drivers/nvdimm/region_devs.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index e6d01911e092..a8e9d428c0a5 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -593,6 +593,13 @@ static umode_t region_visible(struct kobject *kobj, struct attribute *a, int n) return 0; } + if (a == &dev_attr_persistence_domain.attr) { + if ((nd_region->flags & (BIT(ND_REGION_PERSIST_CACHE) + | BIT(ND_REGION_PERSIST_MEMCTRL))) == 0) + return 0; + return a->mode; + } + if (a != &dev_attr_set_cookie.attr && a != &dev_attr_available_size.attr) return a->mode; From 214cbc14734958fe533916fdb4194f5983ad4bc4 Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Fri, 16 Mar 2018 21:27:28 +0100 Subject: [PATCH 870/942] MIPS: lantiq: Fix Danube USB clock On Danube the USB0 controller registers are at 1e101000 and the USB0 PHY register is at 1f203018 similar to all other lantiq SoCs. Activate the USB controller gating clock thorough the USB controller driver and not the PHY. This fixes a problem introduced in a previous commit. Fixes: dea54fbad332 ("phy: Add an USB PHY driver for the Lantiq SoCs using the RCU module") Signed-off-by: Mathias Kresin Signed-off-by: Hauke Mehrtens Acked-by: Martin Blumenstingl Cc: Ralf Baechle Cc: John Crispin Cc: linux-mips@linux-mips.org Cc: # 4.14+ Patchwork: https://patchwork.linux-mips.org/patch/18816/ Signed-off-by: James Hogan --- arch/mips/lantiq/xway/sysctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c index 52500d3b7004..f11f1dd10493 100644 --- a/arch/mips/lantiq/xway/sysctrl.c +++ b/arch/mips/lantiq/xway/sysctrl.c @@ -560,7 +560,7 @@ void __init ltq_soc_init(void) } else { clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(), ltq_danube_fpi_hz(), ltq_danube_pp32_hz()); - clkdev_add_pmu("1f203018.usb2-phy", "ctrl", 1, 0, PMU_USB0); + clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0); clkdev_add_pmu("1f203018.usb2-phy", "phy", 1, 0, PMU_USB0_P); clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO); clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU); From 3223a5a7d3a606dcb7d9190a788b9544a45441ee Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Fri, 16 Mar 2018 21:27:29 +0100 Subject: [PATCH 871/942] MIPS: lantiq: Enable AHB Bus for USB On Danube and AR9 the USB core is connected though a AHB bus to the main system cross bar, hence we need to enable the gating clock of the AHB Bus as well to make the USB controller work. Fixes: dea54fbad332 ("phy: Add an USB PHY driver for the Lantiq SoCs using the RCU module") Signed-off-by: Mathias Kresin Signed-off-by: Hauke Mehrtens Acked-by: Martin Blumenstingl Cc: Ralf Baechle Cc: John Crispin Cc: linux-mips@linux-mips.org Cc: # 4.14+ Patchwork: https://patchwork.linux-mips.org/patch/18814/ Signed-off-by: James Hogan --- arch/mips/lantiq/xway/sysctrl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/mips/lantiq/xway/sysctrl.c b/arch/mips/lantiq/xway/sysctrl.c index f11f1dd10493..e0af39b33e28 100644 --- a/arch/mips/lantiq/xway/sysctrl.c +++ b/arch/mips/lantiq/xway/sysctrl.c @@ -549,9 +549,9 @@ void __init ltq_soc_init(void) clkdev_add_static(ltq_ar9_cpu_hz(), ltq_ar9_fpi_hz(), ltq_ar9_fpi_hz(), CLOCK_250M); clkdev_add_pmu("1f203018.usb2-phy", "phy", 1, 0, PMU_USB0_P); - clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0); + clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0 | PMU_AHBM); clkdev_add_pmu("1f203034.usb2-phy", "phy", 1, 0, PMU_USB1_P); - clkdev_add_pmu("1e106000.usb", "otg", 1, 0, PMU_USB1); + clkdev_add_pmu("1e106000.usb", "otg", 1, 0, PMU_USB1 | PMU_AHBM); clkdev_add_pmu("1e180000.etop", "switch", 1, 0, PMU_SWITCH); clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO); clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU); @@ -560,7 +560,7 @@ void __init ltq_soc_init(void) } else { clkdev_add_static(ltq_danube_cpu_hz(), ltq_danube_fpi_hz(), ltq_danube_fpi_hz(), ltq_danube_pp32_hz()); - clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0); + clkdev_add_pmu("1e101000.usb", "otg", 1, 0, PMU_USB0 | PMU_AHBM); clkdev_add_pmu("1f203018.usb2-phy", "phy", 1, 0, PMU_USB0_P); clkdev_add_pmu("1e103000.sdio", NULL, 1, 0, PMU_SDIO); clkdev_add_pmu("1e103100.deu", NULL, 1, 0, PMU_DEU); From a821328c2f3003b908880792d71b2781b44fa53c Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Fri, 16 Mar 2018 21:27:30 +0100 Subject: [PATCH 872/942] MIPS: lantiq: ase: Enable MFD_SYSCON Enable syscon to use it for the RCU MFD on Amazon SE as well. The Amazon SE also has similar reset controller system as Danube and XWAY and use their drivers mostly. As these drivers now need syscon also activate the syscon subsystem for for Amazon SE. Fixes: 2b6639d4c794 ("MIPS: lantiq: Enable MFD_SYSCON to be able to use it for the RCU MFD") Signed-off-by: Mathias Kresin Signed-off-by: Hauke Mehrtens Acked-by: Martin Blumenstingl Cc: Ralf Baechle Cc: John Crispin Cc: linux-mips@linux-mips.org Cc: # 4.14+ Patchwork: https://patchwork.linux-mips.org/patch/18817/ Signed-off-by: James Hogan --- arch/mips/lantiq/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/mips/lantiq/Kconfig b/arch/mips/lantiq/Kconfig index 692ae85a3e3d..8e3a1fc2bc39 100644 --- a/arch/mips/lantiq/Kconfig +++ b/arch/mips/lantiq/Kconfig @@ -13,6 +13,8 @@ choice config SOC_AMAZON_SE bool "Amazon SE" select SOC_TYPE_XWAY + select MFD_SYSCON + select MFD_CORE config SOC_XWAY bool "XWAY" From 924613d3a87feaa886dd1b18496463c5359e7965 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 19 Mar 2018 14:32:59 +0000 Subject: [PATCH 873/942] bnx2x: fix spelling mistake: "registeration" -> "registration" Trivial fix to spelling mistake in BNX2X_ERR error message text Signed-off-by: Colin Ian King Acked-by: Sudarsana Kalluru Signed-off-by: David S. Miller --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 74fc9af4aadb..b8388e93520a 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -13913,7 +13913,7 @@ static void bnx2x_register_phc(struct bnx2x *bp) bp->ptp_clock = ptp_clock_register(&bp->ptp_clock_info, &bp->pdev->dev); if (IS_ERR(bp->ptp_clock)) { bp->ptp_clock = NULL; - BNX2X_ERR("PTP clock registeration failed\n"); + BNX2X_ERR("PTP clock registration failed\n"); } } From 3f2176dd7fe9e4eb1444766741fe4ea6535eb6d8 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 19 Mar 2018 14:57:11 +0000 Subject: [PATCH 874/942] qede: fix spelling mistake: "registeration" -> "registration" Trivial fix to spelling mistakes in DP_ERR error message text and comments Signed-off-by: Colin Ian King Signed-off-by: David S. Miller --- drivers/net/ethernet/qlogic/qede/qede_main.c | 4 ++-- drivers/net/ethernet/qlogic/qede/qede_ptp.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/qlogic/qede/qede_main.c b/drivers/net/ethernet/qlogic/qede/qede_main.c index 5c28209e97d0..a01e7d6e5442 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_main.c +++ b/drivers/net/ethernet/qlogic/qede/qede_main.c @@ -288,7 +288,7 @@ int __init qede_init(void) } /* Must register notifier before pci ops, since we might miss - * interface rename after pci probe and netdev registeration. + * interface rename after pci probe and netdev registration. */ ret = register_netdevice_notifier(&qede_netdev_notifier); if (ret) { @@ -988,7 +988,7 @@ static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level, if (rc) goto err3; - /* Prepare the lock prior to the registeration of the netdev, + /* Prepare the lock prior to the registration of the netdev, * as once it's registered we might reach flows requiring it * [it's even possible to reach a flow needing it directly * from there, although it's unlikely]. diff --git a/drivers/net/ethernet/qlogic/qede/qede_ptp.c b/drivers/net/ethernet/qlogic/qede/qede_ptp.c index 9b2280badaf7..02adb513f475 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_ptp.c +++ b/drivers/net/ethernet/qlogic/qede/qede_ptp.c @@ -485,7 +485,7 @@ int qede_ptp_enable(struct qede_dev *edev, bool init_tc) ptp->clock = ptp_clock_register(&ptp->clock_info, &edev->pdev->dev); if (IS_ERR(ptp->clock)) { rc = -EINVAL; - DP_ERR(edev, "PTP clock registeration failed\n"); + DP_ERR(edev, "PTP clock registration failed\n"); goto err2; } From bbc09e7842a5023ba5bc0f8d559b9dd464e44006 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:22 +0100 Subject: [PATCH 875/942] net/sched: fix idr leak on the error path of tcf_bpf_init() when the following command sequence is entered # tc action add action bpf bytecode '4,40 0 0 12,31 0 1 2048,6 0 0 262144,6 0 0 0' index 100 RTNETLINK answers: Invalid argument We have an error talking to the kernel # tc action add action bpf bytecode '4,40 0 0 12,21 0 1 2048,6 0 0 262144,6 0 0 0' index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel act_bpf correctly refuses to install the first TC rule, because 31 is not a valid instruction. However, it refuses to install the second TC rule, even if the BPF code is correct. Furthermore, it's no more possible to install any other rule having the same value of 'index' until act_bpf module is unloaded/inserted again. After the idr has been reserved, call tcf_idr_release() instead of tcf_idr_cleanup(), to fix this issue. Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index b3f2c15affa7..9d2cabf1dc7e 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -352,7 +352,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, return res; out: if (res == ACT_P_CREATED) - tcf_idr_cleanup(*act, est); + tcf_idr_release(*act, bind); return ret; } From 60e10b3adc3bac0f6a894c28e0eb1f2d13607362 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:23 +0100 Subject: [PATCH 876/942] net/sched: fix idr leak in the error path of tcf_simp_init() if the kernel fails to duplicate 'sdata', creation of a new action fails with -ENOMEM. However, subsequent attempts to install the same action using the same value of 'index' systematically fail with -ENOSPC, and that value of 'index' will no more be usable by act_simple, until rmmod / insmod of act_simple.ko is done: # tc actions add action simple sdata hello index 100 # tc actions list action simple action order 0: Simple index 100 ref 1 bind 0 # tc actions flush action simple # tc actions add action simple sdata hello index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc actions flush action simple # tc actions add action simple sdata hello index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel # tc actions add action simple sdata hello index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel ... Fix this in the error path of tcf_simp_init(), calling tcf_idr_release() in place of tcf_idr_cleanup(). Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Suggested-by: Cong Wang Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index 425eac11f6da..b1f38063ada0 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c @@ -121,7 +121,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, d = to_defact(*a); ret = alloc_defdata(d, defdata); if (ret < 0) { - tcf_idr_cleanup(*a, est); + tcf_idr_release(*a, bind); return ret; } d->tcf_action = parm->action; From 5bf7f8185f7c7112decdfe3d3e5c5d5e67f099a1 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:24 +0100 Subject: [PATCH 877/942] net/sched: fix idr leak in the error path of tcf_act_police_init() tcf_act_police_init() can fail after the idr has been successfully reserved (e.g., qdisc_get_rtab() may return NULL). When this happens, subsequent attempts to configure a police rule using the same idr value systematiclly fail with -ENOSPC: # tc action add action police rate 1000 burst 1000 drop index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action add action police rate 1000 burst 1000 drop index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel # tc action add action police rate 1000 burst 1000 drop index 100 RTNETLINK answers: No space left on device ... Fix this in the error path of tcf_act_police_init(), calling tcf_idr_release() in place of tcf_idr_cleanup(). Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_police.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_police.c b/net/sched/act_police.c index 95d3c9097b25..faebf82b99f1 100644 --- a/net/sched/act_police.c +++ b/net/sched/act_police.c @@ -194,7 +194,7 @@ failure: qdisc_put_rtab(P_tab); qdisc_put_rtab(R_tab); if (ret == ACT_P_CREATED) - tcf_idr_cleanup(*a, est); + tcf_idr_release(*a, bind); return err; } From fe9a552e715dfe5167d52deb74ea16335896bdaf Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Wed, 21 Mar 2018 15:12:07 -0700 Subject: [PATCH 878/942] libnvdimm, nfit: fix persistence domain reporting The persistence domain is a point in the platform where once writes reach that destination the platform claims it will make them persistent relative to power loss. In the ACPI NFIT this is currently communicated as 2 bits in the "NFIT - Platform Capabilities Structure". The bits comprise a hierarchy, i.e. bit0 "CPU Cache Flush to NVDIMM Durability on Power Loss Capable" implies bit1 "Memory Controller Flush to NVDIMM Durability on Power Loss Capable". Commit 96c3a239054a "libnvdimm: expose platform persistence attr..." shows the persistence domain as flags, but it's really an enumerated hierarchy. Fix this newly introduced user ABI to show the closest available persistence domain before userspace develops dependencies on seeing, or needing to develop code to tolerate, the raw NFIT flags communicated through the libnvdimm-generic region attribute. Fixes: 96c3a239054a ("libnvdimm: expose platform persistence attr...") Reviewed-by: Dave Jiang Cc: "Rafael J. Wysocki" Cc: Ross Zwisler Signed-off-by: Dan Williams --- drivers/acpi/nfit/core.c | 10 +++++++--- drivers/nvdimm/region_devs.c | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index bbe48ad20886..eb09ef55c38a 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -2675,10 +2675,14 @@ static int acpi_nfit_register_region(struct acpi_nfit_desc *acpi_desc, else ndr_desc->numa_node = NUMA_NO_NODE; - if(acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH) + /* + * Persistence domain bits are hierarchical, if + * ACPI_NFIT_CAPABILITY_CACHE_FLUSH is set then + * ACPI_NFIT_CAPABILITY_MEM_FLUSH is implied. + */ + if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_CACHE_FLUSH) set_bit(ND_REGION_PERSIST_CACHE, &ndr_desc->flags); - - if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH) + else if (acpi_desc->platform_cap & ACPI_NFIT_CAPABILITY_MEM_FLUSH) set_bit(ND_REGION_PERSIST_MEMCTRL, &ndr_desc->flags); list_for_each_entry(nfit_memdev, &acpi_desc->memdevs, list) { diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c index a8e9d428c0a5..1593e1806b16 100644 --- a/drivers/nvdimm/region_devs.c +++ b/drivers/nvdimm/region_devs.c @@ -532,11 +532,13 @@ static ssize_t persistence_domain_show(struct device *dev, struct device_attribute *attr, char *buf) { struct nd_region *nd_region = to_nd_region(dev); - unsigned long flags = nd_region->flags; - return sprintf(buf, "%s%s\n", - flags & BIT(ND_REGION_PERSIST_CACHE) ? "cpu_cache " : "", - flags & BIT(ND_REGION_PERSIST_MEMCTRL) ? "memory_controller " : ""); + if (test_bit(ND_REGION_PERSIST_CACHE, &nd_region->flags)) + return sprintf(buf, "cpu_cache\n"); + else if (test_bit(ND_REGION_PERSIST_MEMCTRL, &nd_region->flags)) + return sprintf(buf, "memory_controller\n"); + else + return sprintf(buf, "\n"); } static DEVICE_ATTR_RO(persistence_domain); From 94fa3f929ec0c048b1f3658cc335b940df4f6d22 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:25 +0100 Subject: [PATCH 879/942] net/sched: fix idr leak in the error path of tcp_pedit_init() tcf_pedit_init() can fail to allocate 'keys' after the idr has been successfully reserved. When this happens, subsequent attempts to configure a pedit rule using the same idr value systematically fail with -ENOSPC: # tc action add action pedit munge ip ttl set 63 index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action add action pedit munge ip ttl set 63 index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel # tc action add action pedit munge ip ttl set 63 index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel ... Fix this in the error path of tcf_act_pedit_init(), calling tcf_idr_release() in place of tcf_idr_cleanup(). Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_pedit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c index 349beaffb29e..fef08835f26d 100644 --- a/net/sched/act_pedit.c +++ b/net/sched/act_pedit.c @@ -176,7 +176,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, p = to_pedit(*a); keys = kmalloc(ksize, GFP_KERNEL); if (keys == NULL) { - tcf_idr_cleanup(*a, est); + tcf_idr_release(*a, bind); kfree(keys_ex); return -ENOMEM; } From 1e46ef1762bb2e52f0f996131a4d16ed4e9fd065 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:26 +0100 Subject: [PATCH 880/942] net/sched: fix idr leak in the error path of __tcf_ipt_init() __tcf_ipt_init() can fail after the idr has been successfully reserved. When this happens, subsequent attempts to configure xt/ipt rules using the same idr value systematically fail with -ENOSPC: # tc action add action xt -j LOG --log-prefix test1 index 100 tablename: mangle hook: NF_IP_POST_ROUTING target: LOG level warning prefix "test1" index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel Command "(null)" is unknown, try "tc actions help". # tc action add action xt -j LOG --log-prefix test1 index 100 tablename: mangle hook: NF_IP_POST_ROUTING target: LOG level warning prefix "test1" index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel Command "(null)" is unknown, try "tc actions help". # tc action add action xt -j LOG --log-prefix test1 index 100 tablename: mangle hook: NF_IP_POST_ROUTING target: LOG level warning prefix "test1" index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel ... Fix this in the error path of __tcf_ipt_init(), calling tcf_idr_release() in place of tcf_idr_cleanup(). Since tcf_ipt_release() can now be called when tcfi_t is NULL, we also need to protect calls to ipt_destroy_target() to avoid NULL pointer dereference. Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_ipt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/sched/act_ipt.c b/net/sched/act_ipt.c index 06e380ae0928..7e06b9b62613 100644 --- a/net/sched/act_ipt.c +++ b/net/sched/act_ipt.c @@ -80,9 +80,12 @@ static void ipt_destroy_target(struct xt_entry_target *t) static void tcf_ipt_release(struct tc_action *a) { struct tcf_ipt *ipt = to_ipt(a); - ipt_destroy_target(ipt->tcfi_t); + + if (ipt->tcfi_t) { + ipt_destroy_target(ipt->tcfi_t); + kfree(ipt->tcfi_t); + } kfree(ipt->tcfi_tname); - kfree(ipt->tcfi_t); } static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = { @@ -187,7 +190,7 @@ err2: kfree(tname); err1: if (ret == ACT_P_CREATED) - tcf_idr_cleanup(*a, est); + tcf_idr_release(*a, bind); return err; } From d7f20015736048f494988093b59fe513dc232ce9 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:27 +0100 Subject: [PATCH 881/942] net/sched: fix idr leak in the error path of tcf_vlan_init() tcf_vlan_init() can fail after the idr has been successfully reserved. When this happens, every subsequent attempt to configure vlan rules using the same idr value will systematically fail with -ENOSPC, unless the first attempt was done using the 'replace' keyword. # tc action add action vlan pop index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action add action vlan pop index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel # tc action add action vlan pop index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel ... Fix this in tcf_vlan_init(), ensuring that tcf_idr_release() is called on the error path when the idr has been reserved, but not yet inserted. Also, don't test 'ovr' in the error path, to avoid a 'replace' failure implicitly become a 'delete' that leaks refcount in act_vlan module: # rmmod act_vlan; modprobe act_vlan # tc action add action vlan push id 5 index 100 # tc action replace action vlan push id 7 index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action list action vlan # # rmmod act_vlan rmmod: ERROR: Module act_vlan is in use Fixes: 4c5b9d9642c8 ("act_vlan: VLAN action rewrite to use RCU lock/unlock and update") Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_vlan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_vlan.c b/net/sched/act_vlan.c index c2914e9a4a6f..c49cb61adedf 100644 --- a/net/sched/act_vlan.c +++ b/net/sched/act_vlan.c @@ -195,7 +195,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ASSERT_RTNL(); p = kzalloc(sizeof(*p), GFP_KERNEL); if (!p) { - if (ovr) + if (ret == ACT_P_CREATED) tcf_idr_release(*a, bind); return -ENOMEM; } From f29cdfbe33d6915ba8056179b0041279a67e3647 Mon Sep 17 00:00:00 2001 From: Davide Caratti Date: Mon, 19 Mar 2018 15:31:28 +0100 Subject: [PATCH 882/942] net/sched: fix idr leak in the error path of tcf_skbmod_init() tcf_skbmod_init() can fail after the idr has been successfully reserved. When this happens, every subsequent attempt to configure skbmod rules using the same idr value will systematically fail with -ENOSPC, unless the first attempt was done using the 'replace' keyword: # tc action add action skbmod swap mac index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action add action skbmod swap mac index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel # tc action add action skbmod swap mac index 100 RTNETLINK answers: No space left on device We have an error talking to the kernel ... Fix this in tcf_skbmod_init(), ensuring that tcf_idr_release() is called on the error path when the idr has been reserved, but not yet inserted. Also, don't test 'ovr' in the error path, to avoid a 'replace' failure implicitly become a 'delete' that leaks refcount in act_skbmod module: # rmmod act_skbmod; modprobe act_skbmod # tc action add action skbmod swap mac index 100 # tc action add action skbmod swap mac continue index 100 RTNETLINK answers: File exists We have an error talking to the kernel # tc action replace action skbmod swap mac continue index 100 RTNETLINK answers: Cannot allocate memory We have an error talking to the kernel # tc action list action skbmod # # rmmod act_skbmod rmmod: ERROR: Module act_skbmod is in use Fixes: 65a206c01e8e ("net/sched: Change act_api and act_xxx modules to use IDR") Acked-by: Jamal Hadi Salim Signed-off-by: Davide Caratti Signed-off-by: David S. Miller --- net/sched/act_skbmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sched/act_skbmod.c b/net/sched/act_skbmod.c index d09565d6433e..7b0700f52b50 100644 --- a/net/sched/act_skbmod.c +++ b/net/sched/act_skbmod.c @@ -152,7 +152,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, ASSERT_RTNL(); p = kzalloc(sizeof(struct tcf_skbmod_params), GFP_KERNEL); if (unlikely(!p)) { - if (ovr) + if (ret == ACT_P_CREATED) tcf_idr_release(*a, bind); return -ENOMEM; } From 891731f6a5dbe508d12443175a7e166a2fba616a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 20 Mar 2018 19:29:51 +1100 Subject: [PATCH 883/942] MIPS: ralink: Remove ralink_halt() ralink_halt() does nothing that machine_halt() doesn't already do, so it adds no value. It actually causes incorrect behaviour due to the "unreachable()" at the end. This tells the compiler that the end of the function will never be reached, which isn't true. The compiler responds by not adding a 'return' instruction, so control simply moves on to whatever bytes come afterwards in memory. In my tested, that was the ralink_restart() function. This means that an attempt to 'halt' the machine would actually cause a reboot. So remove ralink_halt() so that a 'halt' really does halt. Fixes: c06e836ada59 ("MIPS: ralink: adds reset code") Signed-off-by: NeilBrown Cc: John Crispin Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: # 3.9+ Patchwork: https://patchwork.linux-mips.org/patch/18851/ Signed-off-by: James Hogan --- arch/mips/ralink/reset.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/arch/mips/ralink/reset.c b/arch/mips/ralink/reset.c index 64543d66e76b..e9531fea23a2 100644 --- a/arch/mips/ralink/reset.c +++ b/arch/mips/ralink/reset.c @@ -96,16 +96,9 @@ static void ralink_restart(char *command) unreachable(); } -static void ralink_halt(void) -{ - local_irq_disable(); - unreachable(); -} - static int __init mips_reboot_setup(void) { _machine_restart = ralink_restart; - _machine_halt = ralink_halt; return 0; } From a63d706ea719190a79a6c769e898f70680044d3e Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Wed, 21 Mar 2018 14:02:10 +1100 Subject: [PATCH 884/942] MIPS: ralink: Fix booting on MT7621 Since commit 3af5a67c86a3 ("MIPS: Fix early CM probing") the MT7621 has not been able to boot. This commit caused mips_cm_probe() to be called before mt7621.c::proc_soc_init(). prom_soc_init() has a comment explaining that mips_cm_probe() "wipes out the bootloader config" and means that configuration registers are no longer available. It has some code to re-enable this config. Before this re-enable code is run, the sysc register cannot be read, so when SYSC_REG_CHIP_NAME0 is read, a garbage value is returned and panic() is called. If we move the config-repair code to the top of prom_soc_init(), the registers can be read and boot can proceed. Very occasionally, the first register read after the reconfiguration returns garbage, so add a call to __sync(). Fixes: 3af5a67c86a3 ("MIPS: Fix early CM probing") Signed-off-by: NeilBrown Reviewed-by: Matt Redfearn Cc: John Crispin Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: # 4.5+ Patchwork: https://patchwork.linux-mips.org/patch/18859/ Signed-off-by: James Hogan --- arch/mips/ralink/mt7621.c | 42 ++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/arch/mips/ralink/mt7621.c b/arch/mips/ralink/mt7621.c index 1b274742077d..d2718de60b9b 100644 --- a/arch/mips/ralink/mt7621.c +++ b/arch/mips/ralink/mt7621.c @@ -170,6 +170,28 @@ void prom_soc_init(struct ralink_soc_info *soc_info) u32 n1; u32 rev; + /* Early detection of CMP support */ + mips_cm_probe(); + mips_cpc_probe(); + + if (mips_cps_numiocu(0)) { + /* + * mips_cm_probe() wipes out bootloader + * config for CM regions and we have to configure them + * again. This SoC cannot talk to pamlbus devices + * witout proper iocu region set up. + * + * FIXME: it would be better to do this with values + * from DT, but we need this very early because + * without this we cannot talk to pretty much anything + * including serial. + */ + write_gcr_reg0_base(MT7621_PALMBUS_BASE); + write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE | + CM_GCR_REGn_MASK_CMTGT_IOCU0); + __sync(); + } + n0 = __raw_readl(sysc + SYSC_REG_CHIP_NAME0); n1 = __raw_readl(sysc + SYSC_REG_CHIP_NAME1); @@ -194,26 +216,6 @@ void prom_soc_init(struct ralink_soc_info *soc_info) rt2880_pinmux_data = mt7621_pinmux_data; - /* Early detection of CMP support */ - mips_cm_probe(); - mips_cpc_probe(); - - if (mips_cps_numiocu(0)) { - /* - * mips_cm_probe() wipes out bootloader - * config for CM regions and we have to configure them - * again. This SoC cannot talk to pamlbus devices - * witout proper iocu region set up. - * - * FIXME: it would be better to do this with values - * from DT, but we need this very early because - * without this we cannot talk to pretty much anything - * including serial. - */ - write_gcr_reg0_base(MT7621_PALMBUS_BASE); - write_gcr_reg0_mask(~MT7621_PALMBUS_SIZE | - CM_GCR_REGn_MASK_CMTGT_IOCU0); - } if (!register_cps_smp_ops()) return; From b53117c0b881d78d5d66a7e1be11d62a077c1e25 Mon Sep 17 00:00:00 2001 From: John Hsu Date: Wed, 21 Mar 2018 12:16:32 +0800 Subject: [PATCH 885/942] ASoC: nau8824: recover system clock when device changes User reports an issue in Ubuntu about the device switch upon playback. We find the FLL will disalbe when switching headphone to speaker. The pulseaudio will stop the headphone and close its power. Then, it just opens the speaker and turn on its power. Therefore, the supply of system clock does the OFF event and disables FLL. But the FLL doesn't enable again when the speaker powers on. The patch adds the recovery of system clock to enable FLL again for this case. And it covers the case that system clock from MCLK. Signed-off-by: John Hsu Signed-off-by: Mark Brown --- sound/soc/codecs/nau8824.c | 40 +++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/nau8824.c b/sound/soc/codecs/nau8824.c index 4d9148a6a080..637e9527805f 100644 --- a/sound/soc/codecs/nau8824.c +++ b/sound/soc/codecs/nau8824.c @@ -489,8 +489,12 @@ static int system_clock_control(struct snd_soc_dapm_widget *w, { struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); + struct regmap *regmap = nau8824->regmap; + unsigned int value; + bool clk_fll, error; if (SND_SOC_DAPM_EVENT_OFF(event)) { + dev_dbg(nau8824->dev, "system clock control : POWER OFF\n"); /* Set clock source to disable or internal clock before the * playback or capture end. Codec needs clock for Jack * detection and button press if jack inserted; otherwise, @@ -502,7 +506,40 @@ static int system_clock_control(struct snd_soc_dapm_widget *w, } else { nau8824_config_sysclk(nau8824, NAU8824_CLK_DIS, 0); } + } else { + dev_dbg(nau8824->dev, "system clock control : POWER ON\n"); + /* Check the clock source setting is proper or not + * no matter the source is from FLL or MCLK. + */ + regmap_read(regmap, NAU8824_REG_FLL1, &value); + clk_fll = value & NAU8824_FLL_RATIO_MASK; + /* It's error to use internal clock when playback */ + regmap_read(regmap, NAU8824_REG_FLL6, &value); + error = value & NAU8824_DCO_EN; + if (!error) { + /* Check error depending on source is FLL or MCLK. */ + regmap_read(regmap, NAU8824_REG_CLK_DIVIDER, &value); + if (clk_fll) + error = !(value & NAU8824_CLK_SRC_VCO); + else + error = value & NAU8824_CLK_SRC_VCO; + } + /* Recover the clock source setting if error. */ + if (error) { + if (clk_fll) { + regmap_update_bits(regmap, + NAU8824_REG_FLL6, NAU8824_DCO_EN, 0); + regmap_update_bits(regmap, + NAU8824_REG_CLK_DIVIDER, + NAU8824_CLK_SRC_MASK, + NAU8824_CLK_SRC_VCO); + } else { + nau8824_config_sysclk(nau8824, + NAU8824_CLK_MCLK, 0); + } + } } + return 0; } @@ -591,7 +628,8 @@ static const struct snd_kcontrol_new nau8824_dacr_mux = static const struct snd_soc_dapm_widget nau8824_dapm_widgets[] = { SND_SOC_DAPM_SUPPLY("System Clock", SND_SOC_NOPM, 0, 0, - system_clock_control, SND_SOC_DAPM_POST_PMD), + system_clock_control, SND_SOC_DAPM_POST_PMD | + SND_SOC_DAPM_POST_PMU), SND_SOC_DAPM_INPUT("HSMIC1"), SND_SOC_DAPM_INPUT("HSMIC2"), From 834814e80268c818f354c8f402e0c6604ed75589 Mon Sep 17 00:00:00 2001 From: Alex Williamson Date: Wed, 21 Mar 2018 22:50:19 -0600 Subject: [PATCH 886/942] Revert: "vfio-pci: Mask INTx if a device is not capabable of enabling it" This reverts commit 2170dd04316e0754cbbfa4892a25aead39d225f7 The intent of commit 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it") was to disallow the user from seeing that the device supports INTx if the platform is incapable of enabling it. The detection of this case however incorrectly includes devices which natively do not support INTx, such as SR-IOV VFs, and further discussions reveal gaps even for the target use case. Reported-by: Arjun Vynipadath Fixes: 2170dd04316e ("vfio-pci: Mask INTx if a device is not capabable of enabling it") Signed-off-by: Alex Williamson --- drivers/vfio/pci/vfio_pci.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c index b0f759476900..8a1508a8e481 100644 --- a/drivers/vfio/pci/vfio_pci.c +++ b/drivers/vfio/pci/vfio_pci.c @@ -207,9 +207,6 @@ static bool vfio_pci_nointx(struct pci_dev *pdev) } } - if (!pdev->irq) - return true; - return false; } From 3e4543bf20531d1cdb8672d25b3f2ff6d3d07627 Mon Sep 17 00:00:00 2001 From: Pierre-Yves MORDRET Date: Tue, 13 Mar 2018 17:55:35 +0100 Subject: [PATCH 887/942] dmaengine: stm32-dmamux: fix a potential buffer overflow The bitfield dma_inuse is allocated of size dma_requests bits, thus a valid bit address is from 0 to (dma_requests - 1). When find_first_zero_bit() fails, it returns dma_requests as invalid address. Using such address for the following set_bit() is incorrect and, if dma_requests is a multiple of BITS_PER_LONG, it will cause a buffer overflow. Currently this driver is only used in DT stm32h743.dtsi where a safe value dma_requests=16 is not triggering the buffer overflow. Fixed by checking the return value of find_first_zero_bit() _before_ using it. Signed-off-by: Antonio Borneo Signed-off-by: Pierre-Yves MORDRET Signed-off-by: Vinod Koul --- drivers/dma/stm32-dmamux.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c index 4dbb30cf94ac..b922db90939a 100644 --- a/drivers/dma/stm32-dmamux.c +++ b/drivers/dma/stm32-dmamux.c @@ -118,14 +118,15 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, spin_lock_irqsave(&dmamux->lock, flags); mux->chan_id = find_first_zero_bit(dmamux->dma_inuse, dmamux->dma_requests); - set_bit(mux->chan_id, dmamux->dma_inuse); - spin_unlock_irqrestore(&dmamux->lock, flags); if (mux->chan_id == dmamux->dma_requests) { + spin_unlock_irqrestore(&dmamux->lock, flags); dev_err(&pdev->dev, "Run out of free DMA requests\n"); ret = -ENOMEM; - goto error; + goto error_chan_id; } + set_bit(mux->chan_id, dmamux->dma_inuse); + spin_unlock_irqrestore(&dmamux->lock, flags); /* Look for DMA Master */ for (i = 1, min = 0, max = dmamux->dma_reqs[i]; @@ -173,6 +174,8 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec, error: clear_bit(mux->chan_id, dmamux->dma_inuse); + +error_chan_id: kfree(mux); return ERR_PTR(ret); } From 3b82a4db8eaccce735dffd50b4d4e1578099b8e8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 21 Mar 2018 16:45:53 +0100 Subject: [PATCH 888/942] drm: udl: Properly check framebuffer mmap offsets The memmap options sent to the udl framebuffer driver were not being checked for all sets of possible crazy values. Fix this up by properly bounding the allowed values. Reported-by: Eyal Itkin Cc: stable Signed-off-by: Greg Kroah-Hartman Signed-off-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20180321154553.GA18454@kroah.com --- drivers/gpu/drm/udl/udl_fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c index b5b335c9b2bb..2ebdc6d5a76e 100644 --- a/drivers/gpu/drm/udl/udl_fb.c +++ b/drivers/gpu/drm/udl/udl_fb.c @@ -159,10 +159,15 @@ static int udl_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) { unsigned long start = vma->vm_start; unsigned long size = vma->vm_end - vma->vm_start; - unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; + unsigned long offset; unsigned long page, pos; - if (offset + size > info->fix.smem_len) + if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) + return -EINVAL; + + offset = vma->vm_pgoff << PAGE_SHIFT; + + if (offset > info->fix.smem_len || size > info->fix.smem_len - offset) return -EINVAL; pos = (unsigned long)info->fix.smem_start + offset; From 19b558db12f9f4e45a22012bae7b4783e62224da Mon Sep 17 00:00:00 2001 From: Thomas Gleixner Date: Thu, 15 Feb 2018 17:21:55 +0100 Subject: [PATCH 889/942] posix-timers: Protect posix clock array access against speculation The clockid argument of clockid_to_kclock() comes straight from user space via various syscalls and is used as index into the posix_clocks array. Protect it against spectre v1 array out of bounds speculation. Remove the redundant check for !posix_clock[id] as this is another source for speculation and does not provide any advantage over the return posix_clock[id] path which returns NULL in that case anyway. Signed-off-by: Thomas Gleixner Acked-by: Peter Zijlstra (Intel) Acked-by: Dan Williams Cc: Rasmus Villemoes Cc: Greg KH Cc: stable@vger.kernel.org Cc: Linus Torvalds Cc: David Woodhouse Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1802151718320.1296@nanos.tec.linutronix.de --- kernel/time/posix-timers.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c index 75043046914e..10b7186d0638 100644 --- a/kernel/time/posix-timers.c +++ b/kernel/time/posix-timers.c @@ -50,6 +50,7 @@ #include #include #include +#include #include "timekeeping.h" #include "posix-timers.h" @@ -1346,11 +1347,15 @@ static const struct k_clock * const posix_clocks[] = { static const struct k_clock *clockid_to_kclock(const clockid_t id) { - if (id < 0) + clockid_t idx = id; + + if (id < 0) { return (id & CLOCKFD_MASK) == CLOCKFD ? &clock_posix_dynamic : &clock_posix_cpu; + } - if (id >= ARRAY_SIZE(posix_clocks) || !posix_clocks[id]) + if (id >= ARRAY_SIZE(posix_clocks)) return NULL; - return posix_clocks[id]; + + return posix_clocks[array_index_nospec(idx, ARRAY_SIZE(posix_clocks))]; } From 5df7af85ecd88e8b5f1f31d6456c3cf38a8bbdda Mon Sep 17 00:00:00 2001 From: Kevin Hao Date: Tue, 20 Mar 2018 09:44:52 +0800 Subject: [PATCH 890/942] net: phy: Add general dummy stubs for MMD register access For some phy devices, even though they don't support the MMD extended register access, it does have some side effect if we are trying to read/write the MMD registers via indirect method. So introduce general dummy stubs for MMD register access which these devices can use to avoid such side effect. Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default") Signed-off-by: Kevin Hao Signed-off-by: David S. Miller --- drivers/net/phy/phy_device.c | 17 +++++++++++++++++ include/linux/phy.h | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index fe16f5894092..74664a6c0cdc 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1673,6 +1673,23 @@ int genphy_config_init(struct phy_device *phydev) } EXPORT_SYMBOL(genphy_config_init); +/* This is used for the phy device which doesn't support the MMD extended + * register access, but it does have side effect when we are trying to access + * the MMD register via indirect method. + */ +int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, u16 regnum) +{ + return -EOPNOTSUPP; +} +EXPORT_SYMBOL(genphy_read_mmd_unsupported); + +int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, + u16 regnum, u16 val) +{ + return -EOPNOTSUPP; +} +EXPORT_SYMBOL(genphy_write_mmd_unsupported); + int genphy_suspend(struct phy_device *phydev) { return phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN); diff --git a/include/linux/phy.h b/include/linux/phy.h index b260fb336b25..7c4c2379e010 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -984,6 +984,10 @@ static inline int genphy_no_soft_reset(struct phy_device *phydev) { return 0; } +int genphy_read_mmd_unsupported(struct phy_device *phdev, int devad, + u16 regnum); +int genphy_write_mmd_unsupported(struct phy_device *phdev, int devnum, + u16 regnum, u16 val); /* Clause 45 PHY */ int genphy_c45_restart_aneg(struct phy_device *phydev); From 0231b1a074c672f8c00da00a57144072890d816b Mon Sep 17 00:00:00 2001 From: Kevin Hao Date: Tue, 20 Mar 2018 09:44:53 +0800 Subject: [PATCH 891/942] net: phy: realtek: Use the dummy stubs for MMD register access for rtl8211b The Ethernet on mpc8315erdb is broken since commit b6b5e8a69118 ("gianfar: Disable EEE autoneg by default"). The reason is that even though the rtl8211b doesn't support the MMD extended registers access, it does return some random values if we trying to access the MMD register via indirect method. This makes it seem that the EEE is supported by this phy device. And the subsequent writing to the MMD registers does cause the phy malfunction. So use the dummy stubs for the MMD register access to fix this issue. Fixes: b6b5e8a69118 ("gianfar: Disable EEE autoneg by default") Signed-off-by: Kevin Hao Signed-off-by: David S. Miller --- drivers/net/phy/realtek.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index ee3ca4a2f12b..9f48ecf9c627 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -172,6 +172,8 @@ static struct phy_driver realtek_drvs[] = { .flags = PHY_HAS_INTERRUPT, .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211b_config_intr, + .read_mmd = &genphy_read_mmd_unsupported, + .write_mmd = &genphy_write_mmd_unsupported, }, { .phy_id = 0x001cc914, .name = "RTL8211DN Gigabit Ethernet", From c846a2b7bd0e6900a726afb7c0a066f3a93617cf Mon Sep 17 00:00:00 2001 From: Kevin Hao Date: Tue, 20 Mar 2018 09:44:54 +0800 Subject: [PATCH 892/942] net: phy: micrel: Use the general dummy stubs for MMD register access The new general dummy stubs for MMD register access were introduced. Use that for the codes reuse. Signed-off-by: Kevin Hao Signed-off-by: David S. Miller --- drivers/net/phy/micrel.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 49be85afbea9..f41b224a9cdb 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -635,25 +635,6 @@ static int ksz8873mll_config_aneg(struct phy_device *phydev) return 0; } -/* This routine returns -1 as an indication to the caller that the - * Micrel ksz9021 10/100/1000 PHY does not support standard IEEE - * MMD extended PHY registers. - */ -static int -ksz9021_rd_mmd_phyreg(struct phy_device *phydev, int devad, u16 regnum) -{ - return -1; -} - -/* This routine does nothing since the Micrel ksz9021 does not support - * standard IEEE MMD extended PHY registers. - */ -static int -ksz9021_wr_mmd_phyreg(struct phy_device *phydev, int devad, u16 regnum, u16 val) -{ - return -1; -} - static int kszphy_get_sset_count(struct phy_device *phydev) { return ARRAY_SIZE(kszphy_hw_stats); @@ -946,8 +927,8 @@ static struct phy_driver ksphy_driver[] = { .get_stats = kszphy_get_stats, .suspend = genphy_suspend, .resume = genphy_resume, - .read_mmd = ksz9021_rd_mmd_phyreg, - .write_mmd = ksz9021_wr_mmd_phyreg, + .read_mmd = genphy_read_mmd_unsupported, + .write_mmd = genphy_write_mmd_unsupported, }, { .phy_id = PHY_ID_KSZ9031, .phy_id_mask = MICREL_PHY_ID_MASK, From 6be687395b3124f002a653c1a50b3260222b3cd7 Mon Sep 17 00:00:00 2001 From: Julian Wiedmann Date: Tue, 20 Mar 2018 07:59:12 +0100 Subject: [PATCH 893/942] s390/qeth: free netdevice when removing a card On removal, a qeth card's netdevice is currently not properly freed because the call chain looks as follows: qeth_core_remove_device(card) lx_remove_device(card) unregister_netdev(card->dev) card->dev = NULL !!! qeth_core_free_card(card) if (card->dev) !!! free_netdev(card->dev) Fix it by free'ing the netdev straight after unregistering. This also fixes the sysfs-driven layer switch case (qeth_dev_layer2_store()), where the need to free the current netdevice was not considered at all. Note that free_netdev() takes care of the netif_napi_del() for us too. Fixes: 4a71df50047f ("qeth: new qeth device driver") Signed-off-by: Julian Wiedmann Reviewed-by: Ursula Braun Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 2 -- drivers/s390/net/qeth_l2_main.c | 2 +- drivers/s390/net/qeth_l3_main.c | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index c8b308cfabf1..4a820afececd 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -5087,8 +5087,6 @@ static void qeth_core_free_card(struct qeth_card *card) QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); qeth_clean_channel(&card->read); qeth_clean_channel(&card->write); - if (card->dev) - free_netdev(card->dev); qeth_free_qdio_buffers(card); unregister_service_level(&card->qeth_service_level); kfree(card); diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index 7f236440483f..5ef4c978ad19 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -915,8 +915,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) qeth_l2_set_offline(cgdev); if (card->dev) { - netif_napi_del(&card->napi); unregister_netdev(card->dev); + free_netdev(card->dev); card->dev = NULL; } return; diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 962a04b68dd2..b6b12220da71 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -2865,8 +2865,8 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev) qeth_l3_set_offline(cgdev); if (card->dev) { - netif_napi_del(&card->napi); unregister_netdev(card->dev); + free_netdev(card->dev); card->dev = NULL; } From 1063e432bb45be209427ed3f1ca3908e4aa3c7d7 Mon Sep 17 00:00:00 2001 From: Julian Wiedmann Date: Tue, 20 Mar 2018 07:59:13 +0100 Subject: [PATCH 894/942] s390/qeth: when thread completes, wake up all waiters qeth_wait_for_threads() is potentially called by multiple users, make sure to notify all of them after qeth_clear_thread_running_bit() adjusted the thread_running_mask. With no timeout, callers would otherwise stall. Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 4a820afececd..42ee8806fa53 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -960,7 +960,7 @@ void qeth_clear_thread_running_bit(struct qeth_card *card, unsigned long thread) spin_lock_irqsave(&card->thread_mask_lock, flags); card->thread_running_mask &= ~thread; spin_unlock_irqrestore(&card->thread_mask_lock, flags); - wake_up(&card->wait_q); + wake_up_all(&card->wait_q); } EXPORT_SYMBOL_GPL(qeth_clear_thread_running_bit); From 17bf8c9b3d499d5168537c98b61eb7a1fcbca6c2 Mon Sep 17 00:00:00 2001 From: Julian Wiedmann Date: Tue, 20 Mar 2018 07:59:14 +0100 Subject: [PATCH 895/942] s390/qeth: lock read device while queueing next buffer For calling ccw_device_start(), issue_next_read() needs to hold the device's ccwlock. This is satisfied for the IRQ handler path (where qeth_irq() gets called under the ccwlock), but we need explicit locking for the initial call by the MPC initialization. Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 42ee8806fa53..2a9afaf8f264 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -527,8 +527,7 @@ static inline int qeth_is_cq(struct qeth_card *card, unsigned int queue) queue == card->qdio.no_in_queues - 1; } - -static int qeth_issue_next_read(struct qeth_card *card) +static int __qeth_issue_next_read(struct qeth_card *card) { int rc; struct qeth_cmd_buffer *iob; @@ -559,6 +558,17 @@ static int qeth_issue_next_read(struct qeth_card *card) return rc; } +static int qeth_issue_next_read(struct qeth_card *card) +{ + int ret; + + spin_lock_irq(get_ccwdev_lock(CARD_RDEV(card))); + ret = __qeth_issue_next_read(card); + spin_unlock_irq(get_ccwdev_lock(CARD_RDEV(card))); + + return ret; +} + static struct qeth_reply *qeth_alloc_reply(struct qeth_card *card) { struct qeth_reply *reply; @@ -1182,7 +1192,7 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, return; if (channel == &card->read && channel->state == CH_STATE_UP) - qeth_issue_next_read(card); + __qeth_issue_next_read(card); iob = channel->iob; index = channel->buf_no; From a6c3d93963e4b333c764fde69802c3ea9eaa9d5c Mon Sep 17 00:00:00 2001 From: Julian Wiedmann Date: Tue, 20 Mar 2018 07:59:15 +0100 Subject: [PATCH 896/942] s390/qeth: on channel error, reject further cmd requests When the IRQ handler determines that one of the cmd IO channels has failed and schedules recovery, block any further cmd requests from being submitted. The request would inevitably stall, and prevent the recovery from making progress until the request times out. This sort of error was observed after Live Guest Relocation, where the pending IO on the READ channel intentionally gets terminated to kick-start recovery. Simultaneously the guest executed SIOCETHTOOL, triggering qeth to issue a QUERY CARD INFO command. The command then stalled in the inoperabel WRITE channel. Signed-off-by: Julian Wiedmann Signed-off-by: David S. Miller --- drivers/s390/net/qeth_core_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 2a9afaf8f264..3653bea38470 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -1174,6 +1174,7 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, } rc = qeth_get_problem(cdev, irb); if (rc) { + card->read_or_write_problem = 1; qeth_clear_ipacmd_list(card); qeth_schedule_recovery(card); goto out; From 1bf9a7520fadaebfb8891284b046dd3fa6a2dc32 Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:31 +0300 Subject: [PATCH 897/942] net: aquantia: Fix hardware reset when SPI may rarely hangup Under some circumstances (notably using thunderbolt interface) SPI on chip reset may be in active transaction. Here we forcibly cleanup SPI to prevent possible hangups. Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c index 967f0fd07fcf..fcb3279ff9c7 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c @@ -79,16 +79,15 @@ int hw_atl_utils_initfw(struct aq_hw_s *self, const struct aq_fw_ops **fw_ops) static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self) { + u32 gsr, val; int k = 0; - u32 gsr; aq_hw_write_reg(self, 0x404, 0x40e1); AQ_HW_SLEEP(50); /* Cleanup SPI */ - aq_hw_write_reg(self, 0x534, 0xA0); - aq_hw_write_reg(self, 0x100, 0x9F); - aq_hw_write_reg(self, 0x100, 0x809F); + val = aq_hw_read_reg(self, 0x53C); + aq_hw_write_reg(self, 0x53C, val | 0x10); gsr = aq_hw_read_reg(self, HW_ATL_GLB_SOFT_RES_ADR); aq_hw_write_reg(self, HW_ATL_GLB_SOFT_RES_ADR, (gsr & 0xBFFF) | 0x8000); @@ -97,7 +96,14 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self) aq_hw_write_reg(self, 0x404, 0x80e0); aq_hw_write_reg(self, 0x32a8, 0x0); aq_hw_write_reg(self, 0x520, 0x1); + + /* Reset SPI again because of possible interrupted SPI burst */ + val = aq_hw_read_reg(self, 0x53C); + aq_hw_write_reg(self, 0x53C, val | 0x10); AQ_HW_SLEEP(10); + /* Clear SPI reset state */ + aq_hw_write_reg(self, 0x53C, val & ~0x10); + aq_hw_write_reg(self, 0x404, 0x180e0); for (k = 0; k < 1000; k++) { @@ -147,7 +153,7 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self) static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self) { - u32 gsr, rbl_status; + u32 gsr, val, rbl_status; int k; aq_hw_write_reg(self, 0x404, 0x40e1); @@ -157,6 +163,10 @@ static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self) /* Alter RBL status */ aq_hw_write_reg(self, 0x388, 0xDEAD); + /* Cleanup SPI */ + val = aq_hw_read_reg(self, 0x53C); + aq_hw_write_reg(self, 0x53C, val | 0x10); + /* Global software reset*/ hw_atl_rx_rx_reg_res_dis_set(self, 0U); hw_atl_tx_tx_reg_res_dis_set(self, 0U); From d0f0fb25d6c7a7c299d9bdaa2a11e96e4102e944 Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:32 +0300 Subject: [PATCH 898/942] net: aquantia: Fix a regression with reset on old firmware FW 1.5.58 and below needs a fixed delay even after 0x18 register is filled. Otherwise, setting MPI_INIT state too fast causes traffic hang. Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c index fcb3279ff9c7..dcb27bc7e97c 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c @@ -147,6 +147,8 @@ static int hw_atl_utils_soft_reset_flb(struct aq_hw_s *self) aq_pr_err("FW kickstart failed\n"); return -EIO; } + /* Old FW requires fixed delay after init */ + AQ_HW_SLEEP(15); return 0; } @@ -214,6 +216,8 @@ static int hw_atl_utils_soft_reset_rbl(struct aq_hw_s *self) aq_pr_err("FW kickstart failed\n"); return -EIO; } + /* Old FW requires fixed delay after init */ + AQ_HW_SLEEP(15); return 0; } From 47203b3426a6d0ac8b7a96259ed6784158b6d74b Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:33 +0300 Subject: [PATCH 899/942] net: aquantia: Change inefficient wait loop on fw data reads B1 hardware changes behavior of mailbox interface, it has busy bit always raised. Data ready condition should be detected by increment of address register. Old code has empty `for` loop, and that caused cpu overloads on B1 hardware. aq_nic_service_timer_cb consumed ~100ms because of that. Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- .../aquantia/atlantic/hw_atl/hw_atl_utils.c | 42 ++++++++++++------- .../aquantia/atlantic/hw_atl/hw_atl_utils.h | 1 + 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c index dcb27bc7e97c..d3b847ec7465 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.c @@ -21,6 +21,10 @@ #define HW_ATL_UCP_0X370_REG 0x0370U +#define HW_ATL_MIF_CMD 0x0200U +#define HW_ATL_MIF_ADDR 0x0208U +#define HW_ATL_MIF_VAL 0x020CU + #define HW_ATL_FW_SM_RAM 0x2U #define HW_ATL_MPI_FW_VERSION 0x18 #define HW_ATL_MPI_CONTROL_ADR 0x0368U @@ -269,18 +273,22 @@ int hw_atl_utils_fw_downld_dwords(struct aq_hw_s *self, u32 a, } } - aq_hw_write_reg(self, 0x00000208U, a); + aq_hw_write_reg(self, HW_ATL_MIF_ADDR, a); - for (++cnt; --cnt;) { - u32 i = 0U; + for (++cnt; --cnt && !err;) { + aq_hw_write_reg(self, HW_ATL_MIF_CMD, 0x00008000U); - aq_hw_write_reg(self, 0x00000200U, 0x00008000U); + if (IS_CHIP_FEATURE(REVISION_B1)) + AQ_HW_WAIT_FOR(a != aq_hw_read_reg(self, + HW_ATL_MIF_ADDR), + 1, 1000U); + else + AQ_HW_WAIT_FOR(!(0x100 & aq_hw_read_reg(self, + HW_ATL_MIF_CMD)), + 1, 1000U); - for (i = 1024U; - (0x100U & aq_hw_read_reg(self, 0x00000200U)) && --i;) { - } - - *(p++) = aq_hw_read_reg(self, 0x0000020CU); + *(p++) = aq_hw_read_reg(self, HW_ATL_MIF_VAL); + a += 4; } hw_atl_reg_glb_cpu_sem_set(self, 1U, HW_ATL_FW_SM_RAM); @@ -676,14 +684,18 @@ void hw_atl_utils_hw_chip_features_init(struct aq_hw_s *self, u32 *p) u32 val = hw_atl_reg_glb_mif_id_get(self); u32 mif_rev = val & 0xFFU; - if ((3U & mif_rev) == 1U) { - chip_features |= - HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 | + if ((0xFU & mif_rev) == 1U) { + chip_features |= HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 | HAL_ATLANTIC_UTILS_CHIP_MPI_AQ | HAL_ATLANTIC_UTILS_CHIP_MIPS; - } else if ((3U & mif_rev) == 2U) { - chip_features |= - HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 | + } else if ((0xFU & mif_rev) == 2U) { + chip_features |= HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 | + HAL_ATLANTIC_UTILS_CHIP_MPI_AQ | + HAL_ATLANTIC_UTILS_CHIP_MIPS | + HAL_ATLANTIC_UTILS_CHIP_TPO2 | + HAL_ATLANTIC_UTILS_CHIP_RPF2; + } else if ((0xFU & mif_rev) == 0xAU) { + chip_features |= HAL_ATLANTIC_UTILS_CHIP_REVISION_B1 | HAL_ATLANTIC_UTILS_CHIP_MPI_AQ | HAL_ATLANTIC_UTILS_CHIP_MIPS | HAL_ATLANTIC_UTILS_CHIP_TPO2 | diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h index 2c690947910a..cd8f18f39c61 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_utils.h @@ -161,6 +161,7 @@ struct __packed hw_aq_atl_utils_mbox { #define HAL_ATLANTIC_UTILS_CHIP_MPI_AQ 0x00000010U #define HAL_ATLANTIC_UTILS_CHIP_REVISION_A0 0x01000000U #define HAL_ATLANTIC_UTILS_CHIP_REVISION_B0 0x02000000U +#define HAL_ATLANTIC_UTILS_CHIP_REVISION_B1 0x04000000U #define IS_CHIP_FEATURE(_F_) (HAL_ATLANTIC_UTILS_CHIP_##_F_ & \ self->chip_features) From b647d3980948e881e6bb9bd898465e675d5e8486 Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:34 +0300 Subject: [PATCH 900/942] net: aquantia: Add tx clean budget and valid budget handling logic We should report to napi full budget only when we have more job to do. Before this fix, on any tx queue cleanup we forced napi to do poll again. Thats a waste of cpu resources and caused storming with napi polls when there was at least one tx on each interrupt. With this fix we report full budget only when there is more job on TX to do. Or, as before, when rx budget was fully consumed. Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- drivers/net/ethernet/aquantia/atlantic/aq_cfg.h | 2 ++ drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 7 +++++-- drivers/net/ethernet/aquantia/atlantic/aq_ring.h | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_vec.c | 11 +++++------ 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h index 0b49f1aeebd3..fc7383106946 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_cfg.h @@ -36,6 +36,8 @@ #define AQ_CFG_TX_FRAME_MAX (16U * 1024U) #define AQ_CFG_RX_FRAME_MAX (4U * 1024U) +#define AQ_CFG_TX_CLEAN_BUDGET 256U + /* LRO */ #define AQ_CFG_IS_LRO_DEF 1U diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 0be6a11370bb..b5f1f62e8e25 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -136,11 +136,12 @@ void aq_ring_queue_stop(struct aq_ring_s *ring) netif_stop_subqueue(ndev, ring->idx); } -void aq_ring_tx_clean(struct aq_ring_s *self) +bool aq_ring_tx_clean(struct aq_ring_s *self) { struct device *dev = aq_nic_get_dev(self->aq_nic); + unsigned int budget = AQ_CFG_TX_CLEAN_BUDGET; - for (; self->sw_head != self->hw_head; + for (; self->sw_head != self->hw_head && budget--; self->sw_head = aq_ring_next_dx(self, self->sw_head)) { struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; @@ -167,6 +168,8 @@ void aq_ring_tx_clean(struct aq_ring_s *self) buff->pa = 0U; buff->eop_index = 0xffffU; } + + return !!budget; } #define AQ_SKB_ALIGN SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.h b/drivers/net/ethernet/aquantia/atlantic/aq_ring.h index 965fae0fb6e0..ac1329f4051d 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.h @@ -153,7 +153,7 @@ void aq_ring_free(struct aq_ring_s *self); void aq_ring_update_queue_state(struct aq_ring_s *ring); void aq_ring_queue_wake(struct aq_ring_s *ring); void aq_ring_queue_stop(struct aq_ring_s *ring); -void aq_ring_tx_clean(struct aq_ring_s *self); +bool aq_ring_tx_clean(struct aq_ring_s *self); int aq_ring_rx_clean(struct aq_ring_s *self, struct napi_struct *napi, int *work_done, diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c index f890b8a5a862..d335c334fa56 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_vec.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_vec.c @@ -35,12 +35,12 @@ struct aq_vec_s { static int aq_vec_poll(struct napi_struct *napi, int budget) { struct aq_vec_s *self = container_of(napi, struct aq_vec_s, napi); + unsigned int sw_tail_old = 0U; struct aq_ring_s *ring = NULL; + bool was_tx_cleaned = true; + unsigned int i = 0U; int work_done = 0; int err = 0; - unsigned int i = 0U; - unsigned int sw_tail_old = 0U; - bool was_tx_cleaned = false; if (!self) { err = -EINVAL; @@ -57,9 +57,8 @@ static int aq_vec_poll(struct napi_struct *napi, int budget) if (ring[AQ_VEC_TX_ID].sw_head != ring[AQ_VEC_TX_ID].hw_head) { - aq_ring_tx_clean(&ring[AQ_VEC_TX_ID]); + was_tx_cleaned = aq_ring_tx_clean(&ring[AQ_VEC_TX_ID]); aq_ring_update_queue_state(&ring[AQ_VEC_TX_ID]); - was_tx_cleaned = true; } err = self->aq_hw_ops->hw_ring_rx_receive(self->aq_hw, @@ -90,7 +89,7 @@ static int aq_vec_poll(struct napi_struct *napi, int budget) } } - if (was_tx_cleaned) + if (!was_tx_cleaned) work_done = budget; if (work_done < budget) { From 3e9a545131723ff12fe4304245c222157f0e4622 Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:35 +0300 Subject: [PATCH 901/942] net: aquantia: Allow live mac address changes There is nothing prevents us from changing MAC on the running interface. Allow this with ndev priv flag. Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c index ebbaf63eaf47..34120d5b7c03 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c @@ -247,6 +247,8 @@ void aq_nic_ndev_init(struct aq_nic_s *self) self->ndev->hw_features |= aq_hw_caps->hw_features; self->ndev->features = aq_hw_caps->hw_features; self->ndev->priv_flags = aq_hw_caps->hw_priv_flags; + self->ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; + self->ndev->mtu = aq_nic_cfg->mtu - ETH_HLEN; self->ndev->max_mtu = aq_hw_caps->mtu - ETH_FCS_LEN - ETH_HLEN; From 90869ddfefebb1a79bd7bebfa4f28baa9f8c82cd Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:36 +0300 Subject: [PATCH 902/942] net: aquantia: Implement pci shutdown callback We should close link and all NIC operations during shutdown. On some systems graceful reboot never closes NIC interface on its own, but only indicates pci device shutdown. Without explicit handler, NIC rx rings continued to transfer DMA data into prepared buffers while CPU rebooted already. That caused memory corruptions on soft reboot. Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- .../net/ethernet/aquantia/atlantic/aq_nic.c | 20 +++++++++++++++++++ .../net/ethernet/aquantia/atlantic/aq_nic.h | 1 + .../ethernet/aquantia/atlantic/aq_pci_func.c | 15 ++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c index 34120d5b7c03..c96a92118b8b 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.c @@ -939,3 +939,23 @@ err_exit: out: return err; } + +void aq_nic_shutdown(struct aq_nic_s *self) +{ + int err = 0; + + if (!self->ndev) + return; + + rtnl_lock(); + + netif_device_detach(self->ndev); + + err = aq_nic_stop(self); + if (err < 0) + goto err_exit; + aq_nic_deinit(self); + +err_exit: + rtnl_unlock(); +} \ No newline at end of file diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h index d16b0f1a95aa..219b550d1665 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_nic.h +++ b/drivers/net/ethernet/aquantia/atlantic/aq_nic.h @@ -118,5 +118,6 @@ struct aq_nic_cfg_s *aq_nic_get_cfg(struct aq_nic_s *self); u32 aq_nic_get_fw_version(struct aq_nic_s *self); int aq_nic_change_pm_state(struct aq_nic_s *self, pm_message_t *pm_msg); int aq_nic_update_interrupt_moderation_settings(struct aq_nic_s *self); +void aq_nic_shutdown(struct aq_nic_s *self); #endif /* AQ_NIC_H */ diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c index 87c4308b52a7..ecc6306f940f 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c @@ -323,6 +323,20 @@ static void aq_pci_remove(struct pci_dev *pdev) pci_disable_device(pdev); } +static void aq_pci_shutdown(struct pci_dev *pdev) +{ + struct aq_nic_s *self = pci_get_drvdata(pdev); + + aq_nic_shutdown(self); + + pci_disable_device(pdev); + + if (system_state == SYSTEM_POWER_OFF) { + pci_wake_from_d3(pdev, false); + pci_set_power_state(pdev, PCI_D3hot); + } +} + static int aq_pci_suspend(struct pci_dev *pdev, pm_message_t pm_msg) { struct aq_nic_s *self = pci_get_drvdata(pdev); @@ -345,6 +359,7 @@ static struct pci_driver aq_pci_ops = { .remove = aq_pci_remove, .suspend = aq_pci_suspend, .resume = aq_pci_resume, + .shutdown = aq_pci_shutdown, }; module_pci_driver(aq_pci_ops); From c89bf1cd3498db851bdc184b26e26baaa5f141c5 Mon Sep 17 00:00:00 2001 From: Igor Russkikh Date: Tue, 20 Mar 2018 14:40:37 +0300 Subject: [PATCH 903/942] net: aquantia: driver version bump Signed-off-by: Igor Russkikh Signed-off-by: David S. Miller --- drivers/net/ethernet/aquantia/atlantic/ver.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/ver.h b/drivers/net/ethernet/aquantia/atlantic/ver.h index 5265b937677b..a445de6837a6 100644 --- a/drivers/net/ethernet/aquantia/atlantic/ver.h +++ b/drivers/net/ethernet/aquantia/atlantic/ver.h @@ -13,7 +13,7 @@ #define NIC_MAJOR_DRIVER_VERSION 2 #define NIC_MINOR_DRIVER_VERSION 0 #define NIC_BUILD_DRIVER_VERSION 2 -#define NIC_REVISION_DRIVER_VERSION 0 +#define NIC_REVISION_DRIVER_VERSION 1 #define AQ_CFG_DRV_VERSION_SUFFIX "-kern" From 191f86ca8ef27f7a492fd1c03620498c6e94f0ac Mon Sep 17 00:00:00 2001 From: David Lebrun Date: Tue, 20 Mar 2018 14:44:55 +0000 Subject: [PATCH 904/942] ipv6: sr: fix scheduling in RCU when creating seg6 lwtunnel state The seg6_build_state() function is called with RCU read lock held, so we cannot use GFP_KERNEL. This patch uses GFP_ATOMIC instead. [ 92.770271] ============================= [ 92.770628] WARNING: suspicious RCU usage [ 92.770921] 4.16.0-rc4+ #12 Not tainted [ 92.771277] ----------------------------- [ 92.771585] ./include/linux/rcupdate.h:302 Illegal context switch in RCU read-side critical section! [ 92.772279] [ 92.772279] other info that might help us debug this: [ 92.772279] [ 92.773067] [ 92.773067] rcu_scheduler_active = 2, debug_locks = 1 [ 92.773514] 2 locks held by ip/2413: [ 92.773765] #0: (rtnl_mutex){+.+.}, at: [<00000000e5461720>] rtnetlink_rcv_msg+0x441/0x4d0 [ 92.774377] #1: (rcu_read_lock){....}, at: [<00000000df4f161e>] lwtunnel_build_state+0x59/0x210 [ 92.775065] [ 92.775065] stack backtrace: [ 92.775371] CPU: 0 PID: 2413 Comm: ip Not tainted 4.16.0-rc4+ #12 [ 92.775791] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1.fc27 04/01/2014 [ 92.776608] Call Trace: [ 92.776852] dump_stack+0x7d/0xbc [ 92.777130] __schedule+0x133/0xf00 [ 92.777393] ? unwind_get_return_address_ptr+0x50/0x50 [ 92.777783] ? __sched_text_start+0x8/0x8 [ 92.778073] ? rcu_is_watching+0x19/0x30 [ 92.778383] ? kernel_text_address+0x49/0x60 [ 92.778800] ? __kernel_text_address+0x9/0x30 [ 92.779241] ? unwind_get_return_address+0x29/0x40 [ 92.779727] ? pcpu_alloc+0x102/0x8f0 [ 92.780101] _cond_resched+0x23/0x50 [ 92.780459] __mutex_lock+0xbd/0xad0 [ 92.780818] ? pcpu_alloc+0x102/0x8f0 [ 92.781194] ? seg6_build_state+0x11d/0x240 [ 92.781611] ? save_stack+0x9b/0xb0 [ 92.781965] ? __ww_mutex_wakeup_for_backoff+0xf0/0xf0 [ 92.782480] ? seg6_build_state+0x11d/0x240 [ 92.782925] ? lwtunnel_build_state+0x1bd/0x210 [ 92.783393] ? ip6_route_info_create+0x687/0x1640 [ 92.783846] ? ip6_route_add+0x74/0x110 [ 92.784236] ? inet6_rtm_newroute+0x8a/0xd0 Fixes: 6c8702c60b886 ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels") Signed-off-by: David Lebrun Signed-off-by: David S. Miller --- net/ipv6/seg6_iptunnel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index bd6cc688bd19..8367b859a934 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -418,7 +418,7 @@ static int seg6_build_state(struct nlattr *nla, slwt = seg6_lwt_lwtunnel(newts); - err = dst_cache_init(&slwt->cache, GFP_KERNEL); + err = dst_cache_init(&slwt->cache, GFP_ATOMIC); if (err) { kfree(newts); return err; From 8936ef7604c11b5d701580d779e0f5684abc7b68 Mon Sep 17 00:00:00 2001 From: David Lebrun Date: Tue, 20 Mar 2018 14:44:56 +0000 Subject: [PATCH 905/942] ipv6: sr: fix NULL pointer dereference when setting encap source address When using seg6 in encap mode, we call ipv6_dev_get_saddr() to set the source address of the outer IPv6 header, in case none was specified. Using skb->dev can lead to BUG() when it is in an inconsistent state. This patch uses the net_device attached to the skb's dst instead. [940807.667429] BUG: unable to handle kernel NULL pointer dereference at 000000000000047c [940807.762427] IP: ipv6_dev_get_saddr+0x8b/0x1d0 [940807.815725] PGD 0 P4D 0 [940807.847173] Oops: 0000 [#1] SMP PTI [940807.890073] Modules linked in: [940807.927765] CPU: 6 PID: 0 Comm: swapper/6 Tainted: G W 4.16.0-rc1-seg6bpf+ #2 [940808.028988] Hardware name: HP ProLiant DL120 G6/ProLiant DL120 G6, BIOS O26 09/06/2010 [940808.128128] RIP: 0010:ipv6_dev_get_saddr+0x8b/0x1d0 [940808.187667] RSP: 0018:ffff88043fd836b0 EFLAGS: 00010206 [940808.251366] RAX: 0000000000000005 RBX: ffff88042cb1c860 RCX: 00000000000000fe [940808.338025] RDX: 00000000000002c0 RSI: ffff88042cb1c860 RDI: 0000000000004500 [940808.424683] RBP: ffff88043fd83740 R08: 0000000000000000 R09: ffffffffffffffff [940808.511342] R10: 0000000000000040 R11: 0000000000000000 R12: ffff88042cb1c850 [940808.598012] R13: ffffffff8208e380 R14: ffff88042ac8da00 R15: 0000000000000002 [940808.684675] FS: 0000000000000000(0000) GS:ffff88043fd80000(0000) knlGS:0000000000000000 [940808.783036] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [940808.852975] CR2: 000000000000047c CR3: 00000004255fe000 CR4: 00000000000006e0 [940808.939634] Call Trace: [940808.970041] [940808.995250] ? ip6t_do_table+0x265/0x640 [940809.043341] seg6_do_srh_encap+0x28f/0x300 [940809.093516] ? seg6_do_srh+0x1a0/0x210 [940809.139528] seg6_do_srh+0x1a0/0x210 [940809.183462] seg6_output+0x28/0x1e0 [940809.226358] lwtunnel_output+0x3f/0x70 [940809.272370] ip6_xmit+0x2b8/0x530 [940809.313185] ? ac6_proc_exit+0x20/0x20 [940809.359197] inet6_csk_xmit+0x7d/0xc0 [940809.404173] tcp_transmit_skb+0x548/0x9a0 [940809.453304] __tcp_retransmit_skb+0x1a8/0x7a0 [940809.506603] ? ip6_default_advmss+0x40/0x40 [940809.557824] ? tcp_current_mss+0x24/0x90 [940809.605925] tcp_retransmit_skb+0xd/0x80 [940809.654016] tcp_xmit_retransmit_queue.part.17+0xf9/0x210 [940809.719797] tcp_ack+0xa47/0x1110 [940809.760612] tcp_rcv_established+0x13c/0x570 [940809.812865] tcp_v6_do_rcv+0x151/0x3d0 [940809.858879] tcp_v6_rcv+0xa5c/0xb10 [940809.901770] ? seg6_output+0xdd/0x1e0 [940809.946745] ip6_input_finish+0xbb/0x460 [940809.994837] ip6_input+0x74/0x80 [940810.034612] ? ip6_rcv_finish+0xb0/0xb0 [940810.081663] ipv6_rcv+0x31c/0x4c0 ... Fixes: 6c8702c60b886 ("ipv6: sr: add support for SRH encapsulation and injection with lwtunnels") Reported-by: Tom Herbert Signed-off-by: David Lebrun Signed-off-by: David S. Miller --- net/ipv6/seg6_iptunnel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index 8367b859a934..7a78dcfda68a 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -93,7 +93,8 @@ static void set_tun_src(struct net *net, struct net_device *dev, /* encapsulate an IPv6 packet within an outer IPv6 header with a given SRH */ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) { - struct net *net = dev_net(skb_dst(skb)->dev); + struct dst_entry *dst = skb_dst(skb); + struct net *net = dev_net(dst->dev); struct ipv6hdr *hdr, *inner_hdr; struct ipv6_sr_hdr *isrh; int hdrlen, tot_len, err; @@ -134,7 +135,7 @@ int seg6_do_srh_encap(struct sk_buff *skb, struct ipv6_sr_hdr *osrh, int proto) isrh->nexthdr = proto; hdr->daddr = isrh->segments[isrh->first_segment]; - set_tun_src(net, skb->dev, &hdr->daddr, &hdr->saddr); + set_tun_src(net, ip6_dst_idev(dst)->dev, &hdr->daddr, &hdr->saddr); #ifdef CONFIG_IPV6_SEG6_HMAC if (sr_has_hmac(isrh)) { From 6d066734e9f09cdea4a3b9cb76136db3f29cfb02 Mon Sep 17 00:00:00 2001 From: Guillaume Nault Date: Tue, 20 Mar 2018 16:49:26 +0100 Subject: [PATCH 906/942] ppp: avoid loop in xmit recursion detection code We already detect situations where a PPP channel sends packets back to its upper PPP device. While this is enough to avoid deadlocking on xmit locks, this doesn't prevent packets from looping between the channel and the unit. The problem is that ppp_start_xmit() enqueues packets in ppp->file.xq before checking for xmit recursion. Therefore, __ppp_xmit_process() might dequeue a packet from ppp->file.xq and send it on the channel which, in turn, loops it back on the unit. Then ppp_start_xmit() queues the packet back to ppp->file.xq and __ppp_xmit_process() picks it up and sends it again through the channel. Therefore, the packet will loop between __ppp_xmit_process() and ppp_start_xmit() until some other part of the xmit path drops it. For L2TP, we rapidly fill the skb's headroom and pppol2tp_xmit() drops the packet after a few iterations. But PPTP reallocates the headroom if necessary, letting the loop run and exhaust the machine resources (as reported in https://bugzilla.kernel.org/show_bug.cgi?id=199109). Fix this by letting __ppp_xmit_process() enqueue the skb to ppp->file.xq, so that we can check for recursion before adding it to the queue. Now ppp_xmit_process() can drop the packet when recursion is detected. __ppp_channel_push() is a bit special. It calls __ppp_xmit_process() without having any actual packet to send. This is used by ppp_output_wakeup() to re-enable transmission on the parent unit (for implementations like ppp_async.c, where the .start_xmit() function might not consume the skb, leaving it in ppp->xmit_pending and disabling transmission). Therefore, __ppp_xmit_process() needs to handle the case where skb is NULL, dequeuing as many packets as possible from ppp->file.xq. Reported-by: xu heng Fixes: 55454a565836 ("ppp: avoid dealock on recursive xmit") Signed-off-by: Guillaume Nault Signed-off-by: David S. Miller --- drivers/net/ppp/ppp_generic.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index fa2a9bdd1866..da1937832c99 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c @@ -257,7 +257,7 @@ struct ppp_net { /* Prototypes. */ static int ppp_unattached_ioctl(struct net *net, struct ppp_file *pf, struct file *file, unsigned int cmd, unsigned long arg); -static void ppp_xmit_process(struct ppp *ppp); +static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb); static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb); static void ppp_push(struct ppp *ppp); static void ppp_channel_push(struct channel *pch); @@ -513,13 +513,12 @@ static ssize_t ppp_write(struct file *file, const char __user *buf, goto out; } - skb_queue_tail(&pf->xq, skb); - switch (pf->kind) { case INTERFACE: - ppp_xmit_process(PF_TO_PPP(pf)); + ppp_xmit_process(PF_TO_PPP(pf), skb); break; case CHANNEL: + skb_queue_tail(&pf->xq, skb); ppp_channel_push(PF_TO_CHANNEL(pf)); break; } @@ -1267,8 +1266,8 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev) put_unaligned_be16(proto, pp); skb_scrub_packet(skb, !net_eq(ppp->ppp_net, dev_net(dev))); - skb_queue_tail(&ppp->file.xq, skb); - ppp_xmit_process(ppp); + ppp_xmit_process(ppp, skb); + return NETDEV_TX_OK; outf: @@ -1420,13 +1419,14 @@ static void ppp_setup(struct net_device *dev) */ /* Called to do any work queued up on the transmit side that can now be done */ -static void __ppp_xmit_process(struct ppp *ppp) +static void __ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb) { - struct sk_buff *skb; - ppp_xmit_lock(ppp); if (!ppp->closing) { ppp_push(ppp); + + if (skb) + skb_queue_tail(&ppp->file.xq, skb); while (!ppp->xmit_pending && (skb = skb_dequeue(&ppp->file.xq))) ppp_send_frame(ppp, skb); @@ -1440,7 +1440,7 @@ static void __ppp_xmit_process(struct ppp *ppp) ppp_xmit_unlock(ppp); } -static void ppp_xmit_process(struct ppp *ppp) +static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb) { local_bh_disable(); @@ -1448,7 +1448,7 @@ static void ppp_xmit_process(struct ppp *ppp) goto err; (*this_cpu_ptr(ppp->xmit_recursion))++; - __ppp_xmit_process(ppp); + __ppp_xmit_process(ppp, skb); (*this_cpu_ptr(ppp->xmit_recursion))--; local_bh_enable(); @@ -1458,6 +1458,8 @@ static void ppp_xmit_process(struct ppp *ppp) err: local_bh_enable(); + kfree_skb(skb); + if (net_ratelimit()) netdev_err(ppp->dev, "recursion detected\n"); } @@ -1942,7 +1944,7 @@ static void __ppp_channel_push(struct channel *pch) if (skb_queue_empty(&pch->file.xq)) { ppp = pch->ppp; if (ppp) - __ppp_xmit_process(ppp); + __ppp_xmit_process(ppp, NULL); } } From 68e2ffdeb5dbf54bc3a0684aa4e73c6db8675eed Mon Sep 17 00:00:00 2001 From: David Ahern Date: Tue, 20 Mar 2018 10:06:59 -0700 Subject: [PATCH 907/942] net/ipv6: Handle onlink flag with multipath routes For multipath routes the ONLINK flag can be specified per nexthop in rtnh_flags or globally in rtm_flags. Update ip6_route_multipath_add to consider the ONLINK setting coming from rtnh_flags. Each loop over nexthops the config for the sibling route is initialized to the global config and then per nexthop settings overlayed. The flag is 'or'ed into fib6_config to handle the ONLINK flag coming from either rtm_flags or rtnh_flags. Fixes: fc1e64e1092f ("net/ipv6: Add support for onlink flag") Signed-off-by: David Ahern Signed-off-by: David S. Miller --- net/ipv6/route.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index b3c1137ad0b8..b0d5c64e1978 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -4112,6 +4112,7 @@ static int ip6_route_multipath_add(struct fib6_config *cfg, r_cfg.fc_encap_type = nla_get_u16(nla); } + r_cfg.fc_flags |= (rtnh->rtnh_flags & RTNH_F_ONLINK); rt = ip6_route_info_create(&r_cfg, extack); if (IS_ERR(rt)) { err = PTR_ERR(rt); From 8348e0460ab1473f06c8b824699dd2eed3c1979d Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 20 Mar 2018 15:03:02 -0700 Subject: [PATCH 908/942] hv_netvsc: disable NAPI before channel close This makes sure that no CPU is still process packets when the channel is closed. Fixes: 76bb5db5c749 ("netvsc: fix use after free on module removal") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 0265d703eb03..e70a44273f55 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -568,6 +568,10 @@ void netvsc_device_remove(struct hv_device *device) RCU_INIT_POINTER(net_device_ctx->nvdev, NULL); + /* And disassociate NAPI context from device */ + for (i = 0; i < net_device->num_chn; i++) + netif_napi_del(&net_device->chan_table[i].napi); + /* * At this point, no one should be accessing net_device * except in here @@ -579,10 +583,6 @@ void netvsc_device_remove(struct hv_device *device) netvsc_teardown_gpadl(device, net_device); - /* And dissassociate NAPI context from device */ - for (i = 0; i < net_device->num_chn; i++) - netif_napi_del(&net_device->chan_table[i].napi); - /* Release all resources */ free_netvsc_device_rcu(net_device); } From 02400fcee2542ee334a2394e0d9f6efd969fe782 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 20 Mar 2018 15:03:03 -0700 Subject: [PATCH 909/942] hv_netvsc: use RCU to fix concurrent rx and queue changes The receive processing may continue to happen while the internal network device state is in RCU grace period. The internal RNDIS structure is associated with the internal netvsc_device structure; both have the same RCU lifetime. Defer freeing all associated parts until after grace period. Fixes: 0cf737808ae7 ("hv_netvsc: netvsc_teardown_gpadl() split") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc.c | 17 ++++---------- drivers/net/hyperv/rndis_filter.c | 39 +++++++++++++------------------ 2 files changed, 21 insertions(+), 35 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index e70a44273f55..12c044baf1af 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -90,6 +90,11 @@ static void free_netvsc_device(struct rcu_head *head) = container_of(head, struct netvsc_device, rcu); int i; + kfree(nvdev->extension); + vfree(nvdev->recv_buf); + vfree(nvdev->send_buf); + kfree(nvdev->send_section_map); + for (i = 0; i < VRSS_CHANNEL_MAX; i++) vfree(nvdev->chan_table[i].mrc.slots); @@ -211,12 +216,6 @@ static void netvsc_teardown_gpadl(struct hv_device *device, net_device->recv_buf_gpadl_handle = 0; } - if (net_device->recv_buf) { - /* Free up the receive buffer */ - vfree(net_device->recv_buf); - net_device->recv_buf = NULL; - } - if (net_device->send_buf_gpadl_handle) { ret = vmbus_teardown_gpadl(device->channel, net_device->send_buf_gpadl_handle); @@ -231,12 +230,6 @@ static void netvsc_teardown_gpadl(struct hv_device *device, } net_device->send_buf_gpadl_handle = 0; } - if (net_device->send_buf) { - /* Free up the send buffer */ - vfree(net_device->send_buf); - net_device->send_buf = NULL; - } - kfree(net_device->send_section_map); } int netvsc_alloc_recv_comp_ring(struct netvsc_device *net_device, u32 q_idx) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 00ec80c23fe5..963314eb3226 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -264,13 +264,23 @@ static void rndis_set_link_state(struct rndis_device *rdev, } } -static void rndis_filter_receive_response(struct rndis_device *dev, - struct rndis_message *resp) +static void rndis_filter_receive_response(struct net_device *ndev, + struct netvsc_device *nvdev, + const struct rndis_message *resp) { + struct rndis_device *dev = nvdev->extension; struct rndis_request *request = NULL; bool found = false; unsigned long flags; - struct net_device *ndev = dev->ndev; + + /* This should never happen, it means control message + * response received after device removed. + */ + if (dev->state == RNDIS_DEV_UNINITIALIZED) { + netdev_err(ndev, + "got rndis message uninitialized\n"); + return; + } spin_lock_irqsave(&dev->request_lock, flags); list_for_each_entry(request, &dev->req_list, list_ent) { @@ -352,7 +362,6 @@ static inline void *rndis_get_ppi(struct rndis_packet *rpkt, u32 type) static int rndis_filter_receive_data(struct net_device *ndev, struct netvsc_device *nvdev, - struct rndis_device *dev, struct rndis_message *msg, struct vmbus_channel *channel, void *data, u32 data_buflen) @@ -372,7 +381,7 @@ static int rndis_filter_receive_data(struct net_device *ndev, * should be the data packet size plus the trailer padding size */ if (unlikely(data_buflen < rndis_pkt->data_len)) { - netdev_err(dev->ndev, "rndis message buffer " + netdev_err(ndev, "rndis message buffer " "overflow detected (got %u, min %u)" "...dropping this message!\n", data_buflen, rndis_pkt->data_len); @@ -400,35 +409,20 @@ int rndis_filter_receive(struct net_device *ndev, void *data, u32 buflen) { struct net_device_context *net_device_ctx = netdev_priv(ndev); - struct rndis_device *rndis_dev = net_dev->extension; struct rndis_message *rndis_msg = data; - /* Make sure the rndis device state is initialized */ - if (unlikely(!rndis_dev)) { - netif_dbg(net_device_ctx, rx_err, ndev, - "got rndis message but no rndis device!\n"); - return NVSP_STAT_FAIL; - } - - if (unlikely(rndis_dev->state == RNDIS_DEV_UNINITIALIZED)) { - netif_dbg(net_device_ctx, rx_err, ndev, - "got rndis message uninitialized\n"); - return NVSP_STAT_FAIL; - } - if (netif_msg_rx_status(net_device_ctx)) dump_rndis_message(ndev, rndis_msg); switch (rndis_msg->ndis_msg_type) { case RNDIS_MSG_PACKET: - return rndis_filter_receive_data(ndev, net_dev, - rndis_dev, rndis_msg, + return rndis_filter_receive_data(ndev, net_dev, rndis_msg, channel, data, buflen); case RNDIS_MSG_INIT_C: case RNDIS_MSG_QUERY_C: case RNDIS_MSG_SET_C: /* completion msgs */ - rndis_filter_receive_response(rndis_dev, rndis_msg); + rndis_filter_receive_response(ndev, net_dev, rndis_msg); break; case RNDIS_MSG_INDICATE: @@ -1357,7 +1351,6 @@ void rndis_filter_device_remove(struct hv_device *dev, net_dev->extension = NULL; netvsc_device_remove(dev); - kfree(rndis_dev); } int rndis_filter_open(struct netvsc_device *nvdev) From 0ef58b0a05c127762f975c3dfe8b922e4aa87a29 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 20 Mar 2018 15:03:04 -0700 Subject: [PATCH 910/942] hv_netvsc: change GPAD teardown order on older versions On older versions of Windows, the host ignores messages after vmbus channel is closed. Workaround this by doing what Windows does and send the teardown before close on older versions of NVSP protocol. Reported-by: Mohammed Gamal Fixes: 0cf737808ae7 ("hv_netvsc: netvsc_teardown_gpadl() split") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/netvsc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 12c044baf1af..37b0a30d6b03 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -571,10 +571,15 @@ void netvsc_device_remove(struct hv_device *device) */ netdev_dbg(ndev, "net device safe to remove\n"); + /* older versions require that buffer be revoked before close */ + if (net_device->nvsp_version < NVSP_PROTOCOL_VERSION_4) + netvsc_teardown_gpadl(device, net_device); + /* Now, we can close the channel safely */ vmbus_close(device->channel); - netvsc_teardown_gpadl(device, net_device); + if (net_device->nvsp_version >= NVSP_PROTOCOL_VERSION_4) + netvsc_teardown_gpadl(device, net_device); /* Release all resources */ free_netvsc_device_rcu(net_device); From 7b2ee50c0cd513a176a26a71f2989facdd75bfea Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 20 Mar 2018 15:03:05 -0700 Subject: [PATCH 911/942] hv_netvsc: common detach logic Make common function for detaching internals of device during changes to MTU and RSS. Make sure no more packets are transmitted and all packets have been received before doing device teardown. Change the wait logic to be common and use usleep_range(). Changes transmit enabling logic so that transmit queues are disabled during the period when lower device is being changed. And enabled only after sub channels are setup. This avoids issue where it could be that a packet was being sent while subchannel was not initialized. Fixes: 8195b1396ec8 ("hv_netvsc: fix deadlock on hotplug") Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller --- drivers/net/hyperv/hyperv_net.h | 1 - drivers/net/hyperv/netvsc.c | 20 ++- drivers/net/hyperv/netvsc_drv.c | 278 +++++++++++++++++------------- drivers/net/hyperv/rndis_filter.c | 17 +- 4 files changed, 173 insertions(+), 143 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index cd538d5a7986..32861036c3fc 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -212,7 +212,6 @@ void netvsc_channel_cb(void *context); int netvsc_poll(struct napi_struct *napi, int budget); void rndis_set_subchannel(struct work_struct *w); -bool rndis_filter_opened(const struct netvsc_device *nvdev); int rndis_filter_open(struct netvsc_device *nvdev); int rndis_filter_close(struct netvsc_device *nvdev); struct netvsc_device *rndis_filter_device_add(struct hv_device *dev, diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 37b0a30d6b03..7472172823f3 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -555,8 +555,6 @@ void netvsc_device_remove(struct hv_device *device) = rtnl_dereference(net_device_ctx->nvdev); int i; - cancel_work_sync(&net_device->subchan_work); - netvsc_revoke_buf(device, net_device); RCU_INIT_POINTER(net_device_ctx->nvdev, NULL); @@ -643,14 +641,18 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, queue_sends = atomic_dec_return(&net_device->chan_table[q_idx].queue_sends); - if (net_device->destroy && queue_sends == 0) - wake_up(&net_device->wait_drain); + if (unlikely(net_device->destroy)) { + if (queue_sends == 0) + wake_up(&net_device->wait_drain); + } else { + struct netdev_queue *txq = netdev_get_tx_queue(ndev, q_idx); - if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && - (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || - queue_sends < 1)) { - netif_tx_wake_queue(netdev_get_tx_queue(ndev, q_idx)); - ndev_ctx->eth_stats.wake_queue++; + if (netif_tx_queue_stopped(txq) && + (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || + queue_sends < 1)) { + netif_tx_wake_queue(txq); + ndev_ctx->eth_stats.wake_queue++; + } } } diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index faea0be18924..f28c85d212ce 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -46,7 +46,10 @@ #include "hyperv_net.h" -#define RING_SIZE_MIN 64 +#define RING_SIZE_MIN 64 +#define RETRY_US_LO 5000 +#define RETRY_US_HI 10000 +#define RETRY_MAX 2000 /* >10 sec */ #define LINKCHANGE_INT (2 * HZ) #define VF_TAKEOVER_INT (HZ / 10) @@ -123,10 +126,8 @@ static int netvsc_open(struct net_device *net) } rdev = nvdev->extension; - if (!rdev->link_state) { + if (!rdev->link_state) netif_carrier_on(net); - netif_tx_wake_all_queues(net); - } if (vf_netdev) { /* Setting synthetic device up transparently sets @@ -142,36 +143,25 @@ static int netvsc_open(struct net_device *net) return 0; } -static int netvsc_close(struct net_device *net) +static int netvsc_wait_until_empty(struct netvsc_device *nvdev) { - struct net_device_context *net_device_ctx = netdev_priv(net); - struct net_device *vf_netdev - = rtnl_dereference(net_device_ctx->vf_netdev); - struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); - int ret = 0; - u32 aread, i, msec = 10, retry = 0, retry_max = 20; - struct vmbus_channel *chn; - - netif_tx_disable(net); - - /* No need to close rndis filter if it is removed already */ - if (!nvdev) - goto out; - - ret = rndis_filter_close(nvdev); - if (ret != 0) { - netdev_err(net, "unable to close device (ret %d).\n", ret); - return ret; - } + unsigned int retry = 0; + int i; /* Ensure pending bytes in ring are read */ - while (true) { - aread = 0; + for (;;) { + u32 aread = 0; + for (i = 0; i < nvdev->num_chn; i++) { - chn = nvdev->chan_table[i].channel; + struct vmbus_channel *chn + = nvdev->chan_table[i].channel; + if (!chn) continue; + /* make sure receive not running now */ + napi_synchronize(&nvdev->chan_table[i].napi); + aread = hv_get_bytes_to_read(&chn->inbound); if (aread) break; @@ -181,22 +171,40 @@ static int netvsc_close(struct net_device *net) break; } - retry++; - if (retry > retry_max || aread == 0) - break; + if (aread == 0) + return 0; - msleep(msec); + if (++retry > RETRY_MAX) + return -ETIMEDOUT; - if (msec < 1000) - msec *= 2; + usleep_range(RETRY_US_LO, RETRY_US_HI); + } +} + +static int netvsc_close(struct net_device *net) +{ + struct net_device_context *net_device_ctx = netdev_priv(net); + struct net_device *vf_netdev + = rtnl_dereference(net_device_ctx->vf_netdev); + struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); + int ret; + + netif_tx_disable(net); + + /* No need to close rndis filter if it is removed already */ + if (!nvdev) + return 0; + + ret = rndis_filter_close(nvdev); + if (ret != 0) { + netdev_err(net, "unable to close device (ret %d).\n", ret); + return ret; } - if (aread) { + ret = netvsc_wait_until_empty(nvdev); + if (ret) netdev_err(net, "Ring buffer not empty after closing rndis\n"); - ret = -ETIMEDOUT; - } -out: if (vf_netdev) dev_close(vf_netdev); @@ -845,16 +853,81 @@ static void netvsc_get_channels(struct net_device *net, } } +static int netvsc_detach(struct net_device *ndev, + struct netvsc_device *nvdev) +{ + struct net_device_context *ndev_ctx = netdev_priv(ndev); + struct hv_device *hdev = ndev_ctx->device_ctx; + int ret; + + /* Don't try continuing to try and setup sub channels */ + if (cancel_work_sync(&nvdev->subchan_work)) + nvdev->num_chn = 1; + + /* If device was up (receiving) then shutdown */ + if (netif_running(ndev)) { + netif_tx_disable(ndev); + + ret = rndis_filter_close(nvdev); + if (ret) { + netdev_err(ndev, + "unable to close device (ret %d).\n", ret); + return ret; + } + + ret = netvsc_wait_until_empty(nvdev); + if (ret) { + netdev_err(ndev, + "Ring buffer not empty after closing rndis\n"); + return ret; + } + } + + netif_device_detach(ndev); + + rndis_filter_device_remove(hdev, nvdev); + + return 0; +} + +static int netvsc_attach(struct net_device *ndev, + struct netvsc_device_info *dev_info) +{ + struct net_device_context *ndev_ctx = netdev_priv(ndev); + struct hv_device *hdev = ndev_ctx->device_ctx; + struct netvsc_device *nvdev; + struct rndis_device *rdev; + int ret; + + nvdev = rndis_filter_device_add(hdev, dev_info); + if (IS_ERR(nvdev)) + return PTR_ERR(nvdev); + + /* Note: enable and attach happen when sub-channels setup */ + + netif_carrier_off(ndev); + + if (netif_running(ndev)) { + ret = rndis_filter_open(nvdev); + if (ret) + return ret; + + rdev = nvdev->extension; + if (!rdev->link_state) + netif_carrier_on(ndev); + } + + return 0; +} + static int netvsc_set_channels(struct net_device *net, struct ethtool_channels *channels) { struct net_device_context *net_device_ctx = netdev_priv(net); - struct hv_device *dev = net_device_ctx->device_ctx; struct netvsc_device *nvdev = rtnl_dereference(net_device_ctx->nvdev); unsigned int orig, count = channels->combined_count; struct netvsc_device_info device_info; - bool was_opened; - int ret = 0; + int ret; /* We do not support separate count for rx, tx, or other */ if (count == 0 || @@ -871,9 +944,6 @@ static int netvsc_set_channels(struct net_device *net, return -EINVAL; orig = nvdev->num_chn; - was_opened = rndis_filter_opened(nvdev); - if (was_opened) - rndis_filter_close(nvdev); memset(&device_info, 0, sizeof(device_info)); device_info.num_chn = count; @@ -882,28 +952,17 @@ static int netvsc_set_channels(struct net_device *net, device_info.recv_sections = nvdev->recv_section_cnt; device_info.recv_section_size = nvdev->recv_section_size; - rndis_filter_device_remove(dev, nvdev); + ret = netvsc_detach(net, nvdev); + if (ret) + return ret; - nvdev = rndis_filter_device_add(dev, &device_info); - if (IS_ERR(nvdev)) { - ret = PTR_ERR(nvdev); + ret = netvsc_attach(net, &device_info); + if (ret) { device_info.num_chn = orig; - nvdev = rndis_filter_device_add(dev, &device_info); - - if (IS_ERR(nvdev)) { - netdev_err(net, "restoring channel setting failed: %ld\n", - PTR_ERR(nvdev)); - return ret; - } + if (netvsc_attach(net, &device_info)) + netdev_err(net, "restoring channel setting failed\n"); } - if (was_opened) - rndis_filter_open(nvdev); - - /* We may have missed link change notifications */ - net_device_ctx->last_reconfig = 0; - schedule_delayed_work(&net_device_ctx->dwork, 0); - return ret; } @@ -969,10 +1028,8 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) struct net_device_context *ndevctx = netdev_priv(ndev); struct net_device *vf_netdev = rtnl_dereference(ndevctx->vf_netdev); struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); - struct hv_device *hdev = ndevctx->device_ctx; int orig_mtu = ndev->mtu; struct netvsc_device_info device_info; - bool was_opened; int ret = 0; if (!nvdev || nvdev->destroy) @@ -985,11 +1042,6 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) return ret; } - netif_device_detach(ndev); - was_opened = rndis_filter_opened(nvdev); - if (was_opened) - rndis_filter_close(nvdev); - memset(&device_info, 0, sizeof(device_info)); device_info.num_chn = nvdev->num_chn; device_info.send_sections = nvdev->send_section_cnt; @@ -997,35 +1049,27 @@ static int netvsc_change_mtu(struct net_device *ndev, int mtu) device_info.recv_sections = nvdev->recv_section_cnt; device_info.recv_section_size = nvdev->recv_section_size; - rndis_filter_device_remove(hdev, nvdev); + ret = netvsc_detach(ndev, nvdev); + if (ret) + goto rollback_vf; ndev->mtu = mtu; - nvdev = rndis_filter_device_add(hdev, &device_info); - if (IS_ERR(nvdev)) { - ret = PTR_ERR(nvdev); + ret = netvsc_attach(ndev, &device_info); + if (ret) + goto rollback; - /* Attempt rollback to original MTU */ - ndev->mtu = orig_mtu; - nvdev = rndis_filter_device_add(hdev, &device_info); + return 0; - if (vf_netdev) - dev_set_mtu(vf_netdev, orig_mtu); +rollback: + /* Attempt rollback to original MTU */ + ndev->mtu = orig_mtu; - if (IS_ERR(nvdev)) { - netdev_err(ndev, "restoring mtu failed: %ld\n", - PTR_ERR(nvdev)); - return ret; - } - } - - if (was_opened) - rndis_filter_open(nvdev); - - netif_device_attach(ndev); - - /* We may have missed link change notifications */ - schedule_delayed_work(&ndevctx->dwork, 0); + if (netvsc_attach(ndev, &device_info)) + netdev_err(ndev, "restoring mtu failed\n"); +rollback_vf: + if (vf_netdev) + dev_set_mtu(vf_netdev, orig_mtu); return ret; } @@ -1531,11 +1575,9 @@ static int netvsc_set_ringparam(struct net_device *ndev, { struct net_device_context *ndevctx = netdev_priv(ndev); struct netvsc_device *nvdev = rtnl_dereference(ndevctx->nvdev); - struct hv_device *hdev = ndevctx->device_ctx; struct netvsc_device_info device_info; struct ethtool_ringparam orig; u32 new_tx, new_rx; - bool was_opened; int ret = 0; if (!nvdev || nvdev->destroy) @@ -1560,35 +1602,19 @@ static int netvsc_set_ringparam(struct net_device *ndev, device_info.recv_sections = new_rx; device_info.recv_section_size = nvdev->recv_section_size; - netif_device_detach(ndev); - was_opened = rndis_filter_opened(nvdev); - if (was_opened) - rndis_filter_close(nvdev); - - rndis_filter_device_remove(hdev, nvdev); - - nvdev = rndis_filter_device_add(hdev, &device_info); - if (IS_ERR(nvdev)) { - ret = PTR_ERR(nvdev); + ret = netvsc_detach(ndev, nvdev); + if (ret) + return ret; + ret = netvsc_attach(ndev, &device_info); + if (ret) { device_info.send_sections = orig.tx_pending; device_info.recv_sections = orig.rx_pending; - nvdev = rndis_filter_device_add(hdev, &device_info); - if (IS_ERR(nvdev)) { - netdev_err(ndev, "restoring ringparam failed: %ld\n", - PTR_ERR(nvdev)); - return ret; - } + + if (netvsc_attach(ndev, &device_info)) + netdev_err(ndev, "restoring ringparam failed"); } - if (was_opened) - rndis_filter_open(nvdev); - netif_device_attach(ndev); - - /* We may have missed link change notifications */ - ndevctx->last_reconfig = 0; - schedule_delayed_work(&ndevctx->dwork, 0); - return ret; } @@ -2072,8 +2098,8 @@ no_net: static int netvsc_remove(struct hv_device *dev) { struct net_device_context *ndev_ctx; - struct net_device *vf_netdev; - struct net_device *net; + struct net_device *vf_netdev, *net; + struct netvsc_device *nvdev; net = hv_get_drvdata(dev); if (net == NULL) { @@ -2083,10 +2109,14 @@ static int netvsc_remove(struct hv_device *dev) ndev_ctx = netdev_priv(net); - netif_device_detach(net); - cancel_delayed_work_sync(&ndev_ctx->dwork); + rcu_read_lock(); + nvdev = rcu_dereference(ndev_ctx->nvdev); + + if (nvdev) + cancel_work_sync(&nvdev->subchan_work); + /* * Call to the vsc driver to let it know that the device is being * removed. Also blocks mtu and channel changes. @@ -2096,11 +2126,13 @@ static int netvsc_remove(struct hv_device *dev) if (vf_netdev) netvsc_unregister_vf(vf_netdev); + if (nvdev) + rndis_filter_device_remove(dev, nvdev); + unregister_netdevice(net); - rndis_filter_device_remove(dev, - rtnl_dereference(ndev_ctx->nvdev)); rtnl_unlock(); + rcu_read_unlock(); hv_set_drvdata(dev, NULL); diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 963314eb3226..a6ec41c399d6 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1118,6 +1118,7 @@ void rndis_set_subchannel(struct work_struct *w) for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) ndev_ctx->tx_table[i] = i % nvdev->num_chn; + netif_device_attach(ndev); rtnl_unlock(); return; @@ -1128,6 +1129,8 @@ failed: nvdev->max_chn = 1; nvdev->num_chn = 1; + + netif_device_attach(ndev); unlock: rtnl_unlock(); } @@ -1330,6 +1333,10 @@ out: net_device->num_chn = 1; } + /* No sub channels, device is ready */ + if (net_device->num_chn == 1) + netif_device_attach(net); + return net_device; err_dev_remv: @@ -1342,9 +1349,6 @@ void rndis_filter_device_remove(struct hv_device *dev, { struct rndis_device *rndis_dev = net_dev->extension; - /* Don't try and setup sub channels if about to halt */ - cancel_work_sync(&net_dev->subchan_work); - /* Halt and release the rndis device */ rndis_filter_halt_device(rndis_dev); @@ -1368,10 +1372,3 @@ int rndis_filter_close(struct netvsc_device *nvdev) return rndis_filter_close_device(nvdev->extension); } - -bool rndis_filter_opened(const struct netvsc_device *nvdev) -{ - const struct rndis_device *dev = nvdev->extension; - - return dev->state == RNDIS_DEV_DATAINITIALIZED; -} From 40013ff20b1beed31184935fc0aea6a859d4d4ef Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Tue, 20 Mar 2018 17:31:10 -0700 Subject: [PATCH 912/942] net: dsa: Fix functional dsa-loop dependency on FIXED_PHY We have a functional dependency on the FIXED_PHY MDIO bus because we register fixed PHY devices "the old way" which only works if the code that does this has had a chance to run before the fixed MDIO bus is probed. Make sure we account for that and have dsa_loop_bdinfo.o be either built-in or modular depending on whether CONFIG_FIXED_PHY reflects that too. Fixes: 98cd1552ea27 ("net: dsa: Mock-up driver") Signed-off-by: Florian Fainelli Signed-off-by: David S. Miller --- drivers/net/dsa/Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/Makefile b/drivers/net/dsa/Makefile index d040aeb45172..15c2a831edf1 100644 --- a/drivers/net/dsa/Makefile +++ b/drivers/net/dsa/Makefile @@ -1,7 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_NET_DSA_BCM_SF2) += bcm-sf2.o bcm-sf2-objs := bcm_sf2.o bcm_sf2_cfp.o -obj-$(CONFIG_NET_DSA_LOOP) += dsa_loop.o dsa_loop_bdinfo.o +obj-$(CONFIG_NET_DSA_LOOP) += dsa_loop.o +ifdef CONFIG_NET_DSA_LOOP +obj-$(CONFIG_FIXED_PHY) += dsa_loop_bdinfo.o +endif obj-$(CONFIG_NET_DSA_MT7530) += mt7530.o obj-$(CONFIG_NET_DSA_MV88E6060) += mv88e6060.o obj-$(CONFIG_NET_DSA_QCA8K) += qca8k.o From 5dcd8400884cc4a043a6d4617e042489e5d566a9 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Wed, 21 Mar 2018 11:09:01 +0300 Subject: [PATCH 913/942] macsec: missing dev_put() on error in macsec_newlink() We moved the dev_hold(real_dev); call earlier in the function but forgot to update the error paths. Fixes: 0759e552bce7 ("macsec: fix negative refcnt on parent link") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller --- drivers/net/macsec.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 7de88b33d5b9..9cbb0c8a896a 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3277,7 +3277,7 @@ static int macsec_newlink(struct net *net, struct net_device *dev, err = netdev_upper_dev_link(real_dev, dev, extack); if (err < 0) - goto unregister; + goto put_dev; /* need to be already registered so that ->init has run and * the MAC addr is set @@ -3316,7 +3316,8 @@ del_dev: macsec_del_dev(macsec); unlink: netdev_upper_dev_unlink(real_dev, dev); -unregister: +put_dev: + dev_put(real_dev); unregister_netdevice(dev); return err; } From 5a9f698feb11b198f17b2acebbfe0e2716a3beed Mon Sep 17 00:00:00 2001 From: "Y.C. Chen" Date: Mon, 12 Mar 2018 11:40:23 +0800 Subject: [PATCH 914/942] drm/ast: Fixed 1280x800 Display Issue The original ast driver cannot display properly if the resolution is 1280x800 and the pixel clock is 83.5MHz. Here is the update to fix it. Signed-off-by: Y.C. Chen Signed-off-by: Dave Airlie --- drivers/gpu/drm/ast/ast_tables.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_tables.h b/drivers/gpu/drm/ast/ast_tables.h index 5f4c2e833a65..d665dd5af5dd 100644 --- a/drivers/gpu/drm/ast/ast_tables.h +++ b/drivers/gpu/drm/ast/ast_tables.h @@ -97,7 +97,7 @@ static const struct ast_vbios_dclk_info dclk_table[] = { {0x67, 0x22, 0x00}, /* 0E: VCLK157_5 */ {0x6A, 0x22, 0x00}, /* 0F: VCLK162 */ {0x4d, 0x4c, 0x80}, /* 10: VCLK154 */ - {0xa7, 0x78, 0x80}, /* 11: VCLK83.5 */ + {0x68, 0x6f, 0x80}, /* 11: VCLK83.5 */ {0x28, 0x49, 0x80}, /* 12: VCLK106.5 */ {0x37, 0x49, 0x80}, /* 13: VCLK146.25 */ {0x1f, 0x45, 0x80}, /* 14: VCLK148.5 */ @@ -127,7 +127,7 @@ static const struct ast_vbios_dclk_info dclk_table_ast2500[] = { {0x67, 0x22, 0x00}, /* 0E: VCLK157_5 */ {0x6A, 0x22, 0x00}, /* 0F: VCLK162 */ {0x4d, 0x4c, 0x80}, /* 10: VCLK154 */ - {0xa7, 0x78, 0x80}, /* 11: VCLK83.5 */ + {0x68, 0x6f, 0x80}, /* 11: VCLK83.5 */ {0x28, 0x49, 0x80}, /* 12: VCLK106.5 */ {0x37, 0x49, 0x80}, /* 13: VCLK146.25 */ {0x1f, 0x45, 0x80}, /* 14: VCLK148.5 */ From 8970a63e965b43288c4f5f40efbc2bbf80de7f16 Mon Sep 17 00:00:00 2001 From: Yisheng Xie Date: Thu, 22 Mar 2018 16:17:02 -0700 Subject: [PATCH 915/942] mm/mempolicy.c: avoid use uninitialized preferred_node Alexander reported a use of uninitialized memory in __mpol_equal(), which is caused by incorrect use of preferred_node. When mempolicy in mode MPOL_PREFERRED with flags MPOL_F_LOCAL, it uses numa_node_id() instead of preferred_node, however, __mpol_equal() uses preferred_node without checking whether it is MPOL_F_LOCAL or not. [akpm@linux-foundation.org: slight comment tweak] Link: http://lkml.kernel.org/r/4ebee1c2-57f6-bcb8-0e2d-1833d1ee0bb7@huawei.com Fixes: fc36b8d3d819 ("mempolicy: use MPOL_F_LOCAL to Indicate Preferred Local Policy") Signed-off-by: Yisheng Xie Reported-by: Alexander Potapenko Tested-by: Alexander Potapenko Reviewed-by: Andrew Morton Cc: Dmitriy Vyukov Cc: Vlastimil Babka Cc: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/mempolicy.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d879f1d8a44a..32cba0332787 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -2124,6 +2124,9 @@ bool __mpol_equal(struct mempolicy *a, struct mempolicy *b) case MPOL_INTERLEAVE: return !!nodes_equal(a->v.nodes, b->v.nodes); case MPOL_PREFERRED: + /* a's ->flags is the same as b's */ + if (a->flags & MPOL_F_LOCAL) + return true; return a->v.preferred_node == b->v.preferred_node; default: BUG(); From 296cefee07a20c89c8008c32ea0421ca64caf358 Mon Sep 17 00:00:00 2001 From: Mark Fasheh Date: Thu, 22 Mar 2018 16:17:05 -0700 Subject: [PATCH 916/942] MAINTAINERS: update Mark Fasheh's e-mail I'd like to use my personal e-mail for Ocfs2 requests and review. Link: http://lkml.kernel.org/r/20180311231356.9385-1-mfasheh@versity.com Signed-off-by: Mark Fasheh Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index 4e62756936fa..73c0cdabf755 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10334,7 +10334,7 @@ F: drivers/oprofile/ F: include/linux/oprofile.h ORACLE CLUSTER FILESYSTEM 2 (OCFS2) -M: Mark Fasheh +M: Mark Fasheh M: Joel Becker L: ocfs2-devel@oss.oracle.com (moderated for non-subscribers) W: http://ocfs2.wiki.kernel.org From 2e517d681632326ed98399cb4dd99519efe3e32c Mon Sep 17 00:00:00 2001 From: Tetsuo Handa Date: Thu, 22 Mar 2018 16:17:10 -0700 Subject: [PATCH 917/942] lockdep: fix fs_reclaim warning Dave Jones reported fs_reclaim lockdep warnings. ============================================ WARNING: possible recursive locking detected 4.15.0-rc9-backup-debug+ #1 Not tainted -------------------------------------------- sshd/24800 is trying to acquire lock: (fs_reclaim){+.+.}, at: [<0000000084f438c2>] fs_reclaim_acquire.part.102+0x5/0x30 but task is already holding lock: (fs_reclaim){+.+.}, at: [<0000000084f438c2>] fs_reclaim_acquire.part.102+0x5/0x30 other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(fs_reclaim); lock(fs_reclaim); *** DEADLOCK *** May be due to missing lock nesting notation 2 locks held by sshd/24800: #0: (sk_lock-AF_INET6){+.+.}, at: [<000000001a069652>] tcp_sendmsg+0x19/0x40 #1: (fs_reclaim){+.+.}, at: [<0000000084f438c2>] fs_reclaim_acquire.part.102+0x5/0x30 stack backtrace: CPU: 3 PID: 24800 Comm: sshd Not tainted 4.15.0-rc9-backup-debug+ #1 Call Trace: dump_stack+0xbc/0x13f __lock_acquire+0xa09/0x2040 lock_acquire+0x12e/0x350 fs_reclaim_acquire.part.102+0x29/0x30 kmem_cache_alloc+0x3d/0x2c0 alloc_extent_state+0xa7/0x410 __clear_extent_bit+0x3ea/0x570 try_release_extent_mapping+0x21a/0x260 __btrfs_releasepage+0xb0/0x1c0 btrfs_releasepage+0x161/0x170 try_to_release_page+0x162/0x1c0 shrink_page_list+0x1d5a/0x2fb0 shrink_inactive_list+0x451/0x940 shrink_node_memcg.constprop.88+0x4c9/0x5e0 shrink_node+0x12d/0x260 try_to_free_pages+0x418/0xaf0 __alloc_pages_slowpath+0x976/0x1790 __alloc_pages_nodemask+0x52c/0x5c0 new_slab+0x374/0x3f0 ___slab_alloc.constprop.81+0x47e/0x5a0 __slab_alloc.constprop.80+0x32/0x60 __kmalloc_track_caller+0x267/0x310 __kmalloc_reserve.isra.40+0x29/0x80 __alloc_skb+0xee/0x390 sk_stream_alloc_skb+0xb8/0x340 tcp_sendmsg_locked+0x8e6/0x1d30 tcp_sendmsg+0x27/0x40 inet_sendmsg+0xd0/0x310 sock_write_iter+0x17a/0x240 __vfs_write+0x2ab/0x380 vfs_write+0xfb/0x260 SyS_write+0xb6/0x140 do_syscall_64+0x1e5/0xc05 entry_SYSCALL64_slow_path+0x25/0x25 This warning is caused by commit d92a8cfcb37e ("locking/lockdep: Rework FS_RECLAIM annotation") which replaced the use of lockdep_{set,clear}_current_reclaim_state() in __perform_reclaim() and lockdep_trace_alloc() in slab_pre_alloc_hook() with fs_reclaim_acquire()/ fs_reclaim_release(). Since __kmalloc_reserve() from __alloc_skb() adds __GFP_NOMEMALLOC | __GFP_NOWARN to gfp_mask, and all reclaim path simply propagates __GFP_NOMEMALLOC, fs_reclaim_acquire() in slab_pre_alloc_hook() is trying to grab the 'fake' lock again when __perform_reclaim() already grabbed the 'fake' lock. The /* this guy won't enter reclaim */ if ((current->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) return false; test which causes slab_pre_alloc_hook() to try to grab the 'fake' lock was added by commit cf40bd16fdad ("lockdep: annotate reclaim context (__GFP_NOFS)"). But that test is outdated because PF_MEMALLOC thread won't enter reclaim regardless of __GFP_NOMEMALLOC after commit 341ce06f69ab ("page allocator: calculate the alloc_flags for allocation only once") added the PF_MEMALLOC safeguard ( /* Avoid recursion of direct reclaim */ if (p->flags & PF_MEMALLOC) goto nopage; in __alloc_pages_slowpath()). Thus, let's fix outdated test by removing __GFP_NOMEMALLOC test and allow __need_fs_reclaim() to return false. Link: http://lkml.kernel.org/r/201802280650.FJC73911.FOSOMLJVFFQtHO@I-love.SAKURA.ne.jp Fixes: d92a8cfcb37ecd13 ("locking/lockdep: Rework FS_RECLAIM annotation") Signed-off-by: Tetsuo Handa Reported-by: Dave Jones Tested-by: Dave Jones Cc: Peter Zijlstra Cc: Nick Piggin Cc: Ingo Molnar Cc: Nikolay Borisov Cc: Michal Hocko Cc: [4.14+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/page_alloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 635d7dd29d7f..010dee0f089e 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3596,7 +3596,7 @@ static bool __need_fs_reclaim(gfp_t gfp_mask) return false; /* this guy won't enter reclaim */ - if ((current->flags & PF_MEMALLOC) && !(gfp_mask & __GFP_NOMEMALLOC)) + if (current->flags & PF_MEMALLOC) return false; /* We're only interested __GFP_FS allocations for now */ From 63489f8e821144000e0bdca7e65a8d1cc23a7ee7 Mon Sep 17 00:00:00 2001 From: Mike Kravetz Date: Thu, 22 Mar 2018 16:17:13 -0700 Subject: [PATCH 918/942] hugetlbfs: check for pgoff value overflow A vma with vm_pgoff large enough to overflow a loff_t type when converted to a byte offset can be passed via the remap_file_pages system call. The hugetlbfs mmap routine uses the byte offset to calculate reservations and file size. A sequence such as: mmap(0x20a00000, 0x600000, 0, 0x66033, -1, 0); remap_file_pages(0x20a00000, 0x600000, 0, 0x20000000000000, 0); will result in the following when task exits/file closed, kernel BUG at mm/hugetlb.c:749! Call Trace: hugetlbfs_evict_inode+0x2f/0x40 evict+0xcb/0x190 __dentry_kill+0xcb/0x150 __fput+0x164/0x1e0 task_work_run+0x84/0xa0 exit_to_usermode_loop+0x7d/0x80 do_syscall_64+0x18b/0x190 entry_SYSCALL_64_after_hwframe+0x3d/0xa2 The overflowed pgoff value causes hugetlbfs to try to set up a mapping with a negative range (end < start) that leaves invalid state which causes the BUG. The previous overflow fix to this code was incomplete and did not take the remap_file_pages system call into account. [mike.kravetz@oracle.com: v3] Link: http://lkml.kernel.org/r/20180309002726.7248-1-mike.kravetz@oracle.com [akpm@linux-foundation.org: include mmdebug.h] [akpm@linux-foundation.org: fix -ve left shift count on sh] Link: http://lkml.kernel.org/r/20180308210502.15952-1-mike.kravetz@oracle.com Fixes: 045c7a3f53d9 ("hugetlbfs: fix offset overflow in hugetlbfs mmap") Signed-off-by: Mike Kravetz Reported-by: Nic Losby Acked-by: Michal Hocko Cc: "Kirill A . Shutemov" Cc: Yisheng Xie Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/hugetlbfs/inode.c | 17 ++++++++++++++--- mm/hugetlb.c | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 8fe1b0aa2896..b9a254dcc0e7 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -108,6 +108,16 @@ static void huge_pagevec_release(struct pagevec *pvec) pagevec_reinit(pvec); } +/* + * Mask used when checking the page offset value passed in via system + * calls. This value will be converted to a loff_t which is signed. + * Therefore, we want to check the upper PAGE_SHIFT + 1 bits of the + * value. The extra bit (- 1 in the shift value) is to take the sign + * bit into account. + */ +#define PGOFF_LOFFT_MAX \ + (((1UL << (PAGE_SHIFT + 1)) - 1) << (BITS_PER_LONG - (PAGE_SHIFT + 1))) + static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) { struct inode *inode = file_inode(file); @@ -127,12 +137,13 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma) vma->vm_ops = &hugetlb_vm_ops; /* - * Offset passed to mmap (before page shift) could have been - * negative when represented as a (l)off_t. + * page based offset in vm_pgoff could be sufficiently large to + * overflow a (l)off_t when converted to byte offset. */ - if (((loff_t)vma->vm_pgoff << PAGE_SHIFT) < 0) + if (vma->vm_pgoff & PGOFF_LOFFT_MAX) return -EINVAL; + /* must be huge page aligned */ if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT)) return -EINVAL; diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a963f2034dfc..976bbc5646fe 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -4374,6 +4375,12 @@ int hugetlb_reserve_pages(struct inode *inode, struct resv_map *resv_map; long gbl_reserve; + /* This should never happen */ + if (from > to) { + VM_WARN(1, "%s called with a negative range\n", __func__); + return -EINVAL; + } + /* * Only apply hugepage reservation if asked. At fault time, an * attempt will be made for VM_NORESERVE to allocate a page From 1705f7c534163594f8b05e060cb49fbea86ca70b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 22 Mar 2018 16:17:17 -0700 Subject: [PATCH 919/942] h8300: remove extraneous __BIG_ENDIAN definition A bugfix I did earlier caused a build regression on h8300, which defines the __BIG_ENDIAN macro in a slightly different way than the generic code: arch/h8300/include/asm/byteorder.h:5:0: warning: "__BIG_ENDIAN" redefined We don't need to define it here, as the same macro is already provided by the linux/byteorder/big_endian.h, and that version does not conflict. While this is a v4.16 regression, my earlier patch also got backported to the 4.14 and 4.15 stable kernels, so we need the fixup there as well. Link: http://lkml.kernel.org/r/20180313120752.2645129-1-arnd@arndb.de Fixes: 101110f6271c ("Kbuild: always define endianess in kconfig.h") Signed-off-by: Arnd Bergmann Cc: Yoshinori Sato Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/h8300/include/asm/byteorder.h | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/h8300/include/asm/byteorder.h b/arch/h8300/include/asm/byteorder.h index ecff2d1ca5a3..6eaa7ad5fc2c 100644 --- a/arch/h8300/include/asm/byteorder.h +++ b/arch/h8300/include/asm/byteorder.h @@ -2,7 +2,6 @@ #ifndef __H8300_BYTEORDER_H__ #define __H8300_BYTEORDER_H__ -#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__ #include #endif From b6bdb7517c3d3f41f20e5c2948d6bc3f8897394e Mon Sep 17 00:00:00 2001 From: Toshi Kani Date: Thu, 22 Mar 2018 16:17:20 -0700 Subject: [PATCH 920/942] mm/vmalloc: add interfaces to free unmapped page table On architectures with CONFIG_HAVE_ARCH_HUGE_VMAP set, ioremap() may create pud/pmd mappings. A kernel panic was observed on arm64 systems with Cortex-A75 in the following steps as described by Hanjun Guo. 1. ioremap a 4K size, valid page table will build, 2. iounmap it, pte0 will set to 0; 3. ioremap the same address with 2M size, pgd/pmd is unchanged, then set the a new value for pmd; 4. pte0 is leaked; 5. CPU may meet exception because the old pmd is still in TLB, which will lead to kernel panic. This panic is not reproducible on x86. INVLPG, called from iounmap, purges all levels of entries associated with purged address on x86. x86 still has memory leak. The patch changes the ioremap path to free unmapped page table(s) since doing so in the unmap path has the following issues: - The iounmap() path is shared with vunmap(). Since vmap() only supports pte mappings, making vunmap() to free a pte page is an overhead for regular vmap users as they do not need a pte page freed up. - Checking if all entries in a pte page are cleared in the unmap path is racy, and serializing this check is expensive. - The unmap path calls free_vmap_area_noflush() to do lazy TLB purges. Clearing a pud/pmd entry before the lazy TLB purges needs extra TLB purge. Add two interfaces, pud_free_pmd_page() and pmd_free_pte_page(), which clear a given pud/pmd entry and free up a page for the lower level entries. This patch implements their stub functions on x86 and arm64, which work as workaround. [akpm@linux-foundation.org: fix typo in pmd_free_pte_page() stub] Link: http://lkml.kernel.org/r/20180314180155.19492-2-toshi.kani@hpe.com Fixes: e61ce6ade404e ("mm: change ioremap to set up huge I/O mappings") Reported-by: Lei Li Signed-off-by: Toshi Kani Cc: Catalin Marinas Cc: Wang Xuefeng Cc: Will Deacon Cc: Hanjun Guo Cc: Michal Hocko Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Borislav Petkov Cc: Matthew Wilcox Cc: Chintan Pandya Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/arm64/mm/mmu.c | 10 ++++++++++ arch/x86/mm/pgtable.c | 24 ++++++++++++++++++++++++ include/asm-generic/pgtable.h | 10 ++++++++++ lib/ioremap.c | 6 ++++-- 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index 8c704f1e53c2..2dbb2c9f1ec1 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -972,3 +972,13 @@ int pmd_clear_huge(pmd_t *pmdp) pmd_clear(pmdp); return 1; } + +int pud_free_pmd_page(pud_t *pud) +{ + return pud_none(*pud); +} + +int pmd_free_pte_page(pmd_t *pmd) +{ + return pmd_none(*pmd); +} diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 004abf9ebf12..1eed7ed518e6 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -702,4 +702,28 @@ int pmd_clear_huge(pmd_t *pmd) return 0; } + +/** + * pud_free_pmd_page - Clear pud entry and free pmd page. + * @pud: Pointer to a PUD. + * + * Context: The pud range has been unmaped and TLB purged. + * Return: 1 if clearing the entry succeeded. 0 otherwise. + */ +int pud_free_pmd_page(pud_t *pud) +{ + return pud_none(*pud); +} + +/** + * pmd_free_pte_page - Clear pmd entry and free pte page. + * @pmd: Pointer to a PMD. + * + * Context: The pmd range has been unmaped and TLB purged. + * Return: 1 if clearing the entry succeeded. 0 otherwise. + */ +int pmd_free_pte_page(pmd_t *pmd) +{ + return pmd_none(*pmd); +} #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 2cfa3075d148..bfbb44a5ad38 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -983,6 +983,8 @@ int pud_set_huge(pud_t *pud, phys_addr_t addr, pgprot_t prot); int pmd_set_huge(pmd_t *pmd, phys_addr_t addr, pgprot_t prot); int pud_clear_huge(pud_t *pud); int pmd_clear_huge(pmd_t *pmd); +int pud_free_pmd_page(pud_t *pud); +int pmd_free_pte_page(pmd_t *pmd); #else /* !CONFIG_HAVE_ARCH_HUGE_VMAP */ static inline int p4d_set_huge(p4d_t *p4d, phys_addr_t addr, pgprot_t prot) { @@ -1008,6 +1010,14 @@ static inline int pmd_clear_huge(pmd_t *pmd) { return 0; } +static inline int pud_free_pmd_page(pud_t *pud) +{ + return 0; +} +static inline int pmd_free_pte_page(pmd_t *pmd) +{ + return 0; +} #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ #ifndef __HAVE_ARCH_FLUSH_PMD_TLB_RANGE diff --git a/lib/ioremap.c b/lib/ioremap.c index b808a390e4c3..54e5bbaa3200 100644 --- a/lib/ioremap.c +++ b/lib/ioremap.c @@ -91,7 +91,8 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr, if (ioremap_pmd_enabled() && ((next - addr) == PMD_SIZE) && - IS_ALIGNED(phys_addr + addr, PMD_SIZE)) { + IS_ALIGNED(phys_addr + addr, PMD_SIZE) && + pmd_free_pte_page(pmd)) { if (pmd_set_huge(pmd, phys_addr + addr, prot)) continue; } @@ -117,7 +118,8 @@ static inline int ioremap_pud_range(p4d_t *p4d, unsigned long addr, if (ioremap_pud_enabled() && ((next - addr) == PUD_SIZE) && - IS_ALIGNED(phys_addr + addr, PUD_SIZE)) { + IS_ALIGNED(phys_addr + addr, PUD_SIZE) && + pud_free_pmd_page(pud)) { if (pud_set_huge(pud, phys_addr + addr, prot)) continue; } From 28ee90fe6048fa7b7ceaeb8831c0e4e454a4cf89 Mon Sep 17 00:00:00 2001 From: Toshi Kani Date: Thu, 22 Mar 2018 16:17:24 -0700 Subject: [PATCH 921/942] x86/mm: implement free pmd/pte page interfaces Implement pud_free_pmd_page() and pmd_free_pte_page() on x86, which clear a given pud/pmd entry and free up lower level page table(s). The address range associated with the pud/pmd entry must have been purged by INVLPG. Link: http://lkml.kernel.org/r/20180314180155.19492-3-toshi.kani@hpe.com Fixes: e61ce6ade404e ("mm: change ioremap to set up huge I/O mappings") Signed-off-by: Toshi Kani Reported-by: Lei Li Cc: Michal Hocko Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Borislav Petkov Cc: Matthew Wilcox Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- arch/x86/mm/pgtable.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c index 1eed7ed518e6..34cda7e0551b 100644 --- a/arch/x86/mm/pgtable.c +++ b/arch/x86/mm/pgtable.c @@ -712,7 +712,22 @@ int pmd_clear_huge(pmd_t *pmd) */ int pud_free_pmd_page(pud_t *pud) { - return pud_none(*pud); + pmd_t *pmd; + int i; + + if (pud_none(*pud)) + return 1; + + pmd = (pmd_t *)pud_page_vaddr(*pud); + + for (i = 0; i < PTRS_PER_PMD; i++) + if (!pmd_free_pte_page(&pmd[i])) + return 0; + + pud_clear(pud); + free_page((unsigned long)pmd); + + return 1; } /** @@ -724,6 +739,15 @@ int pud_free_pmd_page(pud_t *pud) */ int pmd_free_pte_page(pmd_t *pmd) { - return pmd_none(*pmd); + pte_t *pte; + + if (pmd_none(*pmd)) + return 1; + + pte = (pte_t *)pmd_page_vaddr(*pmd); + pmd_clear(pmd); + free_page((unsigned long)pte); + + return 1; } #endif /* CONFIG_HAVE_ARCH_HUGE_VMAP */ From fece2029a9e65b9a990831afe2a2b83290cbbe26 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 22 Mar 2018 16:17:28 -0700 Subject: [PATCH 922/942] mm/khugepaged.c: convert VM_BUG_ON() to collapse fail khugepaged is not yet able to convert PTE-mapped huge pages back to PMD mapped. We do not collapse such pages. See check khugepaged_scan_pmd(). But if between khugepaged_scan_pmd() and __collapse_huge_page_isolate() somebody managed to instantiate THP in the range and then split the PMD back to PTEs we would have a problem -- VM_BUG_ON_PAGE(PageCompound(page)) will get triggered. It's possible since we drop mmap_sem during collapse to re-take for write. Replace the VM_BUG_ON() with graceful collapse fail. Link: http://lkml.kernel.org/r/20180315152353.27989-1-kirill.shutemov@linux.intel.com Fixes: b1caa957ae6d ("khugepaged: ignore pmd tables with THP mapped with ptes") Signed-off-by: Kirill A. Shutemov Cc: Laura Abbott Cc: Jerome Marchand Cc: Vlastimil Babka Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/khugepaged.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index b7e2268dfc9a..c15da1ea7e63 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -530,7 +530,12 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma, goto out; } - VM_BUG_ON_PAGE(PageCompound(page), page); + /* TODO: teach khugepaged to collapse THP mapped with pte */ + if (PageCompound(page)) { + result = SCAN_PAGE_COMPOUND; + goto out; + } + VM_BUG_ON_PAGE(!PageAnon(page), page); /* From fa41b900c30b45fab03783724932dc30cd46a6be Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 22 Mar 2018 16:17:31 -0700 Subject: [PATCH 923/942] mm/thp: do not wait for lock_page() in deferred_split_scan() deferred_split_scan() gets called from reclaim path. Waiting for page lock may lead to deadlock there. Replace lock_page() with trylock_page() and skip the page if we failed to lock it. We will get to the page on the next scan. Link: http://lkml.kernel.org/r/20180315150747.31945-1-kirill.shutemov@linux.intel.com Fixes: 9a982250f773 ("thp: introduce deferred_split_huge_page()") Signed-off-by: Kirill A. Shutemov Acked-by: Michal Hocko Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/huge_memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 87ab9b8f56b5..529cf36b7edb 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2783,11 +2783,13 @@ static unsigned long deferred_split_scan(struct shrinker *shrink, list_for_each_safe(pos, next, &list) { page = list_entry((void *)pos, struct page, mapping); - lock_page(page); + if (!trylock_page(page)) + goto next; /* split_huge_page() removes page from list on success */ if (!split_huge_page(page)) split++; unlock_page(page); +next: put_page(page); } From b3cd54b257ad95d344d121dc563d943ca39b0921 Mon Sep 17 00:00:00 2001 From: "Kirill A. Shutemov" Date: Thu, 22 Mar 2018 16:17:35 -0700 Subject: [PATCH 924/942] mm/shmem: do not wait for lock_page() in shmem_unused_huge_shrink() shmem_unused_huge_shrink() gets called from reclaim path. Waiting for page lock may lead to deadlock there. There was a bug report that may be attributed to this: http://lkml.kernel.org/r/alpine.LRH.2.11.1801242349220.30642@mail.ewheeler.net Replace lock_page() with trylock_page() and skip the page if we failed to lock it. We will get to the page on the next scan. We can test for the PageTransHuge() outside the page lock as we only need protection against splitting the page under us. Holding pin oni the page is enough for this. Link: http://lkml.kernel.org/r/20180316210830.43738-1-kirill.shutemov@linux.intel.com Fixes: 779750d20b93 ("shmem: split huge pages beyond i_size under memory pressure") Signed-off-by: Kirill A. Shutemov Reported-by: Eric Wheeler Acked-by: Michal Hocko Reviewed-by: Andrew Morton Cc: Tetsuo Handa Cc: Hugh Dickins Cc: [4.8+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/shmem.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 1907688b75ee..b85919243399 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -493,36 +493,45 @@ next: info = list_entry(pos, struct shmem_inode_info, shrinklist); inode = &info->vfs_inode; - if (nr_to_split && split >= nr_to_split) { - iput(inode); - continue; - } + if (nr_to_split && split >= nr_to_split) + goto leave; - page = find_lock_page(inode->i_mapping, + page = find_get_page(inode->i_mapping, (inode->i_size & HPAGE_PMD_MASK) >> PAGE_SHIFT); if (!page) goto drop; + /* No huge page at the end of the file: nothing to split */ if (!PageTransHuge(page)) { - unlock_page(page); put_page(page); goto drop; } + /* + * Leave the inode on the list if we failed to lock + * the page at this time. + * + * Waiting for the lock may lead to deadlock in the + * reclaim path. + */ + if (!trylock_page(page)) { + put_page(page); + goto leave; + } + ret = split_huge_page(page); unlock_page(page); put_page(page); - if (ret) { - /* split failed: leave it on the list */ - iput(inode); - continue; - } + /* If split failed leave the inode on the list */ + if (ret) + goto leave; split++; drop: list_del_init(&info->shrinklist); removed++; +leave: iput(inode); } From f59f1caf72ba00d519c793c3deb32cd3be32edc2 Mon Sep 17 00:00:00 2001 From: Daniel Vacek Date: Thu, 22 Mar 2018 16:17:38 -0700 Subject: [PATCH 925/942] Revert "mm: page_alloc: skip over regions of invalid pfns where possible" This reverts commit b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible"). The commit is meant to be a boot init speed up skipping the loop in memmap_init_zone() for invalid pfns. But given some specific memory mapping on x86_64 (or more generally theoretically anywhere but on arm with CONFIG_HAVE_ARCH_PFN_VALID) the implementation also skips valid pfns which is plain wrong and causes 'kernel BUG at mm/page_alloc.c:1389!' crash> log | grep -e BUG -e RIP -e Call.Trace -e move_freepages_block -e rmqueue -e freelist -A1 kernel BUG at mm/page_alloc.c:1389! invalid opcode: 0000 [#1] SMP -- RIP: 0010: move_freepages+0x15e/0x160 -- Call Trace: move_freepages_block+0x73/0x80 __rmqueue+0x263/0x460 get_page_from_freelist+0x7e1/0x9e0 __alloc_pages_nodemask+0x176/0x420 -- crash> page_init_bug -v | grep RAM 1000 - 9bfff System RAM (620.00 KiB) 100000 - 430bffff System RAM ( 1.05 GiB = 1071.75 MiB = 1097472.00 KiB) 4b0c8000 - 4bf9cfff System RAM ( 14.83 MiB = 15188.00 KiB) 4bfac000 - 646b1fff System RAM (391.02 MiB = 400408.00 KiB) 7b788000 - 7b7fffff System RAM (480.00 KiB) 100000000 - 67fffffff System RAM ( 22.00 GiB) crash> page_init_bug | head -6 7b788000 - 7b7fffff System RAM (480.00 KiB) 1fffff00000000 0 1 DMA32 4096 1048575 505736 505344 505855 0 0 0 DMA 1 4095 1fffff00000400 0 1 DMA32 4096 1048575 BUG, zones differ! crash> kmem -p 77fff000 78000000 7b5ff000 7b600000 7b787000 7b788000 PAGE PHYSICAL MAPPING INDEX CNT FLAGS ffffea0001e00000 78000000 0 0 0 0 ffffea0001ed7fc0 7b5ff000 0 0 0 0 ffffea0001ed8000 7b600000 0 0 0 0 <<<< ffffea0001ede1c0 7b787000 0 0 0 0 ffffea0001ede200 7b788000 0 0 1 1fffff00000000 Link: http://lkml.kernel.org/r/20180316143855.29838-1-neelx@redhat.com Fixes: b92df1de5d28 ("mm: page_alloc: skip over regions of invalid pfns where possible") Signed-off-by: Daniel Vacek Acked-by: Ard Biesheuvel Acked-by: Michal Hocko Reviewed-by: Andrew Morton Cc: Vlastimil Babka Cc: Mel Gorman Cc: Pavel Tatashin Cc: Paul Burton Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/memblock.h | 1 - mm/memblock.c | 28 ---------------------------- mm/page_alloc.c | 11 +---------- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 8be5077efb5f..f92ea7783652 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -187,7 +187,6 @@ int memblock_search_pfn_nid(unsigned long pfn, unsigned long *start_pfn, unsigned long *end_pfn); void __next_mem_pfn_range(int *idx, int nid, unsigned long *out_start_pfn, unsigned long *out_end_pfn, int *out_nid); -unsigned long memblock_next_valid_pfn(unsigned long pfn, unsigned long max_pfn); /** * for_each_mem_pfn_range - early memory pfn range iterator diff --git a/mm/memblock.c b/mm/memblock.c index b6ba6b7adadc..48376bd33274 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1101,34 +1101,6 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid, *out_nid = r->nid; } -unsigned long __init_memblock memblock_next_valid_pfn(unsigned long pfn, - unsigned long max_pfn) -{ - struct memblock_type *type = &memblock.memory; - unsigned int right = type->cnt; - unsigned int mid, left = 0; - phys_addr_t addr = PFN_PHYS(++pfn); - - do { - mid = (right + left) / 2; - - if (addr < type->regions[mid].base) - right = mid; - else if (addr >= (type->regions[mid].base + - type->regions[mid].size)) - left = mid + 1; - else { - /* addr is within the region, so pfn is valid */ - return pfn; - } - } while (left < right); - - if (right == type->cnt) - return -1UL; - else - return PHYS_PFN(type->regions[right].base); -} - /** * memblock_set_node - set node ID on memblock regions * @base: base of area to set node ID for diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 010dee0f089e..1741dd23e7c1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -5356,17 +5356,8 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone, if (context != MEMMAP_EARLY) goto not_early; - if (!early_pfn_valid(pfn)) { -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP - /* - * Skip to the pfn preceding the next valid one (or - * end_pfn), such that we hit a valid pfn (or end_pfn) - * on our next iteration of the loop. - */ - pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; -#endif + if (!early_pfn_valid(pfn)) continue; - } if (!early_pfn_in_nid(pfn, nid)) continue; if (!update_defer_init(pgdat, pfn, end_pfn, &nr_initialised)) From 1c610d5f93c709df56787f50b3576704ac271826 Mon Sep 17 00:00:00 2001 From: Andrey Ryabinin Date: Thu, 22 Mar 2018 16:17:42 -0700 Subject: [PATCH 926/942] mm/vmscan: wake up flushers for legacy cgroups too Commit 726d061fbd36 ("mm: vmscan: kick flushers when we encounter dirty pages on the LRU") added flusher invocation to shrink_inactive_list() when many dirty pages on the LRU are encountered. However, shrink_inactive_list() doesn't wake up flushers for legacy cgroup reclaim, so the next commit bbef938429f5 ("mm: vmscan: remove old flusher wakeup from direct reclaim path") removed the only source of flusher's wake up in legacy mem cgroup reclaim path. This leads to premature OOM if there is too many dirty pages in cgroup: # mkdir /sys/fs/cgroup/memory/test # echo $$ > /sys/fs/cgroup/memory/test/tasks # echo 50M > /sys/fs/cgroup/memory/test/memory.limit_in_bytes # dd if=/dev/zero of=tmp_file bs=1M count=100 Killed dd invoked oom-killer: gfp_mask=0x14000c0(GFP_KERNEL), nodemask=(null), order=0, oom_score_adj=0 Call Trace: dump_stack+0x46/0x65 dump_header+0x6b/0x2ac oom_kill_process+0x21c/0x4a0 out_of_memory+0x2a5/0x4b0 mem_cgroup_out_of_memory+0x3b/0x60 mem_cgroup_oom_synchronize+0x2ed/0x330 pagefault_out_of_memory+0x24/0x54 __do_page_fault+0x521/0x540 page_fault+0x45/0x50 Task in /test killed as a result of limit of /test memory: usage 51200kB, limit 51200kB, failcnt 73 memory+swap: usage 51200kB, limit 9007199254740988kB, failcnt 0 kmem: usage 296kB, limit 9007199254740988kB, failcnt 0 Memory cgroup stats for /test: cache:49632KB rss:1056KB rss_huge:0KB shmem:0KB mapped_file:0KB dirty:49500KB writeback:0KB swap:0KB inactive_anon:0KB active_anon:1168KB inactive_file:24760KB active_file:24960KB unevictable:0KB Memory cgroup out of memory: Kill process 3861 (bash) score 88 or sacrifice child Killed process 3876 (dd) total-vm:8484kB, anon-rss:1052kB, file-rss:1720kB, shmem-rss:0kB oom_reaper: reaped process 3876 (dd), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB Wake up flushers in legacy cgroup reclaim too. Link: http://lkml.kernel.org/r/20180315164553.17856-1-aryabinin@virtuozzo.com Fixes: bbef938429f5 ("mm: vmscan: remove old flusher wakeup from direct reclaim path") Signed-off-by: Andrey Ryabinin Tested-by: Shakeel Butt Acked-by: Michal Hocko Cc: Mel Gorman Cc: Tejun Heo Cc: Johannes Weiner Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/vmscan.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index bee53495a829..cd5dc3faaa57 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1779,6 +1779,20 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, if (stat.nr_writeback && stat.nr_writeback == nr_taken) set_bit(PGDAT_WRITEBACK, &pgdat->flags); + /* + * If dirty pages are scanned that are not queued for IO, it + * implies that flushers are not doing their job. This can + * happen when memory pressure pushes dirty pages to the end of + * the LRU before the dirty limits are breached and the dirty + * data has expired. It can also happen when the proportion of + * dirty pages grows not through writes but through memory + * pressure reclaiming all the clean cache. And in some cases, + * the flushers simply cannot keep up with the allocation + * rate. Nudge the flusher threads in case they are asleep. + */ + if (stat.nr_unqueued_dirty == nr_taken) + wakeup_flusher_threads(WB_REASON_VMSCAN); + /* * Legacy memcg will stall in page writeback so avoid forcibly * stalling here. @@ -1791,22 +1805,9 @@ shrink_inactive_list(unsigned long nr_to_scan, struct lruvec *lruvec, if (stat.nr_dirty && stat.nr_dirty == stat.nr_congested) set_bit(PGDAT_CONGESTED, &pgdat->flags); - /* - * If dirty pages are scanned that are not queued for IO, it - * implies that flushers are not doing their job. This can - * happen when memory pressure pushes dirty pages to the end of - * the LRU before the dirty limits are breached and the dirty - * data has expired. It can also happen when the proportion of - * dirty pages grows not through writes but through memory - * pressure reclaiming all the clean cache. And in some cases, - * the flushers simply cannot keep up with the allocation - * rate. Nudge the flusher threads in case they are asleep, but - * also allow kswapd to start writing pages during reclaim. - */ - if (stat.nr_unqueued_dirty == nr_taken) { - wakeup_flusher_threads(WB_REASON_VMSCAN); + /* Allow kswapd to start writing pages during reclaim. */ + if (stat.nr_unqueued_dirty == nr_taken) set_bit(PGDAT_DIRTY, &pgdat->flags); - } /* * If kswapd scans pages marked marked for immediate From 9d3c3354bb85bab4d865fe95039443f09a4c8394 Mon Sep 17 00:00:00 2001 From: David Rientjes Date: Thu, 22 Mar 2018 16:17:45 -0700 Subject: [PATCH 927/942] mm, thp: do not cause memcg oom for thp Commit 2516035499b9 ("mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations") changed the page allocator to no longer detect thp allocations based on __GFP_NORETRY. It did not, however, modify the mem cgroup try_charge() path to avoid oom kill for either khugepaged collapsing or thp faulting. It is never expected to oom kill a process to allocate a hugepage for thp; reclaim is governed by the thp defrag mode and MADV_HUGEPAGE, but allocations (and charging) should fallback instead of oom killing processes. Link: http://lkml.kernel.org/r/alpine.DEB.2.20.1803191409420.124411@chino.kir.corp.google.com Fixes: 2516035499b9 ("mm, thp: remove __GFP_NORETRY from khugepaged and madvised allocations") Signed-off-by: David Rientjes Cc: "Kirill A. Shutemov" Cc: Michal Hocko Cc: Vlastimil Babka Cc: Johannes Weiner Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/huge_memory.c | 5 +++-- mm/khugepaged.c | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 529cf36b7edb..5a68730eebd6 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -555,7 +555,8 @@ static int __do_huge_pmd_anonymous_page(struct vm_fault *vmf, struct page *page, VM_BUG_ON_PAGE(!PageCompound(page), page); - if (mem_cgroup_try_charge(page, vma->vm_mm, gfp, &memcg, true)) { + if (mem_cgroup_try_charge(page, vma->vm_mm, gfp | __GFP_NORETRY, &memcg, + true)) { put_page(page); count_vm_event(THP_FAULT_FALLBACK); return VM_FAULT_FALLBACK; @@ -1316,7 +1317,7 @@ alloc: } if (unlikely(mem_cgroup_try_charge(new_page, vma->vm_mm, - huge_gfp, &memcg, true))) { + huge_gfp | __GFP_NORETRY, &memcg, true))) { put_page(new_page); split_huge_pmd(vma, vmf->pmd, vmf->address); if (page) diff --git a/mm/khugepaged.c b/mm/khugepaged.c index c15da1ea7e63..e42568284e06 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -965,7 +965,9 @@ static void collapse_huge_page(struct mm_struct *mm, goto out_nolock; } - if (unlikely(mem_cgroup_try_charge(new_page, mm, gfp, &memcg, true))) { + /* Do not oom kill for khugepaged charges */ + if (unlikely(mem_cgroup_try_charge(new_page, mm, gfp | __GFP_NORETRY, + &memcg, true))) { result = SCAN_CGROUP_CHARGE_FAIL; goto out_nolock; } @@ -1324,7 +1326,9 @@ static void collapse_shmem(struct mm_struct *mm, goto out; } - if (unlikely(mem_cgroup_try_charge(new_page, mm, gfp, &memcg, true))) { + /* Do not oom kill for khugepaged charges */ + if (unlikely(mem_cgroup_try_charge(new_page, mm, gfp | __GFP_NORETRY, + &memcg, true))) { result = SCAN_CGROUP_CHARGE_FAIL; goto out; } From c5d343b6b7badd1f5fe0873eff2e8d63a193e732 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Sat, 17 Mar 2018 21:38:10 +0900 Subject: [PATCH 928/942] tracing: probeevent: Fix to support minus offset from symbol In Documentation/trace/kprobetrace.txt, it says @SYM[+|-offs] : Fetch memory at SYM +|- offs (SYM should be a data symbol) However, the parser doesn't parse minus offset correctly, since commit 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned") drops minus ("-") offset support for kprobe probe address usage. This fixes the traceprobe_split_symbol_offset() to parse minus offset again with checking the offset range, and add a minus offset check in kprobe probe address usage. Link: http://lkml.kernel.org/r/152129028983.31874.13419301530285775521.stgit@devbox Cc: Ingo Molnar Cc: Tom Zanussi Cc: Arnaldo Carvalho de Melo Cc: Ravi Bangoria Cc: stable@vger.kernel.org Fixes: 2fba0c8867af ("tracing/kprobes: Fix probe offset to be unsigned") Acked-by: Namhyung Kim Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) --- kernel/trace/trace_kprobe.c | 4 ++-- kernel/trace/trace_probe.c | 8 +++----- kernel/trace/trace_probe.h | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 1fad24acd444..ae4147eaebd4 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -659,7 +659,7 @@ static int create_trace_kprobe(int argc, char **argv) char *symbol = NULL, *event = NULL, *group = NULL; int maxactive = 0; char *arg; - unsigned long offset = 0; + long offset = 0; void *addr = NULL; char buf[MAX_EVENT_NAME_LEN]; @@ -747,7 +747,7 @@ static int create_trace_kprobe(int argc, char **argv) symbol = argv[1]; /* TODO: support .init module functions */ ret = traceprobe_split_symbol_offset(symbol, &offset); - if (ret) { + if (ret || offset < 0 || offset > UINT_MAX) { pr_info("Failed to parse either an address or a symbol.\n"); return ret; } diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index d59357308677..daf54bda4dc8 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -320,7 +320,7 @@ static fetch_func_t get_fetch_size_function(const struct fetch_type *type, } /* Split symbol and offset. */ -int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset) +int traceprobe_split_symbol_offset(char *symbol, long *offset) { char *tmp; int ret; @@ -328,13 +328,11 @@ int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset) if (!offset) return -EINVAL; - tmp = strchr(symbol, '+'); + tmp = strpbrk(symbol, "+-"); if (tmp) { - /* skip sign because kstrtoul doesn't accept '+' */ - ret = kstrtoul(tmp + 1, 0, offset); + ret = kstrtol(tmp, 0, offset); if (ret) return ret; - *tmp = '\0'; } else *offset = 0; diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index e101c5bb9eda..6a4d3fa94042 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -365,7 +365,7 @@ extern int traceprobe_conflict_field_name(const char *name, extern void traceprobe_update_arg(struct probe_arg *arg); extern void traceprobe_free_probe_arg(struct probe_arg *arg); -extern int traceprobe_split_symbol_offset(char *symbol, unsigned long *offset); +extern int traceprobe_split_symbol_offset(char *symbol, long *offset); /* Sum up total data length for dynamic arraies (strings) */ static nokprobe_inline int From 871bef2000968c312a4000b2f56d370dcedbc93c Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Sat, 17 Mar 2018 21:38:56 +0900 Subject: [PATCH 929/942] selftests: ftrace: Add probe event argument syntax testcase Add a testcase for probe event argument syntax which ensures the kprobe_events interface correctly parses given event arguments. Link: http://lkml.kernel.org/r/152129033679.31874.12705519603869152799.stgit@devbox Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) --- .../test.d/kprobe/kprobe_args_syntax.tc | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc new file mode 100644 index 000000000000..231bcd2c4eb5 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc @@ -0,0 +1,97 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event argument syntax + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +grep "x8/16/32/64" README > /dev/null || exit_unsupported # version issue + +echo 0 > events/enable +echo > kprobe_events + +PROBEFUNC="vfs_read" +GOODREG= +BADREG= +GOODSYM="_sdata" +if ! grep -qw ${GOODSYM} /proc/kallsyms ; then + GOODSYM=$PROBEFUNC +fi +BADSYM="deaqswdefr" +SYMADDR=0x`grep -w ${GOODSYM} /proc/kallsyms | cut -f 1 -d " "` +GOODTYPE="x16" +BADTYPE="y16" + +case `uname -m` in +x86_64|i[3456]86) + GOODREG=%ax + BADREG=%ex +;; +aarch64) + GOODREG=%x0 + BADREG=%ax +;; +arm*) + GOODREG=%r0 + BADREG=%ax +;; +esac + +test_goodarg() # Good-args +{ + while [ "$1" ]; do + echo "p ${PROBEFUNC} $1" > kprobe_events + shift 1 + done; +} + +test_badarg() # Bad-args +{ + while [ "$1" ]; do + ! echo "p ${PROBEFUNC} $1" > kprobe_events + shift 1 + done; +} + +echo > kprobe_events + +: "Register access" +test_goodarg ${GOODREG} +test_badarg ${BADREG} + +: "Symbol access" +test_goodarg "@${GOODSYM}" "@${SYMADDR}" "@${GOODSYM}+10" "@${GOODSYM}-10" +test_badarg "@" "@${BADSYM}" "@${GOODSYM}*10" "@${GOODSYM}/10" \ + "@${GOODSYM}%10" "@${GOODSYM}&10" "@${GOODSYM}|10" + +: "Stack access" +test_goodarg "\$stack" "\$stack0" "\$stack1" +test_badarg "\$stackp" "\$stack0+10" "\$stack1-10" + +: "Retval access" +echo "r ${PROBEFUNC} \$retval" > kprobe_events +! echo "p ${PROBEFUNC} \$retval" > kprobe_events + +: "Comm access" +test_goodarg "\$comm" + +: "Indirect memory access" +test_goodarg "+0(${GOODREG})" "-0(${GOODREG})" "+10(\$stack)" \ + "+0(\$stack1)" "+10(@${GOODSYM}-10)" "+0(+10(+20(\$stack)))" +test_badarg "+(${GOODREG})" "(${GOODREG}+10)" "-(${GOODREG})" "(${GOODREG})" \ + "+10(\$comm)" "+0(${GOODREG})+10" + +: "Name assignment" +test_goodarg "varname=${GOODREG}" +test_badarg "varname=varname2=${GOODREG}" + +: "Type syntax" +test_goodarg "${GOODREG}:${GOODTYPE}" +test_badarg "${GOODREG}::${GOODTYPE}" "${GOODREG}:${BADTYPE}" \ + "${GOODTYPE}:${GOODREG}" + +: "Combination check" + +test_goodarg "\$comm:string" "+0(\$stack):string" +test_badarg "\$comm:x64" "\$stack:string" "${GOODREG}:string" + +echo > kprobe_events From 5fbdbed797b6d12d043a5121fdbc8d8b49d10e80 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Sat, 17 Mar 2018 21:39:44 +0900 Subject: [PATCH 930/942] selftests: ftrace: Add a testcase for string type with kprobe_event Add a testcase for string type with kprobe event. This tests good/bad syntax combinations and also the traced data is correct in several way. Link: http://lkml.kernel.org/r/152129038381.31874.9201387794548737554.stgit@devbox Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) --- .../test.d/kprobe/kprobe_args_string.tc | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc new file mode 100644 index 000000000000..5ba73035e1d9 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc @@ -0,0 +1,46 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event string type argument + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +echo 0 > events/enable +echo > kprobe_events + +case `uname -m` in +x86_64) + ARG2=%si + OFFS=8 +;; +i[3456]86) + ARG2=%cx + OFFS=4 +;; +aarch64) + ARG2=%x1 + OFFS=8 +;; +arm*) + ARG2=%r1 + OFFS=4 +;; +*) + echo "Please implement other architecture here" + exit_untested +esac + +: "Test get argument (1)" +echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string" > kprobe_events +echo 1 > events/kprobes/testprobe/enable +! echo test >> kprobe_events +tail -n 1 trace | grep -qe "testprobe.* arg1=\"test\"" + +echo 0 > events/kprobes/testprobe/enable +: "Test get argument (2)" +echo "p:testprobe create_trace_kprobe arg1=+0(+0(${ARG2})):string arg2=+0(+${OFFS}(${ARG2})):string" > kprobe_events +echo 1 > events/kprobes/testprobe/enable +! echo test1 test2 >> kprobe_events +tail -n 1 trace | grep -qe "testprobe.* arg1=\"test1\" arg2=\"test2\"" + +echo 0 > events/enable +echo > kprobe_events From dfa453bc90eca0febff33c8d292a656e53702158 Mon Sep 17 00:00:00 2001 From: Masami Hiramatsu Date: Sat, 17 Mar 2018 21:40:31 +0900 Subject: [PATCH 931/942] selftests: ftrace: Add a testcase for probepoint Add a testcase for probe point definition. This tests symbol, address and symbol+offset syntax. The offset must be positive and smaller than UINT_MAX. Link: http://lkml.kernel.org/r/152129043097.31874.14273580606301767394.stgit@devbox Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) --- .../ftrace/test.d/kprobe/probepoint.tc | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc new file mode 100644 index 000000000000..4fda01a08da4 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/probepoint.tc @@ -0,0 +1,43 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe events - probe points + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +TARGET_FUNC=create_trace_kprobe + +dec_addr() { # hexaddr + printf "%d" "0x"`echo $1 | tail -c 8` +} + +set_offs() { # prev target next + A1=`dec_addr $1` + A2=`dec_addr $2` + A3=`dec_addr $3` + TARGET="0x$2" # an address + PREV=`expr $A1 - $A2` # offset to previous symbol + NEXT=+`expr $A3 - $A2` # offset to next symbol + OVERFLOW=+`printf "0x%x" ${PREV}` # overflow offset to previous symbol +} + +# We have to decode symbol addresses to get correct offsets. +# If the offset is not an instruction boundary, it cause -EILSEQ. +set_offs `grep -A1 -B1 ${TARGET_FUNC} /proc/kallsyms | cut -f 1 -d " " | xargs` + +UINT_TEST=no +# printf "%x" -1 returns (unsigned long)-1. +if [ `printf "%x" -1 | wc -c` != 9 ]; then + UINT_TEST=yes +fi + +echo 0 > events/enable +echo > kprobe_events +echo "p:testprobe ${TARGET_FUNC}" > kprobe_events +echo "p:testprobe ${TARGET}" > kprobe_events +echo "p:testprobe ${TARGET_FUNC}${NEXT}" > kprobe_events +! echo "p:testprobe ${TARGET_FUNC}${PREV}" > kprobe_events +if [ "${UINT_TEST}" = yes ]; then +! echo "p:testprobe ${TARGET_FUNC}${OVERFLOW}" > kprobe_events +fi +echo > kprobe_events +clear_trace From 06ace26f4e6fcf747e890a39193be811777a048a Mon Sep 17 00:00:00 2001 From: Waiman Long Date: Thu, 22 Mar 2018 15:18:53 -0400 Subject: [PATCH 932/942] x86/efi: Free efi_pgd with free_pages() The efi_pgd is allocated as PGD_ALLOCATION_ORDER pages and therefore must also be freed as PGD_ALLOCATION_ORDER pages with free_pages(). Fixes: d9e9a6418065 ("x86/mm/pti: Allocate a separate user PGD") Signed-off-by: Waiman Long Signed-off-by: Thomas Gleixner Cc: linux-efi@vger.kernel.org Cc: Dave Hansen Cc: Ard Biesheuvel Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/1521746333-19593-1-git-send-email-longman@redhat.com --- arch/x86/platform/efi/efi_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c index c310a8284358..f9cfbc0d1f33 100644 --- a/arch/x86/platform/efi/efi_64.c +++ b/arch/x86/platform/efi/efi_64.c @@ -227,7 +227,7 @@ int __init efi_alloc_page_tables(void) if (!pud) { if (CONFIG_PGTABLE_LEVELS > 4) free_page((unsigned long) pgd_page_vaddr(*pgd)); - free_page((unsigned long)efi_pgd); + free_pages((unsigned long)efi_pgd, PGD_ALLOCATION_ORDER); return -ENOMEM; } From d8ba61ba58c88d5207c1ba2f7d9a2280e7d03be9 Mon Sep 17 00:00:00 2001 From: Andy Lutomirski Date: Thu, 23 Jul 2015 15:37:48 -0700 Subject: [PATCH 933/942] x86/entry/64: Don't use IST entry for #BP stack There's nothing IST-worthy about #BP/int3. We don't allow kprobes in the small handful of places in the kernel that run at CPL0 with an invalid stack, and 32-bit kernels have used normal interrupt gates for #BP forever. Furthermore, we don't allow kprobes in places that have usergs while in kernel mode, so "paranoid" is also unnecessary. Signed-off-by: Andy Lutomirski Signed-off-by: Linus Torvalds Signed-off-by: Thomas Gleixner Cc: stable@vger.kernel.org --- arch/x86/entry/entry_64.S | 2 +- arch/x86/kernel/idt.c | 2 -- arch/x86/kernel/traps.c | 15 ++++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S index d5c7f18f79ac..9b114675fbc0 100644 --- a/arch/x86/entry/entry_64.S +++ b/arch/x86/entry/entry_64.S @@ -1138,7 +1138,7 @@ apicinterrupt3 HYPERV_REENLIGHTENMENT_VECTOR \ #endif /* CONFIG_HYPERV */ idtentry debug do_debug has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK -idtentry int3 do_int3 has_error_code=0 paranoid=1 shift_ist=DEBUG_STACK +idtentry int3 do_int3 has_error_code=0 idtentry stack_segment do_stack_segment has_error_code=1 #ifdef CONFIG_XEN diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index 56d99be3706a..50bee5fe1140 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -160,7 +160,6 @@ static const __initconst struct idt_data early_pf_idts[] = { */ static const __initconst struct idt_data dbg_idts[] = { INTG(X86_TRAP_DB, debug), - INTG(X86_TRAP_BP, int3), }; #endif @@ -183,7 +182,6 @@ gate_desc debug_idt_table[IDT_ENTRIES] __page_aligned_bss; static const __initconst struct idt_data ist_idts[] = { ISTG(X86_TRAP_DB, debug, DEBUG_STACK), ISTG(X86_TRAP_NMI, nmi, NMI_STACK), - SISTG(X86_TRAP_BP, int3, DEBUG_STACK), ISTG(X86_TRAP_DF, double_fault, DOUBLEFAULT_STACK), #ifdef CONFIG_X86_MCE ISTG(X86_TRAP_MC, &machine_check, MCE_STACK), diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c index 3d9b2308e7fa..03f3d7695dac 100644 --- a/arch/x86/kernel/traps.c +++ b/arch/x86/kernel/traps.c @@ -577,7 +577,6 @@ do_general_protection(struct pt_regs *regs, long error_code) } NOKPROBE_SYMBOL(do_general_protection); -/* May run on IST stack. */ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code) { #ifdef CONFIG_DYNAMIC_FTRACE @@ -592,6 +591,13 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code) if (poke_int3_handler(regs)) return; + /* + * Use ist_enter despite the fact that we don't use an IST stack. + * We can be called from a kprobe in non-CONTEXT_KERNEL kernel + * mode or even during context tracking state changes. + * + * This means that we can't schedule. That's okay. + */ ist_enter(regs); RCU_LOCKDEP_WARN(!rcu_is_watching(), "entry code didn't wake RCU"); #ifdef CONFIG_KGDB_LOW_LEVEL_TRAP @@ -609,15 +615,10 @@ dotraplinkage void notrace do_int3(struct pt_regs *regs, long error_code) SIGTRAP) == NOTIFY_STOP) goto exit; - /* - * Let others (NMI) know that the debug stack is in use - * as we may switch to the interrupt stack. - */ - debug_stack_usage_inc(); cond_local_irq_enable(regs); do_trap(X86_TRAP_BP, SIGTRAP, "int3", regs, error_code, NULL); cond_local_irq_disable(regs); - debug_stack_usage_dec(); + exit: ist_exit(regs); } From cfb2f6f6e0ba11ea7b263d6b69c170c4b32ac0ea Mon Sep 17 00:00:00 2001 From: "Eric W. Biederman" Date: Sat, 24 Mar 2018 11:28:14 -0500 Subject: [PATCH 934/942] Revert "mqueue: switch to on-demand creation of internal mount" This reverts commit 36735a6a2b5e042db1af956ce4bcc13f3ff99e21. Aleksa Sarai writes: > [REGRESSION v4.16-rc6] [PATCH] mqueue: forbid unprivileged user access to internal mount > > Felix reported weird behaviour on 4.16.0-rc6 with regards to mqueue[1], > which was introduced by 36735a6a2b5e ("mqueue: switch to on-demand > creation of internal mount"). > > Basically, the reproducer boils down to being able to mount mqueue if > you create a new user namespace, even if you don't unshare the IPC > namespace. > > Previously this was not possible, and you would get an -EPERM. The mount > is the *host* mqueue mount, which is being cached and just returned from > mqueue_mount(). To be honest, I'm not sure if this is safe or not (or if > it was intentional -- since I'm not familiar with mqueue). > > To me it looks like there is a missing permission check. I've included a > patch below that I've compile-tested, and should block the above case. > Can someone please tell me if I'm missing something? Is this actually > safe? > > [1]: https://github.com/docker/docker/issues/36674 The issue is a lot deeper than a missing permission check. sb->s_user_ns was is improperly set as well. So in addition to the filesystem being mounted when it should not be mounted, so things are not allow that should be. We are practically to the release of 4.16 and there is no agreement between Al Viro and myself on what the code should looks like to fix things properly. So revert the code to what it was before so that we can take our time and discuss this properly. Fixes: 36735a6a2b5e ("mqueue: switch to on-demand creation of internal mount") Reported-by: Felix Abecassis Reported-by: Aleksa Sarai Signed-off-by: "Eric W. Biederman" --- ipc/mqueue.c | 74 ++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 55 deletions(-) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index d7f309f74dec..a808f29d4c5a 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -325,9 +325,8 @@ err: static int mqueue_fill_super(struct super_block *sb, void *data, int silent) { struct inode *inode; - struct ipc_namespace *ns = data; + struct ipc_namespace *ns = sb->s_fs_info; - sb->s_fs_info = ns; sb->s_iflags |= SB_I_NOEXEC | SB_I_NODEV; sb->s_blocksize = PAGE_SIZE; sb->s_blocksize_bits = PAGE_SHIFT; @@ -344,44 +343,18 @@ static int mqueue_fill_super(struct super_block *sb, void *data, int silent) return 0; } -static struct file_system_type mqueue_fs_type; -/* - * Return value is pinned only by reference in ->mq_mnt; it will - * live until ipcns dies. Caller does not need to drop it. - */ -static struct vfsmount *mq_internal_mount(void) -{ - struct ipc_namespace *ns = current->nsproxy->ipc_ns; - struct vfsmount *m = ns->mq_mnt; - if (m) - return m; - m = kern_mount_data(&mqueue_fs_type, ns); - spin_lock(&mq_lock); - if (unlikely(ns->mq_mnt)) { - spin_unlock(&mq_lock); - if (!IS_ERR(m)) - kern_unmount(m); - return ns->mq_mnt; - } - if (!IS_ERR(m)) - ns->mq_mnt = m; - spin_unlock(&mq_lock); - return m; -} - static struct dentry *mqueue_mount(struct file_system_type *fs_type, int flags, const char *dev_name, void *data) { - struct vfsmount *m; - if (flags & SB_KERNMOUNT) - return mount_nodev(fs_type, flags, data, mqueue_fill_super); - m = mq_internal_mount(); - if (IS_ERR(m)) - return ERR_CAST(m); - atomic_inc(&m->mnt_sb->s_active); - down_write(&m->mnt_sb->s_umount); - return dget(m->mnt_root); + struct ipc_namespace *ns; + if (flags & SB_KERNMOUNT) { + ns = data; + data = NULL; + } else { + ns = current->nsproxy->ipc_ns; + } + return mount_ns(fs_type, flags, data, ns, ns->user_ns, mqueue_fill_super); } static void init_once(void *foo) @@ -771,16 +744,13 @@ static int prepare_open(struct dentry *dentry, int oflag, int ro, static int do_mq_open(const char __user *u_name, int oflag, umode_t mode, struct mq_attr *attr) { - struct vfsmount *mnt = mq_internal_mount(); - struct dentry *root; + struct vfsmount *mnt = current->nsproxy->ipc_ns->mq_mnt; + struct dentry *root = mnt->mnt_root; struct filename *name; struct path path; int fd, error; int ro; - if (IS_ERR(mnt)) - return PTR_ERR(mnt); - audit_mq_open(oflag, mode, attr); if (IS_ERR(name = getname(u_name))) @@ -791,7 +761,6 @@ static int do_mq_open(const char __user *u_name, int oflag, umode_t mode, goto out_putname; ro = mnt_want_write(mnt); /* we'll drop it in any case */ - root = mnt->mnt_root; inode_lock(d_inode(root)); path.dentry = lookup_one_len(name->name, root, strlen(name->name)); if (IS_ERR(path.dentry)) { @@ -840,9 +809,6 @@ SYSCALL_DEFINE1(mq_unlink, const char __user *, u_name) struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns; struct vfsmount *mnt = ipc_ns->mq_mnt; - if (!mnt) - return -ENOENT; - name = getname(u_name); if (IS_ERR(name)) return PTR_ERR(name); @@ -1569,26 +1535,28 @@ int mq_init_ns(struct ipc_namespace *ns) ns->mq_msgsize_max = DFLT_MSGSIZEMAX; ns->mq_msg_default = DFLT_MSG; ns->mq_msgsize_default = DFLT_MSGSIZE; - ns->mq_mnt = NULL; + ns->mq_mnt = kern_mount_data(&mqueue_fs_type, ns); + if (IS_ERR(ns->mq_mnt)) { + int err = PTR_ERR(ns->mq_mnt); + ns->mq_mnt = NULL; + return err; + } return 0; } void mq_clear_sbinfo(struct ipc_namespace *ns) { - if (ns->mq_mnt) - ns->mq_mnt->mnt_sb->s_fs_info = NULL; + ns->mq_mnt->mnt_sb->s_fs_info = NULL; } void mq_put_mnt(struct ipc_namespace *ns) { - if (ns->mq_mnt) - kern_unmount(ns->mq_mnt); + kern_unmount(ns->mq_mnt); } static int __init init_mqueue_fs(void) { - struct vfsmount *m; int error; mqueue_inode_cachep = kmem_cache_create("mqueue_inode_cache", @@ -1610,10 +1578,6 @@ static int __init init_mqueue_fs(void) if (error) goto out_filesystem; - m = kern_mount_data(&mqueue_fs_type, &init_ipc_ns); - if (IS_ERR(m)) - goto out_filesystem; - init_ipc_ns.mq_mnt = m; return 0; out_filesystem: From f1869a890cdedb92a3fab969db5d0fd982850273 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sat, 24 Mar 2018 10:43:26 +0100 Subject: [PATCH 935/942] tty: vt: fix up tabstops properly Tabs on a console with long lines do not wrap properly, so correctly account for the line length when computing the tab placement location. Reported-by: James Holderness Signed-off-by: Greg Kroah-Hartman Cc: stable Signed-off-by: Linus Torvalds --- drivers/tty/vt/vt.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 88b902c525d7..b4e57c5a8bba 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1727,7 +1727,7 @@ static void reset_terminal(struct vc_data *vc, int do_clear) default_attr(vc); update_attr(vc); - vc->vc_tab_stop[0] = 0x01010100; + vc->vc_tab_stop[0] = vc->vc_tab_stop[1] = vc->vc_tab_stop[2] = vc->vc_tab_stop[3] = @@ -1771,7 +1771,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) vc->vc_pos -= (vc->vc_x << 1); while (vc->vc_x < vc->vc_cols - 1) { vc->vc_x++; - if (vc->vc_tab_stop[vc->vc_x >> 5] & (1 << (vc->vc_x & 31))) + if (vc->vc_tab_stop[7 & (vc->vc_x >> 5)] & (1 << (vc->vc_x & 31))) break; } vc->vc_pos += (vc->vc_x << 1); @@ -1831,7 +1831,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) lf(vc); return; case 'H': - vc->vc_tab_stop[vc->vc_x >> 5] |= (1 << (vc->vc_x & 31)); + vc->vc_tab_stop[7 & (vc->vc_x >> 5)] |= (1 << (vc->vc_x & 31)); return; case 'Z': respond_ID(tty); @@ -2024,7 +2024,7 @@ static void do_con_trol(struct tty_struct *tty, struct vc_data *vc, int c) return; case 'g': if (!vc->vc_par[0]) - vc->vc_tab_stop[vc->vc_x >> 5] &= ~(1 << (vc->vc_x & 31)); + vc->vc_tab_stop[7 & (vc->vc_x >> 5)] &= ~(1 << (vc->vc_x & 31)); else if (vc->vc_par[0] == 3) { vc->vc_tab_stop[0] = vc->vc_tab_stop[1] = From 3eb2ce825ea1ad89d20f7a3b5780df850e4be274 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Sun, 25 Mar 2018 12:44:30 -1000 Subject: [PATCH 936/942] Linux 4.16-rc7 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 486db374d1c1..7ba478ab8c82 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ VERSION = 4 PATCHLEVEL = 16 SUBLEVEL = 0 -EXTRAVERSION = -rc6 +EXTRAVERSION = -rc7 NAME = Fearless Coyote # *DOCUMENTATION* From 267e2c6fd7ca3d4076d20f9d52d49dc91addfe9d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 27 Mar 2018 12:04:04 +0100 Subject: [PATCH 937/942] ASoC: topology: Fix kcontrol name string handling Fix the topology kcontrol string handling so that string pointer references are strdup()ed instead of being copied. This fixes issues with kcontrol templates on the stack or ones that are freed. Remember and free the strings too when topology is unloaded. Signed-off-by: Liam Girdwood Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- sound/soc/soc-topology.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 01a50413c66f..782c580b7aa3 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -523,6 +523,7 @@ static void remove_widget(struct snd_soc_component *comp, kfree(se->dobj.control.dtexts[j]); kfree(se); + kfree(w->kcontrol_news[i].name); } kfree(w->kcontrol_news); } else { @@ -540,6 +541,7 @@ static void remove_widget(struct snd_soc_component *comp, */ kfree((void *)kcontrol->private_value); snd_ctl_remove(card, kcontrol); + kfree(w->kcontrol_news[i].name); } kfree(w->kcontrol_news); } @@ -1233,7 +1235,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( dev_dbg(tplg->dev, " adding DAPM widget mixer control %s at %d\n", mc->hdr.name, i); - kc[i].name = mc->hdr.name; + kc[i].name = kstrdup(mc->hdr.name, GFP_KERNEL); + if (kc[i].name == NULL) + goto err_str; kc[i].private_value = (long)sm; kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc[i].access = mc->hdr.access; @@ -1278,8 +1282,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dmixer_create( err_str: kfree(sm); err: - for (--i; i >= 0; i--) + for (--i; i >= 0; i--) { kfree((void *)kc[i].private_value); + kfree(kc[i].name); + } kfree(kc); return NULL; } @@ -1310,7 +1316,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_denum_create( dev_dbg(tplg->dev, " adding DAPM widget enum control %s\n", ec->hdr.name); - kc[i].name = ec->hdr.name; + kc[i].name = kstrdup(ec->hdr.name, GFP_KERNEL); + if (kc[i].name == NULL) + goto err_se; kc[i].private_value = (long)se; kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc[i].access = ec->hdr.access; @@ -1386,6 +1394,7 @@ err_se: kfree(se->dobj.control.dtexts[j]); kfree(se); + kfree(kc[i].name); } err: kfree(kc); @@ -1424,7 +1433,9 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create( "ASoC: adding bytes kcontrol %s with access 0x%x\n", be->hdr.name, be->hdr.access); - kc[i].name = be->hdr.name; + kc[i].name = kstrdup(be->hdr.name, GFP_KERNEL); + if (kc[i].name == NULL) + goto err; kc[i].private_value = (long)sbe; kc[i].iface = SNDRV_CTL_ELEM_IFACE_MIXER; kc[i].access = be->hdr.access; @@ -1454,8 +1465,10 @@ static struct snd_kcontrol_new *soc_tplg_dapm_widget_dbytes_create( return kc; err: - for (--i; i >= 0; i--) + for (--i; i >= 0; i--) { kfree((void *)kc[i].private_value); + kfree(kc[i].name); + } kfree(kc); return NULL; From 4c50e1e3e2c29899c0226f7ad56d7266e814f2b3 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 28 Mar 2018 01:48:07 +0000 Subject: [PATCH 938/942] ASoC: amd: don't use codec anymore commit c88d31153356 ("ASoC: amd: Enable da7219 master clock using common clock framework") is using rtd->codec, but codec is replaced to component. Let's use component Fixes: c88d31153356 ("ASoC: amd: Enable da7219 master clock using common clock framework") Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/amd/acp-da7219-max98357a.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/soc/amd/acp-da7219-max98357a.c b/sound/soc/amd/acp-da7219-max98357a.c index 99c6b5ce5c6c..b205c782e494 100644 --- a/sound/soc/amd/acp-da7219-max98357a.c +++ b/sound/soc/amd/acp-da7219-max98357a.c @@ -49,7 +49,6 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) { int ret; struct snd_soc_card *card = rtd->card; - struct snd_soc_codec *codec = rtd->codec; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_component *component = codec_dai->component; @@ -69,7 +68,7 @@ static int cz_da7219_init(struct snd_soc_pcm_runtime *rtd) return ret; } - da7219_dai_clk = clk_get(codec->dev, "da7219-dai-clks"); + da7219_dai_clk = clk_get(component->dev, "da7219-dai-clks"); ret = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | From 2759ba9bf811f81c31d14e32f8cff022d54dce1f Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 28 Mar 2018 01:49:36 +0000 Subject: [PATCH 939/942] ASoC: Intel: bytcr_rt5651: don't use codec anymore commit aeec6cc08215 ("ASoC: Intel: bytcr_rt5651: Configure PLL1 before using it") is using codec->dev, but codec is replaced to component. Let's use component Fixes: aeec6cc08215 ("ASoC: Intel: bytcr_rt5651: Configure PLL1 before using it") Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/intel/boards/bytcr_rt5651.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c index 53ce313024f1..1b1997f1d60c 100644 --- a/sound/soc/intel/boards/bytcr_rt5651.c +++ b/sound/soc/intel/boards/bytcr_rt5651.c @@ -147,14 +147,14 @@ static int byt_rt5651_prepare_and_enable_pll1(struct snd_soc_dai *codec_dai, } ret = snd_soc_dai_set_pll(codec_dai, 0, clk_id, clk_freq, rate * 512); if (ret < 0) { - dev_err(codec_dai->codec->dev, "can't set pll: %d\n", ret); + dev_err(codec_dai->component->dev, "can't set pll: %d\n", ret); return ret; } ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1, rate * 512, SND_SOC_CLOCK_IN); if (ret < 0) { - dev_err(codec_dai->codec->dev, "can't set clock %d\n", ret); + dev_err(codec_dai->component->dev, "can't set clock %d\n", ret); return ret; } From b305d8c21cf9c009ce4995084cb44151c7306fc9 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Wed, 28 Mar 2018 01:51:02 +0000 Subject: [PATCH 940/942] ASoC: cpcap: replace codec to component Now we can replace Codec to Component. Let's do it. Note: xxx_codec_xxx() -> xxx_component_xxx() .idle_bias_off = 0 -> .idle_bias_on = 1 .ignore_pmdown_time = 0 -> .use_pmdown_time = 1 - -> .endianness = 1 - -> .non_legacy_dai_naming = 1 Signed-off-by: Kuninori Morimoto Signed-off-by: Mark Brown --- sound/soc/codecs/cpcap.c | 152 +++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 79 deletions(-) diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index aedb267d4581..d7f05b384f1f 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -243,7 +243,7 @@ enum cpcap_dai { }; struct cpcap_audio { - struct snd_soc_codec *codec; + struct snd_soc_component *component; struct regmap *regmap; u16 vendor; @@ -256,8 +256,8 @@ struct cpcap_audio { static int cpcap_st_workaround(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { - struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int err = 0; /* Only CPCAP from ST requires workaround */ @@ -357,8 +357,8 @@ static SOC_ENUM_SINGLE_DECL(cpcap_emu_r_mux_enum, 0, 8, cpcap_out_mux_texts); static int cpcap_output_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; unsigned int shift = e->shift_l; int reg_voice, reg_hifi, reg_ext, status; @@ -400,8 +400,8 @@ static int cpcap_output_mux_get_enum(struct snd_kcontrol *kcontrol, static int cpcap_output_mux_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -445,8 +445,8 @@ static int cpcap_output_mux_put_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_right_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int regval, mask; int err; @@ -484,8 +484,8 @@ static int cpcap_input_right_mux_get_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_right_mux_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -529,8 +529,8 @@ static int cpcap_input_right_mux_put_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_left_mux_get_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int regval, mask; int err; @@ -560,8 +560,8 @@ static int cpcap_input_left_mux_get_enum(struct snd_kcontrol *kcontrol, static int cpcap_input_left_mux_put_enum(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; @@ -969,13 +969,13 @@ static int cpcap_set_sysclk(struct cpcap_audio *cpcap, enum cpcap_dai dai, clkidshift = CPCAP_BIT_CLK_IN_SEL; break; default: - dev_err(cpcap->codec->dev, "invalid DAI: %d", dai); + dev_err(cpcap->component->dev, "invalid DAI: %d", dai); return -EINVAL; } /* setup clk id */ if (clk_id < 0 || clk_id > 1) { - dev_err(cpcap->codec->dev, "invalid clk id %d", clk_id); + dev_err(cpcap->component->dev, "invalid clk id %d", clk_id); return -EINVAL; } err = regmap_update_bits(cpcap->regmap, clkidreg, BIT(clkidshift), @@ -1015,7 +1015,7 @@ static int cpcap_set_sysclk(struct cpcap_audio *cpcap, enum cpcap_dai dai, clkfreqval = 0x06 << clkfreqshift; break; default: - dev_err(cpcap->codec->dev, "unsupported freq %u", freq); + dev_err(cpcap->component->dev, "unsupported freq %u", freq); return -EINVAL; } @@ -1035,7 +1035,7 @@ static int cpcap_set_sysclk(struct cpcap_audio *cpcap, enum cpcap_dai dai, static int cpcap_set_samprate(struct cpcap_audio *cpcap, enum cpcap_dai dai, int samplerate) { - struct snd_soc_codec *codec = cpcap->codec; + struct snd_soc_component *component = cpcap->component; u16 sampreg, sampmask, sampshift, sampval, sampreset; int err, sampreadval; @@ -1053,7 +1053,7 @@ static int cpcap_set_samprate(struct cpcap_audio *cpcap, enum cpcap_dai dai, BIT(CPCAP_BIT_CDC_CLOCK_TREE_RESET); break; default: - dev_err(codec->dev, "invalid DAI: %d", dai); + dev_err(component->dev, "invalid DAI: %d", dai); return -EINVAL; } @@ -1087,7 +1087,7 @@ static int cpcap_set_samprate(struct cpcap_audio *cpcap, enum cpcap_dai dai, sampval = 0x0 << sampshift; break; default: - dev_err(codec->dev, "unsupported samplerate %d", samplerate); + dev_err(component->dev, "unsupported samplerate %d", samplerate); return -EINVAL; } err = regmap_update_bits(cpcap->regmap, sampreg, @@ -1103,7 +1103,7 @@ static int cpcap_set_samprate(struct cpcap_audio *cpcap, enum cpcap_dai dai, return err; if (sampreadval & sampreset) { - dev_err(codec->dev, "reset self-clear failed: %04x", + dev_err(component->dev, "reset self-clear failed: %04x", sampreadval); return -EIO; } @@ -1115,20 +1115,20 @@ static int cpcap_hifi_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int rate = params_rate(params); - dev_dbg(codec->dev, "HiFi setup HW params: rate=%d", rate); + dev_dbg(component->dev, "HiFi setup HW params: rate=%d", rate); return cpcap_set_samprate(cpcap, CPCAP_DAI_HIFI, rate); } static int cpcap_hifi_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); - struct device *dev = codec->dev; + struct snd_soc_component *component = codec_dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); + struct device *dev = component->dev; dev_dbg(dev, "HiFi setup sysclk: clk_id=%u, freq=%u", clk_id, freq); return cpcap_set_sysclk(cpcap, CPCAP_DAI_HIFI, clk_id, freq); @@ -1137,9 +1137,9 @@ static int cpcap_hifi_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, static int cpcap_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); - struct device *dev = codec->dev; + struct snd_soc_component *component = codec_dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); + struct device *dev = component->dev; static const u16 reg = CPCAP_REG_SDACDI; static const u16 mask = BIT(CPCAP_BIT_SMB_ST_DAC) | @@ -1218,8 +1218,8 @@ static int cpcap_hifi_set_dai_fmt(struct snd_soc_dai *codec_dai, static int cpcap_hifi_set_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); static const u16 reg = CPCAP_REG_RXSDOA; static const u16 mask = BIT(CPCAP_BIT_ST_DAC_SW); u16 val; @@ -1229,7 +1229,7 @@ static int cpcap_hifi_set_mute(struct snd_soc_dai *dai, int mute) else val = BIT(CPCAP_BIT_ST_DAC_SW); - dev_dbg(codec->dev, "HiFi mute: %d", mute); + dev_dbg(component->dev, "HiFi mute: %d", mute); return regmap_update_bits(cpcap->regmap, reg, mask, val); } @@ -1244,9 +1244,9 @@ static int cpcap_voice_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_codec *codec = dai->codec; - struct device *dev = codec->dev; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct device *dev = component->dev; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); static const u16 reg_cdi = CPCAP_REG_CDI; int rate = params_rate(params); int channels = params_channels(params); @@ -1283,10 +1283,10 @@ static int cpcap_voice_hw_params(struct snd_pcm_substream *substream, static int cpcap_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, unsigned int freq, int dir) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); - dev_dbg(codec->dev, "Voice setup sysclk: clk_id=%u, freq=%u", + dev_dbg(component->dev, "Voice setup sysclk: clk_id=%u, freq=%u", clk_id, freq); return cpcap_set_sysclk(cpcap, CPCAP_DAI_VOICE, clk_id, freq); } @@ -1294,8 +1294,8 @@ static int cpcap_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id, static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) { - struct snd_soc_codec *codec = codec_dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = codec_dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); static const u16 mask = BIT(CPCAP_BIT_SMB_CDC) | BIT(CPCAP_BIT_CLK_INV) | BIT(CPCAP_BIT_FS_INV) | @@ -1304,7 +1304,7 @@ static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, u16 val = 0x0000; int err; - dev_dbg(codec->dev, "Voice setup dai format (%08x)", fmt); + dev_dbg(component->dev, "Voice setup dai format (%08x)", fmt); /* * "Voice Playback" and "Voice Capture" should always be @@ -1316,7 +1316,7 @@ static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, val &= ~BIT(CPCAP_BIT_SMB_CDC); break; default: - dev_err(codec->dev, "Voice dai fmt failed: CPCAP should be the master"); + dev_err(component->dev, "Voice dai fmt failed: CPCAP should be the master"); val &= ~BIT(CPCAP_BIT_SMB_CDC); break; } @@ -1339,7 +1339,7 @@ static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, val &= ~BIT(CPCAP_BIT_FS_INV); break; default: - dev_err(codec->dev, "Voice dai fmt failed: unsupported clock invert mode"); + dev_err(component->dev, "Voice dai fmt failed: unsupported clock invert mode"); break; } @@ -1361,7 +1361,7 @@ static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, break; } - dev_dbg(codec->dev, "Voice dai format: val=%04x", val); + dev_dbg(component->dev, "Voice dai format: val=%04x", val); err = regmap_update_bits(cpcap->regmap, CPCAP_REG_CDI, mask, val); if (err) return err; @@ -1372,8 +1372,8 @@ static int cpcap_voice_set_dai_fmt(struct snd_soc_dai *codec_dai, static int cpcap_voice_set_mute(struct snd_soc_dai *dai, int mute) { - struct snd_soc_codec *codec = dai->codec; - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct snd_soc_component *component = dai->component; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); static const u16 reg = CPCAP_REG_RXCOA; static const u16 mask = BIT(CPCAP_BIT_CDC_SW); u16 val; @@ -1383,7 +1383,7 @@ static int cpcap_voice_set_mute(struct snd_soc_dai *dai, int mute) else val = BIT(CPCAP_BIT_CDC_SW); - dev_dbg(codec->dev, "Voice mute: %d", mute); + dev_dbg(component->dev, "Voice mute: %d", mute); return regmap_update_bits(cpcap->regmap, reg, mask, val); }; @@ -1460,13 +1460,13 @@ static int cpcap_dai_mux(struct cpcap_audio *cpcap, bool swap_dai_configuration) return 0; } -static int cpcap_audio_reset(struct snd_soc_codec *codec, +static int cpcap_audio_reset(struct snd_soc_component *component, bool swap_dai_configuration) { - struct cpcap_audio *cpcap = snd_soc_codec_get_drvdata(codec); + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int i, err = 0; - dev_dbg(codec->dev, "init audio codec"); + dev_dbg(component->dev, "init audio codec"); for (i = 0; i < ARRAY_SIZE(cpcap_default_regs); i++) { err = regmap_update_bits(cpcap->regmap, @@ -1500,40 +1500,41 @@ static int cpcap_audio_reset(struct snd_soc_codec *codec, return 0; } -static int cpcap_soc_probe(struct snd_soc_codec *codec) +static int cpcap_soc_probe(struct snd_soc_component *component) { struct cpcap_audio *cpcap; int err; - cpcap = devm_kzalloc(codec->dev, sizeof(*cpcap), GFP_KERNEL); + cpcap = devm_kzalloc(component->dev, sizeof(*cpcap), GFP_KERNEL); if (!cpcap) return -ENOMEM; - snd_soc_codec_set_drvdata(codec, cpcap); - cpcap->codec = codec; + snd_soc_component_set_drvdata(component, cpcap); + cpcap->component = component; - cpcap->regmap = dev_get_regmap(codec->dev->parent, NULL); + cpcap->regmap = dev_get_regmap(component->dev->parent, NULL); if (!cpcap->regmap) return -ENODEV; - snd_soc_codec_init_regmap(codec, cpcap->regmap); + snd_soc_component_init_regmap(component, cpcap->regmap); - err = cpcap_get_vendor(codec->dev, cpcap->regmap, &cpcap->vendor); + err = cpcap_get_vendor(component->dev, cpcap->regmap, &cpcap->vendor); if (err) return err; - return cpcap_audio_reset(codec, false); + return cpcap_audio_reset(component, false); } -static struct snd_soc_codec_driver soc_codec_dev_cpcap = { - .probe = cpcap_soc_probe, - - .component_driver = { - .controls = cpcap_snd_controls, - .num_controls = ARRAY_SIZE(cpcap_snd_controls), - .dapm_widgets = cpcap_dapm_widgets, - .num_dapm_widgets = ARRAY_SIZE(cpcap_dapm_widgets), - .dapm_routes = intercon, - .num_dapm_routes = ARRAY_SIZE(intercon), - }, +static struct snd_soc_component_driver soc_codec_dev_cpcap = { + .probe = cpcap_soc_probe, + .controls = cpcap_snd_controls, + .num_controls = ARRAY_SIZE(cpcap_snd_controls), + .dapm_widgets = cpcap_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(cpcap_dapm_widgets), + .dapm_routes = intercon, + .num_dapm_routes = ARRAY_SIZE(intercon), + .idle_bias_on = 1, + .use_pmdown_time = 1, + .endianness = 1, + .non_legacy_dai_naming = 1, }; static int cpcap_codec_probe(struct platform_device *pdev) @@ -1543,19 +1544,12 @@ static int cpcap_codec_probe(struct platform_device *pdev) pdev->dev.of_node = codec_node; - return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_cpcap, + return devm_snd_soc_register_component(&pdev->dev, &soc_codec_dev_cpcap, cpcap_dai, ARRAY_SIZE(cpcap_dai)); } -static int cpcap_codec_remove(struct platform_device *pdev) -{ - snd_soc_unregister_codec(&pdev->dev); - return 0; -} - static struct platform_driver cpcap_codec_driver = { .probe = cpcap_codec_probe, - .remove = cpcap_codec_remove, .driver = { .name = "cpcap-codec", }, From de2404701469a7e8d557b8d7b4d35bda5b262cac Mon Sep 17 00:00:00 2001 From: Ryder Lee Date: Tue, 27 Mar 2018 09:32:25 +0800 Subject: [PATCH 941/942] ASoC: mediatek: remove "simple-mfd" in the example Remove compatible string "simple-mfd" in the example as we have already added devm_of_platform_populate() in the parent driver. Signed-off-by: Ryder Lee Signed-off-by: Mark Brown --- Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt index 6df87b97f7cb..e2f7f4951215 100644 --- a/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt +++ b/Documentation/devicetree/bindings/sound/mt2701-afe-pcm.txt @@ -53,7 +53,7 @@ See ../arm/mediatek/mediatek,audsys.txt for details about the parent node. Example: audsys: audio-subsystem@11220000 { - compatible = "mediatek,mt2701-audsys", "syscon", "simple-mfd"; + compatible = "mediatek,mt2701-audsys", "syscon"; ... afe: audio-controller { From c3fd6a1d1a133d191e6fb09d0fe277330f35c525 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Sat, 24 Mar 2018 12:17:17 -0300 Subject: [PATCH 942/942] ASoC: tscs42xx: Remove owner assignment from i2c_driver Structure i2c_driver does not need to set the owner field, as this will be populated by the driver core. Generated by scripts/coccinelle/api/platform_no_drv_owner.cocci. Signed-off-by: Fabio Estevam Signed-off-by: Mark Brown --- sound/soc/codecs/tscs42xx.c | 1 - 1 file changed, 1 deletion(-) diff --git a/sound/soc/codecs/tscs42xx.c b/sound/soc/codecs/tscs42xx.c index cfc71b5411ee..bbfc73a79b18 100644 --- a/sound/soc/codecs/tscs42xx.c +++ b/sound/soc/codecs/tscs42xx.c @@ -1443,7 +1443,6 @@ MODULE_DEVICE_TABLE(of, tscs42xx_of_match); static struct i2c_driver tscs42xx_i2c_driver = { .driver = { .name = "tscs42xx", - .owner = THIS_MODULE, .of_match_table = tscs42xx_of_match, }, .probe = tscs42xx_i2c_probe,