From patchwork Fri Oct 20 10:43:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Minda Chen X-Patchwork-Id: 155983 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp963112vqb; Fri, 20 Oct 2023 03:44:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEy3F+v7xXjYZB6OcD93rKF+8dyEqGvn6wm1NSpIWjydrbtCJeEgpZCnmGfFm7G30Kdefhi X-Received: by 2002:a05:6358:7e03:b0:143:9b25:c029 with SMTP id o3-20020a0563587e0300b001439b25c029mr1160835rwm.2.1697798673514; Fri, 20 Oct 2023 03:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697798673; cv=none; d=google.com; s=arc-20160816; b=Pi5J4jy8coQbCJaYKhly91UicTcJnMCxC19wkMzlxLJJrILxex2K9+uofRL0tfocDR 668bUMSL/bkTlrg0Nya3Oc9TCDsvkrt+5kDuEl4k9EajKa1ykeQYoIP/9EwfEJidbhz1 0my7TIA78u5uDRwxSOxlLgWR/kM49sxmso7oAFbsRiKEn65RfYEN95TGvBL/cA9qAbaI QhDQjmTmOPZLEU+KSg/RM+Z7NHjzZQ0wuL2juqIC9ufQmGAByzJ+yS4/6cXffarZyo9T vcnO70shWY6lx+LH0BxKJtz7nRZjqJFwzGyTtLAwIQrh1JNMMDghxIA/z586gfXl5DsP k0pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=HzcdZ5ztIaO20YDYvnZyi7VwO7vkI2hZ7GiuPMC4BSw=; fh=ld3UXb1S5Y4IkunPfuj6e9Ppmc+fy6ncC+eQtrVLfK8=; b=e16rv41oq0L6omBGZ5eX+W3HCeI6ZC5KJ61GTnwnc0Os3E7CAiFvD1zmwV481gtxz/ QK2Ob8WdAfr6DwaJPAv46+gbuBVTL5eI++95lPkqX0Xl6/hxhKpfCuPdFTmeAVcUFExI bKzk4KvlTkjclLM79gDdWPzcrLddcc/f5wbvHnV5K6+006o6Lm7+E9EmGtLUlZL4C57E OCOoCubkKGrAJBZuAIMKPgWbzRhP0/EuF11txYZYVmaj/PLRqyOiF1t9X13MX/jbkaSV 2Y3cPt0Ej/QMzDb6SDkKUM2B32RPPzebx/985q8FbsjPUZ33QfekinqsOTi6xP7BpjkV HEQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id s9-20020a637709000000b00577461296a9si1732402pgc.338.2023.10.20.03.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 03:44:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E29F082DD088; Fri, 20 Oct 2023 03:44:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377003AbjJTKoZ (ORCPT + 25 others); Fri, 20 Oct 2023 06:44:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377049AbjJTKn4 (ORCPT ); Fri, 20 Oct 2023 06:43:56 -0400 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A0C8D53; Fri, 20 Oct 2023 03:43:54 -0700 (PDT) Received: from EXMBX165.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX165", Issuer "EXMBX165" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id 4F6BF24E370; Fri, 20 Oct 2023 18:43:53 +0800 (CST) Received: from EXMBX171.cuchost.com (172.16.6.91) by EXMBX165.cuchost.com (172.16.6.75) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 20 Oct 2023 18:43:53 +0800 Received: from ubuntu.localdomain (183.27.99.123) by EXMBX171.cuchost.com (172.16.6.91) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 20 Oct 2023 18:43:51 +0800 From: Minda Chen To: Conor Dooley , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , "Daire McNamara" , Emil Renner Berthing , Krzysztof Kozlowski CC: , , , , Paul Walmsley , Palmer Dabbelt , Albert Ou , Philipp Zabel , Mason Huo , Leyfoon Tan , Kevin Xie , Minda Chen Subject: [PATCH v9 12/20] PCI: microchip: Add request_event_irq() callback function Date: Fri, 20 Oct 2023 18:43:33 +0800 Message-ID: <20231020104341.63157-13-minda.chen@starfivetech.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20231020104341.63157-1-minda.chen@starfivetech.com> References: <20231020104341.63157-1-minda.chen@starfivetech.com> MIME-Version: 1.0 X-Originating-IP: [183.27.99.123] X-ClientProxiedBy: EXCAS062.cuchost.com (172.16.6.22) To EXMBX171.cuchost.com (172.16.6.91) X-YovoleRuleAgent: yovoleflag X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 20 Oct 2023 03:44:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780270942184426080 X-GMAIL-MSGID: 1780270942184426080 PolarFire implements specific PCIe interrupts besides PLDA local interrupt. For PLDA lack of MSI controller, these interrupts can not be added to MSI. Polar driver also register these interrupt symbol name. PolarFire PCIe contain total 28 interrupts event while PLDA contain 13 local interrupts event, interrupt to event num mapping is different. So add a callback function to support different IRQ register function. Also Add PLDA default handler function, which will be moved to pcie-plda-host.c in moving codes patch. Signed-off-by: Minda Chen Acked-by: Conor Dooley --- .../pci/controller/plda/pcie-microchip-host.c | 30 ++++++++++++++++--- drivers/pci/controller/plda/pcie-plda.h | 5 ++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/plda/pcie-microchip-host.c b/drivers/pci/controller/plda/pcie-microchip-host.c index 1799455989ac..c95ef4679fc5 100644 --- a/drivers/pci/controller/plda/pcie-microchip-host.c +++ b/drivers/pci/controller/plda/pcie-microchip-host.c @@ -638,6 +638,11 @@ static irqreturn_t mc_event_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static irqreturn_t plda_event_handler(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + static void plda_handle_event(struct irq_desc *desc) { struct plda_pcie_rp *port = irq_desc_get_handler_data(desc); @@ -799,6 +804,17 @@ static int mc_pcie_init_clks(struct device *dev) return 0; } +static int mc_request_event_irq(struct plda_pcie_rp *plda, int event_irq, + int event) +{ + return devm_request_irq(plda->dev, event_irq, mc_event_handler, + 0, event_cause[event].sym, plda); +} + +static const struct plda_event mc_event = { + .request_event_irq = mc_request_event_irq, +}; + static int plda_pcie_init_irq_domains(struct plda_pcie_rp *port) { struct device *dev = port->dev; @@ -898,7 +914,9 @@ static void mc_disable_interrupts(struct mc_pcie *port) writel_relaxed(GENMASK(31, 0), bridge_base_addr + ISTATUS_HOST); } -static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_rp *port) +static int plda_init_interrupts(struct platform_device *pdev, + struct plda_pcie_rp *port, + const struct plda_event *event) { struct device *dev = &pdev->dev; int irq; @@ -922,8 +940,12 @@ static int plda_init_interrupts(struct platform_device *pdev, struct plda_pcie_r return -ENXIO; } - ret = devm_request_irq(dev, event_irq, mc_event_handler, - 0, event_cause[i].sym, port); + if (event->request_event_irq) + ret = event->request_event_irq(port, event_irq, i); + else + ret = devm_request_irq(dev, event_irq, plda_event_handler, + 0, NULL, port); + if (ret) { dev_err(dev, "failed to request IRQ %d\n", event_irq); return ret; @@ -977,7 +999,7 @@ static int mc_platform_init(struct pci_config_window *cfg) return ret; /* Address translation is up; safe to enable interrupts */ - ret = plda_init_interrupts(pdev, &port->plda); + ret = plda_init_interrupts(pdev, &port->plda, &mc_event); if (ret) return ret; diff --git a/drivers/pci/controller/plda/pcie-plda.h b/drivers/pci/controller/plda/pcie-plda.h index e3d35cef9894..28ed1374e1de 100644 --- a/drivers/pci/controller/plda/pcie-plda.h +++ b/drivers/pci/controller/plda/pcie-plda.h @@ -121,6 +121,11 @@ struct plda_pcie_rp { int num_events; }; +struct plda_event { + int (*request_event_irq)(struct plda_pcie_rp *pcie, + int event_irq, int event); +}; + void plda_pcie_setup_window(void __iomem *bridge_base_addr, u32 index, phys_addr_t axi_addr, phys_addr_t pci_addr, size_t size);