Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1011551iob; Fri, 13 May 2022 19:33:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+LLgXhxszIBsLHlRgb+4ur6wSSvZnaxhkiBtRW4eYTyz1B8tT80elQod97vhIXeaGV+Ty X-Received: by 2002:adf:f210:0:b0:20c:dd8b:7e8f with SMTP id p16-20020adff210000000b0020cdd8b7e8fmr5790713wro.411.1652495613364; Fri, 13 May 2022 19:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652495613; cv=none; d=google.com; s=arc-20160816; b=F263PtuIwh7dBEMHK56jf7dd64liHaad0kK64VoZme4/AqNlrqI3UOF98EpX+cph7b S4rl5LYw9zqzrLYiKzr9dFdoGs6100/oryBfCtPFoVVhcOeWOl1DtyFlUvdq0Yxg2lx/ pMveMCvIhks3pDKCgkplCna5t6k9fNFnTzh3QLDzYu7jeR0f5kpakd87JVBqKhEsTRk0 yXje0z1uuDmDuyspieWshy7b5lMyWMII3DnHTRK4xn40muU3UGptjtf0SfRAkLm2nxy/ wYZPh1b9tEez0l5IeumWOPeBp9ghJXD922R5N8LYJnw2k0MsYpzl5/SdRxY7ZJATudfs 6wyg== 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=IKT2KSvYWXPBkOJxNY0KP8UqAnlGlkZXTyC2nKMMHCE=; b=L3rM+jeVb5fbZUfs5Z4b6mGcSMjTMOuy7eq720WSWmuZ5f6u8iXk0BkcZ+tQpJoGrE nynihF9wd0S31Vu7OVbbxYb/HKkUoTE70aHG+jI3wutuTcut9xvaPP53QL8DgH9gcqeF hzGH3cqyNOmzicmsmTjshLIVfDF4myQIcMUP4lg//13XAnxh4+djSaWJCDeCLdDHRKKX Uvm9c/tLCU2TvPbClsAd+CXBMrI3T4ip6mKqQNLAF70ZzM9yDqM5LAHxytcLDfrdPg1K ojKYFuFKWByispHzGov5GOsXfn0dWnTCv3UQ8419VsZ2ut+HUY/06KPDk7UZgTIPxo8N 4T2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gjXd8tyI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id f16-20020a5d6650000000b0020c5fc1fd01si3415276wrw.247.2022.05.13.19.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:33:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gjXd8tyI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8901432FBE9; Fri, 13 May 2022 17:46:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377268AbiEMO13 (ORCPT + 99 others); Fri, 13 May 2022 10:27:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380701AbiEMOZ6 (ORCPT ); Fri, 13 May 2022 10:25:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 241F66B659; Fri, 13 May 2022 07:25:21 -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 C8D5BB83068; Fri, 13 May 2022 14:25:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E688C34100; Fri, 13 May 2022 14:25:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652451918; bh=CiGNaB9PdFEDjJaiY6qic2eYiJtF5CwjFMm9j/i3FFo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjXd8tyISen/rl/lMkBxTLUre+54S3BhBDpytA+lhI2s9X4u+T75Sa7xf8U/W2/jd YL84r0GV8RmGAJJ5+jnptjCHiJ9l3tjOZFVbzs5YwVAcNzbbE2R2K/Zx8DZvmP64Wl 2uiZMEh0SFUcJHOsT5CZR4/isRNxgR4ALQ102U7Q= 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 4.14 06/14] mmc: rtsx: add 74 Clocks in power on flow Date: Fri, 13 May 2022 16:23:22 +0200 Message-Id: <20220513142227.571293193@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220513142227.381154244@linuxfoundation.org> References: <20220513142227.381154244@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=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Ricky Wu Signed-off-by: Ulf Hansson Signed-off-by: Christian Loehle Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/rtsx_pci_sdmmc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) --- a/drivers/mmc/host/rtsx_pci_sdmmc.c +++ b/drivers/mmc/host/rtsx_pci_sdmmc.c @@ -49,10 +49,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; @@ -913,14 +910,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, @@ -939,11 +943,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; } @@ -952,7 +962,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); @@ -978,7 +988,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; } @@ -1416,7 +1426,7 @@ static int rtsx_pci_sdmmc_drv_probe(stru 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;