From patchwork Tue May 10 23:48:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 1439 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:51:59 -0000 Delivered-To: patches@linaro.org Received: by 10.224.61.3 with SMTP id r3cs38944qah; Tue, 10 May 2011 16:48:16 -0700 (PDT) Received: by 10.42.157.68 with SMTP id c4mr1870404icx.208.1305071296073; Tue, 10 May 2011 16:48:16 -0700 (PDT) Received: from mail-iy0-f178.google.com (mail-iy0-f178.google.com [209.85.210.178]) by mx.google.com with ESMTPS id vt18si21273919icb.33.2011.05.10.16.48.15 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 May 2011 16:48:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linus.ml.walleij@gmail.com designates 209.85.210.178 as permitted sender) client-ip=209.85.210.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linus.ml.walleij@gmail.com designates 209.85.210.178 as permitted sender) smtp.mail=linus.ml.walleij@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by mail-iy0-f178.google.com with SMTP id 12so7230691iyi.37 for ; Tue, 10 May 2011 16:48:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type:content-transfer-encoding; bh=T01xkmYw8m49ndypIcp2PTiitHHDdrfDebHvYOpFd3c=; b=UkdB2UC/WR5FfGm+xOjjwHczf0cUeyTerrLXGPzsImLTjmn0UTukPMUoH+GlwW8wCz J+qzWoLXI5hw/JHcF9L/862A8f42wDDMosPJ7QFw9Bh/Dod423+fDfSADqR0pQsqrooq 1UCVvtlWvr5u+G/iG/v+qUnkMDRCMU6xUgB+k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=TvwMo5m+yWuWY/d17Vbb3wQIhiczTTVm5Jak9+dOGvTA1+LGc/7Bet0EoO94LtbfWS IY0NxXEfLU/9J64xWGiMhyrwQRA2wtnkYCfkfb16S9QICfqiXJjC8mHN+LKXS3MrmTST BlwwkjjGw7br504+cl/PVnNuYDYOJlULjznoQ= MIME-Version: 1.0 Received: by 10.42.150.70 with SMTP id z6mr2709569icv.164.1305071295758; Tue, 10 May 2011 16:48:15 -0700 (PDT) Received: by 10.231.20.3 with HTTP; Tue, 10 May 2011 16:48:15 -0700 (PDT) In-Reply-To: <1304977118-31728-1-git-send-email-linus.walleij@linaro.org> References: <1304977118-31728-1-git-send-email-linus.walleij@linaro.org> Date: Wed, 11 May 2011 01:48:15 +0200 Message-ID: Subject: Fwd: [PATCH 10/13] i2c/i2c-nomadik: change the TX and RX threshold From: Linus Walleij To: patches@linaro.org ---------- Forwarded message ---------- From: Linus Walleij Date: 2011/5/9 Subject: [PATCH 10/13] i2c/i2c-nomadik: change the TX and RX threshold To: Ben Dooks , linux-i2c@vger.kernel.org Kopia: Virupax Sadashivpetimath , Linus Walleij From: Virupax Sadashivpetimath 1) Increase RX FIFO threshold so that there is a reduction in the number of interrupts handled to complete a transaction. 2) Fill TX FIFO in the write function. Signed-off-by: Virupax Sadashivpetimath Reviewed-by: Jonas Aberg Signed-off-by: Linus Walleij ---  drivers/i2c/busses/i2c-nomadik.c |   39 +++++++++++++++++++++++++------------  1 files changed, 26 insertions(+), 13 deletions(-) -- 1.7.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to majordomo@vger.kernel.org More majordomo info at  http://vger.kernel.org/majordomo-info.html diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c index bf061e1..916e4db 100644 --- a/drivers/i2c/busses/i2c-nomadik.c +++ b/drivers/i2c/busses/i2c-nomadik.c @@ -447,6 +447,24 @@ static int read_i2c(struct nmk_i2c_dev *dev)        return status;  } +static void fill_tx_fifo(struct nmk_i2c_dev *dev, int no_bytes) +{ +       int count; + +       for (count = (no_bytes - 2); +                       (count > 0) && +                       (dev->cli.count != 0); +                       count--) { +               /* write to the Tx FIFO */ +               writeb(*dev->cli.buffer, +                       dev->virtbase + I2C_TFR); +               dev->cli.buffer++; +               dev->cli.count--; +               dev->cli.xfer_bytes++; +       } + +} +  /**  * write_i2c() - Write data to I2C client.  * @dev: private data of I2C Driver @@ -474,8 +492,13 @@ static int write_i2c(struct nmk_i2c_dev *dev)        init_completion(&dev->xfer_complete);        /* enable interrupts by settings the masks */ -       irq_mask = (I2C_IT_TXFNE | I2C_IT_TXFOVR | -                       I2C_IT_MAL | I2C_IT_BERR); +       irq_mask = (I2C_IT_TXFOVR | I2C_IT_MAL | I2C_IT_BERR); + +       /* Fill the TX FIFO with transmit data */ +       fill_tx_fifo(dev, MAX_I2C_FIFO_THRESHOLD); + +       if (dev->cli.count != 0) +               irq_mask |= I2C_IT_TXFNE;        /*         * check if we want to transfer a single or multiple bytes, if so @@ -702,17 +725,7 @@ static irqreturn_t i2c_irq_handler(int irq, void *arg)                         */                        disable_interrupts(dev, I2C_IT_TXFNE);                } else { -                       for (count = (MAX_I2C_FIFO_THRESHOLD - tft - 2); -                                       (count > 0) && -                                       (dev->cli.count != 0); -                                       count--) { -                               /* write to the Tx FIFO */ -                               writeb(*dev->cli.buffer, -                                       dev->virtbase + I2C_TFR); -                               dev->cli.buffer++; -                               dev->cli.count--; -                               dev->cli.xfer_bytes++; -                       } +                       fill_tx_fifo(dev, (MAX_I2C_FIFO_THRESHOLD - tft));                        /*                         * if done, close the transfer by disabling the                         * corresponding TXFNE interrupt