From patchwork Fri Jan 30 00:31:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 434691 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 AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6CE7E1400B7 for ; Fri, 30 Jan 2015 11:32:30 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by lists.ozlabs.org (Postfix) with ESMTP id 5193B1A0D8D for ; Fri, 30 Jan 2015 11:32:30 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pa0-x235.google.com (mail-pa0-x235.google.com [IPv6:2607:f8b0:400e:c03::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 8ABD51A0CFA for ; Fri, 30 Jan 2015 11:32:26 +1100 (AEDT) Received: by mail-pa0-f53.google.com with SMTP id kx10so45056998pab.12 for ; Thu, 29 Jan 2015 16:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0OjGVIQVLN14WwutTW2hbf/QWU++D6+m8CU2G1KsDBc=; b=ByixRiHYKAdzC5VxrQgCu+QnnQpUdpXWMO/Oijtujv/4OqhB3lp7URXFSNSCrZ/d1c qJ8a8bxTm1oKbp+nwJeXeWF02mXKmnucTdobdcgMGLEpVQ7km9+N7wlbzZIKoHOwYLh0 P3ruJ54pmF7neWUwelt4msEqnkZejJhZdUpwA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=0OjGVIQVLN14WwutTW2hbf/QWU++D6+m8CU2G1KsDBc=; b=YQ9wFZ+0tiaM9UWj/EfjACV0XI7xqclR/vm9xCJQXvI6g9w/UGViAy5BtLf0w9WRbW edem/PlnX9Q7mU2l5n1HJK4l4JQXVylMTpZiyv87x/hy8EFPC1TTJpZfrN+sCB1UMOKz FI2rfXQA7kRGbjIjzwnWLA7YjgROn9eTry8FmxbXi/GU6BMUCUZxUsM0tSbXn5ewzf2P NaUZUsbdfs9BESVm//nKt8kZsxG4AavOCeRHA1Nh3LtmCAAhLmZqhg9tDD6BWN5Rlfvv A71YCF/v1Uq6eAV1nE/2BWEH4KImTdM4GyCHXbSko8haUL4DK3A8Z/jiuR8TZ7rzNh2S Puqg== X-Gm-Message-State: ALoCoQmltQMpfIUpnEa5zMLNZKjaOrZWIxGLKlsV96IdWWd94pV33SEROAvfuSbrmQwEoc5hGTUF X-Received: by 10.67.6.103 with SMTP id ct7mr4770627pad.49.1422577944872; Thu, 29 Jan 2015 16:32:24 -0800 (PST) Received: from icarus.au.ibm.com (ppp121-45-7-169.lns20.adl2.internode.on.net. [121.45.7.169]) by mx.google.com with ESMTPSA id ca2sm8864916pbc.68.2015.01.29.16.32.21 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 16:32:24 -0800 (PST) From: Joel Stanley To: skiboot@lists.ozlabs.org Date: Fri, 30 Jan 2015 11:01:48 +1030 Message-Id: <1422577911-18394-3-git-send-email-joel@jms.id.au> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1422577911-18394-1-git-send-email-joel@jms.id.au> References: <1422577911-18394-1-git-send-email-joel@jms.id.au> Subject: [Skiboot] [PATCH 2/5] ipmi: Set BMC Global Enables to enable notifications 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: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" For OEM events including graceful power down and BMC PNOR access we want to receive notification whenever a message is ready to be read from the BMC. This requires the Event Message Buffer flag to be enabled. This is the equivalent of doing mc setenables event_msg=on with ipmitool, except the message must come from the BT interface in order to have permission to modify the flags. Signed-off-by: Joel Stanley --- include/ipmi.h | 2 ++ platforms/astbmc/common.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/ipmi.h b/include/ipmi.h index 2e1e5f0..048e6cf 100644 --- a/include/ipmi.h +++ b/include/ipmi.h @@ -102,6 +102,8 @@ #define IPMI_CHASSIS_CONTROL IPMI_CODE(IPMI_NETFN_CHASSIS, 0x02) #define IPMI_SET_POWER_STATE IPMI_CODE(IPMI_NETFN_APP, 0x06) #define IPMI_GET_POWER_STATE IPMI_CODE(IPMI_NETFN_APP, 0x07) +#define IPMI_SET_ENABLES IPMI_CODE(IPMI_NETFN_APP, 0x2E) +#define IPMI_GET_ENABLES IPMI_CODE(IPMI_NETFN_APP, 0x2F) #define IPMI_CLEAR_MESSAGE_FLAGS IPMI_CODE(IPMI_NETFN_APP, 0x30) #define IPMI_GET_MESSAGE_FLAGS IPMI_CODE(IPMI_NETFN_APP, 0x31) #define IPMI_GET_MESSAGE IPMI_CODE(IPMI_NETFN_APP, 0x33) diff --git a/platforms/astbmc/common.c b/platforms/astbmc/common.c index f9c988d..68df2bb 100644 --- a/platforms/astbmc/common.c +++ b/platforms/astbmc/common.c @@ -44,6 +44,52 @@ void astbmc_ext_irq(unsigned int chip_id __unused) bt_irq(); } +static void astbmc_ipmi_error(struct ipmi_msg *msg) +{ + prlog(PR_DEBUG, "ASTBMC: error sending msg. cc = %02x\n", msg->cc); + + ipmi_free_msg(msg); +} + +static void astbmc_ipmi_setenables(void) +{ + struct ipmi_msg *msg; + + struct { + uint8_t oem2_en : 1; + uint8_t oem1_en : 1; + uint8_t oem0_en : 1; + uint8_t reserved : 1; + uint8_t sel_en : 1; + uint8_t msgbuf_en : 1; + uint8_t msgbuf_full_int_en : 1; + uint8_t rxmsg_queue_int_en : 1; + } data; + + /* TODO: The spec says we need to read-modify-write to not clobber + * the state of the other flags */ + memset(&data, 0, sizeof(data)); + + /* These are set on by the bmc */ + data.rxmsg_queue_int_en = 1; + data.sel_en = 1; + + /* These are the ones we want to set on */ + data.msgbuf_en = 1; + + msg = ipmi_mkmsg_simple(IPMI_SET_ENABLES, &data, sizeof(data)); + if (!msg) { + prlog(PR_ERR, "ASTBMC: failed to set enables\n"); + return; + } + + msg->error = astbmc_ipmi_error; + + ipmi_queue_msg(msg); + +} + + void astbmc_init(void) { /* Initialize PNOR/NVRAM */ @@ -59,6 +105,9 @@ void astbmc_init(void) /* As soon as IPMI is up, inform BMC we are in "S0" */ ipmi_set_power_state(IPMI_PWR_SYS_S0_WORKING, IPMI_PWR_NOCHANGE); + /* Enable IPMI OEM message interrupts */ + astbmc_ipmi_setenables(); + /* Setup UART console for use by Linux via OPAL API */ if (!dummy_console_enabled()) uart_setup_opal_console();