summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2008-02-26 11:28:55 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-02-26 11:28:55 +0100
commit3d3c13d8f8238d0ed6e3e23841737de53b2c424f (patch)
tree7a4a9c8a53a2996778c284a85493beb1da3575eb /include
parent51c840cd18acd8a9f656b1491bc8ff100acccbd0 (diff)
downloadbarebox-3d3c13d8f8238d0ed6e3e23841737de53b2c424f.tar.gz
barebox-3d3c13d8f8238d0ed6e3e23841737de53b2c424f.tar.xz
[CFI Driver] - Update Kconfig help texts
- Turn switch/case into if/else to be able to optimize out unused code when not all bankwidths are needed
Diffstat (limited to 'include')
-rw-r--r--include/cfi_flash_new.h37
1 files changed, 28 insertions, 9 deletions
diff --git a/include/cfi_flash_new.h b/include/cfi_flash_new.h
index c00f47c546..2a0517f4b7 100644
--- a/include/cfi_flash_new.h
+++ b/include/cfi_flash_new.h
@@ -209,6 +209,30 @@ static inline uchar flash_read_uchar (flash_info_t * info, uint offset)
#endif
}
+#ifdef CONFIG_DRIVER_CFI_BANK_WIDTH_1
+#define bankwidth_is_1(info) (info->portwidth == 1)
+#else
+#define bankwidth_is_1(info) 0
+#endif
+
+#ifdef CONFIG_DRIVER_CFI_BANK_WIDTH_2
+#define bankwidth_is_2(info) (info->portwidth == 2)
+#else
+#define bankwidth_is_2(info) 0
+#endif
+
+#ifdef CONFIG_DRIVER_CFI_BANK_WIDTH_4
+#define bankwidth_is_4(info) (info->portwidth == 4)
+#else
+#define bankwidth_is_4(info) 0
+#endif
+
+#ifdef CONFIG_DRIVER_CFI_BANK_WIDTH_8
+#define bankwidth_is_8(info) (info->portwidth == 8)
+#else
+#define bankwidth_is_8(info) 0
+#endif
+
typedef union {
unsigned char c;
unsigned short w;
@@ -225,22 +249,17 @@ typedef union {
static inline void flash_write_word(flash_info_t *info, cfiword_t datum, void *addr)
{
- switch (info->portwidth) {
- case FLASH_CFI_8BIT:
+ if (bankwidth_is_1(info)) {
debug("fw addr %p val %02x\n", addr, datum.c);
writeb(datum.c, addr);
- break;
- case FLASH_CFI_16BIT:
+ } else if (bankwidth_is_2(info)) {
debug("fw addr %p val %04x\n", addr, datum.w);
writew(datum.w, addr);
- break;
- case FLASH_CFI_32BIT:
+ } else if (bankwidth_is_4(info)) {
debug("fw addr %p val %08x\n", addr, datum.l);
writel(datum.l, addr);
- break;
- case FLASH_CFI_64BIT:
+ } else if (bankwidth_is_8(info)) {
memcpy((void *)addr, &datum.ll, 8);
- break;
}
}