From nobody Sun Apr 19 02:12:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 180CCC43334 for ; Thu, 7 Jul 2022 08:20:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235426AbiGGIUY (ORCPT ); Thu, 7 Jul 2022 04:20:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235425AbiGGITw (ORCPT ); Thu, 7 Jul 2022 04:19:52 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B02031DCE for ; Thu, 7 Jul 2022 01:18:59 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id v12so9536742edc.10 for ; Thu, 07 Jul 2022 01:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MwipOXb6LRRiT5bisXBXsYDVKLh0i5fzf+d3OONFKdQ=; b=XF+ORnPfOh8IEmMJrmcDE/nhbYDTvEqsNhkOoIyya3QZDqpdeLCkK/GBlPGvh6iM6E 46wUsFol0pTRJHinlg9kifNtEVQfXViXRtk0mTu6NoJ5vXkJWwvl7cJSVzAqfzfS/iMz Yeu8bE+87jXB0kzBZD4Kox+kOGfYu4wstdUxLz2o66amSRIT94OmO2JQBr58DK1Fv7u7 7mH3Ir8zHMnWEW+HS9Tra2cwoRUliJCUiIU39aFPtIIm6KkKZULTYkSz6UPAoi+QqNJt 0/PHD9gDpIrj8HHhg4AgfhT5go0OGUe7ibB5+PWRrdIMvXOx73xLzgZjqGbCdpAlNq75 x9Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MwipOXb6LRRiT5bisXBXsYDVKLh0i5fzf+d3OONFKdQ=; b=rNclV9Zds/j5m/sxfbOVDbcTbd4cs22TJFD25fRVMc4aNzUSV/lSJ6gJWPV9CPczsz Bu6taW+Ll2mjuLS3kOHEBCxTeWJ5ckr9ch/AqKzihcdJISnQA2RE0hb6Iy+Jp2U3kjcK bZ4h33PZUxVRqR4Cwx27F8j32PYYI2GvB11+fuFFX/sud1ceO5rnTTK3C+F64jgriH1n ECrkN43SgzGr7iVHlkIAwUKVjd0PrAeMuSx3vuyTxinn4FG6EAJh1A7j7zM6H/PTKPaH JH8opJYembohO+m3B+bZ2Bux8ijKelCCLTGGclRh+ExjK5GOTq02qMiEV7v9SGv99VRM Vqcg== X-Gm-Message-State: AJIora/TyhE4pXEKAfVmTnbXwzdYSuHEpMrvUOmEVaIZiMR+HdF66Maf 05Jo/ZGVX2mh65KRBF5tzaeCn3/cfuCPkvVq X-Google-Smtp-Source: AGRyM1tlGJouNKahbDS7auq8hdRSYNWEM2VA4KBmQStt7+TfT48n3vBmGrXDJfzkI4Hitl+a+XMy1A== X-Received: by 2002:a05:6402:2802:b0:43a:9098:55a0 with SMTP id h2-20020a056402280200b0043a909855a0mr7942234ede.179.1657181937376; Thu, 07 Jul 2022 01:18:57 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id f13-20020a170906824d00b00726e108b566sm12871779ejx.173.2022.07.07.01.18.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 01:18:56 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: linux-kernel@vger.kernel.org, Rob Herring Cc: Naresh Solanki Subject: [PATCH v4 1/4] dt-bindings: vendor-prefixes: add 9elements Date: Thu, 7 Jul 2022 10:18:23 +0200 Message-Id: <20220707081826.953449-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220707081826.953449-1-Naresh.Solanki@9elements.com> References: <20220707081826.953449-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The vendor prefix for 9elements GmbH [1]. [1] https://9elements.com/ Signed-off-by: Naresh Solanki --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Docum= entation/devicetree/bindings/vendor-prefixes.yaml index 0496773a3c4d..2b3c929b1332 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -29,6 +29,8 @@ patternProperties: description: 70mai Co., Ltd. "^8dev,.*": description: 8devices, UAB + "^9elements,.*": + description: 9elements GmbH "^abb,.*": description: ABB "^abilis,.*": --=20 2.35.3 From nobody Sun Apr 19 02:12:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C376FC43334 for ; Thu, 7 Jul 2022 08:20:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235186AbiGGIUm (ORCPT ); Thu, 7 Jul 2022 04:20:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235101AbiGGIUE (ORCPT ); Thu, 7 Jul 2022 04:20:04 -0400 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10CB953D17 for ; Thu, 7 Jul 2022 01:19:08 -0700 (PDT) Received: by mail-ed1-x52a.google.com with SMTP id e15so1224776edj.2 for ; Thu, 07 Jul 2022 01:19:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=36QQffcbfgyCYivXIz8C1vW53ip+ep0hb4pGJir6Ai8=; b=RQ1XzMNV7/E7fMX515logqe2KcF0Yhs0XpadO3PCNDe8p0KUboO0Afj8c+94Ry2U3z RLDD3lb8z/tDpc3d5hZo0o0qM4YlloEv0OnMk6zHfjkdiX6yCP4S+iMDkQvdJZLD/NGR tLufLaiOdenWIYjXyPzWGzCZh1wWmu0Ff+ymB/l1WBudOxXODbuquO0RJ/WeLELLg+hH NgyElH6FE1nne2vnQDuJEBhxzzsT55k/B+/IfK7pQTLjYrB5+QJwDX/imfU5vTXCpBfy 1uVevoBlXAHlVU4bWiQh2MrN6cdRJJEWyDnib7h11k1Ea+Sj4dKIpvFQNbH/oslU7zUb SRcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=36QQffcbfgyCYivXIz8C1vW53ip+ep0hb4pGJir6Ai8=; b=S7DFB24CxC7In3zUTDqoomlxm+lhlWY51LryVXBr1/98a276EdEuOp6Bm8VfWGV2fe 4xjMImhF2IOHUK/Lyp6Szwrw0AWxPLH346gjKbV8Z8aIleL77psWuGOPs/mUtDXVlzGQ XPCc5HycNaKIl4dBJI5RqS6AWT2DNJvjCcQtALbQN9U0DJ0sqaBhCfwj1Qp42Ca3If0E xbba289g0FqC4h3ucO3EkePd4S9GN/W+bs6GRnXc5NyDCqpfk0YklrLCwFNlgzpUo3ue rV7bcjArTWYfA0p61fbYf4JAhIS4TBqiJMyUmFMTeFdVm0mFcJNlw/t7SzKzKuLzLjN/ twXw== X-Gm-Message-State: AJIora+dox88KAjIvDD0oP78V2urLmLlT45qYUe174LL+jE+qq1V94d4 15aSoQNizoXt5SAChbhVY5+2pwHuKUhAgQna X-Google-Smtp-Source: AGRyM1tbT3fSN3xY6/W8zwopdfYWLaRrUmN/LYTVg5vzAeMd4zfvp+fAJuUH6+RvWzuqIakNjnAtig== X-Received: by 2002:a05:6402:42c8:b0:435:b99c:35f9 with SMTP id i8-20020a05640242c800b00435b99c35f9mr61511391edc.137.1657181946010; Thu, 07 Jul 2022 01:19:06 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id f13-20020a170906824d00b00726e108b566sm12871779ejx.173.2022.07.07.01.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 01:19:05 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown , Patrick Rudolph Cc: Naresh Solanki Subject: [PATCH v4 2/4] dt-bindings: regulator: add bindings for output-supply Date: Thu, 7 Jul 2022 10:18:24 +0200 Message-Id: <20220707081826.953449-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220707081826.953449-1-Naresh.Solanki@9elements.com> References: <20220707081826.953449-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add a devicetree binding for the 9elements,output-supply driver. Example is also provided. Signed-off-by: Naresh Solanki --- .../regulator/9elements,output-supply.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/9elements,o= utput-supply.yaml diff --git a/Documentation/devicetree/bindings/regulator/9elements,output-s= upply.yaml b/Documentation/devicetree/bindings/regulator/9elements,output-s= upply.yaml new file mode 100644 index 000000000000..e4b67bc0794f --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/9elements,output-supply.y= aml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/userspace-consumer.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Regulator output-supply driver + +maintainers: + - Patrick Rudolph + +description: | + Regulator output-supply driver helps interact with regulator. + Provides regulator events & sysfs notify to capture regulator events + in realtime for userspace application. + This enables userspace application to monitor events in regulator(s) & + handle them appropriately. + + +properties: + compatible: + enum: + - 9elements,output-supply + + regulator-name: + description: Name of the consumer line + + regulator-boot-on: + description: Enable regulator during boot + + regulator-supplies: + description: Supply names for this regulator. This can be multiple str= ings + +patternProperties: + ".*-supply$": + description: | + Input supply phandle(s) for this node. There should be + -supply to pass regulators handle + +required: + - compatible + - regulator-supplies + - ".*-supply$" + +additionalProperties: false + +examples: + - | + p12v_b_consumer { + compatible =3D "9elements,output-supply"; + regulator-name =3D "BCM1"; + regulator-supplies =3D "vbus"; + vbus-supply =3D <&p12v_b>; + }; + + ssb_rssd32 { + compatible =3D "9elements,output-supply"; + regulator-name =3D "ssb_rssd32"; + regulator-supplies =3D "sw0", "sw1"; + sw0-supply =3D <&sw0_ssb_rssd32>; + sw1-supply =3D <&sw1_ssb_rssd32>; + }; +... --=20 2.35.3 From nobody Sun Apr 19 02:12:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85AAEC43334 for ; Thu, 7 Jul 2022 08:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235296AbiGGIU5 (ORCPT ); Thu, 7 Jul 2022 04:20:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234787AbiGGIUJ (ORCPT ); Thu, 7 Jul 2022 04:20:09 -0400 Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4502753D26 for ; Thu, 7 Jul 2022 01:19:10 -0700 (PDT) Received: by mail-ed1-x530.google.com with SMTP id g1so14530204edb.12 for ; Thu, 07 Jul 2022 01:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OU+/1ZARQ0jB8FL93NzkGXB/S1O4C4RObHnGZSJfcBg=; b=hDYBAi/KxfZ6QNL5Pb28EkaMQOuXGX6vXQUxNep3Lxuvr1zkL47zEzDo9g+BLMDEyR KsVVEhduLHEYSVSUqPjD2hxNCVhT85zZS2w+okI/Jjd9mFMoqs7h0ltcyaoGBJU2sPfm 72Rg1sn1NX8jwXqc0OURFV+VlW73lpHamrL1puC2b96Y9zOpqPu5uRihVHkb7khAr/tM dJEzge5m38P4G39bx79GMi7SdEWDH+sL5pg9JQc6mUP3sh56mOdzITWqu9GEJfJ7Y47d qDz4Gxvu2BocRDWfMHg7hmzqSV0CaeFYgrTXRgdxAEUh2bNQ3aWLRpyS5ZneawOsiKwj vAXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OU+/1ZARQ0jB8FL93NzkGXB/S1O4C4RObHnGZSJfcBg=; b=Dun6EpXPBiyHs1vwppcoQi3O5lLrA/DylMBT2szbtQbXyUFEAtlQ6fpvNuR+Rzeugf yd47rQV0YVG621tbFJESkkxPkmZtmAFtKteAiiDFtzGE2haMEZlf/zQaRuZJfrnI9cgs Zl0xIfvhYaUcCpgSGgBipyH199tam9Cp+ruNYS6n+241NFd973BMLQSTJl6E6eXtTqE6 LwM+YLa8EtEciIH6zHlrh8fyXxS6sHLQHEd/7HhB4lltxeoo/hLaG2wx6okySi2OIchy GLCblgt5cHEj6D2p0srDsCXontJt+AZwaY6x74KqqA2eW4yhlQBZ/SXAeGNuGKONYYxW yeig== X-Gm-Message-State: AJIora+jYWdBj98PkfDhy6XrQ3rSq26LxvYikK0pUBFx8ejzAKVKhspW 4dpFw6CFv+nYiuy7yORMP4LZb4Ct5XrZmZgl X-Google-Smtp-Source: AGRyM1uOLQ2GGBTRfiYr9s2R1dVzJksKvREtmhZEntCZCPs2sSnNJpSErtb7fKpMFY4oWn4LXS6w9g== X-Received: by 2002:a05:6402:239f:b0:43a:92a7:84e with SMTP id j31-20020a056402239f00b0043a92a7084emr5422416eda.293.1657181948280; Thu, 07 Jul 2022 01:19:08 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id f13-20020a170906824d00b00726e108b566sm12871779ejx.173.2022.07.07.01.19.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 01:19:07 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown Cc: Laxman Dewangan , Naresh Solanki Subject: [PATCH v4 3/4] regulator: output-supply: Add devicetree support Date: Thu, 7 Jul 2022 10:18:25 +0200 Message-Id: <20220707081826.953449-4-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220707081826.953449-1-Naresh.Solanki@9elements.com> References: <20220707081826.953449-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Laxman Dewangan Add DT support of the regulator driver output-supply. The supply names for this driver is provided through DT properties so that proper regulator(s) handle can be acquired. Board DT can configure the output-supply driver to * set regulator name * turn on at boot time * specific regulator handles that needs to be controlled by the driver. Post boot facilitate control of regulator(s) from sysfs. Signed-off-by: Laxman Dewangan Signed-off-by: Naresh Solanki --- drivers/regulator/userspace-consumer.c | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/use= rspace-consumer.c index 8ca28664776e..b424a0ddf582 100644 --- a/drivers/regulator/userspace-consumer.c +++ b/drivers/regulator/userspace-consumer.c @@ -18,6 +18,7 @@ #include #include #include +#include =20 struct userspace_consumer_data { const char *name; @@ -100,6 +101,40 @@ static const struct attribute_group attr_group =3D { .attrs =3D attributes, }; =20 +static struct regulator_userspace_consumer_data *get_pdata_from_dt_node( + struct platform_device *pdev) +{ + struct regulator_userspace_consumer_data *pdata; + struct device_node *np =3D pdev->dev.of_node; + struct property *prop; + const char *supply; + int num_supplies; + int count =3D 0; + + pdata =3D devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return ERR_PTR(-ENOMEM); + + pdata->name =3D of_get_property(np, "regulator-name", NULL); + pdata->init_on =3D of_property_read_bool(np, "regulator-boot-on"); + num_supplies =3D of_property_count_strings(np, "regulator-supplies"); + if (num_supplies < 0) { + dev_err(&pdev->dev, + "could not parse property regulator-supplies\n"); + return ERR_PTR(-EINVAL); + } + pdata->num_supplies =3D num_supplies; + pdata->supplies =3D devm_kzalloc(&pdev->dev, num_supplies * + sizeof(*pdata->supplies), GFP_KERNEL); + if (!pdata->supplies) + return ERR_PTR(-ENOMEM); + + of_property_for_each_string(np, "regulator-supplies", prop, supply) + pdata->supplies[count++].supply =3D supply; + + return pdata; +} + static int regulator_userspace_consumer_probe(struct platform_device *pdev) { struct regulator_userspace_consumer_data *pdata; @@ -107,6 +142,11 @@ static int regulator_userspace_consumer_probe(struct p= latform_device *pdev) int ret; =20 pdata =3D dev_get_platdata(&pdev->dev); + if (!pdata && pdev->dev.of_node) { + pdata =3D get_pdata_from_dt_node(pdev); + if (IS_ERR(pdata)) + return PTR_ERR(pdata); + } if (!pdata) return -EINVAL; =20 @@ -166,11 +206,18 @@ static int regulator_userspace_consumer_remove(struct= platform_device *pdev) return 0; } =20 +static const struct of_device_id regulator_userspace_consumer_of_match[] = =3D { + { .compatible =3D "9elements,output-supply", }, + {}, +}; +MODULE_DEVICE_TABLE(of, regulator_userspace_consumer_of_match); + static struct platform_driver regulator_userspace_consumer_driver =3D { .probe =3D regulator_userspace_consumer_probe, .remove =3D regulator_userspace_consumer_remove, .driver =3D { .name =3D "reg-userspace-consumer", + .of_match_table =3D regulator_userspace_consumer_of_match, }, }; =20 --=20 2.35.3 From nobody Sun Apr 19 02:12:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DAB4C43334 for ; Thu, 7 Jul 2022 08:21:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235500AbiGGIVF (ORCPT ); Thu, 7 Jul 2022 04:21:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235303AbiGGIUT (ORCPT ); Thu, 7 Jul 2022 04:20:19 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 398A24F64E for ; Thu, 7 Jul 2022 01:19:15 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id r18so22141567edb.9 for ; Thu, 07 Jul 2022 01:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xK6L9kQL/su+qUtSf+q4avn5i0/HUMQbVZpZK/zoTOQ=; b=TIQ4acE2XR+YDLnijnmuxoNvn/IXoCYF3tvh2p55MVItZZGqVDvlehlrnTjQdhPsL8 GgtlVkEptPTHBmPpTYW1cZWmm8UhayN0dN7GGWfvE6j4WsOKyAn3Xfz0T6sLBq1Q2zRX d094EZrlUe7reGHGv4BME4f9WPDTQXvHzdBSdWI+6zbKBVhwRX4/dt5gNaFPMe+JUcBr 06bqQarW2uI6Pn/kUqu1efXSUAtnjialv2TOyS3MGufB3gtZ+gPxAz6ipR7U8seOEgB1 y6KpVCN1BcwGbzkuJcoxbJ0XJ51m/GTw3tIepBftzSbv+jIy4ia/Ix2kkNgF/cf3fXYl Z2QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xK6L9kQL/su+qUtSf+q4avn5i0/HUMQbVZpZK/zoTOQ=; b=DkrKQtM8Lz8JhqxrIiiJv0jBV82oeYFrszov46Sz/R5ER3tBk5mdz165Igd5Qrjbkn aOS58pHwhTgYgyZ9N8/vUlyLEOx3CvEVs6mVGY36Mt0byBlO/bYY390Dmlv4ZAlG+6k0 Jh8/AeV6vTt9ViLZvq+4+cGtEdJRSJx6aARWi3l6qiJZrj2OSmGtbV4l9O71REIfT383 kCS5Ge8Vmp/5onCACZRpRsa3lHTGMMqbkRJtwUcl3texWAdQG9bhkOy6SfyaBMYbwfjj r4b7W35d9K4B2XKBvRVOaIjOJLxpu3m8922VkRXUXV5v8NsHO/YmuqlAtJmdtH+az6GI Ygfw== X-Gm-Message-State: AJIora9JgrEBU3E+26Rhx3cOmg3Yfzdhu6mLEt83wKM7O7fAsUZleuJM LFR5rT/d6GH8O/URsjTjCCkVaRfhU7B0qto3 X-Google-Smtp-Source: AGRyM1tIDL7TShlQb5VPGfvVkaMpDi6zcLKk1STvcR0DpWXiacRbz0pBhiu6c4MxsSOtUSMP7bXTOg== X-Received: by 2002:aa7:dcd5:0:b0:43a:70f7:8e4d with SMTP id w21-20020aa7dcd5000000b0043a70f78e4dmr21884954edu.85.1657181953398; Thu, 07 Jul 2022 01:19:13 -0700 (PDT) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id f13-20020a170906824d00b00726e108b566sm12871779ejx.173.2022.07.07.01.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 01:19:13 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: linux-kernel@vger.kernel.org, Liam Girdwood , Mark Brown Cc: Patrick Rudolph , Naresh Solanki Subject: [PATCH v4 4/4] regulator: output-supply: Add Notification support Date: Thu, 7 Jul 2022 10:18:26 +0200 Message-Id: <20220707081826.953449-5-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220707081826.953449-1-Naresh.Solanki@9elements.com> References: <20220707081826.953449-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Patrick Rudolph Add notification support to output-supply driver to receive regulator events. During runtime, regulator may encounter events like over/under voltage, over current etc. & its useful to report to userspace to take necessary corrective action. If sysfs notification is desired then that can be enabled using regulator-notify-enable property. This is very useful in situation wherein immediate responsive action needs to be taken upon receiving events & delayed response is not acceptable depending on criticality of the received event. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/regulator/userspace-consumer.c | 50 ++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/drivers/regulator/userspace-consumer.c b/drivers/regulator/use= rspace-consumer.c index b424a0ddf582..0cf2724b5c37 100644 --- a/drivers/regulator/userspace-consumer.c +++ b/drivers/regulator/userspace-consumer.c @@ -22,14 +22,33 @@ =20 struct userspace_consumer_data { const char *name; - + bool notify_enable; + struct notifier_block nb; struct mutex lock; bool enabled; + unsigned long events; + struct kobject *kobj; =20 int num_supplies; struct regulator_bulk_data *supplies; }; =20 +static DEFINE_MUTEX(events_lock); + +static ssize_t events_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct userspace_consumer_data *data =3D dev_get_drvdata(dev); + unsigned long e; + + mutex_lock(&events_lock); + e =3D data->events; + data->events =3D 0; + mutex_unlock(&events_lock); + + return sprintf(buf, "0x%lx\n", e); +} + static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -88,12 +107,14 @@ static ssize_t state_store(struct device *dev, struct = device_attribute *attr, return count; } =20 +static DEVICE_ATTR_RO(events); static DEVICE_ATTR_RO(name); static DEVICE_ATTR_RW(state); =20 static struct attribute *attributes[] =3D { &dev_attr_name.attr, &dev_attr_state.attr, + &dev_attr_events.attr, NULL, }; =20 @@ -101,6 +122,22 @@ static const struct attribute_group attr_group =3D { .attrs =3D attributes, }; =20 +static int regulator_userspace_notify(struct notifier_block *nb, + unsigned long event, + void *ignored) +{ + struct userspace_consumer_data *data =3D + container_of(nb, struct userspace_consumer_data, nb); + + mutex_lock(&events_lock); + data->events |=3D event; + mutex_unlock(&events_lock); + + sysfs_notify(data->kobj, NULL, dev_attr_events.attr.name); + + return NOTIFY_OK; +} + static struct regulator_userspace_consumer_data *get_pdata_from_dt_node( struct platform_device *pdev) { @@ -139,7 +176,7 @@ static int regulator_userspace_consumer_probe(struct pl= atform_device *pdev) { struct regulator_userspace_consumer_data *pdata; struct userspace_consumer_data *drvdata; - int ret; + int ret, i; =20 pdata =3D dev_get_platdata(&pdev->dev); if (!pdata && pdev->dev.of_node) { @@ -159,6 +196,7 @@ static int regulator_userspace_consumer_probe(struct pl= atform_device *pdev) drvdata->name =3D pdata->name; drvdata->num_supplies =3D pdata->num_supplies; drvdata->supplies =3D pdata->supplies; + drvdata->kobj =3D &pdev->dev.kobj; =20 mutex_init(&drvdata->lock); =20 @@ -183,7 +221,15 @@ static int regulator_userspace_consumer_probe(struct p= latform_device *pdev) } } =20 + drvdata->nb.notifier_call =3D regulator_userspace_notify; + for (i =3D 0; i < drvdata->num_supplies; i++) { + ret =3D devm_regulator_register_notifier(drvdata->supplies[i].consumer, = &drvdata->nb); + if (ret) + goto err_enable; + } + drvdata->enabled =3D pdata->init_on; + platform_set_drvdata(pdev, drvdata); =20 return 0; --=20 2.35.3