Re: [PATCH v4 3/3] pinctrl: mcp23s08: add open drain configuration for irq output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On středa 21. února 2018 8:11:25 CET, Alexander Stein wrote:
Well, that is the exact situation on the board I had to deal with. The MCP was attached to a transisitor inverting the signal. The output on MCP has to be push-pull as there was no pull-up oder -down. But the line connecting the inverter to the CPU was an open-drain one and this line was actually a shared IRQ line. So of course the line bewteen MCP and inverter cannot be shared, but the IRQ used on CPU is actually shared. How can this be respresented in DT?

What I propose is to have it like this:

	gpio@1 {
		compatible = "microchip,mcp23s17";
		irq-active-high;
		interrupt-parent = <&gpio0>;
		interrupts = <123 IRQ_TYPE_LEVEL_LOW>;
		// ...
	};

In other words, the "interrupt-parent" and "interrupts" DT statements specify how the upstream interrupt controller should be set up, while other properties define settings of the IRQ source.

But as Phil points out, such a change would break the DT ABI. This means that we should preserve the semantics of any existing DT. We can do that by introducing another property. Here's a rough sketch:

#define MCP23S08_IRQ_OPEN_DRAIN 1
#define MCP23S08_IRQ_PUSH_PULL_ACTIVE_LOW 2
#define MCP23S08_IRQ_PUSH_PULL_ACTIVE_HIGH 3

	irqflags = IRQF_SHARED | IRQF_ONESHOT;

	if (new_irq_mode != -1) {
		/* irqflags are only set to IRQF_SHARED | IRQF_ONESHOT,
		nothing else */
	} else if (irq_active_high) {
		/* an existing property */
		irqflags |= IRQF_ACTIVE_HIGH;
	} else {
		irqflags |= IRQF_ACTIVE_LOW;
	}

A "new-style" DT then should look like this for your scenario with an electrical invertor:

	gpio@1 {
		compatible = "microchip,mcp23s17";
		irq-mode = MCP23S08_IRQ_PUSH_PULL_ACTIVE_HIGH;
		interrupt-parent = <&gpio0>;
		interrupts = <123 IRQ_TYPE_LEVEL_LOW>;
		// ...
	};

A downside of this approach is that it's using a custom enum, not a standard property like drive-open-drain. Pick your poison.

Cheers,
Jan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux