[U-Boot] [PATCH 0/2] EXYNOS: Support a delay after deactivate for SPI

This patch set exports the function timer_get_us and adds a delay for devices that need some time to react after spi transation finishes
This patch set is based on "Exynos: Add timer_get_us function" link: http://patchwork.ozlabs.org/patch/223566/ "EXYNOS: SPI: Support SPI_PREAMBLE mode" link: http://patchwork.ozlabs.org/patch/229891/
Rajeshwari Shinde (2): EXYNOS: Export timer_get_us() to get microsecond timer EXYNOS: SPI: Support a delay after deactivate
drivers/spi/exynos_spi.c | 20 ++++++++++++++++++++ include/common.h | 8 ++++++++ 2 files changed, 28 insertions(+), 0 deletions(-)

This function, if implemented by the board, provides a microsecond timer. The granularity may be larger than 1us if hardware does not support this.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- include/common.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/common.h b/include/common.h index 4ad17ea..0c21edc 100644 --- a/include/common.h +++ b/include/common.h @@ -558,6 +558,14 @@ void ddr_enable_ecc(unsigned int dram_size); #endif #endif
+#if defined CONFIG_EXYNOS5 +/* + * Return the current value of a monotonically increasing microsecond timer. + * Granularity may be larger than 1us if hardware does not support this. + */ +ulong timer_get_us(void); +#endif + /* $(CPU)/cpu.c */ static inline int cpumask_next(int cpu, unsigned int mask) {

Hi Rajeshwari,
On Fri, Mar 22, 2013 at 5:28 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This function, if implemented by the board, provides a microsecond timer. The granularity may be larger than 1us if hardware does not support this.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
include/common.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/common.h b/include/common.h index 4ad17ea..0c21edc 100644 --- a/include/common.h +++ b/include/common.h @@ -558,6 +558,14 @@ void ddr_enable_ecc(unsigned int dram_size); #endif #endif
+#if defined CONFIG_EXYNOS5
I don't think we need the #ifdef. If some boards don't have then that is OK.
+/*
- Return the current value of a monotonically increasing microsecond timer.
- Granularity may be larger than 1us if hardware does not support this.
- */
+ulong timer_get_us(void); +#endif
/* $(CPU)/cpu.c */ static inline int cpumask_next(int cpu, unsigned int mask) { -- 1.7.4.4
Regards, Simon

On Fri, Mar 22, 2013 at 6:45 PM, Simon Glass sjg@chromium.org wrote:
Hi Rajeshwari,
On Fri, Mar 22, 2013 at 5:28 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This function, if implemented by the board, provides a microsecond timer. The granularity may be larger than 1us if hardware does not support this.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
include/common.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/common.h b/include/common.h index 4ad17ea..0c21edc 100644 --- a/include/common.h +++ b/include/common.h @@ -558,6 +558,14 @@ void ddr_enable_ecc(unsigned int dram_size); #endif #endif
+#if defined CONFIG_EXYNOS5
I don't think we need the #ifdef. If some boards don't have then that is OK.
Further to this, I suppose we can always remove the #ifdef when other boards define the function. So:
Acked-by: Simon Glass sjg@chromium.org

Hi Simon,
Thank you for review comments,
On Sat, May 11, 2013 at 8:38 PM, Simon Glass sjg@chromium.org wrote:
On Fri, Mar 22, 2013 at 6:45 PM, Simon Glass sjg@chromium.org wrote:
Hi Rajeshwari,
On Fri, Mar 22, 2013 at 5:28 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
This function, if implemented by the board, provides a microsecond timer. The granularity may be larger than 1us if hardware does not support this.
Signed-off-by: Simon Glass sjg@chromium.org Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
include/common.h | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/include/common.h b/include/common.h index 4ad17ea..0c21edc 100644 --- a/include/common.h +++ b/include/common.h @@ -558,6 +558,14 @@ void ddr_enable_ecc(unsigned int dram_size); #endif #endif
+#if defined CONFIG_EXYNOS5
I don't think we need the #ifdef. If some boards don't have then that is OK.
Further to this, I suppose we can always remove the #ifdef when other boards define the function. So:
Will remove the #ifdef and resend the patch soon.
Acked-by: Simon Glass sjg@chromium.org _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

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 sjg@chromium.org Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com --- 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 09e88d5..c19e227 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->slave.bus = busnum; spi_slave->slave.cs = cs; spi_slave->regs = bus->regs; @@ -109,6 +113,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) @@ -370,9 +375,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(); }
/** @@ -421,6 +438,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; }

On Fri, Mar 22, 2013 at 6:28 AM, Rajeshwari Shinde rajeshwari.s@samsung.com wrote:
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 sjg@chromium.org Signed-off-by: Rajeshwari Shinde rajeshwari.s@samsung.com
Acked-by: Simon Glass sjg@chromium.org
participants (3)
-
Rajeshwari Birje
-
Rajeshwari Shinde
-
Simon Glass