Lines Matching refs:volt

32 nvkm_volt_get(struct nvkm_volt *volt)  in nvkm_volt_get()  argument
36 if (volt->func->volt_get) in nvkm_volt_get()
37 return volt->func->volt_get(volt); in nvkm_volt_get()
39 ret = volt->func->vid_get(volt); in nvkm_volt_get()
41 for (i = 0; i < volt->vid_nr; i++) { in nvkm_volt_get()
42 if (volt->vid[i].vid == ret) in nvkm_volt_get()
43 return volt->vid[i].uv; in nvkm_volt_get()
51 nvkm_volt_set(struct nvkm_volt *volt, u32 uv) in nvkm_volt_set() argument
53 struct nvkm_subdev *subdev = &volt->subdev; in nvkm_volt_set()
54 int i, ret = -EINVAL, best_err = volt->max_uv, best = -1; in nvkm_volt_set()
56 if (volt->func->volt_set) in nvkm_volt_set()
57 return volt->func->volt_set(volt, uv); in nvkm_volt_set()
59 for (i = 0; i < volt->vid_nr; i++) { in nvkm_volt_set()
60 int err = volt->vid[i].uv - uv; in nvkm_volt_set()
75 ret = volt->func->vid_set(volt, volt->vid[best].vid); in nvkm_volt_set()
77 volt->vid[best].uv, ret); in nvkm_volt_set()
82 nvkm_volt_map_min(struct nvkm_volt *volt, u8 id) in nvkm_volt_map_min() argument
84 struct nvkm_bios *bios = volt->subdev.device->bios; in nvkm_volt_map_min()
92 int ret = nvkm_volt_map_min(volt, info.link); in nvkm_volt_map_min()
104 nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temp) in nvkm_volt_map() argument
106 struct nvkm_bios *bios = volt->subdev.device->bios; in nvkm_volt_map()
115 if (volt->speedo < 0) in nvkm_volt_map()
116 return volt->speedo; in nvkm_volt_map()
120 result += div64_s64((s64)info.arg[1] * volt->speedo, 10); in nvkm_volt_map()
121 result += div64_s64((s64)info.arg[2] * volt->speedo * volt->speedo, 100000); in nvkm_volt_map()
127 result += ((s64)info.arg[1] * volt->speedo * 15625) >> 18; in nvkm_volt_map()
129 result += ((s64)info.arg[3] * volt->speedo * temp * 15625) >> 18; in nvkm_volt_map()
130 result += ((s64)info.arg[4] * volt->speedo * volt->speedo * 15625) >> 30; in nvkm_volt_map()
148 int ret = nvkm_volt_map(volt, info.link, temp); in nvkm_volt_map()
160 nvkm_volt_set_id(struct nvkm_volt *volt, u8 id, u8 min_id, u8 temp, in nvkm_volt_set_id() argument
165 if (volt->func->set_id) in nvkm_volt_set_id()
166 return volt->func->set_id(volt, id, condition); in nvkm_volt_set_id()
168 ret = nvkm_volt_map(volt, id, temp); in nvkm_volt_set_id()
170 int prev = nvkm_volt_get(volt); in nvkm_volt_set_id()
174 int min = nvkm_volt_map(volt, min_id, temp); in nvkm_volt_set_id()
177 ret = nvkm_volt_set(volt, ret); in nvkm_volt_set_id()
186 nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt) in nvkm_volt_parse_bios() argument
198 volt->min_uv = info.min; in nvkm_volt_parse_bios()
199 volt->max_uv = info.max; in nvkm_volt_parse_bios()
203 volt->vid[volt->vid_nr].uv = info.base; in nvkm_volt_parse_bios()
204 volt->vid[volt->vid_nr].vid = i; in nvkm_volt_parse_bios()
205 volt->vid_nr++; in nvkm_volt_parse_bios()
209 volt->vid_mask = info.vidmask; in nvkm_volt_parse_bios()
212 volt->min_uv = 0xffffffff; in nvkm_volt_parse_bios()
213 volt->max_uv = 0; in nvkm_volt_parse_bios()
218 volt->vid[volt->vid_nr].uv = ivid.voltage; in nvkm_volt_parse_bios()
219 volt->vid[volt->vid_nr].vid = ivid.vid; in nvkm_volt_parse_bios()
220 volt->vid_nr++; in nvkm_volt_parse_bios()
221 volt->min_uv = min(volt->min_uv, ivid.voltage); in nvkm_volt_parse_bios()
222 volt->max_uv = max(volt->max_uv, ivid.voltage); in nvkm_volt_parse_bios()
225 volt->vid_mask = info.vidmask; in nvkm_volt_parse_bios()
227 volt->min_uv = info.base; in nvkm_volt_parse_bios()
228 volt->max_uv = info.base + info.pwm_range; in nvkm_volt_parse_bios()
233 nvkm_volt_speedo_read(struct nvkm_volt *volt) in nvkm_volt_speedo_read() argument
235 if (volt->func->speedo_read) in nvkm_volt_speedo_read()
236 return volt->func->speedo_read(volt); in nvkm_volt_speedo_read()
243 struct nvkm_volt *volt = nvkm_volt(subdev); in nvkm_volt_init() local
244 int ret = nvkm_volt_get(volt); in nvkm_volt_init()
257 struct nvkm_volt *volt = nvkm_volt(subdev); in nvkm_volt_oneinit() local
259 volt->speedo = nvkm_volt_speedo_read(volt); in nvkm_volt_oneinit()
260 if (volt->speedo > 0) in nvkm_volt_oneinit()
261 nvkm_debug(&volt->subdev, "speedo %x\n", volt->speedo); in nvkm_volt_oneinit()
263 if (volt->func->oneinit) in nvkm_volt_oneinit()
264 return volt->func->oneinit(volt); in nvkm_volt_oneinit()
284 enum nvkm_subdev_type type, int inst, struct nvkm_volt *volt) in nvkm_volt_ctor() argument
289 nvkm_subdev_ctor(&nvkm_volt, device, type, inst, &volt->subdev); in nvkm_volt_ctor()
290 volt->func = func; in nvkm_volt_ctor()
297 nvkm_volt_parse_bios(bios, volt); in nvkm_volt_ctor()
298 nvkm_debug(&volt->subdev, "min: %iuv max: %iuv\n", in nvkm_volt_ctor()
299 volt->min_uv, volt->max_uv); in nvkm_volt_ctor()
302 volt->max0_id = vmap.max0; in nvkm_volt_ctor()
303 volt->max1_id = vmap.max1; in nvkm_volt_ctor()
304 volt->max2_id = vmap.max2; in nvkm_volt_ctor()
306 volt->max0_id = 0xff; in nvkm_volt_ctor()
307 volt->max1_id = 0xff; in nvkm_volt_ctor()
308 volt->max2_id = 0xff; in nvkm_volt_ctor()
312 if (volt->vid_nr) { in nvkm_volt_ctor()
313 for (i = 0; i < volt->vid_nr; i++) { in nvkm_volt_ctor()
314 nvkm_debug(&volt->subdev, "VID %02x: %duv\n", in nvkm_volt_ctor()
315 volt->vid[i].vid, volt->vid[i].uv); in nvkm_volt_ctor()