From patchwork Fri Apr 13 13:37:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Liu X-Patchwork-Id: 7779 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 E041323E00 for ; Fri, 13 Apr 2012 13:38:08 +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 A436EA183B3 for ; Fri, 13 Apr 2012 13:38:08 +0000 (UTC) Received: by iage36 with SMTP id e36so5814507iag.11 for ; Fri, 13 Apr 2012 06:38:08 -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=NA+tNjjOZsPT+ldUmNEW1RERpN3uFdRDOlohTQ7Xr2Q=; b=Ga51VjQVx6dm1qh+3Cn+DYhXUI5Si7l7FWPzhEhLBIh3b7Y/xTCIZvDjW1RBAEQmra yhgeze3+br4IYyRSTFvTrNhT7vo2BvWHFf18cZgsVqbH8kdv3Zh11wxQvpwAY2jZxEfJ lpeMcLPWvrVkkUp/K3u46c0C+q6U1SRzOyltm/FZQecDO82LJptqfVmMdFvXGKoaEjw9 GLb3c600fpJdZEKjZfD4s+JCCt7auFGwxblYoQR5J0fen7SigWS4m/p5im7xnF5Q5GGY ULLrakhs8reFV2juApXi4Rux9dq2+hLXMZklFbkow7YVCamw/EQlSc2rfkbjfKAoyELm BUug== Received: by 10.50.187.226 with SMTP id fv2mr1575163igc.40.1334324287978; Fri, 13 Apr 2012 06:38:07 -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 c5csp28178ibj; Fri, 13 Apr 2012 06:38:07 -0700 (PDT) Received: by 10.68.193.135 with SMTP id ho7mr4815604pbc.119.1334324287220; Fri, 13 Apr 2012 06:38:07 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id t9si10674775pbj.132.2012.04.13.06.38.07 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Apr 2012 06:38:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of paul.liu@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.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 mail-pb0-f50.google.com with SMTP id xa12so4326504pbc.37 for ; Fri, 13 Apr 2012 06:38:07 -0700 (PDT) Received: by 10.68.240.40 with SMTP id vx8mr145318pbc.131.1334324286798; Fri, 13 Apr 2012 06:38:06 -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 i1sm8760981pbj.70.2012.04.13.06.38.04 (version=SSLv3 cipher=OTHER); Fri, 13 Apr 2012 06:38:06 -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, "Ying-Chun Liu (PaulLiu)" , Mark Brown , Liam Girdwood , Samuel Ortiz , Shawn Guo , Ashish Jangam Subject: [PATCH v2 2/2] regulator: da9052: add device tree support Date: Fri, 13 Apr 2012 21:37:41 +0800 Message-Id: <1334324261-5476-2-git-send-email-paul.liu@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1334324261-5476-1-git-send-email-paul.liu@linaro.org> References: <1334324261-5476-1-git-send-email-paul.liu@linaro.org> X-Gm-Message-State: ALoCoQke4hDZeCdoGyev0JmudOe4Zesh/Bjs6thqTE0rLMoxDPmUQiWNpOfthfM1QBeiOani5mIn 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 | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c index b6c8c4b..2678cbe 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 @@ -425,8 +428,32 @@ static int __devinit da9052_regulator_probe(struct platform_device *pdev) } config.dev = &pdev->dev; - config.init_data = pdata->regulators[pdev->id]; config.driver_data = regulator; + if (pdata && pdata->regulators) { + config.init_data = pdata->regulators[pdev->id]; + } else { +#ifdef CONFIG_OF + struct device_node *nproot = da9052->dev->of_node; + struct device_node *np; + + if (!nproot) + return -ENODEV; + + nproot = of_find_node_by_name(nproot, "regulators"); + if (!nproot) + return -ENODEV; + + for (np = of_get_next_child(nproot, NULL); !np; + np = of_get_next_child(nproot, np)) { + if (!of_node_cmp(np->name, + regulator->info->reg_desc.name)) { + config.init_data = of_get_regulator_init_data( + &pdev->dev, np); + break; + } + } +#endif + } regulator->rdev = regulator_register(®ulator->info->reg_desc, &config);