Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1069373yba; Tue, 2 Apr 2019 01:26:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxWGhc7BkFbMVKw147mHB/BhCihHhLsRGhaerqLEc6V0mCc8hy2HGoSTrSLUjFsTyvFtZGG X-Received: by 2002:a63:5150:: with SMTP id r16mr56431793pgl.307.1554193586523; Tue, 02 Apr 2019 01:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554193586; cv=none; d=google.com; s=arc-20160816; b=dIIlNl7xR4yoHdcrgR25JTTo722GhBlEjNQrJD99aQoNty2+i9aKgr+PJBN9ay20Ys 1Gx8EEm295Pg8K8CHoG/Eu/N0NoYGcz0i9vmfsN+j6FlvUA4s+TRCuyPo9qUlbSMckBq NYUZNFFjXzIdP0AbUyMuCRrVUgqs1jx9YK7Wrrtc+1t9pg9O7wmjhHFZ8IzlV9YFvJS1 s9I85IDeHvPOvEWnLafhJIjonWit2fXySeu+1S14dXXfgzSIe6YyIwpR7YRBvJKsBNkn 5IFwqrrFIGu37pK9sbF3gazg7VccfMpdWoL01ANlIh+QbXH3+GkGU3vStCKQXtxNXk3K cFzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0mLqGazU6rN+in+HWOWWGDjbKCiAOq44ih/Rglku8rg=; b=wU1qajNFmFI/QDfpv71ZV4Q9fd2JLqzcW9XWyf74PDIwlIDNPVArvA22wMiu4zYTBM 459y2KLUuRjShu+QbnD8F9HXq+bUOnS28ltxVN0zpM5x5+Uxz2ynPl2ShbCe7Giecapq uocEWZcNrHpti+B24PEHUEPmcNSjBHtgW8K6eaZDA1zPEdqqqqh4N/edIu8nBmvAOHOp yKtD0EMlCpyuDN5cMXcGA3eZGBpL+pkkBtmJk567t75fCnyjn4uieyT1MR/GSs8AiNJL Ze2oHdRKHMnZubVKcmc06d9mx6h7Yg8tYF6WRFiS7BpcIwd5MUdPJQJ2DrA2R9FL12N2 Xlrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=CmICvH8e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si10408935pfe.72.2019.04.02.01.26.09; Tue, 02 Apr 2019 01:26:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=CmICvH8e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729488AbfDBIZK (ORCPT + 99 others); Tue, 2 Apr 2019 04:25:10 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:41227 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728695AbfDBIZK (ORCPT ); Tue, 2 Apr 2019 04:25:10 -0400 Received: by mail-lj1-f194.google.com with SMTP id k8so2339690lja.8 for ; Tue, 02 Apr 2019 01:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0mLqGazU6rN+in+HWOWWGDjbKCiAOq44ih/Rglku8rg=; b=CmICvH8ejCwJEBwJDJRgYqm92pZaN/g0gJzWtIDs99mCW65WzIcAkRx/A+Hw/f8Eb9 eGu8P9t4WYxwJiglXBIUihMv0N0nrW7KbZrh7xVjTgHJ261lKFdcC+zWDILhRmCj58+Z /TV6iUUnxUyVtrlBATU5O7vRmPEdK2plsSUxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0mLqGazU6rN+in+HWOWWGDjbKCiAOq44ih/Rglku8rg=; b=XTTfg06dzJqlELrzBTUhzpOF+lwai9q4ccZmsNv/z36mejzkeYZsYYlFTJ1wCRYyyR c+OzuF1bSmVpRZ1MnTQZDAD67Le4TBCVvIhLw0D5H1wsaS4OQDanUBBXvim2PZ/fdc53 FwYKVfebKh5clH6QmnH4nNNHUR5rMmIuEfuvCT/4ISOLa1eAYHyvNGsq9GBa+quV4MoH 2NVC/Du5MXc60gGwnWe8KMBPqf1JBK0wXbo/hXRHx8711x1GxhVNELYJZBXFL25Kehj4 jq1mfXUZD604/EJAbMqQgQuN1YZfl5a8+Ip95Hl40zS9OVirZskJTYO+3t3mNwxrlsBd 5jAQ== X-Gm-Message-State: APjAAAVC1DSjlF4pvWgFEwhWMj7xejGRWf9kWaZWkcUZeyCwK4WvhR2x CH3z8J04294y7z7PYk3eq9odfv2FmFDhfFQIlWPSNA== X-Received: by 2002:a2e:8905:: with SMTP id d5mr919358lji.59.1554193508040; Tue, 02 Apr 2019 01:25:08 -0700 (PDT) MIME-Version: 1.0 References: <20190214175725.60462-1-ray.jui@broadcom.com> <20190214175725.60462-3-ray.jui@broadcom.com> <20190327221452.GA15396@kunai> In-Reply-To: From: Rayagonda Kokatanur Date: Tue, 2 Apr 2019 13:54:56 +0530 Message-ID: Subject: Re: [PATCH v5 2/8] i2c: iproc: Add slave mode support To: Ray Jui Cc: Wolfram Sang , Rob Herring , Mark Rutland , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, Shreesha Rajashekar , Michael Cheng Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ray/Wolfram, On Tue, Apr 2, 2019 at 3:03 AM Ray Jui wrote: > > Hi Wolfram/Rayagonda, > > On 3/27/2019 3:14 PM, Wolfram Sang wrote: > > > >> +static void bcm_iproc_i2c_slave_init( > >> + struct bcm_iproc_i2c_dev *iproc_i2c, bool need_reset) > >> +{ > >> + u32 val; > >> + > >> + if (need_reset) { > >> + /* put controller in reset */ > >> + val = readl(iproc_i2c->base + CFG_OFFSET); > >> + val |= BIT(CFG_RESET_SHIFT); > >> + writel(val, iproc_i2c->base + CFG_OFFSET); > >> + > >> + /* wait 100 usec per spec */ > >> + udelay(100); > >> + > >> + /* bring controller out of reset */ > >> + val &= ~(BIT(CFG_RESET_SHIFT)); > >> + writel(val, iproc_i2c->base + CFG_OFFSET); > >> + } > >> + > >> + /* flush TX/RX FIFOs */ > >> + val = (BIT(S_FIFO_RX_FLUSH_SHIFT) | BIT(S_FIFO_TX_FLUSH_SHIFT)); > >> + writel(val, iproc_i2c->base + S_FIFO_CTRL_OFFSET); > > > > Will flushing FIFOs work when a slave is register while a master > > transfer is on-going at the same time? > > > > Okay, as you pointed out in a subsequent email, this can't happen. > > >> + > >> + /* RANDOM SLAVE STRETCH time - 20ms*/ > > > > What is a "random stretch time"? 20ms sounds like a lot. Also, missing > > space before comment terminator. > > > > Rayagonda, > > Could you please help to comment on the choice of the 20 ms to allow > clock stretch from the slave? In probably all cases, the slave should > not need more than 1 ms? 20 ms does seem way too long as Wolfram pointed > out. In fact we are programming max slave stretch time ie 25ms, comment should be correcting. Its maximum time for slave to complete read/write operation, if slave is done with read/write then clock will not be stretched further, it will be released immediately. Hence I feel no harm in programming max timeout value. Also determining correct slave stretch is very subjective and depends on slave type as well. Best regards, Rayagonda > > Will fix the missing space before comment terminator. > > >> @@ -224,22 +473,25 @@ static int bcm_iproc_i2c_init(struct bcm_iproc_i2c_dev *iproc_i2c) > >> > >> /* put controller in reset */ > >> val = readl(iproc_i2c->base + CFG_OFFSET); > >> - val |= 1 << CFG_RESET_SHIFT; > >> - val &= ~(1 << CFG_EN_SHIFT); > >> + val |= BIT(CFG_RESET_SHIFT); > >> + val &= ~(BIT(CFG_EN_SHIFT)); > >> writel(val, iproc_i2c->base + CFG_OFFSET); > >> > >> /* wait 100 usec per spec */ > >> udelay(100); > >> > >> /* bring controller out of reset */ > >> - val &= ~(1 << CFG_RESET_SHIFT); > >> + val &= ~(BIT(CFG_RESET_SHIFT)); > >> writel(val, iproc_i2c->base + CFG_OFFSET); > >> > >> /* flush TX/RX FIFOs and set RX FIFO threshold to zero */ > >> - val = (1 << M_FIFO_RX_FLUSH_SHIFT) | (1 << M_FIFO_TX_FLUSH_SHIFT); > >> + val = (BIT(M_FIFO_RX_FLUSH_SHIFT) | BIT(M_FIFO_TX_FLUSH_SHIFT)); > >> writel(val, iproc_i2c->base + M_FIFO_CTRL_OFFSET); > >> /* disable all interrupts */ > >> - writel(0, iproc_i2c->base + IE_OFFSET); > >> + val = readl(iproc_i2c->base + IE_OFFSET); > >> + val &= ~(IE_M_ALL_INTERRUPT_MASK << > >> + IE_M_ALL_INTERRUPT_SHIFT); > >> + writel(val, iproc_i2c->base + IE_OFFSET); > > > > This block looks unrelated, but I won't be too strict here... > > > >> + case M_CMD_STATUS_FIFO_UNDERRUN: > >> + dev_dbg(iproc_i2c->device, "FIFO under-run\n"); > >> + return -ENXIO; > >> + > >> + case M_CMD_STATUS_RX_FIFO_FULL: > >> + dev_dbg(iproc_i2c->device, "Master Rx FIFO full > 10ms\n"); > >> + return -ETIMEDOUT; > >> + > > > > ... however, this looks really unrelated to me. This is about master > > transmission, or? > > This should be submitted in a separate commit. Will do that in the next > iteration of patch series. > > > > > Rest looks OK. > > > > Thanks, > > Ray