Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E013C07E9A for ; Tue, 13 Jul 2021 01:17:29 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C499C61154 for ; Tue, 13 Jul 2021 01:17:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C499C61154 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D292582E3F; Tue, 13 Jul 2021 03:17:26 +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="KfNYq02G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 98BDC82E48; Tue, 13 Jul 2021 03:17:24 +0200 (CEST) Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) (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 997AD82E41 for ; Tue, 13 Jul 2021 03:17:21 +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-wm1-x32d.google.com with SMTP id g12so4691191wme.2 for ; Mon, 12 Jul 2021 18:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:subject:from:to:cc:date:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=eyqnHOtMTTow/awSrVoB8aQSV7n6B/Cdq6eyvZpOKoU=; b=KfNYq02GEikmxdQCmQbcOyIk83KXyKG9pFCexYB3ntXW1EDk2g3omfKJHscPaWLao4 T7VTqQzMjrQOa07h6/aepQKFTJCJV/X+7L4uPk4uYqZu36LQckH4ZddxO/2RPL6nt66v D4nuh7qFQVLanmFTHj4NjjTwNf3BDTojgkdR7y2gNPUFVunkUBbMJ8jo3hEzPwM+AhI2 bZdpoPlYZizKCwv9YD/Nll7GP897OZN/wDNaEAzd4dtc21LTvyH5dQ0r5KyPElu87CEd MvGMWgjvGQt7aONQatA+0r/SPvw81AT/0p5QpKIeIZRXnDZgLmVHKa7Tq0UDQvfxEQ/w kO1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=eyqnHOtMTTow/awSrVoB8aQSV7n6B/Cdq6eyvZpOKoU=; b=Px/3IfvjxpdtL3wPTBtGjl4ZTyey4XCWqdrJsrER8FfKz6yVrlXdXDPzHUNBWYtevL vMwFvDqio2VjogvjHZvtqwZvLu0XIcvdk+i2jbsYv5REHv96jTrIknNgeh3OGMjWSRGL UVx6WZIog4ZwdGOrL7ftW2fts6Ej9hhPOQXh17ZopbPYMB9b6zOu2ulP+YNz2xCVlQLS a9hFxoT4g97JXlDV5UIxNli7vbEFdk80IhGaeWbdc/V/5ZAYH1fm28X6rBQ/l3qe3HRz HhxTqWratIxBN+fBaw4zKbAebStRvvjQSC3U9RNHQKmQrGp6ntOiNi1ymyA+gOVNJmwf 1j6Q== X-Gm-Message-State: AOAM531MZ8zIlDrygr1qO8vleC0rqQxIbspiceDohKab1cjgH5KxZbUZ WFF98ewqjtyMnlMvPtyFBTw= X-Google-Smtp-Source: ABdhPJxDglRN7W/6/mQUWAqSNlxfzWl/ZL2jEvrXq11MXhye7aJpzcNMUuyV4I7h2cBJbSTXpvGVTw== X-Received: by 2002:a1c:1d8e:: with SMTP id d136mr2041534wmd.52.1626139040995; Mon, 12 Jul 2021 18:17:20 -0700 (PDT) Received: from workstation.lan.schwierd.dedyn.io (i5E860710.versanet.de. [94.134.7.16]) by smtp.googlemail.com with ESMTPSA id b16sm16500080wrs.51.2021.07.12.18.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jul 2021 18:17:20 -0700 (PDT) Message-ID: Subject: Re: [PATCH 5/6] MIPS: malta: add support for PCI driver model From: Daniel Schwierzeck To: Simon Glass Cc: U-Boot Mailing List , Stefan Roese , Tom Rini Date: Tue, 13 Jul 2021 03:17:18 +0200 In-Reply-To: References: <20210706142222.497569-1-daniel.schwierzeck@gmail.com> <20210706142222.497569-6-daniel.schwierzeck@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 Hi Simon, Am Samstag, den 10.07.2021, 18:00 -0600 schrieb Simon Glass: > () Hi Daniel, > > On Tue, 6 Jul 2021 at 08:22, Daniel Schwierzeck > wrote: > > 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 > > --- > > > > board/imgtec/malta/malta.c | 84 > > +++++++++++++++++++++++++++++++++++++- > > 1 file changed, 83 insertions(+), 1 deletion(-) > > > > diff --git a/board/imgtec/malta/malta.c > > b/board/imgtec/malta/malta.c > > index c04f727961..e78d5a7fbc 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,81 @@ 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, > ); > > + 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; > > + u32 val32; > > + u8 val8; > > + int ret; > > + > > + pci_init(); > > + > > + ret = dm_pci_find_device(PCI_VENDOR_ID_INTEL, > > + PCI_DEVICE_ID_INTEL_82371AB_0, 0, > > &dev); > > This feels a bit wonky to me. How about a sysinfo driver for your > board which does this init? Then you could just probe it. > > As to finding PCI devices, your sysinfo driver could have a few > phandle properties to point to the two devices you need. > > But if these are really SYSCON devices, why not use the SYSCON > devices, give them a unique ID (perhaps you already have with > SYSCON_MSC01) and then call syscon_get_regmap_by_driver_data() ? This is just a reimplementation of the original pci_init_board() function. I wanted to keep the changes small and to keep the original PCI init behaviour to get the PCI DM conversion done and get this patch series merged in this merge window ;) The Malta board is the reference board for MIPS Qemu and essential for testing and U-Boot CI. Therefore it would be very bad if it gets removed due to the PCI DM conversion deadline. I already tried to add PIIX4 IRQ and ATA drivers for this init code. But those drivers were just bound and I didn't have an idea how to trigger a probe. I will look into it again with the next patch series for removing all non-DM code. > > > > + 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); > > This feels like it should be in DT. > > I don't know if this is at all similar to x86, but see > create_pirq_routing_table() and intel,irq-router.txt for some ideas. > > > + > > + /* mux SERIRQ onto SERIRQ pin */ > > + dm_pci_read_config32(dev, PCI_CFG_PIIX4_GENCFG, &val32); > > + val32 |= PCI_CFG_PIIX4_GENCFG_SERIRQ; > > + dm_pci_write_config32(dev, PCI_CFG_PIIX4_GENCFG, val32); > > + > > dm_pci_clrset_config32() can do these three in one line, similar > below. I'll fix it > > > > + /* enable SERIRQ - Linux currently depends upon this */ > > + dm_pci_read_config8(dev, PCI_CFG_PIIX4_SERIRQC, &val8); > > + val8 |= PCI_CFG_PIIX4_SERIRQC_EN | > > PCI_CFG_PIIX4_SERIRQC_CONT; > > + dm_pci_write_config8(dev, PCI_CFG_PIIX4_SERIRQC, val8); > > + > > + 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 */ > > + val32 |= PCI_COMMAND_MASTER | PCI_COMMAND_IO; > > + dm_pci_write_config32(dev, PCI_COMMAND, val32); > > + > > + /* 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 +312,4 @@ void pci_init_board(void) > > pci_write_config_dword(bdf, PCI_CFG_PIIX4_IDETIM_SEC, > > PCI_CFG_PIIX4_IDETIM_IDE); > > } > > +#endif > > -- > > 2.32.0 > > > > Regards, > Simon -- - Daniel