From patchwork Mon Nov 17 12:52:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avi Shchislowski X-Patchwork-Id: 5318661 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7416A9F2ED for ; Mon, 17 Nov 2014 12:52:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7FF7C2015E for ; Mon, 17 Nov 2014 12:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 726442015A for ; Mon, 17 Nov 2014 12:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752567AbaKQMwa (ORCPT ); Mon, 17 Nov 2014 07:52:30 -0500 Received: from mail-bl2on0090.outbound.protection.outlook.com ([65.55.169.90]:26016 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752556AbaKQMw2 (ORCPT ); Mon, 17 Nov 2014 07:52:28 -0500 Received: from BLUPR02CA032.namprd02.prod.outlook.com (25.160.23.150) by BN1PR02MB118.namprd02.prod.outlook.com (10.255.204.19) with Microsoft SMTP Server (TLS) id 15.1.16.15; Mon, 17 Nov 2014 12:52:22 +0000 Received: from BL2FFO11FD053.protection.gbl (2a01:111:f400:7c09::183) by BLUPR02CA032.outlook.office365.com (2a01:111:e400:8ad::22) with Microsoft SMTP Server (TLS) id 15.1.16.15 via Frontend Transport; Mon, 17 Nov 2014 12:52:22 +0000 Received: from milsmgep12.sandisk.com (63.163.107.173) by BL2FFO11FD053.mail.protection.outlook.com (10.173.161.181) with Microsoft SMTP Server id 15.1.6.13 via Frontend Transport; Mon, 17 Nov 2014 12:52:21 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com ( [172.22.12.162]) by milsmgep12.sandisk.com (Symantec Messaging Gateway) with SMTP id 9A.43.11368.58FE9645; Mon, 17 Nov 2014 04:52:21 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.195.1; Mon, 17 Nov 2014 04:52:20 -0800 X-AuditID: ac160a69-f79066d000002c68-26-5469ef8551c9 Received: from KFAC110926.sdcorp.global.sandisk.com ( [10.177.8.100]) by milsmgip11.sandisk.com (Symantec Messaging Gateway) with SMTP id 26.54.10458.38FE9645; Mon, 17 Nov 2014 04:52:20 -0800 (PST) From: Avi Shchislowski To: CC: , , Avi Shchislowski , Alex Lemberg Subject: =?UTF-8?q?=5BPATCH=201/1=5D=20Production=20State=20Awareness=20support=20in=20host=20side?= Date: Mon, 17 Nov 2014 14:52:06 +0200 Message-ID: <1416228726-8514-1-git-send-email-avi.shchislowski@sandisk.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGLMWRmVeSWpSXmKPExsWyRoxnkW7r+8wQg5dfBS0mXN7OaHHkfz+j xfG14Q7MHneu7WHzuPFqIZPH501yAcxRXDYpqTmZZalF+nYJXBn9696xFiyRr5j16gFTA+Mf iS5GTg4JAROJ+be2MELYYhIX7q1n62Lk4hASOMEosXbZVnYIZwejxJVZm9lgOv5s3wRmCwmc ZJS48VYKxGYTMJWY2baUqYuRg0NEQEai8YAxSC+zQD+jRFdvJzNIjbBAisTDP4dYQWwWAVWJ jQ1bwWxeAW+JqwvvMIL0SggoSMyZZAMRFpQ4OfMJC4jNLKAp0br9NzuELS/RvHU2M8h8CYFV rBIzXzxhhLhHU+LkwuVsExiFZiHpn4WkfxaS/gWMzKsYxXIzc4pz01MLDI30ihPzUjKLs/WS 83M3MYJDmytzB+OKSeaHGAU4GJV4eA2uZoYIsSaWFVfmHmKU4GBWEuGNuQgU4k1JrKxKLcqP LyrNSS0+xCjNwaIkzis4PctfSCA9sSQ1OzW1ILUIJsvEwSnVwGh0/tUMtuMdRfP4s5Xvvt3D G/To9oTjlrNvpzz5qbhDfrPk/HUGm5yflLaEMTUcuMe/IySKsUj1kcHWL5c3XpuStnZercCR tfuPPDF4vKS20OpV3SsLN58XdsWdk46GJR+wEvtiZPFyo10re/48fl9fy0X5Yi+NPjzoZJi0 zynnfMDW+383rC5WYinOSDTUYi4qTgQAxZjo0GkCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJJMWRmVeSWpSXmKPExsXCtZEjRbflfWaIwdYJNhY3H/xgs9i5dx2T xYTL2xktjvzvZ7Q4vjbcgdXjzrU9bB43Xi1k8pi25jyTx+dNcgEsUVw2Kak5mWWpRfp2CVwZ /evesRYska+Y9eoBUwPjH4kuRk4OCQETiT/bN7FB2GISF+6tB7K5OIQEjjNKvFpxnwUkwSZg KjGzbSkTiC0iICXR87SZGaSIWaCfUWL+mrmMIAlhgRSJh38OsYLYLAKqEhsbtgLZHBy8At4S l+bxgZgSAgoScybZgFTwCghKnJz5hAUkzCygLrF+nhBImFlAXqJ562zmCYy8s5BUzUKomoWk agEj8ypGsdzMnOLc9MwCQ0O94sS8lMzibL3k/NxNjODA44zcwfh0ovkhRiYOTqkGxqaT70Nv x6QX+WU25+g2cea7iv8xWXQuaeoVn/DTn9yvO59IefP7pujekI4skR/5cpPXNm6bJrLlW0Kk 4BnmPWu3JU41lhf4x7v8yP2WB10TrjfNyG9bkVqqqKb/VWxP5ZvGIJNDslvjzr1XnHeL98Lt OlOXFcFZy/76zel8MuvQtUW3jr25sVyJpTgj0VCLuag4EQDHzEal7AEAAA== X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:63.163.107.173; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(438002)(199003)(189002)(68736004)(19580405001)(19580395003)(69596002)(36756003)(87286001)(50466002)(84676001)(89996001)(50986999)(31966008)(33646002)(21056001)(110136001)(44976005)(87936001)(88136002)(23676002)(104166001)(93916002)(86362001)(4396001)(50226001)(46102003)(92566001)(92726001)(20776003)(47776003)(107046002)(2351001)(64706001)(106466001)(102836001)(120916001)(99396003)(81156004)(97736003)(229853001)(62966003)(77156002)(95666004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR02MB118; H:milsmgep12.sandisk.com; FPR:; MLV:sfv; PTR:ErrorRetry; A:1; MX:1; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB118; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB118; X-Forefront-PRVS: 03982FDC1D Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.173 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.173; helo=milsmgep12.sandisk.com; Authentication-Results: spf=pass (sender IP is 63.163.107.173) smtp.mailfrom=Avi.Shchislowski@sandisk.com; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB118; X-OriginatorOrg: sandisk.com Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adding support for PSA (Production State Awareness) feature for all eMMC devices with revision >=5.0 In this patch the eMMC driver will check if device was completed its Production State mode, and will switch it to Normal (field) mode. Switching to normal mode signal the device to complete its work in production mode and start working in regular performance mode. Signed-off-by: Alex Lemberg diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 02ad792..2d59722 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -605,6 +605,20 @@ static int mmc_read_ext_csd(struct mmc_card *card) mmc_hostname(card->host)); err = 0; } + /* eMMC v5.0 or later */ + if (card->ext_csd.rev > 6) { + card->ext_csd.psa = + ext_csd[EXT_CSD_PSA]; + if (ext_csd[EXT_CSD_PSA_TIMEOUT] > 0) { + card->ext_csd.psa_timeout = + 100 * + (1 << ext_csd[EXT_CSD_PSA_TIMEOUT]); + } else { + card->ext_csd.psa_timeout = 0; + pr_warn("%s: EXT_CSD PSA Timeout is zero\n", + mmc_hostname(card->host)); + } + } return err; } @@ -1330,6 +1344,25 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, if (card->csd.dsr_imp && host->dsr_req) mmc_set_dsr(host); + /* + * eMMC v5.0 or later + * and Production State Awareness state is EXT_CSD_PSA_POST_SOLDERING_WRITES + * The host should set the device to NORMAL mode + */ + if ((card->ext_csd.rev > 6) + && (card->ext_csd.psa == EXT_CSD_PSA_POST_SOLDERING_WRITES)) { + unsigned int timeout; + /*Zero value in PSA Timeout – PSA is not defined*/ + if (card->ext_csd.psa_timeout != 0) { + timeout = DIV_ROUND_UP(card->ext_csd.psa_timeout, 1000); + card->ext_csd.psa = EXT_CSD_PSA_NORMAL; + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_PSA, card->ext_csd.psa, timeout); + if (err && err != -EBADMSG) + goto free_card; + } + } + /* * Select card, as all following commands rely on that. */ diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 4d69c00..09ac3b0 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -60,9 +60,11 @@ struct mmc_ext_csd { u8 packed_event_en; unsigned int part_time; /* Units: ms */ unsigned int sa_timeout; /* Units: 100ns */ + unsigned int psa_timeout; /* Units: 100us */ unsigned int generic_cmd6_time; /* Units: 10ms */ unsigned int power_off_longtime; /* Units: ms */ u8 power_off_notification; /* state */ + u8 psa; /* production state awareness */ unsigned int hs_max_dtr; unsigned int hs200_max_dtr; #define MMC_HIGH_26_MAX_DTR 26000000 diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 49ad7a9..eb170ff 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -285,6 +285,9 @@ struct _mmc_csd { #define EXT_CSD_EXP_EVENTS_STATUS 54 /* RO, 2 bytes */ #define EXT_CSD_EXP_EVENTS_CTRL 56 /* R/W, 2 bytes */ #define EXT_CSD_DATA_SECTOR_SIZE 61 /* R */ +#define EXT_CSD_QRDY_SUPPORT 96 /* RO */ +#define EXT_CSD_CMDQ_QRDY_FUNCTION 97 /* R/W */ +#define EXT_CSD_PSA 133 /* R/W/E */ #define EXT_CSD_GP_SIZE_MULT 143 /* R/W */ #define EXT_CSD_PARTITION_SETTING_COMPLETED 155 /* R/W */ #define EXT_CSD_PARTITION_ATTRIBUTE 156 /* R/W */ @@ -315,6 +318,7 @@ struct _mmc_csd { #define EXT_CSD_PWR_CL_26_360 203 /* RO */ #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ #define EXT_CSD_S_A_TIMEOUT 217 /* RO */ +#define EXT_CSD_PSA_TIMEOUT 218 /* RO */ #define EXT_CSD_REL_WR_SEC_C 222 /* RO */ #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ #define EXT_CSD_ERASE_TIMEOUT_MULT 223 /* RO */ @@ -433,6 +437,13 @@ struct _mmc_csd { #define EXT_CSD_BKOPS_LEVEL_2 0x2 /* + * PRODUCTION STATE AWARENESS fields + */ + +#define EXT_CSD_PSA_NORMAL 0x00 +#define EXT_CSD_PSA_POST_SOLDERING_WRITES 0x02 + +/* * MMC_SWITCH access modes */