mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
synced 2026-05-02 18:17:50 -04:00
gpio: pcf857x: add support for reset-gpios on (most) PCA967x
The PCA9670, PCA9671, PCA9672 and PCA9673 all have a RESETN input pin that is used to reset the I2C GPIO expander. One needs to hold this pin low for at least 4us and the reset should be finished after about 100us according to the datasheet[1]. Once the reset is done, the "registers and I2C-bus state machine will be held in their default state until the RESET input is once again HIGH.". Because the logic is reset, the latch values eventually provided in the Device Tree via lines-initial-states property are inapplicable so they are simply ignored if a reset GPIO is provided. [1] https://www.nxp.com/docs/en/data-sheet/PCA9670.pdf 8.5 and fig 22. Tested-by: Heiko Stuebner <heiko@sntech.de> # RK3588 Tiger Haikou Video Demo Reviewed-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Link: https://lore.kernel.org/r/20250224-pca976x-reset-driver-v3-2-58370ef405be@cherry.de Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
This commit is contained in:
committed by
Bartosz Golaszewski
parent
b28037d4f3
commit
087f8a6b8c
@@ -5,6 +5,8 @@
|
||||
* Copyright (C) 2007 David Brownell
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
@@ -272,12 +274,11 @@ static const struct irq_chip pcf857x_irq_chip = {
|
||||
|
||||
static int pcf857x_probe(struct i2c_client *client)
|
||||
{
|
||||
struct gpio_desc *reset_gpio;
|
||||
struct pcf857x *gpio;
|
||||
unsigned int n_latch = 0;
|
||||
int status;
|
||||
|
||||
device_property_read_u32(&client->dev, "lines-initial-states", &n_latch);
|
||||
|
||||
/* Allocate, initialize, and register this gpio_chip. */
|
||||
gpio = devm_kzalloc(&client->dev, sizeof(*gpio), GFP_KERNEL);
|
||||
if (!gpio)
|
||||
@@ -297,6 +298,30 @@ static int pcf857x_probe(struct i2c_client *client)
|
||||
gpio->chip.direction_output = pcf857x_output;
|
||||
gpio->chip.ngpio = (uintptr_t)i2c_get_match_data(client);
|
||||
|
||||
reset_gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
|
||||
if (IS_ERR(reset_gpio))
|
||||
return dev_err_probe(&client->dev, PTR_ERR(reset_gpio),
|
||||
"failed to get reset GPIO\n");
|
||||
|
||||
if (reset_gpio) {
|
||||
/* Reset already held with devm_gpiod_get_optional with GPIOD_OUT_HIGH */
|
||||
fsleep(4); /* tw(rst) > 4us */
|
||||
gpiod_set_value_cansleep(reset_gpio, 0);
|
||||
fsleep(100); /* trst > 100uS */
|
||||
|
||||
/*
|
||||
* Performing a reset means "The PCA9670 registers and I2C-bus
|
||||
* state machine will be held in their default state until the
|
||||
* RESET input is once again HIGH".
|
||||
*
|
||||
* This is the same as writing 1 for all pins, which is the same
|
||||
* as n_latch=0, the default value of the variable.
|
||||
*/
|
||||
} else {
|
||||
device_property_read_u32(&client->dev, "lines-initial-states",
|
||||
&n_latch);
|
||||
}
|
||||
|
||||
/* NOTE: the OnSemi jlc1562b is also largely compatible with
|
||||
* these parts, notably for output. It has a low-resolution
|
||||
* DAC instead of pin change IRQs; and its inputs can be the
|
||||
|
||||
Reference in New Issue
Block a user