diff options
192 files changed, 1396 insertions, 1125 deletions
@@ -666,6 +666,7 @@ libs-$(CONFIG_API) += api/ libs-$(CONFIG_HAS_POST) += post/ libs-y += test/ libs-y += test/dm/ +libs-$(CONFIG_UT_ENV) += test/env/ libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/) @@ -948,6 +948,9 @@ The following options need to be configured: bytes are output before the console is initialised, the earlier bytes are discarded. + Note that when printing the buffer a copy is made on the + stack so CONFIG_PRE_CON_BUF_SZ must fit on the stack. + 'Sane' compilers will generate smaller code if CONFIG_PRE_CON_BUF_SZ is a power of 2 @@ -2107,18 +2110,6 @@ CBFS (Coreboot Filesystem) support Some PHY like Intel LXT971A need extra delay after command issued before MII status register can be read -- Ethernet address: - CONFIG_ETHADDR - CONFIG_ETH1ADDR - CONFIG_ETH2ADDR - CONFIG_ETH3ADDR - CONFIG_ETH4ADDR - CONFIG_ETH5ADDR - - Define a default value for Ethernet address to use - for the respective Ethernet interface, in case this - is not determined automatically. - - IP address: CONFIG_IPADDR @@ -2873,8 +2864,8 @@ CBFS (Coreboot Filesystem) support completely disabled. Anybody can change or delete these parameters. - Alternatively, if you #define _both_ CONFIG_ETHADDR - _and_ CONFIG_OVERWRITE_ETHADDR_ONCE, a default + Alternatively, if you define _both_ an ethaddr in the + default env _and_ CONFIG_OVERWRITE_ETHADDR_ONCE, a default Ethernet address is installed in the environment, which can be changed exactly ONCE by the user. [The serial# is unaffected by this, i. e. it remains @@ -4151,6 +4142,10 @@ Configuration Settings: list, simply add an entry for the same variable name to the ".flags" variable. + If CONFIG_REGEX is defined, the variable_name above is evaluated as a + regular expression. This allows multiple variables to define the same + flags without explicitly listing them for each variable. + - CONFIG_ENV_ACCESS_IGNORE_FORCE If defined, don't allow the -f switch to env set override variable access flags. @@ -5549,6 +5544,10 @@ override any association in the static list. You can define CONFIG_ENV_CALLBACK_LIST_DEFAULT to a list (string) to define the ".callbacks" environment variable in the default or embedded environment. +If CONFIG_REGEX is defined, the variable_name above is evaluated as a +regular expression. This allows multiple variables to be connected to +the same callback without explicitly listing them all out. + Command Line Parsing: ===================== @@ -5623,7 +5622,8 @@ o If both the SROM and the environment contain a MAC address, and the warning is printed. o If neither SROM nor the environment contain a MAC address, an error - is raised. + is raised. If CONFIG_NET_RANDOM_ETHADDR is defined, then in this case + a random, locally-assigned MAC is used. If Ethernet drivers implement the 'write_hwaddr' function, valid MAC addresses will be programmed into hardware as part of the initialization process. This diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 6718ae2205..e6730c0dfa 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -68,6 +68,10 @@ static int gpio_init(void) sunxi_gpio_set_cfgpin(SUNXI_GPG(3), SUN5I_GPG_UART1); sunxi_gpio_set_cfgpin(SUNXI_GPG(4), SUN5I_GPG_UART1); sunxi_gpio_set_pull(SUNXI_GPG(4), SUNXI_GPIO_PULL_UP); +#elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I) + sunxi_gpio_set_cfgpin(SUNXI_GPB(0), SUN8I_GPB_UART2); + sunxi_gpio_set_cfgpin(SUNXI_GPB(1), SUN8I_GPB_UART2); + sunxi_gpio_set_pull(SUNXI_GPB(1), SUNXI_GPIO_PULL_UP); #elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN8I) sunxi_gpio_set_cfgpin(SUNXI_GPL(2), SUN8I_GPL_R_UART); sunxi_gpio_set_cfgpin(SUNXI_GPL(3), SUN8I_GPL_R_UART); diff --git a/arch/arm/cpu/armv7/sunxi/dram_sun4i.c b/arch/arm/cpu/armv7/sunxi/dram_sun4i.c index c736fa3b47..f7b4915037 100644 --- a/arch/arm/cpu/armv7/sunxi/dram_sun4i.c +++ b/arch/arm/cpu/armv7/sunxi/dram_sun4i.c @@ -508,7 +508,7 @@ static void mctl_ddr3_initialize(void) /* * Perform impedance calibration on the DRAM controller side of the wire. */ -static void mctl_set_impedance(u32 zq, u32 odt_en) +static void mctl_set_impedance(u32 zq, bool odt_en) { struct sunxi_dram_reg *dram = (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE; u32 reg_val; @@ -556,7 +556,7 @@ static void mctl_set_impedance(u32 zq, u32 odt_en) clrbits_le32(&dram->zqcr0, DRAM_ZQCR0_ZCAL); /* Set I/O configure register */ - writel(DRAM_IOCR_ODT_EN(odt_en), &dram->iocr); + writel(DRAM_IOCR_ODT_EN, &dram->iocr); } static unsigned long dramc_init_helper(struct dram_para *para) diff --git a/arch/arm/cpu/armv7/sunxi/dram_sun8i_a23.c b/arch/arm/cpu/armv7/sunxi/dram_sun8i_a23.c index 3d7964d1af..165c052122 100644 --- a/arch/arm/cpu/armv7/sunxi/dram_sun8i_a23.c +++ b/arch/arm/cpu/armv7/sunxi/dram_sun8i_a23.c @@ -26,12 +26,14 @@ #include <asm/arch/clock.h> #include <asm/arch/dram.h> #include <asm/arch/prcm.h> +#include <linux/kconfig.h> static const struct dram_para dram_para = { .clock = CONFIG_DRAM_CLK, .type = 3, .zq = CONFIG_DRAM_ZQ, - .odt_en = 1, + .odt_en = IS_ENABLED(CONFIG_DRAM_ODT_EN), + .odt_correction = CONFIG_DRAM_ODT_CORRECTION, .para1 = 0, /* not used (only used when tpr13 bit 31 is set */ .para2 = 0, /* not used (only used when tpr13 bit 31 is set */ .mr0 = 6736, @@ -97,7 +99,6 @@ static void mctl_init(u32 *bus_width) (struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE; struct sunxi_mctl_phy_reg * const mctl_phy = (struct sunxi_mctl_phy_reg *)SUNXI_DRAM_PHY0_BASE; - int correction; if (dram_para.tpr13 & 0x20) writel(0x40b, &mctl_phy->dcr); @@ -138,7 +139,7 @@ static void mctl_init(u32 *bus_width) writel(0x01000081, &mctl_phy->dtcr); - if (dram_para.clock <= 240 || !(dram_para.odt_en & 0x01)) { + if (dram_para.clock <= 240 || !dram_para.odt_en) { clrbits_le32(&mctl_phy->dx0gcr, 0x600); clrbits_le32(&mctl_phy->dx1gcr, 0x600); } @@ -251,13 +252,11 @@ static void mctl_init(u32 *bus_width) } else *bus_width = 16; - correction = (dram_para.odt_en >> 8) & 0xff; - if (correction) { - if (dram_para.odt_en & 0x80000000) - correction = -correction; - - mctl_apply_odt_correction(&mctl_phy->dx0lcdlr1, correction); - mctl_apply_odt_correction(&mctl_phy->dx1lcdlr1, correction); + if (dram_para.odt_correction) { + mctl_apply_odt_correction(&mctl_phy->dx0lcdlr1, + dram_para.odt_correction); + mctl_apply_odt_correction(&mctl_phy->dx1lcdlr1, + dram_para.odt_correction); } mctl_await_completion(&mctl_ctl->statr, 0x01, 0x01); diff --git a/arch/arm/cpu/armv7/sunxi/dram_sun8i_a33.c b/arch/arm/cpu/armv7/sunxi/dram_sun8i_a33.c index d03f00dc4b..ebba438319 100644 --- a/arch/arm/cpu/armv7/sunxi/dram_sun8i_a33.c +++ b/arch/arm/cpu/armv7/sunxi/dram_sun8i_a33.c @@ -14,12 +14,12 @@ #include <asm/arch/clock.h> #include <asm/arch/dram.h> #include <asm/arch/prcm.h> +#include <linux/kconfig.h> /* PLL runs at 2x dram-clk, controller runs at PLL / 4 (dram-clk / 2) */ #define DRAM_CLK_MUL 2 #define DRAM_CLK_DIV 4 #define DRAM_SIGMA_DELTA_ENABLE 1 -#define DRAM_ODT_EN 0 struct dram_para { u8 cs1; @@ -195,7 +195,7 @@ static int mctl_train_dram(struct dram_para *para) (struct sunxi_mctl_ctl_reg *)SUNXI_DRAM_CTL0_BASE; mctl_data_train_cfg(para); - mctl_set_pir(0x1f3); + mctl_set_pir(0x5f3); return ((readl(&mctl_ctl->pgsr0) >> 20) & 0xff) ? -EIO : 0; } @@ -215,7 +215,7 @@ static int mctl_channel_init(struct dram_para *para) clrbits_le32(&mctl_ctl->pgcr0, 0x3f << 0); /* Set ODT */ - if ((CONFIG_DRAM_CLK > 400) && DRAM_ODT_EN) { + if ((CONFIG_DRAM_CLK > 400) && IS_ENABLED(CONFIG_DRAM_ODT_EN)) { setbits_le32(DXnGCR0(0), 0x3 << 9); setbits_le32(DXnGCR0(1), 0x3 << 9); } else { diff --git a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h index bacd70adf6..6465f215e8 100644 --- a/arch/arm/include/asm/arch-sunxi/clock_sun6i.h +++ b/arch/arm/include/asm/arch-sunxi/clock_sun6i.h @@ -331,6 +331,9 @@ struct sunxi_ccm_reg { #define AHB_RESET_OFFSET_LCD1 5 #define AHB_RESET_OFFSET_LCD0 4 +/* ahb_reset2 offsets */ +#define AHB_RESET_OFFSET_LVDS 0 + /* apb2 reset */ #define APB2_RESET_UART_SHIFT (16) #define APB2_RESET_UART_MASK (0xff << APB2_RESET_UART_SHIFT) diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h index 5e94253203..ae954171f3 100644 --- a/arch/arm/include/asm/arch-sunxi/display.h +++ b/arch/arm/include/asm/arch-sunxi/display.h @@ -363,6 +363,11 @@ struct sunxi_tve_reg { #define SUNXI_LCDC_TCON0_TIMING_H_TOTAL(n) (((n) - 1) << 16) #define SUNXI_LCDC_TCON0_TIMING_V_BP(n) (((n) - 1) << 0) #define SUNXI_LCDC_TCON0_TIMING_V_TOTAL(n) (((n) * 2) << 16) +#ifdef CONFIG_SUNXI_GEN_SUN6I +#define SUNXI_LCDC_TCON0_LVDS_CLK_SEL_TCON0 (1 << 20) +#else +#define SUNXI_LCDC_TCON0_LVDS_CLK_SEL_TCON0 0 /* NA */ +#endif #define SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(n) ((n) << 26) #define SUNXI_LCDC_TCON0_LVDS_INTF_ENABLE (1 << 31) #define SUNXI_LCDC_TCON0_IO_POL_DCLK_PHASE(x) ((x) << 28) @@ -372,8 +377,15 @@ struct sunxi_tve_reg { #define SUNXI_LCDC_TCON1_TIMING_H_TOTAL(n) (((n) - 1) << 16) #define SUNXI_LCDC_TCON1_TIMING_V_BP(n) (((n) - 1) << 0) #define SUNXI_LCDC_TCON1_TIMING_V_TOTAL(n) (((n) * 2) << 16) +#ifdef CONFIG_SUNXI_GEN_SUN6I +#define SUNXI_LCDC_LVDS_ANA0 0x40040320 +#define SUNXI_LCDC_LVDS_ANA0_EN_MB (1 << 31) +#define SUNXI_LCDC_LVDS_ANA0_DRVC (1 << 24) +#define SUNXI_LCDC_LVDS_ANA0_DRVD(x) ((x) << 20) +#else #define SUNXI_LCDC_LVDS_ANA0 0x3f310000 #define SUNXI_LCDC_LVDS_ANA0_UPDATE (1 << 22) +#endif #define SUNXI_LCDC_LVDS_ANA1_INIT1 (0x1f << 26 | 0x1f << 10) #define SUNXI_LCDC_LVDS_ANA1_INIT2 (0x1f << 16 | 0x1f << 00) diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun4i.h b/arch/arm/include/asm/arch-sunxi/dram_sun4i.h index 40c385a5bc..139e3366a6 100644 --- a/arch/arm/include/asm/arch-sunxi/dram_sun4i.h +++ b/arch/arm/include/asm/arch-sunxi/dram_sun4i.h @@ -164,8 +164,7 @@ struct dram_para { #define DRAM_ZQSR_ZDONE (1 << 31) /* ZQ calibration completion flag */ -#define DRAM_IOCR_ODT_EN(n) ((((n) & 0x3) << 30) | ((n) & 0x3) << 0) -#define DRAM_IOCR_ODT_EN_MASK DRAM_IOCR_ODT_EN(0x3) +#define DRAM_IOCR_ODT_EN ((3 << 30) | (3 << 0)) #define DRAM_MR_BURST_LENGTH(n) (((n) & 0x7) << 0) #define DRAM_MR_BURST_LENGTH_MASK DRAM_MR_BURST_LENGTH(0x7) diff --git a/arch/arm/include/asm/arch-sunxi/dram_sun8i_a23.h b/arch/arm/include/asm/arch-sunxi/dram_sun8i_a23.h index 06adee2723..316a3338f8 100644 --- a/arch/arm/include/asm/arch-sunxi/dram_sun8i_a23.h +++ b/arch/arm/include/asm/arch-sunxi/dram_sun8i_a23.h @@ -19,6 +19,7 @@ struct dram_para { u32 type; u32 zq; u32 odt_en; + s32 odt_correction; u32 para1; u32 para2; u32 mr0; diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h b/arch/arm/include/asm/arch-sunxi/gpio.h index 59d8210e88..148123a87f 100644 --- a/arch/arm/include/asm/arch-sunxi/gpio.h +++ b/arch/arm/include/asm/arch-sunxi/gpio.h @@ -155,6 +155,7 @@ enum sunxi_gpio_number { #define SUN5I_GPB_TWI2 2 #define SUN4I_GPB_UART0 2 #define SUN5I_GPB_UART0 2 +#define SUN8I_GPB_UART2 2 #define SUNXI_GPC_SDC2 3 #define SUN6I_GPC_SDC3 4 diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig index 8aac96f8d9..f078c9e504 100644 --- a/arch/sandbox/Kconfig +++ b/arch/sandbox/Kconfig @@ -10,9 +10,6 @@ config SYS_BOARD config SYS_CONFIG_NAME default "sandbox" -config DM_TEST - default y - config PCI bool "PCI support" help @@ -20,16 +17,4 @@ config PCI used on some devices to allow the CPU to communicate with its peripherals. -config NET - default y - -config NETDEVICES - default y - -config DM_ETH - default y - -config ETH_SANDBOX_RAW - default y - endmenu diff --git a/board/bct-brettl2/bct-brettl2.c b/board/bct-brettl2/bct-brettl2.c index 1f0dfb4d40..bf7cd62954 100644 --- a/board/bct-brettl2/bct-brettl2.c +++ b/board/bct-brettl2/bct-brettl2.c @@ -29,13 +29,6 @@ int checkboard(void) } #ifdef CONFIG_BFIN_MAC -static void board_init_enetaddr(uchar *mac_addr) -{ - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); - eth_setenv_enetaddr("ethaddr", mac_addr); -} - int board_eth_init(bd_t *bis) { int retry = 3; @@ -107,12 +100,6 @@ static void turn_leds_off(void) /* miscellaneous platform dependent initialisations */ int misc_init_r(void) { -#ifdef CONFIG_BFIN_MAC - uchar enetaddr[6]; - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) - board_init_enetaddr(enetaddr); -#endif - gpio_cfi_flash_init(); init_tlv320aic31(); init_mute_pin(); diff --git a/board/bf518f-ezbrd/bf518f-ezbrd.c b/board/bf518f-ezbrd/bf518f-ezbrd.c index 8ecfbb28c9..bf4a7db03d 100644 --- a/board/bf518f-ezbrd/bf518f-ezbrd.c +++ b/board/bf518f-ezbrd/bf518f-ezbrd.c @@ -29,28 +29,14 @@ int checkboard(void) #if defined(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 *)0x203F0096; - if (is_valid_ethaddr(board_mac_addr)) { - memcpy(mac_addr, board_mac_addr, 6); - valid_mac = true; - } - } - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); +#ifndef CONFIG_SYS_NO_FLASH + /* we cram the MAC in the last flash sector */ + uchar *board_mac_addr = (uchar *)0x203F0096; + if (is_valid_ethaddr(board_mac_addr)) { + memcpy(mac_addr, board_mac_addr, 6); + eth_setenv_enetaddr("ethaddr", mac_addr); } - - eth_setenv_enetaddr("ethaddr", mac_addr); +#endif } /* Only the first run of boards had a KSZ switch */ diff --git a/board/bf526-ezbrd/bf526-ezbrd.c b/board/bf526-ezbrd/bf526-ezbrd.c index 0a88491e90..db1ee283f2 100644 --- a/board/bf526-ezbrd/bf526-ezbrd.c +++ b/board/bf526-ezbrd/bf526-ezbrd.c @@ -26,28 +26,14 @@ int checkboard(void) #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 *)0x203F0096; - if (is_valid_ethaddr(board_mac_addr)) { - memcpy(mac_addr, board_mac_addr, 6); - valid_mac = true; - } - } - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); +#ifndef CONFIG_SYS_NO_FLASH + /* we cram the MAC in the last flash sector */ + uchar *board_mac_addr = (uchar *)0x203F0096; + if (is_valid_ethaddr(board_mac_addr)) { + memcpy(mac_addr, board_mac_addr, 6); + eth_setenv_enetaddr("ethaddr", mac_addr); } - - eth_setenv_enetaddr("ethaddr", mac_addr); +#endif } int board_eth_init(bd_t *bis) diff --git a/board/bf527-ezkit/bf527-ezkit.c b/board/bf527-ezkit/bf527-ezkit.c index 257775f3c8..b551d4ed7e 100644 --- a/board/bf527-ezkit/bf527-ezkit.c +++ b/board/bf527-ezkit/bf527-ezkit.c @@ -27,8 +27,6 @@ int checkboard(void) #ifdef CONFIG_BFIN_MAC static void board_init_enetaddr(uchar *mac_addr) { - bool valid_mac = false; - /* the MAC is stored in OTP memory page 0xDF */ uint32_t ret; uint64_t otp_mac; @@ -41,15 +39,8 @@ static void board_init_enetaddr(uchar *mac_addr) mac_addr[ret] = otp_mac_p[5 - ret]; if (is_valid_ethaddr(mac_addr)) - valid_mac = true; - } - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); + eth_setenv_enetaddr("ethaddr", mac_addr); } - - eth_setenv_enetaddr("ethaddr", mac_addr); } int board_eth_init(bd_t *bis) diff --git a/board/bf537-minotaur/bf537-minotaur.c b/board/bf537-minotaur/bf537-minotaur.c index 71b4293ad6..9312216dc7 100644 --- a/board/bf537-minotaur/bf537-minotaur.c +++ b/board/bf537-minotaur/bf537-minotaur.c @@ -23,26 +23,8 @@ int checkboard(void) } #ifdef CONFIG_BFIN_MAC -static void board_init_enetaddr(uchar *mac_addr) -{ - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); - eth_setenv_enetaddr("ethaddr", mac_addr); -} - int board_eth_init(bd_t *bis) { return bfin_EMAC_initialize(bis); } #endif - -int misc_init_r(void) -{ -#ifdef CONFIG_BFIN_MAC - uchar enetaddr[6]; - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) - board_init_enetaddr(enetaddr); -#endif - - return 0; -} diff --git a/board/bf537-pnav/bf537-pnav.c b/board/bf537-pnav/bf537-pnav.c index 93522df56c..6739fe1ed6 100644 --- a/board/bf537-pnav/bf537-pnav.c +++ b/board/bf537-pnav/bf537-pnav.c @@ -23,26 +23,8 @@ int checkboard(void) } #ifdef CONFIG_BFIN_MAC -static void board_init_enetaddr(uchar *mac_addr) -{ - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); - eth_setenv_enetaddr("ethaddr", mac_addr); -} - int board_eth_init(bd_t *bis) { return bfin_EMAC_initialize(bis); } #endif - -int misc_init_r(void) -{ -#ifdef CONFIG_BFIN_MAC - uchar enetaddr[6]; - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) - board_init_enetaddr(enetaddr); -#endif - - return 0; -} diff --git a/board/bf537-srv1/bf537-srv1.c b/board/bf537-srv1/bf537-srv1.c index 6581028294..b0ffe1aeea 100644 --- a/board/bf537-srv1/bf537-srv1.c +++ b/board/bf537-srv1/bf537-srv1.c @@ -23,26 +23,8 @@ int checkboard(void) } #ifdef CONFIG_BFIN_MAC -static void board_init_enetaddr(uchar *mac_addr) -{ - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); - eth_setenv_enetaddr("ethaddr", mac_addr); -} - int board_eth_init(bd_t *bis) { return bfin_EMAC_initialize(bis); } #endif - -int misc_init_r(void) -{ -#ifdef CONFIG_BFIN_MAC - uchar enetaddr[6]; - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) - board_init_enetaddr(enetaddr); -#endif - - return 0; -} diff --git a/board/bf537-stamp/bf537-stamp.c b/board/bf537-stamp/bf537-stamp.c index 66e54925da..85d41d0aaa 100644 --- a/board/bf537-stamp/bf537-stamp.c +++ b/board/bf537-stamp/bf537-stamp.c @@ -29,28 +29,14 @@ int checkboard(void) #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_ethaddr(board_mac_addr)) { - memcpy(mac_addr, board_mac_addr, 6); - valid_mac = true; - } - } - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); +#ifndef CONFIG_SYS_NO_FLASH + /* we cram the MAC in the last flash sector */ + uchar *board_mac_addr = (uchar *)0x203F0000; + if (is_valid_ethaddr(board_mac_addr)) { + memcpy(mac_addr, board_mac_addr, 6); + eth_setenv_enetaddr("ethaddr", mac_addr); } - - eth_setenv_enetaddr("ethaddr", mac_addr); +#endif } int board_eth_init(bd_t *bis) diff --git a/board/buffalo/lsxl/lsxl.c b/board/buffalo/lsxl/lsxl.c index 487875c23a..45dd788805 100644 --- a/board/buffalo/lsxl/lsxl.c +++ b/board/buffalo/lsxl/lsxl.c @@ -230,16 +230,6 @@ static void rescue_mode(void) uchar enetaddr[6]; printf("Entering rescue mode..\n"); -#ifdef CONFIG_RANDOM_MACADDR - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { - net_random_ethaddr(enetaddr); - if (eth_setenv_enetaddr("ethaddr", enetaddr)) { - printf("Failed to set ethernet address\n"); - set_led(LED_ALARM_BLINKING); - return; - } - } -#endif setenv("bootsource", "rescue"); } diff --git a/board/cm-bf527/cm-bf527.c b/board/cm-bf527/cm-bf527.c index 2871fa2d6a..3186c6717e 100644 --- a/board/cm-bf527/cm-bf527.c +++ b/board/cm-bf527/cm-bf527.c @@ -26,8 +26,6 @@ int checkboard(void) #ifdef CONFIG_BFIN_MAC static void board_init_enetaddr(uchar *mac_addr) { - bool valid_mac = false; - /* the MAC is stored in OTP memory page 0xDF */ uint32_t ret; uint64_t otp_mac; @@ -40,15 +38,8 @@ static void board_init_enetaddr(uchar *mac_addr) mac_addr[ret] = otp_mac_p[5 - ret]; if (is_valid_ethaddr(mac_addr)) - valid_mac = true; - } - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); + eth_setenv_enetaddr("ethaddr", mac_addr); } - - eth_setenv_enetaddr("ethaddr", mac_addr); } int board_eth_init(bd_t *bis) diff --git a/board/cm-bf537e/cm-bf537e.c b/board/cm-bf537e/cm-bf537e.c index 902611ec01..57c72a2c06 100644 --- a/board/cm-bf537e/cm-bf537e.c +++ b/board/cm-bf537e/cm-bf537e.c @@ -23,18 +23,6 @@ int checkboard(void) return 0; } -static void board_init_enetaddr(char *var) -{ - uchar enetaddr[6]; - - if (eth_getenv_enetaddr(var, enetaddr)) - return; - - printf("Warning: %s: generating 'random' MAC address\n", var); - net_random_ethaddr(enetaddr); - eth_setenv_enetaddr(var, enetaddr); -} - #ifndef CONFIG_BFIN_MAC # define bfin_EMAC_initialize(x) 1 #endif @@ -50,9 +38,6 @@ int board_eth_init(bd_t *bis) int misc_init_r(void) { - board_init_enetaddr("ethaddr"); - board_init_enetaddr("eth1addr"); - gpio_cfi_flash_init(); return 0; diff --git a/board/cm-bf537u/cm-bf537u.c b/board/cm-bf537u/cm-bf537u.c index 69bffd76de..f365cdbeb7 100644 --- a/board/cm-bf537u/cm-bf537u.c +++ b/board/cm-bf537u/cm-bf537u.c @@ -23,18 +23,6 @@ int checkboard(void) return 0; } -static void board_init_enetaddr(char *var) -{ - uchar enetaddr[6]; - - if (eth_getenv_enetaddr(var, enetaddr)) - return; - - printf("Warning: %s: generating 'random' MAC address\n", var); - net_random_ethaddr(enetaddr); - eth_setenv_enetaddr(var, enetaddr); -} - #ifndef CONFIG_BFIN_MAC # define bfin_EMAC_initialize(x) 1 #endif @@ -50,9 +38,6 @@ int board_eth_init(bd_t *bis) int misc_init_r(void) { - board_init_enetaddr("ethaddr"); - board_init_enetaddr("eth1addr"); - gpio_cfi_flash_init(); return 0; diff --git a/board/dnp5370/dnp5370.c b/board/dnp5370/dnp5370.c index 655fcace2b..ae9ba84dc2 100644 --- a/board/dnp5370/dnp5370.c +++ b/board/dnp5370/dnp5370.c @@ -36,28 +36,14 @@ int checkboard(void) #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 *)0x202F0000; - if (is_valid_ethaddr(board_mac_addr)) { - memcpy(mac_addr, board_mac_addr, 6); - valid_mac = true; - } - } - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); +#ifndef CONFIG_SYS_NO_FLASH + /* we cram the MAC in the last flash sector */ + uchar *board_mac_addr = (uchar *)0x202F0000; + if (is_valid_ethaddr(board_mac_addr)) { + memcpy(mac_addr, board_mac_addr, 6); + eth_setenv_enetaddr("ethaddr", mac_addr); } - - eth_setenv_enetaddr("ethaddr", mac_addr); +#endif } int board_eth_init(bd_t *bis) diff --git a/board/ip04/ip04.c b/board/ip04/ip04.c index d20500f4df..70765bce50 100644 --- a/board/ip04/ip04.c +++ b/board/ip04/ip04.c @@ -26,16 +26,4 @@ int board_eth_init(bd_t *bis) { return dm9000_initialize(bis); } - -int misc_init_r(void) -{ - uchar enetaddr[6]; - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(enetaddr); - eth_setenv_enetaddr("ethaddr", enetaddr); - } - - return 0; -} #endif diff --git a/board/sunxi/Kconfig b/board/sunxi/Kconfig index 5b6cc5c82f..a6bbf6e786 100644 --- a/board/sunxi/Kconfig +++ b/board/sunxi/Kconfig @@ -91,6 +91,13 @@ config DRAM_ZQ ---help--- Set the dram zq value. +config DRAM_ODT_EN + bool "sunxi dram odt enable" + default n if !MACH_SUN8I_A23 + default y if MACH_SUN8I_A23 + ---help--- + Select this to enable dram odt (on die termination). + if MACH_SUN4I || MACH_SUN5I || MACH_SUN7I config DRAM_EMR1 int "sunxi dram emr1 value" @@ -99,13 +106,6 @@ config DRAM_EMR1 ---help--- Set the dram controller emr1 value. -config DRAM_ODT_EN - int "sunxi dram odt_en value" - default 0 - ---help--- - Set the dram controller odt_en parameter. This can be used to - enable/disable the ODT feature. - config DRAM_TPR3 hex "sunxi dram tpr3 value" default 0 @@ -166,6 +166,17 @@ endchoice endif +if MACH_SUN8I_A23 +config DRAM_ODT_CORRECTION + int "sunxi dram odt correction value" + default 0 + ---help--- + Set the dram odt correction value (range -255 - 255). In allwinner + fex files, this option is found in bits 8-15 of the u32 odt_en variable + in the [dram] section. When bit 31 of the odt_en variable is set + then the correction is negative. Usually the value for this is 0. +endif + config SYS_CLK_FREQ default 912000000 if MACH_SUN7I default 1008000000 if MACH_SUN4I || MACH_SUN5I || MACH_SUN6I || MACH_SUN8I @@ -544,6 +555,9 @@ config GMAC_TX_DELAY ---help--- Set the GMAC Transmit Clock Delay Chain value. +config SYS_MALLOC_CLEAR_ON_INIT + default n + config NET default y diff --git a/board/sunxi/MAINTAINERS b/board/sunxi/MAINTAINERS index 339904b84f..a650554938 100644 --- a/board/sunxi/MAINTAINERS +++ b/board/sunxi/MAINTAINERS @@ -37,6 +37,7 @@ F: configs/Orangepi_mini_defconfig F: configs/qt840a_defconfig F: configs/Wits_Pro_A20_DKT_defconfig F: include/configs/sun8i.h +F: configs/ga10h_v1_1_defconfig F: configs/Ippo_q8h_v1_2_defconfig F: configs/Ippo_q8h_v1_2_a33_1024x600_defconfig diff --git a/board/sunxi/board.c b/board/sunxi/board.c index d9f7691373..5f79cc1bb8 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -476,7 +476,27 @@ static struct musb_hdrc_platform_data musb_plat = { #ifdef CONFIG_USB_GADGET int g_dnl_board_usb_cable_connected(void) { - return sunxi_usbc_vbus_detect(0); + return sunxi_usb_phy_vbus_detect(0); +} +#endif + +#ifdef CONFIG_SERIAL_TAG +void get_board_serial(struct tag_serialnr *serialnr) +{ + char *serial_string; + unsigned long long serial; + + serial_string = getenv("serial#"); + + if (serial_string) { + serial = simple_strtoull(serial_string, NULL, 16); + + serialnr->high = (unsigned int) (serial >> 32); + serialnr->low = (unsigned int) (serial & 0xffffffff); + } else { + serialnr->high = 0; + serialnr->low = 0; + } } #endif diff --git a/board/sunxi/dram_sun4i_auto.c b/board/sunxi/dram_sun4i_auto.c index 09e0c9ae2e..149bb51dcb 100644 --- a/board/sunxi/dram_sun4i_auto.c +++ b/board/sunxi/dram_sun4i_auto.c @@ -1,5 +1,6 @@ #include <common.h> #include <asm/arch/dram.h> +#include <linux/kconfig.h> static struct dram_para dram_para = { .clock = CONFIG_DRAM_CLK, @@ -9,7 +10,7 @@ static struct dram_para dram_para = { .io_width = 0, .bus_width = 0, .zq = CONFIG_DRAM_ZQ, - .odt_en = CONFIG_DRAM_ODT_EN, + .odt_en = IS_ENABLED(CONFIG_DRAM_ODT_EN), .size = 0, #ifdef CONFIG_DRAM_TIMINGS_VENDOR_MAGIC .cas = 6, diff --git a/board/sunxi/dram_sun5i_auto.c b/board/sunxi/dram_sun5i_auto.c index 660b18ebbd..596a206072 100644 --- a/board/sunxi/dram_sun5i_auto.c +++ b/board/sunxi/dram_sun5i_auto.c @@ -2,6 +2,7 @@ #include <common.h> #include <asm/arch/dram.h> +#include <linux/kconfig.h> static struct dram_para dram_para = { .clock = CONFIG_DRAM_CLK, @@ -12,7 +13,7 @@ static struct dram_para dram_para = { .io_width = 0, .bus_width = 0, .zq = CONFIG_DRAM_ZQ, - .odt_en = CONFIG_DRAM_ODT_EN, + .odt_en = IS_ENABLED(CONFIG_DRAM_ODT_EN), .size = 0, #ifdef CONFIG_DRAM_TIMINGS_VENDOR_MAGIC .cas = 9, diff --git a/board/tcm-bf518/tcm-bf518.c b/board/tcm-bf518/tcm-bf518.c index 3fa7d972ea..4348678aeb 100644 --- a/board/tcm-bf518/tcm-bf518.c +++ b/board/tcm-bf518/tcm-bf518.c @@ -23,52 +23,12 @@ int checkboard(void) } #if defined(CONFIG_BFIN_MAC) -static void board_init_enetaddr(uchar *mac_addr) -{ - bool valid_mac = false; - -#if 0 - /* the MAC is stored in OTP memory page 0xDF */ - uint32_t ret; - uint64_t otp_mac; - - ret = bfrom_OtpRead(0xDF, OTP_LOWER_HALF, &otp_mac); - if (!(ret & OTP_MASTER_ERROR)) { - uchar *otp_mac_p = (uchar *)&otp_mac; - - for (ret = 0; ret < 6; ++ret) - mac_addr[ret] = otp_mac_p[5 - ret]; - - if (is_valid_ethaddr(mac_addr)) - valid_mac = true; - } -#endif - - if (!valid_mac) { - puts("Warning: Generating 'random' MAC address\n"); - net_random_ethaddr(mac_addr); - } - - eth_setenv_enetaddr("ethaddr", mac_addr); -} - int board_eth_init(bd_t *bis) { return bfin_EMAC_initialize(bis); } #endif -int misc_init_r(void) -{ -#ifdef CONFIG_BFIN_MAC - uchar enetaddr[6]; - if (!eth_getenv_enetaddr("ethaddr", enetaddr)) - board_init_enetaddr(enetaddr); -#endif - - return 0; -} - #ifdef CONFIG_BFIN_SDH int board_mmc_init(bd_t *bis) { diff --git a/board/tcm-bf537/tcm-bf537.c b/board/tcm-bf537/tcm-bf537.c index 2531a44336..2cf70cab15 100644 --- a/board/tcm-bf537/tcm-bf537.c +++ b/board/tcm-bf537/tcm-bf537.c @@ -23,18 +23,6 @@ int checkboard(void) return 0; } -static void board_init_enetaddr(char *var) -{ - uchar enetaddr[6]; - - if (eth_getenv_enetaddr(var, enetaddr)) - return; - - printf("Warning: %s: generating 'random' MAC address\n", var); - net_random_ethaddr(enetaddr); - eth_setenv_enetaddr(var, enetaddr); -} - #ifndef CONFIG_BFIN_MAC # define bfin_EMAC_initialize(x) 1 #endif @@ -50,9 +38,6 @@ int board_eth_init(bd_t *bis) int misc_init_r(void) { - board_init_enetaddr("ethaddr"); - board_init_enetaddr("eth1addr"); - gpio_cfi_flash_init(); return 0; diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index be792ae746..f4c2523f2f 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -208,12 +208,11 @@ DONE: * Set a new environment variable, * or replace or delete an existing one. */ -static int _do_env_set(int flag, int argc, char * const argv[]) +static int _do_env_set(int flag, int argc, char * const argv[], int env_flag) { int i, len; char *name, *value, *s; ENTRY e, *ep; - int env_flag = H_INTERACTIVE; debug("Initial value for argc=%d\n", argc); while (argc > 1 && **(argv + 1) == '-') { @@ -291,9 +290,9 @@ int setenv(const char *varname, const char *varvalue) return 1; if (varvalue == NULL || varvalue[0] == '\0') - return _do_env_set(0, 2, (char * const *)argv); + return _do_env_set(0, 2, (char * const *)argv, H_PROGRAMMATIC); else - return _do_env_set(0, 3, (char * const *)argv); + return _do_env_set(0, 3, (char * const *)argv, H_PROGRAMMATIC); } /** @@ -347,7 +346,7 @@ static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc < 2) return CMD_RET_USAGE; - return _do_env_set(flag, argc, argv); + return _do_env_set(flag, argc, argv, H_INTERACTIVE); } /* @@ -422,12 +421,13 @@ int do_env_ask(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } /* Continue calling setenv code */ - return _do_env_set(flag, len, local_args); + return _do_env_set(flag, len, local_args, H_INTERACTIVE); } #endif #if defined(CONFIG_CMD_ENV_CALLBACK) -static int print_static_binding(const char *var_name, const char *callback_name) +static int print_static_binding(const char *var_name, const char *callback_name, + void *priv) { printf("\t%-20s %-20s\n", var_name, callback_name); @@ -489,7 +489,7 @@ int do_env_callback(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) puts("Static callback bindings:\n"); printf("\t%-20s %-20s\n", "Variable Name", "Callback Name"); printf("\t%-20s %-20s\n", "-------------", "-------------"); - env_attr_walk(ENV_CALLBACK_LIST_STATIC, print_static_binding); + env_attr_walk(ENV_CALLBACK_LIST_STATIC, print_static_binding, NULL); puts("\n"); /* walk through each variable and print the callback if it has one */ @@ -502,7 +502,8 @@ int do_env_callback(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #endif #if defined(CONFIG_CMD_ENV_FLAGS) -static int print_static_flags(const char *var_name, const char *flags) +static int print_static_flags(const char *var_name, const char *flags, + void *priv) { enum env_flags_vartype type = env_flags_parse_vartype(flags); enum env_flags_varaccess access = env_flags_parse_varaccess(flags); @@ -559,7 +560,7 @@ int do_env_flags(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) "Variable Access"); printf("\t%-20s %-20s %-20s\n", "-------------", "-------------", "---------------"); - env_attr_walk(ENV_FLAGS_LIST_STATIC, print_static_flags); + env_attr_walk(ENV_FLAGS_LIST_STATIC, print_static_flags, NULL); puts("\n"); /* walk through each variable and print the flags if non-default */ @@ -586,6 +587,10 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, if (argc < 2) return CMD_RET_USAGE; + /* before import into hashtable */ + if (!(gd->flags & GD_FLG_ENV_READY)) + return 1; + /* Set read buffer to initial value or empty sting */ init_val = getenv(argv[1]); if (init_val) @@ -596,7 +601,16 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc, if (cli_readline_into_buffer("edit: ", buffer, 0) < 0) return 1; - return setenv(argv[1], buffer); + if (buffer[0] == '\0') { + const char * const _argv[3] = { "setenv", argv[1], NULL }; + + return _do_env_set(0, 2, (char * const *)_argv, H_INTERACTIVE); + } else { + const char * const _argv[4] = { "setenv", argv[1], buffer, + NULL }; + + return _do_env_set(0, 3, (char * const *)_argv, H_INTERACTIVE); + } } #endif /* CONFIG_CMD_EDITENV */ #endif /* CONFIG_SPL_BUILD */ diff --git a/common/console.c b/common/console.c index 3f25e76fe7..00582224d4 100644 --- a/common/console.c +++ b/common/console.c @@ -200,15 +200,15 @@ static void console_putc(int file, const char c) } #ifdef CONFIG_PRE_CONSOLE_BUFFER -static void console_putc_noserial(int file, const char c) +static void console_puts_noserial(int file, const char *s) { int i; struct stdio_dev *dev; for (i = 0; i < cd_count[file]; i++) { dev = console_devices[file][i]; - if (dev->putc != NULL && strcmp(dev->name, "serial") != 0) - dev->putc(dev, c); + if (dev->puts != NULL && strcmp(dev->name, "serial") != 0) + dev->puts(dev, s); } } #endif @@ -251,10 +251,10 @@ static inline void console_putc(int file, const char c) } #ifdef CONFIG_PRE_CONSOLE_BUFFER -static inline void console_putc_noserial(int file, const char c) +static inline void console_puts_noserial(int file, const char *s) { if (strcmp(stdio_devices[file]->name, "serial") != 0) - stdio_devices[file]->putc(stdio_devices[file], c); + stdio_devices[file]->puts(stdio_devices[file], s); } #endif @@ -425,22 +425,26 @@ static void pre_console_puts(const char *s) static void print_pre_console_buffer(int flushpoint) { - unsigned long i = 0; - char *buffer = (char *)CONFIG_PRE_CON_BUF_ADDR; + unsigned long in = 0, out = 0; + char *buf_in = (char *)CONFIG_PRE_CON_BUF_ADDR; + char buf_out[CONFIG_PRE_CON_BUF_SZ + 1]; if (gd->precon_buf_idx > CONFIG_PRE_CON_BUF_SZ) - i = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ; + in = gd->precon_buf_idx - CONFIG_PRE_CON_BUF_SZ; - while (i < gd->precon_buf_idx) - switch (flushpoint) { - case PRE_CONSOLE_FLUSHPOINT1_SERIAL: - putc(buffer[CIRC_BUF_IDX(i++)]); - break; - case PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL: - console_putc_noserial(stdout, - buffer[CIRC_BUF_IDX(i++)]); - break; - } + while (in < gd->precon_buf_idx) + buf_out[out++] = buf_in[CIRC_BUF_IDX(in++)]; + + buf_out[out] = 0; + + switch (flushpoint) { + case PRE_CONSOLE_FLUSHPOINT1_SERIAL: + puts(buf_out); + break; + case PRE_CONSOLE_FLUSHPOINT2_EVERYTHING_BUT_SERIAL: + console_puts_noserial(stdout, buf_out); + break; + } } #else static inline void pre_console_putc(const char c) {} diff --git a/common/env_attr.c b/common/env_attr.c index 64baca5a10..5bfe5e3a89 100644 --- a/common/env_attr.c +++ b/common/env_attr.c @@ -11,6 +11,7 @@ #include <linux/linux_string.h> #else #include <common.h> +#include <slre.h> #endif #include <env_attr.h> @@ -26,7 +27,8 @@ * list = entry[,list] */ int env_attr_walk(const char *attr_list, - int (*callback)(const char *name, const char *attributes)) + int (*callback)(const char *name, const char *attributes, void *priv), + void *priv) { const char *entry, *entry_end; char *name, *attributes; @@ -93,7 +95,7 @@ int env_attr_walk(const char *attr_list, if (strlen(name) != 0) { int retval = 0; - retval = callback(name, attributes); + retval = callback(name, attributes, priv); if (retval) { free(entry_cpy); return retval; @@ -108,34 +110,53 @@ int env_attr_walk(const char *attr_list, return 0; } -/* - * Search for the last matching string in another string with the option to - * start looking at a certain point (i.e. ignore anything beyond that point). - */ -static char *reverse_strstr(const char *searched, const char *search_for, - const char *searched_start) +#if defined(CONFIG_REGEX) +struct regex_callback_priv { + const char *searched_for; + char *regex; + char *attributes; +}; + +static int regex_callback(const char *name, const char *attributes, void *priv) { - char *result = NULL; + int retval = 0; + struct regex_callback_priv *cbp = (struct regex_callback_priv *)priv; + struct slre slre; + char regex[strlen(name) + 3]; - if (*search_for == '\0') - return (char *)searched; + /* Require the whole string to be described by the regex */ + sprintf(regex, "^%s$", name); + if (slre_compile(&slre, regex)) { + struct cap caps[slre.num_caps + 2]; - for (;;) { - char *match = strstr(searched, search_for); - - /* - * Stop looking if no new match is found or looking past the - * searched_start pointer - */ - if (match == NULL || (searched_start != NULL && - match + strlen(search_for) > searched_start)) - break; + if (slre_match(&slre, cbp->searched_for, + strlen(cbp->searched_for), caps)) { + free(cbp->regex); + cbp->regex = malloc(strlen(regex) + 1); + if (cbp->regex) { + strcpy(cbp->regex, regex); + } else { + retval = -ENOMEM; + goto done; + } - result = match; - searched = match + 1; + free(cbp->attributes); + cbp->attributes = malloc(strlen(attributes) + 1); + if (cbp->attributes) { + strcpy(cbp->attributes, attributes); + } else { + retval = -ENOMEM; + free(cbp->regex); + cbp->regex = NULL; + goto done; + } + } + } else { + printf("Error compiling regex: %s\n", slre.err_str); + retval = EINVAL; } - - return result; +done: + return retval; } /* @@ -144,41 +165,112 @@ static char *reverse_strstr(const char *searched, const char *search_for, */ int env_attr_lookup(const char *attr_list, const char *name, char *attributes) { - const char *entry = NULL; - if (!attributes) /* bad parameter */ - return -1; + return -EINVAL; if (!attr_list) /* list not found */ - return 1; + return -EINVAL; + + struct regex_callback_priv priv; + int retval; - entry = reverse_strstr(attr_list, name, NULL); - while (entry != NULL) { - const char *prevch = entry - 1; - const char *nextch = entry + strlen(name); + priv.searched_for = name; + priv.regex = NULL; + priv.attributes = NULL; + retval = env_attr_walk(attr_list, regex_callback, &priv); + if (retval) + return retval; /* error */ + + if (priv.regex) { + strcpy(attributes, priv.attributes); + free(priv.attributes); + free(priv.regex); + /* success */ + return 0; + } + return -ENOENT; /* not found in list */ +} +#else + +/* + * Search for the last exactly matching name in an attribute list + */ +static int reverse_name_search(const char *searched, const char *search_for, + const char **result) +{ + int result_size = 0; + const char *cur_searched = searched; + + if (result) + *result = NULL; + + if (*search_for == '\0') { + if (result) + *result = searched; + return strlen(searched); + } + + for (;;) { + const char *match = strstr(cur_searched, search_for); + const char *prevch; + const char *nextch; + + /* Stop looking if no new match is found */ + if (match == NULL) + break; + + prevch = match - 1; + nextch = match + strlen(search_for); /* Skip spaces */ - while (*prevch == ' ') + while (*prevch == ' ' && prevch >= searched) prevch--; while (*nextch == ' ') nextch++; - /* check for an exact match */ - if ((entry == attr_list || - *prevch == ENV_ATTR_LIST_DELIM) && - (*nextch == ENV_ATTR_SEP || - *nextch == ENV_ATTR_LIST_DELIM || - *nextch == '\0')) - break; + /* Start looking past the current match so last is found */ + cur_searched = match + 1; + /* Check for an exact match */ + if (match != searched && + *prevch != ENV_ATTR_LIST_DELIM && + prevch != searched - 1) + continue; + if (*nextch != ENV_ATTR_SEP && + *nextch != ENV_ATTR_LIST_DELIM && + *nextch != '\0') + continue; - entry = reverse_strstr(attr_list, name, entry); + if (result) + *result = match; + result_size = strlen(search_for); } + + return result_size; +} + +/* + * Retrieve the attributes string associated with a single name in the list + * There is no protection on attributes being too small for the value + */ +int env_attr_lookup(const char *attr_list, const char *name, char *attributes) +{ + const char *entry = NULL; + int entry_len; + + if (!attributes) + /* bad parameter */ + return -EINVAL; + if (!attr_list) + /* list not found */ + return -EINVAL; + + entry_len = reverse_name_search(attr_list, name, &entry); if (entry != NULL) { int len; /* skip the name */ - entry += strlen(name); + entry += entry_len; /* skip spaces */ while (*entry == ' ') entry++; @@ -209,5 +301,6 @@ int env_attr_lookup(const char *attr_list, const char *name, char *attributes) } /* not found in list */ - return 2; + return -ENOENT; } +#endif diff --git a/common/env_callback.c b/common/env_callback.c index d03fa03a43..f4d3dbd77f 100644 --- a/common/env_callback.c +++ b/common/env_callback.c @@ -90,7 +90,7 @@ static int clear_callback(ENTRY *entry) /* * Call for each element in the list that associates variables to callbacks */ -static int set_callback(const char *name, const char *value) +static int set_callback(const char *name, const char *value, void *priv) { ENTRY e, *ep; struct env_clbk_tbl *clbkp; @@ -126,9 +126,9 @@ static int on_callbacks(const char *name, const char *value, enum env_op op, hwalk_r(&env_htab, clear_callback); /* configure any static callback bindings */ - env_attr_walk(ENV_CALLBACK_LIST_STATIC, set_callback); + env_attr_walk(ENV_CALLBACK_LIST_STATIC, set_callback, NULL); /* configure any dynamic callback bindings */ - env_attr_walk(value, set_callback); + env_attr_walk(value, set_callback, NULL); return 0; } diff --git a/common/env_flags.c b/common/env_flags.c index 985f92e50e..5189f5b2dd 100644 --- a/common/env_flags.c +++ b/common/env_flags.c @@ -435,7 +435,7 @@ static int clear_flags(ENTRY *entry) /* * Call for each element in the list that defines flags for a variable */ -static int set_flags(const char *name, const char *value) +static int set_flags(const char *name, const char *value, void *priv) { ENTRY e, *ep; @@ -463,9 +463,9 @@ static int on_flags(const char *name, const char *value, enum env_op op, hwalk_r(&env_htab, clear_flags); /* configure any static flags */ - env_attr_walk(ENV_FLAGS_LIST_STATIC, set_flags); + env_attr_walk(ENV_FLAGS_LIST_STATIC, set_flags, NULL); /* configure any dynamic flags */ - env_attr_walk(value, set_flags); + env_attr_walk(value, set_flags, NULL); return 0; } diff --git a/configs/bct-brettl2_defconfig b/configs/bct-brettl2_defconfig index 26b145d30a..84eb1febde 100644 --- a/configs/bct-brettl2_defconfig +++ b/configs/bct-brettl2_defconfig @@ -1,3 +1,4 @@ CONFIG_BLACKFIN=y -CONFIG_TARGET_BCT_BRETTL2=y +CONFIG_NET=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/bf518f-ezbrd_defconfig b/configs/bf518f-ezbrd_defconfig index fb35ad023d..51f93f8456 100644 --- a/configs/bf518f-ezbrd_defconfig +++ b/configs/bf518f-ezbrd_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF518F_EZBRD=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/bf526-ezbrd_defconfig b/configs/bf526-ezbrd_defconfig index da06d3ad6e..245faacfcc 100644 --- a/configs/bf526-ezbrd_defconfig +++ b/configs/bf526-ezbrd_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF526_EZBRD=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/bf527-ezkit_defconfig b/configs/bf527-ezkit_defconfig index 69f6ef781b..0451c64391 100644 --- a/configs/bf527-ezkit_defconfig +++ b/configs/bf527-ezkit_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF527_EZKIT=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/bf537-minotaur_defconfig b/configs/bf537-minotaur_defconfig index e76118fbd3..1f398a00d1 100644 --- a/configs/bf537-minotaur_defconfig +++ b/configs/bf537-minotaur_defconfig @@ -1,2 +1,4 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF537_MINOTAUR=y +CONFIG_NET_RANDOM_ETHADDR=y diff --git a/configs/bf537-pnav_defconfig b/configs/bf537-pnav_defconfig index ba5eaaa392..63722589b8 100644 --- a/configs/bf537-pnav_defconfig +++ b/configs/bf537-pnav_defconfig @@ -1,2 +1,4 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF537_PNAV=y +CONFIG_NET_RANDOM_ETHADDR=y diff --git a/configs/bf537-srv1_defconfig b/configs/bf537-srv1_defconfig index 61ac0e7d0e..f007c8269e 100644 --- a/configs/bf537-srv1_defconfig +++ b/configs/bf537-srv1_defconfig @@ -1,2 +1,4 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF537_SRV1=y +CONFIG_NET_RANDOM_ETHADDR=y diff --git a/configs/bf537-stamp_defconfig b/configs/bf537-stamp_defconfig index 9b9a92f13f..50483b18ff 100644 --- a/configs/bf537-stamp_defconfig +++ b/configs/bf537-stamp_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_BF537_STAMP=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/cm-bf527_defconfig b/configs/cm-bf527_defconfig index a6830b54fd..5bceb17bc9 100644 --- a/configs/cm-bf527_defconfig +++ b/configs/cm-bf527_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_CM_BF527=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/cm-bf537e_defconfig b/configs/cm-bf537e_defconfig index a44eab7f0d..fd9dd00d3e 100644 --- a/configs/cm-bf537e_defconfig +++ b/configs/cm-bf537e_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_CM_BF537E=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/cm-bf537u_defconfig b/configs/cm-bf537u_defconfig index 29c33b9514..4a8f123bb0 100644 --- a/configs/cm-bf537u_defconfig +++ b/configs/cm-bf537u_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_CM_BF537U=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/dnp5370_defconfig b/configs/dnp5370_defconfig index 0c00087631..c7104caef8 100644 --- a/configs/dnp5370_defconfig +++ b/configs/dnp5370_defconfig @@ -1,2 +1,4 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_DNP5370=y +CONFIG_NET_RANDOM_ETHADDR=y diff --git a/configs/ga10h_v1_1_defconfig b/configs/ga10h_v1_1_defconfig new file mode 100644 index 0000000000..3eca0237f3 --- /dev/null +++ b/configs/ga10h_v1_1_defconfig @@ -0,0 +1,29 @@ +# The ga10h is an 10" tablet with an A33 or A23 soc, 1G RAM, 8G or 16G nand, +# sdio wifi, 2 micro usb ports, 1 otg and 1 host and 1 micro sd slot. +# +# This defconfig is for the v1.1 pcb with an a33 soc. +CONFIG_SPL=y +CONFIG_SYS_EXTRA_OPTIONS="CONS_INDEX=5" +CONFIG_DEFAULT_DEVICE_TREE="sun8i-a33-ippo-q8h-v1.2-lcd1024x600" +CONFIG_USB_MUSB_SUNXI=y +CONFIG_USB0_VBUS_PIN="AXP0-VBUS-ENABLE" +CONFIG_USB0_VBUS_DET="AXP0-VBUS-DETECT" +CONFIG_AXP_GPIO=y +CONFIG_VIDEO_LCD_MODE="x:1024,y:600,depth:18,pclk_khz:52000,le:138,ri:162,up:22,lo:10,hs:20,vs:3,sync:3,vmode:0" +CONFIG_VIDEO_LCD_PANEL_LVDS=y +CONFIG_VIDEO_LCD_DCLK_PHASE=0 +CONFIG_VIDEO_LCD_POWER="PH7" +CONFIG_VIDEO_LCD_BL_EN="PH6" +CONFIG_VIDEO_LCD_BL_PWM="PH0" +#CONFIG_VIDEO_LCD_BL_PWM_ACTIVE_LOW=n +CONFIG_ARM=y +CONFIG_ARCH_SUNXI=y +CONFIG_MACH_SUN8I_A33=y +CONFIG_DRAM_CLK=432 +# zq = 0x3bbb +CONFIG_DRAM_ZQ=15291 +CONFIG_DRAM_ODT_EN=y +# Wifi power +CONFIG_AXP221_DLDO1_VOLT=3300 +# aldo1 is connected to VCC-IO, VCC-PD, VCC-USB and VCC-HP +CONFIG_AXP221_ALDO1_VOLT=3000 diff --git a/configs/ip04_defconfig b/configs/ip04_defconfig index ba737aedfb..69110a3cb7 100644 --- a/configs/ip04_defconfig +++ b/configs/ip04_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_IP04=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/lschlv2_defconfig b/configs/lschlv2_defconfig index efd8fcaa48..31452a3463 100644 --- a/configs/lschlv2_defconfig +++ b/configs/lschlv2_defconfig @@ -1,4 +1,6 @@ CONFIG_ARM=y CONFIG_KIRKWOOD=y CONFIG_TARGET_LSXL=y +CONFIG_NET=y CONFIG_SYS_EXTRA_OPTIONS="LSCHLV2" +CONFIG_NET_RANDOM_ETHADDR=y diff --git a/configs/lsxhl_defconfig b/configs/lsxhl_defconfig index bb3a80e873..00f48bcc47 100644 --- a/configs/lsxhl_defconfig +++ b/configs/lsxhl_defconfig @@ -1,4 +1,6 @@ CONFIG_ARM=y CONFIG_KIRKWOOD=y CONFIG_TARGET_LSXL=y +CONFIG_NET=y CONFIG_SYS_EXTRA_OPTIONS="LSXHL" +CONFIG_NET_RANDOM_ETHADDR=y diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index f8dac33a4a..e1d495c89f 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -1,4 +1,7 @@ CONFIG_DM_USB=y +CONFIG_NET=y +CONFIG_NETDEVICES=y +CONFIG_DM_ETH=y CONFIG_PCI=y CONFIG_SYS_VSNPRINTF=y CONFIG_DEFAULT_DEVICE_TREE="sandbox" @@ -8,6 +11,8 @@ CONFIG_FIT=y CONFIG_FIT_VERBOSE=y CONFIG_FIT_SIGNATURE=y CONFIG_CMD_SOUND=y +CONFIG_CMD_PMIC=y +CONFIG_CMD_REGULATOR=y CONFIG_OF_CONTROL=y CONFIG_OF_HOSTFILE=y CONFIG_DM_PCI=y @@ -21,17 +26,18 @@ CONFIG_TPM_TIS_SANDBOX=y CONFIG_SYS_I2C_SANDBOX=y CONFIG_SANDBOX_SPI=y CONFIG_SANDBOX_GPIO=y +CONFIG_DM_PMIC=y +CONFIG_DM_PMIC_SANDBOX=y +CONFIG_DM_REGULATOR=y +CONFIG_DM_REGULATOR_SANDBOX=y CONFIG_SOUND=y CONFIG_SOUND_SANDBOX=y CONFIG_USB=y CONFIG_USB_EMUL=y CONFIG_USB_STORAGE=y CONFIG_DM_RTC=y -CONFIG_CMD_UT_TIME=y CONFIG_ERRNO_STR=y -CONFIG_DM_PMIC=y -CONFIG_DM_PMIC_SANDBOX=y -CONFIG_CMD_PMIC=y -CONFIG_DM_REGULATOR=y -CONFIG_DM_REGULATOR_SANDBOX=y -CONFIG_CMD_REGULATOR=y +CONFIG_UNIT_TEST=y +CONFIG_UT_TIME=y +CONFIG_UT_DM=y +CONFIG_UT_ENV=y diff --git a/configs/tcm-bf518_defconfig b/configs/tcm-bf518_defconfig index 0c9ae4d57e..f16d863435 100644 --- a/configs/tcm-bf518_defconfig +++ b/configs/tcm-bf518_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_TCM_BF518=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/configs/tcm-bf537_defconfig b/configs/tcm-bf537_defconfig index 6d604b6c9e..7f3a3a67a6 100644 --- a/configs/tcm-bf537_defconfig +++ b/configs/tcm-bf537_defconfig @@ -1,3 +1,5 @@ CONFIG_BLACKFIN=y +CONFIG_NET=y CONFIG_TARGET_TCM_BF537=y +CONFIG_NET_RANDOM_ETHADDR=y CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED=y diff --git a/doc/README.enetaddr b/doc/README.enetaddr index 0fafd2cdcd..50e4899787 100644 --- a/doc/README.enetaddr +++ b/doc/README.enetaddr @@ -15,7 +15,7 @@ Here are the places where MAC addresses might be stored: - board-specific location (eeprom, dedicated flash, ...) Note: only used when mandatory due to hardware design etc... - - environment ("ethaddr", "eth1addr", ...) (see CONFIG_ETHADDR) + - environment ("ethaddr", "eth1addr", ...) Note: this is the preferred way to permanently store MAC addresses - ethernet data (struct eth_device -> enetaddr) @@ -37,6 +37,8 @@ Correct flow of setting up the MAC address (summarized): environment variable will be used unchanged. If the environment variable is not set, it will be initialized from eth_device->enetaddr, and a warning will be printed. + If both are invalid and CONFIG_NET_RANDOM_ETHADDR is defined, a random, + locally-assigned MAC is written to eth_device->enetaddr. 4. Program the address into hardware if the following conditions are met: a) The relevant driver has a 'write_addr' function b) The user hasn't set an 'ethmacskip' environment variable diff --git a/doc/README.scrapyard b/doc/README.scrapyard index aa2b07b4ba..a62bd0ba4c 100644 --- a/doc/README.scrapyard +++ b/doc/README.scrapyard @@ -12,9 +12,11 @@ The list should be sorted in reverse chronological order. Board Arch CPU Commit Removed Last known maintainer/contact ================================================================================================= -afeb9260 arm arm926ejs - - Sergey Lapin <slapin@ossfans.org> -tny_a9260 arm arm926ejs - - Albin Tonnerre <albin.tonnerre@free-electrons.com> -sbc35_a9g20 arm arm926ejs - - Albin Tonnerre <albin.tonnerre@free-electrons.com> +afeb9260 arm arm926ejs f6b42c14 2015-05-13 Sergey Lapin <slapin@ossfans.org> +tny_a9260 arm arm926ejs f6b42c14 2015-05-13 Albin Tonnerre <albin.tonnerre@free-electrons.com> +sbc35_a9g20 arm arm926ejs f6b42c14 2015-05-13 Albin Tonnerre <albin.tonnerre@free-electrons.com> +sc3 powerpc ppc4xx 27e72156 2015-05-10 Heiko Schocher <hs@denx.de> +T4240EMU powerpc mpc85xx 7fc63cca 2015-05-05 York Sun <yorksun@freescale.com> korat powerpc ppc4xx 5043045d 2015-03-17 Larry Johnson <lrj@acm.org> galaxy5200 powerpc mpc5xxx 41eb4e5c 2015-03-17 Eric Millbrandt <emillbrandt@dekaresearch.com> W7OLMC powerpc ppc4xx 6beecd5d 2015-03-17 Erik Theisen <etheisen@mindspring.com> diff --git a/drivers/net/bcm-sf2-eth.c b/drivers/net/bcm-sf2-eth.c index 51d5146363..eab4c1f900 100644 --- a/drivers/net/bcm-sf2-eth.c +++ b/drivers/net/bcm-sf2-eth.c @@ -154,12 +154,6 @@ static int bcm_sf2_eth_open(struct eth_device *dev, bd_t *bt) debug("Enabling BCM SF2 Ethernet.\n"); - /* Set MAC address from env */ - if (bcm_sf2_eth_write_hwaddr(dev) != 0) { - error("%s: MAC set error when opening !\n", __func__); - return -1; - } - eth->enable_mac(); /* enable tx and rx DMA */ diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 07281a6ce9..ae51cf3781 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -243,10 +243,6 @@ static int _dw_eth_init(struct dw_eth_dev *priv, u8 *enetaddr) mdelay(100); }; - /* Soft reset above clears HW address registers. - * So we have to set it here once again */ - _dw_write_hwaddr(priv, enetaddr); - rx_descs_init(priv); tx_descs_init(priv); diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c index ccd2131f88..3c41cec3e4 100644 --- a/drivers/net/dm9000x.c +++ b/drivers/net/dm9000x.c @@ -343,13 +343,7 @@ static int dm9000_init(struct eth_device *dev, bd_t *bd) printf("MAC: %pM\n", dev->enetaddr); if (!is_valid_ethaddr(dev->enetaddr)) { -#ifdef CONFIG_RANDOM_MACADDR - printf("Bad MAC address (uninitialized EEPROM?), randomizing\n"); - net_random_ethaddr(dev->enetaddr); - printf("MAC: %pM\n", dev->enetaddr); -#else printf("WARNING: Bad MAC address (uninitialized EEPROM?)\n"); -#endif } /* fill device MAC address registers */ diff --git a/drivers/net/ftmac110.c b/drivers/net/ftmac110.c index 4bae9ad977..4f17015bc5 100644 --- a/drivers/net/ftmac110.c +++ b/drivers/net/ftmac110.c @@ -424,9 +424,6 @@ int ftmac110_initialize(bd_t *bis) dev->send = ftmac110_send; dev->recv = ftmac110_recv; - if (!eth_getenv_enetaddr_by_index("eth", card_nr, dev->enetaddr)) - net_random_ethaddr(dev->enetaddr); - /* allocate tx descriptors (it must be 16 bytes aligned) */ chip->txd = dma_alloc_coherent( sizeof(struct ftmac110_desc) * CFG_TXDES_NUM, &chip->txd_dma); diff --git a/drivers/net/greth.c b/drivers/net/greth.c index a93b37a5d7..9bc8a8d1aa 100644 --- a/drivers/net/greth.c +++ b/drivers/net/greth.c @@ -12,6 +12,7 @@ #include <common.h> #include <command.h> +#include <errno.h> #include <net.h> #include <netdev.h> #include <malloc.h> @@ -653,13 +654,8 @@ int greth_initialize(bd_t * bis) } } } else { - /* HW Address not found in environment, Set default HW address */ - addr[0] = GRETH_HWADDR_0; /* MSB */ - addr[1] = GRETH_HWADDR_1; - addr[2] = GRETH_HWADDR_2; - addr[3] = GRETH_HWADDR_3; - addr[4] = GRETH_HWADDR_4; - addr[5] = GRETH_HWADDR_5; /* LSB */ + /* No ethaddr set */ + return -EINVAL; } /* set and remember MAC address */ diff --git a/drivers/net/lan91c96.c b/drivers/net/lan91c96.c index 495c0886fa..c4dd01ec2a 100644 --- a/drivers/net/lan91c96.c +++ b/drivers/net/lan91c96.c @@ -725,12 +725,6 @@ static int smc_get_ethaddr(bd_t *bd, struct eth_device *dev) static int get_rom_mac(struct eth_device *dev, unsigned char *v_rom_mac) { -#ifdef HARDCODE_MAC /* used for testing or to supress run time warnings */ - char hw_mac_addr[] = { 0x02, 0x80, 0xad, 0x20, 0x31, 0xb8 }; - - memcpy (v_rom_mac, hw_mac_addr, 6); - return (1); -#else int i; SMC_SELECT_BANK(dev, 1); for (i=0; i<6; i++) @@ -738,7 +732,6 @@ static int get_rom_mac(struct eth_device *dev, unsigned char *v_rom_mac) v_rom_mac[i] = SMC_inb(dev, LAN91C96_IA0 + i); } return (1); -#endif } /* Structure to detect the device IDs */ diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 4e1a7fe583..f949161738 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -525,7 +525,6 @@ static int macb_phy_init(struct macb_device *macb) return 1; } -static int macb_write_hwaddr(struct eth_device *dev); static int macb_init(struct eth_device *netdev, bd_t *bd) { struct macb_device *macb = to_macb(netdev); @@ -594,14 +593,6 @@ static int macb_init(struct eth_device *netdev, bd_t *bd) #endif /* CONFIG_RMII */ } - /* update the ethaddr */ - if (is_valid_ethaddr(netdev->enetaddr)) { - macb_write_hwaddr(netdev); - } else { - printf("%s: mac address is not valid\n", netdev->name); - return -1; - } - if (!macb_phy_init(macb)) return -1; diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index f5221a3833..c8d08e8f4f 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -21,6 +21,8 @@ #include <linux/err.h> #include <linux/compiler.h> +DECLARE_GLOBAL_DATA_PTR; + /* Generic PHY support and helper functions */ /** @@ -494,6 +496,20 @@ int phy_register(struct phy_driver *drv) INIT_LIST_HEAD(&drv->list); list_add_tail(&drv->list, &phy_drivers); +#ifdef CONFIG_NEEDS_MANUAL_RELOC + if (drv->probe) + drv->probe += gd->reloc_off; + if (drv->config) + drv->config += gd->reloc_off; + if (drv->startup) + drv->startup += gd->reloc_off; + if (drv->shutdown) + drv->shutdown += gd->reloc_off; + if (drv->readext) + drv->readext += gd->reloc_off; + if (drv->writeext) + drv->writeext += gd->reloc_off; +#endif return 0; } diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index ee9707950a..79452a8df3 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -29,6 +29,19 @@ /* RTL8211x PHY Interrupt Status Register */ #define MIIM_RTL8211x_PHY_INSR 0x13 +/* RTL8211F PHY Status Register */ +#define MIIM_RTL8211F_PHY_STATUS 0x1a +#define MIIM_RTL8211F_AUTONEG_ENABLE 0x1000 +#define MIIM_RTL8211F_PHYSTAT_SPEED 0x0030 +#define MIIM_RTL8211F_PHYSTAT_GBIT 0x0020 +#define MIIM_RTL8211F_PHYSTAT_100 0x0010 +#define MIIM_RTL8211F_PHYSTAT_DUPLEX 0x0008 +#define MIIM_RTL8211F_PHYSTAT_SPDDONE 0x0800 +#define MIIM_RTL8211F_PHYSTAT_LINK 0x0004 + +#define MIIM_RTL8211F_PAGE_SELECT 0x1f +#define MIIM_RTL8211F_TX_DELAY 0x100 + /* RealTek RTL8211x */ static int rtl8211x_config(struct phy_device *phydev) { @@ -48,6 +61,29 @@ static int rtl8211x_config(struct phy_device *phydev) return 0; } +static int rtl8211f_config(struct phy_device *phydev) +{ + u16 reg; + + phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET); + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII) { + /* enable TXDLY */ + phy_write(phydev, MDIO_DEVAD_NONE, + MIIM_RTL8211F_PAGE_SELECT, 0xd08); + reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x11); + reg |= MIIM_RTL8211F_TX_DELAY; + phy_write(phydev, MDIO_DEVAD_NONE, 0x11, reg); + /* restore to default page 0 */ + phy_write(phydev, MDIO_DEVAD_NONE, + MIIM_RTL8211F_PAGE_SELECT, 0x0); + } + + genphy_config_aneg(phydev); + + return 0; +} + static int rtl8211x_parse_status(struct phy_device *phydev) { unsigned int speed; @@ -105,6 +141,51 @@ static int rtl8211x_parse_status(struct phy_device *phydev) return 0; } +static int rtl8211f_parse_status(struct phy_device *phydev) +{ + unsigned int speed; + unsigned int mii_reg; + int i = 0; + + phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, 0xa43); + mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PHY_STATUS); + + phydev->link = 1; + while (!(mii_reg & MIIM_RTL8211F_PHYSTAT_LINK)) { + if (i > PHY_AUTONEGOTIATE_TIMEOUT) { + puts(" TIMEOUT !\n"); + phydev->link = 0; + break; + } + + if ((i++ % 1000) == 0) + putc('.'); + udelay(1000); + mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, + MIIM_RTL8211F_PHY_STATUS); + } + + if (mii_reg & MIIM_RTL8211F_PHYSTAT_DUPLEX) + phydev->duplex = DUPLEX_FULL; + else + phydev->duplex = DUPLEX_HALF; + + speed = (mii_reg & MIIM_RTL8211F_PHYSTAT_SPEED); + + switch (speed) { + case MIIM_RTL8211F_PHYSTAT_GBIT: + phydev->speed = SPEED_1000; + break; + case MIIM_RTL8211F_PHYSTAT_100: + phydev->speed = SPEED_100; + break; + default: + phydev->speed = SPEED_10; + } + + return 0; +} + static int rtl8211x_startup(struct phy_device *phydev) { /* Read the Status (2x to make sure link is right) */ @@ -114,6 +195,15 @@ static int rtl8211x_startup(struct phy_device *phydev) return 0; } +static int rtl8211f_startup(struct phy_device *phydev) +{ + /* Read the Status (2x to make sure link is right) */ + genphy_update_link(phydev); + rtl8211f_parse_status(phydev); + + return 0; +} + /* Support for RTL8211B PHY */ static struct phy_driver RTL8211B_driver = { .name = "RealTek RTL8211B", @@ -147,10 +237,22 @@ static struct phy_driver RTL8211DN_driver = { .shutdown = &genphy_shutdown, }; +/* Support for RTL8211F PHY */ +static struct phy_driver RTL8211F_driver = { + .name = "RealTek RTL8211F", + .uid = 0x1cc916, + .mask = 0xffffff, + .features = PHY_GBIT_FEATURES, + .config = &rtl8211f_config, + .startup = &rtl8211f_startup, + .shutdown = &genphy_shutdown, +}; + int phy_realtek_init(void) { phy_register(&RTL8211B_driver); phy_register(&RTL8211E_driver); + phy_register(&RTL8211F_driver); phy_register(&RTL8211DN_driver); return 0; diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c index 48dbdf5795..269083b666 100644 --- a/drivers/video/sunxi_display.c +++ b/drivers/video/sunxi_display.c @@ -558,8 +558,12 @@ static void sunxi_lcdc_init(void) /* Clock on */ setbits_le32(&ccm->ahb_gate1, 1 << AHB_GATE_OFFSET_LCD0); #ifdef CONFIG_VIDEO_LCD_IF_LVDS +#ifdef CONFIG_SUNXI_GEN_SUN6I + setbits_le32(&ccm->ahb_reset2_cfg, 1 << AHB_RESET_OFFSET_LVDS); +#else setbits_le32(&ccm->lvds_clk_cfg, CCM_LVDS_CTRL_RST); #endif +#endif /* Init lcdc */ writel(0, &lcdc->ctrl); /* Disable tcon */ @@ -582,6 +586,16 @@ static void sunxi_lcdc_enable(void) #ifdef CONFIG_VIDEO_LCD_IF_LVDS setbits_le32(&lcdc->tcon0_lvds_intf, SUNXI_LCDC_TCON0_LVDS_INTF_ENABLE); setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0); +#ifdef CONFIG_SUNXI_GEN_SUN6I + udelay(2); /* delay at least 1200 ns */ + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_EN_MB); + udelay(2); /* delay at least 1200 ns */ + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_DRVC); + if (sunxi_display.depth == 18) + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_DRVD(0x7)); + else + setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_DRVD(0xf)); +#else setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_UPDATE); udelay(2); /* delay at least 1200 ns */ setbits_le32(&lcdc->lvds_ana1, SUNXI_LCDC_LVDS_ANA1_INIT1); @@ -589,6 +603,7 @@ static void sunxi_lcdc_enable(void) setbits_le32(&lcdc->lvds_ana1, SUNXI_LCDC_LVDS_ANA1_INIT2); setbits_le32(&lcdc->lvds_ana0, SUNXI_LCDC_LVDS_ANA0_UPDATE); #endif +#endif } static void sunxi_lcdc_panel_enable(void) @@ -706,7 +721,8 @@ static void sunxi_lcdc_tcon0_mode_set(const struct ctfb_res_modes *mode, #endif #ifdef CONFIG_VIDEO_LCD_IF_LVDS val = (sunxi_display.depth == 18) ? 1 : 0; - writel(SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(val), &lcdc->tcon0_lvds_intf); + writel(SUNXI_LCDC_TCON0_LVDS_INTF_BITWIDTH(val) | + SUNXI_LCDC_TCON0_LVDS_CLK_SEL_TCON0, &lcdc->tcon0_lvds_intf); #endif if (sunxi_display.depth == 18 || sunxi_display.depth == 16) { diff --git a/examples/standalone/README.smc91111_eeprom b/examples/standalone/README.smc91111_eeprom index a2d52e7770..f73a8d3a58 100644 --- a/examples/standalone/README.smc91111_eeprom +++ b/examples/standalone/README.smc91111_eeprom @@ -27,29 +27,6 @@ To find out who has a MAC address, or to purchase MAC addresses, goto the IEEE, at: http://standards.ieee.org/regauth/oui/index.shtml -To change your MAC address, there can not be a MAC address predefined in -U-Boot. To ensure that this does not occur, check your -include/configs/<board_name>.h file, and check to see that the following -settings are _not_ or commented out there. - -#define HARDCODE_MAC 1 -#define CONFIG_ETHADDR 02:80:ad:20:31:b8 - -The purpose of HARDCODE_MAC is to hardcode the MAC address in software, -(not what we want), or to preset it to 02:80:ad:20:31:b8 (not what we -want either). - -You can check this in a running U-Boot, by doing a power cycle, then -before U-Boot tries to do any networking, running the 'printenv' command - - BOOT> printenv - - ethaddr=02:80:ad:20:31:b8 - -If you see the 'ethaddr' variable show up, like the above, you need to -recompile U-Boot, with the above settings commented out of the -include/configs/<board_name>.h file. - 2. Running the smc91111_eeprom program --------------------------------------------------------------------- diff --git a/include/configs/M5208EVBE.h b/include/configs/M5208EVBE.h index 7eac03baaf..d0f4d758b7 100644 --- a/include/configs/M5208EVBE.h +++ b/include/configs/M5208EVBE.h @@ -74,12 +74,10 @@ #define CONFIG_UDP_CHECKSUM #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* CONFIG_MCFFEC */ #define CONFIG_HOSTNAME M5208EVBe diff --git a/include/configs/M5235EVB.h b/include/configs/M5235EVB.h index 4bba81544f..a76632494c 100644 --- a/include/configs/M5235EVB.h +++ b/include/configs/M5235EVB.h @@ -95,12 +95,10 @@ #define CONFIG_BOOTDELAY 1 /* autoboot after 5 seconds */ #define CONFIG_BOOTFILE "u-boot.bin" #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* FEC_ENET */ #define CONFIG_HOSTNAME M5235EVB diff --git a/include/configs/M5272C3.h b/include/configs/M5272C3.h index 159d2f8ced..9946108c12 100644 --- a/include/configs/M5272C3.h +++ b/include/configs/M5272C3.h @@ -94,12 +94,10 @@ #endif #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* CONFIG_MCFFEC */ #define CONFIG_HOSTNAME M5272C3 diff --git a/include/configs/M5282EVB.h b/include/configs/M5282EVB.h index bc740ae905..4d3390b1f0 100644 --- a/include/configs/M5282EVB.h +++ b/include/configs/M5282EVB.h @@ -80,12 +80,10 @@ #define CONFIG_BOOTDELAY 5 #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* CONFIG_MCFFEC */ #define CONFIG_HOSTNAME M5282EVB diff --git a/include/configs/M53017EVB.h b/include/configs/M53017EVB.h index 0829708412..e2dd8e5555 100644 --- a/include/configs/M53017EVB.h +++ b/include/configs/M53017EVB.h @@ -94,13 +94,10 @@ #define CONFIG_UDP_CHECKSUM #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 -# define CONFIG_ETH1ADDR 00:e0:0c:bc:e5:61 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* FEC_ENET */ #define CONFIG_HOSTNAME M53017 diff --git a/include/configs/M5329EVB.h b/include/configs/M5329EVB.h index a42b5f6b47..5a7597c239 100644 --- a/include/configs/M5329EVB.h +++ b/include/configs/M5329EVB.h @@ -88,12 +88,10 @@ #define CONFIG_UDP_CHECKSUM #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* FEC_ENET */ #define CONFIG_HOSTNAME M5329EVB diff --git a/include/configs/M5373EVB.h b/include/configs/M5373EVB.h index c142dfbe23..7550c571b8 100644 --- a/include/configs/M5373EVB.h +++ b/include/configs/M5373EVB.h @@ -88,12 +88,10 @@ #define CONFIG_UDP_CHECKSUM #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* FEC_ENET */ #define CONFIG_HOSTNAME M5373EVB diff --git a/include/configs/M54418TWR.h b/include/configs/M54418TWR.h index 3a6e9811d5..25b3cdac42 100644 --- a/include/configs/M54418TWR.h +++ b/include/configs/M54418TWR.h @@ -113,15 +113,12 @@ "::eth0:off:rw console=ttyS0,115200" #endif -#define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 -#define CONFIG_ETH1ADDR 00:e0:0c:bc:e5:61 #define CONFIG_ETHPRIME "FEC0" #define CONFIG_IPADDR 192.168.1.2 #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_SERVERIP 192.168.1.1 #define CONFIG_GATEWAYIP 192.168.1.1 -#define CONFIG_OVERWRITE_ETHADDR_ONCE #define CONFIG_SYS_FEC_BUF_USE_SRAM /* If CONFIG_SYS_DISCOVER_PHY is not defined - hardcoded */ #ifndef CONFIG_SYS_DISCOVER_PHY diff --git a/include/configs/M54451EVB.h b/include/configs/M54451EVB.h index 1b3598a092..f3cade380e 100644 --- a/include/configs/M54451EVB.h +++ b/include/configs/M54451EVB.h @@ -77,13 +77,11 @@ # define CONFIG_BOOTDELAY 1 /* autoboot after 5 seconds */ # define CONFIG_BOOTARGS "root=/dev/mtdblock1 rw rootfstype=jffs2 ip=none mtdparts=physmap-flash.0:2M(kernel)ro,-(jffs2)" -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_ETHPRIME "FEC0" # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE /* If CONFIG_SYS_DISCOVER_PHY is not defined - hardcoded */ # ifndef CONFIG_SYS_DISCOVER_PHY diff --git a/include/configs/M54455EVB.h b/include/configs/M54455EVB.h index 2288bff56d..b708001251 100644 --- a/include/configs/M54455EVB.h +++ b/include/configs/M54455EVB.h @@ -83,14 +83,11 @@ # define CONFIG_BOOTDELAY 1 /* autoboot after 5 seconds */ # define CONFIG_BOOTARGS "root=/dev/mtdblock1 rw rootfstype=jffs2 ip=none mtdparts=physmap-flash.0:5M(kernel)ro,-(jffs2)" -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 -# define CONFIG_ETH1ADDR 00:e0:0c:bc:e5:61 # define CONFIG_ETHPRIME "FEC0" # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE /* If CONFIG_SYS_DISCOVER_PHY is not defined - hardcoded */ # ifndef CONFIG_SYS_DISCOVER_PHY diff --git a/include/configs/M5475EVB.h b/include/configs/M5475EVB.h index 91d6a1ada9..658c170c92 100644 --- a/include/configs/M5475EVB.h +++ b/include/configs/M5475EVB.h @@ -75,13 +75,10 @@ # endif # endif /* CONFIG_SYS_DISCOVER_PHY */ -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 -# define CONFIG_ETH1ADDR 00:e0:0c:bc:e5:61 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif @@ -135,12 +132,10 @@ #define CONFIG_UDP_CHECKSUM #ifdef CONFIG_MCFFEC -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif /* FEC_ENET */ #define CONFIG_HOSTNAME M547xEVB diff --git a/include/configs/M5485EVB.h b/include/configs/M5485EVB.h index ce9f3b01b2..efb64a14ce 100644 --- a/include/configs/M5485EVB.h +++ b/include/configs/M5485EVB.h @@ -75,13 +75,10 @@ # endif # endif /* CONFIG_SYS_DISCOVER_PHY */ -# define CONFIG_ETHADDR 00:e0:0c:bc:e5:60 -# define CONFIG_ETH1ADDR 00:e0:0c:bc:e5:61 # define CONFIG_IPADDR 192.162.1.2 # define CONFIG_NETMASK 255.255.255.0 # define CONFIG_SERVERIP 192.162.1.1 # define CONFIG_GATEWAYIP 192.162.1.1 -# define CONFIG_OVERWRITE_ETHADDR_ONCE #endif diff --git a/include/configs/MPC8536DS.h b/include/configs/MPC8536DS.h index dc09b1f870..d41eeb59b6 100644 --- a/include/configs/MPC8536DS.h +++ b/include/configs/MPC8536DS.h @@ -720,13 +720,9 @@ /* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:02:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:02:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:02:02:FD #define CONFIG_HAS_ETH3 -#define CONFIG_ETH3ADDR 00:E0:0C:02:03:FD #endif #define CONFIG_IPADDR 192.168.1.254 diff --git a/include/configs/MPC8540ADS.h b/include/configs/MPC8540ADS.h index 37c2b9415a..b388168a11 100644 --- a/include/configs/MPC8540ADS.h +++ b/include/configs/MPC8540ADS.h @@ -12,7 +12,7 @@ * Please refer to doc/README.mpc85xx for more info. * * Make sure you change the MAC address and other network params first, - * search for CONFIG_ETHADDR, CONFIG_SERVERIP, etc in this file. + * search for CONFIG_SERVERIP, etc in this file. */ #ifndef __CONFIG_H @@ -406,11 +406,8 @@ /* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD #endif #define CONFIG_IPADDR 192.168.1.253 diff --git a/include/configs/MPC8541CDS.h b/include/configs/MPC8541CDS.h index 5d229a0d20..609c5bb3be 100644 --- a/include/configs/MPC8541CDS.h +++ b/include/configs/MPC8541CDS.h @@ -418,11 +418,8 @@ extern unsigned long get_clock_freq(void); /* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD #endif #define CONFIG_IPADDR 192.168.1.253 diff --git a/include/configs/MPC8544DS.h b/include/configs/MPC8544DS.h index dade6d3b89..479589e385 100644 --- a/include/configs/MPC8544DS.h +++ b/include/configs/MPC8544DS.h @@ -449,9 +449,7 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); /* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:02:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:02:01:FD #endif #define CONFIG_IPADDR 192.168.1.251 diff --git a/include/configs/MPC8548CDS.h b/include/configs/MPC8548CDS.h index 190c668303..fb28512340 100644 --- a/include/configs/MPC8548CDS.h +++ b/include/configs/MPC8548CDS.h @@ -539,17 +539,11 @@ extern unsigned long get_clock_freq(void); /* * Environment Configuration */ - -/* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD #define CONFIG_HAS_ETH3 -#define CONFIG_ETH3ADDR 00:E0:0C:00:03:FD #endif #define CONFIG_IPADDR 192.168.1.253 diff --git a/include/configs/MPC8555CDS.h b/include/configs/MPC8555CDS.h index 5263ffcc8d..48b55b59e3 100644 --- a/include/configs/MPC8555CDS.h +++ b/include/configs/MPC8555CDS.h @@ -412,15 +412,10 @@ extern unsigned long get_clock_freq(void); /* * Environment Configuration */ - -/* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD #endif #define CONFIG_IPADDR 192.168.1.253 diff --git a/include/configs/MPC8560ADS.h b/include/configs/MPC8560ADS.h index ac78d481d6..92f0b7fe30 100644 --- a/include/configs/MPC8560ADS.h +++ b/include/configs/MPC8560ADS.h @@ -12,7 +12,7 @@ * Please refer to doc/README.mpc85xx for more info. * * Make sure you change the MAC address and other network params first, - * search for CONFIG_ETHADDR, CONFIG_SERVERIP, etc in this file. + * search for CONFIG_SERVERIP, etc. in this file. */ #ifndef __CONFIG_H @@ -443,17 +443,11 @@ /* * Environment Configuration */ - -/* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) || defined(CONFIG_ETHER_ON_FCC) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD #define CONFIG_HAS_ETH3 -#define CONFIG_ETH3ADDR 00:E0:0C:00:03:FD #endif #define CONFIG_IPADDR 192.168.1.253 diff --git a/include/configs/MPC8568MDS.h b/include/configs/MPC8568MDS.h index 02a5acf38e..57fc37b9bc 100644 --- a/include/configs/MPC8568MDS.h +++ b/include/configs/MPC8568MDS.h @@ -438,13 +438,9 @@ extern unsigned long get_clock_freq(void); /* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) || defined(CONFIG_UEC_ETH) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD #define CONFIG_HAS_ETH3 -#define CONFIG_ETH3ADDR 00:E0:0C:00:03:FD #endif #define CONFIG_IPADDR 192.168.1.253 diff --git a/include/configs/MPC8572DS.h b/include/configs/MPC8572DS.h index 5e7bc49dcf..7b3ddbadf2 100644 --- a/include/configs/MPC8572DS.h +++ b/include/configs/MPC8572DS.h @@ -658,17 +658,11 @@ /* * Environment Configuration */ - -/* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:E0:0C:02:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:E0:0C:02:01:FD #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:E0:0C:02:02:FD #define CONFIG_HAS_ETH3 -#define CONFIG_ETH3ADDR 00:E0:0C:02:03:FD #endif #define CONFIG_IPADDR 192.168.1.254 diff --git a/include/configs/MPC8610HPCD.h b/include/configs/MPC8610HPCD.h index e6d570a6af..cae133bf58 100644 --- a/include/configs/MPC8610HPCD.h +++ b/include/configs/MPC8610HPCD.h @@ -300,7 +300,6 @@ #define CONFIG_ULI526X #ifdef CONFIG_ULI526X -#define CONFIG_ETHADDR 00:E0:0C:00:00:01 #endif /************************************************************ diff --git a/include/configs/MPC8641HPCN.h b/include/configs/MPC8641HPCN.h index 9f755e50fc..938874fe42 100644 --- a/include/configs/MPC8641HPCN.h +++ b/include/configs/MPC8641HPCN.h @@ -10,7 +10,7 @@ * MPC8641HPCN board configuration file * * Make sure you change the MAC address and other network params first, - * search for CONFIG_ETHADDR, CONFIG_SERVERIP, etc in this file. + * search for CONFIG_SERVERIP, etc. in this file. */ #ifndef __CONFIG_H @@ -679,14 +679,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy); * Environment Configuration */ -/* The mac addresses for all ethernet interface */ -#if defined(CONFIG_TSEC_ENET) -#define CONFIG_ETHADDR 00:E0:0C:00:00:01 -#define CONFIG_ETH1ADDR 00:E0:0C:00:01:FD -#define CONFIG_ETH2ADDR 00:E0:0C:00:02:FD -#define CONFIG_ETH3ADDR 00:E0:0C:00:03:FD -#endif - #define CONFIG_HAS_ETH0 1 #define CONFIG_HAS_ETH1 1 #define CONFIG_HAS_ETH2 1 diff --git a/include/configs/a4m072.h b/include/configs/a4m072.h index 3c6765560e..00589b7e68 100644 --- a/include/configs/a4m072.h +++ b/include/configs/a4m072.h @@ -165,7 +165,6 @@ "setenv bootargs ${bootargs} no_ethaddr;" \ "fi\0" \ "hostname=CPUP0\0" \ - "ethaddr=00:00:00:00:00:00\0" \ "netdev=eth0\0" \ "bootcmd=run bootcmd_nor\0" \ "" diff --git a/include/configs/bct-brettl2.h b/include/configs/bct-brettl2.h index 2e0e9224cf..0d9fe57ba9 100644 --- a/include/configs/bct-brettl2.h +++ b/include/configs/bct-brettl2.h @@ -73,8 +73,6 @@ #define CONFIG_GATEWAYIP 192.168.233.1 #define CONFIG_SERVERIP 192.168.233.53 #define CONFIG_ROOTPATH "/romfs/brettl2" -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND #endif diff --git a/include/configs/bf518f-ezbrd.h b/include/configs/bf518f-ezbrd.h index 50e85ca93c..dcd19e4db8 100644 --- a/include/configs/bf518f-ezbrd.h +++ b/include/configs/bf518f-ezbrd.h @@ -87,8 +87,6 @@ #endif #define CONFIG_HOSTNAME bf518f-ezbrd #define CONFIG_PHY_ADDR 3 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/bf526-ezbrd.h b/include/configs/bf526-ezbrd.h index 7fc882a133..ad5fa53160 100644 --- a/include/configs/bf526-ezbrd.h +++ b/include/configs/bf526-ezbrd.h @@ -85,8 +85,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME bf526-ezbrd -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/bf527-ezkit.h b/include/configs/bf527-ezkit.h index 79e440a0be..b23a250e0a 100644 --- a/include/configs/bf527-ezkit.h +++ b/include/configs/bf527-ezkit.h @@ -83,8 +83,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME bf527-ezkit -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/bf533-ezkit.h b/include/configs/bf533-ezkit.h index 0fda967ac2..1b7290e8d7 100644 --- a/include/configs/bf533-ezkit.h +++ b/include/configs/bf533-ezkit.h @@ -75,8 +75,6 @@ SSYNC(); \ } while (0) #define CONFIG_HOSTNAME bf533-ezkit -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/bf533-stamp.h b/include/configs/bf533-stamp.h index ae4d83a8f1..322705decb 100644 --- a/include/configs/bf533-stamp.h +++ b/include/configs/bf533-stamp.h @@ -68,8 +68,6 @@ SSYNC(); \ } while (0) #define CONFIG_HOSTNAME bf533-stamp -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:b8 */ /* I2C */ diff --git a/include/configs/bf537-minotaur.h b/include/configs/bf537-minotaur.h index 6df89af402..e705d08b3a 100644 --- a/include/configs/bf537-minotaur.h +++ b/include/configs/bf537-minotaur.h @@ -86,8 +86,6 @@ #define CONFIG_SYS_AUTOLOAD "no" #define CONFIG_ROOTPATH "/romfs" -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */ #define CONFIG_LIB_RAND @@ -133,7 +131,6 @@ #define CONFIG_SYS_LONGHELP 1 #define CONFIG_CMDLINE_EDITING 1 #define CONFIG_ENV_OVERWRITE 1 -#define CONFIG_MISC_INIT_R #define CONFIG_BAUDRATE 57600 #define CONFIG_UART_CONSOLE 0 diff --git a/include/configs/bf537-pnav.h b/include/configs/bf537-pnav.h index 4f2b2cbf29..be11a85bc0 100644 --- a/include/configs/bf537-pnav.h +++ b/include/configs/bf537-pnav.h @@ -65,8 +65,6 @@ #define CONFIG_RMII #endif #define CONFIG_HOSTNAME bf537-pnav -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:24:21:18 */ #define CONFIG_LIB_RAND /* @@ -150,7 +148,6 @@ * Misc Settings */ #define CONFIG_BAUDRATE 115200 -#define CONFIG_MISC_INIT_R #define CONFIG_RTC_BFIN #define CONFIG_UART_CONSOLE 0 diff --git a/include/configs/bf537-srv1.h b/include/configs/bf537-srv1.h index d01d88f3b4..9a7edf36b6 100644 --- a/include/configs/bf537-srv1.h +++ b/include/configs/bf537-srv1.h @@ -86,8 +86,6 @@ #define CONFIG_SYS_AUTOLOAD "no" #define CONFIG_ROOTPATH "/romfs" -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:42 */ #define CONFIG_LIB_RAND /* @@ -132,7 +130,6 @@ #define CONFIG_SYS_LONGHELP 1 #define CONFIG_CMDLINE_EDITING 1 #define CONFIG_ENV_OVERWRITE 1 -#define CONFIG_MISC_INIT_R #define CONFIG_BAUDRATE 115200 #define CONFIG_UART_CONSOLE 0 diff --git a/include/configs/bf537-stamp.h b/include/configs/bf537-stamp.h index 7b5a5a7f71..41f1b1f071 100644 --- a/include/configs/bf537-stamp.h +++ b/include/configs/bf537-stamp.h @@ -65,8 +65,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME bf537-stamp -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/bf538f-ezkit.h b/include/configs/bf538f-ezkit.h index e60558e1b6..3c82bf2701 100644 --- a/include/configs/bf538f-ezkit.h +++ b/include/configs/bf538f-ezkit.h @@ -63,8 +63,6 @@ #define CONFIG_SMC91111 1 #define CONFIG_SMC91111_BASE 0x20310300 #define CONFIG_HOSTNAME bf538f-ezkit -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/bf548-ezkit.h b/include/configs/bf548-ezkit.h index e71e6d324c..53f655890f 100644 --- a/include/configs/bf548-ezkit.h +++ b/include/configs/bf548-ezkit.h @@ -73,8 +73,6 @@ #define CONFIG_SMC911X_BASE 0x24000000 #define CONFIG_SMC911X_16_BIT #define CONFIG_HOSTNAME bf548-ezkit -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/bf561-acvilon.h b/include/configs/bf561-acvilon.h index 6871d8c422..03f3cec9db 100644 --- a/include/configs/bf561-acvilon.h +++ b/include/configs/bf561-acvilon.h @@ -92,9 +92,6 @@ #define CONFIG_HOSTNAME bf561-acvilon -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ - /* * Flash Settings diff --git a/include/configs/bf561-ezkit.h b/include/configs/bf561-ezkit.h index fb6f94873a..efbc6c21d9 100644 --- a/include/configs/bf561-ezkit.h +++ b/include/configs/bf561-ezkit.h @@ -64,8 +64,6 @@ #define CONFIG_SMC91111_BASE 0x2C010300 #define CONFIG_SMC_USE_32_BIT 1 #define CONFIG_HOSTNAME bf561-ezkit -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/blackstamp.h b/include/configs/blackstamp.h index 7de425349f..28bc653442 100644 --- a/include/configs/blackstamp.h +++ b/include/configs/blackstamp.h @@ -76,9 +76,6 @@ #define CONFIG_HOSTNAME blackstamp #define CONFIG_ROOTPATH "/checkout/uClinux-dist/romfs" #define CONFIG_SYS_AUTOLOAD "no" - -/* To remove hardcoding and enable MAC storage in EEPROM */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:b8 */ #endif #define CONFIG_ENV_IS_IN_SPI_FLASH diff --git a/include/configs/blackvme.h b/include/configs/blackvme.h index 6e5774c6ba..27dccf65c4 100644 --- a/include/configs/blackvme.h +++ b/include/configs/blackvme.h @@ -85,9 +85,6 @@ #define CFG_AUTOLOAD "no" #define CONFIG_CMD_DHCP #define CONFIG_CMD_PING -#define CONFIG_ENV_OVERWRITE 1 /* enable changing MAC at runtime */ -/* Comment out hardcoded MAC to enable MAC storage in EEPROM */ -/* # define CONFIG_ETHADDR ff:ee:dd:cc:bb:aa */ /* * SDRAM settings & memory map diff --git a/include/configs/br4.h b/include/configs/br4.h index 48cf184826..a44c18c66e 100644 --- a/include/configs/br4.h +++ b/include/configs/br4.h @@ -69,9 +69,6 @@ #endif #define CONFIG_HOSTNAME br4 #define CONFIG_TFTP_BLOCKSIZE 4404 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 5c:38:1a:80:a7:00 */ - /* * Flash Settings diff --git a/include/configs/cm-bf527.h b/include/configs/cm-bf527.h index 643c8379aa..387f1cb767 100644 --- a/include/configs/cm-bf527.h +++ b/include/configs/cm-bf527.h @@ -83,8 +83,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME cm-bf527 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/cm-bf533.h b/include/configs/cm-bf533.h index 485f01a01c..a4647858dd 100644 --- a/include/configs/cm-bf533.h +++ b/include/configs/cm-bf533.h @@ -66,8 +66,6 @@ #define CONFIG_SMC91111 1 #define CONFIG_SMC91111_BASE 0x20200300 #define CONFIG_HOSTNAME cm-bf533 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/cm-bf537e.h b/include/configs/cm-bf537e.h index e05956846c..95afd51217 100644 --- a/include/configs/cm-bf537e.h +++ b/include/configs/cm-bf537e.h @@ -71,8 +71,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME cm-bf537e -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/cm-bf537u.h b/include/configs/cm-bf537u.h index 1f26457a95..4df4a05c7d 100644 --- a/include/configs/cm-bf537u.h +++ b/include/configs/cm-bf537u.h @@ -69,8 +69,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME cm-bf537u -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/cm-bf548.h b/include/configs/cm-bf548.h index 72eafc5699..cde23ada40 100644 --- a/include/configs/cm-bf548.h +++ b/include/configs/cm-bf548.h @@ -76,8 +76,6 @@ #define CONFIG_SMC911X_BASE 0x24000000 #define CONFIG_SMC911X_16_BIT #define CONFIG_HOSTNAME cm-bf548 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:24:31:91 */ /* diff --git a/include/configs/cm-bf561.h b/include/configs/cm-bf561.h index 96910a7afd..9d8a2c613f 100644 --- a/include/configs/cm-bf561.h +++ b/include/configs/cm-bf561.h @@ -67,8 +67,6 @@ #define CONFIG_SMC911X_BASE 0x24008000 /* AMS1 */ #define CONFIG_SMC911X_16_BIT #define CONFIG_HOSTNAME cm-bf561 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:cf */ /* diff --git a/include/configs/cobra5272.h b/include/configs/cobra5272.h index 38fcc40d9f..11dd4d712b 100644 --- a/include/configs/cobra5272.h +++ b/include/configs/cobra5272.h @@ -177,7 +177,6 @@ considered during boot */ /* User network settings */ -#define CONFIG_ETHADDR 00:00:00:00:00:09 /* default ethernet MAC addr. */ #define CONFIG_IPADDR 192.168.100.2 /* default board IP address */ #define CONFIG_SERVERIP 192.168.100.1 /* default tftp server IP address */ diff --git a/include/configs/dbau1x00.h b/include/configs/dbau1x00.h index 56317ef5e7..70aa699c4a 100644 --- a/include/configs/dbau1x00.h +++ b/include/configs/dbau1x00.h @@ -37,8 +37,6 @@ #endif #endif -#define CONFIG_ETHADDR DE:AD:BE:EF:01:01 /* Ethernet address */ - #define CONFIG_BOOTDELAY 2 /* autoboot after 2 seconds */ #define CONFIG_BAUDRATE 115200 diff --git a/include/configs/ea20.h b/include/configs/ea20.h index ae89368bfb..fc02b30af7 100644 --- a/include/configs/ea20.h +++ b/include/configs/ea20.h @@ -242,7 +242,6 @@ "rootpath=/opt/eldk/arm\0" \ "splashpos=230,180\0" \ "testrfspath=/opt/eldk/test_arm\0" \ - "tempmac=setenv ethaddr 02:ea:20:ff:ff:ff\0" \ "nandargs=setenv bootargs rootfstype=ubifs ro chk_data_crc " \ "ubi.mtd=${as} root=ubi0:rootfs\0" \ "nandrwargs=setenv bootargs rootfstype=ubifs rw chk_data_crc " \ @@ -315,6 +314,6 @@ "fi;" \ "else echo U-Boot not downloaded..exiting;fi\0" \ "ubootupd_nand=echo run load_magic,run load_nand,run upd;\0" \ - "bootcmd=run tempmac;run net_testrfs\0" + "bootcmd=run net_testrfs\0" #endif /* __CONFIG_H */ diff --git a/include/configs/gr_cpci_ax2000.h b/include/configs/gr_cpci_ax2000.h index 854807d486..5d28d8bf08 100644 --- a/include/configs/gr_cpci_ax2000.h +++ b/include/configs/gr_cpci_ax2000.h @@ -280,7 +280,6 @@ /*#define CONFIG_SHOW_ACTIVITY*/ #define CONFIG_NET_RETRY_COUNT 10 /* # of retries */ -#define CONFIG_ETHADDR 00:00:7a:cc:00:13 #define CONFIG_PHY_ADDR 0x00 /* diff --git a/include/configs/gr_ep2s60.h b/include/configs/gr_ep2s60.h index ed2dd2a847..7c320eeb64 100644 --- a/include/configs/gr_ep2s60.h +++ b/include/configs/gr_ep2s60.h @@ -260,16 +260,6 @@ /* USE GRETH Ethernet Driver */ #define CONFIG_GRETH 1 -/* Default GRETH Ethernet HARDWARE address */ -#define GRETH_HWADDR_0 0x00 -#define GRETH_HWADDR_1 0x00 -#define GRETH_HWADDR_2 0x7a -#define GRETH_HWADDR_3 0xcc -#define GRETH_HWADDR_4 0x00 -#define GRETH_HWADDR_5 0x13 -#endif - -#define CONFIG_ETHADDR 00:00:7a:cc:00:13 #define CONFIG_PHY_ADDR 0x00 /* diff --git a/include/configs/gr_xc3s_1500.h b/include/configs/gr_xc3s_1500.h index e3cbb6f596..fdd0aa5455 100644 --- a/include/configs/gr_xc3s_1500.h +++ b/include/configs/gr_xc3s_1500.h @@ -220,15 +220,6 @@ */ #define CONFIG_GRETH 1 -/* Default GRETH Ethernet HARDWARE address */ -#define GRETH_HWADDR_0 0x00 -#define GRETH_HWADDR_1 0x00 -#define GRETH_HWADDR_2 0x7a -#define GRETH_HWADDR_3 0xcc -#define GRETH_HWADDR_4 0x00 -#define GRETH_HWADDR_5 0x12 - -#define CONFIG_ETHADDR 00:00:7a:cc:00:12 #define CONFIG_PHY_ADDR 0x00 /* diff --git a/include/configs/grsim.h b/include/configs/grsim.h index 1e089a9bf7..21b4f5e5d4 100644 --- a/include/configs/grsim.h +++ b/include/configs/grsim.h @@ -94,7 +94,6 @@ "rootpath=/export/roofs\0" \ "scratch=40000000\0" \ "getkernel=tftpboot $(scratch) $(bootfile)\0" \ - "ethaddr=00:00:7A:CC:00:12\0" \ "bootargs=console=ttyS0,38400" \ "" #define CONFIG_NETMASK 255.255.255.0 @@ -243,16 +242,6 @@ */ #define CONFIG_GRETH 1 -/* Default HARDWARE address */ -#define GRETH_HWADDR_0 0x00 -#define GRETH_HWADDR_1 0x00 -#define GRETH_HWADDR_2 0x7A -#define GRETH_HWADDR_3 0xcc -#define GRETH_HWADDR_4 0x00 -#define GRETH_HWADDR_5 0x12 - -#define CONFIG_ETHADDR 00:00:7a:cc:00:12 - /* * Define CONFIG_GRETH_10MBIT to force GRETH at 10Mb/s */ diff --git a/include/configs/grsim_leon2.h b/include/configs/grsim_leon2.h index 66194a8ff0..f050754a75 100644 --- a/include/configs/grsim_leon2.h +++ b/include/configs/grsim_leon2.h @@ -91,7 +91,6 @@ "rootpath=/export/roofs\0" \ "scratch=40000000\0" \ "getkernel=tftpboot $(scratch) $(bootfile)\0" \ - "ethaddr=00:00:7A:CC:00:12\0" \ "bootargs=console=ttyS0,38400" \ "" #define CONFIG_NETMASK 255.255.255.0 @@ -241,16 +240,6 @@ */ /*#define CONFIG_GRETH 1*/ -/* Default HARDWARE address */ -#define GRETH_HWADDR_0 0x00 -#define GRETH_HWADDR_1 0x00 -#define GRETH_HWADDR_2 0x7A -#define GRETH_HWADDR_3 0xcc -#define GRETH_HWADDR_4 0x00 -#define GRETH_HWADDR_5 0x12 - -#define CONFIG_ETHADDR 00:00:7a:cc:00:12 - /* * Define CONFIG_GRETH_10MBIT to force GRETH at 10Mb/s */ diff --git a/include/configs/ibf-dsp561.h b/include/configs/ibf-dsp561.h index 2a937c6a22..4757929618 100644 --- a/include/configs/ibf-dsp561.h +++ b/include/configs/ibf-dsp561.h @@ -64,8 +64,6 @@ #define CONFIG_DRIVER_AX88180 1 #define AX88180_BASE 0x2c000000 #define CONFIG_HOSTNAME ibf-dsp561 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/inka4x0.h b/include/configs/inka4x0.h index f321975c47..92587349d1 100644 --- a/include/configs/inka4x0.h +++ b/include/configs/inka4x0.h @@ -110,9 +110,6 @@ #undef CONFIG_BOOTARGS -#define CONFIG_ETHADDR 00:a0:a4:03:00:00 -#define CONFIG_OVERWRITE_ETHADDR_ONCE - #define CONFIG_IPADDR 192.168.100.2 #define CONFIG_SERVERIP 192.168.100.1 #define CONFIG_NETMASK 255.255.255.0 diff --git a/include/configs/ip04.h b/include/configs/ip04.h index 2ee215f706..2bd81fc5cf 100644 --- a/include/configs/ip04.h +++ b/include/configs/ip04.h @@ -131,7 +131,6 @@ * Misc Settings */ #define CONFIG_BAUDRATE 115200 -#define CONFIG_MISC_INIT_R /* needed for MAC address */ #define CONFIG_UART_CONSOLE 0 #undef CONFIG_SHOW_BOOT_PROGRESS diff --git a/include/configs/lsxl.h b/include/configs/lsxl.h index c354c29296..490f84eb75 100644 --- a/include/configs/lsxl.h +++ b/include/configs/lsxl.h @@ -37,7 +37,6 @@ #define CONFIG_MISC_INIT_R #define CONFIG_SHOW_BOOT_PROGRESS -#define CONFIG_RANDOM_MACADDR #define CONFIG_LIB_RAND #define CONFIG_KIRKWOOD_GPIO #define CONFIG_OF_LIBFDT diff --git a/include/configs/microblaze-generic.h b/include/configs/microblaze-generic.h index 166ab4f056..b84eead661 100644 --- a/include/configs/microblaze-generic.h +++ b/include/configs/microblaze-generic.h @@ -350,7 +350,6 @@ #define CONFIG_IPADDR 192.168.0.3 #define CONFIG_SERVERIP 192.168.0.5 #define CONFIG_GATEWAYIP 192.168.0.1 -#define CONFIG_ETHADDR 00:E0:0C:00:00:FD /* architecture dependent code */ #define CONFIG_SYS_USR_EXCEP /* user exception */ diff --git a/include/configs/motionpro.h b/include/configs/motionpro.h index e8b05932a1..4d648c8a14 100644 --- a/include/configs/motionpro.h +++ b/include/configs/motionpro.h @@ -85,8 +85,6 @@ #define CONFIG_SYS_HUSH_PARSER 1 /* use "hush" command parser */ #define CONFIG_SYS_PROMPT_HUSH_PS2 "> " -#define CONFIG_ETHADDR 00:50:C2:40:10:00 -#define CONFIG_OVERWRITE_ETHADDR_ONCE 1 #define CONFIG_VERSION_VARIABLE 1 /* include version env variable */ /* diff --git a/include/configs/omap3_cairo.h b/include/configs/omap3_cairo.h index 3030054949..20826790fa 100644 --- a/include/configs/omap3_cairo.h +++ b/include/configs/omap3_cairo.h @@ -90,7 +90,6 @@ "machid=ffffffff\0" \ "fdt_high=0x87000000\0" \ "baudrate=115200\0" \ - "ethaddr=00:50:C2:7E:90:F0\0" \ "fec_addr=00:50:C2:7E:90:F0\0" \ "netmask=255.255.255.0\0" \ "ipaddr=192.168.2.9\0" \ diff --git a/include/configs/pb1x00.h b/include/configs/pb1x00.h index a1926bb64d..2508702a4a 100644 --- a/include/configs/pb1x00.h +++ b/include/configs/pb1x00.h @@ -31,8 +31,6 @@ #endif #endif -#define CONFIG_ETHADDR DE:AD:BE:EF:01:01 /* Ethernet address */ - #define CONFIG_BOOTDELAY 2 /* autoboot after 2 seconds */ #define CONFIG_BAUDRATE 115200 diff --git a/include/configs/pr1.h b/include/configs/pr1.h index 13fb675a5f..b9253b9684 100644 --- a/include/configs/pr1.h +++ b/include/configs/pr1.h @@ -69,8 +69,6 @@ #endif #define CONFIG_HOSTNAME pr1 #define CONFIG_TFTP_BLOCKSIZE 4404 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ /* diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index f5361d1091..3a857e2a3d 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -153,6 +153,11 @@ #define CONFIG_CMD_SANDBOX +#define CONFIG_CMD_ENV_FLAGS +#define CONFIG_CMD_ENV_CALLBACK +#define CONFIG_CMD_GREPENV +#define CONFIG_CMD_ASKENV + #define CONFIG_BOOTARGS "" #define CONFIG_BOARD_LATE_INIT diff --git a/include/configs/sbc405.h b/include/configs/sbc405.h index 69dc210917..11bf504832 100644 --- a/include/configs/sbc405.h +++ b/include/configs/sbc405.h @@ -102,7 +102,6 @@ #define CONFIG_SDRAM_BANK0 1 /* init onboard SDRAM bank 0 */ -#define CONFIG_ETHADDR DE:AD:BE:EF:01:01 /* Ethernet address */ #define CONFIG_IPADDR 192.168.193.102 #define CONFIG_NETMASK 255.255.255.224 #define CONFIG_SERVERIP 192.168.193.119 diff --git a/include/configs/sbc8548.h b/include/configs/sbc8548.h index aee0d9e273..5b373cb0f1 100644 --- a/include/configs/sbc8548.h +++ b/include/configs/sbc8548.h @@ -581,13 +581,9 @@ /* * Environment Configuration */ - -/* The mac addresses for all ethernet interface */ #if defined(CONFIG_TSEC_ENET) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 02:E0:0C:00:00:FD #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 02:E0:0C:00:01:FD #endif #define CONFIG_IPADDR 192.168.0.55 diff --git a/include/configs/sbc8641d.h b/include/configs/sbc8641d.h index 8eb7276618..021da50aa8 100644 --- a/include/configs/sbc8641d.h +++ b/include/configs/sbc8641d.h @@ -14,7 +14,7 @@ * SBC8641D board configuration file * * Make sure you change the MAC address and other network params first, - * search for CONFIG_ETHADDR, CONFIG_SERVERIP, etc in this file. + * search for CONFIG_SERVERIP, etc in this file. */ #ifndef __CONFIG_H @@ -528,14 +528,6 @@ * Environment Configuration */ -/* The mac addresses for all ethernet interface */ -#if defined(CONFIG_TSEC_ENET) -#define CONFIG_ETHADDR 02:E0:0C:00:00:01 -#define CONFIG_ETH1ADDR 02:E0:0C:00:01:FD -#define CONFIG_ETH2ADDR 02:E0:0C:00:02:FD -#define CONFIG_ETH3ADDR 02:E0:0C:00:03:FD -#endif - #define CONFIG_HAS_ETH0 1 #define CONFIG_HAS_ETH1 1 #define CONFIG_HAS_ETH2 1 diff --git a/include/configs/scb9328.h b/include/configs/scb9328.h index f4a40bb932..6cac99e042 100644 --- a/include/configs/scb9328.h +++ b/include/configs/scb9328.h @@ -50,7 +50,6 @@ #define CONFIG_BOOTARGS "console=ttySMX0,115200n8 root=/dev/mtdblock3 rootfstype=jffs2 mtdparts=scb9328_flash:128k(U-boot)ro,128k(U-boot_env),1m(kernel),4m(root),4m(fs) eval_board=evk9328" #define CONFIG_BOOTCOMMAND "bootm 10040000" #define CONFIG_SHOW_BOOT_PROGRESS -#define CONFIG_ETHADDR 80:81:82:83:84:85 #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 10.10.10.9 #define CONFIG_SERVERIP 10.10.10.10 diff --git a/include/configs/sequoia.h b/include/configs/sequoia.h index b6a5e6a59c..623be7d39b 100644 --- a/include/configs/sequoia.h +++ b/include/configs/sequoia.h @@ -100,15 +100,6 @@ #if defined(CONFIG_SYS_RAMBOOT) #define CONFIG_ENV_IS_NOWHERE /* Store env in memory only */ #define CONFIG_ENV_SIZE (8 << 10) -/* - * In RAM-booting version, we have no environment storage. So we need to - * provide at least preliminary MAC addresses for the 4xx EMAC driver to - * register the interfaces. Those two addresses are generated via the - * tools/gen_eth_addr tool and should only be used in a closed laboratory - * environment. - */ -#define CONFIG_ETHADDR 4a:56:49:22:3e:43 -#define CONFIG_ETH1ADDR 02:93:53:d5:06:98 #else #define CONFIG_ENV_IS_IN_FLASH /* use FLASH for environ vars */ #endif diff --git a/include/configs/stxgp3.h b/include/configs/stxgp3.h index 5fb40ebf8b..a0817a0f80 100644 --- a/include/configs/stxgp3.h +++ b/include/configs/stxgp3.h @@ -13,7 +13,7 @@ /* mpc8560ads board configuration file */ /* please refer to doc/README.mpc85xx for more info */ /* make sure you change the MAC address and other network params first, - * search for CONFIG_ETHADDR,CONFIG_SERVERIP,etc in this file + * search for CONFIG_SERVERIP, etc. in this file */ #ifndef __CONFIG_H @@ -342,14 +342,10 @@ #define CONFIG_KGDB_BAUDRATE 230400 /* speed to run kgdb serial port */ #endif -/*Note: change below for your network setting!!! */ #if defined(CONFIG_TSEC_ENET) || defined(CONFIG_ETHER_ON_FCC) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:e0:0c:07:9b:8a #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:e0:0c:07:9b:8b #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:e0:0c:07:9b:8c #endif #define CONFIG_SERVERIP 192.168.85.1 diff --git a/include/configs/stxssa.h b/include/configs/stxssa.h index 914d821905..78ac0801d5 100644 --- a/include/configs/stxssa.h +++ b/include/configs/stxssa.h @@ -13,7 +13,7 @@ /* mpc8560ads board configuration file */ /* please refer to doc/README.mpc85xx for more info */ /* make sure you change the MAC address and other network params first, - * search for CONFIG_ETHADDR,CONFIG_SERVERIP,etc in this file + * search for CONFIG_SERVERIP, etc. in this file */ #ifndef __CONFIG_H @@ -377,14 +377,10 @@ #define CONFIG_KGDB_BAUDRATE 230400 /* speed to run kgdb serial port */ #endif -/*Note: change below for your network setting!!! */ #if defined(CONFIG_TSEC_ENET) || defined(CONFIG_ETHER_ON_FCC) #define CONFIG_HAS_ETH0 -#define CONFIG_ETHADDR 00:e0:0c:07:9b:8a #define CONFIG_HAS_ETH1 -#define CONFIG_ETH1ADDR 00:e0:0c:07:9b:8b #define CONFIG_HAS_ETH2 -#define CONFIG_ETH2ADDR 00:e0:0c:07:9b:8c #endif /* diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 2d6b815739..d829899c07 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -66,6 +66,9 @@ # define CONFIG_SYS_NS16550_COM5 SUNXI_R_UART_BASE #endif +/* CPU */ +#define CONFIG_SYS_CACHELINE_SIZE 64 + /* DRAM Base */ #define CONFIG_SYS_SDRAM_BASE 0x40000000 #define CONFIG_SYS_INIT_RAM_ADDR 0x0 @@ -98,6 +101,7 @@ #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG #define CONFIG_INITRD_TAG +#define CONFIG_SERIAL_TAG /* mmc config */ #if !defined(CONFIG_UART0_PORT_F) @@ -240,6 +244,8 @@ extern int soft_i2c_gpio_scl; #endif #elif CONFIG_CONS_INDEX == 2 && defined(CONFIG_MACH_SUN5I) #define OF_STDOUT_PATH "/soc@01c00000/serial@01c28400:115200" +#elif CONFIG_CONS_INDEX == 3 && defined(CONFIG_MACH_SUN8I) +#define OF_STDOUT_PATH "/soc@01c00000/serial@01c28800:115200" #elif CONFIG_CONS_INDEX == 5 && defined(CONFIG_MACH_SUN8I) #define OF_STDOUT_PATH "/soc@01c00000/serial@01f02800:115200" #else @@ -335,7 +341,7 @@ extern int soft_i2c_gpio_scl; /* Enable pre-console buffer to get complete log on the VGA console */ #define CONFIG_PRE_CONSOLE_BUFFER -#define CONFIG_PRE_CON_BUF_SZ (1024 * 1024) +#define CONFIG_PRE_CON_BUF_SZ 4096 /* Aprox 2 80*25 screens */ /* Use the room between the end of bootm_size and the framebuffer */ #define CONFIG_PRE_CON_BUF_ADDR 0x4f000000 diff --git a/include/configs/tcm-bf518.h b/include/configs/tcm-bf518.h index e96a7427e5..e726b29da5 100644 --- a/include/configs/tcm-bf518.h +++ b/include/configs/tcm-bf518.h @@ -66,8 +66,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME tcm-bf518 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* @@ -111,7 +109,6 @@ * Misc Settings */ #define CONFIG_BAUDRATE 115200 -#define CONFIG_MISC_INIT_R #define CONFIG_RTC_BFIN #define CONFIG_UART_CONSOLE 0 #define CONFIG_BOOTCOMMAND "run flashboot" diff --git a/include/configs/tcm-bf537.h b/include/configs/tcm-bf537.h index 42129fb7d8..33265801a6 100644 --- a/include/configs/tcm-bf537.h +++ b/include/configs/tcm-bf537.h @@ -71,8 +71,6 @@ #define CONFIG_NETCONSOLE 1 #endif #define CONFIG_HOSTNAME tcm-bf537 -/* Uncomment next line to use fixed MAC address */ -/* #define CONFIG_ETHADDR 02:80:ad:20:31:e8 */ #define CONFIG_LIB_RAND /* diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h index d4688c54ba..331df6251a 100644 --- a/include/configs/uniphier.h +++ b/include/configs/uniphier.h @@ -209,7 +209,6 @@ /* * Network Configuration */ -#define CONFIG_ETHADDR 00:21:83:24:00:00 #define CONFIG_SERVERIP 192.168.11.1 #define CONFIG_IPADDR 192.168.11.10 #define CONFIG_GATEWAYIP 192.168.11.1 diff --git a/include/configs/v38b.h b/include/configs/v38b.h index 7f6b0c7cb2..688d60e8fb 100644 --- a/include/configs/v38b.h +++ b/include/configs/v38b.h @@ -148,7 +148,6 @@ "netmask=255.255.0.0\0" \ "ipaddr=192.168.160.18\0" \ "serverip=192.168.1.1\0" \ - "ethaddr=00:e0:ee:00:05:2e\0" \ "bootfile=/tftpboot/v38b/uImage\0" \ "u-boot=/tftpboot/v38b/u-boot.bin\0" \ "" diff --git a/include/configs/work_92105.h b/include/configs/work_92105.h index dc8e99fffd..4725fc3d89 100644 --- a/include/configs/work_92105.h +++ b/include/configs/work_92105.h @@ -177,17 +177,6 @@ #define CONFIG_ENV_ADDR 0x80000100 /* - * Provide default ethernet address - * - * THIS IS NORMALLY NOT DONE. HERE WE KEEP WHAT WAS IN THE PORTED - * BOARD CONFIG IN CASE SOME PROVISIONING PROCESS OUT THERE EXPECTS - * THIS MAC ADDRESS WHEN THE DEVICE HAS STILL ITS DEFAULT CONFIG. - */ - -#define CONFIG_ETHADDR 00:12:B4:00:AF:FE -#define CONFIG_OVERWRITE_ETHADDR_ONCE - -/* * U-Boot Commands */ #include <config_cmd_default.h> diff --git a/include/configs/xaeniax.h b/include/configs/xaeniax.h index 2999d1b0f5..fcb76a27a2 100644 --- a/include/configs/xaeniax.h +++ b/include/configs/xaeniax.h @@ -70,7 +70,6 @@ #undef CONFIG_CMD_DTT -#define CONFIG_ETHADDR 08:00:3e:26:0a:5b #define CONFIG_NETMASK 255.255.255.0 #define CONFIG_IPADDR 192.168.68.201 #define CONFIG_SERVERIP 192.168.68.62 diff --git a/include/configs/zeus.h b/include/configs/zeus.h index 4d7a7fc755..9ac4a0f04a 100644 --- a/include/configs/zeus.h +++ b/include/configs/zeus.h @@ -296,8 +296,6 @@ #define CONFIG_IPADDR 192.168.1.10 #define CONFIG_SERVERIP 192.168.1.100 #define CONFIG_GATEWAYIP 192.168.1.100 -#define CONFIG_ETHADDR 50:00:00:00:06:00 -#define CONFIG_ETH1ADDR 50:00:00:00:06:01 #if 0 #define CONFIG_BOOTDELAY -1 /* autoboot disabled */ #else diff --git a/include/dm/test.h b/include/dm/test.h index f03fbcb1cd..a4bc5c8404 100644 --- a/include/dm/test.h +++ b/include/dm/test.h @@ -8,7 +8,7 @@ #define __DM_TEST_H #include <dm.h> -#include <malloc.h> +#include <test/test.h> /** * struct dm_test_cdata - configuration data for test instance @@ -124,7 +124,7 @@ struct dm_test_perdev_uc_pdata { */ extern int dm_testdrv_op_count[DM_TEST_OP_COUNT]; -extern struct dm_test_state global_test_state; +extern struct unit_test_state global_dm_test_state; /* * struct dm_test_state - Entire state of dm test system @@ -133,7 +133,6 @@ extern struct dm_test_state global_test_state; * * @root: Root device * @testdev: Test device - * @fail_count: Number of tests that failed * @force_fail_alloc: Force all memory allocs to fail * @skip_post_probe: Skip uclass post-probe processing * @removed: Used to keep track of a device that was removed @@ -141,11 +140,9 @@ extern struct dm_test_state global_test_state; struct dm_test_state { struct udevice *root; struct udevice *testdev; - int fail_count; int force_fail_alloc; int skip_post_probe; struct udevice *removed; - struct mallinfo start; }; /* Test flags for each test */ @@ -155,26 +152,8 @@ enum { DM_TESTF_SCAN_FDT = 1 << 2, /* scan device tree */ }; -/** - * struct dm_test - Information about a driver model test - * - * @name: Name of test - * @func: Function to call to perform test - * @flags: Flags indicated pre-conditions for test - */ -struct dm_test { - const char *name; - int (*func)(struct dm_test_state *dms); - int flags; -}; - /* Declare a new driver model test */ -#define DM_TEST(_name, _flags) \ - ll_entry_declare(struct dm_test, _name, dm_test) = { \ - .name = #_name, \ - .flags = _flags, \ - .func = _name, \ - } +#define DM_TEST(_name, _flags) UNIT_TEST(_name, _flags, dm_test) /* Declare ping methods for the drivers */ int test_ping(struct udevice *dev, int pingval, int *pingret); @@ -191,7 +170,7 @@ int testfdt_ping(struct udevice *dev, int pingval, int *pingret); * @priv: Pointer to private test information * @return 0 if OK, -ve on error */ -int dm_check_operations(struct dm_test_state *dms, struct udevice *dev, +int dm_check_operations(struct unit_test_state *uts, struct udevice *dev, uint32_t base, struct dm_test_priv *priv); /** @@ -201,7 +180,7 @@ int dm_check_operations(struct dm_test_state *dms, struct udevice *dev, * @num_devices: Number of test devices to check * @return 0 if OK, -ve on error */ -int dm_check_devices(struct dm_test_state *dms, int num_devices); +int dm_check_devices(struct unit_test_state *uts, int num_devices); /** * dm_leak_check_start() - Prepare to check for a memory leak @@ -211,7 +190,7 @@ int dm_check_devices(struct dm_test_state *dms, int num_devices); * * @dms: Overall test state */ -void dm_leak_check_start(struct dm_test_state *dms); +void dm_leak_check_start(struct unit_test_state *uts); /** * dm_leak_check_end() - Check that no memory has leaked @@ -221,17 +200,6 @@ void dm_leak_check_start(struct dm_test_state *dms); * it sees a different amount of total memory allocated than before. * * @dms: Overall test state - */int dm_leak_check_end(struct dm_test_state *dms); - - -/** - * dm_test_main() - Run all or one of the tests - * - * This runs all available driver model tests, or a selected one - * - * @test_name: Name of test to run, or NULL for all - * @return 0 if OK, -ve on error - */ -int dm_test_main(const char *test_name); + */int dm_leak_check_end(struct unit_test_state *uts); #endif diff --git a/include/env_attr.h b/include/env_attr.h index b82fec91be..7bfb7f30d1 100644 --- a/include/env_attr.h +++ b/include/env_attr.h @@ -16,13 +16,14 @@ * attributes = [^,:\s]* * entry = name[:attributes] * list = entry[,list] - * It will call the "callback" function with the "name" and attribute as "value" + * It will call the "callback" function with the "name" and "attributes" * The callback may return a non-0 to abort the list walk. * This return value will be passed through to the caller. * 0 is returned on success. */ -extern int env_attr_walk(const char *attr_list, - int (*callback)(const char *name, const char *value)); +int env_attr_walk(const char *attr_list, + int (*callback)(const char *name, const char *attributes, void *priv), + void *priv); /* * env_attr_lookup takes as input an "attr_list" with the same form as above. @@ -33,7 +34,6 @@ extern int env_attr_walk(const char *attr_list, * "attr_list" is NULL. * Returns 0 on success. */ -extern int env_attr_lookup(const char *attr_list, const char *name, - char *attributes); +int env_attr_lookup(const char *attr_list, const char *name, char *attributes); #endif /* __ENV_ATTR_H__ */ diff --git a/include/env_callback.h b/include/env_callback.h index ab4e115fb0..ab5d42dd81 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -31,14 +31,41 @@ #define SPLASHIMAGE_CALLBACK #endif +#ifdef CONFIG_REGEX +#define ENV_DOT_ESCAPE "\\" +#else +#define ENV_DOT_ESCAPE +#endif + +#ifdef CONFIG_CMD_DNS +#define DNS_CALLBACK "dnsip:dnsip," +#else +#define DNS_CALLBACK +#endif + +#ifdef CONFIG_NET +#define NET_CALLBACKS \ + "bootfile:bootfile," \ + "ipaddr:ipaddr," \ + "gatewayip:gatewayip," \ + "netmask:netmask," \ + "serverip:serverip," \ + "nvlan:nvlan," \ + "vlan:vlan," \ + DNS_CALLBACK \ + "eth\\d?addr:ethaddr," +#else +#define NET_CALLBACKS +#endif + /* * This list of callback bindings is static, but may be overridden by defining * a new association in the ".callbacks" environment variable. */ -#define ENV_CALLBACK_LIST_STATIC ENV_CALLBACK_VAR ":callbacks," \ - ENV_FLAGS_VAR ":flags," \ +#define ENV_CALLBACK_LIST_STATIC ENV_DOT_ESCAPE ENV_CALLBACK_VAR ":callbacks," \ + ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \ "baudrate:baudrate," \ - "bootfile:bootfile," \ + NET_CALLBACKS \ "loadaddr:loadaddr," \ SILENT_CALLBACK \ SPLASHIMAGE_CALLBACK \ diff --git a/include/env_default.h b/include/env_default.h index 90431beb19..3096576836 100644 --- a/include/env_default.h +++ b/include/env_default.h @@ -49,24 +49,6 @@ const uchar default_environment[] = { #ifdef CONFIG_LOADS_ECHO "loads_echo=" __stringify(CONFIG_LOADS_ECHO) "\0" #endif -#ifdef CONFIG_ETHADDR - "ethaddr=" __stringify(CONFIG_ETHADDR) "\0" -#endif -#ifdef CONFIG_ETH1ADDR - "eth1addr=" __stringify(CONFIG_ETH1ADDR) "\0" -#endif -#ifdef CONFIG_ETH2ADDR - "eth2addr=" __stringify(CONFIG_ETH2ADDR) "\0" -#endif -#ifdef CONFIG_ETH3ADDR - "eth3addr=" __stringify(CONFIG_ETH3ADDR) "\0" -#endif -#ifdef CONFIG_ETH4ADDR - "eth4addr=" __stringify(CONFIG_ETH4ADDR) "\0" -#endif -#ifdef CONFIG_ETH5ADDR - "eth5addr=" __stringify(CONFIG_ETH5ADDR) "\0" -#endif #ifdef CONFIG_ETHPRIME "ethprime=" CONFIG_ETHPRIME "\0" #endif diff --git a/include/env_flags.h b/include/env_flags.h index 3ef631105f..2d2de88fc0 100644 --- a/include/env_flags.h +++ b/include/env_flags.h @@ -38,17 +38,31 @@ enum env_flags_varaccess { #endif #ifdef CONFIG_CMD_NET +#ifdef CONFIG_REGEX +#define ETHADDR_WILDCARD "\\d?" +#else +#define ETHADDR_WILDCARD +#endif #ifdef CONFIG_ENV_OVERWRITE -#define ETHADDR_FLAGS "ethaddr:ma," +#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:ma," #else #ifdef CONFIG_OVERWRITE_ETHADDR_ONCE -#define ETHADDR_FLAGS "ethaddr:mc," +#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mc," #else -#define ETHADDR_FLAGS "ethaddr:mo," +#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mo," #endif #endif +#define NET_FLAGS \ + "ipaddr:i," \ + "gatewayip:i," \ + "netmask:i," \ + "serverip:i," \ + "nvlan:i," \ + "vlan:i," \ + "dnsip:i," #else -#define ETHADDR_FLAGS "" +#define ETHADDR_FLAGS +#define NET_FLAGS #endif #ifndef CONFIG_ENV_OVERWRITE @@ -59,6 +73,7 @@ enum env_flags_varaccess { #define ENV_FLAGS_LIST_STATIC \ ETHADDR_FLAGS \ + NET_FLAGS \ SERIAL_FLAGS \ CONFIG_ENV_FLAGS_LIST_STATIC diff --git a/include/search.h b/include/search.h index 9701efb2df..343dbc3d48 100644 --- a/include/search.h +++ b/include/search.h @@ -120,5 +120,7 @@ extern int hwalk_r(struct hsearch_data *__htab, int (*callback)(ENTRY *)); #define H_MATCH_SUBSTR (1 << 7) /* search for substring matches */ #define H_MATCH_REGEX (1 << 8) /* search for regular expression matches */ #define H_MATCH_METHOD (H_MATCH_IDENT | H_MATCH_SUBSTR | H_MATCH_REGEX) +#define H_PROGRAMMATIC (1 << 9) /* indicate that an import is from setenv() */ +#define H_ORIGIN_FLAGS (H_INTERACTIVE | H_PROGRAMMATIC) #endif /* search.h */ diff --git a/include/test/env.h b/include/test/env.h new file mode 100644 index 0000000000..2b0cd682e4 --- /dev/null +++ b/include/test/env.h @@ -0,0 +1,16 @@ +/* + * (C) Copyright 2015 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef __TEST_ENV_H__ +#define __TEST_ENV_H__ + +#include <test/test.h> + +/* Declare a new environment test */ +#define ENV_TEST(_name, _flags) UNIT_TEST(_name, _flags, env_test) + +#endif /* __TEST_ENV_H__ */ diff --git a/include/test/suites.h b/include/test/suites.h new file mode 100644 index 0000000000..f5790333ff --- /dev/null +++ b/include/test/suites.h @@ -0,0 +1,15 @@ +/* + * (C) Copyright 2015 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#ifndef __TEST_SUITES_H__ +#define __TEST_SUITES_H__ + +int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); +int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); + +#endif /* __TEST_SUITES_H__ */ diff --git a/include/test/test.h b/include/test/test.h new file mode 100644 index 0000000000..b7e1ae2dec --- /dev/null +++ b/include/test/test.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2013 Google, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __TEST_TEST_H +#define __TEST_TEST_H + +#include <malloc.h> + +/* + * struct unit_test_state - Entire state of test system + * + * @fail_count: Number of tests that failed + * @start: Store the starting mallinfo when doing leak test + * @priv: A pointer to some other info some suites want to track + */ +struct unit_test_state { + int fail_count; + struct mallinfo start; + void *priv; +}; + +/** + * struct unit_test - Information about a unit test + * + * @name: Name of test + * @func: Function to call to perform test + * @flags: Flags indicated pre-conditions for test + */ +struct unit_test { + const char *name; + int (*func)(struct unit_test_state *state); + int flags; +}; + +/* Declare a new unit test */ +#define UNIT_TEST(_name, _flags, _suite) \ + ll_entry_declare(struct unit_test, _name, _suite) = { \ + .name = #_name, \ + .flags = _flags, \ + .func = _name, \ + } + + +#endif /* __TEST_TEST_H */ diff --git a/include/dm/ut.h b/include/test/ut.h index ec6146545b..5e5aa6ce41 100644 --- a/include/dm/ut.h +++ b/include/test/ut.h @@ -1,39 +1,39 @@ /* - * Simple unit test library for driver model + * Simple unit test library * * Copyright (c) 2013 Google, Inc * * SPDX-License-Identifier: GPL-2.0+ */ -#ifndef __DM_UT_H -#define __DM_UT_H +#ifndef __TEST_UT_H +#define __TEST_UT_H -struct dm_test_state; +struct unit_test_state; /** * ut_fail() - Record failure of a unit test * - * @dms: Test state + * @uts: Test state * @fname: Filename where the error occured * @line: Line number where the error occured * @func: Function name where the error occured * @cond: The condition that failed */ -void ut_fail(struct dm_test_state *dms, const char *fname, int line, +void ut_fail(struct unit_test_state *uts, const char *fname, int line, const char *func, const char *cond); /** * ut_failf() - Record failure of a unit test * - * @dms: Test state + * @uts: Test state * @fname: Filename where the error occured * @line: Line number where the error occured * @func: Function name where the error occured * @cond: The condition that failed * @fmt: printf() format string for the error, followed by args */ -void ut_failf(struct dm_test_state *dms, const char *fname, int line, +void ut_failf(struct unit_test_state *uts, const char *fname, int line, const char *func, const char *cond, const char *fmt, ...) __attribute__ ((format (__printf__, 6, 7))); @@ -41,16 +41,16 @@ void ut_failf(struct dm_test_state *dms, const char *fname, int line, /* Assert that a condition is non-zero */ #define ut_assert(cond) \ if (!(cond)) { \ - ut_fail(dms, __FILE__, __LINE__, __func__, #cond); \ - return -1; \ + ut_fail(uts, __FILE__, __LINE__, __func__, #cond); \ + return CMD_RET_FAILURE; \ } /* Assert that a condition is non-zero, with printf() string */ #define ut_assertf(cond, fmt, args...) \ if (!(cond)) { \ - ut_failf(dms, __FILE__, __LINE__, __func__, #cond, \ + ut_failf(uts, __FILE__, __LINE__, __func__, #cond, \ fmt, ##args); \ - return -1; \ + return CMD_RET_FAILURE; \ } /* Assert that two int expressions are equal */ @@ -58,10 +58,10 @@ void ut_failf(struct dm_test_state *dms, const char *fname, int line, unsigned int val1 = (expr1), val2 = (expr2); \ \ if (val1 != val2) { \ - ut_failf(dms, __FILE__, __LINE__, __func__, \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " == " #expr2, \ "Expected %d, got %d", val1, val2); \ - return -1; \ + return CMD_RET_FAILURE; \ } \ } @@ -70,10 +70,10 @@ void ut_failf(struct dm_test_state *dms, const char *fname, int line, const char *val1 = (expr1), *val2 = (expr2); \ \ if (strcmp(val1, val2)) { \ - ut_failf(dms, __FILE__, __LINE__, __func__, \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " = " #expr2, \ "Expected \"%s\", got \"%s\"", val1, val2); \ - return -1; \ + return CMD_RET_FAILURE; \ } \ } @@ -82,10 +82,10 @@ void ut_failf(struct dm_test_state *dms, const char *fname, int line, const void *val1 = (expr1), *val2 = (expr2); \ \ if (val1 != val2) { \ - ut_failf(dms, __FILE__, __LINE__, __func__, \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr1 " = " #expr2, \ "Expected %p, got %p", val1, val2); \ - return -1; \ + return CMD_RET_FAILURE; \ } \ } @@ -94,10 +94,10 @@ void ut_failf(struct dm_test_state *dms, const char *fname, int line, const void *val = (expr); \ \ if (val == NULL) { \ - ut_failf(dms, __FILE__, __LINE__, __func__, \ + ut_failf(uts, __FILE__, __LINE__, __func__, \ #expr " = NULL", \ "Expected non-null, got NULL"); \ - return -1; \ + return CMD_RET_FAILURE; \ } \ } diff --git a/net/Kconfig b/net/Kconfig index 22b9eaac53..524b7e4da2 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -4,7 +4,16 @@ menuconfig NET bool "Networking support" + select REGEX if NET +config NET_RANDOM_ETHADDR + bool "Random ethaddr if unset" + help + Selecting this will allow the Ethernet interface to function + even when the ethaddr variable for that interface is unset. + A new MAC address will be generated on every boot and it will + not be added to the environment. + endif # if NET @@ -9,11 +9,13 @@ #include <common.h> #include <command.h> #include <dm.h> +#include <environment.h> #include <net.h> #include <miiphy.h> #include <phy.h> #include <asm/errno.h> #include <dm/device-internal.h> +#include <dm/uclass-internal.h> DECLARE_GLOBAL_DATA_PTR; @@ -60,16 +62,6 @@ static inline int eth_setenv_enetaddr_by_index(const char *base_name, int index, return eth_setenv_enetaddr(enetvar, enetaddr); } -static void eth_env_init(void) -{ - const char *s; - - s = getenv("bootfile"); - if (s != NULL) - copy_filename(net_boot_file_name, s, - sizeof(net_boot_file_name)); -} - static int eth_mac_skip(int index) { char enetvar[15]; @@ -104,8 +96,6 @@ static void eth_common_init(void) phy_init(); #endif - eth_env_init(); - /* * If board-specific initialization exists, call it. * If not, call a CPU-specific one @@ -281,6 +271,58 @@ int eth_get_dev_index(void) return -1; } +static int eth_write_hwaddr(struct udevice *dev) +{ + struct eth_pdata *pdata = dev->platdata; + int ret = 0; + + if (!dev || !device_active(dev)) + return -EINVAL; + + /* seq is valid since the device is active */ + if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev->seq)) { + if (!is_valid_ethaddr(pdata->enetaddr)) { + printf("\nError: %s address %pM illegal value\n", + dev->name, pdata->enetaddr); + return -EINVAL; + } + + ret = eth_get_ops(dev)->write_hwaddr(dev); + if (ret) + printf("\nWarning: %s failed to set MAC address\n", + dev->name); + } + + return ret; +} + +static int on_ethaddr(const char *name, const char *value, enum env_op op, + int flags) +{ + int index; + int retval; + struct udevice *dev; + + /* look for an index after "eth" */ + index = simple_strtoul(name + 3, NULL, 10); + + retval = uclass_find_device_by_seq(UCLASS_ETH, index, false, &dev); + if (!retval) { + struct eth_pdata *pdata = dev->platdata; + switch (op) { + case env_op_create: + case env_op_overwrite: + eth_parse_enetaddr(value, pdata->enetaddr); + break; + case env_op_delete: + memset(pdata->enetaddr, 0, 6); + } + } + + return 0; +} +U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr); + int eth_init(void) { struct udevice *current; @@ -298,16 +340,6 @@ int eth_init(void) debug("Trying %s\n", current->name); if (device_active(current)) { - uchar env_enetaddr[6]; - struct eth_pdata *pdata = current->platdata; - - /* Sync environment with network device */ - if (eth_getenv_enetaddr_by_index("eth", current->seq, - env_enetaddr)) - memcpy(pdata->enetaddr, env_enetaddr, 6); - else - memset(pdata->enetaddr, 0, 6); - ret = eth_get_ops(current)->start(current); if (ret >= 0) { struct eth_device_priv *priv = @@ -401,31 +433,6 @@ int eth_rx(void) return ret; } -static int eth_write_hwaddr(struct udevice *dev) -{ - struct eth_pdata *pdata = dev->platdata; - int ret = 0; - - if (!dev || !device_active(dev)) - return -EINVAL; - - /* seq is valid since the device is active */ - if (eth_get_ops(dev)->write_hwaddr && !eth_mac_skip(dev->seq)) { - if (!is_valid_ethaddr(pdata->enetaddr)) { - printf("\nError: %s address %pM illegal value\n", - dev->name, pdata->enetaddr); - return -EINVAL; - } - - ret = eth_get_ops(dev)->write_hwaddr(dev); - if (ret) - printf("\nWarning: %s failed to set MAC address\n", - dev->name); - } - - return ret; -} - int eth_initialize(void) { int num_devices = 0; @@ -529,9 +536,15 @@ static int eth_post_probe(struct udevice *dev) printf("\nWarning: %s using MAC address from ROM\n", dev->name); } else if (is_zero_ethaddr(pdata->enetaddr)) { +#ifdef CONFIG_NET_RANDOM_ETHADDR + net_random_ethaddr(pdata->enetaddr); + printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", + dev->name, dev->seq, pdata->enetaddr); +#else printf("\nError: %s address not set.\n", dev->name); return -EINVAL; +#endif } return 0; @@ -631,6 +644,36 @@ int eth_get_dev_index(void) return eth_current->index; } +static int on_ethaddr(const char *name, const char *value, enum env_op op, + int flags) +{ + int index; + struct eth_device *dev; + + if (!eth_devices) + return 0; + + /* look for an index after "eth" */ + index = simple_strtoul(name + 3, NULL, 10); + + dev = eth_devices; + do { + if (dev->index == index) { + switch (op) { + case env_op_create: + case env_op_overwrite: + eth_parse_enetaddr(value, dev->enetaddr); + break; + case env_op_delete: + memset(dev->enetaddr, 0, 6); + } + } + } while (dev != eth_devices); + + return 0; +} +U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr); + int eth_write_hwaddr(struct eth_device *dev, const char *base_name, int eth_number) { @@ -657,9 +700,15 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name, printf("\nWarning: %s using MAC address from net device\n", dev->name); } else if (is_zero_ethaddr(dev->enetaddr)) { +#ifdef CONFIG_NET_RANDOM_ETHADDR + net_random_ethaddr(dev->enetaddr); + printf("\nWarning: %s (eth%d) using random MAC address - %pM\n", + dev->name, eth_number, dev->enetaddr); +#else printf("\nError: %s address not set.\n", dev->name); return -EINVAL; +#endif } if (dev->write_hwaddr && !eth_mac_skip(eth_number)) { @@ -823,25 +872,13 @@ u32 ether_crc(size_t len, unsigned char const *p) int eth_init(void) { - struct eth_device *old_current, *dev; + struct eth_device *old_current; if (!eth_current) { puts("No ethernet found.\n"); return -ENODEV; } - /* Sync environment with network devices */ - dev = eth_devices; - do { - uchar env_enetaddr[6]; - - if (eth_getenv_enetaddr_by_index("eth", dev->index, - env_enetaddr)) - memcpy(dev->enetaddr, env_enetaddr, 6); - - dev = dev->next; - } while (dev != eth_devices); - old_current = eth_current; do { debug("Trying %s\n", eth_current->name); @@ -208,6 +208,9 @@ int __maybe_unused net_busy_flag; static int on_bootfile(const char *name, const char *value, enum env_op op, int flags) { + if (flags & H_PROGRAMMATIC) + return 0; + switch (op) { case env_op_create: case env_op_overwrite: @@ -222,6 +225,92 @@ static int on_bootfile(const char *name, const char *value, enum env_op op, } U_BOOT_ENV_CALLBACK(bootfile, on_bootfile); +static int on_ipaddr(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_ip = string_to_ip(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(ipaddr, on_ipaddr); + +static int on_gatewayip(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_gateway = string_to_ip(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(gatewayip, on_gatewayip); + +static int on_netmask(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_netmask = string_to_ip(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(netmask, on_netmask); + +static int on_serverip(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_server_ip = string_to_ip(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(serverip, on_serverip); + +static int on_nvlan(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_native_vlan = string_to_vlan(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(nvlan, on_nvlan); + +static int on_vlan(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_our_vlan = string_to_vlan(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(vlan, on_vlan); + +#if defined(CONFIG_CMD_DNS) +static int on_dnsip(const char *name, const char *value, enum env_op op, + int flags) +{ + if (flags & H_PROGRAMMATIC) + return 0; + + net_dns_server = string_to_ip(value); + + return 0; +} +U_BOOT_ENV_CALLBACK(dnsip, on_dnsip); +#endif + /* * Check if autoload is enabled. If so, use either NFS or TFTP to download * the boot file. @@ -252,22 +341,6 @@ void net_auto_load(void) static void net_init_loop(void) { - static int env_changed_id; - int env_id = get_env_id(); - - /* update only when the environment has changed */ - if (env_changed_id != env_id) { - net_ip = getenv_ip("ipaddr"); - net_gateway = getenv_ip("gatewayip"); - net_netmask = getenv_ip("netmask"); - net_server_ip = getenv_ip("serverip"); - net_native_vlan = getenv_vlan("nvlan"); - net_our_vlan = getenv_vlan("vlan"); -#if defined(CONFIG_CMD_DNS) - net_dns_server = getenv_ip("dnsip"); -#endif - env_changed_id = env_id; - } if (eth_get_dev()) memcpy(net_ethaddr, eth_get_ethaddr(), 6); diff --git a/test/Kconfig b/test/Kconfig index 3270c84213..d71c332eee 100644 --- a/test/Kconfig +++ b/test/Kconfig @@ -1,9 +1,19 @@ -config CMD_UT_TIME +menuconfig UNIT_TEST + bool "Unit tests" + help + Select this to compile in unit tests for various parts of + U-Boot. Test suites will be subcommands of the "ut" command. + This does not require sandbox to be included, but it is most + often used there. + +config UT_TIME bool "Unit tests for time functions" + depends on UNIT_TEST help - Enables the 'ut_time' command which tests that the time functions + Enables the 'ut time' command which tests that the time functions work correctly. The test is fairly simple and will not catch all problems. But if you are having problems with udelay() and the like, this is a good place to start. source "test/dm/Kconfig" +source "test/env/Kconfig" diff --git a/test/Makefile b/test/Makefile index 08330e020c..0f5de57399 100644 --- a/test/Makefile +++ b/test/Makefile @@ -4,6 +4,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_UNIT_TEST) += cmd_ut.o +obj-$(CONFIG_UNIT_TEST) += ut.o obj-$(CONFIG_SANDBOX) += command_ut.o obj-$(CONFIG_SANDBOX) += compression.o -obj-$(CONFIG_CMD_UT_TIME) += time_ut.o +obj-$(CONFIG_UT_TIME) += time_ut.o diff --git a/test/cmd_ut.c b/test/cmd_ut.c new file mode 100644 index 0000000000..f6e1f413db --- /dev/null +++ b/test/cmd_ut.c @@ -0,0 +1,80 @@ +/* + * (C) Copyright 2015 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include <common.h> +#include <command.h> +#include <test/suites.h> + +static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); + +static cmd_tbl_t cmd_ut_sub[] = { + U_BOOT_CMD_MKENT(all, CONFIG_SYS_MAXARGS, 1, do_ut_all, "", ""), +#if defined(CONFIG_UT_DM) + U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""), +#endif +#if defined(CONFIG_UT_ENV) + U_BOOT_CMD_MKENT(env, CONFIG_SYS_MAXARGS, 1, do_ut_env, "", ""), +#endif +#ifdef CONFIG_UT_TIME + U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""), +#endif +}; + +static int do_ut_all(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + int i; + int retval; + int any_fail = 0; + + for (i = 1; i < ARRAY_SIZE(cmd_ut_sub); i++) { + printf("----Running %s tests----\n", cmd_ut_sub[i].name); + retval = cmd_ut_sub[i].cmd(cmdtp, flag, 1, &cmd_ut_sub[i].name); + if (!any_fail) + any_fail = retval; + } + + return any_fail; +} + +static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + cmd_tbl_t *cp; + + if (argc < 2) + return CMD_RET_USAGE; + + /* drop initial "ut" arg */ + argc--; + argv++; + + cp = find_cmd_tbl(argv[0], cmd_ut_sub, ARRAY_SIZE(cmd_ut_sub)); + + if (cp) + return cp->cmd(cmdtp, flag, argc, argv); + + return CMD_RET_USAGE; +} + +#ifdef CONFIG_SYS_LONGHELP +static char ut_help_text[] = + "all - execute all enabled tests\n" +#ifdef CONFIG_UT_DM + "ut dm [test-name]\n" +#endif +#ifdef CONFIG_UT_ENV + "ut env [test-name]\n" +#endif +#ifdef CONFIG_UT_TIME + "ut time - Very basic test of time functions\n" +#endif + ; +#endif + +U_BOOT_CMD( + ut, CONFIG_SYS_MAXARGS, 1, do_ut, + "unit tests", ut_help_text +); diff --git a/test/dm/Kconfig b/test/dm/Kconfig index a9d0298e0d..e5b341e523 100644 --- a/test/dm/Kconfig +++ b/test/dm/Kconfig @@ -1,8 +1,8 @@ -config DM_TEST - bool "Enable driver model test command" - depends on SANDBOX && CMD_DM +config UT_DM + bool "Enable driver model unit test command" + depends on SANDBOX && UNIT_TEST help - This enables the 'dm test' command which runs a series of unit + This enables the 'ut dm' command which runs a series of unit tests on the driver model code. Each subsystem (uclass) is tested. If all is well then all tests pass although there will be a few messages printed along the way. diff --git a/test/dm/Makefile b/test/dm/Makefile index c7087bbfba..19ad2fb99f 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -5,17 +5,15 @@ # obj-$(CONFIG_CMD_DM) += cmd_dm.o -obj-$(CONFIG_DM_TEST) += bus.o -obj-$(CONFIG_DM_TEST) += test-driver.o -obj-$(CONFIG_DM_TEST) += test-fdt.o -obj-$(CONFIG_DM_TEST) += test-main.o -obj-$(CONFIG_DM_TEST) += test-uclass.o -obj-$(CONFIG_DM_TEST) += ut.o +obj-$(CONFIG_UT_DM) += bus.o +obj-$(CONFIG_UT_DM) += test-driver.o +obj-$(CONFIG_UT_DM) += test-fdt.o +obj-$(CONFIG_UT_DM) += test-main.o +obj-$(CONFIG_UT_DM) += test-uclass.o # Tests for particular subsystems - when enabling driver model for a new # subsystem you must add sandbox tests here. -obj-$(CONFIG_DM_TEST) += core.o -obj-$(CONFIG_DM_TEST) += ut.o +obj-$(CONFIG_UT_DM) += core.o ifneq ($(CONFIG_SANDBOX),) obj-$(CONFIG_DM_ETH) += eth.o obj-$(CONFIG_DM_GPIO) += gpio.o diff --git a/test/dm/bus.c b/test/dm/bus.c index 116a52db59..a215905add 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -10,8 +10,8 @@ #include <dm/root.h> #include <dm/test.h> #include <dm/uclass-internal.h> -#include <dm/ut.h> #include <dm/util.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; @@ -104,7 +104,7 @@ UCLASS_DRIVER(testbus) = { }; /* Test that we can probe for children */ -static int dm_test_bus_children(struct dm_test_state *dms) +static int dm_test_bus_children(struct unit_test_state *uts) { int num_devices = 6; struct udevice *bus; @@ -120,14 +120,14 @@ static int dm_test_bus_children(struct dm_test_state *dms) ut_assertok(uclass_get(UCLASS_TEST_FDT, &uc)); ut_asserteq(num_devices, list_count_items(&uc->dev_head)); - ut_assert(!dm_check_devices(dms, num_devices)); + ut_assert(!dm_check_devices(uts, num_devices)); return 0; } DM_TEST(dm_test_bus_children, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test our functions for accessing children */ -static int dm_test_bus_children_funcs(struct dm_test_state *dms) +static int dm_test_bus_children_funcs(struct unit_test_state *uts) { const void *blob = gd->fdt_blob; struct udevice *bus, *dev; @@ -173,7 +173,7 @@ static int dm_test_bus_children_funcs(struct dm_test_state *dms) DM_TEST(dm_test_bus_children_funcs, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that we can iterate through children */ -static int dm_test_bus_children_iterators(struct dm_test_state *dms) +static int dm_test_bus_children_iterators(struct unit_test_state *uts) { struct udevice *bus, *dev, *child; @@ -204,7 +204,7 @@ DM_TEST(dm_test_bus_children_iterators, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that the bus can store data about each child */ -static int test_bus_parent_data(struct dm_test_state *dms) +static int test_bus_parent_data(struct unit_test_state *uts) { struct dm_test_parent_data *parent_data; struct udevice *bus, *dev; @@ -264,14 +264,14 @@ static int test_bus_parent_data(struct dm_test_state *dms) return 0; } /* Test that the bus can store data about each child */ -static int dm_test_bus_parent_data(struct dm_test_state *dms) +static int dm_test_bus_parent_data(struct unit_test_state *uts) { - return test_bus_parent_data(dms); + return test_bus_parent_data(uts); } DM_TEST(dm_test_bus_parent_data, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* As above but the size is controlled by the uclass */ -static int dm_test_bus_parent_data_uclass(struct dm_test_state *dms) +static int dm_test_bus_parent_data_uclass(struct unit_test_state *uts) { struct driver *drv; struct udevice *bus; @@ -284,7 +284,7 @@ static int dm_test_bus_parent_data_uclass(struct dm_test_state *dms) size = drv->per_child_auto_alloc_size; bus->uclass->uc_drv->per_child_auto_alloc_size = size; drv->per_child_auto_alloc_size = 0; - ret = test_bus_parent_data(dms); + ret = test_bus_parent_data(uts); if (ret) return ret; bus->uclass->uc_drv->per_child_auto_alloc_size = 0; @@ -296,9 +296,10 @@ DM_TEST(dm_test_bus_parent_data_uclass, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that the bus ops are called when a child is probed/removed */ -static int dm_test_bus_parent_ops(struct dm_test_state *dms) +static int dm_test_bus_parent_ops(struct unit_test_state *uts) { struct dm_test_parent_data *parent_data; + struct dm_test_state *dms = uts->priv; struct udevice *bus, *dev; struct uclass *uc; @@ -333,7 +334,7 @@ static int dm_test_bus_parent_ops(struct dm_test_state *dms) } DM_TEST(dm_test_bus_parent_ops, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int test_bus_parent_platdata(struct dm_test_state *dms) +static int test_bus_parent_platdata(struct unit_test_state *uts) { struct dm_test_parent_platdata *plat; struct udevice *bus, *dev; @@ -406,14 +407,14 @@ static int test_bus_parent_platdata(struct dm_test_state *dms) } /* Test that the bus can store platform data about each child */ -static int dm_test_bus_parent_platdata(struct dm_test_state *dms) +static int dm_test_bus_parent_platdata(struct unit_test_state *uts) { - return test_bus_parent_platdata(dms); + return test_bus_parent_platdata(uts); } DM_TEST(dm_test_bus_parent_platdata, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* As above but the size is controlled by the uclass */ -static int dm_test_bus_parent_platdata_uclass(struct dm_test_state *dms) +static int dm_test_bus_parent_platdata_uclass(struct unit_test_state *uts) { struct udevice *bus; struct driver *drv; @@ -426,7 +427,7 @@ static int dm_test_bus_parent_platdata_uclass(struct dm_test_state *dms) size = drv->per_child_platdata_auto_alloc_size; bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = size; drv->per_child_platdata_auto_alloc_size = 0; - ret = test_bus_parent_platdata(dms); + ret = test_bus_parent_platdata(uts); if (ret) return ret; bus->uclass->uc_drv->per_child_platdata_auto_alloc_size = 0; @@ -438,7 +439,7 @@ DM_TEST(dm_test_bus_parent_platdata_uclass, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that the child post_bind method is called */ -static int dm_test_bus_child_post_bind(struct dm_test_state *dms) +static int dm_test_bus_child_post_bind(struct unit_test_state *uts) { struct dm_test_parent_platdata *plat; struct udevice *bus, *dev; @@ -461,7 +462,7 @@ static int dm_test_bus_child_post_bind(struct dm_test_state *dms) DM_TEST(dm_test_bus_child_post_bind, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that the child post_bind method is called */ -static int dm_test_bus_child_post_bind_uclass(struct dm_test_state *dms) +static int dm_test_bus_child_post_bind_uclass(struct unit_test_state *uts) { struct dm_test_parent_platdata *plat; struct udevice *bus, *dev; @@ -488,7 +489,7 @@ DM_TEST(dm_test_bus_child_post_bind_uclass, * Test that the bus' uclass' child_pre_probe() is called before the * device's probe() method */ -static int dm_test_bus_child_pre_probe_uclass(struct dm_test_state *dms) +static int dm_test_bus_child_pre_probe_uclass(struct unit_test_state *uts) { struct udevice *bus, *dev; int child_count; diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c index 2f527e959b..5bb2a99c8f 100644 --- a/test/dm/cmd_dm.c +++ b/test/dm/cmd_dm.c @@ -14,7 +14,6 @@ #include <errno.h> #include <asm/io.h> #include <dm/root.h> -#include <dm/test.h> #include <dm/uclass-internal.h> static void show_devices(struct udevice *dev, int depth, int last_flag) @@ -109,28 +108,9 @@ static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc, return 0; } -#ifdef CONFIG_DM_TEST -static int do_dm_test(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) -{ - const char *test_name = NULL; - - if (argc > 0) - test_name = argv[0]; - - return dm_test_main(test_name); -} -#define TEST_HELP "\ndm test Run tests" -#else -#define TEST_HELP -#endif - static cmd_tbl_t test_commands[] = { U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""), U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""), -#ifdef CONFIG_DM_TEST - U_BOOT_CMD_MKENT(test, 1, 1, do_dm_test, "", ""), -#endif }; static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) @@ -157,5 +137,4 @@ U_BOOT_CMD( "Driver model low level access", "tree Dump driver model tree ('*' = activated)\n" "dm uclass Dump list of instances for each uclass" - TEST_HELP ); diff --git a/test/dm/core.c b/test/dm/core.c index 91be1e5d43..976a70604f 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -13,10 +13,10 @@ #include <malloc.h> #include <dm/device-internal.h> #include <dm/root.h> -#include <dm/ut.h> #include <dm/util.h> #include <dm/test.h> #include <dm/uclass-internal.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; @@ -67,14 +67,14 @@ static struct driver_info driver_info_pre_reloc = { .platdata = &test_pdata_manual, }; -void dm_leak_check_start(struct dm_test_state *dms) +void dm_leak_check_start(struct unit_test_state *uts) { - dms->start = mallinfo(); - if (!dms->start.uordblks) + uts->start = mallinfo(); + if (!uts->start.uordblks) puts("Warning: Please add '#define DEBUG' to the top of common/dlmalloc.c\n"); } -int dm_leak_check_end(struct dm_test_state *dms) +int dm_leak_check_end(struct unit_test_state *uts) { struct mallinfo end; int id; @@ -90,14 +90,15 @@ int dm_leak_check_end(struct dm_test_state *dms) } end = mallinfo(); - ut_asserteq(dms->start.uordblks, end.uordblks); + ut_asserteq(uts->start.uordblks, end.uordblks); return 0; } /* Test that binding with platdata occurs correctly */ -static int dm_test_autobind(struct dm_test_state *dms) +static int dm_test_autobind(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; struct udevice *dev; /* @@ -130,7 +131,7 @@ static int dm_test_autobind(struct dm_test_state *dms) DM_TEST(dm_test_autobind, 0); /* Test that binding with uclass platdata allocation occurs correctly */ -static int dm_test_autobind_uclass_pdata_alloc(struct dm_test_state *dms) +static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts) { struct dm_test_perdev_uc_pdata *uc_pdata; struct udevice *dev; @@ -159,7 +160,7 @@ static int dm_test_autobind_uclass_pdata_alloc(struct dm_test_state *dms) DM_TEST(dm_test_autobind_uclass_pdata_alloc, DM_TESTF_SCAN_PDATA); /* Test that binding with uclass platdata setting occurs correctly */ -static int dm_test_autobind_uclass_pdata_valid(struct dm_test_state *dms) +static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts) { struct dm_test_perdev_uc_pdata *uc_pdata; struct udevice *dev; @@ -185,8 +186,9 @@ static int dm_test_autobind_uclass_pdata_valid(struct dm_test_state *dms) DM_TEST(dm_test_autobind_uclass_pdata_valid, DM_TESTF_SCAN_PDATA); /* Test that autoprobe finds all the expected devices */ -static int dm_test_autoprobe(struct dm_test_state *dms) +static int dm_test_autoprobe(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; int expected_base_add; struct udevice *dev; struct uclass *uc; @@ -252,7 +254,7 @@ static int dm_test_autoprobe(struct dm_test_state *dms) DM_TEST(dm_test_autoprobe, DM_TESTF_SCAN_PDATA); /* Check that we see the correct platdata in each device */ -static int dm_test_platdata(struct dm_test_state *dms) +static int dm_test_platdata(struct unit_test_state *uts) { const struct dm_test_pdata *pdata; struct udevice *dev; @@ -270,8 +272,9 @@ static int dm_test_platdata(struct dm_test_state *dms) DM_TEST(dm_test_platdata, DM_TESTF_SCAN_PDATA); /* Test that we can bind, probe, remove, unbind a driver */ -static int dm_test_lifecycle(struct dm_test_state *dms) +static int dm_test_lifecycle(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; int op_count[DM_TEST_OP_COUNT]; struct udevice *dev, *test_dev; int pingret; @@ -325,8 +328,9 @@ static int dm_test_lifecycle(struct dm_test_state *dms) DM_TEST(dm_test_lifecycle, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST); /* Test that we can bind/unbind and the lists update correctly */ -static int dm_test_ordering(struct dm_test_state *dms) +static int dm_test_ordering(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; struct udevice *dev, *dev_penultimate, *dev_last, *test_dev; int pingret; @@ -380,7 +384,7 @@ static int dm_test_ordering(struct dm_test_state *dms) DM_TEST(dm_test_ordering, DM_TESTF_SCAN_PDATA); /* Check that we can perform operations on a device (do a ping) */ -int dm_check_operations(struct dm_test_state *dms, struct udevice *dev, +int dm_check_operations(struct unit_test_state *uts, struct udevice *dev, uint32_t base, struct dm_test_priv *priv) { int expected; @@ -408,7 +412,7 @@ int dm_check_operations(struct dm_test_state *dms, struct udevice *dev, } /* Check that we can perform operations on devices */ -static int dm_test_operations(struct dm_test_state *dms) +static int dm_test_operations(struct unit_test_state *uts) { struct udevice *dev; int i; @@ -430,7 +434,7 @@ static int dm_test_operations(struct dm_test_state *dms) base = test_pdata[i].ping_add; debug("dev=%d, base=%d\n", i, base); - ut_assert(!dm_check_operations(dms, dev, base, dev->priv)); + ut_assert(!dm_check_operations(uts, dev, base, dev->priv)); } return 0; @@ -438,7 +442,7 @@ static int dm_test_operations(struct dm_test_state *dms) DM_TEST(dm_test_operations, DM_TESTF_SCAN_PDATA); /* Remove all drivers and check that things work */ -static int dm_test_remove(struct dm_test_state *dms) +static int dm_test_remove(struct unit_test_state *uts) { struct udevice *dev; int i; @@ -460,7 +464,7 @@ static int dm_test_remove(struct dm_test_state *dms) DM_TEST(dm_test_remove, DM_TESTF_SCAN_PDATA | DM_TESTF_PROBE_TEST); /* Remove and recreate everything, check for memory leaks */ -static int dm_test_leak(struct dm_test_state *dms) +static int dm_test_leak(struct unit_test_state *uts) { int i; @@ -469,7 +473,7 @@ static int dm_test_leak(struct dm_test_state *dms) int ret; int id; - dm_leak_check_start(dms); + dm_leak_check_start(uts); ut_assertok(dm_scan_platdata(false)); ut_assertok(dm_scan_fdt(gd->fdt_blob, false)); @@ -483,7 +487,7 @@ static int dm_test_leak(struct dm_test_state *dms) ut_assertok(ret); } - ut_assertok(dm_leak_check_end(dms)); + ut_assertok(dm_leak_check_end(uts)); } return 0; @@ -491,7 +495,7 @@ static int dm_test_leak(struct dm_test_state *dms) DM_TEST(dm_test_leak, 0); /* Test uclass init/destroy methods */ -static int dm_test_uclass(struct dm_test_state *dms) +static int dm_test_uclass(struct unit_test_state *uts) { struct uclass *uc; @@ -520,7 +524,7 @@ DM_TEST(dm_test_uclass, 0); * this array. * @return 0 if OK, -ve on error */ -static int create_children(struct dm_test_state *dms, struct udevice *parent, +static int create_children(struct unit_test_state *uts, struct udevice *parent, int count, int key, struct udevice *child[]) { struct udevice *dev; @@ -543,8 +547,9 @@ static int create_children(struct dm_test_state *dms, struct udevice *parent, #define NODE_COUNT 10 -static int dm_test_children(struct dm_test_state *dms) +static int dm_test_children(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; struct udevice *top[NODE_COUNT]; struct udevice *child[NODE_COUNT]; struct udevice *grandchild[NODE_COUNT]; @@ -559,15 +564,15 @@ static int dm_test_children(struct dm_test_state *dms) ut_assert(NODE_COUNT > 5); /* First create 10 top-level children */ - ut_assertok(create_children(dms, dms->root, NODE_COUNT, 0, top)); + ut_assertok(create_children(uts, dms->root, NODE_COUNT, 0, top)); /* Now a few have their own children */ - ut_assertok(create_children(dms, top[2], NODE_COUNT, 2, NULL)); - ut_assertok(create_children(dms, top[5], NODE_COUNT, 5, child)); + ut_assertok(create_children(uts, top[2], NODE_COUNT, 2, NULL)); + ut_assertok(create_children(uts, top[5], NODE_COUNT, 5, child)); /* And grandchildren */ for (i = 0; i < NODE_COUNT; i++) - ut_assertok(create_children(dms, child[i], NODE_COUNT, 50 * i, + ut_assertok(create_children(uts, child[i], NODE_COUNT, 50 * i, i == 2 ? grandchild : NULL)); /* Check total number of devices */ @@ -629,8 +634,9 @@ static int dm_test_children(struct dm_test_state *dms) DM_TEST(dm_test_children, 0); /* Test that pre-relocation devices work as expected */ -static int dm_test_pre_reloc(struct dm_test_state *dms) +static int dm_test_pre_reloc(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; struct udevice *dev; /* The normal driver should refuse to bind before relocation */ @@ -645,7 +651,7 @@ static int dm_test_pre_reloc(struct dm_test_state *dms) } DM_TEST(dm_test_pre_reloc, 0); -static int dm_test_uclass_before_ready(struct dm_test_state *dms) +static int dm_test_uclass_before_ready(struct unit_test_state *uts) { struct uclass *uc; @@ -661,7 +667,7 @@ static int dm_test_uclass_before_ready(struct dm_test_state *dms) } DM_TEST(dm_test_uclass_before_ready, 0); -static int dm_test_uclass_devices_find(struct dm_test_state *dms) +static int dm_test_uclass_devices_find(struct unit_test_state *uts) { struct udevice *dev; int ret; @@ -677,7 +683,7 @@ static int dm_test_uclass_devices_find(struct dm_test_state *dms) } DM_TEST(dm_test_uclass_devices_find, DM_TESTF_SCAN_PDATA); -static int dm_test_uclass_devices_find_by_name(struct dm_test_state *dms) +static int dm_test_uclass_devices_find_by_name(struct unit_test_state *uts) { struct udevice *finddev; struct udevice *testdev; @@ -714,7 +720,7 @@ static int dm_test_uclass_devices_find_by_name(struct dm_test_state *dms) } DM_TEST(dm_test_uclass_devices_find_by_name, DM_TESTF_SCAN_FDT); -static int dm_test_uclass_devices_get(struct dm_test_state *dms) +static int dm_test_uclass_devices_get(struct unit_test_state *uts) { struct udevice *dev; int ret; @@ -731,7 +737,7 @@ static int dm_test_uclass_devices_get(struct dm_test_state *dms) } DM_TEST(dm_test_uclass_devices_get, DM_TESTF_SCAN_PDATA); -static int dm_test_uclass_devices_get_by_name(struct dm_test_state *dms) +static int dm_test_uclass_devices_get_by_name(struct unit_test_state *uts) { struct udevice *finddev; struct udevice *testdev; @@ -775,7 +781,7 @@ static int dm_test_uclass_devices_get_by_name(struct dm_test_state *dms) } DM_TEST(dm_test_uclass_devices_get_by_name, DM_TESTF_SCAN_FDT); -static int dm_test_device_get_uclass_id(struct dm_test_state *dms) +static int dm_test_device_get_uclass_id(struct unit_test_state *uts) { struct udevice *dev; diff --git a/test/dm/eth.c b/test/dm/eth.c index 196eba85a2..700abdddbd 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -9,16 +9,16 @@ #include <common.h> #include <dm.h> -#include <dm/test.h> -#include <dm/ut.h> #include <fdtdec.h> #include <malloc.h> #include <net.h> +#include <dm/test.h> #include <asm/eth.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; -static int dm_test_eth(struct dm_test_state *dms) +static int dm_test_eth(struct unit_test_state *uts) { net_ping_ip = string_to_ip("1.1.2.2"); @@ -38,7 +38,7 @@ static int dm_test_eth(struct dm_test_state *dms) } DM_TEST(dm_test_eth, DM_TESTF_SCAN_FDT); -static int dm_test_eth_alias(struct dm_test_state *dms) +static int dm_test_eth_alias(struct unit_test_state *uts) { net_ping_ip = string_to_ip("1.1.2.2"); setenv("ethact", "eth0"); @@ -62,7 +62,7 @@ static int dm_test_eth_alias(struct dm_test_state *dms) } DM_TEST(dm_test_eth_alias, DM_TESTF_SCAN_FDT); -static int dm_test_eth_prime(struct dm_test_state *dms) +static int dm_test_eth_prime(struct unit_test_state *uts) { net_ping_ip = string_to_ip("1.1.2.2"); @@ -82,15 +82,9 @@ static int dm_test_eth_prime(struct dm_test_state *dms) } DM_TEST(dm_test_eth_prime, DM_TESTF_SCAN_FDT); -static int dm_test_eth_rotate(struct dm_test_state *dms) +/* The asserts include a return on fail; cleanup in the caller */ +static int _dm_test_eth_rotate1(struct unit_test_state *uts) { - char ethaddr[18]; - - /* Invalidate eth1's MAC address */ - net_ping_ip = string_to_ip("1.1.2.2"); - strcpy(ethaddr, getenv("eth1addr")); - setenv("eth1addr", NULL); - /* Make sure that the default is to rotate to the next interface */ setenv("ethact", "eth@10004000"); ut_assertok(net_loop(PING)); @@ -102,32 +96,61 @@ static int dm_test_eth_rotate(struct dm_test_state *dms) ut_asserteq(-EINVAL, net_loop(PING)); ut_asserteq_str("eth@10004000", getenv("ethact")); - /* Restore the env */ - setenv("eth1addr", ethaddr); - setenv("ethrotate", NULL); - - /* Invalidate eth0's MAC address */ - strcpy(ethaddr, getenv("ethaddr")); - setenv(".flags", "ethaddr"); - setenv("ethaddr", NULL); + return 0; +} +static int _dm_test_eth_rotate2(struct unit_test_state *uts) +{ /* Make sure we can skip invalid devices */ setenv("ethact", "eth@10004000"); ut_assertok(net_loop(PING)); ut_asserteq_str("eth@10004000", getenv("ethact")); + return 0; +} + +static int dm_test_eth_rotate(struct unit_test_state *uts) +{ + char ethaddr[18]; + int retval; + + /* Set target IP to mock ping */ + net_ping_ip = string_to_ip("1.1.2.2"); + + /* Invalidate eth1's MAC address */ + strcpy(ethaddr, getenv("eth1addr")); + /* Must disable access protection for eth1addr before clearing */ + setenv(".flags", "eth1addr"); + setenv("eth1addr", NULL); + + retval = _dm_test_eth_rotate1(uts); + + /* Restore the env */ + setenv("eth1addr", ethaddr); + setenv("ethrotate", NULL); + + if (!retval) { + /* Invalidate eth0's MAC address */ + strcpy(ethaddr, getenv("ethaddr")); + /* Must disable access protection for ethaddr before clearing */ + setenv(".flags", "ethaddr"); + setenv("ethaddr", NULL); + + retval = _dm_test_eth_rotate2(uts); + + /* Restore the env */ + setenv("ethaddr", ethaddr); + } /* Restore the env */ - setenv("ethaddr", ethaddr); setenv(".flags", NULL); - return 0; + return retval; } DM_TEST(dm_test_eth_rotate, DM_TESTF_SCAN_FDT); -static int dm_test_net_retry(struct dm_test_state *dms) +/* The asserts include a return on fail; cleanup in the caller */ +static int _dm_test_net_retry(struct unit_test_state *uts) { - net_ping_ip = string_to_ip("1.1.2.2"); - /* * eth1 is disabled and netretry is yes, so the ping should succeed and * the active device should be eth0 @@ -149,10 +172,21 @@ static int dm_test_net_retry(struct dm_test_state *dms) ut_asserteq(-ETIMEDOUT, net_loop(PING)); ut_asserteq_str("eth@10004000", getenv("ethact")); + return 0; +} + +static int dm_test_net_retry(struct unit_test_state *uts) +{ + int retval; + + net_ping_ip = string_to_ip("1.1.2.2"); + + retval = _dm_test_net_retry(uts); + /* Restore the env */ setenv("netretry", NULL); sandbox_eth_disable_response(1, false); - return 0; + return retval; } DM_TEST(dm_test_net_retry, DM_TESTF_SCAN_FDT); diff --git a/test/dm/gpio.c b/test/dm/gpio.c index b29daf1af4..727db18690 100644 --- a/test/dm/gpio.c +++ b/test/dm/gpio.c @@ -8,15 +8,15 @@ #include <fdtdec.h> #include <dm.h> #include <dm/root.h> -#include <dm/ut.h> #include <dm/test.h> #include <dm/util.h> #include <asm/gpio.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; /* Test that sandbox GPIOs work correctly */ -static int dm_test_gpio(struct dm_test_state *dms) +static int dm_test_gpio(struct unit_test_state *uts) { unsigned int offset, gpio; struct dm_gpio_ops *ops; @@ -103,7 +103,7 @@ static int dm_test_gpio(struct dm_test_state *dms) DM_TEST(dm_test_gpio, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that sandbox anonymous GPIOs work correctly */ -static int dm_test_gpio_anon(struct dm_test_state *dms) +static int dm_test_gpio_anon(struct unit_test_state *uts) { unsigned int offset, gpio; struct udevice *dev; @@ -125,7 +125,7 @@ static int dm_test_gpio_anon(struct dm_test_state *dms) DM_TEST(dm_test_gpio_anon, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that gpio_requestf() works as expected */ -static int dm_test_gpio_requestf(struct dm_test_state *dms) +static int dm_test_gpio_requestf(struct unit_test_state *uts) { unsigned int offset, gpio; struct udevice *dev; @@ -143,7 +143,7 @@ static int dm_test_gpio_requestf(struct dm_test_state *dms) DM_TEST(dm_test_gpio_requestf, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that gpio_request() copies its string */ -static int dm_test_gpio_copy(struct dm_test_state *dms) +static int dm_test_gpio_copy(struct unit_test_state *uts) { unsigned int offset, gpio; struct udevice *dev; @@ -165,19 +165,19 @@ static int dm_test_gpio_copy(struct dm_test_state *dms) DM_TEST(dm_test_gpio_copy, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that we don't leak memory with GPIOs */ -static int dm_test_gpio_leak(struct dm_test_state *dms) +static int dm_test_gpio_leak(struct unit_test_state *uts) { - ut_assertok(dm_test_gpio(dms)); - ut_assertok(dm_test_gpio_anon(dms)); - ut_assertok(dm_test_gpio_requestf(dms)); - ut_assertok(dm_leak_check_end(dms)); + ut_assertok(dm_test_gpio(uts)); + ut_assertok(dm_test_gpio_anon(uts)); + ut_assertok(dm_test_gpio_requestf(uts)); + ut_assertok(dm_leak_check_end(uts)); return 0; } DM_TEST(dm_test_gpio_leak, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that we can find GPIOs using phandles */ -static int dm_test_gpio_phandles(struct dm_test_state *dms) +static int dm_test_gpio_phandles(struct unit_test_state *uts) { struct gpio_desc desc, desc_list[8], desc_list2[8]; struct udevice *dev, *gpio_a, *gpio_b; diff --git a/test/dm/i2c.c b/test/dm/i2c.c index c5939a165e..23d612eb81 100644 --- a/test/dm/i2c.c +++ b/test/dm/i2c.c @@ -10,19 +10,19 @@ #include <dm.h> #include <fdtdec.h> #include <i2c.h> +#include <asm/state.h> +#include <asm/test.h> #include <dm/device-internal.h> #include <dm/test.h> #include <dm/uclass-internal.h> -#include <dm/ut.h> #include <dm/util.h> -#include <asm/state.h> -#include <asm/test.h> +#include <test/ut.h> static const int busnum; static const int chip = 0x2c; /* Test that we can find buses and chips */ -static int dm_test_i2c_find(struct dm_test_state *dms) +static int dm_test_i2c_find(struct unit_test_state *uts) { struct udevice *bus, *dev; const int no_chip = 0x10; @@ -43,7 +43,7 @@ static int dm_test_i2c_find(struct dm_test_state *dms) } DM_TEST(dm_test_i2c_find, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int dm_test_i2c_read_write(struct dm_test_state *dms) +static int dm_test_i2c_read_write(struct unit_test_state *uts) { struct udevice *bus, *dev; uint8_t buf[5]; @@ -60,7 +60,7 @@ static int dm_test_i2c_read_write(struct dm_test_state *dms) } DM_TEST(dm_test_i2c_read_write, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int dm_test_i2c_speed(struct dm_test_state *dms) +static int dm_test_i2c_speed(struct unit_test_state *uts) { struct udevice *bus, *dev; uint8_t buf[5]; @@ -82,7 +82,7 @@ static int dm_test_i2c_speed(struct dm_test_state *dms) } DM_TEST(dm_test_i2c_speed, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int dm_test_i2c_offset_len(struct dm_test_state *dms) +static int dm_test_i2c_offset_len(struct unit_test_state *uts) { struct udevice *bus, *dev; uint8_t buf[5]; @@ -99,7 +99,7 @@ static int dm_test_i2c_offset_len(struct dm_test_state *dms) } DM_TEST(dm_test_i2c_offset_len, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int dm_test_i2c_probe_empty(struct dm_test_state *dms) +static int dm_test_i2c_probe_empty(struct unit_test_state *uts) { struct udevice *bus, *dev; @@ -114,7 +114,7 @@ static int dm_test_i2c_probe_empty(struct dm_test_state *dms) } DM_TEST(dm_test_i2c_probe_empty, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int dm_test_i2c_bytewise(struct dm_test_state *dms) +static int dm_test_i2c_bytewise(struct unit_test_state *uts) { struct udevice *bus, *dev; struct udevice *eeprom; @@ -169,7 +169,7 @@ static int dm_test_i2c_bytewise(struct dm_test_state *dms) } DM_TEST(dm_test_i2c_bytewise, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); -static int dm_test_i2c_offset(struct dm_test_state *dms) +static int dm_test_i2c_offset(struct unit_test_state *uts) { struct udevice *eeprom; struct udevice *dev; diff --git a/test/dm/pci.c b/test/dm/pci.c index 6c63fa4c1f..2f3ae7941b 100644 --- a/test/dm/pci.c +++ b/test/dm/pci.c @@ -8,10 +8,10 @@ #include <dm.h> #include <asm/io.h> #include <dm/test.h> -#include <dm/ut.h> +#include <test/ut.h> /* Test that sandbox PCI works correctly */ -static int dm_test_pci_base(struct dm_test_state *dms) +static int dm_test_pci_base(struct unit_test_state *uts) { struct udevice *bus; @@ -22,7 +22,7 @@ static int dm_test_pci_base(struct dm_test_state *dms) DM_TEST(dm_test_pci_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that we can use the swapcase device correctly */ -static int dm_test_pci_swapcase(struct dm_test_state *dms) +static int dm_test_pci_swapcase(struct unit_test_state *uts) { pci_dev_t pci_dev = PCI_BDF(0, 0x1f, 0); struct pci_controller *hose; diff --git a/test/dm/pmic.c b/test/dm/pmic.c index e9c904c9f1..422ea3e416 100644 --- a/test/dm/pmic.c +++ b/test/dm/pmic.c @@ -14,17 +14,17 @@ #include <malloc.h> #include <dm/device-internal.h> #include <dm/root.h> -#include <dm/ut.h> #include <dm/util.h> #include <dm/test.h> #include <dm/uclass-internal.h> #include <power/pmic.h> #include <power/sandbox_pmic.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; /* Test PMIC get method */ -static int dm_test_power_pmic_get(struct dm_test_state *dms) +static int dm_test_power_pmic_get(struct unit_test_state *uts) { const char *name = "sandbox_pmic"; struct udevice *dev; @@ -40,7 +40,7 @@ static int dm_test_power_pmic_get(struct dm_test_state *dms) DM_TEST(dm_test_power_pmic_get, DM_TESTF_SCAN_FDT); /* Test PMIC I/O */ -static int dm_test_power_pmic_io(struct dm_test_state *dms) +static int dm_test_power_pmic_io(struct unit_test_state *uts) { const char *name = "sandbox_pmic"; uint8_t out_buffer, in_buffer; diff --git a/test/dm/regulator.c b/test/dm/regulator.c index c4f14bdac5..d279c04c84 100644 --- a/test/dm/regulator.c +++ b/test/dm/regulator.c @@ -14,13 +14,13 @@ #include <malloc.h> #include <dm/device-internal.h> #include <dm/root.h> -#include <dm/ut.h> #include <dm/util.h> #include <dm/test.h> #include <dm/uclass-internal.h> #include <power/pmic.h> #include <power/regulator.h> #include <power/sandbox_pmic.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; @@ -47,7 +47,7 @@ static const char *regulator_names[OUTPUT_COUNT][OUTPUT_NAME_COUNT] = { }; /* Test regulator get method */ -static int dm_test_power_regulator_get(struct dm_test_state *dms) +static int dm_test_power_regulator_get(struct unit_test_state *uts) { struct dm_regulator_uclass_platdata *uc_pdata; struct udevice *dev_by_devname; @@ -92,7 +92,7 @@ static int dm_test_power_regulator_get(struct dm_test_state *dms) DM_TEST(dm_test_power_regulator_get, DM_TESTF_SCAN_FDT); /* Test regulator set and get Voltage method */ -static int dm_test_power_regulator_set_get_voltage(struct dm_test_state *dms) +static int dm_test_power_regulator_set_get_voltage(struct unit_test_state *uts) { struct dm_regulator_uclass_platdata *uc_pdata; struct udevice *dev; @@ -119,7 +119,7 @@ static int dm_test_power_regulator_set_get_voltage(struct dm_test_state *dms) DM_TEST(dm_test_power_regulator_set_get_voltage, DM_TESTF_SCAN_FDT); /* Test regulator set and get Current method */ -static int dm_test_power_regulator_set_get_current(struct dm_test_state *dms) +static int dm_test_power_regulator_set_get_current(struct unit_test_state *uts) { struct dm_regulator_uclass_platdata *uc_pdata; struct udevice *dev; @@ -158,7 +158,7 @@ static int dm_test_power_regulator_set_get_current(struct dm_test_state *dms) DM_TEST(dm_test_power_regulator_set_get_current, DM_TESTF_SCAN_FDT); /* Test regulator set and get Enable method */ -static int dm_test_power_regulator_set_get_enable(struct dm_test_state *dms) +static int dm_test_power_regulator_set_get_enable(struct unit_test_state *uts) { const char *platname; struct udevice *dev; @@ -177,7 +177,7 @@ static int dm_test_power_regulator_set_get_enable(struct dm_test_state *dms) DM_TEST(dm_test_power_regulator_set_get_enable, DM_TESTF_SCAN_FDT); /* Test regulator set and get mode method */ -static int dm_test_power_regulator_set_get_mode(struct dm_test_state *dms) +static int dm_test_power_regulator_set_get_mode(struct unit_test_state *uts) { const char *platname; struct udevice *dev; @@ -196,7 +196,7 @@ static int dm_test_power_regulator_set_get_mode(struct dm_test_state *dms) DM_TEST(dm_test_power_regulator_set_get_mode, DM_TESTF_SCAN_FDT); /* Test regulator autoset method */ -static int dm_test_power_regulator_autoset(struct dm_test_state *dms) +static int dm_test_power_regulator_autoset(struct unit_test_state *uts) { const char *platname; struct udevice *dev, *dev_autoset; @@ -276,7 +276,7 @@ static const struct setting expected_setting_list[] = { static int list_count = ARRAY_SIZE(expected_setting_list); /* Test regulator list autoset method */ -static int dm_test_power_regulator_autoset_list(struct dm_test_state *dms) +static int dm_test_power_regulator_autoset_list(struct unit_test_state *uts) { struct udevice *dev_list[2], *dev; int i; diff --git a/test/dm/rtc.c b/test/dm/rtc.c index 9397cf72a7..4345708a3d 100644 --- a/test/dm/rtc.c +++ b/test/dm/rtc.c @@ -9,12 +9,12 @@ #include <dm.h> #include <rtc.h> #include <asm/io.h> -#include <dm/test.h> -#include <dm/ut.h> #include <asm/test.h> +#include <dm/test.h> +#include <test/ut.h> /* Simple RTC sanity check */ -static int dm_test_rtc_base(struct dm_test_state *dms) +static int dm_test_rtc_base(struct unit_test_state *uts) { struct udevice *dev; @@ -52,7 +52,7 @@ static int cmp_times(struct rtc_time *expect, struct rtc_time *time, bool show) } /* Set and get the time */ -static int dm_test_rtc_set_get(struct dm_test_state *dms) +static int dm_test_rtc_set_get(struct unit_test_state *uts) { struct rtc_time now, time, cmp; struct udevice *dev, *emul; @@ -117,7 +117,7 @@ static int dm_test_rtc_set_get(struct dm_test_state *dms) DM_TEST(dm_test_rtc_set_get, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Reset the time */ -static int dm_test_rtc_reset(struct dm_test_state *dms) +static int dm_test_rtc_reset(struct unit_test_state *uts) { struct rtc_time now; struct udevice *dev, *emul; @@ -143,7 +143,7 @@ static int dm_test_rtc_reset(struct dm_test_state *dms) DM_TEST(dm_test_rtc_reset, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Check that two RTC devices can be used independently */ -static int dm_test_rtc_dual(struct dm_test_state *dms) +static int dm_test_rtc_dual(struct unit_test_state *uts) { struct rtc_time now1, now2, cmp; struct udevice *dev1, *dev2; diff --git a/test/dm/sf.c b/test/dm/sf.c index 08098a18b8..b0844629f9 100644 --- a/test/dm/sf.c +++ b/test/dm/sf.c @@ -10,12 +10,12 @@ #include <spi.h> #include <spi_flash.h> #include <asm/state.h> -#include <dm/ut.h> #include <dm/test.h> #include <dm/util.h> +#include <test/ut.h> /* Test that sandbox SPI flash works correctly */ -static int dm_test_spi_flash(struct dm_test_state *dms) +static int dm_test_spi_flash(struct unit_test_state *uts) { /* * Create an empty test file and run the SPI flash tests. This is a diff --git a/test/dm/spi.c b/test/dm/spi.c index c7ee65207b..2e27da72d5 100644 --- a/test/dm/spi.c +++ b/test/dm/spi.c @@ -9,15 +9,15 @@ #include <fdtdec.h> #include <spi.h> #include <spi_flash.h> +#include <asm/state.h> #include <dm/device-internal.h> #include <dm/test.h> #include <dm/uclass-internal.h> -#include <dm/ut.h> #include <dm/util.h> -#include <asm/state.h> +#include <test/ut.h> /* Test that we can find buses and chip-selects */ -static int dm_test_spi_find(struct dm_test_state *dms) +static int dm_test_spi_find(struct unit_test_state *uts) { struct sandbox_state *state = state_get_current(); struct spi_slave *slave; @@ -95,7 +95,7 @@ static int dm_test_spi_find(struct dm_test_state *dms) DM_TEST(dm_test_spi_find, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that sandbox SPI works correctly */ -static int dm_test_spi_xfer(struct dm_test_state *dms) +static int dm_test_spi_xfer(struct unit_test_state *uts) { struct spi_slave *slave; struct udevice *bus; diff --git a/test/dm/test-dm.sh b/test/dm/test-dm.sh index 5c47ffd5d2..1a0f1509b4 100755 --- a/test/dm/test-dm.sh +++ b/test/dm/test-dm.sh @@ -11,6 +11,6 @@ make O=sandbox -s -j${NUM_CPUS} || die "Cannot build U-Boot" dd if=/dev/zero of=spi.bin bs=1M count=2 echo -n "this is a test" > testflash.bin dd if=/dev/zero bs=1M count=4 >>testflash.bin -./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb -c "dm test" +./sandbox/u-boot -d ./sandbox/arch/sandbox/dts/test.dtb -c "ut dm" rm spi.bin rm testflash.bin diff --git a/test/dm/test-driver.c b/test/dm/test-driver.c index bc6a6e721d..d10af51147 100644 --- a/test/dm/test-driver.c +++ b/test/dm/test-driver.c @@ -12,11 +12,11 @@ #include <errno.h> #include <malloc.h> #include <dm/test.h> -#include <dm/ut.h> +#include <test/ut.h> #include <asm/io.h> int dm_testdrv_op_count[DM_TEST_OP_COUNT]; -static struct dm_test_state *dms = &global_test_state; +static struct unit_test_state *uts = &global_dm_test_state; static int testdrv_ping(struct udevice *dev, int pingval, int *pingret) { @@ -114,6 +114,8 @@ static int test_manual_bind(struct udevice *dev) static int test_manual_probe(struct udevice *dev) { + struct dm_test_state *dms = uts->priv; + dm_testdrv_op_count[DM_TEST_OP_PROBE]++; if (!dms->force_fail_alloc) dev->priv = calloc(1, sizeof(struct dm_test_priv)); diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index b8ee9599a2..49a36cb193 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -12,9 +12,9 @@ #include <asm/io.h> #include <dm/test.h> #include <dm/root.h> -#include <dm/ut.h> #include <dm/uclass-internal.h> #include <dm/util.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; @@ -99,7 +99,7 @@ UCLASS_DRIVER(testfdt) = { .flags = DM_UC_FLAG_SEQ_ALIAS, }; -int dm_check_devices(struct dm_test_state *dms, int num_devices) +int dm_check_devices(struct unit_test_state *uts, int num_devices) { struct udevice *dev; int ret; @@ -126,7 +126,7 @@ int dm_check_devices(struct dm_test_state *dms, int num_devices) debug("dev=%d, base=%d: %s\n", i, base, fdt_get_name(gd->fdt_blob, dev->of_offset, NULL)); - ut_assert(!dm_check_operations(dms, dev, base, + ut_assert(!dm_check_operations(uts, dev, base, dev_get_priv(dev))); } @@ -134,7 +134,7 @@ int dm_check_devices(struct dm_test_state *dms, int num_devices) } /* Test that FDT-based binding works correctly */ -static int dm_test_fdt(struct dm_test_state *dms) +static int dm_test_fdt(struct unit_test_state *uts) { const int num_devices = 6; struct udevice *dev; @@ -159,13 +159,13 @@ static int dm_test_fdt(struct dm_test_state *dms) ut_assert(dev->platdata); } - ut_assertok(dm_check_devices(dms, num_devices)); + ut_assertok(dm_check_devices(uts, num_devices)); return 0; } DM_TEST(dm_test_fdt, 0); -static int dm_test_fdt_pre_reloc(struct dm_test_state *dms) +static int dm_test_fdt_pre_reloc(struct unit_test_state *uts) { struct uclass *uc; int ret; @@ -184,7 +184,7 @@ static int dm_test_fdt_pre_reloc(struct dm_test_state *dms) DM_TEST(dm_test_fdt_pre_reloc, 0); /* Test that sequence numbers are allocated properly */ -static int dm_test_fdt_uclass_seq(struct dm_test_state *dms) +static int dm_test_fdt_uclass_seq(struct unit_test_state *uts) { struct udevice *dev; @@ -239,7 +239,7 @@ static int dm_test_fdt_uclass_seq(struct dm_test_state *dms) DM_TEST(dm_test_fdt_uclass_seq, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); /* Test that we can find a device by device tree offset */ -static int dm_test_fdt_offset(struct dm_test_state *dms) +static int dm_test_fdt_offset(struct unit_test_state *uts) { const void *blob = gd->fdt_blob; struct udevice *dev; diff --git a/test/dm/test-main.c b/test/dm/test-main.c index 7348f69165..0477d2fa73 100644 --- a/test/dm/test-main.c +++ b/test/dm/test-main.c @@ -5,21 +5,25 @@ */ #include <common.h> +#include <command.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <dm/test.h> #include <dm/root.h> #include <dm/uclass-internal.h> -#include <dm/ut.h> +#include <test/ut.h> DECLARE_GLOBAL_DATA_PTR; -struct dm_test_state global_test_state; +struct unit_test_state global_dm_test_state; +static struct dm_test_state _global_priv_dm_test_state; /* Get ready for testing */ -static int dm_test_init(struct dm_test_state *dms) +static int dm_test_init(struct unit_test_state *uts) { + struct dm_test_state *dms = uts->priv; + memset(dms, '\0', sizeof(*dms)); gd->dm_root = NULL; memset(dm_testdrv_op_count, '\0', sizeof(dm_testdrv_op_count)); @@ -31,7 +35,7 @@ static int dm_test_init(struct dm_test_state *dms) } /* Ensure all the test devices are probed */ -static int do_autoprobe(struct dm_test_state *dms) +static int do_autoprobe(struct unit_test_state *uts) { struct udevice *dev; int ret; @@ -45,7 +49,7 @@ static int do_autoprobe(struct dm_test_state *dms) return ret; } -static int dm_test_destroy(struct dm_test_state *dms) +static int dm_test_destroy(struct unit_test_state *uts) { int id; @@ -65,12 +69,13 @@ static int dm_test_destroy(struct dm_test_state *dms) return 0; } -int dm_test_main(const char *test_name) +static int dm_test_main(const char *test_name) { - struct dm_test *tests = ll_entry_start(struct dm_test, dm_test); - const int n_ents = ll_entry_count(struct dm_test, dm_test); - struct dm_test_state *dms = &global_test_state; - struct dm_test *test; + struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); + const int n_ents = ll_entry_count(struct unit_test, dm_test); + struct unit_test_state *uts = &global_dm_test_state; + uts->priv = &_global_priv_dm_test_state; + struct unit_test *test; /* * If we have no device tree, or it only has a root node, then these @@ -89,23 +94,37 @@ int dm_test_main(const char *test_name) if (test_name && strcmp(test_name, test->name)) continue; printf("Test: %s\n", test->name); - ut_assertok(dm_test_init(dms)); + ut_assertok(dm_test_init(uts)); - dms->start = mallinfo(); + uts->start = mallinfo(); if (test->flags & DM_TESTF_SCAN_PDATA) ut_assertok(dm_scan_platdata(false)); if (test->flags & DM_TESTF_PROBE_TEST) - ut_assertok(do_autoprobe(dms)); + ut_assertok(do_autoprobe(uts)); if (test->flags & DM_TESTF_SCAN_FDT) ut_assertok(dm_scan_fdt(gd->fdt_blob, false)); - if (test->func(dms)) - break; + test->func(uts); - ut_assertok(dm_test_destroy(dms)); + ut_assertok(dm_test_destroy(uts)); } - printf("Failures: %d\n", dms->fail_count); + printf("Failures: %d\n", uts->fail_count); - return 0; + gd->dm_root = NULL; + ut_assertok(dm_init()); + dm_scan_platdata(false); + dm_scan_fdt(gd->fdt_blob, false); + + return uts->fail_count ? CMD_RET_FAILURE : 0; +} + +int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + const char *test_name = NULL; + + if (argc > 1) + test_name = argv[1]; + + return dm_test_main(test_name); } diff --git a/test/dm/test-uclass.c b/test/dm/test-uclass.c index 4ae75ef764..4a543bb621 100644 --- a/test/dm/test-uclass.c +++ b/test/dm/test-uclass.c @@ -11,12 +11,12 @@ #include <malloc.h> #include <dm.h> #include <errno.h> -#include <dm/test.h> -#include <dm/ut.h> #include <asm/io.h> +#include <dm/test.h> #include <linux/list.h> +#include <test/ut.h> -static struct dm_test_state *dms = &global_test_state; +static struct unit_test_state *uts = &global_dm_test_state; int test_ping(struct udevice *dev, int pingval, int *pingret) { @@ -70,6 +70,7 @@ static int test_post_probe(struct udevice *dev) struct dm_test_uclass_perdev_priv *priv = dev_get_uclass_priv(dev); struct uclass *uc = dev->uclass; + struct dm_test_state *dms = uts->priv; dm_testdrv_op_count[DM_TEST_OP_POST_PROBE]++; ut_assert(priv); diff --git a/test/dm/usb.c b/test/dm/usb.c index 6ea86d7247..9939d837a9 100644 --- a/test/dm/usb.c +++ b/test/dm/usb.c @@ -9,10 +9,10 @@ #include <usb.h> #include <asm/io.h> #include <dm/test.h> -#include <dm/ut.h> +#include <test/ut.h> /* Test that sandbox USB works correctly */ -static int dm_test_usb_base(struct dm_test_state *dms) +static int dm_test_usb_base(struct unit_test_state *uts) { struct udevice *bus; @@ -29,7 +29,7 @@ DM_TEST(dm_test_usb_base, DM_TESTF_SCAN_PDATA | DM_TESTF_SCAN_FDT); * covers scanning the bug, setting up a hub and a flash stick and reading * data from the flash stick. */ -static int dm_test_usb_flash(struct dm_test_state *dms) +static int dm_test_usb_flash(struct unit_test_state *uts) { struct udevice *dev; block_dev_desc_t *dev_desc; diff --git a/test/env/Kconfig b/test/env/Kconfig new file mode 100644 index 0000000000..ff164132e9 --- /dev/null +++ b/test/env/Kconfig @@ -0,0 +1,8 @@ +config UT_ENV + bool "Enable env unit tests" + depends on UNIT_TEST + help + This enables the 'ut env' command which runs a series of unit + tests on the env code. + If all is well then all tests pass although there will be a few + messages printed along the way. diff --git a/test/env/Makefile b/test/env/Makefile new file mode 100644 index 0000000000..5168bcb328 --- /dev/null +++ b/test/env/Makefile @@ -0,0 +1,8 @@ +# +# Copyright (c) 2015 National Instruments, Inc +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y += cmd_ut_env.o +obj-y += attr.o diff --git a/test/env/attr.c b/test/env/attr.c new file mode 100644 index 0000000000..45b8c753a4 --- /dev/null +++ b/test/env/attr.c @@ -0,0 +1,89 @@ +/* + * (C) Copyright 2015 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include <common.h> +#include <command.h> +#include <env_attr.h> +#include <test/env.h> +#include <test/ut.h> + +static int env_test_attrs_lookup(struct unit_test_state *uts) +{ + char attrs[32]; + + ut_assertok(env_attr_lookup("foo:bar", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(",foo:bar", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(",foo:bar,", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(" foo:bar", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup("foo : bar", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(" foo: bar ", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup("foo:bar ", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(",foo:bar,goo:baz", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_asserteq(-ENOENT, env_attr_lookup(",,", "foo", attrs)); + + ut_asserteq(-ENOENT, env_attr_lookup("goo:baz", "foo", attrs)); + + ut_assertok(env_attr_lookup("foo:bar,foo:bat,foo:baz", "foo", attrs)); + ut_asserteq_str("baz", attrs); + + ut_assertok(env_attr_lookup( + " foo : bar , foo : bat , foot : baz ", "foo", attrs)); + ut_asserteq_str("bat", attrs); + + ut_assertok(env_attr_lookup( + " foo : bar , foo : bat , ufoo : baz ", "foo", attrs)); + ut_asserteq_str("bat", attrs); + + ut_asserteq(-EINVAL, env_attr_lookup(NULL, "foo", attrs)); + ut_asserteq(-EINVAL, env_attr_lookup("foo:bar", "foo", NULL)); + + return 0; +} +ENV_TEST(env_test_attrs_lookup, 0); + +#ifdef CONFIG_REGEX +static int env_test_attrs_lookup_regex(struct unit_test_state *uts) +{ + char attrs[32]; + + ut_assertok(env_attr_lookup("foo1?:bar", "foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup("foo1?:bar", "foo1", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(".foo:bar", ".foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup(".foo:bar", "ufoo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_assertok(env_attr_lookup("\\.foo:bar", ".foo", attrs)); + ut_asserteq_str("bar", attrs); + + ut_asserteq(-ENOENT, env_attr_lookup("\\.foo:bar", "ufoo", attrs)); + + return 0; +} +ENV_TEST(env_test_attrs_lookup_regex, 0); +#endif diff --git a/test/env/cmd_ut_env.c b/test/env/cmd_ut_env.c new file mode 100644 index 0000000000..893e5e6a6d --- /dev/null +++ b/test/env/cmd_ut_env.c @@ -0,0 +1,37 @@ +/* + * (C) Copyright 2015 + * Joe Hershberger, National Instruments, joe.hershberger@ni.com + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include <common.h> +#include <command.h> +#include <test/env.h> +#include <test/suites.h> +#include <test/ut.h> + +int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, env_test); + const int n_ents = ll_entry_count(struct unit_test, env_test); + struct unit_test_state uts = { .fail_count = 0 }; + struct unit_test *test; + + if (argc == 1) + printf("Running %d environment tests\n", n_ents); + + for (test = tests; test < tests + n_ents; test++) { + if (argc > 1 && strcmp(argv[1], test->name)) + continue; + printf("Test: %s\n", test->name); + + uts.start = mallinfo(); + + test->func(&uts); + } + + printf("Failures: %d\n", uts.fail_count); + + return uts.fail_count ? CMD_RET_FAILURE : 0; +} diff --git a/test/time_ut.c b/test/time_ut.c index 6b52245d7f..8ca9fcb6aa 100644 --- a/test/time_ut.c +++ b/test/time_ut.c @@ -116,7 +116,7 @@ static int test_udelay(void) return 0; } -static int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { int ret = 0; @@ -129,9 +129,3 @@ static int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS; } - -U_BOOT_CMD( - ut_time, 1, 1, do_ut_time, - "Very basic test of time functions", - "" -); diff --git a/test/dm/ut.c b/test/ut.c index 8b69bc2ab1..0282de595b 100644 --- a/test/dm/ut.c +++ b/test/ut.c @@ -1,5 +1,5 @@ /* - * Simple unit test library for driver model + * Simple unit test library * * Copyright (c) 2013 Google, Inc * @@ -7,19 +7,17 @@ */ #include <common.h> -#include <dm/test.h> -#include <dm/ut.h> +#include <test/test.h> +#include <test/ut.h> -struct dm_test_state; - -void ut_fail(struct dm_test_state *dms, const char *fname, int line, +void ut_fail(struct unit_test_state *uts, const char *fname, int line, const char *func, const char *cond) { printf("%s:%d, %s(): %s\n", fname, line, func, cond); - dms->fail_count++; + uts->fail_count++; } -void ut_failf(struct dm_test_state *dms, const char *fname, int line, +void ut_failf(struct unit_test_state *uts, const char *fname, int line, const char *func, const char *cond, const char *fmt, ...) { va_list args; @@ -29,5 +27,5 @@ void ut_failf(struct dm_test_state *dms, const char *fname, int line, vprintf(fmt, args); va_end(args); putc('\n'); - dms->fail_count++; + uts->fail_count++; } |