From patchwork Sat Oct 25 04:31:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iuncuim X-Patchwork-Id: 731 Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE7D1261B8F for ; Sat, 25 Oct 2025 04:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366735; cv=none; b=QUKIpBCgz9t9IZqpw6OTx9zQVnzlVD7s+p83WOITaE/ecmxWdTWZXF0wxYO33OEdqW1vm+4iXJZiKOpD5Jbsoli8PgcOLss86ytL0Wxk0g/Vuad18ZIeAjqR1hhdPP3Q00vgUO9yuMihvnU3rzvvIdgg6l4xtZBSRFwriMUCNuc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366735; c=relaxed/simple; bh=LxsKOmVaDzOSy8bwwU0rWY43UlPO4MkzptnRxF9FP4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JToJJcjltuNdjnOjIlNTFEmWZq7tBrWd6a+BKj1cSuUovnIovgISU7UIsen4XAC6MCvsk93BgKHNsExCYXqa3ZL8CTm/hvVjy2qN+kwg9OqjA4zukZdCXypw/bI6FFT0IDMWnMRay45DxAA0Lyvu5IUnU9nA1kAqsDW24qtamVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dwKf4EmY; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dwKf4EmY" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-378e0f355b9so15551451fa.0 for ; Fri, 24 Oct 2025 21:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761366731; x=1761971531; darn=lists.linux.dev; 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=CuZHP6YFsCwwA4TkyjhYi+XmEZKmSYURob9jZc/v+s0=; b=dwKf4EmYzHRokYeo01W6aRNiUbBxpqWukKoBAjKrsr21qyv4fvfvv8r8FC0fRGLFIn xy8cwnM77VLu80gvaYIoH/G1JbffxPND91EyaiFDMx7w57Dxf5fePgikVPhf4Pn1rER+ 4jhsW9zoF/8A5zNkYpRTOfhGhf+5cbhXzSScB/AHwJDuf21g0FrmGhY6Kj0o1uZx97yj T+DjkydMlva6JN/kFgrVxo9QorRJTmxGxC8nzGztwIhe3/7SZyXdRH0fx2g22ALfJbnT DburLIF/ltWcgWJjgGNgfaphag5QRSHP9Kdy+M02Ddklj3GSwGmdpam/X1mU8m/hmOjI l4dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761366731; x=1761971531; 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=CuZHP6YFsCwwA4TkyjhYi+XmEZKmSYURob9jZc/v+s0=; b=eLieKkVbuKs5QzpnbsdagdDlb3M/gCwMWb6OHjkqMkKllnkkZcBOuFIs2z4F2aNhWF hGE3GpLXnTyJGHmFYlIhgBfa0uFSdqRyaVJ1ftztoMqzsJApSQcl3J85vlXmhaxDcv9P dc4L+j9kfMcWhuzTRRquG2XI3DIUU6yKjglIVuFxaxwiOb16dRVIYgbwutaGWaWM9O5b PXRTpardNscqaMVQ1/ySi7v+NKr82KqIJ+7ytFcBaN8+NpKzcNz69+Cv3nD6ZQdqQ0Fw YAm5qfK38uCG+3l33BT8YrGE9DO6afjpQOTAnMD01liLzXKsM0CEcAz45Rw999/KqXM4 LM4A== X-Forwarded-Encrypted: i=1; AJvYcCUwLs2fM7HaxlhAWU7BD5ExNhfTL82d4RjTXcR6Ujfjh7YUm4Ocw2WdPisAoywasiTH8LR1+FSIFhYlJQ==@lists.linux.dev X-Gm-Message-State: AOJu0Yw9Ni57j6zw+LeRvPLnSpjFR9A0v6liH0x6hA5mLc5JWq2Mxpvk ZUQZxW/wpaDlMtA7MQurIsGO2FeHvpiQibchcLHbOh/Qs5WC02NHYOZD X-Gm-Gg: ASbGncv/d5WTYflgJnIQvPegi6GU1YVqra0/pTvVWEoypB9pyonT1XQciAVRip92+yd UKNNQKEjqwTIvx9+gzlzOrZ1dH3gfmY88fKmzsVZplQSEVngisIIctIBUaIXBGcwMOr6jPD+lGs qG7v3xayybriBRPQJgr/Tfq1zG7e70yxiUi+vidGoQfiEDNbe5Ou0y0uAUz0bKoC9uGOJoYtX5g JJjU7EDkjTz+SEGGjflk2sRgzxG1DGw7qkcC5xDQSDRmDwFcv6aH1IdR3ZLLzE3/LoL97zbgGN3 cTx5j5n97tOfXfJGX1fFIBhsVG1uvSMRA/WipDzFDQoiUKIwfpRt8Pqogc6lOFA66vjwazymhrd K+LtFERYYiwdSglrJlRCto9m0Bhihx0OmKerONNG1Phndfi3pnskc7/pHgRcsl/evmPOPjbmUJf 0o X-Google-Smtp-Source: AGHT+IHidqK20asSnkSoaYA0Ua+IEXaUMgtNo1d+OXf+4JbTCbl0aR8F8Cd5djjk9glXI6+3c84fFA== X-Received: by 2002:a2e:a916:0:b0:376:4430:b545 with SMTP id 38308e7fff4ca-378e4648542mr13761041fa.49.1761366730866; Fri, 24 Oct 2025 21:32:10 -0700 (PDT) Received: from junAIR ([176.106.241.81]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0ca7a0sm3409241fa.33.2025.10.24.21.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 21:32:10 -0700 (PDT) From: iuncuim To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Philipp Zabel Cc: Andre Przywara , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/6] dt-bindings: thermal: sun8i: Add A523 THS0/1 controllers Date: Sat, 25 Oct 2025 12:31:24 +0800 Message-ID: <20251025043129.160454-2-iuncuim@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025043129.160454-1-iuncuim@gmail.com> References: <20251025043129.160454-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O From: Mikhail Kalashnikov Add a binding for D1/T113s thermal sensor controller. Add dt-bindings description of the thermal sensors in the A523 processor. The controllers require activation of the additional frequency of the associated gpadc controller, so a new clock property has been added. The calibration data is split into two cells that are in different areas of nvmem. Both controllers require access to both memory cell, so a new property nvmem-cells has been added. To maintain backward compatibility, the name of the old cell remains the same and the new nvmem-cell-names is called calibration-second-part Signed-off-by: Mikhail Kalashnikov --- .../thermal/allwinner,sun8i-a83t-ths.yaml | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml index 3e61689f6..b2f750ef2 100644 --- a/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml +++ b/Documentation/devicetree/bindings/thermal/allwinner,sun8i-a83t-ths.yaml @@ -24,18 +24,23 @@ properties: - allwinner,sun50i-h5-ths - allwinner,sun50i-h6-ths - allwinner,sun50i-h616-ths + - allwinner,sun55i-a523-ths0 + - allwinner,sun55i-a523-ths1 clocks: minItems: 1 items: - description: Bus Clock - description: Module Clock + - description: GPADC Clock clock-names: minItems: 1 + maxItems: 2 items: - const: bus - const: mod + - const: gpadc reg: maxItems: 1 @@ -47,11 +52,16 @@ properties: maxItems: 1 nvmem-cells: - maxItems: 1 - description: Calibration data for thermal sensors + minItems: 1 + items: + - description: Calibration data for thermal sensors + - description: Additional cell in case of separate calibration data nvmem-cell-names: - const: calibration + minItems: 1 + items: + - const: calibration + - const: calibration-second-part allwinner,sram: maxItems: 1 @@ -107,6 +117,7 @@ allOf: enum: - allwinner,sun8i-h3-ths - allwinner,sun20i-d1-ths + - allwinner,sun55i-a523-ths0 then: properties: @@ -132,6 +143,32 @@ allOf: - clock-names - resets + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun55i-a523-ths0 + - allwinner,sun55i-a523-ths1 + then: + properties: + clocks: + minItems: 2 + clock-names: + enum: [ bus, gpadc ] + nvmem-cells: + minItems: 2 + nvmem-cell-names: + minItems: 2 + else: + properties: + nvmem-cells: + maxItems: 1 + nvmem-cell-names: + maxItems: 1 + items: + - const: calibration + required: - compatible - reg @@ -176,4 +213,17 @@ examples: #thermal-sensor-cells = <1>; }; + - | + thermal-sensor@2009400 { + compatible = "allwinner,sun55i-a523-ths1"; + reg = <0x02009400 0x400>; + interrupts = ; + clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_GPADC1>; + clock-names = "bus", "gpadc"; + resets = <&ccu RST_BUS_THS>; + nvmem-cells = <&ths_calibration0>, <&ths_calibration1>; + nvmem-cell-names = "calibration", + "calibration-second-part"; + #thermal-sensor-cells = <1>; + }; ... From patchwork Sat Oct 25 04:31:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iuncuim X-Patchwork-Id: 730 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3436E1411DE for ; Sat, 25 Oct 2025 04:32:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366748; cv=none; b=Oy/xK9N06mKaIe4spmNNlD+IizeI4988cFlQSh7gA+1Nli5h8ba67Mh6xKqCuoplpCzDIukcDcLCtSOuZeAJG6bzDSzLreeFlxBJaqXGRN7lrLNDKjIeJ9ZyLAgYbs62Bx7md/kEhkO9hRLkYqCQIw7gK85e1mPAiu+bc+Llgg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366748; c=relaxed/simple; bh=OXisvb9gi/TE1J28fYKNKmNR9Heo/ymBioo9V+DNdQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iSiyxSGiNFrZE/r0VfgAcUr3z4cRYLk+UbkWq5LGA6RQ/y/nMyrs7IsTbDqas4yKCTqZBzFMjntLjkSaoy1IvTb2G2Z0bCjOpBoHEWbF4oVD+Lm9AjxFudpHNn/Unp1zClv1O/V/GAk67wQawDbwzbchYCfjo4DWaHEEzAOD/O0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Q37piOZo; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q37piOZo" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-592f3d2d068so3286245e87.3 for ; Fri, 24 Oct 2025 21:32:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761366745; x=1761971545; darn=lists.linux.dev; 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=bw4z9PVBnrl74pcQ+V85ZiVa2r5TmKnZAhW/Uv6GfHQ=; b=Q37piOZoXp/o7xXATa0X6Yk32FZywtUwLeSr/M7QAtdjeLZ3CYsn49AMVkQgd7OqKp 1MVNfMvQxP5tFAdmUeGrGVKgCLeDoBmNCIgHDzdAykufS7TthgR4/hKCZ5nNEaaM8bkY HEAlQDOf4S94FrqzwmF/mgK+otl7MAidm8KTxzylM0UeQI7IzTXcmvvkd7uOhiJESRXC sBO5LMBsgLjtAIp1hwxs9fsrNASO3zOiL7j/enCIAYVeq441QZcnlsHNfrdMUeZc/5K7 if+0rD6TTvs0fghQUGPSy+BtmfFU6j+t7ECHr3P9iEmliX5XLd6YThpNNz3ZaqOU4t10 qFnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761366745; x=1761971545; 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=bw4z9PVBnrl74pcQ+V85ZiVa2r5TmKnZAhW/Uv6GfHQ=; b=QuGHptAT+c2TCxPzlHgBe4hbgJNDZxtqmHQxXMS1xq38Fhd8z9PYdDWFazfp+k79V7 y/HkITYbP2gnGO2s48alHU8XDCGDzjM7HeOqx5lmtagh426RpyoOJNY82+cc7UDRdeun DMYNUJV0bpwfGP4yHVhyWBmjwi8SH8T4hDYNnGx5hHUhKg8tUIJeTfUvNRH43KJJ47GN VWqYVmCafL+7rC+kARZ9C1Dc/LGkCp0IZPJHapj3O6uC/Eg968jofHhax8B3lzfYhTIP FwGC0gZkXXb+3M/LgI0VId1SvYdsOYfmjzmNY4ygdZRb2qq3NI51PjcsLu3jRNJkevYO +8ZA== X-Forwarded-Encrypted: i=1; AJvYcCVVRn32AKz+3yQjMcOJlBbSz0781DCM6VU854O7C50xwm1dMdjoNYTINBKODc9iIrWdGHjezyTE1T0weA==@lists.linux.dev X-Gm-Message-State: AOJu0YyNXOisTgXdwtVdP9bMjXNjCl3M1Bw583N2o7TWcI3137AFKFcF p0Ux9UGRgd3NNCSIcWul8pILXQZJsjDJ1CczfmoHRH7DljilKmpnDQ4c X-Gm-Gg: ASbGncvX4BKf9a22VsZ2kxOuVbG5Z/G6Q1VabfvME+wGiX+IxnyGes6qBY290X3jiDG 6kxmkRV1gjqBzFj4XWQdj+xZ6BU4nD42SoGOQK7DJgsSvMvZTodn21HI0OQ+DeKjYSIGX0o0vsh CTwV1qM9iJDQkOwOp0IeGIJYyxHvg1ExSjNfV1MWzb84WX47NO+wBqM8nEU98CdaOC73sSl/gU/ Gb6jBfg1R/8B9ixdswIx4xq7cjQPJr5GrHWYNFeFi9hke+kaMzQCB+4SOVLGLD5vMba9qjXHHgP RM5xhTkr2vgRdWaSqR8gzFhxGrOn++jPeNJfCJG0m0otPCGn1S3dDwsQpmgE6iWrHDJyYub3zlK dC9kqHby4P4C5iMd3qBe3t1AHjt4byGGqSBhvtKqaIPBbpTFMSmn1bV45dQ5O+hw1ShLyoOZr5j DX X-Google-Smtp-Source: AGHT+IFIlO0Xnz3NfsASBS+sA6Ogolz52/zgOOHUf1BRiQNX9JIhdrYW1iCIFtP2vXKndrvpB2lUXQ== X-Received: by 2002:a05:651c:221f:b0:375:db6e:fac9 with SMTP id 38308e7fff4ca-37797a0dab3mr93162251fa.31.1761366745177; Fri, 24 Oct 2025 21:32:25 -0700 (PDT) Received: from junAIR ([176.106.241.81]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0ca7a0sm3409241fa.33.2025.10.24.21.32.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 21:32:24 -0700 (PDT) From: iuncuim To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Philipp Zabel Cc: Andre Przywara , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/6] thermal/drivers/sun8i: add gpadc clock Date: Sat, 25 Oct 2025 12:31:25 +0800 Message-ID: <20251025043129.160454-3-iuncuim@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025043129.160454-1-iuncuim@gmail.com> References: <20251025043129.160454-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O From: Mikhail Kalashnikov Some processors (e.g. Allwinner A523) require GPADC clocking activation for temperature sensors to work. So let's add support for enabling it. Signed-off-by: Mikhail Kalashnikov --- drivers/thermal/sun8i_thermal.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 226747906..c02c398b0 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -66,6 +66,7 @@ struct tsensor { }; struct ths_thermal_chip { + bool has_gpadc_clk; bool has_mod_clk; bool has_bus_clk_reset; bool needs_sram; @@ -89,6 +90,7 @@ struct ths_device { struct regmap_field *sram_regmap_field; struct reset_control *reset; struct clk *bus_clk; + struct clk *gpadc_clk; struct clk *mod_clk; struct tsensor sensor[MAX_SENSOR_NUM]; }; @@ -417,6 +419,12 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) if (ret) return ret; + if (tmdev->chip->has_gpadc_clk) { + tmdev->gpadc_clk = devm_clk_get_enabled(&pdev->dev, "gpadc"); + if (IS_ERR(tmdev->gpadc_clk)) + return PTR_ERR(tmdev->gpadc_clk); + } + if (tmdev->chip->needs_sram) { struct regmap *regmap; From patchwork Sat Oct 25 04:31:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iuncuim X-Patchwork-Id: 729 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1776C267F57 for ; Sat, 25 Oct 2025 04:32:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366764; cv=none; b=kKeo7C+jgMUesykXKV/kYk7S++UG/vOrCDCroi82rdUYvVfSk5IpNZn+TbuB52zNJ0mEQD0EmSZc+emuhzUCgYSwfIrwbhLLsX1GQJUshM4G61baC7CHQ46uOwUFSzQbMRyYC0goJ3YQ5HnpTyQ+aJ8uoUib1AM/ncHycmPLrUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366764; c=relaxed/simple; bh=JFlSRxXwWBQ3XACpCIXATa+zwXHpyzhtFajoU+nnbIg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dUabEoWY86NRzQ1lORKaDjHcJBehz6VbSvQD/Tn1HU26gvipX2D8EOamOIOTw5fU3NmB2EyqPO9EbCHbLDnzqpNVzSiVeAViWDJ01S2zTShTH4Zd2PcIrWgRcsOPO79JBE9sUgs31zo4FATEJs4NhZDGP0YLAYGPDa8hv3lEWMw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gN3a5aQK; arc=none smtp.client-ip=209.85.208.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gN3a5aQK" Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-3761e5287c9so32387371fa.2 for ; Fri, 24 Oct 2025 21:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761366761; x=1761971561; darn=lists.linux.dev; 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=i3+BmyLOtp7xUTMRQtQMY1TWwM+wvGI7ScMcGnjI6fc=; b=gN3a5aQKjEFuJrIXb3yS5v/I0iavFqdgz5tWkhTaT3ief6t0tEnmJY2Iy9DQG078V0 6zWXUSYepZYAyoH8PFVcUQ4ivwy7aAgeE2/SK7PEra4FATljAfuQS1xJGBrvZ+wNSUll 1VrVZKwy10lMq8Y/vW3ibD8tCoxRn4qz3Thm36ugJrCrXNIPg2AeJp2wH+cDIhWVzjTL 4dhctp3WPvv4Kycc19yN9eePyKnZsrBQy+PzC/B3WcoEe1bDR5vbN1D8JWJpMPTgSBrV I5vTbD/9aJ3HKjeLx935k0tziz2Ca0CLMnvfUJ2iqma8al0mNGkIisFrY5Utco10IMzB S2tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761366761; x=1761971561; 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=i3+BmyLOtp7xUTMRQtQMY1TWwM+wvGI7ScMcGnjI6fc=; b=xRvBV6NicvyQARn9KpIqXGpAF+TxV6JCkfNPBt49t9c27uCRwCe/v6YM5Uz0accf/q 4TEykPD7TtU+j8k9Ai3aoiohCakGEXSjTHZwACguqRWMKTzoToEmS/A3bcM20TxShYkL jqaZcoiCuRGA6EGR1AvJNOjVnw6Mo2eDOlH4CZVcTRBEe9eLYBVG0uxJx1USCDrlXCoe 0OrNqhqxzWeirvTigr5eMe0gw9PhuC+B/1ekMc+BNHnGGrd13gu/n51stzsEPngF1/NX MR5hv41/TYVFP/SEaeU2kVjBDeYHt/4y21VwcYbwjhCsHcivtx60krSOMt9fxubvxDnv 36QQ== X-Forwarded-Encrypted: i=1; AJvYcCUDlMUrIGC3PHU3vq8JqQSBskgSt9oGTCHkGj2O0Fs0bfA4I2AHlb8MbeMCKCZh+talC6r8ZG5WtRBemQ==@lists.linux.dev X-Gm-Message-State: AOJu0YyqpHOupo82I7QlDNftGVEFY1suZucrIH4nPxE7VjLLNc4dVQKl pZSZg/y+jay3itU+F+w0ELaZO84r+KlHjCmud1ZCXd+FigFMLKIdFkzV X-Gm-Gg: ASbGncskwPEKJiJwSHEUmTN5CkvXBjaOhvMLxUFN9PuRxgTa7ZxyqB4WlpkUWfVzgIE Cy9zj+SjM2wv0VQHLFPBsnwoLY44iS/kfD2zto/JSogyEJiC8xTaH8tgRSfgZ0rI/UYkqmj/FNe zod3igy00+BetoRi2/RF6kxdgs5VcyLom/uPEcM3WkVHdACWFmVEPLDn2v7Cy38BRW2Gz4qIESu kfcHm+p0GHZWp/9aQ/HLUOacMXZz0Zg9mNtiINlY6z1rhCNcUCl8/t/8ektnTFt5OdaBHKBBg/Y kCKBp5qsgf/9QNae77VZWbOTewakhUgWUVxqAwqXa1gmGTAAlmg1EDGH1hs5tPnolWQSifygZUy DxPaQw4E2kZNYohQ4jC7+r4LFRzzjJcDkIylMKQggZR1X5KR/6Wo+jRcJZXoqj+OsnQ== X-Google-Smtp-Source: AGHT+IEKvrwo7BMcvdLr8sMnPaVHb2OI/tgnv1kSKzQDgd1sc7jso2BrG2SWkbje2QobtPqCs0yKQw== X-Received: by 2002:a2e:bd17:0:b0:36c:2367:b3c1 with SMTP id 38308e7fff4ca-37797a58f18mr88205231fa.35.1761366760931; Fri, 24 Oct 2025 21:32:40 -0700 (PDT) Received: from junAIR ([176.106.241.81]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0ca7a0sm3409241fa.33.2025.10.24.21.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 21:32:40 -0700 (PDT) From: iuncuim To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Philipp Zabel Cc: Andre Przywara , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/6] thermal/drivers/sun8i: replace devm_reset_control_get to devm_reset_control_get_shared_deasserted Date: Sat, 25 Oct 2025 12:31:26 +0800 Message-ID: <20251025043129.160454-4-iuncuim@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025043129.160454-1-iuncuim@gmail.com> References: <20251025043129.160454-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O From: Mikhail Kalashnikov The A523 processor has two temperature controllers, but they share a common reset line. Make it shared with the shared variant of devm_reset_control_get(), and also simplify the driver by switching to devm_reset_control_get_shared_deasserted(). Signed-off-by: Mikhail Kalashnikov Reviewed-by: Chen-Yu Tsai --- drivers/thermal/sun8i_thermal.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index c02c398b0..aa496e1ba 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -344,11 +344,6 @@ static int sun8i_ths_calibrate(struct ths_device *tmdev) return ret; } -static void sun8i_ths_reset_control_assert(void *data) -{ - reset_control_assert(data); -} - static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) { struct platform_device *sram_pdev; @@ -391,19 +386,10 @@ static int sun8i_ths_resource_init(struct ths_device *tmdev) return PTR_ERR(tmdev->regmap); if (tmdev->chip->has_bus_clk_reset) { - tmdev->reset = devm_reset_control_get(dev, NULL); + tmdev->reset = devm_reset_control_get_shared_deasserted(dev, NULL); if (IS_ERR(tmdev->reset)) return PTR_ERR(tmdev->reset); - ret = reset_control_deassert(tmdev->reset); - if (ret) - return ret; - - ret = devm_add_action_or_reset(dev, sun8i_ths_reset_control_assert, - tmdev->reset); - if (ret) - return ret; - tmdev->bus_clk = devm_clk_get_enabled(&pdev->dev, "bus"); if (IS_ERR(tmdev->bus_clk)) return PTR_ERR(tmdev->bus_clk); From patchwork Sat Oct 25 04:31:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iuncuim X-Patchwork-Id: 728 Received: from mail-lf1-f52.google.com (mail-lf1-f52.google.com [209.85.167.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF1BF273D75 for ; Sat, 25 Oct 2025 04:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366778; cv=none; b=NIVANlmXo+h+rbfz6H/OPGu7MG714dYcLi2sFlW27fytpqturDYsjGfSRAA+h3B+YiVE3+cx0SivzI7OvGA7QNGHGRg727xxlHsfP/SMXbgoxLRk3bi/7rxJLYnjCyo/mrhId6ZJTI4OFznVt/N/PQrnkDwmJL6y/dfpNDBRhkQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366778; c=relaxed/simple; bh=J/zzc1ja43MRTCgO8LF4bp6opHtC/iF4Lw9TqE0/ybQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HY9SsCwD/yqoRPBLeS6RPcFT3+NyAy/ghJt/j5abwTgqTMrLZ5KW4VdqjD6yxXZqCg+2bpNVIBMQvqRm3oNUcyj/lL5gJ/VVJwRGRsMj+1PMUQaAg21hrsKtdhNaUNnxEJYm8DDwCM0B/3VYtH6jc3hEJeOjfcbWOoM1O1aSSJY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BpVAiOu0; arc=none smtp.client-ip=209.85.167.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BpVAiOu0" Received: by mail-lf1-f52.google.com with SMTP id 2adb3069b0e04-592f5736693so2811847e87.1 for ; Fri, 24 Oct 2025 21:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761366775; x=1761971575; darn=lists.linux.dev; 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=aU3qD3/P4X3aGl+GxoTABgHAWYmZmNCs4mQEkZTLmtc=; b=BpVAiOu01kUDl5PBYhAc1oox1mfJRAR0mWzsJvErh7ey4I2C7vDxZG9O3xk+qqa6Af Kge6NLWv/RxxAl4VP8ZU9B3VC0EeGUofj9pgkx2yXYH+vIkezvCiRSnNeNbIwusQOo+s K8spbIAmg3vI2fYGMNSKm5WqvgXEUtFITwlD2OZjyfFIPJ926qqDefjGaCGisk+msayn gALR/kduqlY8rVj0lJYE5EdNRrsvWjCfVwtbvvtDhH40vA0seIB71hM7nhMgRhihHFkq Gh7w+IRTPN8tJwDiYpG7VPbizt2eI5QTg57qKDozvOp4xO7vI6cEhrxoCaprUa6pkOk8 jdng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761366775; x=1761971575; 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=aU3qD3/P4X3aGl+GxoTABgHAWYmZmNCs4mQEkZTLmtc=; b=BVdXzOIoRQhSQEp70t6k7glMZqgxVJEmylGcPG8tWqemCixPGaCxA5BugxdTAoJdFR ixjh6ybIq5zJFD4ztt3/hv0J7M56Yztbp81UOucp3LdILKM3/9qjq1zjGYAD+Qx3+gt9 hRmR5Jy7pmYpjx8YYS8CAFNe6vy9pshmv5qbVu4poyhD/lzRMlsKjxM0d0m2hWK/heaT Rx7QslnYLaCeTBL5EFTSrT7WaWR87d3WsC04qocElTLNCdI4pIe12Efl9krfJSKscGIO 2yt1gEB6HbvdQBVsjiRfWUfehtBWkDPKmJAXy21gLSj9T0R7WHQL/E8y9X/bBN1n+9J7 GfBQ== X-Forwarded-Encrypted: i=1; AJvYcCWA5ScmZgqnlU0m3AEolR90Dj6AZPSEZ3mW34hj/6ODzGfYY1yosSbCU8g9GBakoyN9BtltdaLCoHeOeQ==@lists.linux.dev X-Gm-Message-State: AOJu0YyE+kUOYTZzKeKwaRXYjUPwxN+JZYyqpMRQ/Ev3yXFmgHTlBify j4QlDNzE/v/CprFaIvtKLweY/ccXqc3oYTacbIa7wJwr3+ivY1EzcQOY X-Gm-Gg: ASbGncs/W5YbLUi+98xu22G9Rh32qhARrk5/xbDEYQ/BgzR9XQV1CgJwprN3kxhq/5O oPjp+W93wftNS6oXle06va84Xdl6d8yLmVQK/spfOGdXopDglpj5F3jAvM0MbYv3uC2QKT9w6SE PpqcHcuYNksXRyntAjqAU/i4FkG/uHmAaHbwRN3ZgPCDj6yOm7aoOwbU1yPyHp81z+EagC9s+43 U6Cbngsi2YEprJIu2b5/p8OUj+1ZQW/e/QuAVlreSgyk5Is6ZFK3h5vzUqIDl5GpbBTMU7/8U8a lCfPbLBqDuXGFjygo0mJUxFI90VbS0QerxQ8UVVGIAxFZc9KvTC1ONxetubnXkEzql6dZJA2MUJ A3nL1kiiP8/PiZ9NsiadxeAXdhRkaaORqHsBiZS0Ofl8kho0UHO0/Dz94BgE9RTPwo6CZnv/LuY PL X-Google-Smtp-Source: AGHT+IH/eF1EDfMQXoqCn1NhnMmPtXp6P1wcPRtuabMRfy3u2y12SFECgEV2LqHRoicJ+PYpOzbYLg== X-Received: by 2002:a2e:a916:0:b0:376:4430:b545 with SMTP id 38308e7fff4ca-378e4648542mr13765001fa.49.1761366774636; Fri, 24 Oct 2025 21:32:54 -0700 (PDT) Received: from junAIR ([176.106.241.81]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0ca7a0sm3409241fa.33.2025.10.24.21.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 21:32:54 -0700 (PDT) From: iuncuim To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Philipp Zabel Cc: Andre Przywara , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 4/6] thermal/drivers/sun8i: get calibration data from two nvmem cells Date: Sat, 25 Oct 2025 12:31:27 +0800 Message-ID: <20251025043129.160454-5-iuncuim@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025043129.160454-1-iuncuim@gmail.com> References: <20251025043129.160454-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O From: Mikhail Kalashnikov The A523 processor has calibration data in two nvmem cell. To be able to add support, the ability to add data from two cells into one array must be added. Signed-off-by: Mikhail Kalashnikov --- drivers/thermal/sun8i_thermal.c | 77 ++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index aa496e1ba..d6d8e13e5 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -303,43 +303,70 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev, static int sun8i_ths_calibrate(struct ths_device *tmdev) { - struct nvmem_cell *calcell; + struct nvmem_cell *calcell = NULL; struct device *dev = tmdev->dev; - u16 *caldata; - size_t callen; + struct device_node *np = dev_of_node(dev); + struct property *prop; + const char *cellname; + u8 *caldata = NULL; + size_t callen = 0; int ret = 0; - calcell = nvmem_cell_get(dev, "calibration"); - if (IS_ERR(calcell)) { - if (PTR_ERR(calcell) == -EPROBE_DEFER) - return -EPROBE_DEFER; - /* - * Even if the external calibration data stored in sid is - * not accessible, the THS hardware can still work, although - * the data won't be so accurate. - * - * The default value of calibration register is 0x800 for - * every sensor, and the calibration value is usually 0x7xx - * or 0x8xx, so they won't be away from the default value - * for a lot. - * - * So here we do not return error if the calibration data is - * not available, except the probe needs deferring. - */ - goto out; + of_property_for_each_string(np, "nvmem-cell-names", prop, cellname) { + size_t len; + u8 *caldatapart; + + calcell = of_nvmem_cell_get(np, cellname); + if (IS_ERR(calcell)) { + if (PTR_ERR(calcell) == -EPROBE_DEFER) + return -EPROBE_DEFER; + /* + * Even if the external calibration data stored in sid is + * not accessible, the THS hardware can still work, although + * the data won't be so accurate. + * + * The default value of calibration register is 0x800 for + * every sensor, and the calibration value is usually 0x7xx + * or 0x8xx, so they won't be away from the default value + * for a lot. + * + * So here we do not return error if the calibration data is + * not available, except the probe needs deferring. + */ + goto out; + } + + caldatapart = nvmem_cell_read(calcell, &len); + nvmem_cell_put(calcell); + calcell = NULL; + if (IS_ERR(caldatapart)) { + ret = PTR_ERR(caldatapart); + goto out; + } + + caldata = devm_krealloc(dev, caldata, callen + len, GFP_KERNEL); + if (!caldata) { + kfree(caldatapart); + ret = -ENOMEM; + goto out; + } + + memcpy(caldata + callen, caldatapart, len); + callen += len; + kfree(caldatapart); } - caldata = nvmem_cell_read(calcell, &callen); if (IS_ERR(caldata)) { ret = PTR_ERR(caldata); goto out; } - tmdev->chip->calibrate(tmdev, caldata, callen); + tmdev->chip->calibrate(tmdev, (u16 *)caldata, callen); - kfree(caldata); + devm_kfree(dev, caldata); + caldata = NULL; out: - if (!IS_ERR(calcell)) + if (calcell && !IS_ERR(calcell)) nvmem_cell_put(calcell); return ret; } From patchwork Sat Oct 25 04:31:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iuncuim X-Patchwork-Id: 727 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB6F9262FCB for ; Sat, 25 Oct 2025 04:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366793; cv=none; b=kqYr9tpdOnLn4VpFqbVe+WgQ9q15QmR+7gDf6FRsdnnK867LPHtFF5mvJzkm7AnvlRPDjcSSVX4ZRO0njqDr5gD6OiqaNes8OqJ2aIl3TGAO//so9WuoXstcH/uFTSrdPvXD53VCtOBmT2+YmjfDM3jWyLwOXkNhlWLRr0A8kxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366793; c=relaxed/simple; bh=vKwIkRtVEbLiJY2BlW4E9oyIfD48LqL7a3hDQ3iAOsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PP6GjYAIPSCQz1jjL/KO9exdSHNwlIX0NohpMlR/15KUliJVPSkRtzVQ1/ca49dk6PuR6DM4B3vFoWPYFWBAlHUEat5vbXfdGqY0C5k1S/xLbZC6AbKrbIG3py3R5Fg6AkLwh9vY2yHjzv1GjryJzvLYpUxNvAUBp3FTkvg3C80= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fCi7RqZH; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fCi7RqZH" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-57bd04f2e84so3388555e87.1 for ; Fri, 24 Oct 2025 21:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761366790; x=1761971590; darn=lists.linux.dev; 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=BpucFmLklCdqMhA9C9XyPHvfCwLqk6dMk7FGikdB0lU=; b=fCi7RqZHSJll7m0e7vYEYQCFlHwowa16GtqUdWiZQnayxfLD5TxeLRGIb+1CCz/w4Y vrcFvmjLe6bFZYH++lXprD1pGKRAkd+kIni/VWP/t5XO5r5tChsxNDQQWXSm1zMYPOsd d+MU8uGJl3v+g5SuI+sq9irladJ2QBejX7rg48ZSI4ltY6ZDNKKEW0ikSVod8f8ntr9f FrDN76OkBHcV+t2XzImS04uagSIm9EJJ4dW06Cqfn9acCElQ/Ru6rNNyWeqDZkIyGO9d Re+hcM/PU3cpaVfu5bAS7hUOjRST0AYlP7+1t+HHP+Xavoh0jPQri1uYO43JnInimLdu CSZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761366790; x=1761971590; 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=BpucFmLklCdqMhA9C9XyPHvfCwLqk6dMk7FGikdB0lU=; b=NPpXf3dHQ05PUpwZOBnLwCdKCBoka8XKW67gXJDDxoKbii9USKIS41W1XY3zTSYtdd 7r9zs2CUZ0jnchJSAdrGuG2hoJaMoK74Z9ZobIxRhEzjpHWmCHsSByVO3bSkFx2O+HJf bKJ0GX5qx5EhIxuXvZTFKtS7Yt+EQSwQwKQN72jJOi9qIqCsfeMZ2dNXNwF+g/huCULE 3mDhrVEMWVXMMsTZL92UfkrRqkwhJ89e0ciDRJKOV5KuswC06Kii+iiM8/wB5nEYykoB HFA7O/HiLueGXMG+8LzSVrLxisyvSyxVTrPLZLsx62Y2uREaafBpDkTQrtjbP2V9fmKD 9XwA== X-Forwarded-Encrypted: i=1; AJvYcCUhJeJdViEL4Px4o9YJuU1kUB2osUAzO9hWV6FgXt2UpImVvTFapxnt1vxpLUdshRxb1UoT+p1ekwLF7g==@lists.linux.dev X-Gm-Message-State: AOJu0YzBIl36mozN682cHd53UotxbhtXfrmJL7zRDDyZMqcC7AeFha2x XCVPQ1h6JNIjD+6xg3g6v1X5N93b//nUWzUyxPr/9P76+iEwUpfumoNi X-Gm-Gg: ASbGncsqpv+YG7d4ECDKYJVcAADO3MAcsX9hw8HcXUYZdxGjqm0dLgvjN00b+hWJZd3 M/OEbhrWneuNL14/1e+mVM2R15Wy3EAivBQEntNAwdQ2SBqXz0fCgW9fhtWJTv0addnWgkyOt8+ r196PDso7lVGIx62dKdWR7zqCpu22ZuCBGO/AcSjJdjEZYDlBlELFXpnFkfjbMMJjzznzrdV2by D4m5ZJymHGCaTMiSompiCJoDJyJw8HkcQySBRguj3MG8p5LqHLq8hwWYm5+G6SQeQ686kY9iCm9 nsO6nNei6AiN8E8AkkVkTfcBAP5q5GLleApg6xW5Ei/i78YzZHAIEaV7uMlnK+vuZTTP93sfXV5 tg9irp7u9tURpvhQPrLs1XlGbhsA4QAm4nsuSKfva+MjkiVpYijZDaJzJ78B8sojLF9/FfVG1o8 T1 X-Google-Smtp-Source: AGHT+IGI1bkGkIs+m+mcDg1QheXEpjkKTfwp/CVg0HfjhPonvg/HY7Zg24J0VSwSVIiajjlFuNgFMg== X-Received: by 2002:a05:651c:150c:b0:378:e58f:5f10 with SMTP id 38308e7fff4ca-378e58f613dmr12893371fa.35.1761366789881; Fri, 24 Oct 2025 21:33:09 -0700 (PDT) Received: from junAIR ([176.106.241.81]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0ca7a0sm3409241fa.33.2025.10.24.21.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 21:33:09 -0700 (PDT) From: iuncuim To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Philipp Zabel Cc: Andre Przywara , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 5/6] thermal/drivers/sun8i: Add support for A523 THS0/1 controllers Date: Sat, 25 Oct 2025 12:31:28 +0800 Message-ID: <20251025043129.160454-6-iuncuim@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025043129.160454-1-iuncuim@gmail.com> References: <20251025043129.160454-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O From: Mikhail Kalashnikov The A523 processor has two temperature controllers, THS0 and THS1. THS0 has only one temperature sensor, which is located in the DRAM. THS1 does have 3 sensors: ths1_0 - "big" cores ths1_1 - "little" cores ths1_2 - gpu The datasheet mentions a fourth sensor in the NPU, but lacks any registers for operation other than calibration registers. The vendor code reads the value from ths1_2, but uses separate calibration data, so we get two different values from real one. Signed-off-by: Mikhail Kalashnikov --- drivers/thermal/sun8i_thermal.c | 133 ++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index d6d8e13e5..7d35ea3c4 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -59,6 +59,12 @@ #define SUN50I_H6_THS_PC_TEMP_PERIOD(x) ((GENMASK(19, 0) & (x)) << 12) #define SUN50I_H6_THS_DATA_IRQ_STS(x) BIT(x) +#define SUN55I_A523_DELIMITER 0x7c8 +#define SUN55I_A523_OFFSET_ABOVE 2736 +#define SUN55I_A523_OFFSET_BELOW 2825 +#define SUN55I_A523_SCALE_ABOVE 74 +#define SUN55I_A523_SCALE_BELOW 65 + struct tsensor { struct ths_device *tmdev; struct thermal_zone_device *tzd; @@ -116,6 +122,15 @@ static int sun50i_h5_calc_temp(struct ths_device *tmdev, return -1590 * reg / 10 + 276000; } +static int sun55i_a523_calc_temp(struct ths_device *tmdev, + int id, int reg) +{ + if (reg >= SUN55I_A523_DELIMITER) + return SUN55I_A523_SCALE_ABOVE * (SUN55I_A523_OFFSET_ABOVE - reg); + else + return SUN55I_A523_SCALE_BELOW * (SUN55I_A523_OFFSET_BELOW - reg); +} + static int sun8i_ths_get_temp(struct thermal_zone_device *tz, int *temp) { struct tsensor *s = thermal_zone_device_priv(tz); @@ -301,6 +316,97 @@ static int sun50i_h6_ths_calibrate(struct ths_device *tmdev, return 0; } +/* + * The A523 nvmem calibration values. The ths1_3 is not used as it + * doesn't have its own sensor and doesn't have any internal switch. + * Instead, the value from the ths1_2 sensor is used, which gives the + * illusion of an independent sensor for NPU and GPU when using + * different calibration values. + * + * efuse layout 0x38-0x3F (caldata[0..3]): + * caldata[0] caldata[1] caldata[2] caldata[3] + * 0 16 24 32 36 48 60 64 + * +---------------+---------------+---------------+---------------+ + * | | | temp | ths1_0 | ths1_1 | + + * +---------------+---------------+---------------+---------------+ + * + * efuse layout 0x44-0x4B (caldata[4..7]): + * caldata[4] caldata[5] caldata[6] caldata[7] + * 0 12 16 24 32 36 48 64 + * +---------------+---------------+---------------+---------------+ + * | ths1_2 | ths1_3 | ths0 | | + + * +---------------+---------------+---------------+---------------+ + */ +static int sun55i_a523_ths_calibrate(struct ths_device *tmdev, + u16 *caldata, int callen) +{ + struct device *dev = tmdev->dev; + int i, ft_temp; + + if (!caldata[0]) + return -EINVAL; + + ft_temp = (((caldata[2] << 8) | (caldata[1] >> 8)) & FT_TEMP_MASK) * 100; + + for (i = 0; i < tmdev->chip->sensor_num; i++) { + int sensor_reg, sensor_temp, cdata, offset; + /* + * Chips ths0 and ths1 have common parameters for value + * calibration. To separate them we can use the number of + * temperature sensors on each chip. + * For ths0 this value is 1. + */ + if (tmdev->chip->sensor_num == 1) { + sensor_reg = ((caldata[5] >> 8) | (caldata[6] << 8)) & TEMP_CALIB_MASK; + } else { + switch (i) { + case 0: + sensor_reg = (caldata[2] >> 4) & TEMP_CALIB_MASK; + break; + case 1: + sensor_reg = caldata[3] & TEMP_CALIB_MASK; + break; + case 2: + sensor_reg = caldata[4] & TEMP_CALIB_MASK; + break; + default: + sensor_reg = 0; + break; + } + } + + sensor_temp = tmdev->chip->calc_temp(tmdev, i, sensor_reg); + + /* + * Calibration data is CALIBRATE_DEFAULT - (calculated + * temperature from sensor reading at factory temperature + * minus actual factory temperature) * X (scale from + * temperature to register values) + */ + cdata = CALIBRATE_DEFAULT - + ((sensor_temp - ft_temp) / SUN55I_A523_SCALE_ABOVE); + + if (cdata & ~TEMP_CALIB_MASK) { + /* + * Calibration value more than 12-bit, but calibration + * register is 12-bit. In this case, ths hardware can + * still work without calibration, although the data + * won't be so accurate. + */ + dev_warn(dev, "sensor%d is not calibrated.\n", i); + continue; + } + + offset = (i % 2) * 16; + regmap_update_bits(tmdev->regmap, + SUN50I_H6_THS_TEMP_CALIB + (i / 2 * 4), + TEMP_CALIB_MASK << offset, + cdata << offset); + } + + return 0; +} + static int sun8i_ths_calibrate(struct ths_device *tmdev) { struct nvmem_cell *calcell = NULL; @@ -730,6 +836,31 @@ static const struct ths_thermal_chip sun50i_h616_ths = { .calc_temp = sun8i_ths_calc_temp, }; +/* The A523 has a shared reset line for both chips */ +static const struct ths_thermal_chip sun55i_a523_ths0 = { + .sensor_num = 1, + .has_bus_clk_reset = true, + .has_gpadc_clk = true, + .ft_deviation = 5000, + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, + .calibrate = sun55i_a523_ths_calibrate, + .init = sun50i_h6_thermal_init, + .irq_ack = sun50i_h6_irq_ack, + .calc_temp = sun55i_a523_calc_temp, +}; + +static const struct ths_thermal_chip sun55i_a523_ths1 = { + .sensor_num = 3, + .has_bus_clk_reset = true, + .has_gpadc_clk = true, + .ft_deviation = 5000, + .temp_data_base = SUN50I_H6_THS_TEMP_DATA, + .calibrate = sun55i_a523_ths_calibrate, + .init = sun50i_h6_thermal_init, + .irq_ack = sun50i_h6_irq_ack, + .calc_temp = sun55i_a523_calc_temp, +}; + static const struct of_device_id of_ths_match[] = { { .compatible = "allwinner,sun8i-a83t-ths", .data = &sun8i_a83t_ths }, { .compatible = "allwinner,sun8i-h3-ths", .data = &sun8i_h3_ths }, @@ -740,6 +871,8 @@ static const struct of_device_id of_ths_match[] = { { .compatible = "allwinner,sun50i-h6-ths", .data = &sun50i_h6_ths }, { .compatible = "allwinner,sun20i-d1-ths", .data = &sun20i_d1_ths }, { .compatible = "allwinner,sun50i-h616-ths", .data = &sun50i_h616_ths }, + { .compatible = "allwinner,sun55i-a523-ths0", .data = &sun55i_a523_ths0 }, + { .compatible = "allwinner,sun55i-a523-ths1", .data = &sun55i_a523_ths1 }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, of_ths_match); From patchwork Sat Oct 25 04:31:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: iuncuim X-Patchwork-Id: 726 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EECCA26D4DD for ; Sat, 25 Oct 2025 04:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366807; cv=none; b=W87BPCXSE+Yeu7JY9O2rNwXy9dp5BR/MBfQ1GVAax+VgZ23rNqLfbDTIwhqU90EdYj8PP7wyin4OWKDOgJoyian8PqHrRGSTYGHDu2UMWmg+XU5qMbvqgDfgkkYzG2cAGWT+z1vR+HiUwMCpXY51BRSuCzwbC7eGJQmx0wrk0Eg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761366807; c=relaxed/simple; bh=HLkZrRq3NGY0xnF3Ajij+/FlY5p+nZpDzyvy6gl4718=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=skqD26hkRaiRM4/7Sa1ll0b6WKpZA2vof8fZ+QCKcVkdRW+g8ZaM2mPcGEPUF5jN5r9V37at1nPd6xCcpp2OU53IOgMNIN/TZxBIyOLJUkGHwmatAqmkcgwRZdmVl3uzL/R1buJc51WIUojFZtvTVe1Pz9yvzHbq8CoMZwEsw4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=c09F8Bc5; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c09F8Bc5" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-378d65d8184so37589561fa.0 for ; Fri, 24 Oct 2025 21:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761366804; x=1761971604; darn=lists.linux.dev; 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=nGpVSnY2YGnC6StYjZi+g05NBMCnFA0794RPi3L6J+s=; b=c09F8Bc57O8yXAts7RYjF72o54jCvCbZ9pMzZD5VJ9eW4Js6I4jruOXwVydSaX6Gv4 fV4G5uXF+VpuoPz4SP/JOdKiKMOl0Gso6Z0NIGaxQ5ou/FnjIPjqTa1e9kRr8Rgrxep8 6/tNUNDDp6v9vHYrrlMEvXE+qVhTdt3LzkCGpMZgcGRTo++1I2dFsKFteyLTm/SkMGdF Fb9Dono92L9hpLtzqSVe3ceisRaPsM2eYF6z3fHD0pC1vcAc726mpnG+LhDm8tyZYfXj 84173szYpzpLmGzYgINiB+1Gr1TUE6yUlz9J6zHUYLEAa7flYSa/zAfDWmhMIzxULgVn V7Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761366804; x=1761971604; 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=nGpVSnY2YGnC6StYjZi+g05NBMCnFA0794RPi3L6J+s=; b=WUPjiqgQx7IinnBlozFHFN9i0cXS8iq7+sNxj8O7/YWxCcC3iyM2WRGvu2TZAzwMxz U2vgMP+L8u178uxU5peC1OZZOPy36Odsc49gb70VLnvjx0BuMzn/HESqfCq1Tzexor7p gop0K44YCFjz2ORy8I6x7Hl1+Rtkn8rwXDNvF3Ivr9PIGOY3yGtpL5XRraHfXvrZvu3T FpP/mkgSahHgcUZFiDrZ4JvHdckLPf/93RyoKtCZSyO34KF3NvHYmpAY58XqDHzX4Srb p/WlkElDu6WaPn/IzHmIEgag2cFMiFPrVstjJGbfuboI1d7A4nhzH2q0e4OhykdSYtzd 418g== X-Forwarded-Encrypted: i=1; AJvYcCWhPK5mZS4e/XKeK1RjOoy4Huh2ygF67Ao3yvn+Lznftn1HVoAC2KVhPg3ntvIb8TYELqnmAWISqc1Gaw==@lists.linux.dev X-Gm-Message-State: AOJu0YyP4eqnYu0fuV/MC4aviJKlFscz5SMRuFuIDBSh+X3/oP0DNHKi kdUtKDvaxcNVhwfQK9O7KQt2IP68heiYEAB36SW4wSy3+7FHlD0ILQr/ X-Gm-Gg: ASbGncsIaL1aETZG8xpZcL3+m+VFScpfybZfvXyRasHMQnrKuhJI1Wy97GJSOS/GcPu xG4byZsse7xihbuNOqC8IDe462n+uVlQ4oUjpAr71B8tVziDj74V7vrBkgQMzm+RE4FD402xOrR 7YYV6eV5xhJmqaHGUd+LRH1yHTNu1Brx9Had25s1ijKyf8MLBSYG5MYbaINktiQJ50Z93DexrkM Kh6bY35tySETQG6m182ODq1B2RhWrmvDj3eAB4GWWmVm2eHsxUMIgepRWKLGA4kHFce3dWRfjwV a/DQTbedKM5OQc9udm/33EefCPks2JWInU6BgG/1OCeby1DYOZi1YR6/Ux/6L4KY9jF7+XEbeR0 EKKXguzsidyJBi5wUqVLdTiiJhe+HqPEwPmVVslI4NqWxyamgWf/YItJ01lVlv6M7Q6BfRsLV4V ua X-Google-Smtp-Source: AGHT+IGj8aCrZj29Rg9HWwRsU0X1CDkriVFw8huU9nZ548l08naKsaur1apTfOMiV+X0MeyojMrrVA== X-Received: by 2002:a2e:b8cc:0:b0:36a:925e:cf3c with SMTP id 38308e7fff4ca-37797a39146mr98679831fa.31.1761366803946; Fri, 24 Oct 2025 21:33:23 -0700 (PDT) Received: from junAIR ([176.106.241.81]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-378ee0ca7a0sm3409241fa.33.2025.10.24.21.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 21:33:23 -0700 (PDT) From: iuncuim To: Vasily Khoruzhick , Yangtao Li , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Philipp Zabel Cc: Andre Przywara , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v3 6/6] Allwinner: A523: add support for A523 THS0/1 controllers Date: Sat, 25 Oct 2025 12:31:29 +0800 Message-ID: <20251025043129.160454-7-iuncuim@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251025043129.160454-1-iuncuim@gmail.com> References: <20251025043129.160454-1-iuncuim@gmail.com> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Status: O From: Mikhail Kalashnikov The A523 processor has two temperature controllers, THS0 and THS1. THS0 has only one temperature sensor, which is located in the DRAM. THS1 does have 3 sensors: ths1_0 - "big" cores ths1_1 - "little" cores ths1_2 - gpu Add the thermal sensor configuration and the thermal zones. Trips temperature, polling-delay and sustainable-power parameters are derived from the manufacturer's BSP. Signed-off-by: Mikhail Kalashnikov --- .../arm64/boot/dts/allwinner/sun55i-a523.dtsi | 154 ++++++++++++++++++ 1 file changed, 154 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi index 7b36c47a3..0cbe73601 100644 --- a/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi @@ -11,6 +11,7 @@ #include #include #include +#include / { interrupt-parent = <&gic>; @@ -26,6 +27,7 @@ cpu0: cpu@0 { device_type = "cpu"; reg = <0x000>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu1: cpu@100 { @@ -33,6 +35,7 @@ cpu1: cpu@100 { device_type = "cpu"; reg = <0x100>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu2: cpu@200 { @@ -40,6 +43,7 @@ cpu2: cpu@200 { device_type = "cpu"; reg = <0x200>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu3: cpu@300 { @@ -47,6 +51,7 @@ cpu3: cpu@300 { device_type = "cpu"; reg = <0x300>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu4: cpu@400 { @@ -54,6 +59,7 @@ cpu4: cpu@400 { device_type = "cpu"; reg = <0x400>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu5: cpu@500 { @@ -61,6 +67,7 @@ cpu5: cpu@500 { device_type = "cpu"; reg = <0x500>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu6: cpu@600 { @@ -68,6 +75,7 @@ cpu6: cpu@600 { device_type = "cpu"; reg = <0x600>; enable-method = "psci"; + #cooling-cells = <2>; }; cpu7: cpu@700 { @@ -75,6 +83,7 @@ cpu7: cpu@700 { device_type = "cpu"; reg = <0x700>; enable-method = "psci"; + #cooling-cells = <2>; }; }; @@ -398,12 +407,46 @@ syscon: syscon@3000000 { ranges; }; + ths1: thermal-sensor@2009400 { + compatible = "allwinner,sun55i-a523-ths1"; + reg = <0x02009400 0x400>; + interrupts = ; + clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_GPADC1>; + clock-names = "bus", "gpadc"; + resets = <&ccu RST_BUS_THS>; + nvmem-cells = <&ths_calibration0>, <&ths_calibration1>; + nvmem-cell-names = "calibration", + "calibration-second-part"; + #thermal-sensor-cells = <1>; + }; + + ths0: thermal-sensor@200a000 { + compatible = "allwinner,sun55i-a523-ths0"; + reg = <0x0200a000 0x400>; + interrupts = ; + clocks = <&ccu CLK_BUS_THS>, <&ccu CLK_GPADC0>; + clock-names = "bus", "gpadc"; + resets = <&ccu RST_BUS_THS>; + nvmem-cells = <&ths_calibration0>, <&ths_calibration1>; + nvmem-cell-names = "calibration", + "calibration-second-part"; + #thermal-sensor-cells = <0>; + }; + sid: efuse@3006000 { compatible = "allwinner,sun55i-a523-sid", "allwinner,sun50i-a64-sid"; reg = <0x03006000 0x1000>; #address-cells = <1>; #size-cells = <1>; + + ths_calibration0: ths-calibration0@38 { + reg = <0x38 0x8>; + }; + + ths_calibration1: ths-calibration1@44 { + reg = <0x44 0x8>; + }; }; gic: interrupt-controller@3400000 { @@ -732,4 +775,115 @@ npu: npu@7122000 { power-domains = <&ppu PD_NPU>; }; }; + + thermal-zones { + cpu0_thermal: cpu0-thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + thermal-sensors = <&ths1 1>; + sustainable-power = <1200>; + + trips { + cpu0_threshold: cpu-trip-0 { + temperature = <70000>; + type = "passive"; + hysteresis = <0>; + }; + cpu0_target: cpu-trip-1 { + temperature = <90000>; + type = "passive"; + hysteresis = <0>; + }; + cpu0_critical: cpu-trip-2 { + temperature = <110000>; + type = "critical"; + hysteresis = <0>; + }; + }; + + cooling-maps { + map0 { + trip = <&cpu0_target>; + cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + cpu4_thermal: cpu4-thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + thermal-sensors = <&ths1 0>; + sustainable-power = <1600>; + + trips { + cpu4_threshold: cpu-trip-0 { + temperature = <70000>; + type = "passive"; + hysteresis = <0>; + }; + cpu4_target: cpu-trip-1 { + temperature = <90000>; + type = "passive"; + hysteresis = <0>; + }; + cpu4_critical: cpu-trip-2 { + temperature = <110000>; + type = "critical"; + hysteresis = <0>; + }; + }; + + cooling-maps { + map0 { + trip = <&cpu4_target>; + cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + }; + }; + }; + + gpu-thermal { + polling-delay-passive = <100>; + polling-delay = <1000>; + thermal-sensors = <&ths1 2>; + sustainable-power = <2400>; + + gpu-trips { + gpu_temp_threshold: gpu-trip-0 { + temperature = <60000>; + type = "passive"; + hysteresis = <0>; + }; + gpu_temp_target: gpu-trip-1 { + temperature = <90000>; + type = "passive"; + hysteresis = <0>; + }; + gpu_temp_critical: gpu-trip-2 { + temperature = <110000>; + type = "critical"; + hysteresis = <0>; + }; + }; + }; + + ddr-thermal { + polling-delay-passive = <0>; + polling-delay = <0>; + thermal-sensors = <&ths0>; + + trips { + ddr_temp_critical: ddr-trip-0 { + temperature = <110000>; + type = "critical"; + hysteresis = <0>; + }; + }; + }; + }; };