1 #ifndef __NOUVEAU_CLK_H__
2 #define __NOUVEAU_CLK_H__
4 #include <core/device.h>
5 #include <core/subdev.h>
7 struct nouveau_pll_vals;
17 nv_clk_src_hclkm2d3, /* NVAA */
18 nv_clk_src_hclkm4, /* NVAA */
19 nv_clk_src_cclk, /* NVAA */
26 nv_clk_src_mpllsrcref,
52 struct nouveau_cstate {
53 struct list_head head;
55 u32 domain[nv_clk_src_max];
58 struct nouveau_pstate {
59 struct list_head head;
60 struct list_head list; /* c-states */
61 struct nouveau_cstate base;
67 struct nouveau_subdev base;
69 struct nouveau_domain *domains;
70 struct nouveau_pstate bstate;
72 struct list_head states;
75 struct work_struct work;
76 wait_queue_head_t wait;
79 struct nvkm_notify pwrsrc_ntfy;
81 int pstate; /* current */
82 int ustate_ac; /* user-requested (-1 disabled, -2 perfmon) */
83 int ustate_dc; /* user-requested (-1 disabled, -2 perfmon) */
84 int astate; /* perfmon adjustment (base) */
85 int tstate; /* thermal adjustment (max-) */
86 int dstate; /* display adjustment (min+) */
90 int (*read)(struct nouveau_clk *, enum nv_clk_src);
91 int (*calc)(struct nouveau_clk *, struct nouveau_cstate *);
92 int (*prog)(struct nouveau_clk *);
93 void (*tidy)(struct nouveau_clk *);
95 /*XXX: die, these are here *only* to support the completely
96 * bat-shit insane what-was-nouveau_hw.c code
98 int (*pll_calc)(struct nouveau_clk *, struct nvbios_pll *,
99 int clk, struct nouveau_pll_vals *pv);
100 int (*pll_prog)(struct nouveau_clk *, u32 reg1,
101 struct nouveau_pll_vals *pv);
104 static inline struct nouveau_clk *
105 nouveau_clk(void *obj)
107 return (void *)nouveau_subdev(obj, NVDEV_SUBDEV_CLK);
110 struct nouveau_domain {
111 enum nv_clk_src name;
112 u8 bios; /* 0xff for none */
113 #define NVKM_CLK_DOM_FLAG_CORE 0x01
119 #define nouveau_clk_create(p,e,o,i,r,s,n,d) \
120 nouveau_clk_create_((p), (e), (o), (i), (r), (s), (n), sizeof(**d), \
122 #define nouveau_clk_destroy(p) ({ \
123 struct nouveau_clk *clk = (p); \
124 _nouveau_clk_dtor(nv_object(clk)); \
126 #define nouveau_clk_init(p) ({ \
127 struct nouveau_clk *clk = (p); \
128 _nouveau_clk_init(nv_object(clk)); \
130 #define nouveau_clk_fini(p,s) ({ \
131 struct nouveau_clk *clk = (p); \
132 _nouveau_clk_fini(nv_object(clk), (s)); \
135 int nouveau_clk_create_(struct nouveau_object *, struct nouveau_object *,
136 struct nouveau_oclass *,
137 struct nouveau_domain *, struct nouveau_pstate *,
138 int, bool, int, void **);
139 void _nouveau_clk_dtor(struct nouveau_object *);
140 int _nouveau_clk_init(struct nouveau_object *);
141 int _nouveau_clk_fini(struct nouveau_object *, bool);
143 extern struct nouveau_oclass nv04_clk_oclass;
144 extern struct nouveau_oclass nv40_clk_oclass;
145 extern struct nouveau_oclass *nv50_clk_oclass;
146 extern struct nouveau_oclass *nv84_clk_oclass;
147 extern struct nouveau_oclass *nvaa_clk_oclass;
148 extern struct nouveau_oclass nva3_clk_oclass;
149 extern struct nouveau_oclass nvc0_clk_oclass;
150 extern struct nouveau_oclass nve0_clk_oclass;
151 extern struct nouveau_oclass gk20a_clk_oclass;
153 int nv04_clk_pll_set(struct nouveau_clk *, u32 type, u32 freq);
154 int nv04_clk_pll_calc(struct nouveau_clk *, struct nvbios_pll *,
155 int clk, struct nouveau_pll_vals *);
156 int nv04_clk_pll_prog(struct nouveau_clk *, u32 reg1,
157 struct nouveau_pll_vals *);
158 int nva3_clk_pll_calc(struct nouveau_clk *, struct nvbios_pll *,
159 int clk, struct nouveau_pll_vals *);
161 int nouveau_clk_ustate(struct nouveau_clk *, int req, int pwr);
162 int nouveau_clk_astate(struct nouveau_clk *, int req, int rel, bool wait);
163 int nouveau_clk_dstate(struct nouveau_clk *, int req, int rel);
164 int nouveau_clk_tstate(struct nouveau_clk *, int req, int rel);