Blackfin updates for 2009.03 (part 2)
Subsystems (7)
cover Blackfin updates for 2009.03 (part 2)
A few more simple bug fixes, but now we get some fun stuff too:
- major cleanup of the Blackfin on-chip MAC driver
- new driver for Blackfin on-chip NAND controller
- new driver for Blackfin on-chip ATAPI controller
- new driver for Blackfin on-chip SDIO controller
- improve cache performance
- improve dma memcpy performance
Cliff Cai (1):
Blackfin: add driver for on-chip MMC/SD controller
Mike Frysinger (25):
Blackfin: bfin_mac: force board_get_enetaddr() usage
Blackfin: bfin_mac: set MDCDIV based on SCLK
Blackfin: bfin_mac: cleanup MII/PHY functions
Blackfin: bfin_mac: respect CONFIG_PHY_{ADDR,CLOCK_FREQ}
Blackfin: bfin_mac: use common debug()
Blackfin: bfin_mac: convert CONFIG_BFIN_MAC_RMII to CONFIG_RMII
Blackfin: bfin_mac: cleanup pointer/casts for aliasing issues
Blackfin: only build post code when CONFIG_POST
Blackfin: add driver for on-chip SPI controller
Blackfin: dont check baud if it wont actually get used
Blackfin: enable --gc-sections
Blackfin: cache core/system clock values
Blackfin: setup bi_enetaddr for single nets
Blackfin: rewrite cache handling functions
Blackfin: dma_memcpy(): fix random failures
Blackfin: only flag L1 instruction for DMA memcpy
Blackfin: use 8/16/32 bit transfer widths in dma_memcpy()
Blackfin: fix up EBIU defines
Blackfin: build with -mno-fdpic
Blackfin: add driver for on-chip NAND controller
Blackfin: add port I bits
Blackfin: update asm-blackfin/posix_types.h to latest Linux version
Blackfin: set default CONFIG_ENV_SPI_CS based on bootrom
Blackfin: output booting source when booting
Blackfin: add port muxing for BF51x SPI
Sonic Zhang (1):
Blackfin: add driver for on-chip ATAPI controller
blackfin_config.mk | 5 +- board/bf537-stamp/spi_flash.c | 20 +- cpu/blackfin/Makefile | 1 + cpu/blackfin/cache.S | 118 ++- cpu/blackfin/initcode.c | 6 +- drivers/block/Makefile | 1 + drivers/block/pata_bfin.c | 1201 ++++++++++++++++++++++++++ drivers/block/pata_bfin.h | 173 ++++ drivers/mmc/Makefile | 1 + drivers/mmc/bfin_sdh.c | 546 ++++++++++++ drivers/mmc/bfin_sdh.h | 59 ++ drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/bfin_nand.c | 376 ++++++++ drivers/net/bfin_mac.c | 404 +++++----- drivers/net/bfin_mac.h | 31 +- drivers/spi/Makefile | 1 + drivers/spi/bfin_spi.c | 343 ++++++++ include/asm-blackfin/blackfin-config-post.h | 5 + include/asm-blackfin/blackfin-config-pre.h | 22 + include/asm-blackfin/blackfin_local.h | 20 +- include/asm-blackfin/mach-bf548/ports.h | 20 +- include/asm-blackfin/mach-common/bits/ebiu.h | 4 +- include/asm-blackfin/mach-common/bits/pata.h | 220 +++++ include/asm-blackfin/mach-common/bits/sdh.h | 122 +++ include/asm-blackfin/mmc.h | 1 + include/asm-blackfin/posix_types.h | 20 +- include/common.h | 2 +- lib_blackfin/Makefile | 4 +- lib_blackfin/board.c | 92 +-- lib_blackfin/cache.c | 18 +- lib_blackfin/clocks.c | 77 ++ lib_blackfin/post.c | 4 - lib_blackfin/string.c | 38 +- lib_blackfin/tests.c | 3 - 34 files changed, 3545 insertions(+), 414 deletions(-) create mode 100644 drivers/block/pata_bfin.c create mode 100644 drivers/block/pata_bfin.h create mode 100644 drivers/mmc/bfin_sdh.c create mode 100644 drivers/mmc/bfin_sdh.h create mode 100644 drivers/mtd/nand/bfin_nand.c create mode 100644 drivers/spi/bfin_spi.c create mode 100644 include/asm-blackfin/mach-common/bits/pata.h create mode 100644 include/asm-blackfin/mach-common/bits/sdh.h create mode 100644 include/asm-blackfin/mmc.h create mode 100644 lib_blackfin/clocks.c
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Since the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own board_get_enetaddr() function.
--- drivers/net/bfin_mac.c | 24 +++++++++++++++++++++++- include/common.h | 2 +- lib_blackfin/board.c | 31 ++----------------------------- 3 files changed, 26 insertions(+), 31 deletions(-)
drivers/net/bfin_mac.c +23 -1
@@ -70,8 +70,9 @@ const ADI_DMA_CONFIG_REG txdmacfg = { .b_FLOW = 7 /* large desc flow */ }; -int bfin_EMAC_initialize (bd_t *bis) +int bfin_EMAC_initialize (bd_t *bd) { +const char *ethaddr;struct eth_device *dev; dev = (struct eth_device *)malloc (sizeof (*dev));if (dev ==NULL )
@@ -89,6 +90,27 @@ int bfin_EMAC_initialize(bd_t *bis)eth_register (dev); + ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR +if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); +sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , + bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], + bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], + bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); +setenv ("ethaddr" , nid); + } else +#endif + { +int i; +char *e; +for (i =0 ; i <6 ; ++i) { + bd->bi_enetaddr[i] =simple_strtoul (ethaddr, &e,16 ); + ethaddr = (*e) ? e +1 : e; + } + } +return 0 ; }
include/common.h +1 -1
@@ -354,7 +354,7 @@ void board_ether_init (void);#if defined(CONFIG_RPXCLASSIC ) || defined(CONFIG_MBX ) || \ defined(CONFIG_IAD210 ) || defined(CONFIG_XPEDITE1K ) || \ defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) || \ - defined(CONFIG_V38B ) + defined(CONFIG_V38B ) || defined(CONFIG_BFIN_MAC )void board_get_enetaddr (uchar *addr);#endif
lib_blackfin/board.c +2 -29
@@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -#ifdef CONFIG_CMD_NET -/* board MAC address */ - s =getenv ("ethaddr" ); -if (s ==NULL ) { -# ifndef CONFIG_ETHADDR -# if 0 -if (!board_get_enetaddr (bd->bi_enetaddr)) { -char nid[20 ]; -sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , - bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], - bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); -setenv ("ethaddr" , nid); - } -# endif -# endif - }else { -int i; -char *e; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); - s = (*e) ? e +1 : e; - } - } - -/* IP Address */ - bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -#endif -/* Initialize devices */ devices_init ();jumptable_init ();
@@ -433,6 +404,8 @@ void board_init_r(gd_t * id, ulong dest_addr)#endif #ifdef CONFIG_CMD_NET +/* IP Address */ + bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );printf ("Net: " );eth_initialize (gd->bd);if (getenv ("ethaddr" ))
Signature · 1 line
1.6.1.1
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Hi Mike,
Quoted 28 lines · Mike Frysinger
Since the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own
board_get_enetaddr()function.Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>--- drivers/net/bfin_mac.c | 24 +++++++++++++++++++++++- include/common.h | 2 +- lib_blackfin/board.c | 31 ++----------------------------- 3 files changed, 26 insertions(+), 31 deletions(-)drivers/net/bfin_mac.c +2
-1@@ -70,8 +70,9 @@ const ADI_DMA_CONFIG_REG txdmacfg = { .b_FLOW = 7 /* large desc flow */ }; -int bfin_EMAC_initialize (bd_t *bis) +int bfin_EMAC_initialize (bd_t *bd) { +const char *ethaddr;struct eth_device *dev; dev = (struct eth_device *)malloc (sizeof (*dev));if (dev ==NULL )
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 95
Quoted 6 lines
drivers/net/bfin_mac.c +2
-0@@ -89,6 +90,27 @@ int bfin_EMAC_initialize(bd_t *bis)eth_register (dev); + ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR
I know this was there before, but CONFIG_ETHADDR is kinda deprecated. We don't allow it in in-tree config files, so as far as I'm concerned we should pretend it doesn't exist. Boards should get their MAC address from an EEPROM or from the environment.
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 116
Quoted 5 lines
drivers/net/bfin_mac.c +4
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",
How about snprintf()
Quoted 73 lines
drivers/net/bfin_mac.c +15
-0+ bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], + bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], + bd->bi_enetaddr[4], bd->bi_enetaddr[5]); +setenv ("ethaddr" , nid); + } else +#endif + { +int i; +char *e; +for (i =0 ; i <6 ; ++i) { + bd->bi_enetaddr[i] =simple_strtoul (ethaddr, &e,16 ); + ethaddr = (*e) ? e +1 : e; + } + } +return 0 ;}
include/common.h +1
-1@@ -354,7 +354,7 @@ void board_ether_init (void);#if defined(CONFIG_RPXCLASSIC ) || defined(CONFIG_MBX ) || \ defined(CONFIG_IAD210 ) || defined(CONFIG_XPEDITE1K ) || \ defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) || \ - defined(CONFIG_V38B ) + defined(CONFIG_V38B ) || defined(CONFIG_BFIN_MAC )void board_get_enetaddr (uchar *addr);#endif lib_blackfin/board.c +0
-29@@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -#ifdef CONFIG_CMD_NET -/* board MAC address */ - s =getenv ("ethaddr" ); -if (s ==NULL ) { -# ifndef CONFIG_ETHADDR -# if 0 -if (!board_get_enetaddr (bd->bi_enetaddr)) { -char nid[20 ]; -sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , - bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], - bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); -setenv ("ethaddr" , nid); - } -# endif -# endif - }else { -int i; -char *e; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); - s = (*e) ? e +1 : e; - } - } - -/* IP Address */ - bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -#endif -/* Initialize devices */ devices_init ();jumptable_init ();
lib_blackfin/board.c void board_init_r(gd_t * id, ulong dest_addr) · line 411
Quoted 8 lines
lib_blackfin/board.c +2
-0@@ -433,6 +404,8 @@ void board_init_r(gd_t * id, ulong dest_addr)#endif #ifdef CONFIG_CMD_NET +/* IP Address */ + bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );printf ("Net: " );eth_initialize (gd->bd);if (getenv ("ethaddr" ))
regards,
Ben
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 6 lines · On Thursday 29 January 2009 00:43:31 Ben Warren wrote:
Quoted 5 lines · Mike Frysinger
drivers/net/bfin_mac.c +0
-0eth_register (dev);
Quoted 7 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 94
Quoted 2 lines
drivers/net/bfin_mac.c +2
-0+ ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR I know this was there before, but
CONFIG_ETHADDRis kinda deprecated. We don't allow it in in-tree config files, so as far as I'm concerned we should pretend it doesn't exist. Boards should get their MAC address from an EEPROM or from the environment.
that's news to me. i see no mention of deprecation in the README file (quite the opposite ... looks fully supported there), and i see a ton of board configs defining it:
$ grep 'CONFIG_ETH.*ADDR' include/configs/*.h | wc -l 257
so what's up ?
Quoted 6 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 98
Quoted 4 lines
drivers/net/bfin_mac.c +4
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",How about
snprintf()
when would the limit actually be violated ? bi_enetaddr is unsigned char which means it is impossible for it to be represented as more than two chars. so storage would always be exactly 2 * 6 + 5 + 1 (17 bytes). -mike
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 18 lines · Mike Frysinger
Quoted 7 lines · On Thursday 29 January 2009 00:43:31 Ben Warren wrote:
Quoted 5 lines · Mike Frysinger
drivers/net/bfin_mac.c +0
-0eth_register (dev);Quoted 8 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 94
Quoted 3 lines
drivers/net/bfin_mac.c +2
-0+ ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR I know this was there before, but
CONFIG_ETHADDRis kinda deprecated. We don't allow it in in-tree config files, so as far as I'm concerned we should pretend it doesn't exist. Boards should get their MAC address from an EEPROM or from the environment.
Quoted 9 lines
that's news to me. i see no mention of deprecation in the README file (quite the opposite ... looks fully supported there), and i see a ton of board configs defining it:
$ grep 'CONFIG_ETH.*ADDR' include/configs/*.h | wc -l 257so what's up ?
Hence the 'kinda'. It's one of those things that doesn't make sense (MAC addresses are supposed to be unique, so why would you hard code?) and for at least the past year we've been rejecting config files that use it.
Quoted 8 lines
Quoted 7 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 98
Quoted 5 lines
drivers/net/bfin_mac.c +4
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",How about
snprintf()
Quoted 4 lines
when would the limit actually be violated ?
bi_enetaddris unsigned char which means it is impossible for it to be represented as more than two chars. so storage would always be exactly 2 * 6 + 5 + 1 (17 bytes).
You're right, not a strong opinion on my part. I guess I've been beaten to submission by Coverity at work and so always use the 'n' functions.
Quoted 2 lines
-mike
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 22 lines · On Thursday 29 January 2009 01:01:41 Ben Warren wrote:
Quoted 21 lines · Mike Frysinger
Quoted 6 lines · On Thursday 29 January 2009 00:43:31 Ben Warren wrote:
Quoted 5 lines · Mike Frysinger
drivers/net/bfin_mac.c +0
-0eth_register (dev);Quoted 7 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 94
Quoted 2 lines
drivers/net/bfin_mac.c +2
-0+ ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR I know this was there before, but
CONFIG_ETHADDRis kinda deprecated. We don't allow it in in-tree config files, so as far as I'm concerned we should pretend it doesn't exist. Boards should get their MAC address from an EEPROM or from the environment.that's news to me. i see no mention of deprecation in the README file (quite the opposite ... looks fully supported there), and i see a ton of board configs defining it:
$ grep 'CONFIG_ETH.*ADDR' include/configs/*.h | wc -l 257
Quoted 6 lines
Quoted 1 line
so what's up ?
Hence the 'kinda'. It's one of those things that doesn't make sense (MAC addresses are supposed to be unique, so why would you hard code?) and for at least the past year we've been rejecting config files that use it.
if that's the case, shouldnt we at least mark the README as "these options are discouraged / deprecated" ?
i dont have a problem removing the ifndef here as it accomplishes two things:
- no board_get_enetaddr() reference
- slightly smaller code
it will break a Blackfin platform or two, but i can fix them up pretty easily.
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 98
Quoted 4 lines
drivers/net/bfin_mac.c +4
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",How about
snprintf()
Quoted 6 lines
Quoted 3 lines
when would the limit actually be violated ?
bi_enetaddris unsigned char which means it is impossible for it to be represented as more than two chars. so storage would always be exactly 2 * 6 + 5 + 1 (17 bytes).You're right, not a strong opinion on my part. I guess I've been beaten to submission by Coverity at work and so always use the 'n' functions.
i have no problem with proactive coding when it makes sense, but i hate some of the BSD-ish policies where they try and cram the "n" versions down your throat all the time.
-mike
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 35 lines · Mike Frysinger
Quoted 25 lines · On Thursday 29 January 2009 01:01:41 Ben Warren wrote:
Quoted 23 lines · Mike Frysinger
Quoted 7 lines · On Thursday 29 January 2009 00:43:31 Ben Warren wrote:
Quoted 5 lines · Mike Frysinger
drivers/net/bfin_mac.c +0
-0eth_register (dev);Quoted 8 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 94
Quoted 3 lines
drivers/net/bfin_mac.c +2
-0+ ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR I know this was there before, but
CONFIG_ETHADDRis kinda deprecated. We don't allow it in in-tree config files, so as far as I'm concerned we should pretend it doesn't exist. Boards should get their MAC address from an EEPROM or from the environment.that's news to me. i see no mention of deprecation in the README file (quite the opposite ... looks fully supported there), and i see a ton of board configs defining it:
$ grep 'CONFIG_ETH.*ADDR' include/configs/*.h | wc -l 257Quoted 7 lines
Quoted 2 lines
so what's up ?
Hence the 'kinda'. It's one of those things that doesn't make sense (MAC addresses are supposed to be unique, so why would you hard code?) and for at least the past year we've been rejecting config files that use it.
Quoted 10 lines
if that's the case, shouldnt we at least mark the README as "these options are discouraged / deprecated" ?
i dont have a problem removing the ifndef here as it accomplishes two things:
- noboard_get_enetaddr()reference
- slightly smaller codeit will break a Blackfin platform or two, but i can fix them up pretty easily.
I'll patch README to make this more official and clear
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 98
Quoted 5 lines
drivers/net/bfin_mac.c +4
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",How about
snprintf()when would the limit actually be violated ?
bi_enetaddris unsigned char which means it is impossible for it to be represented as more than two chars. so storage would always be exactly 2 * 6 + 5 + 1 (17 bytes).
Quoted 8 lines
Quoted 3 lines
You're right, not a strong opinion on my part. I guess I've been beaten to submission by Coverity at work and so always use the 'n' functions.
i have no problem with proactive coding when it makes sense, but i hate some of the BSD-ish policies where they try and cram the "n" versions down your throat all the time.
amen
Quoted 2 lines
-mike
regards,
Ben
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
if that's the case, shouldnt we at least mark the README as "these options are discouraged / deprecated" ?
Maybe discouraged and deprecated are not really optimal terms here, but what is?
Fact is, that ther eare very few legitimate uses of CONFIG_ETHADDR, but then these uses *are* legitimate (but then this is strictly board-specific code, definitely not in any global files).
We currently handle this through code reviews - if you useCONFIG_ETHADDR, we ask you why. In your case, it seems CONFIG_ETHADDR should not be used at all.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There is a multi-legged creature crawling on your shoulder. -- Spock, "A Taste of Armageddon", stardate 3193.9
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Ben WarrenSince the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own board_get_enetaddr() function.
---
v2
- drop CONFIG_ETHADDR handling
drivers/net/bfin_mac.c | 21 ++++++++++++++++++++- include/common.h | 2 +- lib_blackfin/board.c | 31 ++----------------------------- 3 files changed, 23 insertions(+), 31 deletions(-)
drivers/net/bfin_mac.c +20 -1
@@ -70,8 +70,9 @@ const ADI_DMA_CONFIG_REG txdmacfg = { .b_FLOW = 7 /* large desc flow */ }; -int bfin_EMAC_initialize (bd_t *bis) +int bfin_EMAC_initialize (bd_t *bd) { +const char *ethaddr;struct eth_device *dev; dev = (struct eth_device *)malloc (sizeof (*dev));if (dev ==NULL )
@@ -89,6 +90,24 @@ int bfin_EMAC_initialize(bd_t *bis)eth_register (dev); + ethaddr =getenv ("ethaddr" ); +if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); +sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , + bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], + bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], + bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); +setenv ("ethaddr" , nid); + }else { +int i; +char *e; +for (i =0 ; i <6 ; ++i) { + bd->bi_enetaddr[i] =simple_strtoul (ethaddr, &e,16 ); + ethaddr = (*e) ? e +1 : e; + } + } +return 0 ; }
include/common.h +1 -1
@@ -354,7 +354,7 @@ void board_ether_init (void);#if defined(CONFIG_RPXCLASSIC ) || defined(CONFIG_MBX ) || \ defined(CONFIG_IAD210 ) || defined(CONFIG_XPEDITE1K ) || \ defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) || \ - defined(CONFIG_V38B ) + defined(CONFIG_V38B ) || defined(CONFIG_BFIN_MAC )void board_get_enetaddr (uchar *addr);#endif
lib_blackfin/board.c +2 -29
@@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -#ifdef CONFIG_CMD_NET -/* board MAC address */ - s =getenv ("ethaddr" ); -if (s ==NULL ) { -# ifndef CONFIG_ETHADDR -# if 0 -if (!board_get_enetaddr (bd->bi_enetaddr)) { -char nid[20 ]; -sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , - bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], - bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); -setenv ("ethaddr" , nid); - } -# endif -# endif - }else { -int i; -char *e; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); - s = (*e) ? e +1 : e; - } - } - -/* IP Address */ - bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -#endif -/* Initialize devices */ devices_init ();jumptable_init ();
@@ -433,6 +404,8 @@ void board_init_r(gd_t * id, ulong dest_addr)#endif #ifdef CONFIG_CMD_NET +/* IP Address */ + bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );printf ("Net: " );eth_initialize (gd->bd);if (getenv ("ethaddr" ))
Signature · 1 line
1.6.1.1
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 7 lines · Mike Frysinger
Since the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own
board_get_enetaddr()function.Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
Quoted 104 lines
---
v2
- dropCONFIG_ETHADDRhandlingdrivers/net/bfin_mac.c | 21 ++++++++++++++++++++- include/common.h | 2 +- lib_blackfin/board.c | 31 ++----------------------------- 3 files changed, 23 insertions(+), 31 deletions(-)drivers/net/bfin_mac.c +20
-1@@ -70,8 +70,9 @@ const ADI_DMA_CONFIG_REG txdmacfg = { .b_FLOW = 7 /* large desc flow */ }; -int bfin_EMAC_initialize (bd_t *bis) +int bfin_EMAC_initialize (bd_t *bd) { +const char *ethaddr;struct eth_device *dev; dev = (struct eth_device *)malloc (sizeof (*dev));if (dev ==NULL )@@ -89,6 +90,24 @@ int bfin_EMAC_initialize(bd_t *bis)eth_register (dev); + ethaddr =getenv ("ethaddr" ); +if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); +sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , + bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], + bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], + bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); +setenv ("ethaddr" , nid); + }else { +int i; +char *e; +for (i =0 ; i <6 ; ++i) { + bd->bi_enetaddr[i] =simple_strtoul (ethaddr, &e,16 ); + ethaddr = (*e) ? e +1 : e; + } + } +return 0 ; }include/common.h +1
-1@@ -354,7 +354,7 @@ void board_ether_init (void);#if defined(CONFIG_RPXCLASSIC ) || defined(CONFIG_MBX ) || \ defined(CONFIG_IAD210 ) || defined(CONFIG_XPEDITE1K ) || \ defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) || \ - defined(CONFIG_V38B ) + defined(CONFIG_V38B ) || defined(CONFIG_BFIN_MAC )void board_get_enetaddr (uchar *addr);#endif lib_blackfin/board.c +0
-29@@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -#ifdef CONFIG_CMD_NET -/* board MAC address */ - s =getenv ("ethaddr" ); -if (s ==NULL ) { -# ifndef CONFIG_ETHADDR -# if 0 -if (!board_get_enetaddr (bd->bi_enetaddr)) { -char nid[20 ]; -sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , - bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], - bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); -setenv ("ethaddr" , nid); - } -# endif -# endif - }else { -int i; -char *e; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); - s = (*e) ? e +1 : e; - } - } - -/* IP Address */ - bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -#endif -/* Initialize devices */ devices_init ();jumptable_init ();
lib_blackfin/board.c void board_init_r(gd_t * id, ulong dest_addr) · line 411
Quoted 8 lines
lib_blackfin/board.c +2
-0@@ -433,6 +404,8 @@ void board_init_r(gd_t * id, ulong dest_addr)#endif #ifdef CONFIG_CMD_NET +/* IP Address */ + bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );printf ("Net: " );eth_initialize (gd->bd);if (getenv ("ethaddr" ))
thanks,
Ben
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
Since the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own
board_get_enetaddr()function.
I still think this belongs into board specific code, not into a generic driver.
The driver should be able to rely on environment settings - or bail out.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de O Staat! Wie tief dir alle Besten fluchen! Du bist kein Ziel. Der Mensch mu? weiter suchen. - Christian Morgenstern
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 7 lines · On Thursday 29 January 2009 05:45:23 Wolfgang Denk wrote:
Quoted 3 lines · In message <[email protected]> you wrote:
Since the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own
board_get_enetaddr()function.I still think this belongs into board specific code, not into a generic driver.
the driver isnt really generic. it's specific to the hardware that exists inside of Blackfin chips. the hardware has no support at all for storing the MAC in eeprom or any other place. thus it forces boards to declare some method for finding the MAC since there is literally no way for the hardware itself to do it.
what you propose wouldnt have been possible before, but with Ben's work it should be easy to move to board_eth_init().
as for generic code, i'd point out that lib_ppc/board.c is a much worse offender in this regard ...
-mike
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Dear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
the driver isnt really generic. it's specific to the hardware that exists inside of Blackfin chips. the hardware has no support at all for storing the
Well, the same applies for many other Ethernet drivers as well, be it the FEC ethernet driver for the MPC8xx, the FCC for the MPC82xx or the TSEC for the 8xxx, etc.
Quoted 2 lines
what you propose wouldnt have been possible before, but with Ben's work it should be easy to move to
board_eth_init().
So lat's do this, then, please.
Quoted 2 lines
as for generic code, i'd point out that
lib_ppc/board.cis a much worse offender in this regard ...
I take this as an indication that we can learn from errors made in the past, instead of repeating them.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"You know, after a woman's raised a family and so on, she wants to
start living her own life." "Whose life she's _been_ living, then?"
- Terry Pratchett, _Witches Abroad_PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 5 lines · On Thursday 29 January 2009 14:03:36 Wolfgang Denk wrote:
Quoted 3 lines · In message <[email protected]> you wrote:
the driver isnt really generic. it's specific to the hardware that exists inside of Blackfin chips. the hardware has no support at all for storing the
Quoted 8 lines
Well, the same applies for many other Ethernet drivers as well, be it the FEC ethernet driver for the MPC8xx, the FCC for the MPC82xx or the TSEC for the 8xxx, etc.
Quoted 2 lines
what you propose wouldnt have been possible before, but with Ben's work it should be easy to move to
board_eth_init().So lat's do this, then, please.
so how exactly are $ethaddr in the env and bi_enetaddr in the global data supposed to interact ? this is a mess in the current tree and i dont see any notes that indicate how things are supposed to be handled. and i'd like to make these changes once and get it right the first time ;).
i see it as:
- common net code calls board_eth_init()
- board_eth_init() sets up ethaddr in env if it isnt set already
- board_eth_init() calls the driver init (bfin_EMAC_initialize() in my case)
- driver init looks up ethaddr in env and sets bi_enetaddr in global data
- all other code uses bi_enetaddr to get the MAC address
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090129/4c0d330c/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Dear Mike Frysinger,
Quoted 5 lines · In message <[email protected]> you wrote:
so how exactly are $ethaddr in the env and
bi_enetaddrin the global data supposed to interact ? this is a mess in the current tree and i dont see any notes that indicate how things are supposed to be handled. and i'd like to make these changes once and get it right the first time ;).
Can't you just ask some simple and easy questions for a change? ;-)
Quoted 6 lines
i see it as:
- common net code callsboard_eth_init()
-board_eth_init()sets up ethaddr in env if it isnt set already
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in my case)
- driver init looks up ethaddr in env and setsbi_enetaddrin global data
- all other code usesbi_enetaddrto get the MAC address
This doesn't work, as in the case that you don;t use any network commands in U-Boot, board_eth_init() will not run and consequently you don't know the MAC address so you cannot pass it to Linux either.
Rather:
- misc_init_r() [or similar] sets up ethaddr in env if it isnt set already and sets bi_enetaddr in global data
- board_eth_init() calls the driver init (bfin_EMAC_initialize() in your case)
- driver init looks up ethaddr in env or bi_enetaddr
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It's a small world, but I wouldn't want to paint it.
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 19 lines · On Thursday 29 January 2009 15:41:31 Wolfgang Denk wrote:
Quoted 4 lines · In message <[email protected]> you wrote:
so how exactly are $ethaddr in the env and
bi_enetaddrin the global data supposed to interact ? this is a mess in the current tree and i dont see any notes that indicate how things are supposed to be handled. and i'd like to make these changes once and get it right the first time ;).Can't you just ask some simple and easy questions for a change? ;-)
Quoted 6 lines
i see it as:
- common net code callsboard_eth_init()
-board_eth_init()sets up ethaddr in env if it isnt set already
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in my
case) - driver init looks up ethaddr in env and setsbi_enetaddrin global data - all other code usesbi_enetaddrto get the MAC addressThis doesn't work, as in the case that you don;t use any network commands in U-Boot,
board_eth_init()will not run and consequently you don't know the MAC address so you cannot pass it to Linux either.
Quoted 7 lines
Rather:
-
misc_init_r()[or similar] sets up ethaddr in env if it isnt set already and setsbi_enetaddrin global data
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in your case)
- driver init looks up ethaddr in env orbi_enetaddr
well this gets us into the realm of what i was trying to avoid/fix in the first place: duplication of the env/ethaddr handling/parsing code. i get tired of auditing every board/driver just to find the same simple bugs were duplicated and/or not handled properly.
i guess i can mitigate this by making functions in include/asm-blackfin/net.h and having the boards/drivers call those.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090129/7a2b60ec/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Dear Mike Frysinger,
Quoted 11 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Rather:
-
misc_init_r()[or similar] sets up ethaddr in env if it isnt set already and setsbi_enetaddrin global data
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in your case)
- driver init looks up ethaddr in env orbi_enetaddrwell this gets us into the realm of what i was trying to avoid/fix in the first place: duplication of the env/ethaddr handling/parsing code. i get
What is wrong with using bi_enetaddr? What sort of "handling/parsing code" (in addition to a plain simple memcpy(...,6) is needed?
Quoted 2 lines
tired of auditing every board/driver just to find the same simple bugs were duplicated and/or not handled properly.
I lost you here.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Conquest is easy. Control is not. -- Kirk, "Mirror, Mirror", stardate unknown
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 9 lines · On Thursday 29 January 2009 16:17:09 Wolfgang Denk wrote:
Quoted 8 lines · In message <[email protected]> you wrote:
Quoted 7 lines
Rather:
-
misc_init_r()[or similar] sets up ethaddr in env if it isnt set already and setsbi_enetaddrin global data
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in your case)
- driver init looks up ethaddr in env orbi_enetaddr
Quoted 5 lines
Quoted 2 lines
well this gets us into the realm of what i was trying to avoid/fix in the first place: duplication of the env/ethaddr handling/parsing code. i get
What is wrong with using
bi_enetaddr? What sort of "handling/parsing code" (in addition to a plain simplememcpy(...,6)is needed?
converting the envvar to the raw 6 bytes and back again is duplicated all over the tree. and you suggest that both the board-specific misc_initr() and the driver init should handle this.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090129/e2e502b1/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Dear Mike Frysinger,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
-
misc_init_r()[or similar] sets up ethaddr in env if it isnt set already and setsbi_enetaddrin global data
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in your case)
- driver init looks up ethaddr in env orbi_enetaddr
...
Quoted 6 lines
Quoted 2 lines
What is wrong with using
bi_enetaddr? What sort of "handling/parsing code" (in addition to a plain simplememcpy(...,6)is needed?converting the envvar to the raw 6 bytes and back again is duplicated all over the tree. and you suggest that both the board-specific
misc_initr()and the driver init should handle this.
No, I don't. I suggest that it gets done once (for example in misc_initr()), and that you then use the binary data in bi_enetaddr.
Best regards,
Wolfgang Denk
Signature · 6 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
PoB = "Prisoner of Bill" -- those held captive, unwillingly or other-
wise, by the contemptible Microsoft monopoly.
-- Tom Christiansen in <[email protected]>PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 10 lines · On Thursday 29 January 2009 17:18:00 Wolfgang Denk wrote:
Quoted 9 lines · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
-
misc_init_r()[or similar] sets up ethaddr in env if it isnt set already and setsbi_enetaddrin global data
-board_eth_init()calls the driver init (bfin_EMAC_initialize()in your case)
- driver init looks up ethaddr in env orbi_enetaddrWhat is wrong with using
bi_enetaddr? What sort of "handling/parsing code" (in addition to a plain simplememcpy(...,6)is needed?
Quoted 6 lines
Quoted 3 lines
converting the envvar to the raw 6 bytes and back again is duplicated all over the tree. and you suggest that both the board-specific
misc_initr()and the driver init should handle this.No, I don't. I suggest that it gets done once (for example in
misc_initr()), and that you then use the binary data inbi_enetaddr.
you said:
- driver init looks up ethaddr in env or bi_enetaddr
at any rate, i'm fine with having the driver assume bi_enetaddr is sane. so the series of patches i just posted starts unifying the things i whined about earlier and does what you suggested.
unfortunately, with this small review i noticed another layer of confusion ;). every ethernet device is represented as struct eth_device, and that device has an enetaddr member. the board makes sure ethaddr is set in the environment during misc init. then when the network is actually used, the eth layer calls the board init which calls the driver init which registers a new eth_device. then the eth layer sets up dev->enetaddr based on the appropriate ethaddr env var. so imo, no eth driver should be touching the global data (and thus the bi_enetaddr's contained in there).
going back a step, i dont think the board itself should be touching the global bi_enetaddr. when the board sets the ethaddr env var, the common code in cmd_nvedit.c syncs the value to the global data.
if i were to document this mess, where would be the best place ? start a new doc/README.enetaddr as i dont see any document that covers the eth layer ? that way in the future we can all easily agree on how things should be done. -mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090129/84af7670/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 13 lines · On Thursday 29 January 2009 20:23:06 Mike Frysinger wrote:
at any rate, i'm fine with having the driver assume
bi_enetaddris sane. so the series of patches i just posted starts unifying the things i whined about earlier and does what you suggested.unfortunately, with this small review i noticed another layer of confusion ;). every ethernet device is represented as struct
eth_device, and that device has an enetaddr member. the board makes sure ethaddr is set in the environment during misc init. then when the network is actually used, the eth layer calls the board init which calls the driver init which registers a neweth_device. then the eth layer sets updev->enetaddrbased on the appropriate ethaddr env var. so imo, no eth driver should be touching the global data (and thus the bi_enetaddr's contained in there).
Quoted 8 lines
going back a step, i dont think the board itself should be touching the global
bi_enetaddr. when the board sets the ethaddr env var, the common code incmd_nvedit.csyncs the value to the global data.if i were to document this mess, where would be the best place ? start a new doc/README.enetaddr as i dont see any document that covers the eth layer ? that way in the future we can all easily agree on how things should be done.
how about this document at doc/README.enetaddr ... -mike
---------------------------------
Ethernet Address (MAC) Handling
---------------------------------
There are a variety of places in U-Boot where the MAC address is used, parse, and stored. This document covers proper usage of each location and the moving of data between them.
-----------
Locations
-----------
Here are the places where MAC addresses are stored:
- board-specific location (eeprom, dedicated flash, ...)
- environment ("ethaddr", "eth1addr", ...)
- global data (bi_enetaddr, bi_enet1addr, ...)
- ethernet data (struct eth_device -> enetaddr)
-------
Usage
-------
During board init (like the board-specific misc_init_r() function), boards should take care of locating the MAC address, initializing the environment, and seeding the global data.
During runtime, the ethernet layer will use the environment variables to sync the MAC addresses to the ethernet structures. All ethernet driver code should then only use the enetaddr member of the eth_device structure.
The common environment code will take care of passing environment changes to the global data and to the ethernet layer.
Any other common code that wishes to access the MAC address should then query the global data directly. No one should be looking in the environment for any addresses.
---------
Helpers
---------
To assist in the management of these layers, a few helper functions exist. You should use these rather than attempt to do any kind of parsing/manipulation yourself as many common errors have arisen in the past.
* void eth_parse_enetaddr(char *addr, uchar *enetaddr);
Convert a string representation of a MAC address to the binary version. char *addr = "00:11:22:33:44:55";
uchar enetaddr[6];eth_parse_enetaddr(addr, enetaddr);
/* enetaddr now equals { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 } */
* bool eth_getenv_enetaddr(char *name, uchar *enetaddr);
Look up an environment variable and convert the stored address. If the env var is not set, then the function returns false. Otherwise, the conversion occurs and returns true.
uchar enetaddr[6];
if (eth_getenv_enetaddr("ethaddr", enetaddr))
/* enetaddr is now set to the value stored in the ethaddr env var */ else /* "ethaddr" is not set in the environment */ * int eth_setenv_enetaddr(char *name, uchar *enetaddr);
Store the MAC address into the named environment variable. The return value is the same as the setenv() function.
uchar enetaddr[6] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; eth_setenv_enetaddr("ethaddr", enetaddr);
/* the "ethaddr" env var should now be set to "00:11:22:33:44:55" */
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090202/4b98a04d/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Dear Mike Frysinger,
Quoted 2 lines · In message <[email protected]> you wrote:
how about this document at doc/README.enetaddr ...
Thanks!
Quoted 5 lines
---------------------------------
Ethernet Address (MAC) Handling
---------------------------------There are a variety of places in U-Boot where the MAC address is used, parse,
parsed
Quoted 1 line
Here are the places where MAC addresses are stored:
...where MAC addresses may be stored.
Quoted 1 line
- board-specific location (eeprom, dedicated flash, ...)
Please add:
Note: only used when mandatory due to hardware ddesign etc.
Quoted 1 line
- environment ("ethaddr", "eth1addr", ...)
Please add:
Note: this is the preferred way to permanently store the MAC addresses in U-Boot.
Quoted 2 lines
- global data (
bi_enetaddr,bi_enet1addr, ...)
- ethernet data (structeth_device-> enetaddr)
Please add:
Note: these two are just temporary copies of the MAC address, which exist only after running the respective initialization code.
Quoted 7 lines
-------
Usage
-------During board init (like the board-specific
misc_init_r()function), boards should take care of locating the MAC address, initializing the environment, and seeding the global data.
Please change:
If the hardware design mandates that the MAC address is stored in some special place, like EEPROM etc., then the board specific init code (like the board-specific misc_init_r() function) is responsible for locating the MAC address(es) and initialize the respective environment variable(s) from it.
Note that this shall be done if, and only if, the environment does not already contain these environment variables, i. e. existing variable definitions must not be overwritten.
The envrionment handling code (function setevn()) will update the global data accordingly.
Quoted 3 lines
During runtime, the ethernet layer will use the environment variables to sync the MAC addresses to the ethernet structures. All ethernet driver code should then only use the enetaddr member of the
eth_devicestructure.
Please change:
During runtime, the ethernet layer will use the global data to sync ...
Quoted 2 lines
The common environment code will take care of passing environment changes to the global data and to the ethernet layer.
Maybe again refer to setenv(). Note that this updates only the global data. The ethernet layer shall init any internal structures it needs when it runs it's own init code, i. e. upon invocation of a network related command.
Quoted 3 lines
Any other common code that wishes to access the MAC address should then query the global data directly. No one should be looking in the environment for any addresses.
Any code that wishes to access the MAC address should then query the global data or the environment, depending on whatever (binary or string representation) seems more appropriate.
Quoted 1 line
* bool
eth_getenv_enetaddr(char *name, uchar *enetaddr);
Make this "int" - we don't use "bool" in U-Boot. This is C code.
Quoted 3 lines
Look up an environment variable and convert the stored address. If the env var is not set, then the function returns false. Otherwise, the conversion occurs and returns true.
s/false/-1/; s/true/0/;
Quoted 5 lines
uchar enetaddr[6];
if (eth_getenv_enetaddr("ethaddr", enetaddr))/* enetaddr is now set to the value stored in the ethaddr env var */ else /* "ethaddr" is not set in the environment */
if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
/* "ethaddr" is not set in the environment */
...
}
/* enetaddr is now set to the value stored in the ethaddr env var */Thanks again.
Best regards,
Wolfgang Denk
Signature · 7 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How many seconds are there in a year? If I tell you there are 3.155 x
10^7, you won't even try to remember it. On the other hand, who could
forget that, to within half a percent, pi seconds is a nanocentury.
-- Tom Duff, Bell LabsPATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 17 lines · On Monday 02 February 2009 16:04:34 Wolfgang Denk wrote:
Quoted 7 lines · In message Mike Frysinger you
-------
Usage
-------During board init (like the board-specific
misc_init_r()function), boards should take care of locating the MAC address, initializing the environment, and seeding the global data.Please change:
If the hardware design mandates that the MAC address is stored in some special place, like EEPROM etc., then the board specific init code (like the board-specific
misc_init_r()function) is responsible for locating the MAC address(es) and initialize the respective environment variable(s) from it.
Quoted 6 lines
Note that this shall be done if, and only if, the environment does not already contain these environment variables, i. e. existing variable definitions must not be overwritten.
The envrionment handling code (function
setevn()) will update the global data accordingly.
it will update the global data, but nowhere will it initially seed it. i'm thinking env_init() should be a unified entry point that first calls down to the specific env storage (eeprom/flash/nand/etc...) and then initializes the relevant bi_enetaddr members of the global data structure.
Quoted 9 lines
Quoted 4 lines
During runtime, the ethernet layer will use the environment variables to sync the MAC addresses to the ethernet structures. All ethernet driver code should then only use the enetaddr member of the
eth_devicestructure.Please change:
During runtime, the ethernet layer will use the global data to sync ...
documenting it this way wont change the code ;). the ethernet code does not use the global data in any way. look at eth_initialize() in net/eth.c. i imagine part of the reason for this is that working with multiple ethernet devices is pretty ugly atm. the static list of CONFIG_HAS_ETH{1,2,3,...} makes working with more than one device very messy. the ethernet code today though builds the string dynamically "eth%iaddr" and so can handle arbitrary number of devices without needing any changes.
this also applies to the cascading of setenv() into the global data. that code only handles bi_enetaddr and none of the bi_enetNaddr ... doing 'set eth1addr ..." will not update bi_enet1addr ...
Quoted 7 lines
Quoted 3 lines
Any other common code that wishes to access the MAC address should then query the global data directly. No one should be looking in the environment for any addresses.
Any code that wishes to access the MAC address should then query the global data or the environment, depending on whatever (binary or string representation) seems more appropriate.
relying on global data only means code can avoid having to handle unset variables. global data will always have something in there. the str_enetaddr() utility function makes this easy ...
Quoted 3 lines
Quoted 1 line
* bool
eth_getenv_enetaddr(char *name, uchar *enetaddr);Make this "int" - we don't use "bool" in U-Boot. This is C code.
bool is a C type ... not that i'll bitch enough to keep it :p
i've merged your other changes locally
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090202/d5a1667a/attachment-0001.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Dear Mike Frysinger,
Quoted 13 lines · In message <[email protected]> you wrote:
Quoted 13 lines
Please change:
If the hardware design mandates that the MAC address is stored in some special place, like EEPROM etc., then the board specific init code (like the board-specific
misc_init_r()function) is responsible for locating the MAC address(es) and initialize the respective environment variable(s) from it.Note that this shall be done if, and only if, the environment does not already contain these environment variables, i. e. existing variable definitions must not be overwritten.
Quoted 7 lines
Quoted 2 lines
The envrionment handling code (function
setevn()) will update the global data accordingly.it will update the global data, but nowhere will it initially seed it. i'm thinking
env_init()should be a unified entry point that first calls down to the specific env storage (eeprom/flash/nand/etc...) and then initializes the relevantbi_enetaddrmembers of the global data structure.
No, that would mix functions in a bad way as it creates new dependencies on what can or must be done when. env_init() in sone thing (initializes the environment data), but global data init is another issue.
Maybe we should try and collect the global data initialization into one place - but I have to admit that I don't know if or how easily this can be done.
Quoted 5 lines
Quoted 4 lines
Please change:
During runtime, the ethernet layer will use the global data to sync ...
Quoted 7 lines
documenting it this way wont change the code ;). the ethernet code does not use the global data in any way. look at
eth_initialize()innet/eth.c. i imagine part of the reason for this is that working with multiple ethernet devices is pretty ugly atm. the static list of CONFIG_HAS_ETH{1,2,3,...} makes working with more than one device very messy. the ethernet code today though builds the string dynamically "eth%iaddr" and so can handle arbitrary number of devices without needing any changes.
Well, I think we agree that the current state is a mess. Documenting the mess makes it easier to add to it. But should we not try to clean up instead? I.e. document what we think should be done, and fix the implementation accordingly?
Quoted 3 lines
this also applies to the cascading of
setenv()into the global data. that code only handlesbi_enetaddrand none of thebi_enetNaddr... doing 'set eth1addr ..." will not updatebi_enet1addr...
Agreed - that needs to be fixed, too.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Vulcans do not approve of violence. -- Spock, "Journey to Babel", stardate 3842.4
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 24 lines · On Tuesday 03 February 2009 03:16:27 Wolfgang Denk wrote:
Dear Mike Frysinger,
Quoted 12 lines · In message <[email protected]> you wrote:
Quoted 12 lines
Please change:
If the hardware design mandates that the MAC address is stored in some special place, like EEPROM etc., then the board specific init code (like the board-specific
misc_init_r()function) is responsible for locating the MAC address(es) and initialize the respective environment variable(s) from it.Note that this shall be done if, and only if, the environment does not already contain these environment variables, i. e. existing variable definitions must not be overwritten.
Quoted 8 lines
Quoted 2 lines
The envrionment handling code (function
setevn()) will update the global data accordingly.it will update the global data, but nowhere will it initially seed it. i'm thinking
env_init()should be a unified entry point that first calls down to the specific env storage (eeprom/flash/nand/etc...) and then initializes the relevantbi_enetaddrmembers of the global data structure.
Quoted 8 lines
No, that would mix functions in a bad way as it creates new dependencies on what can or must be done when.
env_init()in sone thing (initializes the environment data), but global data init is another issue.Maybe we should try and collect the global data initialization into one place - but I have to admit that I don't know if or how easily this can be done.
trying to do it in one go will probably be ugly and break crap, so i think starting with a few pieces and expanding from there is fine. in this case, we'll start with updating all the lib_*/board.c files to call global_init() and that will in turn start with setting up bi_enetaddr.
Quoted 14 lines
Quoted 5 lines
Quoted 4 lines
Please change:
During runtime, the ethernet layer will use the global data to sync ...Quoted 8 lines
documenting it this way wont change the code ;). the ethernet code does not use the global data in any way. look at
eth_initialize()innet/eth.c. i imagine part of the reason for this is that working with multiple ethernet devices is pretty ugly atm. the static list of CONFIG_HAS_ETH{1,2,3,...} makes working with more than one device very messy. the ethernet code today though builds the string dynamically "eth%iaddr" and so can handle arbitrary number of devices without needing any changes.
Quoted 4 lines
Well, I think we agree that the current state is a mess. Documenting the mess makes it easier to add to it. But should we not try to clean up instead? I.e. document what we think should be done, and fix the implementation accordingly?
yes, but having the documentation say one thing and the actual implementation do something completely different leads to confusion. people dont know whether the documentation is out of date, plain wrong, or what. to both ends, we can have the documentation read what *should* be happening and then add a note about what *actually* is happening and how it needs to be changed.
Quoted 5 lines
Quoted 3 lines
this also applies to the cascading of
setenv()into the global data. that code only handlesbi_enetaddrand none of thebi_enetNaddr... doing 'set eth1addr ..." will not updatebi_enet1addr...Agreed - that needs to be fixed, too.
so does it make sense for the env code to even be calling eth_set_enetaddr() ? after all, any network operation will call the eth init code which will take care of rereading the mac address from the env/global data.
also, are you saying that the current method of a static # of ethernet devices is the way to go ? we'll have to maintain a hardcoded list of places like:
#ifdef CONFIG_HAS_ETH1 ... work with bi_enet1addr ...
#endif
#ifdef CONFIG_HAS_ETH2
... do same thing but now with bi_enet2addr ...
#endif
#ifdef CONFIG_HAS_ETH3
... do same thing but now with bi_enet3addr ...
#endif
#ifdef CONFIG_HAS_ETH4
... do same thing but now with bi_enet4addr ...
#endif
i think we can agree that this does not scale at all. if, however, we change the global data to something like:
typedef struct bd_info {
...
#ifdef CONFIG_NET_MULTI
uchar bi_enetXaddr[CONFIG_NET_MULTI_MAX][6];
# define bi_enetaddr bi_enetXaddr[0]
#else
uchar bi_enetaddr[6];
#endif
...
};
then we should be able to scale nicely ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090203/da737fe8/attachment-0001.pgp PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 12 lines · On Tuesday 03 February 2009 14:40:00 Mike Frysinger wrote:
i think we can agree that this does not scale at all. if, however, we change the global data to something like:
typedef struct bd_info { ... #ifdef CONFIG_NET_MULTI uchar bi_enetXaddr[CONFIG_NET_MULTI_MAX][6]; # define bi_enetaddr bi_enetXaddr[0] #else uchar bi_enetaddr[6]; #endif ... };
Ben: does this sound reasonable ? if so, i can start a patch series moving in this direction ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090210/b27c2b9d/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 16 lines · Mike Frysinger
Quoted 13 lines · On Tuesday 03 February 2009 14:40:00 Mike Frysinger wrote:
i think we can agree that this does not scale at all. if, however, we change the global data to something like:
typedef struct bd_info { ... #ifdef CONFIG_NET_MULTI uchar bi_enetXaddr[CONFIG_NET_MULTI_MAX][6]; # define bi_enetaddr bi_enetXaddr[0] #else uchar bi_enetaddr[6]; #endif ... };
Quoted 4 lines
Ben: does this sound reasonable ? if so, i can start a patch series moving in this direction ...
-mike
Thanks for tackling this cluster$%@#. I'm not crazy about the CONFIG_NET_MULTI_MAX, but then I'm not really sure why the ethernet addresses exist in global data on boards with CONFIG_NET_MULTI. The net library doesn't use them, most (maybe all?) of the drivers don't look at it. Some common code does, but does it need to? Maybe it's needed to pass to some operating systems? This is an example of something that could use some serious refactoring, but I expect it's an onion with many, many layers. OTOH, if you're going to change the name of a variable in global data, you'll find out really fast where it's used. Maybe we can gut it completely? I'm lacking in historical perspective and my world view is pretty limited, so hopefully others (read WD) will chime in.
regards,
Ben
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 18 lines · On Wednesday 11 February 2009 00:45:05 Ben Warren wrote:
Quoted 14 lines · Mike Frysinger
Quoted 12 lines · On Tuesday 03 February 2009 14:40:00 Mike Frysinger wrote:
i think we can agree that this does not scale at all. if, however, we change the global data to something like:
typedef struct bd_info { ... #ifdef CONFIG_NET_MULTI uchar bi_enetXaddr[CONFIG_NET_MULTI_MAX][6]; # define bi_enetaddr bi_enetXaddr[0] #else uchar bi_enetaddr[6]; #endif ... };Quoted 2 lines
Ben: does this sound reasonable ? if so, i can start a patch series moving in this direction ...
Quoted 12 lines
Thanks for tackling this cluster$%@#. I'm not crazy about the
CONFIG_NET_MULTI_MAX, but then I'm not really sure why the ethernet addresses exist in global data on boards withCONFIG_NET_MULTI. The net library doesn't use them, most (maybe all?) of the drivers don't look at it. Some common code does, but does it need to? Maybe it's needed to pass to some operating systems? This is an example of something that could use some serious refactoring, but I expect it's an onion with many, many layers. OTOH, if you're going to change the name of a variable in global data, you'll find out really fast where it's used. Maybe we can gut it completely? I'm lacking in historical perspective and my world view is pretty limited, so hopefully others (read WD) will chime in.
i provided a backwards compat define so no code would break:
# define bi_enetaddr bi_enetXaddr[0]
but simply dropping all bi_enet*addr consumption in global data sounds like one way of tackling the situation. i see the structure as kind of a binary cache of the environment. but as a cache, it certainly shows today that it gets out of sync and many places use only one or the other. and with the utility functions i proposed, transitioning over to having the env be the only storage location wouldnt be too bad at all i dont think.
-mike
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Ben WarrenDear Ben Warren,
Quoted 4 lines · In message <[email protected]> you wrote:
Thanks for tackling this cluster$%@#. I'm not crazy about the
CONFIG_NET_MULTI_MAX, but then I'm not really sure why the ethernet addresses exist in global data on boards withCONFIG_NET_MULTI. The net
Good point.
Let's keep in mind that the global data sturcture is something which is supposed to hold data at a time before we have a writable data segment, i. e. the early boot phase before relocation to RAM.
In this case it makes no sense to hold MAC addresses in the global data, as any network activities can only be started after relocation to RAM.
Quoted 8 lines
it. Some common code does, but does it need to? Maybe it's needed to pass to some operating systems? This is an example of something that could use some serious refactoring, but I expect it's an onion with many, many layers. OTOH, if you're going to change the name of a variable in global data, you'll find out really fast where it's used. Maybe we can gut it completely? I'm lacking in historical perspective and my world view is pretty limited, so hopefully others (read WD) will chime in.
I think if we touch it at all, we should do it Right (TM), i. e. move this out of the global data.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Intuition, however illogical, is recognized as a command prerogative. -- Kirk, "Obsession", stardate 3620.7
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 9 lines · On Wednesday 11 February 2009 07:17:39 Wolfgang Denk wrote:
Dear Ben Warren,
Quoted 3 lines · In message <[email protected]> you wrote:
Thanks for tackling this cluster$%@#. I'm not crazy about the
CONFIG_NET_MULTI_MAX, but then I'm not really sure why the ethernet addresses exist in global data on boards withCONFIG_NET_MULTI. The netGood point.
Quoted 7 lines
Let's keep in mind that the global data sturcture is something which is supposed to hold data at a time before we have a writable data segment, i. e. the early boot phase before relocation to RAM.
In this case it makes no sense to hold MAC addresses in the global data, as any network activities can only be started after relocation to RAM.
sounds good. and the place where the board mac init happens will be in an _r func, so no problems there with the board seeding the env ...
Quoted 11 lines
Quoted 8 lines
it. Some common code does, but does it need to? Maybe it's needed to pass to some operating systems? This is an example of something that could use some serious refactoring, but I expect it's an onion with many, many layers. OTOH, if you're going to change the name of a variable in global data, you'll find out really fast where it's used. Maybe we can gut it completely? I'm lacking in historical perspective and my world view is pretty limited, so hopefully others (read WD) will chime in.
I think if we touch it at all, we should do it Right (TM), i. e. move this out of the global data.
ok, i'll start up a branch to do this conversion in my repo. i'm guessing Ben wont have a problem with someone doing the grunt work ;).
-mike
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 34 lines · Mike Frysinger
Quoted 10 lines · On Wednesday 11 February 2009 07:17:39 Wolfgang Denk wrote:
Dear Ben Warren,
Quoted 4 lines · In message <[email protected]> you wrote:
Thanks for tackling this cluster$%@#. I'm not crazy about the
CONFIG_NET_MULTI_MAX, but then I'm not really sure why the ethernet addresses exist in global data on boards withCONFIG_NET_MULTI. The netGood point.
Quoted 8 lines
Let's keep in mind that the global data sturcture is something which is supposed to hold data at a time before we have a writable data segment, i. e. the early boot phase before relocation to RAM.
In this case it makes no sense to hold MAC addresses in the global data, as any network activities can only be started after relocation to RAM.
sounds good. and the place where the board mac init happens will be in an _r func, so no problems there with the board seeding the env ...
Quoted 9 lines
Quoted 9 lines
it. Some common code does, but does it need to? Maybe it's needed to pass to some operating systems? This is an example of something that could use some serious refactoring, but I expect it's an onion with many, many layers. OTOH, if you're going to change the name of a variable in global data, you'll find out really fast where it's used. Maybe we can gut it completely? I'm lacking in historical perspective and my world view is pretty limited, so hopefully others (read WD) will chime in.
Quoted 8 lines
Quoted 3 lines
I think if we touch it at all, we should do it Right (TM), i. e. move this out of the global data.
ok, i'll start up a branch to do this conversion in my repo. i'm guessing Ben wont have a problem with someone doing the grunt work ;).
-mike
Uh, yeah. Not a problem. Thanks!
Ben
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 32 lines · On Wednesday 11 February 2009 15:15:22 Ben Warren wrote:
Quoted 31 lines · Mike Frysinger
Quoted 10 lines · On Wednesday 11 February 2009 07:17:39 Wolfgang Denk wrote:
Dear Ben Warren,
Quoted 4 lines · In message <[email protected]> you wrote:
Thanks for tackling this cluster$%@#. I'm not crazy about the
CONFIG_NET_MULTI_MAX, but then I'm not really sure why the ethernet addresses exist in global data on boards withCONFIG_NET_MULTI. The netGood point.
Quoted 7 lines
Let's keep in mind that the global data sturcture is something which is supposed to hold data at a time before we have a writable data segment, i. e. the early boot phase before relocation to RAM.
In this case it makes no sense to hold MAC addresses in the global data, as any network activities can only be started after relocation to RAM.
sounds good. and the place where the board mac init happens will be in an _r func, so no problems there with the board seeding the env ...
Quoted 9 lines
Quoted 8 lines
it. Some common code does, but does it need to? Maybe it's needed to pass to some operating systems? This is an example of something that could use some serious refactoring, but I expect it's an onion with many, many layers. OTOH, if you're going to change the name of a variable in global data, you'll find out really fast where it's used. Maybe we can gut it completely? I'm lacking in historical perspective and my world view is pretty limited, so hopefully others (read WD) will chime in.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I think if we touch it at all, we should do it Right (TM), i. e. move this out of the global data.
ok, i'll start up a branch to do this conversion in my repo. i'm guessing Ben wont have a problem with someone doing the grunt work ;). -mike
Uh, yeah. Not a problem. Thanks!
please checkout the macaddr branch of the blackfin repo ... there's about 60 changes cookin in there that touch every arch and common/boards/drivers. i'd like to get you to eye em over first before i spam the list ;).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090211/b69e1f38/attachment-0001.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Hi Mike,
<snip>
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
ok, i'll start up a branch to do this conversion in my repo. i'm guessing Ben wont have a problem with someone doing the grunt work ;). -mike
Quoted 9 lines
Quoted 1 line
Uh, yeah. Not a problem. Thanks!
please checkout the macaddr branch of the blackfin repo ... there's about 60
changes cookin in there that touch every arch and common/boards/drivers.
i'd
like to get you to eye em over first before i spam the list ;). -mike
In general this looks really good. I'm always a big fan of removing more than you add, and you've done that in spades. Of course I and others will nitpick individual bits, but let's get these into circulation. I imagine we'll pull this whole bunch into net/next fairly early so it can get some hang time.
thanks again,
Ben
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 11 lines · On Thursday 12 February 2009 01:24:03 Ben Warren wrote:
Quoted 10 lines
Quoted 5 lines
Quoted 3 lines
ok, i'll start up a branch to do this conversion in my repo. i'm guessing Ben wont have a problem with someone doing the grunt work ;).
Uh, yeah. Not a problem. Thanks!
please checkout the macaddr branch of the blackfin repo ... there's about 60 changes cookin in there that touch every arch and common/boards/drivers. i'd like to get you to eye em over first before i spam the list ;).
Quoted 5 lines
In general this looks really good. I'm always a big fan of removing more than you add, and you've done that in spades. Of course I and others will nitpick individual bits, but let's get these into circulation. I imagine we'll pull this whole bunch into net/next fairly early so it can get some hang time.
i was hoping we could get some of the obvious nitpicks out of the way first. otherwise i'll just go ahead and post things now.
in terms of testing, i did Blackfin, but i dont have any cross-compilers on this system let alone real hardware ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090212/1fe03168/attachment.pgp
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Mike FrysingerDear Mike,
Quoted 4 lines · In message <[email protected]> you wrote:
please checkout the macaddr branch of the blackfin repo ... there's about 60 changes cookin in there that touch every arch and common/boards/drivers. i'd like to get you to eye em over first before i spam the list ;).
Thanks.
net: new utility functions for working with enetaddr's:
Please ditch str_enetaddr() and rename str_enetaddr_r() into str_enetaddr(); using a static buffer for the return value is nothing I'd like to see in the code. It is trivial for the caller to allocate a buffer on the stack.
eth_parse_enetaddr() should be "int"" and allow for error checking (to catch at least simple format errors).
*: get mac address from environment
I think these N patches should be squashed into one, ot at least a much smaller number of patches.
*: do not initialize bi_enet*addr in global data
Ditto.
kup4k/kup4x: rename load_sernum_ethaddr() to kup_load_sernum_ethaddr()
tqm8xx: rename load_sernum_ethaddr() to tqc_load_sernum_ethaddr()
NAK for two reasons:
- I see no reason for such a change, and especially not for adding an empty function load_sernum_ethaddr(). [And you do not give any explanation why you're making such a change either.]
- You add the calls to the new kup_load_sernum_ethaddr() / tqc_load_sernum_ethaddr() functions right in the middle of a list of declarations. That's not acceptable.
ppc: do not initialize bi_enet*addr in global data:
...
Also stop calling load_sernum_ethaddr() since all boards now implement this as a stub.
Makes no sense to me. I don't even see what such a stub would be needed for or where it was called. Just looks like a waste of memory footprint to me. NAK.
drop now unused load_sernum_ethaddr() function:
Ah. You propbably want to change the order of your changes so you can avoid these intermediate steps. But still please do not rename load_sernum_ethaddr() - there is no need for more complex names.
Thanks for all the work!
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Only a fool fights in a burning house. -- Kank the Klingon, "Day of the Dove", stardate unknown
PATCH v2 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
Quoted 6 lines · On Thursday 12 February 2009 02:33:46 Wolfgang Denk wrote:
net: new utility functions for working with enetaddr's:
Please ditch
str_enetaddr()and renamestr_enetaddr_r()intostr_enetaddr(); using a static buffer for the return value is nothing I'd like to see in the code. It is trivial for the caller to allocate a buffer on the stack.
i'm lazy which is why i added that. but easy enough to convert things over.
Quoted 2 lines
eth_parse_enetaddr()should be "int"" and allow for error checking (to catch at least simple format errors).
there is no error checking in there now, just straight string -> number conversion. what kind of error checking would you like added ? i could tail off with a call to is_valid_ether_addr() which would reject addresses that are all 00's (technically valid, but the likely hood of anyone having that for real is nil) and any that have the multicast bit set (which i dont think will be a problem for any boards).
otherwise, i imagine we could add stuff to the simple_stroul() ? i'd be a little iffy here though as no place that i found in u-boot ever checked this and so far, no one has complained about it.
Quoted 8 lines
*: get mac address from environment
I think these N patches should be squashed into one, ot at least a much smaller number of patches.
*: do not initialize bi_enet*addr in global data
Ditto.
i did it by boards/cpu dirs so maintainers could review/ack/merge easier. but squashing is easy enough, and if you do the merge that'd address the collation issue.
Quoted 5 lines
kup4k/kup4x: rename
load_sernum_ethaddr()tokup_load_sernum_ethaddr()
tqm8xx: renameload_sernum_ethaddr()totqc_load_sernum_ethaddr()NAK for two reasons:
Quoted 7 lines
- I see no reason for such a change, and especially not for adding an empty function
load_sernum_ethaddr(). [And you do not give any explanation why you're making such a change either.]
- You add the calls to the newkup_load_sernum_ethaddr()/tqc_load_sernum_ethaddr()functions right in the middle of a list of declarations. That's not acceptable.
meh, i didnt really notice with the #ifdef mess
Quoted 10 lines
ppc: do not initialize bi_enet*addr in global data:
...
Also stop callingload_sernum_ethaddr()since all boards now implement this as a stub.Makes no sense to me. I don't even see what such a stub would be needed for or where it was called. Just looks like a waste of memory footprint to me. NAK.
Quoted 6 lines
drop now unused
load_sernum_ethaddr()function:Ah. You propbably want to change the order of your changes so you can avoid these intermediate steps. But still please do not rename
load_sernum_ethaddr()- there is no need for more complex names.
the point was so that things could be merged easily w/out requiring strict order, and so that bisection would not break. otherwise i have to combine the ppc change with the board changes. or break bisection. doesnt matter to me as these arent my boards ;).
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090212/6595cd58/attachment.pgp
PATCH 1/1 net: new utility functions eth_{parse, {get, set}env}_enetaddr()
In reply to Wolfgang DenkDeclare new utility functions for converting between the environment variables (eth*addr) and the binary MAC address representation. This way we can unify all the random places that already do this kind of thing.
--- include/net.h | 3 ++ net/eth.c | 76 +++++++++++++++++++++++++++++++++----------------------- 2 files changed, 48 insertions(+), 31 deletions(-)
include/net.h +3 -0
@@ -119,6 +119,9 @@ extern struct eth_device *eth_get_dev(void); /* get the current device MAC */extern struct eth_device *eth_get_dev_by_name (char *devname);/* get device */ extern int eth_get_dev_index (void );/* get the device index */ extern void eth_set_enetaddr (int num,char * a);/* Set new MAC address */ +extern void eth_parse_enetaddr (char *addr,uchar *enetaddr); +extern bool eth_getenv_enetaddr (char *name,uchar *enetaddr); +extern int eth_setenv_enetaddr (char *name,uchar *enetaddr);extern int eth_init (bd_t *bis);/* Initialize the device */ extern int eth_send (volatile void *packet,int length);/* Send a packet */
net/eth.c +45 -31
120 lines not on this page · raw message
Signature · 1 line
1.6.1.1
PATCH v3 1/27 Blackfin: bfin_mac: force boards to setup the MAC themselves
In reply to Wolfgang DenkSince the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this driver to setup the board data with a proper MAC.
---
v3
- do no work -- make the boards do it themselves
v2
- drop CONFIG_ETHADDR handling
lib_blackfin/board.c | 31 ++----------------------------- 1 files changed, 2 insertions(+), 29 deletions(-)
lib_blackfin/board.c +2 -29
@@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -#ifdef CONFIG_CMD_NET -/* board MAC address */ - s =getenv ("ethaddr" ); -if (s ==NULL ) { -# ifndef CONFIG_ETHADDR -# if 0 -if (!board_get_enetaddr (bd->bi_enetaddr)) { -char nid[20 ]; -sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , - bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], - bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); -setenv ("ethaddr" , nid); - } -# endif -# endif - }else { -int i; -char *e; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); - s = (*e) ? e +1 : e; - } - } - -/* IP Address */ - bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -#endif -/* Initialize devices */ devices_init ();jumptable_init ();
@@ -433,6 +404,8 @@ void board_init_r(gd_t * id, ulong dest_addr)#endif #ifdef CONFIG_CMD_NET +/* IP Address */ + bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );printf ("Net: " );eth_initialize (gd->bd);if (getenv ("ethaddr" ))
Signature · 1 line
1.6.1.1
PATCH 1/1 Blackfin: bf537-stamp: rewrite MAC-in-flash handling
In reply to Wolfgang DenkUse the common net eth functions to setup the env/global data with the MAC address, and properly handle the case where CONFIG_SYS_NO_FLASH is defined.
--- board/bf537-stamp/bf537-stamp.c | 79 +++++++++++++++++++++++++++----------- include/asm-blackfin/net.h | 28 ++++++++++++++ 2 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 include/asm-blackfin/net.h
board/bf537-stamp/bf537-stamp.c +56 -23
@@ -1,7 +1,7 @@/* -* U-boot - BF537.c +* U-boot - main board file * -* Copyright (c) 2005-2007 Analog Devices Inc. +* Copyright (c) 2005-2008 Analog Devices Inc. * * (C) Copyright 2000-2004 * Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -29,7 +29,7 @@#include <config.h> #include <command.h> #include <asm/blackfin.h> -#include <asm/io.h> +#include <asm/net.h> #include <net.h> #include <asm/mach-common/bits/bootrom.h> #include <netdev.h>
@@ -105,22 +105,63 @@ phys_size_t initdram(int board_type)return gd->bd->bi_memsize; } +void board_reset (void ) +{ +/* workaround for weak pull ups on ssel */ +if (CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_SPI_MASTER ) { +bfin_write_PORTF_FER (bfin_read_PORTF_FER () & ~PF10 ); +bfin_write_PORTFIO_SET (PF10 ); +udelay (1 ); + } +} + +#ifdef CONFIG_BFIN_MAC +static void board_init_enetaddr (uchar *mac_addr) +{ +#ifdef CONFIG_SYS_NO_FLASH +# define USE_MAC_IN_FLASH 0 +#else +# define USE_MAC_IN_FLASH 1 +#endif +bool valid_mac = false; + +if (USE_MAC_IN_FLASH ) { +/* we cram the MAC in the last flash sector */ +uchar *board_mac_addr = (uchar *)0x203F0000 ; +if (is_valid_ether_addr (board_mac_addr)) { +memcpy (mac_addr, board_mac_addr,6 ); + valid_mac = true; + } + } + +if (!valid_mac) { +puts ("Warning: Generating 'random' MAC address\n" ); +bfin_gen_rand_mac (mac_addr); + } + +eth_setenv_enetaddr ("ethaddr" , mac_addr); +} + +int board_eth_init (bd_t *bis) +{ +return bfin_EMAC_initialize (bis); +} +#endif +#if defined(CONFIG_MISC_INIT_R )/* miscellaneous platform dependent initialisations */ int misc_init_r (void ) { -#if defined(CONFIG_CMD_NET ) -char nid[32 ]; -unsigned char *pMACaddr = (unsigned char *)0x203F0000 ; - -/* The 0xFF check here is to make sure we don't use the address -* in flash if it's simply been erased (aka all 0xFF values) */ -if (getenv ("ethaddr" ) ==NULL &&is_valid_ether_addr (pMACaddr)) { -sprintf (nid,"%02x:%02x:%02x:%02x:%02x:%02x" , - pMACaddr[0 ], pMACaddr[1 ], - pMACaddr[2 ], pMACaddr[3 ], pMACaddr[4 ], pMACaddr[5 ]); -setenv ("ethaddr" , nid); - } +#ifndef CONFIG_SYS_NO_FLASH +/* we use the last sector for the MAC address / POST LDR */ +extern flash_info_t flash_info[]; +flash_protect (FLAG_PROTECT_SET ,0x203F0000 ,0x203FFFFF , &flash_info[0 ]); +#endif + +#ifdef CONFIG_BFIN_MAC +uchar *enetaddr = bis->bi_enetaddr; +if (!eth_getenv_enetaddr ("ethaddr" , enetaddr)) +board_init_enetaddr (enetaddr);#endif #if defined(CONFIG_BFIN_IDE )
@@ -143,14 +184,6 @@ int misc_init_r(void) }#endif /* CONFIG_MISC_INIT_R */ -#if defined(CONFIG_BFIN_MAC ) - -int board_eth_init (bd_t *bis) -{ -return bfin_EMAC_initialize (bis); -} -#endif -#ifdef CONFIG_POST /* Using sw10-PF5 as the hotkey */ int post_hotkeys_pressed (void )
include/asm-blackfin/net.h new file +28 -0
@@ -0,0 +1,28 @@ +/* +* net.h - misc Blackfin network helpers +* +* Copyright (c) 2008-2009 Analog Devices Inc. +* +* Licensed under the GPL-2 or later. +*/ + +#ifndef __ASM_BFIN_RAND_MAC__ +#define __ASM_BFIN_RAND_MAC__ + +/* If the board does not have a real MAC assigned to it, then generate a +* locally administrated pseudo-random one based on CYCLES and compile date. +*/ +static inline void bfin_gen_rand_mac (uchar *mac_addr) +{ +/* make something up */ +const char s[] = __DATE__; +size_t i; +u32 cycles; +for (i =0 ; i <6 ; ++i) { + asm("%0 = CYCLES;" :"=r" (cycles)); + mac_addr[i] = cycles ^ s[i]; + } + mac_addr[0 ] = (mac_addr[0 ] |0x02 ) & ~0x01 ;/* make it local unicast */ +} + +#endif
Signature · 1 line
1.6.1.1
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Ben WarrenQuoted 7 lines · Ben Warren
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 98
Quoted 5 lines · Mike Frysinger
drivers/net/bfin_mac.c +4
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); + sprintf(nid, "%02X:%02X:%02X:%02X:%02X:%02X",How about
snprintf()
Doesn't exist in u-boot, unfortunately.
-Scott
PATCH 1/27 Blackfin: bfin_mac: force board_get_enetaddr() usage
In reply to Mike FrysingerDear Mike Frysinger,
Quoted 3 lines · In message <[email protected]> you wrote:
Since the on-chip MAC does not have an eeprom or similar interface, force all Blackfin boards that use this to define their own
board_get_enetaddr()function.
This patch makes littel sense to me.
Quoted 10 lines
drivers/net/bfin_mac.c +3
-0+const char *ethaddr;struct eth_device *dev; dev = (struct eth_device *)malloc (sizeof (*dev));if (dev ==NULL )@@ -89,6 +90,27 @@ int bfin_EMAC_initialize(bd_t *bis)eth_register (dev); + ethaddr =getenv ("ethaddr" ); +#ifndef CONFIG_ETHADDR
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 104
Quoted 10 lines
drivers/net/bfin_mac.c +10
-0+if (ethaddr ==NULL ) { +char nid[20 ]; +board_get_enetaddr (bd->bi_enetaddr); +sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , + bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], + bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], + bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); +setenv ("ethaddr" , nid); + } else +#endif
Why don't you simply do the setenv("ethaddr",...) in some board init code, like other boards do?
drivers/net/bfin_mac.c int bfin_EMAC_initialize(bd_t *bis) · line 112
Quoted 8 lines
drivers/net/bfin_mac.c +8
-0+ { +int i; +char *e; +for (i =0 ; i <6 ; ++i) { + bd->bi_enetaddr[i] =simple_strtoul (ethaddr, &e,16 ); + ethaddr = (*e) ? e +1 : e; + } + }
Please no nested blocks without real need.
include/common.h void board_ether_init (void); · line 357
Quoted 10 lines
include/common.h +1
-1@@ -354,7 +354,7 @@ void board_ether_init (void);#if defined(CONFIG_RPXCLASSIC ) || defined(CONFIG_MBX ) || \ defined(CONFIG_IAD210 ) || defined(CONFIG_XPEDITE1K ) || \ defined(CONFIG_METROBOX ) || defined(CONFIG_KAREF ) || \ - defined(CONFIG_V38B ) + defined(CONFIG_V38B ) || defined(CONFIG_BFIN_MAC )
Please keep lists sorted.
Quoted 24 lines
lib_blackfin/board.c +0
-18@@ -378,35 +378,6 @@ void board_init_r(gd_t * id, ulong dest_addr)/* relocate environment function pointers etc. */ env_relocate (); -#ifdef CONFIG_CMD_NET -/* board MAC address */ - s =getenv ("ethaddr" ); -if (s ==NULL ) { -# ifndef CONFIG_ETHADDR -# if 0 -if (!board_get_enetaddr (bd->bi_enetaddr)) { -char nid[20 ]; -sprintf (nid,"%02X:%02X:%02X:%02X:%02X:%02X" , - bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], - bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], - bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); -setenv ("ethaddr" , nid); - } -# endif -# endif - }else { -int i;
lib_blackfin/board.c void board_init_r(gd_t * id, ulong dest_addr) · line 408
Quoted 10 lines
lib_blackfin/board.c +0
-10-char *e; -for (i =0 ; i <6 ; ++i) { - bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); - s = (*e) ? e +1 : e; - } - } - -/* IP Address */ - bd->bi_ip_addr =getenv_IPaddr ("ipaddr" ); -#endif
To me this seems to be a better place for the code (which needs fixing, of course).
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I really hate this damned machine It never does quite what I want I wish that they would sell it. But only what I tell it.
PATCH 2/27 Blackfin: bfin_mac: set MDCDIV based on SCLK
In reply to Mike FrysingerRather than hardcoding MDCDIV to 24 (which is correct for ~125mhz SCLK), use the real algorithm so it gets set correctly regardless of SCLK.
--- drivers/net/bfin_mac.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/bfin_mac.c +5 -5
@@ -345,9 +345,12 @@ static void SoftResetPHY(void) }#endif +/* MDC = SCLK / MDC_freq / 2 - 1 */ +#define MDC_FREQ_TO_DIV (mdc_freq) (get_sclk() / (mdc_freq) / 2 - 1) +static int SetupSystemRegs (int *opmode) { -u16 sysctl, phydat; +u16 phydat;int count =0 ;/* Enable PHY output */ *pVR_CTL |=CLKBUFOE ;
@@ -390,12 +393,9 @@ static int SetupSystemRegs(int *opmode)# endif #endif -/* MDC = 2.5 MHz */ - sysctl =SET_MDCDIV (24 );/* Odd word alignment for Receive Frame DMA word */ /* Configure checksum support and rcve frame word alignment */ - sysctl |=RXDWA |RXCKS ; - *pEMAC_SYSCTL = sysctl; + *pEMAC_SYSCTL =RXDWA |RXCKS |SET_MDCDIV (MDC_FREQ_TO_DIV (2500000 ));/* auto negotiation on */ /* full duplex */ /* 100 Mbps */
Signature · 1 line
1.6.1.1
PATCH 2/27 Blackfin: bfin_mac: set MDCDIV based on SCLK
Quoted 6 lines · Mike Frysinger
Rather than hardcoding MDCDIV to 24 (which is correct for ~125mhz SCLK), use the real algorithm so it gets set correctly regardless of SCLK.
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
Quoted 37 lines
--- drivers/net/bfin_mac.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)drivers/net/bfin_mac.c +5
-5@@ -345,9 +345,12 @@ static void SoftResetPHY(void) }#endif +/* MDC = SCLK / MDC_freq / 2 - 1 */ +#define MDC_FREQ_TO_DIV (mdc_freq) (get_sclk() / (mdc_freq) / 2 - 1) +static int SetupSystemRegs (int *opmode) { -u16 sysctl, phydat; +u16 phydat;int count =0 ;/* Enable PHY output */ *pVR_CTL |=CLKBUFOE ;@@ -390,12 +393,9 @@ static int SetupSystemRegs(int *opmode)# endif #endif -/* MDC = 2.5 MHz */ - sysctl =SET_MDCDIV (24 );/* Odd word alignment for Receive Frame DMA word */ /* Configure checksum support and rcve frame word alignment */ - sysctl |=RXDWA |RXCKS ; - *pEMAC_SYSCTL = sysctl; + *pEMAC_SYSCTL =RXDWA |RXCKS |SET_MDCDIV (MDC_FREQ_TO_DIV (2500000 ));/* auto negotiation on */ /* full duplex */ /* 100 Mbps */
PATCH 3/27 Blackfin: bfin_mac: cleanup MII/PHY functions
In reply to Mike FrysingerCleanup and rewrite the MII/PHY related functions so that we can reuse the existing common linux/miiphy.h code and hook into the mii command.
--- drivers/net/bfin_mac.c | 284 +++++++++++++++++++++++------------------------- drivers/net/bfin_mac.h | 25 ---- 2 files changed, 134 insertions(+), 175 deletions(-)
drivers/net/bfin_mac.c +134 -150
@@ -12,6 +12,8 @@#include <netdev.h> #include <command.h> #include <malloc.h> +#include <miiphy.h> +#include <linux/mii.h> #include <asm/blackfin.h> #include <asm/mach-common/bits/dma.h>
@@ -43,8 +45,6 @@ ADI_ETHER_BUFFER *rxbuf[PKTBUFSRX];static u16 txIdx;/* index of the current RX buffer */ static u16 rxIdx;/* index of the current TX buffer */ -u16 PHYregs[NO_PHY_REGS ];/* u16 PHYADDR; */ -/* DMAx_CONFIG values at DMA Restart */ const ADI_DMA_CONFIG_REG rxdmacfg = { .b_DMA_EN =1 ,/* enabled */
@@ -70,11 +70,39 @@ const ADI_DMA_CONFIG_REG txdmacfg = { .b_FLOW = 7 /* large desc flow */ }; +static int bfin_miiphy_wait (void ) +{ +/* poll the STABUSY bit */ +while (bfin_read_EMAC_STAADD () &STABUSY ) +continue ; +return 0 ; +} + +static int bfin_miiphy_read (char *devname,uchar addr,uchar reg,ushort *val) +{ +if (bfin_miiphy_wait ()) +return 1 ; +bfin_write_EMAC_STAADD (SET_PHYAD (addr) |SET_REGAD (reg) |STABUSY ); +if (bfin_miiphy_wait ()) +return 1 ; + *val =bfin_read_EMAC_STADAT (); +return 0 ; +} + +static int bfin_miiphy_write (char *devname,uchar addr,uchar reg,ushort val) +{ +if (bfin_miiphy_wait ()) +return 1 ; +bfin_write_EMAC_STADAT (val); +bfin_write_EMAC_STAADD (SET_PHYAD (addr) |SET_REGAD (reg) |STAOP |STABUSY ); +return 0 ; +} +int bfin_EMAC_initialize (bd_t *bd) {const char *ethaddr;struct eth_device *dev; - dev = (struct eth_device *)malloc (sizeof (*dev)); + dev =malloc (sizeof (*dev));if (dev ==NULL )hang ();
@@ -90,6 +118,10 @@ int bfin_EMAC_initialize(bd_t *bd)eth_register (dev); +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) +miiphy_register (dev->name, bfin_miiphy_read, bfin_miiphy_write); +#endif + ethaddr =getenv ("ethaddr" );#ifndef CONFIG_ETHADDR if (ethaddr ==NULL ) {
@@ -204,6 +236,100 @@ static int bfin_EMAC_recv(struct eth_device *dev)* *************************************************************/ +/* MDC = SCLK / MDC_freq / 2 - 1 */ +#define MDC_FREQ_TO_DIV (mdc_freq) (get_sclk() / (mdc_freq) / 2 - 1) + +static int bfin_miiphy_init (struct eth_device *dev,int *opmode) +{ +u16 phydat; +size_t count; + +/* Enable PHY output */ + *pVR_CTL |=CLKBUFOE ; + +/* Set all the pins to peripheral mode */ +#ifdef CONFIG_BFIN_MAC_RMII +/* grab RMII pins */ +# if defined(__ADSPBF51x__) + *pPORTF_MUX = (*pPORTF_MUX & \ + ~(PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \ + PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1; + *pPORTF_FER |=PF8 |PF9 |PF10 |PF11 |PF12 |PF13 |PF14 |PF15 ; + *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1; + *pPORTG_FER |=PG0 |PG1 |PG2 ; +# elif defined(__ADSPBF52x__) + *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2; + *pPORTG_FER |=PG14 |PG15 ; + *pPORTH_MUX = (*pPORTH_MUX & ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK)) | \ + PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2; + *pPORTH_FER |=PH0 |PH1 |PH2 |PH3 |PH4 |PH5 |PH6 |PH7 |PH8 ; +# else + *pPORTH_FER |=PH0 |PH1 |PH4 |PH5 |PH6 |PH8 |PH9 |PH14 |PH15 ; +# endif +#else +/* grab MII & RMII pins */ +# if defined(__ADSPBF51x__) + *pPORTF_MUX = (*pPORTF_MUX & \ + ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK | PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \ + PORT_x_MUX_0_FUNC_1 | PORT_x_MUX_1_FUNC_1 | PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1; + *pPORTF_FER |=PF0 |PF1 |PF2 |PF3 |PF4 |PF5 |PF6 |PF8 |PF9 |PF10 |PF11 |PF12 |PF13 |PF14 |PF15 ; + *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1; + *pPORTG_FER |=PG0 |PG1 |PG2 ; +# elif defined(__ADSPBF52x__) + *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2; + *pPORTG_FER |=PG14 |PG15 ; + *pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2 | PORT_x_MUX_2_FUNC_2; + *pPORTH_FER =-1 ;/* all pins */ +# else + *pPORTH_FER =-1 ;/* all pins */ +# endif +#endif + +/* Odd word alignment for Receive Frame DMA word */ +/* Configure checksum support and rcve frame word alignment */ +bfin_write_EMAC_SYSCTL (RXDWA |RXCKS |SET_MDCDIV (MDC_FREQ_TO_DIV (2500000 ))); + +/* turn on auto-negotiation and wait for link to come up */ +bfin_miiphy_write (dev->name,PHYADDR ,MII_BMCR ,BMCR_ANENABLE ); + count =0 ; +while (1 ) { + ++count; +if (bfin_miiphy_read (dev->name,PHYADDR ,MII_BMSR , &phydat)) +return -1 ; +if (phydat &BMSR_LSTATUS ) +break ; +if (count >30000 ) { +printf ("%s: link down, check cable\n" , dev->name); +return -1 ; + } +udelay (100 ); + } + +/* see what kind of link we have */ +if (bfin_miiphy_read (dev->name,PHYADDR ,MII_LPA , &phydat)) +return -1 ; +if (phydat &LPA_DUPLEX ) + *opmode =FDMODE ; +else + *opmode =0 ; + +bfin_write_EMAC_MMC_CTL (RSTC |CROLL ); + +/* Initialize the TX DMA channel registers */ + *pDMA2_X_COUNT =0 ; + *pDMA2_X_MODIFY =4 ; + *pDMA2_Y_COUNT =0 ; + *pDMA2_Y_MODIFY =0 ; + +/* Initialize the RX DMA channel registers */ + *pDMA1_X_COUNT =0 ; + *pDMA1_X_MODIFY =4 ; + *pDMA1_Y_COUNT =0 ; + *pDMA1_Y_MODIFY =0 ; + +return 0 ; +} +static int bfin_EMAC_init (struct eth_device *dev,bd_t *bd) {u32 opmode;
@@ -214,14 +340,14 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd) txIdx =0 ; rxIdx =0 ; -/* Initialize System Register */ -if (SetupSystemRegs (&dat) <0 ) +/* Initialize System Register */ +if (bfin_miiphy_init (dev, &dat) <0 )return -1 ; -/* Initialize EMAC address */ +/* Initialize EMAC address */ bfin_EMAC_setup_addr (bd); -/* Initialize TX and RX buffer */ +/* Initialize TX and RX buffer */ for (i =0 ; i <PKTBUFSRX ; i++) { rxbuf[i] =SetupRxBuffer (i);if (i >0 ) {
@@ -248,7 +374,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd) *pDMA1_CONFIG = *((u16 *) (void *)&rxbuf[0 ]->Dma[0 ].CONFIG);/* Wait MII done */ -PollMdcDone (); +bfin_miiphy_wait ();/* We enable only RX here */ /* ASTP : Enable Automatic Pad Stripping
@@ -293,148 +419,6 @@ void bfin_EMAC_setup_addr(bd_t *bd) bd->bi_enetaddr[5 ] <<8 ; } -static void PollMdcDone (void ) -{ -/* poll the STABUSY bit */ -while (*pEMAC_STAADD &STABUSY ) ; -} - -static void WrPHYReg (u16 PHYAddr,u16 RegAddr,u16 Data) -{ -PollMdcDone (); - - *pEMAC_STADAT = Data; - - *pEMAC_STAADD =SET_PHYAD (PHYAddr) |SET_REGAD (RegAddr) | -STAOP |STAIE |STABUSY ; -} - -/********************************************************************************* -* Read an off-chip register in a PHY through the MDC/MDIO port * -*********************************************************************************/ -static u16 RdPHYReg (u16 PHYAddr,u16 RegAddr) -{ -u16 Data; - -PollMdcDone (); - - *pEMAC_STAADD =SET_PHYAD (PHYAddr) |SET_REGAD (RegAddr) | -STAIE |STABUSY ; - -PollMdcDone (); - - Data = (u16) * pEMAC_STADAT; - - PHYregs[RegAddr] = Data;/* save shadow copy */ - -return Data; -} - -#if 0 /* dead code ? */ -static void SoftResetPHY (void ) -{ -u16 phydat; -/* set the reset bit */ -WrPHYReg (PHYADDR ,PHY_MODECTL ,PHY_RESET ); -/* and clear it again */ -WrPHYReg (PHYADDR ,PHY_MODECTL ,0x0000 ); -do { -/* poll until reset is complete */ - phydat =RdPHYReg (PHYADDR ,PHY_MODECTL ); - }while ((phydat &PHY_RESET ) !=0 ); -} -#endif - -/* MDC = SCLK / MDC_freq / 2 - 1 */ -#define MDC_FREQ_TO_DIV (mdc_freq) (get_sclk() / (mdc_freq) / 2 - 1) - -static int SetupSystemRegs (int *opmode) -{ -u16 phydat; -int count =0 ; -/* Enable PHY output */ - *pVR_CTL |=CLKBUFOE ; -/* Set all the pins to peripheral mode */ - -#ifdef CONFIG_BFIN_MAC_RMII -/* grab RMII pins */ -# if defined(__ADSPBF51x__) - *pPORTF_MUX = (*pPORTF_MUX & \ - ~(PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \ - PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1; - *pPORTF_FER |=PF8 |PF9 |PF10 |PF11 |PF12 |PF13 |PF14 |PF15 ; - *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1; - *pPORTG_FER |=PG0 |PG1 |PG2 ; -# elif defined(__ADSPBF52x__) - *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2; - *pPORTG_FER |=PG14 |PG15 ; - *pPORTH_MUX = (*pPORTH_MUX & ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK)) | \ - PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2; - *pPORTH_FER |=PH0 |PH1 |PH2 |PH3 |PH4 |PH5 |PH6 |PH7 |PH8 ; -# else - *pPORTH_FER |=PH0 |PH1 |PH4 |PH5 |PH6 |PH8 |PH9 |PH14 |PH15 ; -# endif -#else -/* grab MII & RMII pins */ -# if defined(__ADSPBF51x__) - *pPORTF_MUX = (*pPORTF_MUX & \ - ~(PORT_x_MUX_0_MASK | PORT_x_MUX_1_MASK | PORT_x_MUX_3_MASK | PORT_x_MUX_4_MASK | PORT_x_MUX_5_MASK)) | \ - PORT_x_MUX_0_FUNC_1 | PORT_x_MUX_1_FUNC_1 | PORT_x_MUX_3_FUNC_1 | PORT_x_MUX_4_FUNC_1 | PORT_x_MUX_5_FUNC_1; - *pPORTF_FER |=PF0 |PF1 |PF2 |PF3 |PF4 |PF5 |PF6 |PF8 |PF9 |PF10 |PF11 |PF12 |PF13 |PF14 |PF15 ; - *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_1; - *pPORTG_FER |=PG0 |PG1 |PG2 ; -# elif defined(__ADSPBF52x__) - *pPORTG_MUX = (*pPORTG_MUX & ~PORT_x_MUX_6_MASK) | PORT_x_MUX_6_FUNC_2; - *pPORTG_FER |=PG14 |PG15 ; - *pPORTH_MUX = PORT_x_MUX_0_FUNC_2 | PORT_x_MUX_1_FUNC_2 | PORT_x_MUX_2_FUNC_2; - *pPORTH_FER =-1 ;/* all pins */ -# else - *pPORTH_FER =-1 ;/* all pins */ -# endif -#endif - -/* Odd word alignment for Receive Frame DMA word */ -/* Configure checksum support and rcve frame word alignment */ - *pEMAC_SYSCTL =RXDWA |RXCKS |SET_MDCDIV (MDC_FREQ_TO_DIV (2500000 )); -/* auto negotiation on */ -/* full duplex */ -/* 100 Mbps */ - phydat =PHY_ANEG_EN |PHY_DUPLEX |PHY_SPD_SET ; -WrPHYReg (PHYADDR ,PHY_MODECTL , phydat); -do { -udelay (1000 ); - phydat =RdPHYReg (PHYADDR ,PHY_MODESTAT ); -if (count >3000 ) { -printf - ("Link is down, please check your network connection\n" ); -return -1 ; - } - count++; - }while (!(phydat &0x0004 )); - - phydat =RdPHYReg (PHYADDR ,PHY_ANLPAR ); - -if ((phydat &0x0100 ) || (phydat &0x0040 )) - *opmode =FDMODE ; -else - *opmode =0 ; - - *pEMAC_MMC_CTL =RSTC |CROLL ; - -/* Initialize the TX DMA channel registers */ - *pDMA2_X_COUNT =0 ; - *pDMA2_X_MODIFY =4 ; - *pDMA2_Y_COUNT =0 ; - *pDMA2_Y_MODIFY =0 ; - -/* Initialize the RX DMA channel registers */ - *pDMA1_X_COUNT =0 ; - *pDMA1_X_MODIFY =4 ; - *pDMA1_Y_COUNT =0 ; - *pDMA1_Y_MODIFY =0 ; -return 0 ; -} -ADI_ETHER_BUFFER *SetupRxBuffer (int no) {ADI_ETHER_FRAME_BUFFER *frmbuf;
drivers/net/bfin_mac.h +0 -25
@@ -10,28 +10,8 @@#define __BFIN_MAC_H__#define PHYADDR 0x01 -#define NO_PHY_REGS 0x20 - -#define DEFAULT_PHY_PHYID1 0x0007 -#define DEFAULT_PHY_PHYID2 0xC0A3 -#define PHY_MODECTL 0x00 -#define PHY_MODESTAT 0x01 -#define PHY_PHYID1 0x02 -#define PHY_PHYID2 0x03 -#define PHY_ANAR 0x04 -#define PHY_ANLPAR 0x05 -#define PHY_ANER 0x06 - -#define PHY_RESET 0x8000 -#define PHY_ANEG_EN 0x1000 -#define PHY_DUPLEX 0x0100 -#define PHY_SPD_SET 0x2000 -#define RECV_BUFSIZE (0x614) -typedef volatile u32 reg32 ; -typedef volatile u16 reg16 ; - typedef struct ADI_DMA_CONFIG_REG { u16 b_DMA_EN:1; /* 0 Enabled */ u16 b_WNR:1; /* 1 Direction */
@@ -79,11 +59,6 @@ static void bfin_EMAC_halt(struct eth_device *dev);static int bfin_EMAC_send (struct eth_device *dev,volatile void *packet,int length);static int bfin_EMAC_recv (struct eth_device *dev); -static void PollMdcDone (void ); -static void WrPHYReg (u16 PHYAddr,u16 RegAddr,u16 Data); -static u16 RdPHYReg (u16 PHYAddr,u16 RegAddr); -static int SetupSystemRegs (int *opmode); -static void bfin_EMAC_setup_addr (bd_t *bd);#endif
Signature · 1 line
1.6.1.1
PATCH 3/27 Blackfin: bfin_mac: cleanup MII/PHY functions
Quoted 6 lines · Mike Frysinger
Cleanup and rewrite the MII/PHY related functions so that we can reuse the existing common
linux/miiphy.hcode and hook into themiicommand.Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
<snip>
regards,
Ben
PATCH 4/27 Blackfin: bfin_mac: respect CONFIG_PHY_{ADDR, CLOCK_FREQ}
In reply to Mike FrysingerRather than having the on-chip MAC hardcoded to phy address 1 and a speed of 2.5mhz, use these ase defaults if the board doesn't specify otherwise.
--- drivers/net/bfin_mac.c | 15 +++++++++++---- drivers/net/bfin_mac.h | 1 - 2 files changed, 11 insertions(+), 5 deletions(-)
drivers/net/bfin_mac.c +11 -4
@@ -22,6 +22,13 @@#include "bfin_mac.h" +#ifndef CONFIG_PHY_ADDR +# define CONFIG_PHY_ADDR 1 +#endif +#ifndef CONFIG_PHY_CLOCK_FREQ +# define CONFIG_PHY_CLOCK_FREQ 2500000 +#endif +#ifdef CONFIG_POST #include <post.h> #endif
@@ -287,14 +294,14 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode)/* Odd word alignment for Receive Frame DMA word */ /* Configure checksum support and rcve frame word alignment */ -bfin_write_EMAC_SYSCTL (RXDWA |RXCKS |SET_MDCDIV (MDC_FREQ_TO_DIV (2500000 ))); +bfin_write_EMAC_SYSCTL (RXDWA |RXCKS |SET_MDCDIV (MDC_FREQ_TO_DIV (CONFIG_PHY_CLOCK_FREQ )));/* turn on auto-negotiation and wait for link to come up */ -bfin_miiphy_write (dev->name,PHYADDR ,MII_BMCR ,BMCR_ANENABLE ); +bfin_miiphy_write (dev->name,CONFIG_PHY_ADDR ,MII_BMCR ,BMCR_ANENABLE ); count =0 ;while (1 ) { ++count; -if (bfin_miiphy_read (dev->name,PHYADDR ,MII_BMSR , &phydat)) +if (bfin_miiphy_read (dev->name,CONFIG_PHY_ADDR ,MII_BMSR , &phydat))return -1 ;if (phydat &BMSR_LSTATUS )break ;
@@ -306,7 +313,7 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) }/* see what kind of link we have */ -if (bfin_miiphy_read (dev->name,PHYADDR ,MII_LPA , &phydat)) +if (bfin_miiphy_read (dev->name,CONFIG_PHY_ADDR ,MII_LPA , &phydat))return -1 ;if (phydat &LPA_DUPLEX ) *opmode =FDMODE ;
drivers/net/bfin_mac.h +0 -1
@@ -9,7 +9,6 @@ #ifndef __BFIN_MAC_H__ #define __BFIN_MAC_H__ -#define PHYADDR 0x01 #define RECV_BUFSIZE (0x614) typedef struct ADI_DMA_CONFIG_REG {
Signature · 1 line
1.6.1.1
PATCH 4/27 Blackfin: bfin_mac: respect CONFIG_PHY_{ADDR, CLOCK_FREQ}
Quoted 6 lines · Mike Frysinger
Rather than having the on-chip MAC hardcoded to phy address 1 and a speed of 2.5mhz, use these ase defaults if the board doesn't specify otherwise.
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
<snip>
regards,
Ben
PATCH 5/27 Blackfin: bfin_mac: use common debug()
In reply to Mike FrysingerRather then defining our own DEBUGF(), just use the common debug().
--- drivers/net/bfin_mac.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-)
drivers/net/bfin_mac.c +3 -11
@@ -33,14 +33,6 @@#include <post.h> #endif -#undef DEBUG_ETHERNET - -#ifdef DEBUG_ETHERNET -#define DEBUGF(fmt, args...) printf(fmt, ##args) -#else -#define DEBUGF(fmt, args...) -#endif -#define RXBUF_BASE_ADDR 0xFF900000#define TXBUF_BASE_ADDR 0xFF800000#define TX_BUF_CNT 1
@@ -197,7 +189,7 @@ static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet,else txIdx++; out: -DEBUGF ("BFIN EMAC send: length = %d\n" , length); +debug ("BFIN EMAC send: length = %d\n" , length);return result; }
@@ -342,7 +334,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)u32 opmode;int dat;int i; -DEBUGF ("Eth_init: ......\n" ); +debug ("Eth_init: ......\n" ); txIdx =0 ; rxIdx =0 ;
@@ -405,7 +397,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)static void bfin_EMAC_halt (struct eth_device *dev) { -DEBUGF ("Eth_halt: ......\n" ); +debug ("Eth_halt: ......\n" );/* Turn off the EMAC */ *pEMAC_OPMODE =0x00000000 ;/* Turn off the EMAC RX DMA */
Signature · 1 line
1.6.1.1
PATCH 5/27 Blackfin: bfin_mac: use common debug()
Quoted 5 lines · Mike Frysinger
Rather then defining our own
DEBUGF(), just use the commondebug().Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
Quoted 43 lines
--- drivers/net/bfin_mac.c | 14 +++----------- 1 files changed, 3 insertions(+), 11 deletions(-)drivers/net/bfin_mac.c +2
-10@@ -33,14 +33,6 @@#include <post.h> #endif -#undef DEBUG_ETHERNET - -#ifdef DEBUG_ETHERNET -#define DEBUGF(fmt, args...) printf(fmt, ##args) -#else -#define DEBUGF(fmt, args...) -#endif -#define RXBUF_BASE_ADDR 0xFF900000#define TXBUF_BASE_ADDR 0xFF800000#define TX_BUF_CNT 1@@ -197,7 +189,7 @@ static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet,else txIdx++; out: -DEBUGF ("BFIN EMAC send: length = %d\n" , length); +debug ("BFIN EMAC send: length = %d\n" , length);return result; }@@ -342,7 +334,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)u32 opmode;int dat;int i; -DEBUGF ("Eth_init: ......\n" ); +debug ("Eth_init: ......\n" ); txIdx =0 ; rxIdx =0 ;
drivers/net/bfin_mac.c static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd) · line 403
Quoted 8 lines
drivers/net/bfin_mac.c +1
-1@@ -405,7 +397,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)static void bfin_EMAC_halt (struct eth_device *dev) { -DEBUGF ("Eth_halt: ......\n" ); +debug ("Eth_halt: ......\n" );/* Turn off the EMAC */ *pEMAC_OPMODE =0x00000000 ;/* Turn off the EMAC RX DMA */
regards,
Ben
PATCH 6/27 Blackfin: bfin_mac: convert CONFIG_BFIN_MAC_RMII to CONFIG_RMII
In reply to Mike FrysingerNo point in having a Blackfin-specific define "CONFIG_BFIN_MAC_RMII" that does exactly the same thing as common "CONFIG_RMII".
--- drivers/net/bfin_mac.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/bfin_mac.c +2 -2
@@ -247,7 +247,7 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) *pVR_CTL |=CLKBUFOE ;/* Set all the pins to peripheral mode */ -#ifdef CONFIG_BFIN_MAC_RMII +#ifdef CONFIG_RMII /* grab RMII pins */ # if defined(__ADSPBF51x__) *pPORTF_MUX = (*pPORTF_MUX & \
@@ -387,7 +387,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)else opmode =ASTP |PSF ; opmode |=RE ; -#ifdef CONFIG_BFIN_MAC_RMII +#ifdef CONFIG_RMII opmode |=TE |RMII ;#endif /* Turn on the EMAC */
Signature · 1 line
1.6.1.1
PATCH 6/27 Blackfin: bfin_mac: convert CONFIG_BFIN_MAC_RMII to CONFIG_RMII
Quoted 6 lines · Mike Frysinger
No point in having a Blackfin-specific define "
CONFIG_BFIN_MAC_RMII" that does exactly the same thing as common "CONFIG_RMII".Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
Quoted 19 lines
--- drivers/net/bfin_mac.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)drivers/net/bfin_mac.c +1
-1@@ -247,7 +247,7 @@ static int bfin_miiphy_init(struct eth_device *dev, int *opmode) *pVR_CTL |=CLKBUFOE ;/* Set all the pins to peripheral mode */ -#ifdef CONFIG_BFIN_MAC_RMII +#ifdef CONFIG_RMII /* grab RMII pins */ # if defined(__ADSPBF51x__) *pPORTF_MUX = (*pPORTF_MUX & \
drivers/net/bfin_mac.c static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd) · line 393
Quoted 8 lines
drivers/net/bfin_mac.c +1
-1@@ -387,7 +387,7 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)else opmode =ASTP |PSF ; opmode |=RE ; -#ifdef CONFIG_BFIN_MAC_RMII +#ifdef CONFIG_RMII opmode |=TE |RMII ;#endif /* Turn on the EMAC */
thanks,
Ben
PATCH 7/27 Blackfin: bfin_mac: cleanup pointer/casts for aliasing issues
In reply to Mike FrysingerRedo how pointers are managed to get rid of ugly casts and strict pointer aliasing issues that are highlighted by gcc 4.3.
--- drivers/net/bfin_mac.c | 75 +++++++++++++++++++---------------------------- drivers/net/bfin_mac.h | 5 ++- 2 files changed, 34 insertions(+), 46 deletions(-)
drivers/net/bfin_mac.c +30 -45
@@ -39,34 +39,27 @@#define TOUT_LOOP 1000000 -ADI_ETHER_BUFFER *txbuf[TX_BUF_CNT ]; -ADI_ETHER_BUFFER *rxbuf[PKTBUFSRX ]; +static ADI_ETHER_BUFFER *txbuf[TX_BUF_CNT ]; +static ADI_ETHER_BUFFER *rxbuf[PKTBUFSRX ];static u16 txIdx;/* index of the current RX buffer */ static u16 rxIdx;/* index of the current TX buffer */ /* DMAx_CONFIG values at DMA Restart */ -const ADI_DMA_CONFIG_REG rxdmacfg = { - .b_DMA_EN =1 ,/* enabled */ - .b_WNR =1 ,/* write to memory */ - .b_WDSIZE =2 ,/* wordsize is 32 bits */ - .b_DMA2D =0 , - .b_RESTART =0 , - .b_DI_SEL =0 , - .b_DI_EN =0 ,/* no interrupt */ - .b_NDSIZE =5 ,/* 5 half words is desc size */ - .b_FLOW =7 /* large desc flow */ -}; - -const ADI_DMA_CONFIG_REG txdmacfg = { - .b_DMA_EN =1 ,/* enabled */ - .b_WNR =0 ,/* read from memory */ - .b_WDSIZE =2 ,/* wordsize is 32 bits */ - .b_DMA2D =0 , - .b_RESTART =0 , - .b_DI_SEL =0 , - .b_DI_EN =0 ,/* no interrupt */ - .b_NDSIZE =5 ,/* 5 half words is desc size */ - .b_FLOW =7 /* large desc flow */ +static const union { +u16 data; +ADI_DMA_CONFIG_REG reg; +} txdmacfg = { + .reg = { + .b_DMA_EN =1 ,/* enabled */ + .b_WNR =0 ,/* read from memory */ + .b_WDSIZE =2 ,/* wordsize is 32 bits */ + .b_DMA2D =0 , + .b_RESTART =0 , + .b_DI_SEL =0 , + .b_DI_EN =0 ,/* no interrupt */ + .b_NDSIZE =5 ,/* 5 half words is desc size */ + .b_FLOW =7 /* large desc flow */ + }, };static int bfin_miiphy_wait (void )
@@ -172,8 +165,8 @@ static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet, txbuf[txIdx]->FrmData->NoBytes = length;memcpy (txbuf[txIdx]->FrmData->Dest, (void *)packet, length); txbuf[txIdx]->Dma[0 ].START_ADDR = (u32 ) txbuf[txIdx]->FrmData; - *pDMA2_NEXT_DESC_PTR = &txbuf[txIdx]->Dma[0 ]; - *pDMA2_CONFIG = *(u16 *) (void *)(&txdmacfg); + *pDMA2_NEXT_DESC_PTR = txbuf[txIdx]->Dma; + *pDMA2_CONFIG = txdmacfg.data; *pEMAC_OPMODE |=TE ;for (i =0 ; (txbuf[txIdx]->StatusWord &TX_COMP ) ==0 ; i++) {
@@ -350,27 +343,23 @@ static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd)for (i =0 ; i <PKTBUFSRX ; i++) { rxbuf[i] =SetupRxBuffer (i);if (i >0 ) { - rxbuf[i -1 ]->Dma[1 ].NEXT_DESC_PTR = - &(rxbuf[i]->Dma[0 ]); + rxbuf[i -1 ]->Dma[1 ].NEXT_DESC_PTR = rxbuf[i]->Dma;if (i == (PKTBUFSRX -1 )) - rxbuf[i]->Dma[1 ].NEXT_DESC_PTR = - &(rxbuf[0 ]->Dma[0 ]); + rxbuf[i]->Dma[1 ].NEXT_DESC_PTR = rxbuf[0 ]->Dma; } }for (i =0 ; i <TX_BUF_CNT ; i++) { txbuf[i] =SetupTxBuffer (i);if (i >0 ) { - txbuf[i -1 ]->Dma[1 ].NEXT_DESC_PTR = - &(txbuf[i]->Dma[0 ]); + txbuf[i -1 ]->Dma[1 ].NEXT_DESC_PTR = txbuf[i]->Dma;if (i == (TX_BUF_CNT -1 )) - txbuf[i]->Dma[1 ].NEXT_DESC_PTR = - &(txbuf[0 ]->Dma[0 ]); + txbuf[i]->Dma[1 ].NEXT_DESC_PTR = txbuf[0 ]->Dma; } }/* Set RX DMA */ - *pDMA1_NEXT_DESC_PTR = &rxbuf[0 ]->Dma[0 ]; - *pDMA1_CONFIG = *((u16 *) (void *)&rxbuf[0 ]->Dma[0 ].CONFIG); + *pDMA1_NEXT_DESC_PTR = rxbuf[0 ]->Dma; + *pDMA1_CONFIG = rxbuf[0 ]->Dma[0 ].CONFIG_DATA;/* Wait MII done */ bfin_miiphy_wait ();
@@ -425,10 +414,8 @@ ADI_ETHER_BUFFER *SetupRxBuffer(int no)int nobytes_buffer =sizeof (ADI_ETHER_BUFFER [2 ]) /2 ;/* ensure a multi. of 4 */ int total_size = nobytes_buffer +RECV_BUFSIZE ; - buf = (ADI_ETHER_BUFFER *) (RXBUF_BASE_ADDR + no * total_size); - frmbuf = - (ADI_ETHER_FRAME_BUFFER *) (RXBUF_BASE_ADDR + no * total_size + - nobytes_buffer); + buf = (void *) (RXBUF_BASE_ADDR + no * total_size); + frmbuf = (void *) (RXBUF_BASE_ADDR + no * total_size + nobytes_buffer);memset (buf,0x00 , nobytes_buffer); buf->FrmData = frmbuf;
@@ -444,7 +431,7 @@ ADI_ETHER_BUFFER *SetupRxBuffer(int no) buf->Dma[0 ].CONFIG.b_FLOW =7 ;/* large desc flow */ /* set up second desc to point to status word */ - buf->Dma[1 ].NEXT_DESC_PTR = &(buf->Dma[0 ]); + buf->Dma[1 ].NEXT_DESC_PTR = buf->Dma; buf->Dma[1 ].START_ADDR = (u32) & buf->IPHdrChksum; buf->Dma[1 ].CONFIG.b_DMA_EN =1 ;/* enabled */ buf->Dma[1 ].CONFIG.b_WNR =1 ;/* Write to memory */
@@ -463,10 +450,8 @@ ADI_ETHER_BUFFER *SetupTxBuffer(int no)int nobytes_buffer =sizeof (ADI_ETHER_BUFFER [2 ]) /2 ;/* ensure a multi. of 4 */ int total_size = nobytes_buffer +RECV_BUFSIZE ; - buf = (ADI_ETHER_BUFFER *) (TXBUF_BASE_ADDR + no * total_size); - frmbuf = - (ADI_ETHER_FRAME_BUFFER *) (TXBUF_BASE_ADDR + no * total_size + - nobytes_buffer); + buf = (void *) (TXBUF_BASE_ADDR + no * total_size); + frmbuf = (void *) (TXBUF_BASE_ADDR + no * total_size + nobytes_buffer);memset (buf,0x00 , nobytes_buffer); buf->FrmData = frmbuf;
drivers/net/bfin_mac.h +4 -1
@@ -35,7 +35,10 @@ typedef struct adi_ether_frame_buffer {typedef struct dma_descriptor {struct dma_descriptor *NEXT_DESC_PTR;u32 START_ADDR; -ADI_DMA_CONFIG_REG CONFIG; +union { +u16 CONFIG_DATA; +ADI_DMA_CONFIG_REG CONFIG; + }; }DMA_DESCRIPTOR ;/* 10 bytes/struct in 12 bytes */
Signature · 1 line
1.6.1.1
PATCH 7/27 Blackfin: bfin_mac: cleanup pointer/casts for aliasing issues
Quoted 6 lines · Mike Frysinger
Redo how pointers are managed to get rid of ugly casts and strict pointer aliasing issues that are highlighted by gcc 4.3.
Signed-off-by Mike Frysinger <[email protected]>CC Ben Warren <[email protected]>
<snip>
regards,
Ben
PATCH 8/27 Blackfin: only build post code when CONFIG_POST
In reply to Mike FrysingerSave some time by using CONFIG_POST in the Makefile rather than C files.
--- lib_blackfin/Makefile | 3 +-- lib_blackfin/post.c | 4 ---- lib_blackfin/tests.c | 3 --- 3 files changed, 1 insertions(+), 9 deletions(-)
lib_blackfin/Makefile +1 -2
@@ -40,9 +40,8 @@ COBJS-y += board.o COBJS-y += boot.o COBJS-y += cache.o COBJS-y += muldi3.o -COBJS-y += post.o +COBJS-$(CONFIG_POST) += post.o tests.o COBJS-y += string.o -COBJS-y += tests.o SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
lib_blackfin/post.c +0 -4
@@ -30,8 +30,6 @@#include <logbuff.h> #endif -#ifdef CONFIG_POST -DECLARE_GLOBAL_DATA_PTR ;#define POST_MAX_NUMBER 32
@@ -421,5 +419,3 @@ unsigned long post_time_ms(unsigned long base) {return (unsigned long )get_ticks () / (get_tbclk () /CONFIG_SYS_HZ ) - base; } - -#endif /* CONFIG_POST */
lib_blackfin/tests.c +0 -3
@@ -27,7 +27,6 @@#include <common.h> #include <config.h> -#ifdef CONFIG_POST #include <post.h> #define CONFIG_SYS_POST_FLASH 0x00004000
@@ -249,5 +248,3 @@ struct post_test post_list[] = { };unsigned int post_list_size =sizeof (post_list) /sizeof (struct post_test ); - -#endif /* CONFIG_POST */
Signature · 1 line
1.6.1.1
PATCH 9/27 Blackfin: add driver for on-chip SPI controller
In reply to Mike FrysingerThis fills out the SPI backend for the Blackfin on-chip SPI peripheral.
--- drivers/spi/Makefile | 1 + drivers/spi/bfin_spi.c | 343 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 344 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/bfin_spi.c
drivers/spi/Makefile +1 -0
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libspi.a COBJS-$(CONFIG_ATMEL_SPI) += atmel_spi.o +COBJS-$(CONFIG_BFIN_SPI) += bfin_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o
drivers/spi/bfin_spi.c new file +343 -0
343 lines not on this page · raw message
Signature · 1 line
1.6.1.1
PATCH 10/27 Blackfin: dont check baud if it wont actually get used
In reply to Mike Frysinger--- cpu/blackfin/initcode.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
cpu/blackfin/initcode.c +5 -1
@@ -61,7 +61,11 @@ static inline uint32_t serial_init(void) }#endif -uint32_t old_baud =serial_early_get_baud (); +uint32_t old_baud; +if (BFIN_DEBUG_EARLY_SERIAL ||CONFIG_BFIN_BOOT_MODE ==BFIN_BOOT_UART ) + old_baud =serial_early_get_baud (); +else + old_baud =CONFIG_BAUDRATE ;if (BFIN_DEBUG_EARLY_SERIAL ) {serial_early_init ();
Signature · 1 line
1.6.1.1
PATCH 11/27 Blackfin: enable --gc-sections
In reply to Mike FrysingerStart building all Blackfin boards with -ffunction-sections/-fdata-sections and linking with --gc-sections.
--- blackfin_config.mk | 3 +++ cpu/blackfin/Makefile | 1 + 2 files changed, 4 insertions(+), 0 deletions(-)
blackfin_config.mk +3 -0
@@ -27,6 +27,9 @@ CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE))) PLATFORM_RELFLAGS += -ffixed-P5 -fomit-frame-pointer PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN +LDFLAGS += --gc-sections +PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections + ifneq (,$(CONFIG_BFIN_CPU)) PLATFORM_RELFLAGS += -mcpu=$(CONFIG_BFIN_CPU) endif
cpu/blackfin/Makefile +1 -0
@@ -47,6 +47,7 @@ $(obj)bootrom-asm-offsets.h: $(obj)bootrom-asm-offsets.s # make sure our initcode (which goes into LDR) does not # have relocs or external references +$(obj)initcode.o: CFLAGS += -fno-function-sections -fno-data-sections READINIT = env LC_ALL=C $(CROSS_COMPILE)readelf -s $< check_initcode: $(obj)initcode.o ifneq ($(CONFIG_BFIN_BOOT_MODE),BFIN_BOOT_BYPASS)
Signature · 1 line
1.6.1.1
PATCH 12/27 Blackfin: cache core/system clock values
In reply to Mike FrysingerCalculating the clocks requires a bit of calls to gcc math functions, so cache the values after the first run since they'll most likely never change once U-Boot is up and running.
--- include/asm-blackfin/blackfin_local.h | 2 + lib_blackfin/Makefile | 1 + lib_blackfin/board.c | 44 ------------------- lib_blackfin/clocks.c | 77 +++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 44 deletions(-) create mode 100644 lib_blackfin/clocks.c
include/asm-blackfin/blackfin_local.h +2 -0
@@ -52,6 +52,8 @@# include <linux/types.h> +extern u_long get_vco (void ); +extern u_long get_cclk (void );extern u_long get_sclk (void );# define bfin_revid () (*pCHIPID >> 28)
lib_blackfin/Makefile +1 -0
@@ -39,6 +39,7 @@ SOBJS-y += memset.o COBJS-y += board.o COBJS-y += boot.o COBJS-y += cache.o +COBJS-y += clocks.o COBJS-y += muldi3.o COBJS-$(CONFIG_POST) += post.o tests.o COBJS-y += string.o
lib_blackfin/board.c +0 -44
50 lines not on this page · raw message
lib_blackfin/clocks.c new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
1.6.1.1
PATCH 13/27 Blackfin: setup bi_enetaddr for single nets
In reply to Mike FrysingerFor systems with CONFIG_NET_MULTI disabled, bi_enetaddr does not get setup based on $ethaddr, so set it up.
--- lib_blackfin/board.c | 11 ++++++++++- 1 files changed, 10 insertions(+), 1 deletions(-)
lib_blackfin/board.c +10 -1
@@ -364,10 +364,19 @@ void board_init_r(gd_t * id, ulong dest_addr) bd->bi_ip_addr =getenv_IPaddr ("ipaddr" );printf ("Net: " );eth_initialize (gd->bd); -if (getenv ("ethaddr" )) +if ((s =getenv ("ethaddr" ))) { +# ifndef CONFIG_NET_MULTI +size_t i; +char *e; +for (i =0 ; i <6 ; ++i) { + bd->bi_enetaddr[i] =simple_strtoul (s, &e,16 ); + s = (*e) ? e +1 : e; + } +# endif printf ("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n" , bd->bi_enetaddr[0 ], bd->bi_enetaddr[1 ], bd->bi_enetaddr[2 ], bd->bi_enetaddr[3 ], bd->bi_enetaddr[4 ], bd->bi_enetaddr[5 ]); + }#endif display_global_data ();
Signature · 1 line
1.6.1.1
PATCH 14/27 Blackfin: rewrite cache handling functions
In reply to Mike FrysingerTake the cache flush functions from the kernel as they use hardware loops in order to get optimal performance.
--- cpu/blackfin/cache.S | 118 ++++++++++++++++++++------------- include/asm-blackfin/blackfin_local.h | 4 + lib_blackfin/cache.c | 18 ++++- 3 files changed, 90 insertions(+), 50 deletions(-)
cpu/blackfin/cache.S +72 -46
@@ -1,5 +1,10 @@ -/* cache.S - low level cache handling routines - * Copyright (C) 2003-2007 Analog Devices Inc. +/* + * Blackfin cache control code + * + * Copyright 2003-2008 Analog Devices Inc. + * + * Enter bugs at http://blackfin.uclinux.org/ + * * Licensed under the GPL-2 or later. */
@@ -8,54 +13,75 @@ #include <asm/blackfin.h> .text -.align 2 -ENTRY(_blackfin_icache_flush_range) - R2 = -32; - R2 = R0 & R2; - P0 = R2; - P1 = R1; - CSYNC; +/* Since all L1 caches work the same way, we use the same method for flushing + * them. Only the actual flush instruction differs. We write this in asm as + * GCC can be hard to coax into writing nice hardware loops. + * + * Also, we assume the following register setup: + * R0 = start address + * R1 = end address + */ +.macro do_flush flushins:req optflushins optnopins label + + R2 = -L1_CACHE_BYTES; + + /* start = (start & -L1_CACHE_BYTES) */ + R0 = R0 & R2; + + /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */ + R1 += -1; + R1 = R1 & R2; + R1 += L1_CACHE_BYTES; + + /* count = (end - start) >> L1_CACHE_SHIFT */ + R2 = R1 - R0; + R2 >>= L1_CACHE_SHIFT; + P1 = R2; + +.ifnb \label +\label : +.endif + P0 = R0; + LSETUP (1f, 2f) LC1 = P1; 1: - IFLUSH[P0++]; - CC = P0 < P1(iu); - IF CC JUMP 1b(bp); - IFLUSH[P0]; - SSYNC; +.ifnb \optflushins + \optflushins [P0]; +.endif +#if ANOMALY_05000443 +.ifb \optnopins +2: +.endif + \flushins [P0++]; +.ifnb \optnopins +2: \optnopins; +.endif +#else +2: \flushins [P0++]; +#endif + RTS; +.endm + +/* Invalidate all instruction cache lines assocoiated with this memory area */ +ENTRY(_blackfin_icache_flush_range) + do_flush IFLUSH, , nop ENDPROC(_blackfin_icache_flush_range) -ENTRY(_blackfin_dcache_flush_range) - R2 = -32; - R2 = R0 & R2; - P0 = R2; - P1 = R1; - CSYNC; -1: - FLUSH[P0++]; - CC = P0 < P1(iu); - IF CC JUMP 1b(bp); - FLUSH[P0]; - SSYNC; - RTS; -ENDPROC(_blackfin_dcache_flush_range) +/* Flush all cache lines assocoiated with this area of memory. */ +ENTRY(_blackfin_icache_dcache_flush_range) + do_flush FLUSH, IFLUSH +ENDPROC(_blackfin_icache_dcache_flush_range) +/* Throw away all D-cached data in specified region without any obligation to + * write them back. Since the Blackfin ISA does not have an "invalidate" + * instruction, we use flush/invalidate. Perhaps as a speed optimization we + * could bang on the DTEST MMRs ... + */ ENTRY(_blackfin_dcache_flush_invalidate_range) - R2 = -32; - R2 = R0 & R2; - P0 = R2; - P1 = R1; - CSYNC; -1: - FLUSHINV[P0++]; - CC = P0 < P1(iu); - IF CC JUMP 1b(bp); - - /* - * If the data crosses a cache line, then we'll be pointing to - * the last cache line, but won't have flushed/invalidated it yet, so do - * one more. - */ - FLUSHINV[P0]; - SSYNC; - RTS; + do_flush FLUSHINV ENDPROC(_blackfin_dcache_flush_invalidate_range) + +/* Flush all data cache lines assocoiated with this memory area */ +ENTRY(_blackfin_dcache_flush_range) + do_flush FLUSH, , , .Ldfr +ENDPROC(_blackfin_dcache_flush_range)
include/asm-blackfin/blackfin_local.h +4 -0
@@ -43,6 +43,9 @@#define SCLK_TO_MSEC (sclk) ((MSEC_PER_SEC * ((sclk) / USEC_PER_MSEC)) / (BFIN_SCLK / USEC_PER_MSEC))#define MSEC_TO_SCLK (msec) ((((BFIN_SCLK / USEC_PER_MSEC) * (msec)) / MSEC_PER_SEC) * USEC_PER_MSEC) +#define L1_CACHE_SHIFT 5 +#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) +#include <asm/linkage.h> #ifndef __ASSEMBLY__
@@ -60,6 +63,7 @@ extern u_long get_sclk(void);extern void blackfin_icache_flush_range (const void *,const void *);extern void blackfin_dcache_flush_range (const void *,const void *); +extern void blackfin_icache_dcache_flush_range (const void *,const void *);extern void blackfin_dcache_flush_invalidate_range (const void *,const void *);/* Use DMA to move data from on chip to external memory. While this is
lib_blackfin/cache.c +14 -4
@@ -15,15 +15,25 @@void flush_cache (unsigned long addr,unsigned long size) { +void *start_addr, *end_addr; +int istatus, dstatus; +/* no need to flush stuff in on chip memory (L1/L2/etc...) */ if (addr >=0xE0000000 )return ; -if (icache_status ()) -blackfin_icache_flush_range ((void *)addr, (void *)(addr + size)); + start_addr = (void *)addr; + end_addr = (void *)(addr + size); + istatus =icache_status (); + dstatus =dcache_status (); -if (dcache_status ()) -blackfin_dcache_flush_range ((void *)addr, (void *)(addr + size)); +if (istatus) { +if (dstatus) +blackfin_icache_dcache_flush_range (start_addr, end_addr); +else +blackfin_icache_flush_range (start_addr, end_addr); + }else if (dstatus) +blackfin_dcache_flush_range (start_addr, end_addr); }void icache_enable (void )
Signature · 1 line
1.6.1.1
PATCH 15/27 Blackfin: dma_memcpy(): fix random failures
In reply to Mike FrysingerWe have to make sure the DMA channel is actually disabled in hardware before attempting to reprogram it. Otherwise the new settings are ignored and we end up with random hangs/failures.
--- lib_blackfin/string.c | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-)
lib_blackfin/string.c +11 -8
@@ -136,6 +136,14 @@ int strncmp(const char *cs, const char *ct, size_t count)*/ void dma_memcpy_nocache (void *dst,const void *src,size_t count) { +/* Disable DMA in case it's still running (older u-boot's did not +* always turn them off). Do it before the if statement below so +* we can be cheap and not do a SSYNC() due to the forced abort. +*/ +bfin_write_MDMA_D0_CONFIG (0 ); +bfin_write_MDMA_S0_CONFIG (0 ); +bfin_write_MDMA_D0_IRQ_STATUS (DMA_RUN |DMA_DONE |DMA_ERR ); +/* Scratchpad cannot be a DMA source or destination */ if (((unsigned long)src >= L1_SRAM_SCRATCH && (unsigned long)src < L1_SRAM_SCRATCH_END) ||
@@ -143,10 +151,6 @@ void dma_memcpy_nocache(void *dst, const void *src, size_t count) (unsigned long)dst < L1_SRAM_SCRATCH_END))hang (); -bfin_write_MDMA_S0_CONFIG (0 ); -bfin_write_MDMA_D0_CONFIG (0 ); -bfin_write_MDMA_D0_IRQ_STATUS (DMA_RUN |DMA_DONE |DMA_ERR ); -/* Copy sram functions from sdram to sram */ /* Setup destination start address */ bfin_write_MDMA_D0_START_ADDR (dst);
@@ -164,14 +168,13 @@ void dma_memcpy_nocache(void *dst, const void *src, size_t count)/* Enable source DMA */ bfin_write_MDMA_S0_CONFIG (DMAEN ); - -bfin_write_MDMA_D0_CONFIG (WNR |DMAEN ); +bfin_write_MDMA_D0_CONFIG (WNR |DMAEN |DI_EN );SSYNC (); -while (bfin_read_MDMA_D0_IRQ_STATUS () &DMA_RUN ) +while (!(bfin_read_MDMA_D0_IRQ_STATUS () &DMA_DONE ))continue ; -bfin_write_MDMA_D0_IRQ_STATUS (bfin_read_MDMA_D0_IRQ_STATUS () |DMA_RUN |DMA_DONE |DMA_ERR ); +bfin_write_MDMA_D0_IRQ_STATUS (DMA_RUN |DMA_DONE |DMA_ERR );bfin_write_MDMA_D0_CONFIG (0 );bfin_write_MDMA_S0_CONFIG (0 ); }
Signature · 1 line
1.6.1.1
PATCH 16/27 Blackfin: only flag L1 instruction for DMA memcpy
In reply to Mike FrysingerThe performance difference from doing an 8 bit DMA memcpy vs an optimized core memcpy can be pretty big when you add in the overhead of setting up the MDMA registers, cache flushes, etc... So only use dma_memcpy() when we actually require it.
--- include/asm-blackfin/blackfin_local.h | 14 ++++---------- 1 files changed, 4 insertions(+), 10 deletions(-)
include/asm-blackfin/blackfin_local.h +4 -10
@@ -66,17 +66,11 @@ extern void blackfin_dcache_flush_range(const void *, const void *);extern void blackfin_icache_dcache_flush_range (const void *,const void *);extern void blackfin_dcache_flush_invalidate_range (const void *,const void *); -/* Use DMA to move data from on chip to external memory. While this is -* required for only L1 instruction (it is not directly readable by the -* core via data loads), it isn't a huge performance issue for other -* regions (it's probably even faster than core load/stores). However, -* the DMA engine does not have access to the L1 scratchpad, and we -* cannot use DMA inside of the MMR space. +/* Use DMA to move data from on chip to external memory. The L1 instruction +* regions can only be accessed via DMA, so if the address in question is in +* that region, make sure we attempt to DMA indirectly. */ -# define addr_bfin_on_chip_mem (addr) \ - (((unsigned long)(addr) >= 0xef000000 && (unsigned long)addr < SYSMMR_BASE) && \ - !((unsigned long)(addr) >= L1_SRAM_SCRATCH && \ - (unsigned long)(addr) < L1_SRAM_SCRATCH_END)) +# define addr_bfin_on_chip_mem (addr) (((unsigned long)(addr) & 0xFFF00000) == 0xFFA00000)# include <asm/system.h>
Signature · 1 line
1.6.1.1
PATCH 17/27 Blackfin: use 8/16/32 bit transfer widths in dma_memcpy()
In reply to Mike FrysingerRather than using 8bit transfers for everything, use 8/16/32 bit transfers as usable with the source/destination addresses and the count size.
--- lib_blackfin/string.c | 23 +++++++++++++++++++---- 1 files changed, 19 insertions(+), 4 deletions(-)
lib_blackfin/string.c +19 -4
@@ -136,6 +136,8 @@ int strncmp(const char *cs, const char *ct, size_t count)*/ void dma_memcpy_nocache (void *dst,const void *src,size_t count) { +uint16_t wdsize, mod; +/* Disable DMA in case it's still running (older u-boot's did not * always turn them off). Do it before the if statement below so * we can be cheap and not do a SSYNC() due to the forced abort.
@@ -151,24 +153,37 @@ void dma_memcpy_nocache(void *dst, const void *src, size_t count) (unsigned long)dst < L1_SRAM_SCRATCH_END))hang (); +if (((unsigned long )dst | (unsigned long )src | count) &0x1 ) { + wdsize =WDSIZE_8 ; + mod =1 ; + }else if (((unsigned long )dst | (unsigned long )src | count) &0x2 ) { + wdsize =WDSIZE_16 ; + count >>=1 ; + mod =2 ; + }else { + wdsize =WDSIZE_32 ; + count >>=2 ; + mod =4 ; + } +/* Copy sram functions from sdram to sram */ /* Setup destination start address */ bfin_write_MDMA_D0_START_ADDR (dst);/* Setup destination xcount */ bfin_write_MDMA_D0_X_COUNT (count);/* Setup destination xmodify */ -bfin_write_MDMA_D0_X_MODIFY (1 ); +bfin_write_MDMA_D0_X_MODIFY (mod);/* Setup Source start address */ bfin_write_MDMA_S0_START_ADDR (src);/* Setup Source xcount */ bfin_write_MDMA_S0_X_COUNT (count);/* Setup Source xmodify */ -bfin_write_MDMA_S0_X_MODIFY (1 ); +bfin_write_MDMA_S0_X_MODIFY (mod);/* Enable source DMA */ -bfin_write_MDMA_S0_CONFIG (DMAEN ); -bfin_write_MDMA_D0_CONFIG (WNR |DMAEN |DI_EN ); +bfin_write_MDMA_S0_CONFIG (wdsize |DMAEN ); +bfin_write_MDMA_D0_CONFIG (wdsize |DMAEN |WNR |DI_EN );SSYNC ();while (!(bfin_read_MDMA_D0_IRQ_STATUS () &DMA_DONE ))
Signature · 1 line
1.6.1.1
PATCH 18/27 Blackfin: fix up EBIU defines
In reply to Mike FrysingerThe EBIU defines for EBSZ 256/512 were incorrect.
--- include/asm-blackfin/mach-common/bits/ebiu.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/asm-blackfin/mach-common/bits/ebiu.h +2 -2
@@ -357,8 +357,8 @@#define EBSZ_32 0x0002/* SDRAM External Bank Size = 32MB */ #define EBSZ_64 0x0004/* SDRAM External Bank Size = 64MB */ #define EBSZ_128 0x0006/* SDRAM External Bank Size = 128MB */ -#define EBSZ_256 0x0007/* SDRAM External Bank Size = 256MB */ -#define EBSZ_512 0x0008/* SDRAM External Bank Size = 512MB */ +#define EBSZ_256 0x0008/* SDRAM External Bank Size = 256MB */ +#define EBSZ_512 0x000A/* SDRAM External Bank Size = 512MB */ #define EBCAW_8 0x0000/* SDRAM External Bank Column Address Width = 8 Bits */ #define EBCAW_9 0x0010/* SDRAM External Bank Column Address Width = 9 Bits */ #define EBCAW_10 0x0020/* SDRAM External Bank Column Address Width = 10 Bits */
Signature · 1 line
1.6.1.1
PATCH 19/27 Blackfin: build with -mno-fdpic
In reply to Mike FrysingerUse the -mno-fdpic flag so that any Blackfin toolchain can be used to build up u-boot, including ones that output FDPIC ELF by default.
--- blackfin_config.mk | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
blackfin_config.mk +1 -1
@@ -24,7 +24,7 @@ CONFIG_BFIN_CPU := $(strip $(subst ",,$(CONFIG_BFIN_CPU))) CONFIG_BFIN_BOOT_MODE := $(strip $(subst ",,$(CONFIG_BFIN_BOOT_MODE))) -PLATFORM_RELFLAGS += -ffixed-P5 -fomit-frame-pointer +PLATFORM_RELFLAGS += -ffixed-P5 -fomit-frame-pointer -mno-fdpic PLATFORM_CPPFLAGS += -DCONFIG_BLACKFIN LDFLAGS += --gc-sections
Signature · 1 line
1.6.1.1
PATCH 20/27 Blackfin: add driver for on-chip NAND controller
In reply to Mike FrysingerThis is a port of the Linux Blackfin on-chip NFC driver to U-Boot.
--- drivers/mtd/nand/Makefile | 1 + drivers/mtd/nand/bfin_nand.c | 376 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 377 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/nand/bfin_nand.c
drivers/mtd/nand/Makefile +1 -0
@@ -35,6 +35,7 @@ COBJS-y += nand_ids.o COBJS-y += nand_util.o endif +COBJS-$(CONFIG_DRIVER_NAND_BFIN) += bfin_nand.o COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_nand.o COBJS-$(CONFIG_NAND_FSL_UPM) += fsl_upm.o COBJS-$(CONFIG_NAND_S3C64XX) += s3c64xx.o
drivers/mtd/nand/bfin_nand.c new file +376 -0
376 lines not on this page · raw message
Signature · 1 line
1.6.1.1
PATCH 21/27 Blackfin: add driver for on-chip ATAPI controller
In reply to Mike FrysingerFrom: Sonic Zhang <[email protected]>
This is a port of the Linux Blackfin on-chip ATAPI driver to U-Boot.
--- drivers/block/Makefile | 1 + drivers/block/pata_bfin.c | 1201 ++++++++++++++++++++++++++ drivers/block/pata_bfin.h | 173 ++++ include/asm-blackfin/mach-common/bits/pata.h | 220 +++++ 4 files changed, 1595 insertions(+), 0 deletions(-) create mode 100644 drivers/block/pata_bfin.c create mode 100644 drivers/block/pata_bfin.h create mode 100644 include/asm-blackfin/mach-common/bits/pata.h
drivers/block/Makefile +1 -0
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_SCSI_AHCI) += ahci.o COBJS-$(CONFIG_ATA_PIIX) += ata_piix.o COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o COBJS-$(CONFIG_LIBATA) += libata.o +COBJS-$(CONFIG_PATA_BFIN) += pata_bfin.o COBJS-$(CONFIG_SATA_SIL3114) += sata_sil3114.o COBJS-$(CONFIG_IDE_SIL680) += sil680.o COBJS-$(CONFIG_SCSI_SYM53C8XX) += sym53c8xx.o
drivers/block/pata_bfin.c new file +1201 -0
1,201 lines not on this page · raw message
drivers/block/pata_bfin.h new file +173 -0
173 lines not on this page · raw message
include/asm-blackfin/mach-common/bits/pata.h new file +220 -0
220 lines not on this page · raw message
Signature · 1 line
1.6.1.1
PATCH 22/27 Blackfin: add port I bits
In reply to Mike FrysingerSome people need to access port I, so make sure the pins are defined.
--- include/asm-blackfin/mach-bf548/ports.h | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
include/asm-blackfin/mach-bf548/ports.h +19 -1
@@ -236,7 +236,25 @@#define PH14 0x4000#define PH15 0x8000 -/* Port J Masks */ +/* Port I Masks */ +#define PI0 0x0001 +#define PI1 0x0002 +#define PI2 0x0004 +#define PI3 0x0008 +#define PI4 0x0010 +#define PI5 0x0020 +#define PI6 0x0040 +#define PI7 0x0080 +#define PI8 0x0100 +#define PI9 0x0200 +#define PI10 0x0400 +#define PI11 0x0800 +#define PI12 0x1000 +#define PI13 0x2000 +#define PI14 0x4000 +#define PI15 0x8000 + +/* Port I Masks */ #define PJ0 0x0001#define PJ1 0x0002#define PJ2 0x0004
Signature · 1 line
1.6.1.1
PATCH 23/27 Blackfin: update asm-blackfin/posix_types.h to latest Linux version
In reply to Mike Frysinger--- include/asm-blackfin/posix_types.h | 20 +++++++++----------- 1 files changed, 9 insertions(+), 11 deletions(-)
include/asm-blackfin/posix_types.h +9 -11
@@ -40,15 +40,17 @@ typedef unsigned short __kernel_mode_t;typedef unsigned short __kernel_nlink_t ;typedef long __kernel_off_t ;typedef int __kernel_pid_t ; -typedef unsigned short __kernel_ipc_pid_t ; -typedef unsigned short __kernel_uid_t ; -typedef unsigned short __kernel_gid_t ; -typedef unsigned int __kernel_size_t ; -typedef int __kernel_ssize_t ; +typedef unsigned int __kernel_ipc_pid_t ; +typedef unsigned int __kernel_uid_t ; +typedef unsigned int __kernel_gid_t ; +typedef unsigned long __kernel_size_t ; +typedef long __kernel_ssize_t ;typedef int __kernel_ptrdiff_t ;typedef long __kernel_time_t ;typedef long __kernel_suseconds_t ;typedef long __kernel_clock_t ; +typedef int __kernel_timer_t ; +typedef int __kernel_clockid_t ;typedef int __kernel_daddr_t ;typedef char *__kernel_caddr_t ;typedef unsigned short __kernel_uid16_t ;
@@ -67,14 +69,10 @@ typedef long long __kernel_loff_t;#endif typedef struct { -#if defined(__KERNEL__) || defined(__USE_ALL)int val[2 ]; -#else /* !defined(__KERNEL__) && !defined(__USE_ALL) */ -int __val[2 ]; -#endif /* !defined(__KERNEL__) && !defined(__USE_ALL) */ }__kernel_fsid_t ; -#if defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ <2 ) +#if defined(__KERNEL__)#undef __FD_SET#define __FD_SET (d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
@@ -88,6 +86,6 @@ typedef struct {#undef __FD_ZERO#define __FD_ZERO (fdsetp) (memset (fdsetp, 0, sizeof(*(fd_set *)fdsetp))) -#endif /* defined(__KERNEL__) || !defined(__GLIBC__) || (__GLIBC__ < 2) */ +#endif /* defined(__KERNEL__) */ #endif
Signature · 1 line
1.6.1.1
PATCH 24/27 Blackfin: set default CONFIG_ENV_SPI_CS based on bootrom
In reply to Mike FrysingerSet the default CONFIG_ENV_SPI_CS value to match the SPI CS that is used by the Blackfin on-chip bootrom to boot out of SPI flash.
--- include/asm-blackfin/blackfin-config-post.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
include/asm-blackfin/blackfin-config-post.h +5 -0
@@ -67,6 +67,11 @@# define CONFIG_LINUX_CMDLINE_SIZE L1_SRAM_SCRATCH_SIZE#endif +/* Set default SPI flash CS to the one we boot from */ +#if defined(CONFIG_ENV_IS_IN_SPI_FLASH ) && !defined(CONFIG_ENV_SPI_CS ) +# define CONFIG_ENV_SPI_CS BFIN_BOOT_SPI_SSEL +#endif +/* Default/common Blackfin memory layout */ #ifndef CONFIG_SYS_SDRAM_BASE # define CONFIG_SYS_SDRAM_BASE 0
Signature · 1 line
1.6.1.1
PATCH 25/27 Blackfin: output booting source when booting
In reply to Mike FrysingerKnowing the booting source of the part is useful, especially when the part can switch dynamically between sources.
--- include/asm-blackfin/blackfin-config-pre.h | 22 ++++++++++++++++++++++ lib_blackfin/board.c | 6 +++++- 2 files changed, 27 insertions(+), 1 deletions(-)
include/asm-blackfin/blackfin-config-pre.h +22 -0
@@ -38,4 +38,26 @@#define BFIN_BOOT_8HOST_DMA 12/* boot ldr from 8-bit host dma */ #define BFIN_BOOT_NAND 13/* boot ldr from nand flash */ +#ifndef __ASSEMBLY__ +static inline const char *get_bfin_boot_mode (int bfin_boot) +{ +switch (bfin_boot) { +case BFIN_BOOT_BYPASS :return "bypass" ; +case BFIN_BOOT_PARA :return "parallel flash" ; +case BFIN_BOOT_SPI_MASTER :return "spi flash" ; +case BFIN_BOOT_SPI_SLAVE :return "spi slave" ; +case BFIN_BOOT_TWI_MASTER :return "i2c flash" ; +case BFIN_BOOT_TWI_SLAVE :return "i2c slave" ; +case BFIN_BOOT_UART :return "uart" ; +case BFIN_BOOT_IDLE :return "idle" ; +case BFIN_BOOT_FIFO :return "fifo" ; +case BFIN_BOOT_MEM :return "memory" ; +case BFIN_BOOT_16HOST_DMA :return "16bit dma" ; +case BFIN_BOOT_8HOST_DMA :return "8bit dma" ; +case BFIN_BOOT_NAND :return "nand flash" ; +default :return "INVALID" ; + } +} +#endif +#endif
lib_blackfin/board.c +5 -1
@@ -70,7 +70,11 @@ void *sbrk(ptrdiff_t increment)static int display_banner (void ) {printf ("\n\n%s\n\n" , version_string); - printf("CPU: ADSP " MK_STR(CONFIG_BFIN_CPU) " (Detected Rev: 0.%d)\n", bfin_revid()); + printf("CPU: ADSP " MK_STR(CONFIG_BFIN_CPU) " " +"(Detected Rev: 0.%d) " +"(%s boot)\n" , +bfin_revid (), +get_bfin_boot_mode (CONFIG_BFIN_BOOT_MODE ));return 0 ; }
Signature · 1 line
1.6.1.1
PATCH 26/27 Blackfin: add port muxing for BF51x SPI
In reply to Mike Frysinger--- board/bf537-stamp/spi_flash.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
board/bf537-stamp/spi_flash.c +11 -9
@@ -3,7 +3,7 @@* * Enter bugs at http://blackfin.uclinux.org/ * -* Copyright (c) 2005-2007 Analog Devices Inc. +* Copyright (c) 2005-2008 Analog Devices Inc. * * Licensed under the GPL-2 or later. */
@@ -163,7 +163,9 @@ static struct manufacturer_info flash_manufacturers[] = {#define TIMEOUT 5000/* timeout of 5 seconds */ -/* BF54x support */ +/* If part has multiple SPI flashes, assume SPI0 as that is +* the one we can boot off of ... +*/ #ifndef pSPI_CTL# define pSPI_CTL pSPI0_CTL# define pSPI_BAUD pSPI0_BAUD
@@ -171,19 +173,16 @@ static struct manufacturer_info flash_manufacturers[] = {# define pSPI_RDBR pSPI0_RDBR# define pSPI_STAT pSPI0_STAT# define pSPI_TDBR pSPI0_TDBR -# define SPI0_SCK 0x0001 -# define SPI0_MOSI 0x0004 -# define SPI0_MISO 0x0002 -# define SPI0_SEL1 0x0010#endif /* Default to the SPI SSEL that we boot off of: * BF54x, BF537, (everything new?): SSEL1 -* BF533, BF561: SSEL2 +* BF51x, BF533, BF561: SSEL2 */ #ifndef CONFIG_SPI_FLASH_SSEL # if defined(__ADSPBF531__) || defined(__ADSPBF532__) || defined(__ADSPBF533__) || \ - defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__) + defined(__ADSPBF538__) || defined(__ADSPBF539__) || defined(__ADSPBF561__) || \ + defined(__ADSPBF51x__)# define CONFIG_SPI_FLASH_SSEL 2# else # define CONFIG_SPI_FLASH_SSEL 1
@@ -200,12 +199,15 @@ static void SPI_INIT(void)/* enable SPI pins: SSEL, MOSI, MISO, SCK */ #ifdef __ADSPBF54x__ - *pPORTE_FER |= (SPI0_SCK |SPI0_MOSI |SPI0_MISO |SPI0_SEL1 ); + *pPORTE_FER |= (PE0 |PE1 |PE2 |PE4 );#elif defined(__ADSPBF534__) || defined(__ADSPBF536__) || defined(__ADSPBF537__) *pPORTF_FER |= (PF10 |PF11 |PF12 |PF13 );#elif defined(__ADSPBF52x__)bfin_write_PORTG_MUX ((bfin_read_PORTG_MUX () & ~PORT_x_MUX_0_MASK) | PORT_x_MUX_0_FUNC_3);bfin_write_PORTG_FER (bfin_read_PORTG_FER () |PG1 |PG2 |PG3 |PG4 ); +#elif defined(__ADSPBF51x__) +bfin_write_PORTG_MUX ((bfin_read_PORTG_MUX () & ~PORT_x_MUX_7_MASK) | PORT_x_MUX_7_FUNC_1); +bfin_write_PORTG_FER (bfin_read_PORTG_FER () |PG12 |PG13 |PG14 |PG15 );#endif /* initate communication upon write of TDBR */
Signature · 1 line
1.6.1.1
PATCH 27/27 Blackfin: add driver for on-chip MMC/SD controller
In reply to Mike FrysingerFrom: Cliff Cai <[email protected]>
This is a port of the Linux Blackfin on-chip SDH driver to U-Boot.
--- drivers/mmc/Makefile | 1 + drivers/mmc/bfin_sdh.c | 546 +++++++++++++++++++++++++++ drivers/mmc/bfin_sdh.h | 59 +++ include/asm-blackfin/mach-common/bits/sdh.h | 122 ++++++ include/asm-blackfin/mmc.h | 1 + 5 files changed, 729 insertions(+), 0 deletions(-) create mode 100644 drivers/mmc/bfin_sdh.c create mode 100644 drivers/mmc/bfin_sdh.h create mode 100644 include/asm-blackfin/mach-common/bits/sdh.h create mode 100644 include/asm-blackfin/mmc.h
drivers/mmc/Makefile +1 -0
@@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libmmc.a COBJS-$(CONFIG_ATMEL_MCI) += atmel_mci.o +COBJS-$(CONFIG_BFIN_SDH) += bfin_sdh.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c)
drivers/mmc/bfin_sdh.c new file +546 -0
546 lines not on this page · raw message
drivers/mmc/bfin_sdh.h new file +59 -0
59 lines not on this page · raw message
include/asm-blackfin/mach-common/bits/sdh.h new file +122 -0
122 lines not on this page · raw message
include/asm-blackfin/mmc.h new file +1 -0
@@ -0,0 +1 @@ +#include <asm-avr32/arch-at32ap700x/mmc.h>
Signature · 1 line
1.6.1.1