.. | .. |
---|
24 | 24 | #include "rk_codec_digital.h" |
---|
25 | 25 | |
---|
26 | 26 | #define RK3568_GRF_SOC_CON2 (0x0508) |
---|
| 27 | +#define RK3588_GRF_SOC_CON6 (0x0318) |
---|
| 28 | +#define RV1106_GRF_SOC_CON1 (0x0004) |
---|
27 | 29 | #define RV1126_GRF_SOC_CON2 (0x0008) |
---|
28 | 30 | |
---|
29 | 31 | struct rk_codec_digital_soc_data { |
---|
.. | .. |
---|
80 | 82 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
81 | 83 | struct soc_mixer_control *mc = |
---|
82 | 84 | (struct soc_mixer_control *)kcontrol->private_value; |
---|
83 | | - unsigned int val = snd_soc_component_read32(component, mc->reg); |
---|
84 | | - unsigned int sign = snd_soc_component_read32(component, ADCVOGP); |
---|
| 85 | + unsigned int val = snd_soc_component_read(component, mc->reg); |
---|
| 86 | + unsigned int sign = snd_soc_component_read(component, ADCVOGP); |
---|
85 | 87 | unsigned int mask = (1 << fls(mc->max)) - 1; |
---|
86 | 88 | unsigned int shift = mc->shift; |
---|
87 | 89 | int mid = mc->max / 2; |
---|
.. | .. |
---|
162 | 164 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
163 | 165 | struct soc_mixer_control *mc = |
---|
164 | 166 | (struct soc_mixer_control *)kcontrol->private_value; |
---|
165 | | - unsigned int val = snd_soc_component_read32(component, mc->reg); |
---|
166 | | - unsigned int sign = snd_soc_component_read32(component, DACVOGP); |
---|
| 167 | + unsigned int val = snd_soc_component_read(component, mc->reg); |
---|
| 168 | + unsigned int sign = snd_soc_component_read(component, DACVOGP); |
---|
167 | 169 | unsigned int mask = (1 << fls(mc->max)) - 1; |
---|
168 | 170 | unsigned int shift = mc->shift; |
---|
169 | 171 | int mid = mc->max / 2; |
---|
.. | .. |
---|
221 | 223 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
222 | 224 | struct rk_codec_digital_priv *rcd = snd_soc_component_get_drvdata(component); |
---|
223 | 225 | |
---|
224 | | - if (!rcd || !rcd->pa_ctl) |
---|
| 226 | + if (!rcd->pa_ctl) |
---|
225 | 227 | return -EINVAL; |
---|
226 | 228 | |
---|
227 | 229 | ucontrol->value.enumerated.item[0] = gpiod_get_value(rcd->pa_ctl); |
---|
.. | .. |
---|
235 | 237 | struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol); |
---|
236 | 238 | struct rk_codec_digital_priv *rcd = snd_soc_component_get_drvdata(component); |
---|
237 | 239 | |
---|
238 | | - if (!rcd || !rcd->pa_ctl) |
---|
| 240 | + if (!rcd->pa_ctl) |
---|
239 | 241 | return -EINVAL; |
---|
240 | 242 | |
---|
241 | 243 | gpiod_set_value(rcd->pa_ctl, ucontrol->value.enumerated.item[0]); |
---|
.. | .. |
---|
405 | 407 | ACDCDIG_DACSCLKRXINT_DIV_SCKRXDIV(div_bclk)); |
---|
406 | 408 | regmap_update_bits(rcd->regmap, I2S_CKR0, |
---|
407 | 409 | ACDCDIG_I2S_CKR0_RSD_MASK, |
---|
408 | | - ACDCDIG_I2S_CKR0_RSD(64)); |
---|
| 410 | + ACDCDIG_I2S_CKR0_RSD_64); |
---|
409 | 411 | regmap_update_bits(rcd->regmap, ADCSCLKTXINT_DIV, |
---|
410 | 412 | ACDCDIG_ADCSCLKTXINT_DIV_SCKTXDIV_MASK, |
---|
411 | 413 | ACDCDIG_ADCSCLKTXINT_DIV_SCKTXDIV(div_bclk)); |
---|
412 | 414 | regmap_update_bits(rcd->regmap, I2S_CKR0, |
---|
413 | 415 | ACDCDIG_I2S_CKR0_TSD_MASK, |
---|
414 | | - ACDCDIG_I2S_CKR0_TSD(64)); |
---|
| 416 | + ACDCDIG_I2S_CKR0_TSD_64); |
---|
415 | 417 | |
---|
416 | 418 | return 0; |
---|
417 | 419 | } |
---|
.. | .. |
---|
448 | 450 | ACDCDIG_DACSCLKRXINT_DIV_SCKRXDIV(div_bclk)); |
---|
449 | 451 | regmap_update_bits(rcd->regmap, I2S_CKR0, |
---|
450 | 452 | ACDCDIG_I2S_CKR0_RSD_MASK, |
---|
451 | | - ACDCDIG_I2S_CKR0_RSD(64)); |
---|
| 453 | + ACDCDIG_I2S_CKR0_RSD_64); |
---|
452 | 454 | } else { |
---|
453 | 455 | clk_set_rate(rcd->clk_adc, mclk); |
---|
454 | 456 | |
---|
.. | .. |
---|
462 | 464 | ACDCDIG_ADCSCLKTXINT_DIV_SCKTXDIV(div_bclk)); |
---|
463 | 465 | regmap_update_bits(rcd->regmap, I2S_CKR0, |
---|
464 | 466 | ACDCDIG_I2S_CKR0_TSD_MASK, |
---|
465 | | - ACDCDIG_I2S_CKR0_TSD(64)); |
---|
| 467 | + ACDCDIG_I2S_CKR0_TSD_64); |
---|
466 | 468 | } |
---|
467 | 469 | |
---|
468 | 470 | return 0; |
---|
.. | .. |
---|
746 | 748 | struct rk_codec_digital_priv *rcd = |
---|
747 | 749 | snd_soc_component_get_drvdata(dai->component); |
---|
748 | 750 | |
---|
749 | | - if (rcd && rcd->pa_ctl) { |
---|
| 751 | + if (rcd->pa_ctl) { |
---|
750 | 752 | gpiod_set_value_cansleep(rcd->pa_ctl, 1); |
---|
751 | 753 | if (rcd->pa_ctl_delay_ms) |
---|
752 | 754 | msleep(rcd->pa_ctl_delay_ms); |
---|
.. | .. |
---|
761 | 763 | struct rk_codec_digital_priv *rcd = |
---|
762 | 764 | snd_soc_component_get_drvdata(dai->component); |
---|
763 | 765 | |
---|
764 | | - if (rcd && rcd->pa_ctl) |
---|
| 766 | + if (rcd->pa_ctl) |
---|
765 | 767 | gpiod_set_value_cansleep(rcd->pa_ctl, 0); |
---|
766 | 768 | |
---|
767 | 769 | if (rcd->sync) { |
---|
768 | | - if (!snd_soc_component_is_active(dai->component)) { |
---|
| 770 | + if (!snd_soc_component_active(dai->component)) { |
---|
769 | 771 | rk_codec_digital_disable_sync(rcd); |
---|
770 | 772 | rk_codec_digital_reset(rcd); |
---|
771 | 773 | } |
---|
.. | .. |
---|
882 | 884 | .deinit = rk3568_soc_deinit, |
---|
883 | 885 | }; |
---|
884 | 886 | |
---|
| 887 | +static int rk3588_soc_init(struct device *dev) |
---|
| 888 | +{ |
---|
| 889 | + struct rk_codec_digital_priv *rcd = dev_get_drvdata(dev); |
---|
| 890 | + |
---|
| 891 | + if (IS_ERR(rcd->grf)) |
---|
| 892 | + return PTR_ERR(rcd->grf); |
---|
| 893 | + |
---|
| 894 | + /* enable internal codec to i2s3 */ |
---|
| 895 | + return regmap_write(rcd->grf, RK3588_GRF_SOC_CON6, |
---|
| 896 | + (BIT(11) << 16 | BIT(11))); |
---|
| 897 | +} |
---|
| 898 | + |
---|
| 899 | +static void rk3588_soc_deinit(struct device *dev) |
---|
| 900 | +{ |
---|
| 901 | + struct rk_codec_digital_priv *rcd = dev_get_drvdata(dev); |
---|
| 902 | + |
---|
| 903 | + if (IS_ERR(rcd->grf)) |
---|
| 904 | + return; |
---|
| 905 | + |
---|
| 906 | + regmap_write(rcd->grf, RK3588_GRF_SOC_CON6, (BIT(11) << 16)); |
---|
| 907 | +} |
---|
| 908 | + |
---|
| 909 | +static const struct rk_codec_digital_soc_data rk3588_data = { |
---|
| 910 | + .init = rk3588_soc_init, |
---|
| 911 | + .deinit = rk3588_soc_deinit, |
---|
| 912 | +}; |
---|
| 913 | + |
---|
| 914 | +static int rv1106_soc_init(struct device *dev) |
---|
| 915 | +{ |
---|
| 916 | + struct rk_codec_digital_priv *rcd = dev_get_drvdata(dev); |
---|
| 917 | + |
---|
| 918 | + if (IS_ERR(rcd->grf)) |
---|
| 919 | + return PTR_ERR(rcd->grf); |
---|
| 920 | + |
---|
| 921 | + /* enable internal codec to i2s0 */ |
---|
| 922 | + return regmap_write(rcd->grf, RV1106_GRF_SOC_CON1, |
---|
| 923 | + (BIT(8) << 16 | BIT(8))); |
---|
| 924 | +} |
---|
| 925 | + |
---|
| 926 | +static void rv1106_soc_deinit(struct device *dev) |
---|
| 927 | +{ |
---|
| 928 | + struct rk_codec_digital_priv *rcd = dev_get_drvdata(dev); |
---|
| 929 | + |
---|
| 930 | + if (IS_ERR(rcd->grf)) |
---|
| 931 | + return; |
---|
| 932 | + |
---|
| 933 | + regmap_write(rcd->grf, RV1106_GRF_SOC_CON1, (BIT(8) << 16)); |
---|
| 934 | +} |
---|
| 935 | + |
---|
| 936 | +static const struct rk_codec_digital_soc_data rv1106_data = { |
---|
| 937 | + .init = rv1106_soc_init, |
---|
| 938 | + .deinit = rv1106_soc_deinit, |
---|
| 939 | +}; |
---|
| 940 | + |
---|
885 | 941 | static int rv1126_soc_init(struct device *dev) |
---|
886 | 942 | { |
---|
887 | 943 | struct rk_codec_digital_priv *rcd = dev_get_drvdata(dev); |
---|
.. | .. |
---|
912 | 968 | #ifdef CONFIG_OF |
---|
913 | 969 | static const struct of_device_id rcd_of_match[] = { |
---|
914 | 970 | { .compatible = "rockchip,codec-digital-v1", }, |
---|
| 971 | +#ifdef CONFIG_CPU_RK3568 |
---|
915 | 972 | { .compatible = "rockchip,rk3568-codec-digital", .data = &rk3568_data }, |
---|
| 973 | +#endif |
---|
| 974 | +#ifdef CONFIG_CPU_RK3588 |
---|
| 975 | + { .compatible = "rockchip,rk3588-codec-digital", .data = &rk3588_data }, |
---|
| 976 | +#endif |
---|
| 977 | +#ifdef CONFIG_CPU_RV1106 |
---|
| 978 | + { .compatible = "rockchip,rv1106-codec-digital", .data = &rv1106_data }, |
---|
| 979 | +#endif |
---|
| 980 | +#ifdef CONFIG_CPU_RV1126 |
---|
916 | 981 | { .compatible = "rockchip,rv1126-codec-digital", .data = &rv1126_data }, |
---|
| 982 | +#endif |
---|
917 | 983 | {}, |
---|
918 | 984 | }; |
---|
919 | 985 | MODULE_DEVICE_TABLE(of, rcd_of_match); |
---|
.. | .. |
---|
995 | 1061 | |
---|
996 | 1062 | rcd->rc = devm_reset_control_get(&pdev->dev, "reset"); |
---|
997 | 1063 | |
---|
998 | | - rcd->clk_adc = devm_clk_get(&pdev->dev, "adc"); |
---|
| 1064 | + /* optional on some platform */ |
---|
| 1065 | + rcd->clk_adc = devm_clk_get_optional(&pdev->dev, "adc"); |
---|
999 | 1066 | if (IS_ERR(rcd->clk_adc)) |
---|
1000 | 1067 | return PTR_ERR(rcd->clk_adc); |
---|
1001 | 1068 | |
---|