2023-03-07 10:20:44

by Christoph Niedermaier

[permalink] [raw]
Subject: [PATCH V3 1/3] mfd: da9062: Use MFD_CELL_OF macro

Use MFD_CELL_OF macro helper instead of plain struct properties, which makes
the code a bit shorter and to have commonly defined MFD cell attributes.

Signed-off-by: Christoph Niedermaier <[email protected]>
---
Cc: Support Opensource <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V3: - Add this patch to the series
---
drivers/mfd/da9062-core.c | 92 +++++++++++++----------------------------------
1 file changed, 24 insertions(+), 68 deletions(-)

diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c
index 40cde51e5719..9418c58c2b06 100644
--- a/drivers/mfd/da9062-core.c
+++ b/drivers/mfd/da9062-core.c
@@ -182,34 +182,16 @@ static const struct resource da9061_onkey_resources[] = {
};

static const struct mfd_cell da9061_devs[] = {
- {
- .name = "da9061-core",
- .num_resources = ARRAY_SIZE(da9061_core_resources),
- .resources = da9061_core_resources,
- },
- {
- .name = "da9062-regulators",
- .num_resources = ARRAY_SIZE(da9061_regulators_resources),
- .resources = da9061_regulators_resources,
- },
- {
- .name = "da9061-watchdog",
- .num_resources = ARRAY_SIZE(da9061_wdt_resources),
- .resources = da9061_wdt_resources,
- .of_compatible = "dlg,da9061-watchdog",
- },
- {
- .name = "da9061-thermal",
- .num_resources = ARRAY_SIZE(da9061_thermal_resources),
- .resources = da9061_thermal_resources,
- .of_compatible = "dlg,da9061-thermal",
- },
- {
- .name = "da9061-onkey",
- .num_resources = ARRAY_SIZE(da9061_onkey_resources),
- .resources = da9061_onkey_resources,
- .of_compatible = "dlg,da9061-onkey",
- },
+ MFD_CELL_OF("da9061-core", da9061_core_resources, NULL, 0, 0,
+ NULL),
+ MFD_CELL_OF("da9062-regulators", da9061_regulators_resources, NULL, 0, 0,
+ NULL),
+ MFD_CELL_OF("da9061-watchdog", da9061_wdt_resources, NULL, 0, 0,
+ "dlg,da9061-watchdog"),
+ MFD_CELL_OF("da9061-thermal", da9061_thermal_resources, NULL, 0, 0,
+ "dlg,da9061-thermal"),
+ MFD_CELL_OF("da9061-onkey", da9061_onkey_resources, NULL, 0, 0,
+ "dlg,da9061-onkey"),
};

