From patchwork Tue Nov 5 05:50:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 11226941 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1D9513BD for ; Tue, 5 Nov 2019 05:51:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CE61520818 for ; Tue, 5 Nov 2019 05:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727132AbfKEFvB (ORCPT ); Tue, 5 Nov 2019 00:51:01 -0500 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:50743 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726820AbfKEFvB (ORCPT ); Tue, 5 Nov 2019 00:51:01 -0500 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id CFDB93C0588; Tue, 5 Nov 2019 06:50:56 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SGKHH59H7g6m; Tue, 5 Nov 2019 06:50:51 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 2F7D23C0585; Tue, 5 Nov 2019 06:50:51 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.468.0; Tue, 5 Nov 2019 06:50:50 +0100 From: Eugeniu Rosca To: Ulf Hansson , Adrian Hunter , Wolfram Sang , CC: Linus Walleij , Mathieu Malaterre , Pavel Machek , , , Eugeniu Rosca , Eugeniu Rosca Subject: [PATCH 1/3] dt-bindings: mmc: Add 'fixed-emmc-driver-type-hs{200,400}' Date: Tue, 5 Nov 2019 06:50:13 +0100 Message-ID: <20191105055015.23656-1-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org A certain eMMC manufacturer provided below requirement: ---snip--- Use "drive strength" value of 4 or 1 for HS400 or 0 for HS200. ---snip--- The existing "fixed-emmc-driver-type" property [1] is the closest one to implement the above, but it falls short due to being unable to define two values to differentiate between HS200 and HS400 (both modes may be supported by the same non-removable MMC device). To allow users to set a preferred HS200/HS400 "drive strength", provide two more bindings inspired from [1]: - fixed-emmc-driver-type-hs200 - fixed-emmc-driver-type-hs400 For more details about eMMC I/O driver strength types, see Jedec spec. Keep "fixed-emmc-driver-type" in place for backward compatibility. [1] commit 6186d06c519e21 ("mmc: parse new binding for eMMC fixed driver type") Cc: Wolfram Sang Signed-off-by: Eugeniu Rosca --- .../bindings/mmc/mmc-controller.yaml | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml index 080754e0ef35..1c64b14f91a3 100644 --- a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml +++ b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml @@ -248,6 +248,24 @@ properties: the driver type as specified in the eMMC specification (table 206 in spec version 5.1) + fixed-emmc-driver-type-hs200: + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - minimum: 0 + - maximum: 4 + description: + Same as "fixed-emmc-driver-type", but specific to HS200 mode. + If defined, overrides "fixed-emmc-driver-type" in HS200 mode. + + fixed-emmc-driver-type-hs400: + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - minimum: 0 + - maximum: 4 + description: + Same as "fixed-emmc-driver-type", but specific to HS400 mode. + If defined, overrides "fixed-emmc-driver-type" in HS400 mode. + post-power-on-delay-ms: allOf: - $ref: /schemas/types.yaml#/definitions/uint32 @@ -336,6 +354,8 @@ patternProperties: dependencies: cd-debounce-delay-ms: [ cd-gpios ] fixed-emmc-driver-type: [ non-removable ] + fixed-emmc-driver-type-hs200: [ non-removable ] + fixed-emmc-driver-type-hs400: [ non-removable ] examples: - | From patchwork Tue Nov 5 05:50:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 11226945 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52DD31747 for ; Tue, 5 Nov 2019 05:51:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BCED21929 for ; Tue, 5 Nov 2019 05:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730454AbfKEFvR (ORCPT ); Tue, 5 Nov 2019 00:51:17 -0500 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:50753 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730346AbfKEFvR (ORCPT ); Tue, 5 Nov 2019 00:51:17 -0500 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id 2BF163C0591; Tue, 5 Nov 2019 06:51:15 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vcDgZBvjmmhC; Tue, 5 Nov 2019 06:51:09 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id BD2323C0585; Tue, 5 Nov 2019 06:51:09 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.468.0; Tue, 5 Nov 2019 06:51:09 +0100 From: Eugeniu Rosca To: Ulf Hansson , Adrian Hunter , Wolfram Sang , CC: Linus Walleij , Mathieu Malaterre , Pavel Machek , , , Eugeniu Rosca , Eugeniu Rosca Subject: [PATCH 2/3] mmc: host: Compress 'fixed-emmc-driver-type' handling Date: Tue, 5 Nov 2019 06:50:14 +0100 Message-ID: <20191105055015.23656-2-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105055015.23656-1-erosca@de.adit-jv.com> References: <20191105055015.23656-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Prepare for reading two additional OF properties (inspired from "fixed-emmc-driver-type"): - fixed-emmc-driver-type-hs200 - fixed-emmc-driver-type-hs400 The parsing mechanism is common too all three, thus factored out. The only functional change is a tiny update in the error message. Cc: Wolfram Sang Signed-off-by: Eugeniu Rosca --- drivers/mmc/core/host.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 105b7a7c0251..54abfdfc69ba 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -161,6 +161,20 @@ static void mmc_retune_timer(struct timer_list *t) mmc_retune_needed(host); } +static void mmc_of_read_drv_type(struct mmc_host *host, char *prop, u32 *val) +{ + struct device *dev = host->parent; + u32 drv_type; + + if (device_property_read_u32(dev, prop, &drv_type)) + return; + + if (host->caps & MMC_CAP_NONREMOVABLE) + *val = drv_type; + else + dev_err(dev, "can't use %s, media is removable\n", prop); +} + /** * mmc_of_parse() - parse host's device-tree node * @host: host whose node should be parsed. @@ -173,7 +187,7 @@ static void mmc_retune_timer(struct timer_list *t) int mmc_of_parse(struct mmc_host *host) { struct device *dev = host->parent; - u32 bus_width, drv_type, cd_debounce_delay_ms; + u32 bus_width, cd_debounce_delay_ms; int ret; bool cd_cap_invert, cd_gpio_invert = false; bool ro_cap_invert, ro_gpio_invert = false; @@ -321,13 +335,7 @@ int mmc_of_parse(struct mmc_host *host) host->caps2 |= MMC_CAP2_NO_MMC; /* Must be after "non-removable" check */ - if (device_property_read_u32(dev, "fixed-emmc-driver-type", &drv_type) == 0) { - if (host->caps & MMC_CAP_NONREMOVABLE) - host->fixed_drv_type = drv_type; - else - dev_err(host->parent, - "can't use fixed driver type, media is removable\n"); - } + mmc_of_read_drv_type(host, "fixed-emmc-driver-type", &host->fixed_drv_type); host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr); if (host->dsr_req && (host->dsr & ~0xffff)) { From patchwork Tue Nov 5 05:50:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniu Rosca X-Patchwork-Id: 11226947 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A17D1390 for ; Tue, 5 Nov 2019 05:51:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 013A020869 for ; Tue, 5 Nov 2019 05:51:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730499AbfKEFvq (ORCPT ); Tue, 5 Nov 2019 00:51:46 -0500 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:50763 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727113AbfKEFvq (ORCPT ); Tue, 5 Nov 2019 00:51:46 -0500 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id EC4323C0594; Tue, 5 Nov 2019 06:51:42 +0100 (CET) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NIvBb3uK3IUk; Tue, 5 Nov 2019 06:51:37 +0100 (CET) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id 807E13C0585; Tue, 5 Nov 2019 06:51:37 +0100 (CET) Received: from vmlxhi-102.adit-jv.com (10.72.93.184) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.468.0; Tue, 5 Nov 2019 06:51:36 +0100 From: Eugeniu Rosca To: Ulf Hansson , Adrian Hunter , Wolfram Sang , CC: Linus Walleij , Mathieu Malaterre , Pavel Machek , , , Eugeniu Rosca , Eugeniu Rosca Subject: [PATCH 3/3] mmc: core: Add 'fixed-emmc-driver-type-hs{200,400}' Date: Tue, 5 Nov 2019 06:50:15 +0100 Message-ID: <20191105055015.23656-3-erosca@de.adit-jv.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191105055015.23656-1-erosca@de.adit-jv.com> References: <20191105055015.23656-1-erosca@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.93.184] Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Add support for two more DT bindings, which stem from the need to implement below real-life requirement shared by eMMC vendor: ---snip--- Use "drive strength" value of 4 or 1 for HS400 or 0 for HS200. ---snip--- Inspire from [Y] and [Z] during implementation and testing (H3ULCB-KF). Below decision matrix is intended as function of user's input: [0] [2] [4] [0] hs200:[0] hs200:[2] hs200:[0] hs400:[0] hs400:[0] hs400:[4] [2] hs200:[2] hs200:[2] hs200:[2] hs400:[0] hs400:[R] hs400:[4] [4] hs200:[0] hs200:[2] hs200:[R] hs400:[4] hs400:[4] hs400:[4] [0] "fixed-emmc-driver-type" [2] "fixed-emmc-driver-type-hs200" [4] "fixed-emmc-driver-type-hs400" [R] RAW/ECSD drive strength as implemented in commit cc4f414c885cd0 ("mmc: mmc: Add driver strength selection") [Y] commit 6186d06c519e21 ("mmc: parse new binding for eMMC fixed driver type") [Z] https://www.elinux.org/Tests:eMMC-fixed-drive-strength Cc: Wolfram Sang Signed-off-by: Eugeniu Rosca --- drivers/mmc/core/host.c | 4 ++++ drivers/mmc/core/mmc.c | 19 ++++++++++++++++--- include/linux/mmc/host.h | 2 ++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 54abfdfc69ba..2a3d3b542e0d 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -336,6 +336,8 @@ int mmc_of_parse(struct mmc_host *host) /* Must be after "non-removable" check */ mmc_of_read_drv_type(host, "fixed-emmc-driver-type", &host->fixed_drv_type); + mmc_of_read_drv_type(host, "fixed-emmc-driver-type-hs200", &host->fixed_drv_type_hs200); + mmc_of_read_drv_type(host, "fixed-emmc-driver-type-hs400", &host->fixed_drv_type_hs400); host->dsr_req = !device_property_read_u32(dev, "dsr", &host->dsr); if (host->dsr_req && (host->dsr & ~0xffff)) { @@ -455,6 +457,8 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) host->max_blk_count = PAGE_SIZE / 512; host->fixed_drv_type = -EINVAL; + host->fixed_drv_type_hs200 = -EINVAL; + host->fixed_drv_type_hs400 = -EINVAL; host->ios.power_delay_ms = 10; return host; diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index c8804895595f..89e6fb9aedeb 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c @@ -62,6 +62,8 @@ static const unsigned int taac_mant[] = { __res & __mask; \ }) +static void mmc_select_driver_type(struct mmc_card *card, int timing); + /* * Given the decoded CSD structure, decode the raw CID to our CID structure. */ @@ -1192,6 +1194,8 @@ static int mmc_select_hs400(struct mmc_card *card) return err; } + mmc_select_driver_type(card, EXT_CSD_TIMING_HS400); + /* Switch card to HS400 */ val = EXT_CSD_TIMING_HS400 | card->drive_strength << EXT_CSD_DRV_STR_SHIFT; @@ -1270,6 +1274,8 @@ int mmc_hs400_to_hs200(struct mmc_card *card) if (err) goto out_err; + mmc_select_driver_type(card, EXT_CSD_TIMING_HS200); + /* Switch HS to HS200 */ val = EXT_CSD_TIMING_HS200 | card->drive_strength << EXT_CSD_DRV_STR_SHIFT; @@ -1304,10 +1310,17 @@ int mmc_hs400_to_hs200(struct mmc_card *card) return err; } -static void mmc_select_driver_type(struct mmc_card *card) +static void mmc_select_driver_type(struct mmc_card *card, int timing) { int card_drv_type, drive_strength, drv_type = 0; int fixed_drv_type = card->host->fixed_drv_type; + int fixed_drv_type_hs200 = card->host->fixed_drv_type_hs200; + int fixed_drv_type_hs400 = card->host->fixed_drv_type_hs400; + + if (fixed_drv_type_hs200 >= 0 && timing == EXT_CSD_TIMING_HS200) + fixed_drv_type = fixed_drv_type_hs200; + else if (fixed_drv_type_hs400 >= 0 && timing == EXT_CSD_TIMING_HS400) + fixed_drv_type = fixed_drv_type_hs400; card_drv_type = card->ext_csd.raw_driver_strength | mmc_driver_type_mask(0); @@ -1385,7 +1398,7 @@ static int mmc_select_hs400es(struct mmc_card *card) goto out_err; } - mmc_select_driver_type(card); + mmc_select_driver_type(card, EXT_CSD_TIMING_HS400); /* Switch card to HS400 */ val = EXT_CSD_TIMING_HS400 | @@ -1445,7 +1458,7 @@ static int mmc_select_hs200(struct mmc_card *card) if (err) return err; - mmc_select_driver_type(card); + mmc_select_driver_type(card, EXT_CSD_TIMING_HS200); /* * Set the bus width(4 or 8) with host's support and diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index ba703384bea0..6960ba98810a 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -371,6 +371,8 @@ struct mmc_host { #define MMC_CAP2_MERGE_CAPABLE (1 << 26) /* Host can merge a segment over the segment size */ int fixed_drv_type; /* fixed driver type for non-removable media */ + int fixed_drv_type_hs200; /* HS200-specific fixed_drv_type */ + int fixed_drv_type_hs400; /* HS400-specific fixed_drv_type */ mmc_pm_flag_t pm_caps; /* supported pm features */