drivers/memory/tegra/tegra-emc-common.c
Source file repositories/reference/linux-study-clean/drivers/memory/tegra/tegra-emc-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/memory/tegra/tegra-emc-common.c- Extension
.c- Size
- 4144 bytes
- Lines
- 144
- Domain
- Driver Families
- Bucket
- drivers/memory
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/device.hlinux/module.hlinux/mutex.hlinux/pm_opp.htegra-emc-common.h
Detected Declarations
function tegra_emc_rate_requests_initfunction tegra_emc_request_ratefunction tegra_emc_set_min_ratefunction tegra_emc_set_max_rateexport tegra_emc_rate_requests_initexport tegra_emc_set_min_rateexport tegra_emc_set_max_rate
Annotated Snippet
if (i == type) {
min_rate = max(new_min_rate, min_rate);
max_rate = min(new_max_rate, max_rate);
} else {
min_rate = max(req->min_rate, min_rate);
max_rate = min(req->max_rate, max_rate);
}
}
if (min_rate > max_rate) {
dev_err_ratelimited(reqs->dev, "%s: type %u: out of range: %lu %lu\n",
__func__, type, min_rate, max_rate);
return -ERANGE;
}
/*
* EMC rate-changes should go via OPP API because it manages voltage
* changes.
*/
err = dev_pm_opp_set_rate(reqs->dev, min_rate);
if (err)
return err;
reqs->requested_rate[type].min_rate = new_min_rate;
reqs->requested_rate[type].max_rate = new_max_rate;
return 0;
}
/**
* tegra_emc_set_min_rate() - Update minimum rate request for a request type
* @reqs: rate request tracking state
* @rate: new minimum rate in Hz requested by @type
* @type: type of request
*
* Records @rate as the new minimum rate request for @type, recalculates target
* rate based on all requests and applies new rate through the OPP API.
*
* Context: Sleeps. Requests to same @reqs are synchronized via mutex.
*
* Return:
* * %0 - success
* * %-ERANGE - request would cause minimum rate request to be higher than
* maximum rate request
* * other - setting new rate failed
*/
int tegra_emc_set_min_rate(struct tegra_emc_rate_requests *reqs,
unsigned long rate,
enum tegra_emc_rate_request_type type)
{
struct tegra_emc_rate_request *req = &reqs->requested_rate[type];
int ret;
mutex_lock(&reqs->rate_lock);
ret = tegra_emc_request_rate(reqs, rate, req->max_rate, type);
mutex_unlock(&reqs->rate_lock);
return ret;
}
EXPORT_SYMBOL_GPL(tegra_emc_set_min_rate);
/**
* tegra_emc_set_max_rate() - Update maximum rate request for a request type
* @reqs: rate request tracking state
* @rate: new maximum rate in Hz requested by @type
* @type: type of request
*
* Records @rate as the new maximum rate request for @type, recalculates target
* rate based on all requests and applies new rate through the OPP API.
*
* Context: Sleeps. Requests to same @reqs are synchronized via mutex.
*
* Return:
* * %0 - success
* * %-ERANGE - request would cause minimum rate request to be higher than
* maximum rate request
* * other - setting new rate failed
*/
int tegra_emc_set_max_rate(struct tegra_emc_rate_requests *reqs,
unsigned long rate,
enum tegra_emc_rate_request_type type)
{
struct tegra_emc_rate_request *req = &reqs->requested_rate[type];
int ret;
mutex_lock(&reqs->rate_lock);
ret = tegra_emc_request_rate(reqs, req->min_rate, rate, type);
mutex_unlock(&reqs->rate_lock);
return ret;
Annotation
- Immediate include surface: `linux/device.h`, `linux/module.h`, `linux/mutex.h`, `linux/pm_opp.h`, `tegra-emc-common.h`.
- Detected declarations: `function tegra_emc_rate_requests_init`, `function tegra_emc_request_rate`, `function tegra_emc_set_min_rate`, `function tegra_emc_set_max_rate`, `export tegra_emc_rate_requests_init`, `export tegra_emc_set_min_rate`, `export tegra_emc_set_max_rate`.
- Atlas domain: Driver Families / drivers/memory.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.