drivers/ioexpander/icjx: add option to set filters during initialization

This adds filters field to icjx_config_s structure that is passed
as an argument in icjx_initialize function. This field allows to
configure I/O filters (control world 1 and 3) with three possible
filters or disable them at all.

The filter configuration is currently only configurable during the
initialization, not at run time (the same as current source)

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc
2025-04-23 15:06:29 +02:00
committed by Alan C. Assis
parent 4a8af202c6
commit 8832136b69
3 changed files with 35 additions and 5 deletions
+21 -5
View File
@@ -1084,31 +1084,47 @@ FAR struct ioexpander_dev_s *icjx_initialize(FAR struct spi_dev_s *spi,
ret = icjx_write(priv, ICJX_CTRL_WORD_2_A, regval, ICJX_NOB1);
if (ret < 0)
{
gpioerr("ERROR: Could write to ICJX_CTRL_WORD_2_A: %d!\n", ret);
gpioerr("ERROR: Couldn't write to ICJX_CTRL_WORD_2_A: %d!\n", ret);
goto err;
}
ret = icjx_write(priv, ICJX_CTRL_WORD_2_B, regval, ICJX_NOB1);
if (ret < 0)
{
gpioerr("ERROR: Could write to ICJX_CTRL_WORD_2_B: %d!\n", ret);
gpioerr("ERROR: Couldn't write to ICJX_CTRL_WORD_2_B: %d!\n", ret);
goto err;
}
/* Bypass filters as those are not yet supported. */
regval = ICJX_CTRL_WORD_1_BYP0 | ICJX_CTRL_WORD_1_BYP1;
if (config->filters != ICJX_CTRL_WORD_FILTER_DISABLED)
{
regval = ICJX_CTRL_WORD_3_ICLK;
}
else
{
regval = ICJX_CTRL_WORD_3_DIS;
}
ret = icjx_write(priv, ICJX_CTRL_WORD_3_B, regval, ICJX_NOB1);
if (ret < 0)
{
gpioerr("ERROR: Couldn't write to ICJX_CTRL_WORD_3_B: %d!\n", ret);
goto err;
}
regval = (config->filters << 4) | config->filters;
ret = icjx_write(priv, ICJX_CTRL_WORD_1_A, regval, ICJX_NOB1);
if (ret < 0)
{
gpioerr("ERROR: Could write to ICJX_CTRL_WORD_1_A: %d!\n", ret);
gpioerr("ERROR: Couldn't write to ICJX_CTRL_WORD_1_A: %d!\n", ret);
goto err;
}
ret = icjx_write(priv, ICJX_CTRL_WORD_1_B, regval, ICJX_NOB1);
if (ret < 0)
{
gpioerr("ERROR: Could write to ICJX_CTRL_WORD_1_B: %d!\n", ret);
gpioerr("ERROR: Couldn't write to ICJX_CTRL_WORD_1_B: %d!\n", ret);
goto err;
}
+5
View File
@@ -100,6 +100,11 @@
#define ICJX_CTRL_WORD_2_NIOL (1 << 3)
#define ICJX_CTRL_WORD_2_NIOH (1 << 7)
/* Control Word 3 */
#define ICJX_CTRL_WORD_3_ICLK (1 << 2)
#define ICJX_CTRL_WORD_3_DIS (1 << 3)
/* Control Word 4 */
#define ICJX_CTRL_WORD_4_EOI (1 << 7)