Lines Matching +full:sc2731 +full:- +full:charger

1 // SPDX-License-Identifier: GPL-2.0-only
10 #include <linux/mfd/sc27xx-pmic.h>
15 #include <uapi/linux/usb/charger.h>
28 /* PMIC charger detection definition */
74 const struct sprd_pmic_data *pdata = ddata->pdata; in sprd_pmic_detect_charger_type()
79 ret = regmap_read_poll_timeout(ddata->regmap, pdata->charger_det, val, in sprd_pmic_detect_charger_type()
84 dev_err(&spi->dev, "failed to detect charger type\n"); in sprd_pmic_detect_charger_type()
126 return -EINVAL; in sprd_pmic_spi_read()
158 pdata = of_device_get_match_data(&spi->dev); in sprd_pmic_probe()
160 dev_err(&spi->dev, "No matching driver data found\n"); in sprd_pmic_probe()
161 return -EINVAL; in sprd_pmic_probe()
164 ddata = devm_kzalloc(&spi->dev, sizeof(*ddata), GFP_KERNEL); in sprd_pmic_probe()
166 return -ENOMEM; in sprd_pmic_probe()
168 ddata->regmap = devm_regmap_init(&spi->dev, &sprd_pmic_regmap, in sprd_pmic_probe()
169 &spi->dev, &sprd_pmic_config); in sprd_pmic_probe()
170 if (IS_ERR(ddata->regmap)) { in sprd_pmic_probe()
171 ret = PTR_ERR(ddata->regmap); in sprd_pmic_probe()
172 dev_err(&spi->dev, "Failed to allocate register map %d\n", ret); in sprd_pmic_probe()
177 ddata->dev = &spi->dev; in sprd_pmic_probe()
178 ddata->irq = spi->irq; in sprd_pmic_probe()
179 ddata->pdata = pdata; in sprd_pmic_probe()
181 ddata->irq_chip.name = dev_name(&spi->dev); in sprd_pmic_probe()
182 ddata->irq_chip.status_base = in sprd_pmic_probe()
183 pdata->irq_base + SPRD_PMIC_INT_MASK_STATUS; in sprd_pmic_probe()
184 ddata->irq_chip.unmask_base = pdata->irq_base + SPRD_PMIC_INT_EN; in sprd_pmic_probe()
185 ddata->irq_chip.ack_base = 0; in sprd_pmic_probe()
186 ddata->irq_chip.num_regs = 1; in sprd_pmic_probe()
187 ddata->irq_chip.num_irqs = pdata->num_irqs; in sprd_pmic_probe()
189 ddata->irqs = devm_kcalloc(&spi->dev, in sprd_pmic_probe()
190 pdata->num_irqs, sizeof(struct regmap_irq), in sprd_pmic_probe()
192 if (!ddata->irqs) in sprd_pmic_probe()
193 return -ENOMEM; in sprd_pmic_probe()
195 ddata->irq_chip.irqs = ddata->irqs; in sprd_pmic_probe()
196 for (i = 0; i < pdata->num_irqs; i++) in sprd_pmic_probe()
197 ddata->irqs[i].mask = BIT(i); in sprd_pmic_probe()
199 ret = devm_regmap_add_irq_chip(&spi->dev, ddata->regmap, ddata->irq, in sprd_pmic_probe()
201 &ddata->irq_chip, &ddata->irq_data); in sprd_pmic_probe()
203 dev_err(&spi->dev, "Failed to add PMIC irq chip %d\n", ret); in sprd_pmic_probe()
207 ret = devm_of_platform_populate(&spi->dev); in sprd_pmic_probe()
209 dev_err(&spi->dev, "Failed to populate sub-devices %d\n", ret); in sprd_pmic_probe()
213 device_init_wakeup(&spi->dev, true); in sprd_pmic_probe()
222 enable_irq_wake(ddata->irq); in sprd_pmic_suspend()
232 disable_irq_wake(ddata->irq); in sprd_pmic_resume()
242 { .compatible = "sprd,sc2731", .data = &sc2731_data },
249 { .name = "sc2731", .driver_data = (unsigned long)&sc2731_data },
256 .name = "sc27xx-pmic",