From patchwork Fri Sep 21 10:08:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 1490951 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A76E8DF28C for ; Fri, 21 Sep 2012 10:08:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933034Ab2IUKIa (ORCPT ); Fri, 21 Sep 2012 06:08:30 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:56065 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933013Ab2IUKIa (ORCPT ); Fri, 21 Sep 2012 06:08:30 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MAP002CF2U0QPB0@mailout3.samsung.com> for linux-mmc@vger.kernel.org; Fri, 21 Sep 2012 19:08:28 +0900 (KST) X-AuditID: cbfee61a-b7f726d000000ec7-b8-505c3c9c0325 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 43.CA.03783.C9C3C505; Fri, 21 Sep 2012 19:08:28 +0900 (KST) Received: from [10.90.51.55] by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MAP0022G2U3C670@mmp2.samsung.com> for linux-mmc@vger.kernel.org; Fri, 21 Sep 2012 19:08:28 +0900 (KST) Message-id: <505C3C85.3070505@samsung.com> Date: Fri, 21 Sep 2012 19:08:05 +0900 From: Jaehoon Chung User-Agent: Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-version: 1.0 To: linux-mmc Cc: Chris Ball , Kyungmin Park , "svenkatr@ti.com" , Maya Erez 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+t9jQd05NjEBBosuaFgc+d/P6MDo8XmT XABjFJdNSmpOZllqkb5dAlfGwVdrWAomSlVsfLWKvYHxuUgXIyeHhICJRHPPB1YIW0ziwr31 bF2MXBxCAtMZJc6+7mQGSQgJtDNJNMzLBLF5BbQkDja1soPYLAKqEq+fPWUBsdkEdCS2fzvO BGKLCoRILJn7lR2iXlDix+R7YDUiApoSndtXgi1gFpjMKPHo8ifGLkYODmEBW4kVjaEgNcxA c/a3TmODsOUlNq95yzyBkW8WklGzkJTNQlK2gJF5FaNoakFyQXFSeq6hXnFibnFpXrpecn7u JkZwQD2T2sG4ssHiEKMAB6MSD++Kb9EBQqyJZcWVuYcYJTiYlUR4H8UAhXhTEiurUovy44tK c1KLDzFKc7AoifMKfwoMEBJITyxJzU5NLUgtgskycXBKNTDaFFw2eRV1kqWrx6G1saC1tqA0 OzQ0P/eurvaOT99OHNc92H37WsSatV+EeIonXRRLPLbiVe+c+NMrpVIlmO8W/ti6Z33Dx0vt 7SIWM01ZZ6w04whSXnDH+wI/U6Dzy3aTWnfbo/n3vVM8/SIuJdv25prtPGv1fq3oKVcJzrAf KtdmerK//aHEUpyRaKjFXFScCAAByXPqJAIAAA== 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(-) -- 1.7.4.1 -- -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);