[Nouveau] [PATCH v4 18/37] volt: add speedo

Martin Peres martin.peres at free.fr
Tue Apr 19 21:17:02 UTC 2016


On 18/04/16 22:13, Karol Herbst wrote:
> Signed-off-by: Karol Herbst <nouveau at karolherbst.de>
> ---
>   bin/nv_cmp_volt.c                      |  2 +-
>   drm/nouveau/include/nvkm/subdev/volt.h |  2 ++
>   drm/nouveau/nvkm/subdev/volt/base.c    | 12 ++++++++++++
>   drm/nouveau/nvkm/subdev/volt/priv.h    |  1 +
>   4 files changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/bin/nv_cmp_volt.c b/bin/nv_cmp_volt.c
> index 34147b9..e61056c 100644
> --- a/bin/nv_cmp_volt.c
> +++ b/bin/nv_cmp_volt.c
> @@ -53,7 +53,7 @@ main(int argc, char **argv)
>   
>   	ret = u_device("lib", argv[0], "error", true, true,
>                          (1ULL << NVKM_SUBDEV_CLK) |
> -//                       (1ULL << NVKM_SUBDEV_FUSE) |
> +                       (1ULL << NVKM_SUBDEV_FUSE) |

This change comes a little early, as fuse would be an implementation 
detail (coming in the next patch) to read the speedo.

Either way, I do not really care, as this won't go in the kernel anyway 
and it does not hurt to enable this a little early.

Reviewed-by: Martin Peres <martin.peres at free.fr>

>                          (1ULL << NVKM_SUBDEV_GPIO) |
>   //                       (1ULL << NVKM_SUBDEV_I2C) |
>                          (1ULL << NVKM_SUBDEV_PCI) |
> diff --git a/drm/nouveau/include/nvkm/subdev/volt.h b/drm/nouveau/include/nvkm/subdev/volt.h
> index f223577..4cb0292 100644
> --- a/drm/nouveau/include/nvkm/subdev/volt.h
> +++ b/drm/nouveau/include/nvkm/subdev/volt.h
> @@ -20,6 +20,8 @@ struct nvkm_volt {
>   	u8 max0_id;
>   	u8 max1_id;
>   	u8 max2_id;
> +
> +	int speedo;
>   };
>   
>   int nvkm_volt_map(struct nvkm_volt *volt, u8 id, u8 temperature);
> diff --git a/drm/nouveau/nvkm/subdev/volt/base.c b/drm/nouveau/nvkm/subdev/volt/base.c
> index 028c6e2..cecfac6 100644
> --- a/drm/nouveau/nvkm/subdev/volt/base.c
> +++ b/drm/nouveau/nvkm/subdev/volt/base.c
> @@ -201,6 +201,14 @@ nvkm_volt_parse_bios(struct nvkm_bios *bios, struct nvkm_volt *volt)
>   }
>   
>   static int
> +nvkm_volt_speedo_read(struct nvkm_volt *volt)
> +{
> +	if (volt->func->speedo_read)
> +		return volt->func->speedo_read(volt);
> +	return -EINVAL;
> +}
> +
> +static int
>   nvkm_volt_init(struct nvkm_subdev *subdev)
>   {
>   	struct nvkm_volt *volt = nvkm_volt(subdev);
> @@ -262,6 +270,10 @@ nvkm_volt_ctor(const struct nvkm_volt_func *func, struct nvkm_device *device,
>   				   volt->vid[i].vid, volt->vid[i].uv);
>   		}
>   	}
> +
> +	volt->speedo = nvkm_volt_speedo_read(volt);
> +	if (volt->speedo > 0)
> +		nvkm_debug(&volt->subdev, "speedo %x\n", volt->speedo);
>   }
>   
>   int
> diff --git a/drm/nouveau/nvkm/subdev/volt/priv.h b/drm/nouveau/nvkm/subdev/volt/priv.h
> index d5140d9..9b34e9f 100644
> --- a/drm/nouveau/nvkm/subdev/volt/priv.h
> +++ b/drm/nouveau/nvkm/subdev/volt/priv.h
> @@ -14,6 +14,7 @@ struct nvkm_volt_func {
>   	int (*vid_get)(struct nvkm_volt *);
>   	int (*vid_set)(struct nvkm_volt *, u8 vid);
>   	int (*set_id)(struct nvkm_volt *, u8 id, int condition);
> +	int (*speedo_read)(struct nvkm_volt *);
>   };
>   
>   int nvkm_voltgpio_init(struct nvkm_volt *);



More information about the Nouveau mailing list