From patchwork Tue Dec 23 09:50:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Santa Cruz X-Patchwork-Id: 423631 X-Patchwork-Delegate: panto@antoniou-consulting.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 28B911400B7 for ; Tue, 23 Dec 2014 21:02:22 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3C2C34B67F; Tue, 23 Dec 2014 11:02:20 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q8dyhQsg8uhd; Tue, 23 Dec 2014 11:02:19 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8C46C4B683; Tue, 23 Dec 2014 11:02:19 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id CCD424B67F for ; Tue, 23 Dec 2014 11:02:13 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e4SdKiJbGv8l for ; Tue, 23 Dec 2014 11:02:13 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0081.outbound.protection.outlook.com [157.55.234.81]) by theia.denx.de (Postfix) with ESMTPS id 94E1A4B67E for ; Tue, 23 Dec 2014 11:02:08 +0100 (CET) Received: from DB4PR01MB125.eurprd01.prod.exchangelabs.com (10.242.156.12) by DB4PR01MB269.eurprd01.prod.exchangelabs.com (10.242.158.13) with Microsoft SMTP Server (TLS) id 15.1.53.12; Tue, 23 Dec 2014 09:51:15 +0000 Received: from prefix.spinetix.local (212.147.27.179) by DB4PR01MB125.eurprd01.prod.exchangelabs.com (10.242.156.12) with Microsoft SMTP Server (TLS) id 15.1.49.12; Tue, 23 Dec 2014 09:51:14 +0000 From: Diego Santa Cruz To: Date: Tue, 23 Dec 2014 10:50:30 +0100 Message-ID: <1419328233-6977-16-git-send-email-Diego.SantaCruz@spinetix.com> X-Mailer: git-send-email 2.2.1 In-Reply-To: <1419328233-6977-1-git-send-email-Diego.SantaCruz@spinetix.com> References: <1419328233-6977-1-git-send-email-Diego.SantaCruz@spinetix.com> MIME-Version: 1.0 X-Originating-IP: [212.147.27.179] X-ClientProxiedBy: DB4PR04CA0041.eurprd04.prod.outlook.com (25.160.41.51) To DB4PR01MB125.eurprd01.prod.exchangelabs.com (10.242.156.12) Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Diego.SantaCruz@spinetix.com; X-Microsoft-Antispam: UriScan:;UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DB4PR01MB125; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:DB4PR01MB125; X-Forefront-PRVS: 04347F8039 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(76176999)(77156002)(110136001)(101416001)(68736005)(62966003)(31966008)(40100003)(21056001)(50986999)(122386002)(92566001)(99396003)(48376002)(2950100001)(86362001)(77096005)(87976001)(66066001)(2351001)(20776003)(107046002)(89996001)(97736003)(229853001)(4396001)(46102003)(120916001)(36756003)(64706001)(50466002)(106356001)(105586002)(19580395003)(19580405001)(50226001)(42186005)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR01MB125; H:prefix.spinetix.local; FPR:; SPF:None; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: spinetix.com does not designate permitted sender hosts) X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:DB4PR01MB125; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Dec 2014 09:51:14.1906 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR01MB125 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DB4PR01MB269; X-OriginatorOrg: spinetix.com Cc: panto@antoniou-consulting.com Subject: [U-Boot] [PATCH v4 15/18] mmc: add mmc hwpartition sub-command to do eMMC hardware partitioning X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.13 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Adds the mmc hwpartition sub-command to perform eMMC hardware partitioning on an mmc device. The number of arguments can be large for a complex partitioning, but as the partitioning has to be done in one go it is difficult to make it simpler. Signed-off-by: Diego Santa Cruz --- common/cmd_mmc.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 1 deletion(-) diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c index 491a889..3c168ac 100644 --- a/common/cmd_mmc.c +++ b/common/cmd_mmc.c @@ -482,6 +482,91 @@ static int do_mmc_list(cmd_tbl_t *cmdtp, int flag, print_mmc_devices('\n'); return CMD_RET_SUCCESS; } + +static int do_mmc_hwpartition(cmd_tbl_t *cmdtp, int flag, + int argc, char * const argv[]) +{ + struct mmc *mmc; + struct mmc_hwpart_conf pconf = { }; + enum mmc_hwpart_conf_mode mode = MMC_HWPART_CONF_CHECK; + int i, pidx; + + mmc = init_mmc_device(curr_device, false); + if (!mmc) + return CMD_RET_FAILURE; + + if (argc < 1) + return CMD_RET_USAGE; + i = 1; + while (i < argc) { + if (!strcmp(argv[i], "userenh")) { + if (i + 2 >= argc) + return CMD_RET_USAGE; + memset(&pconf.user, 0, sizeof(pconf.user)); + pconf.user.enh_start = + simple_strtoul(argv[i+1], NULL, 10); + pconf.user.enh_size = + simple_strtoul(argv[i+2], NULL, 10); + i += 3; + } else if (!strncmp(argv[i], "gp", 2) && + strlen(argv[i]) == 3 && + argv[i][2] >= '1' && argv[i][2] <= '4') { + if (i + 1 >= argc) + return CMD_RET_USAGE; + pidx = argv[i][2] - '1'; + memset(&pconf.gp_part[pidx], 0, + sizeof(pconf.gp_part[pidx])); + pconf.gp_part[pidx].size = + simple_strtoul(argv[i+1], NULL, 10); + i += 2; + if (i < argc && !strcmp(argv[i], "enh")) { + pconf.gp_part[pidx].enhanced = 1; + i++; + } + } else if (!strcmp(argv[i], "check")) { + mode = MMC_HWPART_CONF_CHECK; + i++; + } else if (!strcmp(argv[i], "set")) { + mode = MMC_HWPART_CONF_SET; + i++; + } else if (!strcmp(argv[i], "complete")) { + mode = MMC_HWPART_CONF_COMPLETE; + i++; + } else { + return CMD_RET_USAGE; + } + } + + puts("Partition configuration:\n"); + if (pconf.user.enh_size) { + puts("\tUser Enhanced Start: "); + print_size(((u64)pconf.user.enh_start) << 9, "\n"); + puts("\tUser Enhanced Size: "); + print_size(((u64)pconf.user.enh_size) << 9, "\n"); + } else { + puts("\tNo enhanced user data area\n"); + } + for (pidx = 0; pidx < 4; pidx++) { + if (pconf.gp_part[pidx].size) { + printf("\tGP%i Capacity: ", pidx+1); + print_size(((u64)pconf.gp_part[pidx].size) << 9, + pconf.gp_part[pidx].enhanced ? + " ENH\n" : "\n"); + } else { + printf("\tNo GP%i partition\n", pidx+1); + } + } + + if (!mmc_hwpart_config(mmc, &pconf, mode)) { + if (mode == MMC_HWPART_CONF_COMPLETE) + puts("Partitioning successful, " + "power-cycle to make effective\n"); + return CMD_RET_SUCCESS; + } else { + return CMD_RET_FAILURE; + } +} + #ifdef CONFIG_SUPPORT_EMMC_BOOT static int do_mmc_bootbus(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) @@ -639,6 +724,7 @@ static cmd_tbl_t cmd_mmc[] = { U_BOOT_CMD_MKENT(part, 1, 1, do_mmc_part, "", ""), U_BOOT_CMD_MKENT(dev, 3, 0, do_mmc_dev, "", ""), U_BOOT_CMD_MKENT(list, 1, 1, do_mmc_list, "", ""), + U_BOOT_CMD_MKENT(hwpartition, 17, 0, do_mmc_hwpartition, "", ""), #ifdef CONFIG_SUPPORT_EMMC_BOOT U_BOOT_CMD_MKENT(bootbus, 5, 0, do_mmc_bootbus, "", ""), U_BOOT_CMD_MKENT(bootpart-resize, 4, 0, do_mmc_boot_resize, "", ""), @@ -678,7 +764,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } U_BOOT_CMD( - mmc, 7, 1, do_mmcops, + mmc, 18, 1, do_mmcops, "MMC sub system", "info - display info of the current MMC device\n" "mmc read addr blk# cnt\n" @@ -688,6 +774,11 @@ U_BOOT_CMD( "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\n" + "mmc hwpartition [args...] - does hardware partitioning\n" + " arguments (sizes in 512-byte blocks):\n" + " [userenh start cnt] - sets enhanced user data area\n" + " [gp1|gp2|gp3|gp4 cnt [enh]] - general purpose partition\n" + " [check|set|complete] - mode, complete set partitioning completed\n" #ifdef CONFIG_SUPPORT_EMMC_BOOT "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n" " - Set the BOOT_BUS_WIDTH field of the specified device\n"