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 B6AFA466B5B; Tue, 16 Jun 2026 17:45:04 +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=1781631905; cv=none; b=cyn6LwmSR741mk1L5GaFBk+BMogCqVRC7toEpme+SYCnozuORpOCccrG3vuZPHYKSoHGtMXYcAFFzXsdh4UEbu2/ZuDkxOGtVl1QJT8wSWLrPkeh5AdqLJADcUyrVgjRR3ZOQ9ioCdw1ZKUyaz68g8mSUpy8IKtAl+M+BgKt7qM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781631905; c=relaxed/simple; bh=wSszrKdZryiwIT7NQhJ3/NOjMA0Z28C3weooqg8qIxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gkztd4mS6jWBVPwpk9dFGNg1A7thjjeGxyId2UdgUVX7FyhBA0Eo0UgAb07NgxectoVLYQEJfTEu4W1dcemKfk8ca1myJV+g7kLMeMOgFtSOcFXl/O3DWv4UM80F8tx4zgFyYklt0OCixm5kr0DinJ+ViY8NsWDzbcsJAKxwsoY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wEye7asD; 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="wEye7asD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0CFD1F000E9; Tue, 16 Jun 2026 17:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1781631904; bh=qWBoClFF0JxwMchntC96/YS48UBR9Y/sVBF71+wkNhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=wEye7asDKdO995T394L9IkvPFJANNZaT7Gjzo1gqAOrUQbANT+e+G8RC1AgVxupuD hz01m5sT2hhXdUaQtsTPRIfwWG+P0lYY6qcZsOwp+dFUxuNl/xUbBJyu/LlLEzOkT/ HBwCihn0EAOjoh7ZjEZYlksVpWllChjrc3GXoAhE= 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 6.1 310/522] mmc: litex_mmc: Set mandatory idle clocks before CMD0 Date: Tue, 16 Jun 2026 20:27:37 +0530 Message-ID: <20260616145140.373368316@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260616145125.307082728@linuxfoundation.org> References: <20260616145125.307082728@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 6.1-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