hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/sound/soc/codecs/rt5668.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * rt5668.c -- RT5668B ALSA SoC audio component driver
34 *
45 * Copyright 2018 Realtek Semiconductor Corp.
56 * Author: Bard Liao <bardliao@realtek.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/module.h>
....@@ -850,7 +847,7 @@
850847 {
851848 int btn_type, val;
852849
853
- val = snd_soc_component_read32(component, RT5668_4BTN_IL_CMD_1);
850
+ val = snd_soc_component_read(component, RT5668_4BTN_IL_CMD_1);
854851 btn_type = val & 0xfff0;
855852 snd_soc_component_write(component, RT5668_4BTN_IL_CMD_1, val);
856853 pr_debug("%s btn_type=%x\n", __func__, btn_type);
....@@ -910,11 +907,11 @@
910907 RT5668_TRIG_JD_MASK, RT5668_TRIG_JD_HIGH);
911908
912909 count = 0;
913
- val = snd_soc_component_read32(component, RT5668_CBJ_CTRL_2)
910
+ val = snd_soc_component_read(component, RT5668_CBJ_CTRL_2)
914911 & RT5668_JACK_TYPE_MASK;
915912 while (val == 0 && count < 50) {
916913 usleep_range(10000, 15000);
917
- val = snd_soc_component_read32(component,
914
+ val = snd_soc_component_read(component,
918915 RT5668_CBJ_CTRL_2) & RT5668_JACK_TYPE_MASK;
919916 count++;
920917 }
....@@ -958,7 +955,7 @@
958955 struct rt5668_priv *rt5668 = container_of(work, struct rt5668_priv,
959956 jd_check_work.work);
960957
961
- if (snd_soc_component_read32(rt5668->component, RT5668_AJD1_CTRL)
958
+ if (snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL)
962959 & RT5668_JDH_RS_MASK) {
963960 /* jack out */
964961 rt5668->jack_type = rt5668_headset_detect(rt5668->component, 0);
....@@ -1025,15 +1022,17 @@
10251022 container_of(work, struct rt5668_priv, jack_detect_work.work);
10261023 int val, btn_type;
10271024
1028
- while (!rt5668->component)
1029
- usleep_range(10000, 15000);
1030
-
1031
- while (!rt5668->component->card->instantiated)
1032
- usleep_range(10000, 15000);
1025
+ if (!rt5668->component || !rt5668->component->card ||
1026
+ !rt5668->component->card->instantiated) {
1027
+ /* card not yet ready, try later */
1028
+ mod_delayed_work(system_power_efficient_wq,
1029
+ &rt5668->jack_detect_work, msecs_to_jiffies(15));
1030
+ return;
1031
+ }
10331032
10341033 mutex_lock(&rt5668->calibrate_mutex);
10351034
1036
- val = snd_soc_component_read32(rt5668->component, RT5668_AJD1_CTRL)
1035
+ val = snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL)
10371036 & RT5668_JDH_RS_MASK;
10381037 if (!val) {
10391038 /* jack in */
....@@ -1194,7 +1193,7 @@
11941193 int ref, val, reg, idx = -EINVAL;
11951194 static const int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48};
11961195
1197
- val = snd_soc_component_read32(component, RT5668_GPIO_CTRL_1) &
1196
+ val = snd_soc_component_read(component, RT5668_GPIO_CTRL_1) &
11981197 RT5668_GP4_PIN_MASK;
11991198 if (w->shift == RT5668_PWR_ADC_S1F_BIT &&
12001199 val == RT5668_GP4_PIN_ADCDAT2)
....@@ -1222,7 +1221,7 @@
12221221 struct snd_soc_component *component =
12231222 snd_soc_dapm_to_component(w->dapm);
12241223
1225
- val = snd_soc_component_read32(component, RT5668_GLB_CLK);
1224
+ val = snd_soc_component_read(component, RT5668_GLB_CLK);
12261225 val &= RT5668_SCLK_SRC_MASK;
12271226 if (val == RT5668_SCLK_SRC_PLL1)
12281227 return 1;
....@@ -1250,7 +1249,7 @@
12501249 return 0;
12511250 }
12521251
1253
- val = (snd_soc_component_read32(component, reg) >> shift) & 0xf;
1252
+ val = (snd_soc_component_read(component, reg) >> shift) & 0xf;
12541253 switch (val) {
12551254 case RT5668_CLK_SEL_I2S1_ASRC:
12561255 case RT5668_CLK_SEL_I2S2_ASRC:
....@@ -2375,7 +2374,8 @@
23752374 .cache_type = REGCACHE_RBTREE,
23762375 .reg_defaults = rt5668_reg,
23772376 .num_reg_defaults = ARRAY_SIZE(rt5668_reg),
2378
- .use_single_rw = true,
2377
+ .use_single_read = true,
2378
+ .use_single_write = true,
23792379 };
23802380
23812381 static const struct i2c_device_id rt5668_i2c_id[] = {
....@@ -2587,15 +2587,8 @@
25872587
25882588 }
25892589
2590
- return snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5668,
2590
+ return devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5668,
25912591 rt5668_dai, ARRAY_SIZE(rt5668_dai));
2592
-}
2593
-
2594
-static int rt5668_i2c_remove(struct i2c_client *i2c)
2595
-{
2596
- snd_soc_unregister_component(&i2c->dev);
2597
-
2598
- return 0;
25992592 }
26002593
26012594 static void rt5668_i2c_shutdown(struct i2c_client *client)
....@@ -2628,7 +2621,6 @@
26282621 .acpi_match_table = ACPI_PTR(rt5668_acpi_match),
26292622 },
26302623 .probe = rt5668_i2c_probe,
2631
- .remove = rt5668_i2c_remove,
26322624 .shutdown = rt5668_i2c_shutdown,
26332625 .id_table = rt5668_i2c_id,
26342626 };