1 /* SPDX-License-Identifier: MIT */
4 #include <core/subdev.h>
5 #include <subdev/pci.h>
9 #define NVKM_CLK_CSTATE_DEFAULT -1 /* POSTed default */
10 #define NVKM_CLK_CSTATE_BASE -2 /* pstate base */
11 #define NVKM_CLK_CSTATE_HIGHEST -3 /* highest possible */
20 nv_clk_src_hclkm2d3, /* NVAA */
21 nv_clk_src_hclkm4, /* NVAA */
22 nv_clk_src_cclk, /* NVAA */
29 nv_clk_src_mpllsrcref,
56 struct list_head head;
58 u32 domain[nv_clk_src_max];
63 struct list_head head;
64 struct list_head list; /* c-states */
65 struct nvkm_cstate base;
68 enum nvkm_pcie_speed pcie_speed;
74 u8 bios; /* 0xff for none */
75 #define NVKM_CLK_DOM_FLAG_CORE 0x01
76 #define NVKM_CLK_DOM_FLAG_VPSTATE 0x02
83 const struct nvkm_clk_func *func;
84 struct nvkm_subdev subdev;
86 const struct nvkm_domain *domains;
87 struct nvkm_pstate bstate;
89 struct list_head states;
92 struct work_struct work;
93 wait_queue_head_t wait;
97 int pstate; /* current */
98 int ustate_ac; /* user-requested (-1 disabled, -2 perfmon) */
99 int ustate_dc; /* user-requested (-1 disabled, -2 perfmon) */
100 int astate; /* perfmon adjustment (base) */
101 int dstate; /* display adjustment (min+) */
105 #define NVKM_CLK_BOOST_NONE 0x0
106 #define NVKM_CLK_BOOST_BIOS 0x1
107 #define NVKM_CLK_BOOST_FULL 0x2
112 /*XXX: die, these are here *only* to support the completely
113 * bat-shit insane what-was-nouveau_hw.c code
115 int (*pll_calc)(struct nvkm_clk *, struct nvbios_pll *, int clk,
116 struct nvkm_pll_vals *pv);
117 int (*pll_prog)(struct nvkm_clk *, u32 reg1, struct nvkm_pll_vals *pv);
120 int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);
121 int nvkm_clk_ustate(struct nvkm_clk *, int req, int pwr);
122 int nvkm_clk_astate(struct nvkm_clk *, int req, int rel, bool wait);
123 int nvkm_clk_dstate(struct nvkm_clk *, int req, int rel);
124 int nvkm_clk_tstate(struct nvkm_clk *, u8 temperature);
125 int nvkm_clk_pwrsrc(struct nvkm_device *);
127 int nv04_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
128 int nv40_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
129 int nv50_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
130 int g84_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
131 int mcp77_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
132 int gt215_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
133 int gf100_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
134 int gk104_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
135 int gk20a_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);
136 int gm20b_clk_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_clk **);