mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Juergen Beisert <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: Re: [PATCH 03/13] mci-core: add multiple block support
Date: Fri, 22 Oct 2010 15:40:52 +0200	[thread overview]
Message-ID: <201010221540.52926.jbe@pengutronix.de> (raw)
In-Reply-To: <1287753331-7696-4-git-send-email-s.hauer@pengutronix.de>

Sascha Hauer wrote:
> So far only for reading blocks. This is based on the corresponding
> U-Boot code.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Juergen Beisert <jbe@pengutronix.de>

At least my S32440 target still works with this patch.

Acked-by: Juergen Beisert <jbe@pengurtronix.de>

> ---
>  drivers/mci/mci-core.c |   35 +++++++++++++++++++++++++++--------
>  1 files changed, 27 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
> index c92d5a9..34c4f8c 100644
> --- a/drivers/mci/mci-core.c
> +++ b/drivers/mci/mci-core.c
> @@ -139,23 +139,41 @@ static int mci_block_write(struct device_d *mci_dev,
> const void *src, unsigned b * @param dst Where to store the data read from
> the card
>   * @param blocknum Block number to read
>   */
> -static int mci_read_block(struct device_d *mci_dev, void *dst, unsigned
> blocknum) +static int mci_read_block(struct device_d *mci_dev, void *dst,
> unsigned blocknum, int blocks) {
>  	struct mci *mci = GET_MCI_DATA(mci_dev);
>  	struct mci_cmd cmd;
>  	struct mci_data data;
> +	int ret;
> +	unsigned mmccmd;
> +
> +	if (blocks > 1)
> +		mmccmd = MMC_CMD_READ_MULTIPLE_BLOCK;
> +	else
> +		mmccmd = MMC_CMD_READ_SINGLE_BLOCK;
>
>  	mci_setup_cmd(&cmd,
> -		MMC_CMD_READ_SINGLE_BLOCK,
> +		mmccmd,
>  		mci->high_capacity != 0 ? blocknum : blocknum * mci->read_bl_len,
>  		MMC_RSP_R1);
>
>  	data.dest = dst;
> -	data.blocks = 1;
> +	data.blocks = blocks;
>  	data.blocksize = mci->read_bl_len;
>  	data.flags = MMC_DATA_READ;
>
> -	return mci_send_cmd(mci_dev, &cmd, &data);
> +	ret = mci_send_cmd(mci_dev, &cmd, &data);
> +	if (ret)
> +		return ret;
> +
> +	if (blocks > 1) {
> +		mci_setup_cmd(&cmd,
> +			MMC_CMD_STOP_TRANSMISSION,
> +			0,
> +			MMC_RSP_R1b);
> +			ret = mci_send_cmd(mci_dev, &cmd, NULL);
> +	}
> +	return ret;
>  }
>
>  /**
> @@ -979,19 +997,20 @@ static int mci_sd_read(struct device_d *disk_dev,
> uint64_t sector_start, }
>
>  	while (sector_count) {
> +		int now = min(sector_count, 32);
>  		if (sector_start > MAX_BUFFER_NUMBER) {
>  			pr_err("Cannot handle block number %lu. Too large!\n",
>  				(unsigned)sector_start);
>  			return -EINVAL;
>  		}
> -		rc = mci_read_block(mci_dev, buffer, (unsigned)sector_start);
> +		rc = mci_read_block(mci_dev, buffer, (unsigned)sector_start, now);
>  		if (rc != 0) {
>  			pr_err("Reading block %lu failed with %d\n", (unsigned)sector_start,
> rc); return rc;
>  		}
> -		sector_count--;
> -		buffer += mci->read_bl_len;
> -		sector_start++;
> +		sector_count -= now;
> +		buffer += mci->read_bl_len * now;
> +		sector_start += now;
>  	}
>
>  	return 0;



-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | Phone: +49-8766-939 228     |
Vertretung Sued/Muenchen, Germany             | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686              | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2010-10-22 13:41 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22 13:15 more patches for next Sascha Hauer
2010-10-22 13:15 ` [PATCH 01/13] ARM pca100: Use a flash bbt Sascha Hauer
2010-10-22 13:15 ` [PATCH 02/13] i.MX nand: optimize nand boot code for size Sascha Hauer
2010-10-22 13:15 ` [PATCH 03/13] mci-core: add multiple block support Sascha Hauer
2010-10-22 13:40   ` Juergen Beisert [this message]
2010-10-22 14:03   ` Juergen Beisert
2010-10-22 13:15 ` [PATCH 04/13] i.MX51: Fix mmcclk rate Sascha Hauer
2010-10-22 13:15 ` [PATCH 05/13] i.MX esdctl: Add register bits from redboot Sascha Hauer
2010-10-22 13:15 ` [PATCH 06/13] i.MX35 regs: Add watchdog base Sascha Hauer
2010-10-22 13:15 ` [PATCH 07/13] fb: i.MX IPU: remove unnecessary printf Sascha Hauer
2010-10-22 13:15 ` [PATCH 08/13] fb: i.MX IPU: move fb_info initialization to a single function Sascha Hauer
2010-10-22 13:15 ` [PATCH 09/13] fb: i.MX IPU: fold mx3fb_set_par into its only user Sascha Hauer
2010-10-22 13:15 ` [PATCH 10/13] mci: align data for commands Sascha Hauer
2010-10-22 13:41   ` Juergen Beisert
2010-10-22 13:15 ` [PATCH 11/13] ARM: Add Garz+Fricke Cupid board support Sascha Hauer
2010-10-22 13:15 ` [PATCH 12/13] defaultenv: fix mtdparts Sascha Hauer
2010-10-22 13:15 ` [PATCH 13/13] ARM: Add defconfig for Garz+Fricke cupid board Sascha Hauer
2010-10-26  9:20 ` more patches for next Juergen Beisert
2010-10-26  9:48   ` Marc Kleine-Budde
2010-10-26 18:58   ` Sascha Hauer

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=201010221540.52926.jbe@pengutronix.de \
    --to=jbe@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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