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: 13181566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C223C77B70 for ; Mon, 20 Mar 2023 16:25:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232441AbjCTQZz (ORCPT ); Mon, 20 Mar 2023 12:25:55 -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-Google-Smtp-Source: AK7set/ebkMAtb/OC+EwXIR1KGDkJgBk8R+DvG5xZiO9rKE4WvacMxeNV2sAqH1/UVYoplZ5pY2fkQ== 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 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org 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);