From patchwork Fri Oct 19 07:06:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 986574 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="WSjnm0Ux"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="P1TNKeyP"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42bxnv2xJWz9s8T for ; Fri, 19 Oct 2018 18:08:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=zBug2SjwnVnXtUd1B9wABESgEQG4em+ZamevW+I2x1c=; b=WSjnm0UxTsF9jPftDUpF2Htjsp rg8A2aCYYBgzq37Anx2xUdeet20jzSam5hQebWNtdQvgzUh69DwxjjYZL5zTy6Uy73P4YVoOiztIV WYroEJ+xdUQ7A1MT/KGnK6cHi5lS4b3fgUBG1jU+qZ+e45KQO30AloYJm/3qN+PcxMBCAS9dBJxPT TgvhIm8irNjksv2PgpDmM6hGxf3pjjnguS9zx4MiLBZAID42nubL3Tl6FIfuJFhThD+UmfVsHmYKW 5+XtEftp5++BajCB12T/1/gXpFbz0v+X1qVg/QjiTbLF/ZrMYffGfVg0RRpxI9fnBHbtDySHo5zvS thCRafig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gDOss-0004AA-D7; Fri, 19 Oct 2018 07:07:46 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gDOrr-0003e5-O7 for linux-mtd@lists.infradead.org; Fri, 19 Oct 2018 07:06:45 +0000 Received: by mail-lf1-x142.google.com with SMTP id l1-v6so4663952lfc.3 for ; Fri, 19 Oct 2018 00:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t99Q+i/SoyorLvc8faum8S770uSZRfnM+qqD2AM2ppI=; b=P1TNKeyPvyDiNwGhk5p8DVsytN+Q7+jD6G4vRBbr47j2UkbqFossmZ/ydVZUUV6PVf wLCElWkgUKCb4OQjl4/pDYAVXX2kFUIV4XtFo68j1i6xx5jq01+2YO8K8y62JSANS01m kgPXSrG0pvjjSsXGcxZfGFppLq7TjtIdiKOsI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t99Q+i/SoyorLvc8faum8S770uSZRfnM+qqD2AM2ppI=; b=SWM1MkmQWypJLU+QF0k8lpKR0yNGYY/w/uzMKOGxhM9IES1BXfuLEpgaBrz24gR4Zr VclkFeHftzxFApVrLkz2+dx0l2q2/v8RzXt0pU9O5Z3IXOm/L9ZW6JOE5pPA6rQPOTqA TzGAaFTCp+TEObhlUy7MI7Kra6c3hNvr+Zbq915NBcbCKBMV47fQkunXmfyMtkMm41aa u3vuKkgo0cvomBCkfGxiDJLis7GoFskEUBM2DmVSM1UyXRVdEsKvTkQQ2gvHua31ea+f W6LJg5HdQVYQOI6UIgKfOwg/UIOwHcK/C0o5lyBaMXOfDTH8yJ3Vb6xscv52W2u8U/zs QFFQ== X-Gm-Message-State: ABuFfoiF07Hp+QkHBx7IUUbtMH9vYocJIZ5N7KQt5ov8r/jYdxShJuSB yZJPGLIoxVS5d/cPJDfXVpXVXQ== X-Google-Smtp-Source: ACcGV61VXpZ18Jko9VypMWLpR5yxtyZrbmRmQvZnaGtB7LW2ya2stnw4TF4oS5RAu9rJpknt9+t2fw== X-Received: by 2002:a19:771b:: with SMTP id s27-v6mr2149756lfc.84.1539932791622; Fri, 19 Oct 2018 00:06:31 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-ae7b71d5.014-348-6c756e10.bbcust.telenor.se. [213.113.123.174]) by smtp.gmail.com with ESMTPSA id m12-v6sm5537lfj.39.2018.10.19.00.06.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Oct 2018 00:06:30 -0700 (PDT) From: Linus Walleij To: David Woodhouse , Brian Norris , Boris Brezillon , Marek Vasut , Richard Weinberger , linux-mtd@lists.infradead.org Subject: [PATCH 3/3] mtd: partitions: Add OF support to RedBoot partitions Date: Fri, 19 Oct 2018 09:06:22 +0200 Message-Id: <20181019070622.26661-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181019070622.26661-1-linus.walleij@linaro.org> References: <20181019070622.26661-1-linus.walleij@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181019_000643_778812_7538904A X-CRM114-Status: GOOD ( 20.54 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:142 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Linus Walleij MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This adds device tree support for RedBoot partitioning. We read out the FIS directory block information from the device tree and then parse the partition table from there. Signed-off-by: Linus Walleij --- drivers/mtd/parsers/redboot.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/parsers/redboot.c b/drivers/mtd/parsers/redboot.c index 7623ac5fc586..fb816825aa19 100644 --- a/drivers/mtd/parsers/redboot.c +++ b/drivers/mtd/parsers/redboot.c @@ -25,7 +25,7 @@ #include #include #include - +#include #include #include #include @@ -56,6 +56,31 @@ static inline int redboot_checksum(struct fis_image_desc *img) return 1; } +#ifdef CONFIG_OF +static void parse_redboot_of(struct mtd_info *master) +{ + struct device_node *np; + u32 dirblock; + int ret; + + np = mtd_get_of_node(master); + if (!np) + return; + ret = of_property_read_u32(np, "fis-index-block", &dirblock); + if (ret) + return; + /* + * Assign the block found in the device tree to the local + * directory block pointer. + */ + directory = dirblock; +} +#else +static void parse_redboot_of(struct mtd_info *master) +{ +} +#endif + static int parse_redboot_partitions(struct mtd_info *master, const struct mtd_partition **pparts, struct mtd_part_parser_data *data) @@ -75,6 +100,7 @@ static int parse_redboot_partitions(struct mtd_info *master, #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED static char nullstring[] = "unallocated"; #endif + parse_redboot_of(master); if ( directory < 0 ) { offset = master->size + directory * master->erasesize; @@ -289,9 +315,16 @@ static int parse_redboot_partitions(struct mtd_info *master, return ret; } +static const struct of_device_id mtd_parser_redboot_of_match_table[] = { + { .compatible = "redboot-fis" }, + {}, +}; +MODULE_DEVICE_TABLE(of, mtd_parser_trx_of_match_table); + static struct mtd_part_parser redboot_parser = { .parse_fn = parse_redboot_partitions, .name = "RedBoot", + .of_match_table = mtd_parser_redboot_of_match_table, }; module_mtd_part_parser(redboot_parser);