From patchwork Thu May 17 13:45:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 8745 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 1590A23E23 for ; Thu, 17 May 2012 13:46:44 +0000 (UTC) Received: from mail-qc0-f180.google.com (mail-qc0-f180.google.com [209.85.216.180]) by fiordland.canonical.com (Postfix) with ESMTP id DC6EDA183E2 for ; Thu, 17 May 2012 13:46:43 +0000 (UTC) Received: by mail-qc0-f180.google.com with SMTP id v28so1485217qcm.11 for ; Thu, 17 May 2012 06:46:43 -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=RfcxNUNWNu0sxoPblmIMufw/zCa7lCzxhjJTwq46lkc=; b=eN+Ipt5cSn9UYXbB9sdXQxMQvGN8ns/XmrnLmV4ONecriyxcD11otZewP+ecREPur9 oCulEsUiw+zzxKb7rRGpXSrC67CkDPwoDuVxPMdFtKbckc4NF7j896/3Y8ZU5Ku2aG5N jh18TpqKhs71q0N4C74PmDkq7OAfZZlvw1/tg9ASDzXrh1AqQCgATD+IVvwXJ2RP5RkZ S4o0y4MAaDoTVsBs156iN0m988yAaG4bNgX95kGKRv/ukSBcrhLAL7MsJCKAyNEijLS4 Q4QMVPuOvd20EiroJs9VM/fpX4H9layEzIYGS+AY60eEScm1sHVCkNM+1n11oJsbRYHm DXdg== Received: by 10.50.154.169 with SMTP id vp9mr13291923igb.53.1337262403376; Thu, 17 May 2012 06:46:43 -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 o8csp29034ibd; Thu, 17 May 2012 06:46:42 -0700 (PDT) Received: by 10.213.27.206 with SMTP id j14mr2367535ebc.131.1337262402040; Thu, 17 May 2012 06:46:42 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id 81si7452963wej.18.2012.05.17.06.46.41 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 06:46:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.172; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wi0-f172.google.com with SMTP id hj8so4303012wib.13 for ; Thu, 17 May 2012 06:46:41 -0700 (PDT) Received: by 10.180.74.7 with SMTP id p7mr17715991wiv.20.1337262401559; Thu, 17 May 2012 06:46:41 -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.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 May 2012 06:46:40 -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 Subject: [PATCH 08/18] mfd: Enable Device Tree for ab8500-core driver Date: Thu, 17 May 2012 14:45:13 +0100 Message-Id: <1337262323-27692-9-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: ALoCoQnupGHDNN3QVwNHhCN4vun4I9FYLQ9M5Vuk8C0dbmfVy6RyE00EwMUu9D1qUkR7+8S7yPeb This patch will allow the ab8500-core driver to be probed and set up when booting when Device Tree is enabled. This includes platform ID look-up which identifies the machine it is currently running on. If we are undergoing a DT enabled boot, we will refuse to setup each of the other ab8500-* devices, as they will be probed individually by DT. Signed-off-by: Lee Jones --- drivers/mfd/ab8500-core.c | 73 +++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index 0e2df71..bc6c2d5 100644 --- a/drivers/mfd/ab8500-core.c +++ b/drivers/mfd/ab8500-core.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include /* * Interrupt register offsets @@ -1112,11 +1114,20 @@ static struct attribute_group ab9540_attr_group = { .attrs = ab9540_sysfs_entries, }; +static const struct of_device_id ab8500_match[] = { + { + .compatible = "stericsson,ab8500", + .data = (void *)AB8500_VERSION_AB8500, + }, + {}, +}; + static int __devinit ab8500_probe(struct platform_device *pdev) { struct ab8500_platform_data *plat = dev_get_platdata(&pdev->dev); const struct platform_device_id *platid = platform_get_device_id(pdev); - enum ab8500_version version = platid->driver_data; + enum ab8500_version version = AB8500_VERSION_UNDEFINED; + struct device_node *np = pdev->dev.of_node; struct ab8500 *ab8500; struct resource *resource; int ret; @@ -1129,6 +1140,14 @@ static int __devinit ab8500_probe(struct platform_device *pdev) if (plat) ab8500->irq_base = plat->irq_base; + else if (np) + ret = of_property_read_u32(np, "stericsson,irq-base", &ab8500->irq_base); + + if (!ab8500->irq_base) { + dev_info(&pdev->dev, "couldn't find irq-base\n"); + ret = -EINVAL; + goto out_free_ab8500; + } ab8500->dev = &pdev->dev; @@ -1150,6 +1169,12 @@ static int __devinit ab8500_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ab8500); + if (platid) + version = platid->driver_data; + else if (np) + version = (unsigned int) + of_match_device(ab8500_match, &pdev->dev)->data; + if (version != AB8500_VERSION_UNDEFINED) ab8500->version = version; else { @@ -1246,29 +1271,32 @@ static int __devinit ab8500_probe(struct platform_device *pdev) goto out_removeirq; } - ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, - ARRAY_SIZE(abx500_common_devs), NULL, - ab8500->irq_base); - - if (ret) - goto out_freeirq; + if (!np) { + ret = mfd_add_devices(ab8500->dev, 0, abx500_common_devs, + ARRAY_SIZE(abx500_common_devs), NULL, + ab8500->irq_base); - if (is_ab9540(ab8500)) - ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, - ARRAY_SIZE(ab9540_devs), NULL, - ab8500->irq_base); - else - ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, - ARRAY_SIZE(ab8500_devs), NULL, - ab8500->irq_base); - - if (is_ab9540(ab8500) || is_ab8505(ab8500)) - ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, - ARRAY_SIZE(ab9540_ab8505_devs), NULL, - ab8500->irq_base); + if (ret) + goto out_freeirq; + + if (is_ab9540(ab8500)) + ret = mfd_add_devices(ab8500->dev, 0, ab9540_devs, + ARRAY_SIZE(ab9540_devs), NULL, + ab8500->irq_base); + else + ret = mfd_add_devices(ab8500->dev, 0, ab8500_devs, + ARRAY_SIZE(ab8500_devs), NULL, + ab8500->irq_base); + if (ret) + goto out_freeirq; - if (ret) - goto out_freeirq; + if (is_ab9540(ab8500) || is_ab8505(ab8500)) + ret = mfd_add_devices(ab8500->dev, 0, ab9540_ab8505_devs, + ARRAY_SIZE(ab9540_ab8505_devs), NULL, + ab8500->irq_base); + if (ret) + goto out_freeirq; + } if (!no_bm) { /* Add battery management devices */ @@ -1338,6 +1366,7 @@ static struct platform_driver ab8500_core_driver = { .driver = { .name = "ab8500-core", .owner = THIS_MODULE, + .of_match_table = ab8500_match, }, .probe = ab8500_probe, .remove = __devexit_p(ab8500_remove),