[U-Boot] Subject: [U-BOOT] [PATCH] In stmicro_erase() correctly calculate the high byte of the sector address.
In stmicro_erase() correctly calculate the high byte of the sector address. Signed-off-by: Gary Jennejohn ga...@denx.de --- drivers/mtd/spi/stmicro.c |8 +++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/spi/stmicro.c b/drivers/mtd/spi/stmicro.c index 9b910c1..b5808c5 100644 --- a/drivers/mtd/spi/stmicro.c +++ b/drivers/mtd/spi/stmicro.c @@ -281,7 +281,13 @@ int stmicro_erase(struct spi_flash *flash, u32 offset, size_t len) ret = 0; for (actual = 0; actual len; actual++) { - cmd[1] = (offset / sector_size) + actual; + /* +* Correctly calculate the high byte of the address. +* +* Note that the new code basically does what the +* Linux driver does. +*/ + cmd[1] = ((offset + actual * sector_size) 16) 0xff; ret = spi_flash_cmd(flash-spi, CMD_M25PXX_WREN, NULL, 0); if (ret 0) { -- 1.6.2.5 --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH-ARM] CONFIG_SYS_HZ fix for ARM902T S3C24X0 Boards
1562500 +#define CONFIG_SYS_HZ 1000 /* valid baudrates */ #define CONFIG_SYS_BAUDRATE_TABLE{ 9600, 19200, 38400, 57600, 115200 } diff --git a/include/configs/smdk2410.h b/include/configs/smdk2410.h index d340098..c57751b 100644 --- a/include/configs/smdk2410.h +++ b/include/configs/smdk2410.h @@ -124,9 +124,7 @@ #define CONFIG_SYS_LOAD_ADDR0x3300 /* default load address */ -/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */ -/* it to wrap 100 times (total 1562500) to get 1 sec. */ -#define CONFIG_SYS_HZ 1562500 +#define CONFIG_SYS_HZ 1000 /* valid baudrates */ #define CONFIG_SYS_BAUDRATE_TABLE{ 9600, 19200, 38400, 57600, 115200 } diff --git a/include/configs/trab.h b/include/configs/trab.h index 43c191b..97f30ce 100644 --- a/include/configs/trab.h +++ b/include/configs/trab.h @@ -320,17 +320,7 @@ #define CONFIG_SYS_LOAD_ADDR0x0CF0 /* default load address */ -#ifdef CONFIG_TRAB_50MHZ -/* the PWM TImer 4 uses a counter of 15625 for 10 ms, so we need */ -/* it to wrap 100 times (total 1562500) to get 1 sec. */ -/* this should _really_ be calculated !! */ -#define CONFIG_SYS_HZ 1562500 -#else -/* the PWM TImer 4 uses a counter of 10390 for 10 ms, so we need */ -/* it to wrap 100 times (total 1039000) to get 1 sec. */ -/* this should _really_ be calculated !! */ -#define CONFIG_SYS_HZ 1039000 -#endif +#define CONFIG_SYS_HZ 1000 /* valid baudrates */ #define CONFIG_SYS_BAUDRATE_TABLE{ 9600, 19200, 38400, 57600, 115200 } -- 1.6.0.6 I don't have any hardware to test this on, but I strongly suspect that your changes break get_tbclk() for SMDK2400 and TRAB. It looks like the correct fix would be to remove all the idef's and simply set tbclk = CONFIG_SYS_HZ for all boards in get_tbclk(). --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
On Mon, 08 Dec 2008 14:05:22 -0800 Ben Warren [EMAIL PROTECTED] wrote: Wolfgang Denk wrote: Dear Ben, In message [EMAIL PROTECTED] Gary Jennejohn wrote: This change is needed for mgcoge because it uses two ethernet drivers. Add a check for the presence of the PIGGY board on mgcoge. Without this board networking cannot work and the initialization must be aborted. Only allocate rtx once to prevent DPRAM exhaustion. Initialize ether_scc.c and the keymile-specific HDLC driver (to be added soon) in eth.c. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] Any comments on this? Best regards, Wolfgang Denk Looks like I pulled it into the 'next' branch and forgot to tell anyone :-( Do you want it in the current release? You told me :-) --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/4 v3] powerpc: keymile: Add a check for the PIGGY debug board
On Thu, 20 Nov 2008 09:58:39 +0100 Heiko Schocher [EMAIL PROTECTED] wrote: Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device. Signed-off-by: Heiko Schocher [EMAIL PROTECTED] --- changes since v2: - added comments from Ben Warren board/keymile/common/common.c | 20 ++-- board/keymile/common/common.h | 16 board/keymile/kmeter1/Makefile |6 -- board/keymile/kmeter1/kmeter1.c |7 ++- board/keymile/mgcoge/mgcoge.c | 10 +++--- board/keymile/mgsuvd/mgsuvd.c |8 ++-- include/configs/kmeter1.h |9 + include/configs/mgcoge.h| 10 ++ include/configs/mgsuvd.h|9 + 9 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 board/keymile/common/common.h diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index a4cf24c..cc30b36 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -22,10 +22,14 @@ */ #include common.h +#if defined(CONFIG_MGCOGE) #include mpc8260.h +#endif #include ioports.h #include malloc.h #include hush.h +#include net.h +#include asm/io.h #if defined(CONFIG_OF_BOARD_SETUP) defined(CONFIG_OF_LIBFDT) #include libfdt.h @@ -33,8 +37,6 @@ #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) #include i2c.h -#endif -#include asm/io.h extern int i2c_soft_read_pin (void); @@ -495,6 +497,7 @@ void i2c_init_board(void) #endif } #endif +#endif #if defined(CONFIG_OF_BOARD_SETUP) defined(CONFIG_OF_LIBFDT) int fdt_set_node_and_value (void *blob, @@ -521,3 +524,16 @@ int fdt_set_node_and_value (void *blob, return ret; } #endif + +int ethernet_present (void) +{ + return (in_8((u8 *)CONFIG_SYS_PIGGY_BASE + CONFIG_SYS_SLOT_ID_OFF) 0x80); +} + +int board_eth_init(bd_t *bis) +{ #ifdef CONFIG_KEYMILE_HDLC_ENET (void)keymile_hdlc_enet_initialize(bis); #endif + if (ethernet_present ()) { + return -1; + } + return 0; +} If it looked like this it would be perfect! --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
This change is needed for mgcoge because it uses two ethernet drivers. Add a check for the presence of the PIGGY board on mgcoge. Without this board networking cannot work and the initialization must be aborted. Only allocate rtx once to prevent DPRAM exhaustion. Initialize ether_scc.c and the keymile-specific HDLC driver (to be added soon) in eth.c. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- v3 - Rebased to HEAD ac524c0a0b130fd942e1c632719bd7d631cdb057 Remove call to ethernet_present() in sec_init() because it is now handled in board_eth_init() cpu/mpc8260/Makefile|8 +- cpu/mpc8260/cpu.c |3 ++ cpu/mpc8260/ether_scc.c | 50 +- include/netdev.h|1 + 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/cpu/mpc8260/Makefile b/cpu/mpc8260/Makefile index 80d7852..9f0c2dd 100644 --- a/cpu/mpc8260/Makefile +++ b/cpu/mpc8260/Makefile @@ -1,5 +1,5 @@ # -# (C) Copyright 2000-2006 +# (C) Copyright 2000-2008 # Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED] # # See file CREDITS for list of people who contributed to this @@ -27,9 +27,13 @@ LIB = $(obj)lib$(CPU).a START = start.o kgdb.o COBJS = traps.o serial_smc.o serial_scc.o cpu.o cpu_init.o speed.o \ - interrupts.o ether_scc.o ether_fcc.o i2c.o commproc.o \ + interrupts.o ether_fcc.o i2c.o commproc.o \ bedbug_603e.o pci.o spi.o +COBJS-$(CONFIG_ETHER_ON_SCC) = ether_scc.o + +COBJS += $(COBJS-y) + SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) START := $(addprefix $(obj),$(START)) diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c index b9e748a..f4beca5 100644 --- a/cpu/mpc8260/cpu.c +++ b/cpu/mpc8260/cpu.c @@ -326,5 +326,8 @@ int cpu_eth_init(bd_t *bis) #if defined(CONFIG_ETHER_ON_FCC) fec_initialize(bis); #endif +#if defined(CONFIG_ETHER_ON_SCC) + mpc82xx_scc_enet_initialize(bd); +#endif return 0; } diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c index c65f0e0..3671ef1 100644 --- a/cpu/mpc8260/ether_scc.c +++ b/cpu/mpc8260/ether_scc.c @@ -10,6 +10,12 @@ * Advent Networks, Inc. http://www.adventnetworks.com * Jay Monkman [EMAIL PROTECTED] * + * Modified so that it plays nicely when more than one ETHERNET interface + * is in use a la ether_fcc.c. + * (C) Copyright 2008 + * DENX Software Engineerin GmbH + * Gary Jennejohn [EMAIL PROTECTED] + * * See file CREDITS for list of people who contributed to this * project. * @@ -32,11 +38,14 @@ #include common.h #include asm/cpm_8260.h #include mpc8260.h +#include malloc.h #include net.h #include command.h #include config.h -#if defined(CONFIG_ETHER_ON_SCC) defined(CONFIG_CMD_NET) +#ifndef CONFIG_NET_MULTI +#error CONFIG_NET_MULTI must be defined. +#endif #if (CONFIG_ETHER_INDEX == 1) # define PROFF_ENETPROFF_SCC1 @@ -100,7 +109,7 @@ typedef volatile struct CommonBufferDescriptor { static RTXBD *rtx; -int eth_send(volatile void *packet, int length) +static int sec_send(struct eth_device *dev, volatile void *packet, int length) { int i; int result = 0; @@ -137,7 +146,7 @@ int eth_send(volatile void *packet, int length) } -int eth_rx(void) +static int sec_rx(struct eth_device *dev) { int length; @@ -184,7 +193,7 @@ int eth_rx(void) * */ -int eth_init(bd_t *bis) +static int sec_init(struct eth_device *dev, bd_t *bis) { int i; volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; @@ -194,9 +203,14 @@ int eth_init(bd_t *bis) rxIdx = 0; txIdx = 0; -/* assign static pointer to BD area */ -dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16); -rtx = (RTXBD *)immr-im_dprambase[dpaddr]; +/* + * Assign static pointer to BD area. + * Avoid exhausting DPRAM, which would cause a panic. + */ +if (rtx == NULL) { + dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16); + rtx = (RTXBD *)immr-im_dprambase[dpaddr]; +} /* 24.21 - (1-3): ioports have been set up already */ @@ -338,7 +352,7 @@ int eth_init(bd_t *bis) } -void eth_halt(void) +static void sec_halt(struct eth_device *dev) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; immr-im_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl = ~(SCC_GSMRL_ENR | @@ -346,7 +360,7 @@ void eth_halt(void) } #if 0 -void restart(void) +static void sec_restart(void) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; immr-im_cpm.cp_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl |= (SCC_GSMRL_ENR | @@ -354,4 +368,20 @@ void restart(void) } #endif -#endif +int mpc82xx_scc_enet_initialize(bd_t *bis) +{ + struct eth_device *dev; + + dev = (struct eth_device *) malloc(sizeof *dev); + memset(dev, 0, sizeof *dev); + + sprintf(dev-name, SCC ETHERNET); + dev-init = sec_init; + dev-halt
Re: [U-Boot] [PATCH 4/5] powerpc: keymile: Add a check for the PIGGY debug board
On Thu, 13 Nov 2008 09:30:51 -0800 Ben Warren [EMAIL PROTECTED] wrote: Heiko Schocher wrote: Hello Ben Ben Warren wrote: Heiko Schocher wrote: Check the presence of the PIGGY on the keymile boards mgcoge, mgsuvd and kmeter1. If the PIGGY is not present, dont register this Ethernet device. Signed-off-by: Heiko Schocher [EMAIL PROTECTED] --- This looks like useful stuff to have, but I'd prefer that you put the check logic in board_eth_init() rather than adding to the individual device drivers. I know the 8260 SCC driver is the older style, which precludes the use of board_eth_init, but I'll convert it if you're able to test. Unfortunately, this approach won't work. First of all, the 82xx SCC driver is now initialized in cpu_eth_init(), which knows nothing about board-specific peculiarities like the PIGGY. Secondly, the HDLC driver for Keymile has to be initialized in board_eth_init(), and it has nothing to do with the PIGGY. Putting the check in board_eth_init() would break it completely. I looked at Heiko's latest patch and couldn't figure out a way to cleanly differentiate between initializing the HDLC driver and checking whether the PIGGY was present fo the other ENET drivers. Yes, I could test such a change for you, but hmm... I am not sure, if board_eth_init () is the right place for my purpose. I need for every Ethernet device a selection, if this device is present or not. Correct me if I am wrong, but it looks like board_eth_init () is not made for this purpose. (Ok, I can do a specific device init in board_eth_init (), but then we must do something, that prevents that the device is again initialized in eth_initialize () ... board_eth_init() was introduced for exactly this sort of thing. Have a look at the net repo (I've sent a pull request to Wolfgang so the current changes will make it into the 12.2008 release). There aren't any device initializations left in eth_initialize(), so there's no issue of a device being initialized twice. The goal is for all devices to be started by cpu_eth_int() or board_eth_init(). Hmm... while writing this it comes a idea in my mind: we could move all the *_initialize functions in eth_initialize () in a seperate function, say eth_hardware_init() and maybe making this function weak, so a board writer can write his own eth_hardware_init() ... in such a function, I could check which device is present, and only initialize the present devices ... what do you think? That's what board_eth_init() and cpu_eth_init() are for. In addition, I forgot to mention that a couple of days ago Gary Jennejohn submitted a patch for changing the 82xx SCC driver over to CONFIG_NET_MULTI style. Correct, and it must explicitly call ethernet_present() - see above. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
This change is needed for mgcoge because it uses two ethernet drivers. Add a check for the presence of the PIGGY board on mgcoge. Without this board networking cannot work and the initialization must be aborted. Only allocate rtx once to prevent DPRAM exhaustion. Initialize ether_scc.c and the keymile-specific HDLC driver (to be added soon) in eth.c. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- I ran MAKEALL ppc and no errors were caused by this patch. v2 - handle comments from Ben Warren 1) set local routines in ether_scc.c static; renamed sec_initialize() to mpc82xx_scc_enet_initialize(); eliminated the dependency on CONFIG_ETHER_ON_SCC and CONFIG_CMD_NET 2) made compilation of ether_scc.c conditional on CONFIG_ETHER_ON_SCC in cpu/mpc8260/Makefile 3) moved the initialization of ether_scc.c from net/eth.c to cpu/mpc8260/cpu.c 4) added mpc82xx_scc_enet_initialize() to include/netdev.h 5) Changes to net/eth.c are no longer required and this part of the old patch has now disappeared cpu/mpc8260/Makefile|8 +- cpu/mpc8260/cpu.c | 11 - cpu/mpc8260/ether_scc.c | 58 ++ include/netdev.h|1 + 4 files changed, 65 insertions(+), 13 deletions(-) diff --git a/cpu/mpc8260/Makefile b/cpu/mpc8260/Makefile index 80d7852..9f0c2dd 100644 --- a/cpu/mpc8260/Makefile +++ b/cpu/mpc8260/Makefile @@ -1,5 +1,5 @@ # -# (C) Copyright 2000-2006 +# (C) Copyright 2000-2008 # Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED] # # See file CREDITS for list of people who contributed to this @@ -27,9 +27,13 @@ LIB = $(obj)lib$(CPU).a START = start.o kgdb.o COBJS = traps.o serial_smc.o serial_scc.o cpu.o cpu_init.o speed.o \ - interrupts.o ether_scc.o ether_fcc.o i2c.o commproc.o \ + interrupts.o ether_fcc.o i2c.o commproc.o \ bedbug_603e.o pci.o spi.o +COBJS-$(CONFIG_ETHER_ON_SCC) = ether_scc.o + +COBJS += $(COBJS-y) + SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) START := $(addprefix $(obj),$(START)) diff --git a/cpu/mpc8260/cpu.c b/cpu/mpc8260/cpu.c index 9f834d3..f9b9bed 100644 --- a/cpu/mpc8260/cpu.c +++ b/cpu/mpc8260/cpu.c @@ -1,5 +1,5 @@ /* - * (C) Copyright 2000-2006 + * (C) Copyright 2000-2008 * Wolfgang Denk, DENX Software Engineering, [EMAIL PROTECTED] * * See file CREDITS for list of people who contributed to this @@ -44,6 +44,7 @@ #include watchdog.h #include command.h #include mpc8260.h +#include netdev.h #include asm/processor.h #include asm/cpm_8260.h @@ -315,3 +316,11 @@ void ft_cpu_setup (void *blob, bd_t *bd) do_fixup_by_path_u32(blob, cpu_path, clock-frequency, bd-bi_intfreq, 1); } #endif /* CONFIG_OF_LIBFDT */ + +/* - */ +#if defined(CONFIG_ETHER_ON_SCC) +int cpu_eth_init(bd_t *bd) +{ + return mpc82xx_scc_enet_initialize(bd); +} +#endif /* CONFIG_ETHER_ON_SCC */ diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c index c65f0e0..8e8e6bb 100644 --- a/cpu/mpc8260/ether_scc.c +++ b/cpu/mpc8260/ether_scc.c @@ -10,6 +10,12 @@ * Advent Networks, Inc. http://www.adventnetworks.com * Jay Monkman [EMAIL PROTECTED] * + * Modified so that it plays nicely when more than one ETHERNET interface + * is in use a la ether_fcc.c. + * (C) Copyright 2008 + * DENX Software Engineerin GmbH + * Gary Jennejohn [EMAIL PROTECTED] + * * See file CREDITS for list of people who contributed to this * project. * @@ -32,11 +38,14 @@ #include common.h #include asm/cpm_8260.h #include mpc8260.h +#include malloc.h #include net.h #include command.h #include config.h -#if defined(CONFIG_ETHER_ON_SCC) defined(CONFIG_CMD_NET) +#ifndef CONFIG_NET_MULTI +#error CONFIG_NET_MULTI must be defined. +#endif #if (CONFIG_ETHER_INDEX == 1) # define PROFF_ENETPROFF_SCC1 @@ -100,7 +109,7 @@ typedef volatile struct CommonBufferDescriptor { static RTXBD *rtx; -int eth_send(volatile void *packet, int length) +static int sec_send(struct eth_device *dev, volatile void *packet, int length) { int i; int result = 0; @@ -137,7 +146,7 @@ int eth_send(volatile void *packet, int length) } -int eth_rx(void) +static int sec_rx(struct eth_device *dev) { int length; @@ -184,19 +193,32 @@ int eth_rx(void) * */ -int eth_init(bd_t *bis) +static int sec_init(struct eth_device *dev, bd_t *bis) { int i; volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; scc_enet_t *pram_ptr; uint dpaddr; +#if defined(CONFIG_CHECK_ETHERNET_PRESENT) + if (ethernet_present(CONFIG_ETHER_INDEX) == 0) { + printf(Ethernet index: %d not present.\n, + CONFIG_ETHER_INDEX); + return -1; + } +#endif + rxIdx = 0; txIdx = 0
Re: [U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
Hi Ben, Ben Warren [EMAIL PROTECTED] wrote: Gary Jennejohn wrote: [snip] #if defined(CONFIG_ETHER_ON_SCC) defined(CONFIG_CMD_NET) While you're mucking around with this file, please settle on a single CONFIG that can allow conditional compilation from the Makefile, then get rid of this stuff. You mean get rid of CONFIG_ETHER_ON_SCC and CONFIG_CMD_NET? But isn't at least CONFIG_CMD_NET required to get networking support in other parts of U-Boot, which would make it a prerequisite for compiling this? And eliminating or supplementing CONFIG_ETHER_ON_SCC with a new CONFIG would mean changing a whole slew of configuration files, not to mention include/net.h. -int eth_send(volatile void *packet, int length) +int sec_send(struct eth_device *dev, volatile void *packet, int length) Please give all these functions, except initialize(), file scope (i.e. make them static). I'm not crazy about the name 'sec', but if it's static the objection doesn't carry much weight. I also can't think of a better name. Yeah, I should have thought of this when I did the mods. [snip] +int sec_initialize(bd_t *bis) For this function with global namespace, please pick a more descriptive name. Maybe 82xx_scc_initialize() or something? I called it 82xx_scc_enet_initialize() to make its function clear. --- a/net/eth.c +++ b/net/eth.c @@ -48,6 +48,8 @@ extern int ppc_4xx_eth_initialize(bd_t *); extern int scc_initialize(bd_t*); extern int npe_initialize(bd_t *); extern int uec_initialize(int); +extern int sec_initialize(bd_t *); +extern int keymile_hdlc_enet_initialize(bd_t *); #ifdef CONFIG_API extern void (*push_packet)(volatile void *, int); @@ -196,6 +198,12 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_IXP4XX_NPE) npe_initialize(bis); #endif +#if defined(CONFIG_ETHER_ON_SCC) defined(CONFIG_MPC8260) + sec_initialize(bis); +#endif +#if defined(CONFIG_KEYMILE_HDLC_ENET) + keymile_hdlc_enet_initialize(bis); +#endif if (!eth_devices) { puts (No ethernet found.\n); show_boot_progress (-64); Please don't add anything to this file. All initializations now go in cpu_eth_init()/board_eth_init(). There are plenty of examples you can draw from. Don't forget to add your initializer function to include/netdev.h OK, that should be easy enough. I've now done it for keymile. You get bonus points if you move this driver to drivers/net I'll look into it but make no promises. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] RFC - How to speed up multiplexed input between serial and network?
On Wed, 29 Oct 2008 13:14:52 +0100 Wolfgang Denk [EMAIL PROTECTED] wrote: [big snip details of analysis] My suggestion is to make the multiplexing more intelligent instead of making the serial driver more complex. The nice thing with this is that you probably still get the same results (actually even better ones as the artificial 128 byte line lengt limit can be avoided), and the changes are only in the new code, i. e. users who do not need such I/O multiplexing will not be affected. I think it should be fairly simple to implement something similar to the VTIME feature for non-canonical reads in the Unix serial drivers (see man tcsetattr): - In idle mode, all configured input devices are polled in a round-robin manner (as it is done now). - As soon as a character is received on the serial line, a timestamp is taken. As you calculated, one character at 115 kbps takes about 100 us on the wire. Within a window of (for exmaple) 500 us (or about 5 character times) now polling of all other I/O ports will be skipped. I took a quick look at this idea, but I didn't try to implement all the fancy timestamp stuff, etc. Basically, I kept the pointer to the last device which had input and checked it first in tstc(). My testing was done on a sequoia at a baudrate of 115200. The sequoia is a fast board. Testing was done with combinations of stdin and stdout devices (serial and nc). I observed no performance improvements. I then looked more closely at the results of a rather simple case - stdin=serial and stdout=serial,nc. In this case the change mentioned above would have no effect since ther is only one stdin device. Doing a paste of an 80 character line resulted in 90% loss of input. With stdin=stdout=serial cutpaste worked with no character loss. The obvious conclusion is that the _output_ to nc was so slow that it caused the character loss. Thus, efforts to try to optimize the input at high baudrates in the multiplexing code itself it will not help due to the slow output. The suggestion to lower the baudrate seems like the most intelligent solution. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] mgsuvd add the board-specific part of the HDLC driver
Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- board/keymile/mgsuvd/Makefile |3 +- board/keymile/mgsuvd/mgsuvd_hdlc_enet.c | 278 +++ 2 files changed, 280 insertions(+), 1 deletions(-) create mode 100644 board/keymile/mgsuvd/mgsuvd_hdlc_enet.c diff --git a/board/keymile/mgsuvd/Makefile b/board/keymile/mgsuvd/Makefile index b2145f9..2c5732d 100644 --- a/board/keymile/mgsuvd/Makefile +++ b/board/keymile/mgsuvd/Makefile @@ -28,7 +28,8 @@ endif LIB= $(obj)lib$(BOARD).a -COBJS = $(BOARD).o ../common/common.o +COBJS = $(BOARD).o ../common/common.o ../common/keymile_hdlc_enet.o \ + mgsuvd_hdlc_enet.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/keymile/mgsuvd/mgsuvd_hdlc_enet.c b/board/keymile/mgsuvd/mgsuvd_hdlc_enet.c new file mode 100644 index 000..9b93131 --- /dev/null +++ b/board/keymile/mgsuvd/mgsuvd_hdlc_enet.c @@ -0,0 +1,278 @@ +/* + * (C) Copyright 2008 + * Gary Jennejohn, DENX Software Engineering GmbH, [EMAIL PROTECTED] + * + * Based in part on cpu/mpc8xx/scc.c. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h/* commproc.h is included here */ +#include malloc.h +#include net.h + +#ifdef CONFIG_KEYMILE_HDLC_ENET + +#include ../common/keymile_hdlc_enet.h + +char keymile_slot; /* our slot number in the backplane */ + +/* + * Since, except during initialization, ethact is always HDLC ETHERNET + * while we're in the driver, just use serial_printf() everywhere for + * output. This avoids possible conflicts when netconsole is being + * used. + */ +#define dprintf(fmt, args...) serial_printf(fmt, ##args) + +static int already_inited; + +/* + * SCC Ethernet Tx and Rx buffer descriptors allocated at the + * immr-udata_bd address on Dual-Port RAM + * Provide for Double Buffering + */ +typedef volatile struct CommonBufferDescriptor { +cbd_t txbd;/* Tx BD */ +cbd_t rxbd[HDLC_PKTBUFSRX];/* Rx BD */ +} RTXBD; + +static RTXBD *rtx; + +int keymile_hdlc_enet_init(struct eth_device *, bd_t *); +void keymile_hdlc_enet_halt(struct eth_device *); +extern void keymile_hdlc_enet_init_bds(RTXBD *); +extern void initCachedNumbers(int); + +/* Use SCC4 */ +#define MGS_CPM_CR_HDLCCPM_CR_CH_SCC4 +#define MGS_PROFF_HDLC PROFF_SCC4 +#define MGS_SCC_HDLC 3 /* Index, not number! */ + +int keymile_hdlc_enet_init(struct eth_device *dev, bd_t *bis) +{ + /* int i; */ + /* volatile cbd_t *bdp; */ + volatile cpm8xx_t *cp; + volatile scc_t *sccp; + volatile hdlc_pram_t *hpr; + volatile iop8xx_t *iop; + + if (already_inited) + return 0; + + cp = (cpm8xx_t *)(((volatile immap_t *)CONFIG_SYS_IMMR)-im_cpm); + hpr = (hdlc_pram_t *)(cp-cp_dparam[MGS_PROFF_HDLC]); + sccp = (volatile scc_t *)(cp-cp_scc[MGS_SCC_HDLC]); + iop = (iop8xx_t *)(((volatile immap_t *)CONFIG_SYS_IMMR)-im_ioport); + + /* +* Disable receive and transmit just in case. +*/ + sccp-scc_gsmrl = ~(SCC_GSMRL_ENR | SCC_GSMRL_ENT); + +#ifndef CONFIG_SYS_ALLOC_DPRAM +#error CONFIG_SYS_ALLOC_DPRAM must be defined +#else + /* +* Avoid exhausting DPRAM, which would cause a panic. +* Actually this isn't really necessary, but leave it here +* for safety's sake. +*/ + if (rtx == NULL) { + rtx = (RTXBD *) (cp-cp_dpmem + +dpram_alloc_align(sizeof(RTXBD), 8)); + if (rtx == (RTXBD *)CPM_DP_NOSPACE) + return -1; + memset((void *)rtx, 0, sizeof(RTXBD)); + } +#endif /* !CONFIG_SYS_ALLOC_DPRAM */ + + /* We need the slot number for addressing. */ + keymile_slot = *(char *)(CONFIG_SYS_SLOT_ID_BASE + + CONFIG_SYS_SLOT_ID_OFF) CONFIG_SYS_SLOT_ID_MASK; + /* +* Be consistent with the Linux driver and set +* only enetaddr[0]. +* +* Always add 1 to the slot number so that +* there are no problems with an ethaddr which +* is all 0s. This should be acceptable because +* a board should never have
[U-Boot] [PATCH] keymile add the common parts of the HDLC driver
This implements the ICN protocol used across the backplane and is needed by all the keymile boards. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- checkpatch.pl reports an ERROR which is false. board/keymile/common/keymile_hdlc_enet.c | 620 ++ board/keymile/common/keymile_hdlc_enet.h | 129 ++ 2 files changed, 749 insertions(+), 0 deletions(-) create mode 100644 board/keymile/common/keymile_hdlc_enet.c create mode 100644 board/keymile/common/keymile_hdlc_enet.h diff --git a/board/keymile/common/keymile_hdlc_enet.c b/board/keymile/common/keymile_hdlc_enet.c new file mode 100644 index 000..141371b --- /dev/null +++ b/board/keymile/common/keymile_hdlc_enet.c @@ -0,0 +1,620 @@ +/* + * (C) Copyright 2008 + * Gary Jennejohn, DENX Software Engineering GmbH, [EMAIL PROTECTED] + * + * Based in part on cpu/mpc8260/ether_scc.c. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include common.h +#include malloc.h +#include net.h + +#ifdef CONFIG_KEYMILE_HDLC_ENET +#ifdef TEST_IT +#include command.h +#endif + +#include keymile_hdlc_enet.h + +extern char keymile_slot; /* our slot number in the backplane */ + +/* Allow up to about 50 ms for sending */ +#define TOUT_LOOP 5 + +/* + * Since, except during initialization, ethact is always HDLC ETHERNET + * while we're in the driver, just use serial_printf() everywhere for + * output. This avoids possible conflicts when netconsole is being + * used. + */ +#define dprintf(fmt, args...) serial_printf(fmt, ##args) + +/* Cannot use the storage from net.c because we allocate larger buffers */ +static volatile uchar MyPktBuf[HDLC_PKTBUFSRX * PKT_MAXBLR_SIZE + PKTALIGN]; +static volatile uchar *MyRxPackets[HDLC_PKTBUFSRX]; /* Receive packet */ + +static unsigned int keymile_rxIdx; /* index of the current RX buffer */ + +static IPaddr_t cachedNumbers[CACHEDNUMBERS]; /* 4 bytes per entry */ +void initCachedNumbers(int); + +/* + * SCC Ethernet Tx and Rx buffer descriptors allocated at the + * immr-udata_bd address on Dual-Port RAM + * Provide for Double Buffering + */ +typedef volatile struct CommonBufferDescriptor { +cbd_t txbd;/* Tx BD */ +cbd_t rxbd[HDLC_PKTBUFSRX];/* Rx BD */ +} RTXBD; + +/* + * This must be extern because it is allocated in DPRAM using CPM-sepcific + * code. + */ +static RTXBD *rtx; + +static int keymile_hdlc_enet_send(struct eth_device *, volatile void *, int); +static int keymile_hdlc_enet_recv(struct eth_device *); +void keymile_hdlc_enet_init_bds(RTXBD *); +extern int keymile_hdlc_enet_init(struct eth_device *, bd_t *); +extern void keymile_hdlc_enet_halt(struct eth_device *); + +/* flags in the buffer descriptor not defined anywhere else */ +#define BD_SC_CT BD_SC_CD +#define BD_SC_CR 0x04 +#define BD_SC_DE 0x80 +#ifndef BD_SC_TC +#define BD_SC_TC ((ushort)0x0400)/* Transmit CRC */ +#endif +#define BD_SC_FIRSTBD_SC_TC +#define BD_SC_STATS (BD_SC_BR | BD_SC_FR | BD_SC_PR | BD_SC_CR | BD_SC_CD \ + | BD_SC_OV | BD_SC_DE) + +#if defined(TEST_RX) || defined(TEST_TX) || defined(TEST_IT) +static void hexdump(unsigned char *buf, int len) +{ + int i; + const int bytesPerLine = 32; + + if (len 4 * bytesPerLine) + len = 4 * bytesPerLine; + dprintf(\t address: %08x\n, (unsigned int)buf); + for (i = 0; i len; i++) { + if (i % bytesPerLine == 0) + dprintf(%04x: , (unsigned short)i); + dprintf(%02x , buf[i]); + if ((i + 1) % bytesPerLine == 0) { + dprintf(\n); + continue; + } + if ((i + 1) % 8 == 0) + printf( ); + } + if (len % bytesPerLine) + dprintf(\n); +} +#endif + +int keymile_hdlc_enet_initialize(bd_t *bis) +{ + struct eth_device *dev; + + dev = (struct eth_device *) malloc(sizeof *dev); + memset(dev, 0, sizeof *dev); +#ifdef TEST_IT + seth = dev; +#endif + + sprintf(dev-name, HDLC ETHERNET); + dev-init = keymile_hdlc_enet_init; + dev-halt = keymile_hdlc_enet_halt
[U-Boot] [PATCH] mgcoge make ether_scc.c work with CONFIG_NET_MULTI
This change is needed for mgcoge because it uses two ethernet drivers. Add a check for the presence of the PIGGY board on mgcoge. Without this board networking cannot work and the initialization must be aborted. Only allocate rtx once to prevent DPRAM exhaustion. Initialize ether_scc.c and the keymile-specific HDLC driver (to be added soon) in eth.c. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- I ran MAKEALL ppc and no errors were caused by this patch. cpu/mpc8260/ether_scc.c | 56 +-- net/eth.c |8 ++ 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/cpu/mpc8260/ether_scc.c b/cpu/mpc8260/ether_scc.c index c65f0e0..537cd39 100644 --- a/cpu/mpc8260/ether_scc.c +++ b/cpu/mpc8260/ether_scc.c @@ -10,6 +10,12 @@ * Advent Networks, Inc. http://www.adventnetworks.com * Jay Monkman [EMAIL PROTECTED] * + * Modified so that it plays nicely when more than one ETHERNET interface + * is in use a la ether_fcc.c. + * (C) Copyright 2008 + * DENX Software Engineerin GmbH + * Gary Jennejohn [EMAIL PROTECTED] + * * See file CREDITS for list of people who contributed to this * project. * @@ -32,12 +38,17 @@ #include common.h #include asm/cpm_8260.h #include mpc8260.h +#include malloc.h #include net.h #include command.h #include config.h #if defined(CONFIG_ETHER_ON_SCC) defined(CONFIG_CMD_NET) +#ifndef CONFIG_NET_MULTI +#error CONFIG_NET_MULTI must be defined. +#endif + #if (CONFIG_ETHER_INDEX == 1) # define PROFF_ENETPROFF_SCC1 # define CPM_CR_ENET_PAGE CPM_CR_SCC1_PAGE @@ -100,7 +111,7 @@ typedef volatile struct CommonBufferDescriptor { static RTXBD *rtx; -int eth_send(volatile void *packet, int length) +int sec_send(struct eth_device *dev, volatile void *packet, int length) { int i; int result = 0; @@ -137,7 +148,7 @@ int eth_send(volatile void *packet, int length) } -int eth_rx(void) +int sec_rx(struct eth_device *dev) { int length; @@ -184,19 +195,32 @@ int eth_rx(void) * */ -int eth_init(bd_t *bis) +int sec_init(struct eth_device *dev, bd_t *bis) { int i; volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; scc_enet_t *pram_ptr; uint dpaddr; +#if defined(CONFIG_CHECK_ETHERNET_PRESENT) + if (ethernet_present (CONFIG_ETHER_INDEX) == 0) { + printf(Ethernet index: %d not present.\n, + CONFIG_ETHER_INDEX); + return -1; + } +#endif + rxIdx = 0; txIdx = 0; -/* assign static pointer to BD area */ -dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16); -rtx = (RTXBD *)immr-im_dprambase[dpaddr]; +/* + * Assign static pointer to BD area. + * Avoid exhausting DPRAM, which would cause a panic. + */ +if (rtx == NULL) { + dpaddr = m8260_cpm_dpalloc(sizeof(RTXBD) + 2, 16); + rtx = (RTXBD *)immr-im_dprambase[dpaddr]; +} /* 24.21 - (1-3): ioports have been set up already */ @@ -338,7 +362,7 @@ int eth_init(bd_t *bis) } -void eth_halt(void) +void sec_halt(struct eth_device *dev) { volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; immr-im_scc[CONFIG_ETHER_INDEX-1].scc_gsmrl = ~(SCC_GSMRL_ENR | @@ -354,4 +378,22 @@ void restart(void) } #endif +int sec_initialize(bd_t *bis) +{ + struct eth_device *dev; + + dev = (struct eth_device *) malloc(sizeof *dev); + memset(dev, 0, sizeof *dev); + + sprintf(dev-name, SCC ETHERNET); + dev-init = sec_init; + dev-halt = sec_halt; + dev-send = sec_send; + dev-recv = sec_rx; + + eth_register(dev); + + return 1; +} + #endif diff --git a/net/eth.c b/net/eth.c index ccd871a..5fe8b83 100644 --- a/net/eth.c +++ b/net/eth.c @@ -48,6 +48,8 @@ extern int ppc_4xx_eth_initialize(bd_t *); extern int scc_initialize(bd_t*); extern int npe_initialize(bd_t *); extern int uec_initialize(int); +extern int sec_initialize(bd_t *); +extern int keymile_hdlc_enet_initialize(bd_t *); #ifdef CONFIG_API extern void (*push_packet)(volatile void *, int); @@ -196,6 +198,12 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_IXP4XX_NPE) npe_initialize(bis); #endif +#if defined(CONFIG_ETHER_ON_SCC) defined(CONFIG_MPC8260) + sec_initialize(bis); +#endif +#if defined(CONFIG_KEYMILE_HDLC_ENET) + keymile_hdlc_enet_initialize(bis); +#endif if (!eth_devices) { puts (No ethernet found.\n); show_boot_progress (-64); -- 1.5.4.3 --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED
Re: [U-Boot] [PATCH 1/2 V3] IOMUX: Add console multiplexing support.
Modifications to support console multiplexing. This is controlled using CONFIG_SYS_CONSOLE_MUX in the board configuration file. This allows a user to specify multiple console devices in the environment with a command like this: setenv stdin serial,nc. As a result, the user can enter text on both the serial and netconsole interfaces. All devices - stdin, stdout and stderr - can be set in this manner. 1) common/iomux.c and include/iomux.h contain the environment setting implementation. 2) doc/README.iomux contains a somewhat more detailed description. 3) The implementation in (1) is called from common/cmd_nvedit.c to handle setenv and from common/console.c to handle initialization of input/output devices at boot time. 4) common/console.c also contains the code needed to poll multiple console devices for input and send output to all devices registered for output. 5) include/common.h includes iomux.h and common/Makefile generates iomux.o when CONFIG_SYS_CONSOLE_MUX is set. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- V3 - handle comments from the ML - iomux_doenv() now removes repeated device entries common/Makefile |1 + common/cmd_nvedit.c |6 ++ common/console.c| 156 +- common/iomux.c | 175 +++ doc/README.iomux| 106 +++ include/common.h|7 ++ include/iomux.h | 48 ++ 7 files changed, 498 insertions(+), 1 deletions(-) create mode 100644 common/iomux.c create mode 100644 doc/README.iomux create mode 100644 include/iomux.h diff --git a/common/Makefile b/common/Makefile index f00cbd9..b1d2297 100644 --- a/common/Makefile +++ b/common/Makefile @@ -149,6 +149,7 @@ COBJS-$(CONFIG_CMD_XIMG) += cmd_ximg.o COBJS-$(CONFIG_YAFFS2) += cmd_yaffs2.o COBJS-$(CONFIG_VFD) += cmd_vfd.o COBJS-$(CONFIG_CMD_DOC) += docecc.o +COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-y += kgdb.o COBJS-$(CONFIG_LCD) += lcd.o diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index d280cb0..85025da 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -213,6 +213,11 @@ int _do_setenv (int flag, int argc, char *argv[]) return 1; } +#ifdef CONFIG_CONSOLE_MUX + i = iomux_doenv(console, argv[2]); + if (i) + return i; +#else /* Try assigning specified device */ if (console_assign (console, argv[2]) 0) return 1; @@ -221,6 +226,7 @@ int _do_setenv (int flag, int argc, char *argv[]) if (serial_assign (argv[2]) 0) return 1; #endif +#endif /* CONFIG_CONSOLE_MUX */ } /* diff --git a/common/console.c b/common/console.c index 6f0846f..89aeab6 100644 --- a/common/console.c +++ b/common/console.c @@ -93,6 +93,76 @@ static int console_setfile (int file, device_t * dev) return error; } +#if defined(CONFIG_CONSOLE_MUX) +/** Console I/O multiplexing ***/ + +static device_t *tstcdev; +device_t **console_devices[MAX_FILES]; +int cd_count[MAX_FILES]; + +/* + * This depends on tstc() always being called before getc(). + * This is guaranteed to be true because this routine is called + * only from fgetc() which assures it. + * No attempt is made to demultiplex multiple input sources. + */ +static int iomux_getc(void) +{ + unsigned char ret; + + /* This is never called with testcdev == NULL */ + ret = tstcdev-getc(); + tstcdev = NULL; + return ret; +} + +static int iomux_tstc(int file) +{ + int i, ret; + device_t *dev; + + disable_ctrlc(1); + for (i = 0; i cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev-tstc != NULL) { + ret = dev-tstc(); + if (ret 0) { + tstcdev = dev; + disable_ctrlc(0); + return ret; + } + } + } + disable_ctrlc(0); + + return 0; +} + +static void iomux_putc(int file, const char c) +{ + int i; + device_t *dev; + + for (i = 0; i cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev-putc != NULL) + dev-putc(c); + } +} + +static void iomux_puts(int file, const char *s) +{ + int i; + device_t *dev; + + for (i = 0; i cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev-puts != NULL) + dev-puts(s); + } +} +#endif /* defined(CONFIG_CONSOLE_MUX) */ + /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS
Re: [U-Boot] [PATCH 1/2 V3] IOMUX: Add console multiplexing support.
On Thu, 6 Nov 2008 15:30:38 +0100 Jean-Christophe PLAGNIOL-VILLARD [EMAIL PROTECTED] wrote: On 15:04 Thu 06 Nov , Gary Jennejohn wrote: Modifications to support console multiplexing. This is controlled using CONFIG_SYS_CONSOLE_MUX in the board configuration file. This allows a user to specify multiple console devices in the environment with a command like this: setenv stdin serial,nc. As a result, the user can enter text on both the serial and netconsole interfaces. All devices - stdin, stdout and stderr - can be set in this manner. 1) common/iomux.c and include/iomux.h contain the environment setting implementation. 2) doc/README.iomux contains a somewhat more detailed description. 3) The implementation in (1) is called from common/cmd_nvedit.c to handle setenv and from common/console.c to handle initialization of input/output devices at boot time. 4) common/console.c also contains the code needed to poll multiple console devices for input and send output to all devices registered for output. 5) include/common.h includes iomux.h and common/Makefile generates iomux.o when CONFIG_SYS_CONSOLE_MUX is set. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- V3 - handle comments from the ML - iomux_doenv() now removes repeated device entries common/Makefile |1 + common/cmd_nvedit.c |6 ++ common/console.c| 156 +- common/iomux.c | 175 +++ doc/README.iomux| 106 +++ include/common.h|7 ++ include/iomux.h | 48 ++ 7 files changed, 498 insertions(+), 1 deletions(-) create mode 100644 common/iomux.c create mode 100644 doc/README.iomux create mode 100644 include/iomux.h you steel do not use list_head. You agree about the idea. is there any special reason? There are actually two a) I *did* look at using list_head, but I couldn't wrap my head around it in a reasonable length of time and it wasn't clear to me how to implement the functionality I wanted b) It was much easier for me to modify the code to what I needed using realloc since it was already using an array --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2 V2] IOMUX: Add console multiplexing support.
Modifications to support console multiplexing. This is controlled using CONFIG_SYS_CONSOLE_MUX in the board configuration file. This allows a user to specify multiple console devices in the environment with a command like this: setenv stdin serial,nc. As a result, the user can enter text on both the serial and netconsole interfaces. All devices - stdin, stdout and stderr - can be set in this manner. 1) common/iomux.c and include/iomux.h contain the environment setting implementation. 2) doc/README.iomux contains a somewhat more detailed description. 3) The implementation in (1) is called from common/cmd_nvedit.c to handle setenv and from common/console.c to handle initialization of input/output devices at boot time. 4) common/console.c also contains the code needed to poll multiple console devices for input and send output to all devices registered for output. 5) include/common.h includes iomux.h and common/Makefile generates iomux.o when CONFIG_SYS_CONSOLE_MUX is set. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- common/Makefile |1 + common/cmd_nvedit.c |6 ++ common/console.c| 162 common/iomux.c | 170 +++ doc/README.iomux| 89 +++ include/common.h|7 ++ include/iomux.h | 54 7 files changed, 489 insertions(+), 0 deletions(-) create mode 100644 common/iomux.c create mode 100644 doc/README.iomux create mode 100644 include/iomux.h diff --git a/common/Makefile b/common/Makefile index f00cbd9..0296a8a 100644 --- a/common/Makefile +++ b/common/Makefile @@ -156,6 +156,7 @@ COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_UPDATE_TFTP) += update.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o +COBJS-$(CONFIG_SYS_CONSOLE_MUX) += iomux.o COBJS := $(sort $(COBJS-y)) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index d280cb0..7a49296 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -213,6 +213,11 @@ int _do_setenv (int flag, int argc, char *argv[]) return 1; } +#ifdef CONFIG_SYS_CONSOLE_MUX + i = iomux_doenv(console, argv[2]); + if (i) + return i; +#else /* Try assigning specified device */ if (console_assign (console, argv[2]) 0) return 1; @@ -221,6 +226,7 @@ int _do_setenv (int flag, int argc, char *argv[]) if (serial_assign (argv[2]) 0) return 1; #endif +#endif /* CONFIG_SYS_CONSOLE_MUX */ } /* diff --git a/common/console.c b/common/console.c index 6f0846f..c89020d 100644 --- a/common/console.c +++ b/common/console.c @@ -93,6 +93,73 @@ static int console_setfile (int file, device_t * dev) return error; } +#if defined(CONFIG_SYS_CONSOLE_MUX) +/** Console I/O multiplexing ***/ + +static device_t *tstcdev; +device_t **console_devices[MAX_FILES]; +int cd_count[MAX_FILES]; + +/* + * This depends on tstc() always being called before getc(). + * No attempt is made to demultiplex multiple input sources. + */ +static int iomux_getc(void) +{ + unsigned char ret; + + ret = tstcdev-getc(); + tstcdev = NULL; + return ret; +} + +static int iomux_tstc(int file) +{ + int i, ret; + device_t *dev; + + disable_ctrlc(1); + for (i = 0; i cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev-tstc != NULL) { + ret = dev-tstc(); + if (ret 0) { + tstcdev = dev; + disable_ctrlc(0); + return ret; + } + } + } + disable_ctrlc(0); + + return 0; +} + +static void iomux_putc(int file, const char c) +{ + int i; + device_t *dev; + + for (i = 0; i cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev-putc != NULL) + dev-putc(c); + } +} + +static void iomux_puts(int file, const char *s) +{ + int i; + device_t *dev; + + for (i = 0; i cd_count[file]; i++) { + dev = console_devices[file][i]; + if (dev-puts != NULL) + dev-puts(s); + } +} +#endif /* defined(CONFIG_SYS_CONSOLE_MUX) */ + /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS */ void serial_printf (const char *fmt, ...) @@ -115,7 +182,41 @@ void serial_printf (const char *fmt, ...) int fgetc (int file) { if (file MAX_FILES) +#if defined(CONFIG_SYS_CONSOLE_MUX
[U-Boot] Missing definition of DIV_ROUND
From u-boot HEAD grabbed just a few minutes ago... garyj:tdt:u-boot:bash:1 ./MAKEALL ppc Configuring for cmi_mpc5xx board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' lib_generic/libgeneric.a(strmhz.o): In function `strmhz': /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:30: undefined reference to `DIV_ROUND' /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:34: undefined reference to `DIV_ROUND' make: *** [u-boot] Error 1 size: './u-boot': No such file Configuring for ads5121 board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' lib_generic/libgeneric.a(strmhz.o): In function `strmhz': /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:30: undefined reference to `DIV_ROUND' /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:34: undefined reference to `DIV_ROUND' make: *** [u-boot] Error 1 size: './u-boot': No such file Configuring for BC3450 board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' lib_generic/libgeneric.a(strmhz.o): In function `strmhz': /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:30: undefined reference to `DIV_ROUND' /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:34: undefined reference to `DIV_ROUND' make: *** [u-boot] Error 1 size: './u-boot': No such file Configuring for cm5200 board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' lib_generic/libgeneric.a(strmhz.o): In function `strmhz': /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:30: undefined reference to `DIV_ROUND' /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:34: undefined reference to `DIV_ROUND' make: *** [u-boot] Error 1 size: './u-boot': No such file Configuring for cpci5200 board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' Script done on Tue 28 Oct 2008 12:16:36 PM CET --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] Missing definition of DIV_ROUND
On Tue, 28 Oct 2008 17:55:49 +0100 Wolfgang Denk [EMAIL PROTECTED] wrote: Dear Wolfgang, In message [EMAIL PROTECTED] you wrote: From u-boot HEAD grabbed just a few minutes ago... Which commit ID is this where you see such behaviour? garyj:tdt:u-boot:bash:1 ./MAKEALL ppc Configuring for cmi_mpc5xx board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' lib_generic/libgeneric.a(strmhz.o): In function `strmhz': /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:30: undefined reference to `DIV_ROUND' /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:34: undefined reference to `DIV_ROUND' make: *** [u-boot] Error 1 size: './u-boot': No such file Configuring for ads5121 board... strmhz.c: In function 'strmhz': strmhz.c:30: warning: implicit declaration of function 'DIV_ROUND' lib_generic/libgeneric.a(strmhz.o): In function `strmhz': /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:30: undefined reference to `DIV_ROUND' /home/garyj/proj/junk/u-boot/lib_generic/strmhz.c:34: undefined reference to `DIV_ROUND' Hmm... for me, current head is: - git-describe v2008.10-121-gd35c451 - git-log commit d35c451d6cff3e77e40fbdfc7a2933cdcb86ae4b Merge: a369f4a... 6b59e03... Author: Wolfgang Denk [EMAIL PROTECTED] Date: Tue Oct 28 08:37:19 2008 +0100 Merge branch 'master' of git://git.denx.de/u-boot-video ... I have d35c451d6cff3e77e40fbdfc7a2933cdcb86ae4b, exactly the same as you. And garyj:tdt:u-boot:-bash:184 git branch -a * master origin/HEAD origin/i.MX31 origin/lwmon5 origin/master origin/next origin/origin origin/u-boot-next origin/[EMAIL PROTECTED] so I'm on the master branch. And this builds just fine: - JOBS=-j5 ./MAKEALL ppc Configuring for cmi_mpc5xx board... textdata bss dec hex filename 94312 711606756 172228 2a0c4 ./u-boot Configuring for ads5121 board... textdata bss dec hex filename 198296 35480 28584 262360 400d8 ./u-boot Configuring for BC3450 board... textdata bss dec hex filename 284504 29004 296336 609844 94e34 ./u-boot Configuring for cm5200 board... textdata bss dec hex filename 263448 17532 281344 562324 89494 ./u-boot ... You must be doing something wrong, it seems. Well, I also did MAKEALL ppc. I don't see how that could wrong. I'll just delete u-boot and grab a fresh copy. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] Missing definition of DIV_ROUND
On Tue, 28 Oct 2008 18:15:41 +0100 Gary Jennejohn [EMAIL PROTECTED] wrote: You must be doing something wrong, it seems. Well, I also did MAKEALL ppc. I don't see how that could wrong. I'll just delete u-boot and grab a fresh copy. Ah, now I see. I somehow managed to overwrite common.h with an old copy. Sorry for wasting bandwidth. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] IOMUX: Add console multiplexing support.
On Fri, 24 Oct 2008 13:18:42 +0200 Wolfgang Denk [EMAIL PROTECTED] wrote: Dear Wolfgang, In message [EMAIL PROTECTED] you wrote: On Sun, 14 Sep 2008 23:59:39 +0200 Jean-Christophe PLAGNIOL-VILLARD [EMAIL PROTECTED] wrote: +#if defined(CONFIG_IO_MUX) +/** Console I/O multiplexing ***/ + +static device_t *tstcdev; +device_t *console_devices[MAX_FILES][MAX_CONSARGS]; please use a list_head instead This is an excellent suggestion. Thanks! I understood that you would repost a new, modified patch which uses this suggestion, but I haven't seen any repost sice. You know that the merge window is open right now - do you plan to repost this stuff any time soon? I actually solved the problem by using realloc() rather than using a list_head. I've merged the console multiplexing stuff into HEAD but hesitate to post it because my previous patch (setting GD_FLG_DEVINIT) is still unresolved. But if the window is now open I'll post the new patch without resolution of the other one. However, this approach may well lead to an unusable U-Boot if the user wants to set nc as a console in the environment. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2 V2] IOMUX: Add console multiplexing support.
On Mon, 20 Oct 2008 13:13:32 -0700 Ben Warren [EMAIL PROTECTED] wrote: Wolfgang Denk wrote: Dear Gary Jennejohn, In message [EMAIL PROTECTED] you wrote: I looked at this some more. eth_initialize() is called in every architecture-specific library which means changing 8 files to move it up to before the initialization of netconsole. netconsole is intialized in devices_init() which is called even before console_init_r() and long before eth_initialize(). Well, maybe there is a less intrusive approach to solve the problem. One alrernative which occurs to me would be to introduce a new flag GD_FLG_ETHINIT, but this is even worse because it requires modifying 12 header files and 3 or more C files. Hm... let's sum up what exactly the problem is; you wrote: | This causes problems because u-boot will try to write to nc as soon | as GD_FLG_DEVINIT is set in gd-flags, which happens before the | network devices are initialized in net/eth.c. This results in error | messages being spewed out. I read this that what we actually want to do is stopping NC to transmit too early. Correct? Well, nc_send_packet() (see drivers/net/netconsole.c) can be easily shortcut if we find a way to make eth_get_dev() return NULL. And eth_get_dev() (see net/eth.c) just returns eth_current. So maybe there is a way to make sure eth_current is set to NULL until it's OK for netconsole to transmit? Maybe, maybe eventually the real cause of your problems is that eth_current is not read as NULL while running from flash? Maybe changing the declaration in net/eth.c into something like this would help? static struct eth_device *eth_current __attribute__ ((section(.data))) = NULL; What do you think? This looks like a good idea. eth_current is a variable that should definitely be in a known state. By the time the problem arises we're already running out of RAM. I think the real problem is that console_init_r() is called too early. If it were called *after* eth_initialize() then there would be no difficulties. AFAICT moving console_init_r() shouldn't present any problems, since until its invocation U-Boot will simply use the serial interface. I can't imagine that waiting a few milliseconds longer to switch to whatever console the user has set in the environment would present a problem. This has the following advantages a) nc has been initialized and can be used as a console, if so desired b) any hardware initializations, such as SPI or I2C, which may be required to initialize an ethernet device have already happened c) the ethernet device is already initialized and ready to go d) no need to split up setting gd-flags What do you think about this idea? It requires changing a lot of files but seems like the cleanest approach to me. It isn't clear to me whether the architecture-specific libs have custodians. Does anyone know? --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2 V2] IOMUX: Add console multiplexing support.
On Tue, 21 Oct 2008 12:34:30 +0200 Wolfgang Denk [EMAIL PROTECTED] wrote: In message [EMAIL PROTECTED] you wrote: By the time the problem arises we're already running out of RAM. So maybe you can describe exactly what happens, and when? I think the real problem is that console_init_r() is called too early. If it were called *after* eth_initialize() then there would be no difficulties. AFAICT moving console_init_r() shouldn't present any problems, since until its invocation U-Boot will simply use the serial interface. I am not so sure. Moving things around not as trivial as it may seem, as we have all kinds of configurations with LCD display, modem support etc. All console_init_r() does is to search for devices which can be used for STDIN/STDOUT/STDERR (whether in the environment or the device list), call console_setfile() and then print out the list of devices found. console_setfile() actually calls the device start routines. The actual registration of the devices happens in device_init() which is called before console_init_r(). So I see no reason why moving console_init_r() would have any effect. It isn't clear to me whether the architecture-specific libs have custodians. Does anyone know? What is not clear about that? Do we have custodians for architecture specific files? Yes, we do. So whay do you doubt that the libs fall into their responsibility, too? Did I write that I doubt anything? No. I just asked for some clarification because it wasn't clear to me from the very abbreviated descriptions on the Custodian page just exactly what is within the purview of a custodian. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2 V2] IOMUX: Add console multiplexing support.
On Mon, 20 Oct 2008 15:24:53 +0200 Wolfgang Denk [EMAIL PROTECTED] wrote: Dear Wolfgang Denk, Is there another part of the patch, part 1/2, too? Yes, but I did this part first because it's small and easily generated. Since it also affects net I wanted to get it to the custodian. The other part adds the console multiplexing and isn't directly related to this. Note this is V2 of the patch and the original version also depended on CONFIG_IO_MUX, which we decided in this ML wasn't really relevant. In message [EMAIL PROTECTED] you wrote: When both CONFIG_SYS_CONSOLE_IS_IN_ENV and CONFIG_NETCONSOLE are defined the user can have stdout set to nc (netconsole). This causes problems because u-boot will try to write to nc as soon as GD_FLG_DEVINIT is set in gd-flags, which happens before the network devices are initialized in net/eth.c. This results in error messages being spewed out. It seems this can happen only if CONFIG_SYS_CONSOLE_IS_IN_ENV is defined, right? Correct, as I stated in the comment. Note that it isn't evident in the patch, but the console_init_r() which I changed is #ifdef CONFIG_SYS_CONSOLE_IS_IN_ENV (there's another version in the #else-branch which isn't). To prevent this problem set GD_FLG_DEVINIT in net/eth.c:eth_initialize(), after the network devices have been initialized, instead of in common/console.c:console_init_r(). I have to admit that I don't like the idea of splitting the GD_FLG_DEVINIT into several, unrelated parts of the code. I don't like it too much myself, but it seemed like the logical approach to me at the time I made this modification. Would it not make more sense to have the netconsole part wait with output until it's been initialized? And/or move the netweork init to an earlier point, when netconsole is enabled? Not a bad idea. I think it would be most logical to do it in the netconsole code, rather than moving up the network initialization. I'll take a look at that. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2 V2] IOMUX: Add console multiplexing support.
On Mon, 20 Oct 2008 15:57:32 +0200 Gary Jennejohn [EMAIL PROTECTED] wrote: On Mon, 20 Oct 2008 15:24:53 +0200 Wolfgang Denk [EMAIL PROTECTED] wrote: I have to admit that I don't like the idea of splitting the GD_FLG_DEVINIT into several, unrelated parts of the code. I don't like it too much myself, but it seemed like the logical approach to me at the time I made this modification. Would it not make more sense to have the netconsole part wait with output until it's been initialized? And/or move the netweork init to an earlier point, when netconsole is enabled? Not a bad idea. I think it would be most logical to do it in the netconsole code, rather than moving up the network initialization. I'll take a look at that. I looked at this some more. eth_initialize() is called in every architecture-specific library which means changing 8 files to move it up to before the initialization of netconsole. netconsole is intialized in devices_init() which is called even before console_init_r() and long before eth_initialize(). What's the opinion of the ML? Is it worth all the repository churn to move eth_initialize() up rather than changing just two files? One alrernative which occurs to me would be to introduce a new flag GD_FLG_ETHINIT, but this is even worse because it requires modifying 12 header files and 3 or more C files. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2] 8xx: prevent a machine check in scc_init().
Without this change DPRAM can be exhausted when CFG_ALLOC_DPRAM is defined, which eventually leads to a machine check. This change assures that DPRAM is allocated only once in that case. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- cpu/mpc8xx/scc.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/cpu/mpc8xx/scc.c b/cpu/mpc8xx/scc.c index 09a3db1..d91289a 100644 --- a/cpu/mpc8xx/scc.c +++ b/cpu/mpc8xx/scc.c @@ -216,7 +216,9 @@ static int scc_init (struct eth_device *dev, bd_t * bis) txIdx = 0; #ifdef CFG_ALLOC_DPRAM - rtx = (RTXBD *) (immr-im_cpm.cp_dpmem + + /* Avoid exhausting DPRAM. */ + if (rtx == NULL) + rtx = (RTXBD *) (immr-im_cpm.cp_dpmem + dpram_alloc_align (sizeof (RTXBD), 8)); #else rtx = (RTXBD *) (immr-im_cpm.cp_dpmem + CPM_SCC_BASE); -- 1.5.4.3 --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] 8xx: prevent a machine check in scc_init().
Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- cpu/mpc8xx/scc.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/cpu/mpc8xx/scc.c b/cpu/mpc8xx/scc.c index 09a3db1..9ffeb11 100644 --- a/cpu/mpc8xx/scc.c +++ b/cpu/mpc8xx/scc.c @@ -70,6 +70,9 @@ static int scc_recv(struct eth_device* dev); static int scc_init (struct eth_device* dev, bd_t * bd); static void scc_halt(struct eth_device* dev); +/* avoid unnecessary reinitialization of the SCC */ +static int scc_init_completed; + int scc_initialize(bd_t *bis) { struct eth_device* dev; @@ -193,6 +196,19 @@ static int scc_init (struct eth_device *dev, bd_t * bis) volatile immap_t *immr = (immap_t *) CFG_IMMR; + /* +* This routine is called again and again from eth_init(), +* especially when CONFIG_NETCONSOLE is defined and +* stdout=nc. +* Avoid unneccessary flailing, otherwise we can get a panic here. +*/ + if (scc_init_completed) { + immr-im_ioport.iop_pcso |= (PC_ENET_CLSN | PC_ENET_RENA); + immr-im_cpm.cp_scc[SCC_ENET].scc_gsmrl |= + (SCC_GSMRL_ENR | SCC_GSMRL_ENT); + return 1; + } + #if defined(CONFIG_LWMON) reset_phy(); #endif @@ -544,6 +560,7 @@ static int scc_init (struct eth_device *dev, bd_t * bis) udelay (10);/* wait 100 ms */ #endif + scc_init_completed = 1; return 1; } -- 1.5.4.3 --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 1/2] IOMUX: Add console multiplexing support.
See doc/README.iomux for a general description of what this does. This is the first of two commits. The second commit touches net/eth.c and has to go through the custodian, so I split it out for simplicity. Tested with MAKEALL 8xx. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- common/Makefile |1 + common/cmd_nvedit.c |6 ++ common/console.c| 173 +++ common/iomux.c | 133 +++ doc/README.iomux| 90 ++ include/common.h|7 ++ include/iomux.h | 48 ++ 7 files changed, 458 insertions(+), 0 deletions(-) create mode 100644 common/iomux.c create mode 100644 doc/README.iomux create mode 100644 include/iomux.h diff --git a/common/Makefile b/common/Makefile index 8bddf8e..9138742 100644 --- a/common/Makefile +++ b/common/Makefile @@ -155,6 +155,7 @@ COBJS-$(CONFIG_LCD) += lcd.o COBJS-$(CONFIG_LYNXKDI) += lynxkdi.o COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o +COBJS-$(CONFIG_IO_MUX) += iomux.o COBJS := $(sort $(COBJS-y)) SRCS := $(AOBJS:.o=.S) $(COBJS:.o=.c) diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 637d6c9..6fc9313 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -213,6 +213,11 @@ int _do_setenv (int flag, int argc, char *argv[]) return 1; } +#ifdef CONFIG_IO_MUX + i = iomux_doenv(console, argv[2]); + if (i) + return i; +#else /* Try assigning specified device */ if (console_assign (console, argv[2]) 0) return 1; @@ -221,6 +226,7 @@ int _do_setenv (int flag, int argc, char *argv[]) if (serial_assign (argv[2]) 0) return 1; #endif +#endif /* CONFIG_IO_MUX */ } /* diff --git a/common/console.c b/common/console.c index 56d9118..6158af9 100644 --- a/common/console.c +++ b/common/console.c @@ -93,6 +93,78 @@ static int console_setfile (int file, device_t * dev) return error; } +#if defined(CONFIG_IO_MUX) +/** Console I/O multiplexing ***/ + +static device_t *tstcdev; +device_t *console_devices[MAX_FILES][MAX_CONSARGS]; + +/* + * This depends on tstc() always being called before getc(). + * No attempt is made to demultiplex multiple input sources. + */ +static int iomux_getc(void) +{ + unsigned char ret; + + ret = tstcdev-getc(); + tstcdev = NULL; + return ret; +} + +static int iomux_tstc(int file) +{ + int i, ret; + device_t *dev; + + disable_ctrlc(1); + for (i = 0; i MAX_CONSARGS; i++) { + dev = console_devices[file][i]; + if (dev == NULL) + break; + if (dev-tstc != NULL) { + ret = dev-tstc(); + if (ret 0) { + tstcdev = dev; + disable_ctrlc(0); + return ret; + } + } + } + disable_ctrlc(0); + + return 0; +} + +static void iomux_putc(int file, const char c) +{ + int i; + device_t *dev; + + for (i = 0; i MAX_CONSARGS; i++) { + dev = console_devices[file][i]; + if (dev == NULL) + break; + if (dev-putc != NULL) + dev-putc(c); + } +} + +static void iomux_puts(int file, const char *s) +{ + int i; + device_t *dev; + + for (i = 0; i MAX_CONSARGS; i++) { + dev = console_devices[file][i]; + if (dev == NULL) + break; + if (dev-puts != NULL) + dev-puts(s); + } +} +#endif /* defined(CONFIG_IO_MUX) */ + /** U-Boot INITIAL CONSOLE-NOT COMPATIBLE FUNCTIONS */ void serial_printf (const char *fmt, ...) @@ -115,7 +187,41 @@ void serial_printf (const char *fmt, ...) int fgetc (int file) { if (file MAX_FILES) +#if defined(CONFIG_IO_MUX) + { + int cntr = 0; + + /* +* Effectively poll for input wherever it may be available. +*/ + for (;;) { + /* +* Upper layer may have already called tstc() so +* check for that first. +*/ + if (tstcdev != NULL) + return iomux_getc(); + iomux_tstc(file); + /* +* Even this is too slow for serial cutpaste due +* to the overhead of calling tstc
[U-Boot] [PATCH 2/2] IOMUX: Add console multiplexing support.
Since this patch touches net/eth.c it is being sent separately. When CONFIG_IO_MUX, CONFIG_NETCONSOLE and CFG_CONSOLE_IS_IN_ENV are all defined together it is possible that nc (netconsole) is defined as an output device. In this case it is necessary to set GD_FLG_DEVINIT after the network devices have been initialized, otherwise u-boot might try to send output to a device before it is ready, which leads to various errors. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- net/eth.c | 24 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/net/eth.c b/net/eth.c index 432dd60..94b6e3a 100644 --- a/net/eth.c +++ b/net/eth.c @@ -26,6 +26,11 @@ #include net.h #include miiphy.h +#if defined(CONFIG_IO_MUX) defined(CONFIG_NETCONSOLE) \ + defined(CFG_CONSOLE_IS_IN_ENV) +DECLARE_GLOBAL_DATA_PTR; +#endif + #if defined(CONFIG_CMD_NET) defined(CONFIG_NET_MULTI) /* @@ -256,6 +261,15 @@ int eth_initialize(bd_t *bis) putc ('\n'); } +#if defined(CONFIG_IO_MUX) defined(CONFIG_NETCONSOLE) \ + defined(CFG_CONSOLE_IS_IN_ENV) + /* +* Must do this very late because a network device may be set as a +* console at boot time. +*/ + gd-flags |= GD_FLG_DEVINIT;/* device initialization completed */ +#endif + return eth_number; } @@ -532,6 +546,16 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_DRIVER_TI_EMAC) davinci_eth_miiphy_initialize(bis); #endif + +#if defined(CONFIG_IO_MUX) defined(CONFIG_NETCONSOLE) \ + defined(CFG_CONSOLE_IS_IN_ENV) + /* +* Must do this very late because a network device may be set as a +* console at boot time. +*/ + gd-flags |= GD_FLG_DEVINIT;/* device initialization completed */ +#endif + return 0; } #endif -- 1.5.4.3 --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] IOMUX: Add console multiplexing support.
On Sun, 14 Sep 2008 18:07:42 +0200 Wolfgang Denk [EMAIL PROTECTED] wrote: In message [EMAIL PROTECTED] you wrote: Since this patch touches net/eth.c it is being sent separately. When CONFIG_IO_MUX, CONFIG_NETCONSOLE and CFG_CONSOLE_IS_IN_ENV are all defined together it is possible that nc (netconsole) is defined as an output device. In this case it is necessary to set GD_FLG_DEVINIT after the network devices have been initialized, otherwise u-boot might try to send output to a device before it is ready, which leads to various errors. I don't understand this patch for two reasons: 1) What has CONFIG_IO_MUX to do with that? We can have a netconsole defined with or without that new feature, so why would it make any difference? This is a valid comment. I had IOMUX on the brain when I wrote this code since I had to make this change in the course of developing it. This patch would still be valid without CONFIG_IO_MUX. Signed-off-by: Gary Jennejohn [EMAIL PROTECTED] --- net/eth.c | 24 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/net/eth.c b/net/eth.c index 432dd60..94b6e3a 100644 --- a/net/eth.c +++ b/net/eth.c @@ -26,6 +26,11 @@ #include net.h #include miiphy.h +#if defined(CONFIG_IO_MUX) defined(CONFIG_NETCONSOLE) \ + defined(CFG_CONSOLE_IS_IN_ENV) +DECLARE_GLOBAL_DATA_PTR; +#endif + #if defined(CONFIG_CMD_NET) defined(CONFIG_NET_MULTI) /* @@ -256,6 +261,15 @@ int eth_initialize(bd_t *bis) putc ('\n'); } +#if defined(CONFIG_IO_MUX) defined(CONFIG_NETCONSOLE) \ + defined(CFG_CONSOLE_IS_IN_ENV) + /* +* Must do this very late because a network device may be set as a +* console at boot time. +*/ + gd-flags |= GD_FLG_DEVINIT;/* device initialization completed */ +#endif + return eth_number; } @@ -532,6 +546,16 @@ int eth_initialize(bd_t *bis) #if defined(CONFIG_DRIVER_TI_EMAC) davinci_eth_miiphy_initialize(bis); #endif + +#if defined(CONFIG_IO_MUX) defined(CONFIG_NETCONSOLE) \ + defined(CFG_CONSOLE_IS_IN_ENV) + /* +* Must do this very late because a network device may be set as a +* console at boot time. +*/ + gd-flags |= GD_FLG_DEVINIT;/* device initialization completed */ +#endif + 2) You only add new points where the GD_FLG_DEVINIT bit gets set in gd-flags. That means there are two possibilities when your newly added code is run: either, this bit is already set by other parts of the codem than the operation was redundant and couldbe omitted; or, the flasg was not set yet, then you set it now, which means you set it EARLIE than it would have been set before. But your comment suggests that that would be done LATER now. So what exactly is the purpose of this patch? This bit is normally ser in console_init_r, which is called very early. You have to look at this patch in conjunction with the first patch and not as a separate entity, which it most definitely is not. --- Gary Jennejohn * DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: [EMAIL PROTECTED] * ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot