Commit c923d500 authored by Christoph Niedermaier's avatar Christoph Niedermaier Committed by Lee Jones

mfd: da9062: Remove IRQ requirement

This patch removes the requirement for an IRQ, because for the core
functionality IRQ isn't needed. So this makes the DA9061/62 chip
usable for designs which haven't connected the IRQ pin.
Signed-off-by: default avatarChristoph Niedermaier <cniedermaier@dh-electronics.com>
Acked-by: default avatarAdam Ward <DLG-Adam.Ward.opensource@dm.renesas.com>
Signed-off-by: default avatarLee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230309092254.56279-2-cniedermaier@dh-electronics.com
parent 7d61f631
...@@ -181,7 +181,7 @@ static const struct resource da9061_onkey_resources[] = { ...@@ -181,7 +181,7 @@ static const struct resource da9061_onkey_resources[] = {
DEFINE_RES_IRQ_NAMED(DA9061_IRQ_ONKEY, "ONKEY"), DEFINE_RES_IRQ_NAMED(DA9061_IRQ_ONKEY, "ONKEY"),
}; };
static const struct mfd_cell da9061_devs[] = { static const struct mfd_cell da9061_devs_irq[] = {
MFD_CELL_OF("da9061-core", da9061_core_resources, NULL, 0, 0, MFD_CELL_OF("da9061-core", da9061_core_resources, NULL, 0, 0,
NULL), NULL),
MFD_CELL_OF("da9062-regulators", da9061_regulators_resources, NULL, 0, 0, MFD_CELL_OF("da9062-regulators", da9061_regulators_resources, NULL, 0, 0,
...@@ -194,6 +194,14 @@ static const struct mfd_cell da9061_devs[] = { ...@@ -194,6 +194,14 @@ static const struct mfd_cell da9061_devs[] = {
"dlg,da9061-onkey"), "dlg,da9061-onkey"),
}; };
static const struct mfd_cell da9061_devs_noirq[] = {
MFD_CELL_OF("da9061-core", NULL, NULL, 0, 0, NULL),
MFD_CELL_OF("da9062-regulators", NULL, NULL, 0, 0, NULL),
MFD_CELL_OF("da9061-watchdog", NULL, NULL, 0, 0, "dlg,da9061-watchdog"),
MFD_CELL_OF("da9061-thermal", NULL, NULL, 0, 0, "dlg,da9061-thermal"),
MFD_CELL_OF("da9061-onkey", NULL, NULL, 0, 0, "dlg,da9061-onkey"),
};
static const struct resource da9062_core_resources[] = { static const struct resource da9062_core_resources[] = {
DEFINE_RES_NAMED(DA9062_IRQ_VDD_WARN, 1, "VDD_WARN", IORESOURCE_IRQ), DEFINE_RES_NAMED(DA9062_IRQ_VDD_WARN, 1, "VDD_WARN", IORESOURCE_IRQ),
}; };
...@@ -227,7 +235,7 @@ static const struct resource da9062_gpio_resources[] = { ...@@ -227,7 +235,7 @@ static const struct resource da9062_gpio_resources[] = {
DEFINE_RES_NAMED(DA9062_IRQ_GPI4, 1, "GPI4", IORESOURCE_IRQ), DEFINE_RES_NAMED(DA9062_IRQ_GPI4, 1, "GPI4", IORESOURCE_IRQ),
}; };
static const struct mfd_cell da9062_devs[] = { static const struct mfd_cell da9062_devs_irq[] = {
MFD_CELL_OF("da9062-core", da9062_core_resources, NULL, 0, 0, MFD_CELL_OF("da9062-core", da9062_core_resources, NULL, 0, 0,
NULL), NULL),
MFD_CELL_OF("da9062-regulators", da9062_regulators_resources, NULL, 0, 0, MFD_CELL_OF("da9062-regulators", da9062_regulators_resources, NULL, 0, 0,
...@@ -244,6 +252,16 @@ static const struct mfd_cell da9062_devs[] = { ...@@ -244,6 +252,16 @@ static const struct mfd_cell da9062_devs[] = {
"dlg,da9062-gpio"), "dlg,da9062-gpio"),
}; };
static const struct mfd_cell da9062_devs_noirq[] = {
MFD_CELL_OF("da9062-core", NULL, NULL, 0, 0, NULL),
MFD_CELL_OF("da9062-regulators", NULL, NULL, 0, 0, NULL),
MFD_CELL_OF("da9062-watchdog", NULL, NULL, 0, 0, "dlg,da9062-watchdog"),
MFD_CELL_OF("da9062-thermal", NULL, NULL, 0, 0, "dlg,da9062-thermal"),
MFD_CELL_OF("da9062-rtc", NULL, NULL, 0, 0, "dlg,da9062-rtc"),
MFD_CELL_OF("da9062-onkey", NULL, NULL, 0, 0, "dlg,da9062-onkey"),
MFD_CELL_OF("da9062-gpio", NULL, NULL, 0, 0, "dlg,da9062-gpio"),
};
static int da9062_clear_fault_log(struct da9062 *chip) static int da9062_clear_fault_log(struct da9062 *chip)
{ {
int ret; int ret;
...@@ -581,7 +599,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c) ...@@ -581,7 +599,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
{ {
const struct i2c_device_id *id = i2c_client_get_device_id(i2c); const struct i2c_device_id *id = i2c_client_get_device_id(i2c);
struct da9062 *chip; struct da9062 *chip;
unsigned int irq_base; unsigned int irq_base = 0;
const struct mfd_cell *cell; const struct mfd_cell *cell;
const struct regmap_irq_chip *irq_chip; const struct regmap_irq_chip *irq_chip;
const struct regmap_config *config; const struct regmap_config *config;
...@@ -601,22 +619,16 @@ static int da9062_i2c_probe(struct i2c_client *i2c) ...@@ -601,22 +619,16 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, chip); i2c_set_clientdata(i2c, chip);
chip->dev = &i2c->dev; chip->dev = &i2c->dev;
if (!i2c->irq) { /* Start with a base configuration without IRQ */
dev_err(chip->dev, "No IRQ configured\n");
return -EINVAL;
}
switch (chip->chip_type) { switch (chip->chip_type) {
case COMPAT_TYPE_DA9061: case COMPAT_TYPE_DA9061:
cell = da9061_devs; cell = da9061_devs_noirq;
cell_num = ARRAY_SIZE(da9061_devs); cell_num = ARRAY_SIZE(da9061_devs_noirq);
irq_chip = &da9061_irq_chip;
config = &da9061_regmap_config; config = &da9061_regmap_config;
break; break;
case COMPAT_TYPE_DA9062: case COMPAT_TYPE_DA9062:
cell = da9062_devs; cell = da9062_devs_noirq;
cell_num = ARRAY_SIZE(da9062_devs); cell_num = ARRAY_SIZE(da9062_devs_noirq);
irq_chip = &da9062_irq_chip;
config = &da9062_regmap_config; config = &da9062_regmap_config;
break; break;
default: default:
...@@ -651,6 +663,18 @@ static int da9062_i2c_probe(struct i2c_client *i2c) ...@@ -651,6 +663,18 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
if (ret) if (ret)
return ret; return ret;
/* If IRQ is available, reconfigure it accordingly */
if (i2c->irq) {
if (chip->chip_type == COMPAT_TYPE_DA9061) {
cell = da9061_devs_irq;
cell_num = ARRAY_SIZE(da9061_devs_irq);
irq_chip = &da9061_irq_chip;
} else {
cell = da9062_devs_irq;
cell_num = ARRAY_SIZE(da9062_devs_irq);
irq_chip = &da9062_irq_chip;
}
ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type); ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type);
if (ret < 0) { if (ret < 0) {
dev_err(chip->dev, "Failed to configure IRQ type\n"); dev_err(chip->dev, "Failed to configure IRQ type\n");
...@@ -667,12 +691,14 @@ static int da9062_i2c_probe(struct i2c_client *i2c) ...@@ -667,12 +691,14 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
} }
irq_base = regmap_irq_chip_get_base(chip->regmap_irq); irq_base = regmap_irq_chip_get_base(chip->regmap_irq);
}
ret = mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, cell, ret = mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, cell,
cell_num, NULL, irq_base, cell_num, NULL, irq_base,
NULL); NULL);
if (ret) { if (ret) {
dev_err(chip->dev, "Cannot register child devices\n"); dev_err(chip->dev, "Cannot register child devices\n");
if (i2c->irq)
regmap_del_irq_chip(i2c->irq, chip->regmap_irq); regmap_del_irq_chip(i2c->irq, chip->regmap_irq);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment