Commit 6052dc57 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/volt: cosmetic changes

This is purely preparation for upcoming commits, there should be no
code changes here.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent cb8bb9ce
......@@ -8,7 +8,7 @@ struct nvkm_voltage {
};
struct nvkm_volt {
struct nvkm_subdev base;
struct nvkm_subdev subdev;
int (*vid_get)(struct nvkm_volt *);
int (*get)(struct nvkm_volt *);
......
......@@ -140,7 +140,7 @@ _nvkm_volt_init(struct nvkm_object *object)
struct nvkm_volt *volt = (void *)object;
int ret;
ret = nvkm_subdev_init(&volt->base);
ret = nvkm_subdev_init(&volt->subdev);
if (ret)
return ret;
......@@ -159,7 +159,7 @@ void
_nvkm_volt_dtor(struct nvkm_object *object)
{
struct nvkm_volt *volt = (void *)object;
nvkm_subdev_destroy(&volt->base);
nvkm_subdev_destroy(&volt->subdev);
}
int
......
......@@ -33,7 +33,7 @@ struct cvb_coef {
int c5;
};
struct gk20a_volt_priv {
struct gk20a_volt {
struct nvkm_volt base;
struct regulator *vdd;
};
......@@ -101,35 +101,35 @@ gk20a_volt_calc_voltage(const struct cvb_coef *coef, int speedo)
}
static int
gk20a_volt_vid_get(struct nvkm_volt *volt)
gk20a_volt_vid_get(struct nvkm_volt *obj)
{
struct gk20a_volt_priv *priv = (void *)volt;
struct gk20a_volt *volt = container_of(obj, typeof(*volt), base);
int i, uv;
uv = regulator_get_voltage(priv->vdd);
uv = regulator_get_voltage(volt->vdd);
for (i = 0; i < volt->vid_nr; i++)
if (volt->vid[i].uv >= uv)
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 *volt, u8 vid)
gk20a_volt_vid_set(struct nvkm_volt *obj, u8 vid)
{
struct gk20a_volt_priv *priv = (void *)volt;
struct gk20a_volt *volt = container_of(obj, typeof(*volt), base);
nv_debug(volt, "set voltage as %duv\n", volt->vid[vid].uv);
return regulator_set_voltage(priv->vdd, volt->vid[vid].uv, 1200000);
nv_debug(volt, "set voltage as %duv\n", volt->base.vid[vid].uv);
return regulator_set_voltage(volt->vdd, volt->base.vid[vid].uv, 1200000);
}
static int
gk20a_volt_set_id(struct nvkm_volt *volt, u8 id, int condition)
gk20a_volt_set_id(struct nvkm_volt *obj, u8 id, int condition)
{
struct gk20a_volt_priv *priv = (void *)volt;
int prev_uv = regulator_get_voltage(priv->vdd);
int target_uv = volt->vid[id].uv;
struct gk20a_volt *volt = container_of(obj, typeof(*volt), base);
int prev_uv = regulator_get_voltage(volt->vdd);
int target_uv = volt->base.vid[id].uv;
int ret;
nv_debug(volt, "prev=%d, target=%d, condition=%d\n",
......@@ -137,7 +137,7 @@ gk20a_volt_set_id(struct nvkm_volt *volt, u8 id, int condition)
if (!condition ||
(condition < 0 && target_uv < prev_uv) ||
(condition > 0 && target_uv > prev_uv)) {
ret = gk20a_volt_vid_set(volt, volt->vid[id].vid);
ret = gk20a_volt_vid_set(&volt->base, volt->base.vid[id].vid);
} else {
ret = 0;
}
......@@ -150,36 +150,34 @@ gk20a_volt_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct gk20a_volt_priv *priv;
struct nvkm_volt *volt;
struct gk20a_volt *volt;
struct nouveau_platform_device *plat;
int i, ret, uv;
ret = nvkm_volt_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
ret = nvkm_volt_create(parent, engine, oclass, &volt);
*pobject = nv_object(volt);
if (ret)
return ret;
volt = &priv->base;
plat = nv_device_to_platform(nv_device(parent));
uv = regulator_get_voltage(plat->gpu->vdd);
nv_info(priv, "The default voltage is %duV\n", uv);
priv->vdd = plat->gpu->vdd;
priv->base.vid_get = gk20a_volt_vid_get;
priv->base.vid_set = gk20a_volt_vid_set;
priv->base.set_id = gk20a_volt_set_id;
volt->vid_nr = ARRAY_SIZE(gk20a_cvb_coef);
nv_debug(priv, "%s - vid_nr = %d\n", __func__, volt->vid_nr);
for (i = 0; i < volt->vid_nr; i++) {
volt->vid[i].vid = i;
volt->vid[i].uv = gk20a_volt_calc_voltage(&gk20a_cvb_coef[i],
nv_info(volt, "The default voltage is %duV\n", uv);
volt->vdd = plat->gpu->vdd;
volt->base.vid_get = gk20a_volt_vid_get;
volt->base.vid_set = gk20a_volt_vid_set;
volt->base.set_id = gk20a_volt_set_id;
volt->base.vid_nr = ARRAY_SIZE(gk20a_cvb_coef);
nv_debug(volt, "%s - vid_nr = %d\n", __func__, volt->base.vid_nr);
for (i = 0; i < volt->base.vid_nr; i++) {
volt->base.vid[i].vid = i;
volt->base.vid[i].uv =
gk20a_volt_calc_voltage(&gk20a_cvb_coef[i],
plat->gpu_speedo);
nv_debug(priv, "%2d: vid=%d, uv=%d\n", i, volt->vid[i].vid,
volt->vid[i].uv);
nv_debug(volt, "%2d: vid=%d, uv=%d\n", i,
volt->base.vid[i].vid, volt->base.vid[i].uv);
}
return 0;
......
......@@ -23,20 +23,16 @@
*/
#include <subdev/volt.h>
struct nv40_volt_priv {
struct nvkm_volt base;
};
static int
nv40_volt_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
struct nvkm_object **pobject)
{
struct nv40_volt_priv *priv;
struct nvkm_volt *volt;
int ret;
ret = nvkm_volt_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
ret = nvkm_volt_create(parent, engine, oclass, &volt);
*pobject = nv_object(volt);
if (ret)
return ret;
......
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