linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.cirrus.com>
To: Marc Zyngier <maz@kernel.org>
Cc: Mark Brown <broonie@kernel.org>,
	Richard Fitzgerald <rf@opensource.cirrus.com>, <lee@kernel.org>,
	<robh+dt@kernel.org>, <krzysztof.kozlowski+dt@linaro.org>,
	<linus.walleij@linaro.org>, <tglx@linutronix.de>,
	<alsa-devel@alsa-project.org>, <devicetree@vger.kernel.org>,
	<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<patches@opensource.cirrus.com>
Subject: Re: [PATCH 09/12] irqchip: cirrus: Add driver for Cirrus Logic CS48L31/32/33 codecs
Date: Fri, 11 Nov 2022 11:16:11 +0000	[thread overview]
Message-ID: <20221111111611.GH10437@ediswmail.ad.cirrus.com> (raw)
In-Reply-To: <87h6z5vs39.wl-maz@kernel.org>

On Fri, Nov 11, 2022 at 08:00:10AM +0000, Marc Zyngier wrote:
> On Thu, 10 Nov 2022 20:36:16 +0000,
> Mark Brown <broonie@kernel.org> wrote:
> > On Thu, Nov 10, 2022 at 06:47:20PM +0000, Marc Zyngier wrote:

Apologies this ended up getting quite long. Cirrus has no trouble
changing how the IRQ driver works I just think we are struggling a
little to understand exactly what parts of the code need reworking
in what way, we appreciate your patience in helping us through.

> > > If you were implementing an actual interrupt controller driver, I'd
> > > take it without any question. The fact that this code mandates
> > > the use of its own homegrown API rules it out.

I think this is part of the crossed wires here, the code does not
mandate the use of its own home grown API, although it does
provide one. For example our CODECs often provide GPIO/IRQ
services for other devices such as say speaker amps attached
along side them.

Here is a DT example from one of my dev systems with GPIO1 on
cs47l35 (a madera CODEC) handling the IRQ for cs35l35 (a speaker
amp):

cs35l35_left: cs35l35@40 {
	compatible = "cirrus,cs35l35";
	reg = <0x40>;

	#sound-dai-cells = <1>;

	reset-gpios = <&axi_gpio0 0 0>;

	interrupt-parent = <&cs47l35>;
	interrupts = <57 0>;
};

No special code is required in the cs35l35 driver (it is fully
upstreamed sound/soc/codecs/cs35l35.c). So if we are missing some
actual interrupt controller API we need to be supporting that we
are not please point us at it and we will happily add support?

So I think your objections are mostly regarding the
cs48l32_request_irq function (and friends) that are being
used by the other parts of the MFD.  I don't think it would be super
hard to remove these functions and move the IRQ into DT if that is
the preferred way.

> > ACPI gets to be a lot of fun here, it's just not idiomatic to describe
> > the internals of these devices in firmware there and a lot of the
> > systems shipping this stuff are targeted at other OSs and system
> > integrators are therefore not in the least worried about Linux
> > preferences.

I would echo Mark's statement that going the way of moving this
into DT/ACPI will actually likely necessitate the addition of a
lot of "board file" stuff in the future. If the part gets used in
any ACPI systems (granted support is not in yet but this is not a
super unlikely addition in the future for cs48l32) we will need to
support the laptops containing the part in Linux and the vendors are
extremely unlikely to put internal CODEC IRQs into the ACPI tables.

But that aside I guess my main question about this approach would
be what the DT binding would look like for the CODEC. Currently
our devices use a single DT node for the device. Again pulling a
Madera example from my dev setup, this is what the DT binding for
one of our CODECs currently looks vaguely like:

cs47l35: cs47l35@1 {
	compatible = "cirrus,cs47l35";
	reg = <0x1>;

	spi-max-frequency = <11000000>;

	interrupt-controller;
	#interrupt-cells = <2>;
	interrupt-parent = <&gpio0>;
	interrupts = <56 8>;

	gpio-controller;
	#gpio-cells = <2>;

	#sound-dai-cells = <1>;

	AVDD-supply = <&lochnagar_vdd1v8>;
	DBVDD1-supply = <&lochnagar_vdd1v8>;
	DBVDD2-supply = <&lochnagar_vdd1v8>;
	CPVDD1-supply = <&lochnagar_vdd1v8>;
	CPVDD2-supply = <&lochnagar_vddcore>;
	DCVDD-supply = <&lochnagar_vddcore>;
	SPKVDD-supply = <&wallvdd>;

	reset-gpios = <&lochnagar_pin 0 0>;

	clocks = <&lochnagar_clk LOCHNAGAR_CDC_MCLK1>, <&lochnagar_clk LOCHNAGAR_CDC_MCLK2>;
	clock-names = "mclk1", "mclk2";

	pinctrl-names = "default";
	pinctrl-0 = <&cs47l35_defaults>;
};

The interrupt-parent points at who our IRQ is connected to, and
we are an interrupt-controller so people can use our IRQs. I
think it is not currently supported to have more than a single
interrupt-parent for a device so with the current binding is it
actually possible for the device to refer to its own IRQs in DT?

An alternative approach would be to actually represent the MFD in
device tree, I think this would allow things to work and look
something like (totally not tested just for discussion):

cs47l35: cs47l35@1 {
	compatible = "cirrus,cs47l35";
	reg = <0x1>;

	spi-max-frequency = <11000000>;

	irq: madera-irq {
		compatible = "cirrus,madera-irq";

		interrupt-controller;
		#interrupt-cells = <2>;
		interrupt-parent = <&gpio0>;
		interrupts = <56 8>;
	};

	gpio: madera-gpio {
		compatible = "cirrus,madera-gpio";
		gpio-controller;
		#gpio-cells = <2>;
	};

	sound: madera-sound {
		compatible = "cirrus,cs47l35-sound";

		interrupt-parent = <&madera-irq>;
		interrupts = <55 0>, <56 0>;
		#sound-dai-cells = <1>;
	};
};

Historically I believe we have been discouraged (by upstream, not
from our customers) from explicitly representing the parts of the
MFD in device tree separately, as it was viewed that this is just
an external SPI CODEC and one node mapped much more logically to the
hardware, which is what DT should be describing. However, are you
saying this would be a preferrable approach from your side?  Or am
I missing some alternative solution?

Again thank you kindly for you time looking at this.

Thanks,
Charles

  reply	other threads:[~2022-11-11 11:16 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 16:53 [PATCH 00/12] Add support for the Cirrus Logic CS48L32 audio codecs Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 01/12] dt-bindings: mfd: Add Cirrus Logic CS48L32 audio codec Richard Fitzgerald
2022-11-09 21:09   ` Rob Herring
2022-11-14  8:36   ` Krzysztof Kozlowski
2022-11-09 16:53 ` [PATCH 02/12] mfd: cs48l32: Add register definitions for Cirrus Logic CS48L31/32/33 Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 03/12] mfd: cs48l32: Add support for CS48L31/32/33 codecs Richard Fitzgerald
2022-11-11 23:07   ` kernel test robot
2022-11-16 15:43   ` Lee Jones
2022-11-09 16:53 ` [PATCH 04/12] dt-bindings: pinctrl: Add Cirrus Logic CS48L31/32/33 Richard Fitzgerald
2022-11-09 21:09   ` Rob Herring
2022-11-14  8:39   ` Krzysztof Kozlowski
2022-11-09 16:53 ` [PATCH 05/12] pinctrl: cirrus: Add support for CS48L31/32/33 codecs Richard Fitzgerald
2022-11-10 10:02   ` Linus Walleij
2022-11-10 10:55     ` Richard Fitzgerald
2022-11-12 21:01   ` kernel test robot
2022-11-09 16:53 ` [PATCH 06/12] regulator: arizona-micsupp: Don't hardcode use of ARIZONA defines Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 07/12] regulator: arizona-micsupp: Don't use a common regulator name Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 08/12] regulator: arizona-micsupp: Support Cirrus Logic CS48L31/32/33 Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 09/12] irqchip: cirrus: Add driver for Cirrus Logic CS48L31/32/33 codecs Richard Fitzgerald
2022-11-10  8:02   ` Marc Zyngier
2022-11-10 11:22     ` Richard Fitzgerald
2022-11-10 12:01       ` Marc Zyngier
2022-11-10 13:00         ` Richard Fitzgerald
2022-11-10 15:13           ` Marc Zyngier
2022-11-10 16:31             ` Richard Fitzgerald
2022-11-10 16:55               ` Mark Brown
2022-11-10 18:47               ` Marc Zyngier
2022-11-10 20:36                 ` Mark Brown
2022-11-11  8:00                   ` Marc Zyngier
2022-11-11 11:16                     ` Charles Keepax [this message]
2022-11-11 11:49                       ` Mark Brown
2022-11-11 13:01                         ` Charles Keepax
2022-11-11 13:00                       ` Charles Keepax
2022-11-16 16:44                     ` Mark Brown
2022-11-10 13:14         ` Richard Fitzgerald
2022-11-10 15:40           ` Marc Zyngier
2022-11-10 13:01       ` Mark Brown
2022-11-09 16:53 ` [PATCH 10/12] ASoC: wm_adsp: Allow client to hook into pre_run callback Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 11/12] dt-bindings: sound: Add Cirrus Logic CS48L31/32/33 codecs Richard Fitzgerald
2022-11-09 21:09   ` Rob Herring
2022-11-14  8:45   ` Krzysztof Kozlowski
2022-11-14 11:00     ` Richard Fitzgerald
2022-11-14 11:03       ` Krzysztof Kozlowski
2022-11-14 12:34         ` Richard Fitzgerald
2022-11-09 16:53 ` [PATCH 12/12] ASoC: cs48l32: Add codec driver for Cirrus Logic CS48L31/32/33 Richard Fitzgerald
2022-11-10 20:20   ` kernel test robot
2022-11-10 20:53 ` [PATCH 00/12] Add support for the Cirrus Logic CS48L32 audio codecs Mark Brown
2022-11-11 13:50   ` Richard Fitzgerald
2022-11-23 13:11 ` (subset) " Mark Brown

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=20221111111611.GH10437@ediswmail.ad.cirrus.com \
    --to=ckeepax@opensource.cirrus.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=rf@opensource.cirrus.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    /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).