All of lore.kernel.org
 help / color / mirror / Atom feed
From: Loic Pallardy <loic.pallardy@stericsson.com>
To: linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	STEricsson_nomadik_linux <STEricsson_nomadik_linux@list.st.com>,
	Ulf Hansson <ulf.hansson@stericcson.com>,
	Loic Pallardy <loic.pallardy@stericsson.com>,
	Alex Macro <alex.macro@stericsson.com>
Subject: [PATCH v1 1/5] mmc: core: Expose access to RPMB partition
Date: Fri, 6 Jul 2012 10:44:00 +0200	[thread overview]
Message-ID: <1341564244-6178-2-git-send-email-loic.pallardy@stericsson.com> (raw)
In-Reply-To: <1341564244-6178-1-git-send-email-loic.pallardy@stericsson.com>

Following JEDEC standard, if the mmc support RPMB partition,
a new interface is created and exposed via /dev/block.
Users will be able to access RPMB partition using standard
mmc IOCTL command.

Signed-off-by: Alex Macro <alex.macro@stericsson.com>
Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com>
---
 drivers/mmc/core/mmc.c   | 11 +++++++++++
 include/linux/mmc/card.h |  2 ++
 include/linux/mmc/mmc.h  |  2 ++
 3 files changed, 15 insertions(+)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 258b203..8a459cb 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -480,6 +480,17 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 
 		card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
 		card->ext_csd.rst_n_function = ext_csd[EXT_CSD_RST_N_FUNCTION];
+
+		/*
+		 * RPMB regions are defined in multiples of 128K.
+		 */
+		card->ext_csd.raw_rpmb_size_mult = ext_csd[EXT_CSD_RPMB_MULT];
+		if (ext_csd[EXT_CSD_RPMB_MULT]) {
+			mmc_part_add(card, ext_csd[EXT_CSD_RPMB_MULT] << 17,
+				EXT_CSD_PART_CONFIG_ACC_RPMB,
+				"rpmb", 0, false,
+				MMC_BLK_DATA_AREA_RPMB);
+		}
 	}
 
 	card->ext_csd.raw_erased_mem_count = ext_csd[EXT_CSD_ERASED_MEM_CONT];
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index d76513b..46a5502 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -81,6 +81,7 @@ struct mmc_ext_csd {
 	unsigned int		boot_ro_lock;		/* ro lock support */
 	bool			boot_ro_lockable;
 	u8			raw_partition_support;	/* 160 */
+	u8			raw_rpmb_size_mult;	/* 168 */
 	u8			raw_erased_mem_count;	/* 181 */
 	u8			raw_ext_csd_structure;	/* 194 */
 	u8			raw_card_type;		/* 196 */
@@ -200,6 +201,7 @@ struct mmc_part {
 #define MMC_BLK_DATA_AREA_MAIN	(1<<0)
 #define MMC_BLK_DATA_AREA_BOOT	(1<<1)
 #define MMC_BLK_DATA_AREA_GP	(1<<2)
+#define MMC_BLK_DATA_AREA_RPMB	(1<<3)
 };
 
 /*
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index d425cab..e73136a 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -282,6 +282,7 @@ struct _mmc_csd {
 #define EXT_CSD_RST_N_FUNCTION		162	/* R/W */
 #define EXT_CSD_SANITIZE_START		165     /* W */
 #define EXT_CSD_WR_REL_PARAM		166	/* RO */
+#define EXT_CSD_RPMB_MULT		168	/* RO */
 #define EXT_CSD_BOOT_WP			173	/* R/W */
 #define EXT_CSD_ERASE_GROUP_DEF		175	/* R/W */
 #define EXT_CSD_PART_CONFIG		179	/* R/W */
@@ -333,6 +334,7 @@ struct _mmc_csd {
 
 #define EXT_CSD_PART_CONFIG_ACC_MASK	(0x7)
 #define EXT_CSD_PART_CONFIG_ACC_BOOT0	(0x1)
+#define EXT_CSD_PART_CONFIG_ACC_RPMB	(0x3)
 #define EXT_CSD_PART_CONFIG_ACC_GP0	(0x4)
 
 #define EXT_CSD_PART_SUPPORT_PART_EN	(0x1)
-- 
1.7.11.1


  reply	other threads:[~2012-07-06  9:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06  8:43 [PATCH v1 0/5] mmc: Add access to RPMB partition Loic Pallardy
2012-07-06  8:44 ` Loic Pallardy [this message]
2012-07-08 19:17   ` [PATCH v1 1/5] mmc: core: Expose " Linus Walleij
2012-07-09 17:42     ` Johan Rudholm
2012-07-06  8:44 ` [PATCH v1 2/5] mmc: card: Do not scan RPMB partitions Loic Pallardy
2012-07-08 19:18   ` Linus Walleij
2012-07-11  0:35   ` Namjae Jeon
2012-07-11 12:36     ` Loic pallardy
2012-07-06  8:44 ` [PATCH v1 3/5] mmc: core: Extend sysfs to ext_csd parameters for RPMB support Loic Pallardy
2012-07-08 19:19   ` Linus Walleij
2012-07-09 17:45     ` Johan Rudholm
2012-07-06  8:44 ` [PATCH v1 4/5] mmc: core: Add mmc_set_blockcount feature Loic Pallardy
2012-07-08 19:20   ` Linus Walleij
2012-07-09 17:48     ` Johan Rudholm
2012-07-06  8:44 ` [PATCH v1 5/5] mmc: card: Add RPMB support in IOCTL interface Loic Pallardy
2012-07-08 19:22   ` Linus Walleij
2012-07-09 17:54     ` Johan Rudholm
2012-07-10  0:37   ` Namjae Jeon
2012-07-10 12:28     ` Loic pallardy
2012-07-11  0:12       ` Namjae Jeon

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=1341564244-6178-2-git-send-email-loic.pallardy@stericsson.com \
    --to=loic.pallardy@stericsson.com \
    --cc=STEricsson_nomadik_linux@list.st.com \
    --cc=alex.macro@stericsson.com \
    --cc=cjb@laptop.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=ulf.hansson@stericcson.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 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.