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 9084EC61DA4 for ; Fri, 3 Feb 2023 09:28:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 87C7085ED6; Fri, 3 Feb 2023 10:27:29 +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="GB0SpQOA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AB7DB85F08; Fri, 3 Feb 2023 10:27:18 +0100 (CET) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (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 9AF8E85ED6 for ; Fri, 3 Feb 2023 10:27:10 +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-x336.google.com with SMTP id bg26so3394089wmb.0 for ; Fri, 03 Feb 2023 01:27:10 -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=GB0SpQOA5HGaZnf36ylhRWlQTNnhDNkB5N928Ph3oDZLO5RQ9UXxD7zpFMBDEx4cgi 2b3rPXfwh4zbdil8rb9GsyxVModl6P1mxHI9b+lRzYEe1/Ul4SKdELDGhFBMaReaR60U TkuomYbt0q8lFo1nn7O2wbL0aqU8ml259TLVMmut38bgpNi9yISoHdfGSJogAsEXc/dp UevccmEPA/RoI/2bakIOr1p6rdS61G746XkRm94VT/arB4HmyaH0E552CFWsZ07hnu6Q 2fFwLzk6TxrWLUkpDrmtC7KWy+q21cKqT/0nXG+A5ya/vyY44yVrNrWAJC6QQq6lRYI1 nUGw== 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=dqjb3umz7MpfEBTlGPvU1N4ZwbW/b+kWl0b650IxRH5Xhq2KcpJ4fATRpTHP5VeWN6 Rq+/lx7IFG785DxHOvfPQ+r1bR8QKJwfx1nJPDUdN4EEAUD04fwij4ChIRd0atldgINV GPhArnv8Tcb3zjh1eMgjJswWbhuyO9FQq7DlFEUt7rp7dDVN6rfe4fDoSo5wnP7oeFiA 70ygwG4vjx0RDcwvuFKjKQrejORSVkUvX5CPVaaVhvWCJppn2upwi7BqSsZSAvkxJPEB eWYMKpD6isSu7cJHVuKFimQR4cYccUcJiQhgO1O4BBHeXfioMuycEWxoUy19bDrsr8+z h2mg== X-Gm-Message-State: AO0yUKWZb3HJzej+phw0JFPpwPLsXlNERLfsM2iGpVQ7SJZU1jRvdyms 99rHEFfslC724LVUzTddmSc= X-Google-Smtp-Source: AK7set/xmOG4CfhaCLRxkyEbXnXdHLeqO07omtdmjwnE5uTqmypEdC0b0noiTmi3j/dh6WbTcghFmw== X-Received: by 2002:a05:600c:34cb:b0:3dc:51ad:9dc4 with SMTP id d11-20020a05600c34cb00b003dc51ad9dc4mr9260392wmq.18.1675416430118; Fri, 03 Feb 2023 01:27:10 -0800 (PST) Received: from xeon.. ([188.163.112.54]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c46c600b003dc54344764sm7865025wmo.48.2023.02.03.01.27.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:27:09 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , 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 v3 04/16] ARM: tegra: clock: add clock_decode_pair helper Date: Fri, 3 Feb 2023 11:26:28 +0200 Message-Id: <20230203092640.40821-5-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230203092640.40821-1-clamor95@gmail.com> References: <20230203092640.40821-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