static const struct resource da9062_core_resources[] = {
@@ -246,46 +228,20 @@ static const struct resource da9062_gpio_resources[] = {
};

static const struct mfd_cell da9062_devs[] = {
- {
- .name = "da9062-core",
- .num_resources = ARRAY_SIZE(da9062_core_resources),
- .resources = da9062_core_resources,
- },
- {
- .name = "da9062-regulators",
- .num_resources = ARRAY_SIZE(da9062_regulators_resources),
- .resources = da9062_regulators_resources,
- },
- {
- .name = "da9062-watchdog",
- .num_resources = ARRAY_SIZE(da9062_wdt_resources),
- .resources = da9062_wdt_resources,
- .of_compatible = "dlg,da9062-watchdog",
- },
- {
- .name = "da9062-thermal",
- .num_resources = ARRAY_SIZE(da9062_thermal_resources),
- .resources = da9062_thermal_resources,
- .of_compatible = "dlg,da9062-thermal",
- },
- {
- .name = "da9062-rtc",
- .num_resources = ARRAY_SIZE(da9062_rtc_resources),
- .resources = da9062_rtc_resources,
- .of_compatible = "dlg,da9062-rtc",
- },
- {
- .name = "da9062-onkey",
- .num_resources = ARRAY_SIZE(da9062_onkey_resources),
- .resources = da9062_onkey_resources,
- .of_compatible = "dlg,da9062-onkey",
- },
- {
- .name = "da9062-gpio",
- .num_resources = ARRAY_SIZE(da9062_gpio_resources),
- .resources = da9062_gpio_resources,
- .of_compatible = "dlg,da9062-gpio",
- },
+ MFD_CELL_OF("da9062-core", da9062_core_resources, NULL, 0, 0,
+ NULL),
+ MFD_CELL_OF("da9062-regulators", da9062_regulators_resources, NULL, 0, 0,
+ NULL),
+ MFD_CELL_OF("da9062-watchdog", da9062_wdt_resources, NULL, 0, 0,
+ "dlg,da9062-watchdog"),
+ MFD_CELL_OF("da9062-thermal", da9062_thermal_resources, NULL, 0, 0,
+ "dlg,da9062-thermal"),
+ MFD_CELL_OF("da9062-rtc", da9062_rtc_resources, NULL, 0, 0,
+ "dlg,da9062-rtc"),
+ MFD_CELL_OF("da9062-onkey", da9062_onkey_resources, NULL, 0, 0,
+ "dlg,da9062-onkey"),
+ MFD_CELL_OF("da9062-gpio", da9062_gpio_resources, NULL, 0, 0,
+ "dlg,da9062-gpio"),
};

static int da9062_clear_fault_log(struct da9062 *chip)
--
2.11.0



2023-03-07 10:44:48

by Christoph Niedermaier

[permalink] [raw]
Subject: [PATCH V3 2/3] 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: Christoph Niedermaier <[email protected]>
---
Cc: Support Opensource <[email protected]>
Cc: Lee Jones <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V2: - Rebase on current next 20230209
- Add Lee Jones to Cc list
V3: - Rebase on current next 20230307
- Use macro MFD_CELL_OF
- Refactoring the code for use without IRQ
---
drivers/mfd/da9062-core.c | 84 +++++++++++++++++++++++++++++++----------------
1 file changed, 55 insertions(+), 29 deletions(-)

diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c
index 9418c58c2b06..d073d5f106ec 100644
--- a/drivers/mfd/da9062-core.c
+++ b/drivers/mfd/da9062-core.c
@@ -181,7 +181,7 @@ static const struct resource da9061_onkey_resources[] = {
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,
NULL),
MFD_CELL_OF("da9062-regulators", da9061_regulators_resources, NULL, 0, 0,
@@ -194,6 +194,14 @@ static const struct mfd_cell da9061_devs[] = {
"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[] = {
DEFINE_RES_NAMED(DA9062_IRQ_VDD_WARN, 1, "VDD_WARN", IORESOURCE_IRQ),
};
@@ -227,7 +235,7 @@ static const struct resource da9062_gpio_resources[] = {
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,
NULL),
MFD_CELL_OF("da9062-regulators", da9062_regulators_resources, NULL, 0, 0,
@@ -244,6 +252,16 @@ static const struct mfd_cell da9062_devs[] = {
"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)
{
int ret;
@@ -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);
struct da9062 *chip;
- unsigned int irq_base;
+ unsigned int irq_base = 0;
const struct mfd_cell *cell;
const struct regmap_irq_chip *irq_chip;
const struct regmap_config *config;
@@ -601,22 +619,16 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
i2c_set_clientdata(i2c, chip);
chip->dev = &i2c->dev;

- if (!i2c->irq) {
- dev_err(chip->dev, "No IRQ configured\n");
- return -EINVAL;
- }
-
+ /* Start with a base configuration without IRQ */
switch (chip->chip_type) {
case COMPAT_TYPE_DA9061:
- cell = da9061_devs;
- cell_num = ARRAY_SIZE(da9061_devs);
- irq_chip = &da9061_irq_chip;
+ cell = da9061_devs_noirq;
+ cell_num = ARRAY_SIZE(da9061_devs_noirq);
config = &da9061_regmap_config;
break;
case COMPAT_TYPE_DA9062:
- cell = da9062_devs;
- cell_num = ARRAY_SIZE(da9062_devs);
- irq_chip = &da9062_irq_chip;
+ cell = da9062_devs_noirq;
+ cell_num = ARRAY_SIZE(da9062_devs_noirq);
config = &da9062_regmap_config;
break;
default:
@@ -651,29 +663,43 @@ static int da9062_i2c_probe(struct i2c_client *i2c)
if (ret)
return ret;

- ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type);
- if (ret < 0) {
- dev_err(chip->dev, "Failed to configure IRQ type\n");
- 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 = regmap_add_irq_chip(chip->regmap, i2c->irq,
- trigger_type | IRQF_SHARED | IRQF_ONESHOT,
- -1, irq_chip, &chip->regmap_irq);
- if (ret) {
- dev_err(chip->dev, "Failed to request IRQ %d: %d\n",
- i2c->irq, ret);
- return ret;
- }
+ ret = da9062_configure_irq_type(chip, i2c->irq, &trigger_type);
+ if (ret < 0) {
+ dev_err(chip->dev, "Failed to configure IRQ type\n");
+ return ret;
+ }

- irq_base = regmap_irq_chip_get_base(chip->regmap_irq);
+ ret = regmap_add_irq_chip(chip->regmap, i2c->irq,
+ trigger_type | IRQF_SHARED | IRQF_ONESHOT,
+ -1, irq_chip, &chip->regmap_irq);
+ if (ret) {
+ dev_err(chip->dev, "Failed to request IRQ %d: %d\n",
+ i2c->irq, ret);
+ return ret;
+ }
+
+ irq_base = regmap_irq_chip_get_base(chip->regmap_irq);
+ }

ret = mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE, cell,
cell_num, NULL, irq_base,
NULL);
if (ret) {
dev_err(chip->dev, "Cannot register child devices\n");
- regmap_del_irq_chip(i2c->irq, chip->regmap_irq);
+ if (i2c->irq)
+ regmap_del_irq_chip(i2c->irq, chip->regmap_irq);
return ret;
}

--
2.11.0


2023-03-07 11:01:25

by Christoph Niedermaier

[permalink] [raw]
Subject: [PATCH V3 3/3] regulator: da9062: Make the use of IRQ optional

This patch makes the use of IRQ optional to make the DA9061/62 usable
for designs that don't have the IRQ pin connected, because the regulator
is usable without IRQ.

Signed-off-by: Christoph Niedermaier <[email protected]>
Acked-by: Mark Brown <[email protected]>
Reviewed-by: Adam Ward <[email protected]>
---
Cc: Support Opensource <[email protected]>
Cc: Adam Thomson <[email protected]>
Cc: Liam Girdwood <[email protected]>
Cc: Mark Brown <[email protected]>
Cc: Marek Vasut <[email protected]>
Cc: [email protected]
Cc: [email protected]
To: [email protected]
---
V2: - Rebase on current next 20230209
- Add Reviewed-by and Acked-by tags
V3: - Rebase on current next 20230307
---
drivers/regulator/da9062-regulator.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 1a6324001027..653e1844dd61 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -1012,10 +1012,9 @@ static int da9062_regulator_probe(struct platform_device *pdev)
}

/* LDOs overcurrent event support */
- irq = platform_get_irq_byname(pdev, "LDO_LIM");
- if (irq < 0)
- return irq;
- regulators->irq_ldo_lim = irq;
+ regulators->irq_ldo_lim = platform_get_irq_byname_optional(pdev, "LDO_LIM");
+ if (regulators->irq_ldo_lim < 0)
+ return 0;

ret = devm_request_threaded_irq(&pdev->dev, irq,
NULL, da9062_ldo_lim_event,
--
2.11.0


2023-03-08 09:24:00

by DLG Adam Ward

[permalink] [raw]
Subject: RE: [PATCH V3 1/3] mfd: da9062: Use MFD_CELL_OF macro

On 07/03/2023 10:18, Christoph Niedermaier wrote:
>
>Use MFD_CELL_OF macro helper instead of plain struct properties, which makes the code a bit shorter and to have commonly defined MFD cell attributes.
>
>Signed-off-by: Christoph Niedermaier <[email protected]>

Acked-by: Adam Ward <[email protected]>


2023-03-08 09:24:04

by DLG Adam Ward

[permalink] [raw]
Subject: RE: [PATCH V3 2/3] mfd: da9062: Remove IRQ requirement

On 07/03/2023 10:18, Christoph Niedermaier wrote:
>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: Christoph Niedermaier <[email protected]>

Acked-by: Adam Ward <[email protected]>


2023-03-08 15:13:07

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH V3 3/3] regulator: da9062: Make the use of IRQ optional

Hi Christoph,

I love your patch! Perhaps something to improve:

[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on lee-mfd/for-mfd-fixes soc/for-next broonie-regulator/for-next linus/master v6.3-rc1 next-20230308]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Christoph-Niedermaier/mfd-da9062-Remove-IRQ-requirement/20230307-190334
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
patch link: https://lore.kernel.org/r/20230307101813.77267-3-cniedermaier%40dh-electronics.com
patch subject: [PATCH V3 3/3] regulator: da9062: Make the use of IRQ optional
config: i386-randconfig-a013-20230306 (https://download.01.org/0day-ci/archive/20230308/[email protected]/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/98b59e5759ae23dcd6d1d04089e513adf11e6376
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Christoph-Niedermaier/mfd-da9062-Remove-IRQ-requirement/20230307-190334
git checkout 98b59e5759ae23dcd6d1d04089e513adf11e6376
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/regulator/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/regulator/da9062-regulator.c:1019:46: warning: variable 'irq' is uninitialized when used here [-Wuninitialized]
ret = devm_request_threaded_irq(&pdev->dev, irq,
^~~
drivers/regulator/da9062-regulator.c:927:9: note: initialize the variable 'irq' to silence this warning
int irq, n, ret;
^
= 0
1 warning generated.


vim +/irq +1019 drivers/regulator/da9062-regulator.c

4068e5182ada26 S Twiss 2015-05-19 919
4068e5182ada26 S Twiss 2015-05-19 920 static int da9062_regulator_probe(struct platform_device *pdev)
4068e5182ada26 S Twiss 2015-05-19 921 {
4068e5182ada26 S Twiss 2015-05-19 922 struct da9062 *chip = dev_get_drvdata(pdev->dev.parent);
4068e5182ada26 S Twiss 2015-05-19 923 struct da9062_regulators *regulators;
4068e5182ada26 S Twiss 2015-05-19 924 struct da9062_regulator *regl;
4068e5182ada26 S Twiss 2015-05-19 925 struct regulator_config config = { };
4b7f4958a37e01 Steve Twiss 2017-06-07 926 const struct da9062_regulator_info *rinfo;
4068e5182ada26 S Twiss 2015-05-19 927 int irq, n, ret;
4b7f4958a37e01 Steve Twiss 2017-06-07 928 int max_regulators;
4b7f4958a37e01 Steve Twiss 2017-06-07 929
4b7f4958a37e01 Steve Twiss 2017-06-07 930 switch (chip->chip_type) {
4b7f4958a37e01 Steve Twiss 2017-06-07 931 case COMPAT_TYPE_DA9061:
4b7f4958a37e01 Steve Twiss 2017-06-07 932 max_regulators = DA9061_MAX_REGULATORS;
4b7f4958a37e01 Steve Twiss 2017-06-07 933 rinfo = local_da9061_regulator_info;
4b7f4958a37e01 Steve Twiss 2017-06-07 934 break;
4b7f4958a37e01 Steve Twiss 2017-06-07 935 case COMPAT_TYPE_DA9062:
4b7f4958a37e01 Steve Twiss 2017-06-07 936 max_regulators = DA9062_MAX_REGULATORS;
4b7f4958a37e01 Steve Twiss 2017-06-07 937 rinfo = local_da9062_regulator_info;
4b7f4958a37e01 Steve Twiss 2017-06-07 938 break;
4b7f4958a37e01 Steve Twiss 2017-06-07 939 default:
4b7f4958a37e01 Steve Twiss 2017-06-07 940 dev_err(chip->dev, "Unrecognised chip type\n");
4b7f4958a37e01 Steve Twiss 2017-06-07 941 return -ENODEV;
4b7f4958a37e01 Steve Twiss 2017-06-07 942 }
4068e5182ada26 S Twiss 2015-05-19 943
4068e5182ada26 S Twiss 2015-05-19 944 /* Allocate memory required by usable regulators */
97b047e72bd6e6 Gustavo A. R. Silva 2019-02-22 945 regulators = devm_kzalloc(&pdev->dev, struct_size(regulators, regulator,
97b047e72bd6e6 Gustavo A. R. Silva 2019-02-22 946 max_regulators), GFP_KERNEL);
4068e5182ada26 S Twiss 2015-05-19 947 if (!regulators)
4068e5182ada26 S Twiss 2015-05-19 948 return -ENOMEM;
4068e5182ada26 S Twiss 2015-05-19 949
4b7f4958a37e01 Steve Twiss 2017-06-07 950 regulators->n_regulators = max_regulators;
4068e5182ada26 S Twiss 2015-05-19 951 platform_set_drvdata(pdev, regulators);
4068e5182ada26 S Twiss 2015-05-19 952
151b03791e4acb Axel Lin 2019-10-07 953 for (n = 0; n < regulators->n_regulators; n++) {
4068e5182ada26 S Twiss 2015-05-19 954 /* Initialise regulator structure */
4068e5182ada26 S Twiss 2015-05-19 955 regl = &regulators->regulator[n];
4068e5182ada26 S Twiss 2015-05-19 956 regl->hw = chip;
4b7f4958a37e01 Steve Twiss 2017-06-07 957 regl->info = &rinfo[n];
4068e5182ada26 S Twiss 2015-05-19 958 regl->desc = regl->info->desc;
4068e5182ada26 S Twiss 2015-05-19 959 regl->desc.type = REGULATOR_VOLTAGE;
4068e5182ada26 S Twiss 2015-05-19 960 regl->desc.owner = THIS_MODULE;
4068e5182ada26 S Twiss 2015-05-19 961
54129d641cac77 Axel Lin 2019-01-26 962 if (regl->info->mode.reg) {
4068e5182ada26 S Twiss 2015-05-19 963 regl->mode = devm_regmap_field_alloc(
4068e5182ada26 S Twiss 2015-05-19 964 &pdev->dev,
4068e5182ada26 S Twiss 2015-05-19 965 chip->regmap,
4068e5182ada26 S Twiss 2015-05-19 966 regl->info->mode);
54129d641cac77 Axel Lin 2019-01-26 967 if (IS_ERR(regl->mode))
54129d641cac77 Axel Lin 2019-01-26 968 return PTR_ERR(regl->mode);
54129d641cac77 Axel Lin 2019-01-26 969 }
54129d641cac77 Axel Lin 2019-01-26 970
54129d641cac77 Axel Lin 2019-01-26 971 if (regl->info->suspend.reg) {
4068e5182ada26 S Twiss 2015-05-19 972 regl->suspend = devm_regmap_field_alloc(
4068e5182ada26 S Twiss 2015-05-19 973 &pdev->dev,
4068e5182ada26 S Twiss 2015-05-19 974 chip->regmap,
4068e5182ada26 S Twiss 2015-05-19 975 regl->info->suspend);
54129d641cac77 Axel Lin 2019-01-26 976 if (IS_ERR(regl->suspend))
54129d641cac77 Axel Lin 2019-01-26 977 return PTR_ERR(regl->suspend);
54129d641cac77 Axel Lin 2019-01-26 978 }
54129d641cac77 Axel Lin 2019-01-26 979
54129d641cac77 Axel Lin 2019-01-26 980 if (regl->info->sleep.reg) {
4068e5182ada26 S Twiss 2015-05-19 981 regl->sleep = devm_regmap_field_alloc(
4068e5182ada26 S Twiss 2015-05-19 982 &pdev->dev,
4068e5182ada26 S Twiss 2015-05-19 983 chip->regmap,
4068e5182ada26 S Twiss 2015-05-19 984 regl->info->sleep);
54129d641cac77 Axel Lin 2019-01-26 985 if (IS_ERR(regl->sleep))
54129d641cac77 Axel Lin 2019-01-26 986 return PTR_ERR(regl->sleep);
54129d641cac77 Axel Lin 2019-01-26 987 }
54129d641cac77 Axel Lin 2019-01-26 988
54129d641cac77 Axel Lin 2019-01-26 989 if (regl->info->suspend_sleep.reg) {
4068e5182ada26 S Twiss 2015-05-19 990 regl->suspend_sleep = devm_regmap_field_alloc(
4068e5182ada26 S Twiss 2015-05-19 991 &pdev->dev,
4068e5182ada26 S Twiss 2015-05-19 992 chip->regmap,
4068e5182ada26 S Twiss 2015-05-19 993 regl->info->suspend_sleep);
54129d641cac77 Axel Lin 2019-01-26 994 if (IS_ERR(regl->suspend_sleep))
54129d641cac77 Axel Lin 2019-01-26 995 return PTR_ERR(regl->suspend_sleep);
54129d641cac77 Axel Lin 2019-01-26 996 }
54129d641cac77 Axel Lin 2019-01-26 997
4068e5182ada26 S Twiss 2015-05-19 998 /* Register regulator */
4068e5182ada26 S Twiss 2015-05-19 999 memset(&config, 0, sizeof(config));
4068e5182ada26 S Twiss 2015-05-19 1000 config.dev = chip->dev;
4068e5182ada26 S Twiss 2015-05-19 1001 config.driver_data = regl;
4068e5182ada26 S Twiss 2015-05-19 1002 config.regmap = chip->regmap;
4068e5182ada26 S Twiss 2015-05-19 1003
4068e5182ada26 S Twiss 2015-05-19 1004 regl->rdev = devm_regulator_register(&pdev->dev, &regl->desc,
4068e5182ada26 S Twiss 2015-05-19 1005 &config);
4068e5182ada26 S Twiss 2015-05-19 1006 if (IS_ERR(regl->rdev)) {
4068e5182ada26 S Twiss 2015-05-19 1007 dev_err(&pdev->dev,
4068e5182ada26 S Twiss 2015-05-19 1008 "Failed to register %s regulator\n",
4068e5182ada26 S Twiss 2015-05-19 1009 regl->desc.name);
4068e5182ada26 S Twiss 2015-05-19 1010 return PTR_ERR(regl->rdev);
4068e5182ada26 S Twiss 2015-05-19 1011 }
4068e5182ada26 S Twiss 2015-05-19 1012 }
4068e5182ada26 S Twiss 2015-05-19 1013
4068e5182ada26 S Twiss 2015-05-19 1014 /* LDOs overcurrent event support */
98b59e5759ae23 Christoph Niedermaier 2023-03-07 1015 regulators->irq_ldo_lim = platform_get_irq_byname_optional(pdev, "LDO_LIM");
98b59e5759ae23 Christoph Niedermaier 2023-03-07 1016 if (regulators->irq_ldo_lim < 0)
98b59e5759ae23 Christoph Niedermaier 2023-03-07 1017 return 0;
4068e5182ada26 S Twiss 2015-05-19 1018
4068e5182ada26 S Twiss 2015-05-19 @1019 ret = devm_request_threaded_irq(&pdev->dev, irq,
4068e5182ada26 S Twiss 2015-05-19 1020 NULL, da9062_ldo_lim_event,
4068e5182ada26 S Twiss 2015-05-19 1021 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
4068e5182ada26 S Twiss 2015-05-19 1022 "LDO_LIM", regulators);
4068e5182ada26 S Twiss 2015-05-19 1023 if (ret) {
4068e5182ada26 S Twiss 2015-05-19 1024 dev_warn(&pdev->dev,
4068e5182ada26 S Twiss 2015-05-19 1025 "Failed to request LDO_LIM IRQ.\n");
4068e5182ada26 S Twiss 2015-05-19 1026 regulators->irq_ldo_lim = -ENXIO;
4068e5182ada26 S Twiss 2015-05-19 1027 }
4068e5182ada26 S Twiss 2015-05-19 1028
4068e5182ada26 S Twiss 2015-05-19 1029 return 0;
4068e5182ada26 S Twiss 2015-05-19 1030 }
4068e5182ada26 S Twiss 2015-05-19 1031

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests