From patchwork Sat Jun 3 10:59:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng <15330273260@189.cn> X-Patchwork-Id: 102831 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1597325vqr; Sat, 3 Jun 2023 04:19:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4jOnlaINjhBI9iPXQ4GjujqyNUh9xQlHtYWh2QuUebI4IiNZVE27WE9dpU0LYxzPtL7Xfl X-Received: by 2002:a17:90a:3b0c:b0:255:4f3b:f3b6 with SMTP id d12-20020a17090a3b0c00b002554f3bf3b6mr982116pjc.37.1685791198958; Sat, 03 Jun 2023 04:19:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685791198; cv=none; d=google.com; s=arc-20160816; b=h7SwGopydAAoeYHUWyWlfz7BaM7HZCG4ecPAJevH5W5JI0TE4T4RHZpD/08epwhABG OYQkouTnfFaUHKNWgv0nVbDIsSur0VWTqrLSf40TdqgJkQWtr5iaXWthhq44T+HhE29t g7biRoeNzAtLgpgQzb/X5/13VHpDVQwCSKkF0iYSuksyr1JWVoT98qOyg0Y/kqL8fHRO jaiZaes/ozX0LfAOmPIk9t9COaBt2ngFEc6l+Va5noSN0Z1MCwwvpApeJ/NVlve/S4UF TYiatPQI5ebKSKCzAs9KMHD7JLbomvewI0W/ajhOInGdeXgqrcHabznSx2Ft031LXATh TNYA== 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:sender :hmm_source_type:hmm_attache_num:hmm_source_ip; bh=lFqqWmtRH/J9J11jsMskWom0IPkjjgBFL9ZQf8G1yao=; b=xtPQkbMy6u5/cQttzA+hbye3qCf0IfLgQnGvgZVABFkB2QHMsqjcaMbQG9hP8Okw3N XkuwJ7vD8adnMkCv6Y0LjZJQPMHeRQ5gy7HxlzUvYpFLPn9/Dagn0Tq1oSQzmcfGAZ8t xqpQ7CPP3ZfXBuOFQs5cpvL8Nv9iIrL0r2dBn+fHWTUhycGjZ6osA1tEr40Qk4vbTxzo z0YSyhlCxjkEepJWyPqOxbaxrjM973rSFxecN2xuqH9bB4N5/Kc0tCLAqZmBdLvG4Agj G7dAoF6y+2dTt3Ab4OBnS28doOWq+WIf5khXmaarSnZdlghpl64axwKUIrP/AV6nDiX+ ENgA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a17090a680200b002535d0a89f8si4167049pjj.186.2023.06.03.04.19.42; Sat, 03 Jun 2023 04:19:58 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235448AbjFCLAS (ORCPT + 99 others); Sat, 3 Jun 2023 07:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjFCLAK (ORCPT ); Sat, 3 Jun 2023 07:00:10 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 79FE51A6 for ; Sat, 3 Jun 2023 04:00:07 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.43:51732.1826327623 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.43]) by 189.cn (HERMES) with SMTP id AD0FE100283; Sat, 3 Jun 2023 19:00:05 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-7vx9t with ESMTP id b2638a35a34043ce89fa0b0d5456d01f for l.stach@pengutronix.de; Sat, 03 Jun 2023 19:00:06 CST X-Transaction-ID: b2638a35a34043ce89fa0b0d5456d01f X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn From: Sui Jingfeng <15330273260@189.cn> To: Lucas Stach , Christian Gmeiner , Daniel Vetter , Bjorn Helgaas Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng Subject: [PATCH v7 2/7] drm/etnaviv: add a dedicated function to get various clocks Date: Sat, 3 Jun 2023 18:59:38 +0800 Message-Id: <20230603105943.3042766-3-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230603105943.3042766-1-15330273260@189.cn> References: <20230603105943.3042766-1-15330273260@189.cn> MIME-Version: 1.0 X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,FROM_LOCAL_DIGITS, FROM_LOCAL_HEX,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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?1767680191993939309?= X-GMAIL-MSGID: =?utf-8?q?1767680191993939309?= From: Sui Jingfeng Because it is also platform-dependent, there are environments where don't have CLK subsystem support, for example, discreted PCI GPUs. So don't rage quit if there is no CLK subsystem. For the GPU in LS7A1000 and LS2K1000, the working frequency of the GPU is tuned by configuring the PLL register directly. Signed-off-by: Sui Jingfeng --- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 53 ++++++++++++++++----------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c index 636d3f39ddcb..6c7aa9322468 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1565,6 +1565,35 @@ static irqreturn_t irq_handler(int irq, void *data) return ret; } +static int etnaviv_gpu_clk_get(struct etnaviv_gpu *gpu) +{ + struct device *dev = gpu->dev; + + gpu->clk_reg = devm_clk_get_optional(dev, "reg"); + DBG("clk_reg: %p", gpu->clk_reg); + if (IS_ERR(gpu->clk_reg)) + return PTR_ERR(gpu->clk_reg); + + gpu->clk_bus = devm_clk_get_optional(dev, "bus"); + DBG("clk_bus: %p", gpu->clk_bus); + if (IS_ERR(gpu->clk_bus)) + return PTR_ERR(gpu->clk_bus); + + gpu->clk_core = devm_clk_get(dev, "core"); + DBG("clk_core: %p", gpu->clk_core); + if (IS_ERR(gpu->clk_core)) + return PTR_ERR(gpu->clk_core); + gpu->base_rate_core = clk_get_rate(gpu->clk_core); + + gpu->clk_shader = devm_clk_get_optional(dev, "shader"); + DBG("clk_shader: %p", gpu->clk_shader); + if (IS_ERR(gpu->clk_shader)) + return PTR_ERR(gpu->clk_shader); + gpu->base_rate_shader = clk_get_rate(gpu->clk_shader); + + return 0; +} + static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) { int ret; @@ -1865,27 +1894,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) return err; /* Get Clocks: */ - gpu->clk_reg = devm_clk_get_optional(&pdev->dev, "reg"); - DBG("clk_reg: %p", gpu->clk_reg); - if (IS_ERR(gpu->clk_reg)) - return PTR_ERR(gpu->clk_reg); - - gpu->clk_bus = devm_clk_get_optional(&pdev->dev, "bus"); - DBG("clk_bus: %p", gpu->clk_bus); - if (IS_ERR(gpu->clk_bus)) - return PTR_ERR(gpu->clk_bus); - - gpu->clk_core = devm_clk_get(&pdev->dev, "core"); - DBG("clk_core: %p", gpu->clk_core); - if (IS_ERR(gpu->clk_core)) - return PTR_ERR(gpu->clk_core); - gpu->base_rate_core = clk_get_rate(gpu->clk_core); - - gpu->clk_shader = devm_clk_get_optional(&pdev->dev, "shader"); - DBG("clk_shader: %p", gpu->clk_shader); - if (IS_ERR(gpu->clk_shader)) - return PTR_ERR(gpu->clk_shader); - gpu->base_rate_shader = clk_get_rate(gpu->clk_shader); + err = etnaviv_gpu_clk_get(gpu); + if (err) + return err; /* TODO: figure out max mapped size */ dev_set_drvdata(dev, gpu);