
Hmm... looks like it is code done by me :-) So little explanation shall be given.
This code is necessary for some targets (like Samsung's Goni) which can only support 4 bit MMC mode.
for (; width >= 0; width--) { ....
So for FSL ESDHC, the width = 3, after implement mmc_switch successfully, will set the bus to 4 * width. Therefore, I will get the 12bit (4 x 3) bus width.
This problem is MMC subsystem's bug. I think good that will modify the code in mmc.c. If caps is set to MMC_MODE_4BIT | MMC_MODE_8BIT, we can see the 12bit support with using "mmcinfo" command
The mmc_set_bus_width(mmc, 4 * width) in conjunction to above code causes the problem.
I agree, that this code shall be refactored. Lei, what do you think?
I am... very confused by this whole thread. And the code associated with it. The host_caps field has a bitmask which declares the widths supported by a given controller.
What would possess you to index them by addition, and convert their values by multiplication?? It's a bitfield! I'm embarrassed that I allowed this code in, and will review future submissions from you with a very skeptical eye.
Ah, and further review indicates it is Lei Wen who introduced the idea of iterating through a bitfield by subtraction, though I can see how iterating through the EXT_CSD *field* definition (which looks a lot like a bitfield, but may not be) *might* be considered reasonable.
Meanwhile, Huang Changming, why would you see this broken code, and then decide the best workaround was to cripple our controller by eliminating support for 8-bit?
I'm going to fix this right now. Probably in the quite sensible way that Jaehoon Chung suggested.
Andy