int max77693_irq_init(struct max77693_dev *max77693) { struct irq_domain *domain; int i; int ret; mutex_init(&max77693->irqlock); /* Mask individual interrupt sources */ for (i = 0; i < MAX77693_IRQ_GROUP_NR; i++) { struct regmap *map; /* MUIC IRQ 0:MASK 1:NOT MASK */ /* Other IRQ 1:MASK 0:NOT MASK */ if (i >= MUIC_INT1 && i <= MUIC_INT3) { max77693->irq_masks_cur[i] = 0x00; max77693->irq_masks_cache[i] = 0x00; } else { max77693->irq_masks_cur[i] = 0xff; max77693->irq_masks_cache[i] = 0xff; } map = max77693_get_regmap(max77693, i); if (IS_ERR_OR_NULL(map)) continue; if (max77693_mask_reg[i] == MAX77693_REG_INVALID) continue; if (i >= MUIC_INT1 && i <= MUIC_INT3) max77693_write_reg(map, max77693_mask_reg[i], 0x00); else max77693_write_reg(map, max77693_mask_reg[i], 0xff); } domain = irq_domain_add_linear(NULL, MAX77693_IRQ_NR, &max77693_irq_domain_ops, max77693); if (!domain) { dev_err(max77693->dev, "could not create irq domain\n"); return -ENODEV; } max77693->irq_domain = domain; ret = request_threaded_irq(max77693->irq, NULL, max77693_irq_thread, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "max77693-irq", max77693); if (ret) dev_err(max77693->dev, "Failed to request IRQ %d: %d\n", max77693->irq, ret); return 0; }
static int max77693_pmic_probe(struct platform_device *pdev) { enum max77693_types type = platform_get_device_id(pdev)->driver_data; struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent); const struct regulator_desc *regulators; unsigned int regulators_size; int i; struct regulator_config config = { }; config.dev = iodev->dev; switch (type) { case TYPE_MAX77693: regulators = max77693_supported_regulators; regulators_size = ARRAY_SIZE(max77693_supported_regulators); config.driver_data = (void *)&max77693_chg_reg_data; break; case TYPE_MAX77843: regulators = max77843_supported_regulators; regulators_size = ARRAY_SIZE(max77843_supported_regulators); config.driver_data = (void *)&max77843_chg_reg_data; break; default: dev_err(&pdev->dev, "Unsupported device type: %u\n", type); return -ENODEV; } for (i = 0; i < regulators_size; i++) { struct regulator_dev *rdev; config.regmap = max77693_get_regmap(type, iodev, regulators[i].id); rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "Failed to initialize regulator-%d\n", i); return PTR_ERR(rdev); } } return 0; }
static void max77693_irq_sync_unlock(struct irq_data *data) { struct max77693_dev *max77693 = irq_get_chip_data(data->irq); int i; for (i = 0; i < MAX77693_IRQ_GROUP_NR; i++) { u8 mask_reg = max77693_mask_reg[i]; struct regmap *map = max77693_get_regmap(max77693, i); if (mask_reg == MAX77693_REG_INVALID || IS_ERR_OR_NULL(map)) continue; max77693->irq_masks_cache[i] = max77693->irq_masks_cur[i]; max77693_write_reg(map, max77693_mask_reg[i], max77693->irq_masks_cur[i]); } mutex_unlock(&max77693->irqlock); }