From patchwork Mon Aug 3 21:00:54 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: 247400 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp1539387ilo; Mon, 3 Aug 2020 14:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDKpfVezrg82u7jpkLZpSrMOxOPiZaj2RRuoC7rJyaNMEOLCirEk2TVrq+/Q/MgoNKA2ON X-Received: by 2002:a17:906:a204:: with SMTP id r4mr17817566ejy.552.1596488495185; Mon, 03 Aug 2020 14:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596488495; cv=none; d=google.com; s=arc-20160816; b=qw1XmiDuzyNi33IrXEOvayKc/o0CxKpZ5CoRR71jeF5fTmVlw8oCD8p7Tiy8SaiWmn fKeYtG83Md/b7PzbpaY9LNZXns5IvCZZje5nyOUGtEIW1YHDqIYyhFsdWH5wT5NNjRa+ u+Na5L34/tjQiZeSirFiy8TGKp2KMUOKfHKNX3wWoiZIrUYaDvp/ZXymzZzF4KW+dx11 6nK1d8ir7/B6dOI62Ks3ab3rQsWrL5tMiG4A1n8uY/2x+pMiKzFU4i/2ji/0hr20ZoT9 6IhMbiXUh1G1x/dr45NZI7RPouXy5TnB9ETnlkwVmLpS38tTaVaCC/M6Hy+P9E7YylNE Wgxg== 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=EQL3A7dHzz+gC5njEctrBiMEIqtA+XjXrb2o208g3Ks=; b=HLfXvVgS4D1HCUlW30SNJFIg1kr9FxEkBKw6FiAA7jq0kXkJ2ANkNnugPGhRDf34Jd ijQAekdtPNpQ2sqte7qIdyeDSkU3TxQ6w7fO7ecc2xvTQCtUoXICnW3A4rRKH/nSuPNb uaRsYwtXrC4/2K4ePqzyJN8hP8mgu8NeXYwJhiHIXKwSFsOcDPs6i1xkpVA8jPwDlJHQ 6mThTu9AG//q+Cd2QBut84ZF01bjPMj7bu9iUXz37AbtAMxSKYudEC1Utium9U8x7767 3vg4+t4VRvX5Hc2CMu6nbTSiFOAaIOKrDyI6nslyRO1gbO32v33b9PbBzum2+xFlduNg d1DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-samsung-soc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-samsung-soc-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 lk20si8340152ejb.703.2020.08.03.14.01.34; Mon, 03 Aug 2020 14:01:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-samsung-soc-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-samsung-soc-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-samsung-soc-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 S1729043AbgHCVBe (ORCPT + 4 others); Mon, 3 Aug 2020 17:01:34 -0400 Received: from mail-il1-f196.google.com ([209.85.166.196]:44506 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728889AbgHCVBc (ORCPT ); Mon, 3 Aug 2020 17:01:32 -0400 Received: by mail-il1-f196.google.com with SMTP id j9so28944215ilc.11; Mon, 03 Aug 2020 14:01:31 -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=EQL3A7dHzz+gC5njEctrBiMEIqtA+XjXrb2o208g3Ks=; b=F7YBgQRbZju55J1lslO3ZYYUq/hG4N8wTHAwZU2uIZn8/wbItJEPFW7cgXc/wG+XfX h0WHNqI1RTLpyW656CwcisHE7Q+Q4x8mW2n84ZwgibfSrfEBeh6zm2gmmWlakCDUtgEx avkG/p9QCgev92l5nTcWtt14O1h+Elp5VWTer/gNDWmJQlxbloZGCMUvdStxhzeqXlpS LSjbamKWn3SX7BPFb8J11Gzdtulr3dRD/Qp0FqS50o17Sqf7h5MtlxvR1BWPEFbhy8cp PyoI8WMbk9WKubwvcXdA1h7tHii6zExHwmSoD9wS9iFe7js/PGcKdtTMbtf+5I5DxpEU 1XCg== X-Gm-Message-State: AOAM533sflnPRlLher4tSnqpk1k4OBCcobnTMHudfrIOl+9Q6YddgPbV fiUxMbrLl0V74dU6/sv1wQ== X-Received: by 2002:a92:d7cb:: with SMTP id g11mr1303449ilq.89.1596488491153; Mon, 03 Aug 2020 14:01:31 -0700 (PDT) Received: from xps15.herring.priv ([64.188.179.252]) by smtp.googlemail.com with ESMTPSA id r6sm9292280iod.7.2020.08.03.14.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Aug 2020 14:01:30 -0700 (PDT) From: Rob Herring To: Bjorn Helgaas , Gustavo Pimentel , Jingoo Han , Lorenzo Pieralisi Cc: Binghui Wang , Bjorn Andersson , Fabio Estevam , Jesper Nilsson , Jonathan Chocron , Jonathan Hunter , Kevin Hilman , Kishon Vijay Abraham I , Krzysztof Kozlowski , Kukjin Kim , Kunihiko Hayashi , 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-pci@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-tegra@vger.kernel.org, Lucas Stach , Masahiro Yamada , Murali Karicheri , NXP Linux Team , Pengutronix Kernel Team , Pratyush Anand , Richard Zhu , Sascha Hauer , Shawn Guo , Stanimir Varbanov , Thierry Reding , Xiaowei Song , Yue Wang Subject: [RFC 05/27] PCI: dwc: al: Use pci_ops for child config space accessors Date: Mon, 3 Aug 2020 15:00:54 -0600 Message-Id: <20200803210116.3132633-6-robh@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200803210116.3132633-1-robh@kernel.org> References: <20200803210116.3132633-1-robh@kernel.org> MIME-Version: 1.0 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Now that DWC drivers can setup their own pci_ops for the root and child buses, convert the Amazon driver to use the standard pci_ops for child bus config accesses. Cc: Jonathan Chocron Cc: Lorenzo Pieralisi Cc: Bjorn Helgaas Signed-off-by: Rob Herring --- drivers/pci/controller/dwc/pcie-al.c | 63 ++++++---------------------- 1 file changed, 13 insertions(+), 50 deletions(-) -- 2.25.1 diff --git a/drivers/pci/controller/dwc/pcie-al.c b/drivers/pci/controller/dwc/pcie-al.c index 270868f3859a..5c5763f14485 100644 --- a/drivers/pci/controller/dwc/pcie-al.c +++ b/drivers/pci/controller/dwc/pcie-al.c @@ -222,14 +222,15 @@ static inline void al_pcie_target_bus_set(struct al_pcie *pcie, reg); } -static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie, - unsigned int busnr, - unsigned int devfn) +static void __iomem *al_pcie_conf_addr_map_bus(struct pci_bus *bus, + unsigned int devfn, int where) { + struct pcie_port *pp = bus->sysdata; + struct al_pcie *pcie = to_al_pcie(to_dw_pcie_from_pp(pp)); + unsigned int busnr = bus->number; struct al_pcie_target_bus_cfg *target_bus_cfg = &pcie->target_bus_cfg; unsigned int busnr_ecam = busnr & target_bus_cfg->ecam_mask; unsigned int busnr_reg = busnr & target_bus_cfg->reg_mask; - struct pcie_port *pp = &pcie->pci->pp; void __iomem *pci_base_addr; pci_base_addr = (void __iomem *)((uintptr_t)pp->va_cfg0_base + @@ -245,52 +246,14 @@ static void __iomem *al_pcie_conf_addr_map(struct al_pcie *pcie, target_bus_cfg->reg_mask); } - return pci_base_addr; -} - -static int al_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, - unsigned int devfn, int where, int size, - u32 *val) -{ - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct al_pcie *pcie = to_al_pcie(pci); - unsigned int busnr = bus->number; - void __iomem *pci_addr; - int rc; - - pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn); - - rc = dw_pcie_read(pci_addr + where, size, val); - - dev_dbg(pci->dev, "%d-byte config read from %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n", - size, pci_domain_nr(bus), bus->number, - PCI_SLOT(devfn), PCI_FUNC(devfn), where, - (pci_addr + where), *val); - - return rc; + return pci_base_addr + where; } -static int al_pcie_wr_other_conf(struct pcie_port *pp, struct pci_bus *bus, - unsigned int devfn, int where, int size, - u32 val) -{ - struct dw_pcie *pci = to_dw_pcie_from_pp(pp); - struct al_pcie *pcie = to_al_pcie(pci); - unsigned int busnr = bus->number; - void __iomem *pci_addr; - int rc; - - pci_addr = al_pcie_conf_addr_map(pcie, busnr, devfn); - - rc = dw_pcie_write(pci_addr + where, size, val); - - dev_dbg(pci->dev, "%d-byte config write to %04x:%02x:%02x.%d offset 0x%x (pci_addr: 0x%px) - val:0x%x\n", - size, pci_domain_nr(bus), bus->number, - PCI_SLOT(devfn), PCI_FUNC(devfn), where, - (pci_addr + where), val); - - return rc; -} +static struct pci_ops al_child_pci_ops = { + .map_bus = al_pcie_conf_addr_map_bus, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +}; static void al_pcie_config_prepare(struct al_pcie *pcie) { @@ -344,6 +307,8 @@ static int al_pcie_host_init(struct pcie_port *pp) struct al_pcie *pcie = to_al_pcie(pci); int rc; + pp->bridge->child_ops = &al_child_pci_ops; + rc = al_pcie_rev_id_get(pcie, &pcie->controller_rev_id); if (rc) return rc; @@ -358,8 +323,6 @@ static int al_pcie_host_init(struct pcie_port *pp) } static const struct dw_pcie_host_ops al_pcie_host_ops = { - .rd_other_conf = al_pcie_rd_other_conf, - .wr_other_conf = al_pcie_wr_other_conf, .host_init = al_pcie_host_init, };