Re: [RFC 0/2] gpiolib: Initial, basic support for shared GPIO lines

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

 



Hi,

On 20/11/2019 15.34, Peter Ujfalusi wrote:
> Hi,
> 
> The initial support can replace all use of GPIOD_FLAGS_BIT_NONEXCLUSIVE if the
> shared GPIO is configured to follow pass through 'strategy' for the shared GPIO
> pin.
> 
> I have only implemented DT support.
> 
> With the shared gpio support one can choose between three different strategy for
> managing the shared gpio:
> refcounted low: Keep the line low as long as there is at least one low
> 		request is registered
> refcounted high: Keep the line high as long as there is at least one high
> 		request is registered
> pass through: all requests are allowed to go through without refcounting.
> 
> Few shortcomings as of now:
> - can not handle different GPIO_ACTIVE_ on the user side, both the root GPIO
>   (which is shared) and clients must have the same GPIO_ACTIVE_ mode.
>   We are using common gpio_desc.
>   Like with GPIOD_FLAGS_BIT_NONEXCLUSIVE
> - refcounting counts _all_ 1/0 requests coming from the users of the shared
>   GPIO. This could cause issues if clients are using the gpiod API in unbalanced
>   way.
>   We would need to have separate tracking for each of the clients and agregate
>   the level they are asking for at any moment. Basically a new gpio-chip on top
>   of the real gpio pin can solve this.

I forgot to add an example for DT.

I have this for two pcm3168a codec, their RST pin is connected to
tca6416's p0 pin.
The codec's RST line is low active, so the gpio-shared is configured to
refcounted high to make sure that a codec is not placed in reset when it
does not want it.

&main_i2c3 {
	#address-cells = <1>;
	#size-cells = <0>;

	audio_exp: gpio@21 {
		compatible = "ti,tca6416";
		reg = <0x21>;
		gpio-controller;
		#gpio-cells = <2>;

		p00 {
			gpio-shared;
			gpios = <0 GPIO_ACTIVE_LOW>;
			output-high;
			refcounted-high;
			line-name = "CODEC RESET";
		};
	};

	pcm3168a_a: audio-codec@47 {
		compatible = "ti,pcm3168a";
		reg = <0x47>;
		#sound-dai-cells = <1>;

		reset-gpios = <&audio_exp 0 GPIO_ACTIVE_LOW>;
	};

	pcm3168a_b: audio-codec@46 {
		compatible = "ti,pcm3168a";
		reg = <0x46>;
		#sound-dai-cells = <1>;

		reset-gpios = <&audio_exp 0 GPIO_ACTIVE_LOW>;
	};
};


> 
> Regards,
> Peter
> ---
> Peter Ujfalusi (2):
>   dt-bindings: gpio: Document shared GPIO line usage
>   gpiolib: Support for (output only) shared GPIO line
> 
>  .../devicetree/bindings/gpio/gpio.txt         |  66 +++++++++
>  drivers/gpio/gpiolib-of.c                     |  28 +++-
>  drivers/gpio/gpiolib.c                        | 132 ++++++++++++++++--
>  drivers/gpio/gpiolib.h                        |  10 ++
>  4 files changed, 223 insertions(+), 13 deletions(-)
> 

- Péter

Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki



[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