From patchwork Mon Mar 20 16:18:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Paracuellos X-Patchwork-Id: 72264 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp1311435wrt; Mon, 20 Mar 2023 09:29:59 -0700 (PDT) X-Google-Smtp-Source: AK7set+IgRsMF5YGKX0jK/MeUWvD0eX36Z162gEAAmk62pOoO1S4SkSDo1LQ/9yW7UJcan+Cy/CD X-Received: by 2002:a62:f252:0:b0:627:e677:bc70 with SMTP id y18-20020a62f252000000b00627e677bc70mr7222695pfl.14.1679329799547; Mon, 20 Mar 2023 09:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679329799; cv=none; d=google.com; s=arc-20160816; b=KRzD7Y+ooIUIVq35l03SeeVx2iW2L6CG1+ThJfYGH06CsgDCgzBvnSRm0GZagtG/He 14g+/+trxH2AYrHgZ3oE10C3TKgrFa2orNXJJw/G0F67axtBuE7uoGw2SSyeDheK740B QXNa1vELnf0tlBbzUiA1rHw6AimQwxEyOTrNgbadKkXxTOdSXlE9D+5Blxl7bcQ2gQjt uDT3KEUTgpxpeQ91iIXlUYVr+lLj7Z+vDmVht2Zfrpy3AbGrpTx4WWU7tngbwAKUDuB2 hLAyIovrWMhUapoBGyxmuXMTQUI6z+GJNhLbhKcdQp42fAwzzGjIyTI3xYyRPYa8H+TV TBdA== 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=oM8GpGbGiC8m3xETpqZOKVCeTGKwMkImG6hLD6+J4YY=; b=KDY5T6M+x9Irs//bstmic+rCfoPgGkEMNyiUTwD7wqOM30znaMlKuj2CDG+5L8KMMi qjrAmtAieba2RtybuM5n56IWUwnYDFMjp41e9cAuY6U4uP4+sypQ3MxbhUzWVNz3HVgE hUv/gZd9VQkZk2mkUZGIVVxPFoo0dKeiUApumRLtgvdu6w5LtI2xl+zIo/qnWDn31YIJ ONSKCyUsql4xsn8GStTMFk/CUNA/OO57zBfLJwHeWpih8qIfejGd+xjtHDXnfFiXRdHz PFGpphzE+NhD230phSTY+N4hGvHsB5RYh4NNrdgPKjkNnEbhORfjoQSplbwVT0ewJiIP +iBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="pqleI3/s"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z11-20020a6552cb000000b0050ac7d1b32asi10461176pgp.603.2023.03.20.09.29.43; Mon, 20 Mar 2023 09:29:59 -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=@gmail.com header.s=20210112 header.b="pqleI3/s"; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232519AbjCTQ0N (ORCPT + 99 others); Mon, 20 Mar 2023 12:26:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233384AbjCTQZO (ORCPT ); Mon, 20 Mar 2023 12:25:14 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BC7F14E85; Mon, 20 Mar 2023 09:18:41 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id o32so1514550wms.1; Mon, 20 Mar 2023 09:18:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679329121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oM8GpGbGiC8m3xETpqZOKVCeTGKwMkImG6hLD6+J4YY=; b=pqleI3/sbRl1vdeDzJoXM09C5CNbpQRJL/JmaJCOrR6ozCxtu3pEf/4fSlOV3r5B3x xkRLcOYP25jC8DIpfDzB0CY5HS+pzHWsNy0tFXkcolvnk5kOLanKXSg3AjI1h0KH7hqs 5vTlBiEK3K/ATnoC19YgQKcCOwizsOvhLe1WUW7J+UAcKFImlhUpxB2yN4hrLwlRXmrn SyBMfBGnAplxlMswPy5dXBaDhf6M0y3WJOBjp0HH7JRouABMCF5GakS+O+aqYjp4revp eTQ7bE3fS2CiuFCJpRrjZ9+jMzf41ye7hWdy9DwhWeX1lv/VZ5OQeaeG71UfBLcpl9yB hkHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679329121; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oM8GpGbGiC8m3xETpqZOKVCeTGKwMkImG6hLD6+J4YY=; b=Z3IahHBhaGopOPodkp2hva2F4XR+LbgKoPZDhm/dZ9RTyZ7u3rHDrgmo4CKvU8dKxz gNOG8cQ0k0DXNpkC4bMGt4RBMZpmlKqwESQ1BscvJE/bR9eGIoY/WVeV0mNC8Pa/PzUC /wQbdKcdkO0kkNWhK6ZE5Hm6DYlHSIJGXsjO12e2U44HQ7RuBd8SxOgZ+JaYAhYU6NhM iBNh/GboVnlzcfbxrNfIETc8N7VLfYqYFQ7mZXBhOGmNaD6eNfsvfSRApfXSPHDHptVJ pkKA+fRQP9SzhXVcUglLbyTodzFpacm9iKaxoO8YmPlwJE0V0oD6Jdv1xvzpYtCxIjmV gomQ== X-Gm-Message-State: AO0yUKWkPHPfXW/v5SLUoXnbevUqumExrkEl+Od0tRBPSSuouT6ONTXM Ope5udFook+/lj/EiKsd13qR/eE5CEE= X-Received: by 2002:a1c:4b10:0:b0:3ed:e5db:52e1 with SMTP id y16-20020a1c4b10000000b003ede5db52e1mr76491wma.15.1679329120691; Mon, 20 Mar 2023 09:18:40 -0700 (PDT) Received: from localhost.localdomain (106.red-88-13-29.dynamicip.rima-tde.net. [88.13.29.106]) by smtp.gmail.com with ESMTPSA id iv16-20020a05600c549000b003ee1acdaf95sm847776wmb.36.2023.03.20.09.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Mar 2023 09:18:40 -0700 (PDT) From: Sergio Paracuellos To: linux-clk@vger.kernel.org Cc: linux-mips@vger.kernel.org, tsbogend@alpha.franken.de, john@phrozen.org, linux-kernel@vger.kernel.org, p.zabel@pengutronix.de, mturquette@baylibre.com, sboyd@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, matthias.bgg@gmail.com, devicetree@vger.kernel.org, arinc.unal@arinc9.com Subject: [PATCH 09/10] mips: ralink: get cpu rate from new driver code Date: Mon, 20 Mar 2023 17:18:22 +0100 Message-Id: <20230320161823.1424278-10-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230320161823.1424278-1-sergio.paracuellos@gmail.com> References: <20230320161823.1424278-1-sergio.paracuellos@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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?1760904923876981416?= X-GMAIL-MSGID: =?utf-8?q?1760904923876981416?= At very early stage on boot, there is a need to set 'mips_hpt_frequency'. This timer frequency is a half of the CPU frequency. To get clocks properly set we need to call to 'of_clk_init()' and properly get cpu clock frequency afterwards. Depending on the SoC, CPU clock index in the clock provider is different being two for MT7620 SoC and one for the rest. Hence, adapt code to be aligned with new clock driver. Signed-off-by: Sergio Paracuellos --- arch/mips/ralink/clk.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/arch/mips/ralink/clk.c b/arch/mips/ralink/clk.c index 5b02bb7e0829..3d29e956f785 100644 --- a/arch/mips/ralink/clk.c +++ b/arch/mips/ralink/clk.c @@ -11,29 +11,41 @@ #include #include #include +#include #include #include "common.h" -void ralink_clk_add(const char *dev, unsigned long rate) +static int clk_cpu_index(void) { - struct clk *clk = clk_register_fixed_rate(NULL, dev, NULL, 0, rate); + if (ralink_soc == RALINK_UNKNOWN) + return -1; - if (!clk) - panic("failed to add clock"); + if (ralink_soc == MT762X_SOC_MT7620A || + ralink_soc == MT762X_SOC_MT7620N) + return 2; - clkdev_create(clk, NULL, "%s", dev); + return 1; } void __init plat_time_init(void) { + struct of_phandle_args clkspec; struct clk *clk; + int cpu_clk_idx; ralink_of_remap(); - ralink_clk_init(); - clk = clk_get_sys("cpu", NULL); + cpu_clk_idx = clk_cpu_index(); + if (cpu_clk_idx == -1) + panic("unable to get CPU clock index"); + + of_clk_init(NULL); + clkspec.np = of_find_node_by_name(NULL, "sysc"); + clkspec.args_count = 1; + clkspec.args[0] = cpu_clk_idx; + clk = of_clk_get_from_provider(&clkspec); if (IS_ERR(clk)) panic("unable to get CPU clock, err=%ld", PTR_ERR(clk)); pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);