drivers/soc/qcom/ramp_controller.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/ramp_controller.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/ramp_controller.c- Extension
.c- Size
- 9292 bytes
- Lines
- 346
- 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/bitfield.hlinux/kernel.hlinux/module.hlinux/of.hlinux/of_platform.hlinux/platform_device.hlinux/regmap.hlinux/types.h
Detected Declarations
struct qcom_ramp_controller_descstruct qcom_ramp_controllerfunction rc_wait_for_updatefunction rc_set_cfg_updatefunction rc_write_cfgfunction rc_ramp_ctrl_enablefunction qcom_ramp_controller_startfunction qcom_ramp_controller_probefunction qcom_ramp_controller_removefunction qcom_ramp_controller_init
Annotated Snippet
struct qcom_ramp_controller_desc {
const struct reg_sequence *cfg_dfs_sid;
const struct reg_sequence *cfg_link_sid;
const struct reg_sequence *cfg_lmh_sid;
const struct reg_sequence *cfg_ramp_en;
const struct reg_sequence *cfg_ramp_dis;
u8 cmd_reg;
u8 num_dfs_sids;
u8 num_link_sids;
u8 num_lmh_sids;
u8 num_ramp_en;
u8 num_ramp_dis;
};
/**
* struct qcom_ramp_controller - Main driver structure
* @regmap: Regmap handle
* @desc: SoC specific parameters
*/
struct qcom_ramp_controller {
struct regmap *regmap;
const struct qcom_ramp_controller_desc *desc;
};
/**
* rc_wait_for_update() - Wait for Ramp Controller root update
* @qrc: Main driver structure
*
* Return: Zero for success or negative number for failure
*/
static int rc_wait_for_update(struct qcom_ramp_controller *qrc)
{
const struct qcom_ramp_controller_desc *d = qrc->desc;
struct regmap *r = qrc->regmap;
u32 val;
int ret;
ret = regmap_set_bits(r, d->cmd_reg, RC_ROOT_EN);
if (ret)
return ret;
return regmap_read_poll_timeout(r, d->cmd_reg, val, !(val & RC_UPDATE_EN),
1, RC_UPDATE_TIMEOUT_US);
}
/**
* rc_set_cfg_update() - Ramp Controller configuration update
* @qrc: Main driver structure
* @ce: Configuration entry to update
*
* Return: Zero for success or negative number for failure
*/
static int rc_set_cfg_update(struct qcom_ramp_controller *qrc, u8 ce)
{
const struct qcom_ramp_controller_desc *d = qrc->desc;
struct regmap *r = qrc->regmap;
u32 ack, val;
int ret;
/* The ack bit is between bits 16-31 of RC_REG_CFG_UPDATE */
ack = FIELD_PREP(RC_CFG_ACK, BIT(ce));
/* Write the configuration type first... */
ret = regmap_set_bits(r, d->cmd_reg + RC_REG_CFG_UPDATE, ce);
if (ret)
return ret;
/* ...and after that, enable the update bit to sync the changes */
ret = regmap_set_bits(r, d->cmd_reg + RC_REG_CFG_UPDATE, RC_CFG_UPDATE_EN);
if (ret)
return ret;
/* Wait for the changes to go through */
ret = regmap_read_poll_timeout(r, d->cmd_reg + RC_REG_CFG_UPDATE, val,
val & ack, 1, RC_UPDATE_TIMEOUT_US);
if (ret)
return ret;
/*
* Configuration update success! The CFG_UPDATE register will not be
* cleared automatically upon applying the configuration, so we have
* to do that manually in order to leave the ramp controller in a
* predictable and clean state.
*/
ret = regmap_write(r, d->cmd_reg + RC_REG_CFG_UPDATE, 0);
if (ret)
return ret;
/* Wait for the update bit cleared ack */
return regmap_read_poll_timeout(r, d->cmd_reg + RC_REG_CFG_UPDATE,
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/of_platform.h`, `linux/platform_device.h`, `linux/regmap.h`, `linux/types.h`.
- Detected declarations: `struct qcom_ramp_controller_desc`, `struct qcom_ramp_controller`, `function rc_wait_for_update`, `function rc_set_cfg_update`, `function rc_write_cfg`, `function rc_ramp_ctrl_enable`, `function qcom_ramp_controller_start`, `function qcom_ramp_controller_probe`, `function qcom_ramp_controller_remove`, `function qcom_ramp_controller_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.