Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp691721ybb; Wed, 1 Apr 2020 07:57:50 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsbwQCzeGDQEVoLGPizj++9ibXlK5OgYmEunshtyfFn7ukkMiP73AJgAKiOw3+6yj8aI5oT X-Received: by 2002:a05:6830:1dfa:: with SMTP id b26mr16370274otj.13.1585753069861; Wed, 01 Apr 2020 07:57:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585753069; cv=none; d=google.com; s=arc-20160816; b=Ifxj52v6vozSG2+iC+B3m+dmtDJn6o+SXGQPBr0D/mFx/WrXZYRHelmCOGtaRA5rqx ZOBTdaCyh9tpTpl7lt7m+a2N2AxUuQITHFmW1f01aXAiEBzRWsx1MSPJiZsIAtAuUPIG wPnBQEWzV9BmOL1nJrebJNtPnU9KKb8Dn17Zzi2qJT5mGfGT8vm9m57IuApDbVnE+RUW 0033MoO7UpPHHZ7xaNwlVLPwBHzDX7/G23MLBEsUshxhxDtgFZ9UgbKFQ4R3SxxFTsND 2vF5pgyYNlOpGs7cApwd17FgCc7McQhr8SC1q4pxtqnKmlx/MOpv3rB8wNyuxNFyWOVT uv/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=EWMX4dUTXREC+QeK0mkhl2un1ScVfvreF/9iNkJ/5Po=; b=C1DPxvxnJr7+/2iA/3xg5VUhPJ9D061xNtklRPhaQcKots2U0KSCh80FQ3N9vcCeKZ OUrSm8hX1dbpz+Posn55n8LgQuX3rys/KjOfN7IKf+0miu0CA/VJBx5RHopy3vpN+fw0 PmPf1C0ktdul6jQ01ivuqxbsqShkUbCrTY7mgS1oLSxdepN3L6V1pdwkrkUwcOJP69rK aggnLTmHkV3Y5kDKqo4Fa5FYlwHQrJHjMhyXruIrZ3/V2YBlKXQEUPFZNAkyOiSFsw3/ DFQh8psOAY0ep5DjMn4EDY9+y6pEk9D5Bi2PTkrX6ho9bP/PIWFB2lOVYb35SCI40ulB Ho0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=EqXV77Ep; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x1si804756otq.201.2020.04.01.07.57.36; Wed, 01 Apr 2020 07:57:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=EqXV77Ep; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733114AbgDAO5C (ORCPT + 99 others); Wed, 1 Apr 2020 10:57:02 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:55382 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732749AbgDAO5B (ORCPT ); Wed, 1 Apr 2020 10:57:01 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 031EqsY1011855; Wed, 1 Apr 2020 16:56:45 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=EWMX4dUTXREC+QeK0mkhl2un1ScVfvreF/9iNkJ/5Po=; b=EqXV77Ep73eZP2cgb6Lj9cLoPU4qcrBy7L3S7hmXOlTtfCRsZXp+y6peR1F9Kt2uUucl rL9Ohb2+xh26Vji44m4fnag+UcTxRGGclg3p67s6rujUDJ2Q2BQYORfVJJIf6+CzmU2a de022IfAqZpjYUz4smduOYhweYdzsCP0Cqy96IwA7wvHh+xgxgpZV5IckpQ/gfwVsp4X PRygAtG2fEwkEtT8iO1NVg/mor/oLcPde8KpzJ6d09vf9rAKv8MoP6DpSYIzzbIRhXqT ynTeu5YKOGaQMZP35x97iOrNjUQqGb7WC3Wg7QvKpyp8zGMGsVvVPdrOS0kjV/1EnbIf rw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 302y5401q9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 01 Apr 2020 16:56:45 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6E1CE10002A; Wed, 1 Apr 2020 16:56:44 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag6node1.st.com [10.75.127.16]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5C4242B1899; Wed, 1 Apr 2020 16:56:44 +0200 (CEST) Received: from lmecxl0923.lme.st.com (10.75.127.46) by SFHDAG6NODE1.st.com (10.75.127.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 1 Apr 2020 16:56:43 +0200 Subject: Re: [PATCH V2 2/2] mmc: mmci: initialize pwr|clk|datactrl_reg with their hardware values To: Ulf Hansson CC: Rob Herring , Srini Kandagatla , Maxime Coquelin , Alexandre Torgue , Linux ARM , Linux Kernel Mailing List , DTML , "linux-mmc@vger.kernel.org" , References: <20200325143409.13005-1-ludovic.barre@st.com> <20200325143409.13005-3-ludovic.barre@st.com> From: Ludovic BARRE Message-ID: <734ef31d-5104-c7d4-bf14-6bb116484010@st.com> Date: Wed, 1 Apr 2020 16:56:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG6NODE1.st.com (10.75.127.16) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-01_01:2020-03-31,2020-03-31 signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org hi Ulf Le 3/26/20 à 3:27 PM, Ulf Hansson a écrit : > On Wed, 25 Mar 2020 at 15:34, Ludovic Barre wrote: >> >> In mmci_write_pwr|clk|datactrlreg functions, if the desired value >> is equal to corresponding variable (pwr_reg|clk_reg|datactrl_reg), >> the value is not written in the register. >> >> At probe pwr|clk|datactrl_reg of mmci_host structure are initialized >> to 0 (kzalloc of mmc_alloc_host). But they does not necessarily reflect >> hardware value of these registers, if they are used while boot level. >> This is problematic, if we want to write 0 in these registers. > > It could be, but I don't see that we ever needs to do that - at least > not before we have written some other non-zero values to them (through > the helper functions). > The sdmmc variant is slightly different on pwr_ctrl field of MMCIPOWER register. In classic mmci we have 3 or 2 values: MMCI_PWR_OFF(0x0), MMCI_PWR_UP(0x2)optional, MMCI_PWR_ON(0x3) -When you switch the external power supply off, the software set power-off (0x0). -When you switch the external power supply on, the software first enters the power-up(0x2) phase, and waits until the supply output is stable before moving to the power-on (0x3)phase. On sdmmc we have 3 values: MMCI_PWR_OFF(0x0), MCI_STM32_PWR_CYC(0x2), MMCI_PWR_ON(0x3) -When you switch the external power supply off, the software must MCI_STM32_PWR_CYC(0x2) => This will make that the SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are driven low, to prevent the card from being supplied through the signal lines. -When you switch the external power supply on, when supply output is stable the MMCI_PWR_OFF(0x0) state can be apply (minimum 1ms) => The SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are set to drive “1”. After MMCI_PWR_ON(0x3) stat could be set. In fact the last value of power off sequence is different between classic and sdmmc: The classic mmci finish the power off sequence by 0x0, But the sdmmc finish by 0x2, and we must write 0x0 in power on sequence before set MMCI_PWR_ON. The 0x0 value is not written due to kzalloc value of pwr_reg (which not reflect hardware value of pwr register). >> >> This patch initializes pwr|clk|datactrl_reg variables with their >> hardware values while probing. > > Hmm, so in principle this change seems quite okay, but I am hesitant > to pick it up - unless it really addresses a problem that you have > observed. > > The reason is, this change may lead to avoiding to re-write the > register with the same value it got during boot - and who knows what > is best here. I understand your hesitation. If you prefer, I can move the pwr_reg initialisation in sdmmc_variant_init ? Regards Ludo > > Kind regards > Uffe > >> >> Signed-off-by: Ludovic Barre >> --- >> drivers/mmc/host/mmci.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c >> index 647567def612..f378ae18d5dc 100644 >> --- a/drivers/mmc/host/mmci.c >> +++ b/drivers/mmc/host/mmci.c >> @@ -2085,6 +2085,10 @@ static int mmci_probe(struct amba_device *dev, >> else if (plat->ocr_mask) >> dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n"); >> >> + host->pwr_reg = readl_relaxed(host->base + MMCIPOWER); >> + host->clk_reg = readl_relaxed(host->base + MMCICLOCK); >> + host->datactrl_reg = readl_relaxed(host->base + MMCIDATACTRL); >> + >> /* We support these capabilities. */ >> mmc->caps |= MMC_CAP_CMD23; >> >> -- >> 2.17.1 >>