[U-Boot] [PATCH 2/4] spi: add spi_set_speed func
Thomas Chou
thomas at wytron.com.tw
Fri Dec 24 08:16:07 CET 2010
This func helps mmc_spi driver set correct speed for mmc/sd, as
mmc card needs 400KHz clock for spi mode initialization.
Signed-off-by: Thomas Chou <thomas at wytron.com.tw>
---
drivers/spi/Makefile | 1 +
drivers/spi/spi.c | 9 +++++++++
include/spi.h | 8 ++++++++
3 files changed, 18 insertions(+), 0 deletions(-)
create mode 100644 drivers/spi/spi.c
diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile
index e34a124..c4eb627 100644
--- a/drivers/spi/Makefile
+++ b/drivers/spi/Makefile
@@ -25,6 +25,7 @@ include $(TOPDIR)/config.mk
LIB := $(obj)libspi.o
+COBJS-$(CONFIG_MMC_SPI) += spi.o
COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o
COBJS-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
new file mode 100644
index 0000000..944466a
--- /dev/null
+++ b/drivers/spi/spi.c
@@ -0,0 +1,9 @@
+#include <common.h>
+#include <spi.h>
+
+/* default func for SPI driver without set speed func */
+static void __spi_set_speed(struct spi_slave *slave, uint hz)
+{
+}
+void spi_set_speed(struct spi_slave *slave, uint hz)
+ __attribute__((weak, alias("__spi_set_speed")));
diff --git a/include/spi.h b/include/spi.h
index 320e50e..7887d0f 100644
--- a/include/spi.h
+++ b/include/spi.h
@@ -176,6 +176,14 @@ void spi_cs_activate(struct spi_slave *slave);
void spi_cs_deactivate(struct spi_slave *slave);
/*-----------------------------------------------------------------------
+ * Set transfer speed.
+ * This sets a new speed to be applied for next spi_xfer().
+ * slave: The SPI slave
+ * hz: The transfer speed
+ */
+void spi_set_speed(struct spi_slave *slave, uint hz);
+
+/*-----------------------------------------------------------------------
* Write 8 bits, then read 8 bits.
* slave: The SPI slave we're communicating with
* byte: Byte to be written
--
1.7.3.4
More information about the U-Boot
mailing list