From patchwork Wed Mar 30 07:24:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 64638 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp2436425lbc; Wed, 30 Mar 2016 00:25:47 -0700 (PDT) X-Received: by 10.66.131.79 with SMTP id ok15mr10593856pab.151.1459322746574; Wed, 30 Mar 2016 00:25:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o86si4427138pfi.217.2016.03.30.00.25.46; Wed, 30 Mar 2016 00:25:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 S1758655AbcC3HZZ (ORCPT + 7 others); Wed, 30 Mar 2016 03:25:25 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33847 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758606AbcC3HZX (ORCPT ); Wed, 30 Mar 2016 03:25:23 -0400 Received: by mail-pa0-f51.google.com with SMTP id fe3so33615295pab.1 for ; Wed, 30 Mar 2016 00:25:23 -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=UloNsLf0FJ4n4fpKm5AGviJrrPPn53kRpmB1VdvmEPM=; b=kZrABRpgt9E2qrbjB54PjVY8uQ9Y2gpduXHjDMdhgPGVBymgDPRYbBEPa9doxrNV6u F5xxncaxHCN6lfnhnf9Z4Hpniwqh7OOv8BP3M6K9POpWpM/R6n9EqZfHkG8g5JHTLpTD YPGImatw/jzw9h0W7vIqP/inGtfQ/iBxx2Mbs= 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=UloNsLf0FJ4n4fpKm5AGviJrrPPn53kRpmB1VdvmEPM=; b=Vw8XFp6P85GcYGj2Iqq+CbUBlpH7bdV15VY0xqvQRhbA1Rhj0sw9ccI75qL3CJOsqa rJkNpL3FQxKSDx+DUjcVs9NIjF0CY5JPZusAB1zo4wsNB5Hz6crbClYTsLBIWLsrHzHl DGlAnzV9PcpRoxFOqFhJTMkfWfyQQTWGjdJNAGtYKzNJ3nQlRsEqpqiEyMtSdXHk4rIs tZp9+ZuHwZUkAFuiRXYjuhGS+wm+BVPZEM/nQrWlMKhI9QHfBTh1NMAmT40P0WR498S+ OjSy1k/2kAUHe8PrDYyisR4fVh6TiIn7/Zxxn6wJ2jm6HMwlqMp4vzisg3Wd9h0EHf+0 qL6A== X-Gm-Message-State: AD7BkJLUDmY69OHxmPEWlfCE55ZFa5Ustm5nrB6DVwl7oSUkDVboU6LWpn8jB7DHHlweKkJY X-Received: by 10.66.55.6 with SMTP id n6mr10685225pap.35.1459322723198; Wed, 30 Mar 2016 00:25:23 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.44]) by smtp.gmail.com with ESMTPSA id 9sm3251359pft.44.2016.03.30.00.25.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 30 Mar 2016 00:25:22 -0700 (PDT) From: Guodong Xu To: shawn.lin@rock-chips.com, jh80.chung@samsung.com, --to=robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, ulf.hansson@linaro.org, guodong.xu@linaro.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Xinwei Kong , Zhangfei Gao Subject: [PATCH v3 2/2] mmc: dw_mmc: add resets support to dw_mmc Date: Wed, 30 Mar 2016 15:24:56 +0800 Message-Id: <1459322696-29919-3-git-send-email-guodong.xu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1459322696-29919-1-git-send-email-guodong.xu@linaro.org> References: <1459322696-29919-1-git-send-email-guodong.xu@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org mmc registers may in abnormal state if mmc is used in bootloader, eg. to support booting from eMMC. So we need reset mmc registers when kernel boots up, instead of assuming mmc is in clean state. With this patch, user can add a 'resets' property into dw_mmc dts node. When driver parse_dt and probe, it calls reset API to deassert the 'reset' of dw_mmc host controller. When probe error or remove, it calls reset API to assert it. Please also refer to Documentation/devicetree/bindings/reset/reset.txt Signed-off-by: Guodong Xu Signed-off-by: Xinwei Kong Signed-off-by: Zhangfei Gao --- drivers/mmc/host/dw_mmc.c | 20 +++++++++++++++++++- include/linux/mmc/dw_mmc.h | 6 ++++-- 2 files changed, 23 insertions(+), 3 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" 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 242f9a0..d0a4535 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2878,6 +2878,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); @@ -2949,7 +2956,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; } @@ -3012,6 +3021,9 @@ int dw_mci_probe(struct dw_mci *host) } } + if (!IS_ERR(host->pdata->rstc)) + reset_control_deassert(host->pdata->rstc); + setup_timer(&host->cmd11_timer, dw_mci_cmd11_timer, (unsigned long)host); @@ -3164,6 +3176,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: if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); @@ -3196,6 +3211,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); + if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 7b41c6d..b95cd84 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h @@ -14,9 +14,10 @@ #ifndef LINUX_MMC_DW_MMC_H #define LINUX_MMC_DW_MMC_H -#include -#include #include +#include +#include +#include #define MAX_MCI_SLOTS 2 @@ -260,6 +261,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; };