drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c- Extension
.c- Size
- 5780 bytes
- Lines
- 187
- Domain
- Driver Families
- Bucket
- drivers/gpu
- 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
priv.hcore/tegra.hgk20a.h
Detected Declarations
function gk20a_volt_get_cvb_voltagefunction gk20a_volt_get_cvb_t_voltagefunction gk20a_volt_calc_voltagefunction gk20a_volt_vid_getfunction gk20a_volt_vid_setfunction gk20a_volt_set_idfunction gk20a_volt_ctorfunction gk20a_volt_new
Annotated Snippet
#define gk20a_volt(p) container_of((p), struct gk20a_volt, base)
#include "priv.h"
#include <core/tegra.h>
#include "gk20a.h"
static const struct cvb_coef gk20a_cvb_coef[] = {
/* MHz, c0, c1, c2, c3, c4, c5 */
/* 72 */ { 1209886, -36468, 515, 417, -13123, 203},
/* 108 */ { 1130804, -27659, 296, 298, -10834, 221},
/* 180 */ { 1162871, -27110, 247, 238, -10681, 268},
/* 252 */ { 1220458, -28654, 247, 179, -10376, 298},
/* 324 */ { 1280953, -30204, 247, 119, -9766, 304},
/* 396 */ { 1344547, -31777, 247, 119, -8545, 292},
/* 468 */ { 1420168, -34227, 269, 60, -7172, 256},
/* 540 */ { 1490757, -35955, 274, 60, -5188, 197},
/* 612 */ { 1599112, -42583, 398, 0, -1831, 119},
/* 648 */ { 1366986, -16459, -274, 0, -3204, 72},
/* 684 */ { 1391884, -17078, -274, -60, -1526, 30},
/* 708 */ { 1415522, -17497, -274, -60, -458, 0},
/* 756 */ { 1464061, -18331, -274, -119, 1831, -72},
/* 804 */ { 1524225, -20064, -254, -119, 4272, -155},
/* 852 */ { 1608418, -21643, -269, 0, 763, -48},
};
/*
* cvb_mv = ((c2 * speedo / s_scale + c1) * speedo / s_scale + c0)
*/
static inline int
gk20a_volt_get_cvb_voltage(int speedo, int s_scale, const struct cvb_coef *coef)
{
int mv;
mv = DIV_ROUND_CLOSEST(coef->c2 * speedo, s_scale);
mv = DIV_ROUND_CLOSEST((mv + coef->c1) * speedo, s_scale) + coef->c0;
return mv;
}
/*
* cvb_t_mv =
* ((c2 * speedo / s_scale + c1) * speedo / s_scale + c0) +
* ((c3 * speedo / s_scale + c4 + c5 * T / t_scale) * T / t_scale)
*/
static inline int
gk20a_volt_get_cvb_t_voltage(int speedo, int temp, int s_scale, int t_scale,
const struct cvb_coef *coef)
{
int cvb_mv, mv;
cvb_mv = gk20a_volt_get_cvb_voltage(speedo, s_scale, coef);
mv = DIV_ROUND_CLOSEST(coef->c3 * speedo, s_scale) + coef->c4 +
DIV_ROUND_CLOSEST(coef->c5 * temp, t_scale);
mv = DIV_ROUND_CLOSEST(mv * temp, t_scale) + cvb_mv;
return mv;
}
static int
gk20a_volt_calc_voltage(const struct cvb_coef *coef, int speedo)
{
static const int v_scale = 1000;
int mv;
mv = gk20a_volt_get_cvb_t_voltage(speedo, -10, 100, 10, coef);
mv = DIV_ROUND_UP(mv, v_scale);
return mv * 1000;
}
static int
gk20a_volt_vid_get(struct nvkm_volt *base)
{
struct gk20a_volt *volt = gk20a_volt(base);
int i, uv;
uv = regulator_get_voltage(volt->vdd);
for (i = 0; i < volt->base.vid_nr; i++)
if (volt->base.vid[i].uv >= uv)
return i;
return -EINVAL;
}
static int
gk20a_volt_vid_set(struct nvkm_volt *base, u8 vid)
{
struct gk20a_volt *volt = gk20a_volt(base);
struct nvkm_subdev *subdev = &volt->base.subdev;
Annotation
- Immediate include surface: `priv.h`, `core/tegra.h`, `gk20a.h`.
- Detected declarations: `function gk20a_volt_get_cvb_voltage`, `function gk20a_volt_get_cvb_t_voltage`, `function gk20a_volt_calc_voltage`, `function gk20a_volt_vid_get`, `function gk20a_volt_vid_set`, `function gk20a_volt_set_id`, `function gk20a_volt_ctor`, `function gk20a_volt_new`.
- Atlas domain: Driver Families / drivers/gpu.
- 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.