Skip to content

Commit

Permalink
drm/nouveau/volt: namespace + nvidia gpu names (no binary change)
Browse files Browse the repository at this point in the history
The namespace of NVKM is being changed to nvkm_ instead of nouveau_,
which will be used for the DRM part of the driver.  This is being
done in order to make it very clear as to what part of the driver a
given symbol belongs to, and as a minor step towards splitting the
DRM driver out to be able to stand on its own (for virt).

Because there's already a large amount of churn here anyway, this is
as good a time as any to also switch to NVIDIA's device and chipset
naming to ease collaboration with them.

A comparison of objdump disassemblies proves no code changes.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
  • Loading branch information
Ben Skeggs committed Jan 22, 2015
1 parent 9e79a85 commit de3aaa6
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 108 deletions.
69 changes: 33 additions & 36 deletions drivers/gpu/drm/nouveau/include/nvkm/subdev/volt.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#ifndef __NOUVEAU_VOLT_H__
#define __NOUVEAU_VOLT_H__

#ifndef __NVKM_VOLT_H__
#define __NVKM_VOLT_H__
#include <core/subdev.h>
#include <core/device.h>

struct nouveau_voltage {
struct nvkm_voltage {
u32 uv;
u8 id;
};

struct nouveau_volt {
struct nouveau_subdev base;
struct nvkm_volt {
struct nvkm_subdev base;

int (*vid_get)(struct nouveau_volt *);
int (*get)(struct nouveau_volt *);
int (*vid_set)(struct nouveau_volt *, u8 vid);
int (*set)(struct nouveau_volt *, u32 uv);
int (*set_id)(struct nouveau_volt *, u8 id, int condition);
int (*vid_get)(struct nvkm_volt *);
int (*get)(struct nvkm_volt *);
int (*vid_set)(struct nvkm_volt *, u8 vid);
int (*set)(struct nvkm_volt *, u32 uv);
int (*set_id)(struct nvkm_volt *, u8 id, int condition);

u8 vid_mask;
u8 vid_nr;
Expand All @@ -26,36 +24,35 @@ struct nouveau_volt {
} vid[256];
};

static inline struct nouveau_volt *
nouveau_volt(void *obj)
static inline struct nvkm_volt *
nvkm_volt(void *obj)
{
return (void *)nouveau_subdev(obj, NVDEV_SUBDEV_VOLT);
return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_VOLT);
}

#define nouveau_volt_create(p, e, o, d) \
nouveau_volt_create_((p), (e), (o), sizeof(**d), (void **)d)
#define nouveau_volt_destroy(p) ({ \
struct nouveau_volt *v = (p); \
_nouveau_volt_dtor(nv_object(v)); \
#define nvkm_volt_create(p, e, o, d) \
nvkm_volt_create_((p), (e), (o), sizeof(**d), (void **)d)
#define nvkm_volt_destroy(p) ({ \
struct nvkm_volt *v = (p); \
_nvkm_volt_dtor(nv_object(v)); \
})
#define nouveau_volt_init(p) ({ \
struct nouveau_volt *v = (p); \
_nouveau_volt_init(nv_object(v)); \
#define nvkm_volt_init(p) ({ \
struct nvkm_volt *v = (p); \
_nvkm_volt_init(nv_object(v)); \
})
#define nouveau_volt_fini(p,s) \
nouveau_subdev_fini((p), (s))

int nouveau_volt_create_(struct nouveau_object *, struct nouveau_object *,
struct nouveau_oclass *, int, void **);
void _nouveau_volt_dtor(struct nouveau_object *);
int _nouveau_volt_init(struct nouveau_object *);
#define _nouveau_volt_fini _nouveau_subdev_fini
#define nvkm_volt_fini(p,s) \
nvkm_subdev_fini((p), (s))

extern struct nouveau_oclass nv40_volt_oclass;
extern struct nouveau_oclass gk20a_volt_oclass;
int nvkm_volt_create_(struct nvkm_object *, struct nvkm_object *,
struct nvkm_oclass *, int, void **);
void _nvkm_volt_dtor(struct nvkm_object *);
int _nvkm_volt_init(struct nvkm_object *);
#define _nvkm_volt_fini _nvkm_subdev_fini

int nouveau_voltgpio_init(struct nouveau_volt *);
int nouveau_voltgpio_get(struct nouveau_volt *);
int nouveau_voltgpio_set(struct nouveau_volt *, u8);
extern struct nvkm_oclass nv40_volt_oclass;
extern struct nvkm_oclass gk20a_volt_oclass;

int nvkm_voltgpio_init(struct nvkm_volt *);
int nvkm_voltgpio_get(struct nvkm_volt *);
int nvkm_voltgpio_set(struct nvkm_volt *, u8);
#endif
1 change: 1 addition & 0 deletions drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <subdev/therm.h>
#include <subdev/volt.h>

