mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <sha@pengutronix.de>
Cc: Jules Maselbas <jmaselbas@zdiv.net>, barebox@lists.infradead.org
Subject: Re: [RFC PATCH 08/11] mci: Add sunxi-mmc driver
Date: Fri, 19 May 2023 08:51:39 +0200	[thread overview]
Message-ID: <32889584-7481-183f-2a31-9ac02fc12234@pengutronix.de> (raw)
In-Reply-To: <20230519055120.GE29365@pengutronix.de>

On 19.05.23 07:51, Sascha Hauer wrote:
> 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.

Thanks. I misread and thought the loop was from 0 to 4 and wondered if
we shouldn't use a timeout for the whole loop runtime instead of iteration.

Thanks,
Ahmad

> 
> 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 |




  reply	other threads:[~2023-05-19  6:53 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-10 23:37 [RFC PATCH 00/11] Add support for Allwinner (sunxi) A64 SoC Jules Maselbas
2023-05-10 23:37 ` [RFC PATCH 01/11] scripts: Add Allwinner eGON image support Jules Maselbas
2023-05-11  7:25   ` Sascha Hauer
2023-05-11 20:14     ` Jules Maselbas
2023-05-18 18:47   ` Ahmad Fatoum
2023-05-19  9:40     ` Jules Maselbas
2023-05-10 23:37 ` [RFC PATCH 02/11] sunxi: introduce mach-sunxi Jules Maselbas
2023-05-11  7:27   ` Sascha Hauer
2023-05-18 18:46   ` Ahmad Fatoum
2023-05-19 10:09     ` Jules Maselbas
2023-05-22 10:32       ` Ahmad Fatoum
2023-05-10 23:37 ` [RFC PATCH 03/11] ARM: dls: Add ENTRY_HEADER macro to add .text section Jules Maselbas
2023-05-18 18:49   ` Ahmad Fatoum
2023-05-10 23:37 ` [RFC PATCH 04/11] sunxi: Add lowlevel switch to aarch64 Jules Maselbas
2023-05-18 19:01   ` Ahmad Fatoum
2023-05-10 23:37 ` [RFC PATCH 05/11] arm: sunxi: Add debug_ll Jules Maselbas
2023-05-18 19:05   ` Ahmad Fatoum
2023-05-19 10:36     ` Jules Maselbas
2023-05-10 23:37 ` [RFC PATCH 06/11] clk: Add clock driver for sun50i-a64 Jules Maselbas
2023-05-18 19:06   ` Ahmad Fatoum
2023-05-10 23:37 ` [RFC PATCH 07/11] pinctrl: Add sun50i-a64 pinctrl driver Jules Maselbas
2023-05-18 19:10   ` Ahmad Fatoum
2023-05-19 10:52     ` Jules Maselbas
2023-05-10 23:37 ` [RFC PATCH 08/11] mci: Add sunxi-mmc driver Jules Maselbas
2023-05-18 19:26   ` Ahmad Fatoum
2023-05-19  5:51     ` Sascha Hauer
2023-05-19  6:51       ` Ahmad Fatoum [this message]
2023-05-10 23:37 ` [RFC PATCH 09/11] arm: sunxi: Add sun50i SDRAM init Jules Maselbas
2023-05-11  7:39   ` Sascha Hauer
2023-05-10 23:37 ` [RFC PATCH 10/11] arm: boards: sunxi: Add initial support for the pinephone Jules Maselbas
2023-05-18 19:39   ` Ahmad Fatoum
2023-05-10 23:37 ` [RFC PATCH 11/11] arm: boards: sunxi: Add pine64 board Jules Maselbas
2023-05-18 19:44   ` Ahmad Fatoum
2023-05-19 16:30     ` Jules Maselbas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32889584-7481-183f-2a31-9ac02fc12234@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jmaselbas@zdiv.net \
    --cc=sha@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox