From patchwork Mon May 14 08:06:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135687 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1450988lji; Mon, 14 May 2018 01:19:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZownPDGq59P9+j+pCS41sIZ59dJ9d67KFw3GlxFkk1IgrJto2fGWlDzkR+COCsgLBn4rxr7 X-Received: by 2002:a62:c81d:: with SMTP id z29-v6mr9421101pff.81.1526285946343; Mon, 14 May 2018 01:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285946; cv=none; d=google.com; s=arc-20160816; b=F0T5EJdEL4b6ZMXQLbDC2ch4W2XNQioFhL61HPqnFvhZ8aTZ/fT0apI+4OL+WHJ9qL gUqBBuG4v6muUTEVOr2BJvJq4dYqwnk5Dxi+J7hPbaZZJ8LD3CS2y1yaD49opU+fwUx0 0Rceffad8DYog6vISZJyoNc/2UEjSPCx3dEx/NvOYH8kEIKv0hSKedNxpC0I42JAoDXF 4DQ0CLpPecj+x9yhdpooOILr61pDJDCrdM4ELJKsHKAsLpDaf1wIRNQuQ6Zr6Z+yXgIj /sS2CEvOJQxdy5ZJmhkSoll2XfKy9uIKrjmrZSd0FEh+lcY5jhfNRXNch+Pa9G0szeA6 ngLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Lv8XQeHbivqM8Htc4Jpt74dsyMGNPpWM5EmkQEbSzPo=; b=zBBJkeYZDAGGf5bMhQkT1DpU43bOujySqGB8CpuxV6mNq5U1hMJXDa0NMf55P5JA9B UmqL4XKM8ko7gGQ3EydkCqCBtmaeVMLF0DaSVRIoOe9HpMH0Kx8CjDjNBRknMEZLVI1Q RgysqSrcjCTsjRsKHVgaAWDEBZg03bp1nwrzhA09asHajAumel5/GYV6RL8J/TAxynlF BX+zaVQmjIy7GF7eTTuGgk+kdZzJjs83Eup/T9mzZ6L9iN/kf999Au5GMf6joXnvcEue KmmSAlG3wUbm1WB+6QL1GTYPBsZx1G/C3y5dQaJF1DU+Q1XwLnUterFpXR981RP7FiBN auNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pe25SOxO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t24-v6si9001757pfj.231.2018.05.14.01.19.06; Mon, 14 May 2018 01:19:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Pe25SOxO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752610AbeENITC (ORCPT + 29 others); Mon, 14 May 2018 04:19:02 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:38112 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbeENIG5 (ORCPT ); Mon, 14 May 2018 04:06:57 -0400 Received: by mail-lf0-f65.google.com with SMTP id z142-v6so16529066lff.5 for ; Mon, 14 May 2018 01:06:56 -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; bh=Lv8XQeHbivqM8Htc4Jpt74dsyMGNPpWM5EmkQEbSzPo=; b=Pe25SOxOx1cBlUSNfdEvKW+weXI7dOWUl43WSbQq7GBkI/QBAgcB5xWYdkn+3OEjp5 uzPUEyhF/3mbYvU7tjoP0cknXZTRaIjwPdmLFlLMwbZo5RE3iMSZMT1avskm7YQtAyeb UQqQ34UleKFrB17s8Z7gBm2t1+B/ItH6SGvOg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Lv8XQeHbivqM8Htc4Jpt74dsyMGNPpWM5EmkQEbSzPo=; b=ZwSxP9/t+jPWtAfe+wI8bekEF06vOp+ZLAB1TRHusx4RiE/uUmwya6artr7y1Lx/W8 dai85mNmm1YDcfz0JoH87ouop3ziYLxlS1ARoPeG2+vhS4tVlXZrSZ58fZeFlhPw0zIW egIrTosXe1tvqoNxwNh/btqXQ6+y5eexAya5ZVHrTgpdR1RymLi8OOBvrajiikss7Smc Cp22VUtAEvJ9DABQe5uN/YUNAD/Crlw4wRYgm01ve5D2UiKRlvmAKRoBPOwKRNZSQfUu 1+zGtZsmKbqJphdq/4Nx942RHp9y+Kobr+o+lNJwtLajJxFBUM/3LsaGj5dTo4xsa65V 1UBw== X-Gm-Message-State: ALKqPwd/vzeE8+oUx1OJJalUXBWOFGgMK9ds2svQIrZ5bKQq6R4urBu6 dQZ2JeLpk3UgBJd1uUg+bKxscT/JpXM= X-Received: by 2002:a19:5512:: with SMTP id n18-v6mr5494282lfe.24.1526285215419; Mon, 14 May 2018 01:06:55 -0700 (PDT) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s4-v6sm1725265ljh.9.2018.05.14.01.06.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:06:54 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij , Mikko Perttunen , Laxman Dewangan Subject: [PATCH 04/19 v3] regulator: max8973: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:25 +0200 Message-Id: <20180514080640.12515-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514080640.12515-1-linus.walleij@linaro.org> References: <20180514080640.12515-1-linus.walleij@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_optional() call. Cc: Mikko Perttunen Cc: Laxman Dewangan Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes. --- drivers/regulator/max8973-regulator.c | 54 ++++++++++++++------------- 1 file changed, 29 insertions(+), 25 deletions(-) -- 2.17.0 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index e0c747aa9f85..7cd493ec6315 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -114,7 +115,6 @@ struct max8973_chip { struct regulator_desc desc; struct regmap *regmap; bool enable_external_control; - int enable_gpio; int dvs_gpio; int lru_index[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG]; @@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt( pdata->enable_ext_control = of_property_read_bool(np, "maxim,externally-enable"); - pdata->enable_gpio = of_get_named_gpio(np, "maxim,enable-gpio", 0); pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); @@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client, struct max8973_chip *max; bool pdata_from_dt = false; unsigned int chip_id; + struct gpio_desc *gpiod; + enum gpiod_flags gflags; int ret; pdata = dev_get_platdata(&client->dev); @@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client, return -EIO; } - if ((pdata->dvs_gpio == -EPROBE_DEFER) || - (pdata->enable_gpio == -EPROBE_DEFER)) + if (pdata->dvs_gpio == -EPROBE_DEFER) return -EPROBE_DEFER; max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); @@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client, max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; - max->enable_gpio = (pdata->enable_gpio) ? pdata->enable_gpio : -EINVAL; max->enable_external_control = pdata->enable_ext_control; max->curr_gpio_val = pdata->dvs_def_state; max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; max->junction_temp_warning = pdata->junction_temp_warning; - if (gpio_is_valid(max->enable_gpio)) - max->enable_external_control = true; - max->lru_index[0] = max->curr_vout_reg; if (gpio_is_valid(max->dvs_gpio)) { @@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client, break; } - if (gpio_is_valid(max->enable_gpio)) { - config.ena_gpio_flags = GPIOF_OUT_INIT_LOW; - if (ridata && (ridata->constraints.always_on || - ridata->constraints.boot_on)) - config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; - config.ena_gpio = max->enable_gpio; + if (ridata && (ridata->constraints.always_on || + ridata->constraints.boot_on)) + gflags = GPIOD_OUT_HIGH; + else + gflags = GPIOD_OUT_LOW; + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + gflags); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) { + config.ena_gpiod = gpiod; + max->enable_external_control = true; } + break; case MAX77621: - if (gpio_is_valid(max->enable_gpio)) { - ret = devm_gpio_request_one(&client->dev, - max->enable_gpio, GPIOF_OUT_INIT_HIGH, - "max8973-en-gpio"); - if (ret) { - dev_err(&client->dev, - "gpio_request for gpio %d failed: %d\n", - max->enable_gpio, ret); - return ret; - } - } + /* + * We do not let the core switch this regulator on/off, + * we just leave it on. + */ + gpiod = devm_gpiod_get_optional(&client->dev, + "maxim,enable", + GPIOD_OUT_HIGH); + if (IS_ERR(gpiod)) + return PTR_ERR(gpiod); + if (gpiod) + max->enable_external_control = true; max->desc.enable_reg = MAX8973_VOUT; max->desc.enable_mask = MAX8973_VOUT_ENABLE;