Chen Baozi
2013-Jun-27 07:20 UTC
[PATCH] xen/arm: add OMAP5432 UART support for early_printk
To enable it, add "CONFIG_EARLY_PRINTK := omap5432" to Config.mk Signed-off-by: Chen Baozi <baozich@gmail.com> --- docs/misc/arm/early-printk.txt | 1 + xen/arch/arm/Rules.mk | 6 ++++ xen/arch/arm/arm32/debug-omap.inc | 74 +++++++++++++++++++++++++++++++++++++++ xen/include/asm-arm/omap-uart.h | 62 ++++++++++++++++++++++++++++++++ 4 files changed, 143 insertions(+) create mode 100644 xen/arch/arm/arm32/debug-omap.inc create mode 100644 xen/include/asm-arm/omap-uart.h diff --git a/docs/misc/arm/early-printk.txt b/docs/misc/arm/early-printk.txt index fbc3208..874488f 100644 --- a/docs/misc/arm/early-printk.txt +++ b/docs/misc/arm/early-printk.txt @@ -13,6 +13,7 @@ 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 The base address and baud rate is hardcoded in xen/arch/arm/Rules.mk, see there when adding support for new machines. diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk index 422ed04..6eac20a 100644 --- a/xen/arch/arm/Rules.mk +++ b/xen/arch/arm/Rules.mk @@ -64,6 +64,12 @@ EARLY_PRINTK_INC := pl011 EARLY_PRINTK_BAUD := 115200 EARLY_UART_BASE_ADDRESS := 0xfff36000 endif +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) +EARLY_PRINTK_INC := omap +EARLY_PRINTK_INIT_UART := y +EARLY_PRINTK_BAUD := 115200 +EARLY_UART_BASE_ADDRESS := 0x48020000 +endif ifneq ($(EARLY_PRINTK_INC),) EARLY_PRINTK := y diff --git a/xen/arch/arm/arm32/debug-omap.inc b/xen/arch/arm/arm32/debug-omap.inc new file mode 100644 index 0000000..1fcf6ba --- /dev/null +++ b/xen/arch/arm/arm32/debug-omap.inc @@ -0,0 +1,74 @@ +/* + * xen/arch/arm/arm32/debug-omap.inc + * + * OMAP 5 specific debug code + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#include <asm/omap-uart.h> + +/* OMAP UART initialization + * rb: register which contains the UART base address + * rc: scratch register 1 + * rd: scratch register 2 */ +.macro early_uart_init rb rc rd + mov \rc, #0 + str \rc, [\rb, #UART_IER] + mov \rc, #0x07 + str \rc, [\rb, #UART_OMAP_MDR1] + mov \rc, #(UART_LCR_BKSE|UART_LCRVAL) + str \rc, [\rb, #UART_LCR] + mov \rc, #0 + str \rc, [\rb, #UART_DLL] + str \rc, [\rb, #UART_DLM] + mov \rc, #(UART_LCRVAL) + str \rc, [\rb, #UART_LCR] + mov \rc, #(UART_MCRVAL) + str \rc, [\rb, #UART_MCR] + mov \rc, #(UART_FCRVAL) + str \rc, [\rb, #UART_FCR] + mov \rc, #(UART_LCR_BKSE|UART_LCRVAL) + str \rc, [\rb, #UART_LCR] + /* 115200 baud rate setting: DLL <- 0x1a, DLM <- 0 */ + mov \rc, #0x1a + str \rc, [\rb, #UART_DLL] + mov \rc, #0 + str \rc, [\rb, #UART_DLM] + mov \rc, #(UART_LCRVAL) + str \rc, [\rb, #UART_LCR] + mov \rc, #0 + str \rc, [\rb, #UART_OMAP_MDR1] +.endm + +/* OMAP UART wait UART to be ready to transmit + * rb: register which contains the UART base address + * rc: scratch register */ +.macro early_uart_ready rb rc +1: + ldr \rc, [\rb, #UART_LSR] /* Read line status register */ + tst \rc, #UART_LSR_THRE /* Check Xmit holding register flag */ + beq 1b /* Wait for the UART to be ready */ +.endm + +/* OMAP UART transmit character + * rb: register which contains the UART base address + * rt: register which contains the character to transmit */ +.macro early_uart_transmit rb rt + str \rt, [\rb, #UART_TX] /* Write Transmit buffer */ +.endm + +/* + * Local variables: + * mode: ASM + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/asm-arm/omap-uart.h b/xen/include/asm-arm/omap-uart.h new file mode 100644 index 0000000..30f0e74 --- /dev/null +++ b/xen/include/asm-arm/omap-uart.h @@ -0,0 +1,62 @@ +/* + * xen/include/asm-arm/omap-uart.h + * + * Common constant definition between early printk and the UART driver + * for the OMAP 5432 UART + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef __ASM_ARM_OMAP5432_H +#define __ASM_ARM_OMAP5432_H + +#define UART_RX (0x00<<2) /* In: Receive buffer */ +#define UART_TX (0x00<<2) /* Out: Transmit buffer */ + +#define UART_IER (0x01<<2) /* Out: Interrupt Enable Register */ +#define UART_IIR (0x02<<2) /* In: Interrupt ID Register */ +#define UART_FCR (0x02<<2) /* Out: FIFO Control Register */ +#define UART_LCR (0x03<<2) /* Out: Line Control Register */ +#define UART_MCR (0x04<<2) /* Out: Modem Control Register */ +#define UART_LSR (0x05<<2) /* In: Line Status Register */ +#define UART_MSR (0x06<<2) /* In: Modem Status Register */ +#define UART_SPR (0x07<<2) /* I/O: Scratchpad Register */ + +#define UART_OMAP_MDR1 (0x08<<2) /* Mode definition register */ +#define UART_OMAP_MDR2 (0x09<<2) /* Mode definition register 2 */ +#define UART_OMAP_SCR (0x10<<2) /* Supplementary control register */ +#define UART_OMAP_SSR (0x11<<2) /* Supplementary status register */ +#define UART_OMAP_EBLR (0x12<<2) /* BOF length register */ +#define UART_OMAP_MVR (0x14<<2) /* Module version register */ +#define UART_OMAP_SYSC (0x15<<2) /* System configuration register */ +#define UART_OMAP_SYSS (0x16<<2) /* System status register */ +#define UART_OMAP_WER (0x17<<2) /* Wake-up enable register */ + +#define UART_DLL (0x00<<2) /* Out: Divisor Latch Low */ +#define UART_DLM (0x01<<2) /* Out: Divisor Latch High */ + +#define UART_LCR_BKSE 0x80 /* Bank select enable */ +#define UART_LCRVAL 0x03 /* 8 data, 1 stop, no parity */ +#define UART_MCRVAL 0x03 /* RTS|DTR */ +#define UART_FCRVAL 0x07 /* Clear & enable FIFOs */ + +#define UART_LSR_THRE 0x20 /* Xmit holding register empty */ + +#endif /* __ASM_ARM_OMAP543_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ -- 1.8.1.4
Ian Campbell
2013-Jun-27 08:22 UTC
Re: [PATCH] xen/arm: add OMAP5432 UART support for early_printk
On Thu, 2013-06-27 at 15:20 +0800, Chen Baozi wrote:> To enable it, add "CONFIG_EARLY_PRINTK := omap5432" to Config.mkFrom the register offsets this looks like it might be a somewhat 8250 compatible UART logic block? Bamvor also implemented a driver for an 8250 like device on the sun6i[0]. Rather than having multiple drivers for similar platforms I asked him to produce a single configurable 8250 driver. Perhaps you could work together to make sure this works for you both? Thanks, Ian. [0] see "xen/arm: introduce Allwinner sun6i SOC basic support" <1370004814-30686-3-git-send-email-bjzhang@suse.com>.> +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) > +EARLY_PRINTK_INC := omap > +EARLY_PRINTK_INIT_UART := yDoes your bootloader not setup the UART? Preferably we would simply inherit that setup (avoids more code and mismatched baud rate etc). Ian.
Chen Baozi
2013-Jun-27 08:54 UTC
Re: [PATCH] xen/arm: add OMAP5432 UART support for early_printk
On Jun 27, 2013, at 4:22 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote:> On Thu, 2013-06-27 at 15:20 +0800, Chen Baozi wrote: >> To enable it, add "CONFIG_EARLY_PRINTK := omap5432" to Config.mk > > From the register offsets this looks like it might be a somewhat 8250 > compatible UART logic block?From TI''s data manual, it is said this is a 16C750 compatible UART. So could it be called an 9250 compatible UART?> > Bamvor also implemented a driver for an 8250 like device on the > sun6i[0]. Rather than having multiple drivers for similar platforms I > asked him to produce a single configurable 8250 driver. Perhaps you > could work together to make sure this works for you both?Sure, it is OK for me.> > Thanks, > Ian. > > [0] see "xen/arm: introduce Allwinner sun6i SOC basic support" > <1370004814-30686-3-git-send-email-bjzhang@suse.com>. > >> +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) >> +EARLY_PRINTK_INC := omap >> +EARLY_PRINTK_INIT_UART := y > > Does your bootloader not setup the UART? Preferably we would simply > inherit that setup (avoids more code and mismatched baud rate etc).Yes, it does. I thought re-initilization is necessary and found that is also ok to inherit the u-boot setup just after finishing the patch. Well, in this case, things are much easier :-) Thanks, Baozi> > Ian. >
Chen Baozi
2013-Jun-27 08:59 UTC
Re: [PATCH] xen/arm: add OMAP5432 UART support for early_printk
On Jun 27, 2013, at 4:54 PM, Chen Baozi <baozich@gmail.com> wrote:> > On Jun 27, 2013, at 4:22 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote: > >> On Thu, 2013-06-27 at 15:20 +0800, Chen Baozi wrote: >>> To enable it, add "CONFIG_EARLY_PRINTK := omap5432" to Config.mk >> >> From the register offsets this looks like it might be a somewhat 8250 >> compatible UART logic block? > From TI''s data manual, it is said this is a 16C750 compatible UART. So could it be called an 9250 compatible UART?Sorry, 8250.> >> >> Bamvor also implemented a driver for an 8250 like device on the >> sun6i[0]. Rather than having multiple drivers for similar platforms I >> asked him to produce a single configurable 8250 driver. Perhaps you >> could work together to make sure this works for you both? > Sure, it is OK for me. > >> >> Thanks, >> Ian. >> >> [0] see "xen/arm: introduce Allwinner sun6i SOC basic support" >> <1370004814-30686-3-git-send-email-bjzhang@suse.com>. >> >>> +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) >>> +EARLY_PRINTK_INC := omap >>> +EARLY_PRINTK_INIT_UART := y >> >> Does your bootloader not setup the UART? Preferably we would simply >> inherit that setup (avoids more code and mismatched baud rate etc). > Yes, it does. I thought re-initilization is necessary and found that is also ok to inherit the u-boot setup just after finishing the patch. Well, in this case, things are much easier :-) > > Thanks, > > Baozi > >> >> Ian. >> >
Ian Campbell
2013-Jun-27 10:06 UTC
Re: [PATCH] xen/arm: add OMAP5432 UART support for early_printk
On Thu, 2013-06-27 at 16:59 +0800, Chen Baozi wrote:> On Jun 27, 2013, at 4:54 PM, Chen Baozi <baozich@gmail.com> wrote: > > > > > On Jun 27, 2013, at 4:22 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote: > > > >> On Thu, 2013-06-27 at 15:20 +0800, Chen Baozi wrote: > >>> To enable it, add "CONFIG_EARLY_PRINTK := omap5432" to Config.mk > >> > >> From the register offsets this looks like it might be a somewhat 8250 > >> compatible UART logic block? > > From TI''s data manual, it is said this is a 16C750 compatible UART. So could it be called an 9250 compatible UART? > Sorry, 8250.Phew, I was wondering what a 9250 was ;-)> > > > >> > >> Bamvor also implemented a driver for an 8250 like device on the > >> sun6i[0]. Rather than having multiple drivers for similar platforms I > >> asked him to produce a single configurable 8250 driver. Perhaps you > >> could work together to make sure this works for you both? > > Sure, it is OK for me. > > > >> > >> Thanks, > >> Ian. > >> > >> [0] see "xen/arm: introduce Allwinner sun6i SOC basic support" > >> <1370004814-30686-3-git-send-email-bjzhang@suse.com>. > >> > >>> +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) > >>> +EARLY_PRINTK_INC := omap > >>> +EARLY_PRINTK_INIT_UART := y > >> > >> Does your bootloader not setup the UART? Preferably we would simply > >> inherit that setup (avoids more code and mismatched baud rate etc). > > Yes, it does. I thought re-initilization is necessary and found that is also ok to inherit the u-boot setup just after finishing the patch. Well, in this case, things are much easier :-) > > > > Thanks, > > > > Baozi > > > >> > >> Ian. > >> > > >
Bamvor Jian Zhang
2013-Jun-29 01:33 UTC
答复: Re: [PATCH] xen/arm: add OMAP5432 UART support for early_printk
> >On Jun 27, 2013, at 4:22 PM, Ian Campbell <Ian.Campbell@citrix.com> wrote: > >> On Thu, 2013-06-27 at 15:20 +0800, Chen Baozi wrote: >>> To enable it, add "CONFIG_EARLY_PRINTK := omap5432" to Config.mk >> >> From the register offsets this looks like it might be a somewhat 8250 >> compatible UART logic block? >From TI''s data manual, it is said this is a 16C750 compatible UART. So could it be called an 9250 compatible UART? > >> >> Bamvor also implemented a driver for an 8250 like device on the >> sun6i[0]. Rather than having multiple drivers for similar platforms I >> asked him to produce a single configurable 8250 driver. Perhaps you >> could work together to make sure this works for you both? >Sure, it is OK for me.great. i could update my patch and support both sun6i and omap5432.> >> >> Thanks, >> Ian. >> >> [0] see "xen/arm: introduce Allwinner sun6i SOC basic support" >> <1370004814-30686-3-git-send-email-bjzhang@suse.com>. >> >>> +ifeq ($(CONFIG_EARLY_PRINTK), omap5432) >>> +EARLY_PRINTK_INC := omap >>> +EARLY_PRINTK_INIT_UART := y >> >> Does your bootloader not setup the UART? Preferably we would simply >> inherit that setup (avoids more code and mismatched baud rate etc). >Yes, it does. I thought re-initilization is necessary and found that is also ok to inherit the u-boot setup just after finishing the patch. Well, in this case, things are much easier :-) > >Thanks, > >Baozi > >> >> Ian. >>