From patchwork Wed Jan 18 18:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 45414 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2493115wrn; Wed, 18 Jan 2023 10:26:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXtnX/8GMnlVdQGo+Llbe/1Y/S/G4g/B+1IVA/N5IvrM01gVkOBpjSsdOf8wIFcg7b8bzlhv X-Received: by 2002:a17:902:7c0a:b0:192:c809:a1dd with SMTP id x10-20020a1709027c0a00b00192c809a1ddmr27668755pll.20.1674066410535; Wed, 18 Jan 2023 10:26:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674066410; cv=none; d=google.com; s=arc-20160816; b=j2k8S0Hn4yH5GIcrtTQiyA68WSUICLqaOE7MNlkESLp0YQe00cNPZM3+GAaDbr1Nn0 fwW+EbNmFOyk52oqSms8GoCTlHSXXQg0nGohSuxv+JzvjbFyGCbynbVqEezP7aR2pOVE HWY416+FW+qPwaSDw7KQFnkX/0xloL6R0A2I+Dlb+lBiCEaACGozlmaGx/8RNaUL+FSP 7brJiHHFRzfaJyC8JzGmh8uWB102jX28kS+8kAUFUGG7YPAQFCL2WIIihq1j8i0PHe+D O9v95kPyjWb9cqwypBQcXkXeLcc0BDJ40AQffk/bg17lsuLCefwwvGyEuTuYq1DdsWCK R7Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=FZuxz2Nc/8QrqCzCamHaGIaa6VVO9EC4Sr9XAoWF6pY=; b=tirsPVj/6GtLt8mw5ek9B0gJYRXDWDx/8gtNihNxDUDDbYK4lw5aXpxS+irFO4i4ZK 6ORTsIzhcjE8N4ZkF1R2Eph2PyUX50k6BR00ePKGOcxa5sv/pC9REZoVY8+9jMR2TmDo dJ/0zX+Zq+K76xUSITss1ioU90sKyiIVN8Nk95loEQ/DfwqYX4QYsCxUfBcC3e4IIYU+ N42cBM4yGYuajP7DpagR2NRBcIqTAJQvAwq1EpRnKhECVIC2QLIAdKmi4AyoabTK9lZU klMUNggZZomWB5VJirKfP48KdbRMGoD6nav7eSTtUqJY5RuUGtlrZ/UeyZbhWEEw8h/I Jksg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gkpw9IZz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 12-20020a170902c20c00b00176a6c988c6si34038348pll.218.2023.01.18.10.26.39; Wed, 18 Jan 2023 10:26:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gkpw9IZz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjARSQ7 (ORCPT + 99 others); Wed, 18 Jan 2023 13:16:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbjARSQf (ORCPT ); Wed, 18 Jan 2023 13:16:35 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81AF059E5A for ; Wed, 18 Jan 2023 10:16:33 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id c10-20020a05600c0a4a00b003db0636ff84so2248221wmq.0 for ; Wed, 18 Jan 2023 10:16:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=FZuxz2Nc/8QrqCzCamHaGIaa6VVO9EC4Sr9XAoWF6pY=; b=gkpw9IZzYcl1dAnnjN/nEU/WYiGEqwjyeWRxvrttmz8Pjd7VUHlBIrXHE7G15slK0v +KYozqf8E0OWNAZyZFQKiMp4q+OhBYWwC8TltkpP5eQJeyhZudH6WhKZN6QYD6krmp1e w18W4n46yQkVCOawNbFlfbdWf5/lcqRzQPhMvMl/H6S2ZZ+TfgVuGYIuCZCcrjrVEETM TYwXE+F7+PrNylzMCj3iaAk6Xv1Jrup7ahFxT2VTdmhEUDItNqTWM11dsUzbmZMeulhE /kM0nGMN7L0I/YErnvmLcXJt5GOHD9A4sMnjRBrSjfqDYrWoqH4h6K8sVovsFvQYwHua uGHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FZuxz2Nc/8QrqCzCamHaGIaa6VVO9EC4Sr9XAoWF6pY=; b=G1985LaJ3nLL1L6TD3OMHjBTacD58VE+IVhVjvMpiGP7J3qdous3Gu1N0j9k6SRy2/ GFdEeJsxMVbCpD+l7X7lDLT78MWHYNnz0e9NfyL4xR2RZoSLpuZr9x5vcB53Pah2pUCK kFuBpKXt76l774VdmgPt298ra8JxulcqP42qljVmxzrj3yfu21q8uREnDslFrM9SnTlD xDon9kJCV8k9H2af4wlyONpAPgv5DWiQWm3NAtbA9KTQQq0sLhZevS8CIhNxJYKNSnpn rMjhY+/tGcQrOlYFU5fZlcdNj/EO/tufw1V+T4H239LYEYji7LVeMYOew72b2VVTNEIE uehQ== X-Gm-Message-State: AFqh2kr81OFaDwHHbYALglgwaXX7zlyRsGuADxCRVVCv7tOw0ney+xJk fAR2SqBUz78/hFuSuZKrPx0yhg== X-Received: by 2002:a05:600c:995:b0:3da:f4f5:ad0e with SMTP id w21-20020a05600c099500b003daf4f5ad0emr7467231wmp.9.1674065791979; Wed, 18 Jan 2023 10:16:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 10:16:31 -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 Subject: [PATCH 1/3] thermal/drivers/intel: Use generic trip points for quark_dts Date: Wed, 18 Jan 2023 19:16:19 +0100 Message-Id: <20230118181622.33335-1-daniel.lezcano@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755385860921929959?= X-GMAIL-MSGID: =?utf-8?q?1755385860921929959?= 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 --- .../thermal/intel/intel_quark_dts_thermal.c | 56 +++++++++---------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c index 3eafc6b0e6c3..4e1d1799ec22 100644 --- a/drivers/thermal/intel/intel_quark_dts_thermal.c +++ b/drivers/thermal/intel/intel_quark_dts_thermal.c @@ -84,6 +84,7 @@ #define QRK_DTS_MASK_TP_THRES 0xFF #define QRK_DTS_SHIFT_TP 8 #define QRK_DTS_ID_TP_CRITICAL 0 +#define QRK_DTS_ID_TP_HOT 1 #define QRK_DTS_SAFE_TP_THRES 105 /* Thermal Sensor Register Lock */ @@ -104,6 +105,7 @@ struct soc_sensor_entry { u32 store_ptps; u32 store_dts_enable; struct thermal_zone_device *tzone; + struct thermal_trip trips[QRK_MAX_DTS_TRIPS]; }; static struct soc_sensor_entry *soc_dts; @@ -172,7 +174,7 @@ static int soc_dts_disable(struct thermal_zone_device *tzd) return ret; } -static int _get_trip_temp(int trip, int *temp) +static int get_trip_temp(int trip, int *temp) { int status; u32 out; @@ -197,17 +199,6 @@ static int _get_trip_temp(int trip, int *temp) return 0; } -static inline int sys_get_trip_temp(struct thermal_zone_device *tzd, - int trip, int *temp) -{ - return _get_trip_temp(trip, temp); -} - -static inline int sys_get_crit_temp(struct thermal_zone_device *tzd, int *temp) -{ - return _get_trip_temp(QRK_DTS_ID_TP_CRITICAL, temp); -} - static int update_trip_temp(struct soc_sensor_entry *aux_entry, int trip, int temp) { @@ -262,17 +253,6 @@ static inline int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, return update_trip_temp(tzd->devdata, trip, temp); } -static int sys_get_trip_type(struct thermal_zone_device *thermal, - int trip, enum thermal_trip_type *type) -{ - if (trip) - *type = THERMAL_TRIP_HOT; - else - *type = THERMAL_TRIP_CRITICAL; - - return 0; -} - static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) { @@ -315,10 +295,7 @@ static int sys_change_mode(struct thermal_zone_device *tzd, 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, - .get_crit_temp = sys_get_crit_temp, .change_mode = sys_change_mode, }; @@ -344,7 +321,7 @@ static void free_soc_dts(struct soc_sensor_entry *aux_entry) static struct soc_sensor_entry *alloc_soc_dts(void) { struct soc_sensor_entry *aux_entry; - int err; + int err, temperature; u32 out; int wr_mask; @@ -385,10 +362,27 @@ static struct soc_sensor_entry *alloc_soc_dts(void) goto err_ret; } - aux_entry->tzone = thermal_zone_device_register("quark_dts", - QRK_MAX_DTS_TRIPS, - wr_mask, - aux_entry, &tzone_ops, NULL, 0, polling_delay); + err = get_trip_temp(QRK_DTS_ID_TP_CRITICAL, &temperature); + if (err) + goto err_ret; + + aux_entry->trips[QRK_DTS_ID_TP_CRITICAL].temperature = temperature; + aux_entry->trips[QRK_DTS_ID_TP_CRITICAL].type = THERMAL_TRIP_CRITICAL; + + err = get_trip_temp(QRK_DTS_ID_TP_HOT, &temperature); + if (err) + goto err_ret; + + aux_entry->trips[QRK_DTS_ID_TP_HOT].temperature = temperature; + aux_entry->trips[QRK_DTS_ID_TP_HOT].type = THERMAL_TRIP_HOT; + + aux_entry->tzone = + thermal_zone_device_register_with_trips("quark_dts", + aux_entry->trips, + QRK_MAX_DTS_TRIPS, + wr_mask, + aux_entry, &tzone_ops, + NULL, 0, polling_delay); if (IS_ERR(aux_entry->tzone)) { err = PTR_ERR(aux_entry->tzone); goto err_ret; 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: 45415 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2493190wrn; Wed, 18 Jan 2023 10:27:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXu+K+aa3lVEvAqlUp7taLUIgMtqCJ6shoEVAk/Buza0P6VlWONJG2pfESW2A5izDKOu0siJ X-Received: by 2002:a17:902:7889:b0:192:b5a8:3eb6 with SMTP id q9-20020a170902788900b00192b5a83eb6mr6658965pll.44.1674066422854; Wed, 18 Jan 2023 10:27:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674066422; cv=none; d=google.com; s=arc-20160816; b=RCeXehYKvOTiQEktWYaIWsXKrmDifc2hfaEeeywBu9d56SmG8G35xANT1/MEZERvDn CqwDlXBR9sO2JZPqxbGVJFhd6izEe9WDkVAQnvV+PNY0o5W8eaAPO9kxCchRPDBTG3sE Lsb1WD6fTDcU/FWZ79ffLnDOF3tySuRI4YQytaXD9sTMAFQnGBokOFh9nIvUGt5y//g3 vDOaVnFrLvSGrgFky1HF7PZg2SWNC8QpbaIjoKuF9yHmtzBSqAPU/Iun146J3Xyr4Eto TV+ezQZsnWdvvI+9D+dBYW35hyqyJJHtlzD1YdC2wcRAArXuKkr1RG0wtILS+GrwLanE xrAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zxJbiMFPybMH7ivLVqW5OITYDgd53EwEIHVHwObfw3I=; b=Ttm+4pr4735B2l58dCR3pFvCoZL5kyzSmw6xZDR7nk6WyR08pf4p2ydWcND+ZrgNR8 BCnRGf/qOH6i+M4qhObBKGmFFKoig+r/VEOwFBJvl1TBwR3VvRpOxgTxGRNZouuOBD9C SnNfbdItF2zOznykjoMHjeJP4pZ04cXZpLJ7lDY6z+XAxKhzNWcrvOxjml1hMkJYIhnW +VYknDSykB/PqkS9Wuu91/c4F7XBhELd4qwHyx0sHivk6yKrYHL9HYBCWpZCJJnUGaX7 Fkeyvcbk9G+kn0QGSyAgVwGs4MYlXPpvQajlMo8eCcBgA3maHxl3pKhpiSVZJX/vmD/9 ejbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qyB/Ltnh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170903028400b001926d680150si34342817plr.329.2023.01.18.10.26.51; Wed, 18 Jan 2023 10:27:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="qyB/Ltnh"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230085AbjARSRS (ORCPT + 99 others); Wed, 18 Jan 2023 13:17:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230401AbjARSQg (ORCPT ); Wed, 18 Jan 2023 13:16:36 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772C15A363 for ; Wed, 18 Jan 2023 10:16:35 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id l8so8223750wms.3 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=uR4PnOLfvisuFyyI/ReUOGz6QybHMMsRDZhMeB/EiJXpxHejKznNGcS474/3xfTLxP rjOzwaHuGONBVLs89Ixyrx4EMnzrQFnSpfrmMVytpCn8azxCaYIaJvNJQK2rdD/f5jKI aOCaEquMnjutOy/tBFe5DCgX22+sQBo8njpLASQ06oFTgNU0vyxoLFCrd3loau1ES9rx bzH7ij3wMIZ19RS9bCk6iAbMoRfbs6QcGiof9LlFlyJtQ70xBt8pT7RhFjFlrTeN+okc csKZ7Dtp29qLXIv1vRFli8nyTLOxwBJ2q0R3kF9SMQOIbSDlbBQZPImcg95rYLgKFkwN AxEg== X-Gm-Message-State: AFqh2kp8gwiP2Ejoiw6AuJ9tNqkPvuNz8xazJ4x8F8FK5sZXNjHcl0D9 ohK51zmbLy7XQAIANhUXV9c4TQ== 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 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755385873689745400?= X-GMAIL-MSGID: =?utf-8?q?1755385873689745400?= 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)) { From patchwork Wed Jan 18 18:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 45416 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2493683wrn; Wed, 18 Jan 2023 10:28:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXtlD53KchSpjmOZBXXBfHhqpMaaELOyeGA5XZGWM3cpzH0W5osGv+d4ub/n4AxwKPUQhK5N X-Received: by 2002:a17:902:6b4b:b0:194:a1f6:65b6 with SMTP id g11-20020a1709026b4b00b00194a1f665b6mr9616382plt.41.1674066493256; Wed, 18 Jan 2023 10:28:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674066493; cv=none; d=google.com; s=arc-20160816; b=tAteFwtZKKxJOyUR6aFbY8pfKF1uHs6KEsUtDXC3Xgr6ddCXW851w558gvoa3WBTlb loYq1RhWf3sb/6oQsQHNgdShQoHbZe30u97VNuG2G76hrE9x9VSpQrrOHxO0obHfY1LA sig1Zne2Mx22WOtaslrg7z3gcQ2F9KDn5nvhjMXco+Nx23y9I5b6F1SVAjCdeWJyTvY+ KxSqZe/mJCES5/lQnd25iudPssjkba0sjopv0yFW639FQ12qwW0mwT6sRhLX9efoofut eEs5t96MkGh7eQbOCX0M2PUZ4DaYaYhglLVy/lPEKmIEzOwUVqnEFJPfzdNzCDocSmvF Yp9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v8sOpg2jsh5IIv/+9bpFBSXh64MYJcWPCrHkWXWRQik=; b=QlVmh1cCnbHEKNjSMdas01dL/zDG94XfhWs5e90KhvUa9I88nW8t6b3/CspFA66drZ RDMBWJsxUhI6exAqfOFWKRbdM75qWOaW3Uno6BH5QM6IDrRSVmMduhkfb9nSUcrrVOmb IiiC6U6mQJozw5QAfb0YQ2srHRQcCpxjTTXopEu0KPsg3/fOJNruSRKMSyTMVi+gq7qM Oh1RULehAwcPN9IdCxQDih7+zFxXV9cjHPq1vKrhSekN08gjAmTUo+2raohfR1fzsrk5 +jN8PvY04XEDPsZYFu2Fbh7EMwIG6DPIZ++qDkVci56lTPun1wi4kxFuek2q5bRQ4I4p eHhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpiYy4Jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p4-20020a170902a40400b00192569ad4f2si22426655plq.426.2023.01.18.10.28.01; Wed, 18 Jan 2023 10:28:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PpiYy4Jd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231297AbjARSR1 (ORCPT + 99 others); Wed, 18 Jan 2023 13:17:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230430AbjARSQj (ORCPT ); Wed, 18 Jan 2023 13:16:39 -0500 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6D1D5976C for ; Wed, 18 Jan 2023 10:16:38 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id f12-20020a7bc8cc000000b003daf6b2f9b9so1994903wml.3 for ; Wed, 18 Jan 2023 10:16:38 -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=v8sOpg2jsh5IIv/+9bpFBSXh64MYJcWPCrHkWXWRQik=; b=PpiYy4Jds4QmdJM3SrsLCRcOX+kvsRI1DgfONWLx+2mM83I77cZz+yTUP2iTO8eJmf QkQB3ka3NtkIvhtk//godVvnxyRrIvvLKceVonLL0RWXwYHPgnqJadrcAAmsYtIFU2pY bl6JngCRBjpRzY3gG9WwuE3EDbUD7EHtEP7a0Mz5xQxt0ir7E1VcuZ0hecj40Oc6eFAG oFZsLlaTAcJk0tA2TYTfl+6YtxE70FDurc3OUOJYxVUJZ39Lz0PJryj7zeGFjfa0OvMu EUCzqPGB8aiC3iKtBPQDbzvJv4kGMORKebKNF3kmJOcP3Phduwf7y77n4QuTf7P+H8Ki 9m6g== 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=v8sOpg2jsh5IIv/+9bpFBSXh64MYJcWPCrHkWXWRQik=; b=wR+tHRHc6dw3QNm8EAwQIFUkPwv34XaxKJ2Zbmeo+KktNOMCXRYzVtquQpeXXlJP+V DbA/eFQ9crD6UqTuf8iugQXElfZ4kSMBU994D+XIpqQlbe6oNsjBIHLAUdC+jDFkZtxz LvBOcdmoGPu2ElB4lQLL/reH9z6a249QGxRyHE6eCat+6EfHeNL+XukNVy9DkUVTOK3/ 18vCZwcs81L19mE2K24vosjIvJhkt5Km6FL0KQiUnB+uimIjMupzUxyinzTUsonja7nF MQ137RXsnsSVcJmcKl7J+21304g+kh50+WpJr4vJXGQoYRu/8oHcEUCztpl4GYtfVN01 ZVXA== X-Gm-Message-State: AFqh2krUU2srF/dJSQNBeQ/TDTFoNacDQpRK0rSblqFWCB+xZK4qAQv7 aE43xd6O5OpFZIR58mUBQN273w== X-Received: by 2002:a05:600c:3555:b0:3da:f4d4:4c2 with SMTP id i21-20020a05600c355500b003daf4d404c2mr7426443wmq.37.1674065797376; Wed, 18 Jan 2023 10:16:37 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 10:16:36 -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, Daniel Lezcano , Amit Kucheria Subject: [PATCH 3/3] thermal/drivers/intel: Use generic trip points for intel_soc_dts_iosf Date: Wed, 18 Jan 2023 19:16:21 +0100 Message-Id: <20230118181622.33335-3-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 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755385947420623097?= X-GMAIL-MSGID: =?utf-8?q?1755385947420623097?= From: Daniel Lezcano 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 --- drivers/thermal/intel/intel_soc_dts_iosf.c | 58 ++++++++-------------- drivers/thermal/intel/intel_soc_dts_iosf.h | 2 +- 2 files changed, 23 insertions(+), 37 deletions(-) diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/intel/intel_soc_dts_iosf.c index 342b0bb5a56d..130c416ec601 100644 --- a/drivers/thermal/intel/intel_soc_dts_iosf.c +++ b/drivers/thermal/intel/intel_soc_dts_iosf.c @@ -71,20 +71,13 @@ static int get_tj_max(u32 *tj_max) return err; } -static int sys_get_trip_temp(struct thermal_zone_device *tzd, int trip, - int *temp) +static int get_trip_temp(struct intel_soc_dts_sensors *sensors, int trip, int *temp) { int status; u32 out; - struct intel_soc_dts_sensor_entry *dts; - struct intel_soc_dts_sensors *sensors; - dts = tzd->devdata; - sensors = dts->sensors; - mutex_lock(&sensors->dts_update_lock); status = iosf_mbi_read(BT_MBI_UNIT_PMC, MBI_REG_READ, SOC_DTS_OFFSET_PTPS, &out); - mutex_unlock(&sensors->dts_update_lock); if (status) return status; @@ -173,8 +166,13 @@ static int update_trip_temp(struct intel_soc_dts_sensor_entry *dts, if (status) goto err_restore_te_out; - dts->trip_types[thres_index] = trip_type; - + status = get_trip_temp(sensors, thres_index, &temp); + if (status) + goto err_restore_te_out; + + dts->trips[thres_index].type = trip_type; + dts->trips[thres_index].temperature = temp; + return 0; err_restore_te_out: iosf_mbi_write(BT_MBI_UNIT_PMC, MBI_REG_WRITE, @@ -202,24 +200,12 @@ static int sys_set_trip_temp(struct thermal_zone_device *tzd, int trip, mutex_lock(&sensors->dts_update_lock); status = update_trip_temp(tzd->devdata, trip, temp, - dts->trip_types[trip]); + dts->trips[trip].type); mutex_unlock(&sensors->dts_update_lock); return status; } -static int sys_get_trip_type(struct thermal_zone_device *tzd, - int trip, enum thermal_trip_type *type) -{ - struct intel_soc_dts_sensor_entry *dts; - - dts = tzd->devdata; - - *type = dts->trip_types[trip]; - - return 0; -} - static int sys_get_curr_temp(struct thermal_zone_device *tzd, int *temp) { @@ -245,8 +231,6 @@ static int sys_get_curr_temp(struct thermal_zone_device *tzd, 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, }; @@ -320,7 +304,8 @@ static int add_dts_thermal_zone(int id, struct intel_soc_dts_sensor_entry *dts, dts->trip_mask = trip_mask; dts->trip_count = trip_count; snprintf(name, sizeof(name), "soc_dts%d", id); - dts->tzone = thermal_zone_device_register(name, + dts->tzone = thermal_zone_device_register_with_trips(name, + dts->trips, trip_count, trip_mask, dts, &tzone_ops, @@ -430,27 +415,28 @@ struct intel_soc_dts_sensors *intel_soc_dts_iosf_init( notification = false; else notification = true; - for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { - sensors->soc_dts[i].sensors = sensors; - ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], - notification, trip_count, - read_only_trip_count); - if (ret) - goto err_free; - } for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { ret = update_trip_temp(&sensors->soc_dts[i], 0, 0, THERMAL_TRIP_PASSIVE); if (ret) - goto err_remove_zone; + goto err_free; ret = update_trip_temp(&sensors->soc_dts[i], 1, 0, THERMAL_TRIP_PASSIVE); if (ret) - goto err_remove_zone; + goto err_free; } + for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) { + sensors->soc_dts[i].sensors = sensors; + ret = add_dts_thermal_zone(i, &sensors->soc_dts[i], + notification, trip_count, + read_only_trip_count); + if (ret) + goto err_remove_zone; + } + return sensors; err_remove_zone: for (i = 0; i < SOC_MAX_DTS_SENSORS; ++i) diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.h b/drivers/thermal/intel/intel_soc_dts_iosf.h index c54945748200..ee0a39e3edd3 100644 --- a/drivers/thermal/intel/intel_soc_dts_iosf.h +++ b/drivers/thermal/intel/intel_soc_dts_iosf.h @@ -27,7 +27,7 @@ struct intel_soc_dts_sensor_entry { u32 store_status; u32 trip_mask; u32 trip_count; - enum thermal_trip_type trip_types[2]; + struct thermal_trip trips[2]; struct thermal_zone_device *tzone; struct intel_soc_dts_sensors *sensors; };