From patchwork Thu Aug 31 02:55:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rhys Kidd X-Patchwork-Id: 9931665 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D71E1603B4 for ; Thu, 31 Aug 2017 09:39:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C966B288D1 for ; Thu, 31 Aug 2017 09:39:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE5C8288DD; Thu, 31 Aug 2017 09:39:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0A996288D3 for ; Thu, 31 Aug 2017 09:39:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B49D06E6CB; Thu, 31 Aug 2017 09:38:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qk0-x242.google.com (mail-qk0-x242.google.com [IPv6:2607:f8b0:400d:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8DC9E6E0FB; Thu, 31 Aug 2017 02:55:29 +0000 (UTC) Received: by mail-qk0-x242.google.com with SMTP id m4so6801479qke.4; Wed, 30 Aug 2017 19:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9nlEXTw9y+Cmy8tx7eVBBGFjk8JpBxGMp7fSXd19Gn8=; b=ungZYVP8yOdExBAQ7UroK4pWh4uhefa/zDsj/FlTnhUkYkdHq2QwhZ1AWOn5rrR2n2 KYvB6+7B35u1BUD8DEw36yNwz5/dhNcgLcPaYPSAQPbMAKZhk14OtxNwCYgHS1jsjS2/ BKJeO7mqafGJXuB0GST8xl9RXCtc/zmR1AyCrEonH5L3SkGBSvTvfZRK9TQfAstxhC7C sBlU50De2SVNvE4NDq06N39B09S2jMlc6mKMrperJpU5z2AfBH877Gm8sFaQf6lq1sRu jdWPQxmA+5jG44qcQ/vb/0pBgp+mdyu4gmIoFZog6lNyeGHCvXous+gfcaysDq7h2XE6 YhFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9nlEXTw9y+Cmy8tx7eVBBGFjk8JpBxGMp7fSXd19Gn8=; b=dGwgD/JTuNWFBRNTY288bLseeG9sSfdWpRvCo/UueqWgXD9iRVbVW0W+LdIWQuv9CO nyhciGzfnufD7p2gWORhKciy7qBCMuF8C4HRWrdh75C4hNdfneTL/nwvABBGfpYISS2t tzt66UgTiC8RZG1NEmhTRGATNI4hTqiqmveKIaH+nsBKt/4ngfqjhcjSvKTDfWNDEe7a GQJIOGNHas6X4h/CW08ju1ZQcw8ZIybZPCiWwe0oQpjIaRRcgHKAAObx2fuj5R/PjzMD 8dbH8CLYnosuVFCiFNk+NEUCt1n9rF9/B9QjnjHXQGgup6hSMkHLqvZ8Oo9oZbOQQ907 6cmw== X-Gm-Message-State: AHPjjUhROK3OXfbNbHZvJaHE1NVTEGYPUV47C7/Zwhefu/oPcDIkdvdQ HfwInIWxoyUSPgut X-Google-Smtp-Source: ADKCNb4A3bMLlJzZPadp55UGTVrqlGsZonZz9fxYuoDCSU9fVRgVVOMI+B2mymzJIeh9fFm9zTbmdQ== X-Received: by 10.55.203.209 with SMTP id u78mr574525qkl.173.1504148128569; Wed, 30 Aug 2017 19:55:28 -0700 (PDT) Received: from localhost.localdomain (pool-108-29-189-134.nycmny.fios.verizon.net. [108.29.189.134]) by smtp.gmail.com with ESMTPSA id z187sm4659136qke.4.2017.08.30.19.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Aug 2017 19:55:27 -0700 (PDT) From: Rhys Kidd To: Ben Skeggs , dri-devel@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: [RFC PATCH] drm/nouveau/therm: initial implementation of new gp1xx temperature sensor Date: Wed, 30 Aug 2017 22:55:09 -0400 Message-Id: <20170831025509.4837-1-rhyskidd@gmail.com> X-Mailer: git-send-email 2.11.0 X-Mailman-Approved-At: Thu, 31 Aug 2017 09:38:58 +0000 Cc: Rhys Kidd X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Rhys Kidd --- .../gpu/drm/nouveau/include/nvkm/subdev/therm.h | 1 + drivers/gpu/drm/nouveau/nvkm/engine/device/base.c | 6 +++ drivers/gpu/drm/nouveau/nvkm/subdev/therm/Kbuild | 1 + drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c | 3 +- drivers/gpu/drm/nouveau/nvkm/subdev/therm/gp100.c | 57 ++++++++++++++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/therm/gp100.c diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h index b268b96faece..adf14731ea15 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/therm.h @@ -96,4 +96,5 @@ int g84_therm_new(struct nvkm_device *, int, struct nvkm_therm **); int gt215_therm_new(struct nvkm_device *, int, struct nvkm_therm **); int gf119_therm_new(struct nvkm_device *, int, struct nvkm_therm **); int gm107_therm_new(struct nvkm_device *, int, struct nvkm_therm **); +int gp100_therm_new(struct nvkm_device *, int, struct nvkm_therm **); #endif diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c index 7bdc7a5ae723..a6221b0996bf 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/base.c @@ -2166,6 +2166,7 @@ nv130_chipset = { .ltc = gp100_ltc_new, .mc = gp100_mc_new, .mmu = gf100_mmu_new, + .therm = gp100_therm_new, .secboot = gm200_secboot_new, .pci = gp100_pci_new, .pmu = gp100_pmu_new, @@ -2200,6 +2201,7 @@ nv132_chipset = { .ltc = gp100_ltc_new, .mc = gp100_mc_new, .mmu = gf100_mmu_new, + .therm = gp100_therm_new, .secboot = gp102_secboot_new, .pci = gp100_pci_new, .pmu = gp102_pmu_new, @@ -2234,6 +2236,7 @@ nv134_chipset = { .ltc = gp100_ltc_new, .mc = gp100_mc_new, .mmu = gf100_mmu_new, + .therm = gp100_therm_new, .secboot = gp102_secboot_new, .pci = gp100_pci_new, .pmu = gp102_pmu_new, @@ -2268,6 +2271,7 @@ nv136_chipset = { .ltc = gp100_ltc_new, .mc = gp100_mc_new, .mmu = gf100_mmu_new, + .therm = gp100_therm_new, .secboot = gp102_secboot_new, .pci = gp100_pci_new, .pmu = gp102_pmu_new, @@ -2302,6 +2306,7 @@ nv137_chipset = { .ltc = gp100_ltc_new, .mc = gp100_mc_new, .mmu = gf100_mmu_new, + .therm = gp100_therm_new, .secboot = gp102_secboot_new, .pci = gp100_pci_new, .pmu = gp102_pmu_new, @@ -2332,6 +2337,7 @@ nv13b_chipset = { .ltc = gp100_ltc_new, .mc = gp10b_mc_new, .mmu = gf100_mmu_new, + .therm = gp100_therm_new, .secboot = gp10b_secboot_new, .pmu = gm20b_pmu_new, .timer = gk20a_timer_new, diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/Kbuild index 135758ba3e28..3ef1b396a946 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/Kbuild +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/Kbuild @@ -11,3 +11,4 @@ nvkm-y += nvkm/subdev/therm/g84.o nvkm-y += nvkm/subdev/therm/gt215.o nvkm-y += nvkm/subdev/therm/gf119.o nvkm-y += nvkm/subdev/therm/gm107.o +nvkm-y += nvkm/subdev/therm/gp100.o diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c index 952a7cb0a59a..f27fc6d0d4c6 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/base.c @@ -341,7 +341,8 @@ nvkm_therm_init(struct nvkm_subdev *subdev) { struct nvkm_therm *therm = nvkm_therm(subdev); - therm->func->init(therm); + if (therm->func->init) + therm->func->init(therm); if (therm->suspend >= 0) { /* restore the pwm value only when on manual or auto mode */ diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gp100.c b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gp100.c new file mode 100644 index 000000000000..b83d4af8c8bb --- /dev/null +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/gp100.c @@ -0,0 +1,57 @@ +/* + * Copyright 2017 Rhys Kidd + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Authors: Rhys Kidd + */ +#include "priv.h" + +static int +gp100_temp_get(struct nvkm_therm *therm) +{ + struct nvkm_device *device = therm->subdev.device; + struct nvkm_subdev *subdev = &therm->subdev; + u32 tsensor = nvkm_rd32(device, 0x20460); + u32 status = (tsensor & 0x60000000) >> 29; + u32 t_f24_8 = (tsensor & 0x0001fff8); + + /* device SHADOWed */ + if (status & 0x00000002) + nvkm_error(subdev, "Reading temperature from SHADOWed sensor\n"); + + /* device valid */ + if (status & 0x00000001) + return t_f24_8 / 256; + else + return -ENODEV; +} + +static const struct nvkm_therm_func +gp100_therm = { + .temp_get = gp100_temp_get, + .program_alarms = nvkm_therm_program_alarms_polling, +}; + +int +gp100_therm_new(struct nvkm_device *device, int index, + struct nvkm_therm **ptherm) +{ + return nvkm_therm_new_(&gp100_therm, device, index, ptherm); +} \ No newline at end of file