Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -17699,6 +17699,12 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git nand/next
F: drivers/mtd/nand/
F: include/linux/mtd/*nand*.h

NATIONAL INSTRUMENTS DEVICETREE IRQ RESOLVER
M: Alison Montag <[email protected]>
S: Maintained
F: drivers/misc/niirqresolver.c
F: include/linux/niirqresolver.h

NATIONAL INSTRUMENTS SERIAL DRIVER
M: Chaitanya Vadrevu <[email protected]>
L: [email protected]
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/nati_bluefin_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=16384
CONFIG_SRAM=y
CONFIG_NI_IRQ_RESOLVER=y

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bluefin and slsc have no need for this, neither of them use nikal-based drivers

CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_AT25=y
CONFIG_SCSI=y
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/nati_slsc_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=16384
CONFIG_SRAM=y
CONFIG_NI_IRQ_RESOLVER=y
CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_AT25=y
CONFIG_EEPROM_93CX6=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/nati_zynq_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ CONFIG_BLK_DEV_RAM_SIZE=16384
CONFIG_FPGA_PERIPHERAL=y
CONFIG_NIZYNQ_CPLD=y
CONFIG_SRAM=y
CONFIG_NI_IRQ_RESOLVER=y
Comment thread
alispss marked this conversation as resolved.
CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_AT25=y
CONFIG_SCSI=y
Expand Down
10 changes: 10 additions & 0 deletions drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,16 @@ config NI_WATCHDOG

If unsure, say N (but it's safe to say "Y").

config NI_IRQ_RESOLVER
bool "NI interrupt resolver"
depends on ARCH_ZYNQ
help
Resolves the Linux virtual IRQ for the HW interrupts.
Required for NI-RIO Zynq HW on kernels where the
GIC allocates virtual IRQs dynamically.

If unsure, say Y on NI-RIO Zynq targets.

source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ obj-$(CONFIG_MISC_RP1) += rp1/
obj-$(CONFIG_NI_RT_FEATURES) += nirtfeatures.o
obj-$(CONFIG_NI_WATCHDOG) += niwatchdog.o
obj-$(CONFIG_FPGA_PERIPHERAL) += fpgaperipheral.o
obj-$(CONFIG_NI_IRQ_RESOLVER) += niirqresolver.o
56 changes: 56 additions & 0 deletions drivers/misc/niirqresolver.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Generic devicetree interrupt specifier -> Linux virq resolver.
*
* This file has no knowledge of any specific device, board, or interrupt
* controller: the caller supplies the controller's devicetree "compatible"
* string and its raw, controller-specific interrupt specifier cells (for
* example <type, spi-number, trigger-flags> for an ARM GIC).
*/

#include <linux/export.h>
#include <linux/niirqresolver.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/types.h>

/**
* ni_of_resolve_irq - resolve a Linux virq from a devicetree interrupt specifier
* @compatible: devicetree "compatible" string of the interrupt controller node
* @args: raw interrupt specifier cells, controller-specific
* @args_count: number of valid entries in @args (must not exceed MAX_PHANDLE_ARGS)
*
* Finds the first devicetree node matching @compatible and asks its
* irqdomain to map @args to a Linux virq. Repeated calls with the same
* arguments return the same virq.
*
* Return: the Linux virtual IRQ number, or 0 if it could not be resolved
* (no matching node, args_count out of range, or the domain couldn't map it).
*/
unsigned int ni_of_resolve_irq(const char *compatible, const unsigned int *args,
unsigned int args_count)
{
struct device_node *node;
struct of_phandle_args irq_spec;
unsigned int virq;
unsigned int i;

if (args_count > MAX_PHANDLE_ARGS)
return 0;

node = of_find_compatible_node(NULL, NULL, compatible);
if (!node)
return 0;

irq_spec.np = node;
irq_spec.args_count = args_count;
for (i = 0; i < args_count; i++)
irq_spec.args[i] = args[i];

virq = irq_create_of_mapping(&irq_spec);

of_node_put(node);

return virq;
}
EXPORT_SYMBOL(ni_of_resolve_irq);
23 changes: 23 additions & 0 deletions include/linux/niirqresolver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/* SPDX-License-Identifier: GPL-2.0 */
/*
* Generic devicetree interrupt specifier -> Linux virq resolver.
*
* Public declaration for the NI IRQ resolver implemented in
* drivers/misc/niirqresolver.c.
*/

#ifndef _LINUX_NIIRQRESOLVER_H_
#define _LINUX_NIIRQRESOLVER_H_

/**
* ni_of_resolve_irq - resolve a Linux virq from a devicetree interrupt specifier
* @compatible: devicetree "compatible" string of the interrupt controller node
* @args: raw interrupt specifier cells, controller-specific
* @args_count: number of valid entries in @args (must not exceed MAX_PHANDLE_ARGS)
*
* Return: the Linux virtual IRQ number, or 0 if it could not be resolved.
*/
unsigned int ni_of_resolve_irq(const char *compatible, const unsigned int *args,
unsigned int args_count);

#endif /* _LINUX_NIIRQRESOLVER_H_ */
Loading