drivers/clk/qcom/gdsc.c
Source file repositories/reference/linux-study-clean/drivers/clk/qcom/gdsc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/qcom/gdsc.c- Extension
.c- Size
- 16441 bytes
- Lines
- 678
- Domain
- Driver Families
- Bucket
- drivers/clk
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitops.hlinux/delay.hlinux/err.hlinux/export.hlinux/jiffies.hlinux/kernel.hlinux/ktime.hlinux/pm_domain.hlinux/regmap.hlinux/regulator/consumer.hlinux/reset-controller.hlinux/slab.hgdsc.h
Detected Declarations
enum gdsc_statusfunction gdsc_check_statusfunction gdsc_hwctrlfunction gdsc_poll_statusfunction gdsc_update_collapse_bitfunction gdsc_toggle_logicfunction gdsc_deassert_resetfunction gdsc_assert_resetfunction gdsc_force_mem_onfunction gdsc_clear_mem_onfunction gdsc_deassert_clamp_iofunction gdsc_assert_clamp_iofunction gdsc_assert_reset_aonfunction gdsc_retain_ff_onfunction gdsc_enablefunction gdsc_disablefunction gdsc_set_hwmodefunction gdsc_get_hwmodefunction gdsc_initfunction gdsc_add_subdomain_listfunction gdsc_remove_subdomain_listfunction gdsc_pm_subdomain_removefunction gdsc_registerfunction gdsc_unregisterfunction genpd_dev_pm_attach_by_nameexport gdsc_gx_do_nothing_enable
Annotated Snippet
switch (status) {
case GDSC_ON:
return !!(val & GDSC_POWER_UP_COMPLETE);
case GDSC_OFF:
return !!(val & GDSC_POWER_DOWN_COMPLETE);
}
}
switch (status) {
case GDSC_ON:
return !!(val & PWR_ON_MASK);
case GDSC_OFF:
return !(val & PWR_ON_MASK);
}
return -EINVAL;
}
static int gdsc_hwctrl(struct gdsc *sc, bool en)
{
u32 val = en ? HW_CONTROL_MASK : 0;
return regmap_update_bits(sc->regmap, sc->gdscr, HW_CONTROL_MASK, val);
}
static int gdsc_poll_status(struct gdsc *sc, enum gdsc_status status)
{
ktime_t start;
start = ktime_get();
do {
if (gdsc_check_status(sc, status))
return 0;
} while (ktime_us_delta(ktime_get(), start) < STATUS_POLL_TIMEOUT_US);
if (gdsc_check_status(sc, status))
return 0;
return -ETIMEDOUT;
}
static int gdsc_update_collapse_bit(struct gdsc *sc, bool val)
{
u32 reg, mask;
int ret;
if (sc->collapse_mask) {
reg = sc->collapse_ctrl;
mask = sc->collapse_mask;
} else {
reg = sc->gdscr;
mask = SW_COLLAPSE_MASK;
}
ret = regmap_update_bits(sc->regmap, reg, mask, val ? mask : 0);
if (ret)
return ret;
return 0;
}
static int gdsc_toggle_logic(struct gdsc *sc, enum gdsc_status status,
bool wait)
{
int ret;
if (status == GDSC_ON && sc->rsupply) {
ret = regulator_enable(sc->rsupply);
if (ret < 0)
return ret;
}
ret = gdsc_update_collapse_bit(sc, status == GDSC_OFF);
/* If disabling votable gdscs, don't poll on status */
if ((sc->flags & VOTABLE) && status == GDSC_OFF && !wait) {
/*
* Add a short delay here to ensure that an enable
* right after it was disabled does not put it in an
* unknown state
*/
udelay(TIMEOUT_US);
return 0;
}
if (sc->gds_hw_ctrl) {
/*
* The gds hw controller asserts/de-asserts the status bit soon
* after it receives a power on/off request from a master.
* The controller then takes around 8 xo cycles to start its
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/err.h`, `linux/export.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/ktime.h`, `linux/pm_domain.h`.
- Detected declarations: `enum gdsc_status`, `function gdsc_check_status`, `function gdsc_hwctrl`, `function gdsc_poll_status`, `function gdsc_update_collapse_bit`, `function gdsc_toggle_logic`, `function gdsc_deassert_reset`, `function gdsc_assert_reset`, `function gdsc_force_mem_on`, `function gdsc_clear_mem_on`.
- Atlas domain: Driver Families / drivers/clk.
- Implementation status: integration 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.