arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
Source file repositories/reference/linux-study-clean/arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c
File Facts
- System
- Linux kernel
- Corpus path
arch/arm/mach-shmobile/regulator-quirk-rcar-gen2.c- Extension
.c- Size
- 5868 bytes
- Lines
- 230
- Domain
- Architecture Layer
- Bucket
- arch/arm
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/i2c.hlinux/init.hlinux/io.hlinux/list.hlinux/notifier.hlinux/of.hlinux/of_irq.hlinux/mfd/da9063/registers.h
Detected Declarations
struct regulator_quirkfunction regulator_quirk_notifyfunction list_for_each_entry_safefunction rcar_gen2_regulator_quirkfunction for_each_matching_node_and_matchfunction list_for_each_entry
Annotated Snippet
struct regulator_quirk {
struct list_head list;
const struct of_device_id *id;
struct device_node *np;
struct of_phandle_args irq_args;
struct i2c_msg i2c_msg;
bool shared; /* IRQ line is shared */
};
static LIST_HEAD(quirk_list);
static void __iomem *irqc;
/* first byte sets the memory pointer, following are consecutive reg values */
static u8 da9063_irq_clr[] = { DA9063_REG_IRQ_MASK_A, 0xff, 0xff, 0xff, 0xff };
static u8 da9210_irq_clr[] = { DA9210_REG_MASK_A, 0xff, 0xff };
static struct i2c_msg da9063_msg = {
.len = ARRAY_SIZE(da9063_irq_clr),
.buf = da9063_irq_clr,
};
static struct i2c_msg da9210_msg = {
.len = ARRAY_SIZE(da9210_irq_clr),
.buf = da9210_irq_clr,
};
static const struct of_device_id rcar_gen2_quirk_match[] = {
{ .compatible = "dlg,da9063", .data = &da9063_msg },
{ .compatible = "dlg,da9063l", .data = &da9063_msg },
{ .compatible = "dlg,da9210", .data = &da9210_msg },
{ /* sentinel */ }
};
static int regulator_quirk_notify(struct notifier_block *nb,
unsigned long action, void *data)
{
struct regulator_quirk *pos, *tmp;
struct device *dev = data;
struct i2c_client *client;
static bool done;
int ret;
u32 mon;
if (done)
return 0;
mon = ioread32(irqc + IRQC_MONITOR);
dev_dbg(dev, "%s: %ld, IRQC_MONITOR = 0x%x\n", __func__, action, mon);
if (mon & REGULATOR_IRQ_MASK)
goto remove;
if (action != BUS_NOTIFY_ADD_DEVICE || dev->type == &i2c_adapter_type)
return 0;
client = to_i2c_client(dev);
dev_dbg(dev, "Detected %s\n", client->name);
/*
* Send message to all PMICs that share an IRQ line to deassert it.
*
* WARNING: This works only if all the PMICs are on the same I2C bus.
*/
list_for_each_entry(pos, &quirk_list, list) {
if (!pos->shared)
continue;
if (pos->np->parent != client->dev.parent->of_node)
continue;
dev_info(&client->dev, "clearing %s@0x%02x interrupts\n",
pos->id->compatible, pos->i2c_msg.addr);
ret = i2c_transfer(client->adapter, &pos->i2c_msg, 1);
if (ret != 1)
dev_err(&client->dev, "i2c error %d\n", ret);
}
mon = ioread32(irqc + IRQC_MONITOR);
if (mon & REGULATOR_IRQ_MASK)
goto remove;
return 0;
remove:
dev_info(dev, "IRQ2 is not asserted, removing quirk\n");
list_for_each_entry_safe(pos, tmp, &quirk_list, list) {
list_del(&pos->list);
of_node_put(pos->np);
kfree(pos);
Annotation
- Immediate include surface: `linux/device.h`, `linux/i2c.h`, `linux/init.h`, `linux/io.h`, `linux/list.h`, `linux/notifier.h`, `linux/of.h`, `linux/of_irq.h`.
- Detected declarations: `struct regulator_quirk`, `function regulator_quirk_notify`, `function list_for_each_entry_safe`, `function rcar_gen2_regulator_quirk`, `function for_each_matching_node_and_match`, `function list_for_each_entry`.
- Atlas domain: Architecture Layer / arch/arm.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.