From patchwork Thu Jul 15 18:54:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Schwierzeck X-Patchwork-Id: 1505867 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=YilwkQJb; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GQk8V55Gjz9sWc for ; Fri, 16 Jul 2021 04:55:22 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4AE9982EA7; Thu, 15 Jul 2021 20:54:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="YilwkQJb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 2CFDC829EF; Thu, 15 Jul 2021 20:54:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 79ED382BDC for ; Thu, 15 Jul 2021 20:54:17 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=daniel.schwierzeck@gmail.com Received: by mail-ej1-x62a.google.com with SMTP id nd37so10993482ejc.3 for ; Thu, 15 Jul 2021 11:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fExQ5dd4HtVuGE+556Ls6HUmBrCEEpBShF4G8LZWUhg=; b=YilwkQJb/UB0yTCO1KJK+WzgV5CGDoQ2tHJsKymw/sy36RXRvthv9pr6UT/V6RTLZ6 uFz9sSGTXHXRTYftPnMaNWjwr/DhCydrAvajAHlARkyNOHELBkLT9uPsy9n+bkDJm8RO nZIqJWMp9VV4IoPBJVzVr4/T5K6xCsmTkB7i47IqxmoCqiPoYsrGbT/KvS9V6L+r88pK tEyAYyHkwfGMSPaCIqqqv90TReW4At3KptlwHqvVSG9V6fygK68JElm1uW9qfyLrUbIE Ba/T1RRXYhvzE7P97dhez6+O7xvEOSvvi7utcWD7JTaPjuuyt1ScLYXPPnjYPRkEQh9O Y8ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fExQ5dd4HtVuGE+556Ls6HUmBrCEEpBShF4G8LZWUhg=; b=ozskLKL9P7nYxk/fOZTMsb/3Px42aBdrAoF4y9LJPSoVWdWHBclnoaP6y6euIy3+co 156b1wPnRAZZV6/WbDoBkzaUG3uSjC9ayC0HWCydk7LWJCtGKWn46gGABfeQ7URSQfCS sdk0Seb+99oSKtZrGpAqYy5YV+B90mwDrj4IRI3VIW12S5/ksPZWSwJBl3aPQzwNYoM1 IaEHMxKnpfIUQ3ZLlEKALw8TFJIFolp4kgJCYfvMIwyp5y9YVNBTLDzKl5OQ4KbNgGvU iSEJ1aorb03z9ISnXWBif8zv/MwO8n6b3Qv7PG1LnBbKckf18Z2lBjzxjEYojIMrdEpU eZgw== X-Gm-Message-State: AOAM532dn2fNRg2/ZsR0UGp8bZWlmBesh9Fya8rcQRn4derYZQn92xvk A41Iix8x3dhUck9V5cmXighYTzeEbOs= X-Google-Smtp-Source: ABdhPJxmFBewg66L4VbSRge24e10oQiyMaulelCDOlzj9h8A5BidWCUp+gWLo6nfRlWsTO/Veh7J2w== X-Received: by 2002:a17:907:2067:: with SMTP id qp7mr7144841ejb.225.1626375257125; Thu, 15 Jul 2021 11:54:17 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io (i5E860616.versanet.de. [94.134.6.22]) by smtp.gmail.com with ESMTPSA id t17sm2803486edv.75.2021.07.15.11.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jul 2021 11:54:16 -0700 (PDT) From: Daniel Schwierzeck To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Stefan Roese , Daniel Schwierzeck Subject: [PATCH v2 5/6] MIPS: malta: add support for PCI driver model Date: Thu, 15 Jul 2021 20:54:00 +0200 Message-Id: <20210715185401.301211-6-daniel.schwierzeck@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715185401.301211-1-daniel.schwierzeck@gmail.com> References: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> <20210715185401.301211-1-daniel.schwierzeck@gmail.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean As almost all peripherals are connected via PCI dependent on the used core card, PCI setup is always required. Thus run pci_init() including PCI scanning and probing and core card specific setups in board_early_init_r(). Also prepare support for dynamically managing the status of the different PCI DT nodes dependent on used core card via option CONFIG_OF_BOARD_FIXUP. Before this feature can be enabled, the call order of the fix_fdt() init hook in board_init_f needs to be changed. Otherwise rw_fdt_blob points to a read-only NOR flash address. Thus this options needs to stay disabled until the board_init_f problem could be solved. This breaks running the default U-Boot image on real HW using the FPGA core card but Qemu emulation still works. Currently Qemu is more important as MIPS CI tests depend on Malta and the deadline for PCI DM conversion will be enforced soon. Signed-off-by: Daniel Schwierzeck --- Changes in v2: - use dm_pci_clrset_config32() where possible board/imgtec/malta/malta.c | 80 +++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/board/imgtec/malta/malta.c b/board/imgtec/malta/malta.c index c04f727961..9af1f92e5d 100644 --- a/board/imgtec/malta/malta.c +++ b/board/imgtec/malta/malta.c @@ -4,7 +4,8 @@ * Copyright (C) 2013 Imagination Technologies */ -#include +#include +#include #include #include #include @@ -24,6 +25,9 @@ DECLARE_GLOBAL_DATA_PTR; +#define MALTA_GT_PATH "/pci0@1be00000" +#define MALTA_MSC_PATH "/pci0@1bd00000" + enum core_card { CORE_UNKNOWN, CORE_LV, @@ -120,10 +124,12 @@ int checkboard(void) return 0; } +#if !IS_ENABLED(CONFIG_DM_ETH) int board_eth_init(struct bd_info *bis) { return pci_eth_init(bis); } +#endif void _machine_restart(void) { @@ -167,6 +173,77 @@ int misc_init_r(void) return 0; } +#if IS_ENABLED(CONFIG_OF_BOARD_FIXUP) +/* + * TODO: currently doesn't work because rw_fdt_blob points to a + * NOR flash address. This needs some changes in board_init_f. + */ +int board_fix_fdt(void *rw_fdt_blob) +{ + int node = -1; + + switch (malta_sys_con()) { + case SYSCON_GT64120: + node = fdt_path_offset(rw_fdt_blob, MALTA_GT_PATH); + break; + default: + case SYSCON_MSC01: + node = fdt_path_offset(rw_fdt_blob, MALTA_MSC_PATH); + break; + } + + return fdt_status_okay(rw_fdt_blob, node); +} +#endif + +#if IS_ENABLED(CONFIG_DM_PCI) +int board_early_init_r(void) +{ + struct udevice *dev; + int ret; + + pci_init(); + + ret = dm_pci_find_device(PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_82371AB_0, 0, &dev); + if (ret) + panic("Failed to find PIIX4 PCI bridge\n"); + + /* setup PCI interrupt routing */ + dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCA, 10); + dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCB, 10); + dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCC, 11); + dm_pci_write_config8(dev, PCI_CFG_PIIX4_PIRQRCD, 11); + + /* mux SERIRQ onto SERIRQ pin */ + dm_pci_clrset_config32(dev, PCI_CFG_PIIX4_GENCFG, 0, + PCI_CFG_PIIX4_GENCFG_SERIRQ); + + /* enable SERIRQ - Linux currently depends upon this */ + dm_pci_clrset_config8(dev, PCI_CFG_PIIX4_SERIRQC, 0, + PCI_CFG_PIIX4_SERIRQC_EN | PCI_CFG_PIIX4_SERIRQC_CONT); + + ret = dm_pci_find_device(PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_INTEL_82371AB, 0, &dev); + if (ret) + panic("Failed to find PIIX4 IDE controller\n"); + + /* enable bus master & IO access */ + dm_pci_clrset_config32(dev, PCI_COMMAND, 0, + PCI_COMMAND_MASTER | PCI_COMMAND_IO); + + /* set latency */ + dm_pci_write_config8(dev, PCI_LATENCY_TIMER, 0x40); + + /* enable IDE/ATA */ + dm_pci_write_config32(dev, PCI_CFG_PIIX4_IDETIM_PRI, + PCI_CFG_PIIX4_IDETIM_IDE); + dm_pci_write_config32(dev, PCI_CFG_PIIX4_IDETIM_SEC, + PCI_CFG_PIIX4_IDETIM_IDE); + + return 0; +} +#else void pci_init_board(void) { pci_dev_t bdf; @@ -231,3 +308,4 @@ void pci_init_board(void) pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_SEC, PCI_CFG_PIIX4_IDETIM_IDE); } +#endif