From patchwork Mon Mar 20 14:22:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 665430 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 303D9C6FD1D for ; Mon, 20 Mar 2023 14:22:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231466AbjCTOWn (ORCPT ); Mon, 20 Mar 2023 10:22:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231219AbjCTOWl (ORCPT ); Mon, 20 Mar 2023 10:22:41 -0400 Received: from mail-0301.mail-europe.com (mail-0301.mail-europe.com [188.165.51.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A26F42200D for ; Mon, 20 Mar 2023 07:22:37 -0700 (PDT) Date: Mon, 20 Mar 2023 14:22:20 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1679322154; x=1679581354; bh=PyBkroZpp5Idh5EiLvqP12MWQHI/I6jk1Thl/HtlRy0=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=q2mL4lvgqq6/UT0kzVkGmepQtIBR6RAoGnxho6bvKGLlC4mnjndRTyRybHHjkrQG9 o3/KldHRayXXuqnvLQWQNJEuS0hX722OevRqQksAJ7Dj/Tmv+UBcmjjJGSsvjb+e3B BSxTABGUPWgHtLcgChRVgth7FvhxLgwf2ncmf7YSw8UzuXN9Jvh1WSJwKjF7yeST21 kEp1TTmxo/zZXvjexnHrXq1SHs9pnpKn5CohBY9Kv6UrGQ3FPDWfhux0OCQlaCh++l QhR+Jgad6PLbRbBq0pY6wyQ4myRQT7qygFd3qNEo2fOvu8OHbgecHZpMEyw8N1gBW5 hpXXhAuZahOpw== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Nikita Travkin , Stephan Gerhold , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH 1/2] dt-bindings: leds: aw2013: Document vdd-supply Message-ID: <20230320142103.3440-1-linmengbo0689@protonmail.com> In-Reply-To: <20230320141638.3378-1-linmengbo0689@protonmail.com> References: <20230320141638.3378-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Document vdd-supply, a regulator providing power to the "VDD" pin. Signed-off-by: Lin, Meng-Bo --- Documentation/devicetree/bindings/leds/leds-aw2013.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/leds/leds-aw2013.yaml b/Documentation/devicetree/bindings/leds/leds-aw2013.yaml index 08f3e1cfc1b1..51a58f4b8ed6 100644 --- a/Documentation/devicetree/bindings/leds/leds-aw2013.yaml +++ b/Documentation/devicetree/bindings/leds/leds-aw2013.yaml @@ -23,6 +23,9 @@ properties: vcc-supply: description: Regulator providing power to the "VCC" pin. + vdd-supply: + description: Regulator providing power to the "VDD" pin. + "#address-cells": const: 1 From patchwork Mon Mar 20 14:22:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lin, Meng-Bo" X-Patchwork-Id: 666012 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 27AB1C6FD1D for ; Mon, 20 Mar 2023 14:23:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231523AbjCTOXF (ORCPT ); Mon, 20 Mar 2023 10:23:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231466AbjCTOXD (ORCPT ); Mon, 20 Mar 2023 10:23:03 -0400 X-Greylist: delayed 141 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 20 Mar 2023 07:22:57 PDT Received: from mail-40140.protonmail.ch (mail-40140.protonmail.ch [185.70.40.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0627A5E9 for ; Mon, 20 Mar 2023 07:22:57 -0700 (PDT) Date: Mon, 20 Mar 2023 14:22:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1679322175; x=1679581375; bh=hnNQw8IGieeGXczUkQFigxPqYaJQ3wX8rs+fIziAfsA=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=cFCg2QVgznqVtFP9eEgtD2O96s0VDDWHNQ0clkXOHyio208BE1CMPBFTq4FxwqAQd DgPGzeubXAFZXrfzVtVoI6RuU8pSHhSw4ylAt4cENkTCqaxziMWT9VxFi3cd8pAwC5 iZfknvxU4Lc9+h7rpdHZIjSi2+BhCdjILweF8oOS4SQPDkylWbOxfBwJ2RPcZDI8PZ p7TXOfLVGNPJ+TgPBMhK5Iscjv0ckxSNJc2wZlOP7lM/9O+amqmFDm0O4ByYFxJkp1 C6CZafVjnJ7fyFscCLtxZufKA5kUkAB4rQ86uVxcNwGHjSU9CO2VqIjd3nhJfBmAmB kBdNVB6qyz1rg== To: linux-kernel@vger.kernel.org From: "Lin, Meng-Bo" Cc: Pavel Machek , Lee Jones , Rob Herring , Krzysztof Kozlowski , Nikita Travkin , Stephan Gerhold , linux-leds@vger.kernel.org, devicetree@vger.kernel.org, ~postmarketos/upstreaming@lists.sr.ht Subject: [PATCH 2/2] leds: aw2013: Add vdd regulator Message-ID: <20230320142116.3494-1-linmengbo0689@protonmail.com> In-Reply-To: <20230320141638.3378-1-linmengbo0689@protonmail.com> References: <20230320141638.3378-1-linmengbo0689@protonmail.com> Feedback-ID: 40467236:user:proton MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-leds@vger.kernel.org Implement support for a "vdd" that is enabled by the aw2013 driver so that the regulator gets enabled when needed. Signed-off-by: Lin, Meng-Bo --- drivers/leds/leds-aw2013.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 0b52fc9097c6..91d720edb857 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -62,7 +62,7 @@ struct aw2013_led { struct aw2013 { struct mutex mutex; /* held when writing to registers */ - struct regulator *vcc_regulator; + struct regulator_bulk_data regulators[2]; struct i2c_client *client; struct aw2013_led leds[AW2013_MAX_LEDS]; struct regmap *regmap; @@ -106,7 +106,8 @@ static void aw2013_chip_disable(struct aw2013 *chip) regmap_write(chip->regmap, AW2013_GCR, 0); - ret = regulator_disable(chip->vcc_regulator); + ret = regulator_bulk_disable(ARRAY_SIZE(chip->regulators), + chip->regulators); if (ret) { dev_err(&chip->client->dev, "Failed to disable regulator: %d\n", ret); @@ -123,7 +124,8 @@ static int aw2013_chip_enable(struct aw2013 *chip) if (chip->enabled) return 0; - ret = regulator_enable(chip->vcc_regulator); + ret = regulator_bulk_enable(ARRAY_SIZE(chip->regulators), + chip->regulators); if (ret) { dev_err(&chip->client->dev, "Failed to enable regulator: %d\n", ret); @@ -348,16 +350,20 @@ static int aw2013_probe(struct i2c_client *client) goto error; } - chip->vcc_regulator = devm_regulator_get(&client->dev, "vcc"); - ret = PTR_ERR_OR_ZERO(chip->vcc_regulator); - if (ret) { + chip->regulators[0].supply = "vcc"; + chip->regulators[1].supply = "vdd"; + ret = devm_regulator_bulk_get(&client->dev, + ARRAY_SIZE(chip->regulators), + chip->regulators); + if (ret < 0) { if (ret != -EPROBE_DEFER) dev_err(&client->dev, "Failed to request regulator: %d\n", ret); goto error; } - ret = regulator_enable(chip->vcc_regulator); + ret = regulator_bulk_enable(ARRAY_SIZE(chip->regulators), + chip->regulators); if (ret) { dev_err(&client->dev, "Failed to enable regulator: %d\n", ret); @@ -382,7 +388,8 @@ static int aw2013_probe(struct i2c_client *client) if (ret < 0) goto error_reg; - ret = regulator_disable(chip->vcc_regulator); + ret = regulator_bulk_disable(ARRAY_SIZE(chip->regulators), + chip->regulators); if (ret) { dev_err(&client->dev, "Failed to disable regulator: %d\n", ret); @@ -394,7 +401,8 @@ static int aw2013_probe(struct i2c_client *client) return 0; error_reg: - regulator_disable(chip->vcc_regulator); + regulator_bulk_disable(ARRAY_SIZE(chip->regulators), + chip->regulators); error: mutex_destroy(&chip->mutex);