From patchwork Thu Nov 7 13:53:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaehoon Chung X-Patchwork-Id: 3152811 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 763589F3C4 for ; Thu, 7 Nov 2013 13:53:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4AD53202F9 for ; Thu, 7 Nov 2013 13:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29762204D1 for ; Thu, 7 Nov 2013 13:53:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751483Ab3KGNxg (ORCPT ); Thu, 7 Nov 2013 08:53:36 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:41386 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750996Ab3KGNxf (ORCPT ); Thu, 7 Nov 2013 08:53:35 -0500 Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MVW00FY3BX7SIW0@mailout1.samsung.com> for linux-mmc@vger.kernel.org; Thu, 07 Nov 2013 22:53:34 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.115]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 6D.A9.06969.D5B9B725; Thu, 07 Nov 2013 22:53:33 +0900 (KST) X-AuditID: cbfee68f-b7f836d000001b39-c6-527b9b5d32d3 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 86.2C.09687.D5B9B725; Thu, 07 Nov 2013 22:53:33 +0900 (KST) Received: from [10.252.81.186] by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MVW00LVWBX98T10@mmp1.samsung.com>; Thu, 07 Nov 2013 22:53:33 +0900 (KST) Message-id: <527B9B63.6040206@samsung.com> Date: Thu, 07 Nov 2013 22:53:39 +0900 From: Jaehoon Chung User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-version: 1.0 To: "linux-mmc@vger.kernel.org" Cc: 'Chris Ball' , Ulf Hansson Subject: [RFC PATCH] mmc: core: add the sleep notification feature for eMMC5.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeLIzCtJLcpLzFFi42JZI2JSrBs7uzrI4MUrC4vtrzeyWRz5389o cXxtuAOzx6Eraxk97lzbw+bxeZNcAHMUl01Kak5mWWqRvl0CV8ahWauYCnqUK1ZOd2tgfCHT xcjJISFgItGx7QoLhC0mceHeerYuRi4OIYGljBKTVlxggSm6ufMZO0RiEaPEw9+32UASQgKv GSV+rTQCsXkFtCT+zV7MBGKzCKhKfNx9nx3EZhPQkdj+7ThQnINDVCBE4tuEHIhyQYkfk++x gIRFBKwlmn/LgoSZBdwlru+fxQhiCwv4SVzeuZIdIq4jsb91GhuELS+xec1bZpBzJATa2SUu rXzHArFWQOLb5ENgMyUEZCU2HWCGOF9S4uCKGywTGEVmIdk8C8nYWUjGLmBkXsUomlqQXFCc lF5krFecmFtcmpeul5yfu4kRGAOn/z3r38F494D1IcZkoJUTmaVEk/OBMZRXEm9obGZkYWpi amxkbmlGmrCSOO/9h0lBQgLpiSWp2ampBalF8UWlOanFhxiZODilGhiNt7m5+jF5O/X93t7j eOBLoWbQvFf3Flvace97EWFlOtX34D8X68m2HJUufDrbnDw+KfUavFCo0Op+nMh3Miog9M3F hVvO79l4aj9fdZzhq5iA7sCVKwKOnkt9UrhA4G283OksIf3Lu5vvGobKuB9cZrbvUris06P/ Ss92ayS5/pE/0yVp/EyJpTgj0VCLuag4EQAO96kslwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsVy+t9jAd3Y2dVBBkdXG1hsf72RzeLI/35G i+Nrwx2YPQ5dWcvocefaHjaPz5vkApijGhhtMlITU1KLFFLzkvNTMvPSbZW8g+Od403NDAx1 DS0tzJUU8hJzU22VXHwCdN0yc4AWKSmUJeaUAoUCEouLlfTtME0IDXHTtYBpjND1DQmC6zEy QAMJaxgzDs1axVTQo1yxcrpbA+MLmS5GTg4JAROJmzufsUPYYhIX7q1n62Lk4hASWMQo8fD3 bTaQhJDAa0aJXyuNQGxeAS2Jf7MXM4HYLAKqEh933wdrZhPQkdj+7ThQnINDVCBE4tuEHIhy QYkfk++xgIRFBKwlmn/LgoSZBdwlru+fxQhiCwv4SVzeuZIdIq4jsb91GhuELS+xec1b5gmM fLOQTJqFpGwWkrIFjMyrGEVTC5ILipPScw31ihNzi0vz0vWS83M3MYIj7JnUDsaVDRaHGAU4 GJV4eGfUVAUJsSaWFVfmHmKU4GBWEuHd31cdJMSbklhZlVqUH19UmpNafIgxGejPicxSosn5 wOjPK4k3NDYxM7I0Mje0MDI2J01YSZz3QKt1oJBAemJJanZqakFqEcwWJg5OqQbGoEWzz7/8 Pb/v5euPUbbz65V6ulPa9t9iyl41TeboR+GFOUvb2M2P7Q6Td3bdNeMm57ZDCyfLZX8VcjwS /Y2BsSC9Oio+b8KTXxtm77dN2BPflqe7MeF0sMW8y7rHbe5FSLxSVmVfvnxlg+O8JYf/FCfs 2XBJYI3vii3V7oKnu/KMzu7zNPkkoMRSnJFoqMVcVJwIAKKPGu30AgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Sleep notification is supported since eMMC5.0. Signed-off-by: Jaehoon Chung --- drivers/mmc/core/mmc.c | 30 +++++++++++++++++++++++++++--- include/linux/mmc/card.h | 2 ++ include/linux/mmc/mmc.h | 2 ++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index f631f5a..8c3cce0 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -534,7 +534,7 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) else card->erased_byte = 0x0; - /* eMMC v4.5 or later */ + /* eMMC v4.5 */ if (card->ext_csd.rev >= 6) { card->ext_csd.feature_support |= MMC_DISCARD_FEATURE; @@ -571,6 +571,16 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) card->ext_csd.data_sector_size = 512; } + /* eMMC v5.0 or later */ + if (card->ext_csd.rev >= 7) { + card->ext_csd.raw_sleep_noti_time = + ext_csd[EXT_CSD_SLEEP_NOTIFICATION_TIME]; + if (card->ext_csd.raw_sleep_noti_time > 0 && + card->ext_csd.raw_sleep_noti_time <= 0x17) + card->ext_csd.sleep_notification_time = + (2 << card->ext_csd.raw_sleep_noti_time) + / USEC_PER_MSEC; + } out: return err; } @@ -1390,6 +1400,11 @@ static int mmc_sleep(struct mmc_host *host) return err; } +static int mmc_can_sleep_notify(const struct mmc_card *card) +{ + return card && mmc_card_mmc(card) && card->ext_csd.raw_sleep_noti_time; +} + static int mmc_can_poweroff_notify(const struct mmc_card *card) { return card && @@ -1405,6 +1420,8 @@ static int mmc_poweroff_notify(struct mmc_card *card, unsigned int notify_type) /* Use EXT_CSD_POWER_OFF_SHORT as default notification type. */ if (notify_type == EXT_CSD_POWER_OFF_LONG) timeout = card->ext_csd.power_off_longtime; + else if (notify_type == EXT_CSD_SLEEP_NOTIFICATION) + timeout = card->ext_csd.sleep_notification_time; err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_POWER_OFF_NOTIFICATION, @@ -1495,9 +1512,16 @@ static int _mmc_suspend(struct mmc_host *host, bool is_suspend) if (mmc_can_poweroff_notify(host->card) && ((host->caps2 & MMC_CAP2_FULL_PWR_CYCLE) || !is_suspend)) err = mmc_poweroff_notify(host->card, notify_type); - else if (mmc_can_sleep(host->card)) + else if (mmc_can_sleep(host->card)) { + if (mmc_can_poweroff_notify(host->card) && + mmc_can_sleep_notify(host->card) && is_suspend) { + err = mmc_poweroff_notify(host->card, + EXT_CSD_SLEEP_NOTIFICATION); + if (err) + goto out; + } err = mmc_sleep(host); - else if (!mmc_host_is_spi(host)) + } else if (!mmc_host_is_spi(host)) err = mmc_deselect_cards(host); host->card->state &= ~(MMC_STATE_HIGHSPEED | MMC_STATE_HIGHSPEED_200); diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 176fdf8..ca568a7 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -62,6 +62,7 @@ struct mmc_ext_csd { unsigned int generic_cmd6_time; /* Units: 10ms */ unsigned int power_off_longtime; /* Units: ms */ u8 power_off_notification; /* state */ + unsigned int sleep_notification_time;/* Units: 10us */ unsigned int hs_max_dtr; #define MMC_HIGH_26_MAX_DTR 26000000 #define MMC_HIGH_52_MAX_DTR 52000000 @@ -98,6 +99,7 @@ struct mmc_ext_csd { u8 raw_pwr_cl_26_195; /* 201 */ u8 raw_pwr_cl_52_360; /* 202 */ u8 raw_pwr_cl_26_360; /* 203 */ + u8 raw_sleep_noti_time; /* 216 */ u8 raw_s_a_timeout; /* 217 */ u8 raw_hc_erase_gap_size; /* 221 */ u8 raw_erase_timeout_mult; /* 223 */ diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h index 50bcde3..229ba16 100644 --- a/include/linux/mmc/mmc.h +++ b/include/linux/mmc/mmc.h @@ -307,6 +307,7 @@ struct _mmc_csd { #define EXT_CSD_PWR_CL_52_360 202 /* RO */ #define EXT_CSD_PWR_CL_26_360 203 /* RO */ #define EXT_CSD_SEC_CNT 212 /* RO, 4 bytes */ +#define EXT_CSD_SLEEP_NOTIFICATION_TIME 216 /* Ro */ #define EXT_CSD_S_A_TIMEOUT 217 /* RO */ #define EXT_CSD_REL_WR_SEC_C 222 /* RO */ #define EXT_CSD_HC_WP_GRP_SIZE 221 /* RO */ @@ -385,6 +386,7 @@ struct _mmc_csd { #define EXT_CSD_POWER_ON 1 #define EXT_CSD_POWER_OFF_SHORT 2 #define EXT_CSD_POWER_OFF_LONG 3 +#define EXT_CSD_SLEEP_NOTIFICATION 4 #define EXT_CSD_PWR_CL_8BIT_MASK 0xF0 /* 8 bit PWR CLS */ #define EXT_CSD_PWR_CL_4BIT_MASK 0x0F /* 8 bit PWR CLS */