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 C71A6C433EF for ; Mon, 11 Apr 2022 19:49:00 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5BCF83EE8; Mon, 11 Apr 2022 21:47:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649706430; bh=Lmu8LBldcnJF9IzXWgMcHSrNetedSokSo9G5zDjNLuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=PrmQVGi7XtRXiHBEZW4pzux5hIRh6zE71t7RuUpgmBpUXeHoaNzVHfferyiHYv++X w3DrEzT7lSeSoq03nTtHwWmqbB6Uetnpxl23UO4qvI6sHW2CGAsIwGGqZJxmQV7vMX tyUEaYhxaJnJpBozn04Rw2tAFloRTNJ8a+QeoFa4oNQZvv5wF7rUbnVukKdDoW1hBT TpjzZm5jYQv5YbKnieaCNavsToSzhMlgf+31B+p1e2zYr3vIFCYF4BQVFyTWT5U72V nLnWXvs5I+1PG/CGpa3gsaw2bmM/ISuJZRhevsMBXVkSk4NYDQh2f6buz4Hgs81Nkx J6fBjGo7jVTfQ== Received: from tr.lan (ip-86-49-12-201.net.upcbroadband.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 80DCB83E6C; Mon, 11 Apr 2022 21:46:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649706377; bh=Lmu8LBldcnJF9IzXWgMcHSrNetedSokSo9G5zDjNLuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZIJPpEDJB8cuZDNfA9ia6ndTY3ZGoY9SsPT+HhHeLhjgTfq3kaLqACzm652LwKV42 BKLx0z1qkAJNbNZ2EvrkiMmaHQSgFEUOAGBvM6FcupSO1XY9Q5XhaxxDeAqc0x99Gx PKkBT+dMqKSEQITAseWi24uNMWLceNfmkk0UHNGgzlrKWUyZzVycAKrgBg0P3WCMR7 5dxm6o1vWI5YeBxT1LeDTYzZgndzIOBBRZdjAGQzCKSCSuio1G8UZV2e7HDsQKmFgT YzSpRfHHuEUDI/l/2/ctoZguxsOmF2UXl9o4Bcz+5FVeF+IYt9QVgwAQrWqfrvUizB 3kYcgdS61Hi8Q== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrick Delaunay , Simon Glass Subject: [PATCH v2 16/23] power_domain: Add power_domain_get_by_name() Date: Mon, 11 Apr 2022 21:45:36 +0200 Message-Id: <20220411194543.730647-16-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220411194543.730647-1-marex@denx.de> References: <20220411194543.730647-1-marex@denx.de> 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.5 at phobos.denx.de X-Virus-Status: Clean Implement power_domain_get_by_name() convenience function which parses DT property 'power-domain-names' and looks up power domain by matching name. Signed-off-by: Marek Vasut Cc: Patrick Delaunay Cc: Simon Glass --- drivers/power/domain/power-domain-uclass.c | 14 ++++++++++++++ include/power-domain.h | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/drivers/power/domain/power-domain-uclass.c b/drivers/power/domain/power-domain-uclass.c index 0c5823ceddf..74c33d4e2e0 100644 --- a/drivers/power/domain/power-domain-uclass.c +++ b/drivers/power/domain/power-domain-uclass.c @@ -80,6 +80,20 @@ int power_domain_get_by_index(struct udevice *dev, return 0; } +int power_domain_get_by_name(struct udevice *dev, + struct power_domain *power_domain, const char *name) +{ + int index; + + index = dev_read_stringlist_search(dev, "power-domain-names", name); + if (index < 0) { + debug("fdt_stringlist_search() failed: %d\n", index); + return index; + } + + return power_domain_get_by_index(dev, power_domain, index); +} + int power_domain_get(struct udevice *dev, struct power_domain *power_domain) { return power_domain_get_by_index(dev, power_domain, 0); diff --git a/include/power-domain.h b/include/power-domain.h index 113276b5119..2ff6c77cd76 100644 --- a/include/power-domain.h +++ b/include/power-domain.h @@ -107,6 +107,27 @@ int power_domain_get_by_index(struct udevice *dev, } #endif +/** + * power_domain_get_by_name - Get the named power domain for a device. + * + * @dev: The client device. + * @power_domain: A pointer to a power domain struct to initialize. + * @name: Power domain name to be powered on. + * + * Return: 0 if OK, or a negative error code. + */ +#if CONFIG_IS_ENABLED(POWER_DOMAIN) +int power_domain_get_by_name(struct udevice *dev, + struct power_domain *power_domain, const char *name); +#else +static inline +int power_domain_get_by_name(struct udevice *dev, + struct power_domain *power_domain, const char *name) +{ + return -ENOSYS; +} +#endif + /** * power_domain_free - Free a previously requested power domain. * -- 2.35.1