[U-Boot] [PATCH 0/6] nds32: fix build errors/warnings

Using 'MAKEALL -a nds32' to build U-Boot images from the master branch of the git.denx.de/u-boot.git tree, throws the following errors/warnings:
$ ./MAKEALL -a nds32 Configuring for adp-ag101 board... ftsdc010_mci.c:178: error: 'FTSDC010_DCR_FIFO_RST' undeclared (first use in this function) ftsdc010_mci.c:178: error: (Each undeclared identifier is reported only once ftsdc010_mci.c:178: error: for each function it appears in.) make[1]: *** [ftsdc010_mci.o] Error 1 make: *** [drivers/mmc/libmmc.o] Error 2 size: './u-boot': No such file ftsdc010_mci.c: In function 'ftsdc010_clkset': ftsdc010_mci.c:118: warning: implicit declaration of function 'setbits_le32' ftsdc010_mci.c:123: warning: implicit declaration of function 'clrbits_le32' ftsdc010_mci.c: In function 'ftsdc010_request': ftsdc010_mci.c:178: error: 'FTSDC010_DCR_FIFO_RST' undeclared (first use in this function) ftsdc010_mci.c:178: error: (Each undeclared identifier is reported only once ftsdc010_mci.c:178: error: for each function it appears in.) make[1]: *** [ftsdc010_mci.o] Error 1 make: *** [drivers/mmc/libmmc.o] Error 2 make: *** Waiting for unfinished jobs.... Configuring for adp-ag101p board... ftsdc010_mci.c:178: error: 'FTSDC010_DCR_FIFO_RST' undeclared (first use in this function) ftsdc010_mci.c:178: error: (Each undeclared identifier is reported only once ftsdc010_mci.c:178: error: for each function it appears in.) make[1]: *** [ftsdc010_mci.o] Error 1 make: *** [drivers/mmc/libmmc.o] Error 2 size: './u-boot': No such file ftsdc010_mci.c: In function 'ftsdc010_clkset': ftsdc010_mci.c:118: warning: implicit declaration of function 'setbits_le32' ftsdc010_mci.c:123: warning: implicit declaration of function 'clrbits_le32' ftsdc010_mci.c: In function 'ftsdc010_request': ftsdc010_mci.c:178: error: 'FTSDC010_DCR_FIFO_RST' undeclared (first use in this function) ftsdc010_mci.c:178: error: (Each undeclared identifier is reported only once ftsdc010_mci.c:178: error: for each function it appears in.) make[1]: *** [ftsdc010_mci.o] Error 1 make: *** [drivers/mmc/libmmc.o] Error 2 make: *** Waiting for unfinished jobs.... Configuring for adp-ag102 board... make: *** [u-boot] Error 1 size: './u-boot': No such file ftsdc010_mci.c: In function 'ftsdc010_clkset': ftsdc010_mci.c:118: warning: implicit declaration of function 'setbits_le32' ftsdc010_mci.c:123: warning: implicit declaration of function 'clrbits_le32' cmd_ide.c: In function '__ide_output_data': cmd_ide.c:548: warning: passing argument 2 of 'ide_write_data' discards qualifiers from pointer target type /devel/u-boot.git/include/ide.h:76: note: expected 'ulong *' but argument is of type 'const ulong *' adp-ag102.c: In function 'pci_init_board': adp-ag102.c:95: warning: function declaration isn't a prototype drivers/mmc/libmmc.o: In function `ftsdc010_request': /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:230: undefined reference to `setbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:239: undefined reference to `clrbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:245: undefined reference to `clrbits_le32' drivers/mmc/libmmc.o: In function `ftsdc010_clkset': /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:118: undefined reference to `clrbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:118: undefined reference to `clrbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:121: undefined reference to `setbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:121: undefined reference to `setbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:123: undefined reference to `setbits_le32' make: *** [u-boot] Error 1
--------------------- SUMMARY ---------------------------- Boards compiled: 3 Boards with errors: 3 ( adp-ag101 adp-ag101p adp-ag102 ) ---------------------------------------------------------- $
After the patches are applied, all images can be compiled without errors/warnings:
$ ./MAKEALL -a nds32 Configuring for adp-ag101 board... text data bss dec hex filename 141801 6104 211752 359657 57ce9 ./u-boot Configuring for adp-ag101p board... text data bss dec hex filename 143897 6104 211752 361753 58519 ./u-boot Configuring for adp-ag102 board... text data bss dec hex filename 177369 6712 291592 475673 74219 ./u-boot
--------------------- SUMMARY ---------------------------- Boards compiled: 3 ---------------------------------------------------------- $
Cc: Macpaul Lin macpaul@andestech.com
Gabor Juhos (6): nds32: introduce macros for bit manipulation mmc: ftsdc010_mci: fix build error if CONFIG_FTSDC010_SDIO is not defined block: constify sect_buf argument of ide_write_data pci: add prototype for pci_ftpci_init() function pci: move pci_ftpci100.h to include/faraday/ftpci100.h nds32: adp-ag102: use 'faraday/ftpci100.h' for pci_ftpci_init
arch/nds32/include/asm/io.h | 37 ++++++++++++++++++++ board/AndesTech/adp-ag102/adp-ag102.c | 3 +- doc/driver-model/UDM-block.txt | 2 +- drivers/block/ftide020.c | 2 +- drivers/mmc/ftsdc010_mci.c | 6 +++- drivers/pci/pci_ftpci100.c | 4 +-- .../pci_ftpci100.h => include/faraday/ftpci100.h | 2 ++ include/ide.h | 2 +- 8 files changed, 50 insertions(+), 8 deletions(-) rename drivers/pci/pci_ftpci100.h => include/faraday/ftpci100.h (98%)
-- 1.7.10

