Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp6321448rwd; Mon, 19 Jun 2023 05:50:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GgXTGEWApuPg6vMEvya1C/F1/NUnk1zKWUn5sI1jkPYYzVx0eejetHm9hVvFeryRcM5i4 X-Received: by 2002:a05:6870:4293:b0:1a7:8bac:cf98 with SMTP id y19-20020a056870429300b001a78baccf98mr5327310oah.56.1687179024640; Mon, 19 Jun 2023 05:50:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687179024; cv=none; d=google.com; s=arc-20160816; b=o3OASNpprdccQX4Njxy/RWaIm3Muq4hpn8EswMOJVHBKtiDMh3cWohCidv/+ARzmy1 8AaWKudTAP67JLoNDl/JU/aRV5Qyzg+1BxXdV7sY+oRPKN3T0iXYnJE8ymUjB7HjDZcd OiItDcKL78eohebSu+urwamUg/aRIh4n5OQQSQPRAHLS/YkRJ21o5JHt15z8dTboThCu 1aNGMgzrUBdtn/JD93icEl2VHoLbYvH270oM7zSomM8/qbGvZv/6gLxmAzd24YAqhka5 MDbeagyawvcGUEHBq2rXxI2P4q+HAP1C+2k3O1Aj1iqTf0Gmh2fpKuNzgWK1xtsV2lFz zWsA== 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=U0SWL/JdjvOqGx7gC3JlFOSCNm1yICr30bcx3Pn/rOc=; b=CADXZVQaGBSiFb0yj6yrmHNxE7Ce2MnZmoT/4J3a+yxXjYWvMp/57wXMUEuUJnNhsW RH+GHQ2o0IZLm8PUyRwfPbWhuyIfp0k8JeTgREoLYY9ImPKlLIlPIAtweF0dF+3Mpne+ G32/kn+GOSSaxAu7N09D915kb4llqFr2HdhjoBjIdwjmRPQW9FzsLFyfWuhq6xA+HQJ7 kVaMEHlsaUqY6SqZ3L2NvsJ8ird95JhHZBTXp9qEq7F9lP90hc9Q9B4wZAdV6x4/Zm3P u9NRJ/7DUDQVyuU8M1LqJ4S0c6cgRExPOaWT34bvvGEpYYDLJwXVK1D5jGnCgHoRElwu MgNg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v22-20020a636116000000b005133c334fe9si5295272pgb.847.2023.06.19.05.50.09; Mon, 19 Jun 2023 05:50:24 -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 S229817AbjFSMmT (ORCPT + 99 others); Mon, 19 Jun 2023 08:42:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230253AbjFSMmM (ORCPT ); Mon, 19 Jun 2023 08:42:12 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E2637D7 for ; Mon, 19 Jun 2023 05:42:10 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:49634.708654646 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id 370FF100294; Mon, 19 Jun 2023 20:42:08 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-75648544bd-xwndj with ESMTP id 335925be468247e09fde82d183bdd0ac for l.stach@pengutronix.de; Mon, 19 Jun 2023 20:42:10 CST X-Transaction-ID: 335925be468247e09fde82d183bdd0ac 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 , Russell King , Christian Gmeiner , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Sui Jingfeng , Philipp Zabel , Bjorn Helgaas Subject: [PATCH v10 02/11] drm/etnaviv: Add a dedicated function to get various clocks Date: Mon, 19 Jun 2023 20:41:52 +0800 Message-Id: <20230619124201.2215558-3-15330273260@189.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230619124201.2215558-1-15330273260@189.cn> References: <20230619124201.2215558-1-15330273260@189.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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,RCVD_IN_SBL_CSS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 From: Sui Jingfeng Because it is also platform-dependent, there are systems where we don't have DT-based clock drivers supported. For example, discrete PCI GPUs. Therefire, don't quit if there is no clock subsystem support.      For the GPU in LS7A1000 and LS2K1000, the working frequency of the GPU is rely on the GFX PLL to generate the clock. Typically, the GFX PLL is configured by the platform firmware. Cc: Lucas Stach Cc: Christian Gmeiner Cc: Philipp Zabel Cc: Bjorn Helgaas Cc: Daniel Vetter 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 a03e81337d8f..5e88fa95dac2 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; @@ -1863,27 +1892,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); -- 2.25.1