From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757117Ab2DMNiL (ORCPT ); Fri, 13 Apr 2012 09:38:11 -0400 Received: from mail-pz0-f52.google.com ([209.85.210.52]:46179 "EHLO mail-pz0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932696Ab2DMNiH (ORCPT ); Fri, 13 Apr 2012 09:38:07 -0400 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> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 1.7.9.5