1#ifndef __NVKM_VOLT_H__
2#define __NVKM_VOLT_H__
3#include <core/subdev.h>
4
5struct nvkm_voltage {
6	u32 uv;
7	u8  id;
8};
9
10struct nvkm_volt {
11	struct nvkm_subdev base;
12
13	int (*vid_get)(struct nvkm_volt *);
14	int (*get)(struct nvkm_volt *);
15	int (*vid_set)(struct nvkm_volt *, u8 vid);
16	int (*set)(struct nvkm_volt *, u32 uv);
17	int (*set_id)(struct nvkm_volt *, u8 id, int condition);
18
19	u8 vid_mask;
20	u8 vid_nr;
21	struct {
22		u32 uv;
23		u8 vid;
24	} vid[256];
25};
26
27static inline struct nvkm_volt *
28nvkm_volt(void *obj)
29{
30	return (void *)nvkm_subdev(obj, NVDEV_SUBDEV_VOLT);
31}
32
33#define nvkm_volt_create(p, e, o, d)                                        \
34	nvkm_volt_create_((p), (e), (o), sizeof(**d), (void **)d)
35#define nvkm_volt_destroy(p) ({                                             \
36	struct nvkm_volt *v = (p);                                          \
37	_nvkm_volt_dtor(nv_object(v));                                      \
38})
39#define nvkm_volt_init(p) ({                                                \
40	struct nvkm_volt *v = (p);                                          \
41	_nvkm_volt_init(nv_object(v));                                      \
42})
43#define nvkm_volt_fini(p,s)                                                 \
44	nvkm_subdev_fini((p), (s))
45
46int  nvkm_volt_create_(struct nvkm_object *, struct nvkm_object *,
47			  struct nvkm_oclass *, int, void **);
48void _nvkm_volt_dtor(struct nvkm_object *);
49int  _nvkm_volt_init(struct nvkm_object *);
50#define _nvkm_volt_fini _nvkm_subdev_fini
51
52extern struct nvkm_oclass nv40_volt_oclass;
53extern struct nvkm_oclass gk20a_volt_oclass;
54
55int nvkm_voltgpio_init(struct nvkm_volt *);
56int nvkm_voltgpio_get(struct nvkm_volt *);
57int nvkm_voltgpio_set(struct nvkm_volt *, u8);
58#endif
59