Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-amlogic@lists.infradead.org, linux-iio@vger.kernel.org,
	devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, gnstark@salutedevices.com,
	lars@metafoo.de, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, christianshewitt@gmail.com
Subject: Re: [RFC PATCH v1 2/2] iio: adc: meson: add support for the GXLX SoC
Date: Sat, 4 Jan 2025 13:59:12 +0000	[thread overview]
Message-ID: <20250104135912.390ec87c@jic23-huawei> (raw)
In-Reply-To: <20241231194207.2772750-3-martin.blumenstingl@googlemail.com>

On Tue, 31 Dec 2024 20:42:07 +0100
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> 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).

So IIUC this is to make some non ADC component work.
How are you handling dependencies?  The ADC driver might not be loaded or
is there some reason it definitely is at the point where the audio driver
loads?

Jonathan

> 
> 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..df15a2566ec7 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 = VREF_VOLTAGE_1V8,
> +	.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,



  reply	other threads:[~2025-01-04 14:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-31 19:42 [RFC PATCH v1 0/2] iio: adc: meson: add MPLL clock workaround for GXLX Martin Blumenstingl
2024-12-31 19:42 ` [RFC PATCH v1 1/2] dt-bindings: iio: adc: amlogic,meson-saradc: Add GXLX SoC compatible Martin Blumenstingl
2025-01-02  7:59   ` Krzysztof Kozlowski
2024-12-31 19:42 ` [RFC PATCH v1 2/2] iio: adc: meson: add support for the GXLX SoC Martin Blumenstingl
2025-01-04 13:59   ` Jonathan Cameron [this message]
2025-01-05 15:49     ` Martin Blumenstingl
2025-01-06 13:44       ` Christian Hewitt
2025-01-06 22:34   ` Martin Blumenstingl
2025-01-02  9:40 ` [RFC PATCH v1 0/2] iio: adc: meson: add MPLL clock workaround for GXLX neil.armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250104135912.390ec87c@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=christianshewitt@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gnstark@salutedevices.com \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox