From patchwork Fri Jul 6 08:44:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 1163751 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 8993B3FE80 for ; Fri, 6 Jul 2012 09:13:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751326Ab2GFJMh (ORCPT ); Fri, 6 Jul 2012 05:12:37 -0400 Received: from eu1sys200aog105.obsmtp.com ([207.126.144.119]:35138 "EHLO eu1sys200aog105.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751141Ab2GFJMg (ORCPT ); Fri, 6 Jul 2012 05:12:36 -0400 Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob105.postini.com ([207.126.147.11]) with SMTP ID DSNKT/asAg+xPd7YZn6+iiYGA8JljiR1Ehb3@postini.com; Fri, 06 Jul 2012 09:12:35 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 359654E; Fri, 6 Jul 2012 08:44:58 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DBABE2AD1; Fri, 6 Jul 2012 08:44:57 +0000 (GMT) Received: from exdcvycastm022.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm022", Issuer "exdcvycastm022" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id B9267A8074; Fri, 6 Jul 2012 10:44:53 +0200 (CEST) Received: from lmenx30v.lme.st.com (10.230.100.153) by smtp.stericsson.com (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Fri, 6 Jul 2012 10:44:57 +0200 From: Loic Pallardy To: , Chris Ball Cc: Linus Walleij , STEricsson_nomadik_linux , Ulf Hansson , Loic Pallardy , Alex Macro Subject: [PATCH v1 1/5] mmc: core: Expose access to RPMB partition Date: Fri, 6 Jul 2012 10:44:00 +0200 Message-ID: <1341564244-6178-2-git-send-email-loic.pallardy@stericsson.com> X-Mailer: git-send-email 1.7.11.1 In-Reply-To: <1341564244-6178-1-git-send-email-loic.pallardy@stericsson.com> References: <1341564244-6178-1-git-send-email-loic.pallardy@stericsson.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 Signed-off-by: Loic Pallardy Acked-by: Linus Walleij Acked-by: Johan Rudholm --- 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)