Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216AbdDEEvs (ORCPT ); Wed, 5 Apr 2017 00:51:48 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:48551 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750871AbdDEEvp (ORCPT ); Wed, 5 Apr 2017 00:51:45 -0400 X-AuditID: b6c32a36-f79446d000002bcd-13-58e47542ed6e Subject: Re: [PATCH] mmc: core: add mmc-card hardware reset enable support To: Richard Leitner , ulf.hansson@linaro.org, robh+dt@kernel.org, mark.rutland@arm.com Cc: shawn.lin@rock-chips.com, adrian.hunter@intel.com, linus.walleij@linaro.org, linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, dev@g0hl1n.net From: Jaehoon Chung Message-id: Date: Wed, 05 Apr 2017 13:40:33 +0900 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-version: 1.0 In-reply-to: <1491315394-7568-1-git-send-email-richard.leitner@skidata.com> Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJJsWRmVeSWpSXmKPExsWy7bCmnq5T6ZMIg1fLtCxOPlnDZvF+xxcW i/lHzrFaTPmznMni8q45bBZH/vczWiy9fpHJ4udbG4vWvUfYLe48Wc9qcXxtuAO3x5p5axg9 Vux/zeSxeM9LJo9NqzrZPO5c28Pm8XfWfhaP7WuvMnl83iQXwBGVapORmpiSWqSQmpecn5KZ l26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+TiE6DrlpkDdKeSQlliTilQKCCxuFhJ386mKL+0 JFUhI7+4xFYp2tDQSM/QwFzPyMhIz8Q41srIFKgkITXj7eY3LAX7JSr6Dz5la2BcINzFyMkh IWAi8W/rOTYIW0ziwr31QDYXh5DADkaJC88eMEE47UwS3/43MMJ0TN8/iRkiMYdRYk7jV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Lr/JhtIQkjgAaPElY9GILaw gJfE9NunWEBsEYFSic7+h0wQDQsYJbYcWw3WzSywg1Gif99+sCo2AR2J7d+OA1VxcPAK2Elc epIFEmYRUJW4O30GI0hYVCBM4nmjE0iYV0BQ4sfkeywgYU4Bb4kjqytATGYBdYkpU3JBKpgF 5CU2r3nLPIER6EaEhlkIVbOQVC1gZF7FKJFakFxQnJSea5iXWq5XnJhbXJqXrpecn7uJERyf z6R2MB7c5X6IUYCDUYmHt2La4wgh1sSy4srcQ4wSHMxKIrybc55ECPGmJFZWpRblxxeV5qQW H2I0BXpiIrOUaHI+MHXklcQbmpibmBsbWJhbWpoYKYnzNs5+Fi4kkJ5YkpqdmlqQWgTTx8TB KdXA6LD1Omtk+Rex/++f7TlYXSRvaLFo8jWxx+dOnp3IztouvcDoKBtr2mfvVQIbsxUmf2ec zPxmbt8Cq99Jr1+EO9ZcrOC/fKMv7JD1293z9601So6T/utbfFWlh5HpruX+N/m6a+d9WLaN f/fkq16rdF9UZu5fsPvNGnOWpBM/uL5/Up1n8WT/hEYlluKMREMt5qLiRACawzEc5QIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170405044034epcas1p45ce99d3a5607c68d6d625be9e9987d56 X-Msg-Generator: CA X-Sender-IP: 203.254.230.26 X-Local-Sender: =?UTF-8?B?7KCV7J6s7ZuIG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbU2VuaW9yIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?SmFlaG9vbiBDaHVuZxtUaXplbiBQbGF0Zm9ybSBMYWIuG1Nh?= =?UTF-8?B?bXN1bmcgRWxlY3Ryb25pY3MbU2VuaW9yIEVuZ2luZWVy?= X-Sender-Code: =?UTF-8?B?QzEwG1NUQUYbQzEwVjgxMTE=?= CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-HopCount: 7 X-CMS-RootMailID: 20170404141714epcas5p495985819f877cc723ef217e9cefe89c1 X-RootMTR: 20170404141714epcas5p495985819f877cc723ef217e9cefe89c1 References: <1491315394-7568-1-git-send-email-richard.leitner@skidata.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3045 Lines: 88 Hi, On 04/04/2017 11:16 PM, Richard Leitner wrote: > Some eMMCs disable their hardware reset line (RST_N) by default. To enable > it the host must set the corresponding bit in ECSD. An example for such > a device is the Micron MTFCxGACAANA-4M. > > This patch adds a new mmc-card devicetree property to let the host enable > this feature during card initialization. > > Signed-off-by: Richard Leitner > --- > Documentation/devicetree/bindings/mmc/mmc-card.txt | 3 +++ > drivers/mmc/core/mmc.c | 21 +++++++++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.txt b/Documentation/devicetree/bindings/mmc/mmc-card.txt > index a70fcd6..8590a40 100644 > --- a/Documentation/devicetree/bindings/mmc/mmc-card.txt > +++ b/Documentation/devicetree/bindings/mmc/mmc-card.txt > @@ -12,6 +12,9 @@ Required properties: > Optional properties: > -broken-hpi : Use this to indicate that the mmc-card has a broken hpi > implementation, and that hpi should not be used > +-enable-hw-reset : some eMMC devices have disabled the hw reset functionality > + (RST_N_FUNCTION) by default. By adding this property the > + host will enable it during initialization. As i know, RST_N_FUNCTION is controlled bit[1:0] 0x0 : RST_n disabled (by default) 0x1 : permanently enabled 0x2 : permanently disabled I think that it needs to add the description about these.. > > Example: > > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c > index b502601..518d0e3 100644 > --- a/drivers/mmc/core/mmc.c > +++ b/drivers/mmc/core/mmc.c > @@ -1520,9 +1520,16 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, > int err; > u32 cid[4]; > u32 rocr; > + struct device_node *np; > + bool enable_rst_n = false; > > WARN_ON(!host->claimed); > > + np = mmc_of_find_child_device(host, 0); > + if (np && of_device_is_compatible(np, "mmc-card")) > + enable_rst_n = of_property_read_bool(np, "enable-hw-reset"); > + of_node_put(np); > + > /* Set correct bus mode for MMC before attempting init */ > if (!mmc_host_is_spi(host)) > mmc_set_bus_mode(host, MMC_BUSMODE_OPENDRAIN); > @@ -1810,6 +1817,20 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, > } > } > > + /* > + * try to enable RST_N if requested > + * This is needed because some eMMC chips disable this function by > + * default. > + */ > + if (enable_rst_n) { > + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, > + EXT_CSD_RST_N_FUNCTION, EXT_CSD_RST_N_ENABLED, > + card->ext_csd.generic_cmd6_time); > + if (err && err != -EBADMSG) > + pr_warn("%s: Enabling RST_N feature failed\n", > + mmc_hostname(card->host)); > + } If enabled hw-reset, it doesn't need to re-enable this bit. i didn't check the mmc-util.. If mmc-util provides the changing this, the using mmc-util is better than this. Best Regards, Jaehoon Chung > + > if (!oldcard) > host->card = card; > >