From patchwork Wed Jan 18 18:16:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 643953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 360FBC38147 for ; Wed, 18 Jan 2023 18:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229635AbjARSRS (ORCPT ); Wed, 18 Jan 2023 13:17:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230393AbjARSQg (ORCPT ); Wed, 18 Jan 2023 13:16:36 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7756C5A80A for ; Wed, 18 Jan 2023 10:16:35 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso2213882wmq.5 for ; Wed, 18 Jan 2023 10:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zxJbiMFPybMH7ivLVqW5OITYDgd53EwEIHVHwObfw3I=; b=qyB/LtnhmSxHJrvWocFFevyKHuFEjEQiE5y2D3UO9aNo+RKqMQGFsOuP0uOVdwtO57 UA9A7H9roO1E3q6v24nvjOwhUhm2is6X+Yck2oDLefakLn+jbna/6PE8XcS1+Wkw+cOO y1iZELhycvgDBXlU+lNuFTkXwmDjIqm+sMVBrYBjLyeizTjywTR3WJLK56i+NBLLBIfl PTk6vjNuVHniqv08Y87dd/6pXY/P67dmzqtILvy0vpXjvfpPTBd4QlruumaAq4opM3Xl fGu+pwWVh6CxYjk4JUc75b8ATSxu34a3djWnWmgAbDBuma/dsX8MaYSnUd+eBQbpGEb3 it4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zxJbiMFPybMH7ivLVqW5OITYDgd53EwEIHVHwObfw3I=; b=XKJ/Xl1gl78Zgu6FryZCnkE6PICl0FRfhzQ6PnTCEoO1XL6gDGzIfFztUm9gepW1Wy FKUjhSVZrB4/aoBpUYPfXTnEptYIUavMBer7IC3yoExeUUThewry2E5lcRHDlWuFSmMx KBKrDA0poYrQ51vLQeCVmS1T/mTxnfVPkgX48N1uKZFA2sudl1fehYZRMoTj9lzSs4nn tzEG2f7vjORCW0RHFiYoMbZQw9KYM3O0qkEMik4+DNQ+yjPtcanfLGktJUxkFi/A+RUb Rf/JoCte41+9XCke91s5WKUbMDWSNXTEEE8fWxvCZ56bXzHJTU+xEEkKrcYKKxSZBNYw b9dA== X-Gm-Message-State: AFqh2kpKv7N6KpNg8+TGyxZY8byzi7NpTg/fbUsyBGq9rfdbLWdVaUhv BR7r5NyUQufvMlN/AOOyURKZfw== X-Google-Smtp-Source: AMrXdXv2E22gh+vD4W7TR2GDM8bhtQIDNJcqhSCfxEQ1D83Cs6NJkinjjEX/ewrnDcha4kpIY233wQ== X-Received: by 2002:a1c:cc11:0:b0:3da:1d52:26b5 with SMTP id h17-20020a1ccc11000000b003da1d5226b5mr16204270wmb.14.1674065793891; Wed, 18 Jan 2023 10:16:33 -0800 (PST) Received: from mai.. (146725694.box.freepro.com. [130.180.211.218]) by smtp.gmail.com with ESMTPSA id c10-20020a05600c0a4a00b003db12112fcfsm2817414wmq.4.2023.01.18.10.16.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 10:16:33 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, rafael@kernel.org Cc: srinivas.pandruvada@linux.intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Sumeet Pawnikar , Shang XiaoJing Subject: [PATCH 2/3] thermal/drivers/intel: Use generic trip points for processor_thermal_device_pci Date: Wed, 18 Jan 2023 19:16:20 +0100 Message-Id: <20230118181622.33335-2-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230118181622.33335-1-daniel.lezcano@linaro.org> References: <20230118181622.33335-1-daniel.lezcano@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The thermal framework gives the possibility to register the trip points with the thermal zone. When that is done, no get_trip_* ops are needed and they can be removed. Convert ops content logic into generic trip points and register them with the thermal zone. Signed-off-by: Daniel Lezcano --- .../processor_thermal_device_pci.c | 53 ++++++++----------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c index bf1b1cdfade4..c7d50862bf56 100644 --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci.c @@ -144,34 +144,6 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) return 0; } -static int sys_get_trip_temp(struct thermal_zone_device *tzd, - int trip, int *temp) -{ - struct proc_thermal_pci *pci_info = tzd->devdata; - u32 _temp; - - proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_THRES_0, &_temp); - if (!_temp) { - *temp = THERMAL_TEMP_INVALID; - } else { - int tjmax; - - proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_TJMAX, &tjmax); - _temp = tjmax - _temp; - *temp = (unsigned long)_temp * 1000; - } - - return 0; -} - -static int sys_get_trip_type(struct thermal_zone_device *tzd, int trip, - enum thermal_trip_type *type) -{ - *type = THERMAL_TRIP_PASSIVE; - - return 0; -} - static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp) { struct proc_thermal_pci *pci_info = tzd->devdata; @@ -200,10 +172,26 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, int temp return 0; } +static int get_trip_temp(struct proc_thermal_pci *pci_info) +{ + int temp, tjmax; + + proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_THRES_0, &temp); + if (!temp) + return THERMAL_TEMP_INVALID; + + proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_TJMAX, &tjmax); + temp = (tjmax - temp) * 1000; + + return temp; +} + +static struct thermal_trip psv_trip = { + .type = THERMAL_TRIP_PASSIVE, +}; + static struct thermal_zone_device_ops tzone_ops = { .get_temp = sys_get_curr_temp, - .get_trip_temp = sys_get_trip_temp, - .get_trip_type = sys_get_trip_type, .set_trip_temp = sys_set_trip_temp, }; @@ -251,7 +239,10 @@ static int proc_thermal_pci_probe(struct pci_dev *pdev, const struct pci_device_ if (ret) goto err_ret_thermal; - pci_info->tzone = thermal_zone_device_register("TCPU_PCI", 1, 1, pci_info, + psv_trip.temperature = get_trip_temp(pci_info); + + pci_info->tzone = thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip, + 1, 1, pci_info, &tzone_ops, &tzone_params, 0, 0); if (IS_ERR(pci_info->tzone)) {