From patchwork Sat Apr 22 15:07:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1772303 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=Uiq7ApnD; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q3ZZn2HsVz23tD for ; Sun, 23 Apr 2023 01:10:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqEq1-0001rO-Uq; Sat, 22 Apr 2023 11:07:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqEpz-0001nf-Mi; Sat, 22 Apr 2023 11:07:43 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pqEpw-000596-KI; Sat, 22 Apr 2023 11:07:42 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-94a34d3812cso480632566b.2; Sat, 22 Apr 2023 08:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682176058; x=1684768058; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+EWP4yPmLtvO9JWiKUeH2VsYNoRmYM/ETrmN3+B7dEc=; b=Uiq7ApnD0hq+bd49pePFUZxZa1lvJoIMjzszv5MPjMUKqmYfIlKrLK+tLKZadYpTIl svTifgiyY8R7jfPSbwbyhxPtefdKaxn6OOCf+Bky11WMboOMB1TQoBXQcdnV01MsmNNT /k0wjaUa16Pag61vNoq/SNTreZJyB0vJ+QdazjVXUh3phPObH8j3Sl4m3Gbsh45Lsj7O zx8GM9O7aIykvkavevEzhQYlX1IMZnkQ5KoO/X/9eIJ9A51HggRBlUqZMxjiWQJUSnDp Ilk/WBnVDJiAzdEzU5DcDb7AvHnixpq31F0YlEhoD8TCG7wFDI2VwwPQp11Zx5xdbiYv FgNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682176058; x=1684768058; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+EWP4yPmLtvO9JWiKUeH2VsYNoRmYM/ETrmN3+B7dEc=; b=YJBE1wmofKXrbCRxYxqNNMypxddwFoSa8AUxP3T74V90JYH7WzrPAJsbLBFvqlHt7k CS+Ss4ly+RwpY9evHylwO3do1HbWAd0DbjjcVXUm4cWhHrSMLohjOFUM/2yoTY4lMdor UV7q+JbqOgOymPrBZDbTi7HIs+xnvwqzvya04rv4esLVMFKfRxhmNBeMzKMA8ZLBGfyl 3Jj/z40cCjmus14aQhtzTeyrvnoV3GO9mUzJ5Df/08YX+qAW/0/TL4mPiKiq7ZJT76N/ +OIEb8hBJLrW/1Wg+HnGlGL+v5kboUJW06m+zDX7/ATVgTo+k3lctBx5ppaGhNrnpM1R OFhQ== X-Gm-Message-State: AAQBX9eMIHKF8rEZdXCK3vg2SOW2J12uHTY5Q0cB2AaqxARKUPwp1PX+ tBuJqV2ObJ9hAP/4hNvpqKatTdF8xAg= X-Google-Smtp-Source: AKy350aFg6fqL8mrGqM2OXU2Zs3QnWkYQ00LQ/DDwILWvKzccHcg8V7kb7pim/6ZJXft4RRfzkQNWA== X-Received: by 2002:a17:906:1907:b0:958:cc8:bd55 with SMTP id a7-20020a170906190700b009580cc8bd55mr2169339eje.0.1682176057798; Sat, 22 Apr 2023 08:07:37 -0700 (PDT) Received: from Provence.localdomain (dynamic-077-191-017-015.77.191.pool.telefonica.de. [77.191.17.15]) by smtp.gmail.com with ESMTPSA id e7-20020a170906844700b0094f7b713e40sm3300108ejy.126.2023.04.22.08.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 08:07:37 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Jiaxun Yang , BALATON Zoltan , John Snow , Huacai Chen , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Bernhard Beschow Subject: [PATCH 02/13] hw/ide/via: Implement ISA IRQ routing Date: Sat, 22 Apr 2023 17:07:17 +0200 Message-Id: <20230422150728.176512-3-shentey@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230422150728.176512-1-shentey@gmail.com> References: <20230422150728.176512-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=shentey@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The VIA south bridge allows the legacy IDE interrupts to be routed to four different ISA interrupts. This can be configured through the 0x4a register in the PCI configuration space of the ISA function. The default routing matches the legacy ISA IRQs, that is 14 and 15. Implement this missing piece of the VIA south bridge. Signed-off-by: Bernhard Beschow Reviewed-by: Mark Cave-Ayland --- hw/ide/via.c | 6 ++++-- hw/isa/vt82c686.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/hw/ide/via.c b/hw/ide/via.c index 177baea9a7..0caae52276 100644 --- a/hw/ide/via.c +++ b/hw/ide/via.c @@ -31,6 +31,7 @@ #include "sysemu/dma.h" #include "hw/isa/vt82c686.h" #include "hw/ide/pci.h" +#include "hw/irq.h" #include "trace.h" static uint64_t bmdma_read(void *opaque, hwaddr addr, @@ -104,7 +105,8 @@ static void bmdma_setup_bar(PCIIDEState *d) static void via_ide_set_irq(void *opaque, int n, int level) { - PCIDevice *d = PCI_DEVICE(opaque); + PCIIDEState *s = opaque; + PCIDevice *d = PCI_DEVICE(s); if (level) { d->config[0x70 + n * 8] |= 0x80; @@ -112,7 +114,7 @@ static void via_ide_set_irq(void *opaque, int n, int level) d->config[0x70 + n * 8] &= ~0x80; } - via_isa_set_irq(pci_get_function_0(d), 14 + n, level); + qemu_set_irq(s->isa_irq[n], level); } static void via_ide_reset(DeviceState *dev) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index ca89119ce0..c7e29bb46a 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -568,9 +568,19 @@ static const VMStateDescription vmstate_via = { } }; +static void via_isa_set_ide_irq(void *opaque, int n, int level) +{ + static const uint8_t irqs[] = { 14, 15, 10, 11 }; + ViaISAState *s = opaque; + uint8_t irq = irqs[(s->dev.config[0x4a] >> (n * 2)) & 0x3]; + + qemu_set_irq(s->isa_irqs_in[irq], level); +} + static void via_isa_init(Object *obj) { ViaISAState *s = VIA_ISA(obj); + DeviceState *dev = DEVICE(s); object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC); object_initialize_child(obj, "ide", &s->ide, TYPE_VIA_IDE); @@ -578,6 +588,8 @@ static void via_isa_init(Object *obj) object_initialize_child(obj, "uhci2", &s->uhci[1], TYPE_VT82C686B_USB_UHCI); object_initialize_child(obj, "ac97", &s->ac97, TYPE_VIA_AC97); object_initialize_child(obj, "mc97", &s->mc97, TYPE_VIA_MC97); + + qdev_init_gpio_in_named(dev, via_isa_set_ide_irq, "ide", ARRAY_SIZE(s->ide.isa_irq)); } static const TypeInfo via_isa_info = { @@ -692,6 +704,10 @@ static void via_isa_realize(PCIDevice *d, Error **errp) if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) { return; } + for (i = 0; i < 2; i++) { + qdev_connect_gpio_out(DEVICE(&s->ide), i, + qdev_get_gpio_in_named(DEVICE(s), "ide", i)); + } /* Functions 2-3: USB Ports */ for (i = 0; i < ARRAY_SIZE(s->uhci); i++) { @@ -814,6 +830,7 @@ static void vt8231_isa_reset(DeviceState *dev) PCI_COMMAND_MASTER | PCI_COMMAND_SPECIAL); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); + pci_conf[0x4a] = 0x04; /* IDE interrupt Routing */ pci_conf[0x58] = 0x40; /* Miscellaneous Control 0 */ pci_conf[0x67] = 0x08; /* Fast IR Config */ pci_conf[0x6b] = 0x01; /* Fast IR I/O Base */