summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/spi/sf.c
diff options
context:
space:
mode:
authorJagannadha Sutradharudu Teki <jaganna@xilinx.com>2013-09-26 16:00:15 +0530
committerJagannadha Sutradharudu Teki <jaganna@xilinx.com>2013-10-07 17:55:50 +0530
commit898e76c938eb169fd19733d4e4c44ba26c6dbd87 (patch)
tree68c3ccdd09b3e215347e62a59eb5fda909bdaad1 /drivers/mtd/spi/sf.c
parent1b1bd9a7b3d6ac65fc73cd05dc7cb013e453e14b (diff)
downloadblackbird-obmc-uboot-898e76c938eb169fd19733d4e4c44ba26c6dbd87.tar.gz
blackbird-obmc-uboot-898e76c938eb169fd19733d4e4c44ba26c6dbd87.zip
sf: Rename spi_flash files
Renamed: spi_flash.c -> sf.c spi_flash_internal.h -> sf_internal.h spi_flash_ops.c -> sf_ops.c spi_flash_probe.c -> sf_probe.c Signed-off-by: Jagannadha Sutradharudu Teki <jaganna@xilinx.com>
Diffstat (limited to 'drivers/mtd/spi/sf.c')
-rw-r--r--drivers/mtd/spi/sf.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/drivers/mtd/spi/sf.c b/drivers/mtd/spi/sf.c
new file mode 100644
index 0000000000..ddbdda0dc2
--- /dev/null
+++ b/drivers/mtd/spi/sf.c
@@ -0,0 +1,54 @@
+/*
+ * SPI flash interface
+ *
+ * Copyright (C) 2008 Atmel Corporation
+ * Copyright (C) 2010 Reinhard Meyer, EMK Elektronik
+ *
+ * Licensed under the GPL-2 or later.
+ */
+
+#include <common.h>
+#include <spi.h>
+
+static int spi_flash_read_write(struct spi_slave *spi,
+ const u8 *cmd, size_t cmd_len,
+ const u8 *data_out, u8 *data_in,
+ size_t data_len)
+{
+ unsigned long flags = SPI_XFER_BEGIN;
+ int ret;
+
+ if (data_len == 0)
+ flags |= SPI_XFER_END;
+
+ ret = spi_xfer(spi, cmd_len * 8, cmd, NULL, flags);
+ if (ret) {
+ debug("SF: Failed to send command (%zu bytes): %d\n",
+ cmd_len, ret);
+ } else if (data_len != 0) {
+ ret = spi_xfer(spi, data_len * 8, data_out, data_in,
+ SPI_XFER_END);
+ if (ret)
+ debug("SF: Failed to transfer %zu bytes of data: %d\n",
+ data_len, ret);
+ }
+
+ return ret;
+}
+
+int spi_flash_cmd_read(struct spi_slave *spi, const u8 *cmd,
+ size_t cmd_len, void *data, size_t data_len)
+{
+ return spi_flash_read_write(spi, cmd, cmd_len, NULL, data, data_len);
+}
+
+int spi_flash_cmd(struct spi_slave *spi, u8 cmd, void *response, size_t len)
+{
+ return spi_flash_cmd_read(spi, &cmd, 1, response, len);
+}
+
+int spi_flash_cmd_write(struct spi_slave *spi, const u8 *cmd, size_t cmd_len,
+ const void *data, size_t data_len)
+{
+ return spi_flash_read_write(spi, cmd, cmd_len, data, NULL, data_len);
+}
OpenPOWER on IntegriCloud