* [PATCH] mmc: core: add mmc-card hardware reset enable support @ 2017-04-04 14:16 ` Richard Leitner [not found] ` <1491315394-7568-1-git-send-email-richard.leitner-WcANXNA0UjBBDgjK7y7TUQ@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Richard Leitner @ 2017-04-04 14:16 UTC (permalink / raw) To: ulf.hansson-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8 Cc: shawn.lin-TNX95d0MmH7DzftRWevZcw, adrian.hunter-ral2JQCrhuEAvxtiuMwx3w, jh80.chung-Sze3O3UU22JBDgjK7y7TUQ, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-mmc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, dev-M/VWbR8SM2SsTnJN9+BGXg, Richard Leitner 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 <richard.leitner-WcANXNA0UjBBDgjK7y7TUQ@public.gmane.org> --- 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. 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 (!oldcard) host->card = card; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1491315394-7568-1-git-send-email-richard.leitner-WcANXNA0UjBBDgjK7y7TUQ@public.gmane.org>]
* Re: [PATCH] mmc: core: add mmc-card hardware reset enable support [not found] ` <1491315394-7568-1-git-send-email-richard.leitner-WcANXNA0UjBBDgjK7y7TUQ@public.gmane.org> @ 2017-04-05 4:40 ` Jaehoon Chung 2017-04-05 6:23 ` Richard Leitner 0 siblings, 1 reply; 4+ messages in thread From: Jaehoon Chung @ 2017-04-05 4:40 UTC (permalink / raw) To: Richard Leitner, ulf.hansson-QSEj5FYQhm4dnm+yROfE0A, robh+dt-DgEjT+Ai2ygdnm+yROfE0A, mark.rutland-5wv7dgnIgG8 Cc: shawn.lin-TNX95d0MmH7DzftRWevZcw, adrian.hunter-ral2JQCrhuEAvxtiuMwx3w, linus.walleij-QSEj5FYQhm4dnm+yROfE0A, linux-mmc-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, devicetree-u79uwXL29TY76Z2rM5mHXA, dev-M/VWbR8SM2SsTnJN9+BGXg 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 <richard.leitner-WcANXNA0UjBBDgjK7y7TUQ@public.gmane.org> > --- > 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; > > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: core: add mmc-card hardware reset enable support 2017-04-05 4:40 ` Jaehoon Chung @ 2017-04-05 6:23 ` Richard Leitner 2017-04-10 15:17 ` Rob Herring 0 siblings, 1 reply; 4+ messages in thread From: Richard Leitner @ 2017-04-05 6:23 UTC (permalink / raw) To: Jaehoon Chung, ulf.hansson, robh+dt, mark.rutland Cc: shawn.lin, adrian.hunter, linus.walleij, linux-mmc, linux-kernel, devicetree, dev On 04/05/2017 06:40 AM, Jaehoon Chung wrote: > 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 <richard.leitner@skidata.com> >> --- >> 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.. Ok. >> >> 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. Ok. I can add a check to prevent setting it, if it is set already. > i didn't check the mmc-util.. > If mmc-util provides the changing this, the using mmc-util is better than this. mmc-utils is providing a enable/disable hwreset feature. But as this setting is required for my hardware to allow rebooting it, I thought it would be better if it's in the kernel. So I/the hw doesn't have to depend on userspace tools. Nonetheless you're the experts, therefore if you say it shouldn't be in the kernel/dt I'd be fine with that too. ;-) ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mmc: core: add mmc-card hardware reset enable support 2017-04-05 6:23 ` Richard Leitner @ 2017-04-10 15:17 ` Rob Herring 0 siblings, 0 replies; 4+ messages in thread From: Rob Herring @ 2017-04-10 15:17 UTC (permalink / raw) To: Richard Leitner Cc: Jaehoon Chung, ulf.hansson, mark.rutland, shawn.lin, adrian.hunter, linus.walleij, linux-mmc, linux-kernel, devicetree, dev On Wed, Apr 05, 2017 at 08:23:29AM +0200, Richard Leitner wrote: > On 04/05/2017 06:40 AM, Jaehoon Chung wrote: > > 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 <richard.leitner@skidata.com> > >> --- > >> 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.. > > Ok. > > >> > >> 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. > > Ok. I can add a check to prevent setting it, if it is set already. > > > i didn't check the mmc-util.. > > If mmc-util provides the changing this, the using mmc-util is better than this. > > mmc-utils is providing a enable/disable hwreset feature. But as this > setting is required for my hardware to allow rebooting it, I thought it > would be better if it's in the kernel. So I/the hw doesn't have to > depend on userspace tools. Doesn't really seem like something you'd want a user to have to care about, so in DT seems fine to me. Rob ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-04-10 15:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20170404141714epcas5p495985819f877cc723ef217e9cefe89c1@epcas5p4.samsung.com>
2017-04-04 14:16 ` [PATCH] mmc: core: add mmc-card hardware reset enable support Richard Leitner
[not found] ` <1491315394-7568-1-git-send-email-richard.leitner-WcANXNA0UjBBDgjK7y7TUQ@public.gmane.org>
2017-04-05 4:40 ` Jaehoon Chung
2017-04-05 6:23 ` Richard Leitner
2017-04-10 15:17 ` Rob Herring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox