linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <subhashj@codeaurora.org>
To: "'Nath, Arindam'" <Arindam.Nath@amd.com>, cjb@laptop.org
Cc: zhangfei.gao@gmail.com, prakity@marvell.com,
	linux-mmc@vger.kernel.org, "'Su, Henry'" <Henry.Su@amd.com>,
	"'Lu, Aaron'" <Aaron.Lu@amd.com>,
	anath.amd@gmail.com
Subject: RE: [PATCH v2 07/12] mmc: sd: set current limit for uhs cards
Date: Thu, 10 Mar 2011 15:15:47 +0530	[thread overview]
Message-ID: <000c01cbdf07$f154c220$d3fe4660$@org> (raw)
In-Reply-To: <6C03668EAF45B747AF947A1603D1B300E3AA282D@SAUSEXMBP01.amd.com>



> -----Original Message-----
> From: Nath, Arindam [mailto:Arindam.Nath@amd.com]
> Sent: Thursday, March 10, 2011 2:13 PM
> To: subhashj@codeaurora.org; cjb@laptop.org
> Cc: zhangfei.gao@gmail.com; prakity@marvell.com; linux-
> mmc@vger.kernel.org; Su, Henry; Lu, Aaron; anath.amd@gmail.com
> Subject: RE: [PATCH v2 07/12] mmc: sd: set current limit for uhs cards
> 
> Hi Subhash,
> 
> 
> > -----Original Message-----
> > From: subhashj@codeaurora.org [mailto:subhashj@codeaurora.org]
> > Sent: Thursday, March 10, 2011 1:46 PM
> > To: Nath, Arindam; cjb@laptop.org
> > Cc: zhangfei.gao@gmail.com; prakity@marvell.com; linux-
> > mmc@vger.kernel.org; Su, Henry; Lu, Aaron; anath.amd@gmail.com
> > Subject: RE: [PATCH v2 07/12] mmc: sd: set current limit for uhs
> cards
> >
> >
> >
> > > -----Original Message-----
> > > From: Arindam Nath [mailto:anath.amd@gmail.com] On Behalf Of
> Arindam
> > > Nath
> > > Sent: Friday, March 04, 2011 5:03 PM
> > > To: cjb@laptop.org
> > > Cc: zhangfei.gao@gmail.com; prakity@marvell.com;
> > > subhashj@codeaurora.org; linux-mmc@vger.kernel.org;
> henry.su@amd.com;
> > > aaron.lu@amd.com; anath.amd@gmail.com; Arindam Nath
> > > Subject: [PATCH v2 07/12] mmc: sd: set current limit for uhs cards
> > >
> > > We decide on the current limit to be set for the card based on the
> > > Capability of Host Controller to provide current at 1.8V
> signalling,
> > > and the maximum current limit of the card as indicated by CMD6
> > > mode 0. We then set the current limit for the card using CMD6 mode
> 1.
> > >
> > > Signed-off-by: Arindam Nath <arindam.nath@amd.com>
> > > ---
> > >  drivers/mmc/core/sd.c    |   45
> > > +++++++++++++++++++++++++++++++++++++++++++++
> > >  drivers/mmc/host/sdhci.c |   24 ++++++++++++++++++++++++
> > >  include/linux/mmc/card.h |    9 +++++++++
> > >  include/linux/mmc/host.h |    1 +
> > >  4 files changed, 79 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
> > > index ec0d8e6..df98a2c 100644
> > > --- a/drivers/mmc/core/sd.c
> > > +++ b/drivers/mmc/core/sd.c
> > > @@ -550,6 +550,46 @@ static int sd_set_bus_speed_mode(struct
> mmc_card
> > > *card, u8 *status)
> > >  	return 0;
> > >  }
> > >
> > > +static int sd_set_current_limit(struct mmc_card *card, u8 *status)
> > > +{
> > > +	struct mmc_host *host = card->host;
> > > +	int mmc_host_max_current_180, current_limit;
> > > +	int err;
> > > +
> > > +	/* sanity check */
> > > +	if (!host->ops->get_max_current_180)
> > > +		return 0;
> > > +
> > > +	/* Maximum current supported by host at 1.8V */
> > > +	mmc_host_max_current_180 = host->ops->get_max_current_180(host);
> >
> > I don't think this should be mmc_ops. Max. current limit supported by
> > host
> > should be one of the MMC_CAP*.
> > In your case you can read the "SDHCI_MAX_CURRENT" register during the
> > probe
> > and can set the appropriate MMC_CAP* from below:
> > #define MMC_CAP_MAX_CURRENT_200	(1 << xx)
> > #define MMC_CAP_MAX_CURRENT_400	(1 << (xx+1))
> > #define MMC_CAP_MAX_CURRENT_600	(1 << (xx+2))
> > #define MMC_CAP_MAX_CURRENT_800	(1 << (xx+3))
> 
> Good suggestion. Thanks. I will make the changes.
> 
> >
> > > +
> > > +	if (mmc_host_max_current_180 >= 800) {
> > > +		if (card->sw_caps.uhs_curr_limit & SD_MAX_CURRENT_800)
> > > +			current_limit = SD_SET_CURRENT_LIMIT_800;
> > > +		else if (card->sw_caps.uhs_curr_limit & SD_MAX_CURRENT_600)
> > > +			current_limit = SD_SET_CURRENT_LIMIT_600;
> > > +		else if (card->sw_caps.uhs_curr_limit & SD_MAX_CURRENT_400)
> > > +			current_limit = SD_SET_CURRENT_LIMIT_400;
> > > +	} else if (mmc_host_max_current_180 >= 600) {
> > > +		if (card->sw_caps.uhs_curr_limit & SD_MAX_CURRENT_600)
> > > +			current_limit = SD_SET_CURRENT_LIMIT_600;
> > > +		else if (card->sw_caps.uhs_curr_limit & SD_MAX_CURRENT_400)
> > > +			current_limit = SD_SET_CURRENT_LIMIT_400;
> > > +	} else if (mmc_host_max_current_180 >= 400)
> > > +		if (card->sw_caps.uhs_curr_limit & SD_MAX_CURRENT_400)
> > > +			current_limit = SD_SET_CURRENT_LIMIT_400;
> > > +
> >
> > What will be value of current_limit if (mmc_host_max_current_180 <
> 400)
> 
> I referred to table 4-11 of Physical Layer specv3.01. < 400mA should
> fall under the default current limit.

Ok. this is fine.

> 
> Thanks,
> Arindam
> 
> >
> > > +	err = mmc_sd_switch(card, 1, 3, current_limit, status);
> > > +	if (err)
> > > +		return err;
> > > +
> > > +	if (((status[15] >> 4) & 0x0F) != current_limit)
> > > +		printk(KERN_WARNING "%s: Problem setting current limit!\n",
> > > +			mmc_hostname(card->host));
> > > +
> > > +	return 0;
> > > +}
> > > +
> > >  /*
> > >   * UHS-I specific initialization procedure
> > >   */
> > > @@ -590,6 +630,11 @@ static int mmc_sd_init_uhs_card(struct
> mmc_card
> > > *card)
> > >
> > >  	/* Set bus speed mode of the card */
> > >  	err = sd_set_bus_speed_mode(card, status);
> > > +	if (err)
> > > +		goto out;
> > > +
> > > +	/* Set current limit for the card */
> > > +	err = sd_set_current_limit(card, status);
> > >
> > >  out:
> > >  	kfree(status);
> > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> > > index f127fa2..245cc39 100644
> > > --- a/drivers/mmc/host/sdhci.c
> > > +++ b/drivers/mmc/host/sdhci.c
> > > @@ -1462,12 +1462,36 @@ static int
> > > sdhci_start_signal_voltage_switch(struct mmc_host *mmc)
> > >  	return -EAGAIN;
> > >  }
> > >
> > > +static int sdhci_get_max_current_180(struct mmc_host *mmc)
> > > +{
> > > +	struct sdhci_host *host;
> > > +	u32 max_current_caps;
> > > +	unsigned long flags;
> > > +	int max_current_180;
> > > +
> > > +	host = mmc_priv(mmc);
> > > +
> > > +	spin_lock_irqsave(&host->lock, flags);
> > > +
> > > +	max_current_caps = sdhci_readl(host, SDHCI_MAX_CURRENT);
> > > +
> > > +	spin_unlock_irqrestore(&host->lock, flags);
> > > +
> > > +	/* Maximum current is 4 times the register value for 1.8V */
> > > +	max_current_180 = ((max_current_caps &
> > > SDHCI_MAX_CURRENT_180_MASK) >>
> > > +			   SDHCI_MAX_CURRENT_180_SHIFT) *
> > > +			   SDHCI_MAX_CURRENT_MULTIPLIER;
> > > +
> > > +	return max_current_180;
> > > +}
> > > +
> > >  static const struct mmc_host_ops sdhci_ops = {
> > >  	.request	= sdhci_request,
> > >  	.set_ios	= sdhci_set_ios,
> > >  	.get_ro		= sdhci_get_ro,
> > >  	.enable_sdio_irq = sdhci_enable_sdio_irq,
> > >  	.start_signal_voltage_switch	=
> > > sdhci_start_signal_voltage_switch,
> > > +	.get_max_current_180		= sdhci_get_max_current_180,
> > >  };
> > >
> > >
> > >
> >
> /**********************************************************************
> > > *******\
> > > diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> > > index 0b24c41..a6811ae 100644
> > > --- a/include/linux/mmc/card.h
> > > +++ b/include/linux/mmc/card.h
> > > @@ -98,6 +98,15 @@ struct sd_switch_caps {
> > >  #define SD_DRIVER_TYPE_C	0x04
> > >  #define SD_DRIVER_TYPE_D	0x08
> > >  	unsigned int		uhs_curr_limit;
> > > +#define SD_SET_CURRENT_LIMIT_200	0
> > > +#define SD_SET_CURRENT_LIMIT_400	1
> > > +#define SD_SET_CURRENT_LIMIT_600	2
> > > +#define SD_SET_CURRENT_LIMIT_800	3
> > > +
> > > +#define SD_MAX_CURRENT_200	(1 << SD_SET_CURRENT_LIMIT_200)
> > > +#define SD_MAX_CURRENT_400	(1 << SD_SET_CURRENT_LIMIT_400)
> > > +#define SD_MAX_CURRENT_600	(1 << SD_SET_CURRENT_LIMIT_600)
> > > +#define SD_MAX_CURRENT_800	(1 << SD_SET_CURRENT_LIMIT_800)
> > >  };
> > >
> > >  struct sdio_cccr {
> > > diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> > > index 4dfff6d..e84cd05 100644
> > > --- a/include/linux/mmc/host.h
> > > +++ b/include/linux/mmc/host.h
> > > @@ -128,6 +128,7 @@ struct mmc_host_ops {
> > >  	void	(*init_card)(struct mmc_host *host, struct mmc_card *card);
> > >
> > >  	int	(*start_signal_voltage_switch)(struct mmc_host *host);
> > > +	int	(*get_max_current_180)(struct mmc_host *mmc);
> > >  };
> > >
> > >  struct mmc_card;
> > > --
> > > 1.7.1
> >
> >
> 



  reply	other threads:[~2011-03-10  9:45 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-04 11:32 [PATCH v2 00/12] add support for host controller v3.00 Arindam Nath
2011-03-04 11:32 ` [PATCH v2 01/12] mmc: sdhci: add support for auto CMD23 Arindam Nath
2011-03-09 12:22   ` subhashj
2011-03-09 12:55     ` Nath, Arindam
2011-03-15 11:23   ` Subhash Jadavani
2011-03-15 11:35     ` Nath, Arindam
2011-03-15 11:52       ` Subhash Jadavani
2011-03-16  6:07         ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 02/12] mmc: sd: add support for signal voltage switch procedure Arindam Nath
2011-03-04 11:47   ` Wolfram Sang
2011-03-04 11:52     ` Nath, Arindam
2011-03-09 10:44   ` subhashj
2011-03-10  6:30     ` subhashj
2011-03-10  8:05       ` Nath, Arindam
2011-03-09 12:45   ` zhangfei gao
2011-03-10  8:11     ` Nath, Arindam
2011-03-15 10:18   ` Subhash Jadavani
2011-03-15 10:32     ` Nath, Arindam
2011-03-15 11:18       ` Subhash Jadavani
2011-03-15 11:28         ` Nath, Arindam
2011-03-15 11:58           ` Subhash Jadavani
2011-03-16  3:03             ` zhangfei gao
2011-03-16  6:30               ` Nath, Arindam
2011-03-16 10:44                 ` zhangfei gao
2011-03-16 10:48                   ` Nath, Arindam
2011-03-16 21:39   ` Philip Rakity
2011-03-17  4:18     ` Nath, Arindam
2011-03-24 10:52   ` zhangfei gao
2011-03-24 10:59     ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 03/12] mmc: sd: query function modes for uhs cards Arindam Nath
2011-03-09 14:08   ` subhashj
2011-03-09 14:31     ` Nath, Arindam
2011-03-09 18:04       ` subhashj
2011-03-09 18:16         ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 04/12] mmc: sd: add support for driver type selection Arindam Nath
2011-03-09  5:33   ` Philip Rakity
2011-03-09  8:11     ` Nath, Arindam
2011-03-10  6:57   ` subhashj
2011-03-10  8:31     ` Nath, Arindam
2011-03-10 10:28       ` subhashj
2011-03-10 10:44         ` Nath, Arindam
2011-03-10 11:25           ` subhashj
2011-03-10 11:34             ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 05/12] mmc: sdhci: reset sdclk before setting high speed enable Arindam Nath
2011-03-05  4:57   ` Philip Rakity
2011-03-05  5:07     ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 06/12] mmc: sd: add support for uhs bus speed mode selection Arindam Nath
2011-03-10  8:00   ` subhashj
2011-03-10  8:36     ` Nath, Arindam
2011-03-10 10:07       ` subhashj
2011-03-10 10:15         ` Nath, Arindam
2011-03-21  6:42   ` Subhash Jadavani
2011-03-23  6:04     ` Nath, Arindam
2011-03-23  6:14       ` Subhash Jadavani
2011-03-23  6:17         ` Nath, Arindam
2011-03-23  6:26           ` Subhash Jadavani
2011-03-23  6:35             ` Nath, Arindam
2011-03-23  7:23               ` Subhash Jadavani
2011-03-23 14:02                 ` Nath, Arindam
2011-03-24  7:25                   ` Subhash Jadavani
2011-03-24  8:42                     ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 07/12] mmc: sd: set current limit for uhs cards Arindam Nath
2011-03-09 21:41   ` Philip Rakity
2011-03-10  3:12     ` Nath, Arindam
2011-03-10  8:16   ` subhashj
2011-03-10  8:43     ` Nath, Arindam
2011-03-10  9:45       ` subhashj [this message]
2011-03-16 14:26   ` Philip Rakity
2011-03-16 14:32     ` Nath, Arindam
2011-03-16 14:51       ` Philip Rakity
2011-03-16 15:00         ` Nath, Arindam
2011-03-16 15:18           ` Philip Rakity
2011-03-16 15:24             ` Nath, Arindam
2011-03-16 15:31               ` Philip Rakity
2011-03-16 15:33                 ` Nath, Arindam
2011-03-16 15:34                   ` Philip Rakity
2011-03-21  7:43   ` Subhash Jadavani
2011-03-21  7:54     ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 08/12] mmc: sd: report correct speed and capacity of " Arindam Nath
2011-03-10 11:48   ` subhashj
2011-03-10 13:28     ` Nath, Arindam
2011-03-10 13:41       ` subhashj
2011-03-04 11:32 ` [PATCH v2 09/12] mmc: sd: add support for tuning during uhs initialization Arindam Nath
2011-03-04 18:27   ` Philip Rakity
2011-03-04 18:48     ` Nath, Arindam
2011-03-04 18:34   ` Philip Rakity
2011-03-04 18:54     ` Nath, Arindam
2011-03-15 10:32   ` zhangfei gao
2011-03-15 10:43     ` Nath, Arindam
2011-03-16  2:51       ` zhangfei gao
2011-03-16  6:20         ` Nath, Arindam
2011-03-16 10:18           ` zhangfei gao
2011-03-21  9:43   ` Subhash Jadavani
2011-03-21  9:50     ` Nath, Arindam
2011-03-23  6:58       ` Subhash Jadavani
2011-03-21 10:58   ` Subhash Jadavani
2011-03-21 11:07     ` Nath, Arindam
2011-03-23  6:08       ` Subhash Jadavani
2011-03-23  6:14         ` Nath, Arindam
2011-03-23  6:19           ` Subhash Jadavani
2011-03-23  6:22             ` Nath, Arindam
2011-03-23  6:34               ` Subhash Jadavani
2011-03-23  6:41                 ` Nath, Arindam
2011-03-23  6:45                   ` Subhash Jadavani
2011-03-23  6:48                     ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 10/12] mmc: sdhci: enable preset value after " Arindam Nath
2011-03-10 13:23   ` subhashj
2011-03-10 13:30     ` Nath, Arindam
2011-03-10 13:45       ` subhashj
2011-03-10 13:49         ` Nath, Arindam
2011-03-10 14:03           ` subhashj
2011-03-10 14:07             ` Nath, Arindam
2011-03-10 14:12               ` subhashj
2011-03-10 14:15                 ` Nath, Arindam
2011-03-10 14:19                   ` subhashj
2011-03-10 14:24                     ` Nath, Arindam
2011-03-04 11:32 ` [PATCH v2 11/12] mmc: sdhci: add support for programmable clock mode Arindam Nath
2011-03-04 11:32 ` [PATCH v2 12/12] mmc: sdhci: add support for retuning mode 1 Arindam Nath
2011-03-10 13:57   ` subhashj
2011-03-10 14:00     ` Nath, Arindam
2011-03-04 15:16 ` [PATCH v2 00/12] add support for host controller v3.00 Chris Ball
2011-03-04 15:55   ` Nath, Arindam
2011-03-11 13:13 ` subhashj
2011-03-11 15:29   ` Nath, Arindam
2011-03-11 16:06     ` Chris Ball

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='000c01cbdf07$f154c220$d3fe4660$@org' \
    --to=subhashj@codeaurora.org \
    --cc=Aaron.Lu@amd.com \
    --cc=Arindam.Nath@amd.com \
    --cc=Henry.Su@amd.com \
    --cc=anath.amd@gmail.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=prakity@marvell.com \
    --cc=zhangfei.gao@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).