hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/sound/soc/codecs/wm8996.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * wm8996.c - WM8996 audio codec interface
34 *
45 * Copyright 2011-2 Wolfson Microelectronics PLC.
56 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify it
8
- * under the terms of the GNU General Public License as published by the
9
- * Free Software Foundation; either version 2 of the License, or (at your
10
- * option) any later version.
117 */
128
139 #include <linux/module.h>
....@@ -347,7 +343,7 @@
347343 switch (block) {
348344 case 0:
349345 base = WM8996_DSP1_RX_EQ_GAINS_1;
350
- if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) &
346
+ if (snd_soc_component_read(component, WM8996_POWER_MANAGEMENT_8) &
351347 WM8996_DSP1RX_SRC)
352348 iface = 1;
353349 else
....@@ -355,7 +351,7 @@
355351 break;
356352 case 1:
357353 base = WM8996_DSP1_RX_EQ_GAINS_2;
358
- if (snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_8) &
354
+ if (snd_soc_component_read(component, WM8996_POWER_MANAGEMENT_8) &
359355 WM8996_DSP2RX_SRC)
360356 iface = 1;
361357 else
....@@ -390,7 +386,7 @@
390386 /* The EQ will be disabled while reconfiguring it, remember the
391387 * current configuration.
392388 */
393
- save = snd_soc_component_read32(component, base);
389
+ save = snd_soc_component_read(component, base);
394390 save &= WM8996_DSP1RX_EQ_ENA;
395391
396392 for (i = 0; i < ARRAY_SIZE(pdata->retune_mobile_cfgs[best].regs); i++)
....@@ -676,7 +672,7 @@
676672 timeout--;
677673 }
678674
679
- ret = snd_soc_component_read32(component, WM8996_DC_SERVO_2);
675
+ ret = snd_soc_component_read(component, WM8996_DC_SERVO_2);
680676 dev_dbg(component->dev, "DC servo state: %x\n", ret);
681677 } while (timeout && ret & mask);
682678
....@@ -1745,7 +1741,7 @@
17451741 switch (dai->id) {
17461742 case 0:
17471743 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
1748
- (snd_soc_component_read32(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) {
1744
+ (snd_soc_component_read(component, WM8996_GPIO_1)) & WM8996_GP1_FN_MASK) {
17491745 aifdata_reg = WM8996_AIF1RX_DATA_CONFIGURATION;
17501746 lrclk_reg = WM8996_AIF1_RX_LRCLK_1;
17511747 } else {
....@@ -1756,7 +1752,7 @@
17561752 break;
17571753 case 1:
17581754 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
1759
- (snd_soc_component_read32(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) {
1755
+ (snd_soc_component_read(component, WM8996_GPIO_2)) & WM8996_GP2_FN_MASK) {
17601756 aifdata_reg = WM8996_AIF2RX_DATA_CONFIGURATION;
17611757 lrclk_reg = WM8996_AIF2_RX_LRCLK_1;
17621758 } else {
....@@ -1826,7 +1822,7 @@
18261822 return 0;
18271823
18281824 /* Disable SYSCLK while we reconfigure */
1829
- old = snd_soc_component_read32(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA;
1825
+ old = snd_soc_component_read(component, WM8996_AIF_CLOCKING_1) & WM8996_SYSCLK_ENA;
18301826 snd_soc_component_update_bits(component, WM8996_AIF_CLOCKING_1,
18311827 WM8996_SYSCLK_ENA, 0);
18321828
....@@ -1858,7 +1854,7 @@
18581854 case 24576000:
18591855 ratediv = WM8996_SYSCLK_DIV;
18601856 wm8996->sysclk /= 2;
1861
- /* fall through */
1857
+ fallthrough;
18621858 case 11289600:
18631859 case 12288000:
18641860 snd_soc_component_update_bits(component, WM8996_AIF_RATE,
....@@ -2082,7 +2078,7 @@
20822078 snd_soc_component_write(component, WM8996_FLL_EFS_1, fll_div.lambda);
20832079
20842080 /* Enable the bandgap if it's not already enabled */
2085
- ret = snd_soc_component_read32(component, WM8996_FLL_CONTROL_1);
2081
+ ret = snd_soc_component_read(component, WM8996_FLL_CONTROL_1);
20862082 if (!(ret & WM8996_FLL_ENA))
20872083 wm8996_bg_enable(component);
20882084
....@@ -2121,7 +2117,7 @@
21212117 break;
21222118 }
21232119
2124
- ret = snd_soc_component_read32(component, WM8996_INTERRUPT_RAW_STATUS_2);
2120
+ ret = snd_soc_component_read(component, WM8996_INTERRUPT_RAW_STATUS_2);
21252121 if (ret & WM8996_FLL_LOCK_STS)
21262122 break;
21272123 }
....@@ -2228,6 +2224,9 @@
22282224
22292225 /**
22302226 * wm8996_detect - Enable default WM8996 jack detection
2227
+ * @component: ASoC component
2228
+ * @jack: jack pointer
2229
+ * @polarity_cb: polarity callback
22312230 *
22322231 * The WM8996 has advanced accessory detection support for headsets.
22332232 * This function provides a default implementation which integrates
....@@ -2295,7 +2294,7 @@
22952294 */
22962295 report = SND_JACK_HEADPHONE;
22972296
2298
- reg = snd_soc_component_read32(component, WM8996_HEADPHONE_DETECT_2);
2297
+ reg = snd_soc_component_read(component, WM8996_HEADPHONE_DETECT_2);
22992298 if (reg < 0) {
23002299 dev_err(component->dev, "Failed to read HPDET status\n");
23012300 goto out;
....@@ -2328,7 +2327,7 @@
23282327 wm8996->detecting = false;
23292328
23302329 /* If the output isn't running re-clamp it */
2331
- if (!(snd_soc_component_read32(component, WM8996_POWER_MANAGEMENT_1) &
2330
+ if (!(snd_soc_component_read(component, WM8996_POWER_MANAGEMENT_1) &
23322331 (WM8996_HPOUT1L_ENA | WM8996_HPOUT1R_RMV_SHORT)))
23332332 snd_soc_component_update_bits(component, WM8996_ANALOGUE_HP_1,
23342333 WM8996_HPOUT1L_RMV_SHORT |
....@@ -2387,7 +2386,7 @@
23872386 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
23882387 int val, reg;
23892388
2390
- val = snd_soc_component_read32(component, WM8996_MIC_DETECT_3);
2389
+ val = snd_soc_component_read(component, WM8996_MIC_DETECT_3);
23912390
23922391 dev_dbg(component->dev, "Microphone event: %x\n", val);
23932392
....@@ -2453,7 +2452,7 @@
24532452 return;
24542453 }
24552454
2456
- reg = snd_soc_component_read32(component, WM8996_ACCESSORY_DETECT_MODE_2);
2455
+ reg = snd_soc_component_read(component, WM8996_ACCESSORY_DETECT_MODE_2);
24572456 reg ^= WM8996_HPOUT1FB_SRC | WM8996_MICD_SRC |
24582457 WM8996_MICD_BIAS_SRC;
24592458 snd_soc_component_update_bits(component, WM8996_ACCESSORY_DETECT_MODE_2,
....@@ -2490,13 +2489,13 @@
24902489 struct wm8996_priv *wm8996 = snd_soc_component_get_drvdata(component);
24912490 int irq_val;
24922491
2493
- irq_val = snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2);
2492
+ irq_val = snd_soc_component_read(component, WM8996_INTERRUPT_STATUS_2);
24942493 if (irq_val < 0) {
24952494 dev_err(component->dev, "Failed to read IRQ status: %d\n",
24962495 irq_val);
24972496 return IRQ_NONE;
24982497 }
2499
- irq_val &= ~snd_soc_component_read32(component, WM8996_INTERRUPT_STATUS_2_MASK);
2498
+ irq_val &= ~snd_soc_component_read(component, WM8996_INTERRUPT_STATUS_2_MASK);
25002499
25012500 if (!irq_val)
25022501 return IRQ_NONE;
....@@ -2801,8 +2800,9 @@
28012800
28022801 /* This should really be moved into the regulator core */
28032802 for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++) {
2804
- ret = regulator_register_notifier(wm8996->supplies[i].consumer,
2805
- &wm8996->disable_nb[i]);
2803
+ ret = devm_regulator_register_notifier(
2804
+ wm8996->supplies[i].consumer,
2805
+ &wm8996->disable_nb[i]);
28062806 if (ret != 0) {
28072807 dev_err(&i2c->dev,
28082808 "Failed to register regulator notifier: %d\n",
....@@ -3071,16 +3071,12 @@
30713071 static int wm8996_i2c_remove(struct i2c_client *client)
30723072 {
30733073 struct wm8996_priv *wm8996 = i2c_get_clientdata(client);
3074
- int i;
30753074
30763075 wm8996_free_gpio(wm8996);
30773076 if (wm8996->pdata.ldo_ena > 0) {
30783077 gpio_set_value_cansleep(wm8996->pdata.ldo_ena, 0);
30793078 gpio_free(wm8996->pdata.ldo_ena);
30803079 }
3081
- for (i = 0; i < ARRAY_SIZE(wm8996->supplies); i++)
3082
- regulator_unregister_notifier(wm8996->supplies[i].consumer,
3083
- &wm8996->disable_nb[i]);
30843080
30853081 return 0;
30863082 }