Re: [PATCH v2 2/4] mmc: core: group default initial state

Ulf Hansson
2014-11-06T09:38:16Z

[...]

>>
>> Earlier we used always used MMC_BUSMODE_PUSHPULL, now it will depend on "spi".
>
> The JEDEC spec says that in device identification mode the bus should
> be open-drain and not push-pull. So this way should be compliant to
> the spec, right? Unfortunately, I will require help in testing this on
> a proper eMMC.

For MMC yes, but you will break SD/SDIO in this patch.

The default bus mode at initialization needs to be
MMC_BUSMODE_PUSHPULL, since that's required by the SD/SDIO spec.

The MMC cards are being initialized after SD and SDIO, which means a
switch to MMC_BUSMODE_OPENDRAIN is done in mmc_attach_mmc().
Additionally, to handle resume of MMC cards, mmc_init_card() also do a
switch to MMC_BUSMODE_OPENDRAIN.

>
> I can't find anything in the JEDEC or the SD spec about bus mode in
> SPI mode though. However, this behavior is not changed by this patch,
> so we should be safe.

SPI mode has been removed from the eMMC spec.

The SD spec doesn't have open drain mode but do support SPI mode. That
tells me that we should keep using MMC_BUSMODE_PUSHPULL for SPI mode.

>
>>> host->ios.power_mode = MMC_POWER_UP;
>>> - host->ios.bus_width = MMC_BUS_WIDTH_1;
>>> - host->ios.timing = MMC_TIMING_LEGACY;
>>> - mmc_set_ios(host);
>>> + /* Set initial state and call mmc_set_ios */
>>> + mmc_set_initial_state(host);
>>>
>>> /* Try to set signal voltage to 3.3V but fall back to 1.8v or 1.2v */
>>> if (__mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330) == 0)
>>> @@ -1582,14 +1594,9 @@ void mmc_power_off(struct mmc_host *host)
>>> host->ios.clock = 0;
>>> host->ios.vdd = 0;
>>>
>>> - if (!mmc_host_is_spi(host)) {
>>> - host->ios.bus_mode = MMC_BUSMODE_OPENDRAIN;
>>> - host->ios.chip_select = MMC_CS_DONTCARE;
>>
>> So in here another change in behaviour, right!?
>
> Ok, so the behavior for SPI is changed in this case, now we explicitly
> set the bus+cs modes and before we left them as they were.
>
> Does this matter though, since we're powering off the device and the
> bus+cs modes will be set on the subsequent mmc_power_up?

That seems reasonable, it shouldn't be an issue.

Kind regards
Uffe