Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: sta350: add support for bits in miscellaneous registers

Add support for RPDNEN, NSHHPEN, BRIDGOFF, CPWMEN and PNDLSL, and add DT
bindings to access them.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>

authored by

Daniel Mack and committed by
Mark Brown
7c2fcccc 09af62ff

+82
+22
Documentation/devicetree/bindings/sound/st,sta350.txt
··· 86 86 - st,invalid-input-detect-mute: 87 87 If present, automatic invalid input detect mute is enabled. 88 88 89 + - st,activate-mute-output: 90 + If present, a mute output will be activated in ase the volume will 91 + reach a value lower than -76 dBFS. 89 92 93 + - st,bridge-immediate-off: 94 + If present, the bridge will be switched off immediately after the 95 + power-down-gpio goes low. Otherwise, the bridge will wait for 13 96 + million clock cycles to pass before shutting down. 97 + 98 + - st,noise-shape-dc-cut: 99 + If present, the noise-shaping technique on the DC cutoff filter are 100 + enabled. 101 + 102 + - st,powerdown-master-volume: 103 + If present, the power-down pin and I2C power-down functions will 104 + act on the master volume. Otherwise, the functions will act on the 105 + mute commands. 106 + 107 + - st,powerdown-delay-divider: 108 + If present, the bridge power-down time will be divided by the provided 109 + value. If not specified, a divider of 1 will be used. Allowed values 110 + are 1, 2, 4, 8, 16, 32, 64 and 128. 111 + This property has to be specified as '/bits/ 8' value. 90 112 91 113 Example: 92 114
+5
include/sound/sta350.h
··· 37 37 u8 ch3_output_mapping; 38 38 u8 ffx_power_output_mode; 39 39 u8 drop_compensation_ns; 40 + u8 powerdown_delay_divider; 40 41 unsigned int thermal_warning_recovery:1; 41 42 unsigned int thermal_warning_adjustment:1; 42 43 unsigned int fault_detect_recovery:1; ··· 48 47 unsigned int odd_pwm_speed_mode:1; 49 48 unsigned int distortion_compensation:1; 50 49 unsigned int invalid_input_detect_mute:1; 50 + unsigned int activate_mute_output:1; 51 + unsigned int bridge_immediate_off:1; 52 + unsigned int noise_shape_dc_cut:1; 53 + unsigned int powerdown_master_vol:1; 51 54 }; 52 55 53 56 #endif /* __LINUX_SND__STA350_H */
+45
sound/soc/codecs/sta350.c
··· 1020 1020 pdata->ch3_output_mapping 1021 1021 << STA350_CxCFG_OM_SHIFT); 1022 1022 1023 + /* miscellaneous registers */ 1024 + regmap_update_bits(sta350->regmap, STA350_MISC1, 1025 + STA350_MISC1_CPWMEN, 1026 + pdata->activate_mute_output ? 1027 + STA350_MISC1_CPWMEN : 0); 1028 + regmap_update_bits(sta350->regmap, STA350_MISC1, 1029 + STA350_MISC1_BRIDGOFF, 1030 + pdata->bridge_immediate_off ? 1031 + STA350_MISC1_BRIDGOFF : 0); 1032 + regmap_update_bits(sta350->regmap, STA350_MISC1, 1033 + STA350_MISC1_NSHHPEN, 1034 + pdata->noise_shape_dc_cut ? 1035 + STA350_MISC1_NSHHPEN : 0); 1036 + regmap_update_bits(sta350->regmap, STA350_MISC1, 1037 + STA350_MISC1_RPDNEN, 1038 + pdata->powerdown_master_vol ? 1039 + STA350_MISC1_RPDNEN: 0); 1040 + 1041 + regmap_update_bits(sta350->regmap, STA350_MISC2, 1042 + STA350_MISC2_PNDLSL_MASK, 1043 + pdata->powerdown_delay_divider 1044 + << STA350_MISC2_PNDLSL_SHIFT); 1045 + 1023 1046 /* initialize coefficient shadow RAM with reset values */ 1024 1047 for (i = 4; i <= 49; i += 5) 1025 1048 sta350->coef_shadow[i] = 0x400000; ··· 1117 1094 struct sta350_platform_data *pdata; 1118 1095 const char *ffx_power_mode; 1119 1096 u16 tmp; 1097 + u8 tmp8; 1120 1098 1121 1099 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); 1122 1100 if (!pdata) ··· 1181 1157 /* CONFF */ 1182 1158 if (of_get_property(np, "st,invalid-input-detect-mute", NULL)) 1183 1159 pdata->invalid_input_detect_mute = 1; 1160 + 1161 + /* MISC */ 1162 + if (of_get_property(np, "st,activate-mute-output", NULL)) 1163 + pdata->activate_mute_output = 1; 1164 + 1165 + if (of_get_property(np, "st,bridge-immediate-off", NULL)) 1166 + pdata->bridge_immediate_off = 1; 1167 + 1168 + if (of_get_property(np, "st,noise-shape-dc-cut", NULL)) 1169 + pdata->noise_shape_dc_cut = 1; 1170 + 1171 + if (of_get_property(np, "st,powerdown-master-volume", NULL)) 1172 + pdata->powerdown_master_vol = 1; 1173 + 1174 + if (!of_property_read_u8(np, "st,powerdown-delay-divider", &tmp8)) { 1175 + if (is_power_of_2(tmp8) && tmp8 >= 1 && tmp8 <= 128) 1176 + pdata->powerdown_delay_divider = ilog2(tmp8); 1177 + else 1178 + dev_warn(dev, "Unsupported powerdown delay divider %d\n", 1179 + tmp8); 1180 + } 1184 1181 1185 1182 sta350->pdata = pdata; 1186 1183
+10
sound/soc/codecs/sta350.h
··· 225 225 #define STA350_C3_MIX1 60 226 226 #define STA350_C3_MIX2 61 227 227 228 + /* miscellaneous register 1 */ 229 + #define STA350_MISC1_CPWMEN BIT(2) 230 + #define STA350_MISC1_BRIDGOFF BIT(5) 231 + #define STA350_MISC1_NSHHPEN BIT(6) 232 + #define STA350_MISC1_RPDNEN BIT(7) 233 + 234 + /* miscellaneous register 2 */ 235 + #define STA350_MISC2_PNDLSL_MASK 0x1c 236 + #define STA350_MISC2_PNDLSL_SHIFT 2 237 + 228 238 #endif /* _ASOC_STA_350_H */