From patchwork Fri Jun 7 16:11:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 17686 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B6F5F2395F for ; Fri, 7 Jun 2013 16:12:04 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id b4sf4532521qen.7 for ; Fri, 07 Jun 2013 09:12:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=lmoxW0Q6G4XvN8YR24jyAOJO+wkkrYTIrR3Yh70GE00=; b=eTd9vtofxZqhwnQM7Znl9jPT91OPBCr/QcVYRnRQAcLzzjMqXCEMYW9humt3u/yVcb UrAZuw96bQDhNnPYccwklnQ+dUhJBOxm4cm3Tp9DadN2zE6ORv+rDZv7O6DjAHtCI6Vi H7A9H5TiWcV3gN7fUom3JnFyoXgmYqq1s2zBqaNctNFcenj5QJhNwKKsVm52cg2hOUbr IDjCZqjGtrn5E0f0Ermbffbj1BBKSysF2bI1asToBQ/kFRl7n7ug4FhuzjLqFFMTkBrA w38yIr3eDZhjvtguBV2UB7W/ki/CiokYnt6xH1/ZAzd7510noiNs89c3Z0FR9NonFoB2 YUXQ== X-Received: by 10.236.118.196 with SMTP id l44mr22794186yhh.48.1370621524378; Fri, 07 Jun 2013 09:12:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.119.161 with SMTP id kv1ls899138qeb.74.gmail; Fri, 07 Jun 2013 09:12:04 -0700 (PDT) X-Received: by 10.52.94.174 with SMTP id dd14mr1409986vdb.121.1370621524089; Fri, 07 Jun 2013 09:12:04 -0700 (PDT) Received: from mail-ve0-x234.google.com (mail-ve0-x234.google.com [2607:f8b0:400c:c01::234]) by mx.google.com with ESMTPS id ef7si43736461vdc.7.2013.06.07.09.12.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 09:12:04 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::234; Received: by mail-ve0-f180.google.com with SMTP id pa12so3134489veb.25 for ; Fri, 07 Jun 2013 09:12:04 -0700 (PDT) X-Received: by 10.221.4.131 with SMTP id oc3mr23677625vcb.49.1370621524012; Fri, 07 Jun 2013 09:12:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp120732vcb; Fri, 7 Jun 2013 09:12:03 -0700 (PDT) X-Received: by 10.15.23.73 with SMTP id g49mr15232936eeu.8.1370621522932; Fri, 07 Jun 2013 09:12:02 -0700 (PDT) Received: from mail-ea0-x22f.google.com (mail-ea0-x22f.google.com [2a00:1450:4013:c01::22f]) by mx.google.com with ESMTPS id g44si58368594eeo.323.2013.06.07.09.12.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 09:12:02 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:4013:c01::22f is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:4013:c01::22f; Received: by mail-ea0-f175.google.com with SMTP id z7so45817eaf.34 for ; Fri, 07 Jun 2013 09:12:02 -0700 (PDT) X-Received: by 10.15.23.73 with SMTP id g49mr15232905eeu.8.1370621522456; Fri, 07 Jun 2013 09:12:02 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPSA id c5sm97260340eeu.8.2013.06.07.09.12.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Jun 2013 09:12:01 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, srinidhi.kasagar@stericsson.com, broonie@linaro.org, Lee Jones Subject: [PATCH 09/10] regulator: ab8500-ext: Enable for Device Tree Date: Fri, 7 Jun 2013 17:11:27 +0100 Message-Id: <1370621488-18130-10-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1370621488-18130-1-git-send-email-lee.jones@linaro.org> References: <1370621488-18130-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkPlMgkohM+kk4VmnzE9lCXlhV6KYHS1ExTHXZF4C6uFLqhjWwaU+y7qNPgTg/lt4X7gAl3 X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::234 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Here we use the OF regulator match facility to collect and populate initialisation data from Device Tree if we're booting with it enabled. Signed-off-by: Lee Jones --- drivers/regulator/ab8500-ext.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c index 95f495f..4137a2f 100644 --- a/drivers/regulator/ab8500-ext.c +++ b/drivers/regulator/ab8500-ext.c @@ -16,9 +16,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -333,18 +335,37 @@ static struct ab8500_ext_regulator_info }, }; +static struct of_regulator_match ab8500_ext_regulator_match[] = { + { .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, }, + { .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, }, + { .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, }, +}; + int ab8500_ext_regulator_probe(struct platform_device *pdev) { struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500_platform_data *ppdata; struct ab8500_regulator_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; struct regulator_config config = { }; int i, err; + if (np) { + err = of_regulator_match(&pdev->dev, np, + ab8500_ext_regulator_match, + ARRAY_SIZE(ab8500_ext_regulator_match)); + if (err < 0) { + dev_err(&pdev->dev, + "Error parsing regulator init data: %d\n", err); + return err; + } + } + if (!ab8500) { dev_err(&pdev->dev, "null mfd parent\n"); return -EINVAL; } + ppdata = dev_get_platdata(ab8500->dev); if (!ppdata) { dev_err(&pdev->dev, "null parent pdata\n"); @@ -385,8 +406,11 @@ int ab8500_ext_regulator_probe(struct platform_device *pdev) pdata->ext_regulator[i].driver_data; config.dev = &pdev->dev; - config.init_data = &pdata->ext_regulator[i]; config.driver_data = info; + config.of_node = ab8500_ext_regulator_match[i].of_node; + config.init_data = (np) ? + ab8500_ext_regulator_match[i].init_data : + &pdata->ext_regulator[i]; /* register regulator with framework */ info->rdev = regulator_register(&info->desc, &config);