From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 19 May 2023 07:53:01 +0200 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pzt30-006Lyj-J8 for lore@lore.pengutronix.de; Fri, 19 May 2023 07:53:01 +0200 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pzt2x-0007UV-UL for lore@pengutronix.de; Fri, 19 May 2023 07:53:00 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:From:In-Reply-To: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=AkxzZDQ0NTz+0tap3gA9yTMsKfCJ+FH19Nv1+4WmiVI=; b=pnrF9NWn5pT7PQP8RxSUUzy+jy Jvm8kmerzKhlRpMpxkLxR9oBWdnah3RT/Aq0HDeOaM+rSlJ1B5qxyS5STd/53aiUPrvcn77JyFkOY 4qi8V5IqCcWCBXWy8r+IMe2tsdL7hCmZ5qG4QgHsUkTEuk3Q5DLzde9gVKmPTktTyuvF9vi4VvgEO BOJuHbMranaARcrCWDApFz6N5mmNNlhToitwJDCo60TrlTHBlIMv7WWTjjRaz38Y+DPma9DxrTRRt CHRYKGGd4IJXX4Xx9hLr2EnAYmbC3IOqu22Uf/qVQRja8RGl6o6qjcggmBr4RlL/R21XBDSqIN6HK Tt2KLtew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pzt1Y-00FBgn-1e; Fri, 19 May 2023 05:51:32 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pzt1U-00FBfJ-2R for barebox@lists.infradead.org; Fri, 19 May 2023 05:51:30 +0000 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pzt1N-0007RJ-83; Fri, 19 May 2023 07:51:21 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1pzt1M-00088f-30; Fri, 19 May 2023 07:51:20 +0200 Date: Fri, 19 May 2023 07:51:20 +0200 To: Ahmad Fatoum Cc: Jules Maselbas , barebox@lists.infradead.org Message-ID: <20230519055120.GE29365@pengutronix.de> References: <20230510233711.37345-1-jmaselbas@zdiv.net> <20230510233711.37345-9-jmaselbas@zdiv.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) From: Sascha Hauer X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230518_225128_800536_2BCCC35A X-CRM114-Status: GOOD ( 31.04 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.ext.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-4.7 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: Re: [RFC PATCH 08/11] mci: Add sunxi-mmc driver X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.ext.pengutronix.de) On Thu, May 18, 2023 at 09:26:56PM +0200, Ahmad Fatoum wrote: > On 11.05.23 01:37, Jules Maselbas wrote: > > This driver is adapted from different sources: Linux, u-boot and p-boot. > > The latter, p-boot (forked from u-boot), is a bootloader for pinephones. > > > > It currently only support PIO xfer but could be further improved to also > > support DMA xfer. This driver is split in three source file so it can be > > used by PBL and barebox proper. > > --- > > drivers/mci/Kconfig | 6 + > > drivers/mci/Makefile | 2 + > > drivers/mci/sunxi-mmc-common.c | 259 +++++++++++++++++++++++++++++++++ > > drivers/mci/sunxi-mmc-pbl.c | 81 +++++++++++ > > drivers/mci/sunxi-mmc.c | 173 ++++++++++++++++++++++ > > drivers/mci/sunxi-mmc.h | 225 ++++++++++++++++++++++++++++ > > include/mach/sunxi/xload.h | 12 ++ > > 7 files changed, 758 insertions(+) > > create mode 100644 drivers/mci/sunxi-mmc-common.c > > create mode 100644 drivers/mci/sunxi-mmc-pbl.c > > create mode 100644 drivers/mci/sunxi-mmc.c > > create mode 100644 drivers/mci/sunxi-mmc.h > > create mode 100644 include/mach/sunxi/xload.h > > > > diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig > > index bbdca67e9d..c1903b6c90 100644 > > --- a/drivers/mci/Kconfig > > +++ b/drivers/mci/Kconfig > > @@ -72,6 +72,12 @@ config MCI_DW_PIO > > help > > Use PIO mode (instead of IDMAC) in DW MMC driver. > > > > +config MCI_SUNXI_SMHC > > + bool "Allwinner SD-MMC Memory Card Host Controller" > > + help > > + Enable support for the Allwinner SD-MMC Memory Card Host Controller, > > + his provides host support for SD and MMC interfaces, in PIO mode. > > This > > > + > > config MCI_MXS > > bool "i.MX23/i.MX28" > > depends on ARCH_MXS > > diff --git a/drivers/mci/Makefile b/drivers/mci/Makefile > > index e3dc5ad8ae..c17cd41db1 100644 > > --- a/drivers/mci/Makefile > > +++ b/drivers/mci/Makefile > > @@ -20,4 +20,6 @@ obj-$(CONFIG_MCI_SPI) += mci_spi.o > > obj-$(CONFIG_MCI_DW) += dw_mmc.o > > obj-$(CONFIG_MCI_MMCI) += mmci.o > > obj-$(CONFIG_MCI_STM32_SDMMC2) += stm32_sdmmc2.o > > +obj-$(CONFIG_MCI_SUNXI_SMHC) += sunxi-mmc.o > > +pbl-$(CONFIG_MCI_SUNXI_SMHC) += sunxi-mmc-pbl.o > > obj-pbl-$(CONFIG_MCI_SDHCI) += sdhci.o > > diff --git a/drivers/mci/sunxi-mmc-common.c b/drivers/mci/sunxi-mmc-common.c > > new file mode 100644 > > index 0000000000..845078805b > > --- /dev/null > > +++ b/drivers/mci/sunxi-mmc-common.c > > @@ -0,0 +1,259 @@ > > +#include "sunxi-mmc.h" > > + > > +static int sdxc_read_data_pio(struct sunxi_mmc_host *host, struct mci_data *data); > > +static int sdxc_write_data_pio(struct sunxi_mmc_host *host, struct mci_data *data); > > +static int sunxi_mmc_send_cmd(struct sunxi_mmc_host *host, struct mci_cmd *cmd, struct mci_data *data, const char **why); > > +static int sunxi_mmc_set_ios(struct sunxi_mmc_host *host, struct mci_ios *ios); > > +static void sunxi_mmc_init(struct sunxi_mmc_host *host); > > + > > +static int sdxc_read_data_pio(struct sunxi_mmc_host *host, struct mci_data *data) > > +{ > > + size_t i, len = data->blocks * data->blocksize; > > + u8 *dst = data->dest; > > + u32 reg; > > + > > + sdxc_writel(host, SDXC_REG_GCTRL, SDXC_GCTRL_ACCESS_BY_AHB); > > + > > + for (i = 0; i < len; i += 4) { > > + if (wait_on_timeout(2000 * MSECOND, !sdxc_is_fifo_empty(host))) > > This can add up to 8 seconds. Just use is_timeout directly? > > > + return -ETIMEDOUT; It will return -ETIMEDOUT after two seconds at maximum. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |