From patchwork Fri Aug 12 08:51:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 73839 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp65540qga; Fri, 12 Aug 2016 01:52:10 -0700 (PDT) X-Received: by 10.66.76.132 with SMTP id k4mr25134168paw.22.1470991929582; Fri, 12 Aug 2016 01:52:09 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q75si7937848pfi.216.2016.08.12.01.52.09; Fri, 12 Aug 2016 01:52:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752109AbcHLIvv (ORCPT + 3 others); Fri, 12 Aug 2016 04:51:51 -0400 Received: from mail-pf0-f182.google.com ([209.85.192.182]:35498 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbcHLIvq (ORCPT ); Fri, 12 Aug 2016 04:51:46 -0400 Received: by mail-pf0-f182.google.com with SMTP id x72so7292677pfd.2 for ; Fri, 12 Aug 2016 01:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0p3SNtRKzs5R1Thg8zKTkYr60Z5XF5TCsDRfJw47ddU=; b=c8PuFowRfOen7hpgpmjL191LjAhCxknwXtODKurhgiUF05XQchNkGtI6WnqeRiepGU xHXeGw1sjeYDGut9bTVERKpB0lFYqgH3pKvrc+7EUsDyNx+tvJRouzmoehYknJb56W2m ANh5iTckZ2v5CgfUTQlD3jlnNkXH0G9O1v9no= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0p3SNtRKzs5R1Thg8zKTkYr60Z5XF5TCsDRfJw47ddU=; b=Y01K4QaRz2x1uq2qW8ZJFJdlw7VmHnP6S6yC6ARbSAIXfD6KpdqLPvc5XOimuqlV0i 9mEh2KBDDR7utFwJyWxjz8kckExy5wWQJywvYVDy0hPayrZmeGPZ7mUlaXWpV29Q+q5Z 8L8U/SsDEk2Tbdg1hwxQzuK+n91nX/XnH4bmCgVDoYn3t+ugWYMfVzVStWY7e1alplx5 H7dCuckTx09rW5edTTbR6ZKhjJr8NOgsqFqwnYCwcD1OXT2+2jtF+UgavES8el3XgT31 vEdonBF7b5vHh6UCQ3cwOPHGbBs1qvk8Kbi7rlg4fEumaiRL2eotJR//1wjDRyh+VHOv VVQQ== X-Gm-Message-State: AEkoousihq2rWNWhfrSngfN6ttm/3HQBXkCIVCRNy5GVV09UpyWrqUj822wg/iotDgRtAmlT X-Received: by 10.98.57.151 with SMTP id u23mr25317783pfj.4.1470991905561; Fri, 12 Aug 2016 01:51:45 -0700 (PDT) Received: from localhost.localdomain ([45.56.159.104]) by smtp.gmail.com with ESMTPSA id m128sm10988720pfm.42.2016.08.12.01.51.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Aug 2016 01:51:45 -0700 (PDT) From: Guodong Xu To: heiko@sntech.de, shawn.lin@rock-chips.com, jh80.chung@samsung.com, robh+dt@kernel.org, mark.rutland@arm.com, ulf.hansson@linaro.org, guodong.xu@linaro.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, Xinwei Kong , Zhangfei Gao Subject: [PATCH v5 2/2] mmc: dw_mmc: add reset support to dwmmc host controller Date: Fri, 12 Aug 2016 16:51:26 +0800 Message-Id: <1470991886-22412-3-git-send-email-guodong.xu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470991886-22412-1-git-send-email-guodong.xu@linaro.org> References: <1470991886-22412-1-git-send-email-guodong.xu@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Dwmmc host controller may in unknown state when entering kernel boot. One example is when booting from eMMC, bootloader need initialize MMC host controller into some state so it can read. In order to make sure MMC host controller in a clean initial state, this reset support is added. With this patch, a 'resets' property can be added into dw_mmc device tree node. The hardware logic is: dwmmc host controller IP receives a reset signal from a 'reset provider' (eg. power management unit). The 'resets' property points to this reset signal. So, during dwmmc driver probe, it can use this signal to reset itself. Refer to [1] for more information. [1] Documentation/devicetree/bindings/reset/reset.txt Signed-off-by: Guodong Xu Signed-off-by: Xinwei Kong Signed-off-by: Zhangfei Gao Reviewed-by: Shawn Lin --- drivers/mmc/host/dw_mmc.c | 23 ++++++++++++++++++++++- include/linux/mmc/dw_mmc.h | 2 ++ 2 files changed, 24 insertions(+), 1 deletion(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 1b719a6..4dff0ee 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2872,6 +2872,13 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host) if (!pdata) return ERR_PTR(-ENOMEM); + /* find reset controller when exist */ + pdata->rstc = devm_reset_control_get_optional(dev, NULL); + if (IS_ERR(pdata->rstc)) { + if (PTR_ERR(pdata->rstc) == -EPROBE_DEFER) + return ERR_PTR(-EPROBE_DEFER); + } + /* find out number of slots supported */ of_property_read_u32(np, "num-slots", &pdata->num_slots); @@ -2943,7 +2950,9 @@ int dw_mci_probe(struct dw_mci *host) if (!host->pdata) { host->pdata = dw_mci_parse_dt(host); - if (IS_ERR(host->pdata)) { + if (PTR_ERR(host->pdata) == -EPROBE_DEFER) { + return -EPROBE_DEFER; + } else if (IS_ERR(host->pdata)) { dev_err(host->dev, "platform data not available\n"); return -EINVAL; } @@ -2997,6 +3006,12 @@ int dw_mci_probe(struct dw_mci *host) } } + if (!IS_ERR(host->pdata->rstc)) { + reset_control_assert(host->pdata->rstc); + usleep_range(10, 50); + reset_control_deassert(host->pdata->rstc); + } + setup_timer(&host->cmd11_timer, dw_mci_cmd11_timer, (unsigned long)host); @@ -3146,6 +3161,9 @@ err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + err_clk_ciu: clk_disable_unprepare(host->ciu_clk); @@ -3176,6 +3194,9 @@ void dw_mci_remove(struct dw_mci *host) if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (!IS_ERR(host->pdata->rstc)) + reset_control_assert(host->pdata->rstc); + clk_disable_unprepare(host->ciu_clk); clk_disable_unprepare(host->biu_clk); } diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 83b0edfc..f5af2bd 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -17,6 +17,7 @@ #include #include #include +#include #define MAX_MCI_SLOTS 2 @@ -259,6 +260,7 @@ struct dw_mci_board { /* delay in mS before detecting cards after interrupt */ u32 detect_delay_ms; + struct reset_control *rstc; struct dw_mci_dma_ops *dma_ops; struct dma_pdata *data; };