From: Adrian Hunter <adrian.hunter@intel.com>
To: Johan Rudholm <johan.rudholm@axis.com>,
linux-mmc@vger.kernel.org, Chris Ball <chris@printf.net>,
Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Guennadi Liakhovetski" <g.liakhovetski@gmx.de>,
"David Lanzendörfer" <david.lanzendoerfer@o2s.ch>,
"Jesper Nilsson" <jespern@axis.com>,
"Johan Rudholm" <johanru@axis.com>
Subject: Re: [PATCH 3/4] mmc: core: make hw_reset generic
Date: Mon, 03 Nov 2014 11:20:55 +0200 [thread overview]
Message-ID: <545748F7.8020707@intel.com> (raw)
In-Reply-To: <1414154790-20893-4-git-send-email-johanru@axis.com>
On 24/10/14 15:46, Johan Rudholm wrote:
> Move the (e)MMC specific hw_reset code from core.c into mmc.c and call
> it from the new bus_ops member power_reset. This also lets us add code
power_reset is not a good name because it does not necessarily have
anything to do with power. I am not sure why you don't stick with
hw_reset.
> for reseting SD cards as well.
>
> Rename the mmc_hw_reset* functions into mmc_reset*, since what they
> now actually do depends on the device type (and it may be something else
> than doing a hw_reset).
I don't follow your reasoning about the rename. Cycling the power is
a kind of hardware reset isn't it.
>
> Signed-off-by: Johan Rudholm <johanru@axis.com>
> ---
> drivers/mmc/card/block.c | 2 +-
> drivers/mmc/card/mmc_test.c | 5 +---
> drivers/mmc/core/core.c | 58 +++++++++---------------------------------
> drivers/mmc/core/core.h | 4 +++
> drivers/mmc/core/mmc.c | 40 +++++++++++++++++++++++++++++
> include/linux/mmc/core.h | 5 +--
> 6 files changed, 61 insertions(+), 53 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 452782b..8c4fa46 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1001,7 +1001,7 @@ static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host,
> return -EEXIST;
>
> md->reset_done |= type;
> - err = mmc_hw_reset(host);
> + err = mmc_reset(host);
> /* Ensure we switch back to the correct partition */
> if (err != -EOPNOTSUPP) {
> struct mmc_blk_data *main_md = mmc_get_drvdata(host->card);
> diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c
> index 0c0fc52..599c683 100644
> --- a/drivers/mmc/card/mmc_test.c
> +++ b/drivers/mmc/card/mmc_test.c
> @@ -2339,7 +2339,7 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
> struct mmc_host *host = card->host;
> int err;
>
> - err = mmc_hw_reset_check(host);
> + err = mmc_reset_check(host);
> if (!err)
> return RESULT_OK;
>
> @@ -2349,9 +2349,6 @@ static int mmc_test_hw_reset(struct mmc_test_card *test)
> if (err != -EOPNOTSUPP)
> return err;
>
> - if (!mmc_can_reset(card))
> - return RESULT_UNSUP_CARD;
> -
> return RESULT_UNSUP_HOST;
> }
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index d56e222..486cda8 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2232,65 +2232,33 @@ static void mmc_hw_reset_for_init(struct mmc_host *host)
> mmc_host_clk_release(host);
> }
>
> -int mmc_can_reset(struct mmc_card *card)
> +/* Reset card in a bus-specific way */
> +static int mmc_do_reset(struct mmc_host *host, int check)
> {
> - u8 rst_n_function;
> -
> - if (!mmc_card_mmc(card))
> - return 0;
> - rst_n_function = card->ext_csd.rst_n_function;
> - if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) != EXT_CSD_RST_N_ENABLED)
> - return 0;
> - return 1;
> -}
> -EXPORT_SYMBOL(mmc_can_reset);
> -
> -static int mmc_do_hw_reset(struct mmc_host *host, int check)
> -{
> - struct mmc_card *card = host->card;
> -
> - if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
> - return -EOPNOTSUPP;
> -
> - if (!card)
> - return -EINVAL;
> + int ret;
>
> - if (!mmc_can_reset(card))
> + if (!host->bus_ops || !host->bus_ops->power_reset ||
> + host->bus_ops->power_reset(host, MMC_POWER_RESET_TEST))
> return -EOPNOTSUPP;
>
> - mmc_host_clk_hold(host);
> - mmc_set_clock(host, host->f_init);
> -
> - host->ops->hw_reset(host);
> -
> - /* If the reset has happened, then a status command will fail */
> - if (check) {
> - u32 status;
> -
> - if (!mmc_send_status(card, &status)) {
> - mmc_host_clk_release(host);
> - return -ENOSYS;
> - }
> - }
> -
> - mmc_power_up(host, card->ocr);
> + ret = host->bus_ops->power_reset(host, check);
>
> - mmc_host_clk_release(host);
> + pr_warning("%s: tried to reset card (%d)\n", mmc_hostname(host), ret);
>
> return host->bus_ops->power_restore(host);
> }
>
> -int mmc_hw_reset(struct mmc_host *host)
> +int mmc_reset(struct mmc_host *host)
> {
> - return mmc_do_hw_reset(host, 0);
> + return mmc_do_reset(host, MMC_POWER_RESET_RESET);
> }
> -EXPORT_SYMBOL(mmc_hw_reset);
> +EXPORT_SYMBOL(mmc_reset);
>
> -int mmc_hw_reset_check(struct mmc_host *host)
> +int mmc_reset_check(struct mmc_host *host)
> {
> - return mmc_do_hw_reset(host, 1);
> + return mmc_do_reset(host, MMC_POWER_RESET_CHECK);
> }
> -EXPORT_SYMBOL(mmc_hw_reset_check);
> +EXPORT_SYMBOL(mmc_reset_check);
>
> static int mmc_rescan_try_freq(struct mmc_host *host, unsigned freq)
> {
> diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
> index 443a584..6a0420b 100644
> --- a/drivers/mmc/core/core.h
> +++ b/drivers/mmc/core/core.h
> @@ -25,6 +25,10 @@ struct mmc_bus_ops {
> int (*runtime_resume)(struct mmc_host *);
> int (*power_save)(struct mmc_host *);
> int (*power_restore)(struct mmc_host *);
> + int (*power_reset)(struct mmc_host *, int);
> +#define MMC_POWER_RESET_RESET 0
> +#define MMC_POWER_RESET_TEST 1
> +#define MMC_POWER_RESET_CHECK 2
> int (*alive)(struct mmc_host *);
> int (*shutdown)(struct mmc_host *);
> };
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 793c6f7..ac5192c 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -1762,6 +1762,45 @@ static int mmc_runtime_resume(struct mmc_host *host)
> return 0;
> }
>
> +static int mmc_power_reset(struct mmc_host *host, int test)
> +{
> + struct mmc_card *card = host->card;
> + u8 rst_n_function;
> +
> + if (!card)
> + return -EINVAL;
> +
> + if (!(host->caps & MMC_CAP_HW_RESET) || !host->ops->hw_reset)
> + return -EOPNOTSUPP;
> +
> + rst_n_function = card->ext_csd.rst_n_function;
> + if ((rst_n_function & EXT_CSD_RST_N_EN_MASK) != EXT_CSD_RST_N_ENABLED)
> + return -EOPNOTSUPP;
> +
> + if (test == MMC_POWER_RESET_TEST)
> + return 0;
> +
> + mmc_host_clk_hold(host);
> + mmc_set_clock(host, host->f_init);
> +
> + host->ops->hw_reset(host);
> +
> + if (test == MMC_POWER_RESET_CHECK) {
> + u32 status;
> +
> + if (!mmc_send_status(card, &status)) {
> + mmc_host_clk_release(host);
> + return -ENOSYS;
> + }
> + }
> +
> + mmc_power_up(host, card->ocr);
> +
> + mmc_host_clk_release(host);
> +
> + return 0;
> +}
> +
> static int mmc_power_restore(struct mmc_host *host)
> {
> int ret;
> @@ -1781,6 +1820,7 @@ static const struct mmc_bus_ops mmc_ops = {
> .runtime_suspend = mmc_runtime_suspend,
> .runtime_resume = mmc_runtime_resume,
> .power_restore = mmc_power_restore,
> + .power_reset = mmc_power_reset,
> .alive = mmc_alive,
> .shutdown = mmc_shutdown,
> };
> diff --git a/include/linux/mmc/core.h b/include/linux/mmc/core.h
> index f206e29..4f7a76e 100644
> --- a/include/linux/mmc/core.h
> +++ b/include/linux/mmc/core.h
> @@ -180,9 +180,8 @@ extern unsigned int mmc_calc_max_discard(struct mmc_card *card);
> extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
> extern int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
> bool is_rel_write);
> -extern int mmc_hw_reset(struct mmc_host *host);
> -extern int mmc_hw_reset_check(struct mmc_host *host);
> -extern int mmc_can_reset(struct mmc_card *card);
> +extern int mmc_reset(struct mmc_host *host);
> +extern int mmc_reset_check(struct mmc_host *host);
>
> extern void mmc_set_data_timeout(struct mmc_data *, const struct mmc_card *);
> extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
>
next prev parent reply other threads:[~2014-11-03 9:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-24 12:46 [PATCH 0/4] mmc: core: hw_reset changes Johan Rudholm
2014-10-24 12:46 ` [PATCH 1/4] mmc: core: use mmc_send_status to check hw_reset Johan Rudholm
2014-10-24 12:46 ` [PATCH 2/4] mmc: core: use mmc_power_up in hw_reset Johan Rudholm
2014-11-03 9:21 ` Adrian Hunter
2014-11-03 10:13 ` Johan Rudholm
2014-11-03 10:59 ` Adrian Hunter
2014-10-24 12:46 ` [PATCH 3/4] mmc: core: make hw_reset generic Johan Rudholm
2014-11-03 9:20 ` Adrian Hunter [this message]
2014-11-03 10:19 ` Johan Rudholm
2014-11-03 10:56 ` Adrian Hunter
2014-10-24 12:46 ` [PATCH 4/4] mmc: sd: add power_reset callback Johan Rudholm
2014-11-03 8:46 ` [PATCH 0/4] mmc: core: hw_reset changes Johan Rudholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=545748F7.8020707@intel.com \
--to=adrian.hunter@intel.com \
--cc=chris@printf.net \
--cc=david.lanzendoerfer@o2s.ch \
--cc=g.liakhovetski@gmx.de \
--cc=jespern@axis.com \
--cc=johan.rudholm@axis.com \
--cc=johanru@axis.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.