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 C841FC05027 for ; Tue, 14 Feb 2023 17:37:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A9B6985988; Tue, 14 Feb 2023 18:36:26 +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="N41CP0Xo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D7756859E6; Tue, 14 Feb 2023 18:36:10 +0100 (CET) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 6F82C85988 for ; Tue, 14 Feb 2023 18:36:04 +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-x32d.google.com with SMTP id l21-20020a05600c1d1500b003dfe462b7e4so1431835wms.0 for ; Tue, 14 Feb 2023 09:36:04 -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=WGnOXk7F41+FUWj9KaPiLniOxcq6LrbPqdRniecgUus=; b=N41CP0XoJLG1G7+s+ecuqwkqM/48n1bNUplGHSJL5ztSX6VrakMVvlFL5GVYDBXc0l 1PT1028v25yAZoYj12xUgtCL2xxaFuc9siKj8Y3pow36wRtXDQPhBdir2xip+TP8GYCj 44YTz770zth9M2iD32UGXw6/HS6PkAV66E/5ihblEtw1ksywfJ2BwpIYE7WAR4X+fjUI 3vXzwq+SHcAHRnZAAvFd694+TDs7dSS9vDI+ZsWnpZld09VIFhdcW4QG0NVOoiT7Z1w8 mDG49whVVVj30uZgabc+6Scb4lgnW34CPryUW9fglDRZWL6wJzo6S9/DoQFZZ3o60JGe s7Vg== 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=WGnOXk7F41+FUWj9KaPiLniOxcq6LrbPqdRniecgUus=; b=xCabVVLURktxsiQwyW3LdPfBBazJ0WppEQJZW5e5Aruv7oEuPItA258GjQodQi4riu 42jgZQ9qpP8WxDH9jatdPpTkOhJLgzgYhcWfAX24XoUHIVyGN7NYylY7c61+U8ora61z gVsIz3Qvy8TO8k22sM2JSQeidkycVm5cxrQZvCIPxS5MPt4czaj4uac0x3nifJzQ6ogC 7G+cxLPI7cM/NM7jNwk2rbywbnFa6pHp7dnmmVIgwG1F4LFJGyCoGMaICuMPSYeeElMk HWSdUaC7H5PXuTlPbXMamomzbmZghigwxXBkKbQfZsz2vLxn42RgTa41Eaa5IRNcZl9c D6+g== X-Gm-Message-State: AO0yUKXPN4jjTjBAOFurq8nCNxazwzh/GGg/ELGzBG3vV4lLS545P5ad FDbOTVOWjTjEUpEK9pKn9Og= X-Google-Smtp-Source: AK7set+kedwUdHEauS9wsWlXT70dcHeF1jOe/KgI+6H/rjNFdin52u8AfpIHYBgqh/NwB4NvCnL/Uw== X-Received: by 2002:a05:600c:4f06:b0:3dc:433a:e952 with SMTP id l6-20020a05600c4f0600b003dc433ae952mr2867768wmq.33.1676396163695; Tue, 14 Feb 2023 09:36:03 -0800 (PST) Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Feb 2023 09:36:03 -0800 (PST) From: Svyatoslav Ryhel To: Tom Warren , Marcel Ziswiler , Allen Martin , Jagan Teki , Lukasz Majewski , Marek Vasut , Svyatoslav Ryhel , Ramin Khonsari , Thierry Reding , Maxim Schwalm , Dmitry Osipenko , Simon Glass Cc: u-boot@lists.denx.de Subject: [PATCH v4 04/16] ARM: tegra: clock: add clock_decode_pair helper Date: Tue, 14 Feb 2023 19:35:26 +0200 Message-Id: <20230214173538.6242-5-clamor95@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com> References: <20230214173538.6242-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. Tested-by: Andreas Westman Dorcsak # ASUS TF T30 Tested-by: Robert Eckelmann # ASUS TF101 T20 Tested-by: Svyatoslav Ryhel # HTC One X 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