misc: add Qualcomm GENI SE QUP device driver
authorVladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Fri, 21 Apr 2023 17:50:33 +0000 (20:50 +0300)
committerTom Rini <trini@konsulko.com>
Tue, 2 May 2023 18:23:58 +0000 (14:23 -0400)
This change adds a Qualcomm GENI SE QUP device driver as a wrapper for
actually enabled and used serial devices found on a board.

At the moment the driver is pretty simple, its intention is to populate
childred devices and provide I/O mem read interface to them as clients,
this is needed for GENI UART driver to set up a proper clock divider
and provide the actually asked baud rate.

Signed-off-by: Vladimir Zapolskiy <vladimir.zapolskiy@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/qcom-geni-se.c [new file with mode: 0644]

index 4e1ae03..04460f1 100644 (file)
@@ -511,6 +511,13 @@ config WINBOND_W83627
          legacy UART or other devices in the Winbond Super IO chips
          on X86 platforms.
 
+config QCOM_GENI_SE
+       bool "Qualcomm GENI Serial Engine Driver"
+       depends on ARCH_SNAPDRAGON
+       help
+         The driver manages Generic Interface (GENI) firmware based
+         Qualcomm Technologies, Inc. Universal Peripheral (QUP) Wrapper.
+
 config QFW
        bool
        help
index 3b792f2..52aed09 100644 (file)
@@ -60,6 +60,7 @@ obj-$(CONFIG_NUVOTON_NCT6102D) += nuvoton_nct6102d.o
 obj-$(CONFIG_P2SB) += p2sb-uclass.o
 obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
 obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
+obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o
 ifdef CONFIG_QFW
 obj-y += qfw.o
 obj-$(CONFIG_QFW_PIO) += qfw_pio.o
diff --git a/drivers/misc/qcom-geni-se.c b/drivers/misc/qcom-geni-se.c
new file mode 100644 (file)
index 0000000..281a5ec
--- /dev/null
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm Generic Interface (GENI) Serial Engine (SE) Wrapper
+ *
+ * Copyright (C) 2023 Linaro Ltd. <vladimir.zapolskiy@linaro.org>
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <misc.h>
+#include <asm/io.h>
+
+static int geni_se_qup_read(struct udevice *dev, int offset,
+                           void *buf, int size)
+{
+       fdt_addr_t base = dev_read_addr(dev);
+
+       if (size != sizeof(u32))
+               return -EINVAL;
+
+       *(u32 *)buf = readl(base + offset);
+
+       return size;
+}
+
+static struct misc_ops geni_se_qup_ops = {
+       .read = geni_se_qup_read,
+};
+
+static const struct udevice_id geni_se_qup_ids[] = {
+       { .compatible = "qcom,geni-se-qup" },
+       {}
+};
+
+U_BOOT_DRIVER(geni_se_qup) = {
+       .name = "geni_se_qup",
+       .id = UCLASS_MISC,
+       .of_match = geni_se_qup_ids,
+       .ops = &geni_se_qup_ops,
+       .flags  = DM_FLAG_PRE_RELOC,
+};