x86: Move UCLASS_IRQ into a separate file
authorSimon Glass <sjg@chromium.org>
Sat, 7 Dec 2019 04:41:58 +0000 (21:41 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Sun, 15 Dec 2019 03:44:12 +0000 (11:44 +0800)
Update this uclass to support the needs of the Apollo Lake ITSS. It
supports four operations.

Move the uclass into a separate directory so that sandbox can use it too.
Add a new Kconfig to control it and enable this on x86.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
arch/Kconfig
arch/x86/cpu/irq.c
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/irq-uclass.c [new file with mode: 0644]
include/irq.h [new file with mode: 0644]

index e1f1fcd275bbf414d0f773a1013b5a05ae6e1817..6865e1f909ed404f89b6666355319c87ffbaacc0 100644 (file)
@@ -186,6 +186,7 @@ config X86
        imply USB_HOST_ETHER
        imply PCH
        imply RTC_MC146818
+       imply IRQ
 
        # Thing to enable for when SPL/TPL are enabled: SPL
        imply SPL_DM
index 3adc155818c89a0317ffb77c9e380dc045886f98..cb183496b7a9cfeba89048c2c62131d545e12cb6 100644 (file)
@@ -370,8 +370,3 @@ U_BOOT_DRIVER(irq_router_drv) = {
        .probe          = irq_router_probe,
        .priv_auto_alloc_size = sizeof(struct irq_router),
 };
-
-UCLASS_DRIVER(irq) = {
-       .id             = UCLASS_IRQ,
-       .name           = "irq",
-};
index 71643af9c263461437e0ef7c92f8c431b018b790..f18aa8f7ba930e5ae256e9c88e7cda49f5eff4a0 100644 (file)
@@ -203,6 +203,15 @@ config FSL_SEC_MON
          Security Monitor can be transitioned on any security failures,
          like software violations or hardware security violations.
 
+config IRQ
+       bool "Intel Interrupt controller"
+       depends on X86 || SANDBOX
+       help
+         This enables support for Intel interrupt controllers, including ITSS.
+         Some devices have extra features, such as Apollo Lake. The
+         device has its own uclass since there are several operations
+         involved.
+
 config JZ4780_EFUSE
        bool "Ingenic JZ4780 eFUSE support"
        depends on ARCH_JZ47XX
index 44c9e3ef0855b5c0661a8e084d649784497647e5..28313e4a658944fccc0ed443114d13626d651b71 100644 (file)
@@ -41,6 +41,7 @@ obj-$(CONFIG_FS_LOADER) += fs_loader.o
 obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
 obj-$(CONFIG_GDSYS_SOC) += gdsys_soc.o
+obj-$(CONFIG_IRQ) += irq-uclass.o
 obj-$(CONFIG_$(SPL_)I2C_EEPROM) += i2c_eeprom.o
 obj-$(CONFIG_IHS_FPGA) += ihs_fpga.o
 obj-$(CONFIG_IMX8) += imx8/
diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c
new file mode 100644 (file)
index 0000000..d5182cf
--- /dev/null
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <irq.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);
+}
+
+UCLASS_DRIVER(irq) = {
+       .id             = UCLASS_IRQ,
+       .name           = "irq",
+};
diff --git a/include/irq.h b/include/irq.h
new file mode 100644 (file)
index 0000000..01ded64
--- /dev/null
@@ -0,0 +1,88 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * IRQ is a type of interrupt controller used on recent Intel SoC.
+ *
+ * Copyright 2019 Google LLC
+ */
+
+#ifndef __irq_H
+#define __irq_H
+
+/**
+ * struct irq_ops - Operations for the IRQ
+ */
+struct irq_ops {
+       /**
+        * route_pmc_gpio_gpe() - Get the GPIO for an event
+        *
+        * @dev: IRQ device
+        * @pmc_gpe_num: Event number to check
+        * @returns GPIO for the event, or -ENOENT if none
+        */
+       int (*route_pmc_gpio_gpe)(struct udevice *dev, uint pmc_gpe_num);
+
+       /**
+        * set_polarity() - Set the IRQ polarity
+        *
+        * @dev: IRQ device
+        * @irq: Interrupt number to set
+        * @active_low: true if active low, false for active high
+        * @return 0 if OK, -EINVAL if @irq is invalid
+        */
+       int (*set_polarity)(struct udevice *dev, uint irq, bool active_low);
+
+       /**
+        * snapshot_polarities() - record IRQ polarities for later restore
+        *
+        * @dev: IRQ device
+        * @return 0
+        */
+       int (*snapshot_polarities)(struct udevice *dev);
+
+       /**
+        * restore_polarities() - restore IRQ polarities
+        *
+        * @dev: IRQ device
+        * @return 0
+        */
+       int (*restore_polarities)(struct udevice *dev);
+};
+
+#define irq_get_ops(dev)       ((struct irq_ops *)(dev)->driver->ops)
+
+/**
+ * irq_route_pmc_gpio_gpe() - Get the GPIO for an event
+ *
+ * @dev: IRQ device
+ * @pmc_gpe_num: Event number to check
+ * @returns GPIO for the event, or -ENOENT if none
+ */
+int irq_route_pmc_gpio_gpe(struct udevice *dev, uint pmc_gpe_num);
+
+/**
+ * irq_set_polarity() - Set the IRQ polarity
+ *
+ * @dev: IRQ device
+ * @irq: Interrupt number to set
+ * @active_low: true if active low, false for active high
+ * @return 0 if OK, -EINVAL if @irq is invalid
+ */
+int irq_set_polarity(struct udevice *dev, uint irq, bool active_low);
+
+/**
+ * irq_snapshot_polarities() - record IRQ polarities for later restore
+ *
+ * @dev: IRQ device
+ * @return 0
+ */
+int irq_snapshot_polarities(struct udevice *dev);
+
+/**
+ * irq_restore_polarities() - restore IRQ polarities
+ *
+ * @dev: IRQ device
+ * @return 0
+ */
+int irq_restore_polarities(struct udevice *dev);
+
+#endif