From patchwork Thu Jan 5 18:03:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 639445 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 ACC4AC54EF1 for ; Thu, 5 Jan 2023 18:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235459AbjAESDx (ORCPT ); Thu, 5 Jan 2023 13:03:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbjAESDt (ORCPT ); Thu, 5 Jan 2023 13:03:49 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43045564CA; Thu, 5 Jan 2023 10:03:46 -0800 (PST) Received: from jupiter.universe (dyndsl-085-016-198-020.ewe-ip-backbone.de [85.16.198.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id 5D3706602CD7; Thu, 5 Jan 2023 18:03:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1672941825; bh=sbwbPC8CQ9pDo6+I6EbaGiqJManEPRlNV8KKXl/kDSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gls4Mzv+c+/KPrDmXnys6tTry4Su9e0SSucEF8h5b0l+nTCgBykn2cy3CgnB8Rt3k Z5MUAGSHGjuIdLQQVRCCYMz6xMaKkKnIe6r59dm9pw+0a+gkXniPNJxeJ2YCiMLnq+ NUqrKIsBmPtcc3LNfryQsEpghqRSCzHAF5lo3OtjSsun3VOQ85XTJs2LVYLgrnxlW4 fIRIVi4MRORbXxW/UWVQ1apH1nqRBsTeu26Xn+NWAzaJahOd0Z42Q1E/qu5EjZaxlP QrNIFCgEPh6YpP7UDOD2ognfztesuKzM+OmD7DIoX0QVml7sv6Z+4NjuM27kXsF5ZC v1UzEf3wL9/wA== Received: by jupiter.universe (Postfix, from userid 1000) id A800848011A; Thu, 5 Jan 2023 19:03:42 +0100 (CET) From: Sebastian Reichel To: Heiko Stuebner , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui Cc: Rob Herring , Krzysztof Kozlowski , linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCHv3 3/7] thermal: rockchip: Use dev_err_probe Date: Thu, 5 Jan 2023 19:03:36 +0100 Message-Id: <20230105180340.29140-4-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105180340.29140-1-sebastian.reichel@collabora.com> References: <20230105180340.29140-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Use dev_err_probe to simplify error printing in the driver's probe routine. Reviewed-by: Heiko Stuebner Signed-off-by: Sebastian Reichel --- drivers/thermal/rockchip_thermal.c | 50 +++++++++++------------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index 74e0ad001b33..0670584533a5 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -1379,35 +1379,26 @@ static int rockchip_thermal_probe(struct platform_device *pdev) return PTR_ERR(thermal->regs); thermal->reset = devm_reset_control_array_get(&pdev->dev, false, false); - if (IS_ERR(thermal->reset)) { - error = PTR_ERR(thermal->reset); - dev_err(&pdev->dev, "failed to get tsadc reset: %d\n", error); - return error; - } + if (IS_ERR(thermal->reset)) + return dev_err_probe(&pdev->dev, PTR_ERR(thermal->reset), + "failed to get tsadc reset.\n"); thermal->clk = devm_clk_get_enabled(&pdev->dev, "tsadc"); - if (IS_ERR(thermal->clk)) { - error = PTR_ERR(thermal->clk); - dev_err(&pdev->dev, "failed to get tsadc clock: %d\n", error); - return error; - } + if (IS_ERR(thermal->clk)) + return dev_err_probe(&pdev->dev, PTR_ERR(thermal->clk), + "failed to get tsadc clock.\n"); thermal->pclk = devm_clk_get_enabled(&pdev->dev, "apb_pclk"); - if (IS_ERR(thermal->pclk)) { - error = PTR_ERR(thermal->pclk); - dev_err(&pdev->dev, "failed to get apb_pclk clock: %d\n", - error); - return error; - } + if (IS_ERR(thermal->pclk)) + return dev_err_probe(&pdev->dev, PTR_ERR(thermal->pclk), + "failed to get apb_pclk clock.\n"); rockchip_thermal_reset_controller(thermal->reset); error = rockchip_configure_from_dt(&pdev->dev, np, thermal); - if (error) { - dev_err(&pdev->dev, "failed to parse device tree data: %d\n", - error); - return error; - } + if (error) + return dev_err_probe(&pdev->dev, error, + "failed to parse device tree data\n"); thermal->chip->initialize(thermal->grf, thermal->regs, thermal->tshut_polarity); @@ -1416,23 +1407,18 @@ static int rockchip_thermal_probe(struct platform_device *pdev) error = rockchip_thermal_register_sensor(pdev, thermal, &thermal->sensors[i], thermal->chip->chn_id[i]); - if (error) { - dev_err(&pdev->dev, - "failed to register sensor[%d] : error = %d\n", - i, error); - return error; - } + if (error) + return dev_err_probe(&pdev->dev, error, + "failed to register sensor[%d].\n", i); } error = devm_request_threaded_irq(&pdev->dev, irq, NULL, &rockchip_thermal_alarm_irq_thread, IRQF_ONESHOT, "rockchip_thermal", thermal); - if (error) { - dev_err(&pdev->dev, - "failed to request tsadc irq: %d\n", error); - return error; - } + if (error) + return dev_err_probe(&pdev->dev, error, + "failed to request tsadc irq.\n"); thermal->chip->control(thermal->regs, true); From patchwork Thu Jan 5 18:03:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 639444 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 E457EC63797 for ; Thu, 5 Jan 2023 18:03:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235484AbjAESD4 (ORCPT ); Thu, 5 Jan 2023 13:03:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235443AbjAESDv (ORCPT ); Thu, 5 Jan 2023 13:03:51 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 561FC564E0; Thu, 5 Jan 2023 10:03:49 -0800 (PST) Received: from jupiter.universe (dyndsl-085-016-198-020.ewe-ip-backbone.de [85.16.198.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id D2D1E6602D35; Thu, 5 Jan 2023 18:03:47 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1672941827; bh=CMD2O/f303Ik9opLVvnEYNOZzTeK6AZzuQ+9TPeDUFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OrfpiZz7xC1AQpWQZL8Eq8JI6bfPpdW9jGMfsiFdl2j3vYTMEEiEnIfaG4h+SZmc5 OE0jpcHbwFIl3ryjBqLOkR/QHE1/quXEqxk6RZq4UR9/Qwu4ql4rkZtVbjhOwpOm2L QCVqfjms9IgJT1a2JsR5d1nZKUnDddnKl2F/B919kTcLLySjsaiVviR8bskWCqJmJ+ g1Qkr31GLv4y9BG6iLnQII/3yev+LH/tlyFdU1inbqwWUsTkQgIBUMe4O5TgrTIItz XY1ZxGxpPlP8276u/DpqNilGRUDxvAnFwOjjSYYaKRCEig5Vp/b2MLeGxHisZa/qY/ 5ork/bJzGDDJQ== Received: by jupiter.universe (Postfix, from userid 1000) id ABB4F48011C; Thu, 5 Jan 2023 19:03:42 +0100 (CET) From: Sebastian Reichel To: Heiko Stuebner , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui Cc: Rob Herring , Krzysztof Kozlowski , linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com Subject: [PATCHv3 5/7] thermal: rockchip: Support dynamic sized sensor array Date: Thu, 5 Jan 2023 19:03:38 +0100 Message-Id: <20230105180340.29140-6-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105180340.29140-1-sebastian.reichel@collabora.com> References: <20230105180340.29140-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Dynamically allocate the sensors array based on the amount of platform sensors in preparation for rk3588 support, which needs 7 sensors. Reviewed-by: Heiko Stuebner Signed-off-by: Sebastian Reichel --- drivers/thermal/rockchip_thermal.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/thermal/rockchip_thermal.c b/drivers/thermal/rockchip_thermal.c index 2c8a8b365c80..c104c60faafd 100644 --- a/drivers/thermal/rockchip_thermal.c +++ b/drivers/thermal/rockchip_thermal.c @@ -51,12 +51,6 @@ enum adc_sort_mode { #include "thermal_hwmon.h" -/** - * The max sensors is two in rockchip SoCs. - * Two sensors: CPU and GPU sensor. - */ -#define SOC_MAX_SENSORS 2 - /** * struct chip_tsadc_table - hold information about chip-specific differences * @id: conversion table @@ -147,7 +141,7 @@ struct rockchip_thermal_data { struct platform_device *pdev; struct reset_control *reset; - struct rockchip_thermal_sensor sensors[SOC_MAX_SENSORS]; + struct rockchip_thermal_sensor *sensors; struct clk *clk; struct clk *pclk; @@ -1367,6 +1361,11 @@ static int rockchip_thermal_probe(struct platform_device *pdev) if (!thermal->chip) return -EINVAL; + thermal->sensors = devm_kcalloc(&pdev->dev, thermal->chip->chn_num, + sizeof(*thermal->sensors), GFP_KERNEL); + if (!thermal->sensors) + return -ENOMEM; + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); thermal->regs = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(thermal->regs)) From patchwork Thu Jan 5 18:03:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 639443 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 8BA72C677F1 for ; Thu, 5 Jan 2023 18:03:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235420AbjAESD5 (ORCPT ); Thu, 5 Jan 2023 13:03:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235445AbjAESDv (ORCPT ); Thu, 5 Jan 2023 13:03:51 -0500 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7003564E8; Thu, 5 Jan 2023 10:03:49 -0800 (PST) Received: from jupiter.universe (dyndsl-085-016-198-020.ewe-ip-backbone.de [85.16.198.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: sre) by madras.collabora.co.uk (Postfix) with ESMTPSA id DED7D6602D40; Thu, 5 Jan 2023 18:03:47 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1672941828; bh=HWf3Bker04XVluyDrFFMhig5t6mPNRA+lOaEFDDHk4w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ur5e9FV2G7idP0ty3L6Gvm8Y+hc7aSKg0k8WtLgAHVLf7Ud2H5CjtIwMNotFqzwe7 x3WspQknNnwh130/YVkhUJLe58lZXPpScOCbKt02orJQKcYl231SaYkSV6/piJge8l YJnG2DvCARhkrcuU5Mf3gQsEzotxYgxgZGFFOUNCId5z38bbQfEoJq4KEqyTZhyKD1 4ofZnwln3ZHqGhHmyAikwuPeFzwgPOwifGSh7BNnPxyhu8y0lLLCtn9T7MuC/8jIci 4AHZHWctLUgnrNszG+xXodUOd8eXxivN/rnJeuv++mHK2HSYPum2eeQrahJhfg2Ykm I2MMCEkz7vY6g== Received: by jupiter.universe (Postfix, from userid 1000) id AF9EE48011E; Thu, 5 Jan 2023 19:03:42 +0100 (CET) From: Sebastian Reichel To: Heiko Stuebner , "Rafael J. Wysocki" , Daniel Lezcano , Amit Kucheria , Zhang Rui Cc: Rob Herring , Krzysztof Kozlowski , linux-pm@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Sebastian Reichel , kernel@collabora.com, Krzysztof Kozlowski Subject: [PATCHv3 7/7] dt-bindings: rockchip-thermal: Support the RK3588 SoC compatible Date: Thu, 5 Jan 2023 19:03:40 +0100 Message-Id: <20230105180340.29140-8-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230105180340.29140-1-sebastian.reichel@collabora.com> References: <20230105180340.29140-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a new compatible for the thermal sensor device on RK3588 SoCs. Reviewed-by: Heiko Stuebner Acked-by: Krzysztof Kozlowski Signed-off-by: Sebastian Reichel --- Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml b/Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml index f6c1be226aaa..55f8ec0bec01 100644 --- a/Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml +++ b/Documentation/devicetree/bindings/thermal/rockchip-thermal.yaml @@ -19,6 +19,7 @@ properties: - rockchip,rk3368-tsadc - rockchip,rk3399-tsadc - rockchip,rk3568-tsadc + - rockchip,rk3588-tsadc - rockchip,rv1108-tsadc reg: