From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id AED66C7618E for ; Thu, 20 Apr 2023 19:46:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7B816862E6; Thu, 20 Apr 2023 21:45:48 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org 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=kernel.org header.i=@kernel.org header.b="RUaSZaM9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 674DA85DFC; Thu, 20 Apr 2023 21:45:45 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D159A85F06 for ; Thu, 20 Apr 2023 21:45:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E41360FB2; Thu, 20 Apr 2023 19:45:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3B45C433D2; Thu, 20 Apr 2023 19:45:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682019940; bh=ajI/uVUvcKVxcQsbUlrvrtncYkIUOUIu6cbkSAX8JCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RUaSZaM9d+Qh2QELV/iA6rpEcCNdZO1PSgJtFiZkigwZ9otViA0OCQlcOnqpZAGid XqLz1Xbu5vvQRo2WX7a3NAYJJvNL2VpR7ALw7QGDRtnC1SqDKWXFpSAV/Mzq0qXvQ7 dRuX4r02lxcx2/0UIc1sZTV6GXyg4KUgld09a3eaW8lBp0++CcljrdkRsT7HZoVn1f 1BeJdeeKWq4+4U0iZkPyJZVn7HSVajg52dVoq+2P6a5izHbHjHGys1qt+Wxcj6HWwQ skkH2opEJxHC33pcgWTkvbRulMgqascMHQQv1psgmVmblmcQ4S9CSoDsx2KxmA453v wWH6hMaMGQzFg== Received: by pali.im (Postfix) id 33C84F12; Thu, 20 Apr 2023 21:45:38 +0200 (CEST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Heiko Schocher Cc: u-boot@lists.denx.de Subject: [PATCH u-boot 1/3] pci: mpc85xx: Do not access PCI BARs registers of BDF address 00:00.0 Date: Thu, 20 Apr 2023 21:44:23 +0200 Message-Id: <20230420194425.25224-2-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230420194425.25224-1-pali@kernel.org> References: <20230420194425.25224-1-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.8 at phobos.denx.de X-Virus-Status: Clean At BDF address 00:00.0 is fictional device which PCI configuration header is for configuring mpc85xx PCI controller itself. PCI config space of this device has ATMU inbound registers on position of PCI BARs. Trying to do PCI auto configuration of this device cause rewriting ATMU inbound registers. To avoid it, do not allow overwriting registers at BARs positions. And because this device does not have any PCI memory, return zeros when trying to read PCI BARs config space registers. It signals to auto configuration tool to not allocate any PCI memory for this device. This information is taken from MPC8544E Reference Manual, sections 17.3.1.3, 17.3.1.1.1, 17.3.2 and 17.3.2.11. Available at NXP website: https://www.nxp.com/docs/en/reference-manual/MPC8544ERM.pdf Signed-off-by: Pali Rohár --- drivers/pci/pci_mpc85xx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/pci_mpc85xx.c b/drivers/pci/pci_mpc85xx.c index 833de816c459..249cfe66466b 100644 --- a/drivers/pci/pci_mpc85xx.c +++ b/drivers/pci/pci_mpc85xx.c @@ -27,6 +27,13 @@ static int mpc85xx_pci_dm_read_config(const struct udevice *dev, pci_dev_t bdf, return 0; } + /* Skip mpc85xx PCI controller's ATMU inbound registers */ + if (PCI_BUS(bdf) == 0 && PCI_DEV(bdf) == 0 && PCI_FUNC(bdf) == 0 && + (offset & ~3) >= PCI_BASE_ADDRESS_0 && (offset & ~3) <= PCI_BASE_ADDRESS_5) { + *value = 0; + return 0; + } + addr = PCI_CONF1_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), offset); out_be32(priv->cfg_addr, addr); sync(); @@ -56,6 +63,11 @@ static int mpc85xx_pci_dm_write_config(struct udevice *dev, pci_dev_t bdf, if (offset > 0xff) return 0; + /* Skip mpc85xx PCI controller's ATMU inbound registers */ + if (PCI_BUS(bdf) == 0 && PCI_DEV(bdf) == 0 && PCI_FUNC(bdf) == 0 && + (offset & ~3) >= PCI_BASE_ADDRESS_0 && (offset & ~3) <= PCI_BASE_ADDRESS_5) + return 0; + addr = PCI_CONF1_ADDRESS(PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf), offset); out_be32(priv->cfg_addr, addr); sync(); -- 2.20.1