From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 8/9] sunxi: mmc support
Date: Mon, 24 Mar 2014 22:14:02 +0100 [thread overview]
Message-ID: <201403242214.02923.marex@denx.de> (raw)
In-Reply-To: <1395438866-1193-8-git-send-email-ijc@hellion.org.uk>
On Friday, March 21, 2014 at 10:54:25 PM, Ian Campbell wrote:
> As well as the following signed-off-by the sunxi branch shows commits to
> these files authored by the following:
> Stefan Roese
> Tom Cubie
> yemao
>
> Signed-off-by: Henrik Nordstrom <henrik@henriknordstrom.net>
> Signed-off-by: Luke Leighton <lkcl@lkcl.net>
> Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
> Signed-off-by: Wills Wang <wills.wang.open@gmail.com>
> Signed-off-by: Ian Campbell <ijc@hellion.org.uk>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
[...]
> +
> +static void dumphex32(char *name, char *base, int len)
> +{
> + __u32 i;
> +
> + debug("dump %s registers:", name);
> + for (i = 0; i < len; i += 4) {
> + if (!(i & 0xf))
> + debug("\n0x%p : ", base + i);
> + debug("0x%08x ", readl(base + i));
> + }
> + debug("\n");
> +}
Looks like print_hex_dump() reimplementation ...
[...]
> +static int mmc_trans_data_by_cpu(struct mmc *mmc, struct mmc_data *data)
> +{
> + struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
> + unsigned i;
> + unsigned byte_cnt = data->blocksize * data->blocks;
> + unsigned *buff;
> + unsigned timeout = 0xfffff;
> +
> + if (data->flags & MMC_DATA_READ) {
> + buff = (unsigned int *)data->dest;
> + for (i = 0; i < (byte_cnt >> 2); i++) {
> + while (--timeout &&
> + (readl(&mmchost->reg->status) &
> + SUNXI_MMC_STATUS_FIFO_EMPTY))
> + ;
> + if (timeout <= 0)
> + goto out;
> + buff[i] = readl(mmchost->database);
> + timeout = 0xfffff;
> + }
> + } else {
> + buff = (unsigned int *)data->src;
> + for (i = 0; i < (byte_cnt >> 2); i++) {
> + while (--timeout &&
> + (readl(&mmchost->reg->status) &
> + SUNXI_MMC_STATUS_FIFO_FULL))
> + ;
> + if (timeout <= 0)
> + goto out;
> + writel(buff[i], mmchost->database);
> + timeout = 0xfffff;
Are these two branches almost the same ? Why not just clear that up by squashing
them into one with a small if (...) at the begining of this function ?
[...]
> +static int mmc_trans_data_by_dma(struct mmc *mmc, struct mmc_data *data)
> +{
> + struct sunxi_mmc_host *mmchost = (struct sunxi_mmc_host *)mmc->priv;
> + unsigned byte_cnt = data->blocksize * data->blocks;
> + unsigned char *buff;
> + unsigned des_idx = 0;
> + unsigned buff_frag_num =
> + (byte_cnt + SDXC_DES_BUFFER_MAX_LEN - 1) >> SDXC_DES_NUM_SHIFT;
> + unsigned remain;
> + unsigned i, rval;
> + ALLOC_CACHE_ALIGN_BUFFER(struct sunxi_mmc_des, pdes, buff_frag_num);
> +
> + buff = data->flags & MMC_DATA_READ ?
> + (unsigned char *)data->dest : (unsigned char *)data->src;
> + remain = byte_cnt & (SDXC_DES_BUFFER_MAX_LEN - 1);
> + if (!remain)
> + remain = SDXC_DES_BUFFER_MAX_LEN;
> +
> + flush_cache((unsigned long)buff, (unsigned long)byte_cnt);
> + for (i = 0; i < buff_frag_num; i++, des_idx++) {
> + memset((void *)&pdes[des_idx], 0, sizeof(struct sunxi_mmc_des));
> + pdes[des_idx].des_chain = 1;
> + pdes[des_idx].own = 1;
> + pdes[des_idx].dic = 1;
> + if (buff_frag_num > 1 && i != buff_frag_num - 1)
> + pdes[des_idx].data_buf1_sz =
> + (SDXC_DES_BUFFER_MAX_LEN -
> + 1) & SDXC_DES_BUFFER_MAX_LEN;
> + else
> + pdes[des_idx].data_buf1_sz = remain;
> +
> + pdes[des_idx].buf_addr_ptr1 =
> + (u32) buff + i * SDXC_DES_BUFFER_MAX_LEN;
> + if (i == 0)
> + pdes[des_idx].first_des = 1;
> +
> + if (i == buff_frag_num - 1) {
> + pdes[des_idx].dic = 0;
> + pdes[des_idx].last_des = 1;
> + pdes[des_idx].end_of_ring = 1;
> + pdes[des_idx].buf_addr_ptr2 = 0;
> + } else {
> + pdes[des_idx].buf_addr_ptr2 = (u32)&pdes[des_idx + 1];
> + }
> + debug("frag %d, remain %d, des[%d](%08x): ",
> + i, remain, des_idx, (u32)&pdes[des_idx]);
> + debug("[0] = %08x, [1] = %08x, [2] = %08x, [3] = %08x\n",
> + (u32)((u32 *)&pdes[des_idx])[0],
> + (u32)((u32 *)&pdes[des_idx])[1],
> + (u32)((u32 *)&pdes[des_idx])[2],
> + (u32)((u32 *)&pdes[des_idx])[3]);
Yum, this pointer voodoo looks tasty (and ready for fixing up ... ).
[...]
next prev parent reply other threads:[~2014-03-24 21:14 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-21 21:54 [U-Boot] [PATCH v2 0/9] sunxi: initial upstreamining effort Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 1/9] sunxi: initial sun7i clocks and timer support Ian Campbell
2014-03-24 20:52 ` Marek Vasut
2014-03-24 22:42 ` Olliver Schinagl
2014-03-25 0:57 ` Marek Vasut
2014-03-25 6:35 ` Wolfgang Denk
2014-03-26 8:23 ` Ian Campbell
2014-04-13 19:55 ` Ian Campbell
2014-04-13 21:00 ` Marek Vasut
2014-03-26 8:23 ` Ian Campbell
2014-03-27 21:29 ` Ian Campbell
2014-03-27 22:00 ` Marek Vasut
2014-03-27 22:12 ` Ian Campbell
2014-03-27 22:36 ` Marek Vasut
2014-03-28 8:20 ` Ian Campbell
2014-03-28 8:24 ` Marek Vasut
2014-03-28 8:25 ` Hans de Goede
2014-03-28 8:39 ` Marek Vasut
2014-03-21 21:54 ` [U-Boot] [PATCH v2 2/9] sunxi: initial sun7i pinmux and gpio support Ian Campbell
2014-03-24 20:54 ` Marek Vasut
2014-03-26 8:30 ` Ian Campbell
2014-03-26 8:59 ` Marek Vasut
2014-03-26 9:01 ` Wolfgang Denk
2014-03-27 21:52 ` Ian Campbell
2014-03-26 8:33 ` Ian Campbell
2014-03-26 9:01 ` Marek Vasut
2014-03-26 9:03 ` Wolfgang Denk
2014-03-26 9:39 ` Ian Campbell
2014-03-26 10:03 ` Marek Vasut
2014-03-26 14:57 ` Wolfgang Denk
2014-03-21 21:54 ` [U-Boot] [PATCH v2 3/9] sunxi: initial sun7i dram setup support Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 4/9] sunxi: initial generic sun7i cpu, board and start of day support Ian Campbell
2014-03-22 6:52 ` Wolfgang Denk
2014-03-22 7:08 ` mrnuke
2014-03-22 9:04 ` Hans de Goede
2014-03-22 9:37 ` Ian Campbell
2014-03-22 12:27 ` Wolfgang Denk
2014-03-22 15:28 ` Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 5/9] sunxi: generic sun7i build infrastructure Ian Campbell
2014-03-22 6:46 ` Wolfgang Denk
2014-03-22 10:04 ` Ian Campbell
2014-03-22 12:33 ` Wolfgang Denk
2014-03-22 15:12 ` Hans de Goede
2014-03-22 15:26 ` Ian Campbell
2014-03-22 19:31 ` Wolfgang Denk
2014-03-22 20:07 ` Hans de Goede
2014-03-24 21:01 ` Marek Vasut
2014-03-27 22:05 ` Ian Campbell
2014-03-27 22:37 ` Marek Vasut
2014-03-28 8:26 ` Ian Campbell
2014-03-28 8:37 ` Marek Vasut
2014-03-21 21:54 ` [U-Boot] [PATCH v2 6/9] sunxi: add support for Cubietruck booting in FEL mode Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 7/9] sunxi: add gmac Ethernet support Ian Campbell
2014-03-21 21:54 ` [U-Boot] [PATCH v2 8/9] sunxi: mmc support Ian Campbell
2014-03-24 21:14 ` Marek Vasut [this message]
2014-03-21 21:54 ` [U-Boot] [PATCH v2 9/9] sunxi: non-FEL SPL boot support for sun7i Ian Campbell
2014-03-22 6:54 ` [U-Boot] [PATCH v2 0/9] sunxi: initial upstreamining effort Wolfgang Denk
2014-03-24 0:14 ` [U-Boot] [linux-sunxi] " Henrik Nordström
2014-03-24 8:05 ` Ian Campbell
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=201403242214.02923.marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.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