Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp323030pxb; Sat, 11 Sep 2021 06:16:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+r+FwcZzZCbexGxU8UcmNyGP6g3TrZR75AADgsopsFFZ/XG5IL1/p00G7/L8tH87FeXSC X-Received: by 2002:a17:907:100c:: with SMTP id ox12mr2869605ejb.102.1631366184613; Sat, 11 Sep 2021 06:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631366184; cv=none; d=google.com; s=arc-20160816; b=U61SvldeNR7QQeCyS2Sf9HuWQP43GzAXR91XGhFmMhb+iAgtp5fRk75XzUzohwPc5r TyMA7IwENX5Fc53r/1JuNXvgSCOodxUWMUfgTfASJJdDj/2ZiaBf/9BXlEZw2aerRPGt Q3EsgpxLm1Ix9S8LCNrVj/cA85TqMQzlwKMCiN8K6NCSQnmNRbX387hBx5MUfIy+QavD CHITbxMgp2o5YjGLhmIUxqWB2rkBf52i+DB/gMqLl7QUGEUXtXQAV7ds/glP/IgVAt50 cKx+mCrAq+SqB2y3dynosdrKGtnMPvzkU01ZZLtS0Tj5qx4do3fo/iv7w5vHYweWPi+9 Q5lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gL4LuyrZ//BQH0WSCcyEvUljhNP5QcHEtKIhOw0CWQs=; b=hSeUQUXdXJKDjHDGVOzsD9/lIfpBv8ehCJdpXJ9NOVtqY3DEqe1K5xEJ3Zkx5zYJtr kjQbPfeHOitinBSyYgx0fE4vBSsMqvzgiZ9wziPgWywZNC1gjZA9fVf9UiydK71C2dKa ZpH2CXx1HdvSGkyy7JoududiHQEWYqbDxN8JyHpQXdgNFfcZOcZTzN7W9NlLPjPXLbZD J3mJqvoABmx+xcEY6JcDSQ6Q/1xFn+ncvITJ2xDJB9z2FuEnoMEQemB7Ppj2l2PBAgny AwLhm2RsI7lbZCgQIKmBqeZbR/79nbGRt/jEzZWZSiMlOwJx1l9xmPegsKevTueOg4sp 2DJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SDbS2xwQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 d13si1835299ejz.741.2021.09.11.06.16.01; Sat, 11 Sep 2021 06:16:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SDbS2xwQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S236839AbhIKNPF (ORCPT + 99 others); Sat, 11 Sep 2021 09:15:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:37472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236095AbhIKNN0 (ORCPT ); Sat, 11 Sep 2021 09:13:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C114561209; Sat, 11 Sep 2021 13:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631365933; bh=KfGxBqgb3mnKJOc11Ogxd2i4fFLWa3cqb+xQVzKN5Vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SDbS2xwQaLBfYxXtvYhdF9UbtYYx84pbYgK3zFUvbT5FXCD66YQZAUHL34xSE9nAq A8Jcp1H/cUBP7lzhYC/Ly3KFmKE0F26uAbnH/Grya6m7gibiHHxxMEwrcdSpB/dStY gTdh19CoLeDjk2E/MktT4F8jL/jilLde4WzHkGcsx/gn/n95YQhL3GaCYBFlo/xvjY CmxGzN0xVgH45DEdOsolr7YpSxJ9t3akk/m7fR47f6XJA2x2BZFeUZsHn9uZMGyRTL 6vLArODwKwU8JDXC0bfYrXPh4VVi/OIusqTGngp7EtMu25dlhatQ2WzxdpxySr34Vm krPD7QYKiVe3w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kishon Vijay Abraham I , Lorenzo Pieralisi , Sasha Levin , linux-omap@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.14 17/32] PCI: j721e: Add PCIe support for J7200 Date: Sat, 11 Sep 2021 09:11:34 -0400 Message-Id: <20210911131149.284397-17-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210911131149.284397-1-sashal@kernel.org> References: <20210911131149.284397-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kishon Vijay Abraham I [ Upstream commit f1de58802f0fff364cf49f5e47d1be744baa434f ] J7200 has the same PCIe IP as in J721E with minor changes in the wrapper. J7200 allows byte access of bridge configuration space registers and the register field for LINK_DOWN interrupt is different. J7200 also requires "quirk_detect_quiet_flag" to be set. Configure these changes as part of driver data applicable only to J7200. Link: https://lore.kernel.org/r/20210811123336.31357-4-kishon@ti.com Signed-off-by: Kishon Vijay Abraham I Signed-off-by: Lorenzo Pieralisi Signed-off-by: Sasha Levin --- drivers/pci/controller/cadence/pci-j721e.c | 40 +++++++++++++++++++--- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/cadence/pci-j721e.c b/drivers/pci/controller/cadence/pci-j721e.c index 0c5813b230b4..10b13b728284 100644 --- a/drivers/pci/controller/cadence/pci-j721e.c +++ b/drivers/pci/controller/cadence/pci-j721e.c @@ -27,6 +27,7 @@ #define STATUS_REG_SYS_2 0x508 #define STATUS_CLR_REG_SYS_2 0x708 #define LINK_DOWN BIT(1) +#define J7200_LINK_DOWN BIT(10) #define J721E_PCIE_USER_CMD_STATUS 0x4 #define LINK_TRAINING_ENABLE BIT(0) @@ -57,6 +58,7 @@ struct j721e_pcie { struct cdns_pcie *cdns_pcie; void __iomem *user_cfg_base; void __iomem *intd_cfg_base; + u32 linkdown_irq_regfield; }; enum j721e_pcie_mode { @@ -67,6 +69,9 @@ enum j721e_pcie_mode { struct j721e_pcie_data { enum j721e_pcie_mode mode; unsigned int quirk_retrain_flag:1; + unsigned int quirk_detect_quiet_flag:1; + u32 linkdown_irq_regfield; + unsigned int byte_access_allowed:1; }; static inline u32 j721e_pcie_user_readl(struct j721e_pcie *pcie, u32 offset) @@ -98,12 +103,12 @@ static irqreturn_t j721e_pcie_link_irq_handler(int irq, void *priv) u32 reg; reg = j721e_pcie_intd_readl(pcie, STATUS_REG_SYS_2); - if (!(reg & LINK_DOWN)) + if (!(reg & pcie->linkdown_irq_regfield)) return IRQ_NONE; dev_err(dev, "LINK DOWN!\n"); - j721e_pcie_intd_writel(pcie, STATUS_CLR_REG_SYS_2, LINK_DOWN); + j721e_pcie_intd_writel(pcie, STATUS_CLR_REG_SYS_2, pcie->linkdown_irq_regfield); return IRQ_HANDLED; } @@ -112,7 +117,7 @@ static void j721e_pcie_config_link_irq(struct j721e_pcie *pcie) u32 reg; reg = j721e_pcie_intd_readl(pcie, ENABLE_REG_SYS_2); - reg |= LINK_DOWN; + reg |= pcie->linkdown_irq_regfield; j721e_pcie_intd_writel(pcie, ENABLE_REG_SYS_2, reg); } @@ -284,10 +289,25 @@ static struct pci_ops cdns_ti_pcie_host_ops = { static const struct j721e_pcie_data j721e_pcie_rc_data = { .mode = PCI_MODE_RC, .quirk_retrain_flag = true, + .byte_access_allowed = false, + .linkdown_irq_regfield = LINK_DOWN, }; static const struct j721e_pcie_data j721e_pcie_ep_data = { .mode = PCI_MODE_EP, + .linkdown_irq_regfield = LINK_DOWN, +}; + +static const struct j721e_pcie_data j7200_pcie_rc_data = { + .mode = PCI_MODE_RC, + .quirk_detect_quiet_flag = true, + .linkdown_irq_regfield = J7200_LINK_DOWN, + .byte_access_allowed = true, +}; + +static const struct j721e_pcie_data j7200_pcie_ep_data = { + .mode = PCI_MODE_EP, + .quirk_detect_quiet_flag = true, }; static const struct of_device_id of_j721e_pcie_match[] = { @@ -299,6 +319,14 @@ static const struct of_device_id of_j721e_pcie_match[] = { .compatible = "ti,j721e-pcie-ep", .data = &j721e_pcie_ep_data, }, + { + .compatible = "ti,j7200-pcie-host", + .data = &j7200_pcie_rc_data, + }, + { + .compatible = "ti,j7200-pcie-ep", + .data = &j7200_pcie_ep_data, + }, {}, }; @@ -332,6 +360,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) pcie->dev = dev; pcie->mode = mode; + pcie->linkdown_irq_regfield = data->linkdown_irq_regfield; base = devm_platform_ioremap_resource_byname(pdev, "intd_cfg"); if (IS_ERR(base)) @@ -391,9 +420,11 @@ static int j721e_pcie_probe(struct platform_device *pdev) goto err_get_sync; } - bridge->ops = &cdns_ti_pcie_host_ops; + if (!data->byte_access_allowed) + bridge->ops = &cdns_ti_pcie_host_ops; rc = pci_host_bridge_priv(bridge); rc->quirk_retrain_flag = data->quirk_retrain_flag; + rc->quirk_detect_quiet_flag = data->quirk_detect_quiet_flag; cdns_pcie = &rc->pcie; cdns_pcie->dev = dev; @@ -459,6 +490,7 @@ static int j721e_pcie_probe(struct platform_device *pdev) ret = -ENOMEM; goto err_get_sync; } + ep->quirk_detect_quiet_flag = data->quirk_detect_quiet_flag; cdns_pcie = &ep->pcie; cdns_pcie->dev = dev; -- 2.30.2