2019-12-07 04:41:58 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
2020-02-06 16:54:57 +00:00
|
|
|
* Copyright 2019 Google, LLC
|
|
|
|
* Written by Simon Glass <sjg@chromium.org>
|
2019-12-07 04:41:58 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <dm.h>
|
|
|
|
#include <irq.h>
|
2020-02-06 16:54:57 +00:00
|
|
|
#include <dm/device-internal.h>
|
2019-12-07 04:41:58 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-02-06 16:54:57 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-12-07 04:41:58 +00:00
|
|
|
UCLASS_DRIVER(irq) = {
|
|
|
|
.id = UCLASS_IRQ,
|
|
|
|
.name = "irq",
|
|
|
|
};
|