From patchwork Mon May 14 08:06:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 135672 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1439374lji; Mon, 14 May 2018 01:07:19 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoHRTNd09usmzNPy6p8uOLXEbMI/Igq+P/qfD9Fmby2K0HCNLpnMyQs4UvyzIRTUwqvvnaY X-Received: by 2002:a63:3147:: with SMTP id x68-v6mr7649746pgx.108.1526285239418; Mon, 14 May 2018 01:07:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526285239; cv=none; d=google.com; s=arc-20160816; b=w36BvmE3wg9qY2wbgngkrW9bk73QVNokW0UhEVhYzL+6ybQQtDBI+vSTvlcsFZf4+1 PZP0rUHb0GVnRX3UCPa9Wt0cL3rXKQYhLxR4MTueFpN4G9sOZ4J6LtPNDTEwy0kpNsh4 ekBmmPfDN0lGV1N+gSRnkBzNxBf6mRWReni/c+DnGkH/K0xv+FeWvGFeyjN9NRJDCFxS yzGgOkOKlqsP5u3WzryrlqPajF2Jbzos4ht6XLWmaYmZhXTYGF/N8a35myRYYqb7spC9 ShIpIJnOaigUu5P4A8SVrIe4//atqMGBiHPXwW/nsl7DAssXr4X3BTQzvCejDXa1Rxuc D0gQ== 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=quDZtySXfJOs616epPN65aj3CIviuTNYlmMPcg+2TJk=; b=GhOa3sFPfc7wqSvQL2lWz0m1Pr+F2IgEk/pXY1ussC/xiVna08iGdZI3a3PMllXgx+ Hj08UgcY4AJfhpQWuKG9oz4puMzXZsZxJoURi5fEwzCuyedZPwwPNIQgTPC+dQHf47yB yos3OGAxWQRYfcVD99h5Vcd3UAEDRRYZMgoDtiTk265/2qqgW/pl2mt+qs0796qg52eS SPk4bXH/qvojEMAJo9WaDYz8nGHMIFp/NZxOEH6Ik4e2nayCTt5jmrjB19ODvlTVh/YV oYCMwURD+kbfK8fFnHZ/sAaGqteFuVsFkG45OaH2UBr8sbqoBm+tNcW2QZMf+pcC8bG+ y+qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MnAmo37h; 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 z6-v6si8978027pfk.194.2018.05.14.01.07.19; Mon, 14 May 2018 01:07:19 -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=MnAmo37h; 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 S1752250AbeENIHQ (ORCPT + 29 others); Mon, 14 May 2018 04:07:16 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:41495 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752215AbeENIHN (ORCPT ); Mon, 14 May 2018 04:07:13 -0400 Received: by mail-lf0-f67.google.com with SMTP id m17-v6so11388444lfj.8 for ; Mon, 14 May 2018 01:07:12 -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=quDZtySXfJOs616epPN65aj3CIviuTNYlmMPcg+2TJk=; b=MnAmo37hC/kkWYOfvZ3NvEpcLCsgZZcwToTCB1CmmRUOHbhHDNy2nWkxZUpeaW04ls ilU1Oz7VPbAfjdRmwlvyWsiwUNyeaJxwitRD30LekiH60ONzlXk/tVUKEUgIZWRtHn+x OKdC4kjDH0GRfQITiOLTQwACHOndeKPY8DVNk= 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=quDZtySXfJOs616epPN65aj3CIviuTNYlmMPcg+2TJk=; b=MmfEhY3vatGU+JrCVZ1Z59/w0+nEz9baw8tr/VTnDo83UpfxLBlBIH6gcs6k6iwBmg GRrj8VvUuepn9x1Bc4S1TsaEFsBm7jOpaaN5YYl6vIsxY52YhDv9KNLXsZV0wxXBO5Bs TFlbyWlC8/9Syp6HuNR9P52uhJHGZv1rcPYat2JBR65qwpvE7D89tCITKtLS3+ncdPPH U5cP+v3XTU9/Vu5embspv/mtwoA4TSJlHAiZB8/q1XJZ4d2qJoFEExLZ6oLN5lrMEUik daveXyOswEzA/bwnRAgwSPhro+yX01MMI/r370xAkI2udEdTLlOxbiwftgAKx2wRjVSb xrvw== X-Gm-Message-State: ALKqPweNFjkHBsmHouTqXz94xn6erIhyLNth6Rc+Kmaj4S+L+Gng6yO9 U3FQEwlk5uMNtrw2eYWpveyfzw== X-Received: by 2002:a19:63d7:: with SMTP id v84-v6mr8149767lfi.57.1526285231708; Mon, 14 May 2018 01:07:11 -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.07.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 14 May 2018 01:07:10 -0700 (PDT) From: Linus Walleij To: Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 11/19 v3] regulator: s5m8767: Pass descriptor instead of GPIO number Date: Mon, 14 May 2018 10:06:32 +0200 Message-Id: <20180514080640.12515-12-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 for the enable GPIO, pass a descriptor looked up from the device tree node for the regulator. This regulator supports passing platform data, but enable/sleep regulators are looked up from the device tree exclusively, so we can need not touch other files. Acked-by: Lee Jones Signed-off-by: Linus Walleij --- ChangeLog v2->v3: - Resending. ChangeLog v1->v2: - Rebase the patch on the other changes - Collect Lee's ACK. --- drivers/regulator/s5m8767.c | 26 +++++++++++++++----------- include/linux/mfd/samsung/core.h | 4 +++- 2 files changed, 18 insertions(+), 12 deletions(-) -- 2.17.0 diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 4836947e1521..b8443a360646 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, return; } - if (!gpio_is_valid(rdata->ext_control_gpio)) { + if (!rdata->ext_control_gpiod) { dev_warn(s5m8767->dev, "ext-control for %s: GPIO not valid, ignoring\n", - rdata->reg_node->name); + rdata->reg_node->name); return; } - config->ena_gpio = rdata->ext_control_gpio; - config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH; + config->ena_gpiod = rdata->ext_control_gpiod; } /* @@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, continue; } - rdata->ext_control_gpio = of_get_named_gpio(reg_np, - "s5m8767,pmic-ext-control-gpios", 0); + rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(&pdev->dev, + reg_np, + "s5m8767,pmic-ext-control-gpios", + 0, + GPIOD_OUT_HIGH, + "s5m8767"); + if (IS_ERR(rdata->ext_control_gpiod)) + return PTR_ERR(rdata->ext_control_gpiod); rdata->id = i; rdata->initdata = of_get_regulator_init_data( @@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) config.driver_data = s5m8767; config.regmap = iodev->regmap_pmic; config.of_node = pdata->regulators[i].reg_node; - config.ena_gpio = -EINVAL; - config.ena_gpio_flags = 0; - config.ena_gpio_initialized = true; - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) + config.ena_gpiod = NULL; + if (pdata->regulators[i].ext_control_gpiod) s5m8767_regulator_config_ext_control(s5m8767, &pdata->regulators[i], &config); @@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) return ret; } - if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { + if (pdata->regulators[i].ext_control_gpiod) { ret = s5m8767_enable_ext_control(s5m8767, rdev); if (ret < 0) { dev_err(s5m8767->dev, diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index 5a23dd4df432..28f4ae76271d 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h @@ -39,6 +39,8 @@ #define STEP_12_5_MV 12500 #define STEP_6_25_MV 6250 +struct gpio_desc; + enum sec_device_type { S5M8751X, S5M8763X, @@ -151,7 +153,7 @@ struct sec_regulator_data { int id; struct regulator_init_data *initdata; struct device_node *reg_node; - int ext_control_gpio; + struct gpio_desc *ext_control_gpiod; }; /*