From patchwork Sun Dec 4 19:05:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bernhard Beschow X-Patchwork-Id: 1712091 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=20210112 header.b=e5l0A+4t; 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 4NQGgk6KBqz23yg for ; Mon, 5 Dec 2022 06:18:57 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1uKl-0001jc-LF; Sun, 04 Dec 2022 14:07:27 -0500 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 1p1uKk-0001in-76; Sun, 04 Dec 2022 14:07:26 -0500 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1uKi-0001a5-JC; Sun, 04 Dec 2022 14:07:25 -0500 Received: by mail-ej1-x62f.google.com with SMTP id qk9so5324864ejc.3; Sun, 04 Dec 2022 11:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=lMFMoTtlMr7+uTcURApX//gZTvt+E84r/Dv7wPElE8g=; b=e5l0A+4tHEoqO9ceF5Br/exmaFFAsQSeXYpYsjnzikV1GFy9bz7l84LsUJewnO3r+v VCdNldpu05Py4g/hHD+FPi861amrZknmM6P+2Z2LofSGu1pAXHaxNPb/SWLA9VTZP1eq kN+o4y+jTuRlgOt1N7g+NL9krGo01GH2tZnNamcX/zxhTEJ0Pr81eJdi4+YfxCqYNxvP 70Jmva4KFc8iokesWIjMrETHP81hVmmk/PF4BbQ5aHSInctY2FHCAiBA2fP9WP98JSNF ht7mEqYECv4eLj+7CC/O6dlJKQCpq2jRV9VPEjs6opVBYsFsUdMAJAiPufayCBdQOWpJ RcWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=lMFMoTtlMr7+uTcURApX//gZTvt+E84r/Dv7wPElE8g=; b=SekcJU1oOAGCzWO/8UKq/dmXqBH/NiqwoQim+DuMBppua8OobYcEnJUmrR48Z7XY+T qUvMPzC+3AbWPP7ygosH5ef1OBy8CocKWlXYmUr4O6F0TFGn2FaSwg/xvLHJluaDRC7w 2WamPB/AlKiWTIxB0yBgb1GDIhaomwWTuWyjePwKEzPNEUcWyHClmqS4y4IL6Wc21lRo LAJaKeDuPbcO9VjqnSXXN3K+vW57WlQEkPHGTYQPSoSzXDQ6fcozHlL4uJsXHy6TVOzW 6nJ7I220LIuVArk5GOGVRQK5dO9toG+B3N4lbGdkdC/C+Vl3U/AxYSsZhzUgkItvf/yu iPpA== X-Gm-Message-State: ANoB5plxxqeVoEsyflSMD7XyDHUY8xjOu1XRf8aNw+KnWvpSkytK17ig WiaJDhSNRKz2Gve/MQOGM87mPR2f/g8= X-Google-Smtp-Source: AA0mqf7H1myBkC6yIQim18+SOKXBEikch5X9ZUhlg+tiLJumQcS6s6UPkCUUXQ1O3hG28d14qAUOxw== X-Received: by 2002:a17:906:6a8e:b0:78d:a136:7332 with SMTP id p14-20020a1709066a8e00b0078da1367332mr66002516ejr.355.1670180841734; Sun, 04 Dec 2022 11:07:21 -0800 (PST) Received: from localhost.localdomain (dynamic-089-012-182-051.89.12.pool.telefonica.de. [89.12.182.51]) by smtp.gmail.com with ESMTPSA id j10-20020a17090623ea00b00782ee6b34f2sm5359835ejg.183.2022.12.04.11.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Dec 2022 11:07:21 -0800 (PST) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: =?utf-8?q?Herv=C3=A9_Poussineau?= , Marcel Apfelbaum , John Snow , qemu-block@nongnu.org, Igor Mammedov , Gerd Hoffmann , Aurelien Jarno , Richard Henderson , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Eduardo Habkost , Ani Sinha , Jiaxun Yang Subject: [PATCH 02/32] hw/mips/malta: Set PIIX4 IRQ routes in embedded bootloader Date: Sun, 4 Dec 2022 20:05:23 +0100 Message-Id: <20221204190553.3274-3-shentey@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221204190553.3274-1-shentey@gmail.com> References: <20221204190553.3274-1-shentey@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62f; envelope-from=shentey@gmail.com; helo=mail-ej1-x62f.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 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 From: Philippe Mathieu-Daudé Linux kernel expects the northbridge & southbridge chipsets configured by the BIOS firmware. We emulate that by writing a tiny bootloader code in write_bootloader(). Upon introduction in commit 5c2b87e34d ("PIIX4 support"), the PIIX4 configuration space included values specific to the Malta board. Set the Malta-specific IRQ routing values in the embedded bootloader, so the next commit can remove the Malta specific bits from the PIIX4 PCI-ISA bridge and make it generic (matching the real hardware). Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20221027204720.33611-3-philmd@linaro.org> --- hw/mips/malta.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/mips/malta.c b/hw/mips/malta.c index 9bffa1b128..c3dcd43f37 100644 --- a/hw/mips/malta.c +++ b/hw/mips/malta.c @@ -803,6 +803,8 @@ static void write_bootloader_nanomips(uint8_t *base, uint64_t run_addr, stw_p(p++, 0x8422); stw_p(p++, 0x9088); /* sw t0, 0x88(t1) */ + /* TODO set PIIX IRQC[A:D] routing values! */ + stw_p(p++, 0xe320 | NM_HI1(kernel_entry)); stw_p(p++, NM_HI2(kernel_entry)); @@ -840,6 +842,9 @@ static void write_bootloader_nanomips(uint8_t *base, uint64_t run_addr, static void write_bootloader(uint8_t *base, uint64_t run_addr, uint64_t kernel_entry) { + const char pci_pins_cfg[PCI_NUM_PINS] = { + 10, 10, 11, 11 /* PIIX IRQRC[A:D] */ + }; uint32_t *p; /* Small bootloader */ @@ -914,6 +919,20 @@ static void write_bootloader(uint8_t *base, uint64_t run_addr, #undef cpu_to_gt32 + /* + * The PIIX ISA bridge is on PCI bus 0 dev 10 func 0. + * Load the PIIX IRQC[A:D] routing config address, then + * write routing configuration to the config data register. + */ + bl_gen_write_u32(&p, /* GT_PCI0_CFGADDR */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0xcf8), + tswap32((1 << 31) /* ConfigEn */ + | PCI_BUILD_BDF(0, PIIX4_PCI_DEVFN) << 8 + | PIIX_PIRQCA)); + bl_gen_write_u32(&p, /* GT_PCI0_CFGDATA */ + cpu_mips_phys_to_kseg1(NULL, 0x1be00000 + 0xcfc), + tswap32(ldl_be_p(pci_pins_cfg))); + bl_gen_jump_kernel(&p, true, ENVP_VADDR - 64, /*