From patchwork Fri Sep 7 11:14:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 11250 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 6EE1A23F25 for ; Fri, 7 Sep 2012 11:15:42 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id EBFD1A1962B for ; Fri, 7 Sep 2012 11:15:41 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id k11so4488374iea.11 for ; Fri, 07 Sep 2012 04:15:41 -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=5I0tZN3P2HfvAsq0KXD8aIPjpuYaglWc6LsJRJgWFxg=; b=iusb+wKqau5ql/RoKvnKDUtByd40W1iatHUHd0YU7hJncsaTyJtSzZ2S5LhfkhEI+O OwtJisqNzLGfD9lDP7gMUTrgo/FAgIREiP7gnUiJW4mixrkab0g+1npvxO4cdFUBTftI 2RSJjPfAsmmWdNDbUkzUPNBUYAHAifQm2ut12gjwMcSyz8kBfXrGC+aUSoImBaCbj/Ml bswZwDlbyxuboIgOkLNMETykU7HNU+lAptJ/2TphLMY99JrzJaTS5foBHVW9XAWMIaoA BSQZLLzU1XLAELaiUSI1diIyfIITM0FGXL8dV70lrJW7bMsc0Mudc9Xs1TT9kroZQsFZ CnUg== Received: by 10.50.7.212 with SMTP id l20mr7961328iga.43.1347016541539; Fri, 07 Sep 2012 04:15:41 -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.50.184.232 with SMTP id ex8csp373465igc; Fri, 7 Sep 2012 04:15:40 -0700 (PDT) Received: by 10.216.0.212 with SMTP id 62mr2990336web.92.1347016539964; Fri, 07 Sep 2012 04:15:39 -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 o8si6520689wea.75.2012.09.07.04.15.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Sep 2012 04:15:39 -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 mail-we0-f178.google.com with SMTP id u7so2048653wey.37 for ; Fri, 07 Sep 2012 04:15:39 -0700 (PDT) Received: by 10.180.78.40 with SMTP id y8mr11566735wiw.7.1347016539361; Fri, 07 Sep 2012 04:15:39 -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 k20sm9151505wiv.11.2012.09.07.04.15.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Sep 2012 04:15:38 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, Lee Jones , Samuel Ortiz Subject: [PATCH 17/19] mfd: Enable the tc3589x for Device Tree Date: Fri, 7 Sep 2012 12:14:57 +0100 Message-Id: <1347016499-29354-18-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347016499-29354-1-git-send-email-lee.jones@linaro.org> References: <1347016499-29354-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQk7T1g2VIkEOvm+EVXTPZZyPVgUZ/thCFq7JnUlTK9T2uuSIwYKjnD1KQXI9pSOqZv7swgi Here we provide a means to probe and extract vital information from Device Tree when booting with it enabled. Without this patch sub-devices wouldn't be able to reference the tc3589x from Device Tree. CC: Samuel Ortiz Signed-off-by: Lee Jones --- drivers/mfd/tc3589x.c | 43 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 2df44ac..8f4c853 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -146,6 +147,7 @@ static struct mfd_cell tc3589x_dev_gpio[] = { .name = "tc3589x-gpio", .num_resources = ARRAY_SIZE(gpio_resources), .resources = &gpio_resources[0], + .of_compatible = "tc3589x-gpio", }, }; @@ -154,6 +156,7 @@ static struct mfd_cell tc3589x_dev_keypad[] = { .name = "tc3589x-keypad", .num_resources = ARRAY_SIZE(keypad_resources), .resources = &keypad_resources[0], + .of_compatible = "tc3589x-keypad", }, }; @@ -221,7 +224,7 @@ static struct irq_domain_ops tc3589x_irq_ops = { .xlate = irq_domain_xlate_twocell, }; -static int tc3589x_irq_init(struct tc3589x *tc3589x) +static int tc3589x_irq_init(struct tc3589x *tc3589x, struct device_node *np) { int base = tc3589x->irq_base; @@ -232,7 +235,7 @@ static int tc3589x_irq_init(struct tc3589x *tc3589x) } else { tc3589x->domain = irq_domain_add_linear( - NULL, TC3589x_NR_INTERNAL_IRQS, + np, TC3589x_NR_INTERNAL_IRQS, &tc3589x_irq_ops, tc3589x); } @@ -309,13 +312,47 @@ static int __devinit tc3589x_device_init(struct tc3589x *tc3589x) return ret; } +static int tc3589x_of_probe(struct device_node *np, + struct tc3589x_platform_data *pdata) +{ + struct device_node *child; + + for_each_child_of_node(np, child) { + if (!strcmp(child->name, "tc3589x_gpio")) { + pdata->block |= TC3589x_BLOCK_GPIO; + } + if (!strcmp(child->name, "tc3589x_keypad")) { + pdata->block |= TC3589x_BLOCK_KEYPAD; + } + } + + return 0; +} + static int __devinit tc3589x_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct tc3589x_platform_data *pdata = i2c->dev.platform_data; + struct device_node *np = i2c->dev.of_node; struct tc3589x *tc3589x; int ret; + if (!pdata) { + if (np) { + pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + ret = tc3589x_of_probe(np, pdata); + if (ret) + return ret; + } + else { + dev_err(&i2c->dev, "No platform data or DT found\n"); + return -EINVAL; + } + } + if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_I2C_BLOCK)) return -EIO; @@ -338,7 +375,7 @@ static int __devinit tc3589x_probe(struct i2c_client *i2c, if (ret) goto out_free; - ret = tc3589x_irq_init(tc3589x); + ret = tc3589x_irq_init(tc3589x, np); if (ret) goto out_free;