From patchwork Thu Nov 12 17:23:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 543560 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 05D671402A9 for ; Fri, 13 Nov 2015 04:23:46 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id E73B71A0D02 for ; Fri, 13 Nov 2015 04:23:45 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e06smtp06.uk.ibm.com (e06smtp06.uk.ibm.com [195.75.94.102]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id E23A41A0CA7 for ; Fri, 13 Nov 2015 04:23:23 +1100 (AEDT) Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Nov 2015 17:23:18 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp06.uk.ibm.com (192.168.101.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Nov 2015 17:23:17 -0000 X-IBM-Helo: d06dlp01.portsmouth.uk.ibm.com X-IBM-MailFrom: clg@fr.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3F0CD17D8059 for ; Thu, 12 Nov 2015 17:23:36 +0000 (GMT) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tACHNGY551380260 for ; Thu, 12 Nov 2015 17:23:16 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tACHNFT0005982 for ; Thu, 12 Nov 2015 10:23:16 -0700 Received: from hermes.lab.toulouse-stg.fr.ibm.com (hermes.lab.toulouse-stg.fr.ibm.com [9.101.4.42]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tACHNFRI005965; Thu, 12 Nov 2015 10:23:15 -0700 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: skiboot@lists.ozlabs.org Date: Thu, 12 Nov 2015 18:23:07 +0100 Message-Id: <1447348987-2387-1-git-send-email-clg@fr.ibm.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111217-0025-0000-0000-000004E33272 Subject: [Skiboot] [RFC PATCH] plat/qemu: Add BT device X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 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 adds the BT device used to communicate with the BMC. This is sufficient to handle IPMI messaging, power_downs and reboots the way openpower systems do it. This patch needs to run on Ben's tree adding the support for the PowerNV platform in qemu, plus some patches of mine. You will find the resulting tree here : https://github.com/legoater/qemu/tree/powernv It's basic, probably a little too hacky, but it does provide enough of a framework to handle communication with the BMC. Is it something we want to add to qemu ? Comments welcome. Thanks, C. Signed-off-by: Cédric Le Goater --- hw/bt.c | 8 +++++++ platforms/qemu/qemu.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) Index: skiboot.git/platforms/qemu/qemu.c =================================================================== --- skiboot.git.orig/platforms/qemu/qemu.c +++ skiboot.git/platforms/qemu/qemu.c @@ -21,6 +21,13 @@ #include #include #include +#include +#include + +/* BT config */ +#define BT_IO_BASE 0xe4 +#define BT_IO_COUNT 3 +#define BT_LPC_IRQ 10 static void qemu_init(void) { @@ -32,6 +39,33 @@ static void qemu_init(void) * chiptod_init() */ lpc_rtc_init(); + bt_init(); +} + +static void qemu_dt_fixup_bt(struct dt_node *lpc) +{ + struct dt_node *bt; + char namebuf[32]; + + /* First check if the BT interface is already there */ + dt_for_each_child(lpc, bt) { + if (dt_node_is_compatible(bt, "bt")) + return; + } + + snprintf(namebuf, sizeof(namebuf), "ipmi-bt@i%x", BT_IO_BASE); + bt = dt_new(lpc, namebuf); + + dt_add_property_cells(bt, "reg", + 1, /* IO space */ + BT_IO_BASE, BT_IO_COUNT); + dt_add_property_strings(bt, "compatible", "ipmi-bt"); + + /* Mark it as reserved to avoid Linux trying to claim it */ + dt_add_property_strings(bt, "status", "reserved"); + + dt_add_property_cells(bt, "interrupts", BT_LPC_IRQ); + dt_add_property_cells(bt, "interrupt-parent", lpc->phandle); } static void qemu_dt_fixup_uart(struct dt_node *lpc) @@ -113,6 +147,7 @@ static void qemu_dt_fixup(void) qemu_dt_fixup_rtc(primary_lpc); qemu_dt_fixup_uart(primary_lpc); + qemu_dt_fixup_bt(primary_lpc); } static void qemu_ext_irq_serirq_cpld(unsigned int chip_id) @@ -120,6 +155,21 @@ static void qemu_ext_irq_serirq_cpld(uns lpc_all_interrupts(chip_id); } +static int64_t qemu_ipmi_power_down(uint64_t request) +{ + if (request != IPMI_CHASSIS_PWR_DOWN) { + prlog(PR_WARNING, "PLAT: unexpected shutdown request %llx\n", + request); + } + + return ipmi_chassis_control(request); +} + +static int64_t qemu_ipmi_reboot(void) +{ + return ipmi_chassis_control(IPMI_CHASSIS_HARD_RESET); +} + static bool qemu_probe(void) { if (!dt_node_is_compatible(dt_root, "qemu,powernv")) @@ -145,4 +195,7 @@ DECLARE_PLATFORM(qemu) = { .probe = qemu_probe, .init = qemu_init, .external_irq = qemu_ext_irq_serirq_cpld, + .cec_power_down = qemu_ipmi_power_down, + .cec_reboot = qemu_ipmi_reboot, + .terminate = ipmi_terminate, };