From patchwork Tue Mar 5 13:11:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 15238 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 28A1523E00 for ; Tue, 5 Mar 2013 12:58:24 +0000 (UTC) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by fiordland.canonical.com (Postfix) with ESMTP id BD6C6A1945C for ; Tue, 5 Mar 2013 12:58:23 +0000 (UTC) Received: by mail-ve0-f174.google.com with SMTP id pb11so5629534veb.5 for ; Tue, 05 Mar 2013 04:58:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-auditid:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-brightmail-tracker:x-brightmail-tracker :dlp-filter:x-mtr:x-cfilter-loop:x-gm-message-state; bh=fQqyDccKpFZUf8+HXDswkLkLoavwIln3hsJgyqLa5nI=; b=iR2rVJR1zHYRrFzkU3xPAIEmAX3fkFfjbKqy4Rtw29PJls5Zmom7pG5w2klt09MMXp HTtLDFv1jL5IZNvRUgWhKNsslZL+fHkOg4R31t/eVVuzel6zXtKV3i+bBf6AQwcJ952G AZBMHXO4lHnjRt7ssVLYCLm7S35DfU6xtKVIpsAgyqRn/MEJHNvZLGZmlMGqdv1Gvb9o xIrz0EJESUiaHVUCBUZwbFJYZcXjH1+xW2WisLn1TQhfu8cUueLcpTxG/LhDqyEhxWNg Tn8yJT9mg2g2cV+mUC/Lq42Xs07X48Org7fOEpvMTv45CJuWrhfb+3oyyhn8y6Yqd0W5 /ZhA== X-Received: by 10.52.88.237 with SMTP id bj13mr8266576vdb.75.1362488303154; Tue, 05 Mar 2013 04:58:23 -0800 (PST) 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.58.127.98 with SMTP id nf2csp110023veb; Tue, 5 Mar 2013 04:58:22 -0800 (PST) X-Received: by 10.50.12.201 with SMTP id a9mr6062840igc.10.1362488301910; Tue, 05 Mar 2013 04:58:21 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id fa5si4578926icc.88.2013.03.05.04.58.21; Tue, 05 Mar 2013 04:58:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.33 as permitted sender) client-ip=203.254.224.33; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.33 as permitted sender) smtp.mail=amarendra.xt@samsung.com Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MJ600D9YUOTNB60@mailout3.samsung.com>; Tue, 05 Mar 2013 21:58:20 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.126]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 56.56.25214.CEBE5315; Tue, 05 Mar 2013 21:58:20 +0900 (KST) X-AuditID: cbfee68e-b7fa46d00000627e-89-5135ebecf8bd Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id E3.F1.03880.BEBE5315; Tue, 05 Mar 2013 21:58:20 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MJ600GDUUCXH840@mmp1.samsung.com>; Tue, 05 Mar 2013 21:58:19 +0900 (KST) From: Amar To: u-boot@lists.denx.de Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, afleming@gmail.com, jh80.chung@samsung.com Subject: [PATCH V7 09/10] COMMON: MMC: Command to support EMMC booting and to resize EMMC boot partition Date: Tue, 05 Mar 2013 08:11:29 -0500 Message-id: <1362489090-7745-10-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1362489090-7745-1-git-send-email-amarendra.xt@samsung.com> References: <1362489090-7745-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrFLMWRmVeSWpSXmKPExsWyRsSkTvfNa9NAg63HBC0err/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlLLqxjrngrmrF382T2BsYT8h2MXJwSAiYSKyZot7F yAlkiklcuLeerYuRi0NIYCmjxMKuR4wQCROJ9S0TWSASixgldl85zwTh9DJJHLi2nxFkEpuA qsSvxfYgDSICEhK/+q8ygtQwC3QwSuyYuBlskrBAlsSF2f+ZQWwWoPqNp+azgti8Ah4SL3dd Y4bYJifxYc8jdhCbEyi+6PNCsLiQgLvEpZ5FYFdICDxmk7j+YiMLxCABiW+TD7FAvCMrsekA 1BxJiYMrbrBMYBRewMiwilE0tSC5oDgpvchIrzgxt7g0L10vOT93EyMwHE//e9a3g/HmAetD jMlA4yYyS4km5wPDOa8k3tDYxNzU2NTMyNLS0pQ0YSVxXvlLMoFCAumJJanZqakFqUXxRaU5 qcWHGJk4OKUaGDeaHBPev1/U7OATO4V5XfP2OuypENj6pLfzz9K4R2p77z1RfLvmUen8jZfV JsxhdL1o2lgkJrDZc+4Drkbv9wGakyJ2XPXrfragreTYmyypWbOfbqsImS137VBiJWvYqQdH /5uqSdVMccq+snSWXIlyr/01ZZYdx7T4LCKWONR+ZH1j6CzQ4KzEUpyRaKjFXFScCAAEfZ/1 XQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRmVeSWpSXmKPExsVy+t9jAd03r00DDQ7MYLJ4uP4mi8WUw19Y HJg87lzbwxbAGNXAaJORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+Ti E6DrlpkDNFtJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmLHoxjrmgruq FX83T2JvYDwh28XIySEhYCKxvmUiC4QtJnHh3nq2LkYuDiGBRYwSu6+cZ4JwepkkDlzbz9jF yMHBJqAq8WuxPUiDiICExK/+q4wgNcwCHYwSOyZuZgRJCAtkSVyY/Z8ZxGYBqt94aj4riM0r 4CHxctc1ZohtchIf9jxiB7E5geKLPi8EiwsJuEtc6lnEMoGRdwEjwypG0dSC5ILipPRcI73i xNzi0rx0veT83E2M4HB/Jr2DcVWDxSFGAQ5GJR5ehqMmgUKsiWXFlbmHGCU4mJVEeHc+NQ0U 4k1JrKxKLcqPLyrNSS0+xJgMdNVEZinR5HxgLOaVxBsam5ibGptamliYmFmSJqwkzst46kmA kEB6YklqdmpqQWoRzBYmDk6pBka2a7qPT2bfmmU4I6B8s6+5+V0lBdtbb79w/nb9Yl/48rWN yzoJ3ilucXx3H8xyVrgc+OibrumlhWJ1VRk7kxrKBO9bbDxzdcG/5E+Hvu8JfbHRhHfKyYRE fSu/D9PlmpOPORu+F67Vifrw7pnFfc51u9meTjLaKVweuPHdg9wL6zK9T9/OM45TYinOSDTU Yi4qTgQAgAxWuLsCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmZLypylX5PlDAMPyhRRo+z5i+RCju/tuEELfXg7VvAxXgREaMURcIjGUnR/MRVxWiLQWYf This patch adds commands to access(open/close) and resize boot partitions on EMMC. Signed-off-by: Amar Acked-by: Simon Glass --- Changes since V1: 1)Combined the common piece of code between 'open' and 'close' operations. Changes since V2: 1)Updation of commit message and resubmition of proper patch set. Changes since V3: No change. Changes since V4: 1)Added a new funtion boot_part_access() to combine the common parts of 'mmc open' and 'mmc close' functionalities. 2)Used the generic function "mmc_boot_part_access()" instead of two functions "mmc_boot_open()" and "mmc_boot_close()". By doing so user can specify which boot partition to be accessed (opened / closed). Changes since V5: 1)Updated minor nits in response to review comments. Changes since V6: No change. common/cmd_mmc.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 7dacd51..5f2ae70 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -147,6 +147,31 @@ U_BOOT_CMD( "- display info of the current MMC device" ); +static int boot_part_access(struct mmc *mmc, u32 ack, u32 part_num, u32 access) +{ + int err; + err = mmc_boot_part_access(mmc, ack, part_num, access); + + if ((err == 0) && (access != 0)) { + printf("\t\t\t!!!Notice!!!\n"); + printf("!You must close EMMC boot Partition after all" + "images are written\n"); + printf("!EMMC boot partition has continuity at image" + "writing time.\n"); + printf("!So, do not close the boot partition before all" + "images are written.\n"); + return 0; + } else if ((err == 0) && (access == 0)) + return 0; + else if ((err != 0) && (access != 0)) { + printf("EMMC boot partition-%d OPEN Failed.\n", part_num); + return 1; + } else { + printf("EMMC boot partition-%d CLOSE Failed.\n", part_num); + return 1; + } +} + static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { enum mmc_state state; @@ -248,6 +273,71 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) curr_device, mmc->part_num); return 0; + } else if ((strcmp(argv[1], "open") == 0) || + (strcmp(argv[1], "close") == 0)) { + int dev; + struct mmc *mmc; + u32 ack, part_num, access = 0; + + if (argc == 4) { + dev = simple_strtoul(argv[2], NULL, 10); + part_num = simple_strtoul(argv[3], NULL, 10); + } else + return CMD_RET_USAGE; + + mmc = find_mmc_device(dev); + if (!mmc) { + printf("no mmc device at slot %x\n", dev); + return 1; + } + + if (IS_SD(mmc)) { + printf("SD device cannot be opened/closed\n"); + return 1; + } + + if ((part_num <= 0) || (part_num > MMC_NUM_BOOT_PARTITION)) { + printf("Invalid boot partition number:\n"); + printf("Boot partition number cannot be <= 0\n"); + printf("EMMC44 supports only 2 boot partitions\n"); + return 1; + } + + if (strcmp(argv[1], "open") == 0) + access = part_num; /* enable R/W access to boot part*/ + if (strcmp(argv[1], "close") == 0) + access = 0; /* No access to boot partition */ + + /* acknowledge to be sent during boot operation */ + ack = 1; + return boot_part_access(mmc, ack, part_num, access); + + } else if (strcmp(argv[1], "bootpart") == 0) { + int dev; + dev = simple_strtoul(argv[2], NULL, 10); + + u32 bootsize = simple_strtoul(argv[3], NULL, 10); + u32 rpmbsize = simple_strtoul(argv[4], NULL, 10); + struct mmc *mmc = find_mmc_device(dev); + if (!mmc) { + printf("no mmc device at slot %x\n", dev); + return 1; + } + + if (IS_SD(mmc)) { + printf("It is not a EMMC device\n"); + return 1; + } + + if (0 == mmc_boot_partition_size_change(mmc, + bootsize, rpmbsize)) { + printf("EMMC boot partition Size %d MB\n", bootsize); + printf("EMMC RPMB partition Size %d MB\n", rpmbsize); + return 0; + } else { + printf("EMMC boot partition Size change Failed.\n"); + return 1; + } } state = MMC_INVALID; @@ -317,5 +407,11 @@ U_BOOT_CMD( "mmc rescan\n" "mmc part - lists available partition on current mmc device\n" "mmc dev [dev] [part] - show or set current mmc device [partition]\n" - "mmc list - lists available devices"); + "mmc list - lists available devices\n" + "mmc open \n" + " - Enable boot_part for booting and enable R/W access of boot_part\n" + "mmc close \n" + " - Enable boot_part for booting and disable access to boot_part\n" + "mmc bootpart \n" + " - change sizes of boot and RPMB partions of specified device\n"); #endif