From patchwork Tue Jun 13 13:58:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 9783953 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 582EB602DC for ; Tue, 13 Jun 2017 13:59:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E71E28426 for ; Tue, 13 Jun 2017 13:59:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4269228704; Tue, 13 Jun 2017 13:59:11 +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.0 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 D554628703 for ; Tue, 13 Jun 2017 13:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753452AbdFMN7E (ORCPT ); Tue, 13 Jun 2017 09:59:04 -0400 Received: from [91.227.64.183] ([91.227.64.183]:51380 "EHLO rere.qmqm.pl" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753149AbdFMN7D (ORCPT ); Tue, 13 Jun 2017 09:59:03 -0400 X-Greylist: delayed 664 seconds by postgrey-1.27 at vger.kernel.org; Tue, 13 Jun 2017 09:59:02 EDT Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 435DF38; Tue, 13 Jun 2017 15:58:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1497362334; bh=E/56qqMnj8XiInpdzRKlh4h2v2J433M9dm0YWjcwtV8=; h=Date:In-Reply-To:References:From:Subject:To:Cc:From; b=KLlySyAkAHcPrIsEP8epnG2UjAz0BeRJm86tQYisSmekFFsb7UEqj/3s6+2uwTghR ElyjB5Tda+RkUN/OVVLffXNka8R1vf4kB0Lcx1RShRrc1QIgws43uYC1nufq7tvajH W3wf+AMUrIjUfh8GSqimpAZ6OTsGsjO9rWzJA2BCMeVtIsRTcraY8wTWK5tkvoZbgF bzzPQziixOcMb1yiW4yaLePmvYf/yy8n7+7z0Ds97UIe7QUftOnLFa6S+sm6KHHAqu xo/MXKc+b9oH38xOowcPNIVdnUSlT9qDTLB6QkfeCY6qCQOqER5utmVl7So0MIX2yY sH0pjNZfiw3mg== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.99.2 at rere Date: Tue, 13 Jun 2017 15:58:54 +0200 Message-Id: <32b58e90af76433e42051d3b370cb071903e5402.1497361550.git.mirq-linux@rere.qmqm.pl> In-Reply-To: <0c5e903eed2005e39bdf7abdd1061dffc078109a.1497361550.git.mirq-linux@rere.qmqm.pl> References: <0c5e903eed2005e39bdf7abdd1061dffc078109a.1497361550.git.mirq-linux@rere.qmqm.pl> From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Subject: [PATCH 2/2] regulator: tps65910: Allow supply references to the same chip MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Cc: Liam Girdwood , Mark Brown , Tony Lindgren , linux-omap@vger.kernel.org Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows for (acyclic) references from tps6591x supplies to its outputs. Signed-off-by: Michał Mirosław --- drivers/regulator/tps65910-regulator.c | 39 ++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 81672a58fcc23..f7987168ba4ed 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -1082,7 +1082,8 @@ static int tps65910_probe(struct platform_device *pdev) struct tps65910_reg *pmic; struct tps65910_board *pmic_plat_data; struct of_regulator_match *tps65910_reg_matches = NULL; - int i, err; + bool made_progress; + int i, err, pending; pmic_plat_data = dev_get_platdata(tps65910->dev); if (!pmic_plat_data && tps65910->dev->of_node) @@ -1146,6 +1147,7 @@ static int tps65910_probe(struct platform_device *pdev) if (!pmic->rdev) return -ENOMEM; + /* prepare regulator description */ for (i = 0; i < pmic->num_regulators; i++, info++) { /* Register the regulators */ pmic->info[i] = info; @@ -1196,18 +1198,32 @@ static int tps65910_probe(struct platform_device *pdev) pmic->desc[i].owner = THIS_MODULE; pmic->desc[i].enable_reg = pmic->get_ctrl_reg(i); pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED; + } + + /* Register regulators - loop, as one regulator's output + * might be anothers input */ + + config.dev = pmic->mfd->dev; + config.driver_data = pmic; + config.regmap = pmic->mfd->regmap; + pending = pmic->num_regulators; + +reg_retry: + made_progress = false; + for (i = 0; i < pmic->num_regulators; i++) { + if (pmic->rdev[i]) + continue; - config.dev = tps65910->dev; config.init_data = pmic_plat_data->tps65910_pmic_init_data[i]; - config.driver_data = pmic; - config.regmap = tps65910->regmap; - if (tps65910_reg_matches) config.of_node = tps65910_reg_matches[i].of_node; rdev = devm_regulator_register(&pdev->dev, &pmic->desc[i], &config); if (IS_ERR(rdev)) { + if (PTR_ERR(rdev) == -EPROBE_DEFER) + continue; + dev_err(tps65910->dev, "failed to register %s regulator\n", pdev->name); @@ -1216,8 +1232,19 @@ static int tps65910_probe(struct platform_device *pdev) /* Save regulator for cleanup */ pmic->rdev[i] = rdev; + + made_progress = true; + --pending; } - return 0; + + /* all done? */ + if (!pending) + return 0; + + if (made_progress) + goto reg_retry; + + return -EPROBE_DEFER; } static void tps65910_shutdown(struct platform_device *pdev)