From patchwork Thu Sep 20 13:38:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jeffery X-Patchwork-Id: 972474 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42GJV00DZ0z9sBv for ; Fri, 21 Sep 2018 00:08:08 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.b="k1yY45gT"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dIfcdZTl"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42GJTz4l2yzF3Mb for ; Fri, 21 Sep 2018 00:08:07 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.b="k1yY45gT"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dIfcdZTl"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=aj.id.au (client-ip=66.111.4.25; helo=out1-smtp.messagingengine.com; envelope-from=andrew@aj.id.au; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=aj.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=aj.id.au header.i=@aj.id.au header.b="k1yY45gT"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="dIfcdZTl"; dkim-atps=neutral Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42GHs25R74zF3J9 for ; Thu, 20 Sep 2018 23:39:34 +1000 (AEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 84E0921F6B; Thu, 20 Sep 2018 09:39:32 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 20 Sep 2018 09:39:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aj.id.au; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=q0+1XUgiGmF+jeCy9 4PhooNKpASrPgEhn4yR7uo3UCs=; b=k1yY45gTfwdHlueWHhDzCQcEjSMvDSDom i3MofvO9chpRr6ElUSdua+/9oRoieNcWLsN/WcWMRNCzw9rukbofvXsVdyUsgR17 4/ev+4G9lLdJcHDs+8MuN3eXvBDpS7S4qNSrC+WJ4a3xAXJkIuVhvhg4Tv5/E4LB 2k2lcgR0VX4LIX/qfx7m2y5/MuJCKT6y7KxRyt6LKDUbB3RNv7v3KpKfV87w2Uys EPe3DLoda7QJUWzXX9zSS7i+9PvkqiAEeC6Gc3Uev4tFNDBWyXOagmVIi+FTu+Sr SbzyBdWC0C9QRJDHQh97BveET9eiGGi2SloZkCr+Ax3aMnfW6kFWg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=q0+1XUgiGmF+jeCy94PhooNKpASrPgEhn4yR7uo3UCs=; b=dIfcdZTl 4MdnDGFdZJ4Gt9vawVtMoXaPapjJjUuG6atIGbE4ACB71mKoBleaOxHtZyU5Z0iy k3PPvblFQlvb+25xyGoTp8A1BqMY6c8/LWZcmT3j0ahWRVI1jeEncy68b+hyFIbB 0gvJPVc6fi3sxEmxYfgonBKgjRqLXVPnpI3pMxUmkx6wOcF3ctZYlz7wtaXLTq3f N+NsuCzE/GC1Iw87wOUKhskBDLbJC613qQqJrNBFMv2kusmBLBKANvPcjzbhaqFe Bt1hGq+beas9S5IXtCRw3m2VC9h3OL+8n2DU4Qt3HuFcTpzt7u9tcadc8U1QiG+H mVGlrfeMQUXVQA== X-ME-Proxy: X-ME-Sender: Received: from dave.ibm.com (ppp118-210-231-68.bras1.adl4.internode.on.net [118.210.231.68]) by mail.messagingengine.com (Postfix) with ESMTPA id AA0A4E4121; Thu, 20 Sep 2018 09:39:29 -0400 (EDT) From: Andrew Jeffery To: skiboot@lists.ozlabs.org Date: Thu, 20 Sep 2018 23:08:56 +0930 Message-Id: <20180920133856.20798-7-andrew@aj.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180920133856.20798-1-andrew@aj.id.au> References: <20180920133856.20798-1-andrew@aj.id.au> Subject: [Skiboot] [PATCH 6/6] astbmc: Prefer ipmi-flash for PNOR access X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dkodihal@in.ibm.com, Andrew Jeffery , anoo@linux.ibm.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" If the IPMI command is not available, fall back to the mailbox interface. Signed-off-by: Andrew Jeffery --- hw/ast-bmc/ast-io.c | 10 +++++++--- include/ast.h | 4 ++-- platforms/astbmc/common.c | 8 ++++++-- platforms/astbmc/pnor.c | 42 +++++++++++++++++++++++++++++---------- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/hw/ast-bmc/ast-io.c b/hw/ast-bmc/ast-io.c index a6ae85a4d24f..e8258b4cfc02 100644 --- a/hw/ast-bmc/ast-io.c +++ b/hw/ast-bmc/ast-io.c @@ -426,12 +426,16 @@ bool ast_io_init(void) return ast_io_is_rw(); } -bool ast_lpc_fw_is_mbox(void) +bool ast_lpc_fw_needs_hiomap(void) { - return dt_find_compatible_node(dt_root, NULL, "mbox"); + struct dt_node *n; + + n = dt_find_compatible_node(dt_root, NULL, "mbox"); + + return n != NULL; } -bool ast_lpc_fw_is_flash(void) +bool ast_lpc_fw_maps_flash(void) { uint8_t boot_version; uint8_t boot_flags; diff --git a/include/ast.h b/include/ast.h index b30f7bf27737..4c8fd817b253 100644 --- a/include/ast.h +++ b/include/ast.h @@ -86,8 +86,8 @@ bool ast_can_isolate_sp(void); bool ast_sio_disable(void); bool ast_io_init(void); bool ast_io_is_rw(void); -bool ast_lpc_fw_is_flash(void); -bool ast_lpc_fw_is_mbox(void); +bool ast_lpc_fw_maps_flash(void); +bool ast_lpc_fw_needs_hiomap(void); bool ast_scratch_reg_is_mbox(void); /* UART configuration */ diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index 23550ef37a67..ced38bc3374f 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -120,11 +120,15 @@ static int astbmc_fru_init(void) void astbmc_init(void) { + /* Register the BT interface with the IPMI layer + * + * Initialise this first to enable PNOR access + */ + bt_init(); + /* Initialize PNOR/NVRAM */ pnor_init(); - /* Register the BT interface with the IPMI layer */ - bt_init(); /* Initialize elog */ elog_init(); ipmi_sel_init(); diff --git a/platforms/astbmc/pnor.c b/platforms/astbmc/pnor.c index 55784ee4594f..d2694768e330 100644 --- a/platforms/astbmc/pnor.c +++ b/platforms/astbmc/pnor.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -26,16 +27,27 @@ #include "astbmc.h" +enum ast_flash_style { + raw_flash, + raw_mem, + ipmi_hiomap, + mbox_hiomap, +}; + int pnor_init(void) { struct spi_flash_ctrl *pnor_ctrl = NULL; struct blocklevel_device *bl = NULL; + enum ast_flash_style style; int rc; - bool do_mbox; - do_mbox = ast_lpc_fw_is_mbox(); - if (do_mbox) { - rc = mbox_flash_init(&bl); + if (ast_lpc_fw_needs_hiomap()) { + style = ipmi_hiomap; + rc = ipmi_hiomap_init(&bl); + if (rc) { + style = mbox_hiomap; + rc = mbox_flash_init(&bl); + } } else { /* Open controller and flash. If the LPC->AHB doesn't point to * the PNOR flash base we assume we're booting from BMC system @@ -43,10 +55,12 @@ int pnor_init(void) * FW reads & writes). */ - if (ast_lpc_fw_is_flash()) + if (ast_lpc_fw_maps_flash()) { + style = raw_flash; rc = ast_sf_open(AST_SF_TYPE_PNOR, &pnor_ctrl); - else { + } else { printf("PLAT: Memboot detected\n"); + style = raw_mem; rc = ast_sf_open(AST_SF_TYPE_MEM, &pnor_ctrl); } if (rc) { @@ -66,12 +80,20 @@ int pnor_init(void) if (!rc) return 0; - fail: +fail: if (bl) { - if (do_mbox) - mbox_flash_exit(bl); - else + switch (style) { + case raw_flash: + case raw_mem: flash_exit(bl); + break; + case ipmi_hiomap: + ipmi_hiomap_exit(bl); + break; + case mbox_hiomap: + mbox_flash_exit(bl); + break; + } } if (pnor_ctrl) ast_sf_close(pnor_ctrl);