From patchwork Thu Apr 12 15:39:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 7765 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D145E23E29 for ; Thu, 12 Apr 2012 15:40:33 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 76D6EA1802C for ; Thu, 12 Apr 2012 15:40:33 +0000 (UTC) Received: by iage36 with SMTP id e36so4021741iag.11 for ; Thu, 12 Apr 2012 08:40:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=Rr7giGbbfyEVFF5AQi09nzrNPGGtFeZu+EIqr+RFWMc=; b=dZxAxFLkc5/kuKQQ1WyEw6hq4grsvMQEzXiaz+55KrLyTDtyozfDJvFMQIhYVVgnuA Ikkfb+lbwkou9EJ/5PPr2zJYMu0oJtLMJLdw8CHIUqn+5ysrdN0MyZeYvaHRWAw4qtGf BDTaJ6HzMRcb4v//R12VNg4zH9KdgCqIo0YT2BXY+nn2ujxU4ecAQMb5BTGWD/cvoTJd nJQJFqdG0QMSD6nBhMWF/Sv4iRRk+oCJATM4ZsHyLXSiQOYsA10k2cGCo0Ciy7HN96l2 C66bTwvXCAbRLb3ovX5ypqI9hKLINuO1orbt4flq/4vSdCHjyvNW1hs5Lezfbih5iDai ixfQ== Received: by 10.50.187.137 with SMTP id fs9mr6760214igc.50.1334245232839; Thu, 12 Apr 2012 08:40:32 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.70.69 with SMTP id c5csp272036ibj; Thu, 12 Apr 2012 08:40:32 -0700 (PDT) Received: by 10.236.185.68 with SMTP id t44mr2399232yhm.126.1334245231754; Thu, 12 Apr 2012 08:40:31 -0700 (PDT) Received: from mail-yw0-f50.google.com (mail-yw0-f50.google.com [209.85.213.50]) by mx.google.com with ESMTPS id m11si2594892anc.179.2012.04.12.08.40.31 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 Apr 2012 08:40:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of paul.liu@linaro.org) client-ip=209.85.213.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.213.50 is neither permitted nor denied by best guess record for domain of paul.liu@linaro.org) smtp.mail=paul.liu@linaro.org Received: by yhjj63 with SMTP id j63so1337991yhj.37 for ; Thu, 12 Apr 2012 08:40:31 -0700 (PDT) Received: by 10.60.1.7 with SMTP id 7mr3517001oei.71.1334245231381; Thu, 12 Apr 2012 08:40:31 -0700 (PDT) Received: from freya.lan (host-216.138-185-111.static.totalbb.net.tw. [111.185.138.216]) by mx.google.com with ESMTPS id by5sm7056183obb.19.2012.04.12.08.40.27 (version=SSLv3 cipher=OTHER); Thu, 12 Apr 2012 08:40:30 -0700 (PDT) From: "Ying-Chun Liu (PaulLiu)" To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linaro-dev@lists.linaro.org, patches@linaro.org, broonie@opensource.wolfsonmicro.com, "Ying-Chun Liu (PaulLiu)" , Liam Girdwood , Samuel Ortiz , Shawn Guo , Ashish Jangam Subject: [PATCH 2/2] regulator: da9052: add device tree support Date: Thu, 12 Apr 2012 23:39:42 +0800 Message-Id: <1334245182-31725-2-git-send-email-paul.liu@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1334245182-31725-1-git-send-email-paul.liu@linaro.org> References: <1334245182-31725-1-git-send-email-paul.liu@linaro.org> X-Gm-Message-State: ALoCoQl1DnvaKcRqisLMJq5lJcp3vPIKb9d8fFwUGjVINHw4JnpvTBZ0N6tRwS0df83AnZqUIp1n From: "Ying-Chun Liu (PaulLiu)" This patch adds device tree support for dialog regulators Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Mark Brown Cc: Liam Girdwood Cc: Samuel Ortiz Cc: Shawn Guo Cc: Ashish Jangam --- drivers/regulator/da9052-regulator.c | 44 +++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index 09915e8..892700c 100644 --- a/drivers/regulator/da9052-regulator.c +++ b/drivers/regulator/da9052-regulator.c @@ -19,6 +19,9 @@ #include #include #include +#ifdef CONFIG_OF +#include +#endif #include #include @@ -536,6 +539,7 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev) struct da9052_regulator *regulator; struct da9052 *da9052; struct da9052_pdata *pdata; + struct regulator_init_data *initdata = NULL; int ret; regulator = devm_kzalloc(&pdev->dev, sizeof(struct da9052_regulator), @@ -554,9 +558,47 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev) ret = -EINVAL; goto err; } + if (pdata && pdata->regulators) { + initdata = pdata->regulators[pdev->id]; + } else { +#ifdef CONFIG_OF + struct device_node *nproot = da9052->dev->of_node; + struct device_node *np; + int c; + + if (!nproot) { + ret = -ENODEV; + goto err; + } + + nproot = of_find_node_by_name(nproot, "regulators"); + if (!nproot) { + ret = -ENODEV; + goto err; + } + + c = 0; + for (np = of_get_next_child(nproot, NULL); + np != NULL; + np = of_get_next_child(nproot, np)) { + if (c == pdev->id) { + initdata = of_get_regulator_init_data( + &pdev->dev, np); + break; + } + c++; + } +#endif + } + + if (!initdata) { + dev_err(&pdev->dev, "no initdata\n"); + ret = -ENODEV; + goto err; + } regulator->rdev = regulator_register(®ulator->info->reg_desc, &pdev->dev, - pdata->regulators[pdev->id], + initdata, regulator, NULL); if (IS_ERR(regulator->rdev)) { dev_err(&pdev->dev, "failed to register regulator %s\n",