From patchwork Thu May 24 19:14:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 920075 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sirena.org.uk header.i=@sirena.org.uk header.b="Sh+ud3aC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40sJx224V4z9s1b for ; Fri, 25 May 2018 05:15:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034480AbeEXTPA (ORCPT ); Thu, 24 May 2018 15:15:00 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:56322 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967783AbeEXTOS (ORCPT ); Thu, 24 May 2018 15:14:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=s4p8MntwD6P2FWLLhLx4xFjAKFCLhzQ/W8Uyir+MjX0=; b=Sh+ud3aCaqOh HFOEBT9Vv+5jRscbbu7EbNtOEoP6KbTMCOExkq61kLSKkCPHtN+7Lm8oAFGAs6sZNi4mJ/dujvZRm g2NYyj+TOmDgI0JMFt4dKxtMq/q/tNtxS6Vptqs4d66Z/J24u7QvaV5C4pe70rTcskn8E3MVBpq82 g4TuM=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fLvgk-0006LC-M7; Thu, 24 May 2018 19:14:14 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fLvgk-0005nX-69; Thu, 24 May 2018 20:14:14 +0100 From: Mark Brown To: Linus Walleij Cc: Lee Jones , Mark Brown , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Milo Kim , Lee Jones , linux-kernel@vger.kernel.org Subject: Applied "regulator: lp8788-ldo: Pass descriptor instead of GPIO number" to the regulator tree In-Reply-To: <20180212131717.27193-11-linus.walleij@linaro.org> Message-Id: Date: Thu, 24 May 2018 20:14:14 +0100 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org The patch regulator: lp8788-ldo: Pass descriptor instead of GPIO number has been applied to the regulator tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark From 2468f0d51548b23507ceb3bba5f4e3acaea117ba Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Mon, 14 May 2018 10:06:28 +0200 Subject: [PATCH] regulator: lp8788-ldo: Pass descriptor instead of GPIO number Instead of passing a global GPIO number, pass a descriptor looked up with the standard devm_gpiod_get_index_optional() call. This driver has supported passing a LDO enable GPIO for years, yet this facility has never been put to use in the upstream kernel. If someone desires to put in place GPIO control for the LDOs, this can be done by adding a GPIO descriptor table in the MFD nexus in drivers/mfd/lp8788.c for the LDO device when spawning the MFD children, or using a board file. Signed-off-by: Linus Walleij Acked-by: Lee Jones Signed-off-by: Mark Brown --- drivers/regulator/lp8788-ldo.c | 32 ++++++++++++++++---------------- include/linux/mfd/lp8788.h | 16 ---------------- 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c index cbfd35873575..f2347474a106 100644 --- a/drivers/regulator/lp8788-ldo.c +++ b/drivers/regulator/lp8788-ldo.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include /* register address */ @@ -85,8 +85,6 @@ #define LP8788_STARTUP_TIME_S 3 #define ENABLE_TIME_USEC 32 -#define ENABLE GPIOF_OUT_INIT_HIGH -#define DISABLE GPIOF_OUT_INIT_LOW enum lp8788_ldo_id { DLDO1, @@ -117,7 +115,7 @@ struct lp8788_ldo { struct lp8788 *lp; struct regulator_desc *desc; struct regulator_dev *regulator; - struct lp8788_ldo_enable_pin *en_pin; + struct gpio_desc *ena_gpiod; }; /* DLDO 1, 2, 3, 9 voltage table */ @@ -469,7 +467,6 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, enum lp8788_ldo_id id) { struct lp8788 *lp = ldo->lp; - struct lp8788_platform_data *pdata = lp->pdata; enum lp8788_ext_ldo_en_id enable_id; u8 en_mask[] = { [EN_ALDO1] = LP8788_EN_SEL_ALDO1_M, @@ -504,11 +501,18 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, return 0; } - /* if no platform data for ldo pin, then set default enable mode */ - if (!pdata || !pdata->ldo_pin || !pdata->ldo_pin[enable_id]) + /* FIXME: check default mode for GPIO here: high or low? */ + ldo->ena_gpiod = devm_gpiod_get_index_optional(&pdev->dev, + "enable", + enable_id, + GPIOD_OUT_HIGH); + if (IS_ERR(ldo->ena_gpiod)) + return PTR_ERR(ldo->ena_gpiod); + + /* if no GPIO for ldo pin, then set default enable mode */ + if (!ldo->ena_gpiod) goto set_default_ldo_enable_mode; - ldo->en_pin = pdata->ldo_pin[enable_id]; return 0; set_default_ldo_enable_mode: @@ -533,10 +537,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev) if (ret) return ret; - if (ldo->en_pin) { - cfg.ena_gpio = ldo->en_pin->gpio; - cfg.ena_gpio_flags = ldo->en_pin->init_state; - } + if (ldo->ena_gpiod) + cfg.ena_gpiod = ldo->ena_gpiod; cfg.dev = pdev->dev.parent; cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL; @@ -582,10 +584,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev) if (ret) return ret; - if (ldo->en_pin) { - cfg.ena_gpio = ldo->en_pin->gpio; - cfg.ena_gpio_flags = ldo->en_pin->init_state; - } + if (ldo->ena_gpiod) + cfg.ena_gpiod = ldo->ena_gpiod; cfg.dev = pdev->dev.parent; cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL; diff --git a/include/linux/mfd/lp8788.h b/include/linux/mfd/lp8788.h index 786bf6679a28..2010e0de3e34 100644 --- a/include/linux/mfd/lp8788.h +++ b/include/linux/mfd/lp8788.h @@ -181,20 +181,6 @@ struct lp8788_buck2_dvs { enum lp8788_dvs_sel vsel; }; -/* - * struct lp8788_ldo_enable_pin - * - * Basically, all LDOs are enabled through the I2C commands. - * But ALDO 1 ~ 5, 7, DLDO 7, 9, 11 can be enabled by external gpio pins. - * - * @gpio : gpio number which is used for enabling ldos - * @init_state : initial gpio state (ex. GPIOF_OUT_INIT_LOW) - */ -struct lp8788_ldo_enable_pin { - int gpio; - int init_state; -}; - /* * struct lp8788_chg_param * @addr : charging control register address (range : 0x11 ~ 0x1C) @@ -288,7 +274,6 @@ struct lp8788_vib_platform_data { * @aldo_data : regulator initial data for analog ldo * @buck1_dvs : gpio configurations for buck1 dvs * @buck2_dvs : gpio configurations for buck2 dvs - * @ldo_pin : gpio configurations for enabling LDOs * @chg_pdata : platform data for charger driver * @alarm_sel : rtc alarm selection (1 or 2) * @bl_pdata : configurable data for backlight driver @@ -306,7 +291,6 @@ struct lp8788_platform_data { struct regulator_init_data *aldo_data[LP8788_NUM_ALDOS]; struct lp8788_buck1_dvs *buck1_dvs; struct lp8788_buck2_dvs *buck2_dvs; - struct lp8788_ldo_enable_pin *ldo_pin[EN_LDOS_MAX]; /* charger */ struct lp8788_charger_platform_data *chg_pdata;