From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 201D544CAE0; Tue, 16 Jun 2026 15:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624295; cv=none; b=R1+y2TJuVDUSB4wnR+08g7Uu3Ph5dcpqAZUL483ZwfwW4ctwX2UUmd3kGSdofNgyW5tLWc2RjGIGra68fgA0/3YZaMyM6xO3LB39nXbu4IK2r8bi56RmOGjjaugl22CziFhQznxL2vlC5AKymCb1quSuZebGbIzT3frpb4z5lVk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781624295; c=relaxed/simple; bh=HndvdQadL2BOVDlxA492qgXoBd0irZYz/j5mVVVQroY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6IVIJiXF+HyJ/sIyP1HcvN4VocdODsAlFET/vIZTzYTL+T8TIvpX4Hu6RiBZiFePm/XGgtFEU+QF9iRW6ZZBvdClajDVzY0V3IapH5cJJ9cARRHEUJWoKbcsVYcO+rImKz+s1SUIwqRr6t9sUPLXw8Hw2VIiNSonm50LMx9Q4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zX6rrNut; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zX6rrNut" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F21591F000E9; Tue, 16 Jun 2026 15:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781624293; bh=zzzMFKCv735k4uXaq+jMx9M2op7ZEvxe2J6NYk21+To=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zX6rrNutGz0OP/AnZtwEopYixkHELfy/qWEzg6PaQ4VDpAJNKkd1j649pHtbbPWhj ZfeW68DQGvWaai47zHmW2WDUW0fGe0LmXCEWjZg4cej2jjeLReUCq/1445fSF5J5e3 2mDtbBhJyBH4zUl7/eZalgoMkNnyxWZ2cti+ORYE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Inochi Amaoto , Gabriel Somlo , Ulf Hansson Subject: [PATCH 7.0 309/378] mmc: litex_mmc: Set mandatory idle clocks before CMD0 Date: Tue, 16 Jun 2026 20:29:00 +0530 Message-ID: <20260616145126.467397097@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145109.744539446@linuxfoundation.org> References: <20260616145109.744539446@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Inochi Amaoto commit 99982b743e5ba72bd1f5de0e03e3b96ae70b1e51 upstream. The litex_mmc driver assumes the card is already probed in the BIOS and skip the phy initialization. This will cause the command fail like the following when the old card is unplugged and then insert a new card: [ 62.923593] litex-mmc f0004000.mmc: Command (cmd 8) error, status -110 [ 62.949717] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 [ 62.976606] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 [ 63.002516] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 [ 63.028442] litex-mmc f0004000.mmc: Command (cmd 55) error, status -110 Add required clock settings and initialization for the CMD 0, so it can probe the new card. Fixes: 92e099104729 ("mmc: Add driver for LiteX's LiteSDCard interface") Signed-off-by: Inochi Amaoto Reviewed-by: Gabriel Somlo Cc: stable@vger.kernel.org Signed-off-by: Ulf Hansson Signed-off-by: Greg Kroah-Hartman --- drivers/mmc/host/litex_mmc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/drivers/mmc/host/litex_mmc.c +++ b/drivers/mmc/host/litex_mmc.c @@ -69,6 +69,9 @@ #define SD_SLEEP_US 5 #define SD_TIMEOUT_US 20000 +#define SD_INIT_DELAY_US 1000 +#define SD_INIT_CLK_HZ 400000 + #define SDIRQ_CARD_DETECT 1 #define SDIRQ_SD_TO_MEM_DONE 2 #define SDIRQ_MEM_TO_SD_DONE 4 @@ -450,6 +453,17 @@ static void litex_mmc_set_ios(struct mmc struct litex_mmc_host *host = mmc_priv(mmc); /* + * The SD specification requires at least 74 idle clocks before CMD0. + * These dummy cycles is generated by writing LITEX_PHY_INITIALIZE. + */ + if (ios->chip_select == MMC_CS_HIGH) { + litex_mmc_setclk(host, SD_INIT_CLK_HZ); + litex_write8(host->sdphy + LITEX_PHY_INITIALIZE, 1); + fsleep(SD_INIT_DELAY_US); + return; + } + + /* * NOTE: Ignore any ios->bus_width updates; they occur right after * the mmc core sends its own acmd6 bus-width change notification, * which is redundant since we snoop on the command flow and inject