From patchwork Fri May 17 12:52:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 17023 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f199.google.com (mail-gg0-f199.google.com [209.85.161.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5A9F5238F0 for ; Fri, 17 May 2013 12:47:26 +0000 (UTC) Received: by mail-gg0-f199.google.com with SMTP id q3sf4520255gge.2 for ; Fri, 17 May 2013 05:46:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-google-group-id:list-post:list-help :list-archive:list-unsubscribe; bh=5xw8vdGuVYug7U0ZwU8fVnR46VQZyoTkzdwwrJzZTH0=; b=Pe5TQceSBg6emFvbZ0mvgJt5X4ZGtTxRf7GXQkOM4CnK1zPHyvEbV/ukZoJkU1Am8W TjV8DdH2lu0i6GukJrEco+cPgb/dUPA98ACy328Zm62xHUxoiqrFULVg1Rpg0wnJLOSm gLGUq7/zOf5h29C1nJgp0jB3Jbql6RycZo0pIcaxB08Kaa0SFaWvZFl2ce/bXgl1qocY GEhdN5fFZH0ipp07bS4wSidi4qQzR0/HTIJ5dXLZvrrluDx1WGpQAy7MuULpzBDRYepX NnldIbvHLSZh3HFT4QxrXjtXVhIuNf85oRCfXXzGR499f8U9Mhqa7bl1Auyz+po1jZRv rgOA== X-Received: by 10.224.215.194 with SMTP id hf2mr28084204qab.0.1368794804903; Fri, 17 May 2013 05:46:44 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.37.71 with SMTP id w7ls1611373qej.69.gmail; Fri, 17 May 2013 05:46:44 -0700 (PDT) X-Received: by 10.52.115.1 with SMTP id jk1mr25503685vdb.95.1368794804784; Fri, 17 May 2013 05:46:44 -0700 (PDT) Received: from mail-ve0-x230.google.com (mail-ve0-x230.google.com [2607:f8b0:400c:c01::230]) by mx.google.com with ESMTPS id ef7si2121524vdc.150.2013.05.17.05.46.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 17 May 2013 05:46:44 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::230; Received: by mail-ve0-f176.google.com with SMTP id jz10so2719979veb.7 for ; Fri, 17 May 2013 05:46:44 -0700 (PDT) X-Received: by 10.58.250.66 with SMTP id za2mr29560005vec.56.1368794804479; Fri, 17 May 2013 05:46:44 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.126.138 with SMTP id c10csp107918vcs; Fri, 17 May 2013 05:46:43 -0700 (PDT) X-Received: by 10.66.158.234 with SMTP id wx10mr48421420pab.43.1368794803188; Fri, 17 May 2013 05:46:43 -0700 (PDT) Received: from mailout2.samsung.com (mailout2.samsung.com. [203.254.224.25]) by mx.google.com with ESMTP id xl4si2604333pab.167.2013.05.17.05.46.42 for ; Fri, 17 May 2013 05:46:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.25 as permitted sender) client-ip=203.254.224.25; Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MMY002TS0TRU110@mailout2.samsung.com> for patches@linaro.org; Fri, 17 May 2013 21:46:42 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id F6.E9.28050.1B626915; Fri, 17 May 2013 21:46:41 +0900 (KST) X-AuditID: cbfee690-b7efc6d000006d92-7f-519626b11f19 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id FD.F4.17674.1B626915; Fri, 17 May 2013 21:46:41 +0900 (KST) Received: from rajeshwari-linux.sisodomain.com ([107.108.215.115]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MMY004NE0QITT10@mmp2.samsung.com>; Fri, 17 May 2013 21:46:41 +0900 (KST) From: Rajeshwari Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, u-boot-review@google.com Subject: [PATCH 2/2 V2] EXYNOS: SPI: Support a delay after deactivate Date: Fri, 17 May 2013 18:22:58 +0530 Message-id: <1368795178-25909-3-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.4.4 In-reply-to: <1368795178-25909-1-git-send-email-rajeshwari.s@samsung.com> References: <1368795178-25909-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRmVeSWpSXmKPExsWyRsSkTnej2rRAgze/LCw6jrQwWkw5/IXF 4tuWbYwWy19vZLd4u7eT3YHVY3bDRRaPBZtKPe5c28PmcfbODkaPvi2rGANYo7hsUlJzMstS i/TtErgyNp5dwFhwRqJi9XreBsZekS5GTg4JAROJKVM2skPYYhIX7q1n62Lk4hASWMoo0bFj FTNM0Y2Vl5ghEtMZJRqn3WCHcCYySZy9txesik3ASGLryWmMILaIgITEr/6rYDazQJTE9+5L YCuEBVwlTl2cCFbPI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JmaWpAkrifMebLUOFBJITyxJzU5NLUgtgtnCxMEp1cBoYjR3 RlYRC8/LkzPVS1qbnqR5tVrE5bRNuvo+U1+ecV7+r8+RPeaC+yYd3sY4NzRe4O0W3j/qd8wi UzOuLqxUNZX1TGrs/X4pZcX64hvteZL7ZK/l3FjRJsa3QT7E4NOVYJF5PLb75C0TLMyaN3pk XDnxaGLyam439RCVwrt/W84vO/jyyn8lluKMREMt5qLiRACmpEHW3AIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnoMro2XZ5W9eRZb9yS3Q6on5Zx85E+Y7CC3cDLePsuuMFR3t+ksxAb4Lrc6qKE575n2W+Y X-Original-Sender: rajeshwari.s@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For devices that need some time to react after a spi transaction finishes, add the ability to set a delay. Implement this as a delay on the first/next transaction to avoid any delay in the fairly common case where a SPI transaction is followed by other processing. Based on: "EXYNOS: SPI: Support SPI_PREAMBLE mode" link: http://patchwork.ozlabs.org/patch/229891/ Signed-off-by: Simon Glass Signed-off-by: Rajeshwari Shinde --- Changes in V2: - None. drivers/spi/exynos_spi.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index e81b132..119bf0f 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -38,6 +38,7 @@ struct spi_bus { struct exynos_spi *regs; int inited; /* 1 if this bus is ready for use */ int node; + uint deactivate_delay_us; /* Delay to wait after deactivate */ }; /* A list of spi buses that we know about */ @@ -52,6 +53,8 @@ struct exynos_spi_slave { enum periph_id periph_id; /* Peripheral ID for this device */ unsigned int fifo_size; int skip_preamble; + struct spi_bus *bus; /* Pointer to our SPI bus info */ + ulong last_transaction_us; /* Time of last transaction end */ }; static struct spi_bus *spi_get_bus(unsigned dev_index) @@ -97,6 +100,7 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs, } bus = &spi_bus[busnum]; + spi_slave->bus = bus; spi_slave->regs = bus->regs; spi_slave->mode = mode; spi_slave->periph_id = bus->periph_id; @@ -107,6 +111,7 @@ struct spi_slave *spi_setup_slave(unsigned int busnum, unsigned int cs, spi_slave->fifo_size = 256; spi_slave->skip_preamble = 0; + spi_slave->last_transaction_us = timer_get_us(); spi_slave->freq = bus->frequency; if (max_hz) @@ -368,9 +373,21 @@ void spi_cs_activate(struct spi_slave *slave) { struct exynos_spi_slave *spi_slave = to_exynos_spi(slave); + /* If it's too soon to do another transaction, wait */ + if (spi_slave->bus->deactivate_delay_us && + spi_slave->last_transaction_us) { + ulong delay_us; /* The delay completed so far */ + delay_us = timer_get_us() - spi_slave->last_transaction_us; + if (delay_us < spi_slave->bus->deactivate_delay_us) + udelay(spi_slave->bus->deactivate_delay_us - delay_us); + } clrbits_le32(&spi_slave->regs->cs_reg, SPI_SLAVE_SIG_INACT); debug("Activate CS, bus %d\n", spi_slave->slave.bus); spi_slave->skip_preamble = spi_slave->mode & SPI_PREAMBLE; + + /* Remember time of this transaction so we can honour the bus delay */ + if (spi_slave->bus->deactivate_delay_us) + spi_slave->last_transaction_us = timer_get_us(); } /** @@ -420,6 +437,8 @@ static int spi_get_config(const void *blob, int node, struct spi_bus *bus) /* Use 500KHz as a suitable default */ bus->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", 500000); + bus->deactivate_delay_us = fdtdec_get_int(blob, node, + "spi-deactivate-delay", 0); return 0; }