From patchwork Fri Feb 26 07:48:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "M.h. Lian" X-Patchwork-Id: 8432541 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9B9B39F1D4 for ; Fri, 26 Feb 2016 07:49:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7EDCF2038F for ; Fri, 26 Feb 2016 07:49:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 535EA2037C for ; Fri, 26 Feb 2016 07:49:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZD84-00063l-6E; Fri, 26 Feb 2016 07:48:00 +0000 Received: from mail-bl2on0069.outbound.protection.outlook.com ([65.55.169.69] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aZD7j-0005tK-Jp for linux-arm-kernel@lists.infradead.org; Fri, 26 Feb 2016 07:47:41 +0000 Received: from BY2PR03CA047.namprd03.prod.outlook.com (10.141.249.20) by BL2PR03MB306.namprd03.prod.outlook.com (10.141.68.14) with Microsoft SMTP Server (TLS) id 15.1.409.15; Fri, 26 Feb 2016 07:47:17 +0000 Received: from BN1BFFO11OLC002.protection.gbl (2a01:111:f400:7c10::1:117) by BY2PR03CA047.outlook.office365.com (2a01:111:e400:2c5d::20) with Microsoft SMTP Server (TLS) id 15.1.415.20 via Frontend Transport; Fri, 26 Feb 2016 07:47:17 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11OLC002.mail.protection.outlook.com (10.58.145.13) with Microsoft SMTP Server (TLS) id 15.1.422.5 via Frontend Transport; Fri, 26 Feb 2016 07:47:17 +0000 Received: from lmh.ap.freescale.net (lmh.ap.freescale.net [10.193.20.68]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u1Q7l8bX031042; Fri, 26 Feb 2016 00:47:13 -0700 From: Minghuan Lian To: , Subject: [PATCH 2/2 v4] irqchip/Layerscape: Add SCFG MSI controller support Date: Fri, 26 Feb 2016 15:48:38 +0800 Message-ID: <1456472918-16163-2-git-send-email-Minghuan.Lian@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456472918-16163-1-git-send-email-Minghuan.Lian@nxp.com> References: <1456472918-16163-1-git-send-email-Minghuan.Lian@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131009464372478232; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11OLC002; 1:1OSordHg2+bZC9PeXR60oDnsojBX0PfUe2Fgq+rOCYTKpTE6m1645ziGRQNSwnputPjD1w4iriDCulZ+XKmUc+foACvGLNR8uHWXtxCgTFILMdtHEIDZXysyJuEW0ix7hAJ0E0qfgd69fdbDZ2G3pUXgQhjAWSaXal6Y8J4HNnGpYBoXHjVU1ZvHp4/0KUiv0rT0kGT31EqcvAUwp/0KCMEM0h/WEPPSxBWbuyiDV2RrGB0f9yjfB+lrhv70VgWrw+qt28yZfYefD0WsnCQaP5Om1P47JOUi0D/e+3FJ7I/3/Mt0sW/r93jAQc+LJheBTW5BgS07h2ZKYeG/S/fIG2e3/a0SS1j3WeOUaK07wh6yvwPqoHJI5sPDuQsCKHd/iREZlDp3K3EyR1iVu46KW6i5kTb6rRe1ZVGmuOL9Q9t/utRFmB7kwCEUkZM+Vc6ns8oJM7f8oRuBRFThcHUyKOknNPhOq/qkoRp+1ZhXex+Kym8H6XiREJDP3rjlHlocWXIsHm603HGlUYYqp4U213lf+tOzeZWrOYv+pwKAaFL41+VqmsmrtxaMZrMzFRSiJouBWCkmaabGjXvrMwJITxDGznVLzL1WA+lIcTuwMEg= X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(54534003)(189002)(199003)(76176999)(50986999)(5008740100001)(1220700001)(36756003)(19580405001)(19580395003)(6806005)(104016004)(48376002)(106466001)(92566002)(85426001)(229853001)(1096002)(47776003)(586003)(2950100001)(4326007)(87936001)(2906002)(5001770100001)(5001960100002)(189998001)(5003940100001)(77096005)(11100500001)(86362001)(7059030)(2004002)(2101003)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB306; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; MX:1; A:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: ae262d1c-c996-49a4-c118-08d33e810c99 X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB306; 2:9T1E/UiAd0Y9rDBzf/79vIz+/v8vj0sUS1GtxX9zyFfWsz8H+kj8XGwlU+jQ06ZESOhWk1ESQG9J8UVXvO531VJffTgz/F1yCeYTiT5nS/4/cOMGg/MsTvE+jFQZLdAR63ywn+kriG9VDhPSaoxHf0UsRnipjhj1GDoGjE57+zB8iv+kfKrSn9vIZhsri6IL; 3:eshPEoDq4dJmaydm8K18iok1F5WVIbcTuKxEFypz73R9HCt/Qnr7NMYz0k69e1/Swcx5zLcKwpTbU8JYNCP5jIQ8ZG3EbX+qaN6OxhCYqkKKz1sho+V7ldfm20XIFXB/ocY7QqXHIIhsP8QxJwwST7uMIq9ib7uxBQYRVca6jenARoB0WCz/g6ITjq6aXYF4EXlHsmXLFHWXdn4nCkRACfdO8Efo9Y+hsSSBmYeWuUk=; 25:F085xjmi9OlzIOpTeRSZj+b07TNwpQX+Hffw2H6ohZIsJWxGT+uNTGND/a7L/94z76Nq0pQm/WA5xR1nMxfA1rj01GDxLwpC0up5a+nMCd5cXG5NtJ51Gh1TL3btWgicotoE01ajdTqTrNdjBfjvj29BajQOe7r/UsT40cHVz4qnQaixikcnX7m57dg4+sc6EvUIGiej+ouAzIhtN9dnUhtKOMDjN6XZKf3zDOFOKTzajK02zSYLhBgVFv8jBydhjqHXewQtOpwbrgIa3A2b8Dlq6MT3/l7BAcugORox7X4o+5eMroBHk0G+qc2zrN7lFVCWGj006oWSIyCdMatFSQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2PR03MB306; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(13017025)(13018025)(13023025)(13015025)(13024025)(3002001)(10201501046); SRVR:BL2PR03MB306; BCL:0; PCL:0; RULEID:(400006); SRVR:BL2PR03MB306; X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB306; 4:6aNVPYv3OqgURUorlHnb23oAXOUVPmz0MiYVSjRJDj14a2NUiz6EdXL+3ZGHs6+ePTvH3oEhiZkSTNTpUSCfojgWU2YMUv9FZQE6WUwpUtmR/ZFBZf/60zAh8L2tHeg9XEpHqTQ/DrhAaYWCJkDuK/V8mL8ewqOfsACBrif4aiU9YBUxMPRUIk144q9tGxFvatZ23+C4pNB7aUGgmtc3W/7yDdm76PQ1QNWMHgL5sXp3wV3QzP+PONwjRLbkE5bJm97xZrk4TzWnp21a95JJSyg9sYS0wgbZzxmLr5c3S+aq90xstruHL8DQtNNZG1DIeQ++XjcWtMKIymbyU6D6CTRMMfFKrsgk8qlmyI6qW4knimqGwJzryB+GgtDrMM1dcGeiLuu5oxlhf2xLY/Qm+pjbheGHUM0PUOKMHSPBG3yDzl4UXj1T/82S6MvCLMbjf+PTdAEfBqoeLmVi4y7zqQqHFw625FKdPyqHfR4s/ggqzS7eZpXiojsYxbiaexd5 X-Forefront-PRVS: 0864A36BBF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BL2PR03MB306; 23:C81QOX48/+DqsGnaZLsm9uSKYVKEczojJY+n8BZtY8?= =?us-ascii?Q?7G86++HUFpnmxqhXkpJbP7Sjivr/EPTsjU/Pa6jp/XvG2EYwHYvWWbU/vbbM?= =?us-ascii?Q?/4FWt81sw9moY396hKDa+z3lRPsQcu5un+0LA5DGYMTz2qTbKxo+Eh+ur6VC?= =?us-ascii?Q?O/ld+6u015RVoIrhutTqRLdIW/1OS37GVqaGE2rDQ/FD/gHeyyIn8kDE09zg?= =?us-ascii?Q?+4e+Y0dJoCAtcvOU0nWUo3wO512lUCG9eZIyumf7ggHUhOSuki2I/U20aQpi?= =?us-ascii?Q?ee6PZZjbDrwmKXoWfAOvxo7DJWrBe8PToxQVS1lX8tcpnbLsBPeeUv7IPOVm?= =?us-ascii?Q?R7SpyLjhprlAjxE0cBgcFJCOYZXrBm93F5lu6uvfVLGmYQEJgh406qayMyhX?= =?us-ascii?Q?dbpS9+7X0ImpphhEmGiNleCLlgEAKSXVEJACFau9+zwzqWRl4McNy1HkDxs+?= =?us-ascii?Q?gJOkKGK4d+UWjdsZXezKpVGh94mZ6+W/3al3sbcHdDHG1QdGbs/a13oBsDR8?= =?us-ascii?Q?NjIrwR9CI9aQ3ygtE8pqvDvBs9KmxFZd5V0o7NgwGUeteqy1LXM8Nrn1hSV0?= =?us-ascii?Q?enFDy4OTVflMfeatEeef7Xxbtm5Hd5onvrsTCCF8q19IJJpPE2N8fbeWPZvW?= =?us-ascii?Q?Lyhu/mepCVab5f1nZGt1kW/lLNIbN4XC6bsePSQBhpziWUv/04dm9VnsOiEi?= =?us-ascii?Q?QiJH/z/iz+NYaq9le1YXf8UgRFn58w/mdR+qWUHh5dmu5kCkm5F4CoyvUPpM?= =?us-ascii?Q?YmNUg74HVp+14SBZWBuXTvR4+cafZsOwBsIZTmTWVHJaipWnu/lAgukHVcy7?= =?us-ascii?Q?OUL+ziazbE+zF7lJSF4c+xKQlVYt+1AZm3wrYs4I2SeW6L6jdSSDqKgC1lwH?= =?us-ascii?Q?l9fevFfvLy19cMa1D/o7xfvR7WghGdPY4w13L0/hax7aeEwHRzxw1Gve+ojU?= =?us-ascii?Q?nCkqUm+ymYwnjr4T3xP0vVy75TY0s0tfAlfo1XYR8ZM9E/ju2Kjvknx1/hdv?= =?us-ascii?Q?6d2F9b0iNXd6JgNjABLdRuT2IMXhLym7ZlOxFja9ewYUrVrhiwWev+AhcSxp?= =?us-ascii?Q?u2+uM=3D?= X-Microsoft-Exchange-Diagnostics: 1; BL2PR03MB306; 5:YL6aHXUk5PjXAy/G2EcODicLvvIQLrqaMpJ/coSU7xOt/8otXn4m28ZY9hI1EefJVCoQ6HPmbCjMcDBZepVqhEazwSae4UprHqZfxFbjO/aF20rGIzEjP8B+lyZermWYX5yYXtPNhR3rU5zXUAXzdSaev4FtGoeGwfRHKZ/AMl4=; 24:aDcwofEsGi1AQgo8l9uIsBglmyULyvYbSQA2dsjxwOWxbFR3wUxnGi3g7skWstMWnyH2vE1HScDCZDUopc1KVVaF7ldpL5XrlOD44S1W/p4= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Feb 2016 07:47:17.0138 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR03MB306 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160225_234740_052494_CFF515AD X-CRM114-Status: GOOD ( 19.65 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roy Zang , Jason Cooper , Marc Zyngier , Stuart Yoder , Yang-Leo Li , Minghuan Lian , Thomas Gleixner , Mingkai Hu Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some kind of NXP Layerscape SoC provides a MSI implementation which uses two SCFG registers MSIIR and MSIR to support 32 MSI interrupts for each PCIe controller. The patch is to support it. Signed-off-by: Minghuan Lian --- Change log v4: 1. do not register irq_enable irq_disable 2. shorten the chip name to "SCFG" v3: 1. call of_node_to_fwnode() v2: 1. rename ls1-msi to ls-scfg-msi 2. remove reg-names MSIIR MSIR 3. remove calling set_irq_flags() drivers/irqchip/Kconfig | 5 + drivers/irqchip/Makefile | 1 + drivers/irqchip/irq-ls-scfg-msi.c | 242 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 248 insertions(+) create mode 100644 drivers/irqchip/irq-ls-scfg-msi.c diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index fb50911..0f2a3c3 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -218,3 +218,8 @@ config IRQ_MXS def_bool y if MACH_ASM9260 || ARCH_MXS select IRQ_DOMAIN select STMP_DEVICE + +config LS_SCFG_MSI + def_bool y if SOC_LS1021A || ARCH_LAYERSCAPE + depends on PCI && PCI_MSI + select PCI_MSI_IRQ_DOMAIN diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile index 18caacb..37e12de 100644 --- a/drivers/irqchip/Makefile +++ b/drivers/irqchip/Makefile @@ -59,3 +59,4 @@ obj-$(CONFIG_ARCH_SA1100) += irq-sa11x0.o obj-$(CONFIG_INGENIC_IRQ) += irq-ingenic.o obj-$(CONFIG_IMX_GPCV2) += irq-imx-gpcv2.o obj-$(CONFIG_PIC32_EVIC) += irq-pic32-evic.o +obj-$(CONFIG_LS_SCFG_MSI) += irq-ls-scfg-msi.o diff --git a/drivers/irqchip/irq-ls-scfg-msi.c b/drivers/irqchip/irq-ls-scfg-msi.c new file mode 100644 index 0000000..48df920 --- /dev/null +++ b/drivers/irqchip/irq-ls-scfg-msi.c @@ -0,0 +1,242 @@ +/* + * NXP SCFG MSI(-X) support + * + * Copyright (C) 2016 NXP Semiconductor. + * + * Author: Minghuan Lian + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MSI_MAX_IRQS 32 +#define MSI_IBS_SHIFT 3 +#define MSIR 4 + +struct ls_scfg_msi { + spinlock_t lock; + struct platform_device *pdev; + struct irq_domain *parent; + struct irq_domain *msi_domain; + void __iomem *regs; + phys_addr_t msiir_addr; + u32 nr_irqs; + int irq; + DECLARE_BITMAP(used, MSI_MAX_IRQS); +}; + +static struct irq_chip ls_scfg_msi_irq_chip = { + .name = "MSI", + .irq_mask = pci_msi_mask_irq, + .irq_unmask = pci_msi_unmask_irq, +}; + +static struct msi_domain_info ls_scfg_msi_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | + MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX), + .chip = &ls_scfg_msi_irq_chip, +}; + +static void ls_scfg_msi_compose_msg(struct irq_data *data, struct msi_msg *msg) +{ + struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(data); + + msg->address_hi = upper_32_bits(msi_data->msiir_addr); + msg->address_lo = lower_32_bits(msi_data->msiir_addr); + msg->data = data->hwirq << MSI_IBS_SHIFT; +} + +static int ls_scfg_msi_set_affinity(struct irq_data *irq_data, + const struct cpumask *mask, bool force) +{ + return -EINVAL; +} + +static struct irq_chip ls_scfg_msi_parent_chip = { + .name = "SCFG", + .irq_compose_msi_msg = ls_scfg_msi_compose_msg, + .irq_set_affinity = ls_scfg_msi_set_affinity, +}; + +static int ls_scfg_msi_domain_irq_alloc(struct irq_domain *domain, + unsigned int virq, + unsigned int nr_irqs, + void *args) +{ + struct ls_scfg_msi *msi_data = domain->host_data; + int pos, err = 0; + + WARN_ON(nr_irqs != 1); + + spin_lock(&msi_data->lock); + pos = find_first_zero_bit(msi_data->used, msi_data->nr_irqs); + if (pos < msi_data->nr_irqs) + __set_bit(pos, msi_data->used); + else + err = -ENOSPC; + spin_unlock(&msi_data->lock); + + if (err) + return err; + + irq_domain_set_info(domain, virq, pos, + &ls_scfg_msi_parent_chip, msi_data, + handle_simple_irq, NULL, NULL); + + return 0; +} + +static void ls_scfg_msi_domain_irq_free(struct irq_domain *domain, + unsigned int virq, unsigned int nr_irqs) +{ + struct irq_data *d = irq_domain_get_irq_data(domain, virq); + struct ls_scfg_msi *msi_data = irq_data_get_irq_chip_data(d); + int pos; + + pos = d->hwirq; + if (pos < 0 || pos >= msi_data->nr_irqs) { + pr_err("failed to teardown msi. Invalid hwirq %d\n", pos); + return; + } + + spin_lock(&msi_data->lock); + __clear_bit(pos, msi_data->used); + spin_unlock(&msi_data->lock); +} + +static const struct irq_domain_ops ls_scfg_msi_domain_ops = { + .alloc = ls_scfg_msi_domain_irq_alloc, + .free = ls_scfg_msi_domain_irq_free, +}; + +static void ls_scfg_msi_irq_handler(struct irq_desc *desc) +{ + struct ls_scfg_msi *msi_data = irq_desc_get_handler_data(desc); + unsigned long val; + int pos, virq; + + chained_irq_enter(irq_desc_get_chip(desc), desc); + + val = ioread32be(msi_data->regs + MSIR); + for_each_set_bit(pos, &val, msi_data->nr_irqs) { + virq = irq_find_mapping(msi_data->parent, (31 - pos)); + if (virq) + generic_handle_irq(virq); + } + + chained_irq_exit(irq_desc_get_chip(desc), desc); +} + +static int ls_scfg_msi_domains_init(struct ls_scfg_msi *msi_data) +{ + /* Initialize MSI domain parent */ + msi_data->parent = irq_domain_add_linear(NULL, + msi_data->nr_irqs, + &ls_scfg_msi_domain_ops, + msi_data); + if (!msi_data->parent) { + dev_err(&msi_data->pdev->dev, "failed to create IRQ domain\n"); + return -ENOMEM; + } + + msi_data->msi_domain = pci_msi_create_irq_domain( + of_node_to_fwnode(msi_data->pdev->dev.of_node), + &ls_scfg_msi_domain_info, + msi_data->parent); + if (!msi_data->msi_domain) { + dev_err(&msi_data->pdev->dev, "failed to create MSI domain\n"); + irq_domain_remove(msi_data->parent); + return -ENOMEM; + } + + return 0; +} + +static int ls_scfg_msi_probe(struct platform_device *pdev) +{ + struct ls_scfg_msi *msi_data; + struct resource *res; + int ret; + + msi_data = devm_kzalloc(&pdev->dev, sizeof(*msi_data), GFP_KERNEL); + if (!msi_data) + return -ENOMEM; + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + msi_data->regs = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(msi_data->regs)) { + dev_err(&pdev->dev, "failed to initialize 'regs'\n"); + return PTR_ERR(msi_data->regs); + } + msi_data->msiir_addr = res->start; + + msi_data->irq = platform_get_irq(pdev, 0); + if (msi_data->irq <= 0) { + dev_err(&pdev->dev, "failed to get MSI irq\n"); + return -ENODEV; + } + + msi_data->pdev = pdev; + msi_data->nr_irqs = MSI_MAX_IRQS; + spin_lock_init(&msi_data->lock); + + ret = ls_scfg_msi_domains_init(msi_data); + if (ret) + return ret; + + irq_set_chained_handler_and_data(msi_data->irq, + ls_scfg_msi_irq_handler, + msi_data); + + platform_set_drvdata(pdev, msi_data); + + return 0; +} + +static int ls_scfg_msi_remove(struct platform_device *pdev) +{ + struct ls_scfg_msi *msi_data = platform_get_drvdata(pdev); + + irq_set_chained_handler_and_data(msi_data->irq, NULL, NULL); + + irq_domain_remove(msi_data->msi_domain); + irq_domain_remove(msi_data->parent); + + platform_set_drvdata(pdev, NULL); + + return 0; +} + +static const struct of_device_id ls_scfg_msi_id[] = { + { .compatible = "fsl,1s1021a-msi", }, + { .compatible = "fsl,1s1043a-msi", }, + {}, +}; + +static struct platform_driver ls_scfg_msi_driver = { + .driver = { + .name = "ls-scfg-msi", + .of_match_table = ls_scfg_msi_id, + }, + .probe = ls_scfg_msi_probe, + .remove = ls_scfg_msi_remove, +}; + +module_platform_driver(ls_scfg_msi_driver); + +MODULE_AUTHOR("Minghuan Lian "); +MODULE_DESCRIPTION("NXP Layerscape SCFG MSI controller driver"); +MODULE_LICENSE("GPL v2");