From patchwork Mon Nov 2 03:54:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1391916 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=RlqHbovU; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CPfFG5YJZz9sVK for ; Mon, 2 Nov 2020 14:54:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727767AbgKBDyz (ORCPT ); Sun, 1 Nov 2020 22:54:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727694AbgKBDyz (ORCPT ); Sun, 1 Nov 2020 22:54:55 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27100C061A04 for ; Sun, 1 Nov 2020 19:54:55 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id k9so7941836pgt.9 for ; Sun, 01 Nov 2020 19:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KJDm2LvMwptGdGbHgqfVLzTRm8Rubitr8aoXAWObMZ4=; b=RlqHbovUNuAYEBRpQGxOXwFCa1nMJewY4BGW4okwyZA4P/+VNpAqFM9kqQ++0+HWVQ iYtMzvn0PdpxI2TEZAirP8oxFlj4ujXgSqBZLLB8VC7SvxYLanKoFhkPshEw5w+vD9i8 9Euv3cADifxJABX2OekjOQpTGb7/GegL6eUqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KJDm2LvMwptGdGbHgqfVLzTRm8Rubitr8aoXAWObMZ4=; b=mpQEfLVDNVMbZ8e+VfGv/8axnFK+fGjsIDAhbCWRVF7r8c1FuqZxnPXotSInrBMpej 2xPLhuNyV2gR9/CwXEAThXV0B1InjPp6/MquoUb4pEv8owXZxPbQ+pbq9F/fiYGIzKOS /hlC0Rqt5SjOpvS7sr3hkiKBX2o7E7Y7JCK4eNJI/8sx+kZZiW8BgDQnv6RyIJviWEVE Nj+/QJACVzN5Yd+wPmQcXhLYAF9YC9uld+hWZJgjgs5tgnimARoVmxf4We+ISnPZ46Oa GzWHuPRg5B8/GQ89Xl0WwoeYU4gAhA+uM43mBtuxBNrwz+wxvfuSvr+61Io1P9ZVYMjj HbEw== X-Gm-Message-State: AOAM5315J5PcJTH5tEUY+4P39DzIB2Pu1irHp4g+XeCB8XIdDuz6qOTo RkqokYv95ChkfGMLPJtvczA63g== X-Google-Smtp-Source: ABdhPJwYB7XMYT2ERy6b1KACo/JPeZdWqgosJ2FZaeQF6Typ3caft/wf6DmPo2Vxrsb250lnvdR0nA== X-Received: by 2002:aa7:91cf:0:b029:18a:9972:1aa9 with SMTP id z15-20020aa791cf0000b029018a99721aa9mr10873546pfa.46.1604289294415; Sun, 01 Nov 2020 19:54:54 -0800 (PST) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y5sm5655711pfc.165.2020.11.01.19.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 19:54:53 -0800 (PST) From: Rayagonda Kokatanur To: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Wolfram Sang , Florian Fainelli , Brendan Higgins , Andy Shevchenko , Lori Hikichi , Dhananjay Phadke , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rayagonda Kokatanur Subject: [PATCH v3 1/6] i2c: iproc: handle Master aborted error Date: Mon, 2 Nov 2020 09:24:28 +0530 Message-Id: <20201102035433.6774-2-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> References: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Handle Master aborted error by flushing tx and rx fifo and reinitializing the hw. Signed-off-by: Rayagonda Kokatanur Acked-by: Ray Jui --- drivers/i2c/busses/i2c-bcm-iproc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index d8295b1c379d..834a98caeada 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -93,6 +93,7 @@ #define S_CMD_STATUS_MASK 0x07 #define S_CMD_STATUS_SUCCESS 0x0 #define S_CMD_STATUS_TIMEOUT 0x5 +#define S_CMD_STATUS_MASTER_ABORT 0x7 #define IE_OFFSET 0x38 #define IE_M_RX_FIFO_FULL_SHIFT 31 @@ -311,9 +312,10 @@ static void bcm_iproc_i2c_check_slave_status( return; val = (val >> S_CMD_STATUS_SHIFT) & S_CMD_STATUS_MASK; - if (val == S_CMD_STATUS_TIMEOUT) { - dev_err(iproc_i2c->device, "slave random stretch time timeout\n"); - + if (val == S_CMD_STATUS_TIMEOUT || val == S_CMD_STATUS_MASTER_ABORT) { + dev_err(iproc_i2c->device, (val == S_CMD_STATUS_TIMEOUT) ? + "slave random stretch time timeout\n" : + "Master aborted read transaction\n"); /* re-initialize i2c for recovery */ bcm_iproc_i2c_enable_disable(iproc_i2c, false); bcm_iproc_i2c_slave_init(iproc_i2c, true); From patchwork Mon Nov 2 03:54:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1391917 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=bS8kAS8c; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CPfFM6qHkz9sVT for ; Mon, 2 Nov 2020 14:55:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727790AbgKBDzA (ORCPT ); Sun, 1 Nov 2020 22:55:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbgKBDzA (ORCPT ); Sun, 1 Nov 2020 22:55:00 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22F27C061A04 for ; Sun, 1 Nov 2020 19:55:00 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id c20so9913814pfr.8 for ; Sun, 01 Nov 2020 19:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GksAtHyTZZFp2zs1mWIjBdTpnEfnPhgQU/jfjVENEd8=; b=bS8kAS8cSwBzs3kqWvwxf4HfiStbPcIzLeUU13oJuzHBryVW4xyagBahAmMbpJbPNn zCuAR0HdS2htRV3yOi/AGz8Qspoth/2sUGepNH1imXBXMrTUe+yTv7LoNqbkcgjIuEl9 ZZC7Cx/kX7g30AQJymMf5Cnm5gMICdBOzxf0E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GksAtHyTZZFp2zs1mWIjBdTpnEfnPhgQU/jfjVENEd8=; b=CRBzBQWlGht7p5kjnhUNqtxA/lrgp1Y5uDE4HKoAOr5C9FFRkj+bksRNGCtaRdfqE9 8fSvA+UfeaLyo7KjyuUJ4TyYSn9Ci+jZFFT7dtClB696c1Bgoxh896SBbjkoiRwZlSF+ ymxoHtNVgOwd8WvjdjDSOtha60+4fkawn5EkemLVhTNvYhCNzVceW6bpipjsA3u19arp KSPXne9MxU4O28hqh9iBTMTO+XEXWA9usduB3qEFqo3mr1QQcwIjIP7BQpeAgvOGlJA9 87n2zjj2tPLnJP8iGRUaFcRxYQAEwxC2snZnN8PJOwU50NJZ39BQFSdZwxGn4yf2NYb5 N5SA== X-Gm-Message-State: AOAM530cfbwFdYsWAfxMNk9xFmDl4ljbHRj5x4q+4zO4zNGJVfW1Rdyz CELvpeLTztobxAeZKhGv6gsJew== X-Google-Smtp-Source: ABdhPJxxxFUbd1NTgK6ygQCEHCgCT85kN2fmMUT5stR1NptLqeOlY87efKK0yNg/eA+QCHkHM/o/Bg== X-Received: by 2002:a17:90a:9f82:: with SMTP id o2mr9638483pjp.52.1604289299521; Sun, 01 Nov 2020 19:54:59 -0800 (PST) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y5sm5655711pfc.165.2020.11.01.19.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 19:54:58 -0800 (PST) From: Rayagonda Kokatanur To: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Wolfram Sang , Florian Fainelli , Brendan Higgins , Andy Shevchenko , Lori Hikichi , Dhananjay Phadke , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rayagonda Kokatanur Subject: [PATCH v3 2/6] i2c: iproc: handle only slave interrupts which are enabled Date: Mon, 2 Nov 2020 09:24:29 +0530 Message-Id: <20201102035433.6774-3-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> References: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Handle only slave interrupts which are enabled. The IS_OFFSET register contains the interrupt status bits which will be set regardless of the enabling of the corresponding interrupt condition. One must therefore look at both IS_OFFSET and IE_OFFSET to determine whether an interrupt condition is set and enabled. Fixes: c245d94ed106 ("i2c: iproc: Add multi byte read-write support for slave mode") Signed-off-by: Rayagonda Kokatanur Acked-by: Ray Jui --- drivers/i2c/busses/i2c-bcm-iproc.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index 834a98caeada..b54f5130d246 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -507,12 +507,17 @@ static void bcm_iproc_i2c_process_m_event(struct bcm_iproc_i2c_dev *iproc_i2c, static irqreturn_t bcm_iproc_i2c_isr(int irq, void *data) { struct bcm_iproc_i2c_dev *iproc_i2c = data; - u32 status = iproc_i2c_rd_reg(iproc_i2c, IS_OFFSET); + u32 slave_status; + u32 status; bool ret; - u32 sl_status = status & ISR_MASK_SLAVE; - if (sl_status) { - ret = bcm_iproc_i2c_slave_isr(iproc_i2c, sl_status); + status = iproc_i2c_rd_reg(iproc_i2c, IS_OFFSET); + /* process only slave interrupt which are enabled */ + slave_status = status & iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET) & + ISR_MASK_SLAVE; + + if (slave_status) { + ret = bcm_iproc_i2c_slave_isr(iproc_i2c, slave_status); if (ret) return IRQ_HANDLED; else From patchwork Mon Nov 2 03:54:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1391918 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=UgudOGAY; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CPfFQ1lM1z9sVK for ; Mon, 2 Nov 2020 14:55:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727826AbgKBDzF (ORCPT ); Sun, 1 Nov 2020 22:55:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727702AbgKBDzF (ORCPT ); Sun, 1 Nov 2020 22:55:05 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F33C061A04 for ; Sun, 1 Nov 2020 19:55:05 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id j18so9941478pfa.0 for ; Sun, 01 Nov 2020 19:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8sTTN5AFyMZw4o9/6ROilB5uwU1I/3OjTtrNfY4VLPM=; b=UgudOGAYfIhTanPtV2upRLh6FyttrgmqHvQcEvcQr/5RgcDL1p8N4npG9wDjMNhwsg dtluth1CFDqnLhaUlRrL+ijauIPsByed6VtOfXLRSvsjoOSSWNTgjP3OUFF9n7vW+myK mV/OhfU71u56f5TNUZ1RgTJilcVFu4uuO4OMw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8sTTN5AFyMZw4o9/6ROilB5uwU1I/3OjTtrNfY4VLPM=; b=U2t3G2UK13EJJew/uht/sj+H4b+ZsVpFyg6vJc1ZdjxL57LWdodameSRum8/aG3f+b NJ5d3DyeJWmTE+p1dc6qdBN4tzIDqv4ZEi8FylVDxu79zaOgzM8iou7/kBYuSwMWHPTT MInsbAP6+tcUpYCdyZQB20yz+PBoJSOTkx3naBVEgYejqZ7Zi0tChO2cYipq1GrMhVIu qzlasAeelu8XMxH9juKcrb352kuUblxT6KLzi74W+NPHXAukW/hD1hIXK/u+2bjFfW1q 4/dfByWb2KUPxt9AuKiMmR/RECvpn6Nq8A0fF2XQ6tcYl//4Zdc0oIMyIeKvzAUx/OE6 lMLQ== X-Gm-Message-State: AOAM532m5oxMOdsOwcmt/1fcA2V92Ql+ZyVlKB4EtqKW0n23UczwWuRD dRTbWbCbZVtLxvX+z+f5o7Nrwg== X-Google-Smtp-Source: ABdhPJzut6+4EzNSm0mqUEiHy7KWoQzAohRf9zDwQwtAUjVOS8h2w9vh1l/BTgxLMgYzEnwjVPfQNQ== X-Received: by 2002:a62:7657:0:b029:152:4d66:dcb with SMTP id r84-20020a6276570000b02901524d660dcbmr20463118pfc.74.1604289304535; Sun, 01 Nov 2020 19:55:04 -0800 (PST) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y5sm5655711pfc.165.2020.11.01.19.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 19:55:03 -0800 (PST) From: Rayagonda Kokatanur To: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Wolfram Sang , Florian Fainelli , Brendan Higgins , Andy Shevchenko , Lori Hikichi , Dhananjay Phadke , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rayagonda Kokatanur Subject: [PATCH v3 3/6] i2c: iproc: update slave isr mask (ISR_MASK_SLAVE) Date: Mon, 2 Nov 2020 09:24:30 +0530 Message-Id: <20201102035433.6774-4-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> References: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Update slave isr mask (ISR_MASK_SLAVE) to include remaining two slave interrupts. Fixes: c245d94ed106 ("i2c: iproc: Add multi byte read-write support for slave mode") Signed-off-by: Rayagonda Kokatanur Acked-by: Ray Jui --- drivers/i2c/busses/i2c-bcm-iproc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index b54f5130d246..cd687696bf0b 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -216,7 +216,8 @@ struct bcm_iproc_i2c_dev { #define ISR_MASK_SLAVE (BIT(IS_S_START_BUSY_SHIFT)\ | BIT(IS_S_RX_EVENT_SHIFT) | BIT(IS_S_RD_EVENT_SHIFT)\ - | BIT(IS_S_TX_UNDERRUN_SHIFT)) + | BIT(IS_S_TX_UNDERRUN_SHIFT) | BIT(IS_S_RX_FIFO_FULL_SHIFT)\ + | BIT(IS_S_RX_THLD_SHIFT)) static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave); static int bcm_iproc_i2c_unreg_slave(struct i2c_client *slave); From patchwork Mon Nov 2 03:54:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1391919 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=L2+uu1dL; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CPfFW72mDz9sVK for ; Mon, 2 Nov 2020 14:55:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727848AbgKBDzL (ORCPT ); Sun, 1 Nov 2020 22:55:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbgKBDzK (ORCPT ); Sun, 1 Nov 2020 22:55:10 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A499BC0617A6 for ; Sun, 1 Nov 2020 19:55:10 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id w65so9930375pfd.3 for ; Sun, 01 Nov 2020 19:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9v5ya7Dj3TDsokfeg7wV2+M3UCVwbFUmjVB4QAi1TP8=; b=L2+uu1dLnxtRfRz7QrmPy8gaKjt28q64u7UyA6iY/GRRRCu1h0CgmMGiU5Pji3WN0K k2FSk949rlV9oXvgGOMaDfEIfAPlvbdrwS95xLratzmQFfrBOTyx/oIBLJbnLyvCQukv pVA/OYuvTUL6s/Z0aKO9i0TxMkKglSijiXHlY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9v5ya7Dj3TDsokfeg7wV2+M3UCVwbFUmjVB4QAi1TP8=; b=edkREovbeMrWoNtwnPuSgLh/NzNFbkrH2DkeuBC1Zp/MIbZQFvWz8AQEz4QTKl5M2C IbD/uMWQfarZb4gzqizytUF9/hQajjeqAIlXgMv9NJWvljQUfKZ/jDEmgKqqBCbNdiNZ nnjPwTJKQhv1P0JoJyGOgDwnje432a/viHsDN1LzG6a2TT3PjKNvyLAvsMDve9hCFxJG I563jy9crLDYmt23sWKUKWONVU9pxqij+obRu3Yh13xXOcaabaI6sDnVJ7z/urfm36bZ CELNdqqAL8SYymvYysatlL4fhp+JlP+c4l8W6e8mo8/biL6Xst2qJ0rmtkvGAzlRzwK2 aw2w== X-Gm-Message-State: AOAM531lbYwmxxWaEodHVNQmyjiLpp0pUXd7ugZcyye4nC+YBgKz6vlT qmfHv3GRmIVuMXWc6+JIXRpzXw== X-Google-Smtp-Source: ABdhPJxbKn1pNyplA+Ds06niDEdpRrYZnCw22GZBmIYzN4b2tQfdUO1ub6S8IpQxDdfx7BhI6TWglQ== X-Received: by 2002:a63:c211:: with SMTP id b17mr11489447pgd.195.1604289309585; Sun, 01 Nov 2020 19:55:09 -0800 (PST) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y5sm5655711pfc.165.2020.11.01.19.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 19:55:08 -0800 (PST) From: Rayagonda Kokatanur To: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Wolfram Sang , Florian Fainelli , Brendan Higgins , Andy Shevchenko , Lori Hikichi , Dhananjay Phadke , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rayagonda Kokatanur Subject: [PATCH v3 4/6] i2c: iproc: fix typo in slave_isr function Date: Mon, 2 Nov 2020 09:24:31 +0530 Message-Id: <20201102035433.6774-5-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> References: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Fix typo in bcm_iproc_i2c_slave_isr(). Signed-off-by: Rayagonda Kokatanur --- drivers/i2c/busses/i2c-bcm-iproc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index cd687696bf0b..7a235f9f5884 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -382,7 +382,7 @@ static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, if (status & BIT(IS_S_START_BUSY_SHIFT)) { i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, &value); /* - * Enable interrupt for TX FIFO becomes empty and + * Disable interrupt for TX FIFO becomes empty and * less than PKT_LENGTH bytes were output on the SMBUS */ val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); From patchwork Mon Nov 2 03:54:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1391920 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=N8yEzbr7; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CPfFd4rS4z9sVX for ; Mon, 2 Nov 2020 14:55:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727865AbgKBDzQ (ORCPT ); Sun, 1 Nov 2020 22:55:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727805AbgKBDzP (ORCPT ); Sun, 1 Nov 2020 22:55:15 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4DBAC061A04 for ; Sun, 1 Nov 2020 19:55:15 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id o3so9618414pgr.11 for ; Sun, 01 Nov 2020 19:55:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3F36bxg6LI1uT97DjHNWbeMZQl1FEDiKF0JQ8LQ89q4=; b=N8yEzbr76FLBNOnd9ME4WqXfnNOA81bLnhAPnE4PgOmU6Wu+Og361vaz2WPLlMyc6f SXSgX4B/cYJm807ydYjR02OdlI3UxM5uHWgiMEr9k3H0uVYHSiVfIhsJZ8EfcVgCAM/u GiVyRBBLFkIpSwRq98CA90lTtQ7gdVr7Qhfm4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3F36bxg6LI1uT97DjHNWbeMZQl1FEDiKF0JQ8LQ89q4=; b=MIqwqoPbJAoO2LBwzxVWfannftqBHQ1lGphw974sCWdagNwhDwxNsJ95GMuP7TXOB/ tWJDHRzqup7Lea3wWFwTTJk5EvWYjbRz3G2nFDJVe9Mm9ApqkPm1lBted5c43Uqx4Evj i2AP1s9xRhIXCCrfTlSRwmlixDRbMJ4FPLHtk3HUFAKJq82Nvi1j/Mopj2ZX9o8QYl5U j9xmYtRpsnpcUIbKjNeWIb2uI2nw1MgBHKi+3Dxi2EH3SgObFxcExVznu+ZD1EurZOC8 U9lfI/B6/2w3kYgYDUM1xw5vWSDVlfcvMY95s64L63mschgJfridNuexBQAolcPaqgUi JlZw== X-Gm-Message-State: AOAM533Evz8BE49Up8NO5w9x6aA+gYue9ESWGoObRzGLmqXmOfjapFap 2vbTudMd904ZQ1ICESGRYCKXNg== X-Google-Smtp-Source: ABdhPJxy4Qfc7cAoQ6sk9ClfnX368ToyQ1BBz5/6hFmt1hgk3l4zPGN03tyfsDgru33gY51HcGIoqA== X-Received: by 2002:a63:6585:: with SMTP id z127mr554352pgb.210.1604289315124; Sun, 01 Nov 2020 19:55:15 -0800 (PST) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y5sm5655711pfc.165.2020.11.01.19.55.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 19:55:14 -0800 (PST) From: Rayagonda Kokatanur To: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Wolfram Sang , Florian Fainelli , Brendan Higgins , Andy Shevchenko , Lori Hikichi , Dhananjay Phadke , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rayagonda Kokatanur Subject: [PATCH v3 5/6] i2c: iproc: handle master read request Date: Mon, 2 Nov 2020 09:24:32 +0530 Message-Id: <20201102035433.6774-6-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> References: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Handle single or multi byte master read request with or without repeated start. Fixes: c245d94ed106 ("i2c: iproc: Add multi byte read-write support for slave mode") Signed-off-by: Rayagonda Kokatanur Acked-by: Ray Jui --- drivers/i2c/busses/i2c-bcm-iproc.c | 215 +++++++++++++++++++++++------ 1 file changed, 170 insertions(+), 45 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index 7a235f9f5884..22e04055b447 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -160,6 +160,11 @@ #define IE_S_ALL_INTERRUPT_SHIFT 21 #define IE_S_ALL_INTERRUPT_MASK 0x3f +/* + * It takes ~18us to reading 10bytes of data, hence to keep tasklet + * running for less time, max slave read per tasklet is set to 10 bytes. + */ +#define MAX_SLAVE_RX_PER_INT 10 enum i2c_slave_read_status { I2C_SLAVE_RX_FIFO_EMPTY = 0, @@ -206,8 +211,18 @@ struct bcm_iproc_i2c_dev { /* bytes that have been read */ unsigned int rx_bytes; unsigned int thld_bytes; + + bool slave_rx_only; + bool rx_start_rcvd; + bool slave_read_complete; + u32 tx_underrun; + u32 slave_int_mask; + struct tasklet_struct slave_rx_tasklet; }; +/* tasklet to process slave rx data */ +static void slave_rx_tasklet_fn(unsigned long); + /* * Can be expanded in the future if more interrupt status bits are utilized */ @@ -261,6 +276,7 @@ static void bcm_iproc_i2c_slave_init( { u32 val; + iproc_i2c->tx_underrun = 0; if (need_reset) { /* put controller in reset */ val = iproc_i2c_rd_reg(iproc_i2c, CFG_OFFSET); @@ -297,8 +313,11 @@ static void bcm_iproc_i2c_slave_init( /* Enable interrupt register to indicate a valid byte in receive fifo */ val = BIT(IE_S_RX_EVENT_SHIFT); + /* Enable interrupt register to indicate a Master read transaction */ + val |= BIT(IE_S_RD_EVENT_SHIFT); /* Enable interrupt register for the Slave BUSY command */ val |= BIT(IE_S_START_BUSY_SHIFT); + iproc_i2c->slave_int_mask = val; iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); } @@ -324,76 +343,176 @@ static void bcm_iproc_i2c_check_slave_status( } } -static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, - u32 status) +static void bcm_iproc_i2c_slave_read(struct bcm_iproc_i2c_dev *iproc_i2c) { + u8 rx_data, rx_status; + u32 rx_bytes = 0; u32 val; - u8 value, rx_status; - /* Slave RX byte receive */ - if (status & BIT(IS_S_RX_EVENT_SHIFT)) { + while (rx_bytes < MAX_SLAVE_RX_PER_INT) { val = iproc_i2c_rd_reg(iproc_i2c, S_RX_OFFSET); rx_status = (val >> S_RX_STATUS_SHIFT) & S_RX_STATUS_MASK; - if (rx_status == I2C_SLAVE_RX_START) { - /* Start of SMBUS for Master write */ - i2c_slave_event(iproc_i2c->slave, - I2C_SLAVE_WRITE_REQUESTED, &value); + rx_data = ((val >> S_RX_DATA_SHIFT) & S_RX_DATA_MASK); - val = iproc_i2c_rd_reg(iproc_i2c, S_RX_OFFSET); - value = (u8)((val >> S_RX_DATA_SHIFT) & S_RX_DATA_MASK); + if (rx_status == I2C_SLAVE_RX_START) { + /* Start of SMBUS Master write */ i2c_slave_event(iproc_i2c->slave, - I2C_SLAVE_WRITE_RECEIVED, &value); - } else if (status & BIT(IS_S_RD_EVENT_SHIFT)) { - /* Start of SMBUS for Master Read */ + I2C_SLAVE_WRITE_REQUESTED, &rx_data); + iproc_i2c->rx_start_rcvd = true; + iproc_i2c->slave_read_complete = false; + } else if (rx_status == I2C_SLAVE_RX_DATA && + iproc_i2c->rx_start_rcvd) { + /* Middle of SMBUS Master write */ i2c_slave_event(iproc_i2c->slave, - I2C_SLAVE_READ_REQUESTED, &value); - iproc_i2c_wr_reg(iproc_i2c, S_TX_OFFSET, value); + I2C_SLAVE_WRITE_RECEIVED, &rx_data); + } else if (rx_status == I2C_SLAVE_RX_END && + iproc_i2c->rx_start_rcvd) { + /* End of SMBUS Master write */ + if (iproc_i2c->slave_rx_only) + i2c_slave_event(iproc_i2c->slave, + I2C_SLAVE_WRITE_RECEIVED, + &rx_data); + + i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, + &rx_data); + } else if (rx_status == I2C_SLAVE_RX_FIFO_EMPTY) { + iproc_i2c->rx_start_rcvd = false; + iproc_i2c->slave_read_complete = true; + break; + } - val = BIT(S_CMD_START_BUSY_SHIFT); - iproc_i2c_wr_reg(iproc_i2c, S_CMD_OFFSET, val); + rx_bytes++; + } +} - /* - * Enable interrupt for TX FIFO becomes empty and - * less than PKT_LENGTH bytes were output on the SMBUS - */ - val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); - val |= BIT(IE_S_TX_UNDERRUN_SHIFT); - iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); - } else { - /* Master write other than start */ - value = (u8)((val >> S_RX_DATA_SHIFT) & S_RX_DATA_MASK); +static void slave_rx_tasklet_fn(unsigned long data) +{ + struct bcm_iproc_i2c_dev *iproc_i2c = (struct bcm_iproc_i2c_dev *)data; + u32 int_clr; + + bcm_iproc_i2c_slave_read(iproc_i2c); + + /* clear pending IS_S_RX_EVENT_SHIFT interrupt */ + int_clr = BIT(IS_S_RX_EVENT_SHIFT); + + if (!iproc_i2c->slave_rx_only && iproc_i2c->slave_read_complete) { + /* + * In case of single byte master-read request, + * IS_S_TX_UNDERRUN_SHIFT event is generated before + * IS_S_START_BUSY_SHIFT event. Hence start slave data send + * from first IS_S_TX_UNDERRUN_SHIFT event. + * + * This means don't send any data from slave when + * IS_S_RD_EVENT_SHIFT event is generated else it will increment + * eeprom or other backend slave driver read pointer twice. + */ + iproc_i2c->tx_underrun = 0; + iproc_i2c->slave_int_mask |= BIT(IE_S_TX_UNDERRUN_SHIFT); + + /* clear IS_S_RD_EVENT_SHIFT interrupt */ + int_clr |= BIT(IS_S_RD_EVENT_SHIFT); + } + + /* clear slave interrupt */ + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, int_clr); + /* enable slave interrupts */ + iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, iproc_i2c->slave_int_mask); +} + +static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, + u32 status) +{ + u32 val; + u8 value; + + /* + * Slave events in case of master-write, master-write-read and, + * master-read + * + * Master-write : only IS_S_RX_EVENT_SHIFT event + * Master-write-read: both IS_S_RX_EVENT_SHIFT and IS_S_RD_EVENT_SHIFT + * events + * Master-read : both IS_S_RX_EVENT_SHIFT and IS_S_RD_EVENT_SHIFT + * events or only IS_S_RD_EVENT_SHIFT + */ + if (status & BIT(IS_S_RX_EVENT_SHIFT) || + status & BIT(IS_S_RD_EVENT_SHIFT)) { + /* disable slave interrupts */ + val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); + val &= ~iproc_i2c->slave_int_mask; + iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); + + if (status & BIT(IS_S_RD_EVENT_SHIFT)) + /* Master-write-read request */ + iproc_i2c->slave_rx_only = false; + else + /* Master-write request only */ + iproc_i2c->slave_rx_only = true; + + /* schedule tasklet to read data later */ + tasklet_schedule(&iproc_i2c->slave_rx_tasklet); + + /* clear only IS_S_RX_EVENT_SHIFT interrupt */ + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, + BIT(IS_S_RX_EVENT_SHIFT)); + } + + if (status & BIT(IS_S_TX_UNDERRUN_SHIFT)) { + iproc_i2c->tx_underrun++; + if (iproc_i2c->tx_underrun == 1) + /* Start of SMBUS for Master Read */ i2c_slave_event(iproc_i2c->slave, - I2C_SLAVE_WRITE_RECEIVED, &value); - if (rx_status == I2C_SLAVE_RX_END) - i2c_slave_event(iproc_i2c->slave, - I2C_SLAVE_STOP, &value); - } - } else if (status & BIT(IS_S_TX_UNDERRUN_SHIFT)) { - /* Master read other than start */ - i2c_slave_event(iproc_i2c->slave, - I2C_SLAVE_READ_PROCESSED, &value); + I2C_SLAVE_READ_REQUESTED, + &value); + else + /* Master read other than start */ + i2c_slave_event(iproc_i2c->slave, + I2C_SLAVE_READ_PROCESSED, + &value); iproc_i2c_wr_reg(iproc_i2c, S_TX_OFFSET, value); + /* start transfer */ val = BIT(S_CMD_START_BUSY_SHIFT); iproc_i2c_wr_reg(iproc_i2c, S_CMD_OFFSET, val); + + /* clear interrupt */ + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, + BIT(IS_S_TX_UNDERRUN_SHIFT)); } - /* Stop */ + /* Stop received from master in case of master read transaction */ if (status & BIT(IS_S_START_BUSY_SHIFT)) { - i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, &value); /* * Disable interrupt for TX FIFO becomes empty and * less than PKT_LENGTH bytes were output on the SMBUS */ - val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); - val &= ~BIT(IE_S_TX_UNDERRUN_SHIFT); - iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); + iproc_i2c->slave_int_mask &= ~BIT(IE_S_TX_UNDERRUN_SHIFT); + iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, + iproc_i2c->slave_int_mask); + + /* End of SMBUS for Master Read */ + val = BIT(S_TX_WR_STATUS_SHIFT); + iproc_i2c_wr_reg(iproc_i2c, S_TX_OFFSET, val); + + val = BIT(S_CMD_START_BUSY_SHIFT); + iproc_i2c_wr_reg(iproc_i2c, S_CMD_OFFSET, val); + + /* flush TX FIFOs */ + val = iproc_i2c_rd_reg(iproc_i2c, S_FIFO_CTRL_OFFSET); + val |= (BIT(S_FIFO_TX_FLUSH_SHIFT)); + iproc_i2c_wr_reg(iproc_i2c, S_FIFO_CTRL_OFFSET, val); + + i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, &value); + + /* clear interrupt */ + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, + BIT(IS_S_START_BUSY_SHIFT)); } - /* clear interrupt status */ - iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, status); + /* check slave transmit status only if slave is transmitting */ + if (!iproc_i2c->slave_rx_only) + bcm_iproc_i2c_check_slave_status(iproc_i2c); - bcm_iproc_i2c_check_slave_status(iproc_i2c); return true; } @@ -1074,6 +1193,10 @@ static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave) return -EAFNOSUPPORT; iproc_i2c->slave = slave; + + tasklet_init(&iproc_i2c->slave_rx_tasklet, slave_rx_tasklet_fn, + (unsigned long)iproc_i2c); + bcm_iproc_i2c_slave_init(iproc_i2c, false); return 0; } @@ -1094,6 +1217,8 @@ static int bcm_iproc_i2c_unreg_slave(struct i2c_client *slave) IE_S_ALL_INTERRUPT_SHIFT); iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, tmp); + tasklet_kill(&iproc_i2c->slave_rx_tasklet); + /* Erase the slave address programmed */ tmp = iproc_i2c_rd_reg(iproc_i2c, S_CFG_SMBUS_ADDR_OFFSET); tmp &= ~BIT(S_CFG_EN_NIC_SMB_ADDR3_SHIFT); From patchwork Mon Nov 2 03:54:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rayagonda Kokatanur X-Patchwork-Id: 1391921 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.a=rsa-sha256 header.s=google header.b=iQ8Gtgx8; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CPfFl265wz9sVT for ; Mon, 2 Nov 2020 14:55:23 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727806AbgKBDzW (ORCPT ); Sun, 1 Nov 2020 22:55:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727888AbgKBDzU (ORCPT ); Sun, 1 Nov 2020 22:55:20 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE115C0617A6 for ; Sun, 1 Nov 2020 19:55:20 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id 10so9923078pfp.5 for ; Sun, 01 Nov 2020 19:55:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+c09gSHzirt9O+okE0QmVELqHswcOaAl4j0q9ETC4PM=; b=iQ8Gtgx8SIBRHqaEg9LquXzey1/ndXKVZQ27PoBDyhKgLYDGDeRE+3Aau7RBLMGLlp vPG4kprWEVnxe3KPs6XRmT+oW4x0KGixVbhMD22jitI89KFZ+mPn4CByD+m/WCMfJtIk cFMe12BiFF6N9fkFsHo66m9VCH7ILZnjSgT4E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+c09gSHzirt9O+okE0QmVELqHswcOaAl4j0q9ETC4PM=; b=oNJ8InXooX605mLvS+lppbBEXFy3SpqK0swJXUdnfNHihY0AntEx+K9nbA3HCpvnDc P5OR1draiJqqE7m0CKtkFLyk1QNpC8JWAmjwyoxw3f3WQWem3Tck4CaTideFDmNciD2g d0wD9eFh0zu4TKs/pU1EAkxR2XG0Xdvkre97kTht6hEu8YSU0FWwt7QcPmR5APrktzdO /RGdX5ZzMwYumk2t8vFL/mlxwPC2iYIxADekr9pZqttpR/J2+YWPxAJZ8Yg8QK8aUm4/ agQpwZEi+Noyy2RtSfWnf9ErmXiK8MFtKwOCcaP6YnqbMinj/o0hlCbMtFTbRox5rKLH /Zwg== X-Gm-Message-State: AOAM530cdTdyJLEgqg26DFORPDPw/ZkTNFxiQbV83m0YEHVNfU++1CHq qL04pUe5aouTFQ/StEXxjktS3g== X-Google-Smtp-Source: ABdhPJyjhHDYm+I40geGi/eSntY8YCxTXWDj0z8+PdUxieeYJEIi6M04zchVLuzttnIUXwGqK7RZaQ== X-Received: by 2002:a62:e308:0:b029:152:8cc3:ebdc with SMTP id g8-20020a62e3080000b02901528cc3ebdcmr20143680pfh.42.1604289320107; Sun, 01 Nov 2020 19:55:20 -0800 (PST) Received: from rayagonda.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id y5sm5655711pfc.165.2020.11.01.19.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 19:55:19 -0800 (PST) From: Rayagonda Kokatanur To: Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com, Wolfram Sang , Florian Fainelli , Brendan Higgins , Andy Shevchenko , Lori Hikichi , Dhananjay Phadke , linux-i2c@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rayagonda Kokatanur Subject: [PATCH v3 6/6] i2c: iproc: handle rx fifo full interrupt Date: Mon, 2 Nov 2020 09:24:33 +0530 Message-Id: <20201102035433.6774-7-rayagonda.kokatanur@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> References: <20201102035433.6774-1-rayagonda.kokatanur@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add code to handle IS_S_RX_FIFO_FULL_SHIFT interrupt to support master write request with >= 64 bytes. Iproc has a slave rx fifo size of 64 bytes. Rx fifo full interrupt (IS_S_RX_FIFO_FULL_SHIFT) will be generated when RX fifo becomes full. This can happen if master issues write request of more than 64 bytes. Signed-off-by: Rayagonda Kokatanur --- drivers/i2c/busses/i2c-bcm-iproc.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c index 22e04055b447..cceaf69279a9 100644 --- a/drivers/i2c/busses/i2c-bcm-iproc.c +++ b/drivers/i2c/busses/i2c-bcm-iproc.c @@ -313,6 +313,8 @@ static void bcm_iproc_i2c_slave_init( /* Enable interrupt register to indicate a valid byte in receive fifo */ val = BIT(IE_S_RX_EVENT_SHIFT); + /* Enable interrupt register to indicate Slave Rx FIFO Full */ + val |= BIT(IE_S_RX_FIFO_FULL_SHIFT); /* Enable interrupt register to indicate a Master read transaction */ val |= BIT(IE_S_RD_EVENT_SHIFT); /* Enable interrupt register for the Slave BUSY command */ @@ -434,9 +436,15 @@ static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, * events * Master-read : both IS_S_RX_EVENT_SHIFT and IS_S_RD_EVENT_SHIFT * events or only IS_S_RD_EVENT_SHIFT + * + * iproc has a slave rx fifo size of 64 bytes. Rx fifo full interrupt + * (IS_S_RX_FIFO_FULL_SHIFT) will be generated when RX fifo becomes + * full. This can happen if Master issues write requests of more than + * 64 bytes. */ if (status & BIT(IS_S_RX_EVENT_SHIFT) || - status & BIT(IS_S_RD_EVENT_SHIFT)) { + status & BIT(IS_S_RD_EVENT_SHIFT) || + status & BIT(IS_S_RX_FIFO_FULL_SHIFT)) { /* disable slave interrupts */ val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); val &= ~iproc_i2c->slave_int_mask; @@ -452,9 +460,14 @@ static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, /* schedule tasklet to read data later */ tasklet_schedule(&iproc_i2c->slave_rx_tasklet); - /* clear only IS_S_RX_EVENT_SHIFT interrupt */ - iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, - BIT(IS_S_RX_EVENT_SHIFT)); + /* + * clear only IS_S_RX_EVENT_SHIFT and + * IS_S_RX_FIFO_FULL_SHIFT interrupt. + */ + val = BIT(IS_S_RX_EVENT_SHIFT); + if (status & BIT(IS_S_RX_FIFO_FULL_SHIFT)) + val |= BIT(IS_S_RX_FIFO_FULL_SHIFT); + iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, val); } if (status & BIT(IS_S_TX_UNDERRUN_SHIFT)) {