From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B7BB318EF0 for ; Mon, 18 May 2026 22:20:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779142854; cv=none; b=bLmaTzj8p6lpk0B+rIG76TyTjIjpta15WKj1vaeha3MrWxomJuHOQUo1qIRS43XHpHh1ZJR7oiP4nP11lWyYm+94gm3BFPOC21nrEmn1qKiwFEBFWcGH9ToIx9BC3e3UjjDGZ0cJcNaTtvtOwVEJl3imse/13kRUECjjMI9ufIg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779142854; c=relaxed/simple; bh=WzhGzR/qlbTPFjyOXx+TQCNfw7Gp40vu8efe4hkcEos=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qGSKbsEZePPn/yniRelbsAnyX/ii5YBi0k2N1y5b45FhwgKPocrZkW0Api96YFCg2htmZi1ZLHGWOpI1K9HwwvHCo7Yn5ubZ0hyzjnbtDRMBiWGtYC+gE6sRnfNaCNEVu6V3r0vAIY0xeaBtW6l/3J1yDOz6WG/Y7j/bi8fZlUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EPgnveAZ; arc=none smtp.client-ip=209.85.216.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EPgnveAZ" Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-369002b26f4so1391084a91.3 for ; Mon, 18 May 2026 15:20:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1779142853; x=1779747653; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=pqafggWVzG45XkB/Trqo1jmbkzttKIzZZW2LIt34uL0=; b=EPgnveAZ1WBmbZyI6fJ2J9B7U0WAKvyOIxLCCMhr+OjHqt+7VtaoGGFfFI8TfufWhr VDv3Yv+EOl3d8GkvWYlT3pMq5GHGHxUdTJRjegcyX1xspWNjvl9CI1xwS0p/ziqCy0dd iLs5r+oWjUDY0seQwYUUj3CpwxTmlM+DtbzR06HP2FRKEHpkSdvru9/WIX0y9N1BeyEq JGB+41gos6eqkjL41R6KJWDzvpSIhCQYg3gLV9Xn3qZjB8JRNfkRhZTsNU64Y7DM1mjG NL1Hem0C9CPR5cTAtCzeoxpBpzXrzRmbU2oJq8d798gagRa4mdX1Eh17B4AuxmAYbCES 2uFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779142853; x=1779747653; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pqafggWVzG45XkB/Trqo1jmbkzttKIzZZW2LIt34uL0=; b=f7XCkdqQHnXFEG7TCryR00xEs4wrTAb9rt8/rQtQFkkVHWwnJEtrIjzM+FvEuJMKKU KmuPo0aZBCxQPyZBUeFX5Lg22h2oD7QjRJ3vmXbukAvLLu1eD+EB89Iv+YJrKtNMdiky VWvAxWKL939Zb+8qvk+IiA05892laGfN3zAEanoFAZHMl5Vvf0uN8iE+FRx98J2Ye45G Sl55T3FpmsOUfcD8VDvt5koy7uhZ07THVeeBqY4OtOCXwatmOwv1aHs00x5F6SaFAbIc 9pmmgWISegdZueRhs8yd6r1RoEG427SuLKPRlG2o5SjdF+8fIjXYR4+UbscL0U0Nv0T+ fbIw== X-Forwarded-Encrypted: i=1; AFNElJ/ENf7AFvci/W5uHw2boeHj7M8ohu2yOAI8lwcuq10Cm1OEoDnXbraTG8c2JoMLEx0SpVKss0krHT+jD3A=@vger.kernel.org X-Gm-Message-State: AOJu0YzRu1UNZLfJ/HigVN7KvFLisTPtD7v8HIUF4LPDW9aPr4NgQ8mB FEaBVcjbIp1Du0P7WPACdKeUGVW3R25zM4Ssgwc4C+N2eF4PNzYS9VwcAnROOsLE X-Gm-Gg: Acq92OEFg9Qwh5TZwzYt2F2Wem3WbaMGrghZ2+O1PFHYLErVAArS8zMrCgWQw5mPe0X yx4kqw52BkwdXTUvQ0Uo+jZS8aZC7qwCj5HAGGzQiQ9y5J0AOJFgE9op6BniDN8xeUliLE5RGvP n/QHydB3xbdlL2YxpQJPCXSe/cJz2FdklZN16cK341B89owyapfEWvMBUfKSWW9zdVf9jdZpynB SW+BjGe3rpar/OtH+5q1oY1vMCLQl6nqMIJcwn6zgB9FpzJo8mVvLFNDVzAy25gBFF/ZWdnMPxL Di5t4LpEDRX5ZGF1oIWGTsuXrPiPN/2NkyamiFisbSAuw2hwCR4ds1Wtm7LQWm+Qeq5pPzEtrVK ecysOMttWdshTx8HSUN+4ouDqYRa9OLGMeB0Xf4Tj3N2hsydFdNNcyrX3MeZrw67le8lkohkh1R 4zoMeAzBhRBN+tNf25Sy748SopiLg5gjukI2AsfzvBmyOWalo/szzXRG9JQ9PZH0k0PuuhegGrj eP4BSq3NztZ X-Received: by 2002:a17:903:f8d:b0:2b0:b016:773f with SMTP id d9443c01a7336-2bd7e8a0b31mr185023675ad.11.1779142852619; Mon, 18 May 2026 15:20:52 -0700 (PDT) Received: from errol.ini.cmu.edu (pool-108-17-68-229.pitbpa.fios.verizon.net. [108.17.68.229]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2bd5bd5fc60sm168648905ad.9.2026.05.18.15.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 15:20:52 -0700 (PDT) Date: Mon, 18 May 2026 18:20:49 -0400 From: "Gabriel L. Somlo" To: Inochi Amaoto Cc: Ulf Hansson , Karol Gugala , Mateusz Holenko , Joel Stanley , Kamil Rakoczy , Andy Shevchenko , linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Yixun Lan , Longbin Li Subject: Re: [PATCH v4] mmc: litex_mmc: Set mandatory idle clocks before CMD0 Message-ID: References: <20260517015323.264179-1-inochiama@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260517015323.264179-1-inochiama@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett with this patch on top of today's latest (4d3a2a466b8d), I get (on 64-bit rocketchip with Litex): [ 6.475114] mmc0: invalid bus width [ 6.477870] mmc0: error -22 whilst initialising SD card Thanks, --Gabriel On Sun, May 17, 2026 at 09:53:23AM +0800, Inochi Amaoto wrote: > 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 > --- > Changed from v3: > - https://lore.kernel.org/linux-mmc/20260426112016.1370929-1-inochiama@gmail.com/ > 1. Remove patch 1: mmc: litex_mmc: Move litex_mmc_setclk() to bottom for reuse > 2. Use set_ios() callback to apply the clock change. > > Changed from v2: > - https://lore.kernel.org/linux-mmc/20260424013615.470325-1-inochiama@gmail.com/ > 1. Remove the added function forward reference and add a new patch > for moving litex_mmc_setclk() function > > Change from v1: > - https://lore.kernel.org/linux-mmc/20260421025052.755471-1-inochiama@gmail.com/ > 1. use fsleep to replace udelay > > Inochi Amaoto (2): > mmc: litex_mmc: Move litex_mmc_setclk() to bottom for reuse > mmc: litex_mmc: Set mandatory idle clocks before CMD0 > > drivers/mmc/host/litex_mmc.c | 37 ++++++++++++++++++++++-------------- > 1 file changed, 23 insertions(+), 14 deletions(-) > --- > drivers/mmc/host/litex_mmc.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/mmc/host/litex_mmc.c b/drivers/mmc/host/litex_mmc.c > index d2f19c2dc673..65d5c728f536 100644 > --- a/drivers/mmc/host/litex_mmc.c > +++ b/drivers/mmc/host/litex_mmc.c > @@ -68,6 +68,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 > @@ -449,6 +452,9 @@ static void litex_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > { > struct litex_mmc_host *host = mmc_priv(mmc); > > + if (ios->chip_select == MMC_CS_HIGH) > + ios->clock = SD_INIT_CLK_HZ; > + > /* > * NOTE: Ignore any ios->bus_width updates; they occur right after > * the mmc core sends its own acmd6 bus-width change notification, > @@ -459,6 +465,11 @@ static void litex_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) > /* Update sd_clk */ > if (ios->clock != host->sd_clk) > litex_mmc_setclk(host, ios->clock); > + > + if (ios->chip_select == MMC_CS_HIGH) { > + litex_write8(host->sdphy + LITEX_PHY_INITIALIZE, 1); > + fsleep(SD_INIT_DELAY_US); > + } > } > > static const struct mmc_host_ops litex_mmc_ops = { > -- > 2.54.0 >