From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/3] mmc: uniphier: add driver for UniPhier SD/MMC host controller
Date: Wed, 10 Feb 2016 14:45:48 +0100 [thread overview]
Message-ID: <56BB3F0C.2040002@denx.de> (raw)
In-Reply-To: <1455110911-12224-2-git-send-email-yamada.masahiro@socionext.com>
On 02/10/2016 02:28 PM, Masahiro Yamada wrote:
> Add a driver for the on-chip SD/eMMC host controller used by
> UniPhier SoC family.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
?? ????,
[...]
> +#include <common.h>
> +#include <clk.h>
> +#include <fdtdec.h>
> +#include <mapmem.h>
> +#include <mmc.h>
> +#include <dm/device.h>
> +#include <linux/compat.h>
> +#include <linux/io.h>
> +#include <asm/unaligned.h>
> +#include <asm/dma-mapping.h>
> +
> +#define pr_err printf
> +#define pr_warn printf
> +#ifdef DEBUG
> +#define pr_debug printf
> +#else
> +#define pr_debug(...)
> +#endif
This should go into include/ somewhere, your driver shouldn't be a
platform abstraction library.
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +#define UNIPHIER_SD_CMD 0x000 /* command */
[...]
> +static int uniphier_sd_wait_irq(struct uniphier_sd_priv *priv,
> + unsigned int reg, u32 flag)
> +{
> + long wait = 1000000;
> + int ret;
Replace this with wait_for_bit() please .
> + while (!(readl(priv->regbase + reg) & flag)) {
> + if (wait-- < 0) {
> + pr_err("timeout\n");
> + return -ETIMEDOUT;
> + }
> +
> + ret = uniphier_sd_check_error(priv);
> + if (ret)
> + return ret;
> +
> + udelay(1);
> + }
> +
> + return 0;
> +}
[...]
> +static void uniphier_sd_dma_start(struct uniphier_sd_priv *priv,
> + dma_addr_t dma_addr)
> +{
> + u32 tmp;
> +
> + writel(0, priv->regbase + UNIPHIER_SD_DMA_INFO1);
> + writel(0, priv->regbase + UNIPHIER_SD_DMA_INFO2);
> +
> + /* enable DMA */
> + tmp = readl(priv->regbase + UNIPHIER_SD_EXTMODE);
> + tmp |= UNIPHIER_SD_EXTMODE_DMA_EN;
> + writel(tmp, priv->regbase + UNIPHIER_SD_EXTMODE);
I'd say, use setbits_le32(), but could it be that this driver is kept in
sync with Linux ?
> + writel(dma_addr & U32_MAX, priv->regbase + UNIPHIER_SD_DMA_ADDR_L);
> +
> + /* suppress the warning "right shift count >= width of type" */
> + dma_addr >>= min_t(int, 32, 8 * sizeof(dma_addr));
> +
> + writel(dma_addr & U32_MAX, priv->regbase + UNIPHIER_SD_DMA_ADDR_H);
> +
> + writel(UNIPHIER_SD_DMA_CTL_START, priv->regbase + UNIPHIER_SD_DMA_CTL);
> +}
> +
> +static int uniphier_sd_dma_wait_irq(struct uniphier_sd_priv *priv, u32 flag,
> + unsigned int blocks)
> +{
> + long wait = 1000000 + 10 * blocks;
wait_for_bit() again.
> + while (!(readl(priv->regbase + UNIPHIER_SD_DMA_INFO1) & flag)) {
> + if (wait-- < 0) {
> + pr_err("timeout during DMA\n");
> + return -ETIMEDOUT;
> + }
> +
> + udelay(10);
> + }
> +
> + if (readl(priv->regbase + UNIPHIER_SD_DMA_INFO2)) {
> + pr_err("error during DMA\n");
> + return -EIO;
> + }
> +
> + return 0;
> +}
??
next prev parent reply other threads:[~2016-02-10 13:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-10 13:28 [U-Boot] [PATCH v2 0/3] UniPhier SD/eMMC controller driver Masahiro Yamada
2016-02-10 13:28 ` [U-Boot] [PATCH v2 1/3] mmc: uniphier: add driver for UniPhier SD/MMC host controller Masahiro Yamada
2016-02-10 13:45 ` Marek Vasut [this message]
2016-02-16 8:18 ` Masahiro Yamada
2016-02-16 12:51 ` Marek Vasut
2016-02-10 13:28 ` [U-Boot] [PATCH v2 2/3] ARM: uniphier: enable UniPhier SD/MMC host driver Masahiro Yamada
2016-02-10 13:28 ` [U-Boot] [PATCH v2 3/3] ARM: dts: uniphier: add SD/MMC host controller nodes Masahiro Yamada
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=56BB3F0C.2040002@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