drivers/cpufreq/brcmstb-avs-cpufreq.c
Source file repositories/reference/linux-study-clean/drivers/cpufreq/brcmstb-avs-cpufreq.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/cpufreq/brcmstb-avs-cpufreq.c- Extension
.c- Size
- 20670 bytes
- Lines
- 784
- Domain
- Driver Families
- Bucket
- drivers/cpufreq
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/cpufreq.hlinux/delay.hlinux/interrupt.hlinux/io.hlinux/module.hlinux/of_address.hlinux/platform_device.hlinux/semaphore.h
Detected Declarations
struct pmapstruct private_datafunction wait_for_avs_commandfunction __issue_avs_commandfunction irq_handlerfunction brcm_avs_parse_p1function brcm_avs_parse_p2function brcm_avs_get_pmapfunction brcm_avs_set_pmapfunction brcm_avs_get_pstatefunction brcm_avs_set_pstatefunction brcm_avs_get_voltagefunction brcm_avs_get_frequencyfunction brcm_avs_get_freq_tablefunction brcm_avs_get_pmapfunction brcm_avs_cpufreq_getfunction brcm_avs_target_indexfunction brcm_avs_suspendfunction brcm_avs_resumefunction brcm_avs_cpufreq_initfunction brcm_avs_prepare_uninitfunction brcm_avs_cpufreq_initfunction show_brcm_avs_pstatefunction show_brcm_avs_modefunction show_brcm_avs_pmapfunction show_brcm_avs_voltagefunction show_brcm_avs_frequencyfunction brcm_avs_cpufreq_probefunction brcm_avs_cpufreq_remove
Annotated Snippet
struct pmap {
unsigned int mode;
unsigned int p1;
unsigned int p2;
unsigned int state;
};
struct private_data {
void __iomem *base;
void __iomem *avs_intr_base;
struct device *dev;
struct completion done;
struct semaphore sem;
struct pmap pmap;
int host_irq;
};
static void __iomem *__map_region(const char *name)
{
struct device_node *np;
void __iomem *ptr;
np = of_find_compatible_node(NULL, NULL, name);
if (!np)
return NULL;
ptr = of_iomap(np, 0);
of_node_put(np);
return ptr;
}
static unsigned long wait_for_avs_command(struct private_data *priv,
unsigned long timeout)
{
unsigned long time_left = 0;
u32 val;
/* Event driven, wait for the command interrupt */
if (priv->host_irq >= 0)
return wait_for_completion_timeout(&priv->done,
msecs_to_jiffies(timeout));
/* Polling for command completion */
do {
time_left = timeout;
val = readl(priv->base + AVS_MBOX_STATUS);
if (val)
break;
usleep_range(1000, 2000);
} while (--timeout);
return time_left;
}
static int __issue_avs_command(struct private_data *priv, unsigned int cmd,
unsigned int num_in, unsigned int num_out,
u32 args[])
{
void __iomem *base = priv->base;
unsigned long time_left;
unsigned int i;
int ret;
u32 val;
ret = down_interruptible(&priv->sem);
if (ret)
return ret;
/*
* Make sure no other command is currently running: cmd is 0 if AVS
* co-processor is idle. Due to the guard above, we should almost never
* have to wait here.
*/
for (i = 0, val = 1; val != 0 && i < AVS_LOOP_LIMIT; i++)
val = readl(base + AVS_MBOX_COMMAND);
/* Give the caller a chance to retry if AVS is busy. */
if (i == AVS_LOOP_LIMIT) {
ret = -EAGAIN;
goto out;
}
/* Clear status before we begin. */
writel(AVS_STATUS_CLEAR, base + AVS_MBOX_STATUS);
/* Provide input parameters */
for (i = 0; i < num_in; i++)
writel(args[i], base + AVS_MBOX_PARAM(i));
Annotation
- Immediate include surface: `linux/cpufreq.h`, `linux/delay.h`, `linux/interrupt.h`, `linux/io.h`, `linux/module.h`, `linux/of_address.h`, `linux/platform_device.h`, `linux/semaphore.h`.
- Detected declarations: `struct pmap`, `struct private_data`, `function wait_for_avs_command`, `function __issue_avs_command`, `function irq_handler`, `function brcm_avs_parse_p1`, `function brcm_avs_parse_p2`, `function brcm_avs_get_pmap`, `function brcm_avs_set_pmap`, `function brcm_avs_get_pstate`.
- Atlas domain: Driver Families / drivers/cpufreq.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.