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

iio: adc: meson: add support for the GXLX SoC

The SARADC IP on the GXLX SoC itself is identical to the one found on
GXL SoCs. However, GXLX SoCs require poking the first three bits in the
MESON_SAR_ADC_REG12 register to get the three MPLL clocks (used as clock
generators for the audio frequencies) to work.

The reason why there are MPLL clock bits in the ADC register space is
entirely unknown and it seems that nobody is able to comment on this.
So clearly mark this as a workaround and add a warning so users are
notified that this workaround can change (once we know what these bits
actually do).

Tested-by: Christian Hewitt <christianshewitt@gmail.com>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Link: https://patch.msgid.link/20250330101922.1942169-3-martin.blumenstingl@googlemail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Martin Blumenstingl and committed by
Jonathan Cameron
c6316e19 b2729cdf

+34
+34
drivers/iio/adc/meson_saradc.c
··· 160 160 #define MESON_SAR_ADC_REG11_EOC BIT(1) 161 161 #define MESON_SAR_ADC_REG11_VREF_SEL BIT(0) 162 162 163 + #define MESON_SAR_ADC_REG12 0x30 164 + #define MESON_SAR_ADC_REG12_MPLL0_UNKNOWN BIT(0) 165 + #define MESON_SAR_ADC_REG12_MPLL1_UNKNOWN BIT(1) 166 + #define MESON_SAR_ADC_REG12_MPLL2_UNKNOWN BIT(2) 167 + 163 168 #define MESON_SAR_ADC_REG13 0x34 164 169 #define MESON_SAR_ADC_REG13_12BIT_CALIBRATION_MASK GENMASK(13, 8) 165 170 ··· 331 326 u8 cmv_select; 332 327 u8 adc_eoc; 333 328 enum meson_sar_adc_vref_sel vref_voltage; 329 + bool enable_mpll_clock_workaround; 334 330 }; 335 331 336 332 struct meson_sar_adc_data { ··· 1001 995 priv->param->cmv_select); 1002 996 regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11, 1003 997 MESON_SAR_ADC_REG11_CMV_SEL, regval); 998 + 999 + if (priv->param->enable_mpll_clock_workaround) { 1000 + dev_warn(dev, 1001 + "Enabling unknown bits to make the MPLL clocks work. This may change so always update dtbs and kernel together\n"); 1002 + regmap_write(priv->regmap, MESON_SAR_ADC_REG12, 1003 + MESON_SAR_ADC_REG12_MPLL0_UNKNOWN | 1004 + MESON_SAR_ADC_REG12_MPLL1_UNKNOWN | 1005 + MESON_SAR_ADC_REG12_MPLL2_UNKNOWN); 1006 + } 1004 1007 } 1005 1008 1006 1009 ret = clk_set_parent(priv->adc_sel_clk, priv->clkin); ··· 1234 1219 .cmv_select = 1, 1235 1220 }; 1236 1221 1222 + static const struct meson_sar_adc_param meson_sar_adc_gxlx_param = { 1223 + .has_bl30_integration = true, 1224 + .clock_rate = 1200000, 1225 + .regmap_config = &meson_sar_adc_regmap_config_gxbb, 1226 + .resolution = 12, 1227 + .disable_ring_counter = 1, 1228 + .vref_voltage = 1, 1229 + .cmv_select = true, 1230 + .enable_mpll_clock_workaround = true, 1231 + }; 1232 + 1237 1233 static const struct meson_sar_adc_param meson_sar_adc_axg_param = { 1238 1234 .has_bl30_integration = true, 1239 1235 .clock_rate = 1200000, ··· 1293 1267 .name = "meson-gxl-saradc", 1294 1268 }; 1295 1269 1270 + static const struct meson_sar_adc_data meson_sar_adc_gxlx_data = { 1271 + .param = &meson_sar_adc_gxlx_param, 1272 + .name = "meson-gxlx-saradc", 1273 + }; 1274 + 1296 1275 static const struct meson_sar_adc_data meson_sar_adc_gxm_data = { 1297 1276 .param = &meson_sar_adc_gxl_param, 1298 1277 .name = "meson-gxm-saradc", ··· 1329 1298 }, { 1330 1299 .compatible = "amlogic,meson-gxl-saradc", 1331 1300 .data = &meson_sar_adc_gxl_data, 1301 + }, { 1302 + .compatible = "amlogic,meson-gxlx-saradc", 1303 + .data = &meson_sar_adc_gxlx_data, 1332 1304 }, { 1333 1305 .compatible = "amlogic,meson-gxm-saradc", 1334 1306 .data = &meson_sar_adc_gxm_data,