From patchwork Tue Jul 17 02:44: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: 1202811 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 389203FC33 for ; Tue, 17 Jul 2012 02:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754421Ab2GQCoc (ORCPT ); Mon, 16 Jul 2012 22:44:32 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:14058 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754319Ab2GQCoc (ORCPT ); Mon, 16 Jul 2012 22:44:32 -0400 Received: from epcpsbgm1.samsung.com (mailout4.samsung.com [203.254.224.34]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M7A00463A9XTF10@mailout4.samsung.com> for linux-mmc@vger.kernel.org; Tue, 17 Jul 2012 11:44:26 +0900 (KST) X-AuditID: cbfee61a-b7f616d000004b7e-fb-5004d1895a8c Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 1A.8F.19326.981D4005; Tue, 17 Jul 2012 11:44:26 +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 <0M7A00JXIAA1BEC0@mmp1.samsung.com> for linux-mmc@vger.kernel.org; Tue, 17 Jul 2012 11:44:25 +0900 (KST) Message-id: <5004D179.6080706@samsung.com> Date: Tue, 17 Jul 2012 11:44: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 , Konstantin Dorfman , Adrian Hunter , Ulf Hansson , Per FORLIN , Hanumath Prasad , Sebastian Rasmussen , "Dong, Chuanxiao" Subject: [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+NgFprILMWRmVeSWpSXmKPExsVy+t9jAd2uiywBBhcFLY7872d0YPT4vEku gDGKyyYlNSezLLVI3y6BK+PB/V62gneSFd9vz2VvYDwm0sXIySEhYCKxcNMkNghbTOLCvfVA NheHkMAiRon9p7uhnHYmiRU/doJV8QpoSbRu3s4IYrMIqEpcmXaWGcRmE9CR2P7tOBOILSoQ JvHq7k+oekGJH5PvsYDYIgKaEp3bV4INZRb4xSzx8sEa1i5GDg5hAVuJFY2hIDXMQHP2t05j g7DlJTavecs8gZFvFpJRs5CUzUJStoCReRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGcEA9 k9rBuLLB4hCjAAejEg/v/gssAUKsiWXFlbmHGCU4mJVEeEWOAoV4UxIrq1KL8uOLSnNSiw8x SnOwKInzGnt/9RcSSE8sSc1OTS1ILYLJMnFwSjUwGjc/m3L3/eVIZrF1Tu9+8n+3DjqaYxzj J5f00PHCbouXpr9iCxgEIm+23OPvPe7/Z0pNxTyBT4w1j2QFZbNmpXkeY1EUc3f0MXJm3nuh 9YNmTupOXf3ObeJfLzcHfJVg37Bt3Yf2j8o7lopP+79RvkJMULuZ72qyY7wob4L/nDnuvLNa GJKVWIozEg21mIuKEwFZd1gYJAIAAA== 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 Reviewed-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..3a12653 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 enable 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..271d1e4 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, "Didn't support BKOPS from %s\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);