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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 23EFFC05027 for ; Thu, 2 Feb 2023 18:15:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E474A85E05; Thu, 2 Feb 2023 19:14:32 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NM/n3RwX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7E6CA85D0D; Thu, 2 Feb 2023 19:14:26 +0100 (CET) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5C68B85DDE for ; Thu, 2 Feb 2023 19:14:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=clamor95@gmail.com Received: by mail-wm1-x32b.google.com with SMTP id m16-20020a05600c3b1000b003dc4050c94aso2090554wms.4 for ; Thu, 02 Feb 2023 10:14:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=SbpJz1Be21ayTUFDVSdF25Xiiu32rtYSsczWSstDHF0=; b=NM/n3RwX5E3vOjYbSDtnrS5FtjDo/dJiKfqXLt+3PMEDpAkM48/El5WpJh9lo8V2zl WWNm0PCiq6yhXAJ7pq1ljp3f9ASKJ2mXD/JkZ5t4QH9zLjNBY+LH1K0a2/1XYKCz2Z4D XL1ajrEtwh47fidosAP/U06N008O1aTBFOmpiCo7Cht/Xq+lUY/Urt+jDx92z04bABXm hlf1TM8vfgulO9hbkFNyN2hhIz0kX3cA4KGko8hQUIiLhSZeBhhMDCTOniGWxyL33YiB szdHI3B5w4eKC1owlM9ZWmLKUO6d5WuMjJvk5GLyl3L6T+SuwvABEwyKO5selqbUJz4T Wp1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=SbpJz1Be21ayTUFDVSdF25Xiiu32rtYSsczWSstDHF0=; b=nZ2ZBHoSMlfi1P1njZV3dt6+qgwguc8nKQ0JXR5tE40Yryx8mU/aVTwygIDQr5sJyP cGiyV5QOWz0pC4OWG/JGlPCf6EIOYgCTlCnm3w7wkmdSbwywvXu+Zf6JIJzEqYuwF4xW b6AA3Th+gWqWdz7xHiFkMGJnDybvAYQRYq2z8ELRZf1bA1ATkUuH2iYMIDrD0rf+nBOQ uJGy9ECKtNsztFOaJE+1vzccbjmiyHj3FXbpV+OckEmC97cRFB9/KMKkYleMVZleqhxD E+BmY11pgS6diUwCRU1RU5B3J65hBUDVqLlC6E4nkG+hsbwZaln7Qk3ZUNKs0QJ6RENV SFLw== X-Gm-Message-State: AO0yUKXsNxT57rM9CvxsS1uwhDk9T+IHSKkVvrwnDg3M/eiMwZJMlXpd v/g9rVWeJW6H52bohsu9368= X-Google-Smtp-Source: AK7set98txh+kV1qwu/4ayK96wiY/ykDVwHb+ulLcO0GTp85/pLGVvHp52Bi3DPGTGiLOOXz+MKNnA== X-Received: by 2002:a05:600c:4586:b0:3dd:98d0:1a29 with SMTP id r6-20020a05600c458600b003dd98d01a29mr2515349wmo.38.1675361660758; Thu, 02 Feb 2023 10:14:20 -0800 (PST) Received: from xeon.. ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id x14-20020a1c7c0e000000b003daffc2ecdesm5516543wmc.13.2023.02.02.10.14.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 10:14:20 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , Alban Bedel , Stephen Warren , Marcel Ziswiler , Allen Martin , Jagan Teki , Lukasz Majewski , Marek Vasut , Svyatoslav Ryhel , Ramin Khonsari , Thierry Reding , Maxim Schwalm , Dmitry Osipenko Cc: u-boot@lists.denx.de Subject: [PATCH v2 04/16] ARM: tegra: clock: add clock_decode_pair helper Date: Thu, 2 Feb 2023 20:13:45 +0200 Message-Id: <20230202181357.4455-5-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230202181357.4455-1-clamor95@gmail.com> References: <20230202181357.4455-1-clamor95@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Get periph clock id and its parent from device tree. This works by looking up the peripheral's 'clocks' node and reading out the second and fourth cells, which are the peripheral and PLL clock numbers. Signed-off-by: Svyatoslav Ryhel --- arch/arm/include/asm/arch-tegra/clock.h | 13 +++++++++++++ arch/arm/mach-tegra/clock.c | 23 +++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/arch/arm/include/asm/arch-tegra/clock.h b/arch/arm/include/asm/arch-tegra/clock.h index 2270501406..61ef81e7fe 100644 --- a/arch/arm/include/asm/arch-tegra/clock.h +++ b/arch/arm/include/asm/arch-tegra/clock.h @@ -270,6 +270,19 @@ void clock_ll_start_uart(enum periph_id periph_id); */ int clock_decode_periph_id(struct udevice *dev); +/** + * Get periph clock id and its parent from device tree. + * + * This works by looking up the peripheral's 'clocks' node and reading out + * the second and fourth cells, which are the peripheral and PLL clock numbers. + * + * @param dev udevice associated with FDT node + * @param clk_id pointer to int array of 2 values + * first is periph clock, second is + * its PLL parent according to FDT. + */ +int clock_decode_pair(struct udevice *dev, int *clk_id); + /** * Checks if the oscillator bypass is enabled (XOBP bit) * diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c index 11bffc1701..966009f375 100644 --- a/arch/arm/mach-tegra/clock.c +++ b/arch/arm/mach-tegra/clock.c @@ -678,6 +678,29 @@ int clock_decode_periph_id(struct udevice *dev) assert(clock_periph_id_isvalid(id)); return id; } + +/* + * Get periph clock id and its parent from device tree. + * + * @param dev udevice associated with FDT node + * @param clk_id pointer to u32 array of 2 values + * first is periph clock, second is + * its PLL parent according to FDT. + */ +int clock_decode_pair(struct udevice *dev, int *clk_id) +{ + u32 cell[4]; + int err; + + err = dev_read_u32_array(dev, "clocks", cell, ARRAY_SIZE(cell)); + if (err) + return -EINVAL; + + clk_id[0] = clk_id_to_periph_id(cell[1]); + clk_id[1] = clk_id_to_pll_id(cell[3]); + + return 0; +} #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */ int clock_verify(void) -- 2.37.2