From patchwork Fri Aug 21 03:53:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 248052 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:d4c:0:0:0:0 with SMTP id h12csp4505ilj; Thu, 20 Aug 2020 20:55:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybsLLY74eGihbGik05rqzNMQI2exosEkra4Ady7JfuYwf0q5bb9aimzEeLt7tIbJ3fSZBw X-Received: by 2002:aa7:c64e:: with SMTP id z14mr1027782edr.368.1597982115863; Thu, 20 Aug 2020 20:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597982115; cv=none; d=google.com; s=arc-20160816; b=M6t1VbUIi/mVjBu1Ir+c1JqZc4WVDDiT7x2Q2ZT8Dbk1XseZJA6HfK1rHZ+v6trY3n stitP9SVtA0Lw9FNw4un/R8b0Q68/AUYb8W5UG/+qBP206eZxhsSJGCwGgvmyqJXF+2p gknNw7UM4dnuTHHQcHaWy/5xKG3VgbFxds4syG8Mwt7rxYuTIhpZpCvh9xthrXXpow4u kdK+2LBCOMbMnY2zpBn78xE9xbD9dE4yWa6DREtRFZLSmxyVWCUZFFHOOh5yEArBp34y TgreD2BsmM+GKqT5EIT3hA+VdsB9op3xOMSgBaneSe93mmXAeWYxwsK9vvPEHVFdvGBE YPng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=nFg1YpOXTjGvAAjYWr6Bj6FfzEbwYJGtjSsSCN/Mie0=; b=yypcGSlnyQ2MohRJNCYOhky7UJzh+USMPr0L2fZlOGZnvJfEj9kN+ZaZox+t43JWLH xZ15RFUk0OXH5hjUdJbvZwAYnbAA119MonkW6YspLEWKKmyJcYLmuI0Eyoej+SuWVgnc Lwg3zUomwFBxNjDPmJx9RiWPZLh/wLv8cS2FwIOlgdg8c+L0RKeexTq59YNyoGePNkCz ZD9eEA4Ejs5NoSuJxKYt3X9f7WlBCPzeESKIQnYIXa+l86HRHUM5Z2Z2RHMuEgvN6lp3 qBbs1KTCcvGXP95n31Q5sM4nrBHROriAbgpcrUIKFO1OFg4ByrwjbK+VEhVlKlyxW4TT oEOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z3si380194ejx.477.2020.08.20.20.55.15; Thu, 20 Aug 2020 20:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-omap-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727897AbgHUDzO (ORCPT + 4 others); Thu, 20 Aug 2020 23:55:14 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:40519 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbgHUDzK (ORCPT ); Thu, 20 Aug 2020 23:55:10 -0400 Received: by mail-io1-f66.google.com with SMTP id b17so471477ion.7; Thu, 20 Aug 2020 20:55:09 -0700 (PDT) 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=nFg1YpOXTjGvAAjYWr6Bj6FfzEbwYJGtjSsSCN/Mie0=; b=K4BrF9gWGQMoXEk/8uQ5gRsEVMScPBp/PSlrM7DqpJtl4g2GIgp3BH/p2rHEJK/+Nm Xil1fH+/kkJoRwhnlZbXZSeiSaQqogZKGYkJwQyBT4I1KcYKe8gQOdchkH7wW4cSAW85 OxECeJrPVa5ZBEdaqHfFce93FH2bnSEPBYfPf4dWQNDiy4QBahOLp60pGkIXQ1HHhLHl TA3Nqf26f947eyV+zRlFXKvQvqcvEyXW8y5FOzu7dT4SqjlveS+Gxt15HuW9KVP/cwFK GRSE3mWMTI9K5Y5IeBAnw79nMl8soIbiks/V8UTQmGHDHpmtng95a6rZVFnbG6Xqo0x3 X/jA== X-Gm-Message-State: AOAM532A3XORi1U/nkBUOc5RU/O899pVfIwar/e6PQrLz57z8UwXygXP 5815+dPygaIqHTCfhXVYeA== X-Received: by 2002:a6b:dc0a:: with SMTP id s10mr898987ioc.18.1597982109347; Thu, 20 Aug 2020 20:55:09 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.249]) by smtp.googlemail.com with ESMTPSA id 79sm413923ilc.9.2020.08.20.20.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Aug 2020 20:55:08 -0700 (PDT) From: Rob Herring To: Bjorn Helgaas , Lorenzo Pieralisi Cc: linux-pci@vger.kernel.org, Andy Gross , Binghui Wang , Bjorn Andersson , Dilip Kota , Fabio Estevam , Gustavo Pimentel , Jerome Brunet , Jesper Nilsson , Jingoo Han , Jonathan Chocron , Jonathan Hunter , Kevin Hilman , Kishon Vijay Abraham I , Krzysztof Kozlowski , Kukjin Kim , Kunihiko Hayashi , Lucas Stach , Martin Blumenstingl , Masahiro Yamada , Murali Karicheri , Neil Armstrong , NXP Linux Team , Pengutronix Kernel Team , Pratyush Anand , Richard Zhu , Sascha Hauer , Shawn Guo , Shawn Guo , Stanimir Varbanov , Thierry Reding , Xiaowei Song , Yue Wang , Marc Zyngier , linux-amlogic@lists.infradead.org, linux-arm-kernel@axis.com, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-omap@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH v2 09/40] PCI: dwc: kirin: Use pci_ops for root config space accessors Date: Thu, 20 Aug 2020 21:53:49 -0600 Message-Id: <20200821035420.380495-10-robh@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821035420.380495-1-robh@kernel.org> References: <20200821035420.380495-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Now that DWC drivers can setup their own pci_ops for the root and child buses, convert the HiSilicon Kirin driver to use the standard pci_ops for root bus config accesses. Cc: Xiaowei Song Cc: Binghui Wang Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- drivers/pci/controller/dwc/pcie-kirin.c | 39 +++++++++++++------------ 1 file changed, 21 insertions(+), 18 deletions(-) -- 2.25.1 diff --git a/drivers/pci/controller/dwc/pcie-kirin.c b/drivers/pci/controller/dwc/pcie-kirin.c index e496f51e0152..8a01ab0a4a65 100644 --- a/drivers/pci/controller/dwc/pcie-kirin.c +++ b/drivers/pci/controller/dwc/pcie-kirin.c @@ -330,34 +330,37 @@ static void kirin_pcie_sideband_dbi_r_mode(struct kirin_pcie *kirin_pcie, kirin_apb_ctrl_writel(kirin_pcie, val, SOC_PCIECTRL_CTRL1_ADDR); } -static int kirin_pcie_rd_own_conf(struct pcie_port *pp, +static int kirin_pcie_rd_own_conf(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct kirin_pcie *kirin_pcie = to_kirin_pcie(pci); - int ret; + struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); - kirin_pcie_sideband_dbi_r_mode(kirin_pcie, true); - ret = dw_pcie_read(pci->dbi_base + where, size, val); - kirin_pcie_sideband_dbi_r_mode(kirin_pcie, false); + if (PCI_SLOT(devfn)) { + *val = ~0; + return PCIBIOS_DEVICE_NOT_FOUND; + } - return ret; + *val = dw_pcie_read_dbi(pci, where, size); + return PCIBIOS_SUCCESSFUL; } -static int kirin_pcie_wr_own_conf(struct pcie_port *pp, +static int kirin_pcie_wr_own_conf(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct kirin_pcie *kirin_pcie = to_kirin_pcie(pci); - int ret; + struct dw_pcie *pci = to_dw_pcie_from_pp(bus->sysdata); - kirin_pcie_sideband_dbi_w_mode(kirin_pcie, true); - ret = dw_pcie_write(pci->dbi_base + where, size, val); - kirin_pcie_sideband_dbi_w_mode(kirin_pcie, false); + if (PCI_SLOT(devfn)) + return PCIBIOS_DEVICE_NOT_FOUND; - return ret; + dw_pcie_write_dbi(pci, where, size, val); + return PCIBIOS_SUCCESSFUL; } +static struct pci_ops kirin_pci_ops = { + .read = kirin_pcie_rd_own_conf, + .write = kirin_pcie_wr_own_conf, +}; + static u32 kirin_pcie_read_dbi(struct dw_pcie *pci, void __iomem *base, u32 reg, size_t size) { @@ -423,6 +426,8 @@ static int kirin_pcie_establish_link(struct pcie_port *pp) static int kirin_pcie_host_init(struct pcie_port *pp) { + pp->bridge->ops = &kirin_pci_ops; + kirin_pcie_establish_link(pp); if (IS_ENABLED(CONFIG_PCI_MSI)) @@ -438,8 +443,6 @@ static const struct dw_pcie_ops kirin_dw_pcie_ops = { }; static const struct dw_pcie_host_ops kirin_pcie_host_ops = { - .rd_own_conf = kirin_pcie_rd_own_conf, - .wr_own_conf = kirin_pcie_wr_own_conf, .host_init = kirin_pcie_host_init, };