From: Harry Austen <hpausten@protonmail.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Michal Simek <michal.simek@amd.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>,
Dave Ertman <david.m.ertman@intel.com>,
Ira Weiny <ira.weiny@intel.com>,
linux-clk@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Harry Austen <hpausten@protonmail.com>
Subject: [PATCH v3 7/9] uio: add Xilinx user clock monitor support
Date: Mon, 26 Aug 2024 12:38:36 +0000 [thread overview]
Message-ID: <20240826123602.1872-8-hpausten@protonmail.com> (raw)
In-Reply-To: <20240826123602.1872-1-hpausten@protonmail.com>
Xilinx clocking wizard IP core supports monitoring of up to four
optional user clock inputs, with a corresponding interrupt for
notification in change of clock state (stop, underrun, overrun or
glitch). Give userspace access to this monitor logic through use of the
UIO framework.
Implemented as an auxiliary_driver to avoid introducing UIO dependency
to the main clock driver.
Signed-off-by: Harry Austen <hpausten@protonmail.com>
---
drivers/uio/Kconfig | 8 ++++
drivers/uio/Makefile | 1 +
drivers/uio/uio_xlnx_clk_mon.c | 71 ++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+)
create mode 100644 drivers/uio/uio_xlnx_clk_mon.c
diff --git a/drivers/uio/Kconfig b/drivers/uio/Kconfig
index b060dcd7c6350..ca8a53de26a67 100644
--- a/drivers/uio/Kconfig
+++ b/drivers/uio/Kconfig
@@ -164,4 +164,12 @@ config UIO_DFL
opae-sdk/tools/libopaeuio/
If you compile this as a module, it will be called uio_dfl.
+
+config UIO_XLNX_CLK_MON
+ tristate "Xilinx user clock monitor support"
+ depends on COMMON_CLK_XLNX_CLKWZRD
+ help
+ Userspace I/O interface to the user clock monitor logic within the
+ Xilinx Clocking Wizard IP core.
+
endif
diff --git a/drivers/uio/Makefile b/drivers/uio/Makefile
index 1c5f3b5a95cf5..1e8c242265431 100644
--- a/drivers/uio/Makefile
+++ b/drivers/uio/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_UIO_MF624) += uio_mf624.o
obj-$(CONFIG_UIO_FSL_ELBC_GPCM) += uio_fsl_elbc_gpcm.o
obj-$(CONFIG_UIO_HV_GENERIC) += uio_hv_generic.o
obj-$(CONFIG_UIO_DFL) += uio_dfl.o
+obj-$(CONFIG_UIO_XLNX_CLK_MON) += uio_xlnx_clk_mon.o
diff --git a/drivers/uio/uio_xlnx_clk_mon.c b/drivers/uio/uio_xlnx_clk_mon.c
new file mode 100644
index 0000000000000..afcbeae98eaaf
--- /dev/null
+++ b/drivers/uio/uio_xlnx_clk_mon.c
@@ -0,0 +1,71 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Driver for user clock monitor logic within Xilinx 'Clocking Wizard' IP core
+ *
+ * Copyright (C) 2024 Harry Austen <hpausten@protonmail.com>
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/bits.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/uio_driver.h>
+
+#define WZRD_INTR_ENABLE 0x10
+
+static int clk_mon_irqcontrol(struct uio_info *info, s32 irq_on)
+{
+ if (irq_on)
+ iowrite32(GENMASK(15, 0), info->mem[0].internal_addr + WZRD_INTR_ENABLE);
+ else
+ iowrite32(0, info->mem[0].internal_addr + WZRD_INTR_ENABLE);
+
+ return 0;
+}
+
+static int probe(struct auxiliary_device *adev, const struct auxiliary_device_id *id)
+{
+ struct platform_device *pdev = to_platform_device(adev->dev.parent);
+ struct device *dev = &adev->dev;
+ struct uio_info *info;
+ int irq;
+
+ info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+ if (!info)
+ return -ENOMEM;
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0)
+ return 0;
+
+ info->name = KBUILD_MODNAME;
+ info->version = "0.0.1";
+
+ info->mem[0].name = "clock monitor";
+ info->mem[0].memtype = UIO_MEM_PHYS;
+ info->mem[0].addr = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
+ info->mem[0].size = (WZRD_INTR_ENABLE + 4 + PAGE_SIZE - 1) & PAGE_MASK;
+ info->mem[0].internal_addr = (__force void __iomem *)dev->platform_data;
+
+ info->irq = irq;
+ info->irqcontrol = clk_mon_irqcontrol;
+ return devm_uio_register_device(dev, info);
+}
+
+static struct auxiliary_device_id ids[] = {
+ { .name = "clk_xlnx_clock_wizard.clk-mon" },
+ {}
+};
+MODULE_DEVICE_TABLE(auxiliary, ids);
+
+static struct auxiliary_driver xlnx_clk_mon_driver = {
+ .id_table = ids,
+ .probe = probe,
+};
+
+module_auxiliary_driver(xlnx_clk_mon_driver);
+
+MODULE_AUTHOR("Harry Austen <hpausten@protonmail.com>");
+MODULE_DESCRIPTION("Driver for Xilinx user clock monitor logic");
+MODULE_LICENSE("GPL");
--
2.46.0
next prev parent reply other threads:[~2024-08-26 12:38 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 12:38 [PATCH v3 0/9] clk: clocking-wizard: add user clock monitor support Harry Austen
2024-08-26 12:38 ` [PATCH v3 1/9] clk: clocking-wizard: simplify probe/remove with devres helpers Harry Austen
2024-08-26 12:38 ` [PATCH v3 2/9] clk: clocking-wizard: use newer clk_hw API Harry Austen
2024-08-26 12:38 ` [PATCH v3 3/9] clk: clocking-wizard: use devres versions of " Harry Austen
2024-08-26 12:38 ` [PATCH v3 4/9] clk: clocking-wizard: move clock registration to separate function Harry Austen
2024-08-26 12:38 ` [PATCH v3 5/9] dt-bindings: clock: xilinx: add description of user monitor interrupt Harry Austen
2024-08-26 12:38 ` [PATCH v3 6/9] clk: clocking-wizard: add user clock monitor support Harry Austen
2024-08-26 12:38 ` Harry Austen [this message]
2024-08-26 13:11 ` [PATCH v3 7/9] uio: add Xilinx " Greg Kroah-Hartman
2024-08-27 19:08 ` Harry Austen
2024-08-27 23:40 ` Stephen Boyd
2024-08-28 7:10 ` Greg Kroah-Hartman
2024-08-29 18:17 ` Stephen Boyd
2024-08-30 7:31 ` Harry Austen
2024-08-26 12:38 ` [PATCH v3 8/9] dt-bindings: clock: xilinx: describe whether dynamic reconfig is enabled Harry Austen
2024-08-26 12:38 ` [PATCH v3 9/9] clk: clocking-wizard: move dynamic reconfig setup behind flag Harry Austen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240826123602.1872-8-hpausten@protonmail.com \
--to=hpausten@protonmail.com \
--cc=conor+dt@kernel.org \
--cc=david.m.ertman@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=ira.weiny@intel.com \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michal.simek@amd.com \
--cc=mturquette@baylibre.com \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=shubhrajyoti.datta@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.