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

2021-10-31 Thread Simon Glass
Hi Dzmitry,

On Fri, 15 Oct 2021 at 10:22, Dzmitry Sankouski  wrote:
>
>
> чт, 14 окт. 2021 г. в 18:10, Simon Glass :
>>
>> Hi Dzmitry,
>>
>> On Fri, 8 Oct 2021 at 00:46, 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 
>> > ---
>> > 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
>> >
>> >  MAINTAINERS   |   1 +
>> >  .../serial/msm-geni-serial.txt|   6 +
>> >  drivers/serial/Kconfig|  17 +
>> >  drivers/serial/Makefile   |   1 +
>> >  drivers/serial/serial_msm_geni.c  | 603 ++
>> >  5 files changed, 628 insertions(+)
>> >  create mode 100644 doc/device-tree-bindings/serial/msm-geni-serial.txt
>> >  create mode 100644 drivers/serial/serial_msm_geni.c
>>
>> Reviewed-by: Simon Glass 
>>
>> Some nits below
>>
>> >
>> > 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..b420a5720d 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
>>
>> Do you need this? Most drivers just use the existing DEBUG_UART Kconfig.
>
>
> Documentation for CONFIG_DEBUG_UART says:
> `- Enable the CONFIG for your UART to tell it to provide this interface
>(e.g. CONFIG_DEBUG_UART_NS16550)`
> Debug functionality is controlled by chip specific CONFIG_DEBUG_UART_*.
> So no serial driver uses  plain DEBUG_UART for adding debug functionality.

Ah yes. Well I suppose I am allow to forgot something I wrote 6 years ago.

For my own information, the reason is basically because we can only
have one debug UART, but can have multiple UART drivers with driver
model. So we need to select which to use as a debug UART.

It is a bit unfortunate, since in the vast majority of cases, we only
have a single UART driver in use.

Regards,
Simon


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

2021-10-15 Thread Dzmitry Sankouski
чт, 14 окт. 2021 г. в 18:10, Simon Glass :

> Hi Dzmitry,
>
> On Fri, 8 Oct 2021 at 00:46, 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 
> > ---
> > 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
> >
> >  MAINTAINERS   |   1 +
> >  .../serial/msm-geni-serial.txt|   6 +
> >  drivers/serial/Kconfig|  17 +
> >  drivers/serial/Makefile   |   1 +
> >  drivers/serial/serial_msm_geni.c  | 603 ++
> >  5 files changed, 628 insertions(+)
> >  create mode 100644 doc/device-tree-bindings/serial/msm-geni-serial.txt
> >  create mode 100644 drivers/serial/serial_msm_geni.c
>
> Reviewed-by: Simon Glass 
>
> Some nits below
>
> >
> > 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..b420a5720d 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
>
> Do you need this? Most drivers just use the existing DEBUG_UART Kconfig.
>

Documentation for CONFIG_DEBUG_UART says:
`- Enable the CONFIG for your UART to tell it to provide this interface
   (e.g. CONFIG_DEBUG_UART_NS16550)`
Debug functionality is controlled by chip specific CONFIG_DEBUG_UART_*.
So no serial driver uses  plain DEBUG_UART for adding debug functionality.


> > +   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,15 @@ 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,
>
> 80cols
>
> > + 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

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

2021-10-14 Thread Simon Glass
Hi Dzmitry,

On Fri, 8 Oct 2021 at 00:46, 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 
> ---
> 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
>
>  MAINTAINERS   |   1 +
>  .../serial/msm-geni-serial.txt|   6 +
>  drivers/serial/Kconfig|  17 +
>  drivers/serial/Makefile   |   1 +
>  drivers/serial/serial_msm_geni.c  | 603 ++
>  5 files changed, 628 insertions(+)
>  create mode 100644 doc/device-tree-bindings/serial/msm-geni-serial.txt
>  create mode 100644 drivers/serial/serial_msm_geni.c

Reviewed-by: Simon Glass 

Some nits below

>
> 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..b420a5720d 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

Do you need this? Most drivers just use the existing DEBUG_UART Kconfig.

> +   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,15 @@ 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,

80cols

> + 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..c656d54cbb
> --- /dev/null
> +++ b/drivers/serial/serial_msm_geni.c
> @@ -0,0 +1,603 @@
> +// 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 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define UART_OVERSAMPLING  32
> +#define STALE_TIMEOUT  160
> +#define SE_UART_RX_STALE_CNT   0x294
> +#define