Re: [PATCH v5 07/39] serial: msm: add debug UART

2024-02-26 Thread Sumit Garg
On Mon, 26 Feb 2024 at 22:56, Caleb Connolly  wrote:
>
> Introduce support for early debugging. This relies on the previous stage
> bootloader to initialise the UART clocks, when running with U-Boot as
> the primary bootloader this feature doesn't work. It will require a way
> to configure the clocks before the driver model is available.
>
> Reviewed-by: Neil Armstrong 
> Signed-off-by: Caleb Connolly 
> ---
>  drivers/serial/Kconfig  |  8 
>  drivers/serial/serial_msm.c | 37 +
>  2 files changed, 45 insertions(+)
>
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 26460c4e0cab..fbd351a47859 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -318,8 +318,16 @@ config DEBUG_UART_S5P
>   Select this to enable a debug UART using the serial_s5p 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_MSM
> +   bool "Qualcomm QUP UART debug"
> +   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_MSM_GENI
> bool "Qualcomm snapdragon"
> depends on ARCH_SNAPDRAGON
> help
> diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
> index f4d96313b931..44b93bd7ff21 100644
> --- a/drivers/serial/serial_msm.c
> +++ b/drivers/serial/serial_msm.c
> @@ -251,4 +251,41 @@ U_BOOT_DRIVER(serial_msm) = {
> .priv_auto  = sizeof(struct msm_serial_data),
> .probe = msm_serial_probe,
> .ops= _serial_ops,
>  };
> +
> +#ifdef CONFIG_DEBUG_UART_MSM
> +
> +static struct msm_serial_data init_serial_data = {
> +   .base = CONFIG_VAL(DEBUG_UART_BASE),
> +   .clk_rate = 7372800,
> +};
> +
> +#include 
> +
> +/* Uncomment to turn on UART clocks when debugging U-Boot as aboot on 
> MSM8916 */
> +//int apq8016_clk_init_uart(phys_addr_t gcc_base);
> +

Okay I can live with these comments such that the user is aware before
enabling debug UART on db410c.

Reviewed-by: Sumit Garg 

-Sumit

> +static inline void _debug_uart_init(void)
> +{
> +   /* Uncomment to turn on UART clocks when debugging U-Boot as aboot on 
> MSM8916 */
> +   //apq8016_clk_init_uart(0x180);
> +   uart_dm_init(_serial_data);
> +}
> +
> +static inline void _debug_uart_putc(int ch)
> +{
> +   struct msm_serial_data *priv = _serial_data;
> +
> +   while (!(readl(priv->base + UARTDM_SR) & UARTDM_SR_TX_EMPTY) &&
> +  !(readl(priv->base + UARTDM_ISR) & UARTDM_ISR_TX_READY))
> +   ;
> +
> +   writel(UARTDM_CR_CMD_RESET_TX_READY, priv->base + UARTDM_CR);
> +
> +   writel(1, priv->base + UARTDM_NCF_TX);
> +   writel(ch, priv->base + UARTDM_TF);
> +}
> +
> +DEBUG_UART_FUNCS
> +
> +#endif
>
> --
> 2.43.1
>


[PATCH v5 07/39] serial: msm: add debug UART

2024-02-26 Thread Caleb Connolly
Introduce support for early debugging. This relies on the previous stage
bootloader to initialise the UART clocks, when running with U-Boot as
the primary bootloader this feature doesn't work. It will require a way
to configure the clocks before the driver model is available.

Reviewed-by: Neil Armstrong 
Signed-off-by: Caleb Connolly 
---
 drivers/serial/Kconfig  |  8 
 drivers/serial/serial_msm.c | 37 +
 2 files changed, 45 insertions(+)

diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 26460c4e0cab..fbd351a47859 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -318,8 +318,16 @@ config DEBUG_UART_S5P
  Select this to enable a debug UART using the serial_s5p 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_MSM
+   bool "Qualcomm QUP UART debug"
+   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_MSM_GENI
bool "Qualcomm snapdragon"
depends on ARCH_SNAPDRAGON
help
diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
index f4d96313b931..44b93bd7ff21 100644
--- a/drivers/serial/serial_msm.c
+++ b/drivers/serial/serial_msm.c
@@ -251,4 +251,41 @@ U_BOOT_DRIVER(serial_msm) = {
.priv_auto  = sizeof(struct msm_serial_data),
.probe = msm_serial_probe,
.ops= _serial_ops,
 };
+
+#ifdef CONFIG_DEBUG_UART_MSM
+
+static struct msm_serial_data init_serial_data = {
+   .base = CONFIG_VAL(DEBUG_UART_BASE),
+   .clk_rate = 7372800,
+};
+
+#include 
+
+/* Uncomment to turn on UART clocks when debugging U-Boot as aboot on MSM8916 
*/
+//int apq8016_clk_init_uart(phys_addr_t gcc_base);
+
+static inline void _debug_uart_init(void)
+{
+   /* Uncomment to turn on UART clocks when debugging U-Boot as aboot on 
MSM8916 */
+   //apq8016_clk_init_uart(0x180);
+   uart_dm_init(_serial_data);
+}
+
+static inline void _debug_uart_putc(int ch)
+{
+   struct msm_serial_data *priv = _serial_data;
+
+   while (!(readl(priv->base + UARTDM_SR) & UARTDM_SR_TX_EMPTY) &&
+  !(readl(priv->base + UARTDM_ISR) & UARTDM_ISR_TX_READY))
+   ;
+
+   writel(UARTDM_CR_CMD_RESET_TX_READY, priv->base + UARTDM_CR);
+
+   writel(1, priv->base + UARTDM_NCF_TX);
+   writel(ch, priv->base + UARTDM_TF);
+}
+
+DEBUG_UART_FUNCS
+
+#endif

-- 
2.43.1