* [PATCH v2 1/2] dt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible
2025-03-30 10:19 [PATCH v2 0/2] iio: adc: meson: add MPLL clock workaround for GXLX Martin Blumenstingl
@ 2025-03-30 10:19 ` Martin Blumenstingl
2025-03-30 10:19 ` [PATCH v2 2/2] iio: adc: meson: add support for the GXLX SoC Martin Blumenstingl
2025-03-30 14:08 ` [PATCH v2 0/2] iio: adc: meson: add MPLL clock workaround for GXLX Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2025-03-30 10:19 UTC (permalink / raw)
To: linux-amlogic, linux-iio
Cc: devicetree, linux-arm-kernel, linux-kernel, gnstark, jic23, lars,
robh, krzk+dt, conor+dt, christianshewitt, Martin Blumenstingl,
Krzysztof Kozlowski, Neil Armstrong
Add a compatible string for the GXLX SoC. It's very similar to GXL but
has three additional bits in MESON_SAR_ADC_REG12 for the three MPLL
clocks.
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
.../devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml
index b0962a4583ac..bb9825e7346d 100644
--- a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml
+++ b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.yaml
@@ -23,6 +23,7 @@ properties:
- amlogic,meson8m2-saradc
- amlogic,meson-gxbb-saradc
- amlogic,meson-gxl-saradc
+ - amlogic,meson-gxlx-saradc
- amlogic,meson-gxm-saradc
- amlogic,meson-axg-saradc
- amlogic,meson-g12a-saradc
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH v2 2/2] iio: adc: meson: add support for the GXLX SoC
2025-03-30 10:19 [PATCH v2 0/2] iio: adc: meson: add MPLL clock workaround for GXLX Martin Blumenstingl
2025-03-30 10:19 ` [PATCH v2 1/2] dt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible Martin Blumenstingl
@ 2025-03-30 10:19 ` Martin Blumenstingl
2025-03-30 14:08 ` [PATCH v2 0/2] iio: adc: meson: add MPLL clock workaround for GXLX Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2025-03-30 10:19 UTC (permalink / raw)
To: linux-amlogic, linux-iio
Cc: devicetree, linux-arm-kernel, linux-kernel, gnstark, jic23, lars,
robh, krzk+dt, conor+dt, christianshewitt, Martin Blumenstingl,
Neil Armstrong
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>
---
drivers/iio/adc/meson_saradc.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 997def4a4d2f..c0f2a2ef0c68 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -160,6 +160,11 @@
#define MESON_SAR_ADC_REG11_EOC BIT(1)
#define MESON_SAR_ADC_REG11_VREF_SEL BIT(0)
+#define MESON_SAR_ADC_REG12 0x30
+ #define MESON_SAR_ADC_REG12_MPLL0_UNKNOWN BIT(0)
+ #define MESON_SAR_ADC_REG12_MPLL1_UNKNOWN BIT(1)
+ #define MESON_SAR_ADC_REG12_MPLL2_UNKNOWN BIT(2)
+
#define MESON_SAR_ADC_REG13 0x34
#define MESON_SAR_ADC_REG13_12BIT_CALIBRATION_MASK GENMASK(13, 8)
@@ -326,6 +331,7 @@ struct meson_sar_adc_param {
u8 cmv_select;
u8 adc_eoc;
enum meson_sar_adc_vref_sel vref_voltage;
+ bool enable_mpll_clock_workaround;
};
struct meson_sar_adc_data {
@@ -995,6 +1001,15 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev)
priv->param->cmv_select);
regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG11,
MESON_SAR_ADC_REG11_CMV_SEL, regval);
+
+ if (priv->param->enable_mpll_clock_workaround) {
+ dev_warn(dev,
+ "Enabling unknown bits to make the MPLL clocks work. This may change so always update dtbs and kernel together\n");
+ regmap_write(priv->regmap, MESON_SAR_ADC_REG12,
+ MESON_SAR_ADC_REG12_MPLL0_UNKNOWN |
+ MESON_SAR_ADC_REG12_MPLL1_UNKNOWN |
+ MESON_SAR_ADC_REG12_MPLL2_UNKNOWN);
+ }
}
ret = clk_set_parent(priv->adc_sel_clk, priv->clkin);
@@ -1219,6 +1234,17 @@ static const struct meson_sar_adc_param meson_sar_adc_gxl_param = {
.cmv_select = 1,
};
+static const struct meson_sar_adc_param meson_sar_adc_gxlx_param = {
+ .has_bl30_integration = true,
+ .clock_rate = 1200000,
+ .regmap_config = &meson_sar_adc_regmap_config_gxbb,
+ .resolution = 12,
+ .disable_ring_counter = 1,
+ .vref_voltage = 1,
+ .cmv_select = true,
+ .enable_mpll_clock_workaround = true,
+};
+
static const struct meson_sar_adc_param meson_sar_adc_axg_param = {
.has_bl30_integration = true,
.clock_rate = 1200000,
@@ -1267,6 +1293,11 @@ static const struct meson_sar_adc_data meson_sar_adc_gxl_data = {
.name = "meson-gxl-saradc",
};
+static const struct meson_sar_adc_data meson_sar_adc_gxlx_data = {
+ .param = &meson_sar_adc_gxlx_param,
+ .name = "meson-gxlx-saradc",
+};
+
static const struct meson_sar_adc_data meson_sar_adc_gxm_data = {
.param = &meson_sar_adc_gxl_param,
.name = "meson-gxm-saradc",
@@ -1298,6 +1329,9 @@ static const struct of_device_id meson_sar_adc_of_match[] = {
}, {
.compatible = "amlogic,meson-gxl-saradc",
.data = &meson_sar_adc_gxl_data,
+ }, {
+ .compatible = "amlogic,meson-gxlx-saradc",
+ .data = &meson_sar_adc_gxlx_data,
}, {
.compatible = "amlogic,meson-gxm-saradc",
.data = &meson_sar_adc_gxm_data,
--
2.49.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2 0/2] iio: adc: meson: add MPLL clock workaround for GXLX
2025-03-30 10:19 [PATCH v2 0/2] iio: adc: meson: add MPLL clock workaround for GXLX Martin Blumenstingl
2025-03-30 10:19 ` [PATCH v2 1/2] dt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible Martin Blumenstingl
2025-03-30 10:19 ` [PATCH v2 2/2] iio: adc: meson: add support for the GXLX SoC Martin Blumenstingl
@ 2025-03-30 14:08 ` Jonathan Cameron
2 siblings, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2025-03-30 14:08 UTC (permalink / raw)
To: Martin Blumenstingl
Cc: linux-amlogic, linux-iio, devicetree, linux-arm-kernel,
linux-kernel, gnstark, lars, robh, krzk+dt, conor+dt,
christianshewitt
On Sun, 30 Mar 2025 12:19:20 +0200
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:
> Hello,
>
> Amlogic GXLX SoCs seem to be mostly the same silicon as GXL. The only
> known differences are:
> - one less Mali-450 GPU core
> - no VP9 codec
> - and an odd one: the three MPLL clocks need a bit toggled in the SAR
> ADC register space
>
> This series attempt to fix audio output (which relies on the MPLL
> clocks) on the GXLX boards. Unfortunately all we have is a downstream
> commit [0] without any further explanation (or anyone who wants to
> provide details on this). Since it's not clear if this is a gate, a
> reset or some other hardware fix: the driver side includes a warning
> for users to update their .dtb along with kernel images in case we
> ever figure out what these bits do and how to model them properly.
Applied to the togreg branch of iio.git. Initially pushed out as testing
to get some early testing before I rebase on rc1 next weekend.
Thanks,
Jonathan
>
>
> Changes since v1 at [1]:
> - added Krzysztof's Acked-by to the dt-bindings patch (thank you)
> - added Neil's Reviewed-by (thank you!)
> - fixed meson_sar_adc_gxlx_param to be independent of future
> to-be-upstreamed patches (fixes a build error)
>
>
> [0] https://github.com/khadas/linux/commit/d1d98f2ed8c83eb42af8880ed8e206aa402dd70a#diff-c5aaf54323ef93777c5083de37f933058ea8d0af79a1941e0b5a0667dc0f89b3
> [1] https://lore.kernel.org/linux-amlogic/20241231194207.2772750-1-martin.blumenstingl@googlemail.com/
>
>
> Martin Blumenstingl (2):
> dt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible
> iio: adc: meson: add support for the GXLX SoC
>
> .../iio/adc/amlogic,meson-saradc.yaml | 1 +
> drivers/iio/adc/meson_saradc.c | 34 +++++++++++++++++++
> 2 files changed, 35 insertions(+)
>
^ permalink raw reply [flat|nested] 4+ messages in thread