Loading Documentation/devicetree/bindings/mfd/rohm,bd9576-pmic.yaml 0 → 100644 +123 −0 Original line number Diff line number Diff line # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2 --- $id: http://devicetree.org/schemas/mfd/rohm,bd9576-pmic.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: ROHM BD9576MUF and BD9573MUF Power Management Integrated Circuit bindings maintainers: - Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> description: | BD9576MUF and BD9573MUF are power management ICs primarily intended for powering the R-Car series processors. The IC provides 6 power outputs with configurable sequencing and safety monitoring. A watchdog logic with slow ping/windowed modes is also included. properties: compatible: enum: - rohm,bd9576 - rohm,bd9573 reg: description: I2C slave address. maxItems: 1 interrupts: maxItems: 1 rohm,vout1-en-low: description: BD9576 and BD9573 VOUT1 regulator enable state can be individually controlled by a GPIO. This is dictated by state of vout1-en pin during the PMIC startup. If vout1-en is LOW during PMIC startup then the VOUT1 enable sate is controlled via this pin. Set this property if vout1-en is wired to be down at PMIC start-up. type: boolean rohm,vout1-en-gpios: description: GPIO specifier to specify the GPIO connected to vout1-en for vout1 ON/OFF state control. maxItems: 1 rohm,ddr-sel-low: description: The BD9576 and BD9573 output voltage for DDR can be selected by setting the ddr-sel pin low or high. Set this property if ddr-sel is grounded. type: boolean rohm,watchdog-enable-gpios: description: The GPIO line used to enable the watchdog. maxItems: 1 rohm,watchdog-ping-gpios: description: The GPIO line used to ping the watchdog. maxItems: 1 rohm,hw-timeout-ms: maxItems: 2 description: Watchog timeout in milliseconds. If single value is given it is the maximum timeout. Eg. if pinging watchdog is not done within this time limit the watchdog will be triggered. If two values are given watchdog is configured in "window mode". Then first value is limit for short-ping Eg. if watchdog is pinged sooner than that the watchdog will trigger. When two values is given the second value is the maximum timeout. # (HW) minimum for short timeout is 2ms, maximum 220 ms. # (HW) minimum for max timeout is 4ms, maximum 4416 ms. regulators: $ref: ../regulator/rohm,bd9576-regulator.yaml description: List of child nodes that specify the regulators. required: - compatible - reg - regulators additionalProperties: false examples: - | #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/leds/common.h> i2c { #address-cells = <1>; #size-cells = <0>; pmic: pmic@30 { compatible = "rohm,bd9576"; reg = <0x30>; rohm,vout1-en-low; rohm,vout1-en-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>; rohm,ddr-sel-low; rohm,watchdog-enable-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>; rohm,watchdog-ping-gpios = <&gpio2 7 GPIO_ACTIVE_HIGH>; rohm,hw-timeout-ms = <150>, <2300>; regulators { boost1: regulator-vd50 { regulator-name = "VD50"; }; buck1: regulator-vd18 { regulator-name = "VD18"; }; buck2: regulator-vdddr { regulator-name = "VDDDR"; }; buck3: regulator-vd10 { regulator-name = "VD10"; }; ldo: regulator-voutl1 { regulator-name = "VOUTL1"; }; sw: regulator-vouts1 { regulator-name = "VOUTS1"; }; }; }; }; MAINTAINERS +4 −0 Original line number Diff line number Diff line Loading @@ -15478,18 +15478,22 @@ F: drivers/gpio/gpio-bd71828.c F: drivers/mfd/rohm-bd70528.c F: drivers/mfd/rohm-bd71828.c F: drivers/mfd/rohm-bd718x7.c F: drivers/mfd/rohm-bd9576.c F: drivers/power/supply/bd70528-charger.c F: drivers/regulator/bd70528-regulator.c F: drivers/regulator/bd71815-regulator.c F: drivers/regulator/bd71828-regulator.c F: drivers/regulator/bd718x7-regulator.c F: drivers/regulator/bd9576-regulator.c F: drivers/regulator/rohm-regulator.c F: drivers/rtc/rtc-bd70528.c F: drivers/watchdog/bd70528_wdt.c F: drivers/watchdog/bd9576_wdt.c F: include/linux/mfd/rohm-bd70528.h F: include/linux/mfd/rohm-bd71815.h F: include/linux/mfd/rohm-bd71828.h F: include/linux/mfd/rohm-bd718x7.h F: include/linux/mfd/rohm-bd957x.h F: include/linux/mfd/rohm-generic.h F: include/linux/mfd/rohm-shared.h Loading drivers/mfd/Kconfig +11 −0 Original line number Diff line number Diff line Loading @@ -2001,6 +2001,17 @@ config MFD_ROHM_BD71828 also a single-cell linear charger, a Coulomb counter, a real-time clock (RTC), GPIOs and a 32.768 kHz clock gate. config MFD_ROHM_BD957XMUF tristate "ROHM BD9576MUF and BD9573MUF Power Management ICs" depends on I2C=y depends on OF select REGMAP_I2C select MFD_CORE help Select this option to get support for the ROHM BD9576MUF and BD9573MUF Power Management ICs. BD9576 and BD9573 are primarily designed to be used to power R-Car series processors. config MFD_STM32_LPTIMER tristate "Support for STM32 Low-Power Timer" depends on (ARCH_STM32 && OF) || COMPILE_TEST Loading drivers/mfd/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -262,6 +262,7 @@ obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o obj-$(CONFIG_MFD_ROHM_BD70528) += rohm-bd70528.o obj-$(CONFIG_MFD_ROHM_BD71828) += rohm-bd71828.o obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o obj-$(CONFIG_MFD_ROHM_BD957XMUF) += rohm-bd9576.o obj-$(CONFIG_MFD_STMFX) += stmfx.o obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o Loading drivers/mfd/rohm-bd9576.c 0 → 100644 +189 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2021 ROHM Semiconductors * * ROHM BD9576MUF and BD9573MUF PMIC driver */ #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/mfd/core.h> #include <linux/mfd/rohm-bd957x.h> #include <linux/mfd/rohm-generic.h> #include <linux/module.h> #include <linux/of_device.h> #include <linux/regmap.h> #include <linux/types.h> enum { BD957X_REGULATOR_CELL, BD957X_WDT_CELL, }; /* * Due to the BD9576MUF nasty IRQ behaiour we don't always populate IRQs. * These will be added to regulator resources only if IRQ information for the * PMIC is populated in device-tree. */ static const struct resource bd9576_regulator_irqs[] = { DEFINE_RES_IRQ_NAMED(BD9576_INT_THERM, "bd9576-temp"), DEFINE_RES_IRQ_NAMED(BD9576_INT_OVD, "bd9576-ovd"), DEFINE_RES_IRQ_NAMED(BD9576_INT_UVD, "bd9576-uvd"), }; static struct mfd_cell bd9573_mfd_cells[] = { [BD957X_REGULATOR_CELL] = { .name = "bd9573-regulator", }, [BD957X_WDT_CELL] = { .name = "bd9576-wdt", }, }; static struct mfd_cell bd9576_mfd_cells[] = { [BD957X_REGULATOR_CELL] = { .name = "bd9576-regulator", }, [BD957X_WDT_CELL] = { .name = "bd9576-wdt", }, }; static const struct regmap_range volatile_ranges[] = { regmap_reg_range(BD957X_REG_SMRB_ASSERT, BD957X_REG_SMRB_ASSERT), regmap_reg_range(BD957X_REG_PMIC_INTERNAL_STAT, BD957X_REG_PMIC_INTERNAL_STAT), regmap_reg_range(BD957X_REG_INT_THERM_STAT, BD957X_REG_INT_THERM_STAT), regmap_reg_range(BD957X_REG_INT_OVP_STAT, BD957X_REG_INT_SYS_STAT), regmap_reg_range(BD957X_REG_INT_MAIN_STAT, BD957X_REG_INT_MAIN_STAT), }; static const struct regmap_access_table volatile_regs = { .yes_ranges = &volatile_ranges[0], .n_yes_ranges = ARRAY_SIZE(volatile_ranges), }; static struct regmap_config bd957x_regmap = { .reg_bits = 8, .val_bits = 8, .volatile_table = &volatile_regs, .max_register = BD957X_MAX_REGISTER, .cache_type = REGCACHE_RBTREE, }; static struct regmap_irq bd9576_irqs[] = { REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM), REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP), REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP), REGMAP_IRQ_REG(BD9576_INT_OCP, 0, BD957X_MASK_INT_MAIN_OCP), REGMAP_IRQ_REG(BD9576_INT_OVD, 0, BD957X_MASK_INT_MAIN_OVD), REGMAP_IRQ_REG(BD9576_INT_UVD, 0, BD957X_MASK_INT_MAIN_UVD), REGMAP_IRQ_REG(BD9576_INT_UVP, 0, BD957X_MASK_INT_MAIN_UVP), REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS), }; static struct regmap_irq_chip bd9576_irq_chip = { .name = "bd9576_irq", .irqs = &bd9576_irqs[0], .num_irqs = ARRAY_SIZE(bd9576_irqs), .status_base = BD957X_REG_INT_MAIN_STAT, .mask_base = BD957X_REG_INT_MAIN_MASK, .ack_base = BD957X_REG_INT_MAIN_STAT, .init_ack_masked = true, .num_regs = 1, .irq_reg_stride = 1, }; static int bd957x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { int ret; struct regmap *regmap; struct mfd_cell *cells; int num_cells; unsigned long chip_type; struct irq_domain *domain; bool usable_irqs; chip_type = (unsigned long)of_device_get_match_data(&i2c->dev); switch (chip_type) { case ROHM_CHIP_TYPE_BD9576: cells = bd9576_mfd_cells; num_cells = ARRAY_SIZE(bd9576_mfd_cells); usable_irqs = !!i2c->irq; break; case ROHM_CHIP_TYPE_BD9573: cells = bd9573_mfd_cells; num_cells = ARRAY_SIZE(bd9573_mfd_cells); /* * BD9573 only supports fatal IRQs which we can not handle * because SoC is going to lose the power. */ usable_irqs = false; break; default: dev_err(&i2c->dev, "Unknown device type"); return -EINVAL; } regmap = devm_regmap_init_i2c(i2c, &bd957x_regmap); if (IS_ERR(regmap)) { dev_err(&i2c->dev, "Failed to initialize Regmap\n"); return PTR_ERR(regmap); } /* * BD9576 behaves badly. It kepts IRQ line asserted for the whole * duration of detected HW condition (like over temperature). So we * don't require IRQ to be populated. * If IRQ information is not given, then we mask all IRQs and do not * provide IRQ resources to regulator driver - which then just omits * the notifiers. */ if (usable_irqs) { struct regmap_irq_chip_data *irq_data; struct mfd_cell *regulators; regulators = &bd9576_mfd_cells[BD957X_REGULATOR_CELL]; regulators->resources = bd9576_regulator_irqs; regulators->num_resources = ARRAY_SIZE(bd9576_regulator_irqs); ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, IRQF_ONESHOT, 0, &bd9576_irq_chip, &irq_data); if (ret) { dev_err(&i2c->dev, "Failed to add IRQ chip\n"); return ret; } domain = regmap_irq_get_domain(irq_data); } else { ret = regmap_update_bits(regmap, BD957X_REG_INT_MAIN_MASK, BD957X_MASK_INT_ALL, BD957X_MASK_INT_ALL); if (ret) return ret; domain = NULL; } ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, cells, num_cells, NULL, 0, domain); if (ret) dev_err(&i2c->dev, "Failed to create subdevices\n"); return ret; } static const struct of_device_id bd957x_of_match[] = { { .compatible = "rohm,bd9576", .data = (void *)ROHM_CHIP_TYPE_BD9576, }, { .compatible = "rohm,bd9573", .data = (void *)ROHM_CHIP_TYPE_BD9573, }, { }, }; MODULE_DEVICE_TABLE(of, bd957x_of_match); static struct i2c_driver bd957x_drv = { .driver = { .name = "rohm-bd957x", .of_match_table = bd957x_of_match, }, .probe = &bd957x_i2c_probe, }; module_i2c_driver(bd957x_drv); MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); MODULE_DESCRIPTION("ROHM BD9576MUF and BD9573MUF Power Management IC driver"); MODULE_LICENSE("GPL"); Loading
Documentation/devicetree/bindings/mfd/rohm,bd9576-pmic.yaml 0 → 100644 +123 −0 Original line number Diff line number Diff line # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause %YAML 1.2 --- $id: http://devicetree.org/schemas/mfd/rohm,bd9576-pmic.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# title: ROHM BD9576MUF and BD9573MUF Power Management Integrated Circuit bindings maintainers: - Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> description: | BD9576MUF and BD9573MUF are power management ICs primarily intended for powering the R-Car series processors. The IC provides 6 power outputs with configurable sequencing and safety monitoring. A watchdog logic with slow ping/windowed modes is also included. properties: compatible: enum: - rohm,bd9576 - rohm,bd9573 reg: description: I2C slave address. maxItems: 1 interrupts: maxItems: 1 rohm,vout1-en-low: description: BD9576 and BD9573 VOUT1 regulator enable state can be individually controlled by a GPIO. This is dictated by state of vout1-en pin during the PMIC startup. If vout1-en is LOW during PMIC startup then the VOUT1 enable sate is controlled via this pin. Set this property if vout1-en is wired to be down at PMIC start-up. type: boolean rohm,vout1-en-gpios: description: GPIO specifier to specify the GPIO connected to vout1-en for vout1 ON/OFF state control. maxItems: 1 rohm,ddr-sel-low: description: The BD9576 and BD9573 output voltage for DDR can be selected by setting the ddr-sel pin low or high. Set this property if ddr-sel is grounded. type: boolean rohm,watchdog-enable-gpios: description: The GPIO line used to enable the watchdog. maxItems: 1 rohm,watchdog-ping-gpios: description: The GPIO line used to ping the watchdog. maxItems: 1 rohm,hw-timeout-ms: maxItems: 2 description: Watchog timeout in milliseconds. If single value is given it is the maximum timeout. Eg. if pinging watchdog is not done within this time limit the watchdog will be triggered. If two values are given watchdog is configured in "window mode". Then first value is limit for short-ping Eg. if watchdog is pinged sooner than that the watchdog will trigger. When two values is given the second value is the maximum timeout. # (HW) minimum for short timeout is 2ms, maximum 220 ms. # (HW) minimum for max timeout is 4ms, maximum 4416 ms. regulators: $ref: ../regulator/rohm,bd9576-regulator.yaml description: List of child nodes that specify the regulators. required: - compatible - reg - regulators additionalProperties: false examples: - | #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/leds/common.h> i2c { #address-cells = <1>; #size-cells = <0>; pmic: pmic@30 { compatible = "rohm,bd9576"; reg = <0x30>; rohm,vout1-en-low; rohm,vout1-en-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>; rohm,ddr-sel-low; rohm,watchdog-enable-gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>; rohm,watchdog-ping-gpios = <&gpio2 7 GPIO_ACTIVE_HIGH>; rohm,hw-timeout-ms = <150>, <2300>; regulators { boost1: regulator-vd50 { regulator-name = "VD50"; }; buck1: regulator-vd18 { regulator-name = "VD18"; }; buck2: regulator-vdddr { regulator-name = "VDDDR"; }; buck3: regulator-vd10 { regulator-name = "VD10"; }; ldo: regulator-voutl1 { regulator-name = "VOUTL1"; }; sw: regulator-vouts1 { regulator-name = "VOUTS1"; }; }; }; };
MAINTAINERS +4 −0 Original line number Diff line number Diff line Loading @@ -15478,18 +15478,22 @@ F: drivers/gpio/gpio-bd71828.c F: drivers/mfd/rohm-bd70528.c F: drivers/mfd/rohm-bd71828.c F: drivers/mfd/rohm-bd718x7.c F: drivers/mfd/rohm-bd9576.c F: drivers/power/supply/bd70528-charger.c F: drivers/regulator/bd70528-regulator.c F: drivers/regulator/bd71815-regulator.c F: drivers/regulator/bd71828-regulator.c F: drivers/regulator/bd718x7-regulator.c F: drivers/regulator/bd9576-regulator.c F: drivers/regulator/rohm-regulator.c F: drivers/rtc/rtc-bd70528.c F: drivers/watchdog/bd70528_wdt.c F: drivers/watchdog/bd9576_wdt.c F: include/linux/mfd/rohm-bd70528.h F: include/linux/mfd/rohm-bd71815.h F: include/linux/mfd/rohm-bd71828.h F: include/linux/mfd/rohm-bd718x7.h F: include/linux/mfd/rohm-bd957x.h F: include/linux/mfd/rohm-generic.h F: include/linux/mfd/rohm-shared.h Loading
drivers/mfd/Kconfig +11 −0 Original line number Diff line number Diff line Loading @@ -2001,6 +2001,17 @@ config MFD_ROHM_BD71828 also a single-cell linear charger, a Coulomb counter, a real-time clock (RTC), GPIOs and a 32.768 kHz clock gate. config MFD_ROHM_BD957XMUF tristate "ROHM BD9576MUF and BD9573MUF Power Management ICs" depends on I2C=y depends on OF select REGMAP_I2C select MFD_CORE help Select this option to get support for the ROHM BD9576MUF and BD9573MUF Power Management ICs. BD9576 and BD9573 are primarily designed to be used to power R-Car series processors. config MFD_STM32_LPTIMER tristate "Support for STM32 Low-Power Timer" depends on (ARCH_STM32 && OF) || COMPILE_TEST Loading
drivers/mfd/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -262,6 +262,7 @@ obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o obj-$(CONFIG_MFD_ROHM_BD70528) += rohm-bd70528.o obj-$(CONFIG_MFD_ROHM_BD71828) += rohm-bd71828.o obj-$(CONFIG_MFD_ROHM_BD718XX) += rohm-bd718x7.o obj-$(CONFIG_MFD_ROHM_BD957XMUF) += rohm-bd9576.o obj-$(CONFIG_MFD_STMFX) += stmfx.o obj-$(CONFIG_MFD_KHADAS_MCU) += khadas-mcu.o obj-$(CONFIG_MFD_ACER_A500_EC) += acer-ec-a500.o Loading
drivers/mfd/rohm-bd9576.c 0 → 100644 +189 −0 Original line number Diff line number Diff line // SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (C) 2021 ROHM Semiconductors * * ROHM BD9576MUF and BD9573MUF PMIC driver */ #include <linux/i2c.h> #include <linux/interrupt.h> #include <linux/ioport.h> #include <linux/irq.h> #include <linux/mfd/core.h> #include <linux/mfd/rohm-bd957x.h> #include <linux/mfd/rohm-generic.h> #include <linux/module.h> #include <linux/of_device.h> #include <linux/regmap.h> #include <linux/types.h> enum { BD957X_REGULATOR_CELL, BD957X_WDT_CELL, }; /* * Due to the BD9576MUF nasty IRQ behaiour we don't always populate IRQs. * These will be added to regulator resources only if IRQ information for the * PMIC is populated in device-tree. */ static const struct resource bd9576_regulator_irqs[] = { DEFINE_RES_IRQ_NAMED(BD9576_INT_THERM, "bd9576-temp"), DEFINE_RES_IRQ_NAMED(BD9576_INT_OVD, "bd9576-ovd"), DEFINE_RES_IRQ_NAMED(BD9576_INT_UVD, "bd9576-uvd"), }; static struct mfd_cell bd9573_mfd_cells[] = { [BD957X_REGULATOR_CELL] = { .name = "bd9573-regulator", }, [BD957X_WDT_CELL] = { .name = "bd9576-wdt", }, }; static struct mfd_cell bd9576_mfd_cells[] = { [BD957X_REGULATOR_CELL] = { .name = "bd9576-regulator", }, [BD957X_WDT_CELL] = { .name = "bd9576-wdt", }, }; static const struct regmap_range volatile_ranges[] = { regmap_reg_range(BD957X_REG_SMRB_ASSERT, BD957X_REG_SMRB_ASSERT), regmap_reg_range(BD957X_REG_PMIC_INTERNAL_STAT, BD957X_REG_PMIC_INTERNAL_STAT), regmap_reg_range(BD957X_REG_INT_THERM_STAT, BD957X_REG_INT_THERM_STAT), regmap_reg_range(BD957X_REG_INT_OVP_STAT, BD957X_REG_INT_SYS_STAT), regmap_reg_range(BD957X_REG_INT_MAIN_STAT, BD957X_REG_INT_MAIN_STAT), }; static const struct regmap_access_table volatile_regs = { .yes_ranges = &volatile_ranges[0], .n_yes_ranges = ARRAY_SIZE(volatile_ranges), }; static struct regmap_config bd957x_regmap = { .reg_bits = 8, .val_bits = 8, .volatile_table = &volatile_regs, .max_register = BD957X_MAX_REGISTER, .cache_type = REGCACHE_RBTREE, }; static struct regmap_irq bd9576_irqs[] = { REGMAP_IRQ_REG(BD9576_INT_THERM, 0, BD957X_MASK_INT_MAIN_THERM), REGMAP_IRQ_REG(BD9576_INT_OVP, 0, BD957X_MASK_INT_MAIN_OVP), REGMAP_IRQ_REG(BD9576_INT_SCP, 0, BD957X_MASK_INT_MAIN_SCP), REGMAP_IRQ_REG(BD9576_INT_OCP, 0, BD957X_MASK_INT_MAIN_OCP), REGMAP_IRQ_REG(BD9576_INT_OVD, 0, BD957X_MASK_INT_MAIN_OVD), REGMAP_IRQ_REG(BD9576_INT_UVD, 0, BD957X_MASK_INT_MAIN_UVD), REGMAP_IRQ_REG(BD9576_INT_UVP, 0, BD957X_MASK_INT_MAIN_UVP), REGMAP_IRQ_REG(BD9576_INT_SYS, 0, BD957X_MASK_INT_MAIN_SYS), }; static struct regmap_irq_chip bd9576_irq_chip = { .name = "bd9576_irq", .irqs = &bd9576_irqs[0], .num_irqs = ARRAY_SIZE(bd9576_irqs), .status_base = BD957X_REG_INT_MAIN_STAT, .mask_base = BD957X_REG_INT_MAIN_MASK, .ack_base = BD957X_REG_INT_MAIN_STAT, .init_ack_masked = true, .num_regs = 1, .irq_reg_stride = 1, }; static int bd957x_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { int ret; struct regmap *regmap; struct mfd_cell *cells; int num_cells; unsigned long chip_type; struct irq_domain *domain; bool usable_irqs; chip_type = (unsigned long)of_device_get_match_data(&i2c->dev); switch (chip_type) { case ROHM_CHIP_TYPE_BD9576: cells = bd9576_mfd_cells; num_cells = ARRAY_SIZE(bd9576_mfd_cells); usable_irqs = !!i2c->irq; break; case ROHM_CHIP_TYPE_BD9573: cells = bd9573_mfd_cells; num_cells = ARRAY_SIZE(bd9573_mfd_cells); /* * BD9573 only supports fatal IRQs which we can not handle * because SoC is going to lose the power. */ usable_irqs = false; break; default: dev_err(&i2c->dev, "Unknown device type"); return -EINVAL; } regmap = devm_regmap_init_i2c(i2c, &bd957x_regmap); if (IS_ERR(regmap)) { dev_err(&i2c->dev, "Failed to initialize Regmap\n"); return PTR_ERR(regmap); } /* * BD9576 behaves badly. It kepts IRQ line asserted for the whole * duration of detected HW condition (like over temperature). So we * don't require IRQ to be populated. * If IRQ information is not given, then we mask all IRQs and do not * provide IRQ resources to regulator driver - which then just omits * the notifiers. */ if (usable_irqs) { struct regmap_irq_chip_data *irq_data; struct mfd_cell *regulators; regulators = &bd9576_mfd_cells[BD957X_REGULATOR_CELL]; regulators->resources = bd9576_regulator_irqs; regulators->num_resources = ARRAY_SIZE(bd9576_regulator_irqs); ret = devm_regmap_add_irq_chip(&i2c->dev, regmap, i2c->irq, IRQF_ONESHOT, 0, &bd9576_irq_chip, &irq_data); if (ret) { dev_err(&i2c->dev, "Failed to add IRQ chip\n"); return ret; } domain = regmap_irq_get_domain(irq_data); } else { ret = regmap_update_bits(regmap, BD957X_REG_INT_MAIN_MASK, BD957X_MASK_INT_ALL, BD957X_MASK_INT_ALL); if (ret) return ret; domain = NULL; } ret = devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, cells, num_cells, NULL, 0, domain); if (ret) dev_err(&i2c->dev, "Failed to create subdevices\n"); return ret; } static const struct of_device_id bd957x_of_match[] = { { .compatible = "rohm,bd9576", .data = (void *)ROHM_CHIP_TYPE_BD9576, }, { .compatible = "rohm,bd9573", .data = (void *)ROHM_CHIP_TYPE_BD9573, }, { }, }; MODULE_DEVICE_TABLE(of, bd957x_of_match); static struct i2c_driver bd957x_drv = { .driver = { .name = "rohm-bd957x", .of_match_table = bd957x_of_match, }, .probe = &bd957x_i2c_probe, }; module_i2c_driver(bd957x_drv); MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); MODULE_DESCRIPTION("ROHM BD9576MUF and BD9573MUF Power Management IC driver"); MODULE_LICENSE("GPL");