Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752680AbdLKJ2T (ORCPT ); Mon, 11 Dec 2017 04:28:19 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:44319 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752525AbdLKJ2S (ORCPT ); Mon, 11 Dec 2017 04:28:18 -0500 X-Google-Smtp-Source: AGs4zMbmmA751c7HdNvttF0dmx2qBbKQCi3rEGFHmZqtApV5UImpWxEvOMyXIDYn9tm7NjCXj1y5zA== Subject: Re: [PATCH] ARM: debug: add stm32 low-level debug support To: Ludovic Barre , Russell King Cc: Alexandre Torgue , linux-kernel@vger.kernel.org, Maxime Coquelin , Gerald Baeza , linux-arm-kernel@lists.infradead.org References: <1512394376-25962-1-git-send-email-ludovic.Barre@st.com> From: Neil Armstrong Organization: Baylibre Message-ID: <852f496f-b4eb-2a13-d234-bd86261d0e1a@baylibre.com> Date: Mon, 11 Dec 2017 10:28:15 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1512394376-25962-1-git-send-email-ludovic.Barre@st.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3691 Lines: 119 On 04/12/2017 14:32, Ludovic Barre wrote: > From: Ludovic Barre > > This adds low-level debug support on USART1 for STM32F4 > and STM32F7. Compiled via 'CONFIG_DEBUG_LL' and 'CONFIG_EARLY_PRINTK'. > Enabled via 'earlyprintk' in bootargs. > > Signed-off-by: Gerald Baeza Hi Ludovic, Please also add your sign-off here. Neil > --- > arch/arm/Kconfig.debug | 25 +++++++++++++++++++++++++ > arch/arm/include/debug/stm32.S | 41 +++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 66 insertions(+) > create mode 100644 arch/arm/include/debug/stm32.S > > diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug > index 17685e1..9469c58 100644 > --- a/arch/arm/Kconfig.debug > +++ b/arch/arm/Kconfig.debug > @@ -1140,6 +1140,26 @@ choice > > If unsure, say N. > > + config STM32F4_DEBUG_UART > + bool "Use STM32F4 UART for low-level debug" > + depends on ARCH_STM32 > + select DEBUG_STM32_UART > + help > + Say Y here if you want kernel low-level debugging support > + on STM32 based platforms. > + > + If unsure, say N. > + > + config STM32F7_DEBUG_UART > + bool "Use STM32F7 UART for low-level debug" > + depends on ARCH_STM32 > + select DEBUG_STM32_UART > + help > + Say Y here if you want kernel low-level debugging support > + on STM32 based platforms. > + > + If unsure, say N. > + > config TEGRA_DEBUG_UART_AUTO_ODMDATA > bool "Kernel low-level debugging messages via Tegra UART via ODMDATA" > depends on ARCH_TEGRA > @@ -1424,6 +1444,10 @@ config DEBUG_STI_UART > bool > depends on ARCH_STI > > +config DEBUG_STM32_UART > + bool > + depends on ARCH_STM32 > + > config DEBUG_SIRFSOC_UART > bool > depends on ARCH_SIRF > @@ -1472,6 +1496,7 @@ config DEBUG_LL_INCLUDE > default "debug/s5pv210.S" if DEBUG_S5PV210_UART > default "debug/sirf.S" if DEBUG_SIRFSOC_UART > default "debug/sti.S" if DEBUG_STI_UART > + default "debug/stm32.S" if DEBUG_STM32_UART > default "debug/tegra.S" if DEBUG_TEGRA_UART > default "debug/ux500.S" if DEBUG_UX500_UART > default "debug/vexpress.S" if DEBUG_VEXPRESS_UART0_DETECT > diff --git a/arch/arm/include/debug/stm32.S b/arch/arm/include/debug/stm32.S > new file mode 100644 > index 0000000..4015257 > --- /dev/null > +++ b/arch/arm/include/debug/stm32.S > @@ -0,0 +1,41 @@ > +/* > + * Copyright (C) 2017, STMicroelectronics - All Rights Reserved > + * Author: Gerald Baeza > + * License terms: GNU General Public License (GPL), version 2 > + */ > + > +#define STM32_UART_BASE 0x40011000 /* USART1 */ > + > +#ifdef CONFIG_STM32F4_DEBUG_UART > +#define STM32_USART_SR_OFF 0x00 > +#define STM32_USART_TDR_OFF 0x04 > +#endif > + > +#ifdef CONFIG_STM32F7_DEBUG_UART > +#define STM32_USART_SR_OFF 0x1C > +#define STM32_USART_TDR_OFF 0x28 > +#endif > + > +#define STM32_USART_TC (1 << 6) /* Tx complete */ > +#define STM32_USART_TXE (1 << 7) /* Tx data reg empty */ > + > + .macro addruart, rp, rv, tmp > + ldr \rp, =STM32_UART_BASE @ physical base > + ldr \rv, =STM32_UART_BASE @ virt base /* NoMMU */ > + .endm > + > + .macro senduart,rd,rx > + strb \rd, [\rx, #STM32_USART_TDR_OFF] > + .endm > + > + .macro waituart,rd,rx > +1001: ldr \rd, [\rx, #(STM32_USART_SR_OFF)] @ Read Status Register > + tst \rd, #STM32_USART_TXE @ TXE = 1 = tx empty > + beq 1001b > + .endm > + > + .macro busyuart,rd,rx > +1001: ldr \rd, [\rx, #(STM32_USART_SR_OFF)] @ Read Status Register > + tst \rd, #STM32_USART_TC @ TC = 1 = tx complete > + beq 1001b > + .endm >