From patchwork Fri Feb 27 09:11:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 444222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EAF98140111 for ; Fri, 27 Feb 2015 20:12:09 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id D0BC21A0109 for ; Fri, 27 Feb 2015 20:12:09 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [103.22.144.67]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 5491D1A006F for ; Fri, 27 Feb 2015 20:11:13 +1100 (AEDT) Received: by ozlabs.org (Postfix, from userid 1023) id 3D0FA1400DD; Fri, 27 Feb 2015 20:11:13 +1100 (AEDT) MIME-Version: 1.0 Message-Id: <1425028266.817722.300394579374.5.gpush@pablo> In-Reply-To: <1425028266.816963.907799920643.0.gpush@pablo> To: skiboot@lists.ozlabs.org From: Jeremy Kerr Date: Fri, 27 Feb 2015 17:11:06 +0800 Subject: [Skiboot] [PATCH 05/13] core/flash: add /chosen/ibm, system-flash property to indicate system PNOR X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This change adds a property in /chosen: /chosen/ibm,system-flash Containing the path to the system flash device. We move the system-flash-specific setup to a new function to contain it in the one place. Signed-off-by: Jeremy Kerr --- core/flash.c | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/core/flash.c b/core/flash.c index bf6f587..2bb04f5 100644 --- a/core/flash.c +++ b/core/flash.c @@ -148,7 +148,7 @@ static void flash_add_dt_partition_node(struct dt_node *flash_node, char *name, dt_add_property_strings(part_node, "label", name); } -static void flash_add_dt_node(struct flash *flash, int id, +static struct dt_node *flash_add_dt_node(struct flash *flash, int id, struct ffs_handle *ffs) { struct dt_node *flash_node; @@ -166,7 +166,7 @@ static void flash_add_dt_node(struct flash *flash, int id, dt_add_property_cells(flash_node, "#size-cells", 1); if (!ffs) - return; + return flash_node; for (i = 0; ; i++) { uint32_t start, size; @@ -179,12 +179,38 @@ static void flash_add_dt_node(struct flash *flash, int id, flash_add_dt_partition_node(flash_node, name, start, size); } + + return flash_node; +} + +static void setup_system_flash(struct flash *flash, struct dt_node *node, + const char *name, struct ffs_handle *ffs) +{ + if (system_flash) { + prlog(PR_WARNING, "FLASH: attempted to register a second " + "system flash device %s\n", name); + return; + } + + if (!ffs) { + prlog(PR_WARNING, "FLASH: attempted to register system flash " + "%s, wwhich has no partition info\n", name); + return; + } + + system_flash = flash; + dt_add_property_string(dt_chosen, "ibm,system-flash", node->name); + + prlog(PR_INFO, "FLASH: registered system flash device %s\n", name); + + flash_nvram_probe(flash, ffs); } int flash_register(struct flash_chip *chip, bool is_system_flash) { uint32_t size, block_size; struct ffs_handle *ffs; + struct dt_node *node; struct flash *flash; const char *name; unsigned int i; @@ -224,14 +250,13 @@ int flash_register(struct flash_chip *chip, bool is_system_flash) ffs = NULL; } - flash_add_dt_node(flash, i, ffs); + node = flash_add_dt_node(flash, i, ffs); - if (is_system_flash && !system_flash) { - system_flash = flash; - flash_nvram_probe(flash, ffs); - } + if (is_system_flash) + setup_system_flash(flash, node, name, ffs); - ffs_close(ffs); + if (ffs) + ffs_close(ffs); unlock(&flash_lock);