U-Boot does not compile for the adp-ag101 boards since commit f6c3b34697bf8bf05cb4e81c2fd3cadb9a98daea (mmc: update Faraday FTSDC010 for rw performance)
The driver assumes that the bit manipulation macros are provided by all architectures. This is not the case for nds32 and it causes a build error like this:
ftsdc010_mci.c: In function 'ftsdc010_clkset': ftsdc010_mci.c:118: warning: implicit declaration of function 'setbits_le32' ftsdc010_mci.c:123: warning: implicit declaration of function 'clrbits_le32' drivers/mmc/libmmc.o: In function `ftsdc010_request': /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:234: undefined reference to `setbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:243: undefined reference to `clrbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:234: undefined reference to `clrbits_le32' drivers/mmc/libmmc.o: In function `ftsdc010_clkset': /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:118: undefined reference to `clrbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:118: undefined reference to `clrbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:121: undefined reference to `setbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:123: undefined reference to `setbits_le32' /devel/u-boot.git/drivers/mmc/ftsdc010_mci.c:123: undefined reference to `setbits_le32'
The patch adds bit manipulation macros for the nds32 architecture to avoid the errors. The macros are copied from the ARM implementation.
Compile tested only.
Cc: Kuo-Jung Su dantesu@faraday-tech.com Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org --- Notes:
I'm unsure that the macros are correct or not because I know virtually nothing about the nds32 architecture. However the nds32 specific {in,out}_{l,b]e_{8,16,32} macros are identical to the ARM counterparts so the new bit manipulation macros should behave identically as well.
-Gabor --- arch/nds32/include/asm/io.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
diff --git a/arch/nds32/include/asm/io.h b/arch/nds32/include/asm/io.h index 39c3dc8..254c8f9 100644 --- a/arch/nds32/include/asm/io.h +++ b/arch/nds32/include/asm/io.h @@ -184,6 +184,43 @@ static inline unsigned int readl(unsigned int *addr) #define in_8(a) __raw_readb(a)
/* + * Clear and set bits in one shot. These macros can be used to clear and + * set multiple bits in a register using a single call. These macros can + * also be used to set a multiple-bit bit pattern using a mask, by + * specifying the mask in the 'clear' parameter and the new bit pattern + * in the 'set' parameter. + */ + +#define clrbits(type, addr, clear) \ + out_##type((addr), in_##type(addr) & ~(clear)) + +#define setbits(type, addr, set) \ + out_##type((addr), in_##type(addr) | (set)) + +#define clrsetbits(type, addr, clear, set) \ + out_##type((addr), (in_##type(addr) & ~(clear)) | (set)) + +#define clrbits_be32(addr, clear) clrbits(be32, addr, clear) +#define setbits_be32(addr, set) setbits(be32, addr, set) +#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set) + +#define clrbits_le32(addr, clear) clrbits(le32, addr, clear) +#define setbits_le32(addr, set) setbits(le32, addr, set) +#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set) + +#define clrbits_be16(addr, clear) clrbits(be16, addr, clear) +#define setbits_be16(addr, set) setbits(be16, addr, set) +#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set) + +#define clrbits_le16(addr, clear) clrbits(le16, addr, clear) +#define setbits_le16(addr, set) setbits(le16, addr, set) +#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set) + +#define clrbits_8(addr, clear) clrbits(8, addr, clear) +#define setbits_8(addr, set) setbits(8, addr, set) +#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set) + +/* * Now, pick up the machine-defined IO definitions * #include <asm/arch/io.h> */

Hi Gabor,
2013/5/26 Gabor Juhos juhosg@openwrt.org:
U-Boot does not compile for the adp-ag101 boards since commit f6c3b34697bf8bf05cb4e81c2fd3cadb9a98daea (mmc: update Faraday FTSDC010 for rw performance)
The driver assumes that the bit manipulation macros are provided by all architectures. This is not the case for nds32 and it causes a build error like this:
Applied to u-boot-nds32/master Thanks for your help!

The FTSDC010_DCR_FIFO_RST symbol is conditionally defined in <faraday/ftsdc010.h> and it is available available when CONFIG_FTSDC010_SDIO is enabled.
However the actual driver code unconditionally uses the FTSDC010_DCR_FIFO_RST constant and this causes build error if CONFIG_FTSDC010_SDIO is not enabled.
The following error happens when compiling for the adp-ag101 board:
ftsdc010_mci.c: In function 'ftsdc010_request': ftsdc010_mci.c:178: error: 'FTSDC010_DCR_FIFO_RST' undeclared (first use in this function) ftsdc010_mci.c:178: error: (Each undeclared identifier is reported only once ftsdc010_mci.c:178: error: for each function it appears in.)
The patch ensures that the FTSDC010_DCR_FIFO_RST symbol gets used only if CONFIG_FTSDC010_SDIO is defined.
Compile tested only.
Cc: Kuo-Jung Su dantesu@faraday-tech.com Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org --- drivers/mmc/ftsdc010_mci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/ftsdc010_mci.c b/drivers/mmc/ftsdc010_mci.c index 562b14a..1fcb97c 100644 --- a/drivers/mmc/ftsdc010_mci.c +++ b/drivers/mmc/ftsdc010_mci.c @@ -175,7 +175,11 @@ static int ftsdc010_request(struct mmc *mmc, struct mmc_cmd *cmd, len = data->blocksize * data->blocks;
/* 1. data disable + fifo reset */ - writel(FTSDC010_DCR_FIFO_RST, ®s->dcr); + dcr = 0; +#ifdef CONFIG_FTSDC010_SDIO + dcr |= FTSDC010_DCR_FIFO_RST; +#endif + writel(dcr, ®s->dcr);
/* 2. clear status register */ writel(FTSDC010_STATUS_DATA_MASK | FTSDC010_STATUS_FIFO_URUN

2013/5/26 Gabor Juhos juhosg@openwrt.org:
The FTSDC010_DCR_FIFO_RST symbol is conditionally defined in <faraday/ftsdc010.h> and it is available available when CONFIG_FTSDC010_SDIO is enabled.
However the actual driver code unconditionally uses the FTSDC010_DCR_FIFO_RST constant and this causes build error if CONFIG_FTSDC010_SDIO is not enabled.
The following error happens when compiling for the adp-ag101 board:
ftsdc010_mci.c: In function 'ftsdc010_request': ftsdc010_mci.c:178: error: 'FTSDC010_DCR_FIFO_RST' undeclared (first use in this function) ftsdc010_mci.c:178: error: (Each undeclared identifier is reported only once ftsdc010_mci.c:178: error: for each function it appears in.)
The patch ensures that the FTSDC010_DCR_FIFO_RST symbol gets used only if CONFIG_FTSDC010_SDIO is defined.
Compile tested only.
Sorry, it's my bad. I don't have the NDS32 toolchain, so I didn't run the compiling test for NDS32 platforms.
Cc: Kuo-Jung Su dantesu@faraday-tech.com Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org
drivers/mmc/ftsdc010_mci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/ftsdc010_mci.c b/drivers/mmc/ftsdc010_mci.c index 562b14a..1fcb97c 100644 --- a/drivers/mmc/ftsdc010_mci.c +++ b/drivers/mmc/ftsdc010_mci.c @@ -175,7 +175,11 @@ static int ftsdc010_request(struct mmc *mmc, struct mmc_cmd *cmd, len = data->blocksize * data->blocks;
/* 1. data disable + fifo reset */
writel(FTSDC010_DCR_FIFO_RST, ®s->dcr);
dcr = 0;
+#ifdef CONFIG_FTSDC010_SDIO
dcr |= FTSDC010_DCR_FIFO_RST;
+#endif
writel(dcr, ®s->dcr); /* 2. clear status register */ writel(FTSDC010_STATUS_DATA_MASK | FTSDC010_STATUS_FIFO_URUN
-- 1.7.10
Reviewed-by: Kuo-Jung Su dantesu@faraday-tech.com
-- Best wishes, Kuo-Jung Su

Add a const keyword to the sect_buf argument of ide_write_data to fix the following warning:
cmd_ide.c: In function '__ide_output_data': cmd_ide.c:548: warning: passing argument 2 of 'ide_write_data' discards qualifiers from pointer target type /devel/u-boot.git/include/ide.h:76: note: expected 'ulong *' but argument is of type 'const ulong *'
Also modify the driver-model documentation to match with the new prototype.
Compile tested only.
Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org --- doc/driver-model/UDM-block.txt | 2 +- drivers/block/ftide020.c | 2 +- include/ide.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/doc/driver-model/UDM-block.txt b/doc/driver-model/UDM-block.txt index 5d5c776..b42ec69 100644 --- a/doc/driver-model/UDM-block.txt +++ b/doc/driver-model/UDM-block.txt @@ -93,7 +93,7 @@ I) Overview uchar ide_read_register(int dev, unsigned int port); void ide_write_register(int dev, unsigned int port, unsigned char val); void ide_read_data(int dev, ulong *sect_buf, int words); - void ide_write_data(int dev, ulong *sect_buf, int words); + void ide_write_data(int dev, const ulong *sect_buf, int words);
The first two functions are called from ide_inb()/ide_outb(), and will default to direct memory access if CONFIG_IDE_AHB is not set, or diff --git a/drivers/block/ftide020.c b/drivers/block/ftide020.c index ad8fdad..61900ba 100644 --- a/drivers/block/ftide020.c +++ b/drivers/block/ftide020.c @@ -81,7 +81,7 @@ void ide_write_register(int dev, unsigned int port, unsigned char val) IDE_REG_DA_WRITE(port) | val); }
-void ide_write_data(int dev, ulong *sect_buf, int words) +void ide_write_data(int dev, const ulong *sect_buf, int words) { static struct ftide020_s *ftide020 = (struct ftide020_s *) FTIDE_BASE;
diff --git a/include/ide.h b/include/ide.h index afea85c..703338d 100644 --- a/include/ide.h +++ b/include/ide.h @@ -73,7 +73,7 @@ int ide_device_present(int dev); unsigned char ide_read_register(int dev, unsigned int port); void ide_write_register(int dev, unsigned int port, unsigned char val); void ide_read_data(int dev, ulong *sect_buf, int words); -void ide_write_data(int dev, ulong *sect_buf, int words); +void ide_write_data(int dev, const ulong *sect_buf, int words); #endif
/*

Hi Gabor,
2013/5/26 Gabor Juhos juhosg@openwrt.org:
Add a const keyword to the sect_buf argument of ide_write_data to fix the following warning:
Applied to u-boot-nds32/master Thanks for your help!

The pci_ftpci_init() function is implemented in 'drivers/pci/pci_ftpci100.c' however it is always called by external code.
Add function declaration into ftpci100.h to make it visible for external code.
Compile tested only.
Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org --- drivers/pci/pci_ftpci100.h | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/drivers/pci/pci_ftpci100.h b/drivers/pci/pci_ftpci100.h index 19c81a8..7a4945a 100644 --- a/drivers/pci/pci_ftpci100.h +++ b/drivers/pci/pci_ftpci100.h @@ -76,6 +76,8 @@ struct ftpci100_ahbc { #define FTPCI100_BRIDGE_VENDORID 0x159b #define FTPCI100_BRIDGE_DEVICEID 0x4321
+void pci_ftpci_init(void); + struct pcibar { unsigned int size; unsigned int addr;

Hi Gabor,
2013/5/26 Gabor Juhos juhosg@openwrt.org:
The pci_ftpci_init() function is implemented in 'drivers/pci/pci_ftpci100.c' however it is always called by external code.
Add function declaration into ftpci100.h to make it visible for external code.
Compile tested only.
Applied to u-boot-nds32/master Thanks for your help!

Even though the header files is used only by the pci_ftpci100 driver, it contains declaration for a function which is used by external code.
Move the header file to a common location which lets external code use it.
Compile tested only.
Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org --- drivers/pci/pci_ftpci100.c | 4 ++-- drivers/pci/pci_ftpci100.h => include/faraday/ftpci100.h | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename drivers/pci/pci_ftpci100.h => include/faraday/ftpci100.h (100%)
diff --git a/drivers/pci/pci_ftpci100.c b/drivers/pci/pci_ftpci100.c index a795a97..df7f615 100644 --- a/drivers/pci/pci_ftpci100.c +++ b/drivers/pci/pci_ftpci100.c @@ -23,11 +23,11 @@ #include <malloc.h> #include <pci.h>
+#include <faraday/ftpci100.h> + #include <asm/io.h> #include <asm/types.h> /* u32, u16.... used by pci.h */
-#include "pci_ftpci100.h" - struct ftpci100_data { unsigned int reg_base; unsigned int io_base; diff --git a/drivers/pci/pci_ftpci100.h b/include/faraday/ftpci100.h similarity index 100% rename from drivers/pci/pci_ftpci100.h rename to include/faraday/ftpci100.h

Hi Gabor,
2013/5/26 Gabor Juhos juhosg@openwrt.org:
Even though the header files is used only by the pci_ftpci100 driver, it contains declaration for a function which is used by external code.
Move the header file to a common location which lets external code use it.
Compile tested only.
Applied to u-boot-nds32/master Thanks for your help!

Due to improper external function declaration, building U-Boot for the adp-ag102 board shows this warning:
adp-ag102.c: In function 'pci_init_board': adp-ag102.c:95: warning: function declaration isn't a prototype
Include the 'faraday/ftpci100.h' header which provides the proper declaration and remove the local declaration to get rid of the warning.
Compile tested only.
Cc: Macpaul Lin macpaul@andestech.com Signed-off-by: Gabor Juhos juhosg@openwrt.org --- board/AndesTech/adp-ag102/adp-ag102.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/board/AndesTech/adp-ag102/adp-ag102.c b/board/AndesTech/adp-ag102/adp-ag102.c index 5a25632..1b56dac 100644 --- a/board/AndesTech/adp-ag102/adp-ag102.c +++ b/board/AndesTech/adp-ag102/adp-ag102.c @@ -25,6 +25,7 @@ #include <netdev.h> #include <asm/io.h>
+#include <faraday/ftpci100.h> #include <faraday/ftsdc010.h> #ifdef CONFIG_FTSMC020 #include <faraday/ftsmc020.h> @@ -92,8 +93,6 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info) void pci_init_board(void) { /* should be pci_ftpci100_init() */ - extern void pci_ftpci_init(); - pci_ftpci_init(); } #endif

Hi Gabor,
2013/5/26 Gabor Juhos juhosg@openwrt.org:
Due to improper external function declaration, building U-Boot for the adp-ag102 board shows this warning:
adp-ag102.c: In function 'pci_init_board': adp-ag102.c:95: warning: function declaration isn't a prototype
Include the 'faraday/ftpci100.h' header which provides the proper declaration and remove the local declaration to get rid of the warning.
Compile tested only.
Applied to u-boot-nds32/master Thanks for your help!
participants (3)
-
Gabor Juhos
-
Kuo-Jung Su
-
Macpaul Lin