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()
103 pmic->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); in hi655x_pmic_probe()
104 base = devm_ioremap_resource(dev, pmic->res); in hi655x_pmic_probe()
108 pmic->regmap = devm_regmap_init_mmio_clk(dev, NULL, base, in hi655x_pmic_probe()
110 if (IS_ERR(pmic->regmap)) in hi655x_pmic_probe()
111 return PTR_ERR(pmic->regmap); in hi655x_pmic_probe()
113 regmap_read(pmic->regmap, HI655X_BUS_ADDR(HI655X_VER_REG), &pmic->ver); in hi655x_pmic_probe()
114 if ((pmic->ver < PMU_VER_START) || (pmic->ver > PMU_VER_END)) { in hi655x_pmic_probe()
115 dev_warn(dev, "PMU version %d unsupported\n", pmic->ver); in hi655x_pmic_probe()
116 return -EINVAL; in hi655x_pmic_probe()
119 hi655x_local_irq_clear(pmic->regmap); in hi655x_pmic_probe()
121 pmic->gpio = devm_gpiod_get_optional(dev, "pmic", GPIOD_IN); in hi655x_pmic_probe()
122 if (IS_ERR(pmic->gpio)) in hi655x_pmic_probe()
123 return dev_err_probe(dev, PTR_ERR(pmic->gpio), in hi655x_pmic_probe()
124 "Failed to request hi655x pmic-gpio"); in hi655x_pmic_probe()
126 ret = regmap_add_irq_chip(pmic->regmap, gpiod_to_irq(pmic->gpio), in hi655x_pmic_probe()
128 &hi655x_irq_chip, &pmic->irq_data); in hi655x_pmic_probe()
134 platform_set_drvdata(pdev, pmic); in hi655x_pmic_probe()
138 regmap_irq_get_domain(pmic->irq_data)); in hi655x_pmic_probe()
141 regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data); in hi655x_pmic_probe()
150 struct hi655x_pmic *pmic = platform_get_drvdata(pdev); in hi655x_pmic_remove() local
152 regmap_del_irq_chip(gpiod_to_irq(pmic->gpio), pmic->irq_data); in hi655x_pmic_remove()
153 mfd_remove_devices(&pdev->dev); in hi655x_pmic_remove()
158 { .compatible = "hisilicon,hi655x-pmic", },
165 .name = "hi655x-pmic",
174 MODULE_DESCRIPTION("Hisilicon hi655x PMIC driver");