From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752719AbcAFWX7 (ORCPT ); Wed, 6 Jan 2016 17:23:59 -0500 Received: from mail-bn1bon0137.outbound.protection.outlook.com ([157.56.111.137]:54508 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751906AbcAFWWH (ORCPT ); Wed, 6 Jan 2016 17:22:07 -0500 Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none;freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; From: "J. German Rivera" To: , , , CC: , , , , , , , , , , , , , , "J. German Rivera" Subject: [PATCH RESEND v4 03/11] staging: fsl-mc: Added generic MSI support for FSL-MC devices Date: Wed, 6 Jan 2016 16:03:21 -0600 Message-ID: <1452117809-1870-4-git-send-email-German.Rivera@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1452117809-1870-1-git-send-email-German.Rivera@freescale.com> References: <1452117809-1870-1-git-send-email-German.Rivera@freescale.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD030;1:D5qel2BmWrRkIwnFg4fR1yEipH2FNcRzhctU1Veh6NpernEJV3dzcPwRKqqMaK7DhgAH/45xLOGEgS/tCZPmoQJuD010Z9BGH/f21lmzF5fmWf4IiW5q4tN3ZqsyXPvw5FocjrU1jvXaLVzSmxyOgmaNpAM8ycT8zzUqcEuBibtUC1VVGPzX2iwb5UfyfCdW42ddgY0mvs4+TrV5HvBq+C0o5LYxL8aeTZALy7DFpzRcU9+c+FsYZYzsKkzqclQ9nzDahlCs4rkZP+7JhuDd3quLnuSDjS4BKZSmWH6n2DdV8yougYzu2+rAxh4vlh0+rSPKKraeQBtDlZkbbCO8hliHUecVD1VS8o7GEWlYqcL6oFiDia4eM/hZNTT6y8pyQulEUOhbzMjQH9WcxjnpaFJUsKE/VAFUu1R2epPIOBM7YjS3+3s1IJXxDpDUD1MT X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(448002)(3190300001)(189002)(199003)(81156007)(48376002)(50226001)(104016004)(106466001)(5001770100001)(6806005)(47776003)(5001960100002)(5003940100001)(229853001)(86362001)(1220700001)(2201001)(2906002)(5008740100001)(2950100001)(107886002)(50986999)(189998001)(92566002)(586003)(97736004)(36756003)(85326001)(1096002)(50466002)(19580395003)(4326007)(4001430100002)(77096005)(19580405001)(87936001)(76176999)(41533002)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR0301MB2072;H:tx30smr01.am.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB2072;2:LFyr04U5c4knaizv71vA83gM1+YgURqJUPKbK2DFelp6hcEjW9115/8SN88VDpIz3KYD9pMy1NhH7GsnP2tBlhXox6rGrhssElDZVoWDjhgxdSGieGAPUoi/ORPrwkwWelg/IxM1hhigGa6Y0p7Ibw==;3:A9XQrmOaRQOeWJe9CD36CDRB0xkpjyy4qSxbse5KX2au4grcfXVW+U1QiCZFnvKjDesWWgWEmNJUau/1jqcXeFPGCydrewP8kkg6SBtBNLwV+iexie5+/IuUP3ehOEcWEnFJB7krLxlci+LkgwWBYKycnbsTr+xYidDEXA6Xci0xFoh1oaq/ykj9BQdbjdsPE5qkBH/83vjoaTMyngwzZhjtuRJFq2MZWyFAsTScLFU=;25:7CLapbNwOifUXcvGsiMC+8GokyUsgTRf3SSMWBSGxWElwGmDXMrQmqnaFNoBFef1LxpWqt+ru+1Yi87Q64rE5/SFuBDnjKeI3TcJF8dT4ZtHZ3BOONvxKpV0If8Czr0+wM1X8/nLzsuVmU+8qWunMhfTZjffuChSi4gIkM6Pni3WN1sf5SXuW8usMnbx6d8gNhWmJNyuphJtpXJTVIlCQw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB2072; X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB2072;20:rZLbYsvFUpoK8ervTXFwuKpwGlzfqF9AA1ej7B72o4S4WMsJ6NuS7waPgQNBuvlhoMpGTKdYDnDLJWHVTSD79rZc75zhy+m0/ILfPWzy1XxqJanGBDCv4iUt6zdIYafmik9uezhBMDM+RcR/ew2oebjbINQH62D3LhwBtEpE9d/zVwXB79Z1yXeLvVrUhbXtAC43Ot76n9Ya5anngteqTpaCOgK2r67PpQDfvbRP/BQw03AHq5G0+bdIdCLo4SbFtIrmBk9O2BmKHw98Fp2DAe6f+stfCXLyFSXCOdMDWVO0T3f90zK1qUoycXR8Q2yoPk/XkB/kYALgyi7106Sxzno8+eVumz72MyjOcmGaDTE=;4:9UvGGuDks/1K1Q6tVXPoY59jg8ttCzd9sfSVxv21IggodeSslpwI6eMmgByJYX+VwZe0bTVYqsIi0upEHIwHL0wq59W9GTdyNEEeW3JJoEZuoWSEphbAzq1Etwu8Mu7ltoHhvxwZzreB8QuevHFS1DYmEBeFjzHfUHHh5RCwCGb4In7lJT6F/D6oCFSahk/pxS+XqVcQzjdW4VRX05Akl0YTCHSPk7CMGjheq2LI41Nsa4AbtFFm6TZER8CKqEPjFcoYDYxI0MUS9VNvkl+p1KW2o+VbuWY9HMU88CUHRKpfn8q6ABMBITW8ZVNb836IJInNlWmcjXlZaIBp2LCv4MnO6j4/6DQ39/epT43P7MBUsUNGL8hkYNwh+F8KGgfIc/ynT5Klhpark6Liq2NcxBPzEX3/jCTU8HVVpZviZPgGXhi+I7v2gxW7S1o1ywOE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:BY2PR0301MB2072;BCL:0;PCL:0;RULEID:;SRVR:BY2PR0301MB2072; X-Forefront-PRVS: 0813C68E65 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY2PR0301MB2072;23:yBa7zuXAT8rt/Kz4jRZRaMV4Ok2R2MZRPCbnxGx?= =?us-ascii?Q?Hs3TxYoR9RwFBUjGKv1lC4W18JcVzIL6aUjdXSPJr54irkuQKx9KkBxzgr2i?= =?us-ascii?Q?B9VJYBBBY7HE63hxh2+icDw5ZCGbtwIY29nDSL5iQsh6zeeVdo83V6tg03Vh?= =?us-ascii?Q?isQfV/noRMGJnbDjqJOpNhXwmNvZgvqwMpLkjmMBltmFh7q2eCL3INAFm/HC?= =?us-ascii?Q?6QjkDts44pdE5Kgwh3CKfiUVwL+IcouUq2kj36crtqzz3JP1dwayWFg3yoo2?= =?us-ascii?Q?17ISuCIhNJs/Pq9xpHoAZW2MujJVl+dqonInJiesPr/mKFRVGKLuY25P9A21?= =?us-ascii?Q?FkisUqlyen9zQPu7NDfVigyGT8eJ8phINd9/cvHAiCjdSioly8wA6kSQHbWz?= =?us-ascii?Q?La3BPY3I/pRvYsJlzTl6T7HIw3+WpHJu3xBAbKWRHNuIq1gKrTK1fvFx7aZY?= =?us-ascii?Q?zDyTF4JtxUrQ9RCcN65u6CXkwveBFbxLhttt8ojRCRaYN+iekyBG3eQD0Qo4?= =?us-ascii?Q?KAeZYv25JWfqFKhvKfJFS8jKpFTPTq7/Y3UMMzaEKngnXAftVBqV7iqRnz4c?= =?us-ascii?Q?A660gK5jgYrJv+31I1RvCoJ3addvQXtTwp1uZQOY6zC06yzIUjcP385743d7?= =?us-ascii?Q?ixWefakcz0E2IQBC5JiEuPnpyb3xF1zVkjK22IankfPrzi7HX/K5NvzLTG6k?= =?us-ascii?Q?cepimZyEv/ro6Gxi5/62GZ2SXmEsB4Zksfv9fVX0X/NNhnEaDPflbPZZDJ5D?= =?us-ascii?Q?uEymi8cMduUEsWLLK7z4mEaLw7LSLqpKD5BDZg+HMcT5QYd5Vtq/+ahtQbZv?= =?us-ascii?Q?GTDX2Bb2E774DkcIQL3ihv5GrNef26BCFInF5pSCma1J7/aiR21sh9SUcOjh?= =?us-ascii?Q?sZZCR2K1fG+vw4ByYMuasHbggs8PG/H2+wF3+3f788Xdm/U0Q3STS0xNBb/o?= =?us-ascii?Q?/huuesdZNc5yB1jYZCQXUM0TpQjSwbdJLrnsAa1fH/t5oR5dAdGqfGH/Nrkr?= =?us-ascii?Q?acDBm7s4+CIUgvPcyVJ9wQRBJ4yfJeUVhYS7ko3yygP4LN/TCUoPHjiBvIZJ?= =?us-ascii?Q?vWGZj3Cm4di0GPY4sDF721X7GhJD7L7gtgPoGKWAK8/Mz/Xi4yHiAgaYVRI5?= =?us-ascii?Q?knFRZe/e3xdM=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY2PR0301MB2072;5:ONRosvcF03nF/g6Ve2G6uItNIAKf/d7Axha3OnceBCPypu++5Hey1aLO3oGN1aNjtpmmtTwsbTrXRcbhEdcPxF8W067m3VpkeANm1LLwqRLNvRtu1Vr9CUVHSbbmJwFwF/QFC2Ba5aUZqamIz5RZUA==;24:7502/WtgsAAJ0ZIjeXGnjfcbBYWwVIXlogGzfuZErQYXfNXcgEtbniW3hsujnUYl7IPbia4OifG7u1+bfyBS+POiJNbkmj07I8EPIUCeatI= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2016 22:21:55.6349 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR0301MB2072 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "J. German Rivera" Created an MSI domain for the fsl-mc bus-- including functions to create a domain, find a domain, alloc/free domain irqs, and bus specific overrides for domain and irq_chip ops. Signed-off-by: J. German Rivera --- CHANGE HISTORY Changes in v4: - Addressed comments from Marc Zyngier: * Re-implemented fsl_mc_find_msi_domain() using of_msi_get_domain() Changes in v3: - Addressed comments from Marc Zyngier: * Added WARN_ON in fsl_mc_msi_set_desc to check that caller does not set set_desc * Changed type of paddr in irq_cfg to be phys_addr_t * Added WARN_ON in fsl_mc_msi_update_chip_op() to check that caller does not set irq_write_msi_msg Changes in v2: none drivers/staging/fsl-mc/bus/Kconfig | 1 + drivers/staging/fsl-mc/bus/Makefile | 1 + drivers/staging/fsl-mc/bus/mc-msi.c | 276 ++++++++++++++++++++++++++++ drivers/staging/fsl-mc/include/dprc.h | 2 +- drivers/staging/fsl-mc/include/mc-private.h | 17 ++ drivers/staging/fsl-mc/include/mc.h | 17 ++ 6 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/fsl-mc/bus/mc-msi.c diff --git a/drivers/staging/fsl-mc/bus/Kconfig b/drivers/staging/fsl-mc/bus/Kconfig index 0d779d9..c498ac6 100644 --- a/drivers/staging/fsl-mc/bus/Kconfig +++ b/drivers/staging/fsl-mc/bus/Kconfig @@ -9,6 +9,7 @@ config FSL_MC_BUS tristate "Freescale Management Complex (MC) bus driver" depends on OF && ARM64 + select GENERIC_MSI_IRQ_DOMAIN help Driver to enable the bus infrastructure for the Freescale QorIQ Management Complex (fsl-mc). The fsl-mc is a hardware diff --git a/drivers/staging/fsl-mc/bus/Makefile b/drivers/staging/fsl-mc/bus/Makefile index 25433a9..a5f2ba4 100644 --- a/drivers/staging/fsl-mc/bus/Makefile +++ b/drivers/staging/fsl-mc/bus/Makefile @@ -13,5 +13,6 @@ mc-bus-driver-objs := mc-bus.o \ dpmng.o \ dprc-driver.o \ mc-allocator.o \ + mc-msi.o \ dpmcp.o \ dpbp.o diff --git a/drivers/staging/fsl-mc/bus/mc-msi.c b/drivers/staging/fsl-mc/bus/mc-msi.c new file mode 100644 index 0000000..3a8258f --- /dev/null +++ b/drivers/staging/fsl-mc/bus/mc-msi.c @@ -0,0 +1,276 @@ +/* + * Freescale Management Complex (MC) bus driver MSI support + * + * Copyright (C) 2015 Freescale Semiconductor, Inc. + * Author: German Rivera + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#include "../include/mc-private.h" +#include +#include +#include +#include +#include +#include +#include +#include "../include/mc-sys.h" +#include "dprc-cmd.h" + +static void fsl_mc_msi_set_desc(msi_alloc_info_t *arg, + struct msi_desc *desc) +{ + arg->desc = desc; + arg->hwirq = (irq_hw_number_t)desc->fsl_mc.msi_index; +} + +static void fsl_mc_msi_update_dom_ops(struct msi_domain_info *info) +{ + struct msi_domain_ops *ops = info->ops; + + if (WARN_ON(!ops)) + return; + + /* + * set_desc should not be set by the caller + */ + if (WARN_ON(ops->set_desc)) + return; + + ops->set_desc = fsl_mc_msi_set_desc; +} + +static void __fsl_mc_msi_write_msg(struct fsl_mc_device *mc_bus_dev, + struct fsl_mc_device_irq *mc_dev_irq) +{ + int error; + struct fsl_mc_device *owner_mc_dev = mc_dev_irq->mc_dev; + struct msi_desc *msi_desc = mc_dev_irq->msi_desc; + struct dprc_irq_cfg irq_cfg; + + /* + * msi_desc->msg.address is 0x0 when this function is invoked in + * the free_irq() code path. In this case, for the MC, we don't + * really need to "unprogram" the MSI, so we just return. + */ + if (msi_desc->msg.address_lo == 0x0 && msi_desc->msg.address_hi == 0x0) + return; + + if (WARN_ON(!owner_mc_dev)) + return; + + irq_cfg.paddr = ((u64)msi_desc->msg.address_hi << 32) | + msi_desc->msg.address_lo; + irq_cfg.val = msi_desc->msg.data; + irq_cfg.user_irq_id = msi_desc->irq; + + if (owner_mc_dev == mc_bus_dev) { + /* + * IRQ is for the mc_bus_dev's DPRC itself + */ + error = dprc_set_irq(mc_bus_dev->mc_io, + MC_CMD_FLAG_INTR_DIS | MC_CMD_FLAG_PRI, + mc_bus_dev->mc_handle, + mc_dev_irq->dev_irq_index, + &irq_cfg); + if (error < 0) { + dev_err(&owner_mc_dev->dev, + "dprc_set_irq() failed: %d\n", error); + } + } else { + /* + * IRQ is for for a child device of mc_bus_dev + */ + error = dprc_set_obj_irq(mc_bus_dev->mc_io, + MC_CMD_FLAG_INTR_DIS | MC_CMD_FLAG_PRI, + mc_bus_dev->mc_handle, + owner_mc_dev->obj_desc.type, + owner_mc_dev->obj_desc.id, + mc_dev_irq->dev_irq_index, + &irq_cfg); + if (error < 0) { + dev_err(&owner_mc_dev->dev, + "dprc_obj_set_irq() failed: %d\n", error); + } + } +} + +/* + * NOTE: This function is invoked with interrupts disabled + */ +static void fsl_mc_msi_write_msg(struct irq_data *irq_data, + struct msi_msg *msg) +{ + struct msi_desc *msi_desc = irq_data_get_msi_desc(irq_data); + struct fsl_mc_device *mc_bus_dev = to_fsl_mc_device(msi_desc->dev); + struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev); + struct fsl_mc_device_irq *mc_dev_irq = + &mc_bus->irq_resources[msi_desc->fsl_mc.msi_index]; + + WARN_ON(mc_dev_irq->msi_desc != msi_desc); + msi_desc->msg = *msg; + + /* + * Program the MSI (paddr, value) pair in the device: + */ + __fsl_mc_msi_write_msg(mc_bus_dev, mc_dev_irq); +} + +static void fsl_mc_msi_update_chip_ops(struct msi_domain_info *info) +{ + struct irq_chip *chip = info->chip; + + if (WARN_ON((!chip))) + return; + + /* + * irq_write_msi_msg should not be set by the caller + */ + if (WARN_ON(chip->irq_write_msi_msg)) + return; + + chip->irq_write_msi_msg = fsl_mc_msi_write_msg; +} + +/** + * fsl_mc_msi_create_irq_domain - Create a fsl-mc MSI interrupt domain + * @np: Optional device-tree node of the interrupt controller + * @info: MSI domain info + * @parent: Parent irq domain + * + * Updates the domain and chip ops and creates a fsl-mc MSI + * interrupt domain. + * + * Returns: + * A domain pointer or NULL in case of failure. + */ +struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode, + struct msi_domain_info *info, + struct irq_domain *parent) +{ + struct irq_domain *domain; + + if (info->flags & MSI_FLAG_USE_DEF_DOM_OPS) + fsl_mc_msi_update_dom_ops(info); + if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) + fsl_mc_msi_update_chip_ops(info); + + domain = msi_create_irq_domain(fwnode, info, parent); + if (domain) + domain->bus_token = DOMAIN_BUS_FSL_MC_MSI; + + return domain; +} + +int fsl_mc_find_msi_domain(struct device *mc_platform_dev, + struct irq_domain **mc_msi_domain) +{ + struct irq_domain *msi_domain; + struct device_node *mc_of_node = mc_platform_dev->of_node; + + msi_domain = of_msi_get_domain(mc_platform_dev, mc_of_node, + DOMAIN_BUS_FSL_MC_MSI); + if (!msi_domain) { + pr_err("Unable to find fsl-mc MSI domain for %s\n", + mc_of_node->full_name); + + return -ENOENT; + } + + *mc_msi_domain = msi_domain; + return 0; +} + +static void fsl_mc_msi_free_descs(struct device *dev) +{ + struct msi_desc *desc, *tmp; + + list_for_each_entry_safe(desc, tmp, dev_to_msi_list(dev), list) { + list_del(&desc->list); + free_msi_entry(desc); + } +} + +static int fsl_mc_msi_alloc_descs(struct device *dev, unsigned int irq_count) + +{ + unsigned int i; + int error; + struct msi_desc *msi_desc; + + for (i = 0; i < irq_count; i++) { + msi_desc = alloc_msi_entry(dev); + if (!msi_desc) { + dev_err(dev, "Failed to allocate msi entry\n"); + error = -ENOMEM; + goto cleanup_msi_descs; + } + + msi_desc->fsl_mc.msi_index = i; + msi_desc->nvec_used = 1; + INIT_LIST_HEAD(&msi_desc->list); + list_add_tail(&msi_desc->list, dev_to_msi_list(dev)); + } + + return 0; + +cleanup_msi_descs: + fsl_mc_msi_free_descs(dev); + return error; +} + +int fsl_mc_msi_domain_alloc_irqs(struct device *dev, + unsigned int irq_count) +{ + struct irq_domain *msi_domain; + int error; + + if (WARN_ON(!list_empty(dev_to_msi_list(dev)))) + return -EINVAL; + + error = fsl_mc_msi_alloc_descs(dev, irq_count); + if (error < 0) + return error; + + msi_domain = dev_get_msi_domain(dev); + if (WARN_ON(!msi_domain)) { + error = -EINVAL; + goto cleanup_msi_descs; + } + + /* + * NOTE: Calling this function will trigger the invocation of the + * its_fsl_mc_msi_prepare() callback + */ + error = msi_domain_alloc_irqs(msi_domain, dev, irq_count); + + if (error) { + dev_err(dev, "Failed to allocate IRQs\n"); + goto cleanup_msi_descs; + } + + return 0; + +cleanup_msi_descs: + fsl_mc_msi_free_descs(dev); + return error; +} + +void fsl_mc_msi_domain_free_irqs(struct device *dev) +{ + struct irq_domain *msi_domain; + + msi_domain = dev_get_msi_domain(dev); + if (WARN_ON(!msi_domain)) + return; + + msi_domain_free_irqs(msi_domain, dev); + + if (WARN_ON(list_empty(dev_to_msi_list(dev)))) + return; + + fsl_mc_msi_free_descs(dev); +} diff --git a/drivers/staging/fsl-mc/include/dprc.h b/drivers/staging/fsl-mc/include/dprc.h index c3152f6..94c4927 100644 --- a/drivers/staging/fsl-mc/include/dprc.h +++ b/drivers/staging/fsl-mc/include/dprc.h @@ -176,7 +176,7 @@ int dprc_reset_container(struct fsl_mc_io *mc_io, * @user_irq_id: A user defined number associated with this IRQ */ struct dprc_irq_cfg { - u64 paddr; + phys_addr_t paddr; u32 val; int user_irq_id; }; diff --git a/drivers/staging/fsl-mc/include/mc-private.h b/drivers/staging/fsl-mc/include/mc-private.h index c706f77..36b418c 100644 --- a/drivers/staging/fsl-mc/include/mc-private.h +++ b/drivers/staging/fsl-mc/include/mc-private.h @@ -26,6 +26,9 @@ strcmp(_obj_type, "dpmcp") == 0 || \ strcmp(_obj_type, "dpcon") == 0) +struct irq_domain; +struct msi_domain_info; + /** * struct fsl_mc - Private data of a "fsl,qoriq-mc" platform device * @root_mc_bus_dev: MC object device representing the root DPRC @@ -79,11 +82,13 @@ struct fsl_mc_resource_pool { * @resource_pools: array of resource pools (one pool per resource type) * for this MC bus. These resources represent allocatable entities * from the physical DPRC. + * @irq_resources: Pointer to array of IRQ objects for the IRQ pool * @scan_mutex: Serializes bus scanning */ struct fsl_mc_bus { struct fsl_mc_device mc_dev; struct fsl_mc_resource_pool resource_pools[FSL_MC_NUM_POOL_TYPES]; + struct fsl_mc_device_irq *irq_resources; struct mutex scan_mutex; /* serializes bus scanning */ }; @@ -116,4 +121,16 @@ int __must_check fsl_mc_resource_allocate(struct fsl_mc_bus *mc_bus, void fsl_mc_resource_free(struct fsl_mc_resource *resource); +struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode, + struct msi_domain_info *info, + struct irq_domain *parent); + +int fsl_mc_find_msi_domain(struct device *mc_platform_dev, + struct irq_domain **mc_msi_domain); + +int fsl_mc_msi_domain_alloc_irqs(struct device *dev, + unsigned int irq_count); + +void fsl_mc_msi_domain_free_irqs(struct device *dev); + #endif /* _FSL_MC_PRIVATE_H_ */ diff --git a/drivers/staging/fsl-mc/include/mc.h b/drivers/staging/fsl-mc/include/mc.h index a933291..1c1d6ae 100644 --- a/drivers/staging/fsl-mc/include/mc.h +++ b/drivers/staging/fsl-mc/include/mc.h @@ -104,6 +104,23 @@ struct fsl_mc_resource { }; /** + * struct fsl_mc_device_irq - MC object device message-based interrupt + * @msi_desc: pointer to MSI descriptor allocated by fsl_mc_msi_alloc_descs() + * @mc_dev: MC object device that owns this interrupt + * @dev_irq_index: device-relative IRQ index + * @resource: MC generic resource associated with the interrupt + */ +struct fsl_mc_device_irq { + struct msi_desc *msi_desc; + struct fsl_mc_device *mc_dev; + u8 dev_irq_index; + struct fsl_mc_resource resource; +}; + +#define to_fsl_mc_irq(_mc_resource) \ + container_of(_mc_resource, struct fsl_mc_device_irq, resource) + +/** * Bit masks for a MC object device (struct fsl_mc_device) flags */ #define FSL_MC_IS_DPRC 0x0001 -- 2.3.3