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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08912C433F5 for ; Fri, 8 Oct 2021 06:20:22 +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 5AF4760F6E for ; Fri, 8 Oct 2021 06:20:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5AF4760F6E Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 65C10833E3; Fri, 8 Oct 2021 08:20:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1633674019; bh=m252UO97T45lzFxuK9ZkrZRX/7ET91Yzd4Z3BCMiKIw=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hhd5xeRWBqxuBy3QajM1/DvTJzvU81C4KabimrPYVbQvO0lhO9smJF/RwRFPde4oQ 21THKA4S4ovEyMS0ersOOa52W0QMBd8Bn6L4KSaNmOmv6ueL4O9HGZ1ijsH6+lDewZ jAMfudYH8UlWG9PwzM8V+ge0d9gXxFGGdCMhG6RgBqymUS4sLBiq7J3nNYWZnppa2s NH0suT8jTvFZxxghHVDF7DxO633sIZZ84PlQYYYrvA3L06tzGJqn9RWjaJ+RULFEAo tP8rMRXAAaVIvp4UB3lyXspBgKTzpVg3rnqzvC9kEP7POaMs5jOKkQb7QYSLf6yGNr a5MmuFLmKyVgQ== Received: by phobos.denx.de (Postfix, from userid 109) id B7484835A0; Fri, 8 Oct 2021 08:20:17 +0200 (CEST) Received: from mout-u-205.mailbox.org (mout-u-205.mailbox.org [91.198.250.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BFEF882952 for ; Fri, 8 Oct 2021 08:20:14 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-205.mailbox.org (Postfix) with ESMTPS id 4HQdMy51bSzQl5v; Fri, 8 Oct 2021 08:20:14 +0200 (CEST) Subject: Re: [PATCH u-boot-marvell v2 2/6] arm: a37xx: pci: Add support for accessing PCI Bridge on root bus To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de, =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20210925225446.1872-1-kabel@kernel.org> <20210925225446.1872-3-kabel@kernel.org> <20211005215548.vgmjux4iy2g3qhmg@pali> From: Stefan Roese Message-ID: Date: Fri, 8 Oct 2021 08:20:11 +0200 MIME-Version: 1.0 In-Reply-To: <20211005215548.vgmjux4iy2g3qhmg@pali> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: B5937183C 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 On 05.10.21 23:55, Pali Rohár wrote: > On Sunday 26 September 2021 00:54:42 Marek Behún wrote: >> @@ -355,20 +369,55 @@ static int pcie_advk_read_config(const struct udevice *bus, pci_dev_t bdf, >> enum pci_size_t size) >> { >> struct pcie_advk *pcie = dev_get_priv(bus); >> + int busno = PCI_BUS(bdf) - dev_seq(bus); >> int retry_count; >> bool allow_crs; >> + ulong data; >> uint reg; >> int ret; >> >> dev_dbg(pcie->dev, "PCIE CFG read: (b,d,f)=(%2d,%2d,%2d) ", >> PCI_BUS(bdf), PCI_DEV(bdf), PCI_FUNC(bdf)); >> >> - if (!pcie_advk_addr_valid(bdf, pcie->first_busno)) { >> + if (!pcie_advk_addr_valid(pcie, busno, PCI_DEV(bdf), PCI_FUNC(bdf))) { >> dev_dbg(pcie->dev, "- out of range\n"); >> *valuep = pci_get_ff(size); >> return 0; >> } >> >> + /* >> + * The configuration space of the PCI Bridge on primary (local) bus is >> + * not accessible via PIO transfers like all other PCIe devices. PCI >> + * Bridge config registers are available directly in Aardvark memory >> + * space starting at offset zero. Moreover PCI Bridge registers in the >> + * range 0x10 - 0x34 are not available and register 0x38 (Expansion ROM >> + * Base Address) is at offset 0x30. >> + * We therefore read configuration space content of the primary PCI >> + * Bridge from our virtual cache. >> + */ >> + if (busno == pcie->first_busno) { >> + if (offset >= 0x10 && offset < 0x34) >> + data = pcie->cfgcache[(offset - 0x10) / 4]; >> + else if ((offset & ~3) == PCI_ROM_ADDRESS1) >> + data = advk_readl(pcie, PCIE_CORE_EXP_ROM_BAR_REG); >> + else >> + data = advk_readl(pcie, offset & ~3); >> + >> + if ((offset & ~3) == (PCI_HEADER_TYPE & ~3)) { >> + /* >> + * Change Header Type of PCI Bridge device to Type 1 >> + * (0x01, used by PCI Bridges) because hardwired value >> + * is Type 0 (0x00, used by Endpoint devices). >> + */ >> + data &= ~0x00ff0000; > ^^ > There is a small mistake. Header Type is 7-bit value. Upper 8th bit > indicates if device is multifunction. So correct mask should be: > > data &= ~0x007f0000; I'll try to get to these (and other) patches today and will fix this while applying. Thanks, Stefan >> + data |= PCI_HEADER_TYPE_BRIDGE << 16; >> + } >> + >> + *valuep = pci_conv_32_to_size(data, offset, size); >> + >> + return 0; >> + } >> + >> /* >> * Returning fabricated CRS value (0xFFFF0001) by PCIe Root Complex to >> * OS is allowed only for 4-byte PCI_VENDOR_ID config read request and Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de