From patchwork Thu Jul 19 15:12:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 1217731 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 B5A403FD4F for ; Thu, 19 Jul 2012 15:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751516Ab2GSPMP (ORCPT ); Thu, 19 Jul 2012 11:12:15 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:32410 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752107Ab2GSPMO (ORCPT ); Thu, 19 Jul 2012 11:12:14 -0400 Received: from epcpsbgm2.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M7E00JCRY89ZUB0@mailout2.samsung.com> for linux-mmc@vger.kernel.org; Fri, 20 Jul 2012 00:12:13 +0900 (KST) X-AuditID: cbfee61b-b7f566d000005c8a-ea-500823cd4024 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 9C.E5.23690.DC328005; Fri, 20 Jul 2012 00:12:13 +0900 (KST) Received: from [10.90.51.55] by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M7E00MKFY8COV30@mmp1.samsung.com> for linux-mmc@vger.kernel.org; Fri, 20 Jul 2012 00:12:13 +0900 (KST) Message-id: <500823C9.1040204@samsung.com> Date: Fri, 20 Jul 2012 00:12:09 +0900 From: Jaehoon Chung User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-version: 1.0 To: linux-mmc Cc: Chris Ball , Kyungmin Park , Maya Erez , "svenkatr@ti.com" , Saugata Das , Adrian Hunter , Ulf Hansson , Per FORLIN , Hanumath Prasad , Sebastian Rasmussen , "Dong, Chuanxiao" Subject: [RESEND PATCH] mmc-util: add the method to enable the bkops Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMLMWRmVeSWpSXmKPExsVy+t9jAd2zyhwBBksPc1gc+d/P6MDo8XmT XABjFJdNSmpOZllqkb5dAldG47QJjAUTpCpOX/3F2MD4VKSLkZNDQsBEYuvX02wQtpjEhXvr gWwuDiGBRYwSh6d/Y4Rw2pkklu39xgRSxSugJfH4w2MWEJtFQFVi0qILYDabgI7E9m/HwWpE BcIkXt39yQZRLyjxY/I9sBoRAU2Jzu0rwTYwC5xgltg8eRNYkbCAi8S56cfYQWxmoEH7W6ex QdjyEpvXvGWewMg3C8msWUjKZiEpW8DIvIpRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMjOKie Se9gXNVgcYhRgINRiYe3Q589QIg1say4MvcQowQHs5II72ZFjgAh3pTEyqrUovz4otKc1OJD jNIcLErivCbeX/2FBNITS1KzU1MLUotgskwcnFINjG7xzzb/0exu42a8Knb4y/n8pqTs5i/c G8RKNRTddzxZ4V3S1e1VOLVW85HGqtAT6vM5tz9NMWw2uui6L1ml/n+6glfC9H0L9C7Hp58K 1Nq5L/tS4JJor1u/9k67v6pbdP6GtZ4nC2YJnPJkdD3zYPmODe5751ou8K4Xsgj1Xxqy0jrA zvZcmBJLcUaioRZzUXEiAMy05mUmAgAA X-TM-AS-MML: No Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org This patch added the method to enable the bkops. In ext_csd register, BKOPS_EN bit is one-time programable. So if you want to use the bkops, use the this command. #mmc bkops enable /dev/mmcblk0 Signed-off-by: Jaehoon Chung Signed-off-by: Kyungmin Park Reviewd-by: Venkatraman S --- mmc.c | 5 +++++ mmc.h | 7 +++++++ mmc_cmds.c | 39 +++++++++++++++++++++++++++++++++++++++ mmc_cmds.h | 1 + 4 files changed, 52 insertions(+), 0 deletions(-) diff --git a/mmc.c b/mmc.c index 379d667..d5ef2bb 100644 --- a/mmc.c +++ b/mmc.c @@ -75,6 +75,11 @@ static struct Command commands[] = { "Enable the boot partition for the .\nTo receive acknowledgment of boot from the card set \nto 1, else set it to 0.", NULL }, + { do_write_bkops_en, -1, + "bkops enable", "\n" + "Enable the eMMC BKOPS feature on .", + NULL + }, { 0, 0, 0, 0 } }; diff --git a/mmc.h b/mmc.h index 0a521a8..3d77b38 100644 --- a/mmc.h +++ b/mmc.h @@ -31,12 +31,14 @@ */ #define EXT_CSD_S_CMD_SET 504 #define EXT_CSD_HPI_FEATURE 503 +#define EXT_CSD_BKOPS_SUPPORT 502 /* RO */ #define EXT_CSD_BOOT_INFO 228 /* R/W */ #define EXT_CSD_PART_SWITCH_TIME 199 #define EXT_CSD_BOOT_CFG 179 #define EXT_CSD_PART_CONFIG 179 #define EXT_CSD_BOOT_WP 173 #define EXT_CSD_WR_REL_PARAM 166 +#define EXT_CSD_BKOPS_EN 163 /* R/W */ #define EXT_CSD_NATIVE_SECTOR_SIZE 63 /* R */ #define EXT_CSD_USE_NATIVE_SECTOR 62 /* R/W */ #define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ @@ -48,6 +50,11 @@ #define EN_REL_WR (1<<2) /* + * BKOPS_EN field definition + */ +#define BKOPS_ENABLE (1<<0) + +/* * EXT_CSD field definitions */ #define EXT_CSD_HPI_SUPP (1<<0) diff --git a/mmc_cmds.c b/mmc_cmds.c index 90619db..4c935e0 100644 --- a/mmc_cmds.c +++ b/mmc_cmds.c @@ -280,6 +280,45 @@ int do_write_boot_en(int nargs, char **argv) return ret; } +int do_write_bkops_en(int nargs, char **argv) +{ + __u8 ext_csd[512], value = 0; + int fd, ret; + char *device; + + CHECK(nargs != 2, "Usage: mmc bkops enable \n", + exit(1)); + + device = argv[1]; + + fd = open(device, O_RDWR); + if (fd < 0) { + perror("open"); + exit(1); + } + + ret = read_extcsd(fd, ext_csd); + if (ret) { + fprintf(stderr, "Could not read EXT_CSD from %s\n", device); + exit(1); + } + + if (!(ext_csd[EXT_CSD_BKOPS_SUPPORT] & 0x1)) { + fprintf(stderr, "%s dosen't support BKOPS\n", device); + exit(1); + } + + ret = write_extcsd_value(fd, EXT_CSD_BKOPS_EN, BKOPS_ENABLE); + if (ret) { + fprintf(stderr, "Could not write 0x%02x to " + "EXT_CSD[%d] in %s\n", + value, EXT_CSD_BKOPS_EN, device); + exit(1); + } + + return ret; +} + int do_read_extcsd(int nargs, char **argv) { __u8 ext_csd[512], ext_csd_rev, reg; diff --git a/mmc_cmds.h b/mmc_cmds.h index 2eb1df5..1dd4324 100644 --- a/mmc_cmds.h +++ b/mmc_cmds.h @@ -21,3 +21,4 @@ int do_writeprotect_get(int nargs, char **argv); int do_writeprotect_set(int nargs, char **argv); int do_disable_512B_emulation(int nargs, char **argv); int do_write_boot_en(int nargs, char **argv); +int do_write_bkops_en(int nargs, char **argv);