提交 6052dc57 编写于 作者: B Ben Skeggs

drm/nouveau/volt: cosmetic changes

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