Commit 0d6f8100 authored by Karol Herbst's avatar Karol Herbst Committed by Ben Skeggs

drm/nouveau/clk: Fixup cstate selection

Now the cstatei parameter can be used of the nvkm_cstate_prog function to
select a specific cstate.

v5: Make a constant for the magic value.
    Use list_last_entry.
    Add nvkm_cstate_get here instead of in the next commit.
Signed-off-by: default avatarKarol Herbst <karolherbst@gmail.com>
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 8d08c264
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
struct nvbios_pll; struct nvbios_pll;
struct nvkm_pll_vals; struct nvkm_pll_vals;
#define NVKM_CLK_CSTATE_DEFAULT -1 /* POSTed default */
#define NVKM_CLK_CSTATE_BASE -2 /* pstate base */
#define NVKM_CLK_CSTATE_HIGHEST -3 /* highest possible */
enum nv_clk_src { enum nv_clk_src {
nv_clk_src_crystal, nv_clk_src_crystal,
nv_clk_src_href, nv_clk_src_href,
......
...@@ -74,6 +74,21 @@ nvkm_clk_adjust(struct nvkm_clk *clk, bool adjust, ...@@ -74,6 +74,21 @@ nvkm_clk_adjust(struct nvkm_clk *clk, bool adjust,
/****************************************************************************** /******************************************************************************
* C-States * C-States
*****************************************************************************/ *****************************************************************************/
static struct nvkm_cstate *
nvkm_cstate_get(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
{
struct nvkm_cstate *cstate;
if (cstatei == NVKM_CLK_CSTATE_HIGHEST)
return list_last_entry(&pstate->list, typeof(*cstate), head);
else {
list_for_each_entry(cstate, &pstate->list, head) {
if (cstate->id == cstatei)
return cstate;
}
}
return NULL;
}
static int static int
nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei) nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
{ {
...@@ -85,7 +100,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei) ...@@ -85,7 +100,7 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
int ret; int ret;
if (!list_empty(&pstate->list)) { if (!list_empty(&pstate->list)) {
cstate = list_entry(pstate->list.prev, typeof(*cstate), head); cstate = nvkm_cstate_get(clk, pstate, cstatei);
} else { } else {
cstate = &pstate->base; cstate = &pstate->base;
} }
...@@ -208,7 +223,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei) ...@@ -208,7 +223,7 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
ram->func->tidy(ram); ram->func->tidy(ram);
} }
return nvkm_cstate_prog(clk, pstate, 0); return nvkm_cstate_prog(clk, pstate, NVKM_CLK_CSTATE_HIGHEST);
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment