From patchwork Mon Apr 25 13:59:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying-Chun Liu X-Patchwork-Id: 565707 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2724049map; Mon, 25 Apr 2022 06:59:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwviiqQwSlkpXz7t5KusHK4kWhsSzbnXF77Wpafkic/vX4NtxxNtqUbWNBbBwZGHVk2F6JO X-Received: by 2002:a17:906:dc8d:b0:6f2:b3b1:3dc9 with SMTP id cs13-20020a170906dc8d00b006f2b3b13dc9mr12890380ejc.148.1650895175059; Mon, 25 Apr 2022 06:59:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650895175; cv=none; d=google.com; s=arc-20160816; b=g+8amDgi5bdR4spBerS4HqmIFc/FeC0QrrnYSo4dl5cVXg6lQZ27UcF3K/Jk60ARwA HWqRzrIbwo+ghB5IBSMDxotI3cLRUuf7babN07jowEL2A76XsjsS7YAavlmQZX7MmAwK 36fO+J90yFu0uDFbEBo0OlMcwifx3GE2PSuuZlzusteLVWHMOs4k053CQy9AOqe5N6A+ tcXlDjwvTkCLHvr7xMk5wwwl2fRBxL9SR1QgE5xRfLY40PpgvdE1VKbDR3CTmhLTy6xs 2/vVlxsD5Kv4zaDAUn27ylB0p+DanQFBSZgk0wViFT476GKilt9CUa9eqJTw8j/1aSeJ gnYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bM2/tCYZOySQ2L8dJ5KLoZ8pJWMYda4IsoD+qngUGaE=; b=lk1pJjNtkxIroRBiOGrTpa/WoymzXJ6657dpKNebddxLkpC0eI0ULkVnOMXgMfgib2 PkHg4S2VbI9iiR+64pDKL4R3aCALCmPebvYr/ULDCv30xJOCukmBlFMzHeFN7aWfnt8+ 4NEFfqHTCCZxw0kj0ux017T8+CnTl/5FnVdz2yIWvbqxnvWfR1hsu7hUwjLoOIKL+OY2 GPkqB1sPD6wTN0q1yX17pYbQ/TXWd7coIYQC9uUaAyPZiJK0H1arhYOyoc7Wu4SnM3ra cQxQ+jpNWPDgs+Vo91aCr8L3k0+ffuHJU6OIvn5tM10vzWQgtFLzIvvcIpWDVu5/cGEZ B4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kJnkUytx; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id ho10-20020a1709070e8a00b006f361f9f173si10699859ejc.164.2022.04.25.06.59.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 06:59:35 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=kJnkUytx; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 672D683E33; Mon, 25 Apr 2022 15:59:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kJnkUytx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1881B83D53; Mon, 25 Apr 2022 15:59:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B5D6883BBF for ; Mon, 25 Apr 2022 15:59:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pl1-x635.google.com with SMTP id d15so27215550pll.10 for ; Mon, 25 Apr 2022 06:59:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bM2/tCYZOySQ2L8dJ5KLoZ8pJWMYda4IsoD+qngUGaE=; b=kJnkUytxskK2kTEhjZJX2qx8QM0sWhBlF61YjK9QG7oM6pMkBrcucupiYOQOmW7YPN 26H/YcpV41trk7ZqScRYmNqc08puaqfJ9dZhfszDUqqtvHzKUY1IMbYDFSceOGbi+Z5W SWG59alI0wzl0rqWRdKT94+6Oh/6RYdnZquYqBx2qmPO9UCpilHlri8UvJgLlcCmnDb8 sziEvwmj5mYtpRxg1+YCWKsNPMYpR41vmAwxR3h2L+hgFJ7QNfHYGTXO5E2ZrMVuT2U4 L509xv02DgQ8sRTmFIUGA0Qf8cFVl+CAsEfyAwxzEmzDolY+4yazx1VcDK6lxG0dgOub P2Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bM2/tCYZOySQ2L8dJ5KLoZ8pJWMYda4IsoD+qngUGaE=; b=cLKMd2v9oqPQ6CLh0rca6421uoGf+AZ7PHqoR8Ji6oaD1pguarHSlYU7bl9csVDctm 4ztRCHOlUStp/GkbVEWEfmCq2SWSo9zhRUoGZ/WSf1vIJ9RR/6iCCuLwGGG3HV2BXtJz 7VjO0J72fl28fX5Oh80NvzP6mBZ/ewHrthmhV1TCX5gKb9fKN4iicp55e/EOY5rYfsa5 A6V1ei7Drgn/Klyl322Ow4AeGfSSqPGKzLSOBSUtzvm+lPAPPYcYmOikl7Lnu3R49wX0 UHQYGBc0QhUZQcq2ISYtrNQSRrVe56e+z2rxiVsGMgqOxJ3+3GOXgElH1fzgma+AW0HE KVeA== X-Gm-Message-State: AOAM531LExwNzA4YfObKRNWVWKG733zPJDrVXle+H6HMAd8Jkwq4vwMw rOTdbhuZ3xU7OZ216m4L5q+HetJAJXc= X-Received: by 2002:a17:90a:aa98:b0:1b8:5adb:e35f with SMTP id l24-20020a17090aaa9800b001b85adbe35fmr21175130pjq.192.1650895152765; Mon, 25 Apr 2022 06:59:12 -0700 (PDT) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id q13-20020a17090a2e0d00b001cd4989feebsm15843454pjd.55.2022.04.25.06.59.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 06:59:12 -0700 (PDT) From: Ying-Chun Liu To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Peng Fan , Jaehoon Chung Subject: [PATCH 1/2] drivers: mmc: write protect single boot area Date: Mon, 25 Apr 2022 21:59:02 +0800 Message-Id: <20220425135903.271098-2-grandpaul@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220425135903.271098-1-grandpaul@gmail.com> References: <20220425135903.271098-1-grandpaul@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: "Ying-Chun Liu (PaulLiu)" Add features to write protect single boot area rather than all boot areas. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Peng Fan Cc: Jaehoon Chung --- drivers/mmc/mmc.c | 27 +++++++++++++++++++++++++++ include/mmc.h | 16 ++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index f6ccd837aa..53f931e993 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -860,6 +860,33 @@ int mmc_boot_wp(struct mmc *mmc) return mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_BOOT_WP, 1); } +int mmc_boot_wp_single_partition(struct mmc *mmc, int partition) +{ + u8 value; + int ret; + + value = EXT_CSD_BOOT_WP_B_PWR_WP_EN; + + if (partition == 0) { + value |= EXT_CSD_BOOT_WP_B_SEC_WP_SEL; + ret = mmc_switch(mmc, + EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_BOOT_WP, + value); + } else if (partition == 1) { + value |= EXT_CSD_BOOT_WP_B_SEC_WP_SEL; + value |= EXT_CSD_BOOT_WP_B_PWR_WP_SEC_SEL; + ret = mmc_switch(mmc, + EXT_CSD_CMD_SET_NORMAL, + EXT_CSD_BOOT_WP, + value); + } else { + ret = mmc_boot_wp(mmc); + } + + return ret; +} + #if !CONFIG_IS_ENABLED(MMC_TINY) static int mmc_set_card_speed(struct mmc *mmc, enum bus_mode mode, bool hsdowngrade) diff --git a/include/mmc.h b/include/mmc.h index 6bdcce881d..a1b3c49af4 100644 --- a/include/mmc.h +++ b/include/mmc.h @@ -308,6 +308,10 @@ static inline bool mmc_is_tuning_cmd(uint cmdidx) #define EXT_CSD_HS_CTRL_REL (1 << 0) /* host controlled WR_REL_SET */ +#define EXT_CSD_BOOT_WP_B_SEC_WP_SEL (0x80) /* enable partition selector */ +#define EXT_CSD_BOOT_WP_B_PWR_WP_SEC_SEL (0x02) /* partition selector to protect */ +#define EXT_CSD_BOOT_WP_B_PWR_WP_EN (0x01) /* power-on write-protect */ + #define EXT_CSD_WR_DATA_REL_USR (1 << 0) /* user data area WR_REL */ #define EXT_CSD_WR_DATA_REL_GP(x) (1 << ((x)+1)) /* GP part (x+1) WR_REL */ @@ -980,6 +984,18 @@ int mmc_send_ext_csd(struct mmc *mmc, u8 *ext_csd); */ int mmc_boot_wp(struct mmc *mmc); +/** + * mmc_boot_wp_single_partition() - set write protection to a boot partition. + * + * This function sets a single boot partition to protect and leave the + * other partition writable. + * + * @param mmc the mmc device. + * @param partition 0 - first boot partition, 1 - second boot partition. + * @return 0 for success + */ +int mmc_boot_wp_single_partition(struct mmc *mmc, int partition); + static inline enum dma_data_direction mmc_get_dma_dir(struct mmc_data *data) { return data->flags & MMC_DATA_WRITE ? DMA_TO_DEVICE : DMA_FROM_DEVICE; From patchwork Mon Apr 25 13:59:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ying-Chun Liu X-Patchwork-Id: 565708 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp2724167map; Mon, 25 Apr 2022 06:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpcLIlVR6v+AXiy2d6c2dqtFTQsUGeVoDkZ129Cl+y+MuClwo/NQkdYYjedq8U5KPZ2HxO X-Received: by 2002:a17:906:5d04:b0:6db:7262:570e with SMTP id g4-20020a1709065d0400b006db7262570emr16615860ejt.8.1650895186011; Mon, 25 Apr 2022 06:59:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650895186; cv=none; d=google.com; s=arc-20160816; b=QVMvuWjrV+vs/dYlhFCNFAZ2BsPSSFwj/UpImkT1gSrMdOZ6L+kO9WOh/gqTaMGgtD cYMVQ1lxMIcyRyQHw14YjqfqRgr3pOj1SQNY91JuZI3CoO07S5wfM5KcC6pYtkdT7lIL blA27cd+8YhKj/8shZmbdqkzqj1kgpBmmD5FjrXPhzavI3+52j2rKgDyPN08xANnyYph oo77fio8f0In6Ts5K69afe6skwcEdkeS0Y0Or9HxzTD/EAAsmFfvMXZNeVA5YPQdXrCA hSiK8WuLHVFyPlXV8T0oJ+YQpvCmrvLccbA6BtuOwnpi5sIgOg2E0jrDvPFD+xqF7ihh G+mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cv2j9FK2ZRE2zXKhiEG34+Eixsk1+M2hs8yRWDHGnLI=; b=lix3FocwPpXRPEVRgeDSE4SkBaA4zYgxhnAMCAaEgL/5SEh5l3WkrBuLGk1Agvgkix zvmo6yFTgV6hYg/aq1hHvGlXh2NCil2wVBEY7wz0NA2tJa3UxR1+8PhxvAdkLGBhxjFa WoSud9c3JLnM/FyG1iwwNjzra7hiec3tgm7cRJ0unkyLSNAqR5kFYUhmTIC5AINisOZD uf3fIimUN82KkuVc1CdeNuXOtdQFKyKXQaJPq8pZNuKXEsIA6avBvrjVc1epu0L2n9X+ TVVxoG8JHnmbzkvmye8O6pWCMpnJg87E9zEo/xfit+FesDkyPgtnPP/35KfTOcUKI6H0 XUxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="M/nk1X+x"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id v21-20020a1709062f1500b006df76385ee9si13178851eji.905.2022.04.25.06.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 06:59:46 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="M/nk1X+x"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 793DE83EA0; Mon, 25 Apr 2022 15:59:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="M/nk1X+x"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8270783C62; Mon, 25 Apr 2022 15:59:23 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1BBE183953 for ; Mon, 25 Apr 2022 15:59:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=grandpaul@gmail.com Received: by mail-pl1-x632.google.com with SMTP id s17so27252920plg.9 for ; Mon, 25 Apr 2022 06:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cv2j9FK2ZRE2zXKhiEG34+Eixsk1+M2hs8yRWDHGnLI=; b=M/nk1X+xvCNEf8m7GEREcT8mTZUtZaLmgV3MpDJrWpPlSjwC73uhJsERC71XAeNPph zJytUoA85W0jZY/tNqD7O0sNKNqJM7btWzYXoAeA0QY94/bRHJaoH51QcsplfrJnCreV f+Uuek4JK1WxRM1z6G+Kz7SsA4zL6n/L9zLm77w+oQroldHR3M4vFfCEOXZ+K8+D4Ilp fEWVrF0CLUW2g/KnyjiyfDKNPW+ArwWDsuxxrDQ1JzrQxHt/alq2pgQ932/V0vvffhy5 l05KkLPNITkpDjnctoVsV1mWB7wnYMpSEZVzXk8n49W9yuVFsKdRHrZ7UmV4P8fciIMC OXyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cv2j9FK2ZRE2zXKhiEG34+Eixsk1+M2hs8yRWDHGnLI=; b=qonweFytkyvWBBWty8grXW7Wm8kvwMrMT2H6gyIlkhNYsUNXMIend4btI4noytRFIA Ru3B5InHIR9f94fZPy7M2M6RsACBBa6qMSDGc+bUV1q99EHx7lU/RY8gi/u1iVT0+g6Y HW7vsqDCAgcWrnay+230TNqcw1rC6TFgS/+H3T1sqpMy9mcmsN+Nacd2hm2kPrL8TJr5 u5RwNiDsc9ak4NeRIMjXZxlQ7emO9wb9RdzUPGjQAa2DQ5pRgZMdLqY99dmkuvP1a96C vsVAl55JsffwipzPTsj/x0ZCwPWkQGH4OLeYz/5ZrTDW0o/r7orBJV6jjMvHLKCvP71v KIOw== X-Gm-Message-State: AOAM531RqEVT+XgtKk3chk22qhkuW9p8Fkv6lW+qkiZJhPTYG4nif/u6 49uMRavfct5Q+2i12l/s7Yhr3OE3i30= X-Received: by 2002:a17:903:2ca:b0:156:f1cc:7cb6 with SMTP id s10-20020a17090302ca00b00156f1cc7cb6mr18530505plk.174.1650895155191; Mon, 25 Apr 2022 06:59:15 -0700 (PDT) Received: from localhost ([111.184.129.17]) by smtp.gmail.com with ESMTPSA id b2-20020a056a000a8200b004f1111c66afsm12856627pfl.148.2022.04.25.06.59.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 06:59:14 -0700 (PDT) From: Ying-Chun Liu To: u-boot@lists.denx.de Cc: "Ying-Chun Liu (PaulLiu)" , Peng Fan , Jaehoon Chung Subject: [PATCH 2/2] cmd: mmc: allow to write protect single boot partition Date: Mon, 25 Apr 2022 21:59:03 +0800 Message-Id: <20220425135903.271098-3-grandpaul@gmail.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220425135903.271098-1-grandpaul@gmail.com> References: <20220425135903.271098-1-grandpaul@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean From: "Ying-Chun Liu (PaulLiu)" add arguments for mmc wp to assign which boot partition to protect. Signed-off-by: Ying-Chun Liu (PaulLiu) Cc: Peng Fan Cc: Jaehoon Chung --- cmd/mmc.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmd/mmc.c b/cmd/mmc.c index 7464f8d00c..7f3e5da6cd 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -1046,6 +1046,7 @@ static int do_mmc_boot_wp(struct cmd_tbl *cmdtp, int flag, { int err; struct mmc *mmc; + int part; mmc = init_mmc_device(curr_device, false); if (!mmc) @@ -1054,7 +1055,14 @@ static int do_mmc_boot_wp(struct cmd_tbl *cmdtp, int flag, printf("It is not an eMMC device\n"); return CMD_RET_FAILURE; } - err = mmc_boot_wp(mmc); + + if (argc == 2) { + part = dectoul(argv[1], NULL); + err = mmc_boot_wp_single_partition(mmc, part); + } else { + err = mmc_boot_wp(mmc); + } + if (err) return CMD_RET_FAILURE; printf("boot areas protected\n"); @@ -1064,7 +1072,7 @@ static int do_mmc_boot_wp(struct cmd_tbl *cmdtp, int flag, static struct cmd_tbl cmd_mmc[] = { U_BOOT_CMD_MKENT(info, 1, 0, do_mmcinfo, "", ""), U_BOOT_CMD_MKENT(read, 4, 1, do_mmc_read, "", ""), - U_BOOT_CMD_MKENT(wp, 1, 0, do_mmc_boot_wp, "", ""), + U_BOOT_CMD_MKENT(wp, 2, 0, do_mmc_boot_wp, "", ""), #if CONFIG_IS_ENABLED(MMC_WRITE) U_BOOT_CMD_MKENT(write, 4, 0, do_mmc_write, "", ""), U_BOOT_CMD_MKENT(erase, 3, 0, do_mmc_erase, "", ""), @@ -1138,7 +1146,11 @@ U_BOOT_CMD( " [MMC_LEGACY, MMC_HS, SD_HS, MMC_HS_52, MMC_DDR_52, UHS_SDR12, UHS_SDR25,\n" " UHS_SDR50, UHS_DDR50, UHS_SDR104, MMC_HS_200, MMC_HS_400, MMC_HS_400_ES]\n" "mmc list - lists available devices\n" - "mmc wp - power on write protect boot partitions\n" + "mmc wp [PART] - power on write protect boot partitions\n" + " arguments:\n" + " PART - [0|1]\n" + " : 0 - first boot partition, 1 - second boot partition\n" + " if not assigned, write protect all boot partitions\n" #if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING) "mmc hwpartition - does hardware partitioning\n" " arguments (sizes in 512-byte blocks):\n"