drivers/firmware/arm_scmi/voltage.c
Source file repositories/reference/linux-study-clean/drivers/firmware/arm_scmi/voltage.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/arm_scmi/voltage.c- Extension
.c- Size
- 11085 bytes
- Lines
- 445
- Domain
- Driver Families
- Bucket
- drivers/firmware
- 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/module.hlinux/scmi_protocol.hprotocols.h
Detected Declarations
struct scmi_msg_resp_domain_attributesstruct scmi_msg_cmd_describe_levelsstruct scmi_msg_resp_describe_levelsstruct scmi_msg_cmd_config_setstruct scmi_msg_cmd_level_setstruct scmi_resp_voltage_level_set_completestruct voltage_infostruct scmi_volt_iprivenum scmi_voltage_protocol_cmdfunction scmi_protocol_attributes_getfunction scmi_init_voltage_levelsfunction iter_volt_levels_prepare_messagefunction iter_volt_levels_update_statefunction iter_volt_levels_process_responsefunction scmi_voltage_levels_getfunction scmi_voltage_descriptors_getfunction __scmi_voltage_get_u32function scmi_voltage_config_setfunction scmi_voltage_config_getfunction scmi_voltage_level_setfunction scmi_voltage_level_getfunction scmi_voltage_info_getfunction scmi_voltage_domains_num_getfunction scmi_voltage_protocol_init
Annotated Snippet
struct scmi_msg_resp_domain_attributes {
__le32 attr;
#define SUPPORTS_ASYNC_LEVEL_SET(x) ((x) & BIT(31))
#define SUPPORTS_EXTENDED_NAMES(x) ((x) & BIT(30))
u8 name[SCMI_SHORT_NAME_MAX_SIZE];
};
struct scmi_msg_cmd_describe_levels {
__le32 domain_id;
__le32 level_index;
};
struct scmi_msg_resp_describe_levels {
__le32 flags;
#define NUM_REMAINING_LEVELS(f) ((u16)(FIELD_GET(REMAINING_LEVELS_MASK, (f))))
#define NUM_RETURNED_LEVELS(f) ((u16)(FIELD_GET(RETURNED_LEVELS_MASK, (f))))
#define SUPPORTS_SEGMENTED_LEVELS(f) ((f) & BIT(12))
__le32 voltage[];
};
struct scmi_msg_cmd_config_set {
__le32 domain_id;
__le32 config;
};
struct scmi_msg_cmd_level_set {
__le32 domain_id;
__le32 flags;
__le32 voltage_level;
};
struct scmi_resp_voltage_level_set_complete {
__le32 domain_id;
__le32 voltage_level;
};
struct voltage_info {
unsigned int num_domains;
struct scmi_voltage_info *domains;
};
static int scmi_protocol_attributes_get(const struct scmi_protocol_handle *ph,
struct voltage_info *vinfo)
{
int ret;
struct scmi_xfer *t;
ret = ph->xops->xfer_get_init(ph, PROTOCOL_ATTRIBUTES, 0,
sizeof(__le32), &t);
if (ret)
return ret;
ret = ph->xops->do_xfer(ph, t);
if (!ret)
vinfo->num_domains =
NUM_VOLTAGE_DOMAINS(get_unaligned_le32(t->rx.buf));
ph->xops->xfer_put(ph, t);
return ret;
}
static int scmi_init_voltage_levels(struct device *dev,
struct scmi_voltage_info *v,
u32 num_returned, u32 num_remaining,
bool segmented)
{
u32 num_levels;
num_levels = num_returned + num_remaining;
/*
* segmented levels entries are represented by a single triplet
* returned all in one go.
*/
if (!num_levels ||
(segmented && (num_remaining || num_returned != 3))) {
dev_err(dev,
"Invalid level descriptor(%d/%d/%d) for voltage dom %d\n",
num_levels, num_returned, num_remaining, v->id);
return -EINVAL;
}
v->levels_uv = devm_kcalloc(dev, num_levels, sizeof(u32), GFP_KERNEL);
if (!v->levels_uv)
return -ENOMEM;
v->num_levels = num_levels;
v->segmented = segmented;
return 0;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/scmi_protocol.h`, `protocols.h`.
- Detected declarations: `struct scmi_msg_resp_domain_attributes`, `struct scmi_msg_cmd_describe_levels`, `struct scmi_msg_resp_describe_levels`, `struct scmi_msg_cmd_config_set`, `struct scmi_msg_cmd_level_set`, `struct scmi_resp_voltage_level_set_complete`, `struct voltage_info`, `struct scmi_volt_ipriv`, `enum scmi_voltage_protocol_cmd`, `function scmi_protocol_attributes_get`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.