#include <core/device.h>
#include <core/option.h>

/******************************************************************************
Expand Down
65 changes: 31 additions & 34 deletions drivers/gpu/drm/nouveau/nvkm/subdev/volt/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
*
* Authors: Ben Skeggs
*/

#include <subdev/volt.h>

#include <subdev/bios.h>
#include <subdev/bios/vmap.h>
#include <subdev/bios/volt.h>

static int
nouveau_volt_get(struct nouveau_volt *volt)
nvkm_volt_get(struct nvkm_volt *volt)
{
if (volt->vid_get) {
int ret = volt->vid_get(volt), i;
Expand All @@ -46,7 +44,7 @@ nouveau_volt_get(struct nouveau_volt *volt)
}

static int
nouveau_volt_set(struct nouveau_volt *volt, u32 uv)
nvkm_volt_set(struct nvkm_volt *volt, u32 uv)
{
if (volt->vid_set) {
int i, ret = -EINVAL;
Expand All @@ -63,17 +61,17 @@ nouveau_volt_set(struct nouveau_volt *volt, u32 uv)
}

static int
nouveau_volt_map(struct nouveau_volt *volt, u8 id)
nvkm_volt_map(struct nvkm_volt *volt, u8 id)
{
struct nouveau_bios *bios = nouveau_bios(volt);
struct nvkm_bios *bios = nvkm_bios(volt);
struct nvbios_vmap_entry info;
u8 ver, len;
u16 vmap;

vmap = nvbios_vmap_entry_parse(bios, id, &ver, &len, &info);
if (vmap) {
if (info.link != 0xff) {
int ret = nouveau_volt_map(volt, info.link);
int ret = nvkm_volt_map(volt, info.link);
if (ret < 0)
return ret;
info.min += ret;
Expand All @@ -85,24 +83,24 @@ nouveau_volt_map(struct nouveau_volt *volt, u8 id)
}

static int
nouveau_volt_set_id(struct nouveau_volt *volt, u8 id, int condition)
nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, int condition)
{
int ret = nouveau_volt_map(volt, id);
int ret = nvkm_volt_map(volt, id);
if (ret >= 0) {
int prev = nouveau_volt_get(volt);
int prev = nvkm_volt_get(volt);
if (!condition || prev < 0 ||
(condition < 0 && ret < prev) ||
(condition > 0 && ret > prev)) {
ret = nouveau_volt_set(volt, ret);
ret = nvkm_volt_set(volt, ret);
} else {
ret = 0;
}
}
return ret;
}

static void nouveau_volt_parse_bios(struct nouveau_bios *bios,
struct nouveau_volt *volt)
static void
nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt)
{
struct nvbios_volt_entry ivid;
struct nvbios_volt info;
Expand All @@ -125,7 +123,7 @@ static void nouveau_volt_parse_bios(struct nouveau_bios *bios,
} else if (data && info.vidmask) {
for (i = 0; i < cnt; i++) {
data = nvbios_volt_entry_parse(bios, i, &ver, &hdr,
&ivid);
&ivid);
if (data) {
volt->vid[volt->vid_nr].uv = ivid.voltage;
volt->vid[volt->vid_nr].vid = ivid.vid;
Expand All @@ -137,12 +135,12 @@ static void nouveau_volt_parse_bios(struct nouveau_bios *bios,
}

int
_nouveau_volt_init(struct nouveau_object *object)
_nvkm_volt_init(struct nvkm_object *object)
{
struct nouveau_volt *volt = (void *)object;
struct nvkm_volt *volt = (void *)object;
int ret;

ret = nouveau_subdev_init(&volt->base);
ret = nvkm_subdev_init(&volt->base);
if (ret)
return ret;

Expand All @@ -158,34 +156,33 @@ _nouveau_volt_init(struct nouveau_object *object)
}

void
_nouveau_volt_dtor(struct nouveau_object *object)
_nvkm_volt_dtor(struct nvkm_object *object)
{
struct nouveau_volt *volt = (void *)object;
nouveau_subdev_destroy(&volt->base);
struct nvkm_volt *volt = (void *)object;
nvkm_subdev_destroy(&volt->base);
}

int
nouveau_volt_create_(struct nouveau_object *parent,
struct nouveau_object *engine,
struct nouveau_oclass *oclass, int length, void **pobject)
nvkm_volt_create_(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, int length, void **pobject)
{
struct nouveau_bios *bios = nouveau_bios(parent);
struct nouveau_volt *volt;
struct nvkm_bios *bios = nvkm_bios(parent);
struct nvkm_volt *volt;
int ret, i;

ret = nouveau_subdev_create_(parent, engine, oclass, 0, "VOLT",
"voltage", length, pobject);
ret = nvkm_subdev_create_(parent, engine, oclass, 0, "VOLT",
"voltage", length, pobject);
volt = *pobject;
if (ret)
return ret;

volt->get = nouveau_volt_get;
volt->set = nouveau_volt_set;
volt->set_id = nouveau_volt_set_id;
volt->get = nvkm_volt_get;
volt->set = nvkm_volt_set;
volt->set_id = nvkm_volt_set_id;

/* Assuming the non-bios device should build the voltage table later */
if (bios)
nouveau_volt_parse_bios(bios, volt);
nvkm_volt_parse_bios(bios, volt);

if (volt->vid_nr) {
for (i = 0; i < volt->vid_nr; i++) {
Expand All @@ -196,10 +193,10 @@ nouveau_volt_create_(struct nouveau_object *parent,
/*XXX: this is an assumption.. there probably exists boards
* out there with i2c-connected voltage controllers too..
*/
ret = nouveau_voltgpio_init(volt);
ret = nvkm_voltgpio_init(volt);
if (ret == 0) {
volt->vid_get = nouveau_voltgpio_get;
volt->vid_set = nouveau_voltgpio_set;
volt->vid_get = nvkm_voltgpio_get;
volt->vid_set = nvkm_voltgpio_set;
}
}

Expand Down
36 changes: 17 additions & 19 deletions drivers/gpu/drm/nouveau/nvkm/subdev/volt/gk20a.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/

#include <subdev/volt.h>
#ifdef __KERNEL__
#include <nouveau_platform.h>
#endif
#include <subdev/volt.h>

struct cvb_coef {
int c0;
Expand All @@ -35,7 +34,7 @@ struct cvb_coef {
};

struct gk20a_volt_priv {
struct nouveau_volt base;
struct nvkm_volt base;
struct regulator *vdd;
};

Expand All @@ -62,8 +61,7 @@ const struct cvb_coef gk20a_cvb_coef[] = {
* 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)
gk20a_volt_get_cvb_voltage(int speedo, int s_scale, const struct cvb_coef *coef)
{
int mv;

Expand All @@ -79,7 +77,7 @@ gk20a_volt_get_cvb_voltage(int speedo, int s_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)
const struct cvb_coef *coef)
{
int cvb_mv, mv;

Expand All @@ -103,7 +101,7 @@ gk20a_volt_calc_voltage(const struct cvb_coef *coef, int speedo)
}

static int
gk20a_volt_vid_get(struct nouveau_volt *volt)
gk20a_volt_vid_get(struct nvkm_volt *volt)
{
struct gk20a_volt_priv *priv = (void *)volt;
int i, uv;
Expand All @@ -118,7 +116,7 @@ gk20a_volt_vid_get(struct nouveau_volt *volt)
}

static int
gk20a_volt_vid_set(struct nouveau_volt *volt, u8 vid)
gk20a_volt_vid_set(struct nvkm_volt *volt, u8 vid)
{
struct gk20a_volt_priv *priv = (void *)volt;

Expand All @@ -127,7 +125,7 @@ gk20a_volt_vid_set(struct nouveau_volt *volt, u8 vid)
}

static int
gk20a_volt_set_id(struct nouveau_volt *volt, u8 id, int condition)
gk20a_volt_set_id(struct nvkm_volt *volt, u8 id, int condition)
{
struct gk20a_volt_priv *priv = (void *)volt;
int prev_uv = regulator_get_voltage(priv->vdd);
Expand All @@ -148,16 +146,16 @@ gk20a_volt_set_id(struct nouveau_volt *volt, u8 id, int condition)
}

static int
gk20a_volt_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
struct nouveau_oclass *oclass, void *data, u32 size,
struct nouveau_object **pobject)
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 nouveau_volt *volt;
struct nvkm_volt *volt;
struct nouveau_platform_device *plat;
int i, ret, uv;

ret = nouveau_volt_create(parent, engine, oclass, &priv);
ret = nvkm_volt_create(parent, engine, oclass, &priv);
*pobject = nv_object(priv);
if (ret)
return ret;
Expand Down Expand Up @@ -187,13 +185,13 @@ gk20a_volt_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
return 0;
}

struct nouveau_oclass
struct nvkm_oclass
gk20a_volt_oclass = {
.handle = NV_SUBDEV(VOLT, 0xea),
.ofuncs = &(struct nouveau_ofuncs) {
.ofuncs = &(struct nvkm_ofuncs) {
.ctor = gk20a_volt_ctor,
.dtor = _nouveau_volt_dtor,
.init = _nouveau_volt_init,
.fini = _nouveau_volt_fini,
.dtor = _nvkm_volt_dtor,
.init = _nvkm_volt_init,
.fini = _nvkm_volt_fini,
},
};
Loading

0 comments on commit de3aaa6

Please sign in to comment.