Re: [U-Boot] dfu: dfu and UBI Volumes
Hi Heiko, On May 24, 2013, at 7:39 PM, Heiko Schocher wrote: Hello, just digging in DFU support in U-Boot for an upcoming board support based on an AM335x. This board support uses for example a rootfs in an UBI Volume on a NAND flash, and this should be updated with dfu ... How To do this? Current state on this board is to erase the rootfs mtd partition with a nand erase and write the new image using dfu_nand.c ... which calls in the end nand_write ... which is ... lets say ... not the prefered way on an UBI volume ... How to solve this? Any ideas? Well, what would you like ideally to do? Why is nand_write not ideal for a UBI volume. Note that dfu will skip over the bad blocks... bye, Heiko -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: dfu and UBI Volumes
Hi Guys, On May 27, 2013, at 10:28 AM, Heiko Schocher wrote: Hello Lukasz, Am 27.05.2013 09:02, schrieb Lukasz Majewski: Hi Heiko, Hello Tom, Am 24.05.2013 19:12, schrieb Tom Rini: On Fri, May 24, 2013 at 07:42:01PM +0300, Pantelis Antoniou wrote: Hi Heiko, On May 24, 2013, at 7:39 PM, Heiko Schocher wrote: Hello, just digging in DFU support in U-Boot for an upcoming board support based on an AM335x. This board support uses for example a rootfs in an UBI Volume on a NAND flash, and this should be updated with dfu ... How To do this? Current state on this board is to erase the rootfs mtd partition with a nand erase and write the new image using dfu_nand.c ... which calls in the end nand_write ... which is ... lets say ... not the prefered way on an UBI volume ... How to solve this? Any ideas? Well, what would you like ideally to do? Why is nand_write not ideal for a UBI volume. Note that dfu will skip over the bad blocks... Presumably because they want to replace say ubi0:rootfs (and leave ubi0:user-data and ubi0:u-boot-env and so forth alone) rather than write in a new ubi container of everything. I would suggest that, so long as our existing UBI infrastructure allows this, you add a new method, dfu_ubi which takes care of programming things. This shouldn't be too bad to write as I've heard the existing infrastucture was easily expanded for SPI (and patches are pending a little more clean up prior to posting). This sounds easy ... but they have also raw nand partitions, for example spl partitions on one nand flash ... for which dfu_nand.c fits perfectly ... is it possible to use dfu_nand.c and another dfu_xxx.c at the same time? I'm not so familiar with nand devices handling, but in my opinion we shall create dfu_ubi.c file. I think that, nand part of dfu handling shall be separated from ubi, even if UBI itself is layed on nand. Yes, I tend also to this .. but not as a separte dfu interface .. dfu nand .. should stay, and each partition should know, if it is a raw nand, or UBI, or jffs2?,... as like in dfu_mmc.c ... but this should not be hardcoded in every dfu_xxx.c, instead it should be something like a subinterface ... if it is possible. I'm not completely up to speed with UBI, but dfu_ubi seems to be the way to go for me. Looks like it's simple enough; erase (but don't step over the wear counters) , write (but skip over the wear counters). I don't know how smart you have to be with UBI version; be very careful when the binary format of UBI changes. However, Tom and Pantelis shall give their opinion, since they spent a lot of time on forcing dfu_nand.c to work. Yep, that would be great, as I am a dfu beginner ;-) bye, Heiko -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: dfu and UBI Volumes
Hi On May 27, 2013, at 7:25 PM, Wolfgang Denk wrote: Dear Heiko Schocher, In message 51a30f34.7030...@denx.de you wrote: But how to handle a raw nand partition and a ubi partition on one nand? If ubi is a new dfu interface, somebody must start dfu on u-boot with dfu nand .. or dfu ubi .. dependent on which partition has to be updated ... before using dfu-util on the host side ... and start dfu-util for the correct partition... This seems not really userfriendly to me ... if I have to use the Indeed, this makes no sense and breaks the whole concept of DFU to be able to download a sinlge firmware image with one, simple command. Is ubi really a interface as nand or mmc ... ? No, it is not. It could be considered a partition type at best. Looks like it's simple enough; erase (but don't step over the wear counters) , write (but skip over the wear counters). Yep, or load the complete image in ram, and write it with ubi write ... Not or. When dealing with UBI volumes, then ubi write (or the equivalent C API) is the way to go. I pretty much agree. UBI looks like it's partition type. BTW, the whole point of DFU is not to store your image in RAM at all. There are very few systems that have that much RAM. 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 All a hacker needs is a tight PUSHJ, a loose pair of UUOs, and a warm place to shift. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: dfu and UBI Volumes
Hi Tom, On May 28, 2013, at 6:01 PM, Tom Rini wrote: On Tue, May 28, 2013 at 07:50:46AM +0200, Wolfgang Denk wrote: Dear Tom, In message 20130527233735.GZ17119@bill-the-cat you wrote: Where exactly is this 8 MB limit coming into play? In buffering the data. We cannot write a chunk of a file to a filesystem and then append to it, we don't have the API today. Sorry, I still don't get it. Assuming I have a GiB of RAM, why can I not load a 256 MiB file to RAM, and then write it to a file system? I have definitely dealt with images and files bigger than 8 MiB in thepast, so I really don't see where any buffer problem could be. I thought I might not have been clear about where this limit comes from, after I sent the email. The problem we have, and this is only for writing to a filesystem (_not_ writing of a filesystem) is that we do not have the API for appending to files, only create/overwrite. So we must read the whole file into memory, and then write it out. The DFU protocol doesn't have (I would swear anyhow) a part where it says I'm about to send you a blob of X bytes, so we cannot know at the start how much data is coming our way. Today we solve this with a statically defined CONFIG_SYS_DFU_MAX_FILE_SIZE. Looking at things again, I think this is buggy right now in that we need to also whack DFU_DATA_BUF_SIZE to also be that same value. Going forward, we may be able to switch this to (and both of these are off the top of my head) a getenv to see how much space to malloc, or just making it a malloc and adding some compile-time check to ensure that the malloc area is at least as big as CONFIG_SYS_DFU_MAX_FILE_SIZE. Correct, the DFU protocol doesn't have a method to inform you before hand about the size of the transfer about to happen. The only possible solution I see at this point is to have an environment variable, i.e. dfubuf that controls the size of the buffer. Upon start of a dfu transfer we can allocate the buffer, and do our thing. -- Tom Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: dfu and UBI Volumes
Hi Benoît On May 28, 2013, at 7:31 PM, Benoît Thébaudeau wrote: Dear Pantelis Antoniou, On Tuesday, May 28, 2013 5:05:12 PM, Pantelis Antoniou wrote: Hi Tom, On May 28, 2013, at 6:01 PM, Tom Rini wrote: On Tue, May 28, 2013 at 07:50:46AM +0200, Wolfgang Denk wrote: Dear Tom, In message 20130527233735.GZ17119@bill-the-cat you wrote: Where exactly is this 8 MB limit coming into play? In buffering the data. We cannot write a chunk of a file to a filesystem and then append to it, we don't have the API today. Sorry, I still don't get it. Assuming I have a GiB of RAM, why can I not load a 256 MiB file to RAM, and then write it to a file system? I have definitely dealt with images and files bigger than 8 MiB in thepast, so I really don't see where any buffer problem could be. I thought I might not have been clear about where this limit comes from, after I sent the email. The problem we have, and this is only for writing to a filesystem (_not_ writing of a filesystem) is that we do not have the API for appending to files, only create/overwrite. So we must read the whole file into memory, and then write it out. The DFU protocol doesn't have (I would swear anyhow) a part where it says I'm about to send you a blob of X bytes, so we cannot know at the start how much data is coming our way. Today we solve this with a statically defined CONFIG_SYS_DFU_MAX_FILE_SIZE. Looking at things again, I think this is buggy right now in that we need to also whack DFU_DATA_BUF_SIZE to also be that same value. Going forward, we may be able to switch this to (and both of these are off the top of my head) a getenv to see how much space to malloc, or just making it a malloc and adding some compile-time check to ensure that the malloc area is at least as big as CONFIG_SYS_DFU_MAX_FILE_SIZE. Correct, the DFU protocol doesn't have a method to inform you before hand about the size of the transfer about to happen. The only possible solution I see at this point is to have an environment variable, i.e. dfubuf that controls the size of the buffer. Upon start of a dfu transfer we can allocate the buffer, and do our thing. I don't know the details of the DFU implementation in U-Boot, but the specification leaves the choice between programming the firmware on-the-fly during the download, and later during the manifestation phase (or a mix of both). Hence, there is not need for a global firmware buffer if U-Boot goes for the on-the-fly programming strategy. The only buffer constraint would be wTransferSize (chosen by U-Boot for the control endpoint) in that case. See 7. Manifestation Phase on page 26 here: http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf The problem is not DFU TBH, it's that since we don't have an option to append to a file, we have to have the whole file transferred in RAM and written in one go. The raw medium dfu methods in u-boot don't have a problem. Of course this can't yet apply to writing files on file systems since the current API in U-Boot misses the append feature, but this could be applied to program raw memory partitions, including UBI images. It already happens for raw memory partitions, it's the UBI images being discussed. Best regards, Benoît Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: dfu and UBI Volumes
Hi On May 28, 2013, at 7:43 PM, Benoît Thébaudeau wrote: Hi Pantelis, On Tuesday, May 28, 2013 6:43:06 PM, Pantelis Antoniou wrote: Hi Benoît On May 28, 2013, at 7:31 PM, Benoît Thébaudeau wrote: Dear Pantelis Antoniou, On Tuesday, May 28, 2013 5:05:12 PM, Pantelis Antoniou wrote: Hi Tom, On May 28, 2013, at 6:01 PM, Tom Rini wrote: On Tue, May 28, 2013 at 07:50:46AM +0200, Wolfgang Denk wrote: Dear Tom, In message 20130527233735.GZ17119@bill-the-cat you wrote: Where exactly is this 8 MB limit coming into play? In buffering the data. We cannot write a chunk of a file to a filesystem and then append to it, we don't have the API today. Sorry, I still don't get it. Assuming I have a GiB of RAM, why can I not load a 256 MiB file to RAM, and then write it to a file system? I have definitely dealt with images and files bigger than 8 MiB in thepast, so I really don't see where any buffer problem could be. I thought I might not have been clear about where this limit comes from, after I sent the email. The problem we have, and this is only for writing to a filesystem (_not_ writing of a filesystem) is that we do not have the API for appending to files, only create/overwrite. So we must read the whole file into memory, and then write it out. The DFU protocol doesn't have (I would swear anyhow) a part where it says I'm about to send you a blob of X bytes, so we cannot know at the start how much data is coming our way. Today we solve this with a statically defined CONFIG_SYS_DFU_MAX_FILE_SIZE. Looking at things again, I think this is buggy right now in that we need to also whack DFU_DATA_BUF_SIZE to also be that same value. Going forward, we may be able to switch this to (and both of these are off the top of my head) a getenv to see how much space to malloc, or just making it a malloc and adding some compile-time check to ensure that the malloc area is at least as big as CONFIG_SYS_DFU_MAX_FILE_SIZE. Correct, the DFU protocol doesn't have a method to inform you before hand about the size of the transfer about to happen. The only possible solution I see at this point is to have an environment variable, i.e. dfubuf that controls the size of the buffer. Upon start of a dfu transfer we can allocate the buffer, and do our thing. I don't know the details of the DFU implementation in U-Boot, but the specification leaves the choice between programming the firmware on-the-fly during the download, and later during the manifestation phase (or a mix of both). Hence, there is not need for a global firmware buffer if U-Boot goes for the on-the-fly programming strategy. The only buffer constraint would be wTransferSize (chosen by U-Boot for the control endpoint) in that case. See 7. Manifestation Phase on page 26 here: http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf The problem is not DFU TBH, it's that since we don't have an option to append to a file, we have to have the whole file transferred in RAM and written in one go. The raw medium dfu methods in u-boot don't have a problem. Of course this can't yet apply to writing files on file systems since the current API in U-Boot misses the append feature, but this could be applied to program raw memory partitions, including UBI images. It already happens for raw memory partitions, it's the UBI images being discussed. But what does appending to a file has to do with programming a UBI image, which is a memory partition containing a whole file system? This is what I don't get in this discussion. Is it because of a restriction of the DFU API in U-Boot? Don't expect a discussion on a mailing list to stay on topic for long :) We sort of drifted from UBI to the fixed sized buffer. Best regards, Benoît Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: make data buffer size configurable
Hi Heiko, Just thinking out loud here. Can we have an extra option that allocates the buffer dynamically based on an env variable? Regards -- Pantelis On Jun 4, 2013, at 12:22 PM, Heiko Schocher wrote: Dfu transfer uses a buffer before writing data to the raw storage device. Make the size (in bytes) of this buffer configurable. Signed-off-by: Heiko Schocher h...@denx.de Cc: Pantelis Antoniou pa...@antoniou-consulting.com Cc: Tom Rini tr...@ti.com Cc: Lukasz Majewski l.majew...@samsung.com Cc: Kyungmin Park kyungmin.p...@samsung.com Cc: Marek Vasut ma...@denx.de --- README| 5 + drivers/dfu/dfu.c | 2 +- include/dfu.h | 4 +++- 3 Dateien geändert, 9 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-) diff --git a/README b/README index b1b3e17..8550f34 100644 --- a/README +++ b/README @@ -1360,6 +1360,11 @@ The following options need to be configured: CONFIG_DFU_NAND This enables support for exposing NAND devices via DFU. + CONFIG_SYS_DFU_DATA_BUF_SIZE + Dfu transfer uses a buffer before writing data to the + raw storage device. Make the size (in bytes) of this buffer + configurable. + CONFIG_SYS_DFU_MAX_FILE_SIZE When updating files rather than the raw storage device, we use a static buffer to copy the file into and then write diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index 6af6890..fe3a36e 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -42,7 +42,7 @@ static int dfu_find_alt_num(const char *s) } static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE) - dfu_buf[DFU_DATA_BUF_SIZE]; + dfu_buf[CONFIG_SYS_DFU_DATA_BUF_SIZE]; static int dfu_write_buffer_drain(struct dfu_entity *dfu) { diff --git a/include/dfu.h b/include/dfu.h index a107f4b..124653c 100644 --- a/include/dfu.h +++ b/include/dfu.h @@ -68,7 +68,9 @@ static inline unsigned int get_mmc_blk_size(int dev) #define DFU_NAME_SIZE 32 #define DFU_CMD_BUF_SIZE 128 -#define DFU_DATA_BUF_SIZE(1024*1024*8) /* 8 MiB */ +#ifndef CONFIG_SYS_DFU_DATA_BUF_SIZE +#define CONFIG_SYS_DFU_DATA_BUF_SIZE (1024*1024*8) /* 8 MiB */ +#endif #ifndef CONFIG_SYS_DFU_MAX_FILE_SIZE #define CONFIG_SYS_DFU_MAX_FILE_SIZE (4 20) /* 4 MiB */ #endif -- 1.7.11.7 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: make data buffer size configurable
Heiko, On Jun 4, 2013, at 1:31 PM, Heiko Schocher wrote: Hello Pantelis, Am 04.06.2013 12:08, schrieb Pantelis Antoniou: Hi Heiko, Just thinking out loud here. Can we have an extra option that allocates the buffer dynamically based on an env variable? Hmm.. also a possibility... I have here no preferences ... Name: dfu_data_buf_size if not defined, or env invalid, use default CONFIG_SYS_DFU_DATA_BUF_SIZE size? But this can be done in a second step, right? Yes, only as a second step please. bye, Heiko -- DENX Software Engineering GmbH, MD: Wolfgang Denk Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] usb:composite:fix Provide function data when addressing device with only one interface
Hi Lukasz, On Mar 6, 2013, at 9:42 AM, Lukasz Majewski wrote: Dear All, -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/05/2013 06:24 PM, Marek Vasut wrote: Dear Lukasz Majewski, Hi Marek, Dear Lukasz Majewski, This commit fixes problems with some non-standard requests send with device address instead of interface address (bmRequestType.Receipent field). This happens with dfu-util (debian version: 0.5), which address non standard requests (like w_value=0x21 and bRequest=GET_DESCRIPTOR) to device. Without this fix, the above request is STALLED, and hence causes dfu-util to assume some standard configuration (packet size = 1024B instead of 4096B) In turn it displays following errors: Error obtaining DFU functional descriptor Warning: Assuming DFU version 1.0 Warning: Transfer size can not be detected ... Warning: Trying default transfer size 1024 This fix allows passing non-standard request to function setup code, where it shall be handled. Tested at: Trats (exynos4210) Tested with:DFU and UMS gadgets Can you please repost all the patches you want applied on u-boot-usb ? I'm completely lost in all this DFU stuff. This is only one patch to replace patch done by Pantelis: Patch to replace (revert): dfu: Send correct DFU response from composite_setup SHA1: fef31049fa06e516945114195eb14ac3549d0ad2 And this shall be replaced with posted patch. Another patches (with UMS gadget support - done by Piotr Wilczek), also shall be added to u-boot-usb tree: http://patchwork.ozlabs.org/patch/219744/ http://patchwork.ozlabs.org/patch/219746/ http://patchwork.ozlabs.org/patch/219745/ Ok, please check the u-boot-usb ... if it's OK, I will send Tom a pullrq (finally). Tom, do you still accept those for .04 ? Marek, thanks for pulling those patches. As of earlier in the day it still had Pantelis' patch for sending files larger than memory which breaks all filesystem-based writes, so that needs to go. Lukasz and I are discussing how to deal with that. The patch about which Tom is speaking is: dfu: Support larger than memory transfers. SHA1: a09f955db6ad7031bd715a615fb8b90d671a14d4 This patch is causing regression (not only on Trats). I think, that it shall be dropped and replaced by new patch on which Tom (with my little help) is working now. This patch is not connected to the one, which you have already removed from u-boot-usb tree. You have removed patch about composite.c DFU fix (which was fixed by: usb:composite:fix Provide function data when addressing device with only one interface). Sorry about missing this thread. I've been busy with other stuff. What kind of regressions are we talking about? I'm trying to get around to looking into all of this, but this shouldn't be causing all that trouble. Regards -- Pantelis - -- Tom -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJRNoNSAAoJENk4IS6UOR1WnDkP+QE7ihcrFz0u5v2wAhkjwtaZ etpl6oL/rB7jA6jK9zDYkyoc/Bf9A9/ffxsfGruP8kzjK2BTwHizs/Hz4I8Z90k6 6g4S7DUY4kx9t20Iyyswwuo8Bs0MXuEyDSS1a3kWXsB1110eUXd6xBsQoOKv5BeK 1UO29ZFMRJAnIpKBSrrGNE0e8xG8fnF1y8/Wos8OAk240DKoMPTF1lZEB5TEkbtN 7xePk4XLGClePj8CH8iIBj2YDo5kjRPUCZ2zSd6niayVrp5On5as+Fn9XTvWiQYG UjLDbeAhNinzRJx9q8sB2dxXq2sSh+8ehtKZgnQCwOuj0bV0Ok4um0FP7DKN1Z+K COvJdKC629rZ9cyc/kLfXtJzEYBJwK+OsLjLHOf7YuuhQpcPcugZWmdc8LZt6QMA aL61JGTCfF80PVO8jAjWkJjniTHTSQRL+Adt91wej9D8e246/SbzFMqjjpTWQvVB RcR6fUwKdcMwT+RKAJybYH8z3tqwiRQXleBPs6NqcRYV7E8AHzpeMUh5v7m2Gz/P 8y+ea4v8Nglq79UnYmeqCHmvMO0ZqUpb8/+hB35xfkyuIHstx3J784NHOaQ7IZqj iJZ/Stf3De+ASddDFeAldoyc3EdT2k98gYUKpitExTOB5EbWKrK781JOEC0q+iSb +xUyux8npF6Rhhf55Rm7 =DAuM -END PGP SIGNATURE- -- Best regards, Lukasz Majewski Samsung RD Poland (SRPOL) | Linux Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] dfu: using dfu-util -l shows different output
Heiko, I don't think the gadget is initialized before you issue a dfu call. So that makes sense. Let's wait until Tom wakes up and have an authoritative answer. Regards -- Pantelis On Jun 25, 2013, at 11:08 AM, Heiko Schocher wrote: Hello, using dfu-util -l shows different output connecting to an am335x based board and using dfu_nand.c with current u-boot: after resetting the board I get: # dfu-util -l dfu-util 0.5 (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. (C) 2010-2011 Tormod Volden (DfuSe support) This program is Free Software and has ABSOLUTELY NO WARRANTY dfu-util does currently only support DFU version 1.0 Found Runtime: [0525:bd00] devnum=0, cfg=2, intf=0, alt=0, name=Device Firmware Upgrade # after a dfu transfer I see: # dfu-util -l dfu-util 0.5 (C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. (C) 2010-2011 Tormod Volden (DfuSe support) This program is Free Software and has ABSOLUTELY NO WARRANTY dfu-util does currently only support DFU version 1.0 Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=0, name=SPL Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=1, name=SPL.backup1 Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=2, name=SPL.backup2 Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=3, name=SPL.backup3 Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=4, name=u-boot Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=5, name=kernel_a Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=6, name=kernel_b Found DFU: [0525:bd00] devnum=0, cfg=2, intf=0, alt=7, name=rootfs # Which I expected ... U-Boot environment variable: U-Boot# print dfu_alt_info dfu_alt_info=SPL part 0 1;SPL.backup1 part 0 2;SPL.backup2 part 0 3;SPL.backup3 part 0 4;u-boot part 0 5;kernel_a part 0 7;kernel_b part 0 8;rootfs part 0 10 U-Boot# Is this a bug or a feature? bye, Heiko -- 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
[U-Boot] [PATCH] git-mailrc: Update MMC custodian
Update git-mailrc with my nick and replace afleming as mmc custodian. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- doc/git-mailrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/git-mailrc b/doc/git-mailrc index e3a47c4..03fc482 100644 --- a/doc/git-mailrc +++ b/doc/git-mailrc @@ -24,6 +24,7 @@ alias kimphill Kim Phillips kim.phill...@freescale.com alias macpaulMacpaul Lin macp...@andestech.com alias marex Marek Vasut marek.va...@gmail.com alias monstr Michal Simek mon...@monstr.eu +alias panto Pantelis Antoniou pa...@antoniou-consulting.com alias prafulla Prafulla Wadaskar prafu...@marvell.com alias prom Minkyu Kang mk7.k...@samsung.com alias rbohmerRemy Bohmer li...@bohmer.net @@ -102,7 +103,7 @@ alias cfiuboot, stroese alias kerneldoc uboot, marex alias fdtuboot, Jerry Van Baren vanba...@cideas.com alias i2cuboot, hs -alias mmcuboot, afleming +alias mmcuboot, panto alias nand uboot, scottwood alias netuboot, jhersh alias usbuboot, marex -- 1.7.12 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: sdhci: use the SDHCI_QUIRK_USE_WIDE8 for samsung SoC
Hi Jaehoon, On Aug 13, 2013, at 11:52 AM, Jaehoon Chung wrote: Dear Pantelis, Welcome to take care of u-boot-mmc. Thanks Could you merge this patch? Please hold on a bit; we're still in the process of passing over the (mmc) torch. That patch looks good. Best Regards, Jaehoon Chung Regards -- Pantelis On 07/19/2013 05:44 PM, Jaehoon Chung wrote: Samsung SoC is supported the WIDE8, even if Controller version is v2.0. So add the SDHCI_QUIRK_USE_WIDE8 for Samsung-SoC. Signed-off-by: Jaehoon Chung jh80.ch...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com --- drivers/mmc/s5p_sdhci.c |4 +++- drivers/mmc/sdhci.c | 13 +++-- include/sdhci.h |3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/s5p_sdhci.c b/drivers/mmc/s5p_sdhci.c index e50ff92..97e153e 100644 --- a/drivers/mmc/s5p_sdhci.c +++ b/drivers/mmc/s5p_sdhci.c @@ -84,7 +84,7 @@ int s5p_sdhci_init(u32 regbase, int index, int bus_width) host-quirks = SDHCI_QUIRK_NO_HISPD_BIT | SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B | SDHCI_QUIRK_32BIT_DMA_ADDR | -SDHCI_QUIRK_WAIT_SEND_CMD; +SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_USE_WIDE8; host-voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; host-version = sdhci_readw(host, SDHCI_HOST_VERSION); @@ -93,6 +93,8 @@ int s5p_sdhci_init(u32 regbase, int index, int bus_width) host-index = index; host-host_caps = MMC_MODE_HC; +if (bus_width == 8) +host-host_caps |= MMC_MODE_8BIT; return add_sdhci(host, 5200, 40); } diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index c5631bf..9bf3052 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -270,7 +270,7 @@ static int sdhci_set_clock(struct mmc *mmc, unsigned int clock) if (clock == 0) return 0; -if ((host-version SDHCI_SPEC_VER_MASK) = SDHCI_SPEC_300) { +if (SDHCI_GET_VERSION(host) = SDHCI_SPEC_300) { /* Version 3.00 divisors must be a multiple of 2. */ if (mmc-f_max = clock) div = 1; @@ -363,10 +363,11 @@ void sdhci_set_ios(struct mmc *mmc) ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); if (mmc-bus_width == 8) { ctrl = ~SDHCI_CTRL_4BITBUS; -if ((host-version SDHCI_SPEC_VER_MASK) = SDHCI_SPEC_300) +if ((SDHCI_GET_VERSION(host) = SDHCI_SPEC_300) || +(host-quirks SDHCI_QUIRK_USE_WIDE8)) ctrl |= SDHCI_CTRL_8BITBUS; } else { -if ((host-version SDHCI_SPEC_VER_MASK) = SDHCI_SPEC_300) +if (SDHCI_GET_VERSION(host) = SDHCI_SPEC_300) ctrl = ~SDHCI_CTRL_8BITBUS; if (mmc-bus_width == 4) ctrl |= SDHCI_CTRL_4BITBUS; @@ -453,7 +454,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) if (max_clk) mmc-f_max = max_clk; else { -if ((host-version SDHCI_SPEC_VER_MASK) = SDHCI_SPEC_300) +if (SDHCI_GET_VERSION(host) = SDHCI_SPEC_300) mmc-f_max = (caps SDHCI_CLOCK_V3_BASE_MASK) SDHCI_CLOCK_BASE_SHIFT; else @@ -468,7 +469,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) if (min_clk) mmc-f_min = min_clk; else { -if ((host-version SDHCI_SPEC_VER_MASK) = SDHCI_SPEC_300) +if (SDHCI_GET_VERSION(host) = SDHCI_SPEC_300) mmc-f_min = mmc-f_max / SDHCI_MAX_DIV_SPEC_300; else mmc-f_min = mmc-f_max / SDHCI_MAX_DIV_SPEC_200; @@ -486,7 +487,7 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) mmc-voltages |= host-voltages; mmc-host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT; -if ((host-version SDHCI_SPEC_VER_MASK) = SDHCI_SPEC_300) { +if (SDHCI_GET_VERSION(host) = SDHCI_SPEC_300) { if (caps SDHCI_CAN_DO_8BIT) mmc-host_caps |= MMC_MODE_8BIT; } diff --git a/include/sdhci.h b/include/sdhci.h index cffbe53..f3f8219 100644 --- a/include/sdhci.h +++ b/include/sdhci.h @@ -208,6 +208,8 @@ #define SDHCI_SPEC_200 1 #define SDHCI_SPEC_300 2 +#define SDHCI_GET_VERSION(x) (x-version SDHCI_SPEC_VER_MASK) + /* * End of controller registers. */ @@ -226,6 +228,7 @@ #define SDHCI_QUIRK_NO_CD(1 5) #define SDHCI_QUIRK_WAIT_SEND_CMD(1 6) #define SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER (1 7) +#define SDHCI_QUIRK_USE_WIDE8 (1 8) /* to make gcc happy */ struct sdhci_host; ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: sdhci: use the SDHCI_QUIRK_USE_WIDE8 for samsung SoC
On Jul 19, 2013, at 11:44 AM, Jaehoon Chung wrote: Samsung SoC is supported the WIDE8, even if Controller version is v2.0. So add the SDHCI_QUIRK_USE_WIDE8 for Samsung-SoC. Signed-off-by: Jaehoon Chung jh80.ch...@samsung.com Signed-off-by: Kyungmin Park kyungmin.p...@samsung.com Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com Thanks ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc/dw_mmc: Fix DMA descriptor corruption
Hi Mischa, On Jul 26, 2013, at 3:08 PM, Mischa Jonker wrote: In dwmci_prepare_data, the descriptors are allocated for DMA transfer. These are allocated using the ALLOC_CACHE_ALIGN_BUFFER. This macro uses the stack to allocate these descriptors. This becomes a problem if the DMA transfer continues after the processor leaves the function in which the descriptors were allocated. Therefore, I have moved the allocated of the buffers up one level, to dwmci_send_cmd(). The DMA transfer should be complete when leaving this function. Signed-off-by: Mischa Jonker mjon...@synopsys.com Cc: Alexey Brodkin abrod...@synopsys.com Cc: Jaehoon Chung jh80.ch...@samsung.com Cc: Andy Fleming aflem...@gmail.com Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com Thanks ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [u-boot][RFC v1] mmc: Remove unused variable backup from mmc_send_cmd()
Hi Oleksandr, On Aug 6, 2013, at 1:50 PM, Oleksandr Tyshchenko wrote: Do not call a memset for unused variable backup every time. Remove unused variable from function. Signed-off-by: Oleksandr Tyshchenko oleksandr.tyshche...@ti.com Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com Thanks ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [u-boot][RFC v1] omap_hsmmc: omap4+/am335x: modify MMC controller internal fsm reset func
Hi Oleksandr On Aug 6, 2013, at 1:44 PM, Oleksandr Tyshchenko wrote: mmc_send_cmd: timeout: No status update error sometimes happens in omap_hsmmc driver func mmc_send_cmd() when the MMC controller card identification and selection sequence is executed for eMMC on OMAP4 boards. It happens due to incorrect execution of CMD line reset procedure for OMAP4. Because CMD(DAT) lines reset procedures are slightly different for OMAP3 and OMAP4(AM335x,OMAP5,DRA7xx). According to OMAP3 TRM: Set SRC(SRD) bit in MMCHS_SYSCTL register to 0x1 and wait until it returns to 0x0. According to OMAP4(AM335x,OMAP5,DRA7xx) TRMs, CMD(DATA) lines reset procedure steps must be as follows: 1. Initiate CMD(DAT) line reset by writing 0x1 to SRC(SRD) bit in MMCHS_SYSCTL register (SD_SYSCTL for AM335x). 2. Poll the SRC(SRD) bit until it is set to 0x1. 3. Wait until the SRC(SRD) bit returns to 0x0 (reset procedure is completed). Unfortunately, at present omap_hsmmc driver has support only for OMAP3. And as result step #2 is missing for OMAP4(AM335x,OMAP5,DRA7xx). This sometimes leads to the fact that the waiting loop which is required in step #3 does not executed, because SRC bit does not set yet (at the moment of checking a condition of a loop execution). And as a result this can cause to timeout error when sending a next command. In the particular case (working with eMMC witch do not respond to some SD specific command) due to incorrect reset sequence after command SD_CMD_SEND_IF_COND which finished with CTO flag within 64 clock cycles, the next command MMC_CMD_APP_CMD leads to a timeout error within 1s. So, extend CMD(DATA) lines reset procedure in func mmc_reset_controller_fsm() by adding the missing step #2 for OMAP4+/AM335x boards. Signed-off-by: Oleksandr Tyshchenko oleksandr.tyshche...@ti.com Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com Thanks ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: Initialize mmc_devices list statically
Hi Taras, What are you doing that makes you call any of the mmc_devices list functions before calling mmc_initialize() Which board has this problem; this looks like a board problem to me. Regards -- Pantelis On Aug 6, 2013, at 7:41 PM, Taras Kondratiuk wrote: Currently mmc_device list is initialized from mmc_initialize() function. So crash happens if any function which use mmc_devices list (find_mmc_device, print_mmc_devices, etc.) is called before mmc_initialize(). Fix this by initializing mmc_devices list statically. Signed-off-by: Taras Kondratiuk ta...@ti.com --- drivers/mmc/mmc.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 4da8db9..eb35582 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -21,7 +21,7 @@ #define CONFIG_SYS_MMC_MAX_BLK_COUNT 65535 #endif -static struct list_head mmc_devices; +LIST_HEAD(mmc_devices); static int cur_dev_num = -1; int __weak board_mmc_getwp(struct mmc *mmc) @@ -1477,7 +1477,6 @@ static void do_preinit(void) int mmc_initialize(bd_t *bis) { - INIT_LIST_HEAD (mmc_devices); cur_dev_num = 0; if (board_mmc_init(bis) 0) -- 1.7.9.5 ___ 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 3/5] mmc: don't call *printf or puts when SPL !CONFIG_SPL_LIBCOMMON_SUPPORT
Hi Paul On Sep 4, 2013, at 6:12 PM, Paul Burton wrote: If we don't have CONFIG_SPL_LIBCOMMON_SUPPORT defined then stdio *printf functions are unavailable calling them will cause a link failure. Signed-off-by: Paul Burton paul.bur...@imgtec.com --- drivers/mmc/mmc.c | 36 1 file changed, 36 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 5502675..30a985b 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -135,8 +135,10 @@ static int mmc_send_status(struct mmc *mmc, int timeout) MMC_STATE_PRG) break; else if (cmd.response[0] MMC_STATUS_MASK) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(Status Error: 0x%08X\n, cmd.response[0]); +#endif return COMM_ERR; } } else if (--retries 0) @@ -151,7 +153,9 @@ static int mmc_send_status(struct mmc *mmc, int timeout) printf(CURR STATE:%d\n, status); #endif if (timeout = 0) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(Timeout waiting card ready\n); +#endif return TIMEOUT; } @@ -181,7 +185,9 @@ struct mmc *find_mmc_device(int dev_num) return m; } +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(MMC Device %d not found\n, dev_num); +#endif return NULL; } @@ -233,7 +239,9 @@ static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) return 0; err_out: +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) puts(mmc erase failed\n); +#endif return err; } @@ -248,6 +256,7 @@ mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) if (!mmc) return -1; +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) if ((start % mmc-erase_grp_size) || (blkcnt % mmc-erase_grp_size)) printf(\n\nCaution! Your devices Erase group is 0x%x\n The erase range would be change to @@ -255,6 +264,7 @@ mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) mmc-erase_grp_size, start ~(mmc-erase_grp_size - 1), ((start + blkcnt + mmc-erase_grp_size) ~(mmc-erase_grp_size - 1)) - 1); +#endif while (blk blkcnt) { blk_r = ((blkcnt - blk) mmc-erase_grp_size) ? @@ -281,8 +291,10 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr int timeout = 1000; if ((start + blkcnt) mmc-block_dev.lba) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(MMC: block number 0x LBAF exceeds max(0x LBAF )\n, start + blkcnt, mmc-block_dev.lba); +#endif return 0; } @@ -306,7 +318,9 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr data.flags = MMC_DATA_WRITE; if (mmc_send_cmd(mmc, cmd, data)) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(mmc write failed\n); +#endif return 0; } @@ -318,7 +332,9 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr cmd.cmdarg = 0; cmd.resp_type = MMC_RSP_R1b; if (mmc_send_cmd(mmc, cmd, NULL)) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(mmc fail to send stop cmd\n); +#endif return 0; } } @@ -385,7 +401,9 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start, cmd.cmdarg = 0; cmd.resp_type = MMC_RSP_R1b; if (mmc_send_cmd(mmc, cmd, NULL)) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(mmc fail to send stop cmd\n); +#endif return 0; } } @@ -405,8 +423,10 @@ static ulong mmc_bread(int dev_num, lbaint_t start, lbaint_t blkcnt, void *dst) return 0; if ((start + blkcnt) mmc-block_dev.lba) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(MMC: block number 0x LBAF exceeds max(0x LBAF )\n, start + blkcnt, mmc-block_dev.lba); +#endif return 0; } The idea is sound, but I don't like peppering the source with #ifdefs here. Why not create a varargs orintf macro and use it instead i.e. #if !defined(CONFIG_SPL_BUILD_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) #define mmc_printf(...) ... #else #define
Re: [U-Boot] [PATCH 3/5] mmc: don't call *printf or puts when SPL !CONFIG_SPL_LIBCOMMON_SUPPORT
Hi Paul On Sep 6, 2013, at 3:51 PM, Paul Burton wrote: On 06/09/13 13:48, Pantelis Antoniou wrote: Hi Paul On Sep 4, 2013, at 6:12 PM, Paul Burton wrote: If we don't have CONFIG_SPL_LIBCOMMON_SUPPORT defined then stdio *printf functions are unavailable calling them will cause a link failure. Signed-off-by: Paul Burton paul.bur...@imgtec.com --- drivers/mmc/mmc.c | 36 1 file changed, 36 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 5502675..30a985b 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -135,8 +135,10 @@ static int mmc_send_status(struct mmc *mmc, int timeout) MMC_STATE_PRG) break; else if (cmd.response[0] MMC_STATUS_MASK) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(Status Error: 0x%08X\n, cmd.response[0]); +#endif return COMM_ERR; } } else if (--retries 0) @@ -151,7 +153,9 @@ static int mmc_send_status(struct mmc *mmc, int timeout) printf(CURR STATE:%d\n, status); #endif if (timeout = 0) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(Timeout waiting card ready\n); +#endif return TIMEOUT; } @@ -181,7 +185,9 @@ struct mmc *find_mmc_device(int dev_num) return m; } +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(MMC Device %d not found\n, dev_num); +#endif return NULL; } @@ -233,7 +239,9 @@ static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) return 0; err_out: +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) puts(mmc erase failed\n); +#endif return err; } @@ -248,6 +256,7 @@ mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) if (!mmc) return -1; +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) if ((start % mmc-erase_grp_size) || (blkcnt % mmc-erase_grp_size)) printf(\n\nCaution! Your devices Erase group is 0x%x\n The erase range would be change to @@ -255,6 +264,7 @@ mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) mmc-erase_grp_size, start ~(mmc-erase_grp_size - 1), ((start + blkcnt + mmc-erase_grp_size) ~(mmc-erase_grp_size - 1)) - 1); +#endif while (blk blkcnt) { blk_r = ((blkcnt - blk) mmc-erase_grp_size) ? @@ -281,8 +291,10 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr int timeout = 1000; if ((start + blkcnt) mmc-block_dev.lba) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(MMC: block number 0x LBAF exceeds max(0x LBAF )\n, start + blkcnt, mmc-block_dev.lba); +#endif return 0; } @@ -306,7 +318,9 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr data.flags = MMC_DATA_WRITE; if (mmc_send_cmd(mmc, cmd, data)) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(mmc write failed\n); +#endif return 0; } @@ -318,7 +332,9 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr cmd.cmdarg = 0; cmd.resp_type = MMC_RSP_R1b; if (mmc_send_cmd(mmc, cmd, NULL)) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(mmc fail to send stop cmd\n); +#endif return 0; } } @@ -385,7 +401,9 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start, cmd.cmdarg = 0; cmd.resp_type = MMC_RSP_R1b; if (mmc_send_cmd(mmc, cmd, NULL)) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(mmc fail to send stop cmd\n); +#endif return 0; } } @@ -405,8 +423,10 @@ static ulong mmc_bread(int dev_num, lbaint_t start, lbaint_t blkcnt, void *dst) return 0; if ((start + blkcnt) mmc-block_dev.lba) { +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) printf(MMC: block number 0x LBAF exceeds max(0x LBAF )\n, start + blkcnt, mmc-block_dev.lba); +#endif return 0; } The idea is sound, but I don't like peppering the source with #ifdefs here. Why not create a varargs orintf macro and use it instead i.e. #if !defined(CONFIG_SPL_BUILD_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) #define mmc_printf(...) ... #else #define
Re: [U-Boot] [PATCH 5/5] mmc: don't support write erase for SPL builds
Hi Paul, On Sep 4, 2013, at 6:14 PM, Paul Burton wrote: For SPL builds this is just dead code since we'll only need to read. Eliminating it results in a significant size reduction for the SPL binary. Signed-off-by: Paul Burton paul.bur...@imgtec.com --- I understand what you're trying to do, but I don't like the #ifdef thing. I'd prefer moving the mmc_berase mmc_bwrite in a different file that's only built for non-SPL and then use the a conditional macro in a header file. I.e. #ifndef CONFIG_SPL_BUILD extern unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt); #else #define mmc_berase(dev_num, start, blkcnt) /* nothing */ #endif Etc. Regards -- Pantelis drivers/mmc/mmc.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 30a985b..d305257 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -248,6 +248,7 @@ err_out: static unsigned long mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) { +#ifndef CONFIG_SPL_BUILD int err = 0; struct mmc *mmc = find_mmc_device(dev_num); lbaint_t blk = 0, blk_r = 0; @@ -281,6 +282,9 @@ mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) } return blk; +#else /* CONFIG_SPL_BUILD */ + return -1; +#endif } static ulong @@ -349,6 +353,7 @@ mmc_write_blocks(struct mmc *mmc, lbaint_t start, lbaint_t blkcnt, const void*sr static ulong mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void*src) { +#ifndef CONFIG_SPL_BUILD lbaint_t cur, blocks_todo = blkcnt; struct mmc *mmc = find_mmc_device(dev_num); @@ -368,6 +373,9 @@ mmc_bwrite(int dev_num, lbaint_t start, lbaint_t blkcnt, const void*src) } while (blocks_todo 0); return blkcnt; +#else /* CONFIG_SPL_BUILD */ + return 0; +#endif } static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start, -- 1.8.3.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc:sdhci: Fix card ready status timeout.
Hi there, On Sep 3, 2013, at 3:50 PM, Przemyslaw Marczak wrote: According to JEDEC eMMC specification, after data transfer (multiple or single block) host must wait for card ready status. This is done by waiting for command and data lines to be at idle state after transfer. JEDEC does not specify maximum timeout. Before this change max timeout was 10 ms but in case of UMS - when system does multiple read/write operations on random card blocks - timeout causes I/O errors. The timeout has been increased to 200ms after data transfer. For other transfers it stays unchanged. Tested on Goni and Trats. Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/mmc/sdhci.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 4261991..c495482 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -121,8 +121,18 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, unsigned int timeout, start_addr = 0; unsigned int retry = 1; - /* Wait max 10 ms */ - timeout = 10; + /* + * For some commands this function is called with NULL mmc_data + * pointer. One of those is CMD13 - send card status. + * After read/write data transfer or block erase commands - host sends + * CMD13 and is waiting for card ready status with some timeout. + * According to some internal cards operations after those commands + * this time must be increased. + */ + if (data) + timeout = 10; /* ms */ + else + timeout = 200; sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS); mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT; -- 1.7.9.5 Can we have a config option for these two values instead of magic numbers? With the defaults being set at 10 200 ms. Regards -- Pantelis ___ 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 v2] mmc: don't support write erase for SPL builds
Hi Paul, On Sep 6, 2013, at 4:43 PM, Paul Burton wrote: For SPL builds this is just dead code since we'll only need to read. Eliminating it results in a significant size reduction for the SPL binary, which may be critical for certain platforms where the binary size is highly constrained. Signed-off-by: Paul Burton paul.bur...@imgtec.com --- Changes in v2: - Move the mmc_bwrite mmc_berase functions to a new mmc_write.c file which is only compiled for non-SPL builds, as per a request from Pantelis Antoniou. This requires that a few formerly static functions in mmc.c be accessible to the new file, so they are declared in a new mmc_private.h header along with the write erase functions. For what it's worth I prefered v1, but hey ho. --- drivers/mmc/Makefile | 2 + drivers/mmc/mmc.c | 186 + drivers/mmc/mmc_private.h | 45 +++ drivers/mmc/mmc_write.c | 189 ++ 4 files changed, 240 insertions(+), 182 deletions(-) create mode 100644 drivers/mmc/mmc_private.h create mode 100644 drivers/mmc/mmc_write.c diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index bedf833..06280d1 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -34,6 +34,8 @@ COBJS-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o COBJS-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o ifdef CONFIG_SPL_BUILD COBJS-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o +else +COBJS-$(CONFIG_GENERIC_MMC) += mmc_write.o endif COBJS := $(COBJS-y) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 30a985b..666f77b 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -15,6 +15,7 @@ #include malloc.h #include linux/list.h #include div64.h +#include mmc_private.h /* Set block count limit because of 16 bit register limit on some hardware*/ #ifndef CONFIG_SYS_MMC_MAX_BLK_COUNT @@ -52,8 +53,7 @@ int __board_mmc_getcd(struct mmc *mmc) { int board_mmc_getcd(struct mmc *mmc)__attribute__((weak, alias(__board_mmc_getcd))); -static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, - struct mmc_data *data) +int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) { struct mmc_data backup; int ret; @@ -114,7 +114,7 @@ static int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, return ret; } -static int mmc_send_status(struct mmc *mmc, int timeout) +int mmc_send_status(struct mmc *mmc, int timeout) { struct mmc_cmd cmd; int err, retries = 5; @@ -162,7 +162,7 @@ static int mmc_send_status(struct mmc *mmc, int timeout) return 0; } -static int mmc_set_blocklen(struct mmc *mmc, int len) +int mmc_set_blocklen(struct mmc *mmc, int len) { struct mmc_cmd cmd; @@ -192,184 +192,6 @@ struct mmc *find_mmc_device(int dev_num) return NULL; } -static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) -{ - struct mmc_cmd cmd; - ulong end; - int err, start_cmd, end_cmd; - - if (mmc-high_capacity) - end = start + blkcnt - 1; - else { - end = (start + blkcnt - 1) * mmc-write_bl_len; - start *= mmc-write_bl_len; - } - - if (IS_SD(mmc)) { - start_cmd = SD_CMD_ERASE_WR_BLK_START; - end_cmd = SD_CMD_ERASE_WR_BLK_END; - } else { - start_cmd = MMC_CMD_ERASE_GROUP_START; - end_cmd = MMC_CMD_ERASE_GROUP_END; - } - - cmd.cmdidx = start_cmd; - cmd.cmdarg = start; - cmd.resp_type = MMC_RSP_R1; - - err = mmc_send_cmd(mmc, cmd, NULL); - if (err) - goto err_out; - - cmd.cmdidx = end_cmd; - cmd.cmdarg = end; - - err = mmc_send_cmd(mmc, cmd, NULL); - if (err) - goto err_out; - - cmd.cmdidx = MMC_CMD_ERASE; - cmd.cmdarg = SECURE_ERASE; - cmd.resp_type = MMC_RSP_R1b; - - err = mmc_send_cmd(mmc, cmd, NULL); - if (err) - goto err_out; - - return 0; - -err_out: -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) - puts(mmc erase failed\n); -#endif - return err; -} - -static unsigned long -mmc_berase(int dev_num, lbaint_t start, lbaint_t blkcnt) -{ - int err = 0; - struct mmc *mmc = find_mmc_device(dev_num); - lbaint_t blk = 0, blk_r = 0; - int timeout = 1000; - - if (!mmc) - return -1; - -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) - if ((start % mmc-erase_grp_size) || (blkcnt % mmc-erase_grp_size)) - printf(\n\nCaution! Your devices Erase group is 0x%x\n -The erase range would be change to -0x LBAF ~0x LBAF \n\n, -mmc-erase_grp_size, start ~(mmc-erase_grp_size - 1), -((start + blkcnt + mmc-erase_grp_size
Re: [U-Boot] [PATCH] mmc:sdhci: Fix card ready status timeout.
Hi there, On Sep 6, 2013, at 6:23 PM, Przemyslaw Marczak wrote: Hello Pantelis, On 09/06/2013 03:24 PM, Pantelis Antoniou wrote: Hi there, Can we have a config option for these two values instead of magic numbers? With the defaults being set at 10 200 ms. Regards -- Pantelis I'm not sure that this option is needed. Some cards I/O errors can be avoided by increasing timeout and has no negative influence on other cards read/write operations performance. Moreover there are a lot of timeout values defined in sdhci and mmc drivers, so why should I put at config just only one? Maybe the simplest solution is to leave at this code only 200 ms value. What do you think? Still, it's a magic constant in the code; you don't have to export it to boards, just put it in the same source file just before it's use. Protect it with an #ifndef statement in case someone else would like to override it. Regards -- Pantelis Regards, -- Przemyslaw Marczak Samsung RD Institute Poland Samsung Electronics p.marc...@samsung.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] mmc: don't support write erase for SPL builds
Hi Paul, On Sep 9, 2013, at 11:14 AM, Paul Burton wrote: On Sun 08 Sep 2013 09:48:20 BST, Andreas Bießmann wrote: Dear Paul Burton, On 06.09.13 15:43, Paul Burton wrote: For SPL builds this is just dead code since we'll only need to read. Eliminating it results in a significant size reduction for the SPL binary, which may be critical for certain platforms where the binary size is highly constrained. Signed-off-by: Paul Burton paul.bur...@imgtec.com --- Changes in v2: - Move the mmc_bwrite mmc_berase functions to a new mmc_write.c file which is only compiled for non-SPL builds, as per a request from Pantelis Antoniou. This requires that a few formerly static functions in mmc.c be accessible to the new file, so they are declared in a new mmc_private.h header along with the write erase functions. For what it's worth I prefered v1, but hey ho. --- drivers/mmc/Makefile | 2 + drivers/mmc/mmc.c | 186 + drivers/mmc/mmc_private.h | 45 +++ drivers/mmc/mmc_write.c | 189 ++ 4 files changed, 240 insertions(+), 182 deletions(-) create mode 100644 drivers/mmc/mmc_private.h create mode 100644 drivers/mmc/mmc_write.c snip diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c new file mode 100644 index 000..dde5cf2 --- /dev/null +++ b/drivers/mmc/mmc_write.c @@ -0,0 +1,189 @@ +/* + * Copyright 2008, Freescale Semiconductor, Inc + * Andy Fleming + * + * Based vaguely on the Linux code + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include config.h +#include common.h +#include part.h +#include mmc_private.h + +static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) +{ + struct mmc_cmd cmd; + ulong end; + int err, start_cmd, end_cmd; + + if (mmc-high_capacity) { + end = start + blkcnt - 1; + } else { + end = (start + blkcnt - 1) * mmc-write_bl_len; + start *= mmc-write_bl_len; + } + + if (IS_SD(mmc)) { + start_cmd = SD_CMD_ERASE_WR_BLK_START; + end_cmd = SD_CMD_ERASE_WR_BLK_END; + } else { + start_cmd = MMC_CMD_ERASE_GROUP_START; + end_cmd = MMC_CMD_ERASE_GROUP_END; + } + + cmd.cmdidx = start_cmd; + cmd.cmdarg = start; + cmd.resp_type = MMC_RSP_R1; + + err = mmc_send_cmd(mmc, cmd, NULL); + if (err) + goto err_out; + + cmd.cmdidx = end_cmd; + cmd.cmdarg = end; + + err = mmc_send_cmd(mmc, cmd, NULL); + if (err) + goto err_out; + + cmd.cmdidx = MMC_CMD_ERASE; + cmd.cmdarg = SECURE_ERASE; + cmd.resp_type = MMC_RSP_R1b; + + err = mmc_send_cmd(mmc, cmd, NULL); + if (err) + goto err_out; + + return 0; + +err_out: +#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT) + puts(mmc erase failed\n); +#endif this conditional compile in of puts/printf for SPL are no longer required, I'd prefere to remove them globally in mmc_write.c. Ah, yes good point, I'll remove that. + return err; +} Rest of this patch looks good to me. Best regards Andreas Bießmann Thanks for looking at it! Paul Seem good to me too. I'll give it a spin later this week and make sure nothing breaks. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc:sdhci: Fix card ready status timeout.
Hi there, On Sep 13, 2013, at 3:59 PM, Przemyslaw Marczak wrote: Dear Pantelis, On 09/09/2013 02:58 PM, Przemyslaw Marczak wrote: According to JEDEC eMMC specification, after data transfer (multiple or single block) host must wait for card ready status. This is done by waiting for command and data lines to be at idle state after transfer. JEDEC does not specify maximum timeout. Before this change max timeout was 10 ms but in case of UMS - when system does multiple read/write operations on random card blocks - timeout causes I/O errors. The timeout has been increased to 200ms after data transfer. For other transfers it stays unchanged. Default values are now defined with if defined directive so it can be redefined at board config if needed. Tested on Goni and Trats. Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com Please do not apply this patch yet due to still not enough results on some targets. Timeout value should depends on internal cards operations execution time but this time is unpredictably and that is why JEDEC not specifies it. Maybe u-boot sdhci driver needs some more changes to be more flexible for such operations. In example sdhci background operations timeout at kernel is specified to 4 minutes. I need to make more research. OK, this need to be fleshed out a bit more. Please keep me in the loop cause this sounds board-specific. Perhaps the CONFIG_* option is a sound idea; real world is messy like that. Regards, -- Przemyslaw Marczak Samsung RD Institute Poland Samsung Electronics p.marc...@samsung.com Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] MMC: DWMMC: Correct the CLKDIV register value
Hi Rajesh, I guess we wait for an updated patch here? Regards -- Pantelis On Sep 11, 2013, at 4:25 PM, Rajeshwari Birje wrote: Hi Jaehoon Chung, Thank you for comments, On Wed, Sep 11, 2013 at 11:31 AM, Jaehoon Chung jh80.ch...@samsung.com wrote: On 09/11/2013 02:28 PM, Rajeshwari Birje wrote: Hi All, Please do let me know if any comments on the same. Regards, Rajeshwari Shinde. On Thu, Aug 29, 2013 at 4:34 PM, Rajeshwari Birje rajeshwari.bi...@gmail.com wrote: CCing the MMC Maintainer. On Thu, Aug 29, 2013 at 4:22 PM, Rajeshwari S Shinde rajeshwar...@samsung.com wrote: This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value. as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1) Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register. This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec Signed-off-by: Rajeshwari S Shinde rajeshwar...@samsung.com --- arch/arm/include/asm/arch-exynos/dwmmc.h | 4 drivers/mmc/dw_mmc.c | 2 +- drivers/mmc/exynos_dw_mmc.c | 17 +++-- include/dwmmc.h | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/dwmmc.h b/arch/arm/include/asm/arch-exynos/dwmmc.h index b9eca76..f1c8d8a 100644 --- a/arch/arm/include/asm/arch-exynos/dwmmc.h +++ b/arch/arm/include/asm/arch-exynos/dwmmc.h @@ -14,6 +14,10 @@ #define DWMCI_SET_DRV_CLK(x) ((x) 16) #define DWMCI_SET_DIV_RATIO(x) ((x) 24) +/* CLKSEL Register */ +#define DWMCI_DIVRATIO_BIT 24 +#define DWMCI_DIVRATIO_MASK0x7 + #ifdef CONFIG_OF_CONTROL int exynos_dwmmc_init(const void *blob); #endif diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index a82ee17..3406bdd 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -224,7 +224,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq) * host-bus_hz should be set from user. */ if (host-mmc_clk) - sclk = host-mmc_clk(host-dev_index); + sclk = host-mmc_clk(host); else if (host-bus_hz) sclk = host-bus_hz; else { diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index 4ef9fec..1ed4afe 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host) dwmci_writel(host, DWMCI_CLKSEL, host-clksel_val); } -unsigned int exynos_dwmci_get_clk(int dev_index) +unsigned int exynos_dwmci_get_clk(struct dwmci_host *host) { - return get_mmc_clk(dev_index); + unsigned long sclk; + int8_t clk_div; + + /* +* Since SDCLKIN is divided inside controller by the DIVRATIO +* value set in the CLKSEL register, we need to use the same output +* clock value to calculate the CLKDIV value. +* as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1) +*/ + clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) DWMCI_DIVRATIO_BIT) +DWMCI_DIVRATIO_MASK) + 1; I known DIVRATIO is only exynos5 feature.. And If clk_div is set to 0, then clk_phase/clk_strength is also set to 0. And I think we can fixed this problem into exynos_dwmci_add_port. Best Regards, Jaehoon Chung during the dwmci_setup_bus we call for mmc_clk, this is where the get_mmc_clk(host-dev_index) retruns you the parent clock but since we need the output of mux cclk_in, added in the exynos_dwmci_get_clk. -- Regards, Rajeshwari Shinde + sclk = get_mmc_clk(host-dev_index); + + return sclk / clk_div; } /* diff --git a/include/dwmmc.h b/include/dwmmc.h index 08ced0b..26b53af 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -138,7 +138,7 @@ struct dwmci_host { struct mmc *mmc; void (*clksel)(struct dwmci_host *host); - unsigned int (*mmc_clk)(int dev_index); + unsigned int (*mmc_clk)(struct dwmci_host *host); }; struct dwmci_idmac { -- 1.7.12.4 ___ 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 http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Pull request: u-boot-mmc
Hi Tom, The following changes since commit 46ef4faed18196472eb95216b2f74c1397ecf024: Prepare v2013.10-rc3 (2013-09-16 20:08:33 -0400) are available in the git repository at: git://git.denx.de/u-boot-mmc.git master for you to fetch changes up to b31c9beb9bdde1714b1131cf0e64b8b68350e824: mmc: don't support write erase for SPL builds (2013-09-17 20:03:44 +0300) Jaehoon Chung (1): mmc: sdhci: use the SDHCI_QUIRK_USE_WIDE8 for samsung SoC Lubomir Popov (1): ARM: OMAP: Enable 8-bit eMMC access for OMAP4/5/DRA7xx Oleksandr Tyshchenko (2): mmc: Remove unused variable backup from mmc_send_cmd() omap_hsmmc: omap4+/am335x: modify MMC controller internal fsm reset func Paul Burton (5): spl: remove unnecessary ( ARM specific) include of asm/utils.h spl_mmc: only call printf or puts with CONFIG_SPL_LIBCOMMON_SUPPORT mmc: don't call *printf or puts when SPL !CONFIG_SPL_LIBCOMMON_SUPPORT mmc: size optimization when !CONFIG_MMC_SPI mmc: don't support write erase for SPL builds common/spl/spl_mmc.c | 17 +- drivers/mmc/Makefile | 2 ++ drivers/mmc/mmc.c | 205 +-- drivers/mmc/mmc_private.h | 45 ++ drivers/mmc/mmc_write.c | 189 ++ drivers/mmc/omap_hsmmc.c | 41 +-- drivers/mmc/s5p_sdhci.c | 4 ++- drivers/mmc/sdhci.c | 13 include/mmc.h | 4 +++ include/sdhci.h | 3 ++ 10 files changed, 337 insertions(+), 186 deletions(-) create mode 100644 drivers/mmc/mmc_private.h create mode 100644 drivers/mmc/mmc_write.c Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 12/12 V3] DWMMC: SMDK5420: Disable SMU for eMMC
Hi Rajesh, Simon, On Sep 19, 2013, at 9:12 AM, Simon Glass wrote: Hi Rajeshwari, On Wed, Sep 11, 2013 at 4:01 AM, Rajeshwari S Shinde rajeshwar...@samsung.com wrote: SMDK5420 has a new Security Management Unit added for dwmmc driver, hence, configuring the control registers to support booting via eMMC. Signed-off-by: Alim Akhtar alim.akh...@samsung.com Signed-off-by: Rajeshwari Shinde rajeshwar...@samsung.com --- Changes in V3: - New patch. drivers/mmc/dw_mmc.c | 7 +++ include/dwmmc.h | 12 2 files changed, 19 insertions(+) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index a82ee17..d763949 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -300,6 +300,13 @@ static int dwmci_init(struct mmc *mmc) struct dwmci_host *host = (struct dwmci_host *)mmc-priv; u32 fifo_size; + dwmci_writel(host, EMMCP_MPSBEGIN0, 0); + dwmci_writel(host, EMMCP_SEND0, 0); + dwmci_writel(host, EMMCP_CTRL0, + MPSCTRL_SECURE_READ_BIT | MPSCTRL_SECURE_WRITE_BIT | + MPSCTRL_NON_SECURE_READ_BIT | MPSCTRL_NON_SECURE_WRITE_BIT | + MPSCTRL_VALID); + Is this safe for all users of this file (Exynos5250, etc. ? Same objection here. If it's not safe ifdef CONFIG it. Regards, Simon Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Pull request: u-boot-mmc #2
Hi Tom, The following changes since commit 46ef4faed18196472eb95216b2f74c1397ecf024: Prepare v2013.10-rc3 (2013-09-16 20:08:33 -0400) are available in the git repository at: git://git.denx.de/u-boot-mmc.git master for you to fetch changes up to 2c011847c129491084a19c753a039a3441b7dce4: Fix wrong sdhci host control register read and write (2013-09-20 19:02:29 +0300) Jaehoon Chung (1): mmc: sdhci: use the SDHCI_QUIRK_USE_WIDE8 for samsung SoC Juhyun \(Justin\) Oh (1): Fix wrong sdhci host control register read and write Lubomir Popov (1): ARM: OMAP: Enable 8-bit eMMC access for OMAP4/5/DRA7xx Mischa Jonker (3): mmc/dw_mmc: Fix DMA descriptor corruption mmc/dw_mmc: Allocate the correct amount of descriptors Add parentheses to ALLOC_ALIGN_BUFFER macro's Oleksandr Tyshchenko (2): mmc: Remove unused variable backup from mmc_send_cmd() omap_hsmmc: omap4+/am335x: modify MMC controller internal fsm reset func Paul Burton (5): spl: remove unnecessary ( ARM specific) include of asm/utils.h spl_mmc: only call printf or puts with CONFIG_SPL_LIBCOMMON_SUPPORT mmc: don't call *printf or puts when SPL !CONFIG_SPL_LIBCOMMON_SUPPORT mmc: size optimization when !CONFIG_MMC_SPI mmc: don't support write erase for SPL builds common/spl/spl_mmc.c | 17 +- drivers/mmc/Makefile | 2 ++ drivers/mmc/dw_mmc.c | 9 +++--- drivers/mmc/mmc.c | 205 + drivers/mmc/mmc_private.h | 45 ++ drivers/mmc/mmc_write.c | 179 ++ drivers/mmc/omap_hsmmc.c | 41 ++-- drivers/mmc/s5p_sdhci.c | 4 ++- drivers/mmc/sdhci.c | 18 +-- include/common.h | 4 +-- include/mmc.h | 4 +++ include/sdhci.h | 3 ++ 12 files changed, 336 insertions(+), 195 deletions(-) create mode 100644 drivers/mmc/mmc_private.h create mode 100644 drivers/mmc/mmc_write.c Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] Armada100: Adds SD/MMC Register definitions
Hi Ajay, On Sep 24, 2013, at 11:02 AM, Ajay Bhargav wrote: This patch add SD/MMC interface register difinitions for Armada100 series. Signed-off-by: Ajay Bhargav ajay.bhar...@einfochips.com --- arch/arm/include/asm/arch-armada100/armada100.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/include/asm/arch-armada100/armada100.h b/arch/arm/include/asm/arch-armada100/armada100.h index d9feb16..81e4b8a 100644 --- a/arch/arm/include/asm/arch-armada100/armada100.h +++ b/arch/arm/include/asm/arch-armada100/armada100.h @@ -27,6 +27,14 @@ #define SSP2_APBCLK 0x01 #define SSP2_FNCLK0x02 +/* SD Clock/Reset Control Register Bit definition */ +#define SD1_SD2_AXI_RESET0x01 +#define SD1_RESET0x02 +#define SD1_SD2_AXICLK_EN0x08 +#define SD1_CLK_EN 0x10 +#define SD2_RESET0x02 +#define SD2_CLK_EN 0x10 + /* USB Clock/reset control bits */ #define USB_SPH_AXICLK_EN 0x10 #define USB_SPH_AXI_RST 0x02 @@ -53,6 +61,8 @@ #define ARMD1_UART3_BASE 0xD4026000 #define ARMD1_MPMU_BASE 0xD405 #define ARMD1_USB_HOST_BASE 0xD4209000 +#define ARMD1_SD1_BASE 0xD428 +#define ARMD1_SD2_BASE 0xD4281000 #define ARMD1_APMU_BASE 0xD4282800 #define ARMD1_CPU_BASE0xD4282C00 -- 1.8.3.rc3 Looks fine. Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com * eInfochips Business Disclaimer : This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain legally privileged and confidential information. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer. Any views expressed in this message are those of the individual sender unless otherwise stated. Company has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email. * - Notice: This message has been scanned by Trend Micro Mail Security scanner and is believed to be clean - ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/2] Armada100: Add SD card support for Marvell gplugD
-- 1.8.3.rc3 Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com * eInfochips Business Disclaimer : This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain legally privileged and confidential information. If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer. Any views expressed in this message are those of the individual sender unless otherwise stated. Company has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any virus transmitted by this email. * - Notice: This message has been scanned by Trend Micro Mail Security scanner and is believed to be clean - ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: sdhci: Avoid commands errors by simple timeout adaptation.
Hi there, On Oct 1, 2013, at 3:16 PM, Przemyslaw Marczak wrote: Old command timeout value was too small and it caused I/O errors which led to uncompleted read/write/erase operations and filesystem errors. Timeout adaptation fixes this issue. Changes in sdhci_send_command() function: - change timeout variable to static - increase default command timeout to 100 ms - add definition of max command timeout value, which can be redefined in each board config file - wait for card ready state for max defined time if it doesn't exceed defined maximum or return COMM_ERR Once successfully increased timeout value will be used in next function call. This fix was tested on Goni, Trats, Trats2 boards by testing UMS on MMC storage. Signed-off-by: Przemyslaw Marczak p.marc...@samsung.com --- drivers/mmc/sdhci.c | 34 +++--- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 4261991..af11fc5 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -110,6 +110,22 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data, return 0; } +/* + * No command will be sent by driver if card is busy, so driver must wait + * for card ready state. + * Every time when card is busy after timeout then (last) timeout value will be + * increased twice but only if it doesn't exceed global defined maximum. + * Each function call will use last timeout value. Max timeout can be redefined + * in board config file. + */ +#ifndef CONFIG_SDHCI_CMD_MAX_TIMEOUT +#define CONFIG_SDHCI_CMD_MAX_TIMEOUT 3200 +#endif +#define CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT 100 + +/* Timeout unit - ms */ +static unsigned int cmd_timeout = CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT; + int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) { @@ -118,12 +134,9 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, int ret = 0; int trans_bytes = 0, is_aligned = 1; u32 mask, flags, mode; - unsigned int timeout, start_addr = 0; + unsigned int time = 0, start_addr = 0; unsigned int retry = 1; - /* Wait max 10 ms */ - timeout = 10; - sdhci_writel(host, SDHCI_INT_ALL_MASK, SDHCI_INT_STATUS); mask = SDHCI_CMD_INHIBIT | SDHCI_DATA_INHIBIT; @@ -133,11 +146,18 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, mask = ~SDHCI_DATA_INHIBIT; while (sdhci_readl(host, SDHCI_PRESENT_STATE) mask) { - if (timeout == 0) { + if (time == cmd_timeout) { time = cmd_timeout here. You rely on the timeout hitting exactly the same value which is not guaranteed. printf(Controller never released inhibit bit(s).\n); - return COMM_ERR; + if (2 * cmd_timeout = CONFIG_SDHCI_CMD_MAX_TIMEOUT) { + cmd_timeout += cmd_timeout; + debug(Increasing command timeout to: %u ms.\n, + cmd_timeout); + } else { + error(Command timeout is set to max.\n); + return COMM_ERR; + } } - timeout--; + time++; udelay(1000); } -- 1.7.9.5 Other than that the concept seems sound. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: sdhci: Avoid commands errors by simple timeout adaptation.
Hi Przemyslaw, On Oct 1, 2013, at 7:59 PM, Przemyslaw Marczak wrote: Hello Pantelis, Thank you for reply On 10/01/2013 05:50 PM, Pantelis Antoniou wrote: while (sdhci_readl(host, SDHCI_PRESENT_STATE) mask) { -if (timeout == 0) { +if (time == cmd_timeout) { time = cmd_timeout here. You rely on the timeout hitting exactly the same value which is not guaranteed. I think this condition is guaranteed here, because of time value that is incremented only inside the loop. Also if meets (time == cmd_timeout) condition and next if timeout will be increased twice, then eg. if current timeout is 100ms - next will be 200 ms, so it needs 100 loops and no more. Am I wrong? OK, let's take things one at a time: First of all you use the global variable cmd_timeout, and you alter it's value. Where it is reset back in case the operation starts all over again? Secondly the check time == cmd_timeout is very very fragile. You depend on the loop only incrementing the time by one. This is not always guaranteed to be the case in the future. Using a greater than comparison you are safe even if in sometime in the future the step changes and there is absolutely no performance penalty. Regards -- Przemyslaw Marczak Samsung RD Institute Poland Samsung Electronics p.marc...@samsung.com Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] usb: Fix bug when both DFU ETHER are defined
When both CONFIG_USB_GADGET CONFIG_USB_ETHER are defined the makefile links objects twice. This patch uses a Makefile specific idiom of 'if defined(CONFIG_USB_GADGET) || defined(CONFIG_USB_ETHER)' to handle the case. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/usb/gadget/Makefile | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile index 040eaba..e545b6b 100644 --- a/drivers/usb/gadget/Makefile +++ b/drivers/usb/gadget/Makefile @@ -25,15 +25,21 @@ include $(TOPDIR)/config.mk LIB:= $(obj)libusb_gadget.o +# if defined(CONFIG_USB_GADGET) || defined(CONFIG_USB_ETHER) +# Everytime you forget how crufty makefiles can get things like +# this remind you... +ifneq (,$(CONFIG_USB_GADGET)$(CONFIG_USB_ETHER)) +COBJS-y += epautoconf.o config.o usbstring.o +endif + # new USB gadget layer dependencies ifdef CONFIG_USB_GADGET -COBJS-y += epautoconf.o config.o usbstring.o COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o endif ifdef CONFIG_USB_ETHER -COBJS-y += ether.o epautoconf.o config.o usbstring.o +COBJS-y += ether.o COBJS-$(CONFIG_USB_ETH_RNDIS) += rndis.o COBJS-$(CONFIG_MV_UDC) += mv_udc.o COBJS-$(CONFIG_CPU_PXA25X) += pxa25x_udc.o -- 1.7.12 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/9] usb: Fix bug when both DFU ETHER are defined
Hi Marek, On Dec 1, 2012, at 7:30 AM, Marek Vasut wrote: Dear Pantelis Antoniou, When both CONFIG_USB_GADGET CONFIG_USB_ETHER are defined the makefile links objects twice. The cleanest way to fix is to use a new define, CONFIG_USB_UTIL which must be defined when either CONFIG_USB_ETHER or CONFIG_USB_GADGET are defined. All affected boards have been modified as well. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com Quick google [1] http://old.nabble.com/if-defined%28a%29-||-defined%28b%29-td26806006.html This won't work? Somehow I missed that. Makes some kind of (awful) sense. Updated patch incoming... Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] [nand] Implement nand_extent_skip_bad
When accessing nand any bad blocks encountered are skipped, with no indication about the amount of bad blocks encountered. While this is normally fine, when you have to write a large amount of data in chunks, you need to account for the skipped amount due to the presence of the bad blocks. nand_extend_skip_bad() returns the offset where the next access should occur. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/mtd/nand/nand_util.c | 50 include/nand.h | 2 ++ 2 files changed, 52 insertions(+) diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 2ba0c5e..a25a4cb 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -684,6 +684,56 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, return 0; } +/** + * nand_extent_skip_bad: + * + * Find the extent of a chunk, return the offset where it ends + * Blocks that are marked bad are skipped and the next block is examined + * instead as long as the extend is short enough to fit even after skipping the + * bad blocks. + * + * @param nand NAND device + * @param offset offset in flash + * @param length extend length + * @return next offset in case of success (loff_t)-1 on error + */ +loff_t nand_extent_skip_bad(nand_info_t *nand, loff_t offset, size_t length) +{ + size_t block_len, block_off; + loff_t block_start; + + if ((offset (nand-writesize - 1)) != 0) { + printf (%s: Attempt to check extend non page aligned data\n, + __func__); + return (loff_t)-1; + } + + while (length 0) { + + if (offset = nand-size) { + printf(%s: offset = nand-size (%llx = %llx)\n, + __func__, offset, nand-size); + return (loff_t)-1; + } + + block_start = offset ~(loff_t)(nand-erasesize - 1); + block_off = offset (nand-erasesize - 1); + block_len = nand-erasesize - block_off; + if (block_len length) /* left over */ + block_len = length; + + if (!nand_block_isbad(nand, block_start)) + length -= block_len; + else + debug(%s: bad block at %llx (left %x)\n, + __func__, block_start, length); + + offset += block_len; + } + + return offset; +} + #ifdef CONFIG_CMD_NAND_TORTURE /** diff --git a/include/nand.h b/include/nand.h index dded4e2..710c11a 100644 --- a/include/nand.h +++ b/include/nand.h @@ -168,3 +168,5 @@ __attribute__((noreturn)) void nand_boot(void); #define ENV_OFFSET_SIZE 8 int get_nand_env_oob(nand_info_t *nand, unsigned long *result); #endif + +loff_t nand_extent_skip_bad(nand_info_t *nand, loff_t offset, size_t length); -- 1.7.12 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH] [DFU] Implement NAND dfu support
Introduce on-the fly DFU NAND support. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/dfu/Makefile | 1 + drivers/dfu/dfu.c | 7 ++ drivers/dfu/dfu_nand.c | 194 + include/dfu.h | 23 ++ 4 files changed, 225 insertions(+) create mode 100644 drivers/dfu/dfu_nand.c diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile index 7b717bc..153095d 100644 --- a/drivers/dfu/Makefile +++ b/drivers/dfu/Makefile @@ -27,6 +27,7 @@ LIB = $(obj)libdfu.o COBJS-$(CONFIG_DFU_FUNCTION) += dfu.o COBJS-$(CONFIG_DFU_MMC) += dfu_mmc.o +COBJS-$(CONFIG_DFU_NAND) += dfu_nand.o SRCS:= $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(COBJS-y)) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index fb9b417..1972b17 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -234,6 +234,8 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) dfu-i_buf = dfu-i_buf_start; dfu-b_left = 0; + dfu-bad_skip = 0; + dfu-inited = 1; } @@ -263,6 +265,8 @@ int dfu_read(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num) dfu-i_buf = dfu-i_buf_start; dfu-b_left = 0; + dfu-bad_skip = 0; + dfu-inited = 0; } @@ -285,6 +289,9 @@ static int dfu_fill_entity(struct dfu_entity *dfu, char *s, int alt, if (strcmp(interface, mmc) == 0) { if (dfu_fill_entity_mmc(dfu, s)) return -1; + } else if (strcmp(interface, nand) == 0) { + if (dfu_fill_entity_nand(dfu, s)) + return -1; } else { printf(%s: Device %s not (yet) supported!\n, __func__, interface); diff --git a/drivers/dfu/dfu_nand.c b/drivers/dfu/dfu_nand.c new file mode 100644 index 000..9ea5f0c --- /dev/null +++ b/drivers/dfu/dfu_nand.c @@ -0,0 +1,194 @@ +/* + * dfu_nand.c -- DFU for NAND routines. + * + * Copyright (C) 2012 Texas Instruments, Inc. + * + * Based on dfu_mmc.c which is: + * Copyright (C) 2012 Samsung Electronics + * author: Lukasz Majewski l.majew...@samsung.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include common.h +#include malloc.h +#include errno.h +#include div64.h +#include dfu.h +#include linux/mtd/mtd.h +#include jffs2/load_kernel.h +#include nand.h + +enum dfu_nand_op { + DFU_OP_READ = 1, + DFU_OP_WRITE, +}; + +static int nand_block_op(enum dfu_nand_op op, struct dfu_entity *dfu, + u64 offset, void *buf, long *len) +{ + char cmd_buf[DFU_CMD_BUF_SIZE]; + u64 start, count; + int ret; + int dev; + loff_t actual; + + /* if buf == NULL return total size of the area */ + if (buf == NULL) { + *len = dfu-data.nand.size; + return 0; + } + + start = dfu-data.nand.start + offset + dfu-bad_skip; + count = *len; + if (start + count + dfu-data.nand.start + dfu-data.nand.size) { + printf(%s: block_op out of bounds\n, __func__); + return -1; + } + dev = nand_curr_device; + if (dev 0 || dev = CONFIG_SYS_MAX_NAND_DEVICE || + !nand_info[dev].name) { + printf(%s: invalid nand device\n, __func__); + return -1; + } + + sprintf(cmd_buf, nand %s %p %llx %llx, + op == DFU_OP_READ ? read : write, +buf, start, count); + + debug(%s: %s 0x%p\n, __func__, cmd_buf, cmd_buf); + ret = run_command(cmd_buf, 0); + + /* find out how much actual bytes have been written */ + /* the difference is the amount of skip we must add from now on */ + actual = nand_extent_skip_bad(nand_info[dev], start, count); + if (actual == (loff_t)-1) { + printf(nand_extend_skip_bad: error!\n); + return ret; + } + + if (actual (start + count)) { + debug(%s: skipped %llx bad bytes at %llx\n, __func__, + actual - (start + count), start); + dfu-bad_skip += (u32)(actual - (start + count
Re: [U-Boot] [PATCH v3 6/9] dfu: Send correct DFU response from composite_setup
Hi Lukasz, On Dec 10, 2012, at 7:11 PM, Lukasz Majewski wrote: Hi Pantelis, DFU is a bit peculiar. It needs to hook to composite setup and return it's function descriptor. So when get-descriptor request comes with a type of DFU_DT_FUNC we iterate over the configs, and functions, and when we find the DFU function we call the setup method which is prepared to return the appropriate function descriptor. Sorry, but could you be more informative here? Have you had any non standard problems? I wonder why dfu-util on my linux works OK without this patch? I have absolutely no idea why it works at your side. At our side it just didn't work at all without the patches. If I had to guess maybe your gadget h/w takes care of replying properly for the DFU case. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/usb/gadget/composite.c | 27 +++ drivers/usb/gadget/ep0.c | 1 + drivers/usb/gadget/f_dfu.c | 6 -- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index ebb5131..6496436 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -773,6 +773,33 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) if (value = 0) value = min(w_length, (u16) value); break; + +#ifdef CONFIG_DFU_FUNCTION +/* DFU is mighty weird */ ^^ - please explain this wiredness. I don't recall such a hacks in linux kernel composite.c (any special #ifdef). Am I missing something important in DFU? Does your device have any special requirement, so you need this hack? I generally don't like the idea to patch composite gadget code with #ifdefs for special function. Please convince me. It doesn't work otherwise. I have no idea why you think I would be hacking around there if the thing worked at all. And trust me on that, it just doesn't without those patches, not to mention the way it unceremoniously blows up if you transfer anything larger than the buffer set aside originally. The way I see it, instead of complaining you should be rejoicing since now DFU will be used in an actual production environment. More users == less bugs. When I get a few free cycles I will post a tcpdump capture of the DFU USB transaction hanging. +case DFU_DT_FUNC: +w_value = 0xff; +list_for_each_entry(c, cdev-configs, list) { +if (w_value != 0) { +w_value--; +continue; +} + +list_for_each_entry(f, c-functions, list) { + +/* DFU function only */ +if (strcmp(f-name, dfu) != 0) +continue; + +value = f-setup(f, ctrl); +goto dfu_func_done; +} +} +dfu_func_done: +if (value = 0) +value = min(w_length, (u16) value); +break; +#endif + default: goto unknown; } diff --git a/drivers/usb/gadget/ep0.c b/drivers/usb/gadget/ep0.c index aa8f916..971d846 100644 --- a/drivers/usb/gadget/ep0.c +++ b/drivers/usb/gadget/ep0.c @@ -221,6 +221,7 @@ static int ep0_get_descriptor (struct usb_device_instance *device, break; case USB_DESCRIPTOR_TYPE_CONFIGURATION: +case USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION: ^- why do you need that? { struct usb_configuration_descriptor *configuration_descriptor; diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c index 10547e3..6494f5e 100644 --- a/drivers/usb/gadget/f_dfu.c +++ b/drivers/usb/gadget/f_dfu.c @@ -534,8 +534,10 @@ dfu_handle(struct usb_function *f, const struct usb_ctrlrequest *ctrl) value = min(len, (u16) sizeof(dfu_func)); memcpy(req-buf, dfu_func, value); } -} else /* DFU specific request */ -value = dfu_state[f_dfu-dfu_state] (f_dfu, ctrl, gadget, req); +return value; +} + +value = dfu_state[f_dfu-dfu_state] (f_dfu, ctrl, gadget, req); Why do you change state even after receiving req_type == USB_TYPE_STANDARD? I would expect to change the dfu state only when DFU specific request appears. if (value = 0) { req-length = value; -- Best regards, Lukasz Majewski Samsung Poland RD Center | Linux Platform Group Regards
Re: [U-Boot] [PATCH] [DFU] Implement NAND dfu support
Hi Scott, On Dec 11, 2012, at 3:09 AM, Scott Wood wrote: On 12/10/2012 09:24:32 AM, Pantelis Antoniou wrote: Introduce on-the fly DFU NAND support. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/dfu/Makefile | 1 + drivers/dfu/dfu.c | 7 ++ drivers/dfu/dfu_nand.c | 194 + include/dfu.h | 23 ++ 4 files changed, 225 insertions(+) create mode 100644 drivers/dfu/dfu_nand.c What is DFU? I don't see anything in README or doc/, despite there already being CONFIG symbols for it. This gets answered by a following email. +static int nand_block_op(enum dfu_nand_op op, struct dfu_entity *dfu, +u64 offset, void *buf, long *len) +{ +char cmd_buf[DFU_CMD_BUF_SIZE]; +u64 start, count; +int ret; +int dev; +loff_t actual; + +/* if buf == NULL return total size of the area */ +if (buf == NULL) { +*len = dfu-data.nand.size; +return 0; +} + +start = dfu-data.nand.start + offset + dfu-bad_skip; +count = *len; +if (start + count +dfu-data.nand.start + dfu-data.nand.size) { +printf(%s: block_op out of bounds\n, __func__); +return -1; +} +dev = nand_curr_device; +if (dev 0 || dev = CONFIG_SYS_MAX_NAND_DEVICE || +!nand_info[dev].name) { +printf(%s: invalid nand device\n, __func__); +return -1; +} + +sprintf(cmd_buf, nand %s %p %llx %llx, +op == DFU_OP_READ ? read : write, + buf, start, count); + +debug(%s: %s 0x%p\n, __func__, cmd_buf, cmd_buf); +ret = run_command(cmd_buf, 0); Why not use the C interface to NAND? Sigh. That's what I'm working on right now. The original implementation for mmc uses the user facing cmd api, so that's what I'm using for nand too. The problem is that I see, is that by using this method (dfu_mmc|dfu_nand|dfu_foo) this piece of code gets duplicated for each different dfu target. I was told that Device Model will fix everything, eventually, so I abandoned anything more generic than that. I will follow up with a patch that uses the C interface, and hope that sometime in the future we can consolidate. Maybe. +/* find out how much actual bytes have been written */ +/* the difference is the amount of skip we must add from now on */ +actual = nand_extent_skip_bad(nand_info[dev], start, count); ...especially since you already need to interact with it here? -Scott Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] [nand] Implement nand_extent_skip_bad
Hi Scott, On Dec 11, 2012, at 12:53 AM, Scott Wood wrote: On 12/10/2012 09:24:24 AM, Pantelis Antoniou wrote: When accessing nand any bad blocks encountered are skipped, with no indication about the amount of bad blocks encountered. While this is normally fine, when you have to write a large amount of data in chunks, you need to account for the skipped amount due to the presence of the bad blocks. nand_extend_skip_bad() returns the offset where the next access should occur. s/extend/extent/ Yeah. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/mtd/nand/nand_util.c | 50 include/nand.h | 2 ++ 2 files changed, 52 insertions(+) diff --git a/drivers/mtd/nand/nand_util.c b/drivers/mtd/nand/nand_util.c index 2ba0c5e..a25a4cb 100644 --- a/drivers/mtd/nand/nand_util.c +++ b/drivers/mtd/nand/nand_util.c @@ -684,6 +684,56 @@ int nand_read_skip_bad(nand_info_t *nand, loff_t offset, size_t *length, return 0; } +/** + * nand_extent_skip_bad: + * + * Find the extent of a chunk, return the offset where it ends + * Blocks that are marked bad are skipped and the next block is examined + * instead as long as the extend is short enough to fit even after skipping the + * bad blocks. + * + * @param nand NAND device + * @param offset offset in flash + * @param length extend length + * @return next offset in case of success (loff_t)-1 on error + */ Would it be better to return this information from existing read/write functions -- either instead of or in addition to exporting this functionality? Yes it would. However that would require modifying all callers, which would be a hard sell when there's only one user of it. +loff_t nand_extent_skip_bad(nand_info_t *nand, loff_t offset, size_t length) +{ +size_t block_len, block_off; +loff_t block_start; + +if ((offset (nand-writesize - 1)) != 0) { +printf (%s: Attempt to check extend non page aligned data\n, +__func__); +return (loff_t)-1; +} + +while (length 0) { + +if (offset = nand-size) { +printf(%s: offset = nand-size (%llx = %llx)\n, +__func__, offset, nand-size); +return (loff_t)-1; +} + +block_start = offset ~(loff_t)(nand-erasesize - 1); +block_off = offset (nand-erasesize - 1); +block_len = nand-erasesize - block_off; +if (block_len length) /* left over */ +block_len = length; + +if (!nand_block_isbad(nand, block_start)) +length -= block_len; +else +debug(%s: bad block at %llx (left %x)\n, +__func__, block_start, length); + +offset += block_len; +} + +return offset; +} This seems duplicative of check_skip_len(). It is. check_skip_len doesn't return the information I need. I could modify check_skip_len with an extra parameter if that's going to be OK with you. -Scott Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 6/9] dfu: Send correct DFU response from composite_setup
Hi Lukasz, I bet transmission is performed, but with the default settings of dfu. The DFU function descriptor is completely ignored. An easy way to verify it is to check if the DFU version of the device is the same one as the one stored in the descriptor. Same with the transmission block size. It might work, but only by accident. I sure hope I'll have time today to send my captures as well. Regards -- Pantelis On Dec 11, 2012, at 1:02 PM, Lukasz Majewski wrote: Hi Pantelis, Tomorrow I will prepare output of USB Ellisys analizer on my side, so we could get clue what is going on. Please find attached output from USB ellisys analizer. (It is possible to download WinXP based program to view logs without USB analizer box). What I see in the current implementation stalls on GetDescriptor (Class: 0x21),but afterwards transmission is performed. -- Best regards, Lukasz Majewski Samsung Poland RD Center | Linux Platform Group DFU_mainline_trats.tar ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] [nand] Implement nand_extent_skip_bad
Hi Scott, On Dec 11, 2012, at 7:13 PM, Scott Wood wrote: On 12/11/2012 03:40:53 AM, Pantelis Antoniou wrote: Hi Scott, On Dec 11, 2012, at 12:53 AM, Scott Wood wrote: +/** + * nand_extent_skip_bad: + * + * Find the extent of a chunk, return the offset where it ends + * Blocks that are marked bad are skipped and the next block is examined + * instead as long as the extend is short enough to fit even after skipping the + * bad blocks. + * + * @param nand NAND device + * @param offset offset in flash + * @param length extend length + * @return next offset in case of success (loff_t)-1 on error + */ Would it be better to return this information from existing read/write functions -- either instead of or in addition to exporting this functionality? Yes it would. However that would require modifying all callers, which would be a hard sell when there's only one user of it. There aren't that many callers, and it's all common code (so no issue with testing on obscure hardware). This seems duplicative of check_skip_len(). It is. check_skip_len doesn't return the information I need. I could modify check_skip_len with an extra parameter if that's going to be OK with you. Yes, please modify check_skip_len() instead. -Scott Nice, hope I'll get around doing it today or tomorrow. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PULL] u-boot-usb/master
Lukasz, I'll sent the dump in a couple of hours. Been busy with other work items... Regards -- Pantelis On Dec 17, 2012, at 1:00 PM, Lukasz Majewski wrote: Hi Marek, Pantelis Antoniou (9): g_dnl: Issue connect/disconnect as appropriate g_dnl: Properly terminate string list. dfu: Only perform DFU board_usb_init() for TRATS dfu: Fix crash when wrong number of arguments given dfu: Send correct DFU response from composite_setup dfu: Properly zero out timeout value dfu: Add a partition type target dfu: Support larger than memory transfers. usb: Fix bug when both DFU ETHER are defined Can we wait with pulling DFU related patches? I didn't received tcpdump from Pantelis, so I don't know what is going on (or how to tackle the DFU problem). -- Best regards, Lukasz Majewski Samsung Poland RD Center | Linux Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PULL] u-boot-usb/master
USB DFU Interface... Setting Alternate Setting #6 ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Did not find cached descriptor Error obtaining cached DFU functional descriptor DUMP of func_dfu bLength = 9 bDescriptorType = 33 bmAttributes= 0x0f wDetachTimeOut = 0 wTransferSize = 4096 bcdDFUVersion = 0x0110 DFU mode device DFU version 0110 Device returned transfer size 4096 No valid DFU suffix signature Warning: File has no DFU suffix bytes_per_hash=335554 Copying data from PC to DFU device Starting download: [##] finished! Sent a total of 1628 bytes state(2) = dfuIDLE, status(0) = No error condition is present Done! The response is malformed without the fix in the bad capture: USB URB URB id: 0x88032d9cbdc0 URB type: URB_COMPLETE ('C') URB transfer type: URB_CONTROL (0x02) Endpoint: 0x80, Direction: IN 1... = Direction: IN (1) .000 = Endpoint value: 0 Device: 34 URB bus id: 3 Device setup request: not relevant ('-') Data: present (0) URB sec: 1355753000 URB usec: 572591 URB status: Broken pipe (-EPIPE) (-32) URB length [bytes]: 0 Data length [bytes]: 0 [Request in: 171] [Time from request: 0.000108000 seconds] [bInterfaceClass: Unknown (0x)] [Malformed Packet: USB] [Expert Info (Error/Malformed): Malformed Packet (Exception occurred)] [Message: Malformed Packet (Exception occurred)] [Severity level: Error] [Group: Malformed] c0 bd 9c 2d 03 88 ff ff 43 02 80 22 03 00 2d 00 ...-C-. 0010 28 26 cf 50 00 00 00 00 af bc 08 00 e0 ff ff ff (.P 0020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0030 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 And the dfu-util side at the host complains and fails: $ sudo ./src/dfu-util -v -D ~/test.img -a rootfs dfu-util 0.7 Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2012 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to dfu-u...@lists.gnumonks.org Opening DFU capable USB device... ID 0403:bd00 Did not find cached descriptor WARNING: Can not find cached DFU functional descriptor Warning: Assuming DFU version 1.0 Run-time device DFU version 0100 Claiming USB DFU Runtime Interface... Determining device status: state = appIDLE, status = 0 Device really in Runtime Mode, send DFU detach request... Resetting USB... Opening DFU USB Device... Found DFU: [0403:bd00] devnum=0, cfg=2, intf=0, alt=6, name=rootfs Claiming USB DFU Interface... Setting Alternate Setting #6 ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Did not find cached descriptor Error obtaining cached DFU functional descriptor DUMP of func_dfu bLength = 0 bDescriptorType = 0 bmAttributes= 0x00 wDetachTimeOut = 0 wTransferSize = 0 bcdDFUVersion = 0x Error obtaining DFU functional descriptor Please report this as a bug! Warning: Assuming DFU version 1.0 Warning: Transfer size can not be detected DFU mode device DFU version 0100 Error: Transfer size must be specified The full set of captures (pcap format) is at dfu - https://docs.google.com/folder/d/0B7yJhZ55fi8FOFR3TnVGdTBfbHM/edit As to why it works for you Lukasz, I'm puzzled; maybe some difference in the usb gadget peripheral? I would bet that it might refuse to send a malformed response, dfu-util will eventually time out and then the transfer can continue with some fail-safe defaults. In either way, that's bad, and is a bug that the patchset fixes correctly. Regards -- Pantelis On Dec 17, 2012, at 1:00 PM, Lukasz Majewski wrote: Hi Marek, Pantelis Antoniou (9): g_dnl: Issue connect/disconnect as appropriate g_dnl: Properly terminate string list. dfu: Only perform DFU board_usb_init() for TRATS dfu: Fix crash when wrong number of arguments given dfu: Send correct DFU response from composite_setup dfu: Properly zero out timeout value dfu: Add a partition type target dfu: Support larger than memory transfers. usb: Fix bug when both DFU ETHER are defined Can we wait with pulling DFU related patches? I didn't received tcpdump from Pantelis, so I don't know what is going on (or how to tackle the DFU problem). -- Best regards, Lukasz Majewski Samsung Poland RD Center | Linux Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PULL] u-boot-usb/master
device DFU version 0100 Error: Transfer size must be specified The full set of captures (pcap format) is at dfu - https://docs.google.com/folder/d/0B7yJhZ55fi8FOFR3TnVGdTBfbHM/edit As to why it works for you Lukasz, I'm puzzled; maybe some difference in the usb gadget peripheral? I would bet that it might refuse to send a malformed response, dfu-util will eventually time out and then the transfer can continue with some fail-safe defaults. In either way, that's bad, and is a bug that the patchset fixes correctly. Regards -- Pantelis On Dec 17, 2012, at 1:00 PM, Lukasz Majewski wrote: Hi Marek, Pantelis Antoniou (9): g_dnl: Issue connect/disconnect as appropriate g_dnl: Properly terminate string list. dfu: Only perform DFU board_usb_init() for TRATS dfu: Fix crash when wrong number of arguments given dfu: Send correct DFU response from composite_setup dfu: Properly zero out timeout value dfu: Add a partition type target dfu: Support larger than memory transfers. usb: Fix bug when both DFU ETHER are defined Can we wait with pulling DFU related patches? I didn't received tcpdump from Pantelis, so I don't know what is going on (or how to tackle the DFU problem). -- Best regards, Lukasz Majewski Samsung Poland RD Center | Linux Platform Group -- Best regards, Lukasz Majewski Samsung Poland RD Center | Linux Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PULL] u-boot-usb/master
Hi Lukasz, Mystery solved then :) On Dec 18, 2012, at 1:25 PM, Lukasz Majewski wrote: Hi Pantelis, Can you paste the log of your dfu-util session? Are you supplying a transfer size for example? Regards u-boot-denx/master (denx.de) repository SHA1: fd4d564b3c80b111f18c93adb14233a6a7ddb0e9 (without Pantelis patches) dfu-util version 0.7 (not working): lukma@amdc308:~/work/u-boot-denx(master)$ ../dfu-util/src/dfu-util -V -v -t 0x1000 -a0 -D u-boot.bin dfu-util 0.7 Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2012 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to dfu-u...@lists.gnumonks.org Opening DFU capable USB device... ID 04e8:6601 Did not find cached descriptor WARNING: Can not find cached DFU functional descriptor Warning: Assuming DFU version 1.0 Run-time device DFU version 0100 Found DFU: [04e8:6601] devnum=0, cfg=2, intf=0, alt=0, name=u-boot Claiming USB DFU Interface... Setting Alternate Setting #0 ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Did not find cached descriptor Error obtaining cached DFU functional descriptor Error obtaining DFU functional descriptor Please report this as a bug! Warning: Assuming DFU version 1.0 Warning: Transfer size can not be detected DFU mode device DFU version 0100 Error: Transfer size must be specified Broken. Newer version appears to expect the transfer size to be supplied by the device in order to work. dfu-util version. 0.1+svnexported (available at debian repository (0.0+r4067-3.1)) lukma@amdc308:~/work/u-boot-denx(master)$ dfu-util -v -t 0x1000 -a0 -D u-boot.bin dfu-util - (C) 2007 by OpenMoko Inc. This program is Free Software and has ABSOLUTELY NO WARRANTY Opening USB Device 0x:0x... Found Runtime: [0x04e8:0x6601] devnum=77, cfg=0, intf=0, alt=0, name=u-boot Claiming USB DFU Interface... Setting Alternate Setting ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Error obtaining DFU functional descriptor: error sending control message: Broken pipe Transfer Size = 0x1000 bytes_per_hash=5591 Starting download: [##] finished! state(2) = dfuIDLE, status(0) = No error condition is present Done! WORKS. I bet it only works because you supply the transfer size. Try omitting it and see what happens. Ok, so world has went forward. And I've left behind :-/. With Pantelis Patches: lukma@amdc308:~/work/u-boot-denx(NEW_DFU)$ ../dfu-util/src/dfu-util -V -v -t 0x1000 -a0 -D u-boot.bin dfu-util 0.7 Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. Copyright 2010-2012 Tormod Volden and Stefan Schmidt This program is Free Software and has ABSOLUTELY NO WARRANTY Please report bugs to dfu-u...@lists.gnumonks.org Opening DFU capable USB device... ID 04e8:6601 Did not find cached descriptor WARNING: Can not find cached DFU functional descriptor Warning: Assuming DFU version 1.0 Run-time device DFU version 0100 Claiming USB DFU Runtime Interface... Determining device status: state = appIDLE, status = 0 Device really in Runtime Mode, send DFU detach request... Resetting USB... Opening DFU USB Device... Found DFU: [04e8:6601] devnum=0, cfg=2, intf=0, alt=0, name=u-boot Claiming USB DFU Interface... Setting Alternate Setting #0 ... Determining device status: state = dfuIDLE, status = 0 dfuIDLE, continuing Did not find cached descriptor Error obtaining cached DFU functional descriptor DFU mode device DFU version 0110 ^ correct DFU version detected Device returned transfer size 4096 ^ and optimal transfer size No valid DFU suffix signature Warning: File has no DFU suffix bytes_per_hash=6280 Copying data from PC to DFU device Starting download: [##] finished! Sent a total of 314004 bytes state(2) = dfuIDLE, status(0) = No error condition is present Done! Ok, so it seems to work (CRC is correct, system boots). The reason of the turmoil from my side was the VERY OLD version of dfu-utils, which I've used for testing. I will thoroughly test this and let you know about the result. The only thing, which I see as a problem (in this patch series) is: + +#ifdef CONFIG_DFU_FUNCTION + /* DFU is mighty weird */ + case DFU_DT_FUNC: at ./gadget/composite.c It is weird. Wireshark for example decodes this as an HID class transfer, which is certainly not. I don't know the exact details of the DFU protocol, but it is possible that they didn't bother obtaining a real ID from the usb forum. Since I now know how to reproduce/test the problem I will try to remove this #ifdef. After all this I have a huge moral hangover. No harm done. There is no such thing as a polite _and_ good engineer. You always have to choose, and IMHO
Re: [U-Boot] [PATCH 9/9] dfu: Support larger than memory transfers.
Hi Kasim, On Jan 3, 2013, at 10:30 AM, kasim ling wrote: Hi, Pantelis, A little confusion about FAT fs write supporting, On Sat, Dec 1, 2012 at 12:51 AM, Pantelis Antoniou pa...@antoniou-consulting.com wrote: We didn't support upload/download larger than available memory. This is pretty bad when you have to update your root filesystem for example. This patch removes the limitation (and the crashes when you transfered any file larger than 4MB). On top of that reduces the huge dfu buffer from 4MB to just 64K, which was over the top. The sequence number is a 16 bit counter; make sure we handle rollover correctly. This fixes the wrong transfers for large ( 256MB) images. Also utilize a variable to handle initialization, so that we don't rely on just the counter sent by the host. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/dfu/dfu.c | 244 +++--- drivers/dfu/dfu_mmc.c | 82 +++-- include/dfu.h | 21 - 3 files changed, 264 insertions(+), 83 deletions(-) diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 083d745..29a2c2e 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -22,6 +22,7 @@ #include common.h #include malloc.h #include errno.h +#include div64.h #include dfu.h enum dfu_mmc_op { @@ -30,35 +31,48 @@ enum dfu_mmc_op { }; static int mmc_block_op(enum dfu_mmc_op op, struct dfu_entity *dfu, - void *buf, long *len) + u64 offset, void *buf, long *len) { char cmd_buf[DFU_CMD_BUF_SIZE]; + u32 blk_start, blk_count; - sprintf(cmd_buf, mmc %s 0x%x %x %x, - op == DFU_OP_READ ? read : write, - (unsigned int) buf, - dfu-data.mmc.lba_start, - dfu-data.mmc.lba_size); - - if (op == DFU_OP_READ) + /* if buf == NULL return total size of the area */ + if (buf == NULL) { *len = dfu-data.mmc.lba_blk_size * dfu-data.mmc.lba_size; + return 0; + } + + blk_start = dfu-data.mmc.lba_start + + (u32)lldiv(offset, dfu-data.mmc.lba_blk_size); + blk_count = *len / dfu-data.mmc.lba_blk_size; + if (blk_start + blk_count + dfu-data.mmc.lba_start + dfu-data.mmc.lba_size) { + debug(%s: block_op out of bounds\n, __func__); + return -1; + } + + sprintf(cmd_buf, mmc %s %p %x %x, + op == DFU_OP_READ ? read : write, +buf, blk_start, blk_count); debug(%s: %s 0x%p\n, __func__, cmd_buf, cmd_buf); return run_command(cmd_buf, 0); } -static inline int mmc_block_write(struct dfu_entity *dfu, void *buf, long *len) +static inline int mmc_block_write(struct dfu_entity *dfu, + u64 offset, void *buf, long *len) { - return mmc_block_op(DFU_OP_WRITE, dfu, buf, len); + return mmc_block_op(DFU_OP_WRITE, dfu, offset, buf, len); } -static inline int mmc_block_read(struct dfu_entity *dfu, void *buf, long *len) +static inline int mmc_block_read(struct dfu_entity *dfu, + u64 offset, void *buf, long *len) { - return mmc_block_op(DFU_OP_READ, dfu, buf, len); + return mmc_block_op(DFU_OP_READ, dfu, offset, buf, len); } static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu, - void *buf, long *len) + u64 offset, void *buf, long *len) { char cmd_buf[DFU_CMD_BUF_SIZE]; char *str_env; @@ -66,12 +80,17 @@ static int mmc_file_op(enum dfu_mmc_op op, struct dfu_entity *dfu, switch (dfu-layout) { case DFU_FS_FAT: - sprintf(cmd_buf, fat%s mmc %d:%d 0x%x %s %lx, + sprintf(cmd_buf, fat%s mmc %d:%d 0x%x %s %lx %llx, op == DFU_OP_READ ? load : write, dfu-data.mmc.dev, dfu-data.mmc.part, - (unsigned int) buf, dfu-name, *len); + (unsigned int) buf, dfu-name, *len, offset); Did you tested it on FAT partitions? According to do_fat_fswrite() defined in common/cmd_fat.c, the fatwrite command does not support offset argument. No I haven't had a use case either for fat or ext2/3/4. So I guess it is as broken as it was before. If you want to write to a file, make sure it's smaller than the DFU buffer. One of these days the file access functions must be fixed. Thanks, Alex Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3 V3] esdhc: Workaround for card can't be detected on T4240QDS
Hi Haijun, On Jan 10, 2014, at 7:52 AM, Haijun Zhang wrote: Card detection pin is ineffective on T4240QDS Rev1.0. There are two cards can be connected to board. 1. eMMC card is built-in board, can not be removed. so For eMMC card it is always there. 2. Card detecting pin is functional for SDHC card in Rev2.0. This workaround force sdhc driver scan and initialize the card regardless of whether the card is inserted or not in case Rev1.0. Signed-off-by: Haijun Zhang haijun.zh...@freescale.com --- changes for V3: - Define quirk in board specific file instead of code in driver changes for V2: - Add the judgement condition for this broken card drivers/mmc/fsl_esdhc.c| 4 include/configs/T4240QDS.h | 5 + 2 files changed, 9 insertions(+) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index e522a70..2ee93cd 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -548,6 +548,10 @@ static int esdhc_getcd(struct mmc *mmc) struct fsl_esdhc *regs = (struct fsl_esdhc *)cfg-esdhc_base; int timeout = 1000; +#ifdef CONFIG_ESDHC_DETECT_QUIRK + if (CONFIG_ESDHC_DETECT_QUIRK) + return 1; +#endif while (!(esdhc_read32(regs-prsstat) PRSSTAT_CINS) --timeout) udelay(1000); diff --git a/include/configs/T4240QDS.h b/include/configs/T4240QDS.h index c96df54..0e0b346 100644 --- a/include/configs/T4240QDS.h +++ b/include/configs/T4240QDS.h @@ -165,6 +165,8 @@ unsigned long get_board_ddr_clk(void); #define QIXIS_RCFG_CTL_RECONFIG_IDLE 0x20 #define QIXIS_RCFG_CTL_RECONFIG_START 0x21 #define QIXIS_RCFG_CTL_WATCHDOG_ENBLE 0x08 +#define QIXIS_BRDCFG50x55 +#define QIXIS_MUX_SDHC 2 #define QIXIS_BASE_PHYS (0xfull | QIXIS_BASE) #define CONFIG_SYS_CSPR3_EXT (0xf) @@ -466,6 +468,9 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_CMD_FAT #define CONFIG_DOS_PARTITION #define CONFIG_SYS_FSL_MMC_HAS_CAPBLT_VS33 +#define CONFIG_ESDHC_DETECT_QUIRK \ + (!(readb(QIXIS_BASE + QIXIS_BRDCFG5) QIXIS_MUX_SDHC) || \ + IS_SVR_REV(get_svr(), 1, 0)) #endif #define CONFIG_BOOTDELAY 10 /* -1 disables auto-boot */ -- 1.8.4.1 Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/3 V3] esdhc: Detecting 8 bit width before mmc initialization
Hi Haijun, On Jan 10, 2014, at 7:52 AM, Haijun Zhang wrote: The upper 4 data signals of esdhc are shared with spi flash. So detect if the upper 4 pins are assigned to esdhc before enable sdhc 8 bit width. Signed-off-by: Haijun Zhang haijun.zh...@freescale.com --- changes for V3: - Define quirk in board specific file instead of code in driver changes for V2: - No changes drivers/mmc/fsl_esdhc.c| 5 + include/configs/T4240QDS.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 2ee93cd..72ca109 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -644,6 +644,11 @@ int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg) if (caps ESDHC_HOSTCAPBLT_HSS) mmc-host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS; +#ifdef CONFIG_ESDHC_DETECT_8_BIT_QUIRK + if (CONFIG_ESDHC_DETECT_8_BIT_QUIRK) + mmc-host_caps = ~MMC_MODE_8BIT; +#endif + mmc-f_min = 40; mmc-f_max = MIN(gd-arch.sdhc_clk, 5200); diff --git a/include/configs/T4240QDS.h b/include/configs/T4240QDS.h index 0e0b346..275a7a8 100644 --- a/include/configs/T4240QDS.h +++ b/include/configs/T4240QDS.h @@ -167,6 +167,7 @@ unsigned long get_board_ddr_clk(void); #define QIXIS_RCFG_CTL_WATCHDOG_ENBLE 0x08 #define QIXIS_BRDCFG5 0x55 #define QIXIS_MUX_SDHC2 +#define QIXIS_MUX_SDHC_WIDTH81 #define QIXIS_BASE_PHYS (0xfull | QIXIS_BASE) #define CONFIG_SYS_CSPR3_EXT (0xf) @@ -471,6 +472,8 @@ unsigned long get_board_ddr_clk(void); #define CONFIG_ESDHC_DETECT_QUIRK \ (!(readb(QIXIS_BASE + QIXIS_BRDCFG5) QIXIS_MUX_SDHC) || \ IS_SVR_REV(get_svr(), 1, 0)) +#define CONFIG_ESDHC_DETECT_8_BIT_QUIRK \ + (!(readb(QIXIS_BASE + QIXIS_BRDCFG5) QIXIS_MUX_SDHC_WIDTH8)) #endif #define CONFIG_BOOTDELAY 10 /* -1 disables auto-boot */ -- 1.8.4.1 Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/3 V3] eSDHC: Calculate envaddr accroding to the address format
Hi Haijun, On Jan 10, 2014, at 7:52 AM, Haijun Zhang wrote: On BSC9131, BSC9132, P1010 : For High Capacity SD Cards ( 2 GBytes), the 32-bit source address specifies the memory address in block address format. Block length is fixed to 512 bytes as per the SD High Capacity specification. So we need to convert the block address format to byte address format to calculate the envaddr. If there is no enough space for environment variables or envaddr is larger than 4GiB, we relocate the envaddr to 0x400. The address relocated is in the front of the first partition that is assigned for sdboot only. Signed-off-by: Haijun Zhang haijun.zh...@freescale.com --- changes for V3: - Define quirk in SOC specific file instead of code in driver changes for V2: - Use 0xu instead of UINT_MAX arch/powerpc/include/asm/config_mpc85xx.h | 3 +++ board/freescale/common/sdhc_boot.c| 29 + 2 files changed, 32 insertions(+) diff --git a/arch/powerpc/include/asm/config_mpc85xx.h b/arch/powerpc/include/asm/config_mpc85xx.h index 15affdc..e8bd76a 100644 --- a/arch/powerpc/include/asm/config_mpc85xx.h +++ b/arch/powerpc/include/asm/config_mpc85xx.h @@ -152,6 +152,7 @@ #define CONFIG_SYS_FSL_ERRATUM_A005125 #define CONFIG_SYS_FSL_ERRATUM_I2C_A004447 #define CONFIG_SYS_FSL_A004447_SVR_REV0x10 +#define CONFIG_ESDHC_HC_BLK_ADDR /* P1011 is single core version of P1020 */ #elif defined(CONFIG_P1011) @@ -552,6 +553,7 @@ #define CONFIG_NAND_FSL_IFC #define CONFIG_SYS_FSL_ERRATUM_ESDHC111 #define CONFIG_SYS_FSL_ERRATUM_A005125 +#define CONFIG_ESDHC_HC_BLK_ADDR #elif defined(CONFIG_BSC9132) #define CONFIG_MAX_CPUS 2 @@ -575,6 +577,7 @@ #define CONFIG_SYS_FSL_ERRATUM_A005125 #define CONFIG_SYS_FSL_ERRATUM_I2C_A004447 #define CONFIG_SYS_FSL_A004447_SVR_REV0x11 +#define CONFIG_ESDHC_HC_BLK_ADDR #elif defined(CONFIG_PPC_T4240) || defined(CONFIG_PPC_T4160) #define CONFIG_E6500 diff --git a/board/freescale/common/sdhc_boot.c b/board/freescale/common/sdhc_boot.c index f6e2b2b..022f38b 100644 --- a/board/freescale/common/sdhc_boot.c +++ b/board/freescale/common/sdhc_boot.c @@ -16,6 +16,8 @@ #define ESDHC_BOOT_IMAGE_SIZE 0x48 #define ESDHC_BOOT_IMAGE_ADDR 0x50 +#define ESDHC_DEFAULT_ENVADDR0x400 + int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) { u8 *tmp_buf; @@ -39,6 +41,33 @@ int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr) /* Get the code size from offset 0x48 */ code_len = *(u32 *)(tmp_buf + ESDHC_BOOT_IMAGE_SIZE); +#ifdef CONFIG_ESDHC_HC_BLK_ADDR + /* + * On soc BSC9131, BSC9132: + * In High Capacity SD Cards ( 2 GBytes), the 32-bit source address and + * code length of these soc specify the memory address in block address + * format. Block length is fixed to 512 bytes as per the SD High + * Capacity specification. + */ + u64 tmp; + + if (mmc-high_capacity) { + tmp = (u64)code_offset * blklen; + tmp += code_len * blklen; + } else + tmp = code_offset + code_len; + + if ((tmp + CONFIG_ENV_SIZE mmc-capacity) || + (tmp 0xU)) + *env_addr = ESDHC_DEFAULT_ENVADDR; + else + *env_addr = tmp; + + free(tmp_buf); + + return 0; +#endif + *env_addr = code_offset + code_len; free(tmp_buf); -- 1.8.4.1 Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3 V3] esdhc: Workaround for card can't be detected on T4240QDS
Hi York, On Jan 22, 2014, at 12:01 AM, York Sun wrote: Pantelis, On 01/09/2014 09:52 PM, Haijun Zhang wrote: Card detection pin is ineffective on T4240QDS Rev1.0. There are two cards can be connected to board. 1. eMMC card is built-in board, can not be removed. so For eMMC card it is always there. 2. Card detecting pin is functional for SDHC card in Rev2.0. This workaround force sdhc driver scan and initialize the card regardless of whether the card is inserted or not in case Rev1.0. Signed-off-by: Haijun Zhang haijun.zh...@freescale.com --- changes for V3: - Define quirk in board specific file instead of code in driver changes for V2: - Add the judgement condition for this broken card I think this set of patches are in your backyard. If you ack them, I can apply them to mpc85xx. Go ahead please. http://patchwork.ozlabs.org/patch/309168/ http://patchwork.ozlabs.org/patch/309167/ http://patchwork.ozlabs.org/patch/309170/ York Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V2 01/13] mmc: tegra: support Tegra124
Hi Stephen, Looks fine to me.. On Jan 24, 2014, at 2:42 AM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com Tegra124's MMC controller is very similar to earlier SoC generations, and can be supported by the same driver. However, there are some non-backwards-compatible HW differences, and hence a new DT compatible value must be used to describe the HW. This patch updates the driver to support that new compatible value. That said, the HW differences are only relevant when enabling certain high-performance transfer modes. Since the driver is currently very simple and doesn't enable those modes, we don't actually need to address any of these HW differences in the code yet, hence the simple nature of this patch. Cc: Pantelis Antoniou pa...@antoniou-consulting.com Signed-off-by: Stephen Warren swar...@nvidia.com --- v2: New patch. This patch is needed for MMC support on Tegra124 at run-time, but not strictly required at compile-time. So, it can either go into the MMC tree and all get merged together in the main U-Boot repo, or the MMC maintainer can ack it to go through the Tegra tree with the rest of the changes. --- drivers/mmc/tegra_mmc.c | 9 + include/fdtdec.h| 1 + lib/fdtdec.c| 1 + 3 files changed, 11 insertions(+) diff --git a/drivers/mmc/tegra_mmc.c b/drivers/mmc/tegra_mmc.c index e1817e24f6d4..3d1ce1263c82 100644 --- a/drivers/mmc/tegra_mmc.c +++ b/drivers/mmc/tegra_mmc.c @@ -668,6 +668,15 @@ void tegra_mmc_init(void) const void *blob = gd-fdt_blob; debug(%s entry\n, __func__); + /* See if any Tegra124 MMC controllers are present */ + count = fdtdec_find_aliases_for_id(blob, sdhci, + COMPAT_NVIDIA_TEGRA124_SDMMC, node_list, MAX_HOSTS); + debug(%s: count of Tegra124 sdhci nodes is %d\n, __func__, count); + if (process_nodes(blob, node_list, count)) { + printf(%s: Error processing T30 mmc node(s)!\n, __func__); + return; + } + /* See if any Tegra30 MMC controllers are present */ count = fdtdec_find_aliases_for_id(blob, sdhci, COMPAT_NVIDIA_TEGRA30_SDMMC, node_list, MAX_HOSTS); diff --git a/include/fdtdec.h b/include/fdtdec.h index 433d6a7c0256..19bab7944817 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -59,6 +59,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_NVIDIA_TEGRA124_SDMMC, /* Tegra124 SDMMC controller */ COMPAT_NVIDIA_TEGRA30_SDMMC,/* Tegra30 SDMMC controller */ COMPAT_NVIDIA_TEGRA20_SDMMC,/* Tegra20 SDMMC controller */ COMPAT_NVIDIA_TEGRA20_SFLASH, /* Tegra 2 SPI flash controller */ diff --git a/lib/fdtdec.c b/lib/fdtdec.c index 207314fa72fb..1fecab3fbc30 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -32,6 +32,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(NVIDIA_TEGRA124_SDMMC, nvidia,tegra124-sdhci), COMPAT(NVIDIA_TEGRA30_SDMMC, nvidia,tegra30-sdhci), COMPAT(NVIDIA_TEGRA20_SDMMC, nvidia,tegra20-sdhci), COMPAT(NVIDIA_TEGRA20_SFLASH, nvidia,tegra20-sflash), -- 1.8.1.5 Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] fsl_esdhc: Add Auto command 12 interrupt bit detecting
Sorry, just had a baby and things are a bit busy. It's not fallen into the bit-bucket if that's what you're worried about. Regards -- Pantelis On Jan 29, 2014, at 11:14 PM, York Sun wrote: On 11/01/2013 12:47 AM, Zhang Haijun wrote: :-) Thanks. 于 2013/11/1 15:45, Pantelis Antoniou 写道: Hi Zhang, I'll take a look at it over the weekend. Regards -- Pantelis Where are we on this patch? York ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: set rca to 1 for MMC cards
Looks good. On Jan 31, 2014, at 1:11 AM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com U-Boot currently sets MMC cards' RCA register to 0. This value is reserved according to the specification. Use a value of 1 instead, just like the Linux kernel. Signed-off-by: Stephen Warren swar...@nvidia.com --- drivers/mmc/mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c6a1c23fbf1c..7efc2bedbe11 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -430,7 +430,7 @@ int mmc_complete_op_cond(struct mmc *mmc) mmc-ocr = cmd.response[0]; mmc-high_capacity = ((mmc-ocr OCR_HCS) == OCR_HCS); - mmc-rca = 0; + mmc-rca = 1; return 0; } -- 1.8.1.5 Applied, Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH RESEND] MMC: DWMMC: Correct the CLKDIV register value
Hi Rajesh, Sorry for the delay, patch looks good. On Feb 5, 2014, at 7:18 AM, Rajeshwari Shinde wrote: From: Rajeshwari S Shinde rajeshwar...@samsung.com This patch corrects the divider value written to CLKDIV register. Since SDCLKIN is divided inside controller by the DIVRATIO value set in the CLKSEL register, we need to use the same output clock value to calculate the CLKDIV value. as per user manual: cclk_in = SDCLKIN / (DIVRATIO + 1) Input parameter to mmc_clk is changed to dwmci_host, since we need the same to read DWMCI_CLKSEL register. This improves the read timing values for channel 0 on SMDK5250 from 0.288sec to 0.144sec Signed-off-by: Rajeshwari S Shinde rajeshwar...@samsung.com --- arch/arm/include/asm/arch-exynos/dwmmc.h | 4 drivers/mmc/dw_mmc.c | 2 +- drivers/mmc/exynos_dw_mmc.c | 17 +++-- include/dwmmc.h | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/arch-exynos/dwmmc.h b/arch/arm/include/asm/arch-exynos/dwmmc.h index 09d739d..a7ca12c 100644 --- a/arch/arm/include/asm/arch-exynos/dwmmc.h +++ b/arch/arm/include/asm/arch-exynos/dwmmc.h @@ -23,6 +23,10 @@ #define MPSCTRL_ENCRYPTION(0x11) #define MPSCTRL_VALID (0x10) +/* CLKSEL Register */ +#define DWMCI_DIVRATIO_BIT 24 +#define DWMCI_DIVRATIO_MASK 0x7 + #ifdef CONFIG_OF_CONTROL int exynos_dwmmc_init(const void *blob); #endif diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 4cec5aa..d45c15c 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -237,7 +237,7 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq) * host-bus_hz should be set from user. */ if (host-get_mmc_clk) - sclk = host-get_mmc_clk(host-dev_index); + sclk = host-get_mmc_clk(host); else if (host-bus_hz) sclk = host-bus_hz; else { diff --git a/drivers/mmc/exynos_dw_mmc.c b/drivers/mmc/exynos_dw_mmc.c index b3e5c5e..de8cdcc 100644 --- a/drivers/mmc/exynos_dw_mmc.c +++ b/drivers/mmc/exynos_dw_mmc.c @@ -29,9 +29,22 @@ static void exynos_dwmci_clksel(struct dwmci_host *host) dwmci_writel(host, DWMCI_CLKSEL, host-clksel_val); } -unsigned int exynos_dwmci_get_clk(int dev_index) +unsigned int exynos_dwmci_get_clk(struct dwmci_host *host) { - return get_mmc_clk(dev_index); + unsigned long sclk; + int8_t clk_div; + + /* + * Since SDCLKIN is divided inside controller by the DIVRATIO + * value set in the CLKSEL register, we need to use the same output + * clock value to calculate the CLKDIV value. + * as per user manual:cclk_in = SDCLKIN / (DIVRATIO + 1) + */ + clk_div = ((dwmci_readl(host, DWMCI_CLKSEL) DWMCI_DIVRATIO_BIT) + DWMCI_DIVRATIO_MASK) + 1; + sclk = get_mmc_clk(host-dev_index); + + return sclk / clk_div; } static void exynos_dwmci_board_init(struct dwmci_host *host) diff --git a/include/dwmmc.h b/include/dwmmc.h index a02dd67..b641558 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -142,7 +142,7 @@ struct dwmci_host { void (*clksel)(struct dwmci_host *host); void (*board_init)(struct dwmci_host *host); - unsigned int (*get_mmc_clk)(int dev_index); + unsigned int (*get_mmc_clk)(struct dwmci_host *host); }; struct dwmci_idmac { -- 1.7.12.4 Applied, Thanks Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: Enabled quirk SDHCI_QUIRK_BROKEN_R1B
Hi Michal, On Jan 22, 2014, at 10:17 AM, Michal Simek wrote: From: Siva Durga Prasad Paladugu siva.durga.palad...@xilinx.com As per the below commit mmc: sdhci: add the quirk for broken r1b response (sha1: 3a6383207be3f71b39004e64464a6e99290b16fa) need to add quirk SDHCI_QUIRK_BROKEN_R1B, when the response type is R1b. Signed-off-by: Siva Durga Prasad Paladugu siva...@xilinx.com Signed-off-by: Michal Simek michal.si...@xilinx.com Acked-by: Jagannadha Sutradharudu Teki jaga...@xilinx.com --- drivers/mmc/zynq_sdhci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index 610bef5..72a272f 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -23,7 +23,8 @@ int zynq_sdhci_init(u32 regbase) host-name = zynq_sdhci; host-ioaddr = (void *)regbase; - host-quirks = SDHCI_QUIRK_NO_CD | SDHCI_QUIRK_WAIT_SEND_CMD; + host-quirks = SDHCI_QUIRK_NO_CD | SDHCI_QUIRK_WAIT_SEND_CMD | +SDHCI_QUIRK_BROKEN_R1B; host-version = sdhci_readw(host, SDHCI_HOST_VERSION); host-host_caps = MMC_MODE_HC; -- 1.8.2.3 Applied, Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/8] SPL: Add CONFIG_SUPPORT_EMMC_BOOT support to CONFIG_SPL_FRAMEWORK
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: We use the switch CONFIG_SUPPORT_EMMC_BOOT today to enable some additional features of the eMMC boot partitions. Add support for being told that we have booted from one of these partitions to the spl framework and implement this on TI OMAP/related. Cc: Pantelis Antoniou pa...@antoniou-consulting.com Signed-off-by: Tom Rini tr...@ti.com --- Changes in v3: - Rework eMMC boot detect logic for TI platforms, in the eMMC boot case we rely on non-FAT/RAW values being in bootmode. --- arch/arm/cpu/armv7/omap-common/boot-common.c | 13 - common/spl/spl_mmc.c | 24 include/spl.h|1 + 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/arch/arm/cpu/armv7/omap-common/boot-common.c b/arch/arm/cpu/armv7/omap-common/boot-common.c index 69fff32..52e0f4a 100644 --- a/arch/arm/cpu/armv7/omap-common/boot-common.c +++ b/arch/arm/cpu/armv7/omap-common/boot-common.c @@ -66,7 +66,18 @@ u32 spl_boot_device(void) u32 spl_boot_mode(void) { - return gd-arch.omap_boot_params.omap_bootmode; + u32 val = gd-arch.omap_boot_params.omap_bootmode; + + if (val == MMCSD_MODE_RAW) + return MMCSD_MODE_RAW; + else if (val == MMCSD_MODE_FAT) + return MMCSD_MODE_FAT; + else +#ifdef CONFIG_SUPPORT_EMMC_BOOT + return MMCSD_MODE_EMMCBOOT; +#else + return MMCSD_MODE_UNDEFINED; +#endif } void spl_board_init(void) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 13fbff0..fa6f891 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -111,6 +111,30 @@ void spl_mmc_load_image(void) CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION, CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME); #endif +#ifdef CONFIG_SUPPORT_EMMC_BOOT + } else if (boot_mode == MMCSD_MODE_EMMCBOOT) { + /* + * We need to check what the partition is configured to. + * 1 and 2 match up to boot0 / boot1 and 7 is user data + * which is the first physical partition (0). + */ + int part = (mmc-part_config 3) PART_ACCESS_MASK; + + if (part == 7) + part = 0; + + if (mmc_switch_part(0, part)) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + puts(MMC partition switch failed\n); +#endif + hang(); + } +#ifdef CONFIG_SPL_OS_BOOT + if (spl_start_uboot() || mmc_load_image_raw_os(mmc)) +#endif + err = mmc_load_image_raw(mmc, + CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR); +#endif } else { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts(spl: wrong MMC boot mode\n); diff --git a/include/spl.h b/include/spl.h index 5e24856..dad00c0 100644 --- a/include/spl.h +++ b/include/spl.h @@ -16,6 +16,7 @@ #define MMCSD_MODE_UNDEFINED 0 #define MMCSD_MODE_RAW1 #define MMCSD_MODE_FAT2 +#define MMCSD_MODE_EMMCBOOT 3 struct spl_image_info { const char *name; -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 5/8] cmd_mmc.c: Add bootbus mmc sub-command
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: Add a bootbus sub-command to the mmc command to allow for setting the boot_bus_width, reset_boot_bus_width and boot_mode fields of BOOT_BUS_WIDTH (EXT_CSD[177]). Acked-by: Jaehoon Chung jh80.ch...@samsung.com Signed-off-by: Tom Rini tr...@ti.com --- common/cmd_mmc.c | 29 + drivers/mmc/mmc.c | 21 + include/mmc.h |5 + 3 files changed, 55 insertions(+) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 5842e85..a028149 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -338,6 +338,33 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* acknowledge to be sent during boot operation */ return mmc_set_part_conf(mmc, ack, part_num, access); + } else if (strcmp(argv[1], bootbus) == 0) { + int dev; + struct mmc *mmc; + u8 width, reset, mode; + + if (argc == 6) { + dev = simple_strtoul(argv[2], NULL, 10); + width = simple_strtoul(argv[3], NULL, 10); + reset = simple_strtoul(argv[4], NULL, 10); + mode = simple_strtoul(argv[5], NULL, 10); + } else { + return CMD_RET_USAGE; + } + + mmc = find_mmc_device(dev); + if (!mmc) { + printf(no mmc device at slot %x\n, dev); + return 1; + } + + if (IS_SD(mmc)) { + puts(BOOT_BUS_WIDTH only exists on eMMC\n); + return 1; + } + + /* acknowledge to be sent during boot operation */ + return mmc_set_boot_bus_width(mmc, width, reset, mode); } else if (strcmp(argv[1], bootpart-resize) == 0) { int dev; struct mmc *mmc; @@ -475,6 +502,8 @@ U_BOOT_CMD( - Enable boot_part for booting and enable R/W access of boot_part\n mmc close dev boot_partition\n - Enable boot_part for booting and disable access to boot_part\n + mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n + - Set the BOOT_BUS_WIDTH field of the specified device\n mmc bootpart-resize dev boot part size MB RPMB part size MB\n - Change sizes of boot and RPMB partitions of specified device\n mmc partconf dev boot_ack boot_partition partition_access\n diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 1591fce..fc1c1dc 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1507,6 +1507,27 @@ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access) } /* + * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH + * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH + * and BOOT_MODE. + * + * Returns 0 on success. + */ +int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode) +{ + int err; + + err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_BUS_WIDTH, + EXT_CSD_BOOT_BUS_WIDTH_MODE(mode) | + EXT_CSD_BOOT_BUS_WIDTH_RESET(reset) | + EXT_CSD_BOOT_BUS_WIDTH_WIDTH(width)); + + if (err) + return err; + return 0; +} + +/* * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG) * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and * PARTITION_ACCESS. diff --git a/include/mmc.h b/include/mmc.h index 7e026da..3594286 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -187,6 +187,9 @@ #define EXT_CSD_BOOT_PART_NUM(x) (x 3) #define EXT_CSD_PARTITION_ACCESS(x) (x 0) +#define EXT_CSD_BOOT_BUS_WIDTH_MODE(x) (x 3) +#define EXT_CSD_BOOT_BUS_WIDTH_RESET(x) (x 2) +#define EXT_CSD_BOOT_BUS_WIDTH_WIDTH(x) (x) #define R1_ILLEGAL_COMMAND(1 22) #define R1_APP_CMD(1 5) @@ -314,6 +317,8 @@ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize, int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access); /* Function to modify the PARTITION_CONFIG field of EXT_CSD */ int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access); +/* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */ +int mmc_set_boot_bus_width(struct mmc *mmc, u8 width, u8 reset, u8 mode); /** * Start device initialization and return immediately; it does not block on -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 4/8] cmd_mmc.c: Add 'partconf' command to mmc
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: Add a partconf sub-command to the mmc command to allow for setting the boot_ack, boot_partition and partition_access fields of PARTITION_CONFIG (formerly BOOT_CONFIG, EXT_CSD[179]). Part of this requires changing the check for 'part' from an strncmp to a strcmp, like the rest of the sub-commands. Cc: Andy Fleming aflem...@gmail.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com Acked-by: Jaehoon Chung jh80.ch...@samsung.com Signed-off-by: Tom Rini tr...@ti.com --- common/cmd_mmc.c | 30 +- drivers/mmc/mmc.c | 21 + include/mmc.h |2 ++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index a322063..5842e85 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -195,7 +195,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 1; else return 0; - } else if (strncmp(argv[1], part, 4) == 0) { + } else if (strcmp(argv[1], part) == 0) { block_dev_desc_t *mmc_dev; struct mmc *mmc; @@ -311,7 +311,33 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* acknowledge to be sent during boot operation */ return boot_part_access(mmc, 1, part_num, access); + } else if (strcmp(argv[1], partconf) == 0) { + int dev; + struct mmc *mmc; + u8 ack, part_num, access; + + if (argc == 6) { + dev = simple_strtoul(argv[2], NULL, 10); + ack = simple_strtoul(argv[3], NULL, 10); + part_num = simple_strtoul(argv[4], NULL, 10); + access = simple_strtoul(argv[5], NULL, 10); + } else { + return CMD_RET_USAGE; + } + + mmc = find_mmc_device(dev); + if (!mmc) { + printf(no mmc device at slot %x\n, dev); + return 1; + } + if (IS_SD(mmc)) { + puts(PARTITION_CONFIG only exists on eMMC\n); + return 1; + } + + /* acknowledge to be sent during boot operation */ + return mmc_set_part_conf(mmc, ack, part_num, access); } else if (strcmp(argv[1], bootpart-resize) == 0) { int dev; struct mmc *mmc; @@ -451,6 +477,8 @@ U_BOOT_CMD( - Enable boot_part for booting and disable access to boot_part\n mmc bootpart-resize dev boot part size MB RPMB part size MB\n - Change sizes of boot and RPMB partitions of specified device\n + mmc partconf dev boot_ack boot_partition partition_access\n + - Change the bits of the PARTITION_CONFIG field of the specified device\n #endif mmc setdsr - set DSR register value\n ); diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index c6a1c23..1591fce 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1505,4 +1505,25 @@ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access) } return 0; } + +/* + * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG) + * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and + * PARTITION_ACCESS. + * + * Returns 0 on success. + */ +int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access) +{ + int err; + + err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF, + EXT_CSD_BOOT_ACK(ack) | + EXT_CSD_BOOT_PART_NUM(part_num) | + EXT_CSD_PARTITION_ACCESS(access)); + + if (err) + return err; + return 0; +} #endif diff --git a/include/mmc.h b/include/mmc.h index e1060b9..7e026da 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -312,6 +312,8 @@ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize, unsigned long rpmbsize); /* Function to send commands to open/close the specified boot partition */ int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access); +/* Function to modify the PARTITION_CONFIG field of EXT_CSD */ +int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access); /** * Start device initialization and return immediately; it does not block on -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 3/8] cmd_mmc.c: Rename 'bootpart' to 'bootpart-resize'
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: Rename 'bootpart' to 'bootpart-resize' to better reflect what this command is for. Acked-by: Jaehoon Chung jh80.ch...@samsung.com Signed-off-by: Tom Rini tr...@ti.com --- common/cmd_mmc.c |8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index e118252..a322063 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -312,9 +312,9 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /* acknowledge to be sent during boot operation */ return boot_part_access(mmc, 1, part_num, access); - } else if (strcmp(argv[1], bootpart) == 0) { + } else if (strcmp(argv[1], bootpart-resize) == 0) { int dev; - struct *mmc; + struct mmc *mmc; u32 bootsize, rpmbsize; if (argc == 5) { @@ -449,8 +449,8 @@ U_BOOT_CMD( - Enable boot_part for booting and enable R/W access of boot_part\n mmc close dev boot_partition\n - Enable boot_part for booting and disable access to boot_part\n - mmc bootpart device num boot part size MB RPMB part size MB\n - - change sizes of boot and RPMB partitions of specified device\n + mmc bootpart-resize dev boot part size MB RPMB part size MB\n + - Change sizes of boot and RPMB partitions of specified device\n #endif mmc setdsr - set DSR register value\n ); -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 8/8] dra7xx_evm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: Add a README to the board which lists the commands required to enable booting from the eMMC boot partitions found on the board. Cc: Lokesh Vutla lokeshvu...@ti.com Signed-off-by: Tom Rini tr...@ti.com --- board/ti/dra7xx/README | 25 + include/configs/dra7xx_evm.h |2 ++ 2 files changed, 27 insertions(+) create mode 100644 board/ti/dra7xx/README diff --git a/board/ti/dra7xx/README b/board/ti/dra7xx/README new file mode 100644 index 000..2fdaeac --- /dev/null +++ b/board/ti/dra7xx/README @@ -0,0 +1,25 @@ +Summary +=== + +This document covers various features of the 'dra7xx_evm' build and some +related uses. + +eMMC boot partition use +=== + +It is possible, depending on SYSBOOT configuration to boot from the eMMC +boot partitions using (name depending on documentation referenced) +Alternative Boot operation mode or Boot Sequence Option 1/2. In this +example we load MLO and u-boot.img from the build into DDR and then use +'mmc bootbus' to set the required rate (see TRM) and 'mmc partconfig' to +set boot0 as the boot device. +U-Boot # setenv autoload no +U-Boot # usb start +U-Boot # dhcp +U-Boot # mmc dev 1 1 +U-Boot # tftp ${loadaddr} dra7xx/MLO +U-Boot # mmc write ${loadaddr} 0 100 +U-Boot # tftp ${loadaddr} dra7xx/u-boot.img +U-Boot # mmc write ${loadaddr} 300 400 +U-Boot # mmc bootbus 1 2 0 2 +U-Boot # mmc partconf 1 1 1 0 diff --git a/include/configs/dra7xx_evm.h b/include/configs/dra7xx_evm.h index f210ed8..3c53f0a 100644 --- a/include/configs/dra7xx_evm.h +++ b/include/configs/dra7xx_evm.h @@ -73,6 +73,8 @@ #define CONFIG_SPL_SPI_CS 0 #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x2 +#define CONFIG_SUPPORT_EMMC_BOOT + /* USB xHCI HOST */ #define CONFIG_CMD_USB #define CONFIG_USB_HOST -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 7/8] omap5_uevm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: Add a README to the board which lists the commands required to enable booting from the eMMC boot partitions found on the board. Signed-off-by: Tom Rini tr...@ti.com --- board/ti/omap5_uevm/README | 25 + include/configs/omap5_uevm.h |1 + 2 files changed, 26 insertions(+) create mode 100644 board/ti/omap5_uevm/README diff --git a/board/ti/omap5_uevm/README b/board/ti/omap5_uevm/README new file mode 100644 index 000..970e2ec --- /dev/null +++ b/board/ti/omap5_uevm/README @@ -0,0 +1,25 @@ +Summary +=== + +This document covers various features of the 'omap5_uevm' build and some +related uses. + +eMMC boot partition use +=== + +It is possible, depending on SYSBOOT configuration to boot from the eMMC +boot partitions using (name depending on documentation referenced) +Alternative Boot operation mode or Boot Sequence Option 1/2. In this +example we load MLO and u-boot.img from the build into DDR and then use +'mmc bootbus' to set the required rate (see TRM) and 'mmc partconfig' to +set boot0 as the boot device. +U-Boot # setenv autoload no +U-Boot # usb start +U-Boot # dhcp +U-Boot # mmc dev 1 1 +U-Boot # tftp ${loadaddr} omap5uevm/MLO +U-Boot # mmc write ${loadaddr} 0 100 +U-Boot # tftp ${loadaddr} omap5uevm/u-boot.img +U-Boot # mmc write ${loadaddr} 300 400 +U-Boot # mmc bootbus 1 2 0 2 +U-Boot # mmc partconf 1 1 1 0 diff --git a/include/configs/omap5_uevm.h b/include/configs/omap5_uevm.h index 76c5106..3df502e 100644 --- a/include/configs/omap5_uevm.h +++ b/include/configs/omap5_uevm.h @@ -37,6 +37,7 @@ #define CONFIG_PARTITION_UUIDS #define CONFIG_CMD_PART #define CONFIG_HSMMC2_8BIT +#define CONFIG_SUPPORT_EMMC_BOOT /* Required support for the TCA642X GPIO we have on the uEVM */ #define CONFIG_TCA642X -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 6/8] cmd_mmc.c: Drop open/close mmc sub-commands
) - * 0x1 - Boot partition 1 enabled for boot - * 0x2 - Boot partition 2 enabled for boot - * access: User selects partitions to access - * 0x0 : No access to boot partition (default) - * 0x1 : R/W boot partition 1 - * 0x2 : R/W boot partition 2 - * 0x3 : R/W Replay Protected Memory Block (RPMB) - * - * Returns 0 on success. - */ -int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access) -{ - int err; - struct mmc_cmd cmd; - - /* Boot ack enable, boot partition enable , boot partition access */ - cmd.cmdidx = MMC_CMD_SWITCH; - cmd.resp_type = MMC_RSP_R1b; - - cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE 24) | - (EXT_CSD_PART_CONF 16) | - ((EXT_CSD_BOOT_ACK(ack) | - EXT_CSD_BOOT_PART_NUM(part_num) | - EXT_CSD_PARTITION_ACCESS(access)) 8); - - err = mmc_send_cmd(mmc, cmd, NULL); - if (err) { - if (access) { - debug(mmc boot partition#%d open fail:Error1 = %d\n, - part_num, err); - } else { - debug(mmc boot partition#%d close fail:Error = %d\n, - part_num, err); - } - return err; - } - - if (access) { - /* 4bit transfer mode at booting time. */ - cmd.cmdidx = MMC_CMD_SWITCH; - cmd.resp_type = MMC_RSP_R1b; - - cmd.cmdarg = (MMC_SWITCH_MODE_WRITE_BYTE 24) | - (EXT_CSD_BOOT_BUS_WIDTH 16) | - ((1 0) 8); - - err = mmc_send_cmd(mmc, cmd, NULL); - if (err) { - debug(mmc boot partition#%d open fail:Error2 = %d\n, - part_num, err); - return err; - } - } - return 0; -} - -/* * Modify EXT_CSD[177] which is BOOT_BUS_WIDTH * based on the passed in values for BOOT_BUS_WIDTH, RESET_BOOT_BUS_WIDTH * and BOOT_MODE. diff --git a/include/mmc.h b/include/mmc.h index 3594286..e95a237 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -313,8 +313,6 @@ int mmc_set_dsr(struct mmc *mmc, u16 val); /* Function to change the size of boot partition and rpmb partitions */ int mmc_boot_partition_size_change(struct mmc *mmc, unsigned long bootsize, unsigned long rpmbsize); -/* Function to send commands to open/close the specified boot partition */ -int mmc_boot_part_access(struct mmc *mmc, u8 ack, u8 part_num, u8 access); /* Function to modify the PARTITION_CONFIG field of EXT_CSD */ int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access); /* Function to modify the BOOT_BUS_WIDTH field of EXT_CSD */ -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 1/2] env_mmc: make board configurable the partition for the environment
Hi Hector, On Jan 23, 2014, at 2:39 PM, Hector Palacios wrote: This complements commit 9404a5fc7cb58 env_mmc: allow environment to be in an eMMC partition by allowing boards to accommodate the partition to use for the environment in different scenarios (similarly to what is done with the mmc dev number). Depending on the detected boot media, boards may decide to store the environment in a different partition. The __weak function also allows to remove some ifdefs from the code. If CONFIG_SYS_MMC_ENV_PART is not defined, partition 0 is assumed (default value for U-Boot when a partition is not provided). Signed-off-by: Hector Palacios hector.palac...@digi.com Reviewed-by: Stephen Warren swar...@nvidia.com The patch does not apply cleanly after Tom's mmc patches went in. Can you please rework and report? Thanks. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 2/8] cmd_mmc.c: Change 'bootpart' code to match normal coding style
Hi Tom, On Feb 5, 2014, at 5:24 PM, Tom Rini wrote: Acked-by: Jaehoon Chung jh80.ch...@samsung.com Signed-off-by: Tom Rini tr...@ti.com --- common/cmd_mmc.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index da5fef9..e118252 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -314,11 +314,18 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else if (strcmp(argv[1], bootpart) == 0) { int dev; - dev = simple_strtoul(argv[2], NULL, 10); + struct *mmc; + u32 bootsize, rpmbsize; - u32 bootsize = simple_strtoul(argv[3], NULL, 10); - u32 rpmbsize = simple_strtoul(argv[4], NULL, 10); - struct mmc *mmc = find_mmc_device(dev); + if (argc == 5) { + dev = simple_strtoul(argv[2], NULL, 10); + bootsize = simple_strtoul(argv[3], NULL, 10); + rpmbsize = simple_strtoul(argv[4], NULL, 10); + } else { + return CMD_RET_USAGE; + } + + mmc = find_mmc_device(dev); if (!mmc) { printf(no mmc device at slot %x\n, dev); return 1; -- 1.7.9.5 Applied. Thanks. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Pull request: u-boot-mmc 07022014
Hi Tom, The following changes since commit dbf3de2dd26cae37d16b00b348828c883b658cc5: include/usb/s3c_udc.h: Add asm/sizes.h (2014-02-06 14:26:05 -0500) are available in the git repository at: git://git.denx.de/u-boot-mmc.git master for you to fetch changes up to b818d9ab8d96471c40ccbd4541a46dfa415eda73: dra7xx_evm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage (2014-02-07 18:17:49 +0200) Rajeshwari S Shinde (1): MMC: DWMMC: Correct the CLKDIV register value Siva Durga Prasad Paladugu (1): mmc: Enabled quirk SDHCI_QUIRK_BROKEN_R1B Stephen Warren (1): mmc: set rca to 1 for MMC cards Tom Rini (8): SPL: Add CONFIG_SUPPORT_EMMC_BOOT support to CONFIG_SPL_FRAMEWORK cmd_mmc.c: Change 'bootpart' code to match normal coding style cmd_mmc.c: Rename 'bootpart' to 'bootpart-resize' cmd_mmc.c: Add 'partconf' command to mmc cmd_mmc.c: Add bootbus mmc sub-command cmd_mmc.c: Drop open/close mmc sub-commands omap5_uevm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage dra7xx_evm: Add CONFIG_SUPPORT_EMMC_BOOT, document usage arch/arm/cpu/armv7/omap-common/boot-common.c | 13 ++- arch/arm/include/asm/arch-exynos/dwmmc.h | 4 board/ti/dra7xx/README | 25 + board/ti/omap5_uevm/README | 25 + common/cmd_mmc.c | 108 ++ common/spl/spl_mmc.c | 24 drivers/mmc/dw_mmc.c | 2 +- drivers/mmc/exynos_dw_mmc.c | 17 +-- drivers/mmc/mmc.c| 79 -- drivers/mmc/zynq_sdhci.c | 3 ++- include/configs/dra7xx_evm.h | 2 ++ include/configs/omap5_uevm.h | 1 + include/dwmmc.h | 2 +- include/mmc.h| 9 ++-- include/spl.h| 1 + 15 files changed, 198 insertions(+), 117 deletions(-) create mode 100644 board/ti/dra7xx/README create mode 100644 board/ti/omap5_uevm/README Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] dfu: mmc: Replace calls to u-boot commands with native mmc API
Hi Lukasz, Looks fine to me. Let me run a few tests over the weekend and I'll apply. Thanks -- Pantelis On Feb 21, 2014, at 9:23 AM, Lukasz Majewski wrote: For some time we have been using the run_command() with properly crafted string. Such approach turned to be unreliable and error prone. Switch to native mmc subsystem API would allow better type checking and shall improve speed. Also, it seems that this API is changing less often than u-boot commands. The approach similar to env operations on the eMMC has been reused. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- drivers/dfu/dfu_mmc.c | 31 --- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 0816f46..651cfff 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -12,6 +12,7 @@ #include errno.h #include div64.h #include dfu.h +#include mmc.h static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE) dfu_file_buf[CONFIG_SYS_DFU_MAX_FILE_SIZE]; @@ -20,8 +21,8 @@ static long dfu_file_buf_len; static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, u64 offset, void *buf, long *len) { - char cmd_buf[DFU_CMD_BUF_SIZE]; - u32 blk_start, blk_count; + struct mmc *mmc = find_mmc_device(dfu-dev_num); + u32 blk_start, blk_count, n = 0; /* * We must ensure that we work in lba_blk_size chunks, so ALIGN @@ -38,12 +39,28 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, return -EINVAL; } - sprintf(cmd_buf, mmc %s %p %x %x, - op == DFU_OP_READ ? read : write, - buf, blk_start, blk_count); + debug(%s: %s dev: %d start: %d cnt: %d buf: 0x%p\n, __func__, + op == DFU_OP_READ ? MMC READ : MMC WRITE, dfu-dev_num, + blk_start, blk_count, buf); + switch (op) { + case DFU_OP_READ: + n = mmc-block_dev.block_read(dfu-dev_num, blk_start, + blk_count, buf); + break; + case DFU_OP_WRITE: + n = mmc-block_dev.block_write(dfu-dev_num, blk_start, +blk_count, buf); + break; + default: + error(Operation not supported\n); + } - debug(%s: %s 0x%p\n, __func__, cmd_buf, cmd_buf); - return run_command(cmd_buf, 0); + if (n != blk_count) { + error(MMC operation failed); + return -EIO; + } + + return 0; } static int mmc_file_buffer(struct dfu_entity *dfu, void *buf, long *len) -- 1.7.10.4 ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [RFC] mmc: Remove ops from struct mmc and put in mmc_ops
Remove the in-structure ops and put them in mmc_ops with a constant pointer to it. This makes the mmc structure smaller as well as conserving code space (in theory). All in-tree drivers are converted as well; this is done in a single patch in order to not break git bisect. Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com --- drivers/mmc/arm_pl180_mmci.c | 12 + drivers/mmc/bfin_sdh.c | 11 drivers/mmc/davinci_mmc.c| 13 - drivers/mmc/dw_mmc.c | 10 --- drivers/mmc/fsl_esdhc.c | 14 +- drivers/mmc/ftsdc010_mci.c | 11 +--- drivers/mmc/gen_atmel_mci.c | 12 + drivers/mmc/mmc.c| 21 --- drivers/mmc/mmc_spi.c| 12 + drivers/mmc/mxcmmc.c | 12 + drivers/mmc/mxsmmc.c | 12 + drivers/mmc/omap_hsmmc.c | 63 +++- drivers/mmc/pxa_mmc_gen.c| 11 +--- drivers/mmc/sdhci.c | 13 + drivers/mmc/sh_mmcif.c | 12 + drivers/mmc/tegra_mmc.c | 19 +++-- include/mmc.h| 19 - 17 files changed, 167 insertions(+), 110 deletions(-) diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c index 5a55fe7..4490e97 100644 --- a/drivers/mmc/arm_pl180_mmci.c +++ b/drivers/mmc/arm_pl180_mmci.c @@ -335,6 +335,12 @@ static void host_set_ios(struct mmc *dev) udelay(CLK_CHANGE_DELAY); } +static const struct mmc_ops arm_pl180_mmci_ops = { + .send_cmd = host_request, + .set_ios = host_set_ios, + .init = mmc_host_reset, +}; + /* * mmc_host_init - initialize the mmc controller. * Set initial clock and power for mmc slot. @@ -360,11 +366,7 @@ int arm_pl180_mmci_init(struct pl180_mmc_host *host) sdi_u32 = readl(host-base-mask0) ~SDI_MASK0_MASK; writel(sdi_u32, host-base-mask0); strncpy(dev-name, host-name, sizeof(dev-name)); - dev-send_cmd = host_request; - dev-set_ios = host_set_ios; - dev-init = mmc_host_reset; - dev-getcd = NULL; - dev-getwp = NULL; + dev-ops = arm_pl180_mmci_ops; dev-host_caps = host-caps; dev-voltages = host-voltages; dev-f_min = host-clock_min; diff --git a/drivers/mmc/bfin_sdh.c b/drivers/mmc/bfin_sdh.c index bd9b641..f0871ec 100644 --- a/drivers/mmc/bfin_sdh.c +++ b/drivers/mmc/bfin_sdh.c @@ -274,6 +274,11 @@ static int bfin_sdh_init(struct mmc *mmc) return 0; } +static const struct mmc_ops bfin_mmc_ops = { + .send_cmd = bfin_sdh_request, + .set_ios= bfin_sdh_set_ios, + .init = bfin_sdh_init, +}; int bfin_mmc_init(bd_t *bis) { @@ -284,11 +289,7 @@ int bfin_mmc_init(bd_t *bis) if (!mmc) return -ENOMEM; sprintf(mmc-name, Blackfin SDH); - mmc-send_cmd = bfin_sdh_request; - mmc-set_ios = bfin_sdh_set_ios; - mmc-init = bfin_sdh_init; - mmc-getcd = NULL; - mmc-getwp = NULL; + mmc-ops = bfin_mmc_ops; mmc-host_caps = MMC_MODE_4BIT; mmc-voltages = MMC_VDD_32_33 | MMC_VDD_33_34; diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c index b380961..29ca4a6 100644 --- a/drivers/mmc/davinci_mmc.c +++ b/drivers/mmc/davinci_mmc.c @@ -363,6 +363,12 @@ static void dmmc_set_ios(struct mmc *mmc) dmmc_set_clock(mmc, mmc-clock); } +static const struct mmc_ops dmmc_ops = { + .send_cmd = dmmc_send_cmd, + .set_ios= dmmc_set_ios, + .init = dmmc_init, +}; + /* Called from board_mmc_init during startup. Can be called multiple times * depending on the number of slots available on board and controller */ @@ -375,12 +381,7 @@ int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host) sprintf(mmc-name, davinci); mmc-priv = host; - mmc-send_cmd = dmmc_send_cmd; - mmc-set_ios = dmmc_set_ios; - mmc-init = dmmc_init; - mmc-getcd = NULL; - mmc-getwp = NULL; - + mmc-ops = dmmc_ops; mmc-f_min = 20; mmc-f_max = 2500; mmc-voltages = host-voltages; diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index d45c15c..2e6576e 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -343,6 +343,12 @@ static int dwmci_init(struct mmc *mmc) return 0; } +static const struct mmc_ops dwmci_ops = { + .send_cmd = dwmci_send_cmd, + .set_ios= dwmci_set_ios, + .init = dwmci_init, +}; + int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk) { struct mmc *mmc; @@ -358,9 +364,7 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk) host-mmc = mmc; sprintf(mmc-name, %s, host-name); - mmc-send_cmd = dwmci_send_cmd; - mmc-set_ios = dwmci_set_ios; - mmc-init = dwmci_init; + mmc-ops = dwmci_ops; mmc-f_min = min_clk
Re: [U-Boot] [PATCH] dfu: mmc: Replace calls to u-boot commands with native mmc API
Hi Lukasz, On Feb 27, 2014, at 10:36 AM, Lukasz Majewski wrote: Hi Pantelis, Hi Lukasz, Looks fine to me. Let me run a few tests over the weekend and I'll apply. Have the run test gone smoothly? In the middle of reworking some core stuff in mmc, will test when that's done. Regards -- Pantelis Thanks -- Pantelis On Feb 21, 2014, at 9:23 AM, Lukasz Majewski wrote: For some time we have been using the run_command() with properly crafted string. Such approach turned to be unreliable and error prone. Switch to native mmc subsystem API would allow better type checking and shall improve speed. Also, it seems that this API is changing less often than u-boot commands. The approach similar to env operations on the eMMC has been reused. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- drivers/dfu/dfu_mmc.c | 31 --- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 0816f46..651cfff 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -12,6 +12,7 @@ #include errno.h #include div64.h #include dfu.h +#include mmc.h static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE) dfu_file_buf[CONFIG_SYS_DFU_MAX_FILE_SIZE]; @@ -20,8 +21,8 @@ static long dfu_file_buf_len; static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, u64 offset, void *buf, long *len) { - char cmd_buf[DFU_CMD_BUF_SIZE]; - u32 blk_start, blk_count; + struct mmc *mmc = find_mmc_device(dfu-dev_num); + u32 blk_start, blk_count, n = 0; /* * We must ensure that we work in lba_blk_size chunks, so ALIGN @@ -38,12 +39,28 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, return -EINVAL; } - sprintf(cmd_buf, mmc %s %p %x %x, - op == DFU_OP_READ ? read : write, -buf, blk_start, blk_count); + debug(%s: %s dev: %d start: %d cnt: %d buf: 0x%p\n, __func__, + op == DFU_OP_READ ? MMC READ : MMC WRITE, dfu-dev_num, + blk_start, blk_count, buf); + switch (op) { + case DFU_OP_READ: + n = mmc-block_dev.block_read(dfu-dev_num, blk_start, + blk_count, buf); + break; + case DFU_OP_WRITE: + n = mmc-block_dev.block_write(dfu-dev_num, blk_start, + blk_count, buf); + break; + default: + error(Operation not supported\n); + } - debug(%s: %s 0x%p\n, __func__, cmd_buf, cmd_buf); - return run_command(cmd_buf, 0); + if (n != blk_count) { + error(MMC operation failed); + return -EIO; + } + + return 0; } static int mmc_file_buffer(struct dfu_entity *dfu, void *buf, long *len) -- 1.7.10.4 -- Best regards, Lukasz Majewski Samsung RD Institute Poland (SRPOL) | Linux Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] dfu: mmc: Replace calls to u-boot commands with native mmc API
Hi Lukasz, On Feb 27, 2014, at 11:21 AM, Lukasz Majewski wrote: Hi Pantelis, Hi Lukasz, On Feb 27, 2014, at 10:36 AM, Lukasz Majewski wrote: Hi Pantelis, Hi Lukasz, Looks fine to me. Let me run a few tests over the weekend and I'll apply. Have the run test gone smoothly? In the middle of reworking some core stuff in mmc, will test when that's done. Does your rework intend to change the MMC API? I'm regarding this patch as one suitable for v2014.04, since it replaces cumbersome sprintf() approach with the native mmc API. Those operations are done at dfu_mmc.c, not any core mmc file. Your point is valid; I'll try to give it a spin today. Regards -- Pantelis Thanks -- Pantelis On Feb 21, 2014, at 9:23 AM, Lukasz Majewski wrote: For some time we have been using the run_command() with properly crafted string. Such approach turned to be unreliable and error prone. Switch to native mmc subsystem API would allow better type checking and shall improve speed. Also, it seems that this API is changing less often than u-boot commands. The approach similar to env operations on the eMMC has been reused. Signed-off-by: Lukasz Majewski l.majew...@samsung.com --- drivers/dfu/dfu_mmc.c | 31 --- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c index 0816f46..651cfff 100644 --- a/drivers/dfu/dfu_mmc.c +++ b/drivers/dfu/dfu_mmc.c @@ -12,6 +12,7 @@ #include errno.h #include div64.h #include dfu.h +#include mmc.h static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE) dfu_file_buf[CONFIG_SYS_DFU_MAX_FILE_SIZE]; @@ -20,8 +21,8 @@ static long dfu_file_buf_len; static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, u64 offset, void *buf, long *len) { - char cmd_buf[DFU_CMD_BUF_SIZE]; - u32 blk_start, blk_count; + struct mmc *mmc = find_mmc_device(dfu-dev_num); + u32 blk_start, blk_count, n = 0; /* * We must ensure that we work in lba_blk_size chunks, so ALIGN @@ -38,12 +39,28 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, return -EINVAL; } - sprintf(cmd_buf, mmc %s %p %x %x, - op == DFU_OP_READ ? read : write, - buf, blk_start, blk_count); + debug(%s: %s dev: %d start: %d cnt: %d buf: 0x%p\n, __func__, + op == DFU_OP_READ ? MMC READ : MMC WRITE, dfu-dev_num, + blk_start, blk_count, buf); + switch (op) { + case DFU_OP_READ: + n = mmc-block_dev.block_read(dfu-dev_num, blk_start, + blk_count, buf); + break; + case DFU_OP_WRITE: + n = mmc-block_dev.block_write(dfu-dev_num, blk_start, +blk_count, buf); + break; + default: + error(Operation not supported\n); + } - debug(%s: %s 0x%p\n, __func__, cmd_buf, cmd_buf); - return run_command(cmd_buf, 0); + if (n != blk_count) { + error(MMC operation failed); + return -EIO; + } + + return 0; } static int mmc_file_buffer(struct dfu_entity *dfu, void *buf, long *len) -- 1.7.10.4 -- Best regards, Lukasz Majewski Samsung RD Institute Poland (SRPOL) | Linux Platform Group -- Best regards, Lukasz Majewski Samsung RD Institute Poland (SRPOL) | Linux Platform Group ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: sdhci: Fixed timeout for sdhci_send_command()
Hi Eli, On Jun 12, 2014, at 12:41 PM, Eli Billauer wrote: The current wait loop just reads the status 1 times, which makes the actual timeout period platform-dependent. The udelay() call within the loop makes the new timeout ~100 ms. Signed-off-by: Eli Billauer eli.billa...@gmail.com --- drivers/mmc/sdhci.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/sdhci.c b/drivers/mmc/sdhci.c index 3125d13..80f3a91 100644 --- a/drivers/mmc/sdhci.c +++ b/drivers/mmc/sdhci.c @@ -226,6 +226,7 @@ int sdhci_send_command(struct mmc *mmc, struct mmc_cmd *cmd, break; if (--retry == 0) break; + udelay(10); } while ((stat mask) != mask); if (retry == 0) { -- 1.7.2.3 Looking at the linux sources is no good, cause linux is interrupt driven. This delay is used because the driver is not interrupt driven, so you have to wait until the interrupt indication is delivered. The only reference to interrupt latency I found is related to tuning and is set to 50ms which I supposed is very pessimistic. I think a timeout of 100ms would be fine. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 1/1] ARM: kirkwood: add mvsdio driver
Hi Gerald, On Jul 20, 2014, at 9:28 AM, Gerald Kerma wrote: This patch add Marvell kirkwood MVSDIO/MMC driver and enable it for Sheevaplugs and OpenRD boards. - Fix some typo and missing lines from patch import Signed-off-by: Gerald Kerma drea...@doukki.net --- arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 58 arch/arm/include/asm/arch-kirkwood/config.h| 2 + arch/arm/include/asm/arch-kirkwood/cpu.h | 2 + arch/arm/include/asm/arch-kirkwood/kirkwood.h | 24 ++ arch/arm/include/asm/arch-kirkwood/kw88f6282.h | 33 ++ board/Marvell/openrd/openrd.c | 11 + board/Marvell/sheevaplug/sheevaplug.c | 11 + drivers/mmc/Makefile | 1 + drivers/mmc/mrvl_mmc.c | 463 + include/configs/openrd.h | 8 + include/configs/sheevaplug.h | 19 +- include/mrvl_mmc.h | 290 12 files changed, 920 insertions(+), 2 deletions(-) create mode 100644 arch/arm/include/asm/arch-kirkwood/kw88f6282.h create mode 100644 drivers/mmc/mrvl_mmc.c create mode 100644 include/mrvl_mmc.h diff --git a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c index da80240..472aa8a 100644 --- a/arch/arm/cpu/arm926ejs/kirkwood/cpu.c +++ b/arch/arm/cpu/arm926ejs/kirkwood/cpu.c @@ -333,6 +333,64 @@ int arch_cpu_init(void) } #endif /* CONFIG_ARCH_CPU_INIT */ +/* + * General + / +#if defined(CONFIG_ARCH_DEV_ID) + +void kirkwood_pcie_id(u32 *dev, u32 *rev) +{ + *dev = (readl(KW_REG_PCIE_DEVID) 16) 0x; + *rev = readl(KW_REG_PCIE_REVID) 0xff; +} + +/* + * Identify device ID and revision. + */ +char *kirkwood_id(void) +{ + u32 dev, rev; + + kirkwood_pcie_id(dev, rev); + + if (dev == MV88F6281_DEV_ID) { + if (rev == MV88F6281_REV_Z0) + return MV88F6281-Z0; + else if (rev == MV88F6281_REV_A0) + return MV88F6281-A0; + else if (rev == MV88F6281_REV_A1) + return MV88F6281-A1; + else + return MV88F6281-Rev-Unsupported; + } else if (dev == MV88F6192_DEV_ID) { + if (rev == MV88F6192_REV_Z0) + return MV88F6192-Z0; + else if (rev == MV88F6192_REV_A0) + return MV88F6192-A0; + else if (rev == MV88F6192_REV_A1) + return MV88F6192-A1; + else + return MV88F6192-Rev-Unsupported; + } else if (dev == MV88F6180_DEV_ID) { + if (rev == MV88F6180_REV_A0) + return MV88F6180-Rev-A0; + else if (rev == MV88F6180_REV_A1) + return MV88F6180-Rev-A1; + else + return MV88F6180-Rev-Unsupported; + } else if (dev == MV88F6282_DEV_ID) { + if (rev == MV88F6282_REV_A0) + return MV88F6282-Rev-A0; + else if (rev == MV88F6282_REV_A1) + return MV88F6282-Rev-A1; + else + return MV88F6282-Rev-Unsupported; + } else { + return Device-Unknown; + } +} +#endif /* CONFIG_ARCH_DEV_ID */ + /* * SOC specific misc init */ diff --git a/arch/arm/include/asm/arch-kirkwood/config.h b/arch/arm/include/asm/arch-kirkwood/config.h index 7a688e4..a0563a3 100644 --- a/arch/arm/include/asm/arch-kirkwood/config.h +++ b/arch/arm/include/asm/arch-kirkwood/config.h @@ -19,6 +19,8 @@ #include asm/arch/kw88f6281.h #elif defined (CONFIG_KW88F6192) #include asm/arch/kw88f6192.h +#elif defined(CONFIG_KW88F6182) +#include asm/arch/kw88f6182.h #else #error SOC Name not defined #endif /* CONFIG_KW88F6281 */ diff --git a/arch/arm/include/asm/arch-kirkwood/cpu.h b/arch/arm/include/asm/arch-kirkwood/cpu.h index 97daa40..e7b6448 100644 --- a/arch/arm/include/asm/arch-kirkwood/cpu.h +++ b/arch/arm/include/asm/arch-kirkwood/cpu.h @@ -151,5 +151,7 @@ int kw_config_mpp(unsigned int mpp0_7, unsigned int mpp8_15, unsigned int mpp32_39, unsigned int mpp40_47, unsigned int mpp48_55); unsigned int kw_winctrl_calcsize(unsigned int sizeval); +void kirkwood_pcie_id(u32 *dev, u32 *rev); +char *kirkwood_id(void); #endif /* __ASSEMBLY__ */ #endif /* _KWCPU_H */ diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h b/arch/arm/include/asm/arch-kirkwood/kirkwood.h index bc207f5..489517f 100644 --- a/arch/arm/include/asm/arch-kirkwood/kirkwood.h +++ b/arch/arm/include/asm/arch-kirkwood/kirkwood.h @@ -39,6 +39,7 @@ #define KW_EGIGA0_BASE(KW_REGISTER(0x72000)) #define KW_EGIGA1_BASE
Re: [U-Boot] [PATCH v7 1/1] ARM: kirkwood: add mvsdio driver
Hi Stefan, On Jul 29, 2014, at 9:21 PM, Stefan Roese wrote: On 29.07.2014 18:39, drEagle wrote: On 26/07/2014 13:54, Stefan Roese wrote: On 25.07.2014 21:07, Gerald Kerma wrote: This patch add Marvell kirkwood MVSDIO/MMC driver and enable it for Sheevaplugs and OpenRD boards. Signed-off-by: Gerald Kerma drea...@doukki.net Looks good now, so: Reviewed-by: Stefan Roese s...@denx.de Thank for you review. Is there any action I have to do now ? No. Just a bit of patience. If nobody else has some objections or other review comments your patch will be picked up by the subsystem custodian (Panto). New mmc pull req coming up at the end of this week. Thanks, Stefan Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v7 1/1] ARM: kirkwood: add mvsdio driver
Hi there, On Jul 29, 2014, at 7:39 PM, drEagle wrote: Hi Stefan, On 26/07/2014 13:54, Stefan Roese wrote: On 25.07.2014 21:07, Gerald Kerma wrote: This patch add Marvell kirkwood MVSDIO/MMC driver and enable it for Sheevaplugs and OpenRD boards. Signed-off-by: Gerald Kerma drea...@doukki.net Looks good now, so: Reviewed-by: Stefan Roese s...@denx.de Thank for you review. Is there any action I have to do now ? Enjoy Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [RESEND PATCH v2] bcm2835_sdhci: Add SDHCI_QUIRK_NO_HISPD_BIT flag
Hi Lubomir, On Jul 17, 2014, at 2:57 PM, Lubomir Rintel wrote: Seems like the controller doesn't support the flag. None of the hi-speed cards I've tried could be read, while they successfully worked with the quirk enabled. Signed-off-by: Lubomir Rintel lkund...@v3.sk Tested-by: Stephen Warren swar...@wwwdotorg.org --- Changes to v2: - I've sent the first version with extra and irrelevant hunk. Sorry. drivers/mmc/bcm2835_sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/bcm2835_sdhci.c b/drivers/mmc/bcm2835_sdhci.c index 54cfabf..82079d6 100644 --- a/drivers/mmc/bcm2835_sdhci.c +++ b/drivers/mmc/bcm2835_sdhci.c @@ -179,7 +179,7 @@ int bcm2835_sdhci_init(u32 regbase, u32 emmc_freq) host-name = bcm2835_sdhci; host-ioaddr = (void *)regbase; host-quirks = SDHCI_QUIRK_BROKEN_VOLTAGE | SDHCI_QUIRK_BROKEN_R1B | - SDHCI_QUIRK_WAIT_SEND_CMD; + SDHCI_QUIRK_WAIT_SEND_CMD | SDHCI_QUIRK_NO_HISPD_BIT; host-voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195; host-ops = bcm2835_ops; -- 1.8.3.1 Thanks, Applied. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 11/12] mmc: s3c: Add SD driver
Hi Marek, On Jul 22, 2014, at 3:34 AM, Marek Vasut wrote: Implement SD driver for the S3C24xx family. This implementation is currently only capable of using the PIO transfers, DMA is not supported. Signed-off-by: Marek Vasut ma...@denx.de Cc: Kyungmin Park kyungmin.p...@samsung.com Cc: Lukasz Majewski l.majew...@samsung.com Cc: Minkyu Kang mk7.k...@samsung.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com Cc: Vladimir Zapolskiy v...@mleia.com --- arch/arm/include/asm/arch-s3c24x0/s3c24x0.h | 6 + drivers/mmc/Makefile| 1 + drivers/mmc/s3c_sdi.c | 321 3 files changed, 328 insertions(+) create mode 100644 drivers/mmc/s3c_sdi.c [snip] Applied, thanks -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 11/12] mmc: s3c: Add SD driver
Hi Marek, On Jul 22, 2014, at 3:34 AM, Marek Vasut wrote: Implement SD driver for the S3C24xx family. This implementation is currently only capable of using the PIO transfers, DMA is not supported. Signed-off-by: Marek Vasut ma...@denx.de Cc: Kyungmin Park kyungmin.p...@samsung.com Cc: Lukasz Majewski l.majew...@samsung.com Cc: Minkyu Kang mk7.k...@samsung.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com Cc: Vladimir Zapolskiy v...@mleia.com --- arch/arm/include/asm/arch-s3c24x0/s3c24x0.h | 6 + drivers/mmc/Makefile| 1 + drivers/mmc/s3c_sdi.c | 321 3 files changed, 328 insertions(+) create mode 100644 drivers/mmc/s3c_sdi.c [snip] Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc/dw_mmc: Fix clock divider calculation error for bypass mode
Hi Chin, On Jun 10, 2014, at 9:26 AM, Chin Liang See wrote: To fix the clock divider calculation error when the controller clock same as the operating frequency. This is known as bypass mode. In this mode, the divider should be 0. Signed-off-by: Chin Liang See cl...@altera.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com Cc: Rajeshwari Shinde rajeshwar...@samsung.com Cc: Jaehoon Chung jh80.ch...@samsung.com Cc: Mischa Jonker mjon...@synopsys.com --- drivers/mmc/dw_mmc.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 5bf36a0..0df30bc 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -245,7 +245,10 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq) return -EINVAL; } - div = DIV_ROUND_UP(sclk, 2 * freq); + if (sclk == freq) + div = 0;/* bypass mode */ + else + div = DIV_ROUND_UP(sclk, 2 * freq); dwmci_writel(host, DWMCI_CLKENA, 0); dwmci_writel(host, DWMCI_CLKSRC, 0); -- 1.7.9.5 Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/3] MMC: atmel_mci: add configuration register definition
Hi Bo, On Jul 31, 2014, at 9:39 AM, Bo Shen wrote: Add configuration register definition, this register only exists on MCI IP version = 0x300. Signed-off-by: Bo Shen voice.s...@atmel.com --- include/atmel_mci.h | 14 +- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/atmel_mci.h b/include/atmel_mci.h index 3d2870f..de24148 100644 --- a/include/atmel_mci.h +++ b/include/atmel_mci.h @@ -36,7 +36,9 @@ typedef struct atmel_mci { u32 ier;/* 0x44 */ u32 idr;/* 0x48 */ u32 imr;/* 0x4c */ - u32 reserved[43]; + u32 dma;/* 0x50 */ + u32 cfg;/* 0x54 */ + u32 reserved[41]; u32 version; } atmel_mci_t; @@ -189,6 +191,16 @@ typedef struct atmel_mci { #define MMCI_TRTYP_MULTI_BLOCK1 #define MMCI_TRTYP_STREAM 2 +/* Bitfields in CFG */ +#define MMCI_FIFOMODE_OFFSET 0 +#define MMCI_FIFOMODE_SIZE 1 +#define MMCI_FERRCTRL_OFFSET 4 +#define MMCI_FERRCTRL_SIZE 1 +#define MMCI_HSMODE_OFFSET 8 +#define MMCI_HSMODE_SIZE 1 +#define MMCI_LSYNC_OFFSET12 +#define MMCI_LSYNC_SIZE 1 + /* Bit manipulation macros */ #define MMCI_BIT(name)\ (1 MMCI_##name##_OFFSET) -- 1.8.5.2 Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/3] MMC: atmel_mci: refactor setting the mode register
Hi Bo, On Jul 31, 2014, at 9:39 AM, Bo Shen wrote: The mode register is different between MCI IP version. So, according to MCI IP version to set the mode register. Signed-off-by: Bo Shen voice.s...@atmel.com --- drivers/mmc/gen_atmel_mci.c | 56 + include/atmel_mci.h | 4 2 files changed, 46 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c index a57a9b1..8778a4d 100644 --- a/drivers/mmc/gen_atmel_mci.c +++ b/drivers/mmc/gen_atmel_mci.c @@ -58,30 +58,58 @@ static void mci_set_mode(struct mmc *mmc, u32 hz, u32 blklen) atmel_mci_t *mci = mmc-priv; u32 bus_hz = get_mci_clk_rate(); u32 clkdiv = 255; + unsigned int version = atmel_mci_get_version(mci); + u32 clkodd = 0; + u32 mr; debug(mci: bus_hz is %u, setting clock %u Hz, block size %u\n, bus_hz, hz, blklen); if (hz 0) { - /* find lowest clkdiv yielding a rate = than requested */ - for (clkdiv=0; clkdiv255; clkdiv++) { - if ((bus_hz / (clkdiv+1) / 2) = hz) - break; + if (version = 0x500) { + clkdiv = DIV_ROUND_UP(bus_hz, hz) - 2; + if (clkdiv 511) + clkdiv = 511; + + clkodd = clkdiv 1; + clkdiv = 1; + + printf(mci: setting clock %u Hz, block size %u\n, +bus_hz / (clkdiv * 2 + clkodd + 2), blklen); + } else { + /* find clkdiv yielding a rate = than requested */ + for (clkdiv = 0; clkdiv 255; clkdiv++) { + if ((bus_hz / (clkdiv + 1) / 2) = hz) + break; + } + printf(mci: setting clock %u Hz, block size %u\n, +(bus_hz / (clkdiv + 1)) / 2, blklen); + } } - printf(mci: setting clock %u Hz, block size %u\n, - (bus_hz / (clkdiv+1)) / 2, blklen); blklen = 0xfffc; - /* On some platforms RDPROOF and WRPROOF are ignored */ - writel((MMCI_BF(CLKDIV, clkdiv) - | MMCI_BF(BLKLEN, blklen) - | MMCI_BIT(RDPROOF) - | MMCI_BIT(WRPROOF)), mci-mr); + + mr = MMCI_BF(CLKDIV, clkdiv); + + /* MCI IP version = 0x200 has R/WPROOF */ + if (version = 0x200) + mr |= MMCI_BIT(RDPROOF) | MMCI_BIT(WRPROOF); + /* - * On some new platforms BLKLEN in mci-mr is ignored. - * Should use the BLKLEN in the block register. + * MCI IP version = 0x500 use bit 16 as clkodd. + * MCI IP version 0x500 use upper 16 bits for blklen. */ - writel(MMCI_BF(BLKLEN, blklen), mci-blkr); + if (version = 0x500) + mr |= MMCI_BF(CLKODD, clkodd); + else + mr |= MMCI_BF(BLKLEN, blklen); + + writel(mr, mci-mr); + + /* MCI IP version = 0x200 has blkr */ + if (version = 0x200) + writel(MMCI_BF(BLKLEN, blklen), mci-blkr); + initialized = 1; } diff --git a/include/atmel_mci.h b/include/atmel_mci.h index 090574d..3d2870f 100644 --- a/include/atmel_mci.h +++ b/include/atmel_mci.h @@ -67,6 +67,10 @@ typedef struct atmel_mci { #define MMCI_PDCPADV_SIZE 1 #define MMCI_PDCMODE_OFFSET 15 #define MMCI_PDCMODE_SIZE 1 +/* MCI IP version = 0x500, MR bit 16 used for CLKODD */ +#define MMCI_CLKODD_OFFSET 16 +#define MMCI_CLKODD_SIZE 1 +/* MCI IP version 0x200, MR higher 16bits for BLKLEN */ #define MMCI_BLKLEN_OFFSET16 #define MMCI_BLKLEN_SIZE 16 -- 1.8.5.2 Looks good. Applied, thanks. ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/3] MMC: atmel_mci: enable high speed mode support
Hi Bo, On Jul 31, 2014, at 9:39 AM, Bo Shen wrote: If the MCI IP version = 0x300, it supports hight speed mode option, this patch enable it. Signed-off-by: Bo Shen voice.s...@atmel.com --- drivers/mmc/gen_atmel_mci.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/gen_atmel_mci.c b/drivers/mmc/gen_atmel_mci.c index 8778a4d..45bcffb 100644 --- a/drivers/mmc/gen_atmel_mci.c +++ b/drivers/mmc/gen_atmel_mci.c @@ -110,6 +110,9 @@ static void mci_set_mode(struct mmc *mmc, u32 hz, u32 blklen) if (version = 0x200) writel(MMCI_BF(BLKLEN, blklen), mci-blkr); + if (mmc-card_caps mmc-cfg-host_caps MMC_MODE_HS) + writel(MMCI_BIT(HSMODE), mci-cfg); + initialized = 1; } @@ -404,8 +407,10 @@ int atmel_mci_init(void *regs) /* need to be able to pass these in on a board by board basis */ cfg-voltages = MMC_VDD_32_33 | MMC_VDD_33_34; version = atmel_mci_get_version(mci); - if ((version 0xf00) = 0x300) + if ((version 0xf00) = 0x300) { cfg-host_caps = MMC_MODE_8BIT; + cfg-host_caps |= MMC_MODE_HS | MMC_MODE_HS_52MHz; + } cfg-host_caps |= MMC_MODE_4BIT; -- 1.8.5.2 Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2 2/2] env_mmc: support env partition setup in runtime
Hi Dmitry, On Jul 30, 2014, at 1:19 PM, Dmitry Lifshitz wrote: Add callback with __weak annotation to allow setup of environment partition number in runtime from a board file. Propagate mmc_switch_part() return value into init_mmc_for_env() instead of -1 in case of failure. Signed-off-by: Dmitry Lifshitz lifsh...@compulab.co.il Signed-off-by: Igor Grinberg grinb...@compulab.co.il --- Changes in v2: * Added mmc_get_env_part() proto in environment.h. common/env_mmc.c | 35 +++ include/environment.h |3 +++ 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/common/env_mmc.c b/common/env_mmc.c index 7da10e6..a7621a8 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -62,16 +62,36 @@ int env_init(void) return 0; } -static int init_mmc_for_env(struct mmc *mmc) -{ #ifdef CONFIG_SYS_MMC_ENV_PART +__weak uint mmc_get_env_part(struct mmc *mmc) +{ + return CONFIG_SYS_MMC_ENV_PART; +} + +static int mmc_set_env_part(struct mmc *mmc) +{ + uint part = mmc_get_env_part(mmc); int dev = CONFIG_SYS_MMC_ENV_DEV; + int ret = 0; #ifdef CONFIG_SPL_BUILD dev = 0; #endif + + if (part != mmc-part_num) { + ret = mmc_switch_part(dev, part); + if (ret) + puts(MMC partition switch failed\n); + } + + return ret; +} +#else +static inline int mmc_set_env_part(struct mmc *mmc) {return 0; }; #endif +static int init_mmc_for_env(struct mmc *mmc) +{ if (!mmc) { puts(No MMC card found\n); return -1; @@ -82,16 +102,7 @@ static int init_mmc_for_env(struct mmc *mmc) return -1; } -#ifdef CONFIG_SYS_MMC_ENV_PART - if (CONFIG_SYS_MMC_ENV_PART != mmc-part_num) { - if (mmc_switch_part(dev, CONFIG_SYS_MMC_ENV_PART)) { - puts(MMC partition switch failed\n); - return -1; - } - } -#endif - - return 0; + return mmc_set_env_part(mmc); } static void fini_mmc_for_env(struct mmc *mmc) diff --git a/include/environment.h b/include/environment.h index d7a1adf..1fdbdad 100644 --- a/include/environment.h +++ b/include/environment.h @@ -184,6 +184,9 @@ extern void env_reloc(void); #include mmc.h extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr); +# ifdef CONFIG_SYS_MMC_ENV_PART +extern uint mmc_get_env_part(struct mmc *mmc); +# endif #endif #ifndef DO_DEPS_ONLY -- 1.7.5.4 Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/2] env_mmc: add mmc_get_env_addr() prototype
Hi Dmitry, On Jul 30, 2014, at 1:19 PM, Dmitry Lifshitz wrote: Add missing mmc_get_env_addr() prototype in environment.h Signed-off-by: Dmitry Lifshitz lifsh...@compulab.co.il --- include/environment.h |6 ++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/include/environment.h b/include/environment.h index 08679ae..d7a1adf 100644 --- a/include/environment.h +++ b/include/environment.h @@ -180,6 +180,12 @@ extern unsigned char env_get_char_spec(int); extern void env_reloc(void); #endif +#ifdef CONFIG_ENV_IS_IN_MMC +#include mmc.h + +extern int mmc_get_env_addr(struct mmc *mmc, int copy, u32 *env_addr); +#endif + #ifndef DO_DEPS_ONLY #include env_attr.h -- 1.7.5.4 Applied, thanks. -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Pull request: u-boot-mmc 1/08/2014
Hi Tom, The following changes since commit 25b4adbba018633b943a99322bfb2fb819c0bafb: include: remove CONFIG_SPL/CONFIG_TPL definition in config headers (2014-07-30 14:42:03 -0400) are available in the git repository at: git://git.denx.de/u-boot-mmc.git master for you to fetch changes up to 6e7b7df4df435742fcfde5f384760ae1bda2e39c: env_mmc: support env partition setup in runtime (2014-08-01 20:12:15 +0300) Bo Shen (3): MMC: atmel_mci: refactor setting the mode register MMC: atmel_mci: add configuration register definition MMC: atmel_mci: enable high speed mode support Chin Liang See (1): mmc/dw_mmc: Fix clock divider calculation error for bypass mode Dmitry Lifshitz (2): env_mmc: add mmc_get_env_addr() prototype env_mmc: support env partition setup in runtime DrEagle (1): ARM: kirkwood: add mvsdio driver Lubomir Rintel (1): bcm2835_sdhci: Add SDHCI_QUIRK_NO_HISPD_BIT flag Marek Vasut (2): arm: s3c: Unify the S3C24xx SDI structure mmc: s3c: Add SD driver arch/arm/cpu/arm926ejs/kirkwood/cpu.c | 9 +++ arch/arm/include/asm/arch-kirkwood/kirkwood.h | 1 + arch/arm/include/asm/arch-s3c24x0/s3c2410.h | 4 +- arch/arm/include/asm/arch-s3c24x0/s3c2440.h | 4 +- arch/arm/include/asm/arch-s3c24x0/s3c24x0.h | 19 +++-- common/env_mmc.c | 35 ++--- drivers/mmc/Makefile | 2 + drivers/mmc/bcm2835_sdhci.c | 2 +- drivers/mmc/dw_mmc.c | 5 +- drivers/mmc/gen_atmel_mci.c | 63 +++ drivers/mmc/mvebu_mmc.c | 361 ++ drivers/mmc/s3c_sdi.c | 321 include/atmel_mci.h | 18 - include/configs/openrd.h | 8 ++ include/configs/sheevaplug.h | 11 +++ include/environment.h | 9 +++ include/mvebu_mmc.h | 278 ++ 17 files changed, 1109 insertions(+), 41 deletions(-) create mode 100644 drivers/mmc/mvebu_mmc.c create mode 100644 drivers/mmc/s3c_sdi.c create mode 100644 include/mvebu_mmc.h Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v3 2/4] usb/gadget: fastboot: add eMMC support for flash command
Hi Marek, [snip] I don't want to be the first to defined it for all of armv7 Honestly, we should just enable this CONFIG_SYS_VSNPRINTF by default for the good of humanity and all the things, since this unbounded string handling is just evil (see how OpenSSL ended up, partly because of that ... and I am just starting to see the pattern in all the security code). I don't want to go down that road with U-Boot. So, would you please cook a separate patch to enable this by default, so it would spur the right kind of discussion on this matter ? We should enable this by default. Unbounded string handling scares me. If we have problems with blowing over SPL size restrictions, perhaps have it disabled only on those cases (that are known to have a problem). And I really don't want to define it only only my boards running so that they can run 'fastboot' What do you suggest? See above, thanks ! Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/4] cmd_part: fix type in part command help text
Hi Tom, Sorry about that; It's all on my pile of work to do when I get back home. On May 14, 2014, at 2:17 PM, Tom Rini wrote: On Wed, May 14, 2014 at 11:30:35AM -0600, Stephen Warren wrote: On 05/07/2014 12:19 PM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com All the sub-commands start with the main command anme, but it was missing from one of the help texts. Tom, it looks like I forgot to CC you on these patches. I assume they'll go into the main U-Boot tree. Do you need me to resend them? If not, do they look OK? Acked-by: Tom Rini tr...@ti.com I had tossed the series to Pantelis in patchwork since it's mostly MMC related. -- Tom Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] esdhc/usdhc: Fix PIO mode bug in fsl_esdhc driver
Hi there, On Feb 20, 2014, at 12:00 PM, Ye.Li wrote: From: Ye.Li b37...@freescale.com When configure the fsl_esdhc driver to PIO mode by defining CONFIG_SYS_FSL_ESDHC_USE_PIO, the SD/MMC read and write will fail. Two bugs in the driver to cause the issue: 1. The read buffer was invalidated after reading from DATAPORT register, which should be only applied to DMA mode. The valid data in cache was overwritten by physical memory. 2. The watermarks are not set in PIO mode, will cause according state not be set. Signed-off-by: Ye.Li b37...@freescale.com --- Changes for V2: -Address the comments from Stefano Babic and Albert ARIBAUD to modify the subject drivers/mmc/fsl_esdhc.c | 23 +-- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 7b146a3..5bd0df3 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -174,7 +174,7 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) int timeout; struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc-priv; struct fsl_esdhc *regs = (struct fsl_esdhc *)cfg-esdhc_base; -#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO + uint wml_value; wml_value = data-blocksize/4; @@ -184,12 +184,15 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) wml_value = WML_RD_WML_MAX_VAL; esdhc_clrsetbits32(regs-wml, WML_RD_WML_MASK, wml_value); +#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO esdhc_write32(regs-dsaddr, (u32)data-dest); +#endif } else { +#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO flush_dcache_range((ulong)data-src, (ulong)data-src+data-blocks *data-blocksize); - +#endif if (wml_value WML_WR_WML_MAX) wml_value = WML_WR_WML_MAX_VAL; if ((esdhc_read32(regs-prsstat) PRSSTAT_WPSPL) == 0) { @@ -199,19 +202,10 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data) esdhc_clrsetbits32(regs-wml, WML_WR_WML_MASK, wml_value 16); +#ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO esdhc_write32(regs-dsaddr, (u32)data-src); +#endif } -#else/* CONFIG_SYS_FSL_ESDHC_USE_PIO */ - if (!(data-flags MMC_DATA_READ)) { - if ((esdhc_read32(regs-prsstat) PRSSTAT_WPSPL) == 0) { - printf(\nThe SD card is locked. - Can not write to a locked card.\n\n); - return TIMEOUT; - } - esdhc_write32(regs-dsaddr, (u32)data-src); - } else - esdhc_write32(regs-dsaddr, (u32)data-dest); -#endif /* CONFIG_SYS_FSL_ESDHC_USE_PIO */ esdhc_write32(regs-blkattr, data-blocks 16 | data-blocksize); @@ -393,9 +387,10 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) if (irqstat DATA_ERR) return COMM_ERR; } while ((irqstat DATA_COMPLETE) != DATA_COMPLETE); -#endif + if (data-flags MMC_DATA_READ) check_and_invalidate_dcache_range(cmd, data); +#endif } esdhc_write32(regs-irqstat, -1); -- 1.7.9.5 Applied, thanks Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ 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 v2] mmc: postponed needless timer initialization
Hi Mateusz, On Apr 29, 2014, at 9:15 PM, Mateusz Zalega wrote: mmc_init() doesn't call get_timer() anymore if MMC is already initialized. Signed-off-by: Mateusz Zalega m.zal...@samsung.com Cc: Pantelis Antoniou pa...@antoniou-consulting.com --- Detached from earlier DFU, MMC, Gadget, Goni, misc. series because of lack of relevance to other patches. v2: - deleted change-id line from commit message, sorry! --- drivers/mmc/mmc.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 16051e5..c93dc24 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1310,15 +1310,18 @@ static int mmc_complete_init(struct mmc *mmc) int mmc_init(struct mmc *mmc) { int err = IN_PROGRESS; - unsigned start = get_timer(0); + unsigned start; if (mmc-has_init) return 0; + + start = get_timer(0); + if (!mmc-init_in_progress) err = mmc_start_init(mmc); - if (!err || err == IN_PROGRESS) err = mmc_complete_init(mmc); + ^ some extra formatting here that's not needed; I'll fix it and apply. I am curious what the problem was the problem with getting the timer? debug(%s: %d, time %lu\n, __func__, err, get_timer(start)); return err; } -- 1.9.0 Applied Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] Add board_mmc_init(...) function for init mmc1 only
Hi Hannes, On Apr 8, 2014, at 9:39 AM, Hannes Petermaier wrote: Since BR boards uses only MMC-Controller #1, it only wastes time if we initialize #0 first to see that there is nothing. Cc: tr...@ti.com Signed-off-by: Hannes Petermaier oe5...@oevsv.at --- board/BuR/common/common.c |7 +++ include/configs/kwb.h |2 +- include/configs/tseries.h |2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/board/BuR/common/common.c b/board/BuR/common/common.c index 4c926ce..25cbe62 100644 --- a/board/BuR/common/common.c +++ b/board/BuR/common/common.c @@ -19,6 +19,7 @@ #include asm/arch/clock.h #include asm/arch/gpio.h #include asm/arch/sys_proto.h +#include asm/arch/mmc_host_def.h #include asm/io.h #include asm/gpio.h #include i2c.h @@ -214,3 +215,9 @@ int board_eth_init(bd_t *bis) return rv; } #endif /* CONFIG_DRIVER_TI_CPSW */ +#if defined(CONFIG_GENERIC_MMC) !defined(CONFIG_SPL_BUILD) +int board_mmc_init(bd_t *bis) +{ + return omap_mmc_init(1, 0, 0, -1, -1); +} +#endif diff --git a/include/configs/kwb.h b/include/configs/kwb.h index 0f631c0..0860434 100644 --- a/include/configs/kwb.h +++ b/include/configs/kwb.h @@ -109,7 +109,7 @@ #undef CONFIG_ENV_IS_NOWHERE #define CONFIG_ENV_IS_IN_MMC -#define CONFIG_SYS_MMC_ENV_DEV 1 +#define CONFIG_SYS_MMC_ENV_DEV 0 #define CONFIG_SYS_MMC_ENV_PART 2 #define CONFIG_ENV_OFFSET 0x4 /* TODO: Adresse definieren */ #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) diff --git a/include/configs/tseries.h b/include/configs/tseries.h index 8fb87ac..e550afa 100644 --- a/include/configs/tseries.h +++ b/include/configs/tseries.h @@ -237,7 +237,7 @@ #elif defined(CONFIG_EMMC_BOOT) #undef CONFIG_ENV_IS_NOWHERE #define CONFIG_ENV_IS_IN_MMC -#define CONFIG_SYS_MMC_ENV_DEV 1 +#define CONFIG_SYS_MMC_ENV_DEV 0 #define CONFIG_SYS_MMC_ENV_PART 2 #define CONFIG_ENV_OFFSET 0x4 /* TODO: Adresse definieren */ #define CONFIG_ENV_OFFSET_REDUND (CONFIG_ENV_OFFSET + CONFIG_ENV_SIZE) -- 1.7.9.5 Applied Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ 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 1/1] Read mmc device memory capacity from EXT_CSD if memory is addressed by sector
Hi Frank, On Apr 11, 2014, at 6:35 PM, Frank Bormann wrote: Hi Pantos, hi Tom, I sent this a couple of months ago to the mailing list, never really received a response. We are testing 2014.04-rc3 right now and the issue is still there. Would you still consider bringing this fix in for the upcoming release? This is for an eMMC chip with an initial memory size 2GB whose memory size drops below 2GB when turning enhanced (pseudo-SLC) mode on for the user partition. u-boot would then fail memory size detection and assume memory size if zero. You'd see error messages like: MMC: block number 0x1 exceeds max(0x0) MMC: block number 0x800 exceeds max(0x0) MMC: block number 0x900 exceeds max(0x0) Thanks, Frank Your patch is corrupted; can you please resend and make sure it applies using git am? panto@sles11esa:~/u-boot-mmc.git (master)$ git am -3 U-Boot-RFC-1-1-Read-mmc-device-memory-capacity-from-EXT_CSD-if-memory-is-addressed-by-sector.patch Applying: Read mmc device memory capacity from EXT_CSD if memory is addressed by sector fatal: corrupt patch at line 50 Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0001 Read mmc device memory capacity from EXT_CSD if memory is addressed by sector The copy of the patch that failed is found in: /home/panto/ti/u-boots/u-boot-mmc.git/.git/rebase-apply/patch When you have resolved this problem, run git am --resolved. If you prefer to skip this patch, run git am --skip instead. To restore the original branch and stop patching, run git am --abort. Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH v2] mmc: Handle switch error status bit in MMC card status
Hi Andrew, On Apr 3, 2014, at 12:34 PM, Andrew Gabbasov wrote: MMC switch command for unsupported feature (e.g. bus width) sets a switch error bit in card status. This bit should be checked, and, if it's set, no access with new controller settings should be performed. Signed-off-by: Andrew Gabbasov andrew_gabba...@mentor.com --- drivers/mmc/mmc.c |4 +++- include/mmc.h |2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 16051e5..a850085 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -150,6 +150,8 @@ int mmc_send_status(struct mmc *mmc, int timeout) #endif return TIMEOUT; } + if (cmd.response[0] MMC_STATUS_SWITCH_ERROR) + return SWITCH_ERR; return 0; } @@ -501,7 +503,7 @@ static int mmc_change_freq(struct mmc *mmc) err = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1); if (err) - return err; + return err == SWITCH_ERR ? 0 : err; /* Now check to see that it worked */ err = mmc_send_ext_csd(mmc, ext_csd); diff --git a/include/mmc.h b/include/mmc.h index c0a1d9e..213c112 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -53,6 +53,7 @@ #define COMM_ERR -18 /* Communications Error */ #define TIMEOUT -19 #define IN_PROGRESS -20 /* operation is in progress */ +#define SWITCH_ERR -21 /* Card reports failure to switch mode */ #define MMC_CMD_GO_IDLE_STATE 0 #define MMC_CMD_SEND_OP_COND 1 @@ -108,6 +109,7 @@ #define SECURE_ERASE 0x8000 #define MMC_STATUS_MASK (~0x0206BF7F) +#define MMC_STATUS_SWITCH_ERROR (1 7) #define MMC_STATUS_RDY_FOR_DATA (1 8) #define MMC_STATUS_CURR_STATE (0xf 9) #define MMC_STATUS_ERROR (1 19) -- 1.7.10.4 Applied, Thanks --Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH V5 1/3] eMMC: add support for operations in RPMB partition
Hi Pierre, On Apr 24, 2014, at 11:30 AM, Pierre Aubert wrote: This patch adds functions for read, write and authentication key programming for the Replay Protected Memory Block partition in the eMMC. Signed-off-by: Pierre Aubert p.aub...@staubli.com CC: Pantelis Antoniou pa...@antoniou-consulting.com --- Changes in V5: - move changelog to the right place - change lib/Makefile for adding sha256 when CONFIG_SUPPORT_EMMC_RPMB is defined V3, V4: no changes Changes in V2: - use ALLOC_CACHE_ALIGN_BUFFER in rpmb.c instead of a static buffer for the RPMB frames. drivers/mmc/Makefile |1 + drivers/mmc/rpmb.c | 323 ++ include/mmc.h| 10 ++- lib/Makefile |1 + 4 files changed, 334 insertions(+), 1 deletions(-) create mode 100644 drivers/mmc/rpmb.c diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile index 931922b..4c6ab9e 100644 --- a/drivers/mmc/Makefile +++ b/drivers/mmc/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_DWMMC) += dw_mmc.o obj-$(CONFIG_EXYNOS_DWMMC) += exynos_dw_mmc.o obj-$(CONFIG_ZYNQ_SDHCI) += zynq_sdhci.o obj-$(CONFIG_SOCFPGA_DWMMC) += socfpga_dw_mmc.o +obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o ifdef CONFIG_SPL_BUILD obj-$(CONFIG_SPL_MMC_BOOT) += fsl_esdhc_spl.o else diff --git a/drivers/mmc/rpmb.c b/drivers/mmc/rpmb.c new file mode 100644 index 000..05936f5 --- /dev/null +++ b/drivers/mmc/rpmb.c @@ -0,0 +1,323 @@ +/* + * Copyright 2014, Staubli Faverges + * Pierre Aubert + * + * eMMC- Replay Protected Memory Block + * According to JEDEC Standard No. 84-A441 + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include config.h +#include common.h +#include mmc.h +#include sha256.h +#include mmc_private.h + +/* Request codes */ +#define RPMB_REQ_KEY 1 +#define RPMB_REQ_WCOUNTER2 +#define RPMB_REQ_WRITE_DATA 3 +#define RPMB_REQ_READ_DATA 4 +#define RPMB_REQ_STATUS 5 + +/* Response code */ +#define RPMB_RESP_KEY0x0100 +#define RPMB_RESP_WCOUNTER 0x0200 +#define RPMB_RESP_WRITE_DATA 0x0300 +#define RPMB_RESP_READ_DATA 0x0400 + +/* Error codes */ +#define RPMB_OK 0 +#define RPMB_ERR_GENERAL 1 +#define RPMB_ERR_AUTH2 +#define RPMB_ERR_COUNTER 3 +#define RPMB_ERR_ADDRESS 4 +#define RPMB_ERR_WRITE 5 +#define RPMB_ERR_READ6 +#define RPMB_ERR_KEY 7 +#define RPMB_ERR_CNT_EXPIRED 0x80 +#define RPMB_ERR_MSK 0x7 + +/* Sizes of RPMB data frame */ +#define RPMB_SZ_STUFF196 +#define RPMB_SZ_MAC 32 +#define RPMB_SZ_DATA 256 +#define RPMB_SZ_NONCE16 + +#define SHA256_BLOCK_SIZE64 + +/* Error messages */ +static const char * const rpmb_err_msg[] = { + , + General failure, + Authentication failure, + Counter failure, + Address failure, + Write failure, + Read failure, + Authentication key not yet programmed, +}; + + +/* Structure of RPMB data frame. */ +struct s_rpmb { + unsigned char stuff[RPMB_SZ_STUFF]; + unsigned char mac[RPMB_SZ_MAC]; + unsigned char data[RPMB_SZ_DATA]; + unsigned char nonce[RPMB_SZ_NONCE]; + unsigned long write_counter; + unsigned short address; + unsigned short block_count; + unsigned short result; + unsigned short request; +}; + +static int mmc_set_blockcount(struct mmc *mmc, unsigned int blockcount, + bool is_rel_write) +{ + struct mmc_cmd cmd = {0}; + + cmd.cmdidx = MMC_CMD_SET_BLOCK_COUNT; + cmd.cmdarg = blockcount 0x; + if (is_rel_write) + cmd.cmdarg |= 1 31; + cmd.resp_type = MMC_RSP_R1; + + return mmc_send_cmd(mmc, cmd, NULL); +} +static int mmc_rpmb_request(struct mmc *mmc, const struct s_rpmb *s, + unsigned int count, bool is_rel_write) +{ + struct mmc_cmd cmd = {0}; + struct mmc_data data; + int ret; + + ret = mmc_set_blockcount(mmc, count, is_rel_write); + if (ret) { +#ifdef CONFIG_MMC_RPMB_TRACE + printf(%s:mmc_set_blockcount- %d\n, __func__, ret); +#endif + return 1; + } + + cmd.cmdidx = MMC_CMD_WRITE_MULTIPLE_BLOCK; + cmd.cmdarg = 0; + cmd.resp_type = MMC_RSP_R1b; + + data.src = (const char *)s; + data.blocks = 1; + data.blocksize = MMC_MAX_BLOCK_LEN; + data.flags = MMC_DATA_WRITE; + + ret = mmc_send_cmd(mmc, cmd, data); + if (ret) { +#ifdef CONFIG_MMC_RPMB_TRACE + printf(%s:mmc_send_cmd- %d\n, __func__, ret); +#endif + return 1; + } + return 0; +} +static int mmc_rpmb_response(struct mmc *mmc, struct s_rpmb *s, + unsigned short expected) +{ + struct mmc_cmd cmd = {0}; + struct mmc_data data; + int ret; + + ret = mmc_set_blockcount
Re: [U-Boot] [PATCH V5 2/3] Add the function 'confirm_yesno' for interactive
); /* clear the Control-C condition */ int disable_ctrlc (int);/* 1 to disable, 0 to enable Control-C detect */ - +int confirm_yesno(void);/* 1 if input is y, Y, yes or YES */ /* * STDIO based functions (can always be used) */ -- 1.7.6.5 This is reasonable, and I've applied it to my mmc tree, Applied, Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 1/4] cmd_part: fix type in part command help text
Hi Stephen, On May 7, 2014, at 9:19 PM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com All the sub-commands start with the main command anme, but it was anme=name missing from one of the help texts. Signed-off-by: Stephen Warren swar...@nvidia.com --- common/cmd_part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/cmd_part.c b/common/cmd_part.c index 14248548d9fe..c84bc27b4042 100644 --- a/common/cmd_part.c +++ b/common/cmd_part.c @@ -82,7 +82,7 @@ int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( part, 5, 1, do_part, disk partition related commands, - uuid interface dev:part\n + part uuid interface dev:part\n - print partition UUID\n part uuid interface dev:part varname\n - set environment variable to partition UUID\n -- 1.8.1.5 Fixed typos and applied. Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 2/4] disk: support devices with HW partitions
)) { - printf(** Bad device %s %s **\n, ifname, dev_str); - return -1; + printf(** Bad device %s %s **\n, ifname, dev_hwpart_str); + dev = -1; + goto cleanup; } +cleanup: + free(dup_str); return dev; } -- 1.8.1.5 Applied Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/4] mmc: provide a select_hwpart implementation for get_device()
Hi Stephen, On May 7, 2014, at 9:19 PM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments. Signed-off-by: Stephen Warren swar...@nvidia.com --- disk/part.c | 6 +- drivers/mmc/mmc.c | 26 ++ include/part.h| 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/disk/part.c b/disk/part.c index 5e10cae015e5..2827089d8d5f 100644 --- a/disk/part.c +++ b/disk/part.c @@ -39,7 +39,11 @@ static const struct block_drvr block_drvr[] = { { .name = usb, .get_dev = usb_stor_get_dev, }, #endif #if defined(CONFIG_MMC) - { .name = mmc, .get_dev = mmc_get_dev, }, + { + .name = mmc, + .get_dev = mmc_get_dev, + .select_hwpart = mmc_select_hwpart, + }, #endif #if defined(CONFIG_SYSTEMACE) { .name = ace, .get_dev = systemace_get_dev, }, diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 16051e52ff16..3089d8d807a8 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -550,6 +550,32 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num) return 0; } +int mmc_select_hwpart(int dev_num, int hwpart) +{ + struct mmc *mmc = find_mmc_device(dev_num); + int ret; + + if (!mmc) + return -1; + + if (mmc-part_num == hwpart) + return 0; + + if (mmc-part_config == MMCPART_NOAVAILABLE) { + printf(Card doesn't support part_switch\n); + return -1; + } + + ret = mmc_switch_part(dev_num, hwpart); + if (ret) + return -1; + + mmc-part_num = hwpart; + + return 0; +} + + int mmc_switch_part(int dev_num, unsigned int part_num) { struct mmc *mmc = find_mmc_device(dev_num); diff --git a/include/part.h b/include/part.h index 53532dcd6120..f2c8c641faa8 100644 --- a/include/part.h +++ b/include/part.h @@ -103,6 +103,7 @@ block_dev_desc_t* sata_get_dev(int dev); block_dev_desc_t* scsi_get_dev(int dev); block_dev_desc_t* usb_stor_get_dev(int dev); block_dev_desc_t* mmc_get_dev(int dev); +int mmc_select_hwpart(int dev_num, int hwpart); block_dev_desc_t* systemace_get_dev(int dev); block_dev_desc_t* mg_disk_get_dev(int dev); block_dev_desc_t *host_get_dev(int dev); @@ -126,6 +127,7 @@ static inline block_dev_desc_t* sata_get_dev(int dev) { return NULL; } static inline block_dev_desc_t* scsi_get_dev(int dev) { return NULL; } static inline block_dev_desc_t* usb_stor_get_dev(int dev) { return NULL; } static inline block_dev_desc_t* mmc_get_dev(int dev) { return NULL; } +static inline int mmc_select_hwpart(int dev_num, int hwpart) { return -1; } static inline block_dev_desc_t* systemace_get_dev(int dev) { return NULL; } static inline block_dev_desc_t* mg_disk_get_dev(int dev) { return NULL; } static inline block_dev_desc_t *host_get_dev(int dev) { return NULL; } -- 1.8.1.5 Applied, but expect a follow up patch for returning something else than -1. Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 4/4] cmd_mmc: use new mmc_select_hwpart() function
Hi Stephen, On May 7, 2014, at 9:19 PM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com The implementation of mmc_select_hwpart() was cribbed from do_mmcops(). Update do_mmcops() to call mmc_select_hwpart() to avoid duplication. Signed-off-by: Stephen Warren swar...@nvidia.com --- common/cmd_mmc.c | 19 +-- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index c1916c9b56a6..572aa895fa1c 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -193,7 +193,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_mmc_devices('\n'); return 0; } else if (strcmp(argv[1], dev) == 0) { - int dev, part = -1; + int dev, part = -1, ret; struct mmc *mmc; if (argc == 2) @@ -219,20 +219,11 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) mmc_init(mmc); if (part != -1) { - int ret; - if (mmc-part_config == MMCPART_NOAVAILABLE) { - printf(Card doesn't support part_switch\n); + ret = mmc_select_hwpart(dev, part); + printf(switch to partitions #%d, %s\n, +part, (!ret) ? OK : ERROR); + if (ret) return 1; - } - - if (part != mmc-part_num) { - ret = mmc_switch_part(dev, part); - if (!ret) - mmc-part_num = part; - - printf(switch to partitions #%d, %s\n, - part, (!ret) ? OK : ERROR); - } } curr_device = dev; if (mmc-part_config == MMCPART_NOAVAILABLE) -- 1.8.1.5 Due to patch order mangling, I've applied but with some manual placement. Please verify that it works properly on your end after the patches land at u-boot-mmc. Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] Pull request: u-boot-mmc 23052014
Hi Tom, The following changes since commit d7782d06534fe4fa47a49fa7c106de5ba85a9687: Merge branch 'master' of git://git.denx.de/u-boot-mpc85xx (2014-05-16 18:30:33 -0400) are available in the git repository at: git://git.denx.de/u-boot-mmc.git master for you to fetch changes up to df348d8245922adbb03a3a979429c5e70342973c: cmd_mmc: use new mmc_select_hwpart() function (2014-05-23 12:23:28 +0300) Andrew Gabbasov (1): mmc: Handle switch error status bit in MMC card status Hannes Petermaier (1): Add board_mmc_init(...) function for init mmc1 only Mateusz Zalega (1): mmc: postponed needless timer initialization Pierre Aubert (3): eMMC: add support for operations in RPMB partition Add the function 'confirm_yesno' for interactive eMMC: cmd_mmc.c adds the 'rpmb' sub-command for the 'mmc' command Stephen Warren (4): cmd_part: fix typo in part command help text disk: support devices with HW partitions mmc: provide a select_hwpart implementation for get_device() cmd_mmc: use new mmc_select_hwpart() function Ye.Li (1): esdhc/usdhc: Fix PIO mode bug in fsl_esdhc driver README| 10 ++ board/BuR/common/common.c | 7 + common/cmd_fuse.c | 11 +- common/cmd_mmc.c | 799 +--- common/cmd_nand.c | 16 +-- common/cmd_otp.c | 18 +-- common/cmd_part.c | 2 +- common/console.c | 28 +++- disk/part.c | 80 +-- drivers/mmc/Makefile | 1 + drivers/mmc/fsl_esdhc.c | 23 ++- drivers/mmc/mmc.c | 35 - drivers/mmc/rpmb.c| 323 ++ include/common.h | 2 +- include/configs/kwb.h | 2 +- include/configs/tseries.h | 2 +- include/mmc.h | 12 +- include/part.h| 2 + lib/Makefile | 1 + 19 files changed, 1009 insertions(+), 365 deletions(-) create mode 100644 drivers/mmc/rpmb.c Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH 3/4] mmc: provide a select_hwpart implementation for get_device()
Hi Stephen, On May 23, 2014, at 6:58 PM, Stephen Warren wrote: On 05/23/2014 03:21 AM, Pantelis Antoniou wrote: Hi Stephen, On May 7, 2014, at 9:19 PM, Stephen Warren wrote: This enables specifying which eMMC HW partition to target for any U-Boot command that uses the generic get_partition() function to parse its command-line arguments. Applied, but expect a follow up patch for returning something else than -1. What else should it return? -1 is consistent with plenty of code in that file... Some kind of -ERRNO value? Regards -- Pantelis ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
Re: [U-Boot] [PATCH] mmc: return meaningful error codes from mmc_select_hwpart
Hi Stephen, On May 23, 2014, at 9:47 PM, Stephen Warren wrote: From: Stephen Warren swar...@nvidia.com Rather than just returning -1 everywhere, try to return something meaningful from mmc_select_hwpart(). Note that most other MMC functions don't do this, including functions called from mmc_select_hwpart(), so I'm not sure how effective this will be. Still, it's one less place with hard-coded -1. Suggested-by: Pantelis Antoniou pa...@antoniou-consulting.com Signed-off-by: Stephen Warren swar...@nvidia.com --- drivers/mmc/mmc.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 8b53ead98f80..221a293797e9 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -10,6 +10,7 @@ #include config.h #include common.h #include command.h +#include errno.h #include mmc.h #include part.h #include malloc.h @@ -558,19 +559,19 @@ int mmc_select_hwpart(int dev_num, int hwpart) int ret; if (!mmc) - return -1; + return -ENODEV; if (mmc-part_num == hwpart) return 0; if (mmc-part_config == MMCPART_NOAVAILABLE) { printf(Card doesn't support part_switch\n); - return -1; + return -EMEDIUMTYPE; } ret = mmc_switch_part(dev_num, hwpart); if (ret) - return -1; + return ret; mmc-part_num = hwpart; -- 1.8.1.5 This does indeed look good. Thanks -- Pantelis Acked-by: Pantelis Antoniou pa...@antoniou-consulting.com ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot