All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jean-Jacques Hiblot <jjhiblot@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/22] mmc: make ext_csd part of struct mmc
Date: Fri, 12 May 2017 20:16:21 +0200	[thread overview]
Message-ID: <1494613000-8156-4-git-send-email-jjhiblot@ti.com> (raw)
In-Reply-To: <1494613000-8156-1-git-send-email-jjhiblot@ti.com>

The ext csd is used for comparison many times. Keep a reference content
of the ext csd in the struct mmc to avoid reading multiple times

Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
---
 drivers/mmc/mmc.c | 22 +++++++++++++++++-----
 include/mmc.h     |  1 +
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 1ae10d1..4bd6a96 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1146,9 +1146,10 @@ static int sd_select_bus_freq_width(struct mmc *mmc)
 	return 0;
 }
 
-static int mmc_select_bus_freq_width(struct mmc *mmc, const u8 *ext_csd)
+static int mmc_select_bus_freq_width(struct mmc *mmc)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(u8, test_csd, MMC_MAX_BLOCK_LEN);
+	const u8 *ext_csd = mmc->ext_csd;
 	/* An array of possible bus widths in order of preference */
 	static const unsigned ext_csd_bits[] = {
 		EXT_CSD_DDR_BUS_WIDTH_8,
@@ -1184,6 +1185,11 @@ static int mmc_select_bus_freq_width(struct mmc *mmc, const u8 *ext_csd)
 	if (mmc->version < MMC_VERSION_4)
 		return 0;
 
+	if (!mmc->ext_csd) {
+		error("No ext_csd found!\n"); /* this should enver happen */
+		return -ENOTSUPP;
+	}
+
 	for (idx = 0; idx < ARRAY_SIZE(ext_csd_bits); idx++) {
 		unsigned int extw = ext_csd_bits[idx];
 		unsigned int caps = ext_to_hostcaps[extw];
@@ -1250,16 +1256,23 @@ static int mmc_select_bus_freq_width(struct mmc *mmc, const u8 *ext_csd)
 	return err;
 }
 
-static int mmc_startup_v4(struct mmc *mmc, u8 *ext_csd)
+static int mmc_startup_v4(struct mmc *mmc)
 {
 	int err, i;
 	u64 capacity;
 	bool has_parts = false;
 	bool part_completed;
+	u8 *ext_csd;
 
 	if (IS_SD(mmc) || (mmc->version < MMC_VERSION_4))
 		return 0;
 
+	ext_csd = malloc_cache_aligned(MMC_MAX_BLOCK_LEN);
+	if (!ext_csd)
+		return -ENOMEM;
+
+	mmc->ext_csd = ext_csd;
+
 	/* check  ext_csd version and capacity */
 	err = mmc_send_ext_csd(mmc, ext_csd);
 	if (err)
@@ -1417,7 +1430,6 @@ static int mmc_startup(struct mmc *mmc)
 	uint mult, freq;
 	u64 cmult, csize;
 	struct mmc_cmd cmd;
-	ALLOC_CACHE_ALIGN_BUFFER(u8, ext_csd, MMC_MAX_BLOCK_LEN);
 	struct blk_desc *bdesc;
 
 #ifdef CONFIG_MMC_SPI_CRC_ON
@@ -1566,7 +1578,7 @@ static int mmc_startup(struct mmc *mmc)
 	mmc->erase_grp_size = 1;
 	mmc->part_config = MMCPART_NOAVAILABLE;
 
-	err = mmc_startup_v4(mmc, ext_csd);
+	err = mmc_startup_v4(mmc);
 	if (err)
 		return err;
 
@@ -1577,7 +1589,7 @@ static int mmc_startup(struct mmc *mmc)
 	if (IS_SD(mmc))
 		err = sd_select_bus_freq_width(mmc);
 	else
-		err = mmc_select_bus_freq_width(mmc, ext_csd);
+		err = mmc_select_bus_freq_width(mmc);
 
 	if (err)
 		return err;
diff --git a/include/mmc.h b/include/mmc.h
index fad12d6..9af6b52 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -454,6 +454,7 @@ struct mmc {
 #ifdef CONFIG_DM_MMC
 	struct udevice *dev;	/* Device for this MMC controller */
 #endif
+	u8 *ext_csd;
 };
 
 struct mmc_hwpart_conf {
-- 
1.9.1

  parent reply	other threads:[~2017-05-12 18:16 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170512181724epcas5p36ff2843856a4d329a0b106cd063f7286@epcas5p3.samsung.com>
2017-05-12 18:16 ` [U-Boot] [PATCH 00/22] mmc: Add support for HS200 and UHS modes Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 01/22] mmc: split mmc_startup() Jean-Jacques Hiblot
2017-05-15  3:27     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 02/22] mmc: move the MMC startup for version above v4.0 in a separate function Jean-Jacques Hiblot
2017-05-15  3:27     ` Simon Glass
2017-05-12 18:16   ` Jean-Jacques Hiblot [this message]
2017-05-15  3:27     ` [U-Boot] [PATCH 03/22] mmc: make ext_csd part of struct mmc Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 04/22] mmc: add a function to read and test the ext csd (mmc >= 4) Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 05/22] mmc: introduces mmc modes Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 10:34       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 06/22] mmc: Add a fonction to dump the mmc capabilities Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 07/22] mmc: use mmc modes to select the correct bus speed Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 08/22] cmd: mmc: display the mode name and current bus speed in the mmc info Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 09/22] mmc: refactor SD startup to make it easier to support new modes Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 10:49       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 10/22] mmc: refactor MMC " Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:25     ` Jaehoon Chung
2017-05-25 14:40       ` Jean-Jacques Hiblot
2017-05-26  1:12         ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 11/22] mmc: make mmc_set_ios() return status Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 12/22] mmc: Enable signal voltage to be selected from mmc core Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 14:18       ` Jean-Jacques Hiblot
2017-05-17  1:38         ` Simon Glass
2017-05-17 10:35       ` Kishon Vijay Abraham I
2017-05-12 18:16   ` [U-Boot] [PATCH 13/22] mmc: Add a new callback function to enable/disable vdd Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 14/22] mmc: add power cyle support in mmc core Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 15:50       ` Jean-Jacques Hiblot
2017-05-25 12:35     ` Jaehoon Chung
2017-05-25 14:50       ` Jean-Jacques Hiblot
2017-06-15 16:13       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 15/22] mmc: add a new mmc parameter to disable mmc clock Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 16/22] mmc: disable the mmc clock during power off Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 17/22] mmc: Add a execute_tuning() callback to the mmc operations Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:37     ` Jaehoon Chung
2017-05-25 14:51       ` Jean-Jacques Hiblot
2017-05-12 18:16   ` [U-Boot] [PATCH 18/22] mmc: add HS200 support in MMC core Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:42     ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 19/22] mmc: Add a new callback function to check if the card is busy Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-12 18:16   ` [U-Boot] [PATCH 20/22] mmc: Add support for UHS modes Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-16 14:20     ` Jean-Jacques Hiblot
2017-05-17  1:59       ` Jaehoon Chung
2017-05-25 12:50     ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 21/22] mmc: Change mode when switching to a boot partition Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-25 12:53     ` Jaehoon Chung
2017-05-12 18:16   ` [U-Boot] [PATCH 22/22] mmc: Retry some MMC cmds on failure Jean-Jacques Hiblot
2017-05-15  3:28     ` Simon Glass
2017-05-15 15:49       ` Jean-Jacques Hiblot
2017-05-17  1:38         ` Simon Glass
2017-05-17 14:47           ` Jean-Jacques Hiblot
2017-05-15  2:33   ` [U-Boot] [PATCH 00/22] mmc: Add support for HS200 and UHS modes Jaehoon Chung
2017-05-18  4:27   ` Jaehoon Chung
2017-05-23 15:24     ` Jean-Jacques Hiblot
2017-05-25  7:41       ` Jaehoon Chung
2017-05-25 14:42         ` Jean-Jacques Hiblot
2017-06-02 16:46         ` Jean-Jacques Hiblot
2017-06-16 10:00         ` Jean-Jacques Hiblot
2017-06-29  9:59           ` Jaehoon Chung
2017-07-26 11:33             ` Kever Yang
2017-07-28 13:05               ` Jaehoon Chung
2017-08-25  8:16                 ` Ziyuan
2017-08-27 20:10                   ` Simon Glass
2017-08-27 20:17                     ` Tom Rini
2017-08-28  5:53                       ` Jaehoon Chung
2017-09-12 21:31                         ` Marek Vasut
2017-08-28  5:45                     ` Ziyuan
2017-09-15 13:20                 ` Jean-Jacques Hiblot
2017-09-16 17:12                   ` Marek Vasut

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=1494613000-8156-4-git-send-email-jjhiblot@ti.com \
    --to=jjhiblot@ti.com \
    --cc=u-boot@lists.denx.de \
    /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.