Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1892097rdb; Tue, 3 Oct 2023 04:34:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHCBzDTB35nHXPTAKEUVzgIY0IEZQngX7TfjwKzJBoLCK4enrLUoHH+iPKBGfE8bR55P78d X-Received: by 2002:a05:6a20:4284:b0:162:4f45:b415 with SMTP id o4-20020a056a20428400b001624f45b415mr18126873pzj.51.1696332875098; Tue, 03 Oct 2023 04:34:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696332875; cv=none; d=google.com; s=arc-20160816; b=K2+Pp/2JjNQGp54HrvO9yO+d/B9+Zo/gVfCkLHZpyL0vl/psQiLg8ECFshwmKOmXdF k1c20iyDW/6Z98n4qsVhzFEa5qD/VAFFaJY/pJ46kYpb08UJE/zLIP5ebOa5thuzzZiw zBoPYDOtb2A8AjvlLAeQti8FFP7J+TFAjFpmgCDMR2pfrrOqYGvhZSWHO6AdP1gVo8mi RoWXX/wwUJ7zBtpJ0lwBDt2n2O6ENwjIf64jFsQXsjM3C3hjTWMctnQ7iXMdiknn1bzj mJBvbqlaz7mCFyF80ovEKGxIHyO6ZsAz6fEsCLXLn7bOmfm5de2R4GaKlzcmk0WjsZKV sGiw== 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; bh=ruSirRe3Z6hfUAO7fH93hVSnd1v92kkzsvGcc6NqHcw=; fh=Oyns+MRNENvE/4pdLFKaFp/oMxPAjrImQ5eA0WPGheM=; b=kNCIm1QtPr8pfj+2r7tZvGpLmM+osYF3x1ImbfCkD+tZKVItZ6gPFwFdJBatQ6PfC/ hgJqv1eaBuQI1S1xBS73sQCNm/UE4qoIlkteujBdzkZWsNHuvIpbHgIkGPiD/gHwHbpn IGJAexHAxzwoNatbRvaA5Na+tNSkXoOBZ/0LYWgL33jVcg3t0ZecHTazecJKnrMcQHZr AOdC+CspnP+Co3I71JqURde8hLpp/6hFJ+SnjOrX3DReOJH4swdtV+yAmVpU8shgATLd B86cyNyaG9IKDDf7utun9GaY2I97zShTzze68GFLVNdIPZfPpS0jvgc2SVE0DLroghUt 0ogQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r65-20020a632b44000000b0056fc3ceaba4si1283828pgr.432.2023.10.03.04.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 04:34:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id B37BB8024AE5; Tue, 3 Oct 2023 04:34:25 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240494AbjJCLeH (ORCPT + 99 others); Tue, 3 Oct 2023 07:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232042AbjJCLeE (ORCPT ); Tue, 3 Oct 2023 07:34:04 -0400 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B67DA9E for ; Tue, 3 Oct 2023 04:33:59 -0700 (PDT) Received: from loongson.cn (unknown [10.20.42.43]) by gateway (Coremail) with SMTP id _____8Bxyeom_BtlEM0uAA--.14454S3; Tue, 03 Oct 2023 19:33:58 +0800 (CST) Received: from openarena.loongson.cn (unknown [10.20.42.43]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cx7y8k_Btl7JAXAA--.48472S3; Tue, 03 Oct 2023 19:33:57 +0800 (CST) From: Sui Jingfeng To: Lucas Stach Cc: Christian Gmeiner , dri-devel@lists.freedesktop.org, etnaviv@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v11 1/5] drm/etnaviv: Add a dedicated function to get various clocks Date: Tue, 3 Oct 2023 19:33:52 +0800 Message-Id: <20231003113356.645394-2-suijingfeng@loongson.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003113356.645394-1-suijingfeng@loongson.cn> References: <20231003113356.645394-1-suijingfeng@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: AQAAf8Cx7y8k_Btl7JAXAA--.48472S3 X-CM-SenderInfo: xvxlyxpqjiv03j6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBj93XoWxXFW8KFWxCr17Gw48Zr47Awc_yoW5Aw48pa 1fJ3W5tr1UCryag3yxAF13tr1akr1xCa4xuwn5Zrn3Zws8WF4Ut3yYkrWYqF45ury8XFWS kw15GF4UCFyF9rbCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU7cdbUUUUU X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Tue, 03 Oct 2023 04:34:25 -0700 (PDT) Because the current implement is platform-dependent, there are systems which don't has the DT-based clock device drivers support. Such as x86 and Loongarch desktop platform. Don't rage quit if so. For the GPU in LS7A1000/LS2K1000, the working frequency of the GPU is control by the GFX PLL hardware. Typically, the GFX PLL will be configured by the platform BIOS(either UEFI or PMON) on per boot time. 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 9276756e1397..4aa7c59ae581 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c @@ -1586,6 +1586,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; @@ -1861,27 +1890,9 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) } /* 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.34.1