From patchwork Fri Feb 15 06:34:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amar X-Patchwork-Id: 14823 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 B962223FC2 for ; Fri, 15 Feb 2013 06:14:15 +0000 (UTC) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by fiordland.canonical.com (Postfix) with ESMTP id 45193A185F0 for ; Fri, 15 Feb 2013 06:14:15 +0000 (UTC) Received: by mail-vb0-f53.google.com with SMTP id fj18so1981210vbb.40 for ; Thu, 14 Feb 2013 22:14:14 -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=iWKEilgdtJ9wZfPEI0HQ4EGsEy+d8p99XXzmX7qG/Rg=; b=ohzOoCvUri2wM1gLIpwcwYaOfcKHCv392uc8cb8AmNoDqAJvfZNX9xmu6oYoJb973x pKCHnED1EWxKMMeqaDJs74sGJ2kXq98ZPiNFc8bLsX8iFWLHpRhctGtazY4BLRyBST7s YdTH3+1IiLRV1kDKh3lixD1cbM9EG6gUCUEmfA/OyviYoBoYEwjhEhU6bFFKAAYz2X8p SZNiQKIeEwONjNcVqHK0Galy3YimgmF1dVochsr+UJtRubUTV+hSHCAA1vzUnU/1vRH8 InUB6gGmbuD4g7E2yXhE9W/PtRIeDGAvJRjUqq60VG1GB224qf904OofjH7DFTeLi1T4 aLxw== X-Received: by 10.220.240.141 with SMTP id la13mr1674453vcb.39.1360908854786; Thu, 14 Feb 2013 22:14:14 -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.221.4.5 with SMTP id oa5csp305015vcb; Thu, 14 Feb 2013 22:14:14 -0800 (PST) X-Received: by 10.66.47.193 with SMTP id f1mr4853698pan.48.1360908853674; Thu, 14 Feb 2013 22:14:13 -0800 (PST) Received: from mailout1.samsung.com (mailout1.samsung.com. [203.254.224.24]) by mx.google.com with ESMTP id z9si11304519pav.103.2013.02.14.22.14.13; Thu, 14 Feb 2013 22:14:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.24 as permitted sender) client-ip=203.254.224.24; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of amarendra.xt@samsung.com designates 203.254.224.24 as permitted sender) smtp.mail=amarendra.xt@samsung.com Received: from epcpsbgr1.samsung.com (u141.gpu120.samsung.co.kr [203.254.230.141]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MI800J4GZZ1VHN0@mailout1.samsung.com>; Fri, 15 Feb 2013 15:14:12 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.123]) by epcpsbgr1.samsung.com (EPCPMTA) with SMTP id 8D.BB.16905.432DD115; Fri, 15 Feb 2013 15:14:12 +0900 (KST) X-AuditID: cbfee68d-b7f4f6d000004209-91-511dd23433e8 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 74.9A.03918.432DD115; Fri, 15 Feb 2013 15:14:12 +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 <0MI8005Z0ZYZ7R20@mmp2.samsung.com>; Fri, 15 Feb 2013 15:14:11 +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 V6 09/10] COMMON: MMC: Command to support EMMC booting and to resize EMMC boot partition Date: Fri, 15 Feb 2013 01:34:50 -0500 Message-id: <1360910091-6285-10-git-send-email-amarendra.xt@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1360910091-6285-1-git-send-email-amarendra.xt@samsung.com> References: <1360910091-6285-1-git-send-email-amarendra.xt@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrJLMWRmVeSWpSXmKPExsWyRsSkWtfkkmygwYX7QhYP199ksZhy+AuL A5PHnWt72AIYo7hsUlJzMstSi/TtErgylvV0MxXsVq1Y+dG5gXGDbBcjJ4eEgInEgkX7mSBs MYkL99azdTFycQgJLGWUWDFhKyNM0cVVTcwQiemMEp1nzkE5vUwS6w5tYu9i5OBgE1CV+LXY HqRBREBC4lf/VUaQGmaBDkaJHRM3g00SFsiSmHjqNAtIPQtQ/f+JWSBhXgEPia+bj7JCLJOT +LDnETuIzQkUPzf5NTOILSTgLrHzUwfYTAmB+2wSTfufsYEkWAQEJL5NPgQ2U0JAVmLTAWaI OZISB1fcYJnAKLyAkWEVo2hqQXJBcVJ6kaFecWJucWleul5yfu4mRmAwnv73rHcH4+0D1ocY k4HGTWSWEk3OBwZzXkm8obGJuamxqZmRpaWlKWnCSuK8cpdkAoUE0hNLUrNTUwtSi+KLSnNS iw8xMnFwSjUw3rphJXts3v/t0ikr1kTeiJj/viRek+fPVnvb0jvuh3Pi1mnULrOc4JjZ0hO9 QzWsZil/f9NOcYubP1e5bdx4M83t1WnzNUq71r1J99j6crUOa3ZNOu+RjhCJN5nzi2JOsC3b 0bn81H27uXylIf8cT1h3LXM+Nd3aVmUN5zTz494p/UIrejedVGIpzkg01GIuKk4EACpY4dhc AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGIsWRmVeSWpSXmKPExsVy+t9jQV2TS7KBBuv3sFs8XH+TxWLK4S8s Dkwed67tYQtgjGpgtMlITUxJLVJIzUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLx CdB1y8wBmq2kUJaYUwoUCkgsLlbSt8M0ITTETdcCpjFC1zckCK7HyAANJKxhzFjW081UsFu1 YuVH5wbGDbJdjJwcEgImEhdXNTFD2GISF+6tZ+ti5OIQEpjOKNF55hwzhNPLJLHu0Cb2LkYO DjYBVYlfi+1BGkQEJCR+9V9lBKlhFuhglNgxcTMjSEJYIEti4qnTLCD1LED1/ydmgYR5BTwk vm4+ygqxTE7iw55H7CA2J1D83OTXYEcICbhL7PzUwTiBkXcBI8MqRtHUguSC4qT0XEO94sTc 4tK8dL3k/NxNjOBQfya1g3Flg8UhRgEORiUeXgEJ2UAh1sSy4srcQ4wSHMxKIrxrQoBCvCmJ lVWpRfnxRaU5qcWHGJOBjprILCWanA+Mw7ySeENjE3NTY1NLEwsTM0vShJXEeRlPPQkQEkhP LEnNTk0tSC2C2cLEwSnVwNg1w2bJEYFpr/QrMysNXLYdPf9T8QTPPsXufJWbd0oEltXrX16g ebLDQTTOt6tV+PMC95VPmp26pn78u0DTao/y/WTjT+fd1+wLuN7zq/ug+KKPPX39Penrb37m 3Mp+vHP1SYXkkNyvB75O4/uVu9X3kB3f/Bx/5YC1s+qnP5V+U/Uvb5JOxSclluKMREMt5qLi RAAUa//nuQIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-Gm-Message-State: ALoCoQnsueCbwdSHFnzvQZevKwd/5yOvU3GyJlalHAn03EXOXdoFkqbPicTtLhjoKB8WTCk6cAQW 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. 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