From patchwork Fri Apr 1 15:42:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 555712 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 ACA1BC4332F for ; Fri, 1 Apr 2022 16:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349150AbiDAQV0 (ORCPT ); Fri, 1 Apr 2022 12:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353011AbiDAQSa (ORCPT ); Fri, 1 Apr 2022 12:18:30 -0400 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56CAB20A393 for ; Fri, 1 Apr 2022 08:42:45 -0700 (PDT) Received: by mail-ej1-x62b.google.com with SMTP id j15so6641615eje.9 for ; Fri, 01 Apr 2022 08:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lvLYetfC0M8ee2ZpgnCvvT8BGE0UJGsuIlJ++425c5Q=; b=PJLevIDANrLODu8fBXwyylwK97oTmcegFajjWWGAZOm7niuglbhgOpzthyJV4IGp01 aN9FM2b/uD2BS4esIiMsfm1CDjdsxhppDuCcAoJiv+jcRWMSt3Yim5gpcx9sAoTOpsr4 3jU4aKR965lWuxySpybk6bQjcsLq0orOa9I2KhhwMy8WC1Wt1IMmumuocBuAbuIFPrEQ KFXwtaS5EbO81nVg4AOEb09BpAaEMBYwlxBLE1DmGhFagM839RjR/7c3dAJU4QEwJ2cW ToJ3JOkX5w5b4fGpxixqtINo7nMiZcgf2XK6PIsWHmwujtQqciUrbKlnwehnyVTsaTTi aUag== 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=lvLYetfC0M8ee2ZpgnCvvT8BGE0UJGsuIlJ++425c5Q=; b=5+a2jxNygg9LeyfOJFqD7LMqOvk1X7auZmrCBPqIlxhw85FNZH+8GEeizerx74CwAA 20ouu3IyxrkEceLtwk3BUPe7gEZSv75qz7IRjVnY6/M/Dmn0eUi9gJbX0bfeSU4CtS+s txb2Vh7G9wNWARtYAPbkoRC6AL3ULQrG717m16pe8yteiBbEarwIRtAVm10cDTyGGINe 6YMlXRKwUM+UURtPvyZJClhNFT60qDY2JBVdl2SCT3DJklOlgtIJtLvZmH2n4uCD7nma MMwlBFa/KBULJXJlNP+OjCf87rSQI5cOfM1AHrJ7rH5W/IxtifvuieywvS+qUB/Hle7X 042A== X-Gm-Message-State: AOAM532uEYfM/EjYjzgetAquZ++vmS5FLXdiZAakaOR1ubZEgqbmbmHa N0lLX7Jy7vL6vUxy6gNnM62VNQ== X-Google-Smtp-Source: ABdhPJx4V0qZLEwhvDCy4+cT0n9AkXUO/yzATDyh4tBTtpxZS5WH0DrunhCmOHIu7kIIBGw3uJgdug== X-Received: by 2002:a17:907:270a:b0:6e4:86a4:9b09 with SMTP id w10-20020a170907270a00b006e486a49b09mr354177ejk.23.1648827763561; Fri, 01 Apr 2022 08:42:43 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-201-27.adslplus.ch. [188.155.201.27]) by smtp.gmail.com with ESMTPSA id k12-20020aa7c38c000000b0041939d9ccd0sm1300389edq.81.2022.04.01.08.42.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 08:42:43 -0700 (PDT) From: Krzysztof Kozlowski To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , ChiYuan Huang , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RFT PATCH 1/2] regulator: dt-bindings: richtek, rt4801: use existing ena_gpiod feature Date: Fri, 1 Apr 2022 17:42:36 +0200 Message-Id: <20220401154237.1061331-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220401154237.1061331-1-krzysztof.kozlowski@linaro.org> References: <20220401154237.1061331-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The binding and driver duplicated regulator core feature of controlling regulators with GPIOs (of_parse_cb + ena_gpiod) and created its own enable-gpios property with multiple GPIOs. This is a less preferred way, because enable-gpios should enable only one element, not multiple. It also duplicates existing solution. Deprecate the original 'enable-gpios' and add per-regulator property. Signed-off-by: Krzysztof Kozlowski --- .../regulator/richtek,rt4801-regulator.yaml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml b/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml index 4a4dfa7d9d09..091150c4e579 100644 --- a/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml +++ b/Documentation/devicetree/bindings/regulator/richtek,rt4801-regulator.yaml @@ -32,8 +32,11 @@ properties: If only one gpio is specified, only one gpio used to control ENP/ENM. Else if both are specified, DSVP/DSVN could be controlled individually. If this property not specified, treat both as always-on regulators. + + Property is deprecated. Use enable-gpios in each regulator. minItems: 1 maxItems: 2 + deprecated: true patternProperties: "^DSV(P|N)$": @@ -42,6 +45,14 @@ patternProperties: description: Properties for single display bias regulator. + properties: + enable-gpios: + description: + GPIO to use to enable DSVP/DSVN regulator. One GPIO can be configured + for controlling both regulators. If this property not specified for + any regulator, treat both as always-on regulators. + maxItems: 1 + required: - compatible - reg @@ -57,19 +68,20 @@ examples: rt4801@73 { compatible = "richtek,rt4801"; reg = <0x73>; - enable-gpios = <&gpio26 2 0>, <&gpio26 3 0>; dsvp: DSVP { regulator-name = "rt4801,dsvp"; regulator-min-microvolt = <4000000>; regulator-max-microvolt = <6000000>; regulator-boot-on; + enable-gpios = <&gpio26 2 0>; }; dsvn: DSVN { regulator-name = "rt4801,dsvn"; regulator-min-microvolt = <4000000>; regulator-max-microvolt = <6000000>; regulator-boot-on; + enable-gpios = <&gpio26 3 0>; }; }; From patchwork Fri Apr 1 15:42:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 555713 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 322E0C433FE for ; Fri, 1 Apr 2022 16:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235970AbiDAQVW (ORCPT ); Fri, 1 Apr 2022 12:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353037AbiDAQSb (ORCPT ); Fri, 1 Apr 2022 12:18:31 -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 BE636160441 for ; Fri, 1 Apr 2022 08:42:48 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id c62so3421800edf.5 for ; Fri, 01 Apr 2022 08:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2QTzX8NPjEsC6DS75wIUIMoC9k1vEC4KyMC77JEhWDI=; b=ZwrA4adlvd2jCKD+i2qTWQ+0Q+XRKQFMEpNXkQuuaaIBGVDtcTE5BG6R8bw+4A/T5K z7FBj3jQO5clDqB8kO9ADJvJmOe7l3++ImLeqcXCg/Dg1Y2vyF5Exj1duWxm+LRaf/Ar sSSDC2il/RbQn4SUibUh9YMUrEOhGnEaX7ppeY4sLFz83nPBDl5/ho8zJRuORN6QST6Y EWJWb6OKinyk1m/qH9NF9YLX97cM5Owfa8/c/qNMctYHjXHwEoGzAqR/ymNbvJqUxvrB pPFPTmeHZnht3QcelJ7yIF1Z1lZcyWuwlUtnuyUpMJBJ2l7cAGaTiJOzixiONP7t9sbn cbAw== 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=2QTzX8NPjEsC6DS75wIUIMoC9k1vEC4KyMC77JEhWDI=; b=QO1f1L0iMLq0KRGvIRZhGbil5Hl1RQotlAr8Ii5ABCXif8GTrmoVbY7vEXu0YaOuJq g7iVXh1OLe4tvPKBzzH+o27d4QQ5kXgZhHpTWPbzPM5qQXvwWqgAKcKsALpa6Qmql5QE SMRJTB+V56bfsZAcD1LYerLt89b14/mmzPlH7U3+aikFaE44ChCtleDzz8G1SHM3O2IY How5W1uRyoFEeXr1pxKsS4Tbl7lk4B6Oq/mJo49XSu7ECF8lMSkICBmnTYEXkmcgx1SV rMLwKJ0P0LjlGG57AzWXuk7J8weXwsvxLalImvP2l79l1QCnhod5A/REdD8dx2DlxsYy kpGQ== X-Gm-Message-State: AOAM533/j42O1Rpwb9/G4no2s+j4mT+Talk55fHjI5Wc1/WCCi4YvXk+ 8iLuRttCj1Ry+Z5XHLyiPReC2A== X-Google-Smtp-Source: ABdhPJz4QLYcHdtlV6CyLehrbFSvfS4BABdJhNxxEnOBbddowD6iYsBt3lWTTfhts8yTv0s23ycmog== X-Received: by 2002:a50:ab16:0:b0:414:39b0:7fc1 with SMTP id s22-20020a50ab16000000b0041439b07fc1mr21423933edc.214.1648827764784; Fri, 01 Apr 2022 08:42:44 -0700 (PDT) Received: from localhost.localdomain (xdsl-188-155-201-27.adslplus.ch. [188.155.201.27]) by smtp.gmail.com with ESMTPSA id k12-20020aa7c38c000000b0041939d9ccd0sm1300389edq.81.2022.04.01.08.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Apr 2022 08:42:44 -0700 (PDT) From: Krzysztof Kozlowski To: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , ChiYuan Huang , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Cc: Krzysztof Kozlowski Subject: [RFT PATCH 2/2] regulator: richtek,rt4801: use existing ena_gpiod feature Date: Fri, 1 Apr 2022 17:42:37 +0200 Message-Id: <20220401154237.1061331-3-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220401154237.1061331-1-krzysztof.kozlowski@linaro.org> References: <20220401154237.1061331-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The driver duplicated regulator core feature of controlling regulators with GPIOs (of_parse_cb + ena_gpiod) and created its own enable-gpios property with multiple GPIOs. The core already does it. Keep old method for backwards compatibility. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/rt4801-regulator.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/regulator/rt4801-regulator.c b/drivers/regulator/rt4801-regulator.c index 7a87788d3f09..9d88b7858a21 100644 --- a/drivers/regulator/rt4801-regulator.c +++ b/drivers/regulator/rt4801-regulator.c @@ -34,6 +34,28 @@ struct rt4801_priv { unsigned int volt_sel[DSV_OUT_MAX]; }; +static int rt4801_of_parse_cb(struct device_node *np, + const struct regulator_desc *desc, + struct regulator_config *config) +{ + struct rt4801_priv *priv = config->driver_data; + + if (priv->enable_gpios) { + dev_warn(priv->dev, "duplicated enable-gpios property\n"); + return 0; + } + config->ena_gpiod = fwnode_gpiod_get_index(of_fwnode_handle(np), + "enable-gpios", + 0, + GPIOD_OUT_HIGH | + GPIOD_FLAGS_BIT_NONEXCLUSIVE, + "rt4801"); + if (IS_ERR(config->ena_gpiod)) + config->ena_gpiod = NULL; + + return 0; +} + static int rt4801_set_voltage_sel(struct regulator_dev *rdev, unsigned int selector) { struct rt4801_priv *priv = rdev_get_drvdata(rdev); @@ -122,6 +144,7 @@ static const struct regulator_desc rt4801_regulator_descs[] = { .name = "DSVP", .ops = &rt4801_regulator_ops, .of_match = of_match_ptr("DSVP"), + .of_parse_cb = rt4801_of_parse_cb, .type = REGULATOR_VOLTAGE, .id = DSV_OUT_POS, .min_uV = MIN_UV, @@ -135,6 +158,7 @@ static const struct regulator_desc rt4801_regulator_descs[] = { .name = "DSVN", .ops = &rt4801_regulator_ops, .of_match = of_match_ptr("DSVN"), + .of_parse_cb = rt4801_of_parse_cb, .type = REGULATOR_VOLTAGE, .id = DSV_OUT_NEG, .min_uV = MIN_UV,