Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6260568iob; Tue, 10 May 2022 14:14:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysvScjFGP1vbIB0mXuBpor44sI8AEQhXf3mABJMRNa8q6lgG8hjKrPH2ErkJnbNnsZ4cHI X-Received: by 2002:a63:4d17:0:b0:3da:eda2:444a with SMTP id a23-20020a634d17000000b003daeda2444amr3678599pgb.180.1652217250757; Tue, 10 May 2022 14:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652217250; cv=none; d=google.com; s=arc-20160816; b=QD43Sm6B3jEExlJEAXIwQAUjCiPEihl5DJxe5ppWGevU+/G2R95oiVozeY8LAEjbk6 V2qg58DzIfUrawD+WdB4MGwQx8UIvmdWHRryqoh0Yv7bohB5RKlvkSfRy7aZnUI4j6Cs e/ls5NlvD0SYJfnakxUh7fSmuM49hSHQxR9GXp8R1XOYSxa3CdkxfIbW5xJDW9mLUCaN 3Sd1CFalt4XsRdNElO6t1+PBEK8X7xop1f/5N2XLjVYKCIHFWTZcAPWkiHsjX1xJuJRt WaSM22x5y2XGj3LMq5aZ7y+dIn1N28Mm3Itmi1YnBqfBG7mKS/57EKHyg+Nz+YgxdJpu AkLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Uc551HSIDE/fD67njuz1H9rgfrGW7EyGr+OU2KC8Zs0=; b=JhvCmACpm/BXkYGFPOuUsiiZQwdC+pILut3shSilEaSP57ETSJbf33vFYcmJDDLdSB auUeI1mRDqW3yXzazaDwBjVY/A8Xvil252HYrWcBsrsJD3Ln77IC9rHZfaSUIR21e2G0 yrmA0CwQtcO9YQWb34kOGTVnL75uZIpH9Jh93lmi5hU0eb8ZrCwXLC+z5TNSMsSbPXGK N/1RiZqpvnQJ8K7Y/JO83H4xaxqZ/MJvllWXqBptdOAV3vtZnEDPr6or9ts/1A+bZfl+ yywwBbLJ7PpSN5UlALel3dkRKi1pIdWuZMgSIL5f+GnwNezMioKcVHhPYHltLnYZhY9G aAnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zDMcKjok; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a170902ce8100b0015eaa840a13si236558plg.224.2022.05.10.14.13.54; Tue, 10 May 2022 14:14:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zDMcKjok; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245644AbiEJN60 (ORCPT + 99 others); Tue, 10 May 2022 09:58:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245189AbiEJNih (ORCPT ); Tue, 10 May 2022 09:38:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6856E268223; Tue, 10 May 2022 06:28:23 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1B3B8B81D24; Tue, 10 May 2022 13:28:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BB60C385A6; Tue, 10 May 2022 13:28:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652189300; bh=/Nq8sOMYYkVW91fUqgNO+MrVS7wvcRikl8+thWTEhm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zDMcKjokllCtwW+BBtVmR62bHQg0NaUQhzGlOosIyJkPbCpfuypBOGVOLk7I7C+2A wHlyW3E4M9lwnTYA/zOlNWKqSw6PKSTYb8CkvekLpIsjxZ+TEfdIqmeHdTMuD7zzkm 8PPxaRgV5F44P82qC8ZXSiZMIrR+5NpL9vCjltx0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ricky Wu , Ulf Hansson , Christian Loehle Subject: [PATCH 5.10 70/70] mmc: rtsx: add 74 Clocks in power on flow Date: Tue, 10 May 2022 15:08:29 +0200 Message-Id: <20220510130734.913421890@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220510130732.861729621@linuxfoundation.org> References: <20220510130732.861729621@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ricky WU commit 1f311c94aabdb419c28e3147bcc8ab89269f1a7e upstream. SD spec definition: "Host provides at least 74 Clocks before issuing first command" After 1ms for the voltage stable then start issuing the Clock signals if POWER STATE is MMC_POWER_OFF to MMC_POWER_UP to issue Clock signal to card MMC_POWER_UP to MMC_POWER_ON to stop issuing signal to card Signed-off-by: Ricky Wu Link: https://lore.kernel.org/r/1badf10aba764191a1a752edcbf90389@realtek.com Signed-off-by: Ulf Hansson Signed-off-by: Christian Loehle Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/rtsx_pci_sdmmc.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) --- a/drivers/mmc/host/rtsx_pci_sdmmc.c +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c @@ -37,10 +37,7 @@ struct realtek_pci_sdmmc { bool double_clk; bool eject; bool initial_mode; - int power_state; -#define SDMMC_POWER_ON 1 -#define SDMMC_POWER_OFF 0 - + int prev_power_state; int sg_count; s32 cookie; int cookie_sg_count; @@ -902,14 +899,21 @@ static int sd_set_bus_width(struct realt return err; } -static int sd_power_on(struct realtek_pci_sdmmc *host) +static int sd_power_on(struct realtek_pci_sdmmc *host, unsigned char power_mode) { struct rtsx_pcr *pcr = host->pcr; int err; - if (host->power_state == SDMMC_POWER_ON) + if (host->prev_power_state == MMC_POWER_ON) return 0; + if (host->prev_power_state == MMC_POWER_UP) { + rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, 0); + goto finish; + } + + msleep(100); + rtsx_pci_init_cmd(pcr); rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SELECT, 0x07, SD_MOD_SEL); rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_SHARE_MODE, @@ -928,11 +932,17 @@ static int sd_power_on(struct realtek_pc if (err < 0) return err; + mdelay(1); + err = rtsx_pci_write_register(pcr, CARD_OE, SD_OUTPUT_EN, SD_OUTPUT_EN); if (err < 0) return err; - host->power_state = SDMMC_POWER_ON; + /* send at least 74 clocks */ + rtsx_pci_write_register(pcr, SD_BUS_STAT, SD_CLK_TOGGLE_EN, SD_CLK_TOGGLE_EN); + +finish: + host->prev_power_state = power_mode; return 0; } @@ -941,7 +951,7 @@ static int sd_power_off(struct realtek_p struct rtsx_pcr *pcr = host->pcr; int err; - host->power_state = SDMMC_POWER_OFF; + host->prev_power_state = MMC_POWER_OFF; rtsx_pci_init_cmd(pcr); @@ -967,7 +977,7 @@ static int sd_set_power_mode(struct real if (power_mode == MMC_POWER_OFF) err = sd_power_off(host); else - err = sd_power_on(host); + err = sd_power_on(host, power_mode); return err; } @@ -1404,10 +1414,11 @@ static int rtsx_pci_sdmmc_drv_probe(stru host = mmc_priv(mmc); host->pcr = pcr; + mmc->ios.power_delay_ms = 5; host->mmc = mmc; host->pdev = pdev; host->cookie = -1; - host->power_state = SDMMC_POWER_OFF; + host->prev_power_state = MMC_POWER_OFF; INIT_WORK(&host->work, sd_request); platform_set_drvdata(pdev, host); pcr->slots[RTSX_SD_CARD].p_dev = pdev;