drivers/soc/rockchip/io-domain.c
Source file repositories/reference/linux-study-clean/drivers/soc/rockchip/io-domain.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/rockchip/io-domain.c- Extension
.c- Size
- 17363 bytes
- Lines
- 759
- Domain
- Driver Families
- Bucket
- drivers/soc
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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/kernel.hlinux/module.hlinux/err.hlinux/mfd/syscon.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/regulator/consumer.h
Detected Declarations
struct rockchip_iodomainstruct rockchip_iodomain_supplystruct rockchip_iodomain_soc_datastruct rockchip_iodomainfunction rk3568_iodomain_writefunction rockchip_iodomain_writefunction rockchip_iodomain_notifyfunction thanfunction px30_iodomain_initfunction rk3288_iodomain_initfunction rk3308_iodomain_initfunction rk3328_iodomain_initfunction rk3368_iodomain_initfunction rk3399_pmu_iodomain_initfunction rockchip_iodomain_probefunction rockchip_iodomain_remove
Annotated Snippet
struct rockchip_iodomain_supply {
struct rockchip_iodomain *iod;
struct regulator *reg;
struct notifier_block nb;
int idx;
};
struct rockchip_iodomain_soc_data {
int grf_offset;
const char *supply_names[MAX_SUPPLIES];
void (*init)(struct rockchip_iodomain *iod);
int (*write)(struct rockchip_iodomain_supply *supply, int uV);
};
struct rockchip_iodomain {
struct device *dev;
struct regmap *grf;
const struct rockchip_iodomain_soc_data *soc_data;
struct rockchip_iodomain_supply supplies[MAX_SUPPLIES];
int (*write)(struct rockchip_iodomain_supply *supply, int uV);
};
static int rk3568_iodomain_write(struct rockchip_iodomain_supply *supply, int uV)
{
struct rockchip_iodomain *iod = supply->iod;
u32 is_3v3 = uV > MAX_VOLTAGE_1_8;
u32 val0, val1;
int b;
switch (supply->idx) {
case 0: /* pmuio1 */
break;
case 1: /* pmuio2 */
b = supply->idx;
val0 = BIT(16 + b) | (is_3v3 ? 0 : BIT(b));
b = supply->idx + 4;
val1 = BIT(16 + b) | (is_3v3 ? BIT(b) : 0);
regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL2, val0);
regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL2, val1);
break;
case 3: /* vccio2 */
break;
case 2: /* vccio1 */
case 4: /* vccio3 */
case 5: /* vccio4 */
case 6: /* vccio5 */
case 7: /* vccio6 */
case 8: /* vccio7 */
b = supply->idx - 1;
val0 = BIT(16 + b) | (is_3v3 ? 0 : BIT(b));
val1 = BIT(16 + b) | (is_3v3 ? BIT(b) : 0);
regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL0, val0);
regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL1, val1);
break;
default:
return -EINVAL;
}
return 0;
}
static int rockchip_iodomain_write(struct rockchip_iodomain_supply *supply,
int uV)
{
struct rockchip_iodomain *iod = supply->iod;
u32 val;
int ret;
/* set value bit */
val = (uV > MAX_VOLTAGE_1_8) ? 0 : 1;
val <<= supply->idx;
/* apply hiword-mask */
val |= (BIT(supply->idx) << 16);
ret = regmap_write(iod->grf, iod->soc_data->grf_offset, val);
if (ret)
dev_err(iod->dev, "Couldn't write to GRF\n");
return ret;
}
static int rockchip_iodomain_notify(struct notifier_block *nb,
unsigned long event,
void *data)
{
struct rockchip_iodomain_supply *supply =
container_of(nb, struct rockchip_iodomain_supply, nb);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/err.h`, `linux/mfd/syscon.h`, `linux/of.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/regulator/consumer.h`.
- Detected declarations: `struct rockchip_iodomain`, `struct rockchip_iodomain_supply`, `struct rockchip_iodomain_soc_data`, `struct rockchip_iodomain`, `function rk3568_iodomain_write`, `function rockchip_iodomain_write`, `function rockchip_iodomain_notify`, `function than`, `function px30_iodomain_init`, `function rk3288_iodomain_init`.
- Atlas domain: Driver Families / drivers/soc.
- 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.