Re: [PATCH 1/6 v5] serial: qcom: add support for GENI serial driver

2021-10-31 Thread Tom Rini
On Sun, Oct 17, 2021 at 01:44:27PM +0300, Dzmitry Sankouski wrote:

> Generic Interface (GENI) Serial Engine (SE) based uart
> can be found on newer qualcomm SOCs, starting from SDM845.
> Tested on Samsung SM-G9600(starqltechn)
> by chain-loading u-boot with stock bootloader.
> 
> Signed-off-by: Dzmitry Sankouski 
> Cc: Ramon Fried 
> Cc: Tom Rini 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH 1/6 v5] serial: qcom: add support for GENI serial driver

2021-10-17 Thread Dzmitry Sankouski
Generic Interface (GENI) Serial Engine (SE) based uart
can be found on newer qualcomm SOCs, starting from SDM845.
Tested on Samsung SM-G9600(starqltechn)
by chain-loading u-boot with stock bootloader.

Signed-off-by: Dzmitry Sankouski 
Cc: Ramon Fried 
Cc: Tom Rini 
---
Changes for v2:
- change functions return type to void, where possible
- remove '.' from summary line
Changes for v3:
- move function open brace on new line
- use tab between define name and value
- define: wrap expression with braces, remove braces from constants
Changes for v4:
- add linux/delay.h header
Changes for v5:
- Kconfig: break long lines
- rearrange definitions
- add docs to functions
- add docs on cfg0 variable (packing configuration info)
- get_clk_div_rate, get_clk_cfg: use mainline linux function instead of
starqltechn downstream version
- use setbits_le32
- extract qcom_geni_serial_abort_rx function
- remove explicit pinctrl setup
- make an unconditional cancel at serial init
- calculate CLK_DIV on host machine with #define, when debug enabled.
throw error, if we cannot get target baudrate with CONFIG_DEBUG_UART_CLOCK
value. This is because we cannot adjust clocks at early debug.

 MAINTAINERS   |   1 +
 .../serial/msm-geni-serial.txt|   6 +
 drivers/serial/Kconfig|  18 +
 drivers/serial/Makefile   |   1 +
 drivers/serial/serial_msm_geni.c  | 613 ++
 5 files changed, 639 insertions(+)
 create mode 100644 doc/device-tree-bindings/serial/msm-geni-serial.txt
 create mode 100644 drivers/serial/serial_msm_geni.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 776ff703b9..52ddc99cda 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -390,6 +390,7 @@ F:  drivers/gpio/msm_gpio.c
 F: drivers/mmc/msm_sdhci.c
 F: drivers/phy/msm8916-usbh-phy.c
 F: drivers/serial/serial_msm.c
+F: drivers/serial/serial_msm_geni.c
 F: drivers/smem/msm_smem.c
 F: drivers/usb/host/ehci-msm.c
 
diff --git a/doc/device-tree-bindings/serial/msm-geni-serial.txt 
b/doc/device-tree-bindings/serial/msm-geni-serial.txt
new file mode 100644
index 00..9eadc2561b
--- /dev/null
+++ b/doc/device-tree-bindings/serial/msm-geni-serial.txt
@@ -0,0 +1,6 @@
+Qualcomm GENI UART
+
+Required properties:
+- compatible: must be "qcom,msm-geni-uart"
+- reg: start address and size of the registers
+- clock: interface clock (must accept baudrate as a frequency)
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 93348c0929..5d9d4b46f2 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -278,6 +278,14 @@ config DEBUG_UART_S5P
  will need to provide parameters to make this work. The driver will
  be available until the real driver-model serial is running.
 
+config DEBUG_UART_MSM_GENI
+   bool "Qualcomm snapdragon"
+   depends on ARCH_SNAPDRAGON
+   help
+ Select this to enable a debug UART using the serial_msm driver. You
+ will need to provide parameters to make this work. The driver will
+ be available until the real driver-model serial is running.
+
 config DEBUG_UART_MESON
bool "Amlogic Meson"
depends on MESON_SERIAL
@@ -783,6 +791,16 @@ config MSM_SERIAL
  for example APQ8016 and MSM8916.
  Single baudrate is supported in current implementation (115200).
 
+config MSM_GENI_SERIAL
+   bool "Qualcomm on-chip GENI UART"
+   help
+ Support UART based on Generic Interface (GENI) Serial Engine (SE),
+ used on Qualcomm Snapdragon SoCs. Should support all qualcomm SOCs
+ with Qualcomm Universal Peripheral (QUP) Wrapper cores,
+ i.e. newer ones, starting from SDM845.
+ Driver works in FIFO mode.
+ Multiple baudrates supported.
+
 config OCTEON_SERIAL_BOOTCMD
bool "MIPS Octeon PCI remote bootcmd input"
depends on ARCH_OCTEON
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 3cbea8156f..d44caf4ea2 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -62,6 +62,7 @@ obj-$(CONFIG_PIC32_SERIAL) += serial_pic32.o
 obj-$(CONFIG_BCM283X_MU_SERIAL) += serial_bcm283x_mu.o
 obj-$(CONFIG_BCM283X_PL011_SERIAL) += serial_bcm283x_pl011.o
 obj-$(CONFIG_MSM_SERIAL) += serial_msm.o
+obj-$(CONFIG_MSM_GENI_SERIAL) += serial_msm_geni.o
 obj-$(CONFIG_MVEBU_A3700_UART) += serial_mvebu_a3700.o
 obj-$(CONFIG_MPC8XX_CONS) += serial_mpc8xx.o
 obj-$(CONFIG_NULLDEV_SERIAL) += serial_nulldev.o
diff --git a/drivers/serial/serial_msm_geni.c b/drivers/serial/serial_msm_geni.c
new file mode 100644
index 00..3e255a99dc
--- /dev/null
+++ b/drivers/serial/serial_msm_geni.c
@@ -0,0 +1,613 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm GENI serial engine UART driver
+ *
+ * (C) Copyright 2021 Dzmitry Sankouski 
+ *
+ * Based on Linux driver.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#in