u-boot-brain/drivers/misc/irq-uclass.c
Simon Glass ba87607971 dm: irq: Add support for interrupt controller types
There can be different types of interrupt controllers in a system and some
drivers may need to distinguish between these. In general this can be
handled using the device tree by adding the interrupt information to
device nodes.

However on x86 devices we have interrupt controllers which are not tied
to any particular device and not really used in U-Boot. These still need
to be inited, so a convenient method is to give each controller a type
and allow a particular controller type to be probed.

Add support for this in sandbox along with a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
[bmeng: remove the new bland line at EOF of test/dm/irq.c]
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2020-02-07 22:44:59 +08:00

67 lines
1.3 KiB
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright 2019 Google, LLC
* Written by Simon Glass <sjg@chromium.org>
*/
#include <common.h>
#include <dm.h>
#include <irq.h>
#include <dm/device-internal.h>
int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num)
{
const struct irq_ops *ops = irq_get_ops(dev);
if (!ops->route_pmc_gpio_gpe)
return -ENOSYS;
return ops->route_pmc_gpio_gpe(dev, pmc_gpe_num);
}
int irq_set_polarity(struct udevice *dev, uint irq, bool active_low)
{
const struct irq_ops *ops = irq_get_ops(dev);
if (!ops->set_polarity)
return -ENOSYS;
return ops->set_polarity(dev, irq, active_low);
}
int irq_snapshot_polarities(struct udevice *dev)
{
const struct irq_ops *ops = irq_get_ops(dev);
if (!ops->snapshot_polarities)
return -ENOSYS;
return ops->snapshot_polarities(dev);
}
int irq_restore_polarities(struct udevice *dev)
{
const struct irq_ops *ops = irq_get_ops(dev);
if (!ops->restore_polarities)
return -ENOSYS;
return ops->restore_polarities(dev);
}
int irq_first_device_type(enum irq_dev_t type, struct udevice **devp)
{
int ret;
ret = uclass_first_device_drvdata(UCLASS_IRQ, type, devp);
if (ret)
return log_msg_ret("find", ret);
return 0;
}
UCLASS_DRIVER(irq) = {
.id = UCLASS_IRQ,
.name = "irq",
};