From patchwork Wed May 9 14:48:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saugata Das X-Patchwork-Id: 8503 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id EA0F723E9A for ; Wed, 9 May 2012 14:48:46 +0000 (UTC) Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by fiordland.canonical.com (Postfix) with ESMTP id E1310A18A39 for ; Wed, 9 May 2012 14:48:46 +0000 (UTC) Received: by wibhm4 with SMTP id hm4so350689wib.17 for ; Wed, 09 May 2012 07:48:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:x-gm-message-state; bh=5YvLtOaSz2d+QSZe58M1LhgnOSCWBFPkPXrJfvWeerI=; b=lO9MP91om10gTL5WNw9ewuaTqGkTCyaxmoteXypuY5S3cqKXm9NZnF/L6rE3HuYD6W 8RAQ/NLvoE9sLBWs5pIFIsVJXDJFt4eClSZdIvNL/2zZWlA/2Isxh8WCfiPOIL3vSZPW 2RF9/Q7WdLrAZgZYgj/XQ9KOft3S8YrII0nN2tIt9Jef7vgcEK+M7ZemCcu4iHciL5x3 F5Wot4MyG1D5PIlXAPlDiWjJ5FDj480KRv5GFHIwlpekoRu2/XcsM1tiacWZ6aGXI8IE AxwVPdAjtQb80Z3lhxmG7+SAJOLGr214cBOYMWx9pc+PidSnDBY1u1lj19IwCAi96/2e 1Arg== Received: by 10.50.51.163 with SMTP id l3mr264536igo.3.1336574924547; Wed, 09 May 2012 07:48:44 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.73.147 with SMTP id q19csp21850ibj; Wed, 9 May 2012 07:48:43 -0700 (PDT) Received: by 10.213.32.138 with SMTP id c10mr658590ebd.112.1336574922603; Wed, 09 May 2012 07:48:42 -0700 (PDT) Received: from eu1sys200aog112.obsmtp.com (eu1sys200aog112.obsmtp.com. [207.126.144.133]) by mx.google.com with SMTP id o8si819512eeb.178.2012.05.09.07.48.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 May 2012 07:48:42 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of saugata.das@stericsson.com) client-ip=207.126.144.133; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.133 is neither permitted nor denied by best guess record for domain of saugata.das@stericsson.com) smtp.mail=saugata.das@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob112.postini.com ([207.126.147.11]) with SMTP ID DSNKT6qDxu1etL8kcXXC4Y02RLNrRgMuGjXc@postini.com; Wed, 09 May 2012 14:48:41 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id C0EBC9E; Wed, 9 May 2012 14:40:14 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 424FDAF2; Wed, 9 May 2012 14:48:35 +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 relay1.stm.gmessaging.net (Postfix) with ESMTPS id C04FB24C2E6; Wed, 9 May 2012 16:48:26 +0200 (CEST) Received: from localhost (10.201.54.119) by exdcvycastm022.EQ1STM.local (10.230.100.30) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 9 May 2012 16:48:33 +0200 From: Saugata Das To: Cc: , Subject: [RFC 2/2] [MMC-4.5] [MMC UTIL] Disable emulation Date: Wed, 9 May 2012 20:18:21 +0530 Message-ID: <1336574901-26579-2-git-send-email-saugata.das@stericsson.com> X-Mailer: git-send-email 1.7.4.3 In-Reply-To: <1336574901-26579-1-git-send-email-saugata.das@stericsson.com> References: <1336574901-26579-1-git-send-email-saugata.das@stericsson.com> MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlf2Q+rZKxKSUuXc/ADPCKFaMx3dK0cmezFikhwgRxNymMHg/jj7/nlYVDLq5WyoQS7NY49 From: Saugata Das In this patch, we add utility to disable emulation mode in the eMMC-4.5. This is done to increase the data sector size to 4KB. Signed-off-by: Saugata Das --- mmc.c | 6 ++++++ mmc.h | 2 ++ mmc_cmds.c | 42 ++++++++++++++++++++++++++++++++++++++++++ mmc_cmds.h | 1 + 4 files changed, 51 insertions(+), 0 deletions(-) diff --git a/mmc.c b/mmc.c index c27fc24..43b95aa 100644 --- a/mmc.c +++ b/mmc.c @@ -65,6 +65,12 @@ static struct Command commands[] = { "Set the eMMC writeprotect status of .", NULL }, + { do_disable_emulation, -1, + "disable emulation", "\n" + "Set the eMMC data sector size to 4KB by disabling emulation .", + NULL + }, + { 0, 0, 0, 0 } }; diff --git a/mmc.h b/mmc.h index 3af36f1..a2050fa 100644 --- a/mmc.h +++ b/mmc.h @@ -35,6 +35,8 @@ #define EXT_CSD_PART_SWITCH_TIME 199 #define EXT_CSD_BOOT_CFG 179 #define EXT_CSD_BOOT_WP 173 +#define EXT_CSD_NATIVE_SECTOR_SIZE 63 /* R */ +#define EXT_CSD_NATIVE_SECTOR 62 /* R/W */ /* * EXT_CSD field definitions diff --git a/mmc_cmds.c b/mmc_cmds.c index 4562cef..2713ccd 100644 --- a/mmc_cmds.c +++ b/mmc_cmds.c @@ -168,6 +168,48 @@ int do_writeprotect_set(int nargs, char **argv) return ret; } + +int do_disable_emulation(int nargs, char **argv) +{ + __u8 ext_csd[512], native_sector_size; + int fd, ret; + char *device; + + CHECK(nargs != 2, "Usage: mmc \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); + } + + native_sector_size = ext_csd[EXT_CSD_NATIVE_SECTOR_SIZE]; + + if (native_sector_size) { + ret = write_extcsd_value(fd, EXT_CSD_NATIVE_SECTOR, 1); + + if (ret) { + fprintf(stderr, "Could not write 0x%02x to " + "EXT_CSD[%d] in %s\n", + 1, EXT_CSD_BOOT_WP, device); + exit(1); + } + } else { + printf("MMC does not support 4KB native sector\n"); + } + + 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 66e9acb..dd107d5 100644 --- a/mmc_cmds.h +++ b/mmc_cmds.h @@ -19,3 +19,4 @@ int do_read_extcsd(int nargs, char **argv); int do_write_extcsd(int nargs, char **argv); int do_writeprotect_get(int nargs, char **argv); int do_writeprotect_set(int nargs, char **argv); +int do_disable_emulation(int nargs, char **argv);