From patchwork Mon May 6 12:53:58 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: 1095822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="AE1PXGLZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44yN73677Zz9s7T for ; Mon, 6 May 2019 22:57:19 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726319AbfEFM5N (ORCPT ); Mon, 6 May 2019 08:57:13 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:46219 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726034AbfEFM5N (ORCPT ); Mon, 6 May 2019 08:57:13 -0400 Received: by mail-pl1-f196.google.com with SMTP id bi2so6325322plb.13 for ; Mon, 06 May 2019 05:57:13 -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=UEMFuO/eOkfUtvyg6UNn5h6oENU1qFZHdaBFePFfFNQ=; b=AE1PXGLZJecXBOPRAwBuRMnblokvY4Q0jBYbOPQUH9ga6NW/3/iRhy1M0MHq3tbdCX uJsgHg/lIEiG1eqxsvpOAbsVrjZ4d1hiKTvsA8UuyG735bRdSD5cepmrQY0TJFFtEss0 wq7sz+SKcZa17jAwJaviUSTfm9zOEbyO89WD2RPCMpoe6JGbRvL7PMlSyv7owG0Xdz61 xJHhbCDWt6cYgJH2Om2zDxvsszmaxJ+vEwmAE/8S8yp5pJbAtvq4LzaSKyVeyIZsTkJx +5ewBdy38Br3/bkNF36vOwS7Calww1lDF8AYQP9HBkuEOwP44x1agCGai3klUr1BMjjN joCA== 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=UEMFuO/eOkfUtvyg6UNn5h6oENU1qFZHdaBFePFfFNQ=; b=IL98++al94VfYx9MxCJ6jAUo1k27JZH5iOgMJjGepBoM4ZRl8aX9BNEG+3ZWCh2ntR gsrJpK8bhAIEUaiBSTO5xe+tY5Fl+vZg1ebjLY/XFUAeQXhsnfHK+FEl1DF+qx63fI8o kmRYWbgvRXLRjtDg/R4vGxP5kYfjlHKBvGyGXCLpm4FSjmzY7sifIJmd1AP1zj5YJgnx pXZzA/Ey+7wydKDFmM9JEre4Hb3A9PxadKfenwTfiUE6GnhOf1AfZO0dK1sUxvOBvH0B b64mJhEkxvXDv6eM9ZPbWcBqSIeF5XyUZxY04OV3d2xG5xf7imfq1HKxzLCXjEtEXOup zF3w== X-Gm-Message-State: APjAAAXCJuhxdYEHYhYQIGkWF76NSfuEZIhX8XynojpVNDkrkobo7Hk2 Uu+yYGtmd+BUJFCdHWN8V2GOAw== X-Google-Smtp-Source: APXvYqwOMXzzUAwPKPtRF+CBlMJBVPfD958G5aEnOG3pjXTVVfmOZ08lmJe4WL3RA/tBI9KTIOPqug== X-Received: by 2002:a17:902:a503:: with SMTP id s3mr31394556plq.16.1557147432852; Mon, 06 May 2019 05:57:12 -0700 (PDT) Received: from buildserver-90.open-silicon.com ([114.143.65.226]) by smtp.googlemail.com with ESMTPSA id p81sm18031132pfa.26.2019.05.06.05.57.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 05:57:12 -0700 (PDT) From: Sagar Shrikant Kadam To: robh+dt@kernel.org, mark.rutland@arm.com, palmer@sifive.com, paul.walmsley@sifive.com, sagar.kadam@sifive.com, peter@korsgaard.com, andrew@lunn.ch, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 v1 1/3] dt-bindings: i2c: add documentation for adding SiFive I2C driver Date: Mon, 6 May 2019 18:23:58 +0530 Message-Id: <1557147240-29551-2-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557147240-29551-1-git-send-email-sagar.kadam@sifive.com> References: <1557147240-29551-1-git-send-email-sagar.kadam@sifive.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add DT binding for OpenCore's based i2c device as found in FU540 Chipset on HiFive Unleashed Platform (Rev A00). The doc explains, how to add DT support for I2C devices. Signed-off-by: Sagar Shrikant Kadam --- .../devicetree/bindings/i2c/i2c-sifive.txt | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/i2c/i2c-sifive.txt diff --git a/Documentation/devicetree/bindings/i2c/i2c-sifive.txt b/Documentation/devicetree/bindings/i2c/i2c-sifive.txt new file mode 100644 index 0000000..2a0fc9b --- /dev/null +++ b/Documentation/devicetree/bindings/i2c/i2c-sifive.txt @@ -0,0 +1,29 @@ +SiFive I2C controller Device Tree Bindings +------------------------------------------------- + +Required properties: + +- compatible : Should be "sifive,-i2c" for a particular chip or + "sifive,i2c" for a general I2C block. + For FU540 chipset the supported compatible string is "sifive,fu540-c000-i2c". +- reg : Physical base address and size of I2C registers map. +- reg-names : Should contain the resource reg names. +- clocks : Must reference the frequency given to the controller. +- #address-cells : Must be '1'. +- #size-cells : Must be '0'. +- clock-frequency : desired I2C bus clock frequency. + +Example: + i2c@10030000 { + compatible = "sifive,i2c0","sifive,fu540-c000-i2c"; + reg = <0x0 0x10030000 0x0 0x1000>; + reg-names = "i2c-control"; + clocks = <&tlclk>; + clock-frequency = <100000>; + + reg-shift = <2>; + reg-io-width = <1>; + + #address-cells = <1>; + #size-cells = <0>; + }; From patchwork Mon May 6 12:53:59 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: 1095823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="hKnJBVWq"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44yN7P3W40z9s9y for ; Mon, 6 May 2019 22:57:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726439AbfEFM5b (ORCPT ); Mon, 6 May 2019 08:57:31 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39130 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726424AbfEFM52 (ORCPT ); Mon, 6 May 2019 08:57:28 -0400 Received: by mail-pf1-f194.google.com with SMTP id z26so6737023pfg.6 for ; Mon, 06 May 2019 05:57:28 -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=AZwN4Y8XxFUK2pvt2N7G+01LXJuGE7M19RGGBuG2SYw=; b=hKnJBVWqMGJCsq/b4yG5yQ3YyVPH8QCMFEt15kpkj0ig0/GAPBdsTC7mLxoDrvbhMX mLHM301iBO2DSckX1JDR9YUqGRrQzzmT/7wzfPxD2iMHTygGIYoQPGP5SUZIPgmlyEHn v5ekJE76muREcBmXVd29r6Kf96uVKyvgZlNF+HMrDmOpN4dxHJqZHbhCTVgnBDra93Ul RdN5vSctEmwI9geG2kgV0nGD7C2NmdtTb4mg1SgSQBL9TwDPEJdO5QPBm1jB2CYw5is8 w6I7atptCsJeuLv1BNzLZPApIqAfpJbYLoRK7/D891Uzhl6ZH3Lggynd4lWIrZmWIFOl fwUA== 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=AZwN4Y8XxFUK2pvt2N7G+01LXJuGE7M19RGGBuG2SYw=; b=rDo/T0VVL9Le8QYKY8Sev3FBTdkfsSHBPJFnfEQiNjG+S/ZsgAc9vt9w06Q/o203Bm /cBk+IKoaAiDvCwanmMfvv/r814szyy158kTdEq/rwldNMEkWFXIwxnGxTcRd3p+Zndv no/Pz4u1bf5wjhuxziT0FFJ9DcmSWkQYFHHq8pxwCRJpUAOhFRZv9++XtlKaosIKFfoz Vi6s4YrExEnlxgVgjgqLGQiMCLcqfhIk4ajr8ino45d5yuzKscaD4eIlYQK8RbmGDgdb 3jwUJj5Rvo1cLy6RZjyjMdP5BcKhUgJZQwB6BaoQ8LtPa8tNYfrp+ig6FV0aPGiNjIW2 mP0g== X-Gm-Message-State: APjAAAUIEM3hKYV8ZdZCcnt4lXe5J+CG05iRXEj4++WDBPxWNY1RES2L lU1yktapISRzVzdG33Pg/FJhOQ== X-Google-Smtp-Source: APXvYqySdJKvrX5oi/GsnI2Zz/4BtbWRcPafJni1v7sN+SE8nvhny3X09satX04k94LSFysH41SGqw== X-Received: by 2002:a65:654c:: with SMTP id a12mr31839474pgw.101.1557147447917; Mon, 06 May 2019 05:57:27 -0700 (PDT) Received: from buildserver-90.open-silicon.com ([114.143.65.226]) by smtp.googlemail.com with ESMTPSA id p81sm18031132pfa.26.2019.05.06.05.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 05:57:27 -0700 (PDT) From: Sagar Shrikant Kadam To: robh+dt@kernel.org, mark.rutland@arm.com, palmer@sifive.com, paul.walmsley@sifive.com, sagar.kadam@sifive.com, peter@korsgaard.com, andrew@lunn.ch, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 v1 2/3] i2c-ocore: sifive: add support for i2c device on FU540-c000 SoC. Date: Mon, 6 May 2019 18:23:59 +0530 Message-Id: <1557147240-29551-3-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557147240-29551-1-git-send-email-sagar.kadam@sifive.com> References: <1557147240-29551-1-git-send-email-sagar.kadam@sifive.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Update device id table for Opencores I2C master used in HiFive Unleashed platform having FU540-c000 chipset. Signed-off-by: Sagar Shrikant Kadam --- drivers/i2c/busses/i2c-ocores.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 4e1a077..7bf7b0c 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) { @@ -465,6 +466,10 @@ static u32 ocores_func(struct i2c_adapter *adap) .data = (void *)TYPE_OCORES, }, { + .compatible = "sifive,fu540-c000-i2c", + .data = (void *)TYPE_SIFIVE_REV0, + }, + { .compatible = "aeroflexgaisler,i2cmst", .data = (void *)TYPE_GRLIB, }, From patchwork Mon May 6 12:54:00 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: 1095824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="eLarq4Ff"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44yN7t3bgfz9s7T for ; Mon, 6 May 2019 22:58:02 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726197AbfEFM6B (ORCPT ); Mon, 6 May 2019 08:58:01 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41730 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbfEFM6B (ORCPT ); Mon, 6 May 2019 08:58:01 -0400 Received: by mail-pg1-f196.google.com with SMTP id z3so2723094pgp.8 for ; Mon, 06 May 2019 05:58:01 -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=3yJBCKGR2L57C08ZCcNvx8rpcWn4E4qX0pN/jP148ZU=; b=eLarq4Ffp7BjsITqSQlz2hSLPWtaejD9F29WXPEMw2SqJDUECmBS4D7XP1Pt5cl+Gj 6Qim1TVRAg/xxrtKNnSMLQ1sFJyWF3z8/K4E48r2dufIm4l8G9mRpjrcRd/z5J8qu22a vcWshiwGN/r2EzzCR4FftWIW614/C17yN/JKBzSAlxD4hNwdI4eMxGWHbosZcWaBw/TD +tq4tFRIMr5icG/Elbt41wWtleyysZxvvScYYpCG9VWOIZfmIDUk9b1PfxTQOttXQKMu SJD6DliKlgTV+WndmwX90KWxulzq7oC/wbbkYnMXkCyQB2I/XDdlcdnIW9RGJQmn4i5W AJlA== 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=3yJBCKGR2L57C08ZCcNvx8rpcWn4E4qX0pN/jP148ZU=; b=uPg7HiEoolat8eMSDTMrzaHMRuYuBVbO/eRlcZkaw0Qx8NcGP09k/1U72xdzSu/5I9 pUmeAZzRfXkQizI/7Qc6DdH3IQrhKO5ibIYM80EPoGv3Mc1NB3+enfKQUfR5X6a3m/yf VBiZO5vNa/6Owk+UOgynlbrd0Ag4PjMDPqDNtpljVJ0670AK/DrDx4+ZKBSz47Uto8Vn C/pR0uckVrM5buBweirfLyOGv0kt3oDAgh8So5qkRGxUTPovi4yUzvsxRiPb9ZXOXQfI zu8FrrwLuUmpg0SaUopXhLqt3wKCJ89aGqvO2BLHNkBwojIdb4wcz3wN4sjWoryNOjUi Lbfg== X-Gm-Message-State: APjAAAXf8oHlILgUmqxVyy8olgcknx+usi/8YSFkFgnBUWLTDjSydc7F yd4NzH+eigAI42tHEfyAPW0MGw== X-Google-Smtp-Source: APXvYqzOLRJnZ/ugQgGd1S7emDFcNYFDNzwkPn6sKQ1ywPvxa6ZPbBSvOcGtuJOVmTmh8hb5KAhWdQ== X-Received: by 2002:a63:fd08:: with SMTP id d8mr31596695pgh.141.1557147480957; Mon, 06 May 2019 05:58:00 -0700 (PDT) Received: from buildserver-90.open-silicon.com ([114.143.65.226]) by smtp.googlemail.com with ESMTPSA id p81sm18031132pfa.26.2019.05.06.05.57.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 06 May 2019 05:58:00 -0700 (PDT) From: Sagar Shrikant Kadam To: robh+dt@kernel.org, mark.rutland@arm.com, palmer@sifive.com, paul.walmsley@sifive.com, sagar.kadam@sifive.com, peter@korsgaard.com, andrew@lunn.ch, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 v1 3/3] i2c-ocores: sifive: add polling mode workaround for FU540-C000 SoC. Date: Mon, 6 May 2019 18:24:00 +0530 Message-Id: <1557147240-29551-4-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557147240-29551-1-git-send-email-sagar.kadam@sifive.com> References: <1557147240-29551-1-git-send-email-sagar.kadam@sifive.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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. commit 69c8c0c0efa8 ("i2c: ocores: add polling interface") The workaround / fix is particularly for FU540-COOO SoC. Signed-off-by: Sagar Shrikant Kadam --- drivers/i2c/busses/i2c-ocores.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c index 7bf7b0c..08cdfed 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 SIFIVE_FLAG_POLL BIT(1) /* * 'process_lock' exists because ocores_process() and ocores_process_timeout() @@ -239,8 +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 && SIFIVE_FLAG_POLL) { + 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); @@ -356,6 +362,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 && SIFIVE_FLAG_POLL) + if (i2c->state == STATE_DONE) + break; + } } } @@ -406,7 +417,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) || (i2c->flags & SIFIVE_FLAG_POLL)) return ocores_xfer_polling(adap, msgs, num); return ocores_xfer_core(i2c, msgs, num, false); } @@ -597,6 +608,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; @@ -678,13 +690,21 @@ 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 SIFIVE_FLAG_POLL to enable workaround for FU540 + * in polling mode interface of i2c-ocore driver. + */ + match = of_match_node(ocores_i2c_match, pdev->dev.of_node); + if (match && (long)match->data == TYPE_SIFIVE_REV0) + i2c->flags |= SIFIVE_FLAG_POLL; + else + i2c->flags |= OCORES_FLAG_POLL; } else { if (irq < 0) return irq; } - if (!(i2c->flags & OCORES_FLAG_POLL)) { + if (!(i2c->flags & (OCORES_FLAG_POLL | SIFIVE_FLAG_POLL))) { ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, pdev->name, i2c); if (ret) {