.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * rt5668.c -- RT5668B ALSA SoC audio component driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2018 Realtek Semiconductor Corp. |
---|
5 | 6 | * 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. |
---|
10 | 7 | */ |
---|
11 | 8 | |
---|
12 | 9 | #include <linux/module.h> |
---|
.. | .. |
---|
850 | 847 | { |
---|
851 | 848 | int btn_type, val; |
---|
852 | 849 | |
---|
853 | | - val = snd_soc_component_read32(component, RT5668_4BTN_IL_CMD_1); |
---|
| 850 | + val = snd_soc_component_read(component, RT5668_4BTN_IL_CMD_1); |
---|
854 | 851 | btn_type = val & 0xfff0; |
---|
855 | 852 | snd_soc_component_write(component, RT5668_4BTN_IL_CMD_1, val); |
---|
856 | 853 | pr_debug("%s btn_type=%x\n", __func__, btn_type); |
---|
.. | .. |
---|
910 | 907 | RT5668_TRIG_JD_MASK, RT5668_TRIG_JD_HIGH); |
---|
911 | 908 | |
---|
912 | 909 | count = 0; |
---|
913 | | - val = snd_soc_component_read32(component, RT5668_CBJ_CTRL_2) |
---|
| 910 | + val = snd_soc_component_read(component, RT5668_CBJ_CTRL_2) |
---|
914 | 911 | & RT5668_JACK_TYPE_MASK; |
---|
915 | 912 | while (val == 0 && count < 50) { |
---|
916 | 913 | usleep_range(10000, 15000); |
---|
917 | | - val = snd_soc_component_read32(component, |
---|
| 914 | + val = snd_soc_component_read(component, |
---|
918 | 915 | RT5668_CBJ_CTRL_2) & RT5668_JACK_TYPE_MASK; |
---|
919 | 916 | count++; |
---|
920 | 917 | } |
---|
.. | .. |
---|
958 | 955 | struct rt5668_priv *rt5668 = container_of(work, struct rt5668_priv, |
---|
959 | 956 | jd_check_work.work); |
---|
960 | 957 | |
---|
961 | | - if (snd_soc_component_read32(rt5668->component, RT5668_AJD1_CTRL) |
---|
| 958 | + if (snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL) |
---|
962 | 959 | & RT5668_JDH_RS_MASK) { |
---|
963 | 960 | /* jack out */ |
---|
964 | 961 | rt5668->jack_type = rt5668_headset_detect(rt5668->component, 0); |
---|
.. | .. |
---|
1025 | 1022 | container_of(work, struct rt5668_priv, jack_detect_work.work); |
---|
1026 | 1023 | int val, btn_type; |
---|
1027 | 1024 | |
---|
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 | + } |
---|
1033 | 1032 | |
---|
1034 | 1033 | mutex_lock(&rt5668->calibrate_mutex); |
---|
1035 | 1034 | |
---|
1036 | | - val = snd_soc_component_read32(rt5668->component, RT5668_AJD1_CTRL) |
---|
| 1035 | + val = snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL) |
---|
1037 | 1036 | & RT5668_JDH_RS_MASK; |
---|
1038 | 1037 | if (!val) { |
---|
1039 | 1038 | /* jack in */ |
---|
.. | .. |
---|
1194 | 1193 | int ref, val, reg, idx = -EINVAL; |
---|
1195 | 1194 | static const int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48}; |
---|
1196 | 1195 | |
---|
1197 | | - val = snd_soc_component_read32(component, RT5668_GPIO_CTRL_1) & |
---|
| 1196 | + val = snd_soc_component_read(component, RT5668_GPIO_CTRL_1) & |
---|
1198 | 1197 | RT5668_GP4_PIN_MASK; |
---|
1199 | 1198 | if (w->shift == RT5668_PWR_ADC_S1F_BIT && |
---|
1200 | 1199 | val == RT5668_GP4_PIN_ADCDAT2) |
---|
.. | .. |
---|
1222 | 1221 | struct snd_soc_component *component = |
---|
1223 | 1222 | snd_soc_dapm_to_component(w->dapm); |
---|
1224 | 1223 | |
---|
1225 | | - val = snd_soc_component_read32(component, RT5668_GLB_CLK); |
---|
| 1224 | + val = snd_soc_component_read(component, RT5668_GLB_CLK); |
---|
1226 | 1225 | val &= RT5668_SCLK_SRC_MASK; |
---|
1227 | 1226 | if (val == RT5668_SCLK_SRC_PLL1) |
---|
1228 | 1227 | return 1; |
---|
.. | .. |
---|
1250 | 1249 | return 0; |
---|
1251 | 1250 | } |
---|
1252 | 1251 | |
---|
1253 | | - val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; |
---|
| 1252 | + val = (snd_soc_component_read(component, reg) >> shift) & 0xf; |
---|
1254 | 1253 | switch (val) { |
---|
1255 | 1254 | case RT5668_CLK_SEL_I2S1_ASRC: |
---|
1256 | 1255 | case RT5668_CLK_SEL_I2S2_ASRC: |
---|
.. | .. |
---|
2375 | 2374 | .cache_type = REGCACHE_RBTREE, |
---|
2376 | 2375 | .reg_defaults = rt5668_reg, |
---|
2377 | 2376 | .num_reg_defaults = ARRAY_SIZE(rt5668_reg), |
---|
2378 | | - .use_single_rw = true, |
---|
| 2377 | + .use_single_read = true, |
---|
| 2378 | + .use_single_write = true, |
---|
2379 | 2379 | }; |
---|
2380 | 2380 | |
---|
2381 | 2381 | static const struct i2c_device_id rt5668_i2c_id[] = { |
---|
.. | .. |
---|
2587 | 2587 | |
---|
2588 | 2588 | } |
---|
2589 | 2589 | |
---|
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, |
---|
2591 | 2591 | 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; |
---|
2599 | 2592 | } |
---|
2600 | 2593 | |
---|
2601 | 2594 | static void rt5668_i2c_shutdown(struct i2c_client *client) |
---|
.. | .. |
---|
2628 | 2621 | .acpi_match_table = ACPI_PTR(rt5668_acpi_match), |
---|
2629 | 2622 | }, |
---|
2630 | 2623 | .probe = rt5668_i2c_probe, |
---|
2631 | | - .remove = rt5668_i2c_remove, |
---|
2632 | 2624 | .shutdown = rt5668_i2c_shutdown, |
---|
2633 | 2625 | .id_table = rt5668_i2c_id, |
---|
2634 | 2626 | }; |
---|