From patchwork Tue Oct 3 11:33:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sui Jingfeng X-Patchwork-Id: 147841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2018741vqb; Tue, 3 Oct 2023 04:34:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOvBPRI325JEqfN+/iRQIYvTXXjlxb/OlHYpoHSEH5JxHgME7pKNUyeJQwC2aBiUsmuIa6 X-Received: by 2002:a05:6808:47:b0:3ae:2850:b481 with SMTP id v7-20020a056808004700b003ae2850b481mr13034898oic.17.1696332876808; Tue, 03 Oct 2023 04:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696332876; cv=none; d=google.com; s=arc-20160816; b=vpAr3wTJ+ukSR+SDhSmbXlaaGdSChBGUg9g77rZVzEFXlOT05ngIY40OLdG+33YhRQ hRSqvc0cLSQ3exiFwPgLMScdeXbGqfC4Cz89E3rqFu66uHCnodFKIgWLhE98NUejNJsE uK1mb0WPe5WoEjnYxnvlYvcCEQfmwK3EjaM0WMieIoxxOzZABDFh3cmEJLMs1pLMFx8P zbaQ+9pprbq37I+djgtwDT68auHJPdZ4VJtMXKKHXWF7RTtHN5VUUaUf5fYWzVhanYKh JtZckovDWaBEibJfhKBBKjoH9DajIQi1y/nkLiIpD86QTSZ0bg2JNZC0FfaBii0Baw4Z M10Q== 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 Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id oc14-20020a17090b1c0e00b0027927d7c0ebsi1293493pjb.45.2023.10.03.04.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 04:34:36 -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 59B71801C890; Tue, 3 Oct 2023 04:34:29 -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 S240495AbjJCLeI (ORCPT + 18 others); Tue, 3 Oct 2023 07:34:08 -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 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:29 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778733942343313262 X-GMAIL-MSGID: 1778733942343313262 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);