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 4DF3FC05027 for ; Sun, 29 Jan 2023 18:43:42 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5791985767; Sun, 29 Jan 2023 19:43:16 +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="NJDnaufN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3B19985764; Sun, 29 Jan 2023 19:41:55 +0100 (CET) Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) (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 6E24185750 for ; Sun, 29 Jan 2023 19:41:47 +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-wr1-x42f.google.com with SMTP id h16so9167345wrz.12 for ; Sun, 29 Jan 2023 10:41:47 -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=7SvjedKrbSxHwEwSb01h90+hDIXT8VQfDdQc7ilLVk0=; b=NJDnaufNDP+TyAm4YxaWI0opfuklahSZNXI/9oYdZ07LSlMd3uMK5rIjRFn5mhJz96 sT7q8i7o8hdOLkBfBOB/bTzk0/0MRc5LHXo8R6U9owNM/Pi7iIXv4j5z7pogy5pjzuzi Ie9pkwXKFG0CAiqCJCYhLnaYJmLwD8tpXMhw7Hmtk1ebYyU0HNDdybqD7Ji8LeVufU0D Fkp2ghNj2kSY6xuLGH9rtpHBIBSMryMeFa1o2jgNP38xZnNOZMvBBwZWxjE+ZXSt1hJg 7AWtLMH5ZaZ4Ely5exeDaJymjWnsvO1r8xHVGhZbge0jllf+2dys9ti2C/onGoQOiVit m1Tg== 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=7SvjedKrbSxHwEwSb01h90+hDIXT8VQfDdQc7ilLVk0=; b=eEZCThUF57PPgjOQ7caQbCghMtcOsRnELBrfGimNmRlPXkQOaxlCx3C4jnn+0cacVF KnkkKji3aJ6usqDVo2VVQFJ3fL2cf3OLzrgow+D6RHmXDoKO1kKfb6yT5WJ1mnqrP0R+ y1jMgJZIhBjC2+QdKLwh8qghXY3b/Ydw9YudqhXkUaU+XXKJ6c0WlU02sgIakULYCeY7 WqMqsGRiLK8urBf6wJ3/tPR+TWb/fkkWkjsVYFoVFd9iIjXRqWcVOBlx5W/cdglkEki9 nBwzDDT/g/U6VS8PUpztxNWMCLC5NKnydshSb6egrLvslDQqAM5F6Hu3w8wzOC+dbnBc 0zbg== X-Gm-Message-State: AO0yUKV1kpyvKDhUGQHBEagUqtcejEd0PFHg8vM8CK649h2HrXttQBb3 YN+7B9cBFqmHhhMQbiZMTmo= X-Google-Smtp-Source: AK7set/jtpB6PO9N9eL8nO7P1WxJKxuhqa1gpKFarbiqb6OioPupmbzEgJ3YjtUMN+vJ+XiFlnHZsA== X-Received: by 2002:adf:e90a:0:b0:2bf:e7a0:8b63 with SMTP id f10-20020adfe90a000000b002bfe7a08b63mr2447542wrm.5.1675017706782; Sun, 29 Jan 2023 10:41:46 -0800 (PST) Received: from xeon.. ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id y8-20020adfdf08000000b002bfb31bda06sm10321010wrl.76.2023.01.29.10.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Jan 2023 10:41:46 -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 v1 04/16] ARM: tegra: clock: add clock_decode_pair helper Date: Sun, 29 Jan 2023 20:41:11 +0200 Message-Id: <20230129184123.36001-5-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230129184123.36001-1-clamor95@gmail.com> References: <20230129184123.36001-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 05b3bc2122..59486d74d6 100644 --- a/arch/arm/include/asm/arch-tegra/clock.h +++ b/arch/arm/include/asm/arch-tegra/clock.h @@ -269,6 +269,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 77c8ad978e..7eada78d3a 100644 --- a/arch/arm/mach-tegra/clock.c +++ b/arch/arm/mach-tegra/clock.c @@ -671,6 +671,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