From patchwork Thu May 16 05:08:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagar Shrikant Kadam X-Patchwork-Id: 10945633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CB9FB6C5 for ; Thu, 16 May 2019 05:09:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF8E028A5C for ; Thu, 16 May 2019 05:09:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A378828AC4; Thu, 16 May 2019 05:09:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4A16828A5C for ; Thu, 16 May 2019 05:09:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ht6UxbZozuMOUlQ2JjtgV15HcyjQyUHwlkDfQYfQb2o=; b=RCsTOWWXejLx81 A0gOd+qG4OH4RCgt0sCGJkajyQVo/Yzo0GY4ojqkkWaPoNuc14KGk4CUIxMPwgVEAa0VYaMfWeC0l v6uaoF3vVR9p2mfm/xTDplYWxdvm7KPPo5eusfiMhaifkQQtRqWG7DHdVWVIF1VD80B/HgLnJo3h7 NuboJZqvrtOTxxfQUyjqKcqno2WOafEwBGe0EhrtglCt0QxGIk6HsX9De6C15YTltXpJILLF4KxOB FxKF6TpSoiCQHrpKhAvgdfndfChdXjIvariMoMXgUmD3cAOUOfVFJJnXMeHzGF93Oy3sc4vq1y6Pi fbXhUfhyRTP/Asnw2B/w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hR8e7-0006Bq-6J; Thu, 16 May 2019 05:09:35 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hR8e4-0006BV-3M for linux-riscv@lists.infradead.org; Thu, 16 May 2019 05:09:33 +0000 Received: by mail-pg1-x544.google.com with SMTP id a3so942866pgb.3 for ; Wed, 15 May 2019 22:09:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=bw14u18P9i//6PFBBpNeMD35DBcnBuJpaE6hMWzLBZ0=; b=JMBjAjqj9Bt/mtPeNVVFnwrG6sxggttpsGf3yrrSUASc87Irj9E9jhvOrZ6OxSc4pm 3oweA6sqM0iqogIExq9o+Er5Wtj62ppqTiDzoyWk95Ebb4+W5do0a66GqvVBiL6cNBFL 2OkBNVSw3s+rYw7I92PJ9orjWwAsPwsq0GPBRAqP1uhxgPUIIqbi+wqRsSxiBhrnkEax b2gLSylHqEuhL3gzcj5Jt5t1XEE7luk6bwfSx9J6nOtyU6y0TMiBtG5r1R8FzkL0b6D3 qj4K7GsCIs9w3K+ZDiz3Tv3At8nVqFuTHKCo0hltnNFFBDX/F+BP0LISx4mPRlEtLmC7 /sDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=bw14u18P9i//6PFBBpNeMD35DBcnBuJpaE6hMWzLBZ0=; b=TOoejppxJEvfjcN5LWkOsR0pO8qjGS0l04XE60gsQ+QUN4USYVoMn/+wHH91VLe2w2 IFoAUiO3ZPCc8Yj3ukzT9RNJdxjX4gFUhklefw20uvtF/wxSbEPBVkGic1A+mIPFNalg d12qVl3bpDgb7CBfyMSikFSRC9yoLQjC4JDgNB+75VCkpskTzhSeyb8Zej5MGrjWsqdx MJAPPZyDBxJ8xmuFvosbN4cLRZXnTRuUBMKElykQRMHQntCWR5vPPcyY/zTHbhPISjAA U10ynOJ9l6spcD0r+1QqNKTvksfa0wZOeqVpm7ic7IEt7rCCxIQDVPyfDYnneQ5HbG6X UkOQ== X-Gm-Message-State: APjAAAXmefY1cMmno0IYlj3wh1dT1sUqFsU4c0fyHwV15624rQO2G6Rc VPy1cnnrCw3B/rWg24e+tinL+A== X-Google-Smtp-Source: APXvYqyY6RdF/VL9iKR+Dn640qMh2T+dCAVMBAhbWxEWLJANF3ujtebGYHqiEGcZX5ca2hsGtxbCWg== X-Received: by 2002:a62:e718:: with SMTP id s24mr51969126pfh.247.1557983371371; Wed, 15 May 2019 22:09:31 -0700 (PDT) Received: from buildserver-90.open-silicon.com ([114.143.65.226]) by smtp.googlemail.com with ESMTPSA id u6sm5929531pfa.1.2019.05.15.22.09.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 May 2019 22:09:30 -0700 (PDT) From: Sagar Shrikant Kadam To: robh+dt@kernel.org, mark.rutland@arm.com, peter@korsgaard.com, andrew@lunn.ch, palmer@sifive.com, paul.walmsley@sifive.com, sagar.kadam@sifive.com, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] dt-bindings: i2c: extend existing opencore bindings. Date: Thu, 16 May 2019 10:38:38 +0530 Message-Id: <1557983320-14461-2-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557983320-14461-1-git-send-email-sagar.kadam@sifive.com> References: <1557983320-14461-1-git-send-email-sagar.kadam@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190515_220932_139630_31EAF1F0 X-CRM114-Status: GOOD ( 10.66 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add FU540-C000 specific device tree bindings to already available i2-ocores file. This device is available on HiFive Unleashed Rev A00 board. Move interrupt and interrupt parents under optional property list as these can be optional. The FU540-C000 SoC from sifive, has an Opencore's I2C block reimplementation. The DT compatibility string for this IP is present in HDL and available at. https://github.com/sifive/sifive-blocks/blob/master/src/main/scala/devices/i2c/I2C.scala#L73 Signed-off-by: Sagar Shrikant Kadam --- Documentation/devicetree/bindings/i2c/i2c-ocores.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt index 17bef9a..b73960e 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-ocores.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-ocores.txt @@ -2,8 +2,11 @@ Device tree configuration for i2c-ocores Required properties: - compatible : "opencores,i2c-ocores" or "aeroflexgaisler,i2cmst" + "sifive,fu540-c000-i2c" or "sifive,i2c0". + for Opencore based I2C IP block reimplemented in + FU540-C000 SoC.Please refer sifive-blocks-ip-versioning.txt + for additional details. - reg : bus address start and address range size of device -- interrupts : interrupt number - clocks : handle to the controller clock; see the note below. Mutually exclusive with opencores,ip-clock-frequency - opencores,ip-clock-frequency: frequency of the controller clock in Hz; @@ -12,6 +15,8 @@ Required properties: - #size-cells : should be <0> Optional properties: +- interrupt-parent: handle to interrupt controller. +- interrupts : interrupt number. - clock-frequency : frequency of bus clock in Hz; see the note below. Defaults to 100 KHz when the property is not specified - reg-shift : device register offsets are shifted by this value From patchwork Thu May 16 05:08:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagar Shrikant Kadam X-Patchwork-Id: 10945635 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6DBFC912 for ; Thu, 16 May 2019 05:09:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A566289B7 for ; Thu, 16 May 2019 05:09:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DAD828A6A; Thu, 16 May 2019 05:09:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F3C0E289B7 for ; Thu, 16 May 2019 05:09:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BRgh1bcz6DQoTYk5V3+a1g0yilWTXPv7hkoS3MyCIyA=; b=I/WqpVU5i39dc3 bl8w8E+sL+AJHMUX30Z59BKyJLphh7DJNRQ5DqSv9k/7IZMxdqg6zlT/yxKFVXtaXAVY1q1JW/U3X jGkMJyls/39NZ7udo9tRJj1QjtELCTvcGkMZmJFpP/owThNPUmGwIxVefZv6yPBJwp2UxEcbEHko2 sks7CYNGMxx7XVIPJXjOK9uwO1GJxiRwXmJ3iC31YmXT9w9NvkTg/1GjJJu27H8l5GFMMKcp87dP3 y2cfaBPCbe+mcfqV4ii0sQq2KI+q2zAYkFyd0mGIoozUTSE0qFNcSr+fgEEj22B8HRNyWzXQUqIns 39csQ/KMX11+VBuUnpSg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hR8eC-0006F1-QF; Thu, 16 May 2019 05:09:40 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hR8eA-0006EP-QQ for linux-riscv@lists.infradead.org; Thu, 16 May 2019 05:09:40 +0000 Received: by mail-pf1-x441.google.com with SMTP id n19so1194496pfa.1 for ; Wed, 15 May 2019 22:09:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=4KK0MRvh5MgzBUDrn06tdDHg6h6KtmoqvmbKK6rVaok=; b=lCT8NThGdj/CZVbU3O1mllDstxzU6H3DmbI36AAMAJgIy0GB1HSZ0v8w4a2DRF468Y DeG7kvpHvvTSR4SxEiSV0++dI79XONMqjE2Ps+J1QNvB5iib3wmn5e8nSaZG68kMS+AN hgu+cq0zdUPUyN5qOAsb9IgVmxIzfqCVSGFPqIljut4NuezCSblMIYw9pQCEfGw2eheQ el+zFMF3+U8WkFjYO9FV0AbBXmIzN8/EBHji7txCweH/5/fD/co3YFPsBXUbzC1ZhZLv u8hqsC7IBacwHqbh0v8cV2GTcV3OPGr8KDzz28zQTRkLjQcZ0zIvpsnO5dK7PMoh614f TcCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=4KK0MRvh5MgzBUDrn06tdDHg6h6KtmoqvmbKK6rVaok=; b=ALndOtdualOm+4JGMGiFnCj7kWGWu+djrN+sm9fcJVC0MND81bL+cVy5C3bnATf6j+ yaKQ+YUlS7zPyj5pu45Cy9J4tzF5hoyBYxhPYcJ0Getz9oGuum7+TdabnIq3wqV4/+3c S9DLndtbV4Oj8XBnrssTOvNqDzM70UDenAhXlAge+9f87FTx8F9Y1/0aA7oHDnY6v0Hf SVC4Bx5AAbaeI4cEJBgkgCvVRwmDCr+OtZ3HRHp73noCWF9NwAofDiOyIoQSOI3vPykn spSGxstHlBOcI4aONRQycbkeTCDfTquyXY8gg1lTPygS3t/hwk3h5by8p9lKk6ScBwj8 BUwg== X-Gm-Message-State: APjAAAUFDXliI+yn0PVpM01hu328gX97uDR5oA8gIgvxs3N712rrYEHL 1+tXgSbJayPaRDPhtoShD3YPTw== X-Google-Smtp-Source: APXvYqzyrM198VsHH3arYEHVm5+5CB+0pWo6NzSLosqF9cg2Y4ZM98S/rohCuz5MMvRCx0Dqtxav7w== X-Received: by 2002:a63:234c:: with SMTP id u12mr49894719pgm.264.1557983378110; Wed, 15 May 2019 22:09:38 -0700 (PDT) Received: from buildserver-90.open-silicon.com ([114.143.65.226]) by smtp.googlemail.com with ESMTPSA id u6sm5929531pfa.1.2019.05.15.22.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 May 2019 22:09:37 -0700 (PDT) From: Sagar Shrikant Kadam To: robh+dt@kernel.org, mark.rutland@arm.com, peter@korsgaard.com, andrew@lunn.ch, palmer@sifive.com, paul.walmsley@sifive.com, sagar.kadam@sifive.com, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] i2c-ocore: sifive: add support for i2c device on FU540-c000 SoC. Date: Thu, 16 May 2019 10:38:39 +0530 Message-Id: <1557983320-14461-3-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557983320-14461-1-git-send-email-sagar.kadam@sifive.com> References: <1557983320-14461-1-git-send-email-sagar.kadam@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190515_220938_852769_EDDAC58D X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Update device id table for Opencore's I2C master based re-implementation used in FU540-c000 chipset on HiFive Unleashed platform. Device ID's include Sifive, soc-specific device for chip specific tweaks and sifive IP block specific device for generic programming model. Signed-off-by: Sagar Shrikant Kadam --- drivers/i2c/busses/i2c-ocores.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 4e1a077..aee1d86 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c @@ -85,6 +85,7 @@ struct ocores_i2c { #define TYPE_OCORES 0 #define TYPE_GRLIB 1 +#define TYPE_SIFIVE_REV0 2 static void oc_setreg_8(struct ocores_i2c *i2c, int reg, u8 value) { @@ -468,6 +469,14 @@ static u32 ocores_func(struct i2c_adapter *adap) .compatible = "aeroflexgaisler,i2cmst", .data = (void *)TYPE_GRLIB, }, + { + .compatible = "sifive,fu540-c000-i2c", + .data = (void *)TYPE_SIFIVE_REV0, + }, + { + .compatible = "sifive,i2c0", + .data = (void *)TYPE_SIFIVE_REV0, + }, {}, }; MODULE_DEVICE_TABLE(of, ocores_i2c_match); From patchwork Thu May 16 05:08:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagar Shrikant Kadam X-Patchwork-Id: 10945637 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30481912 for ; Thu, 16 May 2019 05:09:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1CD5A289B7 for ; Thu, 16 May 2019 05:09:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D4B828A6A; Thu, 16 May 2019 05:09:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 973F5289B7 for ; Thu, 16 May 2019 05:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=szlFidiTLa0xOcq4rbXjm+xrwCiAearVv3flp1/gitk=; b=HDS8fBFBtAMaD+ cOh7UDOVTKaH6zRE1qNHJ/VRA0m4kmkR+TC4wWlaOANaFqleb+W97Qbz4AAPAJS/FZ80HSjLJpCLw ENOwrIUcfa4gnuMNbDrBfVBxUbQg0KDHntvrolyGMvoniPsQbomrchMk9n1UOCTofqhWYPmcppuul ufYY6c4epX0+tLSFrdqOxGeH/Nq+rIsKlGhN+7jvs8hpLOn08qhB8LriAjmTCF3fiQWJJc84/8Qc3 WCTzpiyrU964APlTlO1AC8p7vMiZpztajHOBsHBmy748B3wwCHPmhiWLXPt4AIhHvxIXeTvIcUQOa +l6voUvCWSdmnlEWETyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hR8eK-0006Ir-D7; Thu, 16 May 2019 05:09:48 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hR8eH-0006I6-1M for linux-riscv@lists.infradead.org; Thu, 16 May 2019 05:09:46 +0000 Received: by mail-pl1-x642.google.com with SMTP id c5so974319pll.11 for ; Wed, 15 May 2019 22:09:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=agOsn/FsJEMc+Zf/iAfFT/NhIk1MJBZxFX9gyrs1azc=; b=C7XFLkG1+645K/z9YPQ8jDojz6KnEEmXqDTB1ykI6sc64RJeJDUZR5J5OoM9qn9Gcy 5XnW4jrY9Q0qnFQ6klWH7yLSifNUGdW58uS+728vWOTcXgvHgjaQwkRtDStMrRA9xPd1 B0VW4LH2mHoLkJ9WKwhZ52YvjhnEhWzy7MhWcCZLQ55JLD9yzPtUhA+7tZRiVaMGrI4g 5R0bkfsGDJhpPNha5vbqaPEETH2Qy9xfd9r0Z7CHpnMBVzAi+Uk9sC6+bxFR8O/9i65q 1hBPlEJR7AXr9G4F0EayyPMxMdgdA2cWm/mg8TeAtRgA0Ez4/ArhdUhl+36/zuvoweD8 petw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=agOsn/FsJEMc+Zf/iAfFT/NhIk1MJBZxFX9gyrs1azc=; b=SqiA9ubQsQJTFlnE7nBW41UHnzAvWY9c9icb0vrHipTJ5uF3hPwl+a17lv+c+4zHy0 9RiQY5rcWFlnhS7TmfMbkljfcJXBDH7CJKmVtwAH2/jT0/LnZuiNQZ5PshkXSuAdWUE1 wcYjWFPaPYmTsCrnqTmoktI5ONqT0sMgNiRj0BLm2PgzwU6TEOzk+Jdev7W6MhILqfzQ x/RIhOhvQoieDMIhdDgnrj624zFosdchgaA/OrZgym3oJfEkmHHoAjSzuI0l5H7AxzLz RftDZM+B4Ds7t2I72GO9a7SeBfxfJPW+qXoIhGW/bWzMzPilFijFQF3bkICE95QR0l1A X5Uw== X-Gm-Message-State: APjAAAVio21ERbJwk6XLi6g7k8Z9KMYJG3CiE2ek+JtVNmyvpwLe0SxA wqdu9/JuM+vSyN+sVNCM1ZWrXg== X-Google-Smtp-Source: APXvYqyOeGqGHbyS1GYeHd3FsJ1ZgTt6oYeWr0jHKsYiJtZNEzr0IKux09yyFHVwkYQTcv7TjxWQsQ== X-Received: by 2002:a17:902:2d:: with SMTP id 42mr48829831pla.34.1557983384320; Wed, 15 May 2019 22:09:44 -0700 (PDT) Received: from buildserver-90.open-silicon.com ([114.143.65.226]) by smtp.googlemail.com with ESMTPSA id u6sm5929531pfa.1.2019.05.15.22.09.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 May 2019 22:09:43 -0700 (PDT) From: Sagar Shrikant Kadam To: robh+dt@kernel.org, mark.rutland@arm.com, peter@korsgaard.com, andrew@lunn.ch, palmer@sifive.com, paul.walmsley@sifive.com, sagar.kadam@sifive.com, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 3/3] i2c-ocores: sifive: add polling mode workaround for FU540-C000 SoC Date: Thu, 16 May 2019 10:38:40 +0530 Message-Id: <1557983320-14461-4-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557983320-14461-1-git-send-email-sagar.kadam@sifive.com> References: <1557983320-14461-1-git-send-email-sagar.kadam@sifive.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190515_220945_083981_A839444F X-CRM114-Status: GOOD ( 15.27 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-riscv" Errors-To: linux-riscv-bounces+patchwork-linux-riscv=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The i2c-ocore driver already has a polling mode interface.But it needs a workaround for FU540 Chipset on HiFive unleashed board (RevA00). There is an erratum in FU540 chip that prevents interrupt driven i2c transfers from working, and also the I2C controller's interrupt bit cannot be cleared if set, due to this the existing i2c polling mode interface added in mainline earlier doesn't work, and CPU stall's infinitely, when-ever i2c transfer is initiated. Ref:previous polling mode support in mainline commit 69c8c0c0efa8 ("i2c: ocores: add polling interface") The workaround / fix under OCORES_FLAG_BROKEN_IRQ is particularly for FU540-COOO SoC. Signed-off-by: Sagar Shrikant Kadam --- drivers/i2c/busses/i2c-ocores.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index aee1d86..00ee45c 100644 --- a/drivers/i2c/busses/i2c-ocores.c +++ b/drivers/i2c/busses/i2c-ocores.c @@ -27,6 +27,7 @@ #include #define OCORES_FLAG_POLL BIT(0) +#define OCORES_FLAG_BROKEN_IRQ BIT(2) /* Broken IRQ in HiFive Unleashed */ /* * 'process_lock' exists because ocores_process() and ocores_process_timeout() @@ -239,9 +240,13 @@ static irqreturn_t ocores_isr(int irq, void *dev_id) struct ocores_i2c *i2c = dev_id; u8 stat = oc_getreg(i2c, OCI2C_STATUS); - if (!(stat & OCI2C_STAT_IF)) + if (i2c->flags & OCORES_FLAG_BROKEN_IRQ) { + if (stat & OCI2C_STAT_IF) + if (!(stat & OCI2C_STAT_BUSY)) + return IRQ_NONE; + } else if (!(stat & OCI2C_STAT_IF)) { return IRQ_NONE; - + } ocores_process(i2c, stat); return IRQ_HANDLED; @@ -356,6 +361,11 @@ static void ocores_process_polling(struct ocores_i2c *i2c) ret = ocores_isr(-1, i2c); if (ret == IRQ_NONE) break; /* all messages have been transferred */ + else { + if (i2c->flags & OCORES_FLAG_BROKEN_IRQ) + if (i2c->state == STATE_DONE) + break; + } } } @@ -406,7 +416,7 @@ static int ocores_xfer(struct i2c_adapter *adap, { struct ocores_i2c *i2c = i2c_get_adapdata(adap); - if (i2c->flags & OCORES_FLAG_POLL) + if ((i2c->flags & (OCORES_FLAG_POLL | OCORES_FLAG_BROKEN_IRQ))) return ocores_xfer_polling(adap, msgs, num); return ocores_xfer_core(i2c, msgs, num, false); } @@ -471,7 +481,7 @@ static u32 ocores_func(struct i2c_adapter *adap) }, { .compatible = "sifive,fu540-c000-i2c", - .data = (void *)TYPE_SIFIVE_REV0, + .data = (void *)(TYPE_SIFIVE_REV0 | OCORES_FLAG_BROKEN_IRQ), }, { .compatible = "sifive,i2c0", @@ -601,6 +611,7 @@ static int ocores_i2c_probe(struct platform_device *pdev) { struct ocores_i2c *i2c; struct ocores_i2c_platform_data *pdata; + const struct of_device_id *match; struct resource *res; int irq; int ret; @@ -682,13 +693,24 @@ static int ocores_i2c_probe(struct platform_device *pdev) irq = platform_get_irq(pdev, 0); if (irq == -ENXIO) { - i2c->flags |= OCORES_FLAG_POLL; + /* + * Set a OCORES_FLAG_BROKEN_IRQ to enable workaround for + * FU540-C000 SoC in polling mode interface of i2c-ocore driver. + * Else enable default polling mode interface for SIFIVE/OCORE + * device types. + */ + match = of_match_node(ocores_i2c_match, pdev->dev.of_node); + if (match && (long)match->data == + (TYPE_SIFIVE_REV0 | OCORES_FLAG_BROKEN_IRQ)) + i2c->flags |= OCORES_FLAG_BROKEN_IRQ; + else + i2c->flags |= OCORES_FLAG_POLL; } else { if (irq < 0) return irq; } - if (!(i2c->flags & OCORES_FLAG_POLL)) { + if (!(i2c->flags & (OCORES_FLAG_POLL | OCORES_FLAG_BROKEN_IRQ))) { ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, pdev->name, i2c); if (ret) {