From patchwork Sun Mar 6 08:47:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 8512451 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5CA1EC0553 for ; Sun, 6 Mar 2016 08:48:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70A5E20155 for ; Sun, 6 Mar 2016 08:48:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BAD92017D for ; Sun, 6 Mar 2016 08:48:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751208AbcCFIsT (ORCPT ); Sun, 6 Mar 2016 03:48:19 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33128 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbcCFIsI (ORCPT ); Sun, 6 Mar 2016 03:48:08 -0500 Received: by mail-pa0-f41.google.com with SMTP id fl4so60388617pad.0 for ; Sun, 06 Mar 2016 00:48:07 -0800 (PST) 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=PBi6D8x/Iz08m6VmQCLngjx3bwmuakgbbtfRF490tyU=; b=aGCu7wuWvgu0BCQ6DRw5Fk7jo4imwTdqX6t+RFsgb+NWLtePOGIUSeN2p044Xpff1G tWxLGzuLIqX+80CUzg5MiztW/Mzto2lxSgDRWRjZLtogWAdJZvqGp909jilA5JIyc+GZ N/FplxDxyoScXPb9yLeDgN8C6kay/M12JFfMw= 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=PBi6D8x/Iz08m6VmQCLngjx3bwmuakgbbtfRF490tyU=; b=WNrzpMYM6PqspG30mUahyqkbmjwJnDUe4s+KhlTzGqtlsQ0oPutk6Otb+U8SOGYaPK pizDQUWjHeMwwPRUcqDXZXnJFuO6KN4sYJNeSuZk8x1icxLrsiBV7x0Cbt5OalmWQq3G U7NdxBRjinq7pbSuJXVcDzdkbHGQLag4XOTX6NeC2KI63KA1WBdhd90wYeCp1C791jm5 zC0FCWxqHez//18c+RC4BngFqKu3w74xVow2SmQzbdj4eZPktp5c0HR1PCDJO9oC/zRi nn5w4ps2Edee9mwzvZmBBrUxLGbKAtq53gVnXMe6wWIxk8dAZBscNhets/b3uK33FlXV 41yA== X-Gm-Message-State: AD7BkJJ9OQYdLuiFMA+2380HzI/1ETG//VV+0vTacd6B6tXuvcx9VsnFDSvkPuXRooW9SbSY X-Received: by 10.66.124.226 with SMTP id ml2mr24966627pab.90.1457254087043; Sun, 06 Mar 2016 00:48:07 -0800 (PST) Received: from localhost.localdomain (110-170-137-3.static.asianet.co.th. [110.170.137.3]) by smtp.gmail.com with ESMTPSA id xa9sm16613411pab.44.2016.03.06.00.48.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 06 Mar 2016 00:48:06 -0800 (PST) From: Guodong Xu To: robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, jh80.chung@samsung.com, ulf.hansson@linaro.org, shawn.lin@rock-chips.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mmc@vger.kernel.org Cc: Guodong Xu , Xinwei Kong , Zhangfei Gao Subject: [PATCH 2/2] mmc: dw_mmc: add resets support to dw_mmc Date: Sun, 6 Mar 2016 15:47:42 +0700 Message-Id: <1457254062-22677-2-git-send-email-guodong.xu@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1457254062-22677-1-git-send-email-guodong.xu@linaro.org> References: <1457254062-22677-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 X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 242f9a0..281ea9c 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c @@ -2878,6 +2878,14 @@ 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); + pdata->rstc = NULL; + } + /* find out number of slots supported */ of_property_read_u32(np, "num-slots", &pdata->num_slots); @@ -2949,7 +2957,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 +3022,9 @@ int dw_mci_probe(struct dw_mci *host) } } + if (host->pdata->rstc != NULL) + reset_control_deassert(host->pdata->rstc); + setup_timer(&host->cmd11_timer, dw_mci_cmd11_timer, (unsigned long)host); @@ -3164,6 +3177,9 @@ err_dmaunmap: if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (host->pdata->rstc != NULL) + reset_control_assert(host->pdata->rstc); + err_clk_ciu: if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); @@ -3196,11 +3212,15 @@ void dw_mci_remove(struct dw_mci *host) if (host->use_dma && host->dma_ops->exit) host->dma_ops->exit(host); + if (host->pdata->rstc != NULL) + reset_control_assert(host->pdata->rstc); + if (!IS_ERR(host->ciu_clk)) clk_disable_unprepare(host->ciu_clk); if (!IS_ERR(host->biu_clk)) clk_disable_unprepare(host->biu_clk); + } EXPORT_SYMBOL(dw_mci_remove);