From patchwork Thu Mar 23 09:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 73919 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2805655wrt; Thu, 23 Mar 2023 02:24:26 -0700 (PDT) X-Google-Smtp-Source: AK7set+dWCZ35LwALMtjBlr0w2ZUbSULVL5GO+ndJGjtsFES5UeonSJtiICepMgUVX61zVIOGidz X-Received: by 2002:a05:6a20:c129:b0:d8:f082:437e with SMTP id bh41-20020a056a20c12900b000d8f082437emr2600089pzb.12.1679563465941; Thu, 23 Mar 2023 02:24:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679563465; cv=none; d=google.com; s=arc-20160816; b=nYjfYTWWJZeboSVguqiBAq3lcTeOshPlMXZQXJ1Pcuj/wSXin4Yx+BUUexJaTThLAE puV9wTnZ+eLvanLLmi9ZhH1TXkpdNFfRS3QAFMZheSgSRf0LVqKJL+Mxz+BmwQ5pFkRR vhfZHM8ciaL475Ip+GpnaffwDtIGw5ZEgIZstUX/MDnUBGhx6UyNkT8qmnwSrhNsloGa ptItHGwx4rMyv6ZYgWgst9vEXl7zKWdXKu4MJ34i/UG94Hdm2SftGRFzs42apuVkMV3k 8aN/a8oSYigRp0L3XKQgfvFsSX+9fzLP2CHQTlGcOXMqILumD0ly+PR/NVOAdahbPB9V 4C3A== 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=OfRi+b1eRYGCDzJyk0GHoxbAEjyPgckFEtrLaSWg2Cg=; b=G0eIN+xdiKEO/egpew1XTaYxqdYvNRPybFBYD8Q0wch2YIHd5dqrEaQDnbcFT9O2f5 SZS2kM8yxjCOrKfKpQb3jQ9UOUdF7HJcQpruB5jLQJXqbja7tQ6Uuahi0VCeD/41EMis /i3Ge0ejh/tKrUy90itJx0khL6i6T1Z1adniR7UD78f2rY3CqCz6yPu8fBrLjTZLaVzh ZlH2K1DXOGo+dVcfk92PLQPg0aCuCGDk/I0i5qtbCP4TAD5UKGHMa0flmE3RV/+80177 lRuKRTYT8w+1BPDaF/VC9DalKw40KpWrdhjq4QpE0Px3MSYtH/Z9F7j+BpLarn4C3Ykc XLAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Pa1eBUYW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020a056a00080500b005a910206938si13640500pfk.29.2023.03.23.02.24.14; Thu, 23 Mar 2023 02:24:25 -0700 (PDT) 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=@collabora.com header.s=mail header.b=Pa1eBUYW; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230374AbjCWJJe (ORCPT + 99 others); Thu, 23 Mar 2023 05:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230525AbjCWJJR (ORCPT ); Thu, 23 Mar 2023 05:09:17 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D6A11CBC4; Thu, 23 Mar 2023 02:08:31 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 528ED66030BA; Thu, 23 Mar 2023 09:08:29 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1679562510; bh=JcZeO7Hk3n9YL6Pyi7NcCAIvRNlewFD1uN9/JWGWjig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pa1eBUYWyXpb6J00y4TJShK0pq0KPDk2f879FEVLsQS/INas4+9Ehex8ddiYIiGnc aNYvXWU++wlqJPqt2/7+doYWpek+TXZ7OXFhcA0wnmMKnxjK4HyPtO6mEOfwZv4ZM4 OL7NfTXNN02l6vvqX4aMUIQMpid9TDYxhVIWh4MCweYQHlZqyYwRcs9TW7Gg/NmdCB brUy8qw8FRHcilSKhTzlEdsbJakep2aazUQw2SpinZ5N2mHG4U2zwCsxe5Don1RuBd CY1fwSKmFBbZyGCzFSpcgI3BU59qgnT1AxB8KVL5G9zY0v4dOaHDMYzkie8uXZCWGB xdZgMvvPGov6w== From: AngeloGioacchino Del Regno To: airlied@gmail.com Cc: daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wenst@chromium.org, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v1 RESEND 1/2] dt-bindings: gpu: mali-bifrost: Document nvmem for speedbin support Date: Thu, 23 Mar 2023 10:08:21 +0100 Message-Id: <20230323090822.61766-2-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230323090822.61766-1-angelogioacchino.delregno@collabora.com> References: <20230323090822.61766-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 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?1761149940655304142?= X-GMAIL-MSGID: =?utf-8?q?1761149940655304142?= Some SoCs implementing ARM Mali GPUs may be subject to speed binning and the usable bin is read from nvmem: document the addition of nvmem and nvmem-cells for 'speed-bin'. Signed-off-by: AngeloGioacchino Del Regno Acked-by: Krzysztof Kozlowski --- .../devicetree/bindings/gpu/arm,mali-bifrost.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml index 8a0083800810..1eecb014016c 100644 --- a/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml +++ b/Documentation/devicetree/bindings/gpu/arm,mali-bifrost.yaml @@ -104,6 +104,13 @@ properties: dma-coherent: true + nvmem-cell-names: + items: + - const: speed-bin + + nvmem-cells: + maxItems: 1 + required: - compatible - reg From patchwork Thu Mar 23 09:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AngeloGioacchino Del Regno X-Patchwork-Id: 73920 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2805663wrt; Thu, 23 Mar 2023 02:24:27 -0700 (PDT) X-Google-Smtp-Source: AK7set+QHajM5Iyty01R/m9oCxM1oVzhxpQ1ZCEqKtdx/7qhbN1IrFGfYmZCI7OnG4f+4G2cAIuc X-Received: by 2002:a05:6a20:4e1a:b0:da:38d2:c27a with SMTP id gk26-20020a056a204e1a00b000da38d2c27amr2407765pzb.1.1679563466757; Thu, 23 Mar 2023 02:24:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679563466; cv=none; d=google.com; s=arc-20160816; b=mJIiTnl7R+L/eVJazj7qy8jhyXHx+/mjb5b1xSigHF4g/v/6k3/FTEC4NGWpL/U9gF 9djr4lFabp3cyHeqggsoSX/xcnvlQfB6h5j9Fw+qWKRbX/k3sIjSga0v8wrbl44m1F+Q XOmMwXOfnEyQJ919BRTi1VAu7vByfj1nHFkoEar9qRS7TUuja/8MyBcG4l/qaJC7EwPf QqzBVtgZfqpXWU/NZU0gDnvPm6a9lErB7JhbI4TbC1+9CpO/Syy15FHhbMw4LrldiMUP zyWAabPRHa9l2J1ncYn1FDEF9u2nn/9yEZRqEZhn2dg2YeJuNj6uVui/2uJPdH39wBVG Qdkg== 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=OD4Ni99lz0vbInh+660W6jwaUbIKLSiOiTEgVWz1lyw=; b=JU8UjgXnGhAUjk82XKDdaa4DoZTO1I97Vg2mtemgobfYfii9h733nVi+cn4QAry464 AXHDX1CAyz3oLsBxtX1mXHYRy3zB6VubSC1dEhARGyp20WgQSx5dbluauB+szz+8Xd4Q tPCqnE+Iu0J6k9LC1UzpP6GKmdj7Y+GVWF8c41sxOn1i0WMYv8u2oWUDcOpm0fuqqdVL dvW+Wqmyh+xI7IraRZSB2ojoZtyVYJqu7upooS4Mdf95sa11fos/ET9vZzyE66h2aYCn 94yy8gL8cGm6Ebpj/Tzh5R+exUW0g/T/8A6jpX9+TxdTQYhUPjJNO49+H2fztwt2IvMb 4zrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b="Yt//uoEk"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d15-20020a056a0010cf00b006221fa0b8d1si18265942pfu.71.2023.03.23.02.24.14; Thu, 23 Mar 2023 02:24:26 -0700 (PDT) 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=@collabora.com header.s=mail header.b="Yt//uoEk"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230122AbjCWJJh (ORCPT + 99 others); Thu, 23 Mar 2023 05:09:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231367AbjCWJJR (ORCPT ); Thu, 23 Mar 2023 05:09:17 -0400 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 EF03E1E1FF; Thu, 23 Mar 2023 02:08:31 -0700 (PDT) Received: from IcarusMOD.eternityproject.eu (2-237-20-237.ip236.fastwebnet.it [2.237.20.237]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id 25A4A66030C0; Thu, 23 Mar 2023 09:08:30 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1679562510; bh=2/LIFSrMCDoyTlFa4VDWRrfC/Sm1DtA+dl9eYJSJR1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yt//uoEkj/BWkf0EBe+96syvd9Bu0BOr19S3kLHTikmPp7PfL15jVOl1ZLyOPkxJV T4YcpH3oExuHfHzEQvv70Fhcucgf6SFBxtXa/ed9HHKgZf4np7vDrHja7j6h4Tj74z SpAYDtAYtpcIE4Uzzw99WG3zT6M0M57CJ9vwZgbQbAD+H/ma/DaOscrfBErRoOBhrp TX+1sJqcED6Tr7jQobIW+foKmaYPgDwdz/YUw19+d9KfBl0LQ1MHjjpZ8XY6IkB/kH v9movDENfui0+J6C+uGPOCDmCDTSUZEJ8HlbuqDNFVUFBkViONVieTGrzVs3hqRir1 ypVrB0FCXDkGw== From: AngeloGioacchino Del Regno To: airlied@gmail.com Cc: daniel@ffwll.ch, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, wenst@chromium.org, steven.price@arm.com, alyssa.rosenzweig@collabora.com, robh@kernel.org, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@collabora.com, AngeloGioacchino Del Regno Subject: [PATCH v1 RESEND 2/2] drm/panfrost: Add basic support for speed binning Date: Thu, 23 Mar 2023 10:08:22 +0100 Message-Id: <20230323090822.61766-3-angelogioacchino.delregno@collabora.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230323090822.61766-1-angelogioacchino.delregno@collabora.com> References: <20230323090822.61766-1-angelogioacchino.delregno@collabora.com> MIME-Version: 1.0 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 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?1761149941710618791?= X-GMAIL-MSGID: =?utf-8?q?1761149941710618791?= Some SoCs implementing ARM Mali GPUs are subject to speed binning: this means that some versions of the same SoC model may need to be limited to a slower frequency compared to the other: this is being addressed by reading nvmem (usually, an eFuse array) containing a number that identifies the speed binning of the chip, which is usually related to silicon quality. To address such situation, add basic support for reading the speed-bin through nvmem, as to make it possible to specify the supported hardware in the OPP table for GPUs. This commit also keeps compatibility with any platform that does not specify (and does not even support) speed-binning. Signed-off-by: AngeloGioacchino Del Regno --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index fe5f12f16a63..58dfb15a8757 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,31 @@ static struct devfreq_dev_profile panfrost_devfreq_profile = { .get_dev_status = panfrost_devfreq_get_dev_status, }; +static int panfrost_read_speedbin(struct device *dev) +{ + u32 val; + int ret; + + ret = nvmem_cell_read_variable_le_u32(dev, "speed-bin", &val); + if (ret) { + /* + * -ENOENT means that this platform doesn't support speedbins + * as it didn't declare any speed-bin nvmem: in this case, we + * keep going without it; any other error means that we are + * supposed to read the bin value, but we failed doing so. + */ + if (ret != -ENOENT) { + DRM_DEV_ERROR(dev, "Cannot read speed-bin (%d).", ret); + return ret; + } + + return 0; + } + DRM_DEV_DEBUG(dev, "Using speed-bin = 0x%x\n", val); + + return devm_pm_opp_set_supported_hw(dev, &val, 1); +} + int panfrost_devfreq_init(struct panfrost_device *pfdev) { int ret; @@ -101,6 +127,10 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) return 0; } + ret = panfrost_read_speedbin(dev); + if (ret) + return ret; + ret = devm_pm_opp_set_regulators(dev, pfdev->comp->supply_names); if (ret) { /* Continue if the optional regulator is missing */