Re: [U-Boot] [PATCH v3 1/3] EXYNOS: EXYNOS4X12: Populate Exynos4x12 register addresses
On 26/12/12 15:13, Minkyu Kang wrote: > From: Chander Kashyap > > This patch populates base addresses of Exynos4x12 registers. > > Signed-off-by: Chander Kashyap > Signed-off-by: Minkyu Kang > --- > Changes since v2: > - rebased, add SPI and I2S addresses. > > arch/arm/include/asm/arch-exynos/cpu.h | 48 > > 1 file changed, 42 insertions(+), 6 deletions(-) > applied to u-boot-samsung/master. Thanks, Minkyu Kang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 2/3] EXYNOS: EXYNOS4X12: Add clock structure for EXYNOS4X12
On 26/12/12 15:13, Minkyu Kang wrote: > From: Chander Kashyap > > This patch adds clock structure for Exynos4x12. > > Signed-off-by: Chander Kashyap > Signed-off-by: Minkyu Kang > --- > Changes since v2: > - None > > arch/arm/include/asm/arch-exynos/clock.h | 276 > ++ > 1 file changed, 276 insertions(+) > applied to u-boot-samsung/master. Thanks, Minkyu Kang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 3/3] EXYNOS: EXYNOS4X12: Add gpio structure for EXYNOS4X12
On 26/12/12 15:13, Minkyu Kang wrote: > From: Chander Kashyap > > This patch adds gpio structure for Exynos4x12. > > Signed-off-by: Chander Kashyap > Signed-off-by: Minkyu Kang > --- > Changes since v2: > - None > > arch/arm/include/asm/arch-exynos/gpio.h | 85 > +++ > 1 file changed, 85 insertions(+) > applied to u-boot-samsung/master. Thanks, Minkyu Kang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 0/5 v3] Add DT based ethernet driver for SMDK5250
On 11/12/12 19:52, Hatim Ali wrote: > This patch series enables the DT support on SMDK5250. > Ethernet is the first driver whose discovery is based on DT node. > More DT based drivers to be added subsequently > > Changes since v1: > - Renamed the smdk5250.h file to exynos5250-dt.h to create a common > configuration file which can be used by all the boards based on > exynos5250 using Device Tree. > - Created a new smdk5250.h file specifying the dts file specific to > SMDK5250 > - Incorporated minor nit (removal of blank lines) > Changes since v2: > - Rebased the "Add DT node definition for SROM and SMSC9215" patch on > u-boot-samsung.git > > Hatim Ali (5): > EXYNOS5: FDT: add initial dts file for EXYNOS5250, SMDK5250 > fdt: exynos5: Add DT node definition for SROM and SMSC9215 > exynos5: Add DT based driver for SMC911X ethernet > exynos5: config: Rename the smdk5250.h to exynos5250-dt.h > SMDK5250: config: Add configuration file for SMDK5250 board > > arch/arm/dts/exynos5250.dtsi | 31 > arch/arm/include/asm/arch-exynos/sromc.h | 18 ++ > board/samsung/dts/exynos5250-smdk5250.dts | 29 +++ > board/samsung/smdk5250/smdk5250.c | 115 + > include/configs/exynos5250-dt.h | 267 > + > include/configs/smdk5250.h| 245 +- > include/fdtdec.h |2 + > lib/fdtdec.c |2 + > 8 files changed, 442 insertions(+), 267 deletions(-) > create mode 100644 arch/arm/dts/exynos5250.dtsi > create mode 100644 board/samsung/dts/exynos5250-smdk5250.dts > create mode 100644 include/configs/exynos5250-dt.h > applied to u-boot-samsung/master. Thanks, Minkyu Kang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] mx35pdk: Allow booting of a device tree kernel
On 25/12/2012 21:20, Fabio Estevam wrote: > From: Fabio Estevam > > Select CONFIG_OF_LIBFDT, so that a dt kernel can be launched. > > Signed-off-by: Fabio Estevam > --- Applied to u-boot-imx, thanks. 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/9] mx28evk: We shouldn't hardcode a rootfs filesystem type
On 21/12/2012 17:59, Otavio Salvador wrote: > For a generic environment, we shouldn't have a fixed rootfs filesystem > so we drop it from env. > > Signed-off-by: Otavio Salvador > --- Hi Otavio, > include/configs/mx28evk.h |7 ++- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h > index 8b89b25..3cc0726 100644 > --- a/include/configs/mx28evk.h > +++ b/include/configs/mx28evk.h > @@ -292,11 +292,8 @@ > "console_mainline=ttyAMA0\0" \ > "mmcdev=0\0" \ > "mmcpart=2\0" \ > - "mmcroot=/dev/mmcblk0p3 rw\0" \ > - "mmcrootfstype=ext3 rootwait\0" \ > - "mmcargs=setenv bootargs console=${console_mainline},${baudrate} " \ > - "root=${mmcroot} " \ > - "rootfstype=${mmcrootfstype}\0" \ > + "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \ > + "mmcargs=setenv bootargs console=${console_mainline},${baudrate} > root=${mmcroot}\0" \ > "loadbootscript=" \ > "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ > "bootscript=echo Running bootscript from mmc ...; " \ > WARNING: line over 80 characters #37: FILE: include/configs/mx28evk.h:296: + "mmcargs=setenv bootargs console=${console_mainline},${baudrate} root=${mmcroot}\0" \ total: 0 errors, 1 warnings, 13 lines checked Can you fix it ? Regards, Stefano -- = DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/9] mx53loco: We shouldn't hardcode a rootfs filesystem type
On 21/12/2012 17:59, Otavio Salvador wrote: > For a generic environment, we shouldn't have a fixed rootfs filesystem > so we drop it from env. > > Signed-off-by: Otavio Salvador > --- Applied to u-boot-imx, thanks. 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/9] mx53loco: Change default loadaddr to 0x72000000
On 21/12/2012 17:59, Otavio Salvador wrote: > This allow use of mainline and Freescale BSP Linux kernel with same > environment. > > Signed-off-by: Otavio Salvador > --- Applied to u-boot-imx, thanks. 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 4/9] mx6qsabrelite: Change default loadaddr to 0x12000000
On 21/12/2012 17:59, Otavio Salvador wrote: > This allow use of mainline and Freescale BSP Linux kernel with same > environment. > > Signed-off-by: Otavio Salvador > --- Applied to u-boot-imx, thanks. 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 5/9] mx6qsabre_common: Change default loadaddr to 0x12000000
On 21/12/2012 17:59, Otavio Salvador wrote: > This allow use of mainline and Freescale BSP Linux kernel with same > environment. > > Signed-off-by: Otavio Salvador > --- Applied to u-boot-imx, thanks. 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 6/9] mx28evk: Add support to dynamically choose between ftd use or not
On 21/12/2012 17:59, Otavio Salvador wrote: > Signed-off-by: Otavio Salvador > --- Hi Otavio, > include/configs/mx28evk.h | 15 +-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h > index 3cc0726..5c1c052 100644 > --- a/include/configs/mx28evk.h > +++ b/include/configs/mx28evk.h > @@ -290,6 +290,8 @@ > "uimage=uImage\0" \ > "console_fsl=ttyAM0\0" \ > "console_mainline=ttyAMA0\0" \ > + "ftd_file=imx28-evk.dtb\0" \ > + "ftd_addr=0x4100\0" \ > "mmcdev=0\0" \ > "mmcpart=2\0" \ > "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \ > @@ -301,13 +303,22 @@ > "loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \ > "mmcboot=echo Booting from mmc ...; " \ > "run mmcargs; " \ > - "bootm\0" \ > + "if fatload mmc ${mmcdev}:${mmcpart} ${ftd_addr} ${ftd_file}; > then " \ > + "bootm ${loadaddr} - ${ftd_addr}; " \ > + "else " \ > + "bootm; " \ > + "fi;\0" \ > "netargs=setenv bootargs console=${console_mainline},${baudrate} " \ > "root=/dev/nfs " \ > "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \ > "netboot=echo Booting from net ...; " \ > "run netargs; " \ > - "dhcp ${uimage}; bootm\0" > + "dhcp ${uimage}; " \ > + "if dhcp ${ftd_addr} ${ftd_file}; then " \ > + "bootm ${loadaddr} - ${ftd_addr}; " \ > + "else " \ > + "bootm; " \ > + "fi;\0" > > #define CONFIG_BOOTCOMMAND \ > "mmc dev ${mmcdev}; if mmc rescan; then " \ > Please fix the following warning reported by checkpatch: WARNING: line over 80 characters #39: FILE: include/configs/mx28evk.h:306: + "if fatload mmc ${mmcdev}:${mmcpart} ${ftd_addr} ${ftd_file}; then " \ total: 0 errors, 1 warnings, 32 lines checked 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 7/9] mx53loco: Add support to dynamically choose between ftd use or not
On 21/12/2012 17:59, Otavio Salvador wrote: > Signed-off-by: Otavio Salvador > --- > include/configs/mx53loco.h | 15 +-- > 1 file changed, 13 insertions(+), 2 deletions(-) > Hi Otavio, > diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h > index 4cfdc0b..505957c 100644 > --- a/include/configs/mx53loco.h > +++ b/include/configs/mx53loco.h > @@ -118,6 +118,8 @@ > #define CONFIG_EXTRA_ENV_SETTINGS \ > "script=boot.scr\0" \ > "uimage=uImage\0" \ > + "ftd_file=imx53-qsb.dtb\0" \ > + "ftd_addr=0x7100\0" \ > "mmcdev=0\0" \ > "mmcpart=2\0" \ > "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \ > @@ -129,13 +131,22 @@ > "loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \ > "mmcboot=echo Booting from mmc ...; " \ > "run mmcargs; " \ > - "bootm\0" \ > + "if fatload mmc ${mmcdev}:${mmcpart} ${ftd_addr} ${ftd_file}; > then " \ > + "bootm ${loadaddr} - ${ftd_addr}; " \ > + "else " \ > + "bootm; " \ > + "fi;\0" \ > "netargs=setenv bootargs console=ttymxc0,${baudrate} " \ > "root=/dev/nfs " \ > "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \ > "netboot=echo Booting from net ...; " \ > "run netargs; " \ > - "dhcp ${uimage}; bootm\0" \ > + "dhcp ${uimage}; " \ > + "if dhcp ${ftd_addr} ${ftd_file}; then " \ > + "bootm ${loadaddr} - ${ftd_addr}; " \ > + "else " \ > + "bootm; " \ > + "fi;\0" > Only to remark that this is the correct behavior. The kernel with fdt is booted independently if this is wanted or not, but if the fdt file is loaded successfully from MMC or network. This can have some drawback effects if, for example, the fdt is simply stored on the TFTP server, but we want to boot a kernel without DT. For example, when someone wants to test both kernels or there are multiple instances of the same board type (mx53loco in this case) loading from the same TFTP server. In your patch, the behavior depends if the fdt is simply present on the media, but this does not always mean that the file must be loaded. Should be not better to set variable as flag to force the desired behavior and to be sure that the system does not boot in a different way as the user thinks ? In other words, something like : "if boot_fdt; then " \ "if dhcp ${ftd_addr} ${ftd_file}; then " \ "bootm ${loadaddr} - ${ftd_addr}; " \ "else " \ "echo Error: I cannot boot a DT kernel; \" "fi; \" " else bootm; fi;\0" 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-53 Fax: +49-8142-66989-80 Email: sba...@denx.de = ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/3] EXYNOS: EXYNOS4X12: Populate Exynos4x12 register addresses
Thanks for applying. On 26 December 2012 15:37, Minkyu Kang wrote: > On 26/12/12 15:13, Minkyu Kang wrote: >> From: Chander Kashyap >> >> This patch populates base addresses of Exynos4x12 registers. >> >> Signed-off-by: Chander Kashyap >> Signed-off-by: Minkyu Kang >> --- >> Changes since v2: >> - rebased, add SPI and I2S addresses. >> >> arch/arm/include/asm/arch-exynos/cpu.h | 48 >> >> 1 file changed, 42 insertions(+), 6 deletions(-) >> > > applied to u-boot-samsung/master. > > Thanks, > Minkyu Kang. -- with warm regards, Chander Kashyap ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/1] omap4: use plain text env file instead boot scripts
Dear Javier, In message you wrote: > > I think this change makes sense not only to be consistent with the > OMAP3 Beagle board boot sequence but also to make it easier for > developers to modify U-Boot environment variables. I wasn't aware that Beagle implemented such a change (otherwise I woul dhave raised my concernes then). > But yes, it's not hard to execute mkimage -T script too, so is your call :-) I don't intend to block any such changes. I just wanted to make sure everybody involved is aware of the consequences. [I would not have added the text file import mode if I did not consider it useful :-) ] So if you consider this a useful change, please feel free and go ahead. It is fine with me. 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 "You ain't experienced..." "Well, nor are you." "That's true. But the point is ... the point is ... the point is we've been not experienced for a lot longer than you. We've got a lot of experience of not having any experience." - Terry Pratchett, _Witches Abroad_ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/1] omap4: use plain text env file instead boot scripts
On Wed, Dec 26, 2012 at 12:40 PM, Wolfgang Denk wrote: > Dear Javier, > Hello Wolfgang, > In message > you > wrote: >> >> I think this change makes sense not only to be consistent with the >> OMAP3 Beagle board boot sequence but also to make it easier for >> developers to modify U-Boot environment variables. > > I wasn't aware that Beagle implemented such a change (otherwise I > woul dhave raised my concernes then). > The change was introduced on commit "cf073e4 omap3_beagle: enable the use of a plain text file" >> But yes, it's not hard to execute mkimage -T script too, so is your call :-) > > I don't intend to block any such changes. I just wanted to make sure > everybody involved is aware of the consequences. [I would not have > added the text file import mode if I did not consider it useful :-) ] > Indeed :-) > So if you consider this a useful change, please feel free and go > ahead. It is fine with me. > Yes, since this is a development board used primary by developers I think the change is useful. But thanks a lot for raising your concerns and explaining the consequences. > Best regards, > > Wolfgang Denk > Best regards, Javier ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/16] EXYNOS5: FDT : Decode peripheral id
Dear Rajeshwari Shinde, On 14/12/12 20:56, Rajeshwari Shinde wrote: > Api is added to decode peripheral id based on the interrupt number > of the peripheral. > > Signed-off-by: Rajeshwari Shinde > Acked-by; Simon Glass > --- > Changes in V1: > -Rebased on latest u-boot-samsung > arch/arm/cpu/armv7/exynos/pinmux.c| 28 ++ > arch/arm/include/asm/arch-exynos/periph.h | 31 > arch/arm/include/asm/arch-exynos/pinmux.h |8 +++ > 3 files changed, 54 insertions(+), 13 deletions(-) > > diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c > b/arch/arm/cpu/armv7/exynos/pinmux.c > index f02f441..f9f6911 100644 > --- a/arch/arm/cpu/armv7/exynos/pinmux.c > +++ b/arch/arm/cpu/armv7/exynos/pinmux.c > @@ -22,6 +22,7 @@ > */ > > #include > +#include > #include > #include > #include > @@ -396,3 +397,30 @@ int exynos_pinmux_config(int peripheral, int flags) > return -1; > } > } > + > +#ifdef CONFIG_OF_CONTROL > +static int exynos5_pinmux_decode_periph_id(const void *blob, int node) > +{ > + int err; > + u32 cell[3]; > + > + err = fdtdec_get_int_array(blob, node, "interrupts", cell, > + ARRAY_SIZE(cell)); > + if (err) > + return PERIPH_ID_NONE; > + > + if ((131 > cell[1]) || (cell[1] < 31)) What means 131 and 31? > + return cell[1]; > + > + debug(" invalid peripheral id\n"); > + return PERIPH_ID_NONE; > +} > + > +int pinmux_decode_periph_id(const void *blob, int node) > +{ > + if (cpu_is_exynos5()) > + return exynos5_pinmux_decode_periph_id(blob, node); > + else > + return PERIPH_ID_NONE; > +} > +#endif > diff --git a/arch/arm/include/asm/arch-exynos/periph.h > b/arch/arm/include/asm/arch-exynos/periph.h > index 13abd2d..783b77c 100644 > --- a/arch/arm/include/asm/arch-exynos/periph.h > +++ b/arch/arm/include/asm/arch-exynos/periph.h > @@ -25,12 +25,17 @@ > #define __ASM_ARM_ARCH_PERIPH_H > > /* > - * Peripherals requiring clock/pinmux configuration. List will > + * Peripherals requiring pinmux configuration0. List will configuration0? > * grow with support for more devices getting added. > + * Numbering based on interrupt table. > * > */ > enum periph_id { > - PERIPH_ID_I2C0, > + PERIPH_ID_UART0 = 51, > + PERIPH_ID_UART1, > + PERIPH_ID_UART2, > + PERIPH_ID_UART3, > + PERIPH_ID_I2C0 = 56, > PERIPH_ID_I2C1, > PERIPH_ID_I2C2, > PERIPH_ID_I2C3, > @@ -38,22 +43,22 @@ enum periph_id { > PERIPH_ID_I2C5, > PERIPH_ID_I2C6, > PERIPH_ID_I2C7, > - PERIPH_ID_I2S1, > - PERIPH_ID_SDMMC0, > + PERIPH_ID_SPI0 = 68, > + PERIPH_ID_SPI1, > + PERIPH_ID_SPI2, > + PERIPH_ID_SDMMC0 = 75, > PERIPH_ID_SDMMC1, > PERIPH_ID_SDMMC2, > PERIPH_ID_SDMMC3, > - PERIPH_ID_SDMMC4, > - PERIPH_ID_SROMC, > - PERIPH_ID_SPI0, > - PERIPH_ID_SPI1, > - PERIPH_ID_SPI2, > + PERIPH_ID_I2S1 = 99, > + > +/* Since following peripherals do not have shared peripheral interrupts > (SPIs) Please check multi line comment rule. > + * they are numbered arbitiraly after the maximum SPIs Exynos has (128) > + */ > + PERIPH_ID_SROMC = 128, > PERIPH_ID_SPI3, > PERIPH_ID_SPI4, > - PERIPH_ID_UART0, > - PERIPH_ID_UART1, > - PERIPH_ID_UART2, > - PERIPH_ID_UART3, > + PERIPH_ID_SDMMC4, > > PERIPH_ID_COUNT, > PERIPH_ID_NONE = -1, > diff --git a/arch/arm/include/asm/arch-exynos/pinmux.h > b/arch/arm/include/asm/arch-exynos/pinmux.h > index 10ea736..00cbb0d 100644 > --- a/arch/arm/include/asm/arch-exynos/pinmux.h > +++ b/arch/arm/include/asm/arch-exynos/pinmux.h > @@ -55,4 +55,12 @@ enum { > */ > int exynos_pinmux_config(int peripheral, int flags); > > +/** please remove "*". > + * Decode the peripheral id using the interrpt numbers. > + * > + * @param blob Device tree blbo > + * @param node FDT I2C node to find > + * @return peripheral id if ok, PERIPH_ID_NONE on error > + */ > +int pinmux_decode_periph_id(const void *blob, int node); > #endif > -- Thanks, Minkyu Kang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 05/16] I2C: Driver changes for FDT support
Dear Rajeshwari Shinde, On 14/12/12 20:56, Rajeshwari Shinde wrote: > Functions added to get the I2C bus number and reset I2C bus using > FDT node. > > Signed-off-by: Rajeshwari Shinde > Acked-by: Simon Glass > Acked-by: Heiko Schocher > --- > Changes in V1: > -Rebased on latest u-boot-samsung > drivers/i2c/s3c24x0_i2c.c | 83 > - > drivers/i2c/s3c24x0_i2c.h |8 > include/i2c.h | 26 ++ > 3 files changed, 116 insertions(+), 1 deletions(-) > > diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c > index 9bc4c7f..94a093e 100644 > --- a/drivers/i2c/s3c24x0_i2c.c > +++ b/drivers/i2c/s3c24x0_i2c.c > @@ -27,9 +27,11 @@ > */ > > #include > +#include > #ifdef CONFIG_EXYNOS5 > #include > #include > +#include > #else > #include > #endif > @@ -60,7 +62,14 @@ > #define I2C_TIMEOUT 1/* 1 second */ > > > -static unsigned int g_current_bus; /* Stores Current I2C Bus */ > +/* > + * For SPL boot some boards need i2c before SDRAM is initialised so force > + * variables to live in SRAM > + */ > +static unsigned int g_current_bus __attribute__((section(".data"))); > +static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM] > + __attribute__((section(".data"))); > +static int i2c_busses __attribute__((section(".data"))); > > #ifndef CONFIG_EXYNOS5 > static int GetI2CSDA(void) > @@ -507,4 +516,76 @@ int i2c_write(uchar chip, uint addr, int alen, uchar > *buffer, int len) > (i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer, >len) != 0); > } > + > +#ifdef CONFIG_OF_CONTROL > +void board_i2c_init(const void *blob) > +{ > + please remove this blank line. > + int node_list[CONFIG_MAX_I2C_NUM]; > + int count, i; > + > + count = fdtdec_find_aliases_for_id(blob, "i2c", > + COMPAT_SAMSUNG_S3C2440_I2C, node_list, > + CONFIG_MAX_I2C_NUM); need blank line here. > + for (i = 0; i < count; i++) { > + struct s3c24x0_i2c_bus *bus; > + int node = node_list[i]; How handle if the value of count is bigger than CONFIG_MAX_I2C_NUM? > + > + if (node <= 0) > + continue; > + bus = &i2c_bus[i]; > + bus->regs = (struct s3c24x0_i2c *) > + fdtdec_get_addr(blob, node, "reg"); > + bus->id = pinmux_decode_periph_id(blob, node); > + bus->node = node; > + bus->bus_num = i2c_busses++; > + exynos_pinmux_config(bus->id, 0); > + } > + please remove this blank line. > +} > + > +static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx) > +{ > + if (bus_idx < i2c_busses) > + return &i2c_bus[bus_idx]; need blank line here. > + debug("Undefined bus: %d\n", bus_idx); > + return NULL; > +} > + > +int i2c_get_bus_num_fdt(int node) > +{ > + int i; > + > + for (i = 0; i < i2c_busses; i++) { > + if (node == i2c_bus[i].node) > + return i; > + } > + > + debug("%s: Can't find any matched I2C bus\n", __func__); > + return -1; > +} > + > +int i2c_reset_port_fdt(const void *blob, int node) > +{ > + struct s3c24x0_i2c_bus *i2c; > + Please remove this blank line. > + int bus; > + > + bus = i2c_get_bus_num_fdt(node); > + if (bus < 0) { > + debug("could not get bus for node %d\n", node); > + return -1; > + } need blank line here. > + i2c = get_bus(bus); > + if (!i2c) { > + debug("get_bus() failed for node node %d\n", node); > + return -1; > + } > + > + i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); > + > + return 0; > +} > +#endif > + > #endif /* CONFIG_HARD_I2C */ > diff --git a/drivers/i2c/s3c24x0_i2c.h b/drivers/i2c/s3c24x0_i2c.h > index 2dd4b06..1243bf1 100644 > --- a/drivers/i2c/s3c24x0_i2c.h > +++ b/drivers/i2c/s3c24x0_i2c.h > @@ -30,4 +30,12 @@ struct s3c24x0_i2c { > u32 iicds; > u32 iiclc; > }; > + > +struct s3c24x0_i2c_bus { > + int node; /* device tree node */ > + int bus_num;/* i2c bus number */ > + struct s3c24x0_i2c *regs; > + enum periph_id id; > +}; > + > #endif /* _S3C24X0_I2C_H */ > diff --git a/include/i2c.h b/include/i2c.h > index 16f099d..c60d075 100644 > --- a/include/i2c.h > +++ b/include/i2c.h > @@ -262,4 +262,30 @@ extern int get_multi_scl_pin(void); > extern int get_multi_sda_pin(void); > extern int multi_i2c_init(void); > #endif > + > +/** > + * Get FDT values for i2c bus. > + * > + * @param blob Device tree blbo > + * @return the number of I2C bus > + */ > +void board_i2c_init(const void *blob); > + > +/** > + * Find the I2C bus number by given a FDT I2C node. > + * > + * @param blob Device tree blbo > + * @param node FDT I2C node to find > + * @return the number of I2C bus (zero based), or -1 on error > + *
Re: [U-Boot] [PATCH 16/16] SPI: EXYNOS: Add FDT support to driver.
Dear Rajeshwari Shinde, On 14/12/12 20:56, Rajeshwari Shinde wrote: > This patch adds FDT support to the SPI driver. > > Signed-off-by: Simon Glass > Signed-off-by: Rajeshwari Shinde > Acked-by: Simon Glass > --- > Changes in V1: > -Rebased on latest u-boot-samsung > drivers/spi/exynos_spi.c | 96 > +++--- > 1 files changed, 90 insertions(+), 6 deletions(-) > > diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c > index 3e6c18f..7ecc566 100644 > --- a/drivers/spi/exynos_spi.c > +++ b/drivers/spi/exynos_spi.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -28,16 +29,20 @@ > #include > #include > > +DECLARE_GLOBAL_DATA_PTR; > + > /* Information about each SPI controller */ > struct spi_bus { > enum periph_id periph_id; > s32 frequency; /* Default clock frequency, -1 for none */ > struct exynos_spi *regs; > int inited; /* 1 if this bus is ready for use */ > + int node; > }; > > /* A list of spi buses that we know about */ > static struct spi_bus spi_bus[EXYNOS5_SPI_NUM_CONTROLLERS]; > +static unsigned int bus_count; > > struct exynos_spi_slave { > struct spi_slave slave; > @@ -50,7 +55,7 @@ struct exynos_spi_slave { > > static struct spi_bus *spi_get_bus(unsigned dev_index) > { > - if (dev_index < EXYNOS5_SPI_NUM_CONTROLLERS) > + if (dev_index < bus_count) > return &spi_bus[dev_index]; > debug("%s: invalid bus %d", __func__, dev_index); > > @@ -347,21 +352,100 @@ static inline struct exynos_spi *get_spi_base(int > dev_index) > (dev_index - 3); > } > > +/* > + * Read the SPI config from the device tree node. > + * > + * @param blob FDT blob to read from > + * @param node Node offset to read from > + * @param bus SPI bus structure to fill with information > + * @return 0 if ok, or -FDT_ERR_NOTFOUND if something was missing > + */ > +static int spi_get_config(const void *blob, int node, struct spi_bus *bus) > +{ > + bus->node = node; > + bus->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, "reg"); > + bus->periph_id = pinmux_decode_periph_id(blob, node); Please add blank line here. > + if (bus->periph_id == PERIPH_ID_NONE) { > + debug("%s: Invalid peripheral ID %d\n", __func__, > + bus->periph_id); > + return -FDT_ERR_NOTFOUND; > + } > + > + /* Use 500KHz as a suitable default */ > + bus->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", > + 50); > + > + return 0; > +} > + Please remove this blank line. > + > +/* > + * Process a list of nodes, adding them to our list of SPI ports. > + * > + * @param blob fdt blob > + * @param node_list list of nodes to process (any <=0 are ignored) > + * @param count number of nodes to process > + * @param is_dvc1 if these are DVC ports, 0 if standard I2C > + * @return 0 if ok, -1 on error > + */ > +static int process_nodes(const void *blob, int node_list[], int count) > +{ > + int i; > + > + /* build the i2c_controllers[] for each controller */ > + for (i = 0; i < count; i++) { > + int node = node_list[i]; > + struct spi_bus *bus; > + > + if (node <= 0) > + continue; > + > + bus = &spi_bus[i]; > + if (spi_get_config(blob, node, bus)) { > + printf("exynos spi_init: failed to decode bus %d\n", > + i); > + return -1; > + } > + > + debug("spi: controller bus %d at %p, periph_id %d\n", > + i, bus->regs, bus->periph_id); > + bus->inited = 1; > + bus_count++; > + } > + > + return 0; > +} > + > /* Sadly there is no error return from this function */ > void spi_init(void) > { > - int i; > + int count; > + > +#ifdef CONFIG_OF_CONTROL > + int node_list[EXYNOS5_SPI_NUM_CONTROLLERS]; > + const void *blob = gd->fdt_blob; > + > + count = fdtdec_find_aliases_for_id(blob, "spi", > + COMPAT_SAMSUNG_EXYNOS_SPI, node_list, > + EXYNOS5_SPI_NUM_CONTROLLERS); > + if (process_nodes(blob, node_list, count)) > + return; > + > +#else > struct spi_bus *bus; > > - for (i = 0; i < EXYNOS5_SPI_NUM_CONTROLLERS; i++) { > - bus = &spi_bus[i]; > - bus->regs = get_spi_base(i); > - bus->periph_id = PERIPH_ID_SPI0 + i; > + for (count = 0; i < EXYNOS5_SPI_NUM_CONTROLLERS; i++) { i or count? Is it typo? > + bus = &spi_bus[count]; > + bus->regs = get_spi_base(count); > + bus->periph_id = PERIPH_ID_SPI0 + count; > > /* Although Exynos5 supports upto 50Mhz speed
Re: [U-Boot] [PATCH 11/16] Sound: WM8994: Add FDT support to codec
Dear Rajeshwari Shinde, On 14/12/12 20:56, Rajeshwari Shinde wrote: > This patch adds FDT support to the codec. > > Signed-off-by: Rajeshwari Shinde > Acked-by: Simon Glass > --- > Changes in V1: > -Rebased on latest u-boot-samsung > drivers/sound/wm8994.c | 76 ++- > drivers/sound/wm8994.h |6 +-- > 2 files changed, 76 insertions(+), 6 deletions(-) > > diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c > index 293903a..a528502 100644 > --- a/drivers/sound/wm8994.c > +++ b/drivers/sound/wm8994.c > @@ -26,9 +26,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > #include "wm8994.h" > #include "wm8994_registers.h" > > @@ -77,6 +79,7 @@ static int bclk_divs[] = { > > static struct wm8994_priv g_wm8994_info; > static unsigned char g_wm8994_i2c_dev_addr; > +static struct sound_codec_info g_codec_info; > > /* > * Initialise I2C for wm 8994 > @@ -747,13 +750,82 @@ err: > return -1; > } > > +/* > + * Gets fdt values for wm8994 config parameters > + * > + * @param pcodec_infocodec information structure > + * @param blob FDT blob > + * @return int value, 0 for success > + */ > +static int get_codec_values(struct sound_codec_info *pcodec_info, > + const void *blob) > +{ > + int error = 0; > +#ifdef CONFIG_OF_CONTROL > + enum fdt_compat_id compat; > + int node; > + int parent; > + > + /* Get the node from FDT for codec */ > + node = fdtdec_next_compatible(blob, 0, COMPAT_WOLFSON_WM8994_CODEC); > + if (node <= 0) { > + debug("EXYNOS_SOUND: No node for codec in device tree\n"); > + debug("node = %d\n", node); > + return -1; > + } > + > + parent = fdt_parent_offset(blob, node); > + if (parent < 0) { > + debug("%s: Cannot find node parent\n", __func__); > + return -1; > + } > + > + compat = fdtdec_lookup(blob, parent); > + switch (compat) { > + case COMPAT_SAMSUNG_S3C2440_I2C: > + pcodec_info->i2c_bus = i2c_get_bus_num_fdt(parent); > + error |= pcodec_info->i2c_bus; > + debug("i2c bus = %d\n", pcodec_info->i2c_bus); > + pcodec_info->i2c_dev_addr = fdtdec_get_int(blob, node, > + "reg", 0); > + error |= pcodec_info->i2c_dev_addr; > + debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr); > + break; > + default: > + debug("%s: Unknown compat id %d\n", __func__, compat); > + return -1; > + } > +#else > + pcodec_info->i2c_bus = AUDIO_I2C_BUS; > + pcodec_info->i2c_dev_addr = AUDIO_I2C_REG; > + debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr); > +#endif > + > + pcodec_info->codec_type = CODEC_WM_8994; > + > + if (error == -1) { > + debug("fail to get wm8994 codec node properties\n"); > + return -1; > + } > + > + return 0; please remove this blank line. > + > +} > + please remove this blank line. > + > /*wm8994 Device Initialisation */ > -int wm8994_init(struct sound_codec_info *pcodec_info, > - enum en_audio_interface aif_id, > +int wm8994_init(const void *blob, enum en_audio_interface aif_id, > int sampling_rate, int mclk_freq, > int bits_per_sample, unsigned int channels) > { > int ret = 0; > + struct sound_codec_info *pcodec_info = &g_codec_info; > + > + /* Get the codec Values */ > + if (get_codec_values(pcodec_info, blob) < 0) { > + debug("FDT Codec values failed\n"); > + return -1; > + } > > /* shift the device address by 1 for 7 bit addressing */ > g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr; > diff --git a/drivers/sound/wm8994.h b/drivers/sound/wm8994.h > index a8f0de1..a1e8335 100644 > --- a/drivers/sound/wm8994.h > +++ b/drivers/sound/wm8994.h > @@ -69,8 +69,7 @@ enum wm8994_type { > /* > * intialise wm8994 sound codec device for the given configuration > * > - * @param pcodec_infopointer value of the sound codec info > structure > - * parsed from device tree > + * @param blob FDT node for codec values > * @param aif_id enum value of codec interface port in which > * soc i2s is connected > * @param sampling_rate Sampling rate ranges between from 8khz > to 96khz > @@ -80,8 +79,7 @@ enum wm8994_type { > * > * @returns -1 for error and 0 Success. > */ > -int wm8994_init(struct sound_codec_info *pcodec_info, > - enum en_audio_interface aif_id, > +int wm8994_init(const void *blob, enum en_audio_interface aif_id, > int sampling_rate, int mclk_freq, > int
Re: [U-Boot] [PATCH 11/16] Sound: WM8994: Add FDT support to codec
Hi Minkyu Kang, Thank you for comments.Will correct them On Wed, Dec 26, 2012 at 5:25 PM, Minkyu Kang wrote: > Dear Rajeshwari Shinde, > > On 14/12/12 20:56, Rajeshwari Shinde wrote: > > This patch adds FDT support to the codec. > > > > Signed-off-by: Rajeshwari Shinde > > Acked-by: Simon Glass > > --- > > Changes in V1: > > -Rebased on latest u-boot-samsung > > drivers/sound/wm8994.c | 76 > ++- > > drivers/sound/wm8994.h |6 +-- > > 2 files changed, 76 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/sound/wm8994.c b/drivers/sound/wm8994.c > > index 293903a..a528502 100644 > > --- a/drivers/sound/wm8994.c > > +++ b/drivers/sound/wm8994.c > > @@ -26,9 +26,11 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > +#include > > #include "wm8994.h" > > #include "wm8994_registers.h" > > > > @@ -77,6 +79,7 @@ static int bclk_divs[] = { > > > > static struct wm8994_priv g_wm8994_info; > > static unsigned char g_wm8994_i2c_dev_addr; > > +static struct sound_codec_info g_codec_info; > > > > /* > > * Initialise I2C for wm 8994 > > @@ -747,13 +750,82 @@ err: > > return -1; > > } > > > > +/* > > + * Gets fdt values for wm8994 config parameters > > + * > > + * @param pcodec_infocodec information structure > > + * @param blob FDT blob > > + * @return int value, 0 for success > > + */ > > +static int get_codec_values(struct sound_codec_info *pcodec_info, > > + const void *blob) > > +{ > > + int error = 0; > > +#ifdef CONFIG_OF_CONTROL > > + enum fdt_compat_id compat; > > + int node; > > + int parent; > > + > > + /* Get the node from FDT for codec */ > > + node = fdtdec_next_compatible(blob, 0, > COMPAT_WOLFSON_WM8994_CODEC); > > + if (node <= 0) { > > + debug("EXYNOS_SOUND: No node for codec in device tree\n"); > > + debug("node = %d\n", node); > > + return -1; > > + } > > + > > + parent = fdt_parent_offset(blob, node); > > + if (parent < 0) { > > + debug("%s: Cannot find node parent\n", __func__); > > + return -1; > > + } > > + > > + compat = fdtdec_lookup(blob, parent); > > + switch (compat) { > > + case COMPAT_SAMSUNG_S3C2440_I2C: > > + pcodec_info->i2c_bus = i2c_get_bus_num_fdt(parent); > > + error |= pcodec_info->i2c_bus; > > + debug("i2c bus = %d\n", pcodec_info->i2c_bus); > > + pcodec_info->i2c_dev_addr = fdtdec_get_int(blob, node, > > + "reg", 0); > > + error |= pcodec_info->i2c_dev_addr; > > + debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr); > > + break; > > + default: > > + debug("%s: Unknown compat id %d\n", __func__, compat); > > + return -1; > > + } > > +#else > > + pcodec_info->i2c_bus = AUDIO_I2C_BUS; > > + pcodec_info->i2c_dev_addr = AUDIO_I2C_REG; > > + debug("i2c dev addr = %d\n", pcodec_info->i2c_dev_addr); > > +#endif > > + > > + pcodec_info->codec_type = CODEC_WM_8994; > > + > > + if (error == -1) { > > + debug("fail to get wm8994 codec node properties\n"); > > + return -1; > > + } > > + > > + return 0; > > please remove this blank line. > > > + > > +} > > + > > please remove this blank line. > > > + > > /*wm8994 Device Initialisation */ > > -int wm8994_init(struct sound_codec_info *pcodec_info, > > - enum en_audio_interface aif_id, > > +int wm8994_init(const void *blob, enum en_audio_interface aif_id, > > int sampling_rate, int mclk_freq, > > int bits_per_sample, unsigned int channels) > > { > > int ret = 0; > > + struct sound_codec_info *pcodec_info = &g_codec_info; > > + > > + /* Get the codec Values */ > > + if (get_codec_values(pcodec_info, blob) < 0) { > > + debug("FDT Codec values failed\n"); > > + return -1; > > + } > > > > /* shift the device address by 1 for 7 bit addressing */ > > g_wm8994_i2c_dev_addr = pcodec_info->i2c_dev_addr; > > diff --git a/drivers/sound/wm8994.h b/drivers/sound/wm8994.h > > index a8f0de1..a1e8335 100644 > > --- a/drivers/sound/wm8994.h > > +++ b/drivers/sound/wm8994.h > > @@ -69,8 +69,7 @@ enum wm8994_type { > > /* > > * intialise wm8994 sound codec device for the given configuration > > * > > - * @param pcodec_infopointer value of the sound codec > info structure > > - * parsed from device tree > > + * @param blob FDT node for codec values > > * @param aif_id enum value of codec interface port in which > > * soc i2s is connected > > * @param sampling_rate Sampling rate ranges between fr
Re: [U-Boot] [PATCH 04/16] EXYNOS5: FDT : Decode peripheral id
Hi Minkyu Kang, Thank you for comments On Wed, Dec 26, 2012 at 5:24 PM, Minkyu Kang wrote: > Dear Rajeshwari Shinde, > > On 14/12/12 20:56, Rajeshwari Shinde wrote: > > Api is added to decode peripheral id based on the interrupt number > > of the peripheral. > > > > Signed-off-by: Rajeshwari Shinde > > Acked-by; Simon Glass > > --- > > Changes in V1: > > -Rebased on latest u-boot-samsung > > arch/arm/cpu/armv7/exynos/pinmux.c| 28 > ++ > > arch/arm/include/asm/arch-exynos/periph.h | 31 > > > arch/arm/include/asm/arch-exynos/pinmux.h |8 +++ > > 3 files changed, 54 insertions(+), 13 deletions(-) > > > > diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c > b/arch/arm/cpu/armv7/exynos/pinmux.c > > index f02f441..f9f6911 100644 > > --- a/arch/arm/cpu/armv7/exynos/pinmux.c > > +++ b/arch/arm/cpu/armv7/exynos/pinmux.c > > @@ -22,6 +22,7 @@ > > */ > > > > #include > > +#include > > #include > > #include > > #include > > @@ -396,3 +397,30 @@ int exynos_pinmux_config(int peripheral, int flags) > > return -1; > > } > > } > > + > > +#ifdef CONFIG_OF_CONTROL > > +static int exynos5_pinmux_decode_periph_id(const void *blob, int node) > > +{ > > + int err; > > + u32 cell[3]; > > + > > + err = fdtdec_get_int_array(blob, node, "interrupts", cell, > > + ARRAY_SIZE(cell)); > > + if (err) > > + return PERIPH_ID_NONE; > > + > > + if ((131 > cell[1]) || (cell[1] < 31)) > > What means 131 and 31? > will correct and remove magic numbers. They were the high and lowest interrupt numbers. > > > + return cell[1]; > > + > > + debug(" invalid peripheral id\n"); > > + return PERIPH_ID_NONE; > > +} > > + > > +int pinmux_decode_periph_id(const void *blob, int node) > > +{ > > + if (cpu_is_exynos5()) > > + return exynos5_pinmux_decode_periph_id(blob, node); > > + else > > + return PERIPH_ID_NONE; > > +} > > +#endif > > diff --git a/arch/arm/include/asm/arch-exynos/periph.h > b/arch/arm/include/asm/arch-exynos/periph.h > > index 13abd2d..783b77c 100644 > > --- a/arch/arm/include/asm/arch-exynos/periph.h > > +++ b/arch/arm/include/asm/arch-exynos/periph.h > > @@ -25,12 +25,17 @@ > > #define __ASM_ARM_ARCH_PERIPH_H > > > > /* > > - * Peripherals requiring clock/pinmux configuration. List will > > + * Peripherals requiring pinmux configuration0. List will > > configuration0? > - Will correct this > > > * grow with support for more devices getting added. > > + * Numbering based on interrupt table. > > * > > */ > > enum periph_id { > > - PERIPH_ID_I2C0, > > + PERIPH_ID_UART0 = 51, > > + PERIPH_ID_UART1, > > + PERIPH_ID_UART2, > > + PERIPH_ID_UART3, > > + PERIPH_ID_I2C0 = 56, > > PERIPH_ID_I2C1, > > PERIPH_ID_I2C2, > > PERIPH_ID_I2C3, > > @@ -38,22 +43,22 @@ enum periph_id { > > PERIPH_ID_I2C5, > > PERIPH_ID_I2C6, > > PERIPH_ID_I2C7, > > - PERIPH_ID_I2S1, > > - PERIPH_ID_SDMMC0, > > + PERIPH_ID_SPI0 = 68, > > + PERIPH_ID_SPI1, > > + PERIPH_ID_SPI2, > > + PERIPH_ID_SDMMC0 = 75, > > PERIPH_ID_SDMMC1, > > PERIPH_ID_SDMMC2, > > PERIPH_ID_SDMMC3, > > - PERIPH_ID_SDMMC4, > > - PERIPH_ID_SROMC, > > - PERIPH_ID_SPI0, > > - PERIPH_ID_SPI1, > > - PERIPH_ID_SPI2, > > + PERIPH_ID_I2S1 = 99, > > + > > +/* Since following peripherals do not have shared peripheral interrupts > (SPIs) > > Please check multi line comment rule. > - Will correct this > > > + * they are numbered arbitiraly after the maximum SPIs Exynos has (128) > > + */ > > + PERIPH_ID_SROMC = 128, > > PERIPH_ID_SPI3, > > PERIPH_ID_SPI4, > > - PERIPH_ID_UART0, > > - PERIPH_ID_UART1, > > - PERIPH_ID_UART2, > > - PERIPH_ID_UART3, > > + PERIPH_ID_SDMMC4, > > > > PERIPH_ID_COUNT, > > PERIPH_ID_NONE = -1, > > diff --git a/arch/arm/include/asm/arch-exynos/pinmux.h > b/arch/arm/include/asm/arch-exynos/pinmux.h > > index 10ea736..00cbb0d 100644 > > --- a/arch/arm/include/asm/arch-exynos/pinmux.h > > +++ b/arch/arm/include/asm/arch-exynos/pinmux.h > > @@ -55,4 +55,12 @@ enum { > > */ > > int exynos_pinmux_config(int peripheral, int flags); > > > > +/** > > please remove "*". > - Will correct this > > > + * Decode the peripheral id using the interrpt numbers. > > + * > > + * @param blob Device tree blbo > > + * @param node FDT I2C node to find > > + * @return peripheral id if ok, PERIPH_ID_NONE on error > > + */ > > +int pinmux_decode_periph_id(const void *blob, int node); > > #endif > > > > -- > Thanks, > Minkyu Kang. > > ___ > U-Boot mailing list > U-Boot@lists.denx.de > http://lists.denx.de/mailman/listinfo/u-boot > -- Regards, Rajeshwari Shinde ___ U-Boot mailing list U-Boot@lists.denx.de ht
Re: [U-Boot] [PATCH 05/16] I2C: Driver changes for FDT support
Hi Minkyu Kang, Thank you for comments.Will correct them On Wed, Dec 26, 2012 at 5:24 PM, Minkyu Kang wrote: > Dear Rajeshwari Shinde, > > On 14/12/12 20:56, Rajeshwari Shinde wrote: > > Functions added to get the I2C bus number and reset I2C bus using > > FDT node. > > > > Signed-off-by: Rajeshwari Shinde > > Acked-by: Simon Glass > > Acked-by: Heiko Schocher > > --- > > Changes in V1: > > -Rebased on latest u-boot-samsung > > drivers/i2c/s3c24x0_i2c.c | 83 > - > > drivers/i2c/s3c24x0_i2c.h |8 > > include/i2c.h | 26 ++ > > 3 files changed, 116 insertions(+), 1 deletions(-) > > > > diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c > > index 9bc4c7f..94a093e 100644 > > --- a/drivers/i2c/s3c24x0_i2c.c > > +++ b/drivers/i2c/s3c24x0_i2c.c > > @@ -27,9 +27,11 @@ > > */ > > > > #include > > +#include > > #ifdef CONFIG_EXYNOS5 > > #include > > #include > > +#include > > #else > > #include > > #endif > > @@ -60,7 +62,14 @@ > > #define I2C_TIMEOUT 1/* 1 second */ > > > > > > -static unsigned int g_current_bus; /* Stores Current I2C Bus */ > > +/* > > + * For SPL boot some boards need i2c before SDRAM is initialised so > force > > + * variables to live in SRAM > > + */ > > +static unsigned int g_current_bus __attribute__((section(".data"))); > > +static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM] > > + __attribute__((section(".data"))); > > +static int i2c_busses __attribute__((section(".data"))); > > > > #ifndef CONFIG_EXYNOS5 > > static int GetI2CSDA(void) > > @@ -507,4 +516,76 @@ int i2c_write(uchar chip, uint addr, int alen, > uchar *buffer, int len) > > (i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer, > >len) != 0); > > } > > + > > +#ifdef CONFIG_OF_CONTROL > > +void board_i2c_init(const void *blob) > > +{ > > + > > please remove this blank line. > > > + int node_list[CONFIG_MAX_I2C_NUM]; > > + int count, i; > > + > > + count = fdtdec_find_aliases_for_id(blob, "i2c", > > + COMPAT_SAMSUNG_S3C2440_I2C, node_list, > > + CONFIG_MAX_I2C_NUM); > > need blank line here. > > > + for (i = 0; i < count; i++) { > > + struct s3c24x0_i2c_bus *bus; > > + int node = node_list[i]; > > How handle if the value of count is bigger than CONFIG_MAX_I2C_NUM? > > > + > > + if (node <= 0) > > + continue; > > + bus = &i2c_bus[i]; > > + bus->regs = (struct s3c24x0_i2c *) > > + fdtdec_get_addr(blob, node, "reg"); > > + bus->id = pinmux_decode_periph_id(blob, node); > > + bus->node = node; > > + bus->bus_num = i2c_busses++; > > + exynos_pinmux_config(bus->id, 0); > > + } > > + > > please remove this blank line. > > > +} > > + > > +static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx) > > +{ > > + if (bus_idx < i2c_busses) > > + return &i2c_bus[bus_idx]; > > need blank line here. > > > + debug("Undefined bus: %d\n", bus_idx); > > + return NULL; > > +} > > + > > +int i2c_get_bus_num_fdt(int node) > > +{ > > + int i; > > + > > + for (i = 0; i < i2c_busses; i++) { > > + if (node == i2c_bus[i].node) > > + return i; > > + } > > + > > + debug("%s: Can't find any matched I2C bus\n", __func__); > > + return -1; > > +} > > + > > +int i2c_reset_port_fdt(const void *blob, int node) > > +{ > > + struct s3c24x0_i2c_bus *i2c; > > + > > Please remove this blank line. > > > + int bus; > > + > > + bus = i2c_get_bus_num_fdt(node); > > + if (bus < 0) { > > + debug("could not get bus for node %d\n", node); > > + return -1; > > + } > > need blank line here. > > > + i2c = get_bus(bus); > > + if (!i2c) { > > + debug("get_bus() failed for node node %d\n", node); > > + return -1; > > + } > > + > > + i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); > > + > > + return 0; > > +} > > +#endif > > + > > #endif /* CONFIG_HARD_I2C */ > > diff --git a/drivers/i2c/s3c24x0_i2c.h b/drivers/i2c/s3c24x0_i2c.h > > index 2dd4b06..1243bf1 100644 > > --- a/drivers/i2c/s3c24x0_i2c.h > > +++ b/drivers/i2c/s3c24x0_i2c.h > > @@ -30,4 +30,12 @@ struct s3c24x0_i2c { > > u32 iicds; > > u32 iiclc; > > }; > > + > > +struct s3c24x0_i2c_bus { > > + int node; /* device tree node */ > > + int bus_num;/* i2c bus number */ > > + struct s3c24x0_i2c *regs; > > + enum periph_id id; > > +}; > > + > > #endif /* _S3C24X0_I2C_H */ > > diff --git a/include/i2c.h b/include/i2c.h > > index 16f099d..c60d075 100644 > > --- a/include/i2c.h > > +++ b/include/i2c.h > > @@ -262,4 +262,30 @@ extern int get_multi_scl_pin(void); > > extern int get_multi_sda_pin(void); > > ext
Re: [U-Boot] [PATCH 16/16] SPI: EXYNOS: Add FDT support to driver.
Hi Minkyu Kang, Thank you for comments.Will correct them. On Wed, Dec 26, 2012 at 5:24 PM, Minkyu Kang wrote: > Dear Rajeshwari Shinde, > > On 14/12/12 20:56, Rajeshwari Shinde wrote: > > This patch adds FDT support to the SPI driver. > > > > Signed-off-by: Simon Glass > > Signed-off-by: Rajeshwari Shinde > > Acked-by: Simon Glass > > --- > > Changes in V1: > > -Rebased on latest u-boot-samsung > > drivers/spi/exynos_spi.c | 96 > +++--- > > 1 files changed, 90 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/spi/exynos_spi.c b/drivers/spi/exynos_spi.c > > index 3e6c18f..7ecc566 100644 > > --- a/drivers/spi/exynos_spi.c > > +++ b/drivers/spi/exynos_spi.c > > @@ -20,6 +20,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -28,16 +29,20 @@ > > #include > > #include > > > > +DECLARE_GLOBAL_DATA_PTR; > > + > > /* Information about each SPI controller */ > > struct spi_bus { > > enum periph_id periph_id; > > s32 frequency; /* Default clock frequency, -1 for none */ > > struct exynos_spi *regs; > > int inited; /* 1 if this bus is ready for use */ > > + int node; > > }; > > > > /* A list of spi buses that we know about */ > > static struct spi_bus spi_bus[EXYNOS5_SPI_NUM_CONTROLLERS]; > > +static unsigned int bus_count; > > > > struct exynos_spi_slave { > > struct spi_slave slave; > > @@ -50,7 +55,7 @@ struct exynos_spi_slave { > > > > static struct spi_bus *spi_get_bus(unsigned dev_index) > > { > > - if (dev_index < EXYNOS5_SPI_NUM_CONTROLLERS) > > + if (dev_index < bus_count) > > return &spi_bus[dev_index]; > > debug("%s: invalid bus %d", __func__, dev_index); > > > > @@ -347,21 +352,100 @@ static inline struct exynos_spi *get_spi_base(int > dev_index) > > (dev_index - 3); > > } > > > > +/* > > + * Read the SPI config from the device tree node. > > + * > > + * @param blob FDT blob to read from > > + * @param node Node offset to read from > > + * @param bus SPI bus structure to fill with information > > + * @return 0 if ok, or -FDT_ERR_NOTFOUND if something was missing > > + */ > > +static int spi_get_config(const void *blob, int node, struct spi_bus > *bus) > > +{ > > + bus->node = node; > > + bus->regs = (struct exynos_spi *)fdtdec_get_addr(blob, node, > "reg"); > > + bus->periph_id = pinmux_decode_periph_id(blob, node); > > Please add blank line here. > > > + if (bus->periph_id == PERIPH_ID_NONE) { > > + debug("%s: Invalid peripheral ID %d\n", __func__, > > + bus->periph_id); > > + return -FDT_ERR_NOTFOUND; > > + } > > + > > + /* Use 500KHz as a suitable default */ > > + bus->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", > > + 50); > > + > > + return 0; > > +} > > + > > Please remove this blank line. > > > + > > +/* > > + * Process a list of nodes, adding them to our list of SPI ports. > > + * > > + * @param blob fdt blob > > + * @param node_list list of nodes to process (any <=0 are ignored) > > + * @param count number of nodes to process > > + * @param is_dvc1 if these are DVC ports, 0 if standard I2C > > + * @return 0 if ok, -1 on error > > + */ > > +static int process_nodes(const void *blob, int node_list[], int count) > > +{ > > + int i; > > + > > + /* build the i2c_controllers[] for each controller */ > > + for (i = 0; i < count; i++) { > > + int node = node_list[i]; > > + struct spi_bus *bus; > > + > > + if (node <= 0) > > + continue; > > + > > + bus = &spi_bus[i]; > > + if (spi_get_config(blob, node, bus)) { > > + printf("exynos spi_init: failed to decode bus > %d\n", > > + i); > > + return -1; > > + } > > + > > + debug("spi: controller bus %d at %p, periph_id %d\n", > > + i, bus->regs, bus->periph_id); > > + bus->inited = 1; > > + bus_count++; > > + } > > + > > + return 0; > > +} > > + > > /* Sadly there is no error return from this function */ > > void spi_init(void) > > { > > - int i; > > + int count; > > + > > +#ifdef CONFIG_OF_CONTROL > > + int node_list[EXYNOS5_SPI_NUM_CONTROLLERS]; > > + const void *blob = gd->fdt_blob; > > + > > + count = fdtdec_find_aliases_for_id(blob, "spi", > > + COMPAT_SAMSUNG_EXYNOS_SPI, node_list, > > + EXYNOS5_SPI_NUM_CONTROLLERS); > > + if (process_nodes(blob, node_list, count)) > > + return; > > + > > +#else > > struct spi_bus *bus; > > > > - for (i = 0; i < EXYNOS5_SPI_NUM_CONTROLLERS; i++) { > > - bus = &spi_bus[i];
Re: [U-Boot] [PATCH] EXYNOS: EXYNOS4X12: extract Exynos4x12 IPs clock frequency
On Sunday, October 7, 2012, Chander Kashyap wrote: > Adds functions to extract clock frequency of Exynos4x12 IPs. > > Signed-off-by: Chander Kashyap > > --- > arch/arm/cpu/armv7/exynos/clock.c | 163 > +++-- > 1 file changed, 158 insertions(+), 5 deletions(-) > > applied to u-boot-samsung/master thanks Minkyu Kang -- Thanks. Minkyu Kang. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 05/16] I2C: Driver changes for FDT support
Hi Minkyu Kang, On Wed, Dec 26, 2012 at 5:24 PM, Minkyu Kang wrote: > Dear Rajeshwari Shinde, > > On 14/12/12 20:56, Rajeshwari Shinde wrote: > > Functions added to get the I2C bus number and reset I2C bus using > > FDT node. > > > > Signed-off-by: Rajeshwari Shinde > > Acked-by: Simon Glass > > Acked-by: Heiko Schocher > > --- > > Changes in V1: > > -Rebased on latest u-boot-samsung > > drivers/i2c/s3c24x0_i2c.c | 83 > - > > drivers/i2c/s3c24x0_i2c.h |8 > > include/i2c.h | 26 ++ > > 3 files changed, 116 insertions(+), 1 deletions(-) > > > > diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c > > index 9bc4c7f..94a093e 100644 > > --- a/drivers/i2c/s3c24x0_i2c.c > > +++ b/drivers/i2c/s3c24x0_i2c.c > > @@ -27,9 +27,11 @@ > > */ > > > > #include > > +#include > > #ifdef CONFIG_EXYNOS5 > > #include > > #include > > +#include > > #else > > #include > > #endif > > @@ -60,7 +62,14 @@ > > #define I2C_TIMEOUT 1/* 1 second */ > > > > > > -static unsigned int g_current_bus; /* Stores Current I2C Bus */ > > +/* > > + * For SPL boot some boards need i2c before SDRAM is initialised so > force > > + * variables to live in SRAM > > + */ > > +static unsigned int g_current_bus __attribute__((section(".data"))); > > +static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM] > > + __attribute__((section(".data"))); > > +static int i2c_busses __attribute__((section(".data"))); > > > > #ifndef CONFIG_EXYNOS5 > > static int GetI2CSDA(void) > > @@ -507,4 +516,76 @@ int i2c_write(uchar chip, uint addr, int alen, > uchar *buffer, int len) > > (i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, buffer, > >len) != 0); > > } > > + > > +#ifdef CONFIG_OF_CONTROL > > +void board_i2c_init(const void *blob) > > +{ > > + > > please remove this blank line. > > > + int node_list[CONFIG_MAX_I2C_NUM]; > > + int count, i; > > + > > + count = fdtdec_find_aliases_for_id(blob, "i2c", > > + COMPAT_SAMSUNG_S3C2440_I2C, node_list, > > + CONFIG_MAX_I2C_NUM); > > need blank line here. > > > + for (i = 0; i < count; i++) { > > + struct s3c24x0_i2c_bus *bus; > > + int node = node_list[i]; > > How handle if the value of count is bigger than CONFIG_MAX_I2C_NUM? > CONFIG_MAX_I2C_NUM is maximum number of I2C lines supported. if count bigger than CONFIG_MAX_I2C_NUM then it is error. So you want me to add a check here? > > > + > > + if (node <= 0) > > + continue; > > + bus = &i2c_bus[i]; > > + bus->regs = (struct s3c24x0_i2c *) > > + fdtdec_get_addr(blob, node, "reg"); > > + bus->id = pinmux_decode_periph_id(blob, node); > > + bus->node = node; > > + bus->bus_num = i2c_busses++; > > + exynos_pinmux_config(bus->id, 0); > > + } > > + > > please remove this blank line. > > > +} > > + > > +static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx) > > +{ > > + if (bus_idx < i2c_busses) > > + return &i2c_bus[bus_idx]; > > need blank line here. > > > + debug("Undefined bus: %d\n", bus_idx); > > + return NULL; > > +} > > + > > +int i2c_get_bus_num_fdt(int node) > > +{ > > + int i; > > + > > + for (i = 0; i < i2c_busses; i++) { > > + if (node == i2c_bus[i].node) > > + return i; > > + } > > + > > + debug("%s: Can't find any matched I2C bus\n", __func__); > > + return -1; > > +} > > + > > +int i2c_reset_port_fdt(const void *blob, int node) > > +{ > > + struct s3c24x0_i2c_bus *i2c; > > + > > Please remove this blank line. > > > + int bus; > > + > > + bus = i2c_get_bus_num_fdt(node); > > + if (bus < 0) { > > + debug("could not get bus for node %d\n", node); > > + return -1; > > + } > > need blank line here. > > > + i2c = get_bus(bus); > > + if (!i2c) { > > + debug("get_bus() failed for node node %d\n", node); > > + return -1; > > + } > > + > > + i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); > > + > > + return 0; > > +} > > +#endif > > + > > #endif /* CONFIG_HARD_I2C */ > > diff --git a/drivers/i2c/s3c24x0_i2c.h b/drivers/i2c/s3c24x0_i2c.h > > index 2dd4b06..1243bf1 100644 > > --- a/drivers/i2c/s3c24x0_i2c.h > > +++ b/drivers/i2c/s3c24x0_i2c.h > > @@ -30,4 +30,12 @@ struct s3c24x0_i2c { > > u32 iicds; > > u32 iiclc; > > }; > > + > > +struct s3c24x0_i2c_bus { > > + int node; /* device tree node */ > > + int bus_num;/* i2c bus number */ > > + struct s3c24x0_i2c *regs; > > + enum periph_id id; > > +}; > > + > > #endif /* _S3C24X0_I2C_H */ > > diff --git a/include/i2c.h b/include/i2c.h > > index 16f099d..c60d075 100644 > > --- a/include/i2c.h > > +++ b/include
Re: [U-Boot] [PATCH 7/9] mx53loco: Add support to dynamically choose between ftd use or not
On Wed, Dec 26, 2012 at 9:31 AM, Stefano Babic wrote: > Only to remark that this is the correct behavior. The kernel with fdt is > booted independently if this is wanted or not, but if the fdt file is > loaded successfully from MMC or network. This can have some drawback > effects if, for example, the fdt is simply stored on the TFTP server, > but we want to boot a kernel without DT. For example, when someone wants > to test both kernels or there are multiple instances of the same board > type (mx53loco in this case) loading from the same TFTP server. > > In your patch, the behavior depends if the fdt is simply present on the > media, but this does not always mean that the file must be loaded. > Should be not better to set variable as flag to force the desired > behavior and to be sure that the system does not boot in a different way > as the user thinks ? > > In other words, something like : > > "if boot_fdt; then " \ > "if dhcp ${ftd_addr} ${ftd_file}; then " \ > "bootm ${loadaddr} - ${ftd_addr}; " \ > "else " \ > "echo Error: I cannot boot a DT kernel; \" > "fi; \" > " else bootm; fi;\0" Yes, I think this is a good idea and would allow us to easily switch from dt to non-dt kernel during tests. Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 05/16] I2C: Driver changes for FDT support
On 26 December 2012 21:33, Rajeshwari Birje wrote: > Hi Minkyu Kang, > > On Wed, Dec 26, 2012 at 5:24 PM, Minkyu Kang wrote: > > > Dear Rajeshwari Shinde, > > > > On 14/12/12 20:56, Rajeshwari Shinde wrote: > > > Functions added to get the I2C bus number and reset I2C bus using > > > FDT node. > > > > > > Signed-off-by: Rajeshwari Shinde > > > Acked-by: Simon Glass > > > Acked-by: Heiko Schocher > > > --- > > > Changes in V1: > > > -Rebased on latest u-boot-samsung > > > drivers/i2c/s3c24x0_i2c.c | 83 > > - > > > drivers/i2c/s3c24x0_i2c.h |8 > > > include/i2c.h | 26 ++ > > > 3 files changed, 116 insertions(+), 1 deletions(-) > > > > > > diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c > > > index 9bc4c7f..94a093e 100644 > > > --- a/drivers/i2c/s3c24x0_i2c.c > > > +++ b/drivers/i2c/s3c24x0_i2c.c > > > @@ -27,9 +27,11 @@ > > > */ > > > > > > #include > > > +#include > > > #ifdef CONFIG_EXYNOS5 > > > #include > > > #include > > > +#include > > > #else > > > #include > > > #endif > > > @@ -60,7 +62,14 @@ > > > #define I2C_TIMEOUT 1/* 1 second */ > > > > > > > > > -static unsigned int g_current_bus; /* Stores Current I2C Bus */ > > > +/* > > > + * For SPL boot some boards need i2c before SDRAM is initialised so > > force > > > + * variables to live in SRAM > > > + */ > > > +static unsigned int g_current_bus __attribute__((section(".data"))); > > > +static struct s3c24x0_i2c_bus i2c_bus[CONFIG_MAX_I2C_NUM] > > > + __attribute__((section(".data"))); > > > +static int i2c_busses __attribute__((section(".data"))); > > > > > > #ifndef CONFIG_EXYNOS5 > > > static int GetI2CSDA(void) > > > @@ -507,4 +516,76 @@ int i2c_write(uchar chip, uint addr, int alen, > > uchar *buffer, int len) > > > (i2c, I2C_WRITE, chip << 1, &xaddr[4 - alen], alen, > buffer, > > >len) != 0); > > > } > > > + > > > +#ifdef CONFIG_OF_CONTROL > > > +void board_i2c_init(const void *blob) > > > +{ > > > + > > > > please remove this blank line. > > > > > + int node_list[CONFIG_MAX_I2C_NUM]; > > > + int count, i; > > > + > > > + count = fdtdec_find_aliases_for_id(blob, "i2c", > > > + COMPAT_SAMSUNG_S3C2440_I2C, node_list, > > > + CONFIG_MAX_I2C_NUM); > > > > need blank line here. > > > > > + for (i = 0; i < count; i++) { > > > + struct s3c24x0_i2c_bus *bus; > > > + int node = node_list[i]; > > > > How handle if the value of count is bigger than CONFIG_MAX_I2C_NUM? > > > CONFIG_MAX_I2C_NUM is maximum number of I2C lines supported. > if count bigger than CONFIG_MAX_I2C_NUM then it is error. > So you want me to add a check here? > It seems to check at fdtdec_find_aliases_fo_id function. Then OK, enough. > > > > > > + > > > + if (node <= 0) > > > + continue; > > > + bus = &i2c_bus[i]; > > > + bus->regs = (struct s3c24x0_i2c *) > > > + fdtdec_get_addr(blob, node, "reg"); > > > + bus->id = pinmux_decode_periph_id(blob, node); > > > + bus->node = node; > > > + bus->bus_num = i2c_busses++; > > > + exynos_pinmux_config(bus->id, 0); > > > + } > > > + > > > > please remove this blank line. > > > > > +} > > > + > > > +static struct s3c24x0_i2c_bus *get_bus(unsigned int bus_idx) > > > +{ > > > + if (bus_idx < i2c_busses) > > > + return &i2c_bus[bus_idx]; > > > > need blank line here. > > > > > + debug("Undefined bus: %d\n", bus_idx); > > > + return NULL; > > > +} > > > + > > > +int i2c_get_bus_num_fdt(int node) > > > +{ > > > + int i; > > > + > > > + for (i = 0; i < i2c_busses; i++) { > > > + if (node == i2c_bus[i].node) > > > + return i; > > > + } > > > + > > > + debug("%s: Can't find any matched I2C bus\n", __func__); > > > + return -1; > > > +} > > > + > > > +int i2c_reset_port_fdt(const void *blob, int node) > > > +{ > > > + struct s3c24x0_i2c_bus *i2c; > > > + > > > > Please remove this blank line. > > > > > + int bus; > > > + > > > + bus = i2c_get_bus_num_fdt(node); > > > + if (bus < 0) { > > > + debug("could not get bus for node %d\n", node); > > > + return -1; > > > + } > > > > need blank line here. > > > > > + i2c = get_bus(bus); > > > + if (!i2c) { > > > + debug("get_bus() failed for node node %d\n", node); > > > + return -1; > > > + } > > > + > > > + i2c_ch_init(i2c->regs, CONFIG_SYS_I2C_SPEED, > CONFIG_SYS_I2C_SLAVE); > > > + > > > + return 0; > > > +} > > > +#endif > > > + > > > #endif /* CONFIG_HARD_I2C */ > > > diff --git a/drivers/i2c/s3c24x0_i2c.h b/drivers/i2c/s3c24x0_i2c.h > > > index 2dd4b06..1243bf1 100644 > > > --- a/drivers/i2c/s3c24x0_i2c.h > > > +++ b/drivers/i2c/s3c24x0_i2c.h > > > @@ -
Re: [U-Boot] [PATCH 5/5] cm-t35: add support for loading splash image from NAND
Hello Nikita, On 12/25/2012 09:56 AM, Nikita Kiryanov wrote: fyi, I noticed that my board compiled with gcc 4.7.3 from ELDK 5.3 will trap if the bitmap is not aligned. Aligned is a bit tricky though since the bitmap has the signature, e.g. "BM" prepended and is thereafter 32 bit aligned (or at least combined fields of 32 bits). In my case displaying the bitmap now only works when loaded to an aligned address - 2. Since you accept the value from the user, which has no ability to restore it once set "incorrectly", you might want to check the load address (well obviously only if it is a problem in your case as well). Thanks for verifying this issue. I did encounter it during testing, but I assumed it to be a compiler problem because it worked when compiling with a different version. Loading to aligned address - 2 works for me as well when compiling with the problematic compiler, but this is strange to me. Isn't the "packed" attribute that is applied to bmp_header_t supposed to prevent these types of problems by effectively forcing the compiler to assume byte alignment? Not per definition, while the pack does place most members at unaligned addresses, it does not control if the data can be loaded from it. Since the 4.7+ compilers by default assume that the chip does support unaligned accesses, it just generates ldr instruction to get the uint32_t members (and thus trap on this mcu). Older versions (or 4.7 with -mno-unaligned-access) will generate byte fetches due to the pack since it assumes the chip does not support unaligned accesses. So when compiled with a older compiler the bitmap could be loaded anywhere. With 4.7+ it is faster but needs to be aligned (in a bit weird manner). Regards, Jeroen ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
Robert, On Thu, Dec 20, 2012 at 8:04 PM, Robert Nelson wrote: > Hi Fabio, > > It looks like we need one more fixup after commit c73368150 on the > first run/older (non R, Dialog, bug wired extra Capacitor) version of > this board.. Do you happen to have any in your lab? > > U-Boot 2013.01-rc2-dirty (Dec 20 2012 - 15:55:01) > > Board: MX53 LOCO > I2C: ready > DRAM: 1 GiB > pmic_alloc: No available memory for allocation! > pmic_init: POWER allocation error! > CPU: Freescale i.MX53 family rev2.0 at 800 MHz > Reset cause: POR > MMC: FSL_SDHC: 0, FSL_SDHC: 1 > *** Warning - bad CRC, using default environment > > (and it just keeps on resetting) > > It looks to be failing after calloc... > http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/power/power_core.c#l100 > > 100 p = calloc(sizeof(*p), 1); > 101 if (!p) { > 102 printf("%s: No available memory for > allocation!\n", __func__); > 103 return NULL; > 104 } I can reproduce this issue using top of head U-boot tree. It seems indeed to be caused by: Author: Łukasz Majewski Date: Tue Nov 13 03:21:55 2012 + commit c7336815078ff3745e3130aeff35991e3e98e61e Author: Łukasz Majewski Date: Tue Nov 13 03:21:55 2012 + pmic: Extend PMIC framework to support multiple instances of PMIC devices The PMIC framework has been extended to support multiple instances of the variety of devices responsible for power management. This change allows supporting of e.g. fuel gauge, charger, MUIC (Micro USB Interface Circuit). Power related includes have been moved to ./include/power directory. This is a first of a series of patches - in the future "pmic" will be replaced with "power". Two important issues: 1. The PMIC needs to be initialized just after malloc is configured 2. It uses list to hold information about available PMIC devices Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park Cc: Stefano Babic I am Ccing Lukasz/Stefano in case they have any suggestion. With the new PMIC framework: is it safe to call the PMIC API from board_init function? Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 1:02 PM, Fabio Estevam wrote: > With the new PMIC framework: is it safe to call the PMIC API from > board_init function? Calling it from board_late_init fixes the issue for me. Will send the patch soon. Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
Robert, On Wed, Dec 26, 2012 at 1:07 PM, Fabio Estevam wrote: > On Wed, Dec 26, 2012 at 1:02 PM, Fabio Estevam wrote: > >> With the new PMIC framework: is it safe to call the PMIC API from >> board_init function? > > Calling it from board_late_init fixes the issue for me. > > Will send the patch soon. Can you try the patch below? board/freescale/mx53loco/mx53loco.c | 10 -- include/configs/mx53loco.h |1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index 2c8cb7a..63a4f8b 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -462,12 +462,18 @@ int board_init(void) mxc_set_sata_internal_clock(); setup_iomux_i2c(); + + lcd_enable(); + + return 0; +} + +int board_late_init(void) +{ if (!power_init()) clock_1GHz(); print_cpuinfo(); - lcd_enable(); - return 0; } diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h index e30502b..c4181bd 100644 --- a/include/configs/mx53loco.h +++ b/include/configs/mx53loco.h @@ -39,6 +39,7 @@ #define CONFIG_SYS_MALLOC_LEN (10 * 1024 * 1024) #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_BOARD_LATE_INIT #define CONFIG_MXC_GPIO #define CONFIG_REVISION_TAG -- 1.7.9.5 It boots now, but I get resets now: U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 13:13:28) Board: MX53 LOCO I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 In:serial Out: serial Err: serial CPU: Freescale i.MX53 family rev2.1 at 1000 MHz Reset cause: WDOG Net: FEC Warning: FEC using MAC address from net device Hit any key to stop autoboot: 0 data abort MAYBE you should read doc/README.arm-unaligned-accesses pc : [] lr : [] sp : af565e20 ip : af566918 fp : r10: 0003 r9 : affabb5b r8 : af565f58 r7 : r6 : 36747fff r5 : af5668e8 r4 : 36747fff r3 : af5668ec r2 : af5668eb r1 : r0 : af5668e8 Flags: NzcV IRQs off FIQs off Mode SVC_32 Resetting CPU ... resetting ... U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 13:13:28) Board: MX53 LOCO I2C: ready DRAM: 1 GiB but it looks like a separate issue? Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/16] EXYNOS5: FDT : Decode peripheral id
Hi, On Wed, Dec 26, 2012 at 4:00 AM, Rajeshwari Birje wrote: > Hi Minkyu Kang, > > Thank you for comments > > On Wed, Dec 26, 2012 at 5:24 PM, Minkyu Kang wrote: > >> Dear Rajeshwari Shinde, >> >> On 14/12/12 20:56, Rajeshwari Shinde wrote: >> > Api is added to decode peripheral id based on the interrupt number >> > of the peripheral. >> > >> > Signed-off-by: Rajeshwari Shinde >> > Acked-by; Simon Glass >> > --- >> > Changes in V1: >> > -Rebased on latest u-boot-samsung >> > arch/arm/cpu/armv7/exynos/pinmux.c| 28 >> ++ >> > arch/arm/include/asm/arch-exynos/periph.h | 31 >> >> > arch/arm/include/asm/arch-exynos/pinmux.h |8 +++ >> > 3 files changed, 54 insertions(+), 13 deletions(-) >> > >> > diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c >> b/arch/arm/cpu/armv7/exynos/pinmux.c >> > index f02f441..f9f6911 100644 >> > --- a/arch/arm/cpu/armv7/exynos/pinmux.c >> > +++ b/arch/arm/cpu/armv7/exynos/pinmux.c >> > @@ -22,6 +22,7 @@ >> > */ >> > >> > #include >> > +#include >> > #include >> > #include >> > #include >> > @@ -396,3 +397,30 @@ int exynos_pinmux_config(int peripheral, int flags) >> > return -1; >> > } >> > } >> > + >> > +#ifdef CONFIG_OF_CONTROL >> > +static int exynos5_pinmux_decode_periph_id(const void *blob, int node) >> > +{ >> > + int err; >> > + u32 cell[3]; >> > + >> > + err = fdtdec_get_int_array(blob, node, "interrupts", cell, >> > + ARRAY_SIZE(cell)); >> > + if (err) >> > + return PERIPH_ID_NONE; >> > + >> > + if ((131 > cell[1]) || (cell[1] < 31)) >> >> What means 131 and 31? >> > will correct and remove magic numbers. > They were the high and lowest interrupt numbers. > >> >> > + return cell[1]; >> > + >> > + debug(" invalid peripheral id\n"); >> > + return PERIPH_ID_NONE; >> > +} >> > + >> > +int pinmux_decode_periph_id(const void *blob, int node) >> > +{ >> > + if (cpu_is_exynos5()) >> > + return exynos5_pinmux_decode_periph_id(blob, node); >> > + else >> > + return PERIPH_ID_NONE; >> > +} >> > +#endif >> > diff --git a/arch/arm/include/asm/arch-exynos/periph.h >> b/arch/arm/include/asm/arch-exynos/periph.h >> > index 13abd2d..783b77c 100644 >> > --- a/arch/arm/include/asm/arch-exynos/periph.h >> > +++ b/arch/arm/include/asm/arch-exynos/periph.h >> > @@ -25,12 +25,17 @@ >> > #define __ASM_ARM_ARCH_PERIPH_H >> > >> > /* >> > - * Peripherals requiring clock/pinmux configuration. List will >> > + * Peripherals requiring pinmux configuration0. List will >> >> configuration0? >> > - Will correct this > >> >> > * grow with support for more devices getting added. >> > + * Numbering based on interrupt table. >> > * >> > */ >> > enum periph_id { >> > - PERIPH_ID_I2C0, >> > + PERIPH_ID_UART0 = 51, >> > + PERIPH_ID_UART1, >> > + PERIPH_ID_UART2, >> > + PERIPH_ID_UART3, >> > + PERIPH_ID_I2C0 = 56, >> > PERIPH_ID_I2C1, >> > PERIPH_ID_I2C2, >> > PERIPH_ID_I2C3, >> > @@ -38,22 +43,22 @@ enum periph_id { >> > PERIPH_ID_I2C5, >> > PERIPH_ID_I2C6, >> > PERIPH_ID_I2C7, >> > - PERIPH_ID_I2S1, >> > - PERIPH_ID_SDMMC0, >> > + PERIPH_ID_SPI0 = 68, >> > + PERIPH_ID_SPI1, >> > + PERIPH_ID_SPI2, >> > + PERIPH_ID_SDMMC0 = 75, >> > PERIPH_ID_SDMMC1, >> > PERIPH_ID_SDMMC2, >> > PERIPH_ID_SDMMC3, >> > - PERIPH_ID_SDMMC4, >> > - PERIPH_ID_SROMC, >> > - PERIPH_ID_SPI0, >> > - PERIPH_ID_SPI1, >> > - PERIPH_ID_SPI2, >> > + PERIPH_ID_I2S1 = 99, >> > + >> > +/* Since following peripherals do not have shared peripheral interrupts >> (SPIs) >> >> Please check multi line comment rule. >> > - Will correct this > >> >> > + * they are numbered arbitiraly after the maximum SPIs Exynos has (128) >> > + */ >> > + PERIPH_ID_SROMC = 128, >> > PERIPH_ID_SPI3, >> > PERIPH_ID_SPI4, >> > - PERIPH_ID_UART0, >> > - PERIPH_ID_UART1, >> > - PERIPH_ID_UART2, >> > - PERIPH_ID_UART3, >> > + PERIPH_ID_SDMMC4, >> > >> > PERIPH_ID_COUNT, >> > PERIPH_ID_NONE = -1, >> > diff --git a/arch/arm/include/asm/arch-exynos/pinmux.h >> b/arch/arm/include/asm/arch-exynos/pinmux.h >> > index 10ea736..00cbb0d 100644 >> > --- a/arch/arm/include/asm/arch-exynos/pinmux.h >> > +++ b/arch/arm/include/asm/arch-exynos/pinmux.h >> > @@ -55,4 +55,12 @@ enum { >> > */ >> > int exynos_pinmux_config(int peripheral, int flags); >> > >> > +/** >> >> please remove "*". >> > - Will correct this The extra * indicates a comment with doxygen / DocBook comments, so I think we should keep this if we can. There is a bit of a push in U-Boot to use DocBook now (like include/cbfs.h). The format is slightly different from doxygen but it's probably putting to run a converter to switch over at one point. > >> >> > + * Decode the peripheral id using the interrpt numbers
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 1:51 PM, Robert Nelson wrote: > Interesting, I'm still only getting this far on the old Dialog board.. > > U-Boot 2013.01-rc2-00173-gd781d95-dirty (Dec 26 2012 - 09:42:43) > > Board: MX53 LOCO > I2C: ready > DRAM: 1 GiB I tested with 2 mx53loco boards here: one with FSL PMIC and one with Dialog. I recall we had 2 versions of boards with Dialog PMIC, but at least with the one I have here it boots fine now after applying the patch I just sent. If you have any news, just let us know. Thanks, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] mx53loco: Call PMIC related functions from board_late_init()
From: Fabio Estevam Since commit c733681 (pmic: Extend PMIC framework to support multiple instances of PMIC devices) mx53loco fails to allocate the memory for PMIC: U-Boot 2013.01-rc2-dirty (Dec 20 2012 - 15:55:01) Board: MX53 LOCO I2C: ready DRAM: 1 GiB pmic_alloc: No available memory for allocation! pmic_init: POWER allocation error! CPU: Freescale i.MX53 family rev2.0 at 800 MHz Reset cause: POR MMC: FSL_SDHC: 0, FSL_SDHC: 1 Calling the PMIC related functions at a later stage, ie, from board_late_init() fixes the issue. Reported-by: Robert Nelson Signed-off-by: Fabio Estevam --- board/freescale/mx53loco/mx53loco.c | 10 -- include/configs/mx53loco.h |1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/board/freescale/mx53loco/mx53loco.c b/board/freescale/mx53loco/mx53loco.c index 2c8cb7a..63a4f8b 100644 --- a/board/freescale/mx53loco/mx53loco.c +++ b/board/freescale/mx53loco/mx53loco.c @@ -462,12 +462,18 @@ int board_init(void) mxc_set_sata_internal_clock(); setup_iomux_i2c(); + + lcd_enable(); + + return 0; +} + +int board_late_init(void) +{ if (!power_init()) clock_1GHz(); print_cpuinfo(); - lcd_enable(); - return 0; } diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h index e30502b..c4181bd 100644 --- a/include/configs/mx53loco.h +++ b/include/configs/mx53loco.h @@ -39,6 +39,7 @@ #define CONFIG_SYS_MALLOC_LEN (10 * 1024 * 1024) #define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_BOARD_LATE_INIT #define CONFIG_MXC_GPIO #define CONFIG_REVISION_TAG -- 1.7.9.5 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
Hi Fabio, On Wed, Dec 26, 2012 at 9:21 AM, Fabio Estevam wrote: > Robert, > > On Wed, Dec 26, 2012 at 1:07 PM, Fabio Estevam wrote: >> On Wed, Dec 26, 2012 at 1:02 PM, Fabio Estevam wrote: >> >>> With the new PMIC framework: is it safe to call the PMIC API from >>> board_init function? >> >> Calling it from board_late_init fixes the issue for me. >> >> Will send the patch soon. > > Can you try the patch below? Thanks for taking a look at this.. > > board/freescale/mx53loco/mx53loco.c | 10 -- > include/configs/mx53loco.h |1 + > 2 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/board/freescale/mx53loco/mx53loco.c > b/board/freescale/mx53loco/mx53loco.c > index 2c8cb7a..63a4f8b 100644 > --- a/board/freescale/mx53loco/mx53loco.c > +++ b/board/freescale/mx53loco/mx53loco.c > @@ -462,12 +462,18 @@ int board_init(void) > > mxc_set_sata_internal_clock(); > setup_iomux_i2c(); > + > + lcd_enable(); > + > + return 0; > +} > + > +int board_late_init(void) > +{ > if (!power_init()) > clock_1GHz(); > print_cpuinfo(); > > - lcd_enable(); > - > return 0; > } > > diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h > index e30502b..c4181bd 100644 > --- a/include/configs/mx53loco.h > +++ b/include/configs/mx53loco.h > @@ -39,6 +39,7 @@ > #define CONFIG_SYS_MALLOC_LEN (10 * 1024 * 1024) > > #define CONFIG_BOARD_EARLY_INIT_F > +#define CONFIG_BOARD_LATE_INIT Ah, i was missing this when heading down the "board_late_init" road on friday.. > #define CONFIG_MXC_GPIO > #define CONFIG_REVISION_TAG > > -- > 1.7.9.5 > > > It boots now, but I get resets now: > > U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 13:13:28) > > Board: MX53 LOCO > I2C: ready > DRAM: 1 GiB > MMC: FSL_SDHC: 0, FSL_SDHC: 1 > In:serial > Out: serial > Err: serial > CPU: Freescale i.MX53 family rev2.1 at 1000 MHz > Reset cause: WDOG > Net: FEC > Warning: FEC using MAC address from net device Interesting, I'm still only getting this far on the old Dialog board.. U-Boot 2013.01-rc2-00173-gd781d95-dirty (Dec 26 2012 - 09:42:43) Board: MX53 LOCO I2C: ready DRAM: 1 GiB I'm going to start printf'ing: http://git.denx.de/?p=u-boot.git;a=blob;f=drivers/power/power_dialog.c as we aren't getting the memory error, so it should be atleast past that... > Hit any key to stop autoboot: 0 > data abort > > MAYBE you should read doc/README.arm-unaligned-accesses > > pc : [] lr : [] > sp : af565e20 ip : af566918 fp : > r10: 0003 r9 : affabb5b r8 : af565f58 > r7 : r6 : 36747fff r5 : af5668e8 r4 : 36747fff > r3 : af5668ec r2 : af5668eb r1 : r0 : af5668e8 > Flags: NzcV IRQs off FIQs off Mode SVC_32 > Resetting CPU ... > > resetting ... I've reverted this just to double check (no change for me...): http://git.denx.de/?p=u-boot.git;a=commit;h=28e5ac2d974547bde0c72aa0c1d66fd22c6ef3ad > U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 13:13:28) > > Board: MX53 LOCO > I2C: ready > DRAM: 1 GiB > > > but it looks like a separate issue? Regards, -- Robert Nelson http://www.rcn-ee.com/ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 9:54 AM, Fabio Estevam wrote: > On Wed, Dec 26, 2012 at 1:51 PM, Robert Nelson > wrote: > >> Interesting, I'm still only getting this far on the old Dialog board.. >> >> U-Boot 2013.01-rc2-00173-gd781d95-dirty (Dec 26 2012 - 09:42:43) >> >> Board: MX53 LOCO >> I2C: ready >> DRAM: 1 GiB > > I tested with 2 mx53loco boards here: one with FSL PMIC and one with Dialog. > > I recall we had 2 versions of boards with Dialog PMIC, but at least > with the one I have here it boots fine now after applying the patch I > just sent. Okay, good to hear it works with the Dialog PMIC you have, as that should cover a majority of the Dialog based boards customers actually have. As the one I have here was one of the very first ones and i know something changed later in production... Regards, -- Robert Nelson http://www.rcn-ee.com/ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 2:04 PM, Robert Nelson wrote: > Okay, good to hear it works with the Dialog PMIC you have, as that > should cover a majority of the Dialog based boards customers actually > have. As the one I have here was one of the very first ones and i know > something changed later in production... Yes, but not happy to see a regression with your board and also the resets that started to happen now. Which toolchain did you use? I am using gcc 4.6.3. If you have a chance to try the same toolchain to make sure we got the same results, that would be nice. Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 10:50 AM, Fabio Estevam wrote: > On Wed, Dec 26, 2012 at 2:04 PM, Robert Nelson > wrote: > >> Okay, good to hear it works with the Dialog PMIC you have, as that >> should cover a majority of the Dialog based boards customers actually >> have. As the one I have here was one of the very first ones and i know >> something changed later in production... > > Yes, but not happy to see a regression with your board and also the > resets that started to happen now. I'll keep debugging it here, did reverting this commit, help with the resets? http://git.denx.de/?p=u-boot.git;a=commit;h=28e5ac2d974547bde0c72aa0c1d66fd22c6ef3ad > Which toolchain did you use? I am using gcc 4.6.3. If you have a > chance to try the same toolchain to make sure we got the same results, > that would be nice. That build was with Linaro's 4.7.1 2012.04 release, from: https://launchpad.net/linaro-toolchain-binaries/ ./arm-linux-gnueabi-gcc --version arm-linux-gnueabi-gcc (crosstool-NG linaro-1.13.1-2012.04-20120426 - Linaro GCC 2012.04) 4.7.1 20120402 (prerelease) Regards, -- Robert Nelson http://www.rcn-ee.com/ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 3:08 PM, Robert Nelson wrote: > I'll keep debugging it here, did reverting this commit, help with the resets? > http://git.denx.de/?p=u-boot.git;a=commit;h=28e5ac2d974547bde0c72aa0c1d66fd22c6ef3ad Tried reverting it and still see the data-aborts. I am also testing on my mx53loco board with the mc34708 pmic and I see that it hangs on boot about 10% of the attempts: U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 15:15:27) Board: MX53 LOCO I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 This did not happen prior to commit c73368150 (pmic: Extend PMIC framework to support multiple instances of PMIC devices). Regards, Fabio Estevam ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mx53loco: Fix PMIC name
On Wed, Dec 26, 2012 at 11:21 AM, Fabio Estevam wrote: > On Wed, Dec 26, 2012 at 3:08 PM, Robert Nelson > wrote: > >> I'll keep debugging it here, did reverting this commit, help with the resets? >> http://git.denx.de/?p=u-boot.git;a=commit;h=28e5ac2d974547bde0c72aa0c1d66fd22c6ef3ad > > Tried reverting it and still see the data-aborts. > > I am also testing on my mx53loco board with the mc34708 pmic and I see > that it hangs on boot about 10% of the attempts: > U-Boot 2013.01-rc2-00172-gf8cfcf1-dirty (Dec 26 2012 - 15:15:27) > > Board: MX53 LOCO > I2C: ready > DRAM: 1 GiB > MMC: FSL_SDHC: 0, FSL_SDHC: 1 > > This did not happen prior to commit c73368150 (pmic: Extend PMIC > framework to support multiple instances > of PMIC devices). Okay, now we are on the same page, upgraded to: "arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.7-2012.12-20121214 - Linaro GCC 2012.12) 4.7.3 20121205 (prerelease)".. With your Dialog patch, it is properly setting 1Ghz, and just keeps rebooting.. :) U-Boot 2013.01-rc2-00173-ga0d04f3 (Dec 26 2012 - 11:47:34) Board: MX53 LOCO I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 *** Warning - bad CRC, using default environment In:serial Out: serial Err: serial CPU: Freescale i.MX53 family rev2.0 at 1000 MHz Reset cause: WDOG Net: FEC Warning: FEC using MAC address from net device Hit any key to stop autoboot: 0 data abort MAYBE you should read doc/README.arm-unaligned-accesses pc : [] lr : [] sp : af565d68 ip : fff4 fp : r10: 0003 r9 : affab8d9 r8 : af565f58 r7 : r6 : e5bc345d r5 : af6df330 r4 : e5bc345d r3 : af6df334 r2 : af6df333 r1 : r0 : af6df330 Flags: nzCv IRQs off FIQs off Mode SVC_32 Resetting CPU ... resetting ... U-Boot 2013.01-rc2-00173-ga0d04f3 (Dec 26 2012 - 11:47:34) Board: MX53 LOCO I2C: ready DRAM: 1 GiB MMC: FSL_SDHC: 0, FSL_SDHC: 1 *** Warning - bad CRC, using default environment In:serial Out: serial Err: serial CPU: Freescale i.MX53 family rev2.0 at 1000 MHz Reset cause: WDOG Regards, -- Robert Nelson http://www.rcn-ee.com/ ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 8/8] buildman - U-Boot multi-threaded builder and summary tool
Hi, On Sat, Dec 15, 2012 at 12:42 PM, Simon Glass wrote: > This tool handles building U-Boot to check that you have not broken it > with your patch series. It can build each individual commit and report > which boards fail on which commits, and which errors come up. It also > shows differences in image sizes due to particular commits. > > Buildman aims to make full use of multi-processor machines. > > Documentation and caveats are in tools/buildman/README. > > I have removed the RFC from this version. > > Signed-off-by: Simon Glass I have a few minor comments on this and plan to re-issue the patch. It doesn't fully replace MAKEALL yet (e.g currently you need to run the summarise option in another terminal to see what problems it s finding while running). But it would be good to get a few more testers to pass judgement. Is this in line for 2013.01 or perhaps next? Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 7/9] mx53loco: Add support to dynamically choose between ftd use or not
On Wed, Dec 26, 2012 at 10:14 AM, Fabio Estevam wrote: > On Wed, Dec 26, 2012 at 9:31 AM, Stefano Babic wrote: > >> Only to remark that this is the correct behavior. The kernel with fdt is >> booted independently if this is wanted or not, but if the fdt file is >> loaded successfully from MMC or network. This can have some drawback >> effects if, for example, the fdt is simply stored on the TFTP server, >> but we want to boot a kernel without DT. For example, when someone wants >> to test both kernels or there are multiple instances of the same board >> type (mx53loco in this case) loading from the same TFTP server. >> >> In your patch, the behavior depends if the fdt is simply present on the >> media, but this does not always mean that the file must be loaded. >> Should be not better to set variable as flag to force the desired >> behavior and to be sure that the system does not boot in a different way >> as the user thinks ? >> >> In other words, something like : >> >> "if boot_fdt; then " \ >> "if dhcp ${ftd_addr} ${ftd_file}; then " \ >> "bootm ${loadaddr} - ${ftd_addr}; " \ >> "else " \ >> "echo Error: I cannot boot a DT kernel; \" >> "fi; \" >> " else bootm; fi;\0" > > > Yes, I think this is a good idea and would allow us to easily switch > from dt to non-dt kernel during tests. I like the idea but maybe we could have three states? boot_fdt=yes It'd imply force fdt and would behave as you said above; boot_fdt=no Would ignore the fdt completely boot_fdt=auto The current code, which try to load fdt and do not fail otherwise. Comments? -- Otavio Salvador O.S. Systems E-mail: ota...@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/9] mx28evk: We shouldn't hardcode a rootfs filesystem type
On Wed, Dec 26, 2012 at 9:02 AM, Stefano Babic wrote: > On 21/12/2012 17:59, Otavio Salvador wrote: >> For a generic environment, we shouldn't have a fixed rootfs filesystem >> so we drop it from env. >> >> Signed-off-by: Otavio Salvador >> --- > > Hi Otavio, > >> include/configs/mx28evk.h |7 ++- >> 1 file changed, 2 insertions(+), 5 deletions(-) >> >> diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h >> index 8b89b25..3cc0726 100644 >> --- a/include/configs/mx28evk.h >> +++ b/include/configs/mx28evk.h >> @@ -292,11 +292,8 @@ >> "console_mainline=ttyAMA0\0" \ >> "mmcdev=0\0" \ >> "mmcpart=2\0" \ >> - "mmcroot=/dev/mmcblk0p3 rw\0" \ >> - "mmcrootfstype=ext3 rootwait\0" \ >> - "mmcargs=setenv bootargs console=${console_mainline},${baudrate} " \ >> - "root=${mmcroot} " \ >> - "rootfstype=${mmcrootfstype}\0" \ >> + "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \ >> + "mmcargs=setenv bootargs console=${console_mainline},${baudrate} >> root=${mmcroot}\0" \ >> "loadbootscript=" \ >> "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \ >> "bootscript=echo Running bootscript from mmc ...; " \ >> > > WARNING: line over 80 characters > #37: FILE: include/configs/mx28evk.h:296: > + "mmcargs=setenv bootargs console=${console_mainline},${baudrate} > root=${mmcroot}\0" \ > > total: 0 errors, 1 warnings, 13 lines checked > > Can you fix it ? Yes but I think it'd be more confusing for someone reading the code. If you do want me to fix it, I do. -- Otavio Salvador O.S. Systems E-mail: ota...@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 6/9] mx28evk: Add support to dynamically choose between ftd use or not
On Wed, Dec 26, 2012 at 9:15 AM, Stefano Babic wrote: > On 21/12/2012 17:59, Otavio Salvador wrote: >> Signed-off-by: Otavio Salvador >> --- > > Hi Otavio, > >> include/configs/mx28evk.h | 15 +-- >> 1 file changed, 13 insertions(+), 2 deletions(-) >> >> diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h >> index 3cc0726..5c1c052 100644 >> --- a/include/configs/mx28evk.h >> +++ b/include/configs/mx28evk.h >> @@ -290,6 +290,8 @@ >> "uimage=uImage\0" \ >> "console_fsl=ttyAM0\0" \ >> "console_mainline=ttyAMA0\0" \ >> + "ftd_file=imx28-evk.dtb\0" \ >> + "ftd_addr=0x4100\0" \ >> "mmcdev=0\0" \ >> "mmcpart=2\0" \ >> "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \ >> @@ -301,13 +303,22 @@ >> "loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \ >> "mmcboot=echo Booting from mmc ...; " \ >> "run mmcargs; " \ >> - "bootm\0" \ >> + "if fatload mmc ${mmcdev}:${mmcpart} ${ftd_addr} ${ftd_file}; >> then " \ >> + "bootm ${loadaddr} - ${ftd_addr}; " \ >> + "else " \ >> + "bootm; " \ >> + "fi;\0" \ >> "netargs=setenv bootargs console=${console_mainline},${baudrate} " \ >> "root=/dev/nfs " \ >> "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \ >> "netboot=echo Booting from net ...; " \ >> "run netargs; " \ >> - "dhcp ${uimage}; bootm\0" >> + "dhcp ${uimage}; " \ >> + "if dhcp ${ftd_addr} ${ftd_file}; then " \ >> + "bootm ${loadaddr} - ${ftd_addr}; " \ >> + "else " \ >> + "bootm; " \ >> + "fi;\0" >> >> #define CONFIG_BOOTCOMMAND \ >> "mmc dev ${mmcdev}; if mmc rescan; then " \ >> > > Please fix the following warning reported by checkpatch: > > WARNING: line over 80 characters > #39: FILE: include/configs/mx28evk.h:306: > + "if fatload mmc ${mmcdev}:${mmcpart} ${ftd_addr} ${ftd_file}; > then " \ > > total: 0 errors, 1 warnings, 32 lines checked Some to the other patch; it is a little bit above the limit but it seems more easy to read for me. I can fix it but I'd like to double check before. -- Otavio Salvador O.S. Systems E-mail: ota...@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mxs: Add NAND fdt and ramdisk partition to m28evk
On Wed, Dec 26, 2012 at 1:13 AM, Marek Vasut wrote: > Dear Otavio Salvador, > >> On Tue, Dec 25, 2012 at 11:08 PM, Marek Vasut wrote: >> > Adjust the NAND partitioning layout so that there is a separate partition >> > for the ramdisk and fdt blob on the NAND. >> > >> > Signed-off-by: Marek Vasut >> >> A partition for a ramdisk? maybe initramfs or initrd might be better? > > Separate ramdisk (initrd). So maybe name it 'initrd' in the partition table? -- Otavio Salvador O.S. Systems E-mail: ota...@ossystems.com.br http://www.ossystems.com.br Mobile: +55 53 9981-7854 http://projetos.ossystems.com.br ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Please pull u-boot-x86.git
Hi Tom, These are the two that patchwork somehow missed. They are in there now, so here is the pull request for those two. The following changes since commit f8cfcf1b1c7543d5dd103359376a3319301143bc: env: don't generate callback list entries for SPL (2012-12-22 05:57:16 -0700) are available in the git repository at: git://git.denx.de/u-boot-x86.git master Simon Glass (1): x86: coreboot: Enable io command Stefan Reinauer (1): x86: Add coreboot version to u-boot's version command common/cmd_version.c |7 ++- include/configs/coreboot.h |1 + 2 files changed, 7 insertions(+), 1 deletions(-) Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/20] Improvements to memory, hashing functions for sandbox
This series aims to get all the memory functions running correctly on sandbox. There was some discussion about this a while ago, and a commit was added to show a possible approach: 355a8357 sandbox: Change md command to use map_physmem This commit was subsequently reverted because it used map_physmem() instead of the NOP that most architectures need for the memory functions. This series introduces map_sysmem(), a NOP on all architectures except sandbox. It allows us to use a ram buffer to which all U-Boot addresses are relative. The memory commands (including hashing) are updated to use this so that sandbox can now use those commands. Half of the mtest code is behind #ifdefs and there is duplication of some functions in both versions of the memory test. Several patches here clean this up a bit and get it working on sandbox. The numeric setenv_ulong() function is a useful way of avoiding a 'char buf[17]; sprintf(buf, "%ld", ...); setenv("...", buf)' sequence. There is also setenv_addr(). What is missing is setenv_hex() which sets a ulong in hex format. Add this function and then make use of it in the main places: common/ drivers/ and net/. The recently added and very basic hash instructure can help reduce code duplication in some cases. Redo the crc32 command to use this, and make it available through the 'hash' command. Also a few bugs were found in hashing with verify disabled - the arg count was not checked and a variable declaration was missing. To permit the memory tester to run on sandbox, we need ctrl-C to work. To achieve this, add a proper implementation of sandbox's tstc(), with a simple FIFO for character input. An os_usleep() is added to ensure that U-Boot does not consume infinite CPU when setting at the command prompt. With all of this it is possible to use the memory commands in sandbox, as well as crc32 and the other hashing commands. Simon Glass (19): Tidy up error checking and fix bug in hash command Update print_buffer() to use const sandbox: Add un/map_sysmen() to deal with sandbox's ram_buf sandbox: Change memory commands to use map_physmem Split out the memory tests into separate functions Use common mtest iteration counting Fix mtest indenting Bring mtest putc() into common code Reduce casting in mtest Update set_working_fdt_addr() to use setenv_addr() common: Use new numeric setenv functions drivers: Use new numeric setenv functions net: Use new numeric setenv functions image: Use crc header file instead of C prototypes Roll crc32 into hash infrastructure sandbox: config: Enable hash functions and mtest Move CONFIG_SYS_MEMTEST_SCRATCH #ifdef to top of file sandbox: Update mtest to fix crashes sandbox: Allow hash functions to work correctly Taylor Hutt (1): sandbox: Improve sandbox serial port keyboard interface README|9 + arch/sandbox/config.mk|1 + arch/sandbox/cpu/os.c |8 + arch/sandbox/include/asm/io.h | 10 + common/cmd_bootm.c| 11 +- common/cmd_cbfs.c |4 +- common/cmd_cramfs.c |4 +- common/cmd_fdos.c |4 +- common/cmd_fdt.c | 11 +- common/cmd_hash.c |4 + common/cmd_jffs2.c|4 +- common/cmd_load.c | 12 +- common/cmd_mem.c | 798 - common/cmd_mtdparts.c |4 +- common/cmd_nand.c | 12 +- common/cmd_nvedit.c | 11 +- common/cmd_reiser.c |4 +- common/cmd_setexpr.c | 39 ++- common/cmd_unzip.c|4 +- common/cmd_ximg.c |7 +- common/cmd_zfs.c |3 +- common/cmd_zip.c |4 +- common/hash.c | 31 ++- common/image.c|4 +- drivers/net/fm/fm.c |4 +- drivers/serial/sandbox.c | 44 ++- fs/fs.c |4 +- fs/ubifs/ubifs.c |4 +- include/common.h | 29 ++- include/configs/sandbox.h |9 +- include/hash.h|2 +- include/os.h | 10 + include/u-boot/crc.h | 11 + lib/crc32.c |9 + lib/display_options.c |3 +- net/net.c |8 +- 36 files changed, 612 insertions(+), 528 deletions(-) -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 05/20] sandbox: Change memory commands to use map_physmem
Sandbox wants to support commands which use memory. The map_sysmen() call provides this feature, so use this in the memory commands. Signed-off-by: Simon Glass --- common/cmd_mem.c | 122 +++--- 1 files changed, 79 insertions(+), 43 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 4d64cff..e2adea9 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -33,6 +33,7 @@ #include #endif #include +#include static int mod_mem(cmd_tbl_t *, int, int, int, char * const []); @@ -135,9 +136,13 @@ static int do_mem_md(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) # endif { + ulong bytes = size * length; + const void *buf = map_sysmem(addr, bytes); + /* Print the lines. */ - print_buffer(addr, (void*)addr, size, length, DISP_LINE_LEN/size); - addr += size*length; + print_buffer(addr, buf, size, length, DISP_LINE_LEN / size); + addr += bytes; + unmap_sysmem(buf); } #endif @@ -160,6 +165,8 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { ulong addr, writeval, count; int size; + void *buf; + ulong bytes; if ((argc < 3) || (argc > 4)) return CMD_RET_USAGE; @@ -185,15 +192,18 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) count = 1; } + bytes = size * count; + buf = map_sysmem(addr, bytes); while (count-- > 0) { if (size == 4) - *((ulong *)addr) = (ulong )writeval; + *((ulong *)buf) = (ulong)writeval; else if (size == 2) - *((ushort *)addr) = (ushort)writeval; + *((ushort *)buf) = (ushort)writeval; else - *((u_char *)addr) = (u_char)writeval; - addr += size; + *((u_char *)buf) = (u_char)writeval; + buf += size; } + unmap_sysmem(buf); return 0; } @@ -255,10 +265,11 @@ int do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - ulong addr1, addr2, count, ngood; + ulong addr1, addr2, count, ngood, bytes; int size; int rcode = 0; const char *type; + const void *buf1, *buf2, *base; if (argc != 4) return CMD_RET_USAGE; @@ -291,33 +302,40 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif + bytes = size * count; + base = buf1 = map_sysmem(addr1, bytes); + buf2 = map_sysmem(addr2, bytes); for (ngood = 0; ngood < count; ++ngood) { ulong word1, word2; if (size == 4) { - word1 = *(ulong *)addr1; - word2 = *(ulong *)addr2; + word1 = *(ulong *)buf1; + word2 = *(ulong *)buf2; } else if (size == 2) { - word1 = *(ushort *)addr1; - word2 = *(ushort *)addr2; + word1 = *(ushort *)buf1; + word2 = *(ushort *)buf2; } else { - word1 = *(u_char *)addr1; - word2 = *(u_char *)addr2; + word1 = *(u_char *)buf1; + word2 = *(u_char *)buf2; } if (word1 != word2) { + ulong offset = buf1 - base; + printf("%s at 0x%08lx (%#0*lx) != %s at 0x%08lx (%#0*lx)\n", - type, addr1, size, word1, - type, addr2, size, word2); + type, (ulong)(addr1 + offset), size, word1, + type, (ulong)(addr2 + offset), size, word2); rcode = 1; break; } - addr1 += size; - addr2 += size; + buf1 += size; + buf2 += size; /* reset watchdog from time to time */ if ((ngood % (64 << 10)) == 0) WATCHDOG_RESET(); } + unmap_sysmem(buf1); + unmap_sysmem(buf2); printf("Total of %ld %s(s) were the same\n", ngood, type); return rcode; @@ -325,8 +343,10 @@ static int do_mem_cmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) static int do_mem_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - ulong addr, dest, count; + ulong addr, dest, count, bytes; int size; + const void *src; + void *buf;
[U-Boot] [PATCH 03/20] sandbox: Improve sandbox serial port keyboard interface
From: Taylor Hutt Implements the tstc() interface for the serial driver. Multiplexing the console between the serial port and a keyboard uses a polling method of checking if characters are available; this means that the serial console must be non-blocking when attempting to read characters. Signed-off-by: Taylor Hutt Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c|8 drivers/serial/sandbox.c | 44 ++-- include/os.h | 10 ++ 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 36637af..3e37c93 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -44,6 +44,14 @@ ssize_t os_read(int fd, void *buf, size_t count) return read(fd, buf, count); } +ssize_t os_read_no_block(int fd, void *buf, size_t count) +{ + const int flags = fcntl(fd, F_GETFL, 0); + + fcntl(fd, F_SETFL, flags | O_NONBLOCK); + return os_read(fd, buf, count); +} + ssize_t os_write(int fd, const void *buf, size_t count) { return write(fd, buf, count); diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index cb19401..b73520c 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -30,6 +30,19 @@ #include #include +/* + * + * serial_buf: A buffer that holds keyboard characters for the + * Sandbox U-boot. + * + * invariants: + * serial_buf_write == serial_buf_read -> empty buffer + * (serial_buf_write + 1) % 16 == serial_buf_read -> full buffer + */ +static char serial_buf[16]; +static unsigned int serial_buf_write; +static unsigned int serial_buf_read; + static int sandbox_serial_init(void) { os_tty_raw(0); @@ -50,18 +63,37 @@ static void sandbox_serial_puts(const char *str) os_write(1, str, strlen(str)); } -static int sandbox_serial_getc(void) +static unsigned int increment_buffer_index(unsigned int index) +{ + return (index + 1) % ARRAY_SIZE(serial_buf); +} + +static int sandbox_serial_tstc(void) { - char buf; + const unsigned int next_index = + increment_buffer_index(serial_buf_write); ssize_t count; - count = os_read(0, &buf, 1); - return count == 1 ? buf : 0; + os_usleep(100); + if (next_index == serial_buf_read) + return 1; /* buffer full */ + + count = os_read_no_block(0, &serial_buf[serial_buf_write], 1); + if (count == 1) + serial_buf_write = next_index; + return serial_buf_write != serial_buf_read; } -static int sandbox_serial_tstc(void) +static int sandbox_serial_getc(void) { - return 0; + int result; + + while (!sandbox_serial_tstc()) + ; /* buffer empty */ + + result = serial_buf[serial_buf_read]; + serial_buf_read = increment_buffer_index(serial_buf_read); + return result; } static struct serial_device sandbox_serial_drv = { diff --git a/include/os.h b/include/os.h index 699682a..c452d1b 100644 --- a/include/os.h +++ b/include/os.h @@ -40,6 +40,16 @@ struct sandbox_state; ssize_t os_read(int fd, void *buf, size_t count); /** + * Access to the OS read() system call with non-blocking access + * + * \param fd File descriptor as returned by os_open() + * \param buf Buffer to place data + * \param countNumber of bytes to read + * \return number of bytes read, or -1 on error + */ +ssize_t os_read_no_block(int fd, void *buf, size_t count); + +/** * Access to the OS write() system call * * \param fd File descriptor as returned by os_open() -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 18/20] Move CONFIG_SYS_MEMTEST_SCRATCH #ifdef to top of file
This config effectively has a default value of 0, so add this setting at the top of the code to remove an #ifdef in the C function. Signed-off-by: Simon Glass --- common/cmd_mem.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 701157d..f83acdf 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -36,6 +36,10 @@ #include #include +#ifndef CONFIG_SYS_MEMTEST_SCRATCH +#define CONFIG_SYS_MEMTEST_SCRATCH 0 +#endif + static int mod_mem(cmd_tbl_t *, int, int, int, char * const []); /* Display values from last command. @@ -636,11 +640,7 @@ static ulong mem_test_alt(ulong start_addr, ulong end_addr) vu_long temp; vu_long anti_pattern; vu_long num_words; -#if defined(CONFIG_SYS_MEMTEST_SCRATCH) vu_long *dummy = (vu_long *)CONFIG_SYS_MEMTEST_SCRATCH; -#else - vu_long *dummy = NULL; /* yes, this is address 0x0, not NULL */ -#endif static const ulong bitpattern[] = { 0x0001, /* single bit */ 0x0003, /* two adjacent bits */ -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 06/20] Split out the memory tests into separate functions
Half of the code is currently hidden behind an #ifdef. Move the two memory tests into their own functions and use the compiler to eliminate the unused code. Signed-off-by: Simon Glass --- common/cmd_mem.c | 217 +- 1 files changed, 116 insertions(+), 101 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index e2adea9..36ac6f4 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -621,36 +621,26 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif /* CONFIG_LOOPW */ -/* - * Perform a memory test. A more complete alternative test can be - * configured using CONFIG_SYS_ALT_MEMTEST. The complete test loops until - * interrupted by ctrl-c or by a failure of one of the sub-tests. - */ -static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, - char * const argv[]) +static int mem_test_alt(vu_long *start, vu_long *end, + int iteration_limit) { - vu_long *addr, *start, *end; - ulong val; - ulong readback; - ulong errs = 0; + vu_long *addr; int iterations = 1; - int iteration_limit; - -#if defined(CONFIG_SYS_ALT_MEMTEST) - vu_long len; - vu_long offset; - vu_long test_offset; - vu_long pattern; - vu_long temp; - vu_long anti_pattern; - vu_long num_words; + ulong errs = 0; + ulong val, readback; + int j; + vu_long len; + vu_long offset; + vu_long test_offset; + vu_long pattern; + vu_long temp; + vu_long anti_pattern; + vu_long num_words; #if defined(CONFIG_SYS_MEMTEST_SCRATCH) - vu_long *dummy = (vu_long*)CONFIG_SYS_MEMTEST_SCRATCH; + vu_long *dummy = (vu_long *)CONFIG_SYS_MEMTEST_SCRATCH; #else vu_long *dummy = NULL; /* yes, this is address 0x0, not NULL */ #endif - int j; - static const ulong bitpattern[] = { 0x0001, /* single bit */ 0x0003, /* two adjacent bits */ @@ -661,43 +651,18 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, 0x0055, /* four non-adjacent bits */ 0x, /* alternating 1/0 */ }; -#else - ulong incr; - ulong pattern; -#endif - if (argc > 1) - start = (ulong *)simple_strtoul(argv[1], NULL, 16); - else - start = (ulong *)CONFIG_SYS_MEMTEST_START; - - if (argc > 2) - end = (ulong *)simple_strtoul(argv[2], NULL, 16); - else - end = (ulong *)(CONFIG_SYS_MEMTEST_END); - - if (argc > 3) - pattern = (ulong)simple_strtoul(argv[3], NULL, 16); - else - pattern = 0; - - if (argc > 4) - iteration_limit = (ulong)simple_strtoul(argv[4], NULL, 16); - else - iteration_limit = 0; - -#if defined(CONFIG_SYS_ALT_MEMTEST) - printf ("Testing %08x ... %08x:\n", (uint)start, (uint)end); + printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start, + (uint)(uintptr_t)end); debug("%s:%d: start 0x%p end 0x%p\n", - __FUNCTION__, __LINE__, start, end); + __func__, __LINE__, start, end); for (;;) { if (ctrlc()) { - putc ('\n'); + putc('\n'); return 1; } - if (iteration_limit && iterations > iteration_limit) { printf("Tested %d iteration(s) with %lu errors.\n", iterations-1, errs); @@ -726,34 +691,35 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, * pattern and ~pattern). */ addr = start; - for (j = 0; j < sizeof(bitpattern)/sizeof(bitpattern[0]); j++) { + for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); + j++) { val = bitpattern[j]; - for(; val != 0; val <<= 1) { + for (; val != 0; val <<= 1) { *addr = val; - *dummy = ~val; /* clear the test data off of the bus */ + *dummy = ~val; /* clear the test data off the bus */ readback = *addr; if(readback != val) { - printf ("FAILURE (data line): " - "expected %08lx, actual %08lx\n", - val, readback); - errs++; - if (ctrlc()) { - putc ('\n'); - return 1; - } + printf("FAILURE (data line): " + "ex
[U-Boot] [PATCH 02/20] Update print_buffer() to use const
The buffer cannot be changed by this function, so change the buffer pointer to a const. This allows callers with const pointer to use the function without a cast. Signed-off-by: Simon Glass --- include/common.h |3 ++- lib/display_options.c |3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/common.h b/include/common.h index d0bf1e8..f2035c0 100644 --- a/include/common.h +++ b/include/common.h @@ -270,7 +270,8 @@ int cpu_init(void); phys_size_t initdram (int); intdisplay_options (void); void print_size(unsigned long long, const char *); -intprint_buffer (ulong addr, void* data, uint width, uint count, uint linelen); +int print_buffer(ulong addr, const void *data, uint width, uint count, +uint linelen); /* common/main.c */ void main_loop (void); diff --git a/lib/display_options.c b/lib/display_options.c index 694d2f2..0339970 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -98,7 +98,8 @@ void print_size(unsigned long long size, const char *s) */ #define MAX_LINE_LENGTH_BYTES (64) #define DEFAULT_LINE_LENGTH_BYTES (16) -int print_buffer (ulong addr, void* data, uint width, uint count, uint linelen) +int print_buffer(ulong addr, const void *data, uint width, uint count, +uint linelen) { /* linebuf as a union causes proper alignment */ union linebuf { -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 07/20] Use common mtest iteration counting
The iteration code is the same for each version of the memory test, so pull it out into the common function. Signed-off-by: Simon Glass --- common/cmd_mem.c | 123 ++ 1 files changed, 59 insertions(+), 64 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 36ac6f4..41c1e70 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -621,11 +621,9 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif /* CONFIG_LOOPW */ -static int mem_test_alt(vu_long *start, vu_long *end, - int iteration_limit) +static ulong mem_test_alt(vu_long *start, vu_long *end) { vu_long *addr; - int iterations = 1; ulong errs = 0; ulong val, readback; int j; @@ -652,27 +650,6 @@ static int mem_test_alt(vu_long *start, vu_long *end, 0x, /* alternating 1/0 */ }; - printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start, - (uint)(uintptr_t)end); - debug("%s:%d: start 0x%p end 0x%p\n", - __func__, __LINE__, start, end); - - for (;;) { - if (ctrlc()) { - putc('\n'); - return 1; - } - - if (iteration_limit && iterations > iteration_limit) { - printf("Tested %d iteration(s) with %lu errors.\n", - iterations-1, errs); - return errs != 0; - } - - printf("Iteration: %6d\r", iterations); - debug("\n"); - iterations++; - /* * Data line test: write a pattern to the first * location, write the 1's complement to a 'parking' @@ -705,7 +682,7 @@ static int mem_test_alt(vu_long *start, vu_long *end, errs++; if (ctrlc()) { putc('\n'); - return 1; + return -1; } } *addr = ~val; @@ -718,7 +695,7 @@ static int mem_test_alt(vu_long *start, vu_long *end, errs++; if (ctrlc()) { putc('\n'); - return 1; + return -1; } } } @@ -786,7 +763,7 @@ static int mem_test_alt(vu_long *start, vu_long *end, errs++; if (ctrlc()) { putc('\n'); - return 1; + return -1; } } } @@ -808,7 +785,7 @@ static int mem_test_alt(vu_long *start, vu_long *end, errs++; if (ctrlc()) { putc('\n'); - return 1; + return -1; } } } @@ -850,7 +827,7 @@ static int mem_test_alt(vu_long *start, vu_long *end, errs++; if (ctrlc()) { putc('\n'); - return 1; + return -1; } } @@ -872,37 +849,38 @@ static int mem_test_alt(vu_long *start, vu_long *end, errs++; if (ctrlc()) { putc('\n'); - return 1; + return -1; } } start[offset] = 0; } - } + + return 0; } -static int mem_test_quick(vu_long *start, vu_long *end, - int iteration_limit, vu_long pattern) +static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, + int iteration) { vu_long *addr; - int iterations = 1; ulong errs = 0; ulong incr; ulong val, readback; + /* Alternate the pattern */ incr = 1; - for (;;) { - if (ctrlc()) { - putc('\n'); - return 1; - } - - if (iteration_limit && iterations > iteration_limit) { - printf("Tested %d iteration(s) with %lu errors.\n", - iterations-1, errs); - return errs != 0; - } - ++iterations; - + if (iteration & 1) { + incr = -incr; + /* +
[U-Boot] [PATCH 11/20] Update set_working_fdt_addr() to use setenv_addr()
We might as well use this common function instead of repeating the same code. Signed-off-by: Simon Glass --- common/cmd_fdt.c| 11 ++- common/cmd_nvedit.c |8 include/common.h| 14 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 9e2de34..0bdf7b6 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -56,12 +56,8 @@ struct fdt_header *working_fdt; void set_working_fdt_addr(void *addr) { - char buf[17]; - working_fdt = addr; - - sprintf(buf, "%lx", (unsigned long)addr); - setenv("fdtaddr", buf); + setenv_addr("fdtaddr", addr); } /* @@ -348,10 +344,7 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } if (subcmd[0] == 's') { /* get the num nodes at this level */ - char buf[11]; - - sprintf(buf, "%d", curIndex + 1); - setenv(var, buf); + setenv_ulong(var, curIndex + 1); } else { /* node index not found */ printf("libfdt node not found\n"); diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 7633f0c..44e88aa 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -295,17 +295,17 @@ int setenv_ulong(const char *varname, ulong value) } /** - * Set an environment variable to an address in hex + * Set an environment variable to an value in hex * * @param varname Environmet variable to set - * @param addr Value to set it to + * @param valueValue to set it to * @return 0 if ok, 1 on error */ -int setenv_addr(const char *varname, const void *addr) +int setenv_hex(const char *varname, ulong value) { char str[17]; - sprintf(str, "%lx", (uintptr_t)addr); + sprintf(str, "%lx", value); return setenv(varname, str); } diff --git a/include/common.h b/include/common.h index 08d01db..8ecaf56 100644 --- a/include/common.h +++ b/include/common.h @@ -349,7 +349,19 @@ int getenv_yesno(const char *var); intsaveenv (void); intsetenv (const char *, const char *); int setenv_ulong(const char *varname, ulong value); -int setenv_addr(const char *varname, const void *addr); +int setenv_hex(const char *varname, ulong value); +/** + * setenv_addr - Set an environment variable to an address in hex + * + * @varname: Environmet variable to set + * @addr: Value to set it to + * @return 0 if ok, 1 on error + */ +static inline int setenv_addr(const char *varname, const void *addr) +{ + return setenv_hex(varname, (ulong)addr); +} + #ifdef CONFIG_ARM # include # include -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 20/20] sandbox: Allow hash functions to work correctly
Use map_sysmem() so that hashing is possible on sandbox. Signed-off-by: Simon Glass --- common/hash.c | 25 + 1 files changed, 17 insertions(+), 8 deletions(-) diff --git a/common/hash.c b/common/hash.c index e92b4b1..2e0a67b 100644 --- a/common/hash.c +++ b/common/hash.c @@ -28,6 +28,7 @@ #include #include #include +#include /* * These are the hash algorithms we support. Chips which support accelerated @@ -72,10 +73,13 @@ static void store_result(struct hash_algo *algo, const u8 *sum, unsigned int i; if (*dest == '*') { - u8 *ptr; + ulong addr; + void *buf; - ptr = (u8 *)simple_strtoul(dest + 1, NULL, 16); - memcpy(ptr, sum, algo->digest_size); + addr = simple_strtoul(dest + 1, NULL, 16); + buf = map_sysmem(addr, algo->digest_size); + memcpy(buf, sum, algo->digest_size); + unmap_sysmem(buf); } else { char str_output[HASH_MAX_DIGEST_SIZE * 2 + 1]; char *str_ptr = str_output; @@ -105,10 +109,13 @@ static void store_result(struct hash_algo *algo, const u8 *sum, static int parse_verify_sum(struct hash_algo *algo, char *verify_str, u8 *vsum) { if (*verify_str == '*') { - u8 *ptr; + ulong addr; + void *buf; - ptr = (u8 *)simple_strtoul(verify_str + 1, NULL, 16); - memcpy(vsum, ptr, algo->digest_size); + addr = simple_strtoul(verify_str + 1, NULL, 16); + buf = map_sysmem(addr, algo->digest_size); + memcpy(vsum, buf, algo->digest_size); + unmap_sysmem(buf); } else { unsigned int i; char *vsum_str; @@ -169,6 +176,7 @@ int hash_command(const char *algo_name, int verify, cmd_tbl_t *cmdtp, int flag, { struct hash_algo *algo; ulong addr, len; + void *buf; u8 output[HASH_MAX_DIGEST_SIZE]; u8 vsum[HASH_MAX_DIGEST_SIZE]; @@ -189,8 +197,9 @@ int hash_command(const char *algo_name, int verify, cmd_tbl_t *cmdtp, int flag, return 1; } - algo->hash_func_ws((const unsigned char *)addr, len, output, - algo->chunk_size); + buf = map_sysmem(addr, len); + algo->hash_func_ws(buf, len, output, algo->chunk_size); + unmap_sysmem(buf); /* Try to avoid code bloat when verify is not needed */ #ifdef CONFIG_HASH_VERIFY -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/20] Tidy up error checking and fix bug in hash command
There are two problems: 1. The argument count needs to be checked before argv is used 2. When verify is not enabled, we need to define a constant zero value Signed-off-by: Simon Glass --- common/cmd_hash.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/common/cmd_hash.c b/common/cmd_hash.c index 689c608..eb6a338 100644 --- a/common/cmd_hash.c +++ b/common/cmd_hash.c @@ -32,11 +32,15 @@ static int do_hash(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) #ifdef CONFIG_HASH_VERIFY int verify = 0; + if (argc < 4) + return CMD_RET_USAGE; if (!strcmp(argv[1], "-v")) { verify = 1; argc--; argv++; } +#else + const int verify = 0; #endif /* Move forward to 'algorithm' parameter */ argc--; -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 12/20] common: Use new numeric setenv functions
Use setenv_ulong(), setenv_hex() and setenv_addr() in common/ Signed-off-by: Simon Glass --- common/cmd_bootm.c| 11 +++ common/cmd_cbfs.c |4 +--- common/cmd_cramfs.c |4 +--- common/cmd_fdos.c |4 +--- common/cmd_jffs2.c|4 +--- common/cmd_load.c | 12 +++- common/cmd_mtdparts.c |4 +--- common/cmd_nand.c | 12 +++- common/cmd_nvedit.c |3 +-- common/cmd_reiser.c |4 +--- common/cmd_setexpr.c | 39 +++ common/cmd_unzip.c|4 +--- common/cmd_ximg.c |7 ++- common/cmd_zfs.c |3 +-- common/cmd_zip.c |4 +--- 15 files changed, 48 insertions(+), 71 deletions(-) diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index f7595c0..2debfe3 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -447,9 +447,7 @@ static int bootm_start_standalone(ulong iflag, int argc, char * const argv[]) /* Don't start if "autostart" is set to "no" */ if (((s = getenv("autostart")) != NULL) && (strcmp(s, "no") == 0)) { - char buf[32]; - sprintf(buf, "%lX", images.os.image_len); - setenv("filesize", buf); + setenv_hex("filesize", images.os.image_len); return 0; } appl = (int (*)(int, char * const []))(ulong)ntohl(images.ep); @@ -523,17 +521,14 @@ static int do_bootm_subcommand(cmd_tbl_t *cmdtp, int flag, int argc, case BOOTM_STATE_RAMDISK: { ulong rd_len = images.rd_end - images.rd_start; - char str[17]; ret = boot_ramdisk_high(&images.lmb, images.rd_start, rd_len, &images.initrd_start, &images.initrd_end); if (ret) return ret; - sprintf(str, "%lx", images.initrd_start); - setenv("initrd_start", str); - sprintf(str, "%lx", images.initrd_end); - setenv("initrd_end", str); + setenv_hex("initrd_start", images.initrd_start); + setenv_hex("initrd_end", images.initrd_end); } break; #endif diff --git a/common/cmd_cbfs.c b/common/cmd_cbfs.c index 3b6cfd8..f51534b 100644 --- a/common/cmd_cbfs.c +++ b/common/cmd_cbfs.c @@ -65,7 +65,6 @@ int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) const struct cbfs_cachenode *file; unsigned long offset; unsigned long count; - char buf[12]; long size; if (argc < 3) { @@ -95,8 +94,7 @@ int do_cbfs_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) printf("\n%ld bytes read\n", size); - sprintf(buf, "%lX", size); - setenv("filesize", buf); + setenv_hex("filesize", size); return 0; } diff --git a/common/cmd_cramfs.c b/common/cmd_cramfs.c index e7f496e..0e43ab6 100644 --- a/common/cmd_cramfs.c +++ b/common/cmd_cramfs.c @@ -146,11 +146,9 @@ int do_cramfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) size = cramfs_load ((char *) offset, &part, filename); if (size > 0) { - char buf[10]; printf("### CRAMFS load complete: %d bytes loaded to 0x%lx\n", size, offset); - sprintf(buf, "%x", size); - setenv("filesize", buf); + setenv_hex("filesize", size); } else { printf("### CRAMFS LOAD ERROR<%x> for %s!\n", size, filename); } diff --git a/common/cmd_fdos.c b/common/cmd_fdos.c index fbee861..5a35cc1 100644 --- a/common/cmd_fdos.c +++ b/common/cmd_fdos.c @@ -40,7 +40,6 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char *name; char *ep; int size; -char buf [12]; int drive = CONFIG_SYS_FDC_DRIVE_NUMBER; /* pre-set load_addr */ @@ -91,8 +90,7 @@ int do_fdosboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } flush_cache (load_addr, size); -sprintf(buf, "%x", size); -setenv("filesize", buf); + setenv_hex("filesize", size); printf("Floppy DOS load complete: %d bytes loaded to 0x%lx\n", size, load_addr); diff --git a/common/cmd_jffs2.c b/common/cmd_jffs2.c index 27296dd..4a4a000 100644 --- a/common/cmd_jffs2.c +++ b/common/cmd_jffs2.c @@ -525,11 +525,9 @@ int do_jffs2_fsload(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } if (size > 0) { - char buf[10]; printf("### %s load complete: %d bytes loaded to 0x%lx\n", fsname, size, offset); - sprintf(buf, "%x", size); - setenv("filesize", buf); +
[U-Boot] [PATCH 10/20] Reduce casting in mtest
Use a ulong for the command arguments, and only cast to an address when needed. This fixes warnings in sandbox where pointers are typically 64 bits long. Signed-off-by: Simon Glass --- common/cmd_mem.c | 30 ++ 1 files changed, 18 insertions(+), 12 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index a2f6cda..c45a31e 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -621,8 +621,9 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif /* CONFIG_LOOPW */ -static ulong mem_test_alt(vu_long *start, vu_long *end) +static ulong mem_test_alt(ulong start_addr, ulong end_addr) { + vu_long *start, *end; vu_long *addr; ulong errs = 0; ulong val, readback; @@ -650,6 +651,9 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) 0x, /* alternating 1/0 */ }; + start = (vu_long *)start_addr; + end = (vu_long *)end_addr; + /* * Data line test: write a pattern to the first * location, write the 1's complement to a 'parking' @@ -730,7 +734,7 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) * * Returns: 0 if the test succeeds, 1 if the test fails. */ - len = ((ulong)end - (ulong)start)/sizeof(vu_long); + len = (end_addr - start_addr) / sizeof(vu_long); pattern = (vu_long) 0x; anti_pattern = (vu_long) 0x; @@ -846,9 +850,10 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) return 0; } -static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, +static ulong mem_test_quick(ulong start_addr, ulong end_addr, vu_long pattern, int iteration) { + vu_long *start, *end; vu_long *addr; ulong errs = 0; ulong incr; @@ -869,6 +874,8 @@ static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, else pattern = ~pattern; } + start = (vu_long *)start_addr; + end = (vu_long *)end_addr; printf("\rPattern %08lX Writing..." "%12s" "\b\b\b\b\b\b\b\b\b\b", @@ -907,7 +914,7 @@ static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - vu_long *start, *end; + ulong start, end; int iteration_limit; int ret; ulong errs = 0; /* number of errors, or -1 if interrupted */ @@ -920,14 +927,14 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, #endif if (argc > 1) - start = (ulong *)simple_strtoul(argv[1], NULL, 16); + start = simple_strtoul(argv[1], NULL, 16); else - start = (ulong *)CONFIG_SYS_MEMTEST_START; + start = CONFIG_SYS_MEMTEST_START; if (argc > 2) - end = (ulong *)simple_strtoul(argv[2], NULL, 16); + end = simple_strtoul(argv[2], NULL, 16); else - end = (ulong *)(CONFIG_SYS_MEMTEST_END); + end = CONFIG_SYS_MEMTEST_END; if (argc > 3) pattern = (ulong)simple_strtoul(argv[3], NULL, 16); @@ -939,10 +946,9 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, else iteration_limit = 0; - printf("Testing %08x ... %08x:\n", (uint)(uintptr_t)start, - (uint)(uintptr_t)end); - debug("%s:%d: start 0x%p end 0x%p\n", - __func__, __LINE__, start, end); + printf("Testing %08x ... %08x:\n", (uint)start, (uint)end); + debug("%s:%d: start %#08lx end %#08lx\n", __func__, __LINE__, + start, end); for (iteration = 0; !iteration_limit || iteration < iteration_limit; -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 09/20] Bring mtest putc() into common code
If we get a Ctrl-C abort, we always print a newline. Move this repeated code out of the functions and into a single place in the caller. Signed-off-by: Simon Glass --- common/cmd_mem.c | 32 +--- 1 files changed, 9 insertions(+), 23 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 648f93b..a2f6cda 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -679,10 +679,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) "expected %08lx, actual %08lx\n", val, readback); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } *addr = ~val; *dummy = val; @@ -692,10 +690,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) "Is %08lx, should be %08lx\n", readback, ~val); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } } } @@ -760,10 +756,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) " expected 0x%.8lx, actual 0x%.8lx\n", (ulong)&start[offset], pattern, temp); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } } start[test_offset] = pattern; @@ -783,10 +777,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) " actual 0x%.8lx\n", (ulong)&start[offset], pattern, temp); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } } start[test_offset] = pattern; @@ -825,10 +817,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) " expected 0x%.8lx, actual 0x%.8lx)\n", (ulong)&start[offset], pattern, temp); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } anti_pattern = ~pattern; @@ -847,10 +837,8 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) " expected 0x%.8lx, actual 0x%.8lx)\n", (ulong)&start[offset], anti_pattern, temp); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } start[offset] = 0; } @@ -902,10 +890,8 @@ static ulong mem_test_quick(vu_long *start, vu_long *end, vu_long pattern, "found %08lX, expected %08lX\n", (uint)(uintptr_t)addr, readback, val); errs++; - if (ctrlc()) { - putc('\n'); + if (ctrlc()) return -1; - } } val += incr; } @@ -962,7 +948,6 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, !iteration_limit || iteration < iteration_limit; iteration++) { if (ctrlc()) { - putc('\n'); errs = -1UL; break; } @@ -976,7 +961,8 @@ static int do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc, } if (errs == -1UL) { - /* Memory test was aborted */ + /* Memory test was aborted - write a newline to finish off */ + putc('\n'); ret = 1; } else { printf("Tested %d iteration(s) with %lu errors.\n", -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/li
[U-Boot] [PATCH 14/20] net: Use new numeric setenv functions
Use setenv_hex() and setenv_addr() in net/ Signed-off-by: Simon Glass --- drivers/net/fm/fm.c |4 +--- net/net.c |8 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/net/fm/fm.c b/drivers/net/fm/fm.c index 49c74c2..8d70586 100644 --- a/drivers/net/fm/fm.c +++ b/drivers/net/fm/fm.c @@ -362,7 +362,6 @@ static void fm_init_qmi(struct fm_qmi_common *qmi) int fm_init_common(int index, struct ccsr_fman *reg) { int rc; - char env_addr[32]; #if defined(CONFIG_SYS_QE_FMAN_FW_IN_NOR) void *addr = (void *)CONFIG_SYS_QE_FMAN_FW_ADDR; #elif defined(CONFIG_SYS_QE_FMAN_FW_IN_NAND) @@ -416,8 +415,7 @@ int fm_init_common(int index, struct ccsr_fman *reg) rc = fman_upload_firmware(index, ®->fm_imem, addr); if (rc) return rc; - sprintf(env_addr, "0x%lx", (long unsigned int)addr); - setenv("fman_ucode", env_addr); + setenv_addr("fman_ucode", addr); fm_init_muram(index, ®->muram); fm_init_qmi(®->fm_qmi_common); diff --git a/net/net.c b/net/net.c index a40cde1..df94789 100644 --- a/net/net.c +++ b/net/net.c @@ -528,15 +528,11 @@ restart: case NETLOOP_SUCCESS: net_cleanup_loop(); if (NetBootFileXferSize > 0) { - char buf[20]; printf("Bytes transferred = %ld (%lx hex)\n", NetBootFileXferSize, NetBootFileXferSize); - sprintf(buf, "%lX", NetBootFileXferSize); - setenv("filesize", buf); - - sprintf(buf, "%lX", (unsigned long)load_addr); - setenv("fileaddr", buf); + setenv_hex("filesize", NetBootFileXferSize); + setenv_hex("fileaddr", load_addr); } if (protocol != NETCONS) eth_halt(); -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 13/20] drivers: Use new numeric setenv functions
Use setenv_ulong(), setenv_hex() and setenv_addr() in drivers/ Signed-off-by: Simon Glass --- fs/fs.c |4 +--- fs/ubifs/ubifs.c |4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 023e7ef..2c9f2c5 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -256,7 +256,6 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], unsigned long bytes; unsigned long pos; int len_read; - char buf[12]; unsigned long time; if (argc < 2) @@ -308,8 +307,7 @@ int do_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], } puts("\n"); - sprintf(buf, "0x%x", len_read); - setenv("filesize", buf); + setenv_hex("filesize", len_read); return 0; } diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c index 44be3f5..273c0a9 100644 --- a/fs/ubifs/ubifs.c +++ b/fs/ubifs/ubifs.c @@ -687,7 +687,6 @@ int ubifs_load(char *filename, u32 addr, u32 size) int i; int count; int last_block_size = 0; - char buf [10]; c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY); /* ubifs_findfile will resolve symlinks, so we know that we get @@ -740,8 +739,7 @@ int ubifs_load(char *filename, u32 addr, u32 size) if (err) printf("Error reading file '%s'\n", filename); else { - sprintf(buf, "%X", size); - setenv("filesize", buf); + setenv_hex("filesize", size); printf("Done\n"); } -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 04/20] sandbox: Add un/map_sysmen() to deal with sandbox's ram_buf
Sandbox doesn't actually provide U-Boot access to the machine's physical memory. Instead it provides a RAM buffer of configurable size, and all memory accesses are within that buffer. Sandbox memory starts at 0 and is CONFIG_DRAM_SIZE bytes in size. Allowing access outside this buffer might produce unpredictable results in the event of an error, and would expose the host machine's memory architecture to the sandbox U-Boot. Most U-Boot functions assume that they can just access memory at given address. For sandbox this is not true. Add a map_sysmem() call which converts a U-Boot address to a system address. In most cases this is a NOP, but for sandbox it returns a pointer to that memory inside the RAM buffer. To get a U-Boot feature to work correctly within sandbox, you should call map_sysmem() to get a pointer to the address, and then use that address for any U-Boot memory accesses. Signed-off-by: Simon Glass --- README|9 + arch/sandbox/config.mk|1 + arch/sandbox/include/asm/io.h | 10 ++ include/common.h | 12 4 files changed, 32 insertions(+), 0 deletions(-) diff --git a/README b/README index 78f40df..8dd3867 100644 --- a/README +++ b/README @@ -3769,6 +3769,15 @@ Low Level (hardware related) configuration options: that is executed before the actual U-Boot. E.g. when compiling a NAND SPL. +- CONFIG_ARCH_MAP_SYSMEM + Generally U-Boot (and in particular the md command) uses + effective address. It is therefore not necessary to regard + U-Boot address as virtual addresses that need to be translated + to physical addresses. However, sandbox requires this, since + it maintains its own little RAM buffer which contains all + addressable memory. This option causes some memory accesses + to be mapped through map_sysmem() / unmap_sysmem(). + - CONFIG_USE_ARCH_MEMCPY CONFIG_USE_ARCH_MEMSET If these options are used a optimized version of memcpy/memset will diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk index 02ce4a4..4fd0d4e 100644 --- a/arch/sandbox/config.mk +++ b/arch/sandbox/config.mk @@ -18,4 +18,5 @@ # MA 02111-1307 USA PLATFORM_CPPFLAGS += -DCONFIG_SANDBOX -D__SANDBOX__ -U_FORTIFY_SOURCE +PLATFORM_CPPFLAGS += -DCONFIG_ARCH_MAP_SYSMEM PLATFORM_LIBS += -lrt diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 0392d21..d8c0236 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -39,3 +39,13 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags) { } + +/* For sandbox, we want addresses to point into our RAM buffer */ +static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) +{ + return map_physmem(paddr, len, MAP_WRBACK); +} + +static inline void unmap_sysmem(const void *vaddr) +{ +} diff --git a/include/common.h b/include/common.h index f2035c0..08d01db 100644 --- a/include/common.h +++ b/include/common.h @@ -861,6 +861,18 @@ int cpu_disable(int nr); int cpu_release(int nr, int argc, char * const argv[]); #endif +/* Define a null map_sysmem() if the architecture doesn't use it */ +# ifndef CONFIG_ARCH_MAP_SYSMEM +static inline void *map_sysmem(phys_addr_t paddr, unsigned long len) +{ + return (void *)(uintptr_t)paddr; +} + +static inline void unmap_sysmem(const void *vaddr) +{ +} +# endif + #endif /* __ASSEMBLY__ */ #ifdef CONFIG_PPC -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 16/20] Roll crc32 into hash infrastructure
Add the CRC32 algorithm to the list of available hashes, and make the crc32 command use hash_command(). Add a new crc32_wd_buf() to make this possible, which puts its result in a buffer rather than returning it as a 32-bit value. Signed-off-by: Simon Glass --- common/cmd_mem.c | 73 - common/hash.c|6 include/hash.h |2 +- include/u-boot/crc.h | 11 +++ lib/crc32.c |9 ++ 5 files changed, 33 insertions(+), 68 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index c45a31e..701157d 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -32,6 +32,7 @@ #ifdef CONFIG_HAS_DATAFLASH #include #endif +#include #include #include @@ -1093,89 +1094,27 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[]) #ifdef CONFIG_CMD_CRC32 -#ifndef CONFIG_CRC32_VERIFY - static int do_mem_crc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { - ulong addr, length; - ulong crc; - ulong *ptr; - - if (argc < 3) - return CMD_RET_USAGE; - - addr = simple_strtoul (argv[1], NULL, 16); - addr += base_address; - - length = simple_strtoul (argv[2], NULL, 16); - - crc = crc32_wd (0, (const uchar *) addr, length, CHUNKSZ_CRC32); - - printf ("CRC32 for %08lx ... %08lx ==> %08lx\n", - addr, addr + length - 1, crc); - - if (argc > 3) { - ptr = (ulong *) simple_strtoul (argv[3], NULL, 16); - *ptr = crc; - } - - return 0; -} - -#else /* CONFIG_CRC32_VERIFY */ - -int do_mem_crc (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) -{ - ulong addr, length; - ulong crc; - ulong *ptr; - ulong vcrc; - int verify; + int verify = 0; int ac; char * const *av; - if (argc < 3) { -usage: + if (argc < 3) return CMD_RET_USAGE; - } av = argv + 1; ac = argc - 1; +#ifdef CONFIG_HASH_VERIFY if (strcmp(*av, "-v") == 0) { verify = 1; av++; ac--; - if (ac < 3) - goto usage; - } else - verify = 0; - - addr = simple_strtoul(*av++, NULL, 16); - addr += base_address; - length = simple_strtoul(*av++, NULL, 16); - - crc = crc32_wd (0, (const uchar *) addr, length, CHUNKSZ_CRC32); - - if (!verify) { - printf ("CRC32 for %08lx ... %08lx ==> %08lx\n", - addr, addr + length - 1, crc); - if (ac > 2) { - ptr = (ulong *) simple_strtoul (*av++, NULL, 16); - *ptr = crc; - } - } else { - vcrc = simple_strtoul(*av++, NULL, 16); - if (vcrc != crc) { - printf ("CRC32 for %08lx ... %08lx ==> %08lx != %08lx ** ERROR **\n", - addr, addr + length - 1, crc, vcrc); - return 1; - } } +#endif - return 0; - + return hash_command("crc32", verify, cmdtp, flag, ac, av); } -#endif /* CONFIG_CRC32_VERIFY */ #endif diff --git a/common/hash.c b/common/hash.c index e3a6e43..e92b4b1 100644 --- a/common/hash.c +++ b/common/hash.c @@ -50,6 +50,12 @@ static struct hash_algo hash_algo[] = { CHUNKSZ_SHA256, }, #endif + { + "CRC32", + 4, + crc32_wd_buf, + CHUNKSZ_CRC32, + }, }; /** diff --git a/include/hash.h b/include/hash.h index 34ba558..ba2ba65 100644 --- a/include/hash.h +++ b/include/hash.h @@ -22,7 +22,7 @@ #ifndef _HASH_H #define _HASH_H -#ifdef CONFIG_SHA1SUM_VERIFY +#if defined(CONFIG_SHA1SUM_VERIFY) || defined(CONFIG_CRC32_VERIFY) #define CONFIG_HASH_VERIFY #endif diff --git a/include/u-boot/crc.h b/include/u-boot/crc.h index 07badbf..08e509e 100644 --- a/include/u-boot/crc.h +++ b/include/u-boot/crc.h @@ -30,4 +30,15 @@ uint32_t crc32 (uint32_t, const unsigned char *, uint); uint32_t crc32_wd (uint32_t, const unsigned char *, uint, uint); uint32_t crc32_no_comp (uint32_t, const unsigned char *, uint); +/** + * crc32_wd_buf - Perform CRC32 on a buffer and return result in buffer + * + * @input: Input buffer + * @ilen: Input buffer length + * @output:Place to put checksum result (4 bytes) + * @chunk_sz: Trigger watchdog after processing this many bytes + */ +void crc32_wd_buf(const unsigned char *input, uint ilen, + unsigned char *output, uint chunk_sz); + #endif /* _UBOOT_CRC_H */ diff --git a/lib/crc32.c b/lib/crc32.c index 27335a3..76205da 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -249,3 +249,12 @@ uint32_t ZEXPORT crc32_wd (uint32_t crc, return crc; } + +void crc32_wd_buf(const unsigned char *input, unsigned i
[U-Boot] [PATCH 08/20] Fix mtest indenting
Some of the inner loops are not indented correctly. Fix this. Signed-off-by: Simon Glass --- common/cmd_mem.c | 324 +++--- 1 files changed, 162 insertions(+), 162 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index 41c1e70..648f93b 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -650,32 +650,31 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) 0x, /* alternating 1/0 */ }; - /* -* Data line test: write a pattern to the first -* location, write the 1's complement to a 'parking' -* address (changes the state of the data bus so a -* floating bus doen't give a false OK), and then -* read the value back. Note that we read it back -* into a variable because the next time we read it, -* it might be right (been there, tough to explain to -* the quality guys why it prints a failure when the -* "is" and "should be" are obviously the same in the -* error message). -* -* Rather than exhaustively testing, we test some -* patterns by shifting '1' bits through a field of -* '0's and '0' bits through a field of '1's (i.e. -* pattern and ~pattern). -*/ - addr = start; - for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); - j++) { - val = bitpattern[j]; - for (; val != 0; val <<= 1) { + /* +* Data line test: write a pattern to the first +* location, write the 1's complement to a 'parking' +* address (changes the state of the data bus so a +* floating bus doen't give a false OK), and then +* read the value back. Note that we read it back +* into a variable because the next time we read it, +* it might be right (been there, tough to explain to +* the quality guys why it prints a failure when the +* "is" and "should be" are obviously the same in the +* error message). +* +* Rather than exhaustively testing, we test some +* patterns by shifting '1' bits through a field of +* '0's and '0' bits through a field of '1's (i.e. +* pattern and ~pattern). +*/ + addr = start; + for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) { + val = bitpattern[j]; + for (; val != 0; val <<= 1) { *addr = val; *dummy = ~val; /* clear the test data off the bus */ readback = *addr; - if(readback != val) { + if (readback != val) { printf("FAILURE (data line): " "expected %08lx, actual %08lx\n", val, readback); @@ -698,129 +697,130 @@ static ulong mem_test_alt(vu_long *start, vu_long *end) return -1; } } - } } + } - /* -* Based on code whose Original Author and Copyright -* information follows: Copyright (c) 1998 by Michael -* Barr. This software is placed into the public -* domain and may be used for any purpose. However, -* this notice must not be changed or removed and no -* warranty is either expressed or implied by its -* publication or distribution. -*/ - - /* -* Address line test -* -* Description: Test the address bus wiring in a -* memory region by performing a walking -* 1's test on the relevant bits of the -* address and checking for aliasing. -* This test will find single-bit -* address failures such as stuck -high, -* stuck-low, and shorted pins. The base -* address and size of the region are -* selected by the caller. -* -* Notes: For best results, the selected base -* address should have enough LSB 0's to -* guarantee single address bit changes. -* For example, to test a 64-Kbyte -* region, select a base address on a -* 64-Kbyte boundary. Also, select the -* region
[U-Boot] [PATCH 17/20] sandbox: config: Enable hash functions and mtest
Enable the hash command and sha1/256 hashing for sandbox. Also use a better address for memory testing (since the existing one is set up for linux host memory space). Signed-off-by: Simon Glass --- include/configs/sandbox.h |9 +++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 9c431bf..9f51a0b 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -63,8 +63,8 @@ #define CONFIG_SYS_HZ 1000 /* Memory things - we don't really want a memory test */ -#define CONFIG_SYS_LOAD_ADDR 0x1000 -#define CONFIG_SYS_MEMTEST_START 0x1000 +#define CONFIG_SYS_LOAD_ADDR 0x +#define CONFIG_SYS_MEMTEST_START 0x0010 #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000) #define CONFIG_PHYS_64BIT @@ -85,6 +85,11 @@ #undef CONFIG_CMD_NET #undef CONFIG_CMD_NFS +#define CONFIG_CMD_HASH +#define CONFIG_HASH_VERIFY +#define CONFIG_SHA1 +#define CONFIG_SHA256 + #define CONFIG_BOOTARGS "" #define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0" \ -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 15/20] image: Use crc header file instead of C prototypes
We have an existing header which the crc32 definitions, so use it. Signed-off-by: Simon Glass --- common/image.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/image.c b/common/image.c index 95498e6..936b08c 100644 --- a/common/image.c +++ b/common/image.c @@ -75,6 +75,8 @@ static const image_header_t *image_get_ramdisk(ulong rd_addr, uint8_t arch, #include #endif /* !USE_HOSTCC*/ +#include + static const table_entry_t uimage_arch[] = { { IH_ARCH_INVALID,NULL, "Invalid ARCH", }, { IH_ARCH_ALPHA, "alpha","Alpha",}, @@ -161,8 +163,6 @@ static const table_entry_t uimage_comp[] = { { -1, "", "", }, }; -uint32_t crc32(uint32_t, const unsigned char *, uint); -uint32_t crc32_wd(uint32_t, const unsigned char *, uint, uint); #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) static void genimg_print_time(time_t timestamp); #endif -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 19/20] sandbox: Update mtest to fix crashes
Use map_sysmem() in the memory tester so that it works as expected on sandbox. Signed-off-by: Simon Glass --- common/cmd_mem.c | 97 +- 1 files changed, 52 insertions(+), 45 deletions(-) diff --git a/common/cmd_mem.c b/common/cmd_mem.c index f83acdf..1bbe166 100644 --- a/common/cmd_mem.c +++ b/common/cmd_mem.c @@ -626,21 +626,19 @@ int do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } #endif /* CONFIG_LOOPW */ -static ulong mem_test_alt(ulong start_addr, ulong end_addr) +static ulong mem_test_alt(vu_long *buf, ulong start_addr, ulong end_addr, + vu_long *dummy) { - vu_long *start, *end; vu_long *addr; ulong errs = 0; ulong val, readback; int j; - vu_long len; vu_long offset; vu_long test_offset; vu_long pattern; vu_long temp; vu_long anti_pattern; vu_long num_words; - vu_long *dummy = (vu_long *)CONFIG_SYS_MEMTEST_SCRATCH; static const ulong bitpattern[] = { 0x0001, /* single bit */ 0x0003, /* two adjacent bits */ @@ -652,8 +650,7 @@ static ulong mem_test_alt(ulong start_addr, ulong end_addr) 0x, /* alternating 1/0 */ }; - start = (vu_long *)start_addr; - end = (vu_long *)end_addr; + num_words = (end_addr - start_addr) / sizeof(vu_long); /* * Data line test: write a pattern to the first @@ -672,11 +669,11 @@ static ulong mem_test_alt(ulong start_addr, ulong end_addr) * '0's and '0' bits through a field of '1's (i.e. * pattern and ~pattern). */ - addr = start; + addr = buf; for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) { val = bitpattern[j]; for (; val != 0; val <<= 1) { - *addr = val; + *addr = val; *dummy = ~val; /* clear the test data off the bus */ readback = *addr; if (readback != val) { @@ -735,58 +732,56 @@ static ulong mem_test_alt(ulong start_addr, ulong end_addr) * * Returns: 0 if the test succeeds, 1 if the test fails. */ - len = (end_addr - start_addr) / sizeof(vu_long); pattern = (vu_long) 0x; anti_pattern = (vu_long) 0x; - debug("%s:%d: length = 0x%.8lx\n", - __func__, __LINE__, len); + debug("%s:%d: length = 0x%.8lx\n", __func__, __LINE__, num_words); /* * Write the default pattern at each of the * power-of-two offsets. */ - for (offset = 1; offset < len; offset <<= 1) - start[offset] = pattern; + for (offset = 1; offset < num_words; offset <<= 1) + addr[offset] = pattern; /* * Check for address bits stuck high. */ test_offset = 0; - start[test_offset] = anti_pattern; + addr[test_offset] = anti_pattern; - for (offset = 1; offset < len; offset <<= 1) { - temp = start[offset]; + for (offset = 1; offset < num_words; offset <<= 1) { + temp = addr[offset]; if (temp != pattern) { printf("\nFAILURE: Address bit stuck high @ 0x%.8lx:" " expected 0x%.8lx, actual 0x%.8lx\n", - (ulong)&start[offset], pattern, temp); + start_addr + offset, pattern, temp); errs++; if (ctrlc()) return -1; } } - start[test_offset] = pattern; + addr[test_offset] = pattern; WATCHDOG_RESET(); /* * Check for addr bits stuck low or shorted. */ - for (test_offset = 1; test_offset < len; test_offset <<= 1) { - start[test_offset] = anti_pattern; + for (test_offset = 1; test_offset < num_words; test_offset <<= 1) { + addr[test_offset] = anti_pattern; - for (offset = 1; offset < len; offset <<= 1) { - temp = start[offset]; + for (offset = 1; offset < num_words; offset <<= 1) { + temp = addr[offset]; if ((temp != pattern) && (offset != test_offset)) { printf("\nFAILURE: Address bit stuck low or" " shorted @ 0x%.8lx: expected 0x%.8lx," " actual 0x%.8lx\n", - (ulong)&start[offset], pattern, temp); + start_addr + offset, pattern, temp); errs++; if (ctrlc())
[U-Boot] [PATCH 0/11] sandbox: Add filesystem support
This series adds support for filesystems to sandbox. While we don't yet have access to host machine block devices, we can access files on the host through a new 'host' filesystem type and the new sandbox command 'sb'. For example: sb load host 0 1000 foo.bar will load foo.bar from the host into memory at address 1000. The '0' parameter is the device number, currently unused. While doing this work, I noticed that fs.c had code that probably belongs more in the filesystems themselves. So this series moves fat/ext4 code into those files. This removes most of the #ifdefs from this file, as well as the #defines of functions to 'unsupported'. Now there is a list of filesystems that we support, and if we don't find the one we need, we automatically fall back to the 'unsupported' one. Finally, the ext4 write support is moved into a separate file since ext4fs.c was over 3500 lines and the write support seems entirely separate from the main function in that file. Simon Glass (11): ext4: Split write support into its own file fs: Fully populate the filesystem method struct fs: Use filesystem methods instead of switch() fs: Tell probe functions where to put their results fs: Use map_sysmem() on read fs: Move ls and read methods into ext4, fat sandbox: Add a way of obtaining directory listings sandbox: Add host filesystem sandbox: Add 'sb' command to access filesystem features sandbox: Enable ext4 and fat filesystems sandbox: config: Enable sandbox command Makefile |1 + README|1 + arch/sandbox/cpu/os.c | 101 + common/Makefile |1 + common/cmd_sandbox.c | 63 +++ disk/part.c | 17 + fs/ext4/Makefile |2 +- fs/ext4/ext4_write.c | 996 + fs/ext4/ext4fs.c | 962 +-- fs/fat/fat.c | 17 + fs/fs.c | 237 +--- fs/sandbox/Makefile | 47 +++ fs/sandbox/sandboxfs.c| 83 include/config_cmd_all.h |1 + include/configs/sandbox.h |9 + include/ext4fs.h |3 + include/fat.h |2 + include/fs.h |1 + include/os.h | 48 +++ include/sandboxfs.h | 30 ++ 20 files changed, 1533 insertions(+), 1089 deletions(-) create mode 100644 common/cmd_sandbox.c create mode 100644 fs/ext4/ext4_write.c create mode 100644 fs/sandbox/Makefile create mode 100644 fs/sandbox/sandboxfs.c create mode 100644 include/sandboxfs.h -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 02/11] fs: Fully populate the filesystem method struct
There is a structure in fs.c with just a probe method. By adding methods for other operations, we can avoid lots of #ifdefs and switch()s. As a first step, create the structure ready for use. Signed-off-by: Simon Glass --- fs/fs.c | 56 +++- 1 files changed, 47 insertions(+), 9 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 2c9f2c5..66835e2 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -27,6 +27,12 @@ static block_dev_desc_t *fs_dev_desc; static disk_partition_t fs_partition; static int fs_type = FS_TYPE_ANY; +static inline int fs_probe_unsupported(void) +{ + printf("** Unrecognized filesystem type **\n"); + return -1; +} + static inline int fs_ls_unsupported(const char *dirname) { printf("** Unrecognized filesystem type **\n"); @@ -40,6 +46,10 @@ static inline int fs_read_unsupported(const char *filename, ulong addr, return -1; } +static inline void fs_close_unsupported(void) +{ +} + #ifdef CONFIG_FS_FAT static int fs_probe_fat(void) { @@ -143,29 +153,57 @@ static inline void fs_close_ext(void) #define fs_read_ext fs_read_unsupported #endif -static struct { +struct fstype_info { int fstype; int (*probe)(void); -} fstypes[] = { + int (*ls)(const char *dirname); + int (*read)(const char *filename, ulong addr, int offset, int len); + void (*close)(void); +}; + +static struct fstype_info fstypes[] = { +#ifdef CONFIG_FS_FAT { .fstype = FS_TYPE_FAT, .probe = fs_probe_fat, + .close = fs_close_fat, + .ls = file_fat_ls, + .read = fs_read_fat, }, +#endif +#ifdef CONFIG_FS_EXT4 { .fstype = FS_TYPE_EXT, .probe = fs_probe_ext, + .close = fs_close_ext, + .ls = ext4fs_ls, + .read = fs_read_ext, + }, +#endif + { + .fstype = FS_TYPE_ANY, + .probe = fs_probe_unsupported, + .close = fs_close_unsupported, + .ls = fs_ls_unsupported, + .read = fs_read_unsupported, }, }; int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) { + struct fstype_info *info; int part, i; #ifdef CONFIG_NEEDS_MANUAL_RELOC static int relocated; if (!relocated) { - for (i = 0; i < ARRAY_SIZE(fstypes); i++) - fstypes[i].probe += gd->reloc_off; + for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); + i++, info++) { + info->probe += gd->reloc_off; + info->close += gd->reloc_off; + info->ls += gd->reloc_off; + info->read += gd->reloc_off; + } relocated = 1; } #endif @@ -175,17 +213,17 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) if (part < 0) return -1; - for (i = 0; i < ARRAY_SIZE(fstypes); i++) { - if ((fstype != FS_TYPE_ANY) && (fstype != fstypes[i].fstype)) + for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes); i++, info++) { + if (fstype != FS_TYPE_ANY && info->fstype != FS_TYPE_ANY && + fstype != info->fstype) continue; - if (!fstypes[i].probe()) { - fs_type = fstypes[i].fstype; + if (!info->probe()) { + fs_type = info->fstype; return 0; } } - printf("** Unrecognized filesystem type **\n"); return -1; } -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 07/11] sandbox: Add a way of obtaining directory listings
This implementation uses opendir()/readdir() to access the directory information and then puts it in a linked list for the caller's use. Signed-off-by: Simon Glass --- arch/sandbox/cpu/os.c | 101 + include/os.h | 48 +++ 2 files changed, 149 insertions(+), 0 deletions(-) diff --git a/arch/sandbox/cpu/os.c b/arch/sandbox/cpu/os.c index 3e37c93..d075407 100644 --- a/arch/sandbox/cpu/os.c +++ b/arch/sandbox/cpu/os.c @@ -19,10 +19,13 @@ * MA 02111-1307 USA */ +#include #include #include #include +#include #include +#include #include #include #include @@ -261,3 +264,101 @@ int os_parse_args(struct sandbox_state *state, int argc, char *argv[]) return 0; } + +void os_dirent_free(struct os_dirent_node *node) +{ + struct os_dirent_node *next; + + while (node) { + next = node->next; + free(node); + node = next; + } +} + +int os_dirent_ls(const char *dirname, struct os_dirent_node **headp) +{ + struct dirent entry, *result; + struct os_dirent_node *head, *node, *next; + struct stat buf; + DIR *dir; + int ret; + char *fname; + int len; + + *headp = NULL; + dir = opendir(dirname); + if (!dir) + return -1; + + /* Create a buffer for the maximum filename length */ + len = sizeof(entry.d_name) + strlen(dirname) + 2; + fname = malloc(len); + if (!fname) { + ret = -ENOMEM; + goto done; + } + + for (node = head = NULL;; node = next) { + ret = readdir_r(dir, &entry, &result); + if (ret || !result) + break; + next = malloc(sizeof(*node) + strlen(entry.d_name) + 1); + if (!next) { + os_dirent_free(head); + ret = -ENOMEM; + goto done; + } + strcpy(next->name, entry.d_name); + switch (entry.d_type) { + case DT_REG: + next->type = OS_FILET_REG; + break; + case DT_DIR: + next->type = OS_FILET_DIR; + break; + case DT_LNK: + next->type = OS_FILET_LNK; + break; + } + next->size = 0; + snprintf(fname, len, "%s/%s", dirname, next->name); + if (!stat(fname, &buf)) + next->size = buf.st_size; + if (node) + node->next = next; + if (!head) + head = node; + } + *headp = head; + +done: + closedir(dir); + return ret; +} + +const char *os_dirent_typename[OS_FILET_COUNT] = { + " ", + "SYM", + "DIR", + "???", +}; + +const char *os_dirent_get_typename(enum os_dirent_t type) +{ + if (type >= 0 && type < OS_FILET_COUNT) + return os_dirent_typename[type]; + + return os_dirent_typename[OS_FILET_UNKNOWN]; +} + +ssize_t os_get_filesize(const char *fname) +{ + struct stat buf; + int ret; + + ret = stat(fname, &buf); + if (ret) + return ret; + return buf.st_size; +} diff --git a/include/os.h b/include/os.h index c452d1b..038aba9 100644 --- a/include/os.h +++ b/include/os.h @@ -146,4 +146,52 @@ u64 os_get_nsec(void); */ int os_parse_args(struct sandbox_state *state, int argc, char *argv[]); +/* + * Types of directory entry that we support. See also os_dirent_typename in + * the C file. + */ +enum os_dirent_t { + OS_FILET_REG, /* Regular file */ + OS_FILET_LNK, /* Symbolic link */ + OS_FILET_DIR, /* Directory */ + OS_FILET_UNKNOWN, /* Something else */ + + OS_FILET_COUNT, +}; + +/** A directory entry node, containing information about a single dirent */ +struct os_dirent_node { + struct os_dirent_node *next;/* Pointer to next node, or NULL */ + ulong size; /* Size of file in bytes */ + enum os_dirent_t type; /* Type of entry */ + char name[0]; /* Name of entry */ +}; + +/** + * Get a directionry listing + * + * This allocates and returns a linked list containing the directory listing. + * + * @param dirname Directory to examine + * @param headpReturns pointer to head of linked list, or NULL if none + * @return 0 if ok, -ve on error + */ +int os_dirent_ls(const char *dirname, struct os_dirent_node **headp); + +/** + * Get the name of a directory entry type + * + * @param type Type to cehck + * @return string containing the name of that type, or "???" if none/invalid + */ +const char *os_dirent_get_typename(enum os_dirent_t type); + +/** + * Get the size of
[U-Boot] [PATCH 06/11] fs: Move ls and read methods into ext4, fat
It doesn't make a lot of sense to have these methods in fs.c. They are filesystem-specific, not generic code. Add each to the relevant filesystem and remove the associated #ifdefs in fs.c. Signed-off-by: Simon Glass --- fs/ext4/ext4fs.c | 37 + fs/fat/fat.c | 17 fs/fs.c | 118 -- include/ext4fs.h |3 + include/fat.h|2 + 5 files changed, 67 insertions(+), 110 deletions(-) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 7fdb463..4e2 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -191,3 +191,40 @@ int ext4fs_read(char *buf, unsigned len) return ext4fs_read_file(ext4fs_file, 0, len, buf); } + +int ext4fs_probe(block_dev_desc_t *fs_dev_desc, +disk_partition_t *fs_partition) +{ + ext4fs_set_blk_dev(fs_dev_desc, fs_partition); + + if (!ext4fs_mount(fs_partition->size)) { + ext4fs_close(); + return -1; + } + + return 0; +} + +int ext4_read_file(const char *filename, void *buf, int offset, int len) +{ + int file_len; + int len_read; + + if (offset != 0) { + printf("** Cannot support non-zero offset **\n"); + return -1; + } + + file_len = ext4fs_open(filename); + if (file_len < 0) { + printf("** File not found %s **\n", filename); + return -1; + } + + if (len == 0) + len = file_len; + + len_read = ext4fs_read(buf, len); + + return len_read; +} diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 393c378..82135b5 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1256,3 +1256,20 @@ long file_fat_read(const char *filename, void *buffer, unsigned long maxsize) { return file_fat_read_at(filename, 0, buffer, maxsize); } + +int fat_read_file(const char *filename, void *buf, int offset, int len) +{ + int len_read; + + len_read = file_fat_read_at(filename, offset, buf, len); + if (len_read == -1) { + printf("** Unable to read file %s **\n", filename); + return -1; + } + + return len_read; +} + +void fat_close(void) +{ +} diff --git a/fs/fs.c b/fs/fs.c index 0cbec99..95c882e 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -50,110 +50,6 @@ static inline void fs_close_unsupported(void) { } -#ifdef CONFIG_FS_FAT -static int fs_probe_fat(block_dev_desc_t *fs_dev_desc, - disk_partition_t *fs_partition) -{ - return fat_set_blk_dev(fs_dev_desc, fs_partition); -} - -static void fs_close_fat(void) -{ -} - -#define fs_ls_fat file_fat_ls - -static int fs_read_fat(const char *filename, void *buf, int offset, int len) -{ - int len_read; - - len_read = file_fat_read_at(filename, offset, buf, len); - if (len_read == -1) { - printf("** Unable to read file %s **\n", filename); - return -1; - } - - return len_read; -} -#else -static inline int fs_probe_fat(void) -{ - return -1; -} - -static inline void fs_close_fat(void) -{ -} - -#define fs_ls_fat fs_ls_unsupported -#define fs_read_fat fs_read_unsupported -#endif - -#ifdef CONFIG_FS_EXT4 -static int fs_probe_ext(block_dev_desc_t *fs_dev_desc, - disk_partition_t *fs_partition) -{ - ext4fs_set_blk_dev(fs_dev_desc, fs_partition); - - if (!ext4fs_mount(fs_partition->size)) { - ext4fs_close(); - return -1; - } - - return 0; -} - -static void fs_close_ext(void) -{ - ext4fs_close(); -} - -#define fs_ls_ext ext4fs_ls - -static int fs_read_ext(const char *filename, void *buf, int offset, int len) -{ - int file_len; - int len_read; - - if (offset != 0) { - printf("** Cannot support non-zero offset **\n"); - return -1; - } - - file_len = ext4fs_open(filename); - if (file_len < 0) { - printf("** File not found %s **\n", filename); - ext4fs_close(); - return -1; - } - - if (len == 0) - len = file_len; - - len_read = ext4fs_read(buf, len); - ext4fs_close(); - - if (len_read != len) { - printf("** Unable to read file %s **\n", filename); - return -1; - } - - return len_read; -} -#else -static inline int fs_probe_ext(void) -{ - return -1; -} - -static inline void fs_close_ext(void) -{ -} - -#define fs_ls_ext fs_ls_unsupported -#define fs_read_ext fs_read_unsupported -#endif - struct fstype_info { int fstype; int (*probe)(block_dev_desc_t *fs_dev_desc, @@ -167,19 +63,19 @@ static struct fstype_info fstypes[] = { #ifdef CONFIG_FS_FAT { .fstype = FS_TYPE_FAT, - .probe = fs_probe_fat, - .close = fs_close_fat, + .probe = fat_set_blk_dev, + .close = fat_close,
[U-Boot] [PATCH 04/11] fs: Tell probe functions where to put their results
Rather than rely on global variables for the probe functions, pass in the information that we need filled in. This allows us to potentially keep the variables private to fs.c in the future, and the meaning of the probe function is clearer. Signed-off-by: Simon Glass --- fs/fs.c | 20 1 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 856d8ba..3561727 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -27,7 +27,8 @@ static block_dev_desc_t *fs_dev_desc; static disk_partition_t fs_partition; static int fs_type = FS_TYPE_ANY; -static inline int fs_probe_unsupported(void) +static inline int fs_probe_unsupported(block_dev_desc_t *fs_dev_desc, + disk_partition_t *fs_partition) { printf("** Unrecognized filesystem type **\n"); return -1; @@ -49,9 +50,10 @@ static inline void fs_close_unsupported(void) } #ifdef CONFIG_FS_FAT -static int fs_probe_fat(void) +static int fs_probe_fat(block_dev_desc_t *fs_dev_desc, + disk_partition_t *fs_partition) { - return fat_set_blk_dev(fs_dev_desc, &fs_partition); + return fat_set_blk_dev(fs_dev_desc, fs_partition); } static void fs_close_fat(void) @@ -88,11 +90,12 @@ static inline void fs_close_fat(void) #endif #ifdef CONFIG_FS_EXT4 -static int fs_probe_ext(void) +static int fs_probe_ext(block_dev_desc_t *fs_dev_desc, + disk_partition_t *fs_partition) { - ext4fs_set_blk_dev(fs_dev_desc, &fs_partition); + ext4fs_set_blk_dev(fs_dev_desc, fs_partition); - if (!ext4fs_mount(fs_partition.size)) { + if (!ext4fs_mount(fs_partition->size)) { ext4fs_close(); return -1; } @@ -153,7 +156,8 @@ static inline void fs_close_ext(void) struct fstype_info { int fstype; - int (*probe)(void); + int (*probe)(block_dev_desc_t *fs_dev_desc, +disk_partition_t *fs_partition); int (*ls)(const char *dirname); int (*read)(const char *filename, ulong addr, int offset, int len); void (*close)(void); @@ -230,7 +234,7 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) fstype != info->fstype) continue; - if (!info->probe()) { + if (!info->probe(fs_dev_desc, &fs_partition)) { fs_type = info->fstype; return 0; } -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 05/11] fs: Use map_sysmem() on read
This allows us to use filesystems on sandbox. It has no effect on other architectures. Signed-off-by: Simon Glass --- fs/fs.c | 23 +++ 1 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 3561727..0cbec99 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -20,6 +20,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -39,7 +40,7 @@ static inline int fs_ls_unsupported(const char *dirname) return -1; } -static inline int fs_read_unsupported(const char *filename, ulong addr, +static inline int fs_read_unsupported(const char *filename, void *buf, int offset, int len) { return -1; @@ -62,12 +63,11 @@ static void fs_close_fat(void) #define fs_ls_fat file_fat_ls -static int fs_read_fat(const char *filename, ulong addr, int offset, int len) +static int fs_read_fat(const char *filename, void *buf, int offset, int len) { int len_read; - len_read = file_fat_read_at(filename, offset, - (unsigned char *)addr, len); + len_read = file_fat_read_at(filename, offset, buf, len); if (len_read == -1) { printf("** Unable to read file %s **\n", filename); return -1; @@ -110,7 +110,7 @@ static void fs_close_ext(void) #define fs_ls_ext ext4fs_ls -static int fs_read_ext(const char *filename, ulong addr, int offset, int len) +static int fs_read_ext(const char *filename, void *buf, int offset, int len) { int file_len; int len_read; @@ -130,7 +130,7 @@ static int fs_read_ext(const char *filename, ulong addr, int offset, int len) if (len == 0) len = file_len; - len_read = ext4fs_read((char *)addr, len); + len_read = ext4fs_read(buf, len); ext4fs_close(); if (len_read != len) { @@ -159,7 +159,7 @@ struct fstype_info { int (*probe)(block_dev_desc_t *fs_dev_desc, disk_partition_t *fs_partition); int (*ls)(const char *dirname); - int (*read)(const char *filename, ulong addr, int offset, int len); + int (*read)(const char *filename, void *buf, int offset, int len); void (*close)(void); }; @@ -267,9 +267,16 @@ int fs_ls(const char *dirname) int fs_read(const char *filename, ulong addr, int offset, int len) { struct fstype_info *info = fs_get_info(fs_type); + void *buf; int ret; - ret = info->read(filename, addr, offset, len); + /* +* We don't actually know how many bytes are being read, since len==0 +* means read the whole file. +*/ + buf = map_sysmem(addr, len); + ret = info->read(filename, buf, offset, len); + unmap_sysmem(buf); /* If we requested a specific number of bytes, check we got it */ if (ret >= 0 && len && ret != len) { -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 08/11] sandbox: Add host filesystem
This allows reading of files from the host filesystem in sandbox. Signed-off-by: Simon Glass --- Makefile |1 + disk/part.c| 17 ++ fs/fs.c| 10 ++ fs/sandbox/Makefile| 47 +++ fs/sandbox/sandboxfs.c | 83 include/fs.h |1 + include/sandboxfs.h| 30 + 7 files changed, 189 insertions(+), 0 deletions(-) create mode 100644 fs/sandbox/Makefile create mode 100644 fs/sandbox/sandboxfs.c create mode 100644 include/sandboxfs.h diff --git a/Makefile b/Makefile index a7b6cd1..ee21b24 100644 --- a/Makefile +++ b/Makefile @@ -268,6 +268,7 @@ LIBS-y += fs/libfs.o \ fs/fdos/libfdos.o \ fs/jffs2/libjffs2.o \ fs/reiserfs/libreiserfs.o \ + fs/sandbox/libsandboxfs.o \ fs/ubifs/libubifs.o \ fs/yaffs2/libyaffs2.o \ fs/zfs/libzfs.o diff --git a/disk/part.c b/disk/part.c index 7bdc90e..58a4563 100644 --- a/disk/part.c +++ b/disk/part.c @@ -472,6 +472,23 @@ int get_device_and_partition(const char *ifname, const char *dev_part_str, int part; disk_partition_t tmpinfo; + /* +* For now, we have a special case for sandbox, since there is no +* real block device support. +*/ + if (0 == strcmp(ifname, "host")) { + *dev_desc = NULL; + info->start = info->size = info->blksz = 0; + info->bootable = 0; + strcpy((char *)info->type, BOOT_PART_TYPE); + strcpy((char *)info->name, "Sandbox host"); +#ifdef CONFIG_PARTITION_UUIDS + info->uuid[0] = 0; +#endif + + return 0; + } + /* If no dev_part_str, use bootdevice environment variable */ if (!dev_part_str || !strlen(dev_part_str) || !strcmp(dev_part_str, "-")) diff --git a/fs/fs.c b/fs/fs.c index 95c882e..6f5063c 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -20,6 +20,7 @@ #include #include #include +#include #include DECLARE_GLOBAL_DATA_PTR; @@ -78,6 +79,15 @@ static struct fstype_info fstypes[] = { .read = ext4_read_file, }, #endif +#ifdef CONFIG_SANDBOX + { + .fstype = FS_TYPE_SANDBOX, + .probe = sandbox_fs_set_blk_dev, + .close = sandbox_fs_close, + .ls = sandbox_fs_ls, + .read = fs_read_sandbox, + }, +#endif { .fstype = FS_TYPE_ANY, .probe = fs_probe_unsupported, diff --git a/fs/sandbox/Makefile b/fs/sandbox/Makefile new file mode 100644 index 000..b3155b0 --- /dev/null +++ b/fs/sandbox/Makefile @@ -0,0 +1,47 @@ +# +# Copyright (c) 2012, Google Inc. +# +# (C) Copyright 2006 +# Wolfgang Denk, DENX Software Engineering, w...@denx.de. +# +# (C) Copyright 2003 +# Pavel Bartusek, Sysgo Real-Time Solutions AG, p...@sysgo.de +# +# 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)libsandboxfs.o + +COBJS-$(CONFIG_SANDBOX) := sandboxfs.o + +SRCS := $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y)) + +all: $(LIB) $(AOBJS) + +$(LIB):$(obj).depend $(OBJS) + $(call cmd_link_o_target, $(OBJS)) + +# + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +# diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c new file mode 100644 index 000..02d26ff --- /dev/null +++ b/fs/sandbox/sandboxfs.c @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2012, Google Inc. + * + * 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 Pub
[U-Boot] [PATCH 03/11] fs: Use filesystem methods instead of switch()
We can use the available methods and avoid using switch(). When the filesystem is not supported, we fall through to the 'unsupported' methods: fs_probe_unsupported() prints an error, so the others do not need to. Signed-off-by: Simon Glass --- fs/fs.c | 60 ++-- 1 files changed, 26 insertions(+), 34 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 66835e2..856d8ba 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -35,14 +35,12 @@ static inline int fs_probe_unsupported(void) static inline int fs_ls_unsupported(const char *dirname) { - printf("** Unrecognized filesystem type **\n"); return -1; } static inline int fs_read_unsupported(const char *filename, ulong addr, int offset, int len) { - printf("** Unrecognized filesystem type **\n"); return -1; } @@ -189,6 +187,20 @@ static struct fstype_info fstypes[] = { }, }; +static struct fstype_info *fs_get_info(int fstype) +{ + struct fstype_info *info; + int i; + + for (i = 0, info = fstypes; i < ARRAY_SIZE(fstypes) - 1; i++, info++) { + if (fstype == info->fstype) + return info; + } + + /* Return the 'unsupported' sentinel */ + return info; +} + int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) { struct fstype_info *info; @@ -229,17 +241,9 @@ int fs_set_blk_dev(const char *ifname, const char *dev_part_str, int fstype) static void fs_close(void) { - switch (fs_type) { - case FS_TYPE_FAT: - fs_close_fat(); - break; - case FS_TYPE_EXT: - fs_close_ext(); - break; - default: - break; - } + struct fstype_info *info = fs_get_info(fs_type); + info->close(); fs_type = FS_TYPE_ANY; } @@ -247,17 +251,9 @@ int fs_ls(const char *dirname) { int ret; - switch (fs_type) { - case FS_TYPE_FAT: - ret = fs_ls_fat(dirname); - break; - case FS_TYPE_EXT: - ret = fs_ls_ext(dirname); - break; - default: - ret = fs_ls_unsupported(dirname); - break; - } + struct fstype_info *info = fs_get_info(fs_type); + + ret = info->ls(dirname); fs_close(); @@ -266,20 +262,16 @@ int fs_ls(const char *dirname) int fs_read(const char *filename, ulong addr, int offset, int len) { + struct fstype_info *info = fs_get_info(fs_type); int ret; - switch (fs_type) { - case FS_TYPE_FAT: - ret = fs_read_fat(filename, addr, offset, len); - break; - case FS_TYPE_EXT: - ret = fs_read_ext(filename, addr, offset, len); - break; - default: - ret = fs_read_unsupported(filename, addr, offset, len); - break; - } + ret = info->read(filename, addr, offset, len); + /* If we requested a specific number of bytes, check we got it */ + if (ret >= 0 && len && ret != len) { + printf("** Unable to read file %s **\n", filename); + ret = -1; + } fs_close(); return ret; -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 09/11] sandbox: Add 'sb' command to access filesystem features
The new 'sb' command is intended to deal with sandbox-specific features that have no parallel in other archs. This commit adds two sub-commands to list a directory and read a file from the host filesystem. Signed-off-by: Simon Glass --- README |1 + common/Makefile |1 + common/cmd_sandbox.c | 63 ++ include/config_cmd_all.h |1 + 4 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 common/cmd_sandbox.c diff --git a/README b/README index 8dd3867..e54279e 100644 --- a/README +++ b/README @@ -867,6 +867,7 @@ The following options need to be configured: CONFIG_CMD_READ * Read raw data from partition CONFIG_CMD_REGINFO * Register dump CONFIG_CMD_RUNrun command in env variable + CONFIG_CMD_SANDBOX * sb command to access sandbox features CONFIG_CMD_SAVES* save S record dump CONFIG_CMD_SCSI * SCSI Support CONFIG_CMD_SDRAM* print SDRAM configuration information diff --git a/common/Makefile b/common/Makefile index 54fcc81..719fc23 100644 --- a/common/Makefile +++ b/common/Makefile @@ -152,6 +152,7 @@ COBJS-$(CONFIG_CMD_PXE) += cmd_pxe.o COBJS-$(CONFIG_CMD_READ) += cmd_read.o COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o +COBJS-$(CONFIG_SANDBOX) += cmd_sandbox.o COBJS-$(CONFIG_CMD_SATA) += cmd_sata.o COBJS-$(CONFIG_CMD_SF) += cmd_sf.o COBJS-$(CONFIG_CMD_SCSI) += cmd_scsi.o diff --git a/common/cmd_sandbox.c b/common/cmd_sandbox.c new file mode 100644 index 000..206a486 --- /dev/null +++ b/common/cmd_sandbox.c @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2012, Google Inc. + * + * 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 +#include + +static int do_sandbox_load(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return do_load(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX, 16); +} + +static int do_sandbox_ls(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SANDBOX); +} + +static cmd_tbl_t cmd_sandbox_sub[] = { + U_BOOT_CMD_MKENT(load, 3, 0, do_sandbox_load, "", ""), + U_BOOT_CMD_MKENT(ls, 3, 0, do_sandbox_ls, "", ""), +}; + +static int do_sandbox(cmd_tbl_t *cmdtp, int flag, int argc, + char * const argv[]) +{ + cmd_tbl_t *c; + + /* Skip past 'sandbox' */ + argc--; + argv++; + + c = find_cmd_tbl(argv[0], cmd_sandbox_sub, +ARRAY_SIZE(cmd_sandbox_sub)); + + if (c) + return c->cmd(cmdtp, flag, argc, argv); + else + return CMD_RET_USAGE; +} + +U_BOOT_CMD( + sb, 6, 1, do_sandbox, + "Miscellaneous sandbox commands", + "load host [ ] - load a file from host\n" + "sb ls host - save a file to host" +); diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index e82f642..61c302e 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -75,6 +75,7 @@ #define CONFIG_CMD_RARP/* rarpboot support */ #define CONFIG_CMD_READ/* Read data from partition */ #define CONFIG_CMD_RUN /* run command in env variable */ +#define CONFIG_CMD_SANDBOX /* sb command to access sandbox features */ #define CONFIG_CMD_SAVEENV /* saveenv */ #define CONFIG_CMD_SAVES /* save S record dump */ #define CONFIG_CMD_SCSI/* SCSI Support */ -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 10/11] sandbox: Enable ext4 and fat filesystems
These are useful for build-testing code, at least. Signed-off-by: Simon Glass --- include/configs/sandbox.h |7 +++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 9f51a0b..2a45c7b 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -32,6 +32,13 @@ #define CONFIG_OF_LIBFDT #define CONFIG_LMB +#define CONFIG_FS_FAT +#define CONFIG_FS_EXT4 +#define CONFIG_EXT4_WRITE +#define CONFIG_CMD_FAT +#define CONFIG_CMD_EXT4 +#define CONFIG_CMD_EXT4_WRITE + #define CONFIG_SYS_VSNPRINTF #define CONFIG_CMD_GPIO -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 11/11] sandbox: config: Enable sandbox command
The 'sb' command allows loading files from the host, and listing directories. Signed-off-by: Simon Glass --- include/configs/sandbox.h |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h index 2a45c7b..406da43 100644 --- a/include/configs/sandbox.h +++ b/include/configs/sandbox.h @@ -97,6 +97,8 @@ #define CONFIG_SHA1 #define CONFIG_SHA256 +#define CONFIG_CMD_SANDBOX + #define CONFIG_BOOTARGS "" #define CONFIG_EXTRA_ENV_SETTINGS "stdin=serial\0" \ -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/11] ext4: Split write support into its own file
This code seems to be entirely othogonal, so remove the #ifdef and put the condition in the Makefile instead. Signed-off-by: Simon Glass --- fs/ext4/Makefile |2 +- fs/ext4/ext4_write.c | 996 ++ fs/ext4/ext4fs.c | 963 3 files changed, 997 insertions(+), 964 deletions(-) create mode 100644 fs/ext4/ext4_write.c diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile index bb801f9..3bde824 100644 --- a/fs/ext4/Makefile +++ b/fs/ext4/Makefile @@ -31,7 +31,7 @@ LIB = $(obj)libext4fs.o AOBJS = COBJS-$(CONFIG_FS_EXT4) := ext4fs.o ext4_common.o dev.o -COBJS-$(CONFIG_EXT4_WRITE) += ext4_journal.o crc16.o +COBJS-$(CONFIG_EXT4_WRITE) += ext4_write.o ext4_journal.o crc16.o SRCS := $(AOBJS:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(AOBJS) $(COBJS-y)) diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c new file mode 100644 index 000..c4e399c --- /dev/null +++ b/fs/ext4/ext4_write.c @@ -0,0 +1,996 @@ +/* + * (C) Copyright 2011 - 2012 Samsung Electronics + * EXT4 filesystem implementation in Uboot by + * Uma Shankar + * Manjunatha C Achar + * + * ext4ls and ext4load : Based on ext2 ls and load support in Uboot. + *Ext4 read optimization taken from Open-Moko + *Qi bootloader + * + * (C) Copyright 2004 + * esd gmbh + * Reinhard Arlt + * + * based on code from grub2 fs/ext2.c and fs/fshelp.c by + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2003, 2004 Free Software Foundation, Inc. + * + * ext4write : Based on generic ext4 protocol. + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +#include +#include +#include +#include "ext4_common.h" + +static void ext4fs_update(void) +{ + short i; + ext4fs_update_journal(); + struct ext_filesystem *fs = get_fs(); + + /* update super block */ + put_ext4((uint64_t)(SUPERBLOCK_SIZE), +(struct ext2_sblock *)fs->sb, (uint32_t)SUPERBLOCK_SIZE); + + /* update block groups */ + for (i = 0; i < fs->no_blkgrp; i++) { + fs->bgd[i].bg_checksum = ext4fs_checksum_update(i); + put_ext4((uint64_t)(fs->bgd[i].block_id * fs->blksz), +fs->blk_bmaps[i], fs->blksz); + } + + /* update inode table groups */ + for (i = 0; i < fs->no_blkgrp; i++) { + put_ext4((uint64_t) (fs->bgd[i].inode_id * fs->blksz), +fs->inode_bmaps[i], fs->blksz); + } + + /* update the block group descriptor table */ + put_ext4((uint64_t)(fs->gdtable_blkno * fs->blksz), +(struct ext2_block_group *)fs->gdtable, +(fs->blksz * fs->no_blk_pergdt)); + + ext4fs_dump_metadata(); + + gindex = 0; + gd_index = 0; +} + +int ext4fs_get_bgdtable(void) +{ + int status; + int grp_desc_size; + struct ext_filesystem *fs = get_fs(); + grp_desc_size = sizeof(struct ext2_block_group); + fs->no_blk_pergdt = (fs->no_blkgrp * grp_desc_size) / fs->blksz; + if ((fs->no_blkgrp * grp_desc_size) % fs->blksz) + fs->no_blk_pergdt++; + + /* allocate memory for gdtable */ + fs->gdtable = zalloc(fs->blksz * fs->no_blk_pergdt); + if (!fs->gdtable) + return -ENOMEM; + /* read the group descriptor table */ + status = ext4fs_devread(fs->gdtable_blkno * fs->sect_perblk, 0, + fs->blksz * fs->no_blk_pergdt, fs->gdtable); + if (status == 0) + goto fail; + + if (ext4fs_log_gdt(fs->gdtable)) { + printf("Error in ext4fs_log_gdt\n"); + return -1; + } + + return 0; +fail: + free(fs->gdtable); + fs->gdtable = NULL; + + return -1; +} + +static void delete_single_indirect_block(struct ext2_inode *inode) +{ + struct ext2_block_group *bgd = NULL; + static int prev_bg_bmap_idx = -1; + long int blknr; + int remainder; + int bg_idx; + int status; + unsigned int blk_per_grp = ext4fs_root->sblock.blocks_per_group; + struct ext_filesystem *fs = get_fs(); + char *journal_buffer = zalloc(fs->blksz); + if (!journal_buffer) { + print
Re: [U-Boot] [PATCH 8/9] SMDK5250: Enable eMMC booting
Hi Amarendra, On Thu, Dec 20, 2012 at 5:53 AM, Amarendra Reddy wrote: > Hi SImon, > > Thanks for the review comments. > Please find below the responses for your comments. > > Thanks & Regards > Amarendra > > On 20 December 2012 08:05, Simon Glass wrote: >> >> Hi Amar, >> >> On Mon, Dec 17, 2012 at 3:19 AM, Amar wrote: >> >> > This patch adds support for eMMC booting on SMDK5250 >> > >> > Signed-off-by: Amar >> > --- >> > board/samsung/smdk5250/spl_boot.c | 38 >> > - >> > 1 files changed, 37 insertions(+), 1 deletions(-) >> > >> > diff --git a/board/samsung/smdk5250/spl_boot.c >> > b/board/samsung/smdk5250/spl_boot.c >> > index d8f3c1e..2648b4e 100644 >> > --- a/board/samsung/smdk5250/spl_boot.c >> > +++ b/board/samsung/smdk5250/spl_boot.c >> > @@ -23,15 +23,40 @@ >> > #include >> > #include >> > >> > +#include >> > +#include >> > + >> > +#define FSYS1_MMC0_DIV_VAL 0x0701 >> > >> >> Should go in arch/arm/include/... ? >> >> OK. shall move it. >> >> > + >> > enum boot_mode { >> > BOOT_MODE_MMC = 4, >> > + BOOT_MODE_eMMC = 8, /* eMMC44 */ >> > >> >> I think should you use upper case E, although I'm not completely sure. >> OK. will make it upper case to be consistent every where. >> >> >> > BOOT_MODE_SERIAL = 20, >> > /* Boot based on Operating Mode pin settings */ >> > BOOT_MODE_OM = 32, >> > BOOT_MODE_USB, /* Boot using USB download */ >> > }; >> > >> > - typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst); >> > +typedef u32 (*spi_copy_func_t)(u32 offset, u32 nblock, u32 dst); >> > >> >> Should avoid adding typedefs. >> Ok. >> >> >> > +static void set_emmc_clk(void); >> > + >> > +/* >> > +* Set MMC0 clock divisor value. >> > +* So that the mmc0 device operating freq is 50MHz. >> > >> >> Do we only support booting from mmc0? That's fine, but I suggest adding a >> little comment. >> OK. >> >> >> > +*/ >> > +static void set_emmc_clk(void) >> > +{ >> > + struct exynos5_clock *clk = (struct exynos5_clock >> > *)EXYNOS5_CLOCK_BASE; >> > + unsigned int addr; >> > + unsigned int div_mmc; >> > + >> > + addr = (unsigned int) &clk->div_fsys1; >> > + >> > + div_mmc = readl(addr) & ~FSYS1_MMC0_DIV_MASK; >> > + div_mmc |= FSYS1_MMC0_DIV_VAL; >> > + writel(div_mmc, addr); >> > >> >> Can this function go in clock.c? >> This function is used by SPL, only during EMMC boot. >> Hence can be moved into board/samsung/smdk5250/clock_init.c. >> >> Please comment on this. Yes that seems reasonable. There is a lot of code in clock_init that should eventually move to U-Boot proper (i.e. we should only init clocks in SPL that are actually needed in SPL). This can be addressed after Hatim (copied) has finished creating the upstream patches for clock_init / lowlevel_init refactor. > > >> >> > +} >> > + >> > >> > /* >> > * Copy U-boot from mmc to RAM: >> > @@ -43,6 +68,8 @@ void copy_uboot_to_ram(void) >> > spi_copy_func_t spi_copy; >> > enum boot_mode bootmode; >> > u32 (*copy_bl2)(u32, u32, u32); >> > + u32 (*copy_bl2_emmc)(u32, u32); >> > + void (*end_bootop_emmc)(void); >> > >> > bootmode = readl(EXYNOS5_POWER_BASE) & OM_STAT; >> > >> > @@ -57,6 +84,15 @@ void copy_uboot_to_ram(void) >> > copy_bl2(BL2_START_OFFSET, BL2_SIZE_BLOC_COUNT, >> > CONFIG_SYS_TEXT_BASE); >> > break; >> > + case BOOT_MODE_eMMC: >> > + set_emmc_clk(); >> > + end_bootop_emmc = (void *) *(u32 >> > *)EMMC44_END_BOOTOP_FNPTR_ADDR; >> > + copy_bl2_emmc = (void *) *(u32 >> > *)EMMC44_COPY_BL2_FNPTR_ADDR; >> > >> >> I think these are pointers to functions in the IROM. Do they have the same >> signature? Is it possible to create a table of them somewhere instead of >> using defines? >> OK. > > The signatures are different for different booting devices. > More over, SDMMC / SPI / USB booting requires only one function pointer. > Where as EMMC 4.3/4.4 requires two of those function pointers. > > May be something like this can be used to create table > void (*ptr_table[])(void) = { > (void *)0x02020030, /* iROM Function Pointer - SDMMC boot */ > (void *)0x0202003C, /* iROM Function Pointer - EMMC 4.3 boot*/ > (void *)0x02020040, /* iROM Function Pointer - EMMC 4.3 end boot op > */ > (void *)0x02020044, /* iROM Function Pointer - EMMC 4.4 boot*/ > (void *)0x02020048, /* iROM Function Pointer - EMMC 4.4 end boot op > */ > (void *)0x02020050, /* iROM Function Pointer - EFNAND boot */ > (void *)0x02020058, /* iROM Function Pointer - SPI boot */ > (void *)0x02020070 /* iROM Function Pointer - USB boot */ > }; Well I suggest just having addresses in the table (ulong) instead of pointers if you can, so there are fewer casts. > > Usage: >
Re: [U-Boot] [U-Boot,v2,2/2] spi: Add SPI flash test
Hi, On Wed, Dec 19, 2012 at 5:07 PM, Tom Rini wrote: > On Thu, Dec 20, 2012 at 12:19:24AM +0100, Wolfgang Denk wrote: >> Dear Tom Rini, >> >> In message <20121219225956.GG14589@bill-the-cat> you wrote: >> > >> > Applied to u-boot/master, thanks! >> >> Please see my comment from a few minutes ago. >> >> We're adding just dead code here. This makes no sense to me. > > I'll add this option to am335x_evm as soon as I can sneak over to the > office, flip the dip switches so that the SPI flash is available and > double check that yes, really, Simon tested the code one point before > posting. Yeah, -1 to me for adding this before we added a board using > it, but it's a useful thing. Q/A folks here at least will be all 'oh > boy!' when I tell them that starting with the next release they can use > this. Sorry about this. It can be enabled on any board I think - my SPI patches for coreboot got held up a bit by a bug and I missed the merge window. I will send these patches out in the next few weeks. Regards, Simon > > -- > Tom > > ___ > 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] arm/bootstage: Move the bootstage call after gd init
Hi Vikram, On Sun, Dec 23, 2012 at 3:27 AM, Vikram Narayanan wrote: > bootstage_mark_name calls timer_get_boot_us which inturn calls > the arch timer. The arch timer uses the gd pointer to save the > lastinc count. A call to bootstage_mark_name here results in a > data abort as gd is uninitialized. > > Signed-off-by: Vikram Narayanan > Cc: Simon Glass > Cc: Wolfgang Denk > Cc: Albert Aribaud Acked-by: Simon Glass This bug will affect boards which don't have their own timer_get_boot_us() function. Albert, I think we should try to get this in as a bug fix in the upcoming release. Thanks for the fix Vikram. > --- > Though it is true that there are currently no users for this > feature, it isn't good to see an abort when someone tries to > use BOOTSTAGE. I was bugged by this error when trying to > use this feature on i.Mx6Q based board. > > arch/arm/lib/board.c |4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c > index e0cb635..2f09ab9 100644 > --- a/arch/arm/lib/board.c > +++ b/arch/arm/lib/board.c > @@ -277,13 +277,13 @@ void board_init_f(ulong bootflag) > void *new_fdt = NULL; > size_t fdt_size = 0; > > - bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); > - > /* Pointer is writable since we allocated a register for it */ > gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07); > /* compiler optimization barrier needed for GCC >= 3.4 */ > __asm__ __volatile__("": : :"memory"); > > + bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); > + > memset((void *)gd, 0, sizeof(gd_t)); > > gd->mon_len = _bss_end_ofs; > -- > 1.7.4.1 > Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v4 1/2] arm: move C runtime setup code in crt0.S
Hi Albert, On Sun, Dec 23, 2012 at 7:03 AM, Albert ARIBAUD wrote: > Hi Simon, > > On Fri, 30 Nov 2012 14:10:01 -0800, Simon Glass > wrote: > >> >> I tried to test it on a snow (exynos5250) but couldn't really sync up >> >> with our tree, so gave up. I am not completely sure about how the >> >> CONFIG_SPL_BUILD stuff fits together in start.S and I got a build >> >> error I wasn't sure how to correct (arch/arm/cpu/armv7/start.S:179: >> >> undefined reference to `relocate_done') >> > >> > Thansk Simon. >> > >> > In file arch/arm/cpu/armv7/start.S, line 179 uses relocate_done and >> > line 228 provides it, and there is no preprocessor conditional >> > in-between, so I fail to see how you could get this error. >> > >> > Is your tree (and branch) available so that I can try and see the issue >> > for myself? Either it'll uncover a problem in my patch series, or it'll >> > help you merge it (or both). >> >> OK I will try a bit harder and come back to you. Sorry I can't do that >> immediately but will be soon... > > Did you manage to reproduce or sort out this issue? No, I was hoping that I would be able to test upstream U-Boot on snow (waiting on some memory patches to appear), but that hasn't happened. I will have another go at working out the problem - either this week or next depending on when I can set aside the time for it. However, please don't hold up the series for it. > >> Regards, >> Simon > > Amicalement, > -- > Albert. Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 15/20] image: Use crc header file instead of C prototypes
Dear Simon Glass, > We have an existing header which the crc32 definitions, so use it. > > Signed-off-by: Simon Glass Looks ok. Acked-by: Marek Vasut Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 0/15] Enhance SPI/SPI flash probing, add support for Intel ICH controller
Adding new fields to struct spi_slave and struct spi_flash is painful, because most drivers don't zero the fields they don't use. Anyway it seems better to have the SPI/SPI flash infrastructure provide a simple way of doing this that all drivers can use. So the first part of this series adds spi_alloc_slave(), for SPI, and spi_flash_alloc() for SPI flash. Support is added for the Intel ICH SPI controller, possibly the oddest SPI controller in U-Boot. It is designed for use with SPI flash only, and has a number of high-level features which are dedicated to flash. As such it is a bit of a challenge to get it to behave just like a normal U-Boot SPI device. The ICH driver has two interesting features. Firstly it is impossible to read or write more than 64 bytes at a time! For SPI reading it is possible to hide this within the SPI driver. For SPI writing it unfortunately isn't, since the spi_flash layer has to send an unlock command and a new address for every write. It would be an egregious hack to try to fake this in the driver. So a new property is added to spi_flash to allow the maximum transfer size to be set. Secondly, the ICH SPI flash can be memory mapped. On a lot of x86 devices this improves performance significantly. For example, the standard driver gets maybe 12Mbps throughput from a 33Mbps dual interface, roughly 20% utilisation. With memory mapping, many platforms can achieve about 40Mbps. To implement memory mapping, a new property is provided in the device tree to set the memory map address, which varies by platform. Some x86 platforms will see a speed increase with memory mapping, some won't. The memory mapping feature only works for reading. When in use, the spi_flash layer bypasses the SPI driver completely, and just copies the flash data from the correct place in the memory map. Simon Glass (15): fdt: Use sed instead of cpp to pre-process the dtc fdt: Add fdtdec_get_addr_size() to read reg properties spi: Add function to allocate a new SPI slave spi: Use spi_alloc_slave() in each SPI driver sf: Add spi_flash_alloc() to create a new SPI flash struct sf: Use spi_flash_alloc() in each SPI flash driver x86: spi: Add Intel ICH driver spi: Add parameter for maximum write size sf: Respect maximum SPI write size x86: spi: Set maximum write size for ICH sf: Enable FDT-based configuration and memory mapping x86: Move PCI init before SPI init x86: Add FDT SPI node for link x86: Enable SPI flash support for coreboot x86: Enable time command for coreboot arch/x86/lib/board.c |8 +- board/chromebook-x86/dts/link.dts | 11 + drivers/mtd/spi/atmel.c |8 +- drivers/mtd/spi/eon.c |8 +- drivers/mtd/spi/macronix.c|8 +- drivers/mtd/spi/ramtron.c |4 +- drivers/mtd/spi/spansion.c|8 +- drivers/mtd/spi/spi_flash.c | 81 - drivers/mtd/spi/sst.c |8 +- drivers/mtd/spi/stmicro.c |8 +- drivers/mtd/spi/winbond.c |8 +- drivers/spi/Makefile |4 + drivers/spi/altera_spi.c |4 +- drivers/spi/andes_spi.c |4 +- drivers/spi/armada100_spi.c |4 +- drivers/spi/atmel_spi.c |4 +- drivers/spi/bfin_spi.c|4 +- drivers/spi/cf_qspi.c |4 +- drivers/spi/cf_spi.c |4 +- drivers/spi/davinci_spi.c |4 +- drivers/spi/fsl_espi.c|4 +- drivers/spi/ich.c | 752 + drivers/spi/ich.h | 144 +++ drivers/spi/kirkwood_spi.c|5 +- drivers/spi/mpc52xx_spi.c |5 +- drivers/spi/mpc8xxx_spi.c |5 +- drivers/spi/mxc_spi.c |4 +- drivers/spi/mxs_spi.c |4 +- drivers/spi/oc_tiny_spi.c |5 +- drivers/spi/omap3_spi.c | 27 +- drivers/spi/sh_spi.c |4 +- drivers/spi/soft_spi.c|4 +- drivers/spi/spi.c | 39 ++ drivers/spi/tegra_spi.c |4 +- drivers/spi/xilinx_spi.c |4 +- dts/Makefile | 10 +- include/configs/coreboot.h| 13 +- include/fdtdec.h | 16 + include/spi.h | 44 +++ include/spi_flash.h | 39 ++ lib/fdtdec.c | 27 ++- 41 files changed, 1208 insertions(+), 147 deletions(-) create mode 100644 drivers/spi/ich.c create mode 100644 drivers/spi/ich.h create mode 100644 drivers/spi/spi.c -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 01/15] fdt: Use sed instead of cpp to pre-process the dtc
Include file support in dtc is still not available in common distributions so we need to keep our preprocessing arrangement around for a little longer. But # is commonly used in FDT files, so use sed instead of cpp for this preprocessing. Signed-off-by: Simon Glass --- dts/Makefile | 10 -- 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dts/Makefile b/dts/Makefile index 785104e..76f1461 100644 --- a/dts/Makefile +++ b/dts/Makefile @@ -35,11 +35,6 @@ $(if $(CONFIG_ARCH_DEVICE_TREE),,\ $(error Your architecture does not have device tree support enabled. \ Please define CONFIG_ARCH_DEVICE_TREE)) -# We preprocess the device tree file provide a useful define -DTS_CPPFLAGS := -ansi \ - -DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\" \ - -DBOARD_DTS=\"$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts\" - all: $(obj).depend $(LIB) # Use a constant name for this so we can access it from C code. @@ -49,7 +44,10 @@ DT_BIN := $(obj)dt.dtb $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts rc=$$( \ - cat $< | $(CPP) -P $(DTS_CPPFLAGS) - | \ + cat $< \ + | sed '{s#ARCH_CPU_DTS#"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi"#; \ + s#BOARD_DTS#$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts#}' | \ + tee dts.tmp | \ { { $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} - 2>&1 ; \ echo $$? >&3 ; } | \ grep -v '^DTC: dts->dtb on file' ; \ -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 03/15] spi: Add function to allocate a new SPI slave
At present it is difficult to extend the SPI structure since all drivers allocate it themselves, and few of them zero all fields. Add a new function spi_alloc_slave() which can be used by SPI drivers to perform this allocation, and thus ensure that all drivers can better cope with SPI structure changes. Signed-off-by: Simon Glass --- drivers/spi/Makefile |3 +++ drivers/spi/spi.c| 39 +++ include/spi.h| 41 + 3 files changed, 83 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/spi.c diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 824d357..4e8de5d 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -25,6 +25,9 @@ include $(TOPDIR)/config.mk LIB:= $(obj)libspi.o +# There are many options which enable SPI, so make this library available +COBJS-y += spi.o + COBJS-$(CONFIG_ALTERA_SPI) += altera_spi.o COBJS-$(CONFIG_ANDES_SPI) += andes_spi.o COBJS-$(CONFIG_ARMADA100_SPI) += armada100_spi.o diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c new file mode 100644 index 000..cb36c5e --- /dev/null +++ b/drivers/spi/spi.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2011 The Chromium OS Authors. + * + * 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 +#include +#include + +void *spi_do_alloc_slave(int offset, int size, unsigned int bus, +unsigned int cs) +{ + struct spi_slave *slave; + void *ptr; + + ptr = malloc(size); + if (ptr) { + memset(ptr, '\0', size); + slave = (struct spi_slave *)(ptr + offset); + slave->bus = bus; + slave->cs = cs; + } + + return ptr; +} diff --git a/include/spi.h b/include/spi.h index 60e85db..ebc9652 100644 --- a/include/spi.h +++ b/include/spi.h @@ -62,6 +62,47 @@ struct spi_slave { */ void spi_init(void); +/** + * spi_do_alloc_slave - Allocate a new SPI slave (internal) + * + * Allocate and zero all fields in the spi slave, and set the bus/chip + * select. Use the helper macro spi_alloc_slave() to call this. + * + * @offset: Offset of struct spi_slave within slave structure + * @size: Size of slave structure + * @bus: Bus ID of the slave chip. + * @cs: Chip select ID of the slave chip on the specified bus. + */ +void *spi_do_alloc_slave(int offset, int size, unsigned int bus, +unsigned int cs); + +/** + * spi_alloc_slave - Allocate a new SPI slave + * + * Allocate and zero all fields in the spi slave, and set the bus/chip + * select. + * + * @_struct: Name of structure to allocate (e.g. struct tegra_spi). This + * structure must contain a member 'struct spi_slave *slave'. + * @bus: Bus ID of the slave chip. + * @cs: Chip select ID of the slave chip on the specified bus. + */ +#define spi_alloc_slave(_struct, bus, cs) \ + spi_do_alloc_slave(offsetof(_struct, slave), \ + sizeof(_struct), bus, cs) + +/** + * spi_alloc_slave_base - Allocate a new SPI slave with no private data + * + * Allocate and zero all fields in the spi slave, and set the bus/chip + * select. + * + * @bus: Bus ID of the slave chip. + * @cs: Chip select ID of the slave chip on the specified bus. + */ +#define spi_alloc_slave_base(bus, cs) \ + spi_do_alloc_slave(0, sizeof(struct spi_slave), bus, cs) + /*--- * Set up communications parameters for a SPI slave. * -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 02/15] fdt: Add fdtdec_get_addr_size() to read reg properties
It is common to have a "reg = " property in the FDT. Add a function to handle this, similar to the existing fdtdec_get_addr(); Signed-off-by: Simon Glass --- include/fdtdec.h | 15 +++ lib/fdtdec.c | 26 +- 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/fdtdec.h b/include/fdtdec.h index 70d0e97..570d3ac 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -38,11 +38,13 @@ */ #ifdef CONFIG_PHYS_64BIT typedef u64 fdt_addr_t; +typedef u64 fdt_size_t; #define FDT_ADDR_T_NONE (-1ULL) #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) #define fdt_size_to_cpu(reg) be64_to_cpu(reg) #else typedef u32 fdt_addr_t; +typedef u32 fdt_size_t; #define FDT_ADDR_T_NONE (-1U) #define fdt_addr_to_cpu(reg) be32_to_cpu(reg) #define fdt_size_to_cpu(reg) be32_to_cpu(reg) @@ -186,6 +188,19 @@ fdt_addr_t fdtdec_get_addr(const void *blob, int node, const char *prop_name); /** + * Look up an address property in a node and return it as an address. + * The property must hold one address with a length. This is only tested + * on 32-bit machines. + * + * @param blob FDT blob + * @param node node to examine + * @param prop_namename of property to find + * @return address, if found, or FDT_ADDR_T_NONE if not + */ +fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, + const char *prop_name, fdt_size_t *sizep); + +/** * Look up a 32-bit integer property in a node and return it. The property * must have at least 4 bytes of data. The value of the first cell is * returned. diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 6dba438..d0bc848 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -54,25 +54,41 @@ const char *fdtdec_get_compatible(enum fdt_compat_id id) return compat_names[id]; } -fdt_addr_t fdtdec_get_addr(const void *blob, int node, - const char *prop_name) +fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, + const char *prop_name, fdt_size_t *sizep) { const fdt_addr_t *cell; int len; debug("%s: %s: ", __func__, prop_name); cell = fdt_getprop(blob, node, prop_name, &len); - if (cell && (len == sizeof(fdt_addr_t) || + if (cell && ((!sizep && len == sizeof(fdt_addr_t)) || len == sizeof(fdt_addr_t) * 2)) { - fdt_addr_t addr = fdt_addr_to_cpu(*cell); - debug("%p\n", (void *)addr); + fdt_addr_t addr = fdt_addr_to_cpu(*cell); + if (sizep) { + const fdt_size_t *size; + + size = (fdt_size_t *)((char *)cell + + sizeof(fdt_addr_t)); + *sizep = fdt_size_to_cpu(*size); + debug("addr=%p, size=%p\n", (void *)addr, + (void *)*sizep); + } else { + debug("%p\n", (void *)addr); + } return addr; } debug("(not found)\n"); return FDT_ADDR_T_NONE; } +fdt_addr_t fdtdec_get_addr(const void *blob, int node, + const char *prop_name) +{ + return fdtdec_get_addr_size(blob, node, prop_name, NULL); +} + s32 fdtdec_get_int(const void *blob, int node, const char *prop_name, s32 default_val) { -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 05/15] sf: Add spi_flash_alloc() to create a new SPI flash struct
At present it is difficult to extend the SPI flash structure since all devices allocate it themselves, and few of them zero all fields. Add a new function spi_flash_alloc() which can be used by SPI devices to perform this allocation, and thus ensure that all devices can better cope with SPI structure changes. Signed-off-by: Simon Glass --- drivers/mtd/spi/spi_flash.c | 25 + include/spi_flash.h | 38 ++ 2 files changed, 63 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 00aece9..17f3d3c 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -401,6 +401,31 @@ err_claim_bus: return NULL; } +void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi, +const char *name) +{ + struct spi_flash *flash; + void *ptr; + + ptr = malloc(size); + if (!ptr) { + debug("SF: Failed to allocate memory\n"); + return NULL; + } + memset(ptr, '\0', size); + flash = (struct spi_flash *)(ptr + offset); + + /* Set up some basic fields - caller will sort out sizes */ + flash->spi = spi; + flash->name = name; + + flash->read = spi_flash_cmd_read_fast; + flash->write = spi_flash_cmd_write_multi; + flash->erase = spi_flash_cmd_erase; + + return flash; +} + void spi_flash_free(struct spi_flash *flash) { spi_free_slave(flash->spi); diff --git a/include/spi_flash.h b/include/spi_flash.h index 9da9062..030d49c 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -47,6 +47,44 @@ struct spi_flash { size_t len); }; +/** + * spi_flash_do_alloc - Allocate a new spi flash structure + * + * The structure is allocated and cleared with default values for + * read, write and erase, which the caller can modify. The caller must set + * up size, page_size and sector_size. + * + * Use the helper macro spi_flash_alloc() to call this. + * + * @offset: Offset of struct spi_slave within slave structure + * @size: Size of slave structure + * @spi: SPI slave + * @name: Name of SPI flash device + */ +void *spi_flash_do_alloc(int offset, int size, struct spi_slave *spi, +const char *name); + +/** + * spi_flash_alloc - Allocate a new SPI flash structure + * + * @_struct: Name of structure to allocate (e.g. struct ramtron_spi_fram). This + * structure must contain a member 'struct spi_flash *flash'. + * @spi: SPI slave + * @name: Name of SPI flash device + */ +#define spi_flash_alloc(_struct, spi, name) \ + spi_flash_do_alloc(offsetof(_struct, flash), sizeof(_struct), \ + spi, name) + +/** + * spi_flash_alloc_base - Allocate a new SPI flash structure with no private data + * + * @spi: SPI slave + * @name: Name of SPI flash device + */ +#define spi_flash_alloc_base(spi, name) \ + spi_flash_do_alloc(0, sizeof(struct spi_flash), spi, name) + struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, unsigned int max_hz, unsigned int spi_mode); void spi_flash_free(struct spi_flash *flash); -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 04/15] spi: Use spi_alloc_slave() in each SPI driver
Rather than each driver having its own way to allocate a SPI slave, use the new allocation function everywhere. This will make it easier to extend the interface without breaking drivers. Signed-off-by: Simon Glass --- drivers/spi/altera_spi.c|4 +--- drivers/spi/andes_spi.c |4 +--- drivers/spi/armada100_spi.c |4 +--- drivers/spi/atmel_spi.c |4 +--- drivers/spi/bfin_spi.c |4 +--- drivers/spi/cf_qspi.c |4 +--- drivers/spi/cf_spi.c|4 +--- drivers/spi/davinci_spi.c |4 +--- drivers/spi/fsl_espi.c |4 +--- drivers/spi/kirkwood_spi.c |5 + drivers/spi/mpc52xx_spi.c |5 + drivers/spi/mpc8xxx_spi.c |5 + drivers/spi/mxc_spi.c |4 +--- drivers/spi/mxs_spi.c |4 +--- drivers/spi/oc_tiny_spi.c |5 + drivers/spi/omap3_spi.c | 27 ++- drivers/spi/sh_spi.c|4 +--- drivers/spi/soft_spi.c |4 +--- drivers/spi/tegra_spi.c |4 +--- drivers/spi/xilinx_spi.c|4 +--- 20 files changed, 33 insertions(+), 74 deletions(-) diff --git a/drivers/spi/altera_spi.c b/drivers/spi/altera_spi.c index 138d6f4..b53607a 100644 --- a/drivers/spi/altera_spi.c +++ b/drivers/spi/altera_spi.c @@ -83,12 +83,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, if (!spi_cs_is_valid(bus, cs)) return NULL; - altspi = malloc(sizeof(*altspi)); + altspi = spi_alloc_slave(struct altera_spi_slave, bus, cs); if (!altspi) return NULL; - altspi->slave.bus = bus; - altspi->slave.cs = cs; altspi->base = altera_spi_base_list[bus]; debug("%s: bus:%i cs:%i base:%lx\n", __func__, bus, cs, altspi->base); diff --git a/drivers/spi/andes_spi.c b/drivers/spi/andes_spi.c index fdde139..c56377b 100644 --- a/drivers/spi/andes_spi.c +++ b/drivers/spi/andes_spi.c @@ -53,12 +53,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, if (!spi_cs_is_valid(bus, cs)) return NULL; - ds = malloc(sizeof(*ds)); + ds = spi_alloc_slave(struct andes_spi_slave, bus, cs); if (!ds) return NULL; - ds->slave.bus = bus; - ds->slave.cs = cs; ds->regs = (struct andes_spi_regs *)CONFIG_SYS_SPI_BASE; /* diff --git a/drivers/spi/armada100_spi.c b/drivers/spi/armada100_spi.c index 7384c9c..afdbe05 100644 --- a/drivers/spi/armada100_spi.c +++ b/drivers/spi/armada100_spi.c @@ -120,12 +120,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, { struct armd_spi_slave *pss; - pss = malloc(sizeof(*pss)); + pss = spi_alloc_slave(struct armd_spi_slave, bus, cs); if (!pss) return NULL; - pss->slave.bus = bus; - pss->slave.cs = cs; pss->spi_reg = (struct ssp_reg *)SSP_REG_BASE(CONFIG_SYS_SSP_PORT); pss->cr0 = SSCR0_MOTO | SSCR0_DATASIZE(DEFAULT_WORD_LEN) | SSCR0_SSE; diff --git a/drivers/spi/atmel_spi.c b/drivers/spi/atmel_spi.c index c7a51f7..0bca22f 100644 --- a/drivers/spi/atmel_spi.c +++ b/drivers/spi/atmel_spi.c @@ -84,12 +84,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, if (mode & SPI_CPOL) csrx |= ATMEL_SPI_CSRx_CPOL; - as = malloc(sizeof(struct atmel_spi_slave)); + as = spi_alloc_slave(struct atmel_spi_slave, bus, cs); if (!as) return NULL; - as->slave.bus = bus; - as->slave.cs = cs; as->regs = regs; as->mr = ATMEL_SPI_MR_MSTR | ATMEL_SPI_MR_MODFDIS #if defined(CONFIG_AT91SAM9X5) diff --git a/drivers/spi/bfin_spi.c b/drivers/spi/bfin_spi.c index e080bec..ab2e8b9 100644 --- a/drivers/spi/bfin_spi.c +++ b/drivers/spi/bfin_spi.c @@ -182,12 +182,10 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, default: return NULL; } - bss = malloc(sizeof(*bss)); + bss = spi_alloc_slave(struct bfin_spi_slave, bus, cs); if (!bss) return NULL; - bss->slave.bus = bus; - bss->slave.cs = cs; bss->mmr_base = (void *)mmr_base; bss->ctl = SPE | MSTR | TDBR_CORE; if (mode & SPI_CPHA) bss->ctl |= CPHA; diff --git a/drivers/spi/cf_qspi.c b/drivers/spi/cf_qspi.c index 72dd1a5..a37ac4e 100644 --- a/drivers/spi/cf_qspi.c +++ b/drivers/spi/cf_qspi.c @@ -120,13 +120,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, if (!spi_cs_is_valid(bus, cs)) return NULL; - dev = malloc(sizeof(struct cf_qspi_slave)); + dev = spi_alloc_slave(struct cf_qspi_slave, bus, cs); if (!dev) return NULL; /* Initialize to known value */ - dev->slave.bus = bus; - dev->slave.cs = cs; dev->regs = (qspi_t *)MMAP_QSPI; dev->qmr = 0;
[U-Boot] [PATCH 06/15] sf: Use spi_flash_alloc() in each SPI flash driver
Rather than each device having its own way to allocate a SPI flash structure, use the new allocation function everywhere. This will make it easier to extend the interface without breaking devices. Signed-off-by: Simon Glass --- drivers/mtd/spi/atmel.c|8 +--- drivers/mtd/spi/eon.c |8 +--- drivers/mtd/spi/macronix.c |8 +--- drivers/mtd/spi/ramtron.c |4 +--- drivers/mtd/spi/spansion.c |8 +--- drivers/mtd/spi/sst.c |8 +--- drivers/mtd/spi/stmicro.c |8 +--- drivers/mtd/spi/winbond.c |8 +--- 8 files changed, 8 insertions(+), 52 deletions(-) diff --git a/drivers/mtd/spi/atmel.c b/drivers/mtd/spi/atmel.c index 006f6d5..6a92c4b 100644 --- a/drivers/mtd/spi/atmel.c +++ b/drivers/mtd/spi/atmel.c @@ -480,15 +480,13 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) return NULL; } - asf = malloc(sizeof(struct atmel_spi_flash)); + asf = spi_flash_alloc(struct atmel_spi_flash, spi, params->name); if (!asf) { debug("SF: Failed to allocate memory\n"); return NULL; } asf->params = params; - asf->flash.spi = spi; - asf->flash.name = params->name; /* Assuming power-of-two page size initially. */ page_size = 1 << params->l2_page_size; @@ -513,7 +511,6 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) asf->flash.erase = dataflash_erase_at45; page_size += 1 << (params->l2_page_size - 5); } else { - asf->flash.read = spi_flash_cmd_read_fast; asf->flash.write = dataflash_write_p2; asf->flash.erase = dataflash_erase_p2; } @@ -524,9 +521,6 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode) case DF_FAMILY_AT26F: case DF_FAMILY_AT26DF: - asf->flash.read = spi_flash_cmd_read_fast; - asf->flash.write = spi_flash_cmd_write_multi; - asf->flash.erase = spi_flash_cmd_erase; asf->flash.page_size = page_size; asf->flash.sector_size = 4096; /* clear SPRL# bit for locked flash */ diff --git a/drivers/mtd/spi/eon.c b/drivers/mtd/spi/eon.c index 691ed4e..b16e7ab 100644 --- a/drivers/mtd/spi/eon.c +++ b/drivers/mtd/spi/eon.c @@ -46,18 +46,12 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode) return NULL; } - flash = malloc(sizeof(*flash)); + flash = spi_flash_alloc_base(spi, params->name); if (!flash) { debug("SF: Failed to allocate memory\n"); return NULL; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size = 256; flash->sector_size = 256 * 16 * 16; flash->size = 256 * 16 diff --git a/drivers/mtd/spi/macronix.c b/drivers/mtd/spi/macronix.c index c97a39d..036c30d 100644 --- a/drivers/mtd/spi/macronix.c +++ b/drivers/mtd/spi/macronix.c @@ -97,18 +97,12 @@ struct spi_flash *spi_flash_probe_macronix(struct spi_slave *spi, u8 *idcode) return NULL; } - flash = malloc(sizeof(*flash)); + flash = spi_flash_alloc_base(spi, params->name); if (!flash) { debug("SF: Failed to allocate memory\n"); return NULL; } - flash->spi = spi; - flash->name = params->name; - - flash->write = spi_flash_cmd_write_multi; - flash->erase = spi_flash_cmd_erase; - flash->read = spi_flash_cmd_read_fast; flash->page_size = 256; flash->sector_size = 256 * 16 * 16; flash->size = flash->sector_size * params->nr_blocks; diff --git a/drivers/mtd/spi/ramtron.c b/drivers/mtd/spi/ramtron.c index 0999781..5299a6d 100644 --- a/drivers/mtd/spi/ramtron.c +++ b/drivers/mtd/spi/ramtron.c @@ -284,15 +284,13 @@ struct spi_flash *spi_fram_probe_ramtron(struct spi_slave *spi, u8 *idcode) return NULL; found: - sn = malloc(sizeof(*sn)); + sn = spi_flash_alloc(struct ramtron_spi_fram, spi, params->name); if (!sn) { debug("SF: Failed to allocate memory\n"); return NULL; } sn->params = params; - sn->flash.spi = spi; - sn->flash.name = params->name; sn->flash.write = ramtron_write; sn->flash.read = ramtron_read; diff --git a/drivers/mtd/spi/spansion.c b/drivers/mtd/spi/spansion.c index 32b76e0..afd6a8c 100644 --- a/drivers/mtd/spi/spansion.c +++ b/drivers/mtd/spi/spansion.c @@ -128,18 +128,12 @@ struct spi_flash *spi_flash_probe_spansion(struct spi_slave *spi, u8 *idcode) return NULL;
[U-Boot] [PATCH 10/15] x86: spi: Set maximum write size for ICH
This SPI controller can only write 64 bytes at a time. Add this restriction in so that 'sf write' works correct for blocks larger than 64 bytes. Signed-off-by: Simon Glass --- drivers/spi/ich.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c index 31f9482..17defa4 100644 --- a/drivers/spi/ich.c +++ b/drivers/spi/ich.c @@ -166,6 +166,11 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs, return NULL; } + /* +* Yes this controller can only write a small number of bytes at +* once! The limit is typically 64 bytes. +*/ + ich->slave.max_write_size = ctlr.databytes; ich->speed = max_hz; return &ich->slave; -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 09/15] sf: Respect maximum SPI write size
Some SPI flash controllers (e.g. Intel ICH) have a limit on the number of bytes that can be in a write transaction. Support this by breaking the writes into multiple transactions. Signed-off-by: Simon Glass --- drivers/mtd/spi/spi_flash.c | 10 -- 1 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index 17f3d3c..b82011d 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -87,6 +87,9 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); + if (flash->spi->max_write_size) + chunk_len = min(chunk_len, flash->spi->max_write_size); + cmd[1] = page_addr >> 8; cmd[2] = page_addr; cmd[3] = byte_addr; @@ -111,8 +114,11 @@ int spi_flash_cmd_write_multi(struct spi_flash *flash, u32 offset, if (ret) break; - page_addr++; - byte_addr = 0; + byte_addr += chunk_len; + if (byte_addr == page_size) { + page_addr++; + byte_addr = 0; + } } debug("SF: program %s %zu bytes @ %#x\n", -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 13/15] x86: Add FDT SPI node for link
Add a memory-mapped 8GB SPI chip. Signed-off-by: Simon Glass --- board/chromebook-x86/dts/link.dts | 11 +++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/board/chromebook-x86/dts/link.dts b/board/chromebook-x86/dts/link.dts index ae8217d..d0738cb 100644 --- a/board/chromebook-x86/dts/link.dts +++ b/board/chromebook-x86/dts/link.dts @@ -21,4 +21,15 @@ chosen { }; memory { device_type = "memory"; reg = <0 0>; }; + + spi { + #address-cells = <1>; + #size-cells = <0>; + compatible = "intel,ich9"; + spi-flash@0 { + reg = <0>; + compatible = "winbond,w25q64", "spi-flash"; + memory-map = <0xff80 0x0080>; + }; + }; }; -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 14/15] x86: Enable SPI flash support for coreboot
Turn on SPI flash support and related commands. Signed-off-by: Simon Glass --- include/configs/coreboot.h | 12 +--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h index fd383ff..ea92ffe 100644 --- a/include/configs/coreboot.h +++ b/include/configs/coreboot.h @@ -258,10 +258,16 @@ /*--- * FLASH configuration */ +#define CONFIG_ICH_SPI +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_MACRONIX +#define CONFIG_SPI_FLASH_WINBOND +#define CONFIG_SPI_FLASH_GIGADEVICE #define CONFIG_SYS_NO_FLASH -#undef CONFIG_FLASH_CFI_DRIVER -#define CONFIG_SYS_MAX_FLASH_SECT 1 -#define CONFIG_SYS_MAX_FLASH_BANKS 1 +#define CONFIG_CMD_SF +#define CONFIG_CMD_SF_TEST +#define CONFIG_CMD_SPI +#define CONFIG_SPI /*--- * Environment configuration -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 15/15] x86: Enable time command for coreboot
This command is useful for measuring SPI flash load times and the like. Signed-off-by: Simon Glass --- include/configs/coreboot.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/include/configs/coreboot.h b/include/configs/coreboot.h index ea92ffe..4b6eb73 100644 --- a/include/configs/coreboot.h +++ b/include/configs/coreboot.h @@ -180,6 +180,7 @@ #define CONFIG_CMD_SAVEENV #define CONFIG_CMD_SETGETDCR #define CONFIG_CMD_SOURCE +#define CONFIG_CMD_TIME #define CONFIG_CMD_XIMG #define CONFIG_CMD_SCSI -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 07/15] x86: spi: Add Intel ICH driver
This supports Intel ICH7/9. The Intel controller is a little unusual in that it is mostly intended for use with SPI flash, and has some optimisations and features specifically for that application. In particular it is not possible to support ongoing transactions that continue over many calls with SPI_XFER_BEGIN and SPI_XFER_END. This driver supports writes of up to 64 bytes at a time, the limit for the controller. Future work will improve this. Signed-off-by: Bernie Thompson Signed-off-by: Duncan Laurie Signed-off-by: Bill Richardson Signed-off-by: Vadim Bendebury Signed-off-by: Gabe Black Signed-off-by: Simon Glass --- drivers/spi/Makefile |1 + drivers/spi/ich.c| 747 ++ drivers/spi/ich.h| 144 ++ 3 files changed, 892 insertions(+), 0 deletions(-) create mode 100644 drivers/spi/ich.c create mode 100644 drivers/spi/ich.h diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 4e8de5d..cfdc5d3 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -38,6 +38,7 @@ COBJS-$(CONFIG_CF_SPI) += cf_spi.o COBJS-$(CONFIG_CF_QSPI) += cf_qspi.o COBJS-$(CONFIG_DAVINCI_SPI) += davinci_spi.o COBJS-$(CONFIG_EXYNOS_SPI) += exynos_spi.o +COBJS-$(CONFIG_ICH_SPI) += ich.o COBJS-$(CONFIG_KIRKWOOD_SPI) += kirkwood_spi.o COBJS-$(CONFIG_MPC52XX_SPI) += mpc52xx_spi.o COBJS-$(CONFIG_MPC8XXX_SPI) += mpc8xxx_spi.o diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c new file mode 100644 index 000..31f9482 --- /dev/null +++ b/drivers/spi/ich.c @@ -0,0 +1,747 @@ +/* + * Copyright (c) 2011-12 The Chromium OS Authors. + * + * 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 + * + * This file is derived from the flashrom project. + */ + +#include +#include +#include +#include +#include +#include + +#include "ich.h" + +#define SPI_OPCODE_WREN 0x06 +#define SPI_OPCODE_FAST_READ 0x0b + +struct ich_ctlr { + pci_dev_t dev; /* PCI device number */ + int ich_version;/* Controller version, 7 or 9 */ + int ichspi_lock; + int locked; + uint8_t *opmenu; + int menubytes; + void *base; /* Base of register set */ + uint16_t *preop; + uint16_t *optype; + uint32_t *addr; + uint8_t *data; + unsigned databytes; + uint8_t *status; + uint16_t *control; + uint32_t *bbar; + uint32_t *pr; /* only for ich9 */ + uint8_t *speed; /* pointer to speed control */ +}; + +struct ich_ctlr ctlr; + +static inline struct ich_spi_slave *to_ich_spi(struct spi_slave *slave) +{ + return container_of(slave, struct ich_spi_slave, slave); +} + +static unsigned int ich_reg(const void *addr) +{ + return (unsigned)(addr - ctlr.base) & 0x; +} + +static u8 ich_readb(const void *addr) +{ + u8 value = readb(addr); + + debug("read %2.2x from %4.4x\n", value, ich_reg(addr)); + + return value; +} + +static u16 ich_readw(const void *addr) +{ + u16 value = readw(addr); + + debug("read %4.4x from %4.4x\n", value, ich_reg(addr)); + + return value; +} + +static u32 ich_readl(const void *addr) +{ + u32 value = readl(addr); + + debug("read %8.8x from %4.4x\n", value, ich_reg(addr)); + + return value; +} + +static void ich_writeb(u8 value, void *addr) +{ + writeb(value, addr); + debug("wrote %2.2x to %4.4x\n", value, ich_reg(addr)); +} + +static void ich_writew(u16 value, void *addr) +{ + writew(value, addr); + debug("wrote %4.4x to %4.4x\n", value, ich_reg(addr)); +} + +static void ich_writel(u32 value, void *addr) +{ + writel(value, addr); + debug("wrote %8.8x to %4.4x\n", value, ich_reg(addr)); +} + +static void write_reg(const void *value, void *dest, uint32_t size) +{ + const uint8_t *bvalue = value; + uint8_t *bdest = dest; + + while (size >= 4) { + ich_writel(*(const uint32_t *)bvalue, bdest); + bdest += 4; bvalue += 4; size -= 4; + } + while (size) { + ich_writeb(*bvalue, bdest); + bdest++; bvalue++; size--; + } +} + +static void read_reg(const void *src, void *value, uint32_t size) +{ + const uint8_t *bsrc = src; + uint8_t *bvalue = value; + + while (siz
[U-Boot] [PATCH 08/15] spi: Add parameter for maximum write size
Some SPI controllers (e.g. Intel ICH) have a limit on the number of SPI bytes that can be written at a time. Add this as a parameter so that clients of the SPI interface can respect this value. Signed-off-by: Simon Glass --- include/spi.h |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/include/spi.h b/include/spi.h index ebc9652..3fe2e1e 100644 --- a/include/spi.h +++ b/include/spi.h @@ -49,10 +49,13 @@ * * bus: ID of the bus that the slave is attached to. * cs: ID of the chip select connected to the slave. + * max_write_size: If non-zero, the maximum number of bytes which can + * be written at once, excluding command bytes. */ struct spi_slave { unsigned intbus; unsigned intcs; + unsigned int max_write_size; }; /*--- -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 11/15] sf: Enable FDT-based configuration and memory mapping
Enable device tree control of SPI flash, and use this to implement memory-mapped SPI flash, which is supported on Intel chips. Signed-off-by: Simon Glass --- drivers/mtd/spi/spi_flash.c | 46 ++- include/fdtdec.h|1 + include/spi_flash.h |1 + lib/fdtdec.c|1 + 4 files changed, 48 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c index b82011d..85a 100644 --- a/drivers/mtd/spi/spi_flash.c +++ b/drivers/mtd/spi/spi_flash.c @@ -8,6 +8,7 @@ */ #include +#include #include #include #include @@ -15,6 +16,8 @@ #include "spi_flash_internal.h" +DECLARE_GLOBAL_DATA_PTR; + static void spi_flash_addr(u32 addr, u8 *cmd) { /* cmd[0] is actual command */ @@ -146,6 +149,10 @@ int spi_flash_cmd_read_fast(struct spi_flash *flash, u32 offset, { u8 cmd[5]; + /* Handle memory-mapped SPI */ + if (flash->memory_map) + memcpy(data, flash->memory_map + offset, len); + cmd[0] = CMD_READ_ARRAY_FAST; spi_flash_addr(offset, cmd); cmd[4] = 0x00; @@ -275,6 +282,34 @@ int spi_flash_cmd_write_status(struct spi_flash *flash, u8 sr) return 0; } +#ifdef CONFIG_OF_CONTROL +int spi_flash_decode_fdt(const void *blob, struct spi_flash *flash) +{ + fdt_addr_t addr; + fdt_size_t size; + int node; + + /* If there is no node, do nothing */ + node = fdtdec_next_compatible(blob, 0, COMPAT_GENERIC_SPI_FLASH); + if (node < 0) + return 0; + + addr = fdtdec_get_addr_size(blob, node, "memory-map", &size); + if (addr == FDT_ADDR_T_NONE) { + debug("%s: Cannot decode address\n", __func__); + return 0; + } + + if (flash->size != size) { + debug("%s: Memory map must cover entire device\n", __func__); + return -1; + } + flash->memory_map = (void *)addr; + + return 0; +} +#endif /* CONFIG_OF_CONTROL */ + /* * The following table holds all device probe functions * @@ -391,9 +426,18 @@ struct spi_flash *spi_flash_probe(unsigned int bus, unsigned int cs, goto err_manufacturer_probe; } +#ifdef CONFIG_OF_CONTROL + if (spi_flash_decode_fdt(gd->fdt_blob, flash)) { + debug("SF: FDT decode error\n"); + goto err_manufacturer_probe; + } +#endif printf("SF: Detected %s with page size ", flash->name); print_size(flash->sector_size, ", total "); - print_size(flash->size, "\n"); + print_size(flash->size, ""); + if (flash->memory_map) + printf(", mapped at %p", flash->memory_map); + puts("\n"); spi_release_bus(spi); diff --git a/include/fdtdec.h b/include/fdtdec.h index 570d3ac..bfd1dda 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -72,6 +72,7 @@ enum fdt_compat_id { COMPAT_NVIDIA_TEGRA20_NAND, /* Tegra2 NAND controller */ COMPAT_NVIDIA_TEGRA20_PWM, /* Tegra 2 PWM controller */ COMPAT_NVIDIA_TEGRA20_DC, /* Tegra 2 Display controller */ + COMPAT_GENERIC_SPI_FLASH, /* Generic SPI Flash chip */ COMPAT_COUNT, }; diff --git a/include/spi_flash.h b/include/spi_flash.h index 030d49c..3b6a44e 100644 --- a/include/spi_flash.h +++ b/include/spi_flash.h @@ -39,6 +39,7 @@ struct spi_flash { /* Erase (sector) size */ u32 sector_size; + void *memory_map; /* Address of read-only SPI flash access */ int (*read)(struct spi_flash *flash, u32 offset, size_t len, void *buf); int (*write)(struct spi_flash *flash, u32 offset, diff --git a/lib/fdtdec.c b/lib/fdtdec.c index d0bc848..55305b4 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -45,6 +45,7 @@ static const char * const compat_names[COMPAT_COUNT] = { COMPAT(NVIDIA_TEGRA20_NAND, "nvidia,tegra20-nand"), COMPAT(NVIDIA_TEGRA20_PWM, "nvidia,tegra20-pwm"), COMPAT(NVIDIA_TEGRA20_DC, "nvidia,tegra20-dc"), + COMPAT(GENERIC_SPI_FLASH, "spi-flash"), }; const char *fdtdec_get_compatible(enum fdt_compat_id id) -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH 12/15] x86: Move PCI init before SPI init
It is possible that our PCI bus will provide the SPI controller, so change the init order to make this work. Signed-off-by: Simon Glass --- arch/x86/lib/board.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/lib/board.c b/arch/x86/lib/board.c index 555301a..c2407e4 100644 --- a/arch/x86/lib/board.c +++ b/arch/x86/lib/board.c @@ -163,13 +163,13 @@ init_fnc_t *init_sequence_r[] = { #ifndef CONFIG_SYS_NO_FLASH flash_init_r, #endif -#ifdef CONFIG_SPI - init_func_spi; -#endif - env_relocate_r, #ifdef CONFIG_PCI pci_init_r, #endif +#ifdef CONFIG_SPI + init_func_spi, +#endif + env_relocate_r, stdio_init, jumptable_init_r, console_init_r, -- 1.7.7.3 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot