Improve upstream support for Snowball board (v2)
Patches are loosely based on the tree maintained by Calao. FDT confirmed working, LAN is successfully detected by u-boot (but lacking a proper tftp setup this is untested). Upstream U-Boot still has one bug that prevents booting from eMMC. Easiest workaround is to revert
e95504497ecac46907204b0ee3460b708a2981ac mmc: Split device init to decouple OCR-polling delay
until I (or someone else) has time to device a proper fix. This doesn't prevent anyone from pushing these two patches though.
v2: Split up networking patch into one for driver and one for board. Fix checkpatch errors. Three warnings are still reported by checkstyle.pl, related to the use of the volatile keyword. These warning are not justified or relevant for MMIO register reads as far as I know, so could be ignored.
PATCH 1/3 drivers/smc911x: Add support for shifted register read/write
Required for (but potentially not limited to) the snowball board. Implementation is inspired by the linux smsc911x implementation, but by using a (pre-compiler) constant, things should be optimised by the compiler for a shift of 0.
--- drivers/net/smc911x.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/smc911x.h +10 -4
@@ -19,6 +19,12 @@ CONFIG_SMC911X_16_BIT shall be set"#endif +#ifndef CONFIG_SMC911X_SHIFT +#define CONFIG_SMC911X_SHIFT 0 +#endif + +#define smc911x_shift (i) ((i) << CONFIG_SMC911X_SHIFT) +#if defined (CONFIG_SMC911X_32_BIT )static inline u32 __smc911x_reg_read (struct eth_device *dev,u32 offset) {
@@ -37,14 +43,14 @@ void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)#elif defined (CONFIG_SMC911X_16_BIT )static inline u32 smc911x_reg_read (struct eth_device *dev,u32 offset) { -volatile u16 *addr_16 = (u16 *)(dev->iobase + offset); -return ((*addr_16 &0x0000ffff ) | (*(addr_16 +1 ) <<16 )); +volatile u16 *addr_16 = (u16 *)(dev->iobase +smc911x_shift (offset)); +return (*addr_16 &0x0000FFFF ) | (*(addr_16 +smc911x_shift (1 )) <<16 ); }static inline void smc911x_reg_write (struct eth_device *dev,u32 offset,u32 val) { - *(volatile u16 *)(dev->iobase + offset) = (u16 )val; - *(volatile u16 *)(dev->iobase + offset +2 ) = (u16)(val >>16 ); + *(volatile u16 *)(dev->iobase +smc911x_shift (offset)) = (u16 )val; + *(volatile u16 *)(dev->iobase +smc911x_shift (offset +2 )) = (u16 )val; }#else #error "SMC911X: undefined bus width"
Signature · 1 line
1.8.1.2
PATCH 1/3 drivers/smc911x: Add support for shifted register read/write
Hi Roy,
Re: the subject: please next time put the version in the subjetc line too. You may benefit from using patman, which helps managing patch series and handles such things as adding version in suject lines and Cc:ing people according to tags, etc. see tools/patman/README.
Also:
Quoted 14 lines · Roy Spliet
Required for (but potentially not limited to) the snowball board. Implementation is inspired by the linux smsc911x implementation, but by using a (pre-compiler) constant, things should be optimised by the compiler for a shift of 0.
Signed-off-by Roy Spliet <[email protected]>--- drivers/net/smc911x.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/net/smc911x.h +0
-0
drivers/net/smc911x.h line 26
Quoted 8 lines
drivers/net/smc911x.h +5
-0@@ -19,6 +19,12 @@ CONFIG_SMC911X_16_BIT shall be set"#endif +#ifndef CONFIG_SMC911X_SHIFT +#define CONFIG_SMC911X_SHIFT 0 +#endif + +#define smc911x_shift (i) ((i) << CONFIG_SMC911X_SHIFT)
I find that defining a macro just to shift a field by a constant value is over-engineering. It is not really worse to do the (i << NNN)@the point(s) of use, and the reader will immediately understand what's being done.
Quoted 12 lines
drivers/net/smc911x.h +2
-2#if defined (CONFIG_SMC911X_32_BIT )static inline u32 __smc911x_reg_read (struct eth_device *dev,u32 offset) {@@ -37,14 +43,14 @@ void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val)#elif defined (CONFIG_SMC911X_16_BIT )static inline u32 smc911x_reg_read (struct eth_device *dev,u32 offset) { -volatile u16 *addr_16 = (u16 *)(dev->iobase + offset); -return ((*addr_16 &0x0000ffff ) | (*(addr_16 +1 ) <<16 )); +volatile u16 *addr_16 = (u16 *)(dev->iobase +smc911x_shift (offset)); +return (*addr_16 &0x0000FFFF ) | (*(addr_16 +smc911x_shift (1 )) <<16 ); }
drivers/net/smc911x.h void smc911x_reg_write(struct eth_device *dev, u32 offset, u32 val) · line 56
Quoted 10 lines
drivers/net/smc911x.h +2
-2static inline void smc911x_reg_write (struct eth_device *dev,u32 offset,u32 val) { - *(volatile u16 *)(dev->iobase + offset) = (u16 )val; - *(volatile u16 *)(dev->iobase + offset +2 ) = (u16)(val >>16 ); + *(volatile u16 *)(dev->iobase +smc911x_shift (offset)) = (u16 )val; + *(volatile u16 *)(dev->iobase +smc911x_shift (offset +2 )) = (u16 )val; }#else #error "SMC911X: undefined bus width"
Amicalement,
Signature · 1 line
Albert.
PATCH 2/3 board/snowball: Add support for network boot
In reply to Roy Spliet--- board/st-ericsson/snowball/snowball.c | 11 +++++++++++ include/configs/snowball.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+)
board/st-ericsson/snowball/snowball.c +11 -0
@@ -245,6 +245,8 @@ int board_late_init(void)while (tstc ()) (void )getc (); +mdelay (25 ); +return 0 ; }
@@ -338,3 +340,12 @@ int board_mmc_init(bd_t *bis) return 0; }#endif /* CONFIG_MMC */ + +int board_eth_init (bd_t *bis) +{ +int error =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +if (error) +return error; + +return cpu_eth_init (bis); +}
include/configs/snowball.h +14 -0
@@ -95,6 +95,10 @@#define CONFIG_CMD_FAT #define CONFIG_CMD_EXT2 #define CONFIG_CMD_SOURCE +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_NET +#define CONFIG_CMD_NFS +#define CONFIG_CMD_PING #ifndef CONFIG_BOOTDELAY #define CONFIG_BOOTDELAY 1
@@ -245,4 +249,14 @@#define CFG_FSMC_BASE 0x80000000/* FSMC Controller */ +/* +* Networking +*/ +#define CONFIG_NET +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X +#define CONFIG_SMC911X_16_BIT +#define CONFIG_SMC911X_SHIFT 1 +#define CONFIG_SMC911X_BASE 0x50000000 +#endif /* __CONFIG_H */
Signature · 1 line
1.8.1.2
PATCH 2/3 board/snowball: Add support for network boot
Hi Roy,
Quoted 11 lines · Roy Spliet
Signed-off-by Roy Spliet <[email protected]>--- board/st-ericsson/snowball/snowball.c | 11 +++++++++++ include/configs/snowball.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+)board/st-ericsson/snowball/snowball.c +0
-0
board/st-ericsson/snowball/snowball.c int board_late_init(void) · line 248
Quoted 4 lines
board/st-ericsson/snowball/snowball.c +1
-0@@ -245,6 +245,8 @@ int board_late_init(void)while (tstc ()) (void )getc (); +mdelay (25 );
Please explain (here at least, possible also in commit depending on the reason) why a 25 ms delay is needed -- and why it was not needed before.
Quoted 37 lines
board/st-ericsson/snowball/snowball.c +10
-0+return 0 ; }@@ -338,3 +340,12 @@ int board_mmc_init(bd_t *bis) return 0; }#endif /* CONFIG_MMC */ + +int board_eth_init (bd_t *bis) +{ +int error =smc911x_initialize (0 ,CONFIG_SMC911X_BASE ); +if (error) +return error; + +return cpu_eth_init (bis); +}include/configs/snowball.h +5
-0@@ -95,6 +95,10 @@#define CONFIG_CMD_FAT #define CONFIG_CMD_EXT2 #define CONFIG_CMD_SOURCE +#define CONFIG_CMD_DHCP +#define CONFIG_CMD_NET +#define CONFIG_CMD_NFS +#define CONFIG_CMD_PING #ifndef CONFIG_BOOTDELAY #define CONFIG_BOOTDELAY 1@@ -245,4 +249,14 @@#define CFG_FSMC_BASE 0x80000000/* FSMC Controller */ +/*
include/configs/snowball.h line 262
Quoted 10 lines
include/configs/snowball.h +9
-0+* Networking +*/ +#define CONFIG_NET +#define CONFIG_NET_MULTI +#define CONFIG_SMC911X +#define CONFIG_SMC911X_16_BIT +#define CONFIG_SMC911X_SHIFT 1 +#define CONFIG_SMC911X_BASE 0x50000000 +#endif /* __CONFIG_H */
Amicalement,
Signature · 1 line
Albert.
PATCH 3/3 board/snowball: Enable FDT
In reply to Roy Spliet--- include/configs/snowball.h | 5 +++++ 1 file changed, 5 insertions(+)
include/configs/snowball.h +5 -0
@@ -259,4 +259,9 @@#define CONFIG_SMC911X_SHIFT 1#define CONFIG_SMC911X_BASE 0x50000000 +/* +* Device tree +*/ +#define CONFIG_OF_LIBFDT +#endif /* __CONFIG_H */
Signature · 1 line
1.8.1.2