From: Lukasz Majewski Date: Fri, 02 Nov 2012 08:38:06 +0100 Subject: [U-Boot] [PATCH] powerpc/esdhc: force the bus width to 4bit In-Reply-To: References: <1350973580-31726-1-git-send-email-Chang-Ming.Huang@freescale.com> <201210230924.28042.marex@denx.de> <110EED8CC96DFC488B7E717A2027A27C1C69C2@039-SN1MPN1-003.039d.mgd.msft.net> <201210231150.49779.marex@denx.de> <508F934C.5020705@samsung.com> <20121030183541.06766bf7@amdc308.digital.local> Message-ID: <20121102083806.05348b96@amdc308.digital.local> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Andy, > > > > 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. I admit, that this code was a hack, I will even say more (after the "big picture" presented by You) - I've delivered very low quality code. Shame on me - my fault. Period. > > 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 -- Best regards, Lukasz Majewski Samsung Poland R&D Center | Linux Platform Group