From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Fri, 02 Nov 2012 10:12:01 -0600 Subject: [U-Boot] [RFC] mmc: Properly determine maximum supported bus width In-Reply-To: <1351746158-19009-1-git-send-email-afleming@freescale.com> References: <1351746158-19009-1-git-send-email-afleming@freescale.com> Message-ID: <5093F0D1.5040704@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 10/31/2012 11:02 PM, Andy Fleming wrote: > At some point, a confusion arose about the use of the bit > definitions in host_caps for bus widths, and the value > in ext_csd. By coincidence, a simple shift could convert > between one and the other: > > MMC_MODE_1BIT = 0, EXT_CSD_BUS_WIDTH_1 = 0 > MMC_MODE_4BIT = 0x100, EXT_CSD_BUS_WIDTH_4 = 1 > MMC_MODE_8BIT = 0x200, EXT_CSD_BUS_WIDTH_8 = 2 > > However, as host_caps is a bitmask of supported things, > there is not, in fact, a one-to-one correspondence. host_caps > is capable of containing MODE_4BIT | MODE_8BIT, so nonsensical > things were happening where we would try to set the bus width > to 12. > > The new code clarifies the very different namespaces: > > host_caps/card_caps = bitmask (MMC_MODE_*) > ext CSD fields are just an index (EXT_CSD_BUS_WIDTH_*) > mmc->bus_width integer number of bits (1, 4, 8) > > We create arrays to map between the namespaces, like in Linux. (Coupled with a small change to the Tegra driver to correctly set host_caps for 8-/4-bit, which I'll post shortly), Tested-by: Stephen Warren Interestingly, I just yesterday started working on a bug I'd filed months ago to enable 8-bit eMMC support on Tegra, and found the 12-bit issue, and came up with a very similar patch. Oh well!