Lines Matching +full:pmic +full:- +full:gpio

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Device driver for MFD hi655x PMIC
16 #include <linux/mfd/hi655x-pmic.h>
18 #include <linux/gpio/consumer.h>
35 .name = "hi655x-pmic",
48 .max_register = HI655X_BUS_ADDR(0x400) - HI655X_STRIDE,
72 .name = "hi65xx-powerkey",
76 { .name = "hi655x-regulator", },
77 { .name = "hi655x-clk", },
94 struct hi655x_pmic *pmic; in hi655x_pmic_probe() local
95 struct device *dev = &pdev->dev; in hi655x_pmic_probe()
98 pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL); in hi655x_pmic_probe()
99 if (!pmic) in hi655x_pmic_probe()
100 return -ENOMEM; in hi655x_pmic_probe()
101 pmic->dev = dev; in hi655x_pmic_probe()
107 pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base, in hi655x_pmic_probe()
109 if (IS_ERR(pmic->regmap)) in hi655x_pmic_probe()
110 return PTR_ERR(pmic->regmap); in hi655x_pmic_probe()
112 regmap_read(pmic->regmap, HI655X_BUS_ADDR(HI655X_VER_REG), &pmic->ver); in hi655x_pmic_probe()
113 if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) { in hi655x_pmic_probe()
114 dev_warn(dev, "PMU version %d unsupported\n", pmic->ver); in hi655x_pmic_probe()
115 return -EINVAL; in hi655x_pmic_probe()
118 hi655x_local_irq_clear(pmic->regmap); in hi655x_pmic_probe()
120 pmic->gpio = devm_gpiod_get_optional(dev, "pmic", GPIOD_IN); in hi655x_pmic_probe()
121 if (IS_ERR(pmic->gpio)) in hi655x_pmic_probe()
122 return dev_err_probe(dev, PTR_ERR(pmic->gpio), in hi655x_pmic_probe()
123 "Failed to request hi655x pmic-gpio"); in hi655x_pmic_probe()
125 ret = regmap_add_irq_chip(pmic->regmap, gpiod_to_irq(pmic->gpio), in hi655x_pmic_probe()
127 &hi655x_irq_chip, &pmic->irq_data); in hi655x_pmic_probe()
133 platform_set_drvdata(pdev, pmic); in hi655x_pmic_probe()
137 regmap_irq_get_domain(pmic->irq_data)); in hi655x_pmic_probe()
140 regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data); in hi655x_pmic_probe()
149 struct hi655x_pmic *pmic = platform_get_drvdata(pdev); in hi655x_pmic_remove() local
151 regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data); in hi655x_pmic_remove()
152 mfd_remove_devices(&pdev->dev); in hi655x_pmic_remove()
156 { .compatible = "hisilicon,hi655x-pmic", },
163 .name = "hi655x-pmic",
172 MODULE_DESCRIPTION("Hisilicon hi655x PMIC driver");