Re: [U-Boot] [PATCH v6 1/4] mtd, spi: add MTD layer driver
Hello Jagan, Am 16.06.2015 um 10:04 schrieb Jagan Teki: Hi Heiko, On 20 May 2015 at 12:16, Heiko Schocher wrote: Hello Jagan, Am 19.05.2015 22:09, schrieb Jagan Teki: Hi Heiko, I have tested this sf-mtd stuff, please see below and enabled prints in all the func calls. Thanks for testing! zynq-uboot> mtdparts add nor0 0x1@0x0 env mtdparts variable not set, see 'help mtdparts' zynq-uboot> mtdparts device nor0 , # parts = 1 #: namesizeoffset mask_flags 0: env 0x0001 0x 0 active partition: nor0,0 - (env) 0x0001 @ 0x defaults: mtdids : nor0=zynq-sf.0 mtdparts: none zynq-uboot> sf erase env 0x1 spi_flash_erase spi_flash_cmd_erase_ops SF: erase d8 0 0 0 (0) SF: 65536 bytes @ 0x0 Erased: OK zynq-uboot> mw.b 0x100 0x44 0x1 zynq-uboot> sf write 0x100 env device 0 offset 0x0, size 0x1 spi_flash_cmd_write_ops SF: 65536 bytes @ 0x0 Written: OK zynq-uboot> sf read 0x4 env device 0 offset 0x0, size 0x1 spi_flash_cmd_read_ops off = 0x1, len = 0 SF: 65536 bytes @ 0x0 Read: OK zynq-uboot> cmp.b 0x100 0x4 0x1 Total of 65536 byte(s) were the same Looks good ... I wonder none of the sf_mtd_info._* getting called, why? Hmm.. good question .. you use the "sf ..." commands, they do not use the mtd interface, right? I'm fine with the testing, but mtd code in sf seems used only for in UBI only. a fast "grep mtd_read" in the u-boot source shows, that yaffs2 also uses mtd_read ... I did no yaffs2 test, but I think, yaffs2 can be used also with spi flashes now ... if this is wise, I don;t know ... I tested with UBI on a spi flash, and that works ... in the same fashion it currently does on nand for example ... I wouldn't see this is a better approach where mtd code is considered as to be unknown thing for sf. I do not understand you here complete ... drivers/mtd/spi/sf_mtd.c adds just spi flash specific functions to integrate spi flashes into mtd ... and mtd users can then read/write/erase with the mtd_* functions ... Maybe someone has time to convert common/sf.c to use them? So, the final question is, can this patches go into mainline? thanks! bye, Heiko I tested this functions with using UBI on the SPI NOR on the aristainetos and aristianetos2 boards... I added for example in diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c index 0b9cb62..6063ed7 100644 --- a/drivers/mtd/spi/sf_mtd.c +++ b/drivers/mtd/spi/sf_mtd.c @@ -39,6 +40,7 @@ static int spi_flash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, struct spi_flash *flash = mtd->priv; int err; +printf("%s \n", __func__); err = spi_flash_read(flash, from, len, buf); if (!err) *retlen = len; and see: => sf probe SF: Detected N25Q128A with page size 256 Bytes, erase size 64 KiB, total 16 MiB => mtdparts device nor0 , # parts = 4 #: namesizeoffset mask_flags 0: u-boot 0x000d 0x 0 1: env 0x0001 0x000d 0 2: env-red 0x0001 0x000e 0 3: rescue-system 0x00f1 0x000f 0 device nand0 , # parts = 1 #: namesizeoffset mask_flags 0: ubi 0x4000 0x 0 active partition: nor0,0 - (u-boot) 0x000d @ 0x defaults: mtdids : none mtdparts: none => ubi part rescue-system UBI: default fastmap pool size: 10 UBI: default fastmap WL pool size: 25 UBI: attaching mtd2 to ubi0 UBI DBG gen (pid 1): sizeof(struct ubi_ainf_peb) 48 UBI DBG gen (pid 1): sizeof(struct ubi_wl_entry) 20 UBI DBG gen (pid 1): min_io_size 1 UBI DBG gen (pid 1): max_write_size 256 UBI DBG gen (pid 1): hdrs_min_io_size 1 UBI DBG gen (pid 1): ec_hdr_alsize64 UBI DBG gen (pid 1): vid_hdr_alsize 64 UBI DBG gen (pid 1): vid_hdr_offset 64 UBI DBG gen (pid 1): vid_hdr_aloffset 64 UBI DBG gen (pid 1): vid_hdr_shift0 UBI DBG gen (pid 1): leb_start128 UBI DBG gen (pid 1): max_erroneous24 UBI DBG gen (pid 1): process PEB 0 UBI DBG bld (pid 1): scan PEB 0 UBI DBG io (pid 1): read EC header from PEB 0 UBI DBG io (pid 1): read 64 bytes from PEB 0:0 spi_flash_mtd_read UBI DBG io (pid 1): read VID header from PEB 0 UBI DBG io (pid 1): read 64 bytes from PEB 0:64 spi_flash_mtd_read [...] UBI uses the MTD layer ... the sf command not ... Hope this helps? bye, Heiko On 27 April 2015 at 11:12, Heiko Schocher wrote: From: Daniel Schwierzeck add MTD layer driver for spi, original patch from: http://git.denx.de/?p=u-boot/u-boot-mips.git;a=commitdiff;h=bb246819cdc90493dd7089eaa51b9e639765cced changes from Heiko Schocher against this patch: - remove compile error if not defining CONFIG_SPI_FLASH_MTD: LD drivers/mtd/spi/built-in.o drivers/mtd/spi/sf_probe.o: In function `spi_flash_mtd_unregist
Re: [U-Boot] [PATCH v6 1/4] mtd, spi: add MTD layer driver
Hello Jagan, Am 16.06.2015 um 10:52 schrieb Jagan Teki: Hi Heiko, On 16 June 2015 at 14:13, Heiko Schocher denx wrote: Hello Jagan, Am 16.06.2015 um 10:04 schrieb Jagan Teki: Hi Heiko, On 20 May 2015 at 12:16, Heiko Schocher wrote: Hello Jagan, Am 19.05.2015 22:09, schrieb Jagan Teki: Hi Heiko, I have tested this sf-mtd stuff, please see below and enabled prints in all the func calls. Thanks for testing! zynq-uboot> mtdparts add nor0 0x1@0x0 env mtdparts variable not set, see 'help mtdparts' zynq-uboot> mtdparts device nor0 , # parts = 1 #: namesizeoffset mask_flags 0: env 0x0001 0x 0 active partition: nor0,0 - (env) 0x0001 @ 0x defaults: mtdids : nor0=zynq-sf.0 mtdparts: none zynq-uboot> sf erase env 0x1 spi_flash_erase spi_flash_cmd_erase_ops SF: erase d8 0 0 0 (0) SF: 65536 bytes @ 0x0 Erased: OK zynq-uboot> mw.b 0x100 0x44 0x1 zynq-uboot> sf write 0x100 env device 0 offset 0x0, size 0x1 spi_flash_cmd_write_ops SF: 65536 bytes @ 0x0 Written: OK zynq-uboot> sf read 0x4 env device 0 offset 0x0, size 0x1 spi_flash_cmd_read_ops off = 0x1, len = 0 SF: 65536 bytes @ 0x0 Read: OK zynq-uboot> cmp.b 0x100 0x4 0x1 Total of 65536 byte(s) were the same Looks good ... I wonder none of the sf_mtd_info._* getting called, why? Hmm.. good question .. you use the "sf ..." commands, they do not use the mtd interface, right? I'm fine with the testing, but mtd code in sf seems used only for in UBI only. a fast "grep mtd_read" in the u-boot source shows, that yaffs2 also uses mtd_read ... I did no yaffs2 test, but I think, yaffs2 can be used also with spi flashes now ... if this is wise, I don;t know ... I tested with UBI on a spi flash, and that works ... in the same fashion it currently does on nand for example ... I wouldn't see this is a better approach where mtd code is considered as to be unknown thing for sf. I do not understand you here complete ... drivers/mtd/spi/sf_mtd.c adds just spi flash specific functions to integrate spi flashes into mtd ... and mtd users can then read/write/erase with the mtd_* functions ... Maybe someone has time to convert common/sf.c to use them? So, the final question is, can this patches go into mainline? The only point I'm concerned here is If I need to use sf with mtd support without using ubifs or any flash filesystem, the code in sf_mtd.c ops becomes unused. Why you want to enable mtd support for sf, if you not use it? do not define CONFIG_SPI_FLASH_MTD in this case? This seems to be a code size increasing factor which is obviously not a good point for bootloader atleast for u-boot, what do you think? I agreed your concerned for someone may add support to common/cmd_sf.c in future, but I'm bit worried to go this. Why? Its the same state as it is in the nand subsystem ... bye, Heiko I tested this functions with using UBI on the SPI NOR on the aristainetos and aristianetos2 boards... I added for example in diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c index 0b9cb62..6063ed7 100644 --- a/drivers/mtd/spi/sf_mtd.c +++ b/drivers/mtd/spi/sf_mtd.c @@ -39,6 +40,7 @@ static int spi_flash_mtd_read(struct mtd_info *mtd, loff_t from, size_t len, struct spi_flash *flash = mtd->priv; int err; +printf("%s \n", __func__); err = spi_flash_read(flash, from, len, buf); if (!err) *retlen = len; and see: => sf probe SF: Detected N25Q128A with page size 256 Bytes, erase size 64 KiB, total 16 MiB => mtdparts device nor0 , # parts = 4 #: namesizeoffset mask_flags 0: u-boot 0x000d 0x 0 1: env 0x0001 0x000d 0 2: env-red 0x0001 0x000e 0 3: rescue-system 0x00f1 0x000f 0 device nand0 , # parts = 1 #: namesizeoffset mask_flags 0: ubi 0x4000 0x 0 active partition: nor0,0 - (u-boot) 0x000d @ 0x defaults: mtdids : none mtdparts: none => ubi part rescue-system UBI: default fastmap pool size: 10 UBI: default fastmap WL pool size: 25 UBI: attaching mtd2 to ubi0 UBI DBG gen (pid 1): sizeof(struct ubi_ainf_peb) 48 UBI DBG gen (pid 1): sizeof(struct ubi_wl_entry) 20 UBI DBG gen (pid 1): min_io_size 1 UBI DBG gen (pid 1): max_write_size 256 UBI DBG gen (pid 1): hdrs_min_io_size 1 UBI DBG gen (pid 1): ec_hdr_alsize64 UBI DBG gen (pid 1): vid_hdr_alsize 64 UBI DBG gen (pid 1): vid_hdr_offset 64 UBI DBG gen (pid 1): vid_hdr_aloffset 64 UBI DBG gen (pid 1): vid_hdr_shift0 UBI DBG gen (pid 1): leb_start128 UBI DBG gen (pid 1): max_erroneous24 UBI DBG
Re: [U-Boot] [PATCH] arm, am33xx: update for siemens am335x based boards
Hello Samuel, Am 16.06.2015 um 14:08 schrieb Egli, Samuel: Hi Heiko, I noticed a little discrepancy concerning delay for DDR3. During last rebase to v2015.04 I observed that delay needs to be increased to boot successfully. Somehow some timing behavior changed since v2014.04. I set it to udelay(2000) and it works fine again. Please update your patch. Ups... Ok, I send an updated v2 patch. Thanks! bye, Heiko Sam -Original Message- From: Heiko Schocher [mailto:h...@denx.de] Sent: Montag, 15. Juni 2015 14:55 To: u-boot@lists.denx.de Cc: Heiko Schocher; Egli, Samuel; Tom Rini Subject: [PATCH] arm, am33xx: update for siemens am335x based boards [...] @@ -193,6 +196,11 @@ struct ctrl_ioregs draco_ddr3_ioregs = { config_ddr(DDR_PLL_FREQ, &draco_ddr3_ioregs, &draco_ddr3_data, &draco_ddr3_cmd_ctrl_data, &draco_ddr3_emif_reg_data, 0); + + /* For Samsung 2Gbit RAM we need this delay otherwise config fails after +* soft reset. +*/ + udelay(1000); } [...] -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v7 0/4] sf: Add MTD layer support
Hello Jagan, Am 22.06.2015 um 22:00 schrieb Jagan Teki: Just resend the whole series with below changes, Changes for v7: - Add more notes on commit message - Update the info for CONFIG_SPI_FLASH_MTD in README - Remove ^ character in sf erase line sf help text - Update starting character in commit message heads with capitals Heiko and Daniel - send your comments on this series once all clear I will push on my tree. Ok, from my side, thanks! bye, Heiko thanks! Jagan. Daniel Schwierzeck (1): mtd, spi: Add MTD layer driver Heiko Schocher (3): mtd, nand: Move common functions from cmd_nand.c to common place spi, sf: Use offset and size in sf cmd from mtdpartition mtd, spi: Check if flash pointer is used README| 9 +++ common/cmd_nand.c | 148 +- common/cmd_onenand.c | 19 ++ common/cmd_sf.c | 61 + common/cmd_test.c | 12 +--- drivers/mtd/Makefile | 4 +- drivers/mtd/mtd_uboot.c | 99 drivers/mtd/spi/Makefile | 1 + drivers/mtd/spi/sf_internal.h | 5 ++ drivers/mtd/spi/sf_mtd.c | 104 + drivers/mtd/spi/sf_probe.c| 11 ++-- include/linux/mtd/mtd.h | 5 ++ include/vsprintf.h| 2 + lib/vsprintf.c| 16 + 14 files changed, 323 insertions(+), 173 deletions(-) create mode 100644 drivers/mtd/mtd_uboot.c create mode 100644 drivers/mtd/spi/sf_mtd.c -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] Pull request: u-boot-spi/master
Hello Tom, Am 25.06.2015 um 01:31 schrieb Tom Rini: On Tue, Jun 23, 2015 at 08:47:25PM +0530, Jagan Teki wrote: Hi Tom, Please pull this request, few importent feature list on spi-flash front like data flash and spi flash MTD supports. thanks! Jagan. The following changes since commit c6265f7f3410b5e5763181cdd123a3f6fcd9fd58: CPCI4052: Remove CONFIG_SYS_LONGHELP (2015-06-18 16:19:00 -0400) are available in the git repository at: git://git.denx.de/u-boot-spi.git master for you to fetch changes up to 1070bf38a5c92c8d1a77b26380988957890ba6de: mtd, spi: Check if flash pointer is used (2015-06-23 01:13:23 +0530) This introduces build problems on ls1021atwr_qspi and ls1021aqds_qspi. Could you provide a log? I see, based on current mainline: commit 325849ff3d4adeebb8f8f9bc5db950724df9bc21 Merge: 8c65a2f de45149 Author: Tom Rini Date: Fri Jun 19 14:21:32 2015 -0400 Merge git://git.denx.de/u-boot-usb pollux:u-boot hs [20150527] $ make mrproper CLEAN examples/standalone CLEAN tools CLEAN tools/lib tools/common CLEAN include/bmp_logo.h include/bmp_logo_data.h u-boot.lds u-boot.bin u-boot.srec u-boot.map u-boot.cfg u-boot System.map CLEAN scripts/basic CLEAN scripts/kconfig CLEAN include/config include/generated CLEAN .config include/autoconf.mk.dep include/autoconf.mk include/config.h pollux:u-boot hs [20150527] $ make ls1021atwr_qspi_defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf # # configuration written to .config # pollux:u-boot hs [20150527] $ make -s all pollux:u-boot hs [20150527] $ make mrproper m CLEAN examples/standalone a CLEAN tools k CLEAN tools/lib tools/common CLEAN include/bmp_logo.h include/bmp_logo_data.h u-boot.lds u-boot.bin u-boot.srec u-boot.map u-boot.cfg u-boot System.map e ls1021aqds_qspi_ CLEAN scripts/basic CLEAN scripts/kconfig CLEAN include/config include/generated d CLEAN .config include/autoconf.mk.dep include/autoconf.mk include/config.h pollux:u-boot hs [20150527] $ make ls1021aqds_qspi_defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf # # configuration written to .config # pollux:u-boot hs [20150527] $ make -s all pollux:u-boot hs [20150527] $ Thanks! bye, Heiko ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/8] JFFS2: Return early when file read not necessary
Hello Mark, Am 29.06.2015 um 07:02 schrieb Mark Tomlinson: If a destination is not provided, jffs2_1pass_read_inode() only returns the length of the file. In this case, avoid reading all the data nodes, and return as soon as the length of the file is known. Signed-off-by: Mark Tomlinson --- fs/jffs2/jffs2_1pass.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index b1d6470..2335db1 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -719,6 +719,12 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest) } put_fl_mem(jNode, pL->readbuf); } + /* If no destination is provided, we are done. +* Just return the total size. +*/ please change this into /* * If no destination is provided, we are done. * Just return the total size. */ to fit with Coding style. + if (!dest) { + return totalSize; + } no {} needed Beside of this: Acked-by: Heiko Schocher bye, Heiko #endif for (b = pL->frag.listHead; b != NULL; b = b->next) { -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/8] JFFS2: Speed up and fix comparison functions
Hello Mark, Am 29.06.2015 um 07:02 schrieb Mark Tomlinson: Copying complete nodes from flash can be slow if the flash is slow to read. By only reading the data needed, the sorting operation can be made much faster. The directory entry comparison function also had a two bugs. First, it did not ensure the name was copied, so the name comparison may have been faulty (although it would have worked with NOR flash). Second, setting the ino to zero to ignore the entry did not work, since this was either writing to a temporary buffer, or (for NOR flash) directly to flash. Either way, the change was not remembered. Signed-off-by: Mark Tomlinson --- fs/jffs2/jffs2_1pass.c | 82 ++ 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index 2335db1..079bb73 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -598,14 +598,17 @@ insert_node(struct b_list *list, u32 offset) */ static int compare_inodes(struct b_node *new, struct b_node *old) { - struct jffs2_raw_inode ojNew; - struct jffs2_raw_inode ojOld; - struct jffs2_raw_inode *jNew = - (struct jffs2_raw_inode *)get_fl_mem(new->offset, sizeof(ojNew), &ojNew); - struct jffs2_raw_inode *jOld = - (struct jffs2_raw_inode *)get_fl_mem(old->offset, sizeof(ojOld), &ojOld); - - return jNew->version > jOld->version; + /* Only read in the version info from flash, not the entire inode. please fix your comment style globally, thanks1 +* This can make a big difference to speed if flash is slow. +*/ + u32 new_version; + u32 old_version; + get_fl_mem(new->offset + offsetof(struct jffs2_raw_inode, version), + sizeof(new_version), &new_version); + get_fl_mem(old->offset + offsetof(struct jffs2_raw_inode, version), + sizeof(old_version), &old_version); + + return new_version > old_version; } /* Sort directory entries so all entries in the same directory @@ -615,42 +618,41 @@ static int compare_inodes(struct b_node *new, struct b_node *old) */ static int compare_dirents(struct b_node *new, struct b_node *old) { - struct jffs2_raw_dirent ojNew; - struct jffs2_raw_dirent ojOld; - struct jffs2_raw_dirent *jNew = - (struct jffs2_raw_dirent *)get_fl_mem(new->offset, sizeof(ojNew), &ojNew); - struct jffs2_raw_dirent *jOld = - (struct jffs2_raw_dirent *)get_fl_mem(old->offset, sizeof(ojOld), &ojOld); - int cmp; - - /* ascending sort by pino */ - if (jNew->pino != jOld->pino) - return jNew->pino > jOld->pino; - - /* pino is the same, so use ascending sort by nsize, so -* we don't do strncmp unless we really must. -*/ - if (jNew->nsize != jOld->nsize) - return jNew->nsize > jOld->nsize; - - /* length is also the same, so use ascending sort by name -*/ - cmp = strncmp((char *)jNew->name, (char *)jOld->name, jNew->nsize); - if (cmp != 0) - return cmp > 0; - - /* we have duplicate names in this directory, so use ascending -* sort by version + /* Using NULL as the buffer for NOR flash prevents the entire node +* being read. This makes most comparisons much quicker as only one +* or two entries from the node will be used most of the time. */ - if (jNew->version > jOld->version) { - /* since jNew is newer, we know jOld is not valid, so -* mark it with inode 0 and it will not be used + struct jffs2_raw_dirent *jNew = get_node_mem(new->offset, NULL); + struct jffs2_raw_dirent *jOld = get_node_mem(old->offset, NULL); + int cmp; + int ret; + + if (jNew->pino != jOld->pino) { + /* ascending sort by pino */ + ret = jNew->pino > jOld->pino; + } else if (jNew->nsize != jOld->nsize) { + /* pino is the same, so use ascending sort by nsize, so +* we don't do strncmp unless we really must. */ - jOld->ino = 0; - return 1; + ret = jNew->nsize > jOld->nsize; + } else { + /* length is also the same, so use ascending sort by name +*/ + cmp = strncmp((char *)jNew->name, (char *)jOld->name, + jNew->nsize); + if (cmp != 0) { + ret = cmp > 0; + } else { + /* we have duplicate names in this directory, +* so use ascending sort by version +*/ + ret = jNew->version > jOld->version; + } } + put_fl_mem(jNew, NULL); + put_fl_mem(jOld, NULL); - return 0; + return ret; } #endif
Re: [U-Boot] [PATCH 3/8] JFFS2: Only list each directory entry once
Hello Mark, Am 29.06.2015 um 07:02 schrieb Mark Tomlinson: If multiple versions of a file exist, only the most recent version should be used. The scheme to write 0 for the inode in older versions did not work, since this would have required writing to flash. The only time this caused an issue was listing a directory, where older versions of the file would still be seen. Since the directory entries are sorted, just look at the next entry in the list, and if it's the same move to that entry instead. Signed-off-by: Mark Tomlinson --- fs/jffs2/jffs2_1pass.c | 37 - 1 file changed, 32 insertions(+), 5 deletions(-) Reviewed-by: Heiko Schocher bye, Heiko diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index 079bb73..1f6eea7 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -840,7 +840,6 @@ jffs2_1pass_find_inode(struct b_lists * pL, const char *name, u32 pino) jDir = (struct jffs2_raw_dirent *) get_node_mem(b->offset, pL->readbuf); if ((pino == jDir->pino) && (len == jDir->nsize) && - (jDir->ino) && /* 0 for unlink */ (!strncmp((char *)jDir->name, name, len))) { /* a match */ if (jDir->version < version) { put_fl_mem(jDir, pL->readbuf); @@ -961,13 +960,42 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) for (b = pL->dir.listHead; b; b = b->next) { jDir = (struct jffs2_raw_dirent *) get_node_mem(b->offset, pL->readbuf); - if ((pino == jDir->pino) && (jDir->ino)) { /* ino=0 -> unlink */ + if (pino == jDir->pino) { u32 i_version = 0; struct jffs2_raw_inode ojNode; struct jffs2_raw_inode *jNode, *i = NULL; - struct b_node *b2 = pL->frag.listHead; + struct b_node *b2; - while (b2) { +#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS + /* Check for more recent versions of this file */ + int match; + do { + struct b_node *next = b->next; + struct jffs2_raw_dirent *jDirNext; + if (!next) + break; + jDirNext = (struct jffs2_raw_dirent *) + get_node_mem(next->offset, NULL); + match = jDirNext->pino == jDir->pino && + jDirNext->nsize == jDir->nsize && + strncmp((char *)jDirNext->name, + (char *)jDir->name, + jDir->nsize) == 0; + if (match) { + /* Use next. It is more recent */ + b = next; + /* Update buffer with the new info */ + *jDir = *jDirNext; + put_fl_mem(jDirNext, NULL); + } + } while (match); +#endif + if (jDir->ino == 0) { + /* Deleted file */ + continue; + } + + for (b2 = pL->frag.listHead; b2; b2 = b2->next) { jNode = (struct jffs2_raw_inode *) get_fl_mem(b2->offset, sizeof(ojNode), &ojNode); if (jNode->ino == jDir->ino && jNode->version >= i_version) { @@ -983,7 +1011,6 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) sizeof(*i), NULL); } - b2 = b2->next; } dump_inode(pL, jDir, i); -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 4/8] JFFS2: Improve speed reading flash files
Hello Mark, Am 29.06.2015 um 07:02 schrieb Mark Tomlinson: jffs2_1pass_read_inode() would read the entire data for each node in the filesystem, regardless of whether it was part of the file to be loaded or not. By only reading the header data for an inode, and then reading the data only when it is found to be part of the file to be loaded, much copying of data is saved. jffs2_1pass_list_inodes() read each inode for every file in the directory into a buffer. By using NULL as a buffer pointer, NOR flash simply returns a pointer, and therefore avoids a memory copy. Signed-off-by: Mark Tomlinson --- fs/jffs2/jffs2_1pass.c | 25 +++-- 1 file changed, 19 insertions(+), 6 deletions(-) Reviewed-by: Heiko Schocher bye, Heiko diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index 1f6eea7..80210be 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -730,8 +730,12 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest) #endif for (b = pL->frag.listHead; b != NULL; b = b->next) { - jNode = (struct jffs2_raw_inode *) get_node_mem(b->offset, - pL->readbuf); + /* Copy just the node and not the data at this point, +* since we don't yet know if we need this data. +*/ + jNode = (struct jffs2_raw_inode *)get_fl_mem(b->offset, + sizeof(struct jffs2_raw_inode), + pL->readbuf); if (inode == jNode->ino) { #if 0 putLabeledWord("\r\n\r\nread_inode: totlen = ", jNode->totlen); @@ -755,7 +759,14 @@ jffs2_1pass_read_inode(struct b_lists *pL, u32 inode, char *dest) #endif if(dest) { - src = ((uchar *) jNode) + sizeof(struct jffs2_raw_inode); + /* Now that the inode has been checked, +* read the entire inode, including data. +*/ + put_fl_mem(jNode, pL->readbuf); + jNode = (struct jffs2_raw_inode *) + get_node_mem(b->offset, pL->readbuf); + src = ((uchar *)jNode) + + sizeof(struct jffs2_raw_inode); /* ignore data behind latest known EOF */ if (jNode->offset > totalSize) { put_fl_mem(jNode, pL->readbuf); @@ -962,7 +973,6 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) pL->readbuf); if (pino == jDir->pino) { u32 i_version = 0; - struct jffs2_raw_inode ojNode; struct jffs2_raw_inode *jNode, *i = NULL; struct b_node *b2; @@ -997,8 +1007,10 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) for (b2 = pL->frag.listHead; b2; b2 = b2->next) { jNode = (struct jffs2_raw_inode *) - get_fl_mem(b2->offset, sizeof(ojNode), &ojNode); - if (jNode->ino == jDir->ino && jNode->version >= i_version) { + get_fl_mem(b2->offset, sizeof(*jNode), + NULL); + if (jNode->ino == jDir->ino && + jNode->version >= i_version) { i_version = jNode->version; if (i) put_fl_mem(i, NULL); @@ -1011,6 +1023,7 @@ jffs2_1pass_list_inodes(struct b_lists * pL, u32 pino) sizeof(*i), NULL); } + put_fl_mem(jNode, NULL); } dump_inode(pL, jDir, i); -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 7/8] JFFS2: Use CLEANMARKER to reduce scanning time
Hello Mark, Am 29.06.2015 um 07:02 schrieb Mark Tomlinson: If a sector has a CLEANMARKER at the beginning, it indicates that the entire sector has been erased. Therefore, if this is found, we can skip the entire block. This was not being done before this patch. The code now does the same as the kernel does when encountering a CLEANMARKER. It still checks that the next few words are , and if so, the block is assumed to be empty, and so is skipped. Signed-off-by: Mark Tomlinson --- fs/jffs2/jffs2_1pass.c | 22 ++ 1 file changed, 22 insertions(+) Beside of your comment style Reviewed-by: Heiko Schocher bye, Heiko diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index d78fb06..26a748f 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -1520,6 +1520,8 @@ jffs2_1pass_build_lists(struct part_info * part) uint32_t sumlen; int ret; #endif + /* Indicates a sector with a CLEANMARKER was found */ + int clean_sector = 0; /* Set buf_size to maximum length */ buf_size = DEFAULT_EMPTY_SCAN_SIZE; @@ -1643,6 +1645,13 @@ jffs2_1pass_build_lists(struct part_info * part) ofs += 4; } /* Ran off end. */ + /* If this sector had a clean marker at the +* beginning, and immediately following this +* have been a bunch of FF bytes, treat the +* entire sector as empty. +*/ + if (clean_sector) + break; /* See how much more there is to read in this * eraseblock... @@ -1664,6 +1673,10 @@ jffs2_1pass_build_lists(struct part_info * part) buf_ofs = ofs; goto more_empty; } + /* Found something not erased in the sector, so reset +* the 'clean_sector' flag. +*/ + clean_sector = 0; if (node->magic != JFFS2_MAGIC_BITMASK || !hdr_crc(node)) { ofs += 4; @@ -1745,6 +1758,15 @@ jffs2_1pass_build_lists(struct part_info * part) "%d != %zu\n", node->totlen, sizeof(struct jffs2_unknown_node)); + if ((node->totlen == +sizeof(struct jffs2_unknown_node)) && + (ofs == sector_ofs)) { + /* Found a CLEANMARKER at the beginning +* of the sector. It's in the correct +* place with correct size and CRC. +*/ + clean_sector = 1; + } break; case JFFS2_NODETYPE_PADDING: if (node->totlen < sizeof(struct jffs2_unknown_node)) -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 8/8] JFFS2: Use merge sort when parsing filesystem
Hello Mark, Am 29.06.2015 um 07:02 schrieb Mark Tomlinson: When building the file system the existing code does an insertion into a linked list. It attempts to speed this up by keeping a pointer to where the last entry was inserted but it's still slow. Now the nodes are just inserted into the list without searching through for the correct place. This unsorted list is then sorted once using mergesort after all the entries have been added to the list. This speeds up the scanning of the flash file system considerably. Signed-off-by: Mark Tomlinson --- fs/jffs2/Makefile| 1 + fs/jffs2/jffs2_1pass.c | 47 fs/jffs2/jffs2_private.h | 4 +++ fs/jffs2/mergesort.c | 70 4 files changed, 86 insertions(+), 36 deletions(-) create mode 100644 fs/jffs2/mergesort.c diff --git a/fs/jffs2/Makefile b/fs/jffs2/Makefile index 4cb0600..90524ba 100644 --- a/fs/jffs2/Makefile +++ b/fs/jffs2/Makefile @@ -10,4 +10,5 @@ obj-y += compr_rtime.o obj-y += compr_rubin.o obj-y += compr_zlib.o obj-y += jffs2_1pass.o +obj-y += mergesort.o obj-y += mini_inflate.o diff --git a/fs/jffs2/jffs2_1pass.c b/fs/jffs2/jffs2_1pass.c index 26a748f..a456650 100644 --- a/fs/jffs2/jffs2_1pass.c +++ b/fs/jffs2/jffs2_1pass.c @@ -125,7 +125,6 @@ #include "jffs2_private.h" - This change has nothing to do with your commit message ... #define NODE_CHUNK 1024/* size of memory allocation chunk in b_nodes */ #define SPIN_BLKSIZE18 /* spin after having scanned 1next = NULL; -#ifdef CONFIG_SYS_JFFS2_SORT_FRAGMENTS - if (list->listTail != NULL && list->listCompare(new, list->listTail)) - prev = list->listTail; - else if (list->listLast != NULL && list->listCompare(new, list->listLast)) - prev = list->listLast; + if (list->listTail != NULL) + list->listTail->next = new; else - prev = NULL; - - for (b = (prev ? prev->next : list->listHead); -b != NULL && list->listCompare(new, b); -prev = b, b = b->next) { - list->listLoops++; - } - if (b != NULL) - list->listLast = prev; - - if (b != NULL) { - new->next = b; - if (prev != NULL) - prev->next = new; - else - list->listHead = new; - } else -#endif - { - new->next = (struct b_node *) NULL; - if (list->listTail != NULL) { - list->listTail->next = new; - list->listTail = new; - } else { - list->listTail = list->listHead = new; - } - } + list->listHead = new; + list->listTail = new; return new; } @@ -1788,6 +1757,12 @@ jffs2_1pass_build_lists(struct part_info * part) } free(buf); +#if defined(CONFIG_SYS_JFFS2_SORT_FRAGMENTS) + /* Sort the lists. +*/ + sort_list(&pL->frag); + sort_list(&pL->dir); +#endif putstr("\b\b done.\r\n"); /* close off the dots */ /* We don't care if malloc failed - then each read operation will diff --git a/fs/jffs2/jffs2_private.h b/fs/jffs2/jffs2_private.h index 658b325..06b6ca2 100644 --- a/fs/jffs2/jffs2_private.h +++ b/fs/jffs2/jffs2_private.h @@ -98,4 +98,8 @@ data_crc(struct jffs2_raw_inode *node) } } +#if defined(CONFIG_SYS_JFFS2_SORT_FRAGMENTS) +/* External merge sort. */ +int sort_list(struct b_list *list); +#endif #endif /* jffs2_private.h */ diff --git a/fs/jffs2/mergesort.c b/fs/jffs2/mergesort.c new file mode 100644 index 000..10ecc8d --- /dev/null +++ b/fs/jffs2/mergesort.c @@ -0,0 +1,70 @@ +/* + * This file is copyright 2001 Simon Tatham. + * Rewritten from original source 2006 by Dan Merillat for use in u-boot. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL SIMON TATHAM BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +
Re: [U-Boot] [PATCH] siemens,am33x: adjust mtd partition
Hallo Samuel, Am 01.07.2015 um 11:04 schrieb Samuel Egli: Use one mtd partition for rootfs and configuration by means of ubi volumes and get rid of configuration partition. We can use partition layout for both 256MB and 512MB flash. Signed-off-by: Samuel Egli Cc: Heiko Schocher Cc: Roger Meier --- include/configs/siemens-am33x-common.h | 33 1 file changed, 16 insertions(+), 17 deletions(-) only one nitpick ... diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h index 120647f..eddb868 100644 --- a/include/configs/siemens-am33x-common.h +++ b/include/configs/siemens-am33x-common.h @@ -486,7 +486,7 @@ /* * Variant 2 partition layout - * chip-size = 256MiB + * chip-size = 256MiB or 512 MiB *| name |size | address area | *--- *| spl | 128.000 KiB | 0x 0..0x 1 | @@ -496,23 +496,23 @@ *| u-boot | 1.875 MiB | 0x 8..0x 25 | *| uboot.env0 | 512.000 KiB | 0x 26..0x 2D | *| uboot.env1 | 512.000 KiB | 0x 2E..0x 35 | - *| rootfs | 148.000 MiB | 0x 36..0x 975 | - *| mtdoops | 512.000 KiB | 0x 976..0x 98D | - *|configuration | 104.125 MiB | 0x 97E..0x fff | + *| mtdoops | 512.000 KiB | 0x 36..0x 3d | + *| (256) rootfs | 252.125 MiB | 0x 3E..0x fff | + *| (512) rootfs | 508.125 MiB | 0x 3E..0x1fff | *--- */ #define MTDPARTS_DEFAULT_V2 "mtdparts=" MTDIDS_NAME_STR ":" \ - "128k(spl)," \ - "128k(spl.backup1)," \ - "128k(spl.backup2)," \ - "128k(spl.backup3)," \ - "1920k(u-boot)," \ - "512k(u-boot.env0)," \ - "512k(u-boot.env1)," \ - "148m(rootfs)," \ - "512k(mtdoops)," \ - "-(configuration)" + "128k(spl)," \ + "128k(spl.backup1)," \ + "128k(spl.backup2)," \ + "128k(spl.backup3)," \ + "1920k(u-boot)," \ + "512k(u-boot.env0)," \ + "512k(u-boot.env1)," \ + "512k(mtdoops)," \ + "-(rootfs)" You name the partition "rootfs" .. but it contains not only the rootfs, instead it contains now 2 or more UBI volumes ... Maybe a rename it to "ubi" or "ubivolumes" or ... makes this clearer? Beside of this, you can add my: Acked-by: Heiko Schocher bye, Heiko + #define DFU_ALT_INFO_NAND_V2 \ "spl part 0 1;" \ @@ -522,8 +522,7 @@ "u-boot part 0 5;" \ "u-boot.env0 part 0 6;" \ "u-boot.env1 part 0 7;" \ - "rootfs partubi 0 8;" \ - "configuration partubi 0 10" + "rootfs partubi 0 9" \ #define CONFIG_ENV_SETTINGS_NAND_V2 \ "nand_active_ubi_vol=rootfs_a\0" \ @@ -540,7 +539,7 @@ "setenv nand_active_ubi_vol ${rootfs_name}_b;" \ "fi;" \ "setenv nand_root ubi0:${nand_active_ubi_vol} rw " \ - "ubi.mtd=7,2048 ubi.mtd=9,2048;" \ + "ubi.mtd=8,2048;" \ "setenv bootargs ${bootargs} " \ "root=${nand_root} noinitrd ${mtdparts} " \ "rootfstype=${nand_root_fs_type} ip=${ip_method} " \ -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] siemens,am33x: adjust mtd partition
Hello Samuel, Am 01.07.2015 um 17:57 schrieb Samuel Egli: Use one mtd partition for rootfs and configuration by means of ubi volumes and get rid of configuration partition. We can use partition layout for both 256MB and 512MB flash. Signed-off-by: Samuel Egli Cc: Heiko Schocher Cc: Roger Meier --- Changes for v2: - Use partition name instead of number include/configs/siemens-am33x-common.h | 33 1 file changed, 16 insertions(+), 17 deletions(-) Acked-by: Heiko Schocher bye, Heiko diff --git a/include/configs/siemens-am33x-common.h b/include/configs/siemens-am33x-common.h index 35427db..b0d9243 100644 --- a/include/configs/siemens-am33x-common.h +++ b/include/configs/siemens-am33x-common.h @@ -490,7 +490,7 @@ /* * Variant 2 partition layout - * chip-size = 256MiB + * chip-size = 256MiB or 512 MiB *| name |size | address area | *--- *| spl | 128.000 KiB | 0x 0..0x 1 | @@ -500,23 +500,23 @@ *| u-boot | 1.875 MiB | 0x 8..0x 25 | *| uboot.env0 | 512.000 KiB | 0x 26..0x 2D | *| uboot.env1 | 512.000 KiB | 0x 2E..0x 35 | - *| rootfs | 148.000 MiB | 0x 36..0x 975 | - *| mtdoops | 512.000 KiB | 0x 976..0x 98D | - *|configuration | 104.125 MiB | 0x 97E..0x fff | + *| mtdoops | 512.000 KiB | 0x 36..0x 3d | + *| (256) rootfs | 252.125 MiB | 0x 3E..0x fff | + *| (512) rootfs | 508.125 MiB | 0x 3E..0x1fff | *--- */ #define MTDPARTS_DEFAULT_V2 "mtdparts=" MTDIDS_NAME_STR ":" \ - "128k(spl)," \ - "128k(spl.backup1)," \ - "128k(spl.backup2)," \ - "128k(spl.backup3)," \ - "1920k(u-boot)," \ - "512k(u-boot.env0)," \ - "512k(u-boot.env1)," \ - "148m(rootfs)," \ - "512k(mtdoops)," \ - "-(configuration)" + "128k(spl)," \ + "128k(spl.backup1)," \ + "128k(spl.backup2)," \ + "128k(spl.backup3)," \ + "1920k(u-boot)," \ + "512k(u-boot.env0)," \ + "512k(u-boot.env1)," \ + "512k(mtdoops)," \ + "-(rootfs)" + #define DFU_ALT_INFO_NAND_V2 \ "spl part 0 1;" \ @@ -526,8 +526,7 @@ "u-boot part 0 5;" \ "u-boot.env0 part 0 6;" \ "u-boot.env1 part 0 7;" \ - "rootfs partubi 0 8;" \ - "configuration partubi 0 10" + "rootfs partubi 0 9" \ #define CONFIG_ENV_SETTINGS_NAND_V2 \ "nand_active_ubi_vol=rootfs_a\0" \ @@ -544,7 +543,7 @@ "setenv nand_active_ubi_vol ${rootfs_name}_b;" \ "fi;" \ "setenv nand_root ubi0:${nand_active_ubi_vol} rw " \ - "ubi.mtd=7,2048 ubi.mtd=9,2048;" \ + "ubi.mtd=rootfs,2048;" \ "setenv bootargs ${bootargs} " \ "root=${nand_root} noinitrd ${mtdparts} " \ "rootfstype=${nand_root_fs_type} ip=${ip_method} " \ -- 1.7.10.4 -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 02/55] dm: i2c: Add a message debug function
Hello Simon, Am 03.07.2015 um 02:15 schrieb Simon Glass: Add a way to dump the contents of an I2C message for debugging purposes. Signed-off-by: Simon Glass --- drivers/i2c/i2c-uclass.c | 16 include/i2c.h| 10 ++ 2 files changed, 26 insertions(+) Acked-by: Heiko Schocher bye, Heiko diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index eaba965..42d6e89 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -18,6 +18,22 @@ DECLARE_GLOBAL_DATA_PTR; #define I2C_MAX_OFFSET_LEN4 +/* Useful debugging function */ +void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs) +{ + int i; + + for (i = 0; i < nmsgs; i++) { + struct i2c_msg *m = &msg[i]; + + printf(" %s %x len=%x", m->flags & I2C_M_RD ? "R" : "W", + msg->addr, msg->len); + if (!(m->flags & I2C_M_RD)) + printf(": %x", m->buf[0]); + printf("\n"); + } +} + /** * i2c_setup_offset() - Set up a new message with a chip offset * diff --git a/include/i2c.h b/include/i2c.h index 9300d97..a5498a3 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -473,6 +473,16 @@ int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len, int i2c_chip_ofdata_to_platdata(const void *blob, int node, struct dm_i2c_chip *chip); +/** + * i2c_dump_msgs() - Dump a list of I2C messages + * + * This may be useful for debugging. + * + * @msg: Message list to dump + * @nmsgs: Number of messages + */ +void i2c_dump_msgs(struct i2c_msg *msg, int nmsgs); + #ifndef CONFIG_DM_I2C /* -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 03/55] dm: i2c: Correct comment nits in dm_i2c_reg_read/write()
Hello Simon, Am 03.07.2015 um 02:15 schrieb Simon Glass: Add documentation for the @dev parameter. Signed-off-by: Simon Glass --- include/i2c.h | 2 ++ 1 file changed, 2 insertions(+) Acked-by: Heiko Schocher bye, Heiko diff --git a/include/i2c.h b/include/i2c.h index a5498a3..e1ad8d8 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -129,6 +129,7 @@ int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags, * * This reads a single value from the given address in an I2C chip * + * @dev: Device to use for transfer * @addr: Address to read from * @return value read, or -ve on error */ @@ -139,6 +140,7 @@ int dm_i2c_reg_read(struct udevice *dev, uint offset); * * This writes a single value to the given address in an I2C chip * + * @dev: Device to use for transfer * @addr: Address to write to * @val: Value to write (normally a byte) * @return 0 on success, -ve on error -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 04/55] dm: i2c: Move definitions to the top of the header file
Hello Simon, Am 03.07.2015 um 02:15 schrieb Simon Glass: Move the flags and struct definitions higher in the file so that we can reference them with functions declared in the driver model section. Signed-off-by: Simon Glass --- include/i2c.h | 86 +-- 1 file changed, 43 insertions(+), 43 deletions(-) Acked-by: Heiko Schocher bye, Heiko diff --git a/include/i2c.h b/include/i2c.h index e1ad8d8..4c0e263 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -74,6 +74,49 @@ struct dm_i2c_bus { int speed_hz; }; +/* + * Not all of these flags are implemented in the U-Boot API + */ +enum dm_i2c_msg_flags { + I2C_M_TEN = 0x0010, /* ten-bit chip address */ + I2C_M_RD= 0x0001, /* read data, from slave to master */ + I2C_M_STOP = 0x8000, /* send stop after this message */ + I2C_M_NOSTART = 0x4000, /* no start before this message */ + I2C_M_REV_DIR_ADDR = 0x2000, /* invert polarity of R/W bit */ + I2C_M_IGNORE_NAK= 0x1000, /* continue after NAK */ + I2C_M_NO_RD_ACK = 0x0800, /* skip the Ack bit on reads */ + I2C_M_RECV_LEN = 0x0400, /* length is first received byte */ +}; + +/** + * struct i2c_msg - an I2C message + * + * @addr: Slave address + * @flags: Flags (see enum dm_i2c_msg_flags) + * @len: Length of buffer in bytes, may be 0 for a probe + * @buf: Buffer to send/receive, or NULL if no data + */ +struct i2c_msg { + uint addr; + uint flags; + uint len; + u8 *buf; +}; + +/** + * struct i2c_msg_list - a list of I2C messages + * + * This is called i2c_rdwr_ioctl_data in Linux but the name does not seem + * appropriate in U-Boot. + * + * @msg: Pointer to i2c_msg array + * @nmsgs: Number of elements in the array + */ +struct i2c_msg_list { + struct i2c_msg *msgs; + uint nmsgs; +}; + /** * dm_i2c_read() - read bytes from an I2C chip * @@ -294,49 +337,6 @@ void i2c_reg_write(uint8_t addr, uint8_t reg, uint8_t val); #endif -/* - * Not all of these flags are implemented in the U-Boot API - */ -enum dm_i2c_msg_flags { - I2C_M_TEN = 0x0010, /* ten-bit chip address */ - I2C_M_RD= 0x0001, /* read data, from slave to master */ - I2C_M_STOP = 0x8000, /* send stop after this message */ - I2C_M_NOSTART = 0x4000, /* no start before this message */ - I2C_M_REV_DIR_ADDR = 0x2000, /* invert polarity of R/W bit */ - I2C_M_IGNORE_NAK= 0x1000, /* continue after NAK */ - I2C_M_NO_RD_ACK = 0x0800, /* skip the Ack bit on reads */ - I2C_M_RECV_LEN = 0x0400, /* length is first received byte */ -}; - -/** - * struct i2c_msg - an I2C message - * - * @addr: Slave address - * @flags: Flags (see enum dm_i2c_msg_flags) - * @len: Length of buffer in bytes, may be 0 for a probe - * @buf: Buffer to send/receive, or NULL if no data - */ -struct i2c_msg { - uint addr; - uint flags; - uint len; - u8 *buf; -}; - -/** - * struct i2c_msg_list - a list of I2C messages - * - * This is called i2c_rdwr_ioctl_data in Linux but the name does not seem - * appropriate in U-Boot. - * - * @msg: Pointer to i2c_msg array - * @nmsgs: Number of elements in the array - */ -struct i2c_msg_list { - struct i2c_msg *msgs; - uint nmsgs; -}; - /** * struct dm_i2c_ops - driver operations for I2C uclass * -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 05/55] dm: i2c: Add a function to transfer messages
Hello Simon, Am 03.07.2015 um 02:15 schrieb Simon Glass: Sometimes it is useful to be able to transfer a raw I2C message. This happens when the chip address needs to be set manually, or when the data to be sent/received is in another buffer. Add a function to provide access to this. Signed-off-by: Simon Glass --- drivers/i2c/i2c-uclass.c | 11 +++ include/i2c.h| 13 + 2 files changed, 24 insertions(+) Acked-by: Heiko Schocher bye, Heiko diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 42d6e89..50b99ea 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -202,6 +202,17 @@ int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer, } } +int dm_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs) +{ + struct udevice *bus = dev_get_parent(dev); + struct dm_i2c_ops *ops = i2c_get_ops(bus); + + if (!ops->xfer) + return -ENOSYS; + + return ops->xfer(bus, msg, nmsgs); +} + int dm_i2c_reg_read(struct udevice *dev, uint offset) { uint8_t val; diff --git a/include/i2c.h b/include/i2c.h index 4c0e263..d191829 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -191,6 +191,19 @@ int dm_i2c_reg_read(struct udevice *dev, uint offset); int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val); /** + * dm_i2c_xfer() - Transfer messages over I2C + * + * This transfers a raw message. It is best to use dm_i2c_reg_read/write() + * instead. + * + * @dev: Device to use for transfer + * @msg: List of messages to transfer + * @nmsgs: Number of messages to transfer + * @return 0 on success, -ve on error + */ +int dm_i2c_xfer(struct udevice *dev, struct i2c_msg *msg, int nmsgs); + +/** * dm_i2c_set_bus_speed() - set the speed of a bus * * @bus: Bus to adjust -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot