Hi,

On 07/04/2014 04:31 AM, Wills Wang wrote:
> Hi,
>>
>>> diff --git a/drivers/mmc/sunxi_mmc.c b/drivers/mmc/sunxi_mmc.c
>>> index bbfe8a3..f0cb760 100644
>>> --- a/drivers/mmc/sunxi_mmc.c
>>> +++ b/drivers/mmc/sunxi_mmc.c
>>> @@ -173,8 +173,6 @@ static int mmc_core_init(struct mmc *mmc)
>>>       /* Reset controller */
>>>       writel(SUNXI_MMC_GCTRL_RESET, &mmchost->reg->gctrl);
>>>       udelay(1000);
>>> -    /* Always read / write data through the CPU */
>>> -    writel(SUNXI_MMC_GCTRL_ACCESS_BY_AHB, &mmchost->reg->gctrl);
>>>         return 0;
>>>   }
>>> @@ -189,6 +187,13 @@ static int mmc_trans_data_by_cpu(struct mmc *mmc, 
>>> struct mmc_data *data)
>>>       unsigned byte_cnt = data->blocksize * data->blocks;
>>>       unsigned timeout_msecs = 2000;
>>>       unsigned *buff = (unsigned int *)(reading ? data->dest : data->src);
>>> +    unsigned int gctrl;
>>> +
>>> +    /* Always read / write data through the CPU */
>>> +    gctrl = readl(&mmchost->reg->gctrl);
>>> +    gctrl &= ~SUNXI_MMC_GCTRL_ACCESS_BY_AHB;
>> The above line seems redundant / unnecessary.
> 
> These lines are based on read-modify-write principle, the mmc hardware on 
> sunxi have no detail document, we don't know what happen when operate this 
> register in actually.

Right, but the line below this one:

>>> +    gctrl |= SUNXI_MMC_GCTRL_ACCESS_BY_AHB;

Undoes the clearing you're doing. And you are not working on
a register here, but on a local variable. So likely the
C-compiler will just optimize away the redundant line.

But even if the compiler does not optimize it away, then
the mmc controller still will not see it as the
|= overrules the &= and the result is not written to the
mmc controller until after the |= .

Can you please try with the redundant line removed ?



>>> +    writel(gctrl, &mmchost->reg->gctrl);
>> And why is it necessary to move this call at all ? The only reason I
>> can think of why you need this is because of the
>>   writel(SUNXI_MMC_GCTRL_RESET, &mmchost->reg->gctrl);
>>
>> Done in mmc_send_cmd on error, that call really should also include
>> a delay and as such should probably just be replaced with a call
>> to mmc_core_init(). Can you try to build u-boot with your fix
>> reverted and with the above line in mmc_send_cmd replaced with
>> a call to mmc_core_init(), and see if that also fixes things ?
> 
> I have tried, but failed.

Ok, thanks for trying.

Regards,

Hans

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to