1fc782242SIlia Mirkin /*
2fc782242SIlia Mirkin * Copyright 2019 Ilia Mirkin
3fc782242SIlia Mirkin *
4fc782242SIlia Mirkin * Permission is hereby granted, free of charge, to any person obtaining a
5fc782242SIlia Mirkin * copy of this software and associated documentation files (the "Software"),
6fc782242SIlia Mirkin * to deal in the Software without restriction, including without limitation
7fc782242SIlia Mirkin * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8fc782242SIlia Mirkin * and/or sell copies of the Software, and to permit persons to whom the
9fc782242SIlia Mirkin * Software is furnished to do so, subject to the following conditions:
10fc782242SIlia Mirkin *
11fc782242SIlia Mirkin * The above copyright notice and this permission notice shall be included in
12fc782242SIlia Mirkin * all copies or substantial portions of the Software.
13fc782242SIlia Mirkin *
14fc782242SIlia Mirkin * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15fc782242SIlia Mirkin * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16fc782242SIlia Mirkin * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17fc782242SIlia Mirkin * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18fc782242SIlia Mirkin * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19fc782242SIlia Mirkin * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20fc782242SIlia Mirkin * OTHER DEALINGS IN THE SOFTWARE.
21fc782242SIlia Mirkin *
22fc782242SIlia Mirkin * Authors: Ilia Mirkin
23fc782242SIlia Mirkin */
24fc782242SIlia Mirkin #include "priv.h"
25fc782242SIlia Mirkin
26fc782242SIlia Mirkin #include <subdev/fuse.h>
27fc782242SIlia Mirkin
28fc782242SIlia Mirkin static int
gf117_volt_speedo_read(struct nvkm_volt * volt)29fc782242SIlia Mirkin gf117_volt_speedo_read(struct nvkm_volt *volt)
30fc782242SIlia Mirkin {
31fc782242SIlia Mirkin struct nvkm_device *device = volt->subdev.device;
32fc782242SIlia Mirkin struct nvkm_fuse *fuse = device->fuse;
33fc782242SIlia Mirkin
34fc782242SIlia Mirkin if (!fuse)
35fc782242SIlia Mirkin return -EINVAL;
36fc782242SIlia Mirkin
37fc782242SIlia Mirkin return nvkm_fuse_read(fuse, 0x3a8);
38fc782242SIlia Mirkin }
39fc782242SIlia Mirkin
40fc782242SIlia Mirkin static const struct nvkm_volt_func
41fc782242SIlia Mirkin gf117_volt = {
42fc782242SIlia Mirkin .oneinit = gf100_volt_oneinit,
43fc782242SIlia Mirkin .vid_get = nvkm_voltgpio_get,
44fc782242SIlia Mirkin .vid_set = nvkm_voltgpio_set,
45fc782242SIlia Mirkin .speedo_read = gf117_volt_speedo_read,
46fc782242SIlia Mirkin };
47fc782242SIlia Mirkin
48fc782242SIlia Mirkin int
gf117_volt_new(struct nvkm_device * device,enum nvkm_subdev_type type,int inst,struct nvkm_volt ** pvolt)49*d07be5d7SBen Skeggs gf117_volt_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
50*d07be5d7SBen Skeggs struct nvkm_volt **pvolt)
51fc782242SIlia Mirkin {
52fc782242SIlia Mirkin struct nvkm_volt *volt;
53fc782242SIlia Mirkin int ret;
54fc782242SIlia Mirkin
55*d07be5d7SBen Skeggs ret = nvkm_volt_new_(&gf117_volt, device, type, inst, &volt);
56fc782242SIlia Mirkin *pvolt = volt;
57fc782242SIlia Mirkin if (ret)
58fc782242SIlia Mirkin return ret;
59fc782242SIlia Mirkin
60fc782242SIlia Mirkin return nvkm_voltgpio_init(volt);
61fc782242SIlia Mirkin }
62