Re: [U-Boot] device tree compilation problems.
Dear Simon Glass, In message capnjgz3s2+w0ppyuh8c4jqgsemsbzwwdeqbquwkz_bf1o0o...@mail.gmail.com you wrote: $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts - cat $ | $(CPP) -P $(DTS_CPPFLAGS) - $@.tmp - $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} $@.tmp - rm $@.tmp ... The lines above are running the .dts file through the C proprocessor to create a tmp file, which is then compiled. It is only really used to get the name of the SOC's device tree include file - see the definition of DTS_CPPFLAGS. Is there actually any reason for the cat (the UUOCA seems to be extinct these days, cf. http://partmaps.org/era/unix/award.html) and the tmp file? Why not rewriting as $(CPP) -P $(DTS_CPPFLAGS) $ | \ $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} - ? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de This message was made from 100% recycled electrons. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] net/eth.c: fix eth_write_hwaddr() to use dev-enetaddr as fall back
On 23.01.2012 08:31, Simon Glass wrote: Hi, On Thu, Jan 19, 2012 at 12:56 AM, Dirk Behme dirk.be...@de.bosch.com wrote: From: Eric Miao eric.m...@linaro.org Ignore the return value of eth_getenv_enetaddr_by_index(), and if it fails, fall back to use dev-enetaddr, which could be filled up by the ethernet device driver: With the current code, introduced with below commit, eth_write_hwaddr() will fail immediately if there is no ethnaddr in the environment variables. However, e.g. for an overo based product that uses the SMSC911x ethernet chip (with the MAC address set via EEPROM connected to the SMSC911x chip), the MAC address is still OK. On mx28 boards that are depending on the OCOTP bits to set the MAC address (like the Denx m28 board), the OCOTP bits should be used instead of failing on the environment variables. Actually, this was the original behavior, and was later changed by commit 7616e7850804c7c69e0a22c179dfcba9e8f3f587. Signed-off-by: Eric Miao eric.m...@linaro.org Acked-by: Simon Glass s...@chromium.org Acked-by: Dirk Behme dirk.be...@de.bosch.com CC: Stefan Roese s...@denx.de CC: Eric Miao eric.m...@linaro.org CC: Wolfgang Denk w...@denx.de CC: Philip Balister phi...@balister.org CC: Zach Sadecki z...@itwatchdogs.com --- v2: Correct the referenced commit ID and update the commit message. No functional change at the code itself. Note: This resend is based on my understanding from http://lists.denx.de/pipermail/u-boot/2012-January/116118.html Please let Eric and me know if I missed anything there. I don't think you have missed anything and I have already acked this. But I want to start a related discussion. The code structure does bug me a bit - I think it is too confusing. eth_getenv_enetaddr() returns an error if there is no environment variable set or if the address it gets from the environment variable is invalid. We should probably not conflate those two. The first is ok here, but the second isn't, I think. What if the driver has no write_hwaddr method? Do we silently ignore the environment variable value? Why use memcmp() against env_enetaddr when the function we just called returns an error that tells us whether it is supposed to be valid (the error return your patch squashes)? We set the hwaddr by writing directly into the dev-enet_addr field and then calling write_hwaddr() if it exists. Maybe that is ok - is the lack of write_hwaddr() an indication that the driver does MAC address handling on the fly, or just that it can't set the MAC address at all? Overall I feel that eth_write_hwaddr() should return success or failure, confident in its determination that there is either a valid MAC address or there is not. The message you are seeing is I suppose an indication that it thinks there is a problem, when in fact none exists in this case. At the moment it feels fragile. I wonder whether a little refactor here would be best? That said, your patch restores the original behaviour, hiding the problem which isn't actually a problem in this case, and which we don't want to report. So it is better than the status quo. Ok, thanks. I'm not an expert for this code, nor is the patch from me. It's from Eric ;) I just try to help to mainline all the stuff we have collected for i.MX6. Therefore I wonder if it would be possible to split this into two steps: a) Improve the status quo by applying this patch b) In parallel discuss how to refactor and improve this code as you describe above It's my feeling that with (a) we still have a chance to improve v2012.03. But I doubt that (b) would make it into v2012.03. Best regards Dirk ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 0/4] Add SMDK5250 board support
This patchset add support for Samsung's SMDK5250 board based on EXYNOS5250 based SoC. It also adds support for MMC SPL booting. The porting is done by Samsung engineers at HQ in System LSI Team. I am contributing in upstreaming the code for the board. Based upon discussions following patches are dropped in this version: Exynos: Add CONFIG_EXYNOS4 Macro to EXYNOS4 based boards Exynos: Clock.c: Replace exynos4 prefix with exynos SMDK5250: enable device tree support is squashed with EXYNOS: Add SMDK5250 board support Chander Kashyap (4): Exynos: Clock.c: Use CONFIG_SYS_CLK_FREQ macro ARM: EXYNOS: Add support for Exynos5 based SoCs EXYNOS: Add SMDK5250 board support EXYNOS: SMDK5250: Add MMC SPL support MAINTAINERS |1 + arch/arm/cpu/armv7/exynos/clock.c | 214 ++- arch/arm/include/asm/arch-exynos/clock.h | 326 arch/arm/include/asm/arch-exynos/cpu.h| 35 ++- arch/arm/include/asm/arch-exynos/dmc.h| 146 +++ arch/arm/include/asm/arch-exynos/gpio.h | 99 +- arch/arm/include/asm/arch-exynos/tzpc.h | 52 +++ board/samsung/smdk5250/Makefile | 67 board/samsung/smdk5250/clock_init.c | 202 ++ board/samsung/smdk5250/dmc_init.c | 508 + board/samsung/smdk5250/lowlevel_init.S| 96 + board/samsung/smdk5250/mmc_boot.c | 58 +++ board/samsung/smdk5250/setup.h| 353 + board/samsung/smdk5250/smdk5250.c | 152 board/samsung/smdk5250/tools/mkexynos_image.c | 117 ++ board/samsung/smdk5250/tzpc_init.c| 48 +++ boards.cfg|1 + include/configs/s5pc210_universal.h |1 + include/configs/smdk5250.h| 202 ++ include/configs/trats.h |1 + 20 files changed, 2662 insertions(+), 17 deletions(-) create mode 100644 arch/arm/include/asm/arch-exynos/dmc.h create mode 100644 arch/arm/include/asm/arch-exynos/tzpc.h create mode 100644 board/samsung/smdk5250/Makefile create mode 100644 board/samsung/smdk5250/clock_init.c create mode 100644 board/samsung/smdk5250/dmc_init.c create mode 100644 board/samsung/smdk5250/lowlevel_init.S create mode 100644 board/samsung/smdk5250/mmc_boot.c create mode 100644 board/samsung/smdk5250/setup.h create mode 100644 board/samsung/smdk5250/smdk5250.c create mode 100644 board/samsung/smdk5250/tools/mkexynos_image.c create mode 100644 board/samsung/smdk5250/tzpc_init.c create mode 100644 include/configs/smdk5250.h -- 1.7.5.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 1/4] Exynos: Clock.c: Use CONFIG_SYS_CLK_FREQ macro
CONFIG_SYS_CLK_FREQ_C210 macro giving notion of S5PC2XX (Exynos4) architecture. Replace CONFIG_SYS_CLK_FREQ_C210 with CONFIG_SYS_CLK_FREQ to make it generic for exynos architecture. Signed-off-by: Chander Kashyap chander.kash...@linaro.org --- Changes for v2: - None Changes for v3: - None Changes for V4: - Added CONFIG_SYS_CLK_FREQ to trats.h arch/arm/cpu/armv7/exynos/clock.c |6 +- include/configs/s5pc210_universal.h |1 + include/configs/trats.h |1 + 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c index 0c199cd..4d92c53 100644 --- a/arch/arm/cpu/armv7/exynos/clock.c +++ b/arch/arm/cpu/armv7/exynos/clock.c @@ -26,10 +26,6 @@ #include asm/arch/clock.h #include asm/arch/clk.h -#ifndef CONFIG_SYS_CLK_FREQ_C210 -#define CONFIG_SYS_CLK_FREQ_C210 2400 -#endif - /* exynos4: return pll clock frequency */ static unsigned long exynos4_get_pll_clk(int pllreg) { @@ -76,7 +72,7 @@ static unsigned long exynos4_get_pll_clk(int pllreg) /* SDIV [2:0] */ s = r 0x7; - freq = CONFIG_SYS_CLK_FREQ_C210; + freq = CONFIG_SYS_CLK_FREQ; if (pllreg == EPLL) { k = k 0x; diff --git a/include/configs/s5pc210_universal.h b/include/configs/s5pc210_universal.h index be000cb..8286680 100644 --- a/include/configs/s5pc210_universal.h +++ b/include/configs/s5pc210_universal.h @@ -49,6 +49,7 @@ /* input clock of PLL: Universal has 24MHz input clock at EXYNOS4210 */ #define CONFIG_SYS_CLK_FREQ_C210 2400 +#define CONFIG_SYS_CLK_FREQCONFIG_SYS_CLK_FREQ_C210 #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG diff --git a/include/configs/trats.h b/include/configs/trats.h index acb3241..10f11d9 100644 --- a/include/configs/trats.h +++ b/include/configs/trats.h @@ -49,6 +49,7 @@ /* input clock of PLL: TRATS has 24MHz input clock at EXYNOS4210 */ #define CONFIG_SYS_CLK_FREQ_C210 2400 +#define CONFIG_SYS_CLK_FREQCONFIG_SYS_CLK_FREQ_C210 #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_CMDLINE_TAG -- 1.7.5.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v4 2/4] ARM: EXYNOS: Add support for Exynos5 based SoCs
Samsung's ARM Cortex-A15 based SoCs are known as Exynos5 series of SoCs. This patch adds the support for Exynos5. Signed-off-by: Chander Kashyap chander.kash...@linaro.org --- Changes for v2: - This patch was part of EXYNOS: Add SMDK5250 board support - Now it is seprated as SoC support. Changes for v3: - Populated complete exynos5 gpio structures Changes for v4: - Added dmc.h and tzpc.h header files - Renamed EXYNOS5_PHY*_CTRL_BASE to EXYNOS5_DMC_PHY*_BASE arch/arm/cpu/armv7/exynos/clock.c| 208 +++- arch/arm/include/asm/arch-exynos/clock.h | 326 ++ arch/arm/include/asm/arch-exynos/cpu.h | 35 +++- arch/arm/include/asm/arch-exynos/dmc.h | 146 + arch/arm/include/asm/arch-exynos/gpio.h | 99 +- arch/arm/include/asm/arch-exynos/tzpc.h | 52 + 6 files changed, 854 insertions(+), 12 deletions(-) create mode 100644 arch/arm/include/asm/arch-exynos/dmc.h create mode 100644 arch/arm/include/asm/arch-exynos/tzpc.h diff --git a/arch/arm/cpu/armv7/exynos/clock.c b/arch/arm/cpu/armv7/exynos/clock.c index 4d92c53..2f7048b 100644 --- a/arch/arm/cpu/armv7/exynos/clock.c +++ b/arch/arm/cpu/armv7/exynos/clock.c @@ -92,6 +92,72 @@ static unsigned long exynos4_get_pll_clk(int pllreg) return fout; } +/* exynos5: return pll clock frequency */ +static unsigned long exynos5_get_pll_clk(int pllreg) +{ + struct exynos5_clock *clk = + (struct exynos5_clock *)samsung_get_base_clock(); + unsigned long r, m, p, s, k = 0, mask, fout; + unsigned int freq; + + switch (pllreg) { + case APLL: + r = readl(clk-apll_con0); + break; + case MPLL: + r = readl(clk-mpll_con0); + break; + case EPLL: + r = readl(clk-epll_con0); + k = readl(clk-epll_con1); + break; + case VPLL: + r = readl(clk-vpll_con0); + k = readl(clk-vpll_con1); + break; + default: + printf(Unsupported PLL (%d)\n, pllreg); + return 0; + } + + /* +* APLL_CON: MIDV [25:16] +* MPLL_CON: MIDV [25:16] +* EPLL_CON: MIDV [24:16] +* VPLL_CON: MIDV [24:16] +*/ + if (pllreg == APLL || pllreg == MPLL) + mask = 0x3ff; + else + mask = 0x1ff; + + m = (r 16) mask; + + /* PDIV [13:8] */ + p = (r 8) 0x3f; + /* SDIV [2:0] */ + s = r 0x7; + + freq = CONFIG_SYS_CLK_FREQ; + + if (pllreg == EPLL) { + k = k 0x; + /* FOUT = (MDIV + K / 65536) * FIN / (PDIV * 2^SDIV) */ + fout = (m + k / 65536) * (freq / (p * (1 s))); + } else if (pllreg == VPLL) { + k = k 0xfff; + /* FOUT = (MDIV + K / 1024) * FIN / (PDIV * 2^SDIV) */ + fout = (m + k / 1024) * (freq / (p * (1 s))); + } else { + if (s 1) + s = 1; + /* FOUT = MDIV * FIN / (PDIV * 2^(SDIV - 1)) */ + fout = m * (freq / (p * (1 (s - 1; + } + + return fout; +} + /* exynos4: return ARM clock frequency */ static unsigned long exynos4_get_arm_clk(void) { @@ -114,6 +180,28 @@ static unsigned long exynos4_get_arm_clk(void) return armclk; } +/* exynos5: return ARM clock frequency */ +static unsigned long exynos5_get_arm_clk(void) +{ + struct exynos5_clock *clk = + (struct exynos5_clock *)samsung_get_base_clock(); + unsigned long div; + unsigned long armclk; + unsigned int arm_ratio; + unsigned int arm2_ratio; + + div = readl(clk-div_cpu0); + + /* ARM_RATIO: [2:0], ARM2_RATIO: [30:28] */ + arm_ratio = (div 0) 0x7; + arm2_ratio = (div 28) 0x7; + + armclk = get_pll_clk(APLL) / (arm_ratio + 1); + armclk /= (arm2_ratio + 1); + + return armclk; +} + /* exynos4: return pwm clock frequency */ static unsigned long exynos4_get_pwm_clk(void) { @@ -157,6 +245,27 @@ static unsigned long exynos4_get_pwm_clk(void) return pclk; } +/* exynos5: return pwm clock frequency */ +static unsigned long exynos5_get_pwm_clk(void) +{ + struct exynos5_clock *clk = + (struct exynos5_clock *)samsung_get_base_clock(); + unsigned long pclk, sclk; + unsigned int ratio; + + /* +* CLK_DIV_PERIC3 +* PWM_RATIO [3:0] +*/ + ratio = readl(clk-div_peric3); + ratio = ratio 0xf; + sclk = get_pll_clk(MPLL); + + pclk = sclk / (ratio + 1); + + return pclk; +} + /* exynos4: return uart clock frequency */ static unsigned long exynos4_get_uart_clk(int dev_index) { @@ -204,6 +313,53 @@ static unsigned long exynos4_get_uart_clk(int dev_index) return uclk; } +/* exynos5: return uart clock
[U-Boot] [PATCH v4 3/4] EXYNOS: Add SMDK5250 board support
SMDK5250 board is based on Samsungs EXYNOS5250 SoC. Signed-off-by: Chander Kashyap chander.kash...@linaro.org --- Changes for v2: - This patch is bifurcated into borad support and SoC support - Fixed typo: s/EEYNOS/EXYNOS - Squashed patch SMDK5250: enable device tree support in this. Changes for v3: - None Changes for v4: - Converted assembly routines for clock, memory, uart and tzpc - init to c functions - Moved uart init to smdk5250.c MAINTAINERS|1 + board/samsung/smdk5250/Makefile| 51 board/samsung/smdk5250/clock_init.c| 202 + board/samsung/smdk5250/dmc_init.c | 508 board/samsung/smdk5250/lowlevel_init.S | 96 ++ board/samsung/smdk5250/setup.h | 353 ++ board/samsung/smdk5250/smdk5250.c | 152 ++ board/samsung/smdk5250/tzpc_init.c | 48 +++ boards.cfg |1 + include/configs/smdk5250.h | 198 + 10 files changed, 1610 insertions(+), 0 deletions(-) create mode 100644 board/samsung/smdk5250/Makefile create mode 100644 board/samsung/smdk5250/clock_init.c create mode 100644 board/samsung/smdk5250/dmc_init.c create mode 100644 board/samsung/smdk5250/lowlevel_init.S create mode 100644 board/samsung/smdk5250/setup.h create mode 100644 board/samsung/smdk5250/smdk5250.c create mode 100644 board/samsung/smdk5250/tzpc_init.c create mode 100644 include/configs/smdk5250.h diff --git a/MAINTAINERS b/MAINTAINERS index acbd7f1..c03ebb4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -713,6 +713,7 @@ Chander Kashyap k.chan...@samsung.com origen ARM ARMV7 (EXYNOS4210 SoC) SMDKV310ARM ARMV7 (EXYNOS4210 SoC) + SMDK5250ARM ARMV7 (EXYNOS5250 SoC) Heungjun Kim riverful@samsung.com diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile new file mode 100644 index 000..d9c2774 --- /dev/null +++ b/board/samsung/smdk5250/Makefile @@ -0,0 +1,51 @@ +# +# Copyright (C) 2011 Samsung Electronics +# +# See file CREDITS for list of people who contributed to this +# project. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +LIB= $(obj)lib$(BOARD).o + +SOBJS := lowlevel_init.o + +COBJS := clock_init.o +COBJS += dmc_init.o +COBJS += tzpc_init.o +COBJS += smdk5250.o + +SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) + +ALL:= $(obj).depend $(LIB) + +all: $(ALL) + +$(LIB):$(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +# + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +# diff --git a/board/samsung/smdk5250/clock_init.c b/board/samsung/smdk5250/clock_init.c new file mode 100644 index 000..2b53a47 --- /dev/null +++ b/board/samsung/smdk5250/clock_init.c @@ -0,0 +1,202 @@ +/* + * Clock setup for SMDK5250 board based on EXYNOS5 + * + * Copyright (C) 2011 Samsung Electronics + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include config.h +#include version.h +#include asm/io.h +#include asm/arch/clock.h +#include asm/arch/cpu.h +#include asm/arch/gpio.h +#include setup.h + +void system_clock_init() +{ + struct exynos5_clock *clk = (struct
[U-Boot] [PATCH v4 4/4] EXYNOS: SMDK5250: Add MMC SPL support
This patch adds support for MMC SPL booting. Signed-off-by: Chander Kashyap chander.kash...@linaro.org --- Changes for v2: - None Changes for v3: - None Changes for v4: None board/samsung/smdk5250/Makefile | 16 board/samsung/smdk5250/mmc_boot.c | 58 board/samsung/smdk5250/tools/mkexynos_image.c | 117 + include/configs/smdk5250.h|6 +- 4 files changed, 196 insertions(+), 1 deletions(-) create mode 100644 board/samsung/smdk5250/mmc_boot.c create mode 100644 board/samsung/smdk5250/tools/mkexynos_image.c diff --git a/board/samsung/smdk5250/Makefile b/board/samsung/smdk5250/Makefile index d9c2774..908ce5b 100644 --- a/board/samsung/smdk5250/Makefile +++ b/board/samsung/smdk5250/Makefile @@ -29,18 +29,34 @@ SOBJS := lowlevel_init.o COBJS := clock_init.o COBJS += dmc_init.o COBJS += tzpc_init.o + +ifndef CONFIG_SPL_BUILD COBJS += smdk5250.o +endif + +ifdef CONFIG_SPL_BUILD +COBJS += mmc_boot.o +endif SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS)) ALL:= $(obj).depend $(LIB) +ifdef CONFIG_SPL_BUILD +ALL+= $(OBJTREE)/tools/mk$(BOARD)spl +endif + all: $(ALL) $(LIB):$(OBJS) $(call cmd_link_o_target, $(OBJS)) +ifdef CONFIG_SPL_BUILD +$(OBJTREE)/tools/mk$(BOARD)spl:tools/mkexynos_image.c + $(HOSTCC) tools/mkexynos_image.c -o $(OBJTREE)/tools/mk$(BOARD)spl +endif + # # defines $(obj).depend target diff --git a/board/samsung/smdk5250/mmc_boot.c b/board/samsung/smdk5250/mmc_boot.c new file mode 100644 index 000..669c1a3 --- /dev/null +++ b/board/samsung/smdk5250/mmc_boot.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2011 Samsung Electronics + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#includecommon.h +#includeconfig.h + +/* +* Copy U-boot from mmc to RAM: +* COPY_BL2_FNPTR_ADDR: Address in iRAM, which Contains +* Pointer to API (Data transfer from mmc to ram) +*/ +void copy_uboot_to_ram(void) +{ + u32 (*copy_bl2)(u32, u32, u32) = (void *) *(u32 *)COPY_BL2_FNPTR_ADDR; + + copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE); +} + +void board_init_f(unsigned long bootflag) +{ + __attribute__((noreturn)) void (*uboot)(void); + copy_uboot_to_ram(); + + /* Jump to U-Boot image */ + uboot = (void *)CONFIG_SYS_TEXT_BASE; + (*uboot)(); + /* Never returns Here */ +} + +/* Place Holders */ +void board_init_r(gd_t *id, ulong dest_addr) +{ + /* Function attribute is no-return */ + /* This Function never executes */ + while (1) + ; +} + +void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) {} diff --git a/board/samsung/smdk5250/tools/mkexynos_image.c b/board/samsung/smdk5250/tools/mkexynos_image.c new file mode 100644 index 000..e2b7805 --- /dev/null +++ b/board/samsung/smdk5250/tools/mkexynos_image.c @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2011 Samsung Electronics + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include stdio.h +#include stdlib.h +#include unistd.h +#include fcntl.h +#include errno.h +#include string.h +#include sys/stat.h + +#define CHECKSUM_OFFSET(14*1024-4) +#define BUFSIZE(16*1024) +#define FILE_PERM (S_IRUSR | S_IWUSR |
[U-Boot] [PATCH v3 1/3] ARM: I2C: I2C Multi byte address support
Existing OMAP I2C driver does not support address length greater than one. Hence this patch is to add support for 2 byte address read/write. Signed-off-by: Philip, Avinash avinashphi...@ti.com Signed-off-by: Hebbar, Gururaja gururaja.heb...@ti.com Signed-off-by: Patil, Rachna rac...@ti.com --- Changes for v3: rebased, patches applied on top of master branch drivers/i2c/omap24xx_i2c.c | 467 drivers/i2c/omap24xx_i2c.h |2 + 2 files changed, 296 insertions(+), 173 deletions(-) diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index a7ffd95..80932ef 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -29,10 +29,11 @@ DECLARE_GLOBAL_DATA_PTR; -#define I2C_TIMEOUT1000 +#define I2C_STAT_TIMEO (1 31) +#define I2C_TIMEOUT10 -static void wait_for_bb(void); -static u16 wait_for_pin(void); +static u32 wait_for_bb(void); +static u32 wait_for_status_mask(u16 mask); static void flush_fifo(void); /* @@ -50,7 +51,6 @@ void i2c_init(int speed, int slaveadd) int psc, fsscll, fssclh; int hsscll = 0, hssclh = 0; u32 scll, sclh; - int timeout = I2C_TIMEOUT; /* Only handle standard, fast and high speeds */ if ((speed != OMAP_I2C_STANDARD) @@ -112,24 +112,14 @@ void i2c_init(int speed, int slaveadd) sclh = (unsigned int)fssclh; } + if (gd-flags GD_FLG_RELOC) + bus_initialized[current_bus] = 1; + if (readw(i2c_base-con) I2C_CON_EN) { writew(0, i2c_base-con); udelay(5); } - writew(0x2, i2c_base-sysc); /* for ES2 after soft reset */ - udelay(1000); - - writew(I2C_CON_EN, i2c_base-con); - while (!(readw(i2c_base-syss) I2C_SYSS_RDONE) timeout--) { - if (timeout = 0) { - puts(ERROR: Timeout in soft-reset\n); - return; - } - udelay(1000); - } - - writew(0, i2c_base-con); writew(psc, i2c_base-psc); writew(scll, i2c_base-scll); writew(sclh, i2c_base-sclh); @@ -145,81 +135,6 @@ void i2c_init(int speed, int slaveadd) flush_fifo(); writew(0x, i2c_base-stat); writew(0, i2c_base-cnt); - - if (gd-flags GD_FLG_RELOC) - bus_initialized[current_bus] = 1; -} - -static int i2c_read_byte(u8 devaddr, u8 regoffset, u8 *value) -{ - int i2c_error = 0; - u16 status; - - /* wait until bus not busy */ - wait_for_bb(); - - /* one byte only */ - writew(1, i2c_base-cnt); - /* set slave address */ - writew(devaddr, i2c_base-sa); - /* no stop bit needed here */ - writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | - I2C_CON_TRX, i2c_base-con); - - /* send register offset */ - while (1) { - status = wait_for_pin(); - if (status == 0 || status I2C_STAT_NACK) { - i2c_error = 1; - goto read_exit; - } - if (status I2C_STAT_XRDY) { - /* Important: have to use byte access */ - writeb(regoffset, i2c_base-data); - writew(I2C_STAT_XRDY, i2c_base-stat); - } - if (status I2C_STAT_ARDY) { - writew(I2C_STAT_ARDY, i2c_base-stat); - break; - } - } - - /* set slave address */ - writew(devaddr, i2c_base-sa); - /* read one byte from slave */ - writew(1, i2c_base-cnt); - /* need stop bit here */ - writew(I2C_CON_EN | I2C_CON_MST | - I2C_CON_STT | I2C_CON_STP, - i2c_base-con); - - /* receive data */ - while (1) { - status = wait_for_pin(); - if (status == 0 || status I2C_STAT_NACK) { - i2c_error = 1; - goto read_exit; - } - if (status I2C_STAT_RRDY) { -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ - defined(CONFIG_OMAP44XX) - *value = readb(i2c_base-data); -#else - *value = readw(i2c_base-data); -#endif - writew(I2C_STAT_RRDY, i2c_base-stat); - } - if (status I2C_STAT_ARDY) { - writew(I2C_STAT_ARDY, i2c_base-stat); - break; - } - } - -read_exit: - flush_fifo(); - writew(0x, i2c_base-stat); - writew(0, i2c_base-cnt); - return i2c_error; } static void flush_fifo(void) @@ -246,32 +161,42 @@ static void flush_fifo(void) int i2c_probe(uchar chip) { - u16 status; + u32 status; int res = 1; /* default = fail */ if (chip == readw(i2c_base-oa)) return res;
[U-Boot] [PATCH v3 2/3] ARM: AM33XX: Add AM33XX I2C driver support
1. Compliant with Philips I2C specification version 2.1 2. Supports upto 100Kbps in standard mode Signed-off-by: Chandan Nath chandan.n...@ti.com Signed-off-by: Patil, Rachna rac...@ti.com --- Changes for v3: rebased, patches applied on top of master branch drivers/i2c/omap24xx_i2c.c | 20 +--- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/i2c/omap24xx_i2c.c b/drivers/i2c/omap24xx_i2c.c index 80932ef..f06af02 100644 --- a/drivers/i2c/omap24xx_i2c.c +++ b/drivers/i2c/omap24xx_i2c.c @@ -147,7 +147,7 @@ static void flush_fifo(void) stat = readw(i2c_base-stat); if (stat == I2C_STAT_RRDY) { #if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ - defined(CONFIG_OMAP44XX) + defined(CONFIG_OMAP44XX) || defined(CONFIG_AM33XX) readb(i2c_base-data); #else readw(i2c_base-data); @@ -247,7 +247,8 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) switch (alen) { case 2: /* Send address MSByte */ -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ + defined(CONFIG_AM33XX) writew(((addr 8) 0xFF), i2c_base-data); /* Clearing XRDY event */ @@ -264,7 +265,8 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) } #endif case 1: -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ + defined(CONFIG_AM33XX) /* Send address LSByte */ writew((addr 0xFF), i2c_base-data); #else @@ -313,7 +315,8 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len) } if (status I2C_STAT_RRDY) { -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ + defined(CONFIG_AM33XX) buffer[i] = readb(i2c_base-data); #else *((u16 *)buffer[i]) = @@ -400,7 +403,8 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) if (!i2c_error) { if (status I2C_STAT_XRDY) { switch (alen) { -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ + defined(CONFIG_AM33XX) case 2: /* send out MSB byte */ writeb(((addr 8) 0xFF), i2c_base-data); @@ -420,7 +424,8 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) break; } case 1: -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ + defined(CONFIG_AM33XX) /* send out MSB byte */ writeb((addr 0xFF), i2c_base-data); #else @@ -442,7 +447,8 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len) if (!i2c_error) { for (i = ((alen 1) ? 0 : 1); i len; i++) { if (status I2C_STAT_XRDY) { -#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) +#if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX) || \ + defined(CONFIG_AM33XX) writeb((buffer[i] 0xFF), i2c_base-data); #else -- 1.7.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v3 3/3] ARM: AM33XX: Add i2c support
Add i2c driver board hookup for AM335X EVM Signed-off-by: Chandan Nath chandan.n...@ti.com Signed-off-by: Patil, Rachna rac...@ti.com --- Changes for v3: rebased, patches applied on top of master branch arch/arm/cpu/armv7/am33xx/clock.c |5 ++ arch/arm/include/asm/arch-am33xx/common_def.h |1 + arch/arm/include/asm/arch-am33xx/cpu.h|3 +- arch/arm/include/asm/arch-am33xx/i2c.h| 81 + board/ti/am335x/evm.c |7 ++ board/ti/am335x/mux.c | 13 include/configs/am335x_evm.h |9 +++ 7 files changed, 118 insertions(+), 1 deletions(-) create mode 100644 arch/arm/include/asm/arch-am33xx/i2c.h diff --git a/arch/arm/cpu/armv7/am33xx/clock.c b/arch/arm/cpu/armv7/am33xx/clock.c index 98cfd93..bbb9c13 100644 --- a/arch/arm/cpu/armv7/am33xx/clock.c +++ b/arch/arm/cpu/armv7/am33xx/clock.c @@ -113,6 +113,11 @@ static void enable_per_clocks(void) writel(PRCM_MOD_EN, cmper-mmc0clkctrl); while (readl(cmper-mmc0clkctrl) != PRCM_MOD_EN) ; + + /* i2c0 */ + writel(PRCM_MOD_EN, cmwkup-wkup_i2c0ctrl); + while (readl(cmwkup-wkup_i2c0ctrl) != PRCM_MOD_EN) + ; } static void mpu_pll_config(void) diff --git a/arch/arm/include/asm/arch-am33xx/common_def.h b/arch/arm/include/asm/arch-am33xx/common_def.h index 767932d..aa3b554 100644 --- a/arch/arm/include/asm/arch-am33xx/common_def.h +++ b/arch/arm/include/asm/arch-am33xx/common_def.h @@ -18,5 +18,6 @@ extern void enable_uart0_pin_mux(void); extern void enable_mmc0_pin_mux(void); +extern void enable_i2c0_pin_mux(void); #endif/*__COMMON_DEF_H__ */ diff --git a/arch/arm/include/asm/arch-am33xx/cpu.h b/arch/arm/include/asm/arch-am33xx/cpu.h index 25558a2..cd002e6 100644 --- a/arch/arm/include/asm/arch-am33xx/cpu.h +++ b/arch/arm/include/asm/arch-am33xx/cpu.h @@ -95,7 +95,8 @@ struct cm_wkuppll { unsigned int divm2dpllper; /* offset 0xAC */ unsigned int resv11[1]; unsigned int wkup_uart0ctrl;/* offset 0xB4 */ - unsigned int resv12[8]; + unsigned int wkup_i2c0ctrl; /* offset 0xB8 */ + unsigned int resv12[7]; unsigned int divm6dpllcore; /* offset 0xD8 */ }; diff --git a/arch/arm/include/asm/arch-am33xx/i2c.h b/arch/arm/include/asm/arch-am33xx/i2c.h new file mode 100644 index 000..366e2bb --- /dev/null +++ b/arch/arm/include/asm/arch-am33xx/i2c.h @@ -0,0 +1,81 @@ +/* + * (C) Copyright 2012 + * Texas Instruments, www.ti.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ +#ifndef _I2C_H_ +#define _I2C_H_ + +#define I2C_BASE1 0x44E0B000 +#define I2C_BASE2 0x4802A000 +#define I2C_BASE3 0x4819C000 +#define I2C_BUS_MAX3 + +#define I2C_DEFAULT_BASE I2C_BASE1 + +struct i2c { + unsigned short revnb_lo;/* 0x00 */ + unsigned short res1; + unsigned short revnb_hi;/* 0x04 */ + unsigned short res2[13]; + unsigned short sysc;/* 0x20 */ + unsigned short res3; + unsigned short irqstatus_raw; /* 0x24 */ + unsigned short res4; + unsigned short stat;/* 0x28 */ + unsigned short res5; + unsigned short ie; /* 0x2C */ + unsigned short res6; + unsigned short irqenable_clr; /* 0x30 */ + unsigned short res7; + unsigned short iv; /* 0x34 */ + unsigned short res8[45]; + unsigned short syss;/* 0x90 */ + unsigned short res9; + unsigned short buf; /* 0x94 */ + unsigned short res10; + unsigned short cnt; /* 0x98 */ + unsigned short res11; + unsigned short data;/* 0x9C */ + unsigned short res13; + unsigned short res14; /* 0xA0 */ + unsigned short res15; + unsigned short con; /* 0xA4 */ + unsigned short res16; + unsigned short oa; /* 0xA8 */ + unsigned short res17; + unsigned short sa; /* 0xAC */ + unsigned short res18; + unsigned short psc;
Re: [U-Boot] About mtest on boot
isn't U-boot's address given by the relocadrr variable? If it is so, it is already at the end of ram and I'm giving a smaller end address to the ram - I'm getting relocaddr 0x07fcd000 and using this minus 0x01000 as ending position... Érico V. Porto On Sat, Jan 21, 2012 at 2:21 PM, amruth vamadev amruth.vama...@gmail.comwrote: Hi Erico Possibly you are overwriting your u-boot code hence causing the hang.You need to move your uboot code to end of DDR and you should be able to test your RAM.You need to change the entry point and reset vector and you can read using readelf using u-boot. Thanks Amruth p.v On Sat, Jan 21, 2012 at 2:01 AM, Érico Porto ericoporto2...@gmail.com wrote: I've partially solved the ctrl+c situatin inserting more check for it into the code. But this isn't really what I was hoping... Any known alternatives? Thanks. Érico V. Porto On Fri, Jan 20, 2012 at 4:22 PM, Érico Porto ericoporto2...@gmail.com wrote: Okay, got 2011.12 working here. Same problem, my system stalls when I try using mtest on low position of the memory, but now I have the relocaddr var to tell me what is the superior memory limit. ( I can't paste any output here because the list gives me a BASE ENCODE64 not allowed error... ) And if the system freezes during mtest, I can't ctrl+c out of it. Is there any know workaround? My system is much a like MPC8323ERDB. Other than that, seems I can run linux fine on it after bootload, I just can't use mtest... Érico V. Porto On Fri, Jan 20, 2012 at 8:56 AM, Érico Porto ericoporto2...@gmail.com wrote: Now I understood, LTIB is giving me an older u-boot version - 1.1.6 and not 2011.12. Will try to update it... Érico V. Porto On Fri, Jan 20, 2012 at 8:38 AM, Anatolij Gustschin ag...@denx.de wrote: Hi, On Fri, 20 Jan 2012 08:07:41 -0200 Érico Porto ericoporto2...@gmail.com wrote: Hello, I want to stop autoboot and use mtest to check if my ram is alright, but 0x07FD2C00 forward freezes, and 0x0902 also freezes, mtest, when using it. My ramsize is 0x0800. Does u-boot uses any parts of ram by itself, I mean, is there any known spots where I can't test because it would crash my system? U-Boot relocates itself into RAM. You can check the address using 'bdinfo' command (look at 'relocaddr' in the output). There are also some data structures in RAM (global data, board info, stack, malloc area) and also exception vectors. Where it is located in RAM depends on your architecture and board configuration options. You can try to define DEBUG in the arch board.c file to get more info. Board config file should define CONFIG_SYS_MEMTEST_START and CONFIG_SYS_MEMTEST_END to prevent crashing when mtest is invoked. HTH, Anatolij ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default
Dear Wolfgang, On 05.01.2012 16:59, Wolfgang Denk wrote: Dear Grant Erickson, In message 1324580395-27004-1-git-send-email-maratho...@gmail.com you wrote: This patch allows the U-Boot user space companion utility, fw_setenv, to overwrite the 'ethaddr' key/value pair if the current value is set to a per-board-configured default. This change allows 'fw_setenv' to match the behavior of 'setenv' / 'env set' on the U-Boot command line. Signed-off-by: Grant Erickson maratho...@gmail.com --- tools/env/fw_env.c | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) Applied, thanks. This patch breaks building 'env' without board configuration. This is bad cause our automatic build environment build this tool for different boards. Specific configuration is done via /etc/fw_env.config. Can't we use some build-time configuration like http://patchwork.ozlabs.org/patch/120372/ ? best regards Andreas Bießmann ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Toradex Colibri, PXA-270 (ARM)
Hello, i recently stumbled upon a compile-error which appears after trying to compile via /./MAKEALL --arch arm --cpu pxa --vendor toradex/ , it appears U-Boot uses software-FP whereas the native XScale-libs use hardware-FP, see for yourself please : /[dmack@Blizzard ~/workspace/u-boot]$ ./MAKEALL --arch arm --cpu pxa --vendor toradex/ /Configuring for colibri_pxa270 board.../ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_udivsi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_udivsi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_divsi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_divsi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_umodsi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_umodsi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_modsi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_modsi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_dvmd_lnx.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_dvmd_lnx.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_lshrdi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_lshrdi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_ashldi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_ashldi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_udivdi3.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_udivdi3.oS)/ /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_clz.oS) uses hardware FP, whereas u-boot uses software FP/ /arm-linux-ld: failed to merge target specific data of file /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_clz.oS)/ /make: *** [u-boot] Fehler 1/ /size: './u-boot': No such file/ /- SUMMARY / /Boards compiled: 1/ /Boards with warnings or errors: 1 ( colibri_pxa270 )/ /--/ Is there a solution for this, am i missing something? Best regards, Daniel ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Dear =?ISO-8859-1?Q?=C9rico_Porto?=, In message cag1ktjegl3m69knr9tokhqgzrksnrzzjqfch9fnvm5g+6wa...@mail.gmail.com you wrote: isn't U-boot's address given by the relocadrr variable? If it is so, it is already at the end of ram and I'm giving a smaller end address to the ram - I'm getting relocaddr 0x07fcd000 and using this minus 0x01000 as ending position... 0x01000 = 4 kB is way too small. Consider that U-Boot will need space to reserver for it's malloc arena, for global data, and for the stack. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de People have one thing in common: they are all different. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] Toradex Colibri, PXA-270 (ARM)
Dear Daniel Mack, In message 4f1d60e8.4030...@lertes.de you wrote: i recently stumbled upon a compile-error which appears after trying to compile via /./MAKEALL --arch arm --cpu pxa --vendor toradex/ , it appears U-Boot uses software-FP whereas the native XScale-libs use hardware-FP, see for yourself please : This is a tool chain problem. You should get one that supports soft-FP, especially on processors that don;t have a FPU in the first place. /arm-linux-ld: ERROR: /usr/lib/gcc/arm-xscale-linux-gnu/3.4.6/libgcc.a(_udivsi3.oS) uses hardware FP, whereas u-boot uses software FP/ GCC 3.4 has always been (in)famous for causing issues, especially on ARM. And it is so old that you can consider it unsupported. Is there a solution for this, am i missing something? I guess you did not bother to check the mailing list archives? You should. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de Often it is fatal to live too long. - Racine ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Ok, this makes sense, but I think you mean: memory start at 0x mtest { start address: right after (malloc area+global data + stack) end address: relocaddr } memory end at 0x0800 ... Érico V. Porto On Mon, Jan 23, 2012 at 12:23 PM, Wolfgang Denk w...@denx.de wrote: Dear =?ISO-8859-1?Q?=C9rico_Porto?=, In message cag1ktjegl3m69knr9tokhqgzrksnrzzjqfch9fnvm5g+6wa...@mail.gmail.com you wrote: isn't U-boot's address given by the relocadrr variable? If it is so, it is already at the end of ram and I'm giving a smaller end address to the ram - I'm getting relocaddr 0x07fcd000 and using this minus 0x01000 as ending position... 0x01000 = 4 kB is way too small. Consider that U-Boot will need space to reserver for it's malloc arena, for global data, and for the stack. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de People have one thing in common: they are all different. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Dear =?ISO-8859-1?Q?=C9rico_Porto?=, Please stop top posting / full quoting. In message CAG1KTJebU-QhhH2=ibfojsjjvaynh4hrfuzobnwz20uzq-5...@mail.gmail.com you wrote: Ok, this makes sense, but I think you mean: No, I mean what I mean, not what you think I mean. memory start at 0x mtest { start address: right after (malloc area+global data + stack) end address: relocaddr } memory end at 0x0800 Wrong. Assuming you have a simple configuration (no pRAM, no log buffer, no video buffer etc.) then the memory map (as explained in the README, btw) is like that: top of RAM (in your case 0x0800 - 1) ... U-Boot code, data and bss relocaddr ... Malloc Arena ... Board Info Data and permanent copy of global data ... Stack (growing downward) Depending on the size of your malloc arena you need to stay far enough away from relocaddr; try with 1 MB or more. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de For every complex problem, there is a solution that is simple, neat, and wrong. -- H. L. Mencken ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] About mtest on boot
Oh, found the Memory Management section, thanks! And it also explains that stuff should be written after 0x 2000 because of the exception vector - actually, I thinks this is a bit bigger here in my system, but now makes sense why I was also getting crashes at the beginning of the memory! Érico V. Porto On Mon, Jan 23, 2012 at 12:45 PM, Wolfgang Denk w...@denx.de wrote: Dear =?ISO-8859-1?Q?=C9rico_Porto?=, Please stop top posting / full quoting. In message CAG1KTJebU-QhhH2= ibfojsjjvaynh4hrfuzobnwz20uzq-5...@mail.gmail.com you wrote: Ok, this makes sense, but I think you mean: No, I mean what I mean, not what you think I mean. memory start at 0x mtest { start address: right after (malloc area+global data + stack) end address: relocaddr } memory end at 0x0800 Wrong. Assuming you have a simple configuration (no pRAM, no log buffer, no video buffer etc.) then the memory map (as explained in the README, btw) is like that: top of RAM (in your case 0x0800 - 1) ... U-Boot code, data and bss relocaddr ... Malloc Arena ... Board Info Data and permanent copy of global data ... Stack (growing downward) Depending on the size of your malloc arena you need to stay far enough away from relocaddr; try with 1 MB or more. Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de For every complex problem, there is a solution that is simple, neat, and wrong. -- H. L. Mencken ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx28: Show CPU frequency
On 1/23/12, Marek Vasut marek.va...@gmail.com wrote: Just put it amongst the other frequencies displayed by the clock command. What about this? --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c @@ -170,6 +170,7 @@ int arch_cpu_init(void) int print_cpuinfo(void) { printf(Freescale i.MX28 family\n); + do_mx28_showclocks(); return 0; } #endif It will print a lot more info though. Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] pull request: u-boot-tegra/master
Albert, -Original Message- From: Albert ARIBAUD [mailto:albert.u.b...@aribaud.net] Sent: Saturday, January 21, 2012 4:07 AM To: Tom Warren Cc: Wolfgang Denk; u-boot@lists.denx.de; Stephen Warren; Simon Glass Subject: Re: pull request: u-boot-tegra/master Hi Tom, Le 19/01/2012 01:01, Tom Warren a écrit : Albert, Please pull u-boot-tegra/master into arm master. Thanks. The following changes since commit 137703b811502dfea364650fb3e17f20b4c21333: overo: add SPL support (2012-01-16 08:40:13 +0100) are available in the git repository at: git://git.denx.de/u-boot-tegra master Simon Glass (9): tegra: Adjust funcmux config test to permit expansion tegra: Add enum to select from available funcmux configs tegra: Add I2C support to funcmux tegra: Add SDMMC support to funcmux tegra: Use funcmux for MMC on tamonten tegra: Use funcmux for MMC on harmony tegra: Use funcmux for MMC on seaboard tegra: mmc: Support operation with dcache enabled tegra2: Enable data cache Stephen Warren (3): tegra2: Fix conflicting pinmux for UARTA tegra2: Fix default RAM size selection in odmdata tegra2: Add support for Compal Paz00 (Toshiba AC100) MAINTAINERS|1 + arch/arm/cpu/armv7/tegra2/board.c | 12 ++- arch/arm/cpu/armv7/tegra2/funcmux.c| 152 +--- arch/arm/include/asm/arch-tegra2/funcmux.h | 30 ++- board/avionic-design/common/tamonten.c | 10 +-- board/compal/paz00/Makefile| 41 board/compal/paz00/paz00.c | 81 +++ board/nvidia/harmony/harmony.c | 19 +--- board/nvidia/seaboard/seaboard.c | 21 +--- boards.cfg |1 + drivers/mmc/tegra2_mmc.c | 16 +++ include/configs/paz00.h| 51 + 12 files changed, 379 insertions(+), 56 deletions(-) create mode 100644 board/compal/paz00/Makefile create mode 100644 board/compal/paz00/paz00.c create mode 100644 include/configs/paz00.h Applied to u-boot-arm/master, thanks! Thank you! Would it be possible, though, not to have this in your mails to the list? -- - This email message is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. -- - I'm told that I need to add 'nvpublic' to my message to have our exchange server skip the confidentiality statement. I've done so in this reply, and I'll do so in all future postings to u-boot@lists.denx.de. Tom -- nvpublic Amicalement, -- Albert. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx28: Show CPU frequency
On 23/01/2012 16:52, Fabio Estevam wrote: On 1/23/12, Marek Vasut marek.va...@gmail.com wrote: Just put it amongst the other frequencies displayed by the clock command. What about this? --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c @@ -170,6 +170,7 @@ int arch_cpu_init(void) int print_cpuinfo(void) { printf(Freescale i.MX28 family\n); + do_mx28_showclocks(); return 0; } #endif It will print a lot more info though. Well, this is the reason we have a separate function / command (clocks) that can be called only when needed. Generally, we avoid to print too much information if they are not required and can slow down the boot process. In print_cpuinfo() we output the processor type, the revision if it is available and maybe the processor frequency - nothing more. And if we need a complete overview of the clocks, there is the clocks command. So really I prefer the patch as it is - the information printed are the same as for other SOCs, not only i.MX. Best regards, Stefano Babic -- = DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] net/eth.c: fix eth_write_hwaddr() to use dev-enetaddr as fall back
Hi Dirk, On Jan 23, 2012 12:30 AM, Dirk Behme dirk.be...@de.bosch.com wrote: On 23.01.2012 08:31, Simon Glass wrote: Hi, On Thu, Jan 19, 2012 at 12:56 AM, Dirk Behme dirk.be...@de.bosch.com wrote: From: Eric Miao eric.m...@linaro.org Ignore the return value of eth_getenv_enetaddr_by_index(), and if it fails, fall back to use dev-enetaddr, which could be filled up by the ethernet device driver: With the current code, introduced with below commit, eth_write_hwaddr() will fail immediately if there is no ethnaddr in the environment variables. However, e.g. for an overo based product that uses the SMSC911x ethernet chip (with the MAC address set via EEPROM connected to the SMSC911x chip), the MAC address is still OK. On mx28 boards that are depending on the OCOTP bits to set the MAC address (like the Denx m28 board), the OCOTP bits should be used instead of failing on the environment variables. Actually, this was the original behavior, and was later changed by commit 7616e7850804c7c69e0a22c179dfcba9e8f3f587. Signed-off-by: Eric Miao eric.m...@linaro.org Acked-by: Simon Glass s...@chromium.org Acked-by: Dirk Behme dirk.be...@de.bosch.com CC: Stefan Roese s...@denx.de CC: Eric Miao eric.m...@linaro.org CC: Wolfgang Denk w...@denx.de CC: Philip Balister phi...@balister.org CC: Zach Sadecki z...@itwatchdogs.com --- v2: Correct the referenced commit ID and update the commit message. No functional change at the code itself. Note: This resend is based on my understanding from http://lists.denx.de/pipermail/u-boot/2012-January/116118.html Please let Eric and me know if I missed anything there. I don't think you have missed anything and I have already acked this. But I want to start a related discussion. The code structure does bug me a bit - I think it is too confusing. eth_getenv_enetaddr() returns an error if there is no environment variable set or if the address it gets from the environment variable is invalid. We should probably not conflate those two. The first is ok here, but the second isn't, I think. What if the driver has no write_hwaddr method? Do we silently ignore the environment variable value? Why use memcmp() against env_enetaddr when the function we just called returns an error that tells us whether it is supposed to be valid (the error return your patch squashes)? We set the hwaddr by writing directly into the dev-enet_addr field and then calling write_hwaddr() if it exists. Maybe that is ok - is the lack of write_hwaddr() an indication that the driver does MAC address handling on the fly, or just that it can't set the MAC address at all? Overall I feel that eth_write_hwaddr() should return success or failure, confident in its determination that there is either a valid MAC address or there is not. The message you are seeing is I suppose an indication that it thinks there is a problem, when in fact none exists in this case. At the moment it feels fragile. I wonder whether a little refactor here would be best? That said, your patch restores the original behaviour, hiding the problem which isn't actually a problem in this case, and which we don't want to report. So it is better than the status quo. Ok, thanks. I'm not an expert for this code, nor is the patch from me. It's from Eric ;) I just try to help to mainline all the stuff we have collected for i.MX6. Therefore I wonder if it would be possible to split this into two steps: a) Improve the status quo by applying this patch b) In parallel discuss how to refactor and improve this code as you describe above It's my feeling that with (a) we still have a chance to improve v2012.03. But I doubt that (b) would make it into v2012.03. Yes agreed, it is a separate discussion. I added Wolfgang on cc to see what he thinks. Regards, Simon Best regards Dirk ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ARM: tegra: Define Tegra20 CAR binding
Olof Johansson wrote at Saturday, January 21, 2012 12:32 AM: On Thu, Jan 19, 2012 at 9:17 AM, Stephen Warren swar...@nvidia.com wrote: Olof Johansson wrote at Wednesday, January 18, 2012 10:32 PM: On Wed, Jan 18, 2012 at 05:16:52PM -0700, Stephen Warren wrote: diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt +* NVIDIA Tegra20 Clock And Reset Controller + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The CAR (Clock And Reset) Controller on Tegra is the HW module responsible +for muxing and gating Tegra's clocks, and setting their rates. + +Required properties : +- compatible : Should be nvidia,chip-car +- reg : Should contain CAR registers location and length +- clocks : Should contain phandle and clock specifiers for two clocks: + the 32 KHz 32k_in, and the board-specific oscillator osc. +- clock-names : Should contain a list of strings, with values 32k_in, + and osc. ... +Example: + +clocks { + clk_32k: oscillator@0 { If it has a unit addres (@x) it needs a reg property with the same base address. I thought everything needed a unit address period? Is the rule more like the unit address is optional, but if present must match reg, so I can simply remove @0 and @1 here? I guess that makes a lot more sense. Nope, you only need a unit address to make a node unique, i.e. if you have more than one with the same name. It's not something that's been followed very well on ARM dts files, I have even seen review comments asking for explicit unit IDs when none are needed. So you can't remove @0 and @1 here, since there are two oscillator subnodes. If I keep the unit address, then I need to add a reg property per Mitch's response. But, then I need #address-cells and #size-cells in the clock node too. Yuck, since this isn't an addressable bus. Instead, is it acceptable to simply rename the nodes to e.g.: clk_32k: clock {...}; osc: crystal {...}; In the long term, I believe that osc/crystal is going to continue to be a top-level object, but clk_32k is actually an output from the PMU chip, and hence there won't be any naming conflict here anyway... -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ARM: tegra: Define Tegra20 CAR binding
Simon Glass wrote at Sunday, January 22, 2012 11:03 AM: On Wed, Jan 18, 2012 at 4:16 PM, Stephen Warren swar...@nvidia.com wrote: Document a binding for the Tegra20 CAR (Clock And Reset) Controller, add it to tegra20.dtsi, and configure it for the board in tegra- seaboard.dts. ... A comment on the shared enable issue: When enabling/disabling clocks, Tegra requires you to reset the HW module that the clock is routed to. Both reset and clock enable registers are part of the CAR. U-Boot currently has an API to do the reset based on a peripheral ID, which simply means a bit number in a set of 3 reset registers. The bits in those registers share the same numbering as the clock enable registers. Hence, to make life easy for U-Boot, I've defined the clock IDs in this binding to be equal to these bit numbers. However, this breaks down where there isn't a 1:1 mapping between reset and clock enable bits, and clocks. For example, there's a single reset and clock enable bit for the SPDIF controller, yet this applies to two clocks; spdif_in and spdif_out. Hence, this simplification for U-Boot breaks down. I think the correct solution is to fix U-Boot not to require this simplification, renumber the clocks in the CAR binding in a completely arbitrary fashion, and require U-Boot to contain a mapping table between CAR's DT clock IDs and any other information related to those clocks. Do you see any alternative? We really need the two SPDIF clocks to be different clock IDs in the binding, since each has a completely independant mux for the clock source/parent, and the two clocks obviously can't share the same clock ID (well, hmm, perhaps they could if we used 2 cells for the specifier, 1 for the bit number, and one more to differentiate clocks that use the same bit...). I'm still inclined to simply push back on U-Boot to do it right. Are SPDIF and VI the only examples of this? I think so. I should double-check to be sure though before committing to a final binding. If so, perhaps just having a special extra clock ID for those two and mapping in a special way would be more efficient. So two IDs would map to one clock/reset bit but different clocks. I thought about that initially, but it doesn't make semantic sense; there isn't a 1:1 mapping between clock ID and reset bit, so I don't think we should pretend there is for some clocks, and special-case others. Also I note that one is an input and one is an output clock. So we could name them this way, and use the separate ID for the input clocks perhaps. I don't think that solves the problem; HW modules and drivers use both clocks, so special-casing the input clocks doesn't make the problem less relevant. If you do add an arbitrary mapping, what would it be? It might as well follow along with the registers so far as it can, since the device tree should describe the hardware. Then the mapping becomes a few lines of code in the driver instead of YAT (yet another table). The mapping would be that the clock IDs are unrelated to the bit numbers in the CAR's reset/clock-enable registers. In practice, this means that to find the reset bit number, you need a table indexed by the .dts's clock number, with the bit number being retrieved from that table. So instead of bit = of_get_u32(1), we'd have bit = table[of_get_u32(1)]. In practice, I believe we'll need such a table anyway, since each clock has many more parameters than just the reset bit ID; some clocks have no reset bit at all, some clocks have a mux but some don't, the inputs to the mux are different for each clock, some have a divider but some don't, where there's a divider or mux, you need to know the register address to configure them, each clock has a different max rate, etc. Having thought a little more about this, I'm definitely leaning towards this way; making the clock ID and register bit completely unrelated just to make it really obvious that you can't use the clock ID as a register bit. -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 1/6] mxc_spi: move machine specifics into CPU headers
Move (E)CSPI register declarations into the imx-regs.h files for each supported CPU Introduce two new macros to control conditional setup MXC_CSPI - Used for processors with the Configurable Serial Peripheral Interface (MX3x) MXC_ECSPI - For processors with Enhanced Configurable... (MX5x, MX6x) Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com Acked-by: Dirk Behme dirk.be...@de.bosch.com --- arch/arm/include/asm/arch-mx31/imx-regs.h | 27 arch/arm/include/asm/arch-mx35/imx-regs.h | 25 arch/arm/include/asm/arch-mx5/imx-regs.h | 30 + drivers/spi/mxc_spi.c | 93 ++--- 4 files changed, 88 insertions(+), 87 deletions(-) diff --git a/arch/arm/include/asm/arch-mx31/imx-regs.h b/arch/arm/include/asm/arch-mx31/imx-regs.h index 6a517dd..70e3338 100644 --- a/arch/arm/include/asm/arch-mx31/imx-regs.h +++ b/arch/arm/include/asm/arch-mx31/imx-regs.h @@ -890,4 +890,31 @@ struct esdc_regs { #define MXC_EHCI_IPPUE_DOWN(1 8) #define MXC_EHCI_IPPUE_UP (1 9) +/* + * CSPI register definitions + */ +#define MXC_CSPI +#define MXC_CSPICTRL_EN(1 0) +#define MXC_CSPICTRL_MODE (1 1) +#define MXC_CSPICTRL_XCH (1 2) +#define MXC_CSPICTRL_SMC (1 3) +#define MXC_CSPICTRL_POL (1 4) +#define MXC_CSPICTRL_PHA (1 5) +#define MXC_CSPICTRL_SSCTL (1 6) +#define MXC_CSPICTRL_SSPOL (1 7) +#define MXC_CSPICTRL_CHIPSELECT(x) (((x) 0x3) 24) +#define MXC_CSPICTRL_BITCOUNT(x) (((x) 0x1f) 8) +#define MXC_CSPICTRL_DATARATE(x) (((x) 0x7) 16) +#define MXC_CSPICTRL_TC(1 8) +#define MXC_CSPICTRL_RXOVF (1 6) +#define MXC_CSPICTRL_MAXBITS 0x1f + +#define MXC_CSPIPERIOD_32KHZ (1 15) +#define MAX_SPI_BYTES 4 + +#define MXC_SPI_BASE_ADDRESSES \ + 0x43fa4000, \ + 0x5001, \ + 0x53f84000, + #endif /* __ASM_ARCH_MX31_IMX_REGS_H */ diff --git a/arch/arm/include/asm/arch-mx35/imx-regs.h b/arch/arm/include/asm/arch-mx35/imx-regs.h index df74508..e570ad1 100644 --- a/arch/arm/include/asm/arch-mx35/imx-regs.h +++ b/arch/arm/include/asm/arch-mx35/imx-regs.h @@ -179,6 +179,31 @@ #define IPU_CONF_IC_EN (11) #define IPU_CONF_SCI_EN(10) +/* + * CSPI register definitions + */ +#define MXC_CSPI +#define MXC_CSPICTRL_EN(1 0) +#define MXC_CSPICTRL_MODE (1 1) +#define MXC_CSPICTRL_XCH (1 2) +#define MXC_CSPICTRL_SMC (1 3) +#define MXC_CSPICTRL_POL (1 4) +#define MXC_CSPICTRL_PHA (1 5) +#define MXC_CSPICTRL_SSCTL (1 6) +#define MXC_CSPICTRL_SSPOL (1 7) +#define MXC_CSPICTRL_CHIPSELECT(x) (((x) 0x3) 12) +#define MXC_CSPICTRL_BITCOUNT(x) (((x) 0xfff) 20) +#define MXC_CSPICTRL_DATARATE(x) (((x) 0x7) 16) +#define MXC_CSPICTRL_TC(1 7) +#define MXC_CSPICTRL_RXOVF (1 6) +#define MXC_CSPICTRL_MAXBITS 0xfff +#define MXC_CSPIPERIOD_32KHZ (1 15) +#define MAX_SPI_BYTES 4 + +#define MXC_SPI_BASE_ADDRESSES \ + 0x43fa4000, \ + 0x5001, + #define GPIO_PORT_NUM 3 #define GPIO_NUM_PIN 32 diff --git a/arch/arm/include/asm/arch-mx5/imx-regs.h b/arch/arm/include/asm/arch-mx5/imx-regs.h index 0ee88d2..4fa6658 100644 --- a/arch/arm/include/asm/arch-mx5/imx-regs.h +++ b/arch/arm/include/asm/arch-mx5/imx-regs.h @@ -223,6 +223,36 @@ #define CS0_32M_CS1_32M_CS2_32M_CS3_32M3 /* + * CSPI register definitions + */ +#define MXC_ECSPI +#define MXC_CSPICTRL_EN(1 0) +#define MXC_CSPICTRL_MODE (1 1) +#define MXC_CSPICTRL_XCH (1 2) +#define MXC_CSPICTRL_CHIPSELECT(x) (((x) 0x3) 12) +#define MXC_CSPICTRL_BITCOUNT(x) (((x) 0xfff) 20) +#define MXC_CSPICTRL_PREDIV(x) (((x) 0xF) 12) +#define MXC_CSPICTRL_POSTDIV(x)(((x) 0xF) 8) +#define MXC_CSPICTRL_SELCHAN(x)(((x) 0x3) 18) +#define MXC_CSPICTRL_MAXBITS 0xfff +#define MXC_CSPICTRL_TC(1 7) +#define MXC_CSPICTRL_RXOVF (1 6) +#define MXC_CSPIPERIOD_32KHZ (1 15) +#define MAX_SPI_BYTES 32 + +/* Bit position inside CTRL register to be associated with SS */ +#define MXC_CSPICTRL_CHAN 18 + +/* Bit position inside CON register to be associated with SS */ +#define MXC_CSPICON_POL4 +#define MXC_CSPICON_PHA0 +#define MXC_CSPICON_SSPOL 12 +#define MXC_SPI_BASE_ADDRESSES \ + CSPI1_BASE_ADDR, \ + CSPI2_BASE_ADDR, \ + CSPI3_BASE_ADDR, + +/* * Number of GPIO pins per port */ #define GPIO_NUM_PIN32 diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c index 2fa7486..2e15318 100644 --- a/drivers/spi/mxc_spi.c +++ b/drivers/spi/mxc_spi.c @@ -33,93 +33,12 @@ #error i.MX27 CSPI not supported due to drastic differences in register definitions \ See linux mxc_spi driver from Freescale for details. - -#elif defined(CONFIG_MX31) - -#define MXC_CSPICTRL_EN
[U-Boot] [PATCH V2 4/6] sf command: allow default chip select through CONFIG_SPI_FLASH_CS
Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com Acked-by: Dirk Behme dirk.be...@de.bosch.com --- common/cmd_sf.c | 34 +++--- 1 files changed, 23 insertions(+), 11 deletions(-) diff --git a/common/cmd_sf.c b/common/cmd_sf.c index 7225656..4b32171 100644 --- a/common/cmd_sf.c +++ b/common/cmd_sf.c @@ -70,20 +70,28 @@ static int do_spi_flash_probe(int argc, char * const argv[]) char *endp; struct spi_flash *new; - if (argc 2) - return -1; - - cs = simple_strtoul(argv[1], endp, 0); - if (*argv[1] == 0 || (*endp != 0 *endp != ':')) +#ifndef CONFIG_SPI_FLASH_CS + if (argc 2) { + printf(%s: missing arguments\n, __func__); return -1; - if (*endp == ':') { - if (endp[1] == 0) - return -1; + } +#else + cs = CONFIG_SPI_FLASH_CS ; +#endif - bus = cs; - cs = simple_strtoul(endp + 1, endp, 0); - if (*endp != 0) + if (argc = 2) { + cs = simple_strtoul(argv[1], endp, 0); + if (*argv[1] == 0 || (*endp != 0 *endp != ':')) return -1; + if (*endp == ':') { + if (endp[1] == 0) + return -1; + + bus = cs; + cs = simple_strtoul(endp + 1, endp, 0); + if (*endp != 0) + return -1; + } } if (argc = 3) { @@ -299,7 +307,11 @@ usage: U_BOOT_CMD( sf, 5, 1, do_spi_flash, SPI flash sub-system, +#ifndef CONFIG_SPI_FLASH_CS probe [bus:]cs [hz] [mode] - init flash device on given SPI bus\n +#else + probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus\n +#endif and chip select\n sf read addr offset len- read `len' bytes starting at\n `offset' to memory at `addr'\n -- 1.7.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 3/6] mx6q: mx6qsabrelite: Add ECSPI support to the Sabrelite platform
Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com Acked-by: Dirk Behme dirk.be...@de.bosch.com --- board/freescale/mx6qsabrelite/imximage.cfg|2 +- board/freescale/mx6qsabrelite/mx6qsabrelite.c | 25 + include/configs/mx6qsabrelite.h |9 + 3 files changed, 35 insertions(+), 1 deletions(-) diff --git a/board/freescale/mx6qsabrelite/imximage.cfg b/board/freescale/mx6qsabrelite/imximage.cfg index b4ff010..fa40bff 100644 --- a/board/freescale/mx6qsabrelite/imximage.cfg +++ b/board/freescale/mx6qsabrelite/imximage.cfg @@ -156,7 +156,7 @@ DATA 4 0x021b0404 0x00011006 # set the default clock gate to save power DATA 4 0x020c4068 0x00C03F3F -DATA 4 0x020c406c 0x0030FC00 +DATA 4 0x020c406c 0x0030FC03 DATA 4 0x020c4070 0x0FFFC000 DATA 4 0x020c4074 0x3FF0 DATA 4 0x020c4078 0x00FFF300 diff --git a/board/freescale/mx6qsabrelite/mx6qsabrelite.c b/board/freescale/mx6qsabrelite/mx6qsabrelite.c index a0b648f..2ba6b0c 100644 --- a/board/freescale/mx6qsabrelite/mx6qsabrelite.c +++ b/board/freescale/mx6qsabrelite/mx6qsabrelite.c @@ -46,6 +46,10 @@ DECLARE_GLOBAL_DATA_PTR; PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \ PAD_CTL_DSE_40ohm | PAD_CTL_HYS) +#define SPI_PAD_CTRL (PAD_CTL_HYS |\ + PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_MED | \ + PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST) + int dram_init(void) { gd-ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); @@ -193,6 +197,23 @@ int board_mmc_init(bd_t *bis) } #endif +#ifdef CONFIG_MXC_SPI +iomux_v3_cfg_t ecspi1_pads[] = { + /* SS1 */ + MX6Q_PAD_EIM_D19__GPIO_3_19 | MUX_PAD_CTRL(SPI_PAD_CTRL), + MX6Q_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL), + MX6Q_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL), + MX6Q_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL), +}; + +void setup_spi(void) +{ + gpio_direction_output(IMX_GPIO_NR(3, 19), 1); + imx_iomux_v3_setup_multiple_pads(ecspi1_pads, +ARRAY_SIZE(ecspi1_pads)); +} +#endif + #define MII_1000BASET_CTRL 0x9 #define MII_EXTENDED_CTRL 0xb #define MII_EXTENDED_DATAW 0xc @@ -250,6 +271,10 @@ int board_early_init_f(void) { setup_iomux_uart(); +#ifdef CONFIG_MXC_SPI + setup_spi(); +#endif + return 0; } diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index 034fc40..8dd6e39 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -44,6 +44,15 @@ #define CONFIG_MXC_UART #define CONFIG_MXC_UART_BASE UART2_BASE +#define CONFIG_CMD_SF +#ifdef CONFIG_CMD_SF +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_SST +#define CONFIG_MXC_SPI +#define CONFIG_SF_DEFAULT_SPEED 2500 +#define CONFIG_SF_DEFAULT_MODE (SPI_MODE_0) +#endif + /* MMC Configs */ #define CONFIG_FSL_ESDHC #define CONFIG_FSL_USDHC -- 1.7.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 5/6] mx6q: mx6qsabrelite: Provide default chip-select for serial flash
Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com Acked-by: Dirk Behme dirk.be...@de.bosch.com --- include/configs/mx6qsabrelite.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index 8dd6e39..e34f108 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -46,6 +46,7 @@ #define CONFIG_CMD_SF #ifdef CONFIG_CMD_SF +#define CONFIG_SPI_FLASH_CS 0x5300 #define CONFIG_SPI_FLASH #define CONFIG_SPI_FLASH_SST #define CONFIG_MXC_SPI -- 1.7.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 6/6] mx6q: mx6qsabrelite: Conditionally define macros for environment in serial flash
The default settings store the persistent environment on SD card and not serial flash (SPI NOR). To use SPI NOR to save the environment instead of SD card, edit include/configs/mx6qsabrelite.h and - undefine CONFIG_ENV_IS_IN_MMC - define CONFIG_ENV_IS_IN_SPI_FLASH The SPI driver can take as chip select the controller's chip selects as well as an external GPIO. The LSB byte has the value of the internal chip select, the highest (thought as 16-bit value) contains the GPIO number. The GPIO used on Sabre Lite is GP3:19 == 83. Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com Acked-by: Dirk Behme dirk.be...@de.bosch.com --- include/configs/mx6qsabrelite.h | 12 +++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/include/configs/mx6qsabrelite.h b/include/configs/mx6qsabrelite.h index e34f108..024a94c 100644 --- a/include/configs/mx6qsabrelite.h +++ b/include/configs/mx6qsabrelite.h @@ -174,10 +174,20 @@ /* FLASH and environment organization */ #define CONFIG_SYS_NO_FLASH -#define CONFIG_ENV_OFFSET (6 * 64 * 1024) #define CONFIG_ENV_SIZE(8 * 1024) + #define CONFIG_ENV_IS_IN_MMC +/* #define CONFIG_ENV_IS_IN_SPI_FLASH */ + +#if defined(CONFIG_ENV_IS_IN_MMC) +#define CONFIG_ENV_OFFSET (6 * 64 * 1024) #define CONFIG_SYS_MMC_ENV_DEV 0 +#elif defined(CONFIG_ENV_IS_IN_SPI_FLASH) +#define CONFIG_ENV_OFFSET (768 * 1024) +#define CONFIG_ENV_SECT_SIZE (8 * 1024) +#define CONFIG_ENV_SPI_CS 0x5300 +#define CONFIG_ENV_SPI_MODESPI_MODE_0 +#endif #define CONFIG_OF_LIBFDT -- 1.7.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH V2 2/6] mx6q: Add support for ECSPI through mxc_spi driver
Signed-off-by: Eric Nelson eric.nel...@boundarydevices.com Acked-by: Dirk Behme dirk.be...@de.bosch.com --- arch/arm/include/asm/arch-mx6/imx-regs.h | 44 ++ 1 files changed, 44 insertions(+), 0 deletions(-) diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h b/arch/arm/include/asm/arch-mx6/imx-regs.h index 7650cb9..00040c4 100644 --- a/arch/arm/include/asm/arch-mx6/imx-regs.h +++ b/arch/arm/include/asm/arch-mx6/imx-regs.h @@ -190,6 +190,50 @@ struct src { u32 gpr10; }; +/* ECSPI registers */ +struct cspi_regs { + u32 rxdata; + u32 txdata; + u32 ctrl; + u32 cfg; + u32 intr; + u32 dma; + u32 stat; + u32 period; +}; + +/* + * CSPI register definitions + */ +#define MXC_ECSPI +#define MXC_CSPICTRL_EN(1 0) +#define MXC_CSPICTRL_MODE (1 1) +#define MXC_CSPICTRL_XCH (1 2) +#define MXC_CSPICTRL_CHIPSELECT(x) (((x) 0x3) 12) +#define MXC_CSPICTRL_BITCOUNT(x) (((x) 0xfff) 20) +#define MXC_CSPICTRL_PREDIV(x) (((x) 0xF) 12) +#define MXC_CSPICTRL_POSTDIV(x)(((x) 0xF) 8) +#define MXC_CSPICTRL_SELCHAN(x)(((x) 0x3) 18) +#define MXC_CSPICTRL_MAXBITS 0xfff +#define MXC_CSPICTRL_TC(1 7) +#define MXC_CSPICTRL_RXOVF (1 6) +#define MXC_CSPIPERIOD_32KHZ (1 15) +#define MAX_SPI_BYTES 32 + +/* Bit position inside CTRL register to be associated with SS */ +#define MXC_CSPICTRL_CHAN 18 + +/* Bit position inside CON register to be associated with SS */ +#define MXC_CSPICON_POL4 +#define MXC_CSPICON_PHA0 +#define MXC_CSPICON_SSPOL 12 +#define MXC_SPI_BASE_ADDRESSES \ + ECSPI1_BASE_ADDR, \ + ECSPI2_BASE_ADDR, \ + ECSPI3_BASE_ADDR, \ + ECSPI4_BASE_ADDR, \ + ECSPI5_BASE_ADDR + struct iim_regs { u32 ctrl; u32 ctrl_set; -- 1.7.1 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx28: Show CPU frequency
On 23/01/2012 16:52, Fabio Estevam wrote: On 1/23/12, Marek Vasut marek.va...@gmail.com wrote: Just put it amongst the other frequencies displayed by the clock command. What about this? --- a/arch/arm/cpu/arm926ejs/mx28/mx28.c +++ b/arch/arm/cpu/arm926ejs/mx28/mx28.c @@ -170,6 +170,7 @@ int arch_cpu_init(void) int print_cpuinfo(void) { printf(Freescale i.MX28 family\n); + do_mx28_showclocks(); return 0; } #endif It will print a lot more info though. Well, this is the reason we have a separate function / command (clocks) that can be called only when needed. Generally, we avoid to print too much information if they are not required and can slow down the boot process. In print_cpuinfo() we output the processor type, the revision if it is available and maybe the processor frequency - nothing more. And if we need a complete overview of the clocks, there is the clocks command. So really I prefer the patch as it is - the information printed are the same as for other SOCs, not only i.MX. Best regards, Stefano Babic Ok, fine by me then. Acked-by: Marek Vasut marek.va...@gmail.com M ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2 0/6] mxc_spi refactoring (for mx6q and mx6qsabrelite)
Eric, On 1/23/12, Eric Nelson eric.nel...@boundarydevices.com wrote: Patch 4 modifies the 'sf' command to allow a default chip-select to be specified by board headers as is done on efika et al. This allows a bare 'sf' probe command: U-Boot sf probe instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed to specify GP3:19 on SabreLite: U-Boot sf probe 0x5300 I think this comment is very useful and it would be nice to have it in the commit log of the patch. Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] ARM: tegra: Define Tegra20 CAR binding
On Fri, Jan 20, 2012 at 11:32:04PM -0800, Olof Johansson wrote: Hi, On Thu, Jan 19, 2012 at 9:17 AM, Stephen Warren swar...@nvidia.com wrote: Olof Johansson wrote at Wednesday, January 18, 2012 10:32 PM: On Wed, Jan 18, 2012 at 05:16:52PM -0700, Stephen Warren wrote: diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt +* NVIDIA Tegra20 Clock And Reset Controller + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The CAR (Clock And Reset) Controller on Tegra is the HW module responsible +for muxing and gating Tegra's clocks, and setting their rates. + +Required properties : +- compatible : Should be nvidia,chip-car +- reg : Should contain CAR registers location and length +- clocks : Should contain phandle and clock specifiers for two clocks: + the 32 KHz 32k_in, and the board-specific oscillator osc. +- clock-names : Should contain a list of strings, with values 32k_in, + and osc. Hmm. I'd prefer to just ditch the notion of clock-names in the cases where it isn't strictly necessary. Just because some vendors don't want to define an order between their clocks doesn't mean it's a good idea for everybody to use that model. In this case, just declaring that the two clocks refs have to be to those two clocks in that order should be sufficient. OK, that seems reasonable. I'm happy using of_clk_get() rather than of_clk_get_by_name(). I guess that means we should just avoid any discussion of clock-output-names too. Sounds good to me. Let's make sure Grant is OK with it too though. Yes, I agree. g. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 03/20] fdt: Add basic support for decoding GPIO definitions
On 01/21/2012 10:08 AM, Simon Glass wrote: Hi Stephen, On Wed, Jan 18, 2012 at 2:17 PM, Stephen Warren swar...@nvidia.com wrote: On 01/11/2012 09:32 PM, Simon Glass wrote: This adds some support into fdtdec for reading GPIO definitions from the fdt. ... ... diff --git a/include/fdtdec.h b/include/fdtdec.h ... +/* GPIOs are numbered from 0 */ +enum { + FDT_GPIO_NONE = -1U,/* an invalid GPIO used to end our list */ Is this due to the way U-Boot works right now, or something defined by this patch? It's been pointed out that the kernel's choice to use -1 as invalid GPIO rather than 0 was a mistake, since that prevents GPIO fields being easily added to platform data structures, since you then have to go and initialize every new instance to -1, rather than relying on BSS initializing it to 0. I assume this is just the way U-Boot works, so solving this is outside the scope of this patch. It is nothing to do with U-Boot itself - we can choose any number. Surely the value you choose for DT parsing has to align with the value that U-Boot's GPIO API chooses, so you can't just choose any number. What is Linux using now / planning to use? Linux uses -1 right now, but should really have used 0. I don't think there's an actual plan to change this now, since the numbering scheme is entrenched. What Linux does isn't relevant; the numbering scheme I'm talking about is the internal numbering scheme within U-Boot or Linux, which are independent from each-other and the values in the device tree. So that said, I was wondering if U-Boot's GPIO support (covering both non-DT and DT cases) was new enough that it could use 0 to represent invalid GPIO rather than -1, and hence FDT_GPIO_NONE be 0 not -1. It probably isn't though; I guess U-Boot's GPIO numbering scheme is also already entrenched? -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 3/7] tegra: fdt: Add extra I2C bindings for U-Boot
On 01/22/2012 10:41 AM, Simon Glass wrote: Hi Stephen, On Thu, Jan 19, 2012 at 12:51 PM, Stephen Warren swar...@nvidia.com wrote: On 01/12/2012 12:00 PM, Simon Glass wrote: Add U-Boot's peripheral clock information to the Tegra20 device tree file. diff --git a/arch/arm/dts/tegra20.dtsi b/arch/arm/dts/tegra20.dtsi index ca7b523..963cf27 100644 --- a/arch/arm/dts/tegra20.dtsi +++ b/arch/arm/dts/tegra20.dtsi @@ -45,6 +45,8 @@ compatible = nvidia,tegra20-i2c; reg = 0x7000C000 0x100; interrupts = 70 ; + clock-frequency = 10; That's board-specific information. I'd rather not include it in the SoC .dtsi file even as a default; that way, it forces people to think about the correct value and put it in their board file, whereas including a default means people probably won't think about it. OK I moved this into the board file - sadly this means everyone will need to specify it here. Or should we have a default? I think I'd rather not have the default. That way, people need to think about the correct value to use in their board file, rather than having it magically work without having validated the value. If people disagree, we'd need to update the kernel's tegra[23]0.dtsi, since they assume ${board}.dts will set this property. -- nvpublic ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] gen_atmel_mci: CMDR 000d1052 (18) ARGR 0000ec00 (SR: 0000c0d7) XFER DTIP never unset, ignoring
Hello! (sorry for my english) I need help! Did you find solve with sd card for board with 9260/9g20? I have board with at91sam9g20 and I have bug - gen_atmel_mci: CMDR 000d1052 (18) ARGR ec00 (SR: c0d7) XFER DTIP never unset, ignoring u-boot 2011.12 All it works without mmc/sd. My bug: U-Boot mmc part mci: setting clock 195312 Hz, block size 512 mci: setting clock 195312 Hz, block size 512 mci: setting clock 195312 Hz, block size 512 mci: setting clock 195312 Hz, block size 512 mci: setting clock 1250 Hz, block size 512 Partition Map for MMC device 0 -- Partition Type: DOS Partition Start Sector Num Sectors Type 1 62 389484 c U-Boot fatls mmc 0:1 8868 boot.bin 247112 u-boot.bin 2 file(s), 0 dir(s) U-Boot fatload mmc 0:1 0x2040 u-boot.bin 247112 reading u-boot.bin gen_atmel_mci: CMDR 000d1052 (18) ARGR ec00 (SR: c0d7) XFER DTIP never unset, ignoring u-boot.bin for example I have tried kernel.img too and more other. ext2 have like this. I can read partitions and I can see files tree but... My configs: board/atmel/at91sam9260ek.c #include common.h #include net.h #include netdev.h #include mmc.h #include spi.h #include asm/io.h #include asm/arch/hardware.h #include asm/arch/at91sam9260_matrix.h #include asm/arch/at91sam9_smc.h #include asm/arch/at91cap9.h #include asm/arch/at91_common.h #include asm/arch/at91_pmc.h #include asm/arch/at91_rstc.h #include asm/arch/at91_pmc.h #include asm/arch/gpio.h #if defined(CONFIG_RESET_PHY_R) defined(CONFIG_MACB) # include net.h #endif #include netdev.h DECLARE_GLOBAL_DATA_PTR; /* - */ /* * Miscelaneous platform dependent initialisations */ #ifdef CONFIG_CMD_NAND static void at91sam9260ek_nand_hw_init(void) { struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC; struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX; unsigned long csa; /* Assign CS3 to NAND/SmartMedia Interface */ csa = readl(matrix-ebicsa); csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA; writel(csa, matrix-ebicsa); /* Configure SMC CS3 for NAND/SmartMedia */ writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) | AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0), smc-cs[3].setup); writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) | AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3), smc-cs[3].pulse); writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5), smc-cs[3].cycle); writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE | AT91_SMC_MODE_EXNW_DISABLE | #ifdef CONFIG_SYS_NAND_DBW_16 AT91_SMC_MODE_DBW_16 | #else /* CONFIG_SYS_NAND_DBW_8 */ AT91_SMC_MODE_DBW_8 | #endif AT91_SMC_MODE_TDF_CYCLE(2), smc-cs[3].mode); /* Configure RDY/BSY */ at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1); /* Enable NandFlash */ at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1); } #endif #ifdef CONFIG_MACB static void at91sam9260ek_macb_hw_init(void) { struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA; struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC; unsigned long erstl; /* Enable EMAC clock */ writel(1 ATMEL_ID_EMAC0, pmc-pcer); /* * Disable pull-up on: * RXDV (PA17) = PHY normal mode (not Test mode) * ERX0 (PA14) = PHY ADDR0 * ERX1 (PA15) = PHY ADDR1 * ERX2 (PA25) = PHY ADDR2 * ERX3 (PA26) = PHY ADDR3 * ECRS (PA28) = PHY ADDR4 = PHYADDR = 0x0 * * PHY has internal pull-down */ writel(pin_to_mask(AT91_PIN_PA14) | pin_to_mask(AT91_PIN_PA15) | pin_to_mask(AT91_PIN_PA17) | pin_to_mask(AT91_PIN_PA25) | pin_to_mask(AT91_PIN_PA26) | pin_to_mask(AT91_PIN_PA28), pioa-pudr); erstl = readl(rstc-mr) AT91_RSTC_MR_ERSTL_MASK; /* Need to reset PHY - 500ms reset */ writel(AT91_RSTC_KEY | AT91_RSTC_MR_ERSTL(13) | AT91_RSTC_MR_URSTEN, rstc-mr); writel(AT91_RSTC_KEY | AT91_RSTC_CR_EXTRST, rstc-cr); /* Wait for end hardware reset */ while (!(readl(rstc-sr) AT91_RSTC_SR_NRSTL)) ; /* Restore NRST value */ writel(AT91_RSTC_KEY | erstl | AT91_RSTC_MR_URSTEN, rstc-mr); /* Re-enable pull-up */ writel(pin_to_mask(AT91_PIN_PA14) | pin_to_mask(AT91_PIN_PA15) | pin_to_mask(AT91_PIN_PA17) | pin_to_mask(AT91_PIN_PA25) | pin_to_mask(AT91_PIN_PA26) | pin_to_mask(AT91_PIN_PA28), pioa-puer); /* Initialize EMAC=MACB hardware */ at91_macb_hw_init(); } #endif int board_early_init_f(void) { struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; /* Enable clocks for all PIOs */ writel((1 ATMEL_ID_PIOA) | (1 ATMEL_ID_PIOB) | (1 ATMEL_ID_PIOC), pmc-pcer); return 0; } int board_init(void) { #ifdef CONFIG_AT91SAM9G20EK /* arch number of AT91SAM9260EK-Board */ gd-bd-bi_arch_number = MACH_TYPE_AT91SAM9G20EK; #else /* arch number of AT91SAM9260EK-Board */ gd-bd-bi_arch_number = MACH_TYPE_AT91SAM9260EK; #endif /* adress of boot parameters */ gd-bd-bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; at91_seriald_hw_init(); #ifdef CONFIG_CMD_NAND at91sam9260ek_nand_hw_init(); #endif #ifdef CONFIG_HAS_DATAFLASH at91_spi0_hw_init((1 0) | (1 1));
Re: [U-Boot] [PATCH] ARM: tegra: Define Tegra20 CAR binding
On 1/23/2012 6:18 AM, Stephen Warren wrote: Olof Johansson wrote at Saturday, January 21, 2012 12:32 AM: On Thu, Jan 19, 2012 at 9:17 AM, Stephen Warrenswar...@nvidia.com wrote: Olof Johansson wrote at Wednesday, January 18, 2012 10:32 PM: On Wed, Jan 18, 2012 at 05:16:52PM -0700, Stephen Warren wrote: diff --git a/Documentation/devicetree/bindings/clock/nvidia,tegra20-car.txt +* NVIDIA Tegra20 Clock And Reset Controller + +This binding uses the common clock binding: +Documentation/devicetree/bindings/clock/clock-bindings.txt + +The CAR (Clock And Reset) Controller on Tegra is the HW module responsible +for muxing and gating Tegra's clocks, and setting their rates. + +Required properties : +- compatible : Should be nvidia,chip-car +- reg : Should contain CAR registers location and length +- clocks : Should contain phandle and clock specifiers for two clocks: + the 32 KHz 32k_in, and the board-specific oscillator osc. +- clock-names : Should contain a list of strings, with values 32k_in, + and osc. ... +Example: + +clocks { + clk_32k: oscillator@0 { If it has a unit addres (@x) it needs a reg property with the same base address. I thought everything needed a unit address period? Is the rule more like the unit address is optional, but if present must match reg, so I can simply remove @0 and @1 here? I guess that makes a lot more sense. Nope, you only need a unit address to make a node unique, i.e. if you have more than one with the same name. It's not something that's been followed very well on ARM dts files, I have even seen review comments asking for explicit unit IDs when none are needed. So you can't remove @0 and @1 here, since there are two oscillator subnodes. If I keep the unit address, then I need to add a reg property per Mitch's response. But, then I need #address-cells and #size-cells in the clock node too. Yuck, since this isn't an addressable bus. Instead, is it acceptable to simply rename the nodes to e.g.: clk_32k: clock {...}; osc: crystal {...}; One consideration: These nodes are children of a parent, so that parent is implicitly a bus node, even though there is no physical hardware bus. The path resolution rules say that, in the absence of a #address-cells property in a bus node, the default value is 2. So any code that implements that rule will think these nodes are missing a reg property, thus triggering the wildcard node rule, which says that you can match the node with any unit address. Whether or not that would cause problems in practice is hard to say. I think that my Open Firmware implementation would handle it okay, but I can't speak to the Linux device tree code. I'm not sure why you thing yuck about synthesizing an address space for the subnodes. It doesn't seem that bad to me. In the long term, I believe that osc/crystal is going to continue to be a top-level object, but clk_32k is actually an output from the PMU chip, and hence there won't be any naming conflict here anyway... ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2 0/6] mxc_spi refactoring (for mx6q and mx6qsabrelite)
On 01/23/2012 10:51 AM, Fabio Estevam wrote: Patch 4 modifies the 'sf' command to allow a default chip-select to be specified by board headers as is done on efika et al. This allows a bare 'sf' probe command: U-Boot sf probe instead of the more cumbersome usage when a GPIO is tacked onto the chip-select. Otherwise, this command-line would be needed to specify GP3:19 on SabreLite: U-Boot sf probe 0x5300 I think this comment is very useful and it would be nice to have it in the commit log of the patch. Works for me. Any other requests before V3? ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx28: fix i.MX28 spi driver
On 1/14/12, Matthias Fuchs matthias.fu...@esd.eu wrote: The generic spi flash driver (drivers/mtd/spi/spi_flash.c) uses the spi low level driver's spi_xfer() function with len=0 to deassert the SPI flash' chip select. But the i.MX28 spi driver rejects this call due to len=0. This patch implements an exception for len=0 with the SPI_XFER_END flag set. This results in an extra read with the chip select being deasserted afterwards. There seems to be no way to deassert the signal by hand. Signed-off-by: Matthias Fuchs matthias.fu...@esd.eu Tested-by: Fabio Estevam fabio.este...@freescale.com Soldered a SST25VF016B on a mx28evk (and also the SPI pullups) and verified that the flash can be erased succesfully now. I suggest that this patch gets applied as it fixes a real issue. Thanks, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx28: fix i.MX28 spi driver
On 1/14/12, Matthias Fuchs matthias.fu...@esd.eu wrote: The generic spi flash driver (drivers/mtd/spi/spi_flash.c) uses the spi low level driver's spi_xfer() function with len=0 to deassert the SPI flash' chip select. But the i.MX28 spi driver rejects this call due to len=0. This patch implements an exception for len=0 with the SPI_XFER_END flag set. This results in an extra read with the chip select being deasserted afterwards. There seems to be no way to deassert the signal by hand. Signed-off-by: Matthias Fuchs matthias.fu...@esd.eu Tested-by: Fabio Estevam fabio.este...@freescale.com Soldered a SST25VF016B on a mx28evk (and also the SPI pullups) and verified that the flash can be erased succesfully now. I suggest that this patch gets applied as it fixes a real issue. Thanks, Fabio Estevam I'm all for it. M ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] mx28evk: add RTC support
On 1/18/12, Matthias Fuchs matthias.fu...@esd.eu wrote: This patch adds support for the MX28 internal RTC and enables u-boot's date command. Signed-off-by: Matthias Fuchs matthias.fu...@esd.eu Tested-by: Fabio Estevam fabio.este...@freescale.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH/RFC] mx28: print bootmode with cpuinfo
Hi Matthias, On 1/18/12, Matthias Fuchs matthias.fu...@esd.eu wrote: Hi, while playing around with the mx28evk and differnet bootmedia I found it helpful to see the current bootmode without running to the board and checking it's switches. Also some other CPU (e.g. 440 PowerPCs) print some kind of bootstrap configuration during startup. The patch probably needs some little cleanup. But the main issue might be the way how it passes the information from SPL to 2nd stage. I am note sure if those scratch registers are somehow holy :-) I tested your patch and it worked fine. What I really liked about it is that it fixed a real issue that I was seeing: after booting the kernel and issuing a rebootcommand, kernel did shutdown, reset the system, but then U-boot got stuck showing DRAM: 0 bytes. So maybe you could split this patch in two parts: - One patch that touches the HW_DIGCTRL_SCRATCH register (this part is what fixed the RAM size retrievel after a reboot in the kernel - Another one to show the boot media Thanks, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] tools/env: allow overwrite of ethaddr on default
On Monday 23 January 2012 07:23:09 Andreas Bießmann wrote: On 05.01.2012 16:59, Wolfgang Denk wrote: Grant Erickson wrote: This patch allows the U-Boot user space companion utility, fw_setenv, to overwrite the 'ethaddr' key/value pair if the current value is set to a per-board-configured default. This change allows 'fw_setenv' to match the behavior of 'setenv' / 'env set' on the U-Boot command line. Signed-off-by: Grant Erickson maratho...@gmail.com --- tools/env/fw_env.c | 14 -- 1 files changed, 12 insertions(+), 2 deletions(-) Applied, thanks. This patch breaks building 'env' without board configuration. This is bad cause our automatic build environment build this tool for different boards. Specific configuration is done via /etc/fw_env.config. Can't we use some build-time configuration like http://patchwork.ozlabs.org/patch/120372/ ? update your patch to take the new code into account. you're going to have to rebase anyways to get it merged. -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] serial : Device tree support for multiple serial devices.
Hi The board that I am working on has multiple serial ports. I am trying to use device trees to configure board resource of these ports as well as the serial framework. So the driver doesnot know apriori the number of uart ports on the board. But querries the device tree for it.I am facing the following issues. 1) Ports are memory mapped and each port has its own register space. As such the serial framework apis dont provide for passing a port id at the time of the call. So how do i access the correct register space for the corresponding port?. Or should i define for my own set of apis to be called by clients, allowing me to access specific ports corresponding address space, and use the serial framework api's only for the default serial console? 2) the default serial console, also gets configured based on information obtained from the device tree, at run time. If i keep a global representation of the default serial console with its base address etc, it will still have to be reinitialized after relocation. The default_serial_console() gives me an opportunity to reinitialize the global structure. Is that the way to go? Thanks Hanumant ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/3] mx28evk: add SPI support
On Wed, Jan 18, 2012 at 9:33 AM, Matthias Fuchs matthias.fu...@esd.eu wrote: This patch adds SPI support for the MX28EVK. Support for an optionally installed SPI flash is also added. An example configuration for redundant envrionment from SPI flash is also added but disabled by default. This patch has been tested on a MX28EVK Rev. D with an installed SST25VF032B 32Mbit SPI flash. Signed-off-by: Matthias Fuchs matthias.fu...@esd.eu Acked-by: Fabio Estevam fabio.este...@freescale.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/6] sandbox: SPI emulation bus
Hi Mike, On Sun, Jan 22, 2012 at 10:30 PM, Mike Frysinger vap...@gentoo.org wrote: This adds a SPI framework for people to hook up simulated SPI clients. Signed-off-by: Mike Frysinger vap...@gentoo.org --- arch/sandbox/include/asm/spi.h | 33 +++ drivers/spi/Makefile | 1 + drivers/spi/sandbox_spi.c | 183 3 files changed, 217 insertions(+), 0 deletions(-) create mode 100644 arch/sandbox/include/asm/spi.h create mode 100644 drivers/spi/sandbox_spi.c I don't know the SPI interface as well as use - might be useful to have a few comments and debug() things when things go wrong I think. Please see below for some ideas. diff --git a/arch/sandbox/include/asm/spi.h b/arch/sandbox/include/asm/spi.h new file mode 100644 index 000..082df37 --- /dev/null +++ b/arch/sandbox/include/asm/spi.h @@ -0,0 +1,33 @@ +/* + * Simulate a SPI port and clients + * + * Copyright (c) 2011-2012 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * Licensed under the GPL-2 or later. + */ + +#ifndef __ASM_SPI_H__ +#define __ASM_SPI_H__ + +#include linux/types.h + +struct sb_spi_emu_ops { + int (*setup)(void **priv, const char *spec); + void (*free)(void *priv); + void (*cs_activate)(void *priv); + void (*cs_deactivate)(void *priv); + int (*xfer)(void *priv, const u8 *tx, u8 *rx, uint bytes); +}; I think this could do with some comments. + +static inline void sb_spi_tristate(u8 *buf, uint len) What does this do - comments? +{ + /* + * XXX: make this into a user config option ? let them pick + * whether this is pulled low, or high, or tristates. + */ + memset(buf, 0xff, len); +} + +#endif diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index c967d87..d80ff8b 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -40,6 +40,7 @@ COBJS-$(CONFIG_MXC_SPI) += mxc_spi.o COBJS-$(CONFIG_MXS_SPI) += mxs_spi.o COBJS-$(CONFIG_OC_TINY_SPI) += oc_tiny_spi.o COBJS-$(CONFIG_OMAP3_SPI) += omap3_spi.o +COBJS-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o COBJS-$(CONFIG_SOFT_SPI) += soft_spi.o COBJS-$(CONFIG_SH_SPI) += sh_spi.o COBJS-$(CONFIG_FSL_ESPI) += fsl_espi.o diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c new file mode 100644 index 000..eda0f3e --- /dev/null +++ b/drivers/spi/sandbox_spi.c @@ -0,0 +1,183 @@ +/* + * Simulate a SPI port + * + * Copyright (c) 2011-2012 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * Licensed under the GPL-2 or later. + */ + +#include common.h +#include malloc.h +#include spi.h +#include os.h + +#include asm/spi.h + +#ifndef CONFIG_SPI_IDLE_VAL +# define CONFIG_SPI_IDLE_VAL 0xFF +#endif + +struct sb_spi_slave { + struct spi_slave slave; + const char *spec; + const struct sb_spi_emu_ops *ops; + void *priv; +}; + +#define to_sb_spi_slave(s) container_of(s, struct sb_spi_slave, slave) + +static const char *sb_lookup_arg(unsigned int bus, unsigned int cs) +{ + char sf_arg[20]; blank line? + sprintf(sf_arg, --spi-%u-%u, bus, cs); + return os_getopt(sf_arg, 1); +} + +static const struct { + const char *spec; + const struct sb_spi_emu_ops *ops; +} sb_emu_map[] = { +}; + +static int sb_parse_type(struct sb_spi_slave *sss) +{ + size_t i; + + for (i = 0; i ARRAY_SIZE(sb_emu_map); ++i) { + size_t len = strlen(sb_emu_map[i].spec); + const char *sub_spec = sss-spec + len; + + sss-ops = sb_emu_map[i].ops; + if (!memcmp(sss-spec, sb_emu_map[i].spec, len) + sss-spec[len] == ':') + return sss-ops-setup(sss-priv, sub_spec + 1); + } + + return 1; +} + +int spi_cs_is_valid(unsigned int bus, unsigned int cs) +{ + return sb_lookup_arg(bus, cs) ? 1 : 0; +} + +void spi_cs_activate(struct spi_slave *slave) +{ + struct sb_spi_slave *sss = to_sb_spi_slave(slave); + + if (sss-ops-cs_activate) + sss-ops-cs_activate(sss-priv); +} + +void spi_cs_deactivate(struct spi_slave *slave) +{ + struct sb_spi_slave *sss = to_sb_spi_slave(slave); + + if (sss-ops-cs_deactivate) + sss-ops-cs_deactivate(sss-priv); +} + +void spi_init(void) +{ +} + +void spi_set_speed(struct spi_slave *slave, uint hz) +{ Should this store the value somewhere? +} + +struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, + unsigned int max_hz, unsigned int mode) +{ + struct sb_spi_slave *sss; + + if (!spi_cs_is_valid(bus, cs)) + return NULL; + + sss = malloc(sizeof(*sss)); + if (!sss) + return NULL; Do
Re: [U-Boot] [PATCH 4/6] sandbox: new SPI flash driver
Hi Mike, On Sun, Jan 22, 2012 at 10:30 PM, Mike Frysinger vap...@gentoo.org wrote: This adds a SPI flash driver which simulates SPI flash clients. Currently supports the bare min that U-Boot requires: you can probe, read, erase, and write. Should be easy to extend to make it behave more exactly like a real SPI flash, but this is good enough to merge now. Signed-off-by: Mike Frysinger vap...@gentoo.org --- drivers/mtd/spi/Makefile | 1 + drivers/mtd/spi/sandbox.c | 318 + drivers/spi/sandbox_spi.c | 5 + 3 files changed, 324 insertions(+), 0 deletions(-) create mode 100644 drivers/mtd/spi/sandbox.c Again would like a few comments / docs. I'm pleased you have done this - it is much more comprehensive than my noddy implementation. diff --git a/drivers/mtd/spi/Makefile b/drivers/mtd/spi/Makefile index 90f8392..fb37807 100644 --- a/drivers/mtd/spi/Makefile +++ b/drivers/mtd/spi/Makefile @@ -33,6 +33,7 @@ COBJS-$(CONFIG_SPI_FLASH) += spi_flash.o COBJS-$(CONFIG_SPI_FLASH_ATMEL) += atmel.o COBJS-$(CONFIG_SPI_FLASH_EON) += eon.o COBJS-$(CONFIG_SPI_FLASH_MACRONIX) += macronix.o +COBJS-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o COBJS-$(CONFIG_SPI_FLASH_SPANSION) += spansion.o COBJS-$(CONFIG_SPI_FLASH_SST) += sst.o COBJS-$(CONFIG_SPI_FLASH_STMICRO) += stmicro.o diff --git a/drivers/mtd/spi/sandbox.c b/drivers/mtd/spi/sandbox.c new file mode 100644 index 000..a1bb641 --- /dev/null +++ b/drivers/mtd/spi/sandbox.c @@ -0,0 +1,318 @@ +/* + * Simulate a SPI flash + * + * Copyright (c) 2011-2012 The Chromium OS Authors. + * See file CREDITS for list of people who contributed to this + * project. + * + * Licensed under the GPL-2 or later. + */ + +#include common.h +#include malloc.h +#include spi.h +#include os.h + +#include spi_flash.h +#include spi_flash_internal.h + +#include asm/spi.h + These are the different commands, right? +typedef enum { + SF_CMD, SF_ID, SF_READ, SF_WRITE, SF_ERASE, SF_READ_STATUS, SF_WREN, SF_WRDI, +} sb_sf_state; + +#define STAT_WIP (1 0) +#define STAT_WEL (1 1) What are these? Status bus? If so, perhaps a comment for each? + +struct sb_spi_flash_erase_commands { + u8 cmd; + u32 size; +}; +#define IDCODE_LEN 5 +#define MAX_ERASE_CMDS 2 +struct sb_spi_flash_data { + const char *name; + u8 idcode[IDCODE_LEN]; + u32 size; + const struct sb_spi_flash_erase_commands erase_cmds[MAX_ERASE_CMDS]; +}; + +struct sb_spi_flash { + sb_sf_state state; + uint off; + const struct sb_spi_flash_data *data; + int fd; + u8 status; +}; All of the above could do with some comments IMO... + +static const char *sb_sf_state_name(sb_sf_state state) +{ + static const char * const states[] = { + CMD, ID, READ, WRITE, ERASE, READ_STATUS, WREN, WRDI, + }; I wonder if it would be better to put this array up next to the enum? + return states[state]; +} + These are the emulated devices I think. +static const struct sb_spi_flash_data sb_sf_flashes[] = { + { + M25P16, { 0x20, 0x20, 0x15 }, (2 * 1024 * 1024), + { /* erase commands */ + { 0xd8, (64 * 1024), }, /* sector */ + { 0xc7, (2 * 1024 * 1024), }, /* bulk */ Is 10, 20 better? Not sure. + }, + }, +}; + +static u8 sb_sf_0xff[0x1]; Perhaps we should add an os_fputc() instead? Or perhaps write in smaller chunks? + +static int sb_sf_setup(void **priv, const char *spec) +{ + /* spec = idcode:file */ + struct sb_spi_flash *sbsf; + const char *file; + size_t i, len, idname_len; + const struct sb_spi_flash_data *data; + + file = strchr(spec, ':'); + if (!file) + goto error; + idname_len = file - spec; + ++file; + + for (i = 0; i ARRAY_SIZE(sb_sf_flashes); ++i) { + data = sb_sf_flashes[i]; + len = strlen(data-name); + if (idname_len != len) + continue; + if (!memcmp(spec, data-name, len)) + break; + } + if (i == ARRAY_SIZE(sb_sf_flashes)) { + printf(sandbox_spi_flash: unknown flash '%*s'\n, + (int)idname_len, file); + goto error; + } + + if (sb_sf_0xff[0] == 0x00) + memset(sb_sf_0xff, 0xff, sizeof(sb_sf_0xff)); + + sbsf = malloc(sizeof(*sbsf)); + if (!sbsf) + goto error; + + sbsf-fd = os_open(file, 02); + if (sbsf-fd == -1) { + free(sbsf); + goto error; + } + + sbsf-state = SF_CMD; + sbsf-data = data; + + *priv = sbsf; + return 0; + + error: +
Re: [U-Boot] [PATCH 6/6] sandbox: add getenv support
Hi Mike, On Sun, Jan 22, 2012 at 10:30 PM, Mike Frysinger vap...@gentoo.org wrote: Signed-off-by: Mike Frysinger vap...@gentoo.org Acked-by: Simon Glass s...@chromium.org --- arch/sandbox/cpu/os.c | 13 + include/os.h | 1 + 2 files changed, 14 insertions(+), 0 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 1d3e54f..4428f57 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -129,6 +129,19 @@ u64 os_get_nsec(void) #endif } +const char *os_getenv(const char *name) +{ + /* We can't use getenv() as u-boot provides it own */ + extern char **environ; + size_t i, len = strlen(name); + + for (i = 0; environ[i]; ++i) + if (!strncmp(name, environ[i], len) environ[i][len] == '=') + return environ[i][len + 1]; + + return NULL; +} + extern char **sb_argv; const char *os_getopt(const char *name, int has_arg) { diff --git a/include/os.h b/include/os.h index cb88509..095a2ce 100644 --- a/include/os.h +++ b/include/os.h @@ -112,6 +112,7 @@ void os_usleep(unsigned long usec); */ u64 os_get_nsec(void); +const char *os_getenv(const char *name); const char *os_getopt(const char *name, int has_arg); #endif -- 1.7.8.3 Is this used by earlier patches (iwc it probably should go earlier) or is it new? I suppose we can use linker magic to make these sorts of functions available to os.c, but your way seems nicer. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/6] sandbox: SPI emulation bus
On Monday 23 January 2012 19:31:23 Simon Glass wrote: On Sun, Jan 22, 2012 at 10:30 PM, Mike Frysinger wrote: This adds a SPI framework for people to hook up simulated SPI clients. I don't know the SPI interface as well as use - might be useful to have a few comments and debug() things when things go wrong I think. Please see below for some ideas. i can add some more +void spi_set_speed(struct spi_slave *slave, uint hz) +{ Should this store the value somewhere? it could, but i'm not sure where it'd be used ... i don't want to get into simulating the actual line transitions :). the SID project is for that level of craziness: http://sourceware.org/sid/ +struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, + unsigned int max_hz, unsigned int mode) +{ + struct sb_spi_slave *sss; + + if (!spi_cs_is_valid(bus, cs)) + return NULL; + + sss = malloc(sizeof(*sss)); + if (!sss) + return NULL; Do we want a debug() message for this? for memory failures, i don't generally think so. for other probe type failures, sure. +int spi_claim_bus(struct spi_slave *slave) +{ Should we track claim/release for debugging purposes? ah, that'd be good -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 4/6] sandbox: new SPI flash driver
On Monday 23 January 2012 19:41:42 Simon Glass wrote: On Sun, Jan 22, 2012 at 10:30 PM, Mike Frysinger wrote: --- /dev/null +++ b/drivers/mtd/spi/sandbox.c +#include common.h +#include malloc.h +#include spi.h +#include os.h + +#include spi_flash.h +#include spi_flash_internal.h + +#include asm/spi.h These are the different commands, right? are you referring to the enum after your quote ? +typedef enum { + SF_CMD, SF_ID, SF_READ, SF_WRITE, SF_ERASE, SF_READ_STATUS, SF_WREN, SF_WRDI, +} sb_sf_state; + +#define STAT_WIP (1 0) +#define STAT_WEL (1 1) What are these? Status bus? If so, perhaps a comment for each? the STAT defines are for the status register (RDSR). these low bits are about the only ones that SPI flashes have in common. the others tend to diverge real quick (for things like locking different portions of the flash). +static const char *sb_sf_state_name(sb_sf_state state) +{ + static const char * const states[] = { + CMD, ID, READ, WRITE, ERASE, READ_STATUS, WREN, WRDI, + }; I wonder if it would be better to put this array up next to the enum? my only reason for putting it here was to scope it. now only this func has access to the array and so it's the code enforces that. +static const struct sb_spi_flash_data sb_sf_flashes[] = { + { + M25P16, { 0x20, 0x20, 0x15 }, (2 * 1024 * 1024), + { /* erase commands */ + { 0xd8, (64 * 1024), }, /* sector */ + { 0xc7, (2 * 1024 * 1024), }, /* bulk */ Is 10, 20 better? Not sure. personally i find (xxx * 1024 * 1024) easier to understand than bitshifts when it comes to sizes. but that could just be that i'm not used to reading things. +static u8 sb_sf_0xff[0x1]; Perhaps we should add an os_fputc() instead? fputc() operates on a FILE*, not a fd. i don't think we want that. it's easy to emulate putc() with write(). however, we don't want to do that here. calling putc() 65 thousand times to avoid an array of 65 thousand bytes is the wrong trade off imo ;). Or perhaps write in smaller chunks? i picked 0x1 because it was the largest erase block size and be lazy with a single write(). i could shrink it down to 0x1000 and then loop over in 4k chunks. but i'm not too worried about buffers that are 65kb when we talk about code that only runs on our 64bit dev platform ;). +static int sb_sf_xfer(void *priv, const u8 *tx, u8 *rx, + uint bytes) +{ + struct sb_spi_flash *sbsf = priv; + uint i, written = 0; + + debug(sb_sf: state:%x(%s) bytes:%u\n, sbsf-state, + sb_sf_state_name(sbsf-state), bytes); + + if (sbsf-state == SF_CMD) { I wonder if this if() could be split out as it makes the function very long. Might be hard if too many parameters though. yeah, it is a long func. partly due to it starting small and me slowly expanding the state machine, and partly due to the state matching liking to be in one func. i might be able to make it work though ... + case CMD_READ_ARRAY_FAST: { + uint alen = 3; + + sbsf-off = (tx[1] 16) | (tx[2] 8) | tx[3]; + os_lseek(sbsf-fd, sbsf-off, 0); + debug( read addr: %u\n, sbsf-off); + + if (tx[0] == CMD_READ_ARRAY_FAST) + /* read fast needs a dummy byte */ + ++alen; + + written += alen; + sb_spi_tristate(rx[1], alen); + + sbsf-state = SF_READ; + break; + } Are you allowed to not indent the {} in this case? The } ends up at the same level as the switch(). yes, it's ugly, but it's what i've seen in the kernel/u-boot. i just swallow hard and try not to look too hard. + switch (sbsf-state) { + case SF_ID: { + const u8 *idcode = sbsf-data-idcode; + + debug( id: off:%u\n tx:, sbsf-off); + for (i = sbsf-off; i IDCODE_LEN; ++i) { + if (written bytes) { + rx[written++] = idcode[i]; + debug( %02x, idcode[i]); + } else + break; + } + if (written bytes) { + i = bytes - written; Do you think you should use a different variable than i in this case and below? I doubt it would affect the code output. i'm sure there's no code difference ;). i used i since it's available for scratch in this whole func. should be easy to tweak. -mike signature.asc Description: This is a digitally signed message part.
Re: [U-Boot] [PATCH 6/6] sandbox: add getenv support
On Monday 23 January 2012 19:44:15 Simon Glass wrote: Is this used by earlier patches (iwc it probably should go earlier) or is it new? it is not (anymore). i meant to only send out the first five, but this doesn't hurt. i'll probably leave it in my local branch until someone needs it. I suppose we can use linker magic to make these sorts of functions available to os.c, but your way seems nicer. it probably would be possible, but i think very fragile too ... -mike signature.asc Description: This is a digitally signed message part. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/28] net: Make the MAC-seeded random number generator available to /net
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: MAC-seeded rand() will be needed by link-local as well, so give it an interface Signed-off-by: Joe Hershberger joe.hershber...@ni.com Acked-by: Simon Glass s...@chromium.org Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/Makefile | 1 + net/bootp.c | 69 +++ net/bootp.h | 3 -- net/net_rand.c | 68 +++ net/net_rand.h | 18 ++ 5 files changed, 101 insertions(+), 58 deletions(-) create mode 100644 net/net_rand.c create mode 100644 net/net_rand.h diff --git a/net/Makefile b/net/Makefile index 0544f6b..5901046 100644 --- a/net/Makefile +++ b/net/Makefile @@ -31,6 +31,7 @@ COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o COBJS-$(CONFIG_CMD_NET) += net.o +COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o diff --git a/net/bootp.c b/net/bootp.c index 07870d0..9824cd1 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -12,6 +12,9 @@ #include command.h #include net.h #include bootp.h +#ifdef CONFIG_BOOTP_RANDOM_DELAY +#include net_rand.h +#endif #include tftp.h #include nfs.h #ifdef CONFIG_STATUS_LED @@ -37,9 +40,6 @@ ulong BootpID; int BootpTry; -#ifdef CONFIG_BOOTP_RANDOM_DELAY -ulong seed1, seed2; -#endif #if defined(CONFIG_CMD_DHCP) dhcp_state_t dhcp_state = INIT; @@ -583,66 +583,25 @@ BootpRequest(void) uchar *pkt, *iphdr; struct Bootp_t *bp; int ext_len, pktlen, iplen; +#ifdef CONFIG_BOOTP_RANDOM_DELAY + ulong i, rand_ms; +#endif #if defined(CONFIG_CMD_DHCP) dhcp_state = INIT; #endif #ifdef CONFIG_BOOTP_RANDOM_DELAY /* Random BOOTP delay */ - unsigned char bi_enetaddr[6]; - int reg; - ulong tst1, tst2, sum, m_mask, m_value = 0; - - if (BootpTry == 0) { - /* get our mac */ - eth_getenv_enetaddr(ethaddr, bi_enetaddr); - - debug(BootpRequest = Our Mac: ); - for (reg = 0; reg 6; reg++) - debug(%x%c, bi_enetaddr[reg], reg == 5 ? '\n' : ':'); - - /* Mac-Manipulation 2 get seed1 */ - tst1 = 0; - tst2 = 0; - for (reg = 2; reg 6; reg++) { - tst1 = tst1 8; - tst1 = tst1 | bi_enetaddr[reg]; - } - for (reg = 0; reg 2; reg++) { - tst2 = tst2 | bi_enetaddr[reg]; - tst2 = tst2 8; - } - - seed1 = tst1^tst2; + if (BootpTry == 0) + srand_mac(); - /* Mirror seed1*/ - m_mask = 0x1; - for (reg = 1; reg = 32; reg++) { - m_value |= (m_mask seed1); - seed1 = seed1 1; - m_value = m_value 1; - } - seed1 = m_value; - seed2 = 0xB78D0945; - } - - /* Random Number Generator */ - for (reg = 0; reg = 0; reg++) { - sum = seed1 + seed2; - if (sum seed1 || sum seed2) - sum++; - seed2 = seed1; - seed1 = sum; - - if (BootpTry = 2) { /* Start with max 1024 * 1ms */ - sum = sum (22-BootpTry); - } else { /*After 3rd BOOTP request max 8192 * 1ms */ - sum = sum 19; - } - } + if (BootpTry = 2) /* Start with max 1024 * 1ms */ + rand_ms = rand() (22-BootpTry); + else /* After 3rd BOOTP request max 8192 * 1ms */ + rand_ms = rand() 19; - printf(Random delay: %ld ms...\n, sum); - for (reg = 0; reg sum; reg++) + printf(Random delay: %ld ms...\n, rand_ms); + for (i = 0; i rand_ms; i++) udelay(1000); /*Wait 1ms*/ #endif /* CONFIG_BOOTP_RANDOM_DELAY */ diff --git a/net/bootp.h b/net/bootp.h index ce73734..bf4e875 100644 --- a/net/bootp.h +++ b/net/bootp.h @@ -63,9 +63,6 @@ struct Bootp_t { extern ulong BootpID; /* ID of cur BOOTP request */ extern char BootFile[128]; /* Boot file name */ extern int BootpTry; -#ifdef CONFIG_BOOTP_RANDOM_DELAY -extern ulong seed1, seed2; /* seed for random BOOTP delay */ -#endif /* Send a BOOTP request */ diff --git a/net/net_rand.c b/net/net_rand.c new file mode 100644 index 000..744e2f9 --- /dev/null +++ b/net/net_rand.c @@ -0,0
Re: [U-Boot] [PATCH 05/28] net: Move CDP out of net.c
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- arch/powerpc/cpu/mpc8xx/fec.c | 2 +- include/net.h | 9 +- net/Makefile | 1 + net/cdp.c | 380 + net/cdp.h | 18 ++ net/net.c | 368 +--- 6 files changed, 406 insertions(+), 372 deletions(-) create mode 100644 net/cdp.c create mode 100644 net/cdp.h diff --git a/arch/powerpc/cpu/mpc8xx/fec.c b/arch/powerpc/cpu/mpc8xx/fec.c index f2a2c3a..0bc1e5d 100644 --- a/arch/powerpc/cpu/mpc8xx/fec.c +++ b/arch/powerpc/cpu/mpc8xx/fec.c @@ -274,7 +274,7 @@ static int fec_recv (struct eth_device *dev) #if defined(CONFIG_CMD_CDP) if ((rx[0] 1) != 0 memcmp ((uchar *) rx, NetBcastAddr, 6) != 0 - memcmp ((uchar *) rx, NetCDPAddr, 6) != 0) + !is_cdp_packet((uchar *)rx)) Do you think the is_cdp_packet() change should be in a separate commit? Regards, Simon rx = NULL; #endif /* diff --git a/include/net.h b/include/net.h index 09d1b51..0396b69 100644 --- a/include/net.h +++ b/include/net.h @@ -355,10 +355,6 @@ extern uchar NetEtherNullAddr[6]; extern ushort NetOurVLAN; /* Our VLAN */ extern ushort NetOurNativeVLAN; /* Our Native VLAN */ -extern uchar NetCDPAddr[6]; /* Ethernet CDP address */ -extern ushort CDPNativeVLAN; /* CDP returned native VLAN */ -extern ushort CDPApplianceVLAN; /* CDP returned appliance VLAN */ - extern int NetState; /* Network loop state */ #define NETLOOP_CONTINUE 1 #define NETLOOP_RESTART 2 @@ -386,8 +382,9 @@ extern IPaddr_t NetPingIP; /* the ip address to ping */ #if defined(CONFIG_CMD_CDP) /* when CDP completes these hold the return values */ -extern ushort CDPNativeVLAN; -extern ushort CDPApplianceVLAN; +extern ushort CDPNativeVLAN; /* CDP returned native VLAN */ +extern ushort CDPApplianceVLAN; /* CDP returned appliance VLAN */ +int is_cdp_packet(const uchar *et_addr); #endif #if defined(CONFIG_CMD_SNTP) diff --git a/net/Makefile b/net/Makefile index 5901046..b350bfc 100644 --- a/net/Makefile +++ b/net/Makefile @@ -28,6 +28,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libnet.o COBJS-$(CONFIG_CMD_NET) += bootp.o +COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o COBJS-$(CONFIG_CMD_NET) += eth.o COBJS-$(CONFIG_CMD_NET) += net.o diff --git a/net/cdp.c b/net/cdp.c new file mode 100644 index 000..c5e54b2 --- /dev/null +++ b/net/cdp.c @@ -0,0 +1,380 @@ +/* + * Copied from Linux Monitor (LiMon) - Networking. + * + * Copyright 1994 - 2000 Neil Russell. + * (See License) + * Copyright 2000 Roland Borde + * Copyright 2000 Paolo Scaffardi + * Copyright 2000-2002 Wolfgang Denk, w...@denx.de + */ + +#include common.h +#include net.h +#if defined(CONFIG_CDP_VERSION) +#include timestamp.h +#endif + +#include cdp.h + +/* Ethernet bcast address */ +static const uchar NetCDPAddr[6] = { 0x01, 0x00, 0x0c, 0xcc, 0xcc, 0xcc }; + +#define CDP_DEVICE_ID_TLV 0x0001 +#define CDP_ADDRESS_TLV 0x0002 +#define CDP_PORT_ID_TLV 0x0003 +#define CDP_CAPABILITIES_TLV 0x0004 +#define CDP_VERSION_TLV 0x0005 +#define CDP_PLATFORM_TLV 0x0006 +#define CDP_NATIVE_VLAN_TLV 0x000a +#define CDP_APPLIANCE_VLAN_TLV 0x000e +#define CDP_TRIGGER_TLV 0x000f +#define CDP_POWER_CONSUMPTION_TLV 0x0010 +#define CDP_SYSNAME_TLV 0x0014 +#define CDP_SYSOBJECT_TLV 0x0015 +#define CDP_MANAGEMENT_ADDRESS_TLV 0x0016 + +#define CDP_TIMEOUT 250UL /* one packet every 250ms */ + +static int CDPSeq; +static int CDPOK; + +ushort CDPNativeVLAN; +ushort CDPApplianceVLAN; + +static const uchar CDP_SNAP_hdr[8] = { 0xAA, 0xAA, 0x03, 0x00, 0x00, 0x0C, 0x20, + 0x00 }; + +static ushort +CDP_compute_csum(const uchar *buff, ushort len) +{ + ushort csum; + int odd; + ulong result = 0; + ushort leftover; + ushort *p; + + if (len 0) { + odd = 1 (ulong)buff; + if (odd) { + result = *buff 8; + len--; + buff++; + } + while (len
Re: [U-Boot] [PATCH 06/28] net: Move ARP out of net.c
On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Acked-by: Simon Glass s...@chromium.org Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h | 3 +- net/Makefile | 1 + net/arp.c | 213 + net/arp.h | 30 net/net.c | 209 5 files changed, 259 insertions(+), 197 deletions(-) create mode 100644 net/arp.c create mode 100644 net/arp.h diff --git a/include/net.h b/include/net.h index 0396b69..2d00233 100644 --- a/include/net.h +++ b/include/net.h @@ -418,7 +418,8 @@ extern void NetSetIP(uchar *, IPaddr_t, int, int, int); extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ extern uint NetCksum(uchar *, int); /* Calculate the checksum */ -/* Set callbacks */ +/* Callbacks */ +extern rxhand_f *NetGetHandler(void); /* Get RX packet handler */ extern void NetSetHandler(rxhand_f *); /* Set RX packet handler */ extern void net_set_icmp_handler(rxhand_icmp_f *f); /* Set ICMP RX handler */ extern void NetSetTimeout(ulong, thand_f *);/* Set timeout handler */ diff --git a/net/Makefile b/net/Makefile index b350bfc..0916a56 100644 --- a/net/Makefile +++ b/net/Makefile @@ -27,6 +27,7 @@ include $(TOPDIR)/config.mk LIB = $(obj)libnet.o +COBJS-$(CONFIG_CMD_NET) += arp.o COBJS-$(CONFIG_CMD_NET) += bootp.o COBJS-$(CONFIG_CMD_CDP) += cdp.o COBJS-$(CONFIG_CMD_DNS) += dns.o diff --git a/net/arp.c b/net/arp.c new file mode 100644 index 000..f75217c --- /dev/null +++ b/net/arp.c @@ -0,0 +1,213 @@ +/* + * Copied from Linux Monitor (LiMon) - Networking. + * + * Copyright 1994 - 2000 Neil Russell. + * (See License) + * Copyright 2000 Roland Borde + * Copyright 2000 Paolo Scaffardi + * Copyright 2000-2002 Wolfgang Denk, w...@denx.de + */ + +#include common.h + +#include arp.h + +#ifndef CONFIG_ARP_TIMEOUT +/* Milliseconds before trying ARP again */ +# define ARP_TIMEOUT 5000UL +#else +# define ARP_TIMEOUT CONFIG_ARP_TIMEOUT +#endif + + +#ifndef CONFIG_NET_RETRY_COUNT +# define ARP_TIMEOUT_COUNT 5 /* # of timeouts before giving up */ +#else +# define ARP_TIMEOUT_COUNT CONFIG_NET_RETRY_COUNT +#endif + +IPaddr_t NetArpWaitPacketIP; +IPaddr_t NetArpWaitReplyIP; +/* MAC address of waiting packet's destination */ +uchar *NetArpWaitPacketMAC; +/* THE transmit packet */ +uchar *NetArpWaitTxPacket; +int NetArpWaitTxPacketSize; +uchar NetArpWaitPacketBuf[PKTSIZE_ALIGN + PKTALIGN]; +ulong NetArpWaitTimerStart; +int NetArpWaitTry; + +void ArpInit(void) +{ + /* XXX problem with bss workaround */ + NetArpWaitPacketMAC = NULL; + NetArpWaitPacketIP = 0; + NetArpWaitReplyIP = 0; + NetArpWaitTxPacket = NetArpWaitPacketBuf[0] + (PKTALIGN - 1); + NetArpWaitTxPacket -= (ulong)NetArpWaitTxPacket % PKTALIGN; + NetArpWaitTxPacketSize = 0; +} + +void ArpRequest(void) +{ + uchar *pkt; + ARP_t *arp; + + debug(ARP broadcast %d\n, NetArpWaitTry); + + pkt = NetTxPacket; + + pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP); + + arp = (ARP_t *) pkt; + + arp-ar_hrd = htons(ARP_ETHER); + arp-ar_pro = htons(PROT_IP); + arp-ar_hln = 6; + arp-ar_pln = 4; + arp-ar_op = htons(ARPOP_REQUEST); + + /* source ET addr */ + memcpy(arp-ar_data[0], NetOurEther, 6); + /* source IP addr */ + NetWriteIP((uchar *) arp-ar_data[6], NetOurIP); + /* dest ET addr = 0 */ + memset(arp-ar_data[10], '\0', 6); + if ((NetArpWaitPacketIP NetOurSubnetMask) != + (NetOurIP NetOurSubnetMask)) { + if (NetOurGatewayIP == 0) { + puts(## Warning: gatewayip needed but not set\n); + NetArpWaitReplyIP = NetArpWaitPacketIP; + } else { + NetArpWaitReplyIP = NetOurGatewayIP; + } + } else { + NetArpWaitReplyIP = NetArpWaitPacketIP; + } + + NetWriteIP((uchar *) arp-ar_data[16], NetArpWaitReplyIP); + (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); +} + +void ArpTimeoutCheck(void) +{ + ulong t; + + if (!NetArpWaitPacketIP) + return; + + t = get_timer(0); + + /* check for arp timeout */ + if ((t - NetArpWaitTimerStart) ARP_TIMEOUT) { + NetArpWaitTry++; + + if (NetArpWaitTry = ARP_TIMEOUT_COUNT) { + puts(\nARP Retry count exceeded; starting again\n); +
Re: [U-Boot] [PATCH 07/28] net: Move PING out of net.c
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/configs/am3517_crane.h | 2 +- include/configs/am3517_evm.h | 2 +- include/configs/origen.h | 2 +- Perhaps move these config changes to another commit? It would be nice (perhaps later) to remove the camel case. Regards, Simon net/Makefile | 1 + net/net.c | 133 ++--- net/ping.c | 143 net/ping.h | 20 ++ 7 files changed, 172 insertions(+), 131 deletions(-) create mode 100644 net/ping.c create mode 100644 net/ping.h diff --git a/include/configs/am3517_crane.h b/include/configs/am3517_crane.h index 0a0c261..acd4e3f 100644 --- a/include/configs/am3517_crane.h +++ b/include/configs/am3517_crane.h @@ -146,7 +146,7 @@ #define CONFIG_CMD_MMC /* MMC support */ #define CONFIG_CMD_NAND /* NAND support */ #define CONFIG_CMD_DHCP -#define CONFIG_CMD_PING +#undef CONFIG_CMD_PING #undef CONFIG_CMD_FLASH /* flinfo, erase, protect */ #undef CONFIG_CMD_FPGA /* FPGA configuration Support */ diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h index d44eeec..9775107 100644 --- a/include/configs/am3517_evm.h +++ b/include/configs/am3517_evm.h @@ -145,7 +145,7 @@ #define CONFIG_CMD_MMC /* MMC support */ #define CONFIG_CMD_NAND /* NAND support */ #define CONFIG_CMD_DHCP -#define CONFIG_CMD_PING +#undef CONFIG_CMD_PING #undef CONFIG_CMD_FLASH /* flinfo, erase, protect */ #undef CONFIG_CMD_FPGA /* FPGA configuration Support */ diff --git a/include/configs/origen.h b/include/configs/origen.h index cd502d1..c9bac30 100644 --- a/include/configs/origen.h +++ b/include/configs/origen.h @@ -84,7 +84,7 @@ /* Command definition*/ #include config_cmd_default.h -#define CONFIG_CMD_PING +#undef CONFIG_CMD_PING #define CONFIG_CMD_ELF #define CONFIG_CMD_DHCP #define CONFIG_CMD_MMC diff --git a/net/Makefile b/net/Makefile index 0916a56..f1c4859 100644 --- a/net/Makefile +++ b/net/Makefile @@ -35,6 +35,7 @@ COBJS-$(CONFIG_CMD_NET) += eth.o COBJS-$(CONFIG_CMD_NET) += net.o COBJS-$(CONFIG_BOOTP_RANDOM_DELAY) += net_rand.o COBJS-$(CONFIG_CMD_NFS) += nfs.o +COBJS-$(CONFIG_CMD_PING) += ping.o COBJS-$(CONFIG_CMD_RARP) += rarp.o COBJS-$(CONFIG_CMD_SNTP) += sntp.o COBJS-$(CONFIG_CMD_NET) += tftp.o diff --git a/net/net.c b/net/net.c index 2dae5a0..c2fbcb5 100644 --- a/net/net.c +++ b/net/net.c @@ -98,6 +98,9 @@ #if defined(CONFIG_CMD_DNS) #include dns.h #endif +#if defined(CONFIG_CMD_PING) +#include ping.h +#endif DECLARE_GLOBAL_DATA_PTR; @@ -168,13 +171,6 @@ ushort NetOurNativeVLAN = 0x; /* Boot File name */ char BootFile[128]; -#if defined(CONFIG_CMD_PING) -/* the ip address to ping */ -IPaddr_t NetPingIP; - -static void PingStart(void); -#endif - #if defined(CONFIG_CMD_SNTP) /* NTP server IP address */ IPaddr_t NetNtpServerIP; @@ -653,94 +649,6 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, int len) return 0; /* transmitted */ } -#if defined(CONFIG_CMD_PING) -static ushort PingSeqNo; - -int PingSend(void) -{ - static uchar mac[6]; - IP_t *ip; - ushort *s; - uchar *pkt; - - /* XXX always send arp request */ - - memcpy(mac, NetEtherNullAddr, 6); - - debug(sending ARP for %08x\n, NetPingIP); - - NetArpWaitPacketIP = NetPingIP; - NetArpWaitPacketMAC = mac; - - pkt = NetArpWaitTxPacket; - pkt += NetSetEther(pkt, mac, PROT_IP); - - ip = (IP_t *)pkt; - - /* - * Construct an IP and ICMP header. - * (need to set no fragment bit - XXX) - */ - /* IP_HDR_SIZE / 4 (not including UDP) */ - ip-ip_hl_v = 0x45; - ip-ip_tos = 0; - ip-ip_len = htons(IP_HDR_SIZE_NO_UDP + 8); - ip-ip_id = htons(NetIPID++); - ip-ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ - ip-ip_ttl = 255; - ip-ip_p = 0x01; /* ICMP */ - ip-ip_sum = 0; - /* already in network byte order */ - NetCopyIP((void *)ip-ip_src, NetOurIP); - /* - - */ - NetCopyIP((void *)ip-ip_dst, NetPingIP); - ip-ip_sum = ~NetCksum((uchar *)ip, IP_HDR_SIZE_NO_UDP / 2); - - s = ip-udp_src; /* XXX ICMP starts here */ - s[0] = htons(0x0800); /* echo-request, code */ - s[1] = 0; /* checksum
Re: [U-Boot] [PATCH 08/28] net: Move RARP receive logic out of net.c
On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de Acked-by: Simon Glass s...@chromium.org --- net/net.c | 25 + net/rarp.c | 38 +++--- net/rarp.h | 1 + 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/net/net.c b/net/net.c index c2fbcb5..fdc1ebe 100644 --- a/net/net.c +++ b/net/net.c @@ -857,9 +857,6 @@ NetReceive(volatile uchar *inpkt, int len) { Ethernet_t *et; IP_t *ip; -#ifdef CONFIG_CMD_RARP - ARP_t *arp; -#endif IPaddr_t tmp; IPaddr_t src_ip; int x; @@ -964,27 +961,7 @@ NetReceive(volatile uchar *inpkt, int len) #ifdef CONFIG_CMD_RARP case PROT_RARP: - debug(Got RARP\n); - arp = (ARP_t *)ip; - if (len ARP_HDR_SIZE) { - printf(bad length %d %d\n, len, ARP_HDR_SIZE); - return; - } - - if ((ntohs(arp-ar_op) != RARPOP_REPLY) || - (ntohs(arp-ar_hrd) != ARP_ETHER) || - (ntohs(arp-ar_pro) != PROT_IP) || - (arp-ar_hln != 6) || (arp-ar_pln != 4)) { - - puts(invalid RARP header\n); - } else { - NetCopyIP(NetOurIP, arp-ar_data[16]); - if (NetServerIP == 0) - NetCopyIP(NetServerIP, arp-ar_data[6]); - memcpy(NetServerEther, arp-ar_data[0], 6); - - (*packetHandler)(0, 0, 0, 0, 0); - } + RarpReceive(ip, len); break; #endif case PROT_IP: diff --git a/net/rarp.c b/net/rarp.c index 5a813a2..761560c 100644 --- a/net/rarp.c +++ b/net/rarp.c @@ -36,18 +36,37 @@ # define TIMEOUT_COUNT (CONFIG_NET_RETRY_COUNT) #endif - int RarpTry; /* * Handle a RARP received packet. */ -static void -RarpHandler(uchar *dummi0, unsigned dummi1, IPaddr_t sip, unsigned dummi2, - unsigned dummi3) +void void on same line as function? +RarpReceive(IP_t *ip, unsigned len) { - debug(Got good RARP\n); - net_auto_load(); + ARP_t *arp; + + debug(Got RARP\n); + arp = (ARP_t *)ip; + if (len ARP_HDR_SIZE) { + printf(bad length %d %d\n, len, ARP_HDR_SIZE); + return; + } + + if ((ntohs(arp-ar_op) != RARPOP_REPLY) || + (ntohs(arp-ar_hrd) != ARP_ETHER) || + (ntohs(arp-ar_pro) != PROT_IP) || + (arp-ar_hln != 6) || (arp-ar_pln != 4)) { + + puts(invalid RARP header\n); + } else { + NetCopyIP(NetOurIP, arp-ar_data[16]); + if (NetServerIP == 0) + NetCopyIP(NetServerIP, arp-ar_data[6]); + memcpy(NetServerEther, arp-ar_data[0], 6); + debug(Got good RARP\n); + net_auto_load(); + } } @@ -70,7 +89,6 @@ RarpTimeout(void) void RarpRequest(void) { - int i; uchar *pkt; ARP_t *rarp; @@ -90,12 +108,10 @@ RarpRequest(void) memcpy(rarp-ar_data[6], NetOurIP, 4); /* source IP addr */ /* dest ET addr = source ET addr ??*/ memcpy(rarp-ar_data[10], NetOurEther, 6); - /* dest. IP addr set to broadcast */ - for (i = 0; i = 3; i++) - rarp-ar_data[16 + i] = 0xff; + /* dest IP addr set to broadcast */ + memset(rarp-ar_data[16], 0xff, 4); NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); NetSetTimeout(TIMEOUT, RarpTimeout); - NetSetHandler(RarpHandler); } diff --git a/net/rarp.h b/net/rarp.h index 4e92d80..0d728dc 100644 --- a/net/rarp.h +++ b/net/rarp.h @@ -37,6 +37,7 @@ extern int RarpTry; +extern void RarpReceive(IP_t *ip, unsigned len); extern void RarpRequest(void); /* Send a RARP request */ /**/ -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 01/28] net: Remove volatile from all of net except the eth driver interface
Hi Joe, On Fri, Jan 20, 2012 at 12:15 PM, Joe Hershberger joe.hershber...@gmail.com wrote: Hi Simon, On Fri, Jan 20, 2012 at 10:22 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: The mv_eth driver should not redefine the net function definition Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- snip @@ -1454,9 +1454,9 @@ NetReceive(volatile uchar *inpkt, int len) debug(packet received\n); - NetRxPacket = inpkt; + NetRxPacket = (uchar *)inpkt; NetRxPacketLen = len; - et = (Ethernet_t *)inpkt; + et = (Ethernet_t *)NetRxPacket; Why change this? /* too small packet? */ if (len ETHER_HDR_SIZE) @@ -1491,11 +1491,11 @@ NetReceive(volatile uchar *inpkt, int len) */ x = ntohs(et-et_prot); - ip = (IP_t *)(inpkt + E802_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + E802_HDR_SIZE); and these? You are using a global instead of the passed-in local. len -= E802_HDR_SIZE; } else if (x != PROT_VLAN) { /* normal packet */ - ip = (IP_t *)(inpkt + ETHER_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + ETHER_HDR_SIZE); len -= ETHER_HDR_SIZE; } else { /* VLAN packet */ @@ -1519,7 +1519,7 @@ NetReceive(volatile uchar *inpkt, int len) vlanid = cti VLAN_IDMASK; x = ntohs(vet-vet_type); - ip = (IP_t *)(inpkt + VLAN_ETHER_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + VLAN_ETHER_HDR_SIZE); len -= VLAN_ETHER_HDR_SIZE; } This patch removes volatile from the NetRxPacket and all but 1 of the other places that inpkt was assigned. You will notice that the first assignment of inpkt to NetRxPacket casts away the volatile: Yes - I wonder why NetReceive needs to remain volatile? @@ -1454,9 +1454,9 @@ NetReceive(volatile uchar *inpkt, int len) snip - NetRxPacket = inpkt; + NetRxPacket = (uchar *)inpkt; All the assignments that need a non-volatile pointer now use NetRxPacket instead of inpkt, since it is already assigned and and the same type minus volatile. Yes, I am only sensitive to this because it is a global and there is enough use of globals in the net code already. Best regards, -Joe Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 02/28] net: cosmetic: checkpatch compliance
Hi Joe, On Fri, Jan 20, 2012 at 12:21 PM, Joe Hershberger joe.hershber...@gmail.com wrote: Hi Simon, On Fri, Jan 20, 2012 at 10:30 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- common/main.c | 1 - drivers/net/netconsole.c | 122 + include/common.h | 4 + include/net.h | 123 + net/bootp.c | 338 +++--- net/bootp.h | 56 net/eth.c | 66 +- net/net.c | 19 +-- net/nfs.c | 300 - net/nfs.h | 2 +- net/rarp.c | 28 ++-- net/rarp.h | 4 +- net/sntp.c | 31 +++-- net/sntp.h | 2 +- net/tftp.c | 30 ++--- net/tftp.h | 2 +- 16 files changed, 572 insertions(+), 556 deletions(-) Others may fine with it, but it might be worth splitting this very long patch, perhaps split out some of the larger files or the show_activity() change. I had this separated by file, but figured since the series was pretty long, it is all cosmetic (making separate patches not especially helpful), and it was under the 100kB mail limit that it would be better as a single patch. If it will be a barrier to review, I can split it up again. I'm not sure if it is a barrier to review or not, but I did nod off about 15% through :-) Regards, Simon Best regards, -Joe ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 10/28] net: cosmetic: Improve variable names and code readability
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Rename parameter len to payload_len in NetSendUDPPacket: this name more explicitly claims that it does not include the header size Rename CDPHandler to CDPReceive: this is not called as a handler, so don't name it that way Rename OPT_SIZE to OPT_FIELD_SIZE: clearer constant name and also remove related BOOTP_SIZE which was unused and doesn't take into account VLAN packets Rename tmp to reply_ip_addr in arp.c Alphabetize includes in net.c Replace magic numbers in arp.c with constants Add a more explicit comment about 802.2 Yes but why lump all of these together? It would benefit from 3-4 separate commits IMO. Regards, Simon Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h | 11 +++- net/arp.c | 38 net/bootp.c | 10 net/bootp.h | 7 ++--- net/cdp.c | 2 +- net/cdp.h | 2 +- net/net.c | 67 +--- 7 files changed, 73 insertions(+), 64 deletions(-) diff --git a/include/net.h b/include/net.h index 9de1181..add2080 100644 --- a/include/net.h +++ b/include/net.h @@ -169,7 +169,8 @@ struct Ethernet_t { }; #define ETHER_HDR_SIZE 14 /* Ethernet header size */ -#define E802_HDR_SIZE 22 /* 802 ethernet header size */ + /* 802.2 + SNAP + ethernet header size */ +#define E802_HDR_SIZE (ETHER_HDR_SIZE + 8) /* * Ethernet header @@ -231,7 +232,9 @@ struct ARP_t { # define ARP_ETHER 1 /* Ethernet hardware address */ ushort ar_pro; /* Format of protocol address */ uchar ar_hln; /* Length of hardware address */ +# define ARP_HLEN 6 uchar ar_pln; /* Length of protocol address */ +# define ARP_PLEN 4 ushort ar_op; /* Operation */ # define ARPOP_REQUEST 1 /* Request to resolve address */ # define ARPOP_REPLY 2 /* Response to previous request */ @@ -245,6 +248,10 @@ struct ARP_t { * specific hardware/protocol combinations. */ uchar ar_data[0]; +#define ar_sha ar_data[0] +#define ar_spa ar_data[ARP_HLEN] +#define ar_tha ar_data[ARP_HLEN + ARP_PLEN] +#define ar_tpa ar_data[ARP_HLEN + ARP_PLEN + ARP_HLEN] #if 0 uchar ar_sha[]; /* Sender hardware address */ uchar ar_spa[]; /* Sender protocol address */ @@ -431,7 +438,7 @@ extern void NetSendPacket(uchar *, int); /* Transmit UDP packet, performing ARP request if needed */ extern int NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, - int sport, int len); + int sport, int payload_len); /* Processes a received packet */ extern void NetReceive(volatile uchar *, int); diff --git a/net/arp.c b/net/arp.c index 96ffb85..456decd 100644 --- a/net/arp.c +++ b/net/arp.c @@ -63,16 +63,16 @@ void ArpRequest(void) arp-ar_hrd = htons(ARP_ETHER); arp-ar_pro = htons(PROT_IP); - arp-ar_hln = 6; - arp-ar_pln = 4; + arp-ar_hln = ARP_HLEN; + arp-ar_pln = ARP_PLEN; arp-ar_op = htons(ARPOP_REQUEST); /* source ET addr */ - memcpy(arp-ar_data[0], NetOurEther, 6); + memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); /* source IP addr */ - NetWriteIP((uchar *) arp-ar_data[6], NetOurIP); + NetWriteIP(arp-ar_spa, NetOurIP); /* dest ET addr = 0 */ - memset(arp-ar_data[10], '\0', 6); + memset(arp-ar_tha, 0, ARP_HLEN); if ((NetArpWaitPacketIP NetOurSubnetMask) != (NetOurIP NetOurSubnetMask)) { if (NetOurGatewayIP == 0) { @@ -85,7 +85,7 @@ void ArpRequest(void) NetArpWaitReplyIP = NetArpWaitPacketIP; } - NetWriteIP((uchar *) arp-ar_data[16], NetArpWaitReplyIP); + NetWriteIP(arp-ar_tpa, NetArpWaitReplyIP); (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); } @@ -116,7 +116,7 @@ void ArpTimeoutCheck(void) void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) { struct ARP_t *arp; - IPaddr_t tmp; + IPaddr_t reply_ip_addr; uchar *pkt; /* @@ -139,15 +139,15 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) return; if (ntohs(arp-ar_pro) != PROT_IP) return; - if (arp-ar_hln != 6) + if (arp-ar_hln != ARP_HLEN) return; - if (arp-ar_pln != 4) + if (arp-ar_pln != ARP_PLEN) return;
Re: [U-Boot] [PATCH 01/28] net: Remove volatile from all of net except the eth driver interface
Hi Simon, On Tue, Jan 24, 2012 at 12:09 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Fri, Jan 20, 2012 at 12:15 PM, Joe Hershberger joe.hershber...@gmail.com wrote: Hi Simon, On Fri, Jan 20, 2012 at 10:22 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: The mv_eth driver should not redefine the net function definition Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- snip @@ -1454,9 +1454,9 @@ NetReceive(volatile uchar *inpkt, int len) debug(packet received\n); - NetRxPacket = inpkt; + NetRxPacket = (uchar *)inpkt; NetRxPacketLen = len; - et = (Ethernet_t *)inpkt; + et = (Ethernet_t *)NetRxPacket; Why change this? /* too small packet? */ if (len ETHER_HDR_SIZE) @@ -1491,11 +1491,11 @@ NetReceive(volatile uchar *inpkt, int len) */ x = ntohs(et-et_prot); - ip = (IP_t *)(inpkt + E802_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + E802_HDR_SIZE); and these? You are using a global instead of the passed-in local. len -= E802_HDR_SIZE; } else if (x != PROT_VLAN) { /* normal packet */ - ip = (IP_t *)(inpkt + ETHER_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + ETHER_HDR_SIZE); len -= ETHER_HDR_SIZE; } else { /* VLAN packet */ @@ -1519,7 +1519,7 @@ NetReceive(volatile uchar *inpkt, int len) vlanid = cti VLAN_IDMASK; x = ntohs(vet-vet_type); - ip = (IP_t *)(inpkt + VLAN_ETHER_HDR_SIZE); + ip = (IP_t *)(NetRxPacket + VLAN_ETHER_HDR_SIZE); len -= VLAN_ETHER_HDR_SIZE; } This patch removes volatile from the NetRxPacket and all but 1 of the other places that inpkt was assigned. You will notice that the first assignment of inpkt to NetRxPacket casts away the volatile: Yes - I wonder why NetReceive needs to remain volatile? It is called by all the Ethernet drivers with volatile buffer pointers. At this point, I decided to limit the changes to not include every Ethernet driver (have to split it somewhere). @@ -1454,9 +1454,9 @@ NetReceive(volatile uchar *inpkt, int len) snip - NetRxPacket = inpkt; + NetRxPacket = (uchar *)inpkt; All the assignments that need a non-volatile pointer now use NetRxPacket instead of inpkt, since it is already assigned and and the same type minus volatile. Yes, I am only sensitive to this because it is a global and there is enough use of globals in the net code already. I chose to not add a local variable to hold the non-volatile pointer since there was already a global. Since u-boot is single threaded, this should not be a problem and could be easily changed later when the Ethernet driver interface is cleaned up. Best regards, -Joe ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 11/28] net: Refactor IP, UPD, and ICMP header writing functions
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: ICMP (ping) was reimplementing IP header code... it now shares code. Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- include/net.h | 4 +++- net/bootp.c | 6 +++--- net/net.c | 47 --- net/ping.c | 52 +++- 4 files changed, 57 insertions(+), 52 deletions(-) To be honest these sorts of cleanup are great, but they are very hard to review unless you know the code well. In particular your commit message makes me imagine that you are cutting out duplicate code, but it is changing a bit also. diff --git a/include/net.h b/include/net.h index add2080..19e9463 100644 --- a/include/net.h +++ b/include/net.h @@ -421,7 +421,9 @@ extern int NetEthHdrSize(void); extern int NetSetEther(uchar *, uchar *, uint); /* Set IP header */ -extern void NetSetIP(uchar *, IPaddr_t, int, int, int); +extern void NetSetIPHeader(uchar *pkt, IPaddr_t dest, IPaddr_t source); +extern void NetSetUDPHeader(uchar *pkt, IPaddr_t dest, int dport, + int sport, int len); /* Checksum */ extern int NetCksumOk(uchar *, int); /* Return true if cksum OK */ diff --git a/net/bootp.c b/net/bootp.c index 2be8083..0c2af48 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -619,7 +619,7 @@ BootpRequest(void) * determined. * C. Hallinan, DS4.COM, Inc. */ - /* NetSetIP(pkt, 0xL, PORT_BOOTPS, PORT_BOOTPC, + /* NetSetUDPHeader(pkt, 0xL, PORT_BOOTPS, PORT_BOOTPC, sizeof (struct Bootp_t)); */ iphdr = pkt; /* We need this later for NetSetUDPHeader() */ pkt += IP_UDP_HDR_SIZE; @@ -663,7 +663,7 @@ BootpRequest(void) pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; - NetSetIP(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); + NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); #if defined(CONFIG_CMD_DHCP) @@ -844,7 +844,7 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; - NetSetIP(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); + NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY diff --git a/net/net.c b/net/net.c index 9bf74d5..a47b215 100644 --- a/net/net.c +++ b/net/net.c @@ -625,7 +625,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, pkt = NetArpWaitTxPacket; pkt += NetSetEther(pkt, NetArpWaitPacketMAC, PROT_IP); - NetSetIP(pkt, dest, dport, sport, payload_len); + NetSetUDPHeader(pkt, dest, dport, sport, payload_len); memcpy(pkt + IP_UDP_HDR_SIZE, (uchar *)NetTxPacket + (pkt - (uchar *)NetArpWaitTxPacket) + IP_UDP_HDR_SIZE, payload_len); @@ -645,7 +645,7 @@ NetSendUDPPacket(uchar *ether, IPaddr_t dest, int dport, int sport, pkt = (uchar *)NetTxPacket; pkt += NetSetEther(pkt, ether, PROT_IP); - NetSetIP(pkt, dest, dport, sport, payload_len); + NetSetUDPHeader(pkt, dest, dport, sport, payload_len); eth_send(NetTxPacket, (pkt - NetTxPacket) + IP_UDP_HDR_SIZE + payload_len); @@ -1250,40 +1250,49 @@ NetSetEther(uchar *xet, uchar * addr, uint prot) } void -NetSetIP(uchar *xip, IPaddr_t dest, int dport, int sport, int len) +NetSetIPHeader(uchar *pkt, IPaddr_t dest, IPaddr_t source) { - struct IP_UDP_t *ip = (struct IP_UDP_t *)xip; + struct IP_UDP_t *ip = (struct IP_UDP_t *)pkt; /* - * If the data is an odd number of bytes, zero the - * byte after the last byte so that the checksum - * will work. - */ - if (len 1) - xip[IP_UDP_HDR_SIZE + len] = 0; - - /* - * Construct an IP and UDP header. - * (need to set no fragment bit - XXX) + * Construct an IP header. */ /* IP_HDR_SIZE / 4 (not including UDP) */ ip-ip_hl_v = 0x45; ip-ip_tos = 0; - ip-ip_len = htons(IP_UDP_HDR_SIZE + len); + ip-ip_len = htons(IP_HDR_SIZE); ip-ip_id = htons(NetIPID++); ip-ip_off = htons(IP_FLAGS_DFRAG); /* Don't fragment */ ip-ip_ttl = 255; - ip-ip_p = 17;
Re: [U-Boot] [PATCH 12/28] net: Refactor packet length computations
On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de Acked-by: Simon Glass s...@chromium.org --- net/arp.c | 13 - net/ping.c | 7 --- net/rarp.c | 6 -- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/net/arp.c b/net/arp.c index 456decd..60a1ded 100644 --- a/net/arp.c +++ b/net/arp.c @@ -52,12 +52,14 @@ void ArpRequest(void) { uchar *pkt; struct ARP_t *arp; + int eth_hdr_size; debug(ARP broadcast %d\n, NetArpWaitTry); pkt = NetTxPacket; - pkt += NetSetEther(pkt, NetBcastAddr, PROT_ARP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_ARP); + pkt += eth_hdr_size; arp = (struct ARP_t *) pkt; @@ -86,7 +88,7 @@ void ArpRequest(void) } NetWriteIP(arp-ar_tpa, NetArpWaitReplyIP); - (void) eth_send(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); + (void) eth_send(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); } void ArpTimeoutCheck(void) @@ -118,6 +120,7 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) struct ARP_t *arp; IPaddr_t reply_ip_addr; uchar *pkt; + int eth_hdr_size; /* * We have to deal with two types of ARP packets: @@ -155,14 +158,14 @@ void ArpReceive(struct Ethernet_t *et, struct IP_UDP_t *ip, int len) /* reply with our IP address */ debug(Got ARP REQUEST, return our IP\n); pkt = (uchar *)et; - pkt += NetSetEther(pkt, et-et_src, PROT_ARP); + eth_hdr_size = NetSetEther(pkt, et-et_src, PROT_ARP); + pkt += eth_hdr_size; arp-ar_op = htons(ARPOP_REPLY); memcpy(arp-ar_tha, arp-ar_sha, ARP_HLEN); NetCopyIP(arp-ar_tpa, arp-ar_spa); memcpy(arp-ar_sha, NetOurEther, ARP_HLEN); NetCopyIP(arp-ar_spa, NetOurIP); - (void) eth_send((uchar *)et, - (pkt - (uchar *)et) + ARP_HDR_SIZE); + (void) eth_send((uchar *)et, eth_hdr_size + ARP_HDR_SIZE); return; case ARPOP_REPLY: /* arp reply */ diff --git a/net/ping.c b/net/ping.c index 356f107..12f9185 100644 --- a/net/ping.c +++ b/net/ping.c @@ -42,6 +42,7 @@ static int PingSend(void) { static uchar mac[6]; uchar *pkt; + int eth_hdr_size; /* XXX always send arp request */ @@ -53,13 +54,13 @@ static int PingSend(void) NetArpWaitPacketMAC = mac; pkt = NetArpWaitTxPacket; - pkt += NetSetEther(pkt, mac, PROT_IP); + eth_hdr_size = NetSetEther(pkt, mac, PROT_IP); + pkt += eth_hdr_size; SetICMPHeader(pkt, NetPingIP); /* size of the waiting packet */ - NetArpWaitTxPacketSize = - (pkt - NetArpWaitTxPacket) + IP_HDR_SIZE + 8; + NetArpWaitTxPacketSize = eth_hdr_size + IP_ICMP_HDR_SIZE; /* and do the ARP request */ NetArpWaitTry = 1; diff --git a/net/rarp.c b/net/rarp.c index 305b0a4..3097341 100644 --- a/net/rarp.c +++ b/net/rarp.c @@ -91,11 +91,13 @@ RarpRequest(void) { uchar *pkt; struct ARP_t *rarp; + int eth_hdr_size; printf(RARP broadcast %d\n, ++RarpTry); pkt = NetTxPacket; - pkt += NetSetEther(pkt, NetBcastAddr, PROT_RARP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_RARP); + pkt += eth_hdr_size; rarp = (struct ARP_t *)pkt; @@ -111,7 +113,7 @@ RarpRequest(void) /* dest IP addr set to broadcast */ memset(rarp-ar_data[16], 0xff, 4); - NetSendPacket(NetTxPacket, (pkt - NetTxPacket) + ARP_HDR_SIZE); + NetSendPacket(NetTxPacket, eth_hdr_size + ARP_HDR_SIZE); NetSetTimeout(TIMEOUT, RarpTimeout); } -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 13/28] net: Refactor bootp packet length computations
Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/bootp.c | 26 ++ 1 files changed, 14 insertions(+), 12 deletions(-) Refactor why or to what purpose? Perhaps a bit more detail in the commit message? diff --git a/net/bootp.c b/net/bootp.c index 0c2af48..0d5f4cf 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -582,7 +582,8 @@ BootpRequest(void) { uchar *pkt, *iphdr; struct Bootp_t *bp; - int ext_len, pktlen, iplen; + int extlen, pktlen, iplen; Is extlen better than ext_len? + int eth_hdr_size; #ifdef CONFIG_BOOTP_RANDOM_DELAY ulong i, rand_ms; #endif @@ -610,7 +611,8 @@ BootpRequest(void) pkt = NetTxPacket; memset((void *)pkt, 0, PKTSIZE); - pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_IP); + pkt += eth_hdr_size; /* * Next line results in incorrect packet size being transmitted, @@ -639,9 +641,9 @@ BootpRequest(void) /* Request additional information from the BOOTP/DHCP server */ #if defined(CONFIG_CMD_DHCP) - ext_len = DhcpExtended((u8 *)bp-bp_vend, DHCP_DISCOVER, 0, 0); + extlen = DhcpExtended((u8 *)bp-bp_vend, DHCP_DISCOVER, 0, 0); #else - ext_len = BootpExtended((u8 *)bp-bp_vend); + extlen = BootpExtended((u8 *)bp-bp_vend); #endif /* @@ -660,9 +662,8 @@ BootpRequest(void) * Calculate proper packet lengths taking into account the * variable size of the options field */ - pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - - sizeof(bp-bp_vend) + ext_len; - iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; + iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); @@ -798,13 +799,15 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) uchar *pkt, *iphdr; struct Bootp_t *bp; int pktlen, iplen, extlen; + int eth_hdr_size; IPaddr_t OfferedIP; debug(DhcpSendRequestPkt: Sending DHCPREQUEST\n); pkt = NetTxPacket; memset((void *)pkt, 0, PKTSIZE); - pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_IP); + pkt += eth_hdr_size; iphdr = pkt; /* We'll need this later to set proper pkt size */ pkt += IP_UDP_HDR_SIZE; @@ -841,15 +844,14 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) extlen = DhcpExtended((u8 *)bp-bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP); - pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - - sizeof(bp-bp_vend) + extlen; - iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; + iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); - debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY); #endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */ + debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); Did you move this on purpose? NetSendPacket(NetTxPacket, pktlen); } -- 1.6.0.2 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 13/28] net: Refactor bootp packet length computations
Hi Simon, On Tue, Jan 24, 2012 at 1:05 AM, Simon Glass s...@chromium.org wrote: Hi Joe, On Thu, Jan 19, 2012 at 4:53 PM, Joe Hershberger joe.hershber...@ni.com wrote: Signed-off-by: Joe Hershberger joe.hershber...@ni.com Cc: Joe Hershberger joe.hershber...@gmail.com Cc: Wolfgang Denk w...@denx.de --- net/bootp.c | 26 ++ 1 files changed, 14 insertions(+), 12 deletions(-) Refactor why or to what purpose? Perhaps a bit more detail in the commit message? Just removing the pointer subtraction similar to patch 12. diff --git a/net/bootp.c b/net/bootp.c index 0c2af48..0d5f4cf 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -582,7 +582,8 @@ BootpRequest(void) { uchar *pkt, *iphdr; struct Bootp_t *bp; - int ext_len, pktlen, iplen; + int extlen, pktlen, iplen; Is extlen better than ext_len? Just more consistent with other variables in the same calculations. Not especially important, I guess. + int eth_hdr_size; #ifdef CONFIG_BOOTP_RANDOM_DELAY ulong i, rand_ms; #endif @@ -610,7 +611,8 @@ BootpRequest(void) pkt = NetTxPacket; memset((void *)pkt, 0, PKTSIZE); - pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_IP); + pkt += eth_hdr_size; /* * Next line results in incorrect packet size being transmitted, @@ -639,9 +641,9 @@ BootpRequest(void) /* Request additional information from the BOOTP/DHCP server */ #if defined(CONFIG_CMD_DHCP) - ext_len = DhcpExtended((u8 *)bp-bp_vend, DHCP_DISCOVER, 0, 0); + extlen = DhcpExtended((u8 *)bp-bp_vend, DHCP_DISCOVER, 0, 0); #else - ext_len = BootpExtended((u8 *)bp-bp_vend); + extlen = BootpExtended((u8 *)bp-bp_vend); #endif /* @@ -660,9 +662,8 @@ BootpRequest(void) * Calculate proper packet lengths taking into account the * variable size of the options field */ - pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - - sizeof(bp-bp_vend) + ext_len; - iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + ext_len; + iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); NetSetTimeout(SELECT_TIMEOUT, BootpTimeout); @@ -798,13 +799,15 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) uchar *pkt, *iphdr; struct Bootp_t *bp; int pktlen, iplen, extlen; + int eth_hdr_size; IPaddr_t OfferedIP; debug(DhcpSendRequestPkt: Sending DHCPREQUEST\n); pkt = NetTxPacket; memset((void *)pkt, 0, PKTSIZE); - pkt += NetSetEther(pkt, NetBcastAddr, PROT_IP); + eth_hdr_size = NetSetEther(pkt, NetBcastAddr, PROT_IP); + pkt += eth_hdr_size; iphdr = pkt; /* We'll need this later to set proper pkt size */ pkt += IP_UDP_HDR_SIZE; @@ -841,15 +844,14 @@ static void DhcpSendRequestPkt(struct Bootp_t *bp_offer) extlen = DhcpExtended((u8 *)bp-bp_vend, DHCP_REQUEST, NetDHCPServerIP, OfferedIP); - pktlen = ((int)(pkt-NetTxPacket)) + BOOTP_HDR_SIZE - - sizeof(bp-bp_vend) + extlen; - iplen = BOOTP_HDR_SIZE - sizeof(bp-bp_vend) + extlen; + iplen = BOOTP_HDR_SIZE - OPT_FIELD_SIZE + extlen; + pktlen = eth_hdr_size + IP_UDP_HDR_SIZE + iplen; NetSetUDPHeader(iphdr, 0xL, PORT_BOOTPS, PORT_BOOTPC, iplen); - debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); #ifdef CONFIG_BOOTP_DHCP_REQUEST_DELAY udelay(CONFIG_BOOTP_DHCP_REQUEST_DELAY); #endif /* CONFIG_BOOTP_DHCP_REQUEST_DELAY */ + debug(Transmitting DHCPREQUEST packet: len = %d\n, pktlen); Did you move this on purpose? Yes... I figured a transmit debug message should be close to the transmit... not before a delay. NetSendPacket(NetTxPacket, pktlen); } Best regards, -Joe ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot