From patchwork Mon Jan 21 11:43:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 14142 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 A149D23E02 for ; Mon, 21 Jan 2013 11:30:30 +0000 (UTC) Received: from mail-vb0-f41.google.com (mail-vb0-f41.google.com [209.85.212.41]) by fiordland.canonical.com (Postfix) with ESMTP id 402B2A189F6 for ; Mon, 21 Jan 2013 11:30:30 +0000 (UTC) Received: by mail-vb0-f41.google.com with SMTP id l22so1632254vbn.14 for ; Mon, 21 Jan 2013 03:30:29 -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=m9g4wGav6V/NBfqXCaXFVo5+bOaBoUXhN62Q6m1C2Vg=; b=aq6js5zrHnAWWHtfLNuR54H+0Xk6qVwWNyO2uP4JqIheXj5pt5jyk2066LI+pDVBPF Gh+IJUw9IpFUJfYTnBhUsZfZJhZm2x1jsCxw0o9rW2qgMiw4CHb0qGf5KnLS6rtyVGzm BhpwZqiLfAePGEzRl05qSSV9KMCPGvshcrSKzM3ODT7/Ulwpnm++e5wPoJHIliiHomBg GAWARM/1QyJOIRTXQuugMrVe2pbaRHopxTbvdZ/b5h+T1UrrBhqPo/VxEv8A+ZroiWcw Tz4wn/PH07gNedTe7V4CHnlIiAT1YQ7WmdG9bQy82ksVyCw9Tsx0sjx2PeEjOvCiigl/ 4alw== X-Received: by 10.52.16.6 with SMTP id b6mr13770156vdd.40.1358767829766; Mon, 21 Jan 2013 03:30:29 -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.145.101 with SMTP id st5csp196542veb; Mon, 21 Jan 2013 03:30:28 -0800 (PST) X-Received: by 10.66.83.136 with SMTP id q8mr46194549pay.83.1358767828484; Mon, 21 Jan 2013 03:30:28 -0800 (PST) Received: from mailout3.samsung.com (mailout3.samsung.com. [203.254.224.33]) by mx.google.com with ESMTP id ru9si13436697pbc.160.2013.01.21.03.30.27; Mon, 21 Jan 2013 03:30:28 -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 epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MGZ008A73YMV610@mailout3.samsung.com>; Mon, 21 Jan 2013 20:30:27 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.126]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 04.24.03918.2D62DF05; Mon, 21 Jan 2013 20:30:27 +0900 (KST) X-AuditID: cbfee61a-b7f7d6d000000f4e-34-50fd26d26afd Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 43.24.03918.2D62DF05; Mon, 21 Jan 2013 20:30:26 +0900 (KST) Received: from chrome-ubuntu.sisodomain.com ([107.108.73.106]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MGZ0092C3L1A540@mmp2.samsung.com>; Mon, 21 Jan 2013 20:30:26 +0900 (KST) From: Amar To: u-boot@lists.denx.de, jh80.chung@samsung.com Cc: patches@linaro.org, sjg@chromium.org, mk7.kang@samsung.com, chander.kashyap@linaro.org, afleming@gmail.com, hs@denx.de Subject: [PATCH V5 09/10] COMMON: MMC: Command to support EMMC booting and to resize EMMC boot partition Date: Mon, 21 Jan 2013 06:43:57 -0500 Message-id: <1358768638-14187-10-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1358768638-14187-1-git-send-email-amarendra.xt@samsung.com> References: <1358768638-14187-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsWyRsSkTvey2t8Ag09TWCwerr/JYjHl8BcW ByaPO9f2sAUwRnHZpKTmZJalFunbJXBlPF7wlKngj0rFvCuHmRoYz8l0MXJySAiYSOx428wO YYtJXLi3nq2LkYtDSGApo8Tm9m5mmKIVW+cxQySmM0pM+HESqqqXSWLSpDtADgcHm4CqxK/F 9iANIgIGEtOfbGcFsZkFaiQmz7/FBGILC2RJbG66DTaUBaj83eyPYDW8Ap4SN+4ehVomJ/Fh zyOwiziB4vv/7gGrERLwkNi14D8ryF4JgdtsEv1v9jBCDBKQ+Db5EAvIDRICshKbDkDNkZQ4 uOIGywRG4QWMDKsYRVMLkguKk9JzDfWKE3OLS/PS9ZLzczcxAsPx9L9nUjsYVzZYHGIU4GBU 4uHNmPonQIg1say4MvcQowQHs5II788ZQCHelMTKqtSi/Pii0pzU4kOMyUDLJzJLiSbnA2Ml ryTe0NjE3NTY1NLIyMzUlDRhJXFexlNPAoQE0hNLUrNTUwtSi2C2MHFwSjUwHjweGVw32W3e KpP4bIM60Q/V9VxKzkbzuJfIMTwVNJvtu9I3Kn/3N6Mn+6ZweUVlGYTeuNDlUPkrTvvjf/ac RNUnmyyiKzVPHP9+40mi+bqqG7LRAoc/3oxOu3bn0K0tuZ/rHP6vuTxZxPNg3vG9iS6zcx9M 9zh76mHCoQNtd+1kexuKeguYlViKMxINtZiLihMBYhE5OIsCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRmVeSWpSXmKPExsVy+t9jQd1Lan8DDM5cMLR4uP4mi8WUw19Y HJg87lzbwxbAGNXAaJORmpiSWqSQmpecn5KZl26r5B0c7xxvamZgqGtoaWGupJCXmJtqq+Ti E6DrlpkDNFtJoSwxpxQoFJBYXKykb4dpQmiIm64FTGOErm9IEFyPkQEaSFjDmPF4wVOmgj8q FfOuHGZqYDwn08XIySEhYCKxYus8ZghbTOLCvfVsXYxcHEIC0xklJvw4CeX0MklMmnQHyOHg YBNQlfi12B6kQUTAQGL6k+2sIDazQI3E5Pm3mEBsYYEsic1Nt8GGsgCVv5v9EayGV8BT4sbd o1DL5CQ+7HnEDmJzAsX3/90DViMk4CGxa8F/1gmMvAsYGVYxiqYWJBcUJ6XnGuoVJ+YWl+al 6yXn525iBAf7M6kdjCsbLA4xCnAwKvHwZkz9EyDEmlhWXJl7iFGCg1lJhPfnDKAQb0piZVVq UX58UWlOavEhxmSgqyYyS4km5wMjMa8k3tDYxNzU2NTSxMLEzJI0YSVxXsZTTwKEBNITS1Kz U1MLUotgtjBxcEo1MB5plL947U5MTNcHB9f5U58995JNYpry8sb9gksz7H8H9X4xir3zJu3L D60T77zKLiSu2hRzriwtd6Of8qZ7xUIeb/drnObvOZMseXb5hquPbiQrb2EtKMhJ97mbofDS Yc/L3f3mzc/KegunfpzxPD7v99+rIcXK7J6TDzD/rPq2/qlyS7fpx34lluKMREMt5qLiRAAZ bCUsugIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQmRhOfvCgEHRWDiqVvmZlpd2dXmPhUonTOVxj13MsseQVMLKguUlLgUFuuPQFMKEFsZdu1U 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). 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..d036d34 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 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