From patchwork Fri Aug 11 20:57:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pawe=C5=82_Jarosz?= X-Patchwork-Id: 800754 X-Patchwork-Delegate: philipp.tomsich@theobroma-systems.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="TeEB7J/E"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xTcvs6FDmz9sRq for ; Sat, 12 Aug 2017 07:04:57 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id A6123C21E57; Fri, 11 Aug 2017 21:01:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BAF43C21E57; Fri, 11 Aug 2017 20:59:05 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id BA02EC21E1B; Fri, 11 Aug 2017 20:57:42 +0000 (UTC) Received: from mail-lf0-f65.google.com (mail-lf0-f65.google.com [209.85.215.65]) by lists.denx.de (Postfix) with ESMTPS id 753E1C21DDC for ; Fri, 11 Aug 2017 20:57:35 +0000 (UTC) Received: by mail-lf0-f65.google.com with SMTP id t128so2996379lff.3 for ; Fri, 11 Aug 2017 13:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=I4Nr6LU1F+HzluInbHzfHM9nHpcELVIwHyCANb5RYh0=; b=TeEB7J/ErwlI/D2PGBWROyOE6aZRDMYQFzNg6njtEaH4H0bLTmTK7vG/uHxZGclDl9 xyeb52mamH+Ti1RXAb7XuXix7S8eSrk7NwTjyyGzF0+jcNUpMPYVFm3Tw0G4/qTPLuZA rQEg7xXhhBEnQGRzj/xiUJiH9CxXV2WXwHUiwnILt05ir94FwdfhTmSUWOV3MIjIOYG4 rFDvFyQ3FWkqsxK4R1dUFr2f58IBPbHwCrpD8MwxsA6dxq599TjhTNNuHYjMqbCNqj6c cyFdaQFTkRkII7g0nL0JsQR00Wxe8rOEDo6E+RFs3oLKw4xNqvGUUSptR7R0dDneWY0z 0JjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=I4Nr6LU1F+HzluInbHzfHM9nHpcELVIwHyCANb5RYh0=; b=XCDTDqmKyyRjP2KFq1n7Zu3Oz3SIzLgM2z94XFC4FCFwnmuHWJGD9b6LjcUHqGeZEw 8sEJMt32X+Oz1oR9ZfFZi2pzxYTLppxW7cteruVLwNMWgl6xIdKhv/vbZ3Wg7PHkobH2 leJyU2yzTBlmiyZ/YXzzwGVWwVM2KoUTX7Qy39O185mboowcMO4KVX6qmzqkR6fRxbLI Sn+4uQ3931E2hIlfZ1csCHm1PwbUOLloAZgaN+3SGuY/vZa6QNc+RZ/ZGXhP8RAelxm5 DVBIhzrv2AlxwPqT8jpD/686HLbIBe/5Q0DPTz9GdSZY9i6Xa08q2D6ZCO8ntQLSf2zz OMEg== X-Gm-Message-State: AHYfb5ivZjAtjOJhdofK12cL5oVqlIs/G1elNUw6nsB0WKJ/Am6eBrFK XRaZfTFqtg5ClQ== X-Received: by 10.25.150.130 with SMTP id y124mr6072107lfd.202.1502485055061; Fri, 11 Aug 2017 13:57:35 -0700 (PDT) Received: from vaio-ubuntu (admf2.neoplus.adsl.tpnet.pl. [79.185.35.2]) by smtp.gmail.com with ESMTPSA id q130sm253989ljb.29.2017.08.11.13.57.33 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Aug 2017 13:57:34 -0700 (PDT) Date: Fri, 11 Aug 2017 22:57:48 +0200 From: =?utf-8?B?UGF3ZcWC?= Jarosz To: u-boot@lists.denx.de Message-ID: <314307bf634d106cff4ab7b6fc87b45bbe3f858e.1502483336.git.paweljarosz3691@gmail.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Subject: [U-Boot] [PATCH v2 14/19] mmc: dw_mmc: support transfer mode autodetection X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" dw_mmc supports two transfer modes in u-boot: idma and fifo. This patch adds autodetection of transfer mode and eliminates setting this in host config struct Signed-off-by: Paweł Jarosz --- Changes since v1: - none drivers/mmc/dw_mmc.c | 8 ++++++++ include/dwmmc.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c index 700f764..2cc4d67 100644 --- a/drivers/mmc/dw_mmc.c +++ b/drivers/mmc/dw_mmc.c @@ -428,6 +428,7 @@ static int dwmci_set_ios(struct mmc *mmc) static int dwmci_init(struct mmc *mmc) { struct dwmci_host *host = mmc->priv; + uint32_t use_dma; if (host->board_init) host->board_init(host); @@ -439,6 +440,13 @@ static int dwmci_init(struct mmc *mmc) return -EIO; } + use_dma = SDMMC_GET_TRANS_MODE(dwmci_readl(host, DWMCI_HCON)); + if (use_dma == DMA_INTERFACE_IDMA) { + host->fifo_mode = 0; + } else { + host->fifo_mode = 1; + } + /* Enumerate at 400KHz */ dwmci_setup_bus(host, mmc->cfg->f_min); diff --git a/include/dwmmc.h b/include/dwmmc.h index 4dda009..269536d 100644 --- a/include/dwmmc.h +++ b/include/dwmmc.h @@ -115,6 +115,10 @@ #define RX_WMARK_SHIFT 16 #define RX_WMARK_MASK (0xfff << RX_WMARK_SHIFT) +/* HCON Register */ +#define DMA_INTERFACE_IDMA (0x0) +#define SDMMC_GET_TRANS_MODE(x) (((x)>>16) & 0x3) + #define DWMCI_IDMAC_OWN (1 << 31) #define DWMCI_IDMAC_CH (1 << 4) #define DWMCI_IDMAC_FS (1 << 3)