From patchwork Thu May 17 13:45:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 8748 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 5C17A23E23 for ; Thu, 17 May 2012 13:46:49 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 2C81BA18B66 for ; Thu, 17 May 2012 13:46:49 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so2138099yhp.11 for ; Thu, 17 May 2012 06:46:49 -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=uEZxM4yfv3Gir/1PdY1SO93y2dpGJoHLOPfGClLXuBU=; b=pCL/1gHW/3C8kiZwikMHGTVqBsP4I60RlJqFfBKFTSCLJDNn7ulQmlkpbR5I7MRb53 rBpUC/urPPrTtOz8qgU1QVXdmhGOeHMfhYIzNTXaNJiH2tU9O+DXqPBgDQmNS5AnKCCg BPkxbaTouX0OeJcJRhHCuDGmVFytoZyondzkWLHLalANgGCoAuFL5IuX2XqHK7xc0cgR d18swQiiBu7oxNpnknbmjpO3JEgcYkKsoz+AqUSzH6b3bzo9XGuglocwmHDLP9voAuRZ h4BbQxiV6uMRZnTX17h8eoDSipoaH2m1Vx5fdOBi7/AmnQJZCKUd3WuhL7sueVbRO7Cl ewug== Received: by 10.50.40.193 with SMTP id z1mr5574201igk.0.1337262408607; Thu, 17 May 2012 06:46:48 -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.35.72 with SMTP id o8csp29046ibd; Thu, 17 May 2012 06:46:47 -0700 (PDT) Received: by 10.180.99.195 with SMTP id es3mr18590158wib.12.1337262407416; Thu, 17 May 2012 06:46:47 -0700 (PDT) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id gb7si8275488wib.10.2012.05.17.06.46.46 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 06:46:47 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by were53 with SMTP id e53so1561395wer.37 for ; Thu, 17 May 2012 06:46:46 -0700 (PDT) Received: by 10.216.132.94 with SMTP id n72mr4733413wei.60.1337262406419; Thu, 17 May 2012 06:46:46 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id h8sm21166277wix.4.2012.05.17.06.46.44 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 06:46:45 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, arnd@arndb.de, linus.walleij@stericsson.com, grant.likely@secretlab.ca, cjb@laptop.org, broonie@opensource.wolfsonmicro.com, sameo@linux.intel.com Cc: Lee Jones , linux-kernel@vger.kernel.org Subject: [PATCH 11/18] regulator: Enable the ab8500 for Device Tree Date: Thu, 17 May 2012 14:45:16 +0100 Message-Id: <1337262323-27692-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1337262323-27692-1-git-send-email-lee.jones@linaro.org> References: <1337262323-27692-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQkQncr6rZFYNhS6O6urgrxrx3+mS7+04GxLTGoKKK+YDHdXGt00HOSm5YU1kxISL8TE3RgN Here we setup the ab8500 regulator driver for DT. We first do this in the normal way, by providing a match structure during initialisation, but then we provide information so that whilst probing we can use existing data structures to do DT look-ups. Cc: linux-kernel@vger.kernel.org Signed-off-by: Lee Jones --- drivers/regulator/ab8500.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 3571b54..e1b8c54 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c @@ -18,9 +18,12 @@ #include #include #include +#include +#include #include #include #include +#include /** * struct ab8500_regulator_info - ab8500 regulator information @@ -790,12 +793,57 @@ static __devinit int ab8500_regulator_register(struct platform_device *pdev, return 0; } +static struct of_regulator_match ab8500_regulator_matches[] = { + { .name = "LDO-AUX1", .driver_data = (void *) AB8500_LDO_AUX1, }, + { .name = "LDO-AUX2", .driver_data = (void *) AB8500_LDO_AUX2, }, + { .name = "LDO-AUX3", .driver_data = (void *) AB8500_LDO_AUX3, }, + { .name = "LDO-INTCORE", .driver_data = (void *) AB8500_LDO_INTCORE, }, + { .name = "LDO-TVOUT", .driver_data = (void *) AB8500_LDO_TVOUT, }, + { .name = "LDO-USB", .driver_data = (void *) AB8500_LDO_USB, }, + { .name = "LDO-AUDIO", .driver_data = (void *) AB8500_LDO_AUDIO, }, + { .name = "LDO-ANAMIC1", .driver_data = (void *) AB8500_LDO_ANAMIC1, }, + { .name = "LDO-ANAMIC2", .driver_data = (void *) AB8500_LDO_ANAMIC2, }, + { .name = "LDO-DMIC", .driver_data = (void *) AB8500_LDO_DMIC, }, + { .name = "LDO-ANA", .driver_data = (void *) AB8500_LDO_ANA, }, +}; + +static __devinit int +ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np) +{ + int err, i; + + for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { + err = ab8500_regulator_register( + pdev, ab8500_regulator_matches[i].init_data, + i, ab8500_regulator_matches[i].of_node); + if (err) + return err; + } + + return 0; +} + static __devinit int ab8500_regulator_probe(struct platform_device *pdev) { struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; int i, err; + if (np) { + err = of_regulator_match(&pdev->dev, np, + ab8500_regulator_matches, + ARRAY_SIZE(ab8500_regulator_matches)); + if (err < 0) { + dev_err(&pdev->dev, + "Error parsing regulator init data: %d\n", err); + return err; + } + + err = ab8500_regulator_of_probe(pdev, np); + return err; + } + if (!ab8500) { dev_err(&pdev->dev, "null mfd parent\n"); return -EINVAL; @@ -858,12 +906,18 @@ static __devexit int ab8500_regulator_remove(struct platform_device *pdev) return 0; } +static const struct of_device_id ab8500_regulator_match[] = { + { .compatible = "stericsson,ab8500-regulator", }, + {} +}; + static struct platform_driver ab8500_regulator_driver = { .probe = ab8500_regulator_probe, .remove = __devexit_p(ab8500_regulator_remove), .driver = { .name = "ab8500-regulator", .owner = THIS_MODULE, + .of_match_table = ab8500_regulator_match, }, };