ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
Subsystems (3)
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
From: Jonathan Austin <[email protected]>
The current vexpress code attempts to autodetect the debug UART based on some fragile probing of the memory map. If this fails, we may take an abort attempting to access a device that doesn't exist.
This patch avoids probing the various possible UART locations on the different Versatile Express motherboards and instead adds entries into the DEBUG_LL kconfig choice for the two possible memory maps.
--- arch/arm/Kconfig.debug | 16 ++++++++++ arch/arm/mach-vexpress/include/mach/debug-macro.S | 34 ++++++++------------- 2 files changed, 29 insertions(+), 21 deletions(-)
arch/arm/Kconfig.debug +16 -0
@@ -345,6 +345,22 @@ choice For more details about semihosting, please see chapter 8 of DUI0203I_rvct_developer_guide.pdf from ARM Ltd. + config DEBUG_VEXPRESS_CA9X4_UART + bool "Kernel low-level debugging messages via CA9X4 UART" + depends on ARCH_VEXPRESS_CA9X4 + help + Say Y here if you want the debug print routines to direct + their output to UART0 of the Versatile Express motherboards + that pre-date the RS1 memory map. + + config DEBUG_VEXPRESS_RS1_UART + bool "Kernel low-level debugging messages via RS1 UART" + depends on ARCH_VEXPRESS_DT + help + Say Y here if you want the debug print routines to direct + their output to UART0 of the Versatile Express motherboards + with the RS1 memory map. + endchoice config EARLY_PRINTK
arch/arm/mach-vexpress/include/mach/debug-macro.S +13 -21
@@ -10,34 +10,26 @@ * published by the Free Software Foundation. */ +#ifdef CONFIG_DEBUG_VEXPRESS_CA9X4_UART #define DEBUG_LL_PHYS_BASE 0x10000000 #define DEBUG_LL_UART_OFFSET 0x00009000 +#endif -#define DEBUG_LL_PHYS_BASE_RS1 0x1c000000 -#define DEBUG_LL_UART_OFFSET_RS1 0x00090000 +#ifdef CONFIG_DEBUG_VEXPRESS_RS1_UART +#define DEBUG_LL_PHYS_BASE 0x1c000000 +#define DEBUG_LL_UART_OFFSET 0x00090000 +#endif #define DEBUG_LL_VIRT_BASE 0xf8000000 - .macro addruart,rp,rv,tmp - - @ Make an educated guess regarding the memory map: - @ - the original A9 core tile, which has MPCore peripherals - @ located at 0x1e000000, should use UART at 0x10009000 - @ - all other (RS1 complaint) tiles use UART mapped - @ at 0x1c090000 - mrc p15, 4, \tmp, c15, c0, 0 - cmp \tmp, #0x1e000000 - - @ Original memory map - moveq \rp, #DEBUG_LL_UART_OFFSET - orreq \rv, \rp, #DEBUG_LL_VIRT_BASE - orreq \rp, \rp, #DEBUG_LL_PHYS_BASE - - @ RS1 memory map - movne \rp, #DEBUG_LL_UART_OFFSET_RS1 - orrne \rv, \rp, #DEBUG_LL_VIRT_BASE - orrne \rp, \rp, #DEBUG_LL_PHYS_BASE_RS1 +#ifndef DEBUG_LL_UART_OFFSET +#error "Unknown vexpress UART offset" +#endif + .macro addruart,rp,rv,tmp + mov \rp, #DEBUG_LL_UART_OFFSET + orr \rv, \rp, #DEBUG_LL_VIRT_BASE + orr \rp, \rp, #DEBUG_LL_PHYS_BASE .endm #include <asm/hardware/debug-pl01x.S>
Signature · 1 line
1.7.4.1
PATCH 2/2 ARM: vexpress: remove automatic errata workaround selection
The vexpress Kconfig setup tries to be clever^Whelpful and selects some errata workarounds for certain revisions of the Cortex-A9 and PL310, which may be required depending on the coretile.
Since the mach-vexpress can support A5, A7 and A15 coretiles, let's defer errata workaround selection to the user and instead propose recommended workarounds in the defconfig. Note that the use of the savedefconfig target removed some unrelated, redundant entries from the file.
--- arch/arm/configs/vexpress_defconfig | 26 ++++++++------------------ arch/arm/mach-vexpress/Kconfig | 13 ------------- 2 files changed, 8 insertions(+), 31 deletions(-)
arch/arm/configs/vexpress_defconfig +8 -18
@@ -8,11 +8,9 @@ CONFIG_CGROUPS=y CONFIG_CPUSETS=y # CONFIG_UTS_NS is not set # CONFIG_IPC_NS is not set -# CONFIG_USER_NS is not set # CONFIG_PID_NS is not set # CONFIG_NET_NS is not set CONFIG_BLK_DEV_INITRD=y -# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set CONFIG_PROFILING=y CONFIG_OPROFILE=y CONFIG_MODULES=y
@@ -24,9 +22,14 @@ CONFIG_MODULE_UNLOAD=y CONFIG_ARCH_VEXPRESS=y CONFIG_ARCH_VEXPRESS_CA9X4=y # CONFIG_SWP_EMULATE is not set +CONFIG_ARM_ERRATA_720789=y +CONFIG_ARM_ERRATA_751472=y +CONFIG_PL310_ERRATA_753970=y +CONFIG_ARM_ERRATA_754327=y +CONFIG_ARM_ERRATA_764369=y +CONFIG_PL310_ERRATA_769419=y CONFIG_SMP=y CONFIG_VMSPLIT_2G=y -CONFIG_HOTPLUG_CPU=y CONFIG_AEABI=y CONFIG_ZBOOT_ROM_TEXT=0x0 CONFIG_ZBOOT_ROM_BSS=0x0
@@ -46,33 +49,26 @@ CONFIG_IP_PNP_BOOTP=y # CONFIG_WIRELESS is not set CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" CONFIG_MTD=y -CONFIG_MTD_CONCAT=y -CONFIG_MTD_PARTITIONS=y CONFIG_MTD_CMDLINE_PARTS=y CONFIG_MTD_CHAR=y CONFIG_MTD_BLOCK=y CONFIG_MTD_CFI=y CONFIG_MTD_CFI_INTELEXT=y CONFIG_MTD_CFI_AMDSTD=y -CONFIG_MTD_ARM_INTEGRATOR=y -CONFIG_MISC_DEVICES=y # CONFIG_SCSI_PROC_FS is not set CONFIG_BLK_DEV_SD=y # CONFIG_SCSI_LOWLEVEL is not set CONFIG_ATA=y # CONFIG_SATA_PMP is not set CONFIG_NETDEVICES=y -CONFIG_NET_ETHERNET=y CONFIG_SMSC911X=y -# CONFIG_NETDEV_1000 is not set -# CONFIG_NETDEV_10000 is not set # CONFIG_WLAN is not set CONFIG_INPUT_EVDEV=y # CONFIG_SERIO_SERPORT is not set CONFIG_SERIO_AMBAKMI=y +CONFIG_LEGACY_PTY_COUNT=16 CONFIG_SERIAL_AMBA_PL011=y CONFIG_SERIAL_AMBA_PL011_CONSOLE=y -CONFIG_LEGACY_PTY_COUNT=16 # CONFIG_HW_RANDOM is not set # CONFIG_HWMON is not set CONFIG_FB=y
@@ -103,7 +99,6 @@ CONFIG_HID_THRUSTMASTER=y CONFIG_HID_ZEROPLUS=y CONFIG_USB=y CONFIG_USB_ANNOUNCE_NEW_DEVICES=y -# CONFIG_USB_DEVICE_CLASS is not set CONFIG_USB_MON=y CONFIG_USB_ISP1760_HCD=y CONFIG_USB_STORAGE=y
@@ -120,9 +115,7 @@ CONFIG_TMPFS=y CONFIG_JFFS2_FS=y CONFIG_CRAMFS=y CONFIG_NFS_FS=y -CONFIG_NFS_V3=y CONFIG_ROOT_NFS=y -# CONFIG_RPCSEC_GSS_KRB5 is not set CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_ISO8859_1=y CONFIG_MAGIC_SYSRQ=y
@@ -131,10 +124,7 @@ CONFIG_DEBUG_KERNEL=y CONFIG_DETECT_HUNG_TASK=y # CONFIG_SCHED_DEBUG is not set CONFIG_DEBUG_INFO=y -# CONFIG_RCU_CPU_STALL_DETECTOR is not set CONFIG_DEBUG_USER=y -CONFIG_DEBUG_ERRORS=y CONFIG_DEBUG_LL=y +CONFIG_DEBUG_VEXPRESS_CA9X4_UART=y CONFIG_EARLY_PRINTK=y -# CONFIG_CRYPTO_ANSI_CPRNG is not set -# CONFIG_CRYPTO_HW is not set
arch/arm/mach-vexpress/Kconfig +0 -13
@@ -1,20 +1,8 @@ menu "Versatile Express platform type" depends on ARCH_VEXPRESS -config ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA - bool - select ARM_ERRATA_720789 - select ARM_ERRATA_751472 - select PL310_ERRATA_753970 if CACHE_PL310 - help - Provides common dependencies for Versatile Express platforms - based on Cortex-A5 and Cortex-A9 processors. In order to - build a working kernel, you must also enable relevant core - tile support or Flattened Device Tree based support options. - config ARCH_VEXPRESS_CA9X4 bool "Versatile Express Cortex-A9x4 tile" - select ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA select ARM_GIC select CPU_V7 select HAVE_SMP
@@ -22,7 +10,6 @@ config ARCH_VEXPRESS_CA9X4 config ARCH_VEXPRESS_DT bool "Device Tree support for Versatile Express platforms" - select ARCH_VEXPRESS_CORTEX_A5_A9_ERRATA select ARM_GIC select ARM_PATCH_PHYS_VIRT select AUTO_ZRELADDR
Signature · 1 line
1.7.4.1
PATCH 2/2 ARM: vexpress: remove automatic errata workaround selection
Quoted 9 lines · Will Deacon
The vexpress
Kconfigsetup tries to be clever^Whelpful and selects some errata workarounds for certain revisions of the Cortex-A9 and PL310, which may be required depending on the coretile.Since the mach-vexpress can support A5, A7 and A15 coretiles, let's defer errata workaround selection to the user and instead propose recommended workarounds in the defconfig. Note that the use of the savedefconfig target removed some unrelated, redundant entries from the file.
I'm fine with that if no one objects. Will add it to the VE updates for 3.6 merge window.
Pawe?
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
In reply to Will DeaconQuoted 3 lines · Will Deacon
This patch avoids probing the various possible UART locations on the different Versatile Express motherboards and instead adds entries into the
DEBUG_LLkconfig choice for the two possible memory maps.
I wrote similar thing (keeping the autodetection as one of the options) some time ago, but Russell didn't like it (because it wasn't DEBUG_LL choice) and I didn't have time to rework it for 3.5 merge window. Will get this out this time.
Pawe?
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
Hi Pawel,
Quoted 9 lines · Pawel Moll
Quoted 3 lines · Will Deacon
This patch avoids probing the various possible UART locations on the different Versatile Express motherboards and instead adds entries into the
DEBUG_LLkconfig choice for the two possible memory maps.I wrote similar thing (keeping the autodetection as one of the options) some time ago, but Russell didn't like it (because it wasn't
DEBUG_LLchoice) and I didn't have time to rework it for 3.5 merge window. Will get this out this time.
Ok, thanks. We have similar code in mach/uncompress.h -- how do you feel about using the same approach there? I've seen the decompressor explode due to the mrc and it's a royal pain to track down.
Will
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
Quoted 8 lines · Will Deacon
Hi Pawel,
Quoted 5 lines · Pawel Moll
Quoted 3 lines · Will Deacon
This patch avoids probing the various possible UART locations on the different Versatile Express motherboards and instead adds entries into the
DEBUG_LLkconfig choice for the two possible memory maps.
Quoted 8 lines
Quoted 4 lines
I wrote similar thing (keeping the autodetection as one of the options) some time ago, but Russell didn't like it (because it wasn't
DEBUG_LLchoice) and I didn't have time to rework it for 3.5 merge window. Will get this out this time.Ok, thanks. We have similar code in
mach/uncompress.h-- how do you feel about using the same approach there? I've seen the decompressor explode due to the mrc and it's a royal pain to track down.
This was the reason my Kconfig options weren't in DEBUG_LL but in ARCH_VEXPRESS - to serve both decompressor and early console. But as it was NAKed I'm considering several options, one (the simplest) of them is printing nothing in the decompressor unless DEBUG_LL is selected.
Pawe?
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
Quoted 10 lines · Pawel Moll
Quoted 4 lines · Will Deacon
Ok, thanks. We have similar code in
mach/uncompress.h-- how do you feel about using the same approach there? I've seen the decompressor explode due to the mrc and it's a royal pain to track down.This was the reason my
Kconfigoptions weren't inDEBUG_LLbut inARCH_VEXPRESS- to serve both decompressor and early console. But as it was NAKed I'm considering several options, one (the simplest) of them is printing nothing in the decompressor unlessDEBUG_LLis selected.
Indeed, that's the option I'd favour but I thought I'd check whether you were alright with that before updating the patch.
Will
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
Quoted 8 lines · Will Deacon
Quoted 4 lines · Pawel Moll
This was the reason my
Kconfigoptions weren't inDEBUG_LLbut inARCH_VEXPRESS- to serve both decompressor and early console. But as it was NAKed I'm considering several options, one (the simplest) of them is printing nothing in the decompressor unlessDEBUG_LLis selected.Indeed, that's the option I'd favour but I thought I'd check whether you were alright with that before updating the patch.
For what it's worth, here's the additional diff:
arch/arm/mach-vexpress/include/mach/uncompress.h +11 -26
@@ -22,36 +22,19 @@#define AMBA_UART_CR (base) (*(volatile unsigned char *)((base) + 0x30))#define AMBA_UART_FR (base) (*(volatile unsigned char *)((base) + 0x18)) +#ifdef CONFIG_DEBUG_VEXPRESS_CA9X4_UART #define UART_BASE 0x10009000 -#define UART_BASE_RS1 0x1c090000 - -static unsigned long get_uart_base (void ) -{ -unsigned long mpcore_periph; - -/* -* Make an educated guess regarding the memory map: -* - the original A9 core tile, which has MPCore peripherals -* located at 0x1e000000, should use UART at 0x10009000 -* - all other (RS1 complaint) tiles use UART mapped -* at 0x1c090000 -*/ - asm("mrc p15, 4, %0, c15, c0, 0" :"=r" (mpcore_periph)); - -if (mpcore_periph ==0x1e000000 ) -return UART_BASE ; -else -return UART_BASE_RS1 ; -} +#elif CONFIG_DEBUG_VEXPRESS_RS1_UART +#define UART_BASE 0x1c090000 +#endif +#ifdef UART_BASE /* * This does not append a newline */ static inline void putc (int c) { -unsigned long base =get_uart_base (); - -while (AMBA_UART_FR (base) & (1 <<5 )) +while (AMBA_UART_FR (UART_BASE ) & (1 <<5 ))barrier ();AMBA_UART_DR (base) = c;
@@ -59,11 +42,13 @@ static inline void putc(int c)static inline void flush (void ) { -unsigned long base =get_uart_base (); - -while (AMBA_UART_FR (base) & (1 <<3 )) +while (AMBA_UART_FR (UART_BASE ) & (1 <<3 ))barrier (); } +#else +static inline void putc (int c) {} +static inline void flush (void ) {} +#endif /* * nothing to do
Will
PATCH 1/2 ARM: vexpress: add debug UARTs to DEBUG_LL kconfig choice
Pawel,
Quoted 1 line · Will Deacon
For what it's worth, here's the additional diff:
On the off-chance that you're thinking of picking this up, there's a small correction below.
Quoted 21 lines
arch/arm/mach-vexpress/include/mach/uncompress.h +1
-11@@ -22,36 +22,19 @@#define AMBA_UART_CR (base) (*(volatile unsigned char *)((base) + 0x30))#define AMBA_UART_FR (base) (*(volatile unsigned char *)((base) + 0x18)) +#ifdef CONFIG_DEBUG_VEXPRESS_CA9X4_UART #define UART_BASE 0x10009000 -#define UART_BASE_RS1 0x1c090000 - -static unsigned long get_uart_base (void ) -{ -unsigned long mpcore_periph; - -/* -* Make an educated guess regarding the memory map: -* - the original A9 core tile, which has MPCore peripherals -* located at 0x1e000000, should use UART at 0x10009000 -* - all other (RS1 complaint) tiles use UART mapped
arch/arm/mach-vexpress/include/mach/uncompress.h line 27
Quoted 10 lines
arch/arm/mach-vexpress/include/mach/uncompress.h +1
-9-* at 0x1c090000 -*/ - asm("mrc p15, 4, %0, c15, c0, 0" :"=r" (mpcore_periph)); - -if (mpcore_periph ==0x1e000000 ) -return UART_BASE ; -else -return UART_BASE_RS1 ; -} +#elif CONFIG_DEBUG_VEXPRESS_RS1_UART
This should of course be #elif defined(CONFIG...).
Will