devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
Cc: antoniu.miclaus@analog.com, robh+dt@kernel.org,
	krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org,
	jdelvare@suse.com, linux@roeck-us.net, linux-rtc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org,
	Ibrahim Tilki <Ibrahim.Tilki@analog.com>,
	Zeynep Arslanbenzer <Zeynep.Arslanbenzer@analog.com>
Subject: Re: [PATCH v8 1/2] rtc:  max31335: Add support for additional chips
Date: Tue, 27 Feb 2024 03:29:19 +0100	[thread overview]
Message-ID: <20240227022919856ffa1d@mail.local> (raw)
In-Reply-To: <20240227010312.3305966-2-chris.packham@alliedtelesis.co.nz>

On 27/02/2024 14:03:09+1300, Chris Packham wrote:
> -	max31335->clkout.clk = devm_clk_get_enabled(dev, NULL);
> -	if (IS_ERR(max31335->clkout.clk))
> -		return dev_err_probe(dev, PTR_ERR(max31335->clkout.clk),
> -				     "cannot enable clkout\n");

This is so ugly and should have never passed. I went weak in front of
Antoniu's insistance but I'm very close from ripping out the whole
driver from the kernel now.

Seriously, read all the comments that have been made around the IRQ/clk
stuff and come back with a proper solution.

> +static int max31335_irq_init(struct device *dev, const char *devname)
> +{
> +	struct max31335_data *max31335 = dev_get_drvdata(dev);
> +	int ret;
> +
> +	switch (max31335->id) {
> +	case ID_MAX31328:
> +		break;
> +	case ID_MAX31331:
> +	case ID_MAX31334:
> +		if (max31335->clkout.clk) {
> +			/*
> +			 * interrupt muxing depends on clkout so enable clkout
> +			 * if configured before requesting interrupt
> +			 */
> +			ret = clk_prepare_enable(max31335->clkout.clk);

Do I get this right that this is about enabling its own output clock?
Why would you need to do that? Something else must be the consumer, not
the provider itself.

> +			if (ret)
> +				return dev_err_probe(dev, ret,
> +						     "cannot enable clkout\n");
> +		}
> +		break;
> +	default:
> +		if (max31335->clkin) {
> +			if (max31335->clkout.clk && max31335->irq > 0)
> +				return dev_err_probe(dev, -EOPNOTSUPP,
> +						     "irq not possible when both clkin and clkout are configured\n");

This is not true, the RTC is always a clock provider. What is not
possible is muxing the clock on the pin in a few configurations.


-- 
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2024-02-27  2:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  1:03 [PATCH v8 0/2] drivers: rtc: add max313xx series rtc driver Chris Packham
2024-02-27  1:03 ` [PATCH v8 1/2] rtc: max31335: Add support for additional chips Chris Packham
2024-02-27  2:29   ` Alexandre Belloni [this message]
2024-02-27  4:22     ` Chris Packham
2024-02-27  1:03 ` [PATCH v8 2/2] dt-bindings: rtc: add max313xx RTCs Chris Packham
2024-02-28 11:58   ` Conor Dooley
2024-02-28 20:21     ` Chris Packham
2024-02-29 18:07       ` Conor Dooley
2024-02-29 20:11         ` Chris Packham
2024-02-29 20:29           ` Alexandre Belloni

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=20240227022919856ffa1d@mail.local \
    --to=alexandre.belloni@bootlin.com \
    --cc=Ibrahim.Tilki@analog.com \
    --cc=Zeynep.Arslanbenzer@analog.com \
    --cc=antoniu.miclaus@analog.com \
    --cc=chris.packham@alliedtelesis.co.nz \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=robh+dt@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;
as well as URLs for NNTP newsgroup(s).