From patchwork Thu Jul 28 06:41:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 1014602 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6S6qDma018748 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 28 Jul 2011 06:52:40 GMT Received: from canuck.infradead.org ([134.117.69.58]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QmKRX-0003Pq-C0; Thu, 28 Jul 2011 06:51:40 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QmKRW-0006z2-1O; Thu, 28 Jul 2011 06:51:38 +0000 Received: from dakia2.marvell.com ([65.219.4.35]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QmKPO-0006ZR-Oc for linux-arm-kernel@lists.infradead.org; Thu, 28 Jul 2011 06:49:28 +0000 X-ASG-Debug-ID: 1311835765-082eefc40001-tbGyMd Received: from maili.marvell.com (maili.marvell.com [10.68.76.51]) by dakia2.marvell.com with ESMTP id IF116gnuWH1BcNdi; Wed, 27 Jul 2011 23:49:25 -0700 (PDT) X-Barracuda-Envelope-From: haojian.zhuang@marvell.com Received: from localhost (unknown [10.38.164.65]) by maili.marvell.com (Postfix) with ESMTP id 402598A002; Wed, 27 Jul 2011 23:49:25 -0700 (PDT) From: Haojian Zhuang To: haojian.zhuang@gmail.com, eric.y.miao@gmail.com, linux@arm.linux.org.uk, grant.likely@secretlab.ca, alan@linux.intel.com, linux-arm-kernel@lists.infradead.org, devicetree-discuss@lists.ozlabs.org X-ASG-Orig-Subj: [PATCH v2 7/7] i2c: pxa: support to parse property Subject: [PATCH v2 7/7] i2c: pxa: support to parse property Date: Thu, 28 Jul 2011 14:41:33 +0800 X-ASG-Orig-Subj: [PATCH v2 7/7] i2c: pxa: support to parse property Message-Id: <1311835293-18125-8-git-send-email-haojian.zhuang@marvell.com> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: <1311835293-18125-7-git-send-email-haojian.zhuang@marvell.com> References: <1311835293-18125-1-git-send-email-haojian.zhuang@marvell.com> <1311835293-18125-2-git-send-email-haojian.zhuang@marvell.com> <1311835293-18125-3-git-send-email-haojian.zhuang@marvell.com> <1311835293-18125-4-git-send-email-haojian.zhuang@marvell.com> <1311835293-18125-5-git-send-email-haojian.zhuang@marvell.com> <1311835293-18125-6-git-send-email-haojian.zhuang@marvell.com> <1311835293-18125-7-git-send-email-haojian.zhuang@marvell.com> X-Barracuda-Connect: maili.marvell.com[10.68.76.51] X-Barracuda-Start-Time: 1311835765 X-Barracuda-URL: http://10.68.76.222:80/cgi-mod/mark.cgi X-Barracuda-Spam-Score: -1002.00 X-Barracuda-Spam-Status: No, SCORE=-1002.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1000.0 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110728_024927_056899_7592361E X-CRM114-Status: GOOD ( 18.91 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -1.2 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Haojian Zhuang X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 06:52:40 +0000 (UTC) Support to parse some optional properties. These three properties are mrvl,use-polling, mrvl,i2c-frequency, mrvl,i2c-class. After supporting these property, i2c-pxa driver can avoid to use platform data except for slave mode. Signed-off-by: Haojian Zhuang --- .../devicetree/bindings/i2c/pxa255-i2c.txt | 38 ++++++++++++++++++++ drivers/i2c/busses/i2c-pxa.c | 20 +++++++--- 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/pxa255-i2c.txt diff --git a/Documentation/devicetree/bindings/i2c/pxa255-i2c.txt b/Documentation/devicetree/bindings/i2c/pxa255-i2c.txt new file mode 100644 index 0000000..4b5afae --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/pxa255-i2c.txt @@ -0,0 +1,38 @@ +PXA255 I2C + +The I2C-Controller is first used in PXA255. It's widely used in Intel/Marvell +silicons. + +Optional Property: + - mrvl,use-polling: Specifies whether I2C-Controller is used in polling + mode or interrupt mode. The type of property should be . + + - mrvl,i2c-frequency: Specifies the frequency that the I2C-Controller + is working. It indicates I2C-Controller running in standard(100Kb/s) + or fast(400Kb/s) speed. + The type of property should be . The value should be "fast". + + - mrvl,i2c-class: Specifies the adaptor class of I2C-Controller, such as + hwmon or ddc bus. The type of property should be . + +Example: + i2c0: i2c@d4011000 { + compatible = "pxa2xx-i2c"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0xd4011000 0x60>; + /* I2C-Controller works in polling mode. */ + mrvl,use-polling; + /* I2C-Controller's frequency is FAST. */ + mrvl,i2c-frequency = "fast"; + /* interrupt of I2C-Controller */ + interrupts = <7>; + interrupt-parent = <&mmp_intc>; + + pm860x: pmic@34 { + interrupt-controller; + /* interrupt of pm860x */ + interrupts = <4>; + interrupt-parent = <&mmp_intc>; + }; + }; diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c index 8c27733..cebcd26 100644 --- a/drivers/i2c/busses/i2c-pxa.c +++ b/drivers/i2c/busses/i2c-pxa.c @@ -1061,6 +1061,7 @@ static int i2c_pxa_probe(struct platform_device *dev) enum pxa_i2c_types i2c_type; struct resource *res; int irq, ret; + char *p = NULL; static int idx = 0; if (np) { @@ -1093,11 +1094,24 @@ static int i2c_pxa_probe(struct platform_device *dev) if (np) { + if (of_get_property(np, "mrvl,use-polling", NULL)) + i2c->use_pio = 1; + of_property_read_string(np, "mrvl,i2c-frequency", &p); + if (p && !strncmp(p, "fast", 4)) + i2c->fast_mode = 1; + of_property_read_u32(np, "mrvl,i2c-class", &i2c->adap.class); + i2c->adap.nr = idx++; snprintf(i2c->adap.name, sizeof(i2c->adap.name), "pxa2xx-i2c.%u", i2c->adap.nr); i2c->clk = clk_get_sys(i2c->adap.name, NULL); } else { + if (plat) { + i2c->adap.class = plat->class; + i2c->use_pio = plat->use_pio; + i2c->fast_mode = plat->fast_mode; + } + /* * If "dev->id" is negative we consider it as zero. * The reason to do so is to avoid sysfs names that only make @@ -1142,12 +1156,6 @@ static int i2c_pxa_probe(struct platform_device *dev) clk_enable(i2c->clk); - if (plat) { - i2c->adap.class = plat->class; - i2c->use_pio = plat->use_pio; - i2c->fast_mode = plat->fast_mode; - } - if (i2c->use_pio) { i2c->adap.algo = &i2c_pxa_pio_algorithm; } else {