Added read_buff function to ath_flash.
Change-Id: I4e876250f03e7bbed6f095d3e27b3ffe04e4e202
diff --git a/board/atheros/common/ath_flash.c b/board/atheros/common/ath_flash.c
index e89c89b..be88edf 100755
--- a/board/atheros/common/ath_flash.c
+++ b/board/atheros/common/ath_flash.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2013 Qualcomm Atheros, Inc.
- *
+ *
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
@@ -89,9 +89,9 @@
#else
ath_reg_wr_nf(ATH_SPI_CLOCK, 0x43);
#endif
-#endif
+#endif
-#if defined(CONFIG_MACH_QCA953x) /* Added for HB-SMIC */
+#if defined(CONFIG_MACH_QCA953x) /* Added for HB-SMIC */
#ifdef ATH_SST_FLASH
ath_reg_wr_nf(ATH_SPI_CLOCK, 0x4);
ath_spi_flash_unblock();
@@ -99,7 +99,7 @@
#else
ath_reg_wr_nf(ATH_SPI_CLOCK, 0x44);
#endif
-#endif
+#endif
ath_reg_rmw_set(ATH_SPI_FS, 1);
ath_spi_read_id();
ath_reg_rmw_clear(ATH_SPI_FS, 1);
@@ -214,6 +214,32 @@
return(ath_write_buff(info, source, addr - CFG_FLASH_BASE, len));
}
+int
+read_buff(flash_info_t *info, uchar *buf, ulong from, ulong len)
+{
+ ulong i = 0;
+ if (len == 0)
+ {
+ return ERR_OK;
+ }
+ if (from + len > info->size)
+ {
+ printf("ERROR: from: ( %ld ) len: ( %ld ) flash_size: ( %ld )\n", from, len, info->size);
+ return ERR_INVAL;
+ }
+ ath_spi_write_enable();
+ ath_spi_bit_banger(ATH_SPI_CMD_READ);
+ ath_spi_send_addr((uint32_t) from);
+ for (i = 0; i < len; ++i)
+ {
+ ath_spi_delay_8();
+ buf[i] = (uchar) ath_reg_rd(ATH_SPI_RD_STATUS);
+ }
+ ath_spi_go();
+ ath_spi_done();
+ return ERR_OK;
+}
+
#if ENABLE_EXT_ADDR_SUPPORT
int
read_buff_ext(flash_info_t *info, uchar *buf, ulong offset, ulong len)
diff --git a/include/flash.h b/include/flash.h
index 4978f7d..79031a4 100755
--- a/include/flash.h
+++ b/include/flash.h
@@ -89,6 +89,7 @@
extern int flash_write (char *, ulong, ulong);
extern flash_info_t *addr2info (ulong);
extern int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt);
+extern int read_buff (flash_info_t *info, uchar *src, ulong from, ulong len);
#if ENABLE_EXT_ADDR_SUPPORT
extern int write_buff_ext (flash_info_t *info, uchar *src, ulong offset, ulong cnt);
extern int read_buff_ext (flash_info_t *info, uchar *buf, ulong offset, ulong cnt);
@@ -422,7 +423,7 @@
#define FLASH_MT28S4M16LC 0x00E1 /* Micron MT28S4M16LC */
#define FLASH_S29GL064M 0x00F0 /* Spansion S29GL064M-R6 */
-#define FLASH_M25P64 0x00F2
+#define FLASH_M25P64 0x00F2
#define FLASH_UNKNOWN 0xFFFF /* unknown flash type */