Re: Is a multiplexer using latches a gpio controller?

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

 



On Mon, Jul 25, 2022 at 11:19:54AM +0200, Andy Shevchenko wrote:
> On Tue, Jul 19, 2022 at 9:19 AM Uwe Kleine-König
> <u.kleine-koenig@xxxxxxxxxxxxxx> wrote:
> > On Tue, Jul 19, 2022 at 12:11:56AM +0200, Andy Shevchenko wrote:
> > > On Tue, Jul 19, 2022 at 12:05 AM Andy Shevchenko
> > > <andy.shevchenko@xxxxxxxxx> wrote:
> > > > On Mon, Jul 18, 2022 at 10:27 PM Uwe Kleine-König
> > > > <u.kleine-koenig@xxxxxxxxxxxxxx> wrote:
> 
> > > > > we have a customer board here that uses two 8 port latches to drive
> > > > > LEDs. The setup looks as follows:
> > > > >
> > > > > CLK0 ----------------------.        ,--------.
> > > > > CLK1 -------------------.  `--------|>    #0 |
> > > > >                         |           |        |
> > > > > IN0 -----------------+--|-----------|D0    Q0|-----|◁
> > > > > IN1 ---------------+-|--|-----------|D1    Q1|-----|◁
> > > > > IN2 -------------+-|-|--|-----------|D2    Q2|-----|◁
> > > > > IN3 -----------+-|-|-|--|-----------|D3    Q3|-----|◁
> > > > > IN4 ---------+-|-|-|-|--|-----------|D4    Q4|-----|◁
> > > > > IN5 -------+-|-|-|-|-|--|-----------|D5    Q5|-----|◁
> > > > > IN6 -----+-|-|-|-|-|-|--|-----------|D6    Q6|-----|◁
> > > > > IN7 ---+-|-|-|-|-|-|-|--|-----------|D7    Q7|-----|◁
> > > > >        | | | | | | | |  |           `--------'
> > > > >        | | | | | | | |  |
> > > > >        | | | | | | | |  |           ,--------.
> > > > >        | | | | | | | |  `-----------|>    #1 |
> > > > >        | | | | | | | |              |        |
> > > > >        | | | | | | | `--------------|D0    Q0|-----|◁
> > > > >        | | | | | | `----------------|D1    Q1|-----|◁
> > > > >        | | | | | `------------------|D2    Q2|-----|◁
> > > > >        | | | | `--------------------|D3    Q3|-----|◁
> > > > >        | | | `----------------------|D4    Q4|-----|◁
> > > > >        | | `------------------------|D5    Q5|-----|◁
> > > > >        | `--------------------------|D6    Q6|-----|◁
> > > > >        `----------------------------|D7    Q7|-----|◁
> > > > >                                     `--------'
> > > > >
> > > > >
> > > > > So to change output 2 of latch #1 you have to apply the changed level on
> > > > > IN2, apply the previous level on the other inputs (to keep the other
> > > > > outputs constant) and toggle CLK1 once.
> > > > >
> > > > > This way you can drive 16 LEDs (or in general outputs) using only 10
> > > > > GPIOs. (And with a higher number of latches the proportion becomes a bit
> > > > > more useful.)
> > > > >
> > > > > Actually this construct is a general GPO (no input :-) controller, and I
> > > > > wonder if you would accept a driver that models it as a gpio controller.
> > > > >
> > > > > The dt binding could look as follows:
> > > > >
> > > > > latch-gpo {
> > > > >         compatible = "latch-gpo";
> > > > >         pinctrl-0 = <...>;
> > > > >         pinctrl-names = <...>;
> > > > >
> > > > >         clk-gpios = /* CLK0 */ <...>, /* CLK1 */ <...>;
> > > > >         data-gpios = /* IN0 */ <...>, /* IN1 */ <...>, ...;
> > > > > };
> > > > >
> > > > > What do you think?
> > > >
> > > > Bart, what happened to the [1]? Is it abandoned, forgotten?
> > > >
> > > > Uwe, isn't it what you need?
> > >
> > > It needs "downstream" GPIO and ->get_direction(), etc should act accordingly.
> >
> > No, IIUC this is different. With a multiplexer there can always only be
> > a single line that is controlled (or read) and the other lines are (I
> > assume) high-z.
> 
> I don't know the Linux mux framework implementation, but from a
> hardware perspective the mux is what you have. In the GPIO (mux)
> driver you need to be able to switch banks as you wish, the rest is
> the drivers' business. If gpio-cascade gives no possibility to do that
> due to broken mux in Linux, then indeed, it can't be accepted at all
> and I have to withdraw my tags from that.

I think you didn't understand what I said (or I didn't understand the
problem you describe).

The thing that is supported by gpio-mux-input is:

	CTRL  ---.  .
	          \/|
	          / |
	          | |---<-- INPUTA
	GPIO --<--| |
	          | |---<-- INPUTB
	          \ |
	           \|
	            '

This is about inputs. CTRL selects which of the inputs on the right is
forwarded to GPIO and the other lines are tristated. Theoretically you
can also drive one of the lines on the right side, but only one and only
while no other line is read.

The hardware construct I have is about outputs and there is no problem
with highz lines, all lines are always driven.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux