From patchwork Thu Sep 12 12:36:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guennadi Liakhovetski X-Patchwork-Id: 2878221 Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 45D9E9F476 for ; Thu, 12 Sep 2013 12:36:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ECA8E201B3 for ; Thu, 12 Sep 2013 12:36:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C04B8200B4 for ; Thu, 12 Sep 2013 12:36:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754158Ab3ILMgw (ORCPT ); Thu, 12 Sep 2013 08:36:52 -0400 Received: from moutng.kundenserver.de ([212.227.126.186]:51094 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753821Ab3ILMgv (ORCPT ); Thu, 12 Sep 2013 08:36:51 -0400 Received: from axis700.grange (dslb-088-076-068-089.pools.arcor-ip.net [88.76.68.89]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0M3B4h-1WCCKU1i4d-00sxS5; Thu, 12 Sep 2013 14:36:49 +0200 Received: from 6a.grange (6a.grange [192.168.1.11]) by axis700.grange (Postfix) with ESMTPS id EB87940BB5; Thu, 12 Sep 2013 14:36:48 +0200 (CEST) Received: from lyakh by 6a.grange with local (Exim 4.72) (envelope-from ) id 1VK68e-0002lq-Qg; Thu, 12 Sep 2013 14:36:48 +0200 From: Guennadi Liakhovetski To: linux-i2c@vger.kernel.org Cc: Magnus Damm , linux-sh@vger.kernel.org, Wolfram Sang , devicetree@vger.kernel.org, Grant Likely , Rob Herring , Guennadi Liakhovetski Subject: [PATCH v2 3/5] i2c: rcar: add Device Tree support Date: Thu, 12 Sep 2013 14:36:46 +0200 Message-Id: <1378989408-10618-4-git-send-email-g.liakhovetski@gmx.de> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1378989408-10618-1-git-send-email-g.liakhovetski@gmx.de> References: <1378989408-10618-1-git-send-email-g.liakhovetski@gmx.de> X-Provags-ID: V02:K0:Du4H9UO8SoVDr0VaD/fyshqkdBqgU/HA8cvyhbvxfSc u8uDEz3861p9qkkDHKEIqpD7u6sbu1qNL+nbD6XjOKtOeGsIXY bl7sMOxLOmpw3iLVURSyTlbZnHXareImlzko9ZS/bGtJGUd9Ef x0PPxXjOSdpz3yxFXO/roROWoWsAqNpuM9eLqLZZlhWXRWS9xx BAM9Fy33G3Xp6dYBUtFU3E02krNWR9gp5iQFAq9CctFTYcBmDo VN41bxaQyO3Mj8MdYSiS08vAIBqnjszEsZOMUCNc38idO5HpMS f+AcIZq5vn6Qq916u9BI7vU2TLBtSE/NhS+4d5lPJ7qmNCu3wx 43q3T4N+KdLYzWFjjyT20cPWdHbaZtto1mUywfnYHvswmVI3wl jEj1EMH6ADnTA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds Device Tree support to the i2c-rcar driver and respective documentation. Signed-off-by: Guennadi Liakhovetski --- v2: change compatibility string to the common - format Documentation/devicetree/bindings/i2c/i2c-rcar.txt | 22 ++++++++++++++++++++ drivers/i2c/busses/i2c-rcar.c | 21 +++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-rcar.txt diff --git a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt new file mode 100644 index 0000000..b3c030b --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt @@ -0,0 +1,23 @@ +I2C for R-Car platforms + +Required properties: +- compatible: Must be one of + "renesas,i2c-rcar" + "renesas,i2c-r8a7778" + "renesas,i2c-r8a7779" + "renesas,i2c-r8a7790" +- reg: physical base address of the controller and length of memory mapped + region. +- interrupts: interrupt specifier. + +Optional properties: +- clock-frequency: desired I2C bus clock frequency in Hz. The absence of this + propoerty indicates the default frequency 100 kHz. + +Examples : + +i2c0: i2c@e6500000 { + compatible = "renesas,i2c-rcar-h2"; + reg = <0 0xe6500000 0 0x428>; + interrupts = <0 174 0x4>; +}; diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 9325db4..1f285a3 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -638,6 +639,15 @@ static const struct i2c_algorithm rcar_i2c_algo = { .functionality = rcar_i2c_func, }; +static const struct of_device_id rcar_i2c_dt_ids[] = { + { .compatible = "renesas,i2c-rcar", .data = (void *)I2C_RCAR_H1 }, + { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_H1 }, + { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_H1 }, + { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_H2 }, + {}, +}; +MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids); + static int rcar_i2c_probe(struct platform_device *pdev) { struct i2c_rcar_platform_data *pdata = dev_get_platdata(&pdev->dev); @@ -655,10 +665,15 @@ static int rcar_i2c_probe(struct platform_device *pdev) } bus_speed = 100000; /* default 100 kHz */ - if (pdata && pdata->bus_speed) + ret = of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed); + if (ret < 0 && pdata && pdata->bus_speed) bus_speed = pdata->bus_speed; - priv->devtype = platform_get_device_id(pdev)->driver_data; + if (pdev->dev.of_node) + priv->devtype = (long)of_match_device(rcar_i2c_dt_ids, + dev)->data; + else + priv->devtype = platform_get_device_id(pdev)->driver_data; ret = rcar_i2c_clock_calculate(priv, bus_speed, dev); if (ret < 0) @@ -679,6 +694,7 @@ static int rcar_i2c_probe(struct platform_device *pdev) adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; adap->retries = 3; adap->dev.parent = dev; + adap->dev.of_node = dev->of_node; i2c_set_adapdata(adap, priv); strlcpy(adap->name, pdev->name, sizeof(adap->name)); @@ -726,6 +742,7 @@ static struct platform_driver rcar_i2c_driver = { .driver = { .name = "i2c-rcar", .owner = THIS_MODULE, + .of_match_table = rcar_i2c_dt_ids, }, .probe = rcar_i2c_probe, .remove = rcar_i2c_remove,