From patchwork Thu Dec 1 17:33:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timur Tabi X-Patchwork-Id: 128733 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id C9DB810080A for ; Fri, 2 Dec 2011 04:33:49 +1100 (EST) Received: by ozlabs.org (Postfix) id 707A6B6F76; Fri, 2 Dec 2011 04:33:25 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from ch1outboundpool.messaging.microsoft.com (ch1ehsobe006.messaging.microsoft.com [216.32.181.186]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client CN "mail.global.frontbridge.com", Issuer "Microsoft Secure Server Authority" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id EB74BB6F68 for ; Fri, 2 Dec 2011 04:33:23 +1100 (EST) Received: from mail64-ch1-R.bigfish.com (10.43.68.241) by CH1EHSOBE001.bigfish.com (10.43.70.51) with Microsoft SMTP Server id 14.1.225.22; Thu, 1 Dec 2011 17:33:16 +0000 Received: from mail64-ch1 (localhost.localdomain [127.0.0.1]) by mail64-ch1-R.bigfish.com (Postfix) with ESMTP id A1CED10180; Thu, 1 Dec 2011 17:33:16 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275bhz2dh2a8h668h839h) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-SS: 13, Received: from mail64-ch1 (localhost.localdomain [127.0.0.1]) by mail64-ch1 (MessageSwitch) id 1322760796535002_16872; Thu, 1 Dec 2011 17:33:16 +0000 (UTC) Received: from CH1EHSMHS003.bigfish.com (snatpool1.int.messaging.microsoft.com [10.43.68.254]) by mail64-ch1.bigfish.com (Postfix) with ESMTP id 758EB1AA0046; Thu, 1 Dec 2011 17:33:16 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CH1EHSMHS003.bigfish.com (10.43.70.3) with Microsoft SMTP Server (TLS) id 14.1.225.22; Thu, 1 Dec 2011 17:33:15 +0000 Received: from az33smr02.freescale.net (10.64.34.200) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.339.2; Thu, 1 Dec 2011 11:33:03 -0600 Received: from efes.am.freescale.net (efes.am.freescale.net [10.82.123.3]) by az33smr02.freescale.net (8.13.1/8.13.0) with ESMTP id pB1HX2BE020623; Thu, 1 Dec 2011 11:33:02 -0600 (CST) From: Timur Tabi To: , , Subject: [PATCH] i2c-mpc: use the cell-index property to enumerate the I2C adapters Date: Thu, 1 Dec 2011 11:33:01 -0600 Message-ID: <1322760781-31226-1-git-send-email-timur@freescale.com> X-Mailer: git-send-email 1.7.3.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org An I2C device tree node can contain a 'cell-index' property that can be used to enumerate the I2C devices. If such a property exists, use it to specify the I2C adapter number. This feature is necessary for the Freescale PowerPC audio drivers (e.g. on the P1022DS). The "machine driver" needs to know the adapter number for each I2C adapter, but it only has access to the device tree. Previously, the I2C nodes always appeared in cell-index order, so the dynamic numbering coincided with the cell-index property. With commit ab827d97 ("powerpc/85xx: Rework P1022DS device tree"), the I2C nodes are unintentionally reversed in the device tree, and so the machine driver guesses the wrong I2C adapter number. Signed-off-by: Timur Tabi --- drivers/i2c/busses/i2c-mpc.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c index 107397a..8551c34 100644 --- a/drivers/i2c/busses/i2c-mpc.c +++ b/drivers/i2c/busses/i2c-mpc.c @@ -632,7 +632,19 @@ static int __devinit fsl_i2c_probe(struct platform_device *op) i2c->adap.dev.parent = &op->dev; i2c->adap.dev.of_node = of_node_get(op->dev.of_node); - result = i2c_add_adapter(&i2c->adap); + /* + * If the I2C node has a "cell-index" property, use it to enumerate + * the I2C adapter. + */ + prop = of_get_property(i2c->adap.dev.of_node, "cell-index", &plen); + if (prop && plen == sizeof(u32)) { + dev_dbg(i2c->dev, "using cell-index property %u", *prop); + i2c->adap.nr = *prop; + result = i2c_add_numbered_adapter(&i2c->adap); + } else { + result = i2c_add_adapter(&i2c->adap); + } + if (result < 0) { dev_err(i2c->dev, "failed to add adapter\n"); goto fail_add;