| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * rt5670.c -- RT5670 ALSA SoC audio codec driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2014 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> |
|---|
| .. | .. |
|---|
| 28 | 25 | #include <sound/soc-dapm.h> |
|---|
| 29 | 26 | #include <sound/initval.h> |
|---|
| 30 | 27 | #include <sound/tlv.h> |
|---|
| 31 | | -#include <sound/rt5670.h> |
|---|
| 32 | 28 | |
|---|
| 33 | 29 | #include "rl6231.h" |
|---|
| 34 | 30 | #include "rt5670.h" |
|---|
| 35 | 31 | #include "rt5670-dsp.h" |
|---|
| 36 | 32 | |
|---|
| 37 | | -#define RT5670_DEV_GPIO BIT(0) |
|---|
| 33 | +#define RT5670_GPIO1_IS_IRQ BIT(0) |
|---|
| 38 | 34 | #define RT5670_IN2_DIFF BIT(1) |
|---|
| 39 | 35 | #define RT5670_DMIC_EN BIT(2) |
|---|
| 40 | 36 | #define RT5670_DMIC1_IN2P BIT(3) |
|---|
| .. | .. |
|---|
| 456 | 452 | snd_soc_component_update_bits(component, RT5670_CJ_CTRL2, |
|---|
| 457 | 453 | RT5670_CBJ_MN_JD, 0); |
|---|
| 458 | 454 | msleep(300); |
|---|
| 459 | | - val = snd_soc_component_read32(component, RT5670_CJ_CTRL3) & 0x7; |
|---|
| 455 | + val = snd_soc_component_read(component, RT5670_CJ_CTRL3) & 0x7; |
|---|
| 460 | 456 | if (val == 0x1 || val == 0x2) { |
|---|
| 461 | 457 | rt5670->jack_type = SND_JACK_HEADSET; |
|---|
| 462 | 458 | /* for push button */ |
|---|
| 463 | 459 | snd_soc_component_update_bits(component, RT5670_INT_IRQ_ST, 0x8, 0x8); |
|---|
| 464 | 460 | snd_soc_component_update_bits(component, RT5670_IL_CMD, 0x40, 0x40); |
|---|
| 465 | | - snd_soc_component_read32(component, RT5670_IL_CMD); |
|---|
| 461 | + snd_soc_component_read(component, RT5670_IL_CMD); |
|---|
| 466 | 462 | } else { |
|---|
| 467 | 463 | snd_soc_component_update_bits(component, RT5670_GEN_CTRL3, 0x4, 0x4); |
|---|
| 468 | 464 | rt5670->jack_type = SND_JACK_HEADPHONE; |
|---|
| .. | .. |
|---|
| 502 | 498 | { |
|---|
| 503 | 499 | int btn_type, val; |
|---|
| 504 | 500 | |
|---|
| 505 | | - val = snd_soc_component_read32(component, RT5670_IL_CMD); |
|---|
| 501 | + val = snd_soc_component_read(component, RT5670_IL_CMD); |
|---|
| 506 | 502 | btn_type = val & 0xff80; |
|---|
| 507 | 503 | snd_soc_component_write(component, RT5670_IL_CMD, val); |
|---|
| 508 | 504 | if (btn_type != 0) { |
|---|
| 509 | 505 | msleep(20); |
|---|
| 510 | | - val = snd_soc_component_read32(component, RT5670_IL_CMD); |
|---|
| 506 | + val = snd_soc_component_read(component, RT5670_IL_CMD); |
|---|
| 511 | 507 | snd_soc_component_write(component, RT5670_IL_CMD, val); |
|---|
| 512 | 508 | } |
|---|
| 513 | 509 | |
|---|
| .. | .. |
|---|
| 521 | 517 | struct snd_soc_jack *jack = rt5670->jack; |
|---|
| 522 | 518 | int val, btn_type, report = jack->status; |
|---|
| 523 | 519 | |
|---|
| 524 | | - if (rt5670->pdata.jd_mode == 1) /* 2 port */ |
|---|
| 525 | | - val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; |
|---|
| 520 | + if (rt5670->jd_mode == 1) /* 2 port */ |
|---|
| 521 | + val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; |
|---|
| 526 | 522 | else |
|---|
| 527 | | - val = snd_soc_component_read32(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; |
|---|
| 523 | + val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; |
|---|
| 528 | 524 | |
|---|
| 529 | 525 | switch (val) { |
|---|
| 530 | 526 | /* jack in */ |
|---|
| .. | .. |
|---|
| 537 | 533 | break; |
|---|
| 538 | 534 | } |
|---|
| 539 | 535 | btn_type = 0; |
|---|
| 540 | | - if (snd_soc_component_read32(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { |
|---|
| 536 | + if (snd_soc_component_read(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { |
|---|
| 541 | 537 | /* button pressed */ |
|---|
| 542 | 538 | report = SND_JACK_HEADSET; |
|---|
| 543 | 539 | btn_type = rt5670_button_detect(rt5670->component); |
|---|
| .. | .. |
|---|
| 606 | 602 | EXPORT_SYMBOL_GPL(rt5670_set_jack_detect); |
|---|
| 607 | 603 | |
|---|
| 608 | 604 | static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); |
|---|
| 609 | | -static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0); |
|---|
| 605 | +static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0); |
|---|
| 610 | 606 | static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); |
|---|
| 611 | | -static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0); |
|---|
| 607 | +static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000); |
|---|
| 612 | 608 | static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); |
|---|
| 613 | 609 | |
|---|
| 614 | 610 | /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ |
|---|
| .. | .. |
|---|
| 766 | 762 | return 0; |
|---|
| 767 | 763 | } |
|---|
| 768 | 764 | |
|---|
| 769 | | - val = (snd_soc_component_read32(component, reg) >> shift) & 0xf; |
|---|
| 765 | + val = (snd_soc_component_read(component, reg) >> shift) & 0xf; |
|---|
| 770 | 766 | switch (val) { |
|---|
| 771 | 767 | case 1: |
|---|
| 772 | 768 | case 2: |
|---|
| .. | .. |
|---|
| 1058 | 1054 | RT5670_M_OV_R_LM_SFT, 1, 1), |
|---|
| 1059 | 1055 | }; |
|---|
| 1060 | 1056 | |
|---|
| 1061 | | -static const struct snd_kcontrol_new rt5670_hpl_mix[] = { |
|---|
| 1062 | | - SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_HPO_MIXER, |
|---|
| 1063 | | - RT5670_M_DACL1_HML_SFT, 1, 1), |
|---|
| 1064 | | - SOC_DAPM_SINGLE("INL1 Switch", RT5670_HPO_MIXER, |
|---|
| 1065 | | - RT5670_M_INL1_HML_SFT, 1, 1), |
|---|
| 1066 | | -}; |
|---|
| 1067 | | - |
|---|
| 1068 | | -static const struct snd_kcontrol_new rt5670_hpr_mix[] = { |
|---|
| 1069 | | - SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_HPO_MIXER, |
|---|
| 1070 | | - RT5670_M_DACR1_HMR_SFT, 1, 1), |
|---|
| 1071 | | - SOC_DAPM_SINGLE("INR1 Switch", RT5670_HPO_MIXER, |
|---|
| 1072 | | - RT5670_M_INR1_HMR_SFT, 1, 1), |
|---|
| 1073 | | -}; |
|---|
| 1074 | | - |
|---|
| 1075 | 1057 | static const struct snd_kcontrol_new lout_l_enable_control = |
|---|
| 1076 | 1058 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1, |
|---|
| 1077 | 1059 | RT5670_L_MUTE_SFT, 1, 1); |
|---|
| .. | .. |
|---|
| 1197 | 1179 | static const struct snd_kcontrol_new rt5670_sto2_adc_2_mux = |
|---|
| 1198 | 1180 | SOC_DAPM_ENUM("Stereo2 ADC 2 Mux", rt5670_stereo2_adc2_enum); |
|---|
| 1199 | 1181 | |
|---|
| 1200 | | - |
|---|
| 1201 | | -/* MX-27 MX26 [10] */ |
|---|
| 1202 | | -static const char * const rt5670_stereo_adc_src[] = { |
|---|
| 1203 | | - "ADC1L ADC2R", "ADC3" |
|---|
| 1204 | | -}; |
|---|
| 1205 | | - |
|---|
| 1206 | | -static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc_enum, RT5670_STO1_ADC_MIXER, |
|---|
| 1207 | | - RT5670_ADC_SRC_SFT, rt5670_stereo_adc_src); |
|---|
| 1208 | | - |
|---|
| 1209 | | -static const struct snd_kcontrol_new rt5670_sto_adc_mux = |
|---|
| 1210 | | - SOC_DAPM_ENUM("Stereo1 ADC source", rt5670_stereo1_adc_enum); |
|---|
| 1211 | | - |
|---|
| 1212 | | -static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc_enum, RT5670_STO2_ADC_MIXER, |
|---|
| 1213 | | - RT5670_ADC_SRC_SFT, rt5670_stereo_adc_src); |
|---|
| 1214 | | - |
|---|
| 1215 | | -static const struct snd_kcontrol_new rt5670_sto2_adc_mux = |
|---|
| 1216 | | - SOC_DAPM_ENUM("Stereo2 ADC source", rt5670_stereo2_adc_enum); |
|---|
| 1217 | | - |
|---|
| 1218 | 1182 | /* MX-27 MX-26 [9:8] */ |
|---|
| 1219 | 1183 | static const char * const rt5670_stereo_dmic_src[] = { |
|---|
| 1220 | 1184 | "DMIC1", "DMIC2", "DMIC3" |
|---|
| .. | .. |
|---|
| 1231 | 1195 | |
|---|
| 1232 | 1196 | static const struct snd_kcontrol_new rt5670_sto2_dmic_mux = |
|---|
| 1233 | 1197 | SOC_DAPM_ENUM("Stereo2 DMIC source", rt5670_stereo2_dmic_enum); |
|---|
| 1234 | | - |
|---|
| 1235 | | -/* MX-27 [0] */ |
|---|
| 1236 | | -static const char * const rt5670_stereo_dmic3_src[] = { |
|---|
| 1237 | | - "DMIC3", "PDM ADC" |
|---|
| 1238 | | -}; |
|---|
| 1239 | | - |
|---|
| 1240 | | -static SOC_ENUM_SINGLE_DECL(rt5670_stereo_dmic3_enum, RT5670_STO1_ADC_MIXER, |
|---|
| 1241 | | - RT5670_DMIC3_SRC_SFT, rt5670_stereo_dmic3_src); |
|---|
| 1242 | | - |
|---|
| 1243 | | -static const struct snd_kcontrol_new rt5670_sto_dmic3_mux = |
|---|
| 1244 | | - SOC_DAPM_ENUM("Stereo DMIC3 source", rt5670_stereo_dmic3_enum); |
|---|
| 1245 | 1198 | |
|---|
| 1246 | 1199 | /* Mono ADC source */ |
|---|
| 1247 | 1200 | /* MX-28 [12] */ |
|---|
| .. | .. |
|---|
| 1334 | 1287 | |
|---|
| 1335 | 1288 | static const struct snd_kcontrol_new rt5670_if2_adc_in_mux = |
|---|
| 1336 | 1289 | SOC_DAPM_ENUM("IF2 ADC IN source", rt5670_if2_adc_in_enum); |
|---|
| 1337 | | - |
|---|
| 1338 | | -/* MX-30 [5:4] */ |
|---|
| 1339 | | -static const char * const rt5670_if4_adc_in_src[] = { |
|---|
| 1340 | | - "IF_ADC1", "IF_ADC2", "IF_ADC3" |
|---|
| 1341 | | -}; |
|---|
| 1342 | | - |
|---|
| 1343 | | -static SOC_ENUM_SINGLE_DECL(rt5670_if4_adc_in_enum, RT5670_DIG_INF2_DATA, |
|---|
| 1344 | | - RT5670_IF4_ADC_IN_SFT, rt5670_if4_adc_in_src); |
|---|
| 1345 | | - |
|---|
| 1346 | | -static const struct snd_kcontrol_new rt5670_if4_adc_in_mux = |
|---|
| 1347 | | - SOC_DAPM_ENUM("IF4 ADC IN source", rt5670_if4_adc_in_enum); |
|---|
| 1348 | 1290 | |
|---|
| 1349 | 1291 | /* MX-31 [15] [13] [11] [9] */ |
|---|
| 1350 | 1292 | static const char * const rt5670_pdm_src[] = { |
|---|
| .. | .. |
|---|
| 1511 | 1453 | struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); |
|---|
| 1512 | 1454 | struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); |
|---|
| 1513 | 1455 | |
|---|
| 1514 | | - if (!rt5670->pdata.gpio1_is_ext_spk_en) |
|---|
| 1456 | + if (!rt5670->gpio1_is_ext_spk_en) |
|---|
| 1515 | 1457 | return 0; |
|---|
| 1516 | 1458 | |
|---|
| 1517 | 1459 | switch (event) { |
|---|
| .. | .. |
|---|
| 2681 | 2623 | RT5670_LDO_SEL_MASK, 0x3); |
|---|
| 2682 | 2624 | break; |
|---|
| 2683 | 2625 | case SND_SOC_BIAS_OFF: |
|---|
| 2684 | | - if (rt5670->pdata.jd_mode) |
|---|
| 2626 | + if (rt5670->jd_mode) |
|---|
| 2685 | 2627 | snd_soc_component_update_bits(component, RT5670_PWR_ANLG1, |
|---|
| 2686 | 2628 | RT5670_PWR_VREF1 | RT5670_PWR_MB | |
|---|
| 2687 | 2629 | RT5670_PWR_BG | RT5670_PWR_VREF2 | |
|---|
| .. | .. |
|---|
| 2708 | 2650 | struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component); |
|---|
| 2709 | 2651 | struct rt5670_priv *rt5670 = snd_soc_component_get_drvdata(component); |
|---|
| 2710 | 2652 | |
|---|
| 2711 | | - switch (snd_soc_component_read32(component, RT5670_RESET) & RT5670_ID_MASK) { |
|---|
| 2653 | + switch (snd_soc_component_read(component, RT5670_RESET) & RT5670_ID_MASK) { |
|---|
| 2712 | 2654 | case RT5670_ID_5670: |
|---|
| 2713 | 2655 | case RT5670_ID_5671: |
|---|
| 2714 | 2656 | snd_soc_dapm_new_controls(dapm, |
|---|
| .. | .. |
|---|
| 2844 | 2786 | static const struct regmap_config rt5670_regmap = { |
|---|
| 2845 | 2787 | .reg_bits = 8, |
|---|
| 2846 | 2788 | .val_bits = 16, |
|---|
| 2847 | | - .use_single_rw = true, |
|---|
| 2789 | + .use_single_read = true, |
|---|
| 2790 | + .use_single_write = true, |
|---|
| 2848 | 2791 | .max_register = RT5670_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5670_ranges) * |
|---|
| 2849 | 2792 | RT5670_PR_SPACING), |
|---|
| 2850 | 2793 | .volatile_reg = rt5670_volatile_register, |
|---|
| .. | .. |
|---|
| 2890 | 2833 | }, |
|---|
| 2891 | 2834 | .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2892 | 2835 | RT5670_DMIC1_IN2P | |
|---|
| 2893 | | - RT5670_DEV_GPIO | |
|---|
| 2836 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2894 | 2837 | RT5670_JD_MODE1), |
|---|
| 2895 | 2838 | }, |
|---|
| 2896 | 2839 | { |
|---|
| .. | .. |
|---|
| 2902 | 2845 | }, |
|---|
| 2903 | 2846 | .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2904 | 2847 | RT5670_DMIC1_IN2P | |
|---|
| 2905 | | - RT5670_DEV_GPIO | |
|---|
| 2848 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2849 | + RT5670_JD_MODE1), |
|---|
| 2850 | + }, |
|---|
| 2851 | + { |
|---|
| 2852 | + .callback = rt5670_quirk_cb, |
|---|
| 2853 | + .ident = "Lenovo Thinkpad Tablet 8", |
|---|
| 2854 | + .matches = { |
|---|
| 2855 | + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), |
|---|
| 2856 | + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad 8"), |
|---|
| 2857 | + }, |
|---|
| 2858 | + .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2859 | + RT5670_DMIC2_INR | |
|---|
| 2860 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2906 | 2861 | RT5670_JD_MODE1), |
|---|
| 2907 | 2862 | }, |
|---|
| 2908 | 2863 | { |
|---|
| .. | .. |
|---|
| 2914 | 2869 | }, |
|---|
| 2915 | 2870 | .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2916 | 2871 | RT5670_DMIC1_IN2P | |
|---|
| 2917 | | - RT5670_DEV_GPIO | |
|---|
| 2872 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2918 | 2873 | RT5670_JD_MODE1), |
|---|
| 2919 | 2874 | }, |
|---|
| 2920 | 2875 | { |
|---|
| .. | .. |
|---|
| 2926 | 2881 | }, |
|---|
| 2927 | 2882 | .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2928 | 2883 | RT5670_DMIC1_IN2P | |
|---|
| 2929 | | - RT5670_DEV_GPIO | |
|---|
| 2884 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2930 | 2885 | RT5670_JD_MODE1), |
|---|
| 2931 | 2886 | }, |
|---|
| 2932 | 2887 | { |
|---|
| .. | .. |
|---|
| 2950 | 2905 | }, |
|---|
| 2951 | 2906 | .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2952 | 2907 | RT5670_DMIC2_INR | |
|---|
| 2953 | | - RT5670_DEV_GPIO | |
|---|
| 2908 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2909 | + RT5670_JD_MODE3), |
|---|
| 2910 | + }, |
|---|
| 2911 | + { |
|---|
| 2912 | + .callback = rt5670_quirk_cb, |
|---|
| 2913 | + .ident = "Dell Venue 10 Pro 5055", |
|---|
| 2914 | + .matches = { |
|---|
| 2915 | + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), |
|---|
| 2916 | + DMI_MATCH(DMI_PRODUCT_NAME, "Venue 10 Pro 5055"), |
|---|
| 2917 | + }, |
|---|
| 2918 | + .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2919 | + RT5670_DMIC2_INR | |
|---|
| 2920 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2921 | + RT5670_JD_MODE1), |
|---|
| 2922 | + }, |
|---|
| 2923 | + { |
|---|
| 2924 | + .callback = rt5670_quirk_cb, |
|---|
| 2925 | + .ident = "Aegex 10 tablet (RU2)", |
|---|
| 2926 | + .matches = { |
|---|
| 2927 | + DMI_MATCH(DMI_SYS_VENDOR, "AEGEX"), |
|---|
| 2928 | + DMI_MATCH(DMI_PRODUCT_VERSION, "RU2"), |
|---|
| 2929 | + }, |
|---|
| 2930 | + .driver_data = (unsigned long *)(RT5670_DMIC_EN | |
|---|
| 2931 | + RT5670_DMIC2_INR | |
|---|
| 2932 | + RT5670_GPIO1_IS_IRQ | |
|---|
| 2954 | 2933 | RT5670_JD_MODE3), |
|---|
| 2955 | 2934 | }, |
|---|
| 2956 | 2935 | {} |
|---|
| .. | .. |
|---|
| 2959 | 2938 | static int rt5670_i2c_probe(struct i2c_client *i2c, |
|---|
| 2960 | 2939 | const struct i2c_device_id *id) |
|---|
| 2961 | 2940 | { |
|---|
| 2962 | | - struct rt5670_platform_data *pdata = dev_get_platdata(&i2c->dev); |
|---|
| 2963 | 2941 | struct rt5670_priv *rt5670; |
|---|
| 2964 | 2942 | int ret; |
|---|
| 2965 | 2943 | unsigned int val; |
|---|
| .. | .. |
|---|
| 2972 | 2950 | |
|---|
| 2973 | 2951 | i2c_set_clientdata(i2c, rt5670); |
|---|
| 2974 | 2952 | |
|---|
| 2975 | | - if (pdata) |
|---|
| 2976 | | - rt5670->pdata = *pdata; |
|---|
| 2977 | | - |
|---|
| 2978 | 2953 | dmi_check_system(dmi_platform_intel_quirks); |
|---|
| 2979 | 2954 | if (quirk_override) { |
|---|
| 2980 | 2955 | dev_info(&i2c->dev, "Overriding quirk 0x%x => 0x%x\n", |
|---|
| .. | .. |
|---|
| 2982 | 2957 | rt5670_quirk = quirk_override; |
|---|
| 2983 | 2958 | } |
|---|
| 2984 | 2959 | |
|---|
| 2985 | | - if (rt5670_quirk & RT5670_DEV_GPIO) { |
|---|
| 2986 | | - rt5670->pdata.dev_gpio = true; |
|---|
| 2987 | | - dev_info(&i2c->dev, "quirk dev_gpio\n"); |
|---|
| 2960 | + if (rt5670_quirk & RT5670_GPIO1_IS_IRQ) { |
|---|
| 2961 | + rt5670->gpio1_is_irq = true; |
|---|
| 2962 | + dev_info(&i2c->dev, "quirk GPIO1 is IRQ\n"); |
|---|
| 2988 | 2963 | } |
|---|
| 2989 | 2964 | if (rt5670_quirk & RT5670_GPIO1_IS_EXT_SPK_EN) { |
|---|
| 2990 | | - rt5670->pdata.gpio1_is_ext_spk_en = true; |
|---|
| 2965 | + rt5670->gpio1_is_ext_spk_en = true; |
|---|
| 2991 | 2966 | dev_info(&i2c->dev, "quirk GPIO1 is external speaker enable\n"); |
|---|
| 2992 | 2967 | } |
|---|
| 2993 | 2968 | if (rt5670_quirk & RT5670_IN2_DIFF) { |
|---|
| 2994 | | - rt5670->pdata.in2_diff = true; |
|---|
| 2969 | + rt5670->in2_diff = true; |
|---|
| 2995 | 2970 | dev_info(&i2c->dev, "quirk IN2_DIFF\n"); |
|---|
| 2996 | 2971 | } |
|---|
| 2997 | 2972 | if (rt5670_quirk & RT5670_DMIC_EN) { |
|---|
| 2998 | | - rt5670->pdata.dmic_en = true; |
|---|
| 2973 | + rt5670->dmic_en = true; |
|---|
| 2999 | 2974 | dev_info(&i2c->dev, "quirk DMIC enabled\n"); |
|---|
| 3000 | 2975 | } |
|---|
| 3001 | 2976 | if (rt5670_quirk & RT5670_DMIC1_IN2P) { |
|---|
| 3002 | | - rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_IN2P; |
|---|
| 2977 | + rt5670->dmic1_data_pin = RT5670_DMIC_DATA_IN2P; |
|---|
| 3003 | 2978 | dev_info(&i2c->dev, "quirk DMIC1 on IN2P pin\n"); |
|---|
| 3004 | 2979 | } |
|---|
| 3005 | 2980 | if (rt5670_quirk & RT5670_DMIC1_GPIO6) { |
|---|
| 3006 | | - rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_GPIO6; |
|---|
| 2981 | + rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO6; |
|---|
| 3007 | 2982 | dev_info(&i2c->dev, "quirk DMIC1 on GPIO6 pin\n"); |
|---|
| 3008 | 2983 | } |
|---|
| 3009 | 2984 | if (rt5670_quirk & RT5670_DMIC1_GPIO7) { |
|---|
| 3010 | | - rt5670->pdata.dmic1_data_pin = RT5670_DMIC_DATA_GPIO7; |
|---|
| 2985 | + rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO7; |
|---|
| 3011 | 2986 | dev_info(&i2c->dev, "quirk DMIC1 on GPIO7 pin\n"); |
|---|
| 3012 | 2987 | } |
|---|
| 3013 | 2988 | if (rt5670_quirk & RT5670_DMIC2_INR) { |
|---|
| 3014 | | - rt5670->pdata.dmic2_data_pin = RT5670_DMIC_DATA_IN3N; |
|---|
| 2989 | + rt5670->dmic2_data_pin = RT5670_DMIC_DATA_IN3N; |
|---|
| 3015 | 2990 | dev_info(&i2c->dev, "quirk DMIC2 on INR pin\n"); |
|---|
| 3016 | 2991 | } |
|---|
| 3017 | 2992 | if (rt5670_quirk & RT5670_DMIC2_GPIO8) { |
|---|
| 3018 | | - rt5670->pdata.dmic2_data_pin = RT5670_DMIC_DATA_GPIO8; |
|---|
| 2993 | + rt5670->dmic2_data_pin = RT5670_DMIC_DATA_GPIO8; |
|---|
| 3019 | 2994 | dev_info(&i2c->dev, "quirk DMIC2 on GPIO8 pin\n"); |
|---|
| 3020 | 2995 | } |
|---|
| 3021 | 2996 | if (rt5670_quirk & RT5670_DMIC3_GPIO5) { |
|---|
| 3022 | | - rt5670->pdata.dmic3_data_pin = RT5670_DMIC_DATA_GPIO5; |
|---|
| 2997 | + rt5670->dmic3_data_pin = RT5670_DMIC_DATA_GPIO5; |
|---|
| 3023 | 2998 | dev_info(&i2c->dev, "quirk DMIC3 on GPIO5 pin\n"); |
|---|
| 3024 | 2999 | } |
|---|
| 3025 | 3000 | |
|---|
| 3026 | 3001 | if (rt5670_quirk & RT5670_JD_MODE1) { |
|---|
| 3027 | | - rt5670->pdata.jd_mode = 1; |
|---|
| 3002 | + rt5670->jd_mode = 1; |
|---|
| 3028 | 3003 | dev_info(&i2c->dev, "quirk JD mode 1\n"); |
|---|
| 3029 | 3004 | } |
|---|
| 3030 | 3005 | if (rt5670_quirk & RT5670_JD_MODE2) { |
|---|
| 3031 | | - rt5670->pdata.jd_mode = 2; |
|---|
| 3006 | + rt5670->jd_mode = 2; |
|---|
| 3032 | 3007 | dev_info(&i2c->dev, "quirk JD mode 2\n"); |
|---|
| 3033 | 3008 | } |
|---|
| 3034 | 3009 | if (rt5670_quirk & RT5670_JD_MODE3) { |
|---|
| 3035 | | - rt5670->pdata.jd_mode = 3; |
|---|
| 3010 | + rt5670->jd_mode = 3; |
|---|
| 3036 | 3011 | dev_info(&i2c->dev, "quirk JD mode 3\n"); |
|---|
| 3037 | 3012 | } |
|---|
| 3038 | 3013 | |
|---|
| .. | .. |
|---|
| 3073 | 3048 | regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, |
|---|
| 3074 | 3049 | RT5670_MCLK_DET, RT5670_MCLK_DET); |
|---|
| 3075 | 3050 | |
|---|
| 3076 | | - if (rt5670->pdata.in2_diff) |
|---|
| 3051 | + if (rt5670->in2_diff) |
|---|
| 3077 | 3052 | regmap_update_bits(rt5670->regmap, RT5670_IN2, |
|---|
| 3078 | 3053 | RT5670_IN_DF2, RT5670_IN_DF2); |
|---|
| 3079 | 3054 | |
|---|
| 3080 | | - if (rt5670->pdata.dev_gpio) { |
|---|
| 3055 | + if (rt5670->gpio1_is_irq) { |
|---|
| 3081 | 3056 | /* for push button */ |
|---|
| 3082 | 3057 | regmap_write(rt5670->regmap, RT5670_IL_CMD, 0x0000); |
|---|
| 3083 | 3058 | regmap_write(rt5670->regmap, RT5670_IL_CMD2, 0x0010); |
|---|
| .. | .. |
|---|
| 3089 | 3064 | RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT); |
|---|
| 3090 | 3065 | } |
|---|
| 3091 | 3066 | |
|---|
| 3092 | | - if (rt5670->pdata.gpio1_is_ext_spk_en) { |
|---|
| 3067 | + if (rt5670->gpio1_is_ext_spk_en) { |
|---|
| 3093 | 3068 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, |
|---|
| 3094 | 3069 | RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_GPIO1); |
|---|
| 3095 | 3070 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, |
|---|
| 3096 | 3071 | RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT); |
|---|
| 3097 | 3072 | } |
|---|
| 3098 | 3073 | |
|---|
| 3099 | | - if (rt5670->pdata.jd_mode) { |
|---|
| 3074 | + if (rt5670->jd_mode) { |
|---|
| 3100 | 3075 | regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, |
|---|
| 3101 | 3076 | RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_RCCLK); |
|---|
| 3102 | 3077 | rt5670->sysclk = 0; |
|---|
| .. | .. |
|---|
| 3111 | 3086 | RT5670_JD_TRI_CBJ_SEL_MASK | |
|---|
| 3112 | 3087 | RT5670_JD_TRI_HPO_SEL_MASK, |
|---|
| 3113 | 3088 | RT5670_JD_CBJ_JD1_1 | RT5670_JD_HPO_JD1_1); |
|---|
| 3114 | | - switch (rt5670->pdata.jd_mode) { |
|---|
| 3089 | + switch (rt5670->jd_mode) { |
|---|
| 3115 | 3090 | case 1: |
|---|
| 3116 | 3091 | regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, |
|---|
| 3117 | 3092 | RT5670_JD1_MODE_MASK, |
|---|
| .. | .. |
|---|
| 3132 | 3107 | } |
|---|
| 3133 | 3108 | } |
|---|
| 3134 | 3109 | |
|---|
| 3135 | | - if (rt5670->pdata.dmic_en) { |
|---|
| 3110 | + if (rt5670->dmic_en) { |
|---|
| 3136 | 3111 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, |
|---|
| 3137 | 3112 | RT5670_GP2_PIN_MASK, |
|---|
| 3138 | 3113 | RT5670_GP2_PIN_DMIC1_SCL); |
|---|
| 3139 | 3114 | |
|---|
| 3140 | | - switch (rt5670->pdata.dmic1_data_pin) { |
|---|
| 3115 | + switch (rt5670->dmic1_data_pin) { |
|---|
| 3141 | 3116 | case RT5670_DMIC_DATA_IN2P: |
|---|
| 3142 | 3117 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, |
|---|
| 3143 | 3118 | RT5670_DMIC_1_DP_MASK, |
|---|
| .. | .. |
|---|
| 3166 | 3141 | break; |
|---|
| 3167 | 3142 | } |
|---|
| 3168 | 3143 | |
|---|
| 3169 | | - switch (rt5670->pdata.dmic2_data_pin) { |
|---|
| 3144 | + switch (rt5670->dmic2_data_pin) { |
|---|
| 3170 | 3145 | case RT5670_DMIC_DATA_IN3N: |
|---|
| 3171 | 3146 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, |
|---|
| 3172 | 3147 | RT5670_DMIC_2_DP_MASK, |
|---|
| .. | .. |
|---|
| 3186 | 3161 | break; |
|---|
| 3187 | 3162 | } |
|---|
| 3188 | 3163 | |
|---|
| 3189 | | - switch (rt5670->pdata.dmic3_data_pin) { |
|---|
| 3164 | + switch (rt5670->dmic3_data_pin) { |
|---|
| 3190 | 3165 | case RT5670_DMIC_DATA_GPIO5: |
|---|
| 3191 | 3166 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, |
|---|
| 3192 | 3167 | RT5670_DMIC_3_DP_MASK, |
|---|