Add UART support and arch timer initialization for OMAP5
v7 cover Add UART support and arch timer initialization for OMAP5
Since OMAP UART has a few distinct features than common 8250 UART, I re-implemented its driver rather than porting it based on ns16550.c. There are mainly two big differences between the implementations. First, OMAP UART introduces the concept of register access mode, which divides the register map into seperated space. Switching the access mode is then necessary when configuring it. Second, THRE interrupt needs to be disable after finished transmission and enabled once transmission started. This is because the semantic of THRE interrupt differs from common 8250 in TI's implementation, which would be generated if TX FIFO below trigger level and cannot be cleared by simply write to THR once.
Besides UART driver, arch timer initialization for OMAP5432 platform is also done in this patch series.
v7 <- v6:
- Fix a bug in patch #3.
- Fix type problems Julien pointed out in patch #4.
- Add vuart_info callback for omap-uart driver.
v6 <- v5:
- Add EARLY_UART_REG_SHIFT and remove REG_SHIFT in 8250-uart.h
- Define REG_SHIFT in omap-uart.c rather than 8250-uart.h, since Linux also uses hardcoded regshift in omap-uart driver and there is no reg-shift of UART defined in OMAP5's DT.
- Separate dt_property_read_u32 introduction into a single patch.
- Fix some typos.
v5 <- v4:
- Separate dt specified arch_timer clkfrq setup into patch #4.
v4 <- v3:
- Merege #4 and #5 in v3 into one patch.
- Fix some coding-style and comments.
v3 <- v2:
- [3/5] Use bool_t as the return type of dt_property_read_u32.
- [3/5] Use sizeof(*out_value) instead of hardcoded value in dt_property_read_u32.
- [3/5] Fix some coding-style problems and some typos.
v2 <- v1:
- [2/5] Add early printk support for sun6i.
- [3/5] Introduce dt_property_read_u32() helper to get clock-frequency.
- [3/5] Use ioreadl/iowritel instead of uart->regs[...] in OMAP UART driver.
- [3/5] Change do-while structure to while in OMAP UART interrupt handler.
- [3/5] Use hardcoded value when setting up OMAP UART.
- [3/5] Won't enable IRQ if setup failed in init_postirq().
- [3/5] Fix coding-style problems and some typos.
- [3/5] Remove unnecessary define.
- [4/5] Remove the macros that would be used in future.
- [5/5] Use dt_property_read_u32() helper to get clock-frequency.
Chen Baozi (6):
xen: rename ns16550-uart.h to 8250-uart.h and fix some typos xen/arm: add 8250 compatible UART support for early_printk
xen: Introduce a helper to read a u32 property in device tree. xen/arm: Add the new OMAP UART driver.
xen/arm: Add support for device tree specified arch_timer clock
frequency.
xen/arm: Platform recognition and initialize arch_timer for the OMAP5
config/arm32.mk | 1 +
docs/misc/arm/early-printk.txt | 3 +
xen/arch/arm/Rules.mk | 16 +
xen/arch/arm/arm32/debug-8250.inc | 41 +++
xen/arch/arm/platforms/Makefile | 1 +
xen/arch/arm/platforms/omap5.c | 117 ++++++++
xen/arch/arm/time.c | 7 +-
xen/common/device_tree.c | 15 +
xen/drivers/char/Makefile | 1 +
xen/drivers/char/ns16550.c | 2 +-
xen/drivers/char/omap-uart.c | 369 ++++++++++++++++++++++++
xen/include/asm-arm/platforms/omap5.h | 25 ++
xen/include/xen/{ns16550-uart.h => 8250-uart.h} | 69 ++++-
xen/include/xen/device_tree.h | 11 +
14 files changed, 667 insertions(+), 11 deletions(-)
create mode 100644 xen/arch/arm/arm32/debug-8250.inc
create mode 100644 xen/arch/arm/platforms/omap5.c
create mode 100644 xen/drivers/char/omap-uart.c
create mode 100644 xen/include/asm-arm/platforms/omap5.h
rename xen/include/xen/{ns16550-uart.h => 8250-uart.h} (63%)Signature · 1 line
1.8.1.4
PATCH v7 1/6 xen: rename ns16550-uart.h to 8250-uart.h and fix some typos
Since UARTs on OMAP5 & Allwinner's SoC are not ns16550 but only 8250 compatible, rename ns16550-uart.h to 8250-uart.h, which is a more pervasive name. At the same time, fix some typos, which have redundance UART_ prefixes in some macros.
---
xen/drivers/char/ns16550.c | 2 +-
xen/include/xen/{ns16550-uart.h => 8250-uart.h} | 18 +++++++++---------
2 files changed, 10 insertions(+), 10 deletions(-)
rename xen/include/xen/{ns16550-uart.h => 8250-uart.h} (89%)xen/drivers/char/ns16550.c +1 -1
@@ -19,7 +19,7 @@#include <xen/iocap.h> #include <xen/pci.h> #include <xen/pci_regs.h> -#include <xen/ns16550-uart.h> +#include <xen/8250-uart.h> #include <asm/io.h> #ifdef CONFIG_X86 #include <asm/fixmap.h>
xen/include/xen/8250-uart.h renamed from xen/include/xen/ns16550-uart.h +9 -9
@@ -1,5 +1,5 @@/* -* xen/include/xen/ns16550-uart.h +* xen/include/xen/8250-uart.h * * This header is extracted from driver/char/ns16550.c *
@@ -19,8 +19,8 @@* GNU General Public License for more details. */ -#ifndef __XEN_NS16550_UART_H__ -#define __XEN_NS16550_UART_H__ +#ifndef __XEN_8250_UART_H__ +#define __XEN_8250_UART_H__/* Register offsets */ #define UART_RBR 0x00/* receive buffer */
@@ -43,11 +43,11 @@/* Interrupt Identificatiegister */ #define UART_IIR_NOINT 0x01/* no interrupt pending */ -#define UART_UART_IIR_IMA 0x06/* interrupt identity: */ -#define UART_UART_IIR_LSI 0x06/* - rx line status */ -#define UART_UART_IIR_RDA 0x04/* - rx data recv'd */ -#define UART_UART_IIR_THR 0x02/* - tx reg. empty */ -#define UART_UART_IIR_MSI 0x00/* - MODEM status */ +#define UART_IIR_IMA 0x06/* interrupt identity: */ +#define UART_IIR_LSI 0x06/* - rx line status */ +#define UART_IIR_RDA 0x04/* - rx data recv'd */ +#define UART_IIR_THR 0x02/* - tx reg. empty */ +#define UART_IIR_MSI 0x00/* - MODEM status */ /* FIFO Control Register */ #define UART_FCR_ENABLE 0x01/* enable FIFO */
@@ -92,7 +92,7 @@#define RESUME_DELAY MILLISECS(10)#define RESUME_RETRIES 100 -#endif /* __XEN_NS16550_UART_H__ */ +#endif /* __XEN_8250_UART_H__ */ /* * Local variables:
Signature · 1 line
1.8.1.4
PATCH v7 2/6 xen/arm: add 8250 compatible UART support for early_printk
In reply to Chen BaoziBoth OMAP5 and sun6i/sun7i SoCs share this UART driver for early_printk.
--- docs/misc/arm/early-printk.txt | 3 +++ xen/arch/arm/Rules.mk | 16 +++++++++++++++ xen/arch/arm/arm32/debug-8250.inc | 41 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +3 -0
@@ -13,6 +13,9 @@ where mach is the name of the machine: - exynos5250: printk with the second UART - midway: printk with the pl011 on Calxeda Midway processors - fastmodel: printk on ARM Fastmodel software emulators + - omap5432: printk with UART3 on TI OMAP5432 processors + - sun6i: printk with 8250 on Allwinner A31 processors + - sun7i: printk with 8250 on Allwinner A20 processors The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, see there when adding support for new machines.
xen/arch/arm/Rules.mk +16 -0
@@ -64,6 +64,21 @@ EARLY_PRINTK_INC := pl011 EARLY_PRINTK_BAUD := 115200 EARLY_UART_BASE_ADDRESS := 0xfff36000 endif +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) +EARLY_PRINTK_INC := 8250 +EARLY_UART_BASE_ADDRESS := 0x48020000 +EARLY_UART_REG_SHIFT := 2 +endif +ifeq ($(CONFIG_EARLY_PRINTK), sun6i) +EARLY_PRINTK_INC := 8250 +EARLY_UART_BASE_ADDRESS := 0x01c28000 +EARLY_UART_REG_SHIFT := 2 +endif +ifeq ($(CONFIG_EARLY_PRINTK), sun7i) +EARLY_PRINTK_INC := 8250 +EARLY_UART_BASE_ADDRESS := 0x01c28000 +EARLY_UART_REG_SHIFT := 2 +endif ifneq ($(EARLY_PRINTK_INC),) EARLY_PRINTK := y
@@ -74,4 +89,5 @@ CFLAGS-$(EARLY_PRINTK_INIT_UART) += -DEARLY_PRINTK_INIT_UART CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_INC=\"debug-$(EARLY_PRINTK_INC).inc\" CFLAGS-$(EARLY_PRINTK) += -DEARLY_PRINTK_BAUD=$(EARLY_PRINTK_BAUD) CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_BASE_ADDRESS=$(EARLY_UART_BASE_ADDRESS) +CFLAGS-$(EARLY_PRINTK) += -DEARLY_UART_REG_SHIFT=$(EARLY_UART_REG_SHIFT) endif
xen/arch/arm/arm32/debug-8250.inc new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.8.1.4
PATCH v7 3/6 xen: Introduce a helper to read a u32 property in device tree.
In reply to Chen Baozi--- xen/common/device_tree.c | 15 +++++++++++++++ xen/include/xen/device_tree.h | 11 +++++++++++ 2 files changed, 26 insertions(+)
xen/common/device_tree.c +15 -0
@@ -574,6 +574,21 @@ const void *dt_get_property(const struct dt_device_node *np,return pp ? pp->value :NULL ; } +bool_t dt_property_read_u32 (const struct dt_device_node *np, +const char *name,u32 *out_value) +{ +u32 len; +const __be32 *val; + + val =dt_get_property (np, name, &len); +if ( !val || len <sizeof (*out_value) ) +return 0 ; + + *out_value =be32_to_cpup (val); + +return 1 ; +} +bool_t dt_device_is_compatible (const struct dt_device_node *device,const char *compat) {
xen/include/xen/device_tree.h +11 -0
@@ -300,6 +300,17 @@ const void *dt_get_property(const struct dt_device_node *np, const char *name, u32 *lenp);/** +* dt_property_read_u32 - Helper to read a u32 property. +* @np: node to get the value +* @name: name of the property +* @out_value: pointer to return value +* +* Return true if get the desired value. +*/ +bool_t dt_property_read_u32 (const struct dt_device_node *np, +const char *name,u32 *out_value); + +/** * Checks if the given "compat" string matches one of the strings in * the device's "compatible" property */
Signature · 1 line
1.8.1.4
PATCH v7 4/6 xen/arm: Add the new OMAP UART driver.
In reply to Chen BaoziTI OMAP UART introduces some features such as register access modes, which makes its configuration and interrupt handling differs from 8250 compatible UART. Thus, we seperate this driver from ns16550's implementation.
--- config/arm32.mk | 1 + xen/drivers/char/Makefile | 1 + xen/drivers/char/omap-uart.c | 369 +++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/8250-uart.h | 51 ++++++ 4 files changed, 422 insertions(+) create mode 100644 xen/drivers/char/omap-uart.c
config/arm32.mk +1 -0
@@ -11,6 +11,7 @@ CFLAGS += -marm HAS_PL011 := y HAS_EXYNOS4210 := y +HAS_OMAP := y # Use only if calling $(LD) directly. LDFLAGS_DIRECT += -EL
xen/drivers/char/Makefile +1 -0
@@ -2,6 +2,7 @@ obj-y += console.o obj-$(HAS_NS16550) += ns16550.o obj-$(HAS_PL011) += pl011.o obj-$(HAS_EXYNOS4210) += exynos4210-uart.o +obj-$(HAS_OMAP) += omap-uart.o obj-$(HAS_EHCI) += ehci-dbgp.o obj-$(CONFIG_ARM) += dt-uart.o obj-y += serial.o
xen/drivers/char/omap-uart.c new file +369 -0
369 lines not on this page · raw message
xen/include/xen/8250-uart.h +51 -0
71 lines not on this page · raw message
Signature · 1 line
1.8.1.4
PATCH v7 5/6 xen/arm: Add support for device tree specified arch_timer clock frequency.
In reply to Chen Baozi--- xen/arch/arm/time.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
xen/arch/arm/time.c +6 -1
@@ -104,6 +104,7 @@ int __init init_xen_time(void)struct dt_device_node *dev;int res;unsigned int i; +u32 rate; dev =dt_find_compatible_node (NULL ,NULL ,"arm,armv7-timer" );if ( !dev )
@@ -134,7 +135,11 @@ int __init init_xen_time(void)if ( !cpu_has_gentimer )panic ("CPU does not support the Generic Timer v1 interface.\n" ); - cpu_khz =READ_SYSREG32 (CNTFRQ_EL0 ) /1000 ; + res =dt_property_read_u32 (dev,"clock-frequency" , &rate); +if ( res ) + cpu_khz = rate /1000 ; +else + cpu_khz =READ_SYSREG32 (CNTFRQ_EL0 ) /1000 ; boot_count =READ_SYSREG64 (CNTPCT_EL0 );printk ("Using generic timer at %lu KHz\n" , cpu_khz);
Signature · 1 line
1.8.1.4
PATCH v7 6/6 xen/arm: Platform recognition and initialize arch_timer for the OMAP5
In reply to Chen Baozi--- xen/arch/arm/platforms/Makefile | 1 + xen/arch/arm/platforms/omap5.c | 117 ++++++++++++++++++++++++++++++++++ xen/include/asm-arm/platforms/omap5.h | 25 ++++++++ 3 files changed, 143 insertions(+) create mode 100644 xen/arch/arm/platforms/omap5.c create mode 100644 xen/include/asm-arm/platforms/omap5.h
xen/arch/arm/platforms/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-y += vexpress.o obj-y += exynos5.o +obj-y += omap5.o
xen/arch/arm/platforms/omap5.c new file +117 -0
117 lines not on this page · raw message
xen/include/asm-arm/platforms/omap5.h new file +25 -0
@@ -0,0 +1,25 @@ +#ifndef __ASM_ARM_PLATFORMS_OMAP5_H +#define __ASM_ASM_PLATFORMS_OMAP5_H + +#define REALTIME_COUNTER_BASE 0x48243200 +#define INCREMENTER_NUMERATOR_OFFSET 0x10 +#define INCREMENTER_DENUMERATOR_RELOAD_OFFSET 0x14 +#define NUMERATOR_DENUMERATOR_MASK 0xfffff000 +#define PRM_FRAC_INCREMENTER_DENUMERATOR_RELOAD 0x00010000 + +#define OMAP5_L4_WKUP 0x4AE00000 +#define OMAP5_PRM_BASE (OMAP5_L4_WKUP + 0x6000) +#define OMAP5_CKGEN_PRM_BASE (OMAP5_PRM_BASE + 0x100) +#define OMAP5_CM_CLKSEL_SYS 0x10 +#define SYS_CLKSEL_MASK 0xfffffff8 + +#endif /* __ASM_ARM_PLATFORMS_OMAP5_H */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
1.8.1.4