Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: gpio: gpio_pca953x: Adding input latch and interrupt mask #64509

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions drivers/gpio/gpio_pca953x.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ LOG_MODULE_REGISTER(pca953x, CONFIG_GPIO_LOG_LEVEL);
#define PCA953X_INPUT_PORT 0x00
#define PCA953X_OUTPUT_PORT 0x01
#define PCA953X_CONFIGURATION 0x03
#define REG_INPUT_LATCH_PORT0 0x42
#define REG_INT_MASK_PORT0 0x45

/* Number of pins supported by the device */
#define NUM_PINS 8
Expand Down Expand Up @@ -67,6 +69,8 @@ struct pca953x_config {
struct i2c_dt_spec i2c;
const struct gpio_dt_spec gpio_int;
bool interrupt_enabled;
int interrupt_mask;
int input_latch;
};

/**
Expand Down Expand Up @@ -439,6 +443,14 @@ static int gpio_pca953x_init(const struct device *dev)

rc = gpio_add_callback(cfg->gpio_int.port,
&drv_data->gpio_cb);

/* This may not present on all variants of device */
if (cfg->input_latch > -1) {
i2c_reg_write_byte_dt(&cfg->i2c, REG_INPUT_LATCH_PORT0, cfg->input_latch);
}
if (cfg->interrupt_mask > -1) {
i2c_reg_write_byte_dt(&cfg->i2c, REG_INT_MASK_PORT0, cfg->interrupt_mask);
}
}
out:
if (rc) {
Expand Down Expand Up @@ -468,6 +480,8 @@ static const struct gpio_driver_api api_table = {
}, \
.interrupt_enabled = DT_INST_NODE_HAS_PROP(n, nint_gpios), \
.gpio_int = GPIO_DT_SPEC_INST_GET_OR(n, nint_gpios, {0}), \
.interrupt_mask = DT_INST_PROP_OR(n, interrupt_mask, -1), \
.input_latch = DT_INST_PROP_OR(n, input_latch, -1), \
}; \
\
static struct pca953x_drv_data pca953x_drvdata_##n = { \
Expand Down
14 changes: 14 additions & 0 deletions dts/bindings/gpio/ti,tca9538.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ properties:
Connection for the NINT signal. This signal is active-low when
produced by tca9538 GPIO node.

input-latch:
type: int
description: |
Input latch register bit is 0 by default and the input pin state
is not latched. When input latch register bit is 1 and the input
pin state is latched.

interrupt-mask:
type: int
description: |
Interrupt mask register is set to logic 1 by default without
enabling interrupts. Setting corresponding mask bits to logic
0 to enable the interrupts.

gpio-cells:
- pin
- flags
Loading