From patchwork Tue Oct 8 10:50:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajeshwari Shinde X-Patchwork-Id: 20890 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E421525C6D for ; Tue, 8 Oct 2013 10:48:42 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id j7sf10795390qaq.11 for ; Tue, 08 Oct 2013 03:48:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:dlp-filter:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=2jQ3TcxkjQs5SfVFF3Cwy/iGDf3ftYcD5wVsPZTjwe0=; b=T4iLdX8ALqnGDU3W6sbrPZ9kxlvwHRHJ20aGZ45pf/Zp6qh6LFJ72thNMgeTv1A3QF mIX7EIXkDjGPFaMj0XRJgDXHhHT68w/9s94fY1raIW5mU1vTAhNQkY6S4J8cGCFpDKCE /iAjtxtz6ygX2772+o/gz4MB166OefW64INdUQGTxrpbAQpeKqoRcyliw/u9vsOGK3sJ p8f2/4gojgAZTh08whQYc+s8XXCnbNZQt0ze8E5fVJI4hvNmxDTkDOnOr53vMtjPuhWE lRdkw2i00OSBfhF2+MENXenz7jc+raXCHNb5aK6xXLDDn1rbagFrPIThvS5vgRui2oUM 9ZhA== X-Received: by 10.236.186.101 with SMTP id v65mr1008035yhm.12.1381229322648; Tue, 08 Oct 2013 03:48:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.48.66 with SMTP id j2ls166563qen.90.gmail; Tue, 08 Oct 2013 03:48:42 -0700 (PDT) X-Received: by 10.220.48.194 with SMTP id s2mr84935vcf.43.1381229322563; Tue, 08 Oct 2013 03:48:42 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id uh5si9259322vcb.127.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 08 Oct 2013 03:48:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id if17so3412650vcb.4 for ; Tue, 08 Oct 2013 03:48:42 -0700 (PDT) X-Gm-Message-State: ALoCoQlntCWaOdUiJ8WhAEawOQd2+KgjrOiEsTHD/0gET2FxZShc11O79UyP54g0o3ctvmAhUvO7 X-Received: by 10.52.229.4 with SMTP id sm4mr80716vdc.50.1381229322443; Tue, 08 Oct 2013 03:48:42 -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.174.196 with SMTP id u4csp194482vcz; Tue, 8 Oct 2013 03:48:41 -0700 (PDT) X-Received: by 10.68.203.34 with SMTP id kn2mr1174794pbc.82.1381229321334; Tue, 08 Oct 2013 03:48:41 -0700 (PDT) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id rq5si25981321pbc.303.1969.12.31.16.00.00; Tue, 08 Oct 2013 03:48:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of rajeshwari.s@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MUC00DKTJCXBB50@mailout3.samsung.com>; Tue, 08 Oct 2013 19:48:40 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.125]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id 7F.89.29948.703E3525; Tue, 08 Oct 2013 19:48:40 +0900 (KST) X-AuditID: cbfee691-b7f4a6d0000074fc-0d-5253e3078102 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 2C.33.09055.703E3525; Tue, 08 Oct 2013 19:48:39 +0900 (KST) Received: from localhost.localdomain.com ([107.108.73.95]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MUC00059JCVG700@mmp1.samsung.com>; Tue, 08 Oct 2013 19:48:39 +0900 (KST) From: Rajeshwari S Shinde To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, u-boot-review@google.com, jagannadh.teki@gmail.com, alim.akhtar@samsung.com Subject: [PATCH 2/4] spi: exynos: Support a delay after deactivate Date: Tue, 08 Oct 2013 16:20:04 +0530 Message-id: <1381229406-12478-3-git-send-email-rajeshwari.s@samsung.com> X-Mailer: git-send-email 1.7.11.7 In-reply-to: <1381229406-12478-1-git-send-email-rajeshwari.s@samsung.com> References: <1381229406-12478-1-git-send-email-rajeshwari.s@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHLMWRmVeSWpSXmKPExsWyRsSkVpfjcXCQwalOZosH87axWTxcf5PF YtfWFlaLjiMtjBZTDn9hsfi2ZRujxfLXG9kt3u7tZHfg8JjdcJHFY+esu+weCzaVety5tofN 4+ydHYwefVtWMQawRXHZpKTmZJalFunbJXBltD7vYSnYLV4xp0+2gXGycBcjJ4eEgIlEx5bl bBC2mMSFe+uBbC4OIYGljBKXzm9i6mLkACtqnxwPEV/EKHH54AwmCKeLSeLq04NsIEVsQEUb TySADBIRkJD41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Bt4PDhLi TUmsrEotyo8vKs1JLT7EmAx01URmKdHkfGDE55XEGxqbmJsam1qaWJiYWZImrCTOe6DVOlBI ID2xJDU7NbUgtQhmCxMHp1QDY4x5a4AVQ2hfwZ69rouba583W+XG/Ih6+OaiN0dAxIv356ti 1rjyuLZ/uGoWF1dxIW3+dt2P6V/2Skkd0U5w6J5T8jbmjuwWm+VeSUdcY577LNn1c/LReMG5 IuwKmwOlfPU8eY6WqBVGSChNmMqsrHv28cKi64mqkvqOEabOLLfnJcUmzpFTYinOSDTUYi4q TgQAD7HkLu4CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: rajeshwari.s@samsung.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 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. Signed-off-by: Simon Glass Signed-off-by: Rajeshwari S Shinde --- drivers/spi/exynos_spi.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c index efc8b1e..d7fdaac 100644 --- a/drivers/spi/exynos_spi.c +++ b/drivers/spi/exynos_spi.c @@ -26,6 +26,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 */ @@ -40,6 +41,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) @@ -85,6 +88,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; @@ -95,6 +99,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) @@ -359,9 +364,22 @@ 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(); } /** @@ -411,6 +429,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; }