Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2875596lqt; Tue, 23 Apr 2024 04:34:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWsOuWIPBJKVVYWiWGXmdxjt9B1QZa0FHyL78tFl8CiH5RfNWasRvBLZa05Y25XHPS/dHFXzmqa+euZ2eKGDd4/ezY2137T508FLl6uow== X-Google-Smtp-Source: AGHT+IHiN7Ok6hGxkfMo8q2pEkn4xy5eW3NmjJbPg9+nESLCS8QPKXPtm/CQ2siNLXM5of/u9LRW X-Received: by 2002:a05:6358:190b:b0:183:c2e4:a981 with SMTP id w11-20020a056358190b00b00183c2e4a981mr13910899rwm.31.1713872099331; Tue, 23 Apr 2024 04:34:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713872099; cv=pass; d=google.com; s=arc-20160816; b=YkbCsAg21XdrNJhP4Q4O2WZwQtmIIRkFsVz6oqxhGB3D2UFEEqJe3WDGh0FGYqaL50 tbYUb991GpTzuDzRROSOVx8Qjf/rZsRXnvWQ+krjOUkI3kQadlicIj68LyY1aU988Ll/ 50UcQVe6QJfY2oOLcEaQltH3o4gMTvccay14qnUjf2ffy6aSX/EFakkWcv171BwqJ5lO Hs7OyN6OpVZ81BNDmbHchU+yM3QqHRivvx9m/o0aJly7pJjYDay5/4S1tQfBtvDRRLBC Ijlu2a496cLN2py3JVxmkpgu/WrSy4An8xKPWhzNOWqt95gCPWlduzXwVU6Bkef2UT3S eFNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date:dkim-signature; bh=8HXsXyT41e7zXu4VpcQhDNhTQBKrNWOKL68FJq5fIo4=; fh=2yudnfhDFhsG/gEgR422OI3VmX1cKgQuA1qjM71tPlg=; b=Kp7BXVXXWBL1vCb/IZSL7eYcQD/DR14Vl+veeWOqt2dyJHzqFmVmb15S6f1jml6tFC 46bMbS/MQoizKQB/SoH21ioO+l/a1myMi+L16lz7OqRrF0VFSQhea4d2vV30zknz7eUd 0U156JiMQ6BIS6aQ5PT4raL5feraEaMybvXbvhLtygd/flx90BhWNqWuhC1NQbVfXe4/ kQLTtdyEC4IyZbsiWoZkbBW5XGmd7gmFoL7B21c/SxCjppkrhE1+Qk/MsYgYkZCOpLKH YLwe5XUrmVw6N0dWDR1oRgP0jTO3g4opNelG2paBlG9VQFoVIy2TP8QvBCL770cdelfV 4/4w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JiafY+vV; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-154997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154997-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t2-20020a05622a180200b004364e0e1457si12334186qtc.393.2024.04.23.04.34.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 04:34:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=JiafY+vV; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-154997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154997-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id EFA6D1C22AED for ; Tue, 23 Apr 2024 11:34:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82E2384A40; Tue, 23 Apr 2024 11:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="JiafY+vV" Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFB4180028; Tue, 23 Apr 2024 11:33:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713871995; cv=none; b=nfll/xw5OBZm7Dj0B4poevKbjTbIJB8nAiVMHSUCyVtPpq4mNhTacQxmoGQAHNj+9+C1mP9X3lNPrDAHS05L8sCsHmM6uCDvs4V7NhNwk6aAGnvP3oxdKmShyrdPuYI526+7l0JsU0AtVjITAhWJYkX8Bl3PhjW6nUlr19OmJBM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713871995; c=relaxed/simple; bh=WalPArk47tvAzrWfweu0jQS5mtmWIAjNBiO2qe7qn8Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=oNJKDkF6gamt5VW81heA2I/u8HgoMCV39FOvgR6GYOBMq7pw87TeQbedZAxeNHCpFvodEMvA2RuvUR74/qbI238nyCY1h1E4PmM7591mSegFM/f8/k3AyijrzzLxn/Pd8OZnEdQrHkHgRyx97lqFi6+ixiTBoNsnbZZNXmlyAfM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=JiafY+vV; arc=none smtp.client-ip=217.70.183.193 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id A4190240007; Tue, 23 Apr 2024 11:33:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1713871985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8HXsXyT41e7zXu4VpcQhDNhTQBKrNWOKL68FJq5fIo4=; b=JiafY+vVwE+BJ21aRvdSR0mgf3Jvs5sy1F1rcHaH9LLzr7ZCfkbbiAxkJUTh06owGswl9b ckIrd0WyliaYzjDJP1oVA6C2T3hOQTcWpyaxIroFf0Zv4rvHHJVW4KzWqcPvAOR24uDkKT VhgGm6FR1SteFQGt3GMFObX09fXHYdvJPO1LGQOrJ5Q60A8S/2AmrJjnKqf9iDi93MeuWO 5FHQJW38wxN+e0ysTyhqAgCMrjNOTdWBKqqZhrSfv8mrRPwPYF0NFkCWlNDN2bDiqbQpQm ggQtXRQYiGGHVebAAWtwbAHrxKRtiJZsDA0LSbThdVWuvT5ccUQamqSqrOPW3g== Date: Tue, 23 Apr 2024 13:33:01 +0200 From: Herve Codina To: Chris Packham Cc: Bjorn Helgaas , "linux-kernel@vger.kernel.org" , "linux-pci@vger.kernel.org" , "linux-acpi@vger.kernel.org" Subject: Re: local bus enumeration beyond a PCI device Message-ID: <20240423133301.217f7ab2@bootlin.com> In-Reply-To: References: <20240418184531.GA245970@bhelgaas> Organization: Bootlin X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-GND-Sasl: herve.codina@bootlin.com Hi Chris, On Tue, 23 Apr 2024 01:05:21 +0000 Chris Packham wrote: > Hi, > > On 19/04/24 06:45, Bjorn Helgaas wrote: > > [+cc Herve] > > > > On Thu, Apr 18, 2024 at 12:24:06AM +0000, Chris Packham wrote: > >> Hi, > >> > >> We've got a custom x86_64 based design that is using an ASIX9100 to > >> provide a PCI to local bus bridge. Attached to that local bus is an FPGA > >> which mostly provides some GPIOs accessed via registers on the local > >> bus. Right now we've got a custom driver that bundles everything > >> together so effectively we've got a PCI device that provides GPIOs. > > What's the local bus? The ASIX9100 (for which Google doesn't find any > > details) would have a PCI interface on the primary (upstream) side. > > What's the local bus on the secondary (downstream) side? Below you > > mention "PCI bridge", which normally means both the primary and > > secondary sides are PCI buses. > > The ASIX9100 is a multi purpose chip with a few options for providing > GPIO/I2C/SPI/etc. In our hardware configuration we're using it to > provide a 16-bit parallel bus which we're using for register access to > the FPGA. There's an outside chance someone might ask us to hang other > parallel devices like an SRAM or some NOR Flash off it as well. These > are all things we've done on other products with more traditional > embedded SoCs that have a parallel bus interface. > > > If the local bus is not PCI, I guess the ASIX9100 would look to the OS > > like an endpoint, i.e., PCI_HEADER_TYPE_NORMAL, and the ASIX9100 > > driver would handle any "bridge" functionality completely internally? > > I might be using the terminology wrong. Essentially the ASIX9100 is a > PCI-e endpoint (so a device from the PCI subsystems point of view) but > that device can be a I2C, SPI or parallel bus controller onto which > other devices are connected.Hence it's providing a bridge between PCI > and 16-bit parallel busses. > > > Maybe Herve's work at > > https://lore.kernel.org/r/20240325153919.199337-1-herve.codina@bootlin.com > > would be relevant? > > I've had a quick look at that series. I'm not 100% sure it'll help. The > platform I'm dealing with is x86_64 and doesn't have device tree support > (if someone can say "hey do xyz and you'll get DT on x86" that'd be > great).But I'll take a closer look at it and at the original "Generate > device tree node for pci devices" series. You can have DT support on x86. CONFIG_OF=y CONFIG_PCI_DYNAMIC_OF_NODES = y I use a PCIe board from Microchip (Lan966x) and I describe the internal board IPs using a DT overlay. My PCI driver loads the overlay at probe() and call of_platform_default_populate() to instantiate the devices. My DT overlay contains nodes for: - clock controller - reset - i2c bus - pinctrl and gpio - Network switch - MDIO controller I have it working on x86 system. What is mainly missing upstream for x86 system is the DT node creation for the host PCI bridge (root complex). Indeed, on x86 the description comes from ACPI and a DT description of this root bridge is needed. Got a draft code locally (not sent upstream yet) that creates this first bridge on ACPI based systems. PCI-to-PCI bridges and PCI devices are already handled: https://elixir.bootlin.com/linux/v6.9-rc5/source/drivers/pci/of.c#L625 At runtime, based on the PCI enumeration, corresponding DT nodes are created. Best regards, Hervé > > >> But as things can change based on the FPGA program I'd like some > >> flexibility to treat it separately from the PCI bridge. So really I'd > >> like to have a PCI device driver for the ASIX9100 that provides a local > >> bus controller and a (platform?) driver for the FPGA that provides the > >> GPIOs where I can have different compatibles for the different > >> implementations. > >> > >> Then in the ACPI overlay I'd have something like > >> > >>     Scope (\_SB.PCI0.D0B0) > >>     { > >>         Device (ASIX) > >>         { > >>             Name (_ADR, 0x0000) > >> > >>             Device (FPGA) > >>             { > >>                         Name (_HID, "PRP0001") > >>                         Name (_DSD, Package () > >>                         { > >> ToUUID("daffd814-6eba-4d8c-8a91-bc9bbf4aa301"), > >>                                     Package () > >>                                     { > >>                                                 Package () { > >> "compatible", "my-platform-driver-for-fpga" }, > >>                                     } > >>                         }) > >>             } > >>         } > >>     } > >> > >>    Scope(\_SB) > >>    { > >>         Device(OTHR) > >>         { > >>             GpioIo (Exclusive, PullUp, 0, 0, IoRestrictionInputOnly, > >> "\\_SB.PCI0.D0B0.ASIX.FPGA",) { 0 } > >>         } > >>    } > >> > >> Is it even possible to register a host controller for another platform bus? With DT overlay, you can register any devices available on your PCI board. You just need to describe them in the overlay and be sure that a driver exist to handle them based on their compatible property. Also, this solution was designed to work on both DT and ACPI based systems. My Microchip board works on x86 and ARM. Best regards, Hervé