From patchwork Tue Apr 25 15:46:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 9698663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DBEA60224 for ; Tue, 25 Apr 2017 15:47:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DB1B2846D for ; Tue, 25 Apr 2017 15:47:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1287928649; Tue, 25 Apr 2017 15:47:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95EB12846D for ; Tue, 25 Apr 2017 15:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1951007AbdDYPrz (ORCPT ); Tue, 25 Apr 2017 11:47:55 -0400 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:33708 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1950895AbdDYPqp (ORCPT ); Tue, 25 Apr 2017 11:46:45 -0400 Received: from [2001:470:1f1d:6b5::3] (helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d32fR-0000qL-J5; Tue, 25 Apr 2017 15:46:25 +0000 Received: from broonie by debutante with local (Exim 4.89) (envelope-from ) id 1d32fH-0001vf-Tc; Tue, 25 Apr 2017 16:46:07 +0100 From: Mark Brown To: Richard Fitzgerald Cc: Mark Brown , broonie@kernel.org, lee.jones@linaro.org, kgene@kernel.org, krzk@kernel.org, linux-kernel@vger.kernel.org, patches@opensource.wolfsonmicro.com, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1492512234-19210-6-git-send-email-rf@opensource.wolfsonmicro.com> Message-Id: Date: Tue, 25 Apr 2017 16:46:07 +0100 X-SA-Exim-Connect-IP: 2001:470:1f1d:6b5::3 X-SA-Exim-Mail-From: broonie@sirena.org.uk Subject: Applied "regulator: arizona-micsupp: Factor out generic initialization" to the regulator tree X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: No (on mezzanine.sirena.org.uk); Unknown failure Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The patch regulator: arizona-micsupp: Factor out generic initialization has been applied to the regulator tree at git://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 7d8d14b51921cbfe082a796e55c22d0c1dd8fc26 Mon Sep 17 00:00:00 2001 From: Richard Fitzgerald Date: Tue, 18 Apr 2017 11:43:51 +0100 Subject: [PATCH] regulator: arizona-micsupp: Factor out generic initialization In preparation for sharing this driver with Madera codecs, factor out the parts of initialization that aren't dependent on struct arizona. Signed-off-by: Richard Fitzgerald Signed-off-by: Mark Brown --- drivers/regulator/arizona-micsupp.c | 82 +++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index db4fecf228b7..120de94caf02 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c @@ -231,52 +231,27 @@ static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata, return 0; } -static int arizona_micsupp_probe(struct platform_device *pdev) +static int arizona_micsupp_common_init(struct platform_device *pdev, + struct arizona_micsupp *micsupp, + const struct regulator_desc *desc, + struct arizona_micsupp_pdata *pdata) { - struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); - const struct regulator_desc *desc; struct regulator_config config = { }; - struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd; - struct arizona_micsupp *micsupp; int ret; - micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL); - if (!micsupp) - return -ENOMEM; - - micsupp->regmap = arizona->regmap; - micsupp->dapm = &arizona->dapm; - micsupp->dev = arizona->dev; INIT_WORK(&micsupp->check_cp_work, arizona_micsupp_check_cp); - /* - * Since the chip usually supplies itself we provide some - * default init_data for it. This will be overridden with - * platform data if provided. - */ - switch (arizona->type) { - case WM5110: - case WM8280: - desc = &arizona_micsupp_ext; - micsupp->init_data = arizona_micsupp_ext_default; - break; - default: - desc = &arizona_micsupp; - micsupp->init_data = arizona_micsupp_default; - break; - } - micsupp->init_data.consumer_supplies = &micsupp->supply; micsupp->supply.supply = "MICVDD"; - micsupp->supply.dev_name = dev_name(arizona->dev); + micsupp->supply.dev_name = dev_name(micsupp->dev); micsupp->enable_reg = desc->enable_reg; - config.dev = arizona->dev; + config.dev = micsupp->dev; config.driver_data = micsupp; - config.regmap = arizona->regmap; + config.regmap = micsupp->regmap; if (IS_ENABLED(CONFIG_OF)) { - if (!dev_get_platdata(arizona->dev)) { + if (!dev_get_platdata(micsupp->dev)) { ret = arizona_micsupp_of_get_pdata(pdata, &config, desc); if (ret < 0) @@ -289,8 +264,8 @@ static int arizona_micsupp_probe(struct platform_device *pdev) else config.init_data = &micsupp->init_data; - /* Default to regulated mode until the API supports bypass */ - regmap_update_bits(arizona->regmap, ARIZONA_MIC_CHARGE_PUMP_1, + /* Default to regulated mode */ + regmap_update_bits(micsupp->regmap, micsupp->enable_reg, ARIZONA_CPMIC_BYPASS, 0); micsupp->regulator = devm_regulator_register(&pdev->dev, @@ -301,7 +276,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev) if (IS_ERR(micsupp->regulator)) { ret = PTR_ERR(micsupp->regulator); - dev_err(arizona->dev, "Failed to register mic supply: %d\n", + dev_err(micsupp->dev, "Failed to register mic supply: %d\n", ret); return ret; } @@ -311,6 +286,41 @@ static int arizona_micsupp_probe(struct platform_device *pdev) return 0; } +static int arizona_micsupp_probe(struct platform_device *pdev) +{ + struct arizona *arizona = dev_get_drvdata(pdev->dev.parent); + const struct regulator_desc *desc; + struct arizona_micsupp *micsupp; + + micsupp = devm_kzalloc(&pdev->dev, sizeof(*micsupp), GFP_KERNEL); + if (!micsupp) + return -ENOMEM; + + micsupp->regmap = arizona->regmap; + micsupp->dapm = &arizona->dapm; + micsupp->dev = arizona->dev; + + /* + * Since the chip usually supplies itself we provide some + * default init_data for it. This will be overridden with + * platform data if provided. + */ + switch (arizona->type) { + case WM5110: + case WM8280: + desc = &arizona_micsupp_ext; + micsupp->init_data = arizona_micsupp_ext_default; + break; + default: + desc = &arizona_micsupp; + micsupp->init_data = arizona_micsupp_default; + break; + } + + return arizona_micsupp_common_init(pdev, micsupp, desc, + &arizona->pdata.micvdd); +} + static struct platform_driver arizona_micsupp_driver = { .probe = arizona_micsupp_probe, .driver = {