From mboxrd@z Thu Jan 1 00:00:00 1970 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 7162DC433F5 for ; Tue, 12 Apr 2022 22:43:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8850E83F1C; Wed, 13 Apr 2022 00:43:26 +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=1649803406; bh=oogGcwycbL5Rt60spjmBoYUXo5LoCk8cAtEwbU61EzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Cqo/vdP/xerzUF4PM8exS2Imoqc49YyuAJ+HG2b88yP0HHW/8twTOXtVhvKDMndyC 8HRuOL+l8yW5Me6l9FUyMe14Y7nzqyJy4hcSNaFGGOvlXTri3HYliLdY2LqufIdD2A pxMIdrqPEzi4I/RgFAhUXYpBevuewzgjvzP05ZyU2cdlNC4zeiCngd7aUcPFqP7L3R dZVn2SMUIOQSQCPdRc8uU0e/1CJARg6OHPbebkwP8YZ2m/ZsGU9/Fhwt47o/EGBdT4 SUv1My8lo+070dDcghdqfTdCWc9O9DYrQoDBqoTzTgkigbWxtnHuMeIANI8AWXfl2l cICvDbqsOJY+w== 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 6D84B83EF3; Wed, 13 Apr 2022 00:43:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1649803396; bh=oogGcwycbL5Rt60spjmBoYUXo5LoCk8cAtEwbU61EzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YE1DpD+LSDNvie9J++7QjJTJhpM04Gb6caSCGoDGtO86DCvntb800eADb3zoYPXT9 Vbi1I97NxDdq82u0NARIgcMJZ3TgDQqBLe+xnPZ/0Uvbqj/3oWsBZckwE5ZfHegRF/ MRJ+TW+gdT0V8FlW0nURAQ0CoGJos06sUu1tam1zyU+H2isfstCXSFGJhA8XneElWk +iIEvq6ebbKlz+4hRP9tFb9YGsoUjLrOQXQbGDFRn9zP2iXT/XAvAlrgpk0qJt/bY7 S5NBtqcEfq+19JJ2NB3DLuxHQ56UDHzxk2Ygl8Nu/jqwdG+HWkUo93Kp1ESjCyLV/h 482/mbdkDMQbw== From: Marek Vasut To: u-boot@lists.denx.de, sbabic@denx.de Cc: Marek Vasut , Patrick Delaunay , Simon Glass Subject: [PATCH v4 05/10] power_domain: Add power_domain_get_by_name() Date: Wed, 13 Apr 2022 00:42:52 +0200 Message-Id: <20220412224257.195007-5-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220412224257.195007-1-marex@denx.de> References: <20220412224257.195007-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 --- V2: Skipped to align the Vx scheme V3: Skipped to align the Vx scheme V4: Rebase on u-boot-imx/master --- 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