drivers/clk/tegra/clk-bpmp.c
Source file repositories/reference/linux-study-clean/drivers/clk/tegra/clk-bpmp.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/clk/tegra/clk-bpmp.c- Extension
.c- Size
- 16908 bytes
- Lines
- 706
- Domain
- Driver Families
- Bucket
- drivers/clk
- 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/clk-provider.hlinux/device.hlinux/seq_buf.hlinux/slab.hsoc/tegra/bpmp.hsoc/tegra/bpmp-abi.h
Detected Declarations
struct tegra_bpmp_clk_infostruct tegra_bpmp_clkstruct tegra_bpmp_clk_messagefunction tegra_bpmp_clk_transferfunction tegra_bpmp_clk_preparefunction tegra_bpmp_clk_unpreparefunction tegra_bpmp_clk_is_preparedfunction tegra_bpmp_clk_recalc_ratefunction tegra_bpmp_clk_determine_ratefunction tegra_bpmp_clk_set_parentfunction tegra_bpmp_clk_get_parentfunction tegra_bpmp_clk_set_ratefunction tegra_bpmp_clk_get_max_idfunction tegra_bpmp_clk_get_infofunction tegra_bpmp_clk_info_dumpfunction tegra_bpmp_probe_clocksfunction tegra_bpmp_clk_id_to_indexfunction tegra_bpmp_clk_findfunction tegra_bpmp_clk_registerfunction tegra_bpmp_register_clocks_onefunction tegra_bpmp_register_clocksfunction tegra_bpmp_unregister_clocksfunction tegra_bpmp_init_clocks
Annotated Snippet
struct tegra_bpmp_clk_info {
unsigned int id;
char name[MRQ_CLK_NAME_MAXLEN];
unsigned int parents[MRQ_CLK_MAX_PARENTS];
unsigned int num_parents;
unsigned long flags;
};
struct tegra_bpmp_clk {
struct clk_hw hw;
struct tegra_bpmp *bpmp;
unsigned int id;
unsigned int num_parents;
unsigned int *parents;
};
static inline struct tegra_bpmp_clk *to_tegra_bpmp_clk(struct clk_hw *hw)
{
return container_of(hw, struct tegra_bpmp_clk, hw);
}
struct tegra_bpmp_clk_message {
unsigned int cmd;
unsigned int id;
struct {
const void *data;
size_t size;
} tx;
struct {
void *data;
size_t size;
int ret;
} rx;
};
static int tegra_bpmp_clk_transfer(struct tegra_bpmp *bpmp,
const struct tegra_bpmp_clk_message *clk)
{
struct mrq_clk_request request;
struct tegra_bpmp_message msg;
void *req = &request;
int err;
memset(&request, 0, sizeof(request));
request.cmd_and_id = (clk->cmd << 24) | clk->id;
/*
* The mrq_clk_request structure has an anonymous union at offset 4
* that contains all possible sub-command structures. Copy the data
* to that union. Ideally we'd be able to refer to it by name, but
* doing so would require changing the ABI header and increase the
* maintenance burden.
*/
memcpy(req + 4, clk->tx.data, clk->tx.size);
memset(&msg, 0, sizeof(msg));
msg.mrq = MRQ_CLK;
msg.tx.data = &request;
msg.tx.size = sizeof(request);
msg.rx.data = clk->rx.data;
msg.rx.size = clk->rx.size;
err = tegra_bpmp_transfer(bpmp, &msg);
if (err < 0)
return err;
else if (msg.rx.ret < 0)
return -EINVAL;
return 0;
}
static int tegra_bpmp_clk_prepare(struct clk_hw *hw)
{
struct tegra_bpmp_clk *clk = to_tegra_bpmp_clk(hw);
struct tegra_bpmp_clk_message msg;
memset(&msg, 0, sizeof(msg));
msg.cmd = CMD_CLK_ENABLE;
msg.id = clk->id;
return tegra_bpmp_clk_transfer(clk->bpmp, &msg);
}
static void tegra_bpmp_clk_unprepare(struct clk_hw *hw)
{
struct tegra_bpmp_clk *clk = to_tegra_bpmp_clk(hw);
Annotation
- Immediate include surface: `linux/clk-provider.h`, `linux/device.h`, `linux/seq_buf.h`, `linux/slab.h`, `soc/tegra/bpmp.h`, `soc/tegra/bpmp-abi.h`.
- Detected declarations: `struct tegra_bpmp_clk_info`, `struct tegra_bpmp_clk`, `struct tegra_bpmp_clk_message`, `function tegra_bpmp_clk_transfer`, `function tegra_bpmp_clk_prepare`, `function tegra_bpmp_clk_unprepare`, `function tegra_bpmp_clk_is_prepared`, `function tegra_bpmp_clk_recalc_rate`, `function tegra_bpmp_clk_determine_rate`, `function tegra_bpmp_clk_set_parent`.
- Atlas domain: Driver Families / drivers/clk.
- 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.