Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1060051rdb; Wed, 24 Jan 2024 03:49:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFbyrIHoOV4b82J5ezfC/Ri47LnVatkKoaFJYfU1iy4rP8X4zQZ5Yl045VYBNalGFVjsT0g X-Received: by 2002:a25:8a90:0:b0:dc2:4c31:774a with SMTP id h16-20020a258a90000000b00dc24c31774amr462937ybl.49.1706096988266; Wed, 24 Jan 2024 03:49:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706096988; cv=pass; d=google.com; s=arc-20160816; b=1KL5M7Qgpyf+lRcUhIZ72FLAkCuROgfQ72bWubvH6WeEDRiZUPBifspKZof1n4A4R0 zO8Hu+4WaMVOuvZb9psQB00hlYffjEfMLawmJUYhlg2g4CRWvW60KW84SFWiPMQ3q5MZ o7E6wUdWw/YEW7BgyyMOhLVrKTeYINxgoyFIlYpgxR65izRbgwKuksAU2oDsz1iYQywq k78cAQ7i7TsVS2uCkzA79Uc6o0zCVQOpJRJqVZL6tKSvoSZWHo8crkTYGuHs8sAXj8KA 4XVsjeaCEPsF6bOcSBQ5TLA564cxE7I1bnjPp9EAbrEHSchL6ZJ4c3SW7KsIe4ZMr9x+ mL8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:references :dlp-filter:cms-type:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=O+tABnUnHrJhacFqwRIfEaygao34+wSqrWI/LqRW9yA=; fh=E3+QW03k4Rm9MQzWXhK3ydMS9j7SCDNXzLV0jdkcLms=; b=pT3zyDlDhKd9V+hx35PwFDvDl6395PTHuoaHwBCTxJ04JMJWqLfX/ffmW2Z+Gbough 4/vjfV3EFgUvVCciTqHPs/leiJtw5Q4ffLCD8wlsDYHoXFqIIViD5ZE5KqVWUwx4NNI2 nFDynb7MneQEVgLfR2ZQ0vCLTvMTDcXMNwNmeRfOevnEefMuFvngb6ksLucU/gJVAa3Q YIPgdHiAJ9+MeMy0Z6AQJJPxpj4MSUS/efbrvhFvpu/TKEFXRjcj8kSA6/foqUQ5rpRC Vh8lENrKjKodbRFHdfq3kW9MmoMVlgM6iBUeSsckkNC3zwHirgj4rm0RySqeDk4Z44Vl A7wA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Zx3Sgs3f; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-36906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g12-20020a0caacc000000b006818d25e2f2si10130574qvb.520.2024.01.24.03.49.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 03:49:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-36906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Zx3Sgs3f; arc=pass (i=1 spf=pass spfdomain=samsung.com dkim=pass dkdomain=samsung.com dmarc=pass fromdomain=samsung.com); spf=pass (google.com: domain of linux-kernel+bounces-36906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-36906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EF09A1C21B14 for ; Wed, 24 Jan 2024 11:49:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 738695B5B2; Wed, 24 Jan 2024 11:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Zx3Sgs3f" Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A19311AAD1 for ; Wed, 24 Jan 2024 11:47:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.254.224.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706096879; cv=none; b=EFnMPiR3UD2itImr8vYCH0WosRF8w7K+QlW/R7dVLmVfEtE/B5osjJxHU0nRmRnrhMk0a/Ozx1OmkYN+b/N3HtBA+whP/ND9YDhNZHDvi9j8kFh0taC4ghP4arKfbTLBhzmJZJbi5DYObOZofxePTzRvQZR7Z6genSKe2Sh1gNw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706096879; c=relaxed/simple; bh=Q2Lv21q+LPYK+1GamQvuvIuUxtbkeVPHvD2B7RxGgdg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:Content-Type: References; b=OqMKo4p/VWATc00qFunkqqDsjAm+Q5cGFq+U8rHxWAI2HX8tH/ov1stbgY5Sh/0DxePtIRGv37GHmw9VrkKVW1+yn+UecfADpWfwSf9Xzax3jLa5+HwQTOf6cj1oVUAyFTLB3MLnB0HfWuE6fJ5LEMtf3lKDhwX2xlAytaWZ73A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com; spf=pass smtp.mailfrom=samsung.com; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b=Zx3Sgs3f; arc=none smtp.client-ip=203.254.224.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=samsung.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=samsung.com Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20240124114749epoutp032cd4995a1c9f811a9e003373585649d2~tRhBB4Yfn0454404544epoutp03N for ; Wed, 24 Jan 2024 11:47:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20240124114749epoutp032cd4995a1c9f811a9e003373585649d2~tRhBB4Yfn0454404544epoutp03N DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1706096869; bh=O+tABnUnHrJhacFqwRIfEaygao34+wSqrWI/LqRW9yA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zx3Sgs3fErkJhtj11/K5XGyPlpx6jR8LJwuioedMyAO7bYVEEPuS1P+gh+lgMiZ3T NVt7o7SzJhjecNLlLGUcf6RYbX26Y1P24pHsT3dXplzrQqLd7vNhsdlYo+hBCDT/Qo XsFRrgq0j2iSeyNF42e/wN2qeKvn8PEopgdN1FX8= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20240124114748epcas5p19c19c7a52bd78878d3be50572c99e215~tRhAKg7AO0246702467epcas5p1C; Wed, 24 Jan 2024 11:47:48 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp4.localdomain (Postfix) with ESMTP id 4TKhz65RwRz4x9Px; Wed, 24 Jan 2024 11:47:46 +0000 (GMT) Received: from epcas5p4.samsung.com ( [182.195.41.42]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id F5.35.09634.2E8F0B56; Wed, 24 Jan 2024 20:47:46 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20240124103855epcas5p27400bd95df42f36b9547a4e28aa26f5d~tQk2i396z2401024010epcas5p21; Wed, 24 Jan 2024 10:38:55 +0000 (GMT) Received: from epsmgmc1p1new.samsung.com (unknown [182.195.42.40]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20240124103855epsmtrp2a7f6b1794ef3de4fae42c9c2e1221ff7~tQk2h0d2j2380723807epsmtrp2P; Wed, 24 Jan 2024 10:38:55 +0000 (GMT) X-AuditID: b6c32a49-159fd700000025a2-69-65b0f8e2a0ec Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgmc1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 3F.2E.07368.EB8E0B56; Wed, 24 Jan 2024 19:38:54 +0900 (KST) Received: from cheetah.sa.corp.samsungelectronics.net (unknown [107.109.115.53]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20240124103852epsmtip251e8ba5a9680c4140a2a0264c5f62669~tQk0CbMz_0276602766epsmtip2a; Wed, 24 Jan 2024 10:38:52 +0000 (GMT) From: Shradha Todi To: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Cc: mturquette@baylibre.com, sboyd@kernel.org, jingoohan1@gmail.com, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, krzysztof.kozlowski@linaro.org, alim.akhtar@samsung.com, linux@armlinux.org.uk, m.szyprowski@samsung.com, manivannan.sadhasivam@linaro.org, pankaj.dubey@samsung.com, Shradha Todi Subject: [PATCH v4 1/2] clk: Provide managed helper to get and enable bulk clocks Date: Wed, 24 Jan 2024 16:08:37 +0530 Message-Id: <20240124103838.32478-2-shradha.t@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20240124103838.32478-1-shradha.t@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrIJsWRmVeSWpSXmKPExsWy7bCmlu6jHxtSDWZdVrd4MG8bm8WSpgyL FV9mslvsfb2V3aKh5zerxabH11gtPvbcY7W4vGsOm8XZecfZLGac38dkcWjqXkaLlj8tLBZr j9xlt7jb0slqcfGUq8WirV/YLf7v2cFu8e/aRhaL3sO1DsIel69dZPZ4f6OV3WPnrLvsHgs2 lXpsWtXJ5nHn2h42jydXpjN5bF5S79G3ZRWjx+dNcgFcUdk2GamJKalFCql5yfkpmXnptkre wfHO8aZmBoa6hpYW5koKeYm5qbZKLj4Bum6ZOUBvKSmUJeaUAoUCEouLlfTtbIryS0tSFTLy i0tslVILUnIKTAr0ihNzi0vz0vXyUkusDA0MjEyBChOyMyYseMZYMEuq4vSGP8wNjHtFuxg5 OCQETCSm7s/oYuTkEBLYzSjROCW3i5ELyP7EKPH4XjczhPONUeJXx3lmkCqQhlMts9kgEnsZ JY59uMAI4bQySTyauY4RpIpNQEui8WsXWLuIwGJGiVs7NrOCOMwCT5gkltz4ywJSJSwQLLGp 9TwbiM0ioCrx/Gs7O4jNK2Al8X76BUaIffISqzccANvNKWAt8fncPrDdEgJHOCR6Nl2FKnKR uN3/nB3CFpZ4dXwLlC0l8fndXjYIO11i5eYZUE/kSHzbvIQJwraXOHBlDgsoNJgFNCXW79KH CMtKTD21DqyEWYBPovf3E6hyXokd82BsZYkvf/ewQNiSEvOOXWaFsD0kls7ohwZeH6PE7etn mCYwys1CWLGAkXEVo2RqQXFuemqxaYFhXmo5PNqS83M3MYLTrpbnDsa7Dz7oHWJk4mA8xCjB wawkwntDcl2qEG9KYmVValF+fFFpTmrxIUZTYABOZJYSTc4HJv68knhDE0sDEzMzMxNL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FMFkmDk6pBqbVU65ssfzs W3j0xv9ZZ8+KnT9bLhwx6aCyi5pSQlLEvotdjw5tWdLNGHtWQ+Qxu1vNpukJW2PErjKbu6ye v7IrevuFjH3TLr5tNdpj7Th9cfl7059r1Tq0Jjr+tdvHc4NV9NOf2f5W/XtX3p+gJZE4j3P1 FIZnuw+a7co4cOFD5HLxHy/UnLiuaih5t5iVlb+cfaLJvf9Qe2eP5iRF5Qdakte+iJpuOVHN 6Bqx2Uqg10NFUyM1q55Dc6nVyvZbLkwLKrNWrDBbv+6EK+e/krhV3gKPBG+ufz/XS+LSzYq0 omO3JW5pym7XrbgaFF3yP4ZDY0kmw6PZDg3xEve6xQpeKu5vFTqYYef14oHVnCYlluKMREMt 5qLiRABSbpLx/AIAAA== X-CMS-MailID: 20240124103855epcas5p27400bd95df42f36b9547a4e28aa26f5d X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20240124103855epcas5p27400bd95df42f36b9547a4e28aa26f5d References: <20240124103838.32478-1-shradha.t@samsung.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Provide a managed devm_clk_bulk* wrapper to get and enable all bulk clocks in order to simplify drivers that keeps all clocks enabled for the time of driver operation. Suggested-by: Marek Szyprowski Signed-off-by: Shradha Todi --- drivers/clk/clk-devres.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/clk.h | 24 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c index 4fb4fd4b06bd..cbbd2cc339c3 100644 --- a/drivers/clk/clk-devres.c +++ b/drivers/clk/clk-devres.c @@ -182,6 +182,46 @@ int __must_check devm_clk_bulk_get_all(struct device *dev, } EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all); +static void devm_clk_bulk_release_all_enable(struct device *dev, void *res) +{ + struct clk_bulk_devres *devres = res; + + clk_bulk_disable_unprepare(devres->num_clks, devres->clks); + clk_bulk_put_all(devres->num_clks, devres->clks); +} + +int __must_check devm_clk_bulk_get_all_enable(struct device *dev, + struct clk_bulk_data **clks) +{ + struct clk_bulk_devres *devres; + int ret; + + devres = devres_alloc(devm_clk_bulk_release_all_enable, + sizeof(*devres), GFP_KERNEL); + if (!devres) + return -ENOMEM; + + ret = clk_bulk_get_all(dev, &devres->clks); + if (ret > 0) { + *clks = devres->clks; + devres->num_clks = ret; + } else { + devres_free(devres); + return ret; + } + + ret = clk_bulk_prepare_enable(devres->num_clks, *clks); + if (!ret) { + devres_add(dev, devres); + } else { + clk_bulk_put_all(devres->num_clks, devres->clks); + devres_free(devres); + } + + return ret; +} +EXPORT_SYMBOL_GPL(devm_clk_bulk_get_all_enable); + static int devm_clk_match(struct device *dev, void *res, void *data) { struct clk **c = res; diff --git a/include/linux/clk.h b/include/linux/clk.h index 1ef013324237..a005e709b7bd 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -438,6 +438,23 @@ int __must_check devm_clk_bulk_get_optional(struct device *dev, int num_clks, int __must_check devm_clk_bulk_get_all(struct device *dev, struct clk_bulk_data **clks); +/** + * devm_clk_bulk_get_all_enable - managed get multiple clk consumers and + * enable all clks + * @dev: device for clock "consumer" + * @clks: pointer to the clk_bulk_data table of consumer + * + * Returns success (0) or negative errno. + * + * This helper function allows drivers to get several clk + * consumers and enable all of them in one operation with management. + * The clks will automatically be disabled and freed when the device + * is unbound. + */ + +int __must_check devm_clk_bulk_get_all_enable(struct device *dev, + struct clk_bulk_data **clks); + /** * devm_clk_get - lookup and obtain a managed reference to a clock producer. * @dev: device for clock "consumer" @@ -960,6 +977,13 @@ static inline int __must_check devm_clk_bulk_get_all(struct device *dev, return 0; } +static inline int __must_check devm_clk_bulk_get_all_enable(struct device *dev, + struct clk_bulk_data **clks) +{ + + return 0; +} + static inline struct clk *devm_get_clk_from_child(struct device *dev, struct device_node *np, const char *con_id) { -- 2.17.1