Skip to contentSkip to conversation

Add UART support and arch timer initialization for OMAP5

PATCH Superseded Chen Baozi 3 participants 21 messages Aug 8, 2013

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Chen Baozi

author
#0 lore raw

v5 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.

v5 <- v4:
- Seperate 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.
- [5/5] Remove unused define.

Chen Baozi (5):
xen: rename ns16550-uart.h to 8250-uart.h and fix some typos xen/arm: add 8250 compatible UART support for early_printk 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                  |   2 +
 xen/arch/arm/Rules.mk                           |   8 +
 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                    | 352 ++++++++++++++++++++++++
 xen/include/asm-arm/platforms/omap5.h           |  25 ++
 xen/include/xen/{ns16550-uart.h => 8250-uart.h} |  73 ++++-
 xen/include/xen/device_tree.h                   |  11 +
 14 files changed, 645 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
author
#1 lore raw

PATCH v5 1/5 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
index e085a64..6082c85 100644
@@ -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
similarity index 89%
rename from xen/include/xen/ns16550-uart.h
rename to xen/include/xen/8250-uart.h
index 232cef9..7287364 100644
@@ -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
author
#2 lore raw

PATCH v5 2/5 xen/arm: add 8250 compatible UART support for early_printk

In reply to Chen Baozi

Both OMAP5 and sun6i SoCs share this UART driver for early_printk.

---
 docs/misc/arm/early-printk.txt    |  2 ++
 xen/arch/arm/Rules.mk             |  8 ++++++++
 xen/arch/arm/arm32/debug-8250.inc | 41 +++++++++++++++++++++++++++++++++++++++
 xen/include/xen/8250-uart.h       |  4 ++++
 4 files changed, 55 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +2 -0
index fbc3208..f24c6c0 100644
@@ -13,6 +13,8 @@ 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
 
 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 +8 -0
index a18e7fd..7f11e5c 100644
@@ -64,6 +64,14 @@ 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
+endif
+ifeq ($(CONFIG_EARLY_PRINTK), sun6i)
+EARLY_PRINTK_INC := 8250
+EARLY_UART_BASE_ADDRESS := 0x01c28000
+endif
 
 ifneq ($(EARLY_PRINTK_INC),)
 EARLY_PRINTK := y
xen/arch/arm/arm32/debug-8250.inc new file +41 -0

41 lines not on this page · raw message

xen/include/xen/8250-uart.h +4 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif
+
 /* Register offsets */
 #define UART_RBR          0x00    /* receive buffer       */
 #define UART_THR          0x00    /* transmit holding     */
Signature · 1 line
1.8.1.4
#3 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

Quoted 16 lines · Chen Baozi

Both OMAP5 and sun6i SoCs share this UART driver for early_printk.

---
 docs/misc/arm/early-printk.txt    |  2 ++
 xen/arch/arm/Rules.mk             |  8 ++++++++
 xen/arch/arm/arm32/debug-8250.inc | 41 +++++++++++++++++++++++++++++++++++++++
 xen/include/xen/8250-uart.h       |  4 ++++
 4 files changed, 55 insertions(+)
 create mode 100644 xen/arch/arm/arm32/debug-8250.inc
docs/misc/arm/early-printk.txt +0 -0
index fbc3208..f24c6c0 100644

docs/misc/arm/early-printk.txt where mach is the name of the machine: · line 17

Quoted 5 lines
docs/misc/arm/early-printk.txt +2 -0
@@ -13,6 +13,8 @@ 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

We've not been terribly consistent about SoC vs board naming here. I think this is fine, we can always tweak in the future.

I had a comment below so when you respin and can be bothered please can you also add
sun7i: printk with 8250 on Allwinner A20 processors

and the appropriate block (identical to sun6i block).

xen/include/xen/8250-uart.h line 27

Quoted 11 lines
xen/include/xen/8250-uart.h +3 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

Quoted 4 lines
xen/include/xen/8250-uart.h +1 -0
+
 /* Register offsets */
 #define UART_RBR          0x00    /* receive buffer       */
 #define UART_THR          0x00    /* transmit holding     */
#4 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

Quoted 8 lines · Ian Campbell
Quoted 8 lines
xen/include/xen/8250-uart.h +0 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
Quoted 6 lines

xen/include/xen/8250-uart.h line 27

Quoted 3 lines
xen/include/xen/8250-uart.h +3 -0
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

I should have also said that for non-early drivers this should come from the device tree.

Possibly in the case of your OMAP speciifc driver it could be hardcoded, but only if it isn't in DT IMHO.

Ian.

Quoted 6 lines
Quoted 5 lines
xen/include/xen/8250-uart.h +1 -0
+
 /* Register offsets */
 #define UART_RBR          0x00    /* receive buffer       */
 #define UART_THR          0x00    /* transmit holding     */
author
#5 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

Quoted 17 lines · Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 8 lines
xen/include/xen/8250-uart.h +0 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
Quoted 6 lines

xen/include/xen/8250-uart.h line 27

Quoted 3 lines
xen/include/xen/8250-uart.h +3 -0
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

Quoted 5 lines

I should have also said that for non-early drivers this should come from the device tree.

Possibly in the case of your OMAP speciifc driver it could be hardcoded, but only if it isn't in DT IMHO.

It seems OMAP5's DT doesn't have this info? Does exynos5 have it?

Baozi

Quoted 11 lines

Ian.

Quoted 6 lines
Quoted 5 lines
xen/include/xen/8250-uart.h +1 -0
+
 /* Register offsets */
 #define UART_RBR          0x00    /* receive buffer       */
 #define UART_THR          0x00    /* transmit holding     */
#6 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

Quoted 20 lines · Chen Baozi
Quoted 17 lines · Ian Campbell
Quoted 14 lines · Ian Campbell

xen/include/xen/8250-uart.h line 27

Quoted 11 lines
xen/include/xen/8250-uart.h +3 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

Quoted 7 lines
Quoted 5 lines

I should have also said that for non-early drivers this should come from the device tree.

Possibly in the case of your OMAP speciifc driver it could be hardcoded, but only if it isn't in DT IMHO.

It seems OMAP5's DT doesn't have this info? Does exynos5 have it?

Exynos5 uses a different UART which doesn't need shift.

Signature · 1 line
Julien Grall
author
#7 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

Quoted 24 lines · Julien Grall
Quoted 23 lines · Chen Baozi
Quoted 20 lines · Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 8 lines
xen/include/xen/8250-uart.h +0 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
Quoted 6 lines

xen/include/xen/8250-uart.h line 27

Quoted 3 lines
xen/include/xen/8250-uart.h +3 -0
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

I should have also said that for non-early drivers this should come from the device tree.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Possibly in the case of your OMAP speciifc driver it could be hardcoded, but only if it isn't in DT IMHO.

It seems OMAP5's DT doesn't have this info? Does exynos5 have it?

Exynos5 uses a different UART which doesn't need shift.

I don't think DT would hold that info. (Fix me if I'm wrong.) Actually this shift comes from the different register size between OMAP UART (32-bit) and common 8250 UART (8-bit). And we would like to share the offset macros between the two similar UART. For those UART doesn't share offset macros with others or they do have same register size, the shift is not necessary.

Baozi

author
#8 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

Quoted 32 lines · Chen Baozi
Quoted 29 lines · Julien Grall
Quoted 27 lines · Chen Baozi
Quoted 17 lines · Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 8 lines
xen/include/xen/8250-uart.h +0 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
Quoted 6 lines

xen/include/xen/8250-uart.h line 27

Quoted 3 lines
xen/include/xen/8250-uart.h +3 -0
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

Quoted 5 lines

I should have also said that for non-early drivers this should come from the device tree.

Possibly in the case of your OMAP speciifc driver it could be hardcoded, but only if it isn't in DT IMHO.

It seems OMAP5's DT doesn't have this info? Does exynos5 have it?

Quoted 7 lines
Quoted 1 line

Exynos5 uses a different UART which doesn't need shift.

I don't think DT would hold that info. (Fix me if I'm wrong.) Actually this shift comes from the different register size between OMAP UART (32-bit) and common 8250 UART (8-bit). And we would like to share the offset macros between the two similar UART. For those UART doesn't share offset macros with others or they do have same register size, the shift is not necessary.

Maybe we can put REG_SHIFT into arch/arm/arm32/debug-8250.inc and drivers/char/omap-uart.c rather than the header?

#9 lore raw

Re: [PATCH v5 2/5] xen/arm: add 8250 compatible UART support for early_printk

In reply to Chen Baozi
Quoted 31 lines · Chen Baozi
Quoted 29 lines · Julien Grall
Quoted 27 lines · Chen Baozi
Quoted 17 lines · Ian Campbell
Quoted 8 lines · Ian Campbell
Quoted 8 lines
xen/include/xen/8250-uart.h +0 -0
index 7287364..33daa6d 100644
@@ -22,6 +22,10 @@
 #ifndef __XEN_8250_UART_H__
 #define __XEN_8250_UART_H__
 
Quoted 6 lines

xen/include/xen/8250-uart.h line 27

Quoted 3 lines
xen/include/xen/8250-uart.h +3 -0
+#ifdef CONFIG_ARM
+#define REG_SHIFT         2
+#endif

I think this should actually be part of the per-platform early-printk block, e.g. EARLY_UART_REG_SHIFT

Quoted 5 lines

I should have also said that for non-early drivers this should come from the device tree.

Possibly in the case of your OMAP speciifc driver it could be hardcoded, but only if it isn't in DT IMHO.

It seems OMAP5's DT doesn't have this info? Does exynos5 have it?

Quoted 7 lines
Quoted 1 line

Exynos5 uses a different UART which doesn't need shift.

I don't think DT would hold that info. (Fix me if I'm wrong.) Actually this shift comes from the different register size between OMAP UART (32-bit) and common 8250 UART (8-bit). And we would like to share the offset macros between the two similar UART. For those UART doesn't share offset macros with others or they do have same register size, the shift is not necessary.

linux/Documentation/devicetree/bindings/tty/serial/of-serial.txt defines reg-shift, so do a few other bindings.

DT is all about defining how the hardware is wired up, and different register layouts, arising from (effectively) choosing to wire different CPU address lines to the UART address lines, is a part of this.

Ian.

Quoted 2 lines

Baozi

author
#10 lore raw

PATCH v5 3/5 xen/arm: Add the new OMAP UART driver.

In reply to Chen Baozi

TI 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/common/device_tree.c      |  15 ++
 xen/drivers/char/Makefile     |   1 +
 xen/drivers/char/omap-uart.c  | 352 ++++++++++++++++++++++++++++++++++++++++++
 xen/include/xen/8250-uart.h   |  51 ++++++
 xen/include/xen/device_tree.h |  11 ++
 6 files changed, 431 insertions(+)
 create mode 100644 xen/drivers/char/omap-uart.c
config/arm32.mk +1 -0
index 8e21158..76e229d 100644
@@ -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/common/device_tree.c +15 -0
index 84d704d..a4701eb 100644
@@ -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/drivers/char/Makefile +1 -0
index 37543f0..911b788 100644
@@ -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 +352 -0

352 lines not on this page · raw message

xen/include/xen/8250-uart.h +51 -0

71 lines not on this page · raw message

xen/include/xen/device_tree.h +11 -0
index 5a2a5c6..faf727f 100644
@@ -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
#11 lore raw

Re: [PATCH v5 3/5] xen/arm: Add the new OMAP UART driver.

xen/drivers/char/omap-uart.c line 27

Quoted 2 lines · Chen Baozi
xen/drivers/char/omap-uart.c new file +2 -0
+#define omap_read(uart, off)       ioreadl((uart)->regs + (off<<REG_SHIFT))
+#define omap_write(uart, off, val) iowritel((uart)->regs + (off<<REG_SHIFT), (val))

Other than my comment made on #2 about either using DT or hardcoing REG_SHIFT in this driver I think this patch is good.

xen/include/xen/8250-uart.h

Quoted 4 lines
xen/include/xen/8250-uart.h +0 -0
index 33daa6d..7498e71 100644

To what extent are these changes specific to the TI part?

I guess at least OMAP_* could be in its own header or in the .c file I guess? Not sure what others think about that?

Quoted 16 lines
xen/include/xen/8250-uart.h +12 -0
@@ -63,14 +63,45 @@
 #define UART_FCR_TRG8     0x80    /* Rx FIFO trig lev 8   */
 #define UART_FCR_TRG14    0xc0    /* Rx FIFO trig lev 14  */
 
+/*
+ * Note: The FIFO trigger levels are chip specific:
+ *	RX:76 = 00  01  10  11	TX:54 = 00  01  10  11
+ * PC16550D:	 1   4   8  14		xx  xx  xx  xx
+ * TI16C550A:	 1   4   8  14          xx  xx  xx  xx
+ * TI16C550C:	 1   4   8  14          xx  xx  xx  xx
+ * ST16C550:	 1   4   8  14		xx  xx  xx  xx
+ * ST16C650:	 8  16  24  28		16   8  24  30	PORT_16650V2
+ * NS16C552:	 1   4   8  14		xx  xx  xx  xx
+ * ST16C654:	 8  16  56  60		 8  16  32  56	PORT_16654
+ * TI16C750:	 1  16  32  56		xx  xx  xx  xx	PORT_16750
+ * TI16C752:	 8  16  56  60		 8  16  32  56

xen/include/xen/8250-uart.h line 87

Quoted 10 lines
xen/include/xen/8250-uart.h +10 -0
+ * Tegra:	 1   4   8  14		16   8   4   1	PORT_TEGRA
+ */
+#define UART_FCR_R_TRIG_00 0x00
+#define UART_FCR_R_TRIG_01 0x40
+#define UART_FCR_R_TRIG_10 0x80
+#define UART_FCR_R_TRIG_11 0xc0
+#define UART_FCR_T_TRIG_00 0x00
+#define UART_FCR_T_TRIG_01 0x10
+#define UART_FCR_T_TRIG_10 0x20
+#define UART_FCR_T_TRIG_11 0x30

This is inherently chipset specific but covers many so I this is OK here IMO.

xen/include/xen/8250-uart.h line 94

Quoted 7 lines
xen/include/xen/8250-uart.h +4 -0
+
 /* Line Control Register */
 #define UART_LCR_DLAB     0x80    /* Divisor Latch Access */
 
+/*
+ * Access to some registers depends on register access / configuration
+ * mode.

This mode is a TI thing?

xen/include/xen/8250-uart.h line 104

Quoted 10 lines
xen/include/xen/8250-uart.h +5 -0
+ */
+#define UART_LCR_CONF_MODE_A	UART_LCR_DLAB	/* Configuration mode A */
+#define UART_LCR_CONF_MODE_B	0xBF		/* Configuration mode B */
+
 /* Modem Control Register */
 #define UART_MCR_DTR      0x01    /* Data Terminal Ready  */
 #define UART_MCR_RTS      0x02    /* Request to Send      */
 #define UART_MCR_OUT2     0x08    /* OUT2: interrupt mask */
 #define UART_MCR_LOOP     0x10    /* Enable loopback test mode */
+#define UART_MCR_TCRTLR   0x40    /* Access TCR/TLR (TI16C752, EFR[4]=1) */

Also a TI thing? But I can see why you would want it here for consistency.

Quoted 30 lines
xen/include/xen/8250-uart.h +20 -0
 /* Line Status Register */
 #define UART_LSR_DR       0x01    /* Data ready           */
@@ -96,6 +127,26 @@
 #define RESUME_DELAY      MILLISECS(10)
 #define RESUME_RETRIES    100
 
+/* Enhanced feature register */
+#define UART_OMAP_EFR     0x02
+
+#define UART_OMAP_EFR_ECB 0x10 /* Enhanced control bit */
+
+/* Mode definition register 1 */
+#define UART_OMAP_MDR1    0x08
+
+/*
+ * These are the definitions for the MDR1 register
+ */
+#define UART_OMAP_MDR1_16X_MODE 0x00 /* UART 16x mode           */
+#define UART_OMAP_MDR1_DISABLE  0x07 /* Disable (default state) */
+
+/* Supplementary control register */
+#define UART_OMAP_SCR     0x10
+
+/* SCR register bitmasks */
+#define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK (1 << 7)
+
 #endif /* __XEN_8250_UART_H__ */
 
 /*
author
#12 lore raw

Re: [PATCH v5 3/5] xen/arm: Add the new OMAP UART driver.

Quoted 14 lines · Ian Campbell

xen/drivers/char/omap-uart.c line 27

Quoted 2 lines · Chen Baozi
xen/drivers/char/omap-uart.c new file +2 -0
+#define omap_read(uart, off)       ioreadl((uart)->regs + (off<<REG_SHIFT))
+#define omap_write(uart, off, val) iowritel((uart)->regs + (off<<REG_SHIFT), (val))

Other than my comment made on #2 about either using DT or hardcoing REG_SHIFT in this driver I think this patch is good.

xen/include/xen/8250-uart.h

Quoted 4 lines
xen/include/xen/8250-uart.h +0 -0
index 33daa6d..7498e71 100644

To what extent are these changes specific to the TI part?

Quoted 2 lines

I guess at least OMAP_* could be in its own header or in the .c file I guess? Not sure what others think about that?

Hmmm, in Linux, they are in one header (see comments below).

Quoted 35 lines
Quoted 17 lines
xen/include/xen/8250-uart.h +12 -0
@@ -63,14 +63,45 @@
 #define UART_FCR_TRG8     0x80    /* Rx FIFO trig lev 8   */
 #define UART_FCR_TRG14    0xc0    /* Rx FIFO trig lev 14  */
 
+/*
+ * Note: The FIFO trigger levels are chip specific:
+ *	RX:76 = 00  01  10  11	TX:54 = 00  01  10  11
+ * PC16550D:	 1   4   8  14		xx  xx  xx  xx
+ * TI16C550A:	 1   4   8  14          xx  xx  xx  xx
+ * TI16C550C:	 1   4   8  14          xx  xx  xx  xx
+ * ST16C550:	 1   4   8  14		xx  xx  xx  xx
+ * ST16C650:	 8  16  24  28		16   8  24  30	PORT_16650V2
+ * NS16C552:	 1   4   8  14		xx  xx  xx  xx
+ * ST16C654:	 8  16  56  60		 8  16  32  56	PORT_16654
+ * TI16C750:	 1  16  32  56		xx  xx  xx  xx	PORT_16750
+ * TI16C752:	 8  16  56  60		 8  16  32  56

xen/include/xen/8250-uart.h line 87

Quoted 10 lines
xen/include/xen/8250-uart.h +10 -0
+ * Tegra:	 1   4   8  14		16   8   4   1	PORT_TEGRA
+ */
+#define UART_FCR_R_TRIG_00 0x00
+#define UART_FCR_R_TRIG_01 0x40
+#define UART_FCR_R_TRIG_10 0x80
+#define UART_FCR_R_TRIG_11 0xc0
+#define UART_FCR_T_TRIG_00 0x00
+#define UART_FCR_T_TRIG_01 0x10
+#define UART_FCR_T_TRIG_10 0x20
+#define UART_FCR_T_TRIG_11 0x30

This is inherently chipset specific but covers many so I this is OK here IMO.

Quoted 4 lines
xen/include/xen/8250-uart.h +1 -0
+
 /* Line Control Register */
 #define UART_LCR_DLAB     0x80    /* Divisor Latch Access */
 
Quoted 5 lines

xen/include/xen/8250-uart.h line 94

Quoted 3 lines
xen/include/xen/8250-uart.h +3 -0
+/*
+ * Access to some registers depends on register access / configuration
+ * mode.

This mode is a TI thing?

I took this defines from linux/include/linux/serial_reg.h. Though it is used by OMAP5 board only in xen, it seems it is also used by other platform in Linux (See drivers/tty/serial/8250/8250_core.c).

Quoted 47 lines

xen/include/xen/8250-uart.h line 104

Quoted 11 lines
xen/include/xen/8250-uart.h +5 -0
+ */
+#define UART_LCR_CONF_MODE_A	UART_LCR_DLAB	/* Configuration mode A */
+#define UART_LCR_CONF_MODE_B	0xBF		/* Configuration mode B */
+
 /* Modem Control Register */
 #define UART_MCR_DTR      0x01    /* Data Terminal Ready  */
 #define UART_MCR_RTS      0x02    /* Request to Send      */
 #define UART_MCR_OUT2     0x08    /* OUT2: interrupt mask */
 #define UART_MCR_LOOP     0x10    /* Enable loopback test mode */
+#define UART_MCR_TCRTLR   0x40    /* Access TCR/TLR (TI16C752, EFR[4]=1) */

Also a TI thing? But I can see why you would want it here for consistency.

Quoted 30 lines
xen/include/xen/8250-uart.h +20 -0
 /* Line Status Register */
 #define UART_LSR_DR       0x01    /* Data ready           */
@@ -96,6 +127,26 @@
 #define RESUME_DELAY      MILLISECS(10)
 #define RESUME_RETRIES    100
 
+/* Enhanced feature register */
+#define UART_OMAP_EFR     0x02
+
+#define UART_OMAP_EFR_ECB 0x10 /* Enhanced control bit */
+
+/* Mode definition register 1 */
+#define UART_OMAP_MDR1    0x08
+
+/*
+ * These are the definitions for the MDR1 register
+ */
+#define UART_OMAP_MDR1_16X_MODE 0x00 /* UART 16x mode           */
+#define UART_OMAP_MDR1_DISABLE  0x07 /* Disable (default state) */
+
+/* Supplementary control register */
+#define UART_OMAP_SCR     0x10
+
+/* SCR register bitmasks */
+#define OMAP_UART_SCR_RX_TRIG_GRANU1_MASK (1 << 7)
+
 #endif /* __XEN_8250_UART_H__ */
 
 /*
#13 lore raw

Re: [PATCH v5 3/5] xen/arm: Add the new OMAP UART driver.

Quoted 16 lines · Chen Baozi
Quoted 14 lines · Ian Campbell

xen/drivers/char/omap-uart.c line 27

Quoted 2 lines · Chen Baozi
xen/drivers/char/omap-uart.c new file +2 -0
+#define omap_read(uart, off)       ioreadl((uart)->regs + (off<<REG_SHIFT))
+#define omap_write(uart, off, val) iowritel((uart)->regs + (off<<REG_SHIFT), (val))

Other than my comment made on #2 about either using DT or hardcoing REG_SHIFT in this driver I think this patch is good.

xen/include/xen/8250-uart.h

Quoted 4 lines
xen/include/xen/8250-uart.h +0 -0
index 33daa6d..7498e71 100644

To what extent are these changes specific to the TI part?

Quoted 4 lines
Quoted 2 lines

I guess at least OMAP_* could be in its own header or in the .c file I guess? Not sure what others think about that?

Hmmm, in Linux, they are in one header (see comments below).

OK, then I guess that's fine by me.

Ian.

author
#14 lore raw

PATCH v5 4/5 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
index 4ed7882..9a1b080 100644
@@ -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
#15 lore raw

Re: [PATCH v5 4/5] xen/arm: Add support for device tree specified arch_timer clock frequency.

Quoted 1 line · Chen Baozi

Acked + applied, thanks,

Quoted 29 lines
---
 xen/arch/arm/time.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
xen/arch/arm/time.c +6 -1
index 4ed7882..9a1b080 100644
@@ -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);
#16 lore raw

Re: [PATCH v5 4/5] xen/arm: Add support for device tree specified arch_timer clock frequency.

Quoted 4 lines · Ian Campbell
Quoted 1 line · Chen Baozi

Acked + applied, thanks,

:/ This patch depends on #3. It uses dt_property_u32 which is defined the patch before.

Chen, could you send dt_property_u32 in a separate patch?

Cheers,

Signature · 1 line
Julien Grall
#17 lore raw

Re: [PATCH v5 4/5] xen/arm: Add support for device tree specified arch_timer clock frequency.

Quoted 8 lines · Julien Grall
Quoted 4 lines · Ian Campbell
Quoted 1 line · Chen Baozi

Acked + applied, thanks,

:/ This patch depends on #3. It uses dt_property_u32 which is defined the patch before.

Oops, my test script seems to have a habit of missing build failures. I need to rectify this.

For now I have reverted this patch.

Quoted 5 lines

Chen, could you send dt_property_u32 in a separate patch?

Cheers,

author
#18 lore raw

PATCH v5 5/5 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
index ff2b65b..90ddcb1 100644
@@ -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
new file mode 100644
index 0000000..092f340
@@ -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
Acked-by on v5 5/5
#19 lore raw

Re: [PATCH v5 5/5] xen/arm: Platform recognition and initialize arch_timer for the OMAP5

Quoted 1 line · Chen Baozi

I suppose this cannot be applied without some of the precursors from this series?

A few typos:

Quoted 2 lines

---
+ * xen/arch/arm/platforma/omap5.c

"platforms"

Quoted 4 lines

+ *
+ * OMAP5 specific settings
+ *
+ * Chen Baozi <[email protected]>

Quoted 8 lines

+ * Copyright (c) 2013
+ *
+ * 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 distributted in the hope that it will be useful,

"distributted"

Quoted 3 lines

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Gerneral Public License for more details.

"General"

I checked the rest of the tree and you must have introduced these after copying the block ;-)

Quoted 13 lines

+ */

xen/arch/arm/platforms/omap5.c new file +12 -0
+
+#include <xen/config.h>
+#include <asm/platform.h>
+#include <asm/platforms/omap5.h>
+#include <xen/mm.h>
+#include <xen/vmap.h>
+
+static uint16_t num_den[8][2] = {
+    {         0,          0 },  /* not used */
+    {  26 *  64,  26 *  125 },  /* 12.0 Mhz */
+    {   2 * 768,   2 * 1625 },  /* 13.0 Mhz */
+    {         0,          0 },  /* not used */

xen/arch/arm/platforms/omap5.c line 40

Quoted 10 lines
xen/arch/arm/platforms/omap5.c new file +10 -0
+    { 130 *   8, 130 *   25 },  /* 19.2 Mhz */
+    {   2 * 384,   2 * 1625 },  /* 26.0 Mhz */
+    {   3 * 256,   3 * 1125 },  /* 27.0 Mhz */
+    { 130 *   4, 130 *   25 },  /* 38.4 Mhz */
+};
+
+/*
+ * The realtime counter also called master counter, is a free-running
+ * counter, which is related to real time. It produces the count used
+ * by the CPU local timer peripherals in teh MPU cluster. The timer counts

teh -> the

Ian.

author
#20 lore raw

Re: [PATCH v5 5/5] xen/arm: Platform recognition and initialize arch_timer for the OMAP5

Quoted 7 lines · Ian Campbell
Quoted 1 line · Chen Baozi

I suppose this cannot be applied without some of the precursors from this series?

It only depends on patch #4.

And thanks for pointing out the typos, :)

Cheers,

Baozi

Quoted 59 lines

A few typos:

Quoted 2 lines

---
+ * xen/arch/arm/platforma/omap5.c

"platforms"

Quoted 4 lines

+ *
+ * OMAP5 specific settings
+ *
+ * Chen Baozi <[email protected]>

Quoted 8 lines

+ * Copyright (c) 2013
+ *
+ * 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 distributted in the hope that it will be useful,

"distributted"

Quoted 3 lines

+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Gerneral Public License for more details.

"General"

I checked the rest of the tree and you must have introduced these after copying the block ;-)

Quoted 13 lines

+ */

xen/arch/arm/platforms/omap5.c new file +12 -0
+
+#include <xen/config.h>
+#include <asm/platform.h>
+#include <asm/platforms/omap5.h>
+#include <xen/mm.h>
+#include <xen/vmap.h>
+
+static uint16_t num_den[8][2] = {
+    {         0,          0 },  /* not used */
+    {  26 *  64,  26 *  125 },  /* 12.0 Mhz */
+    {   2 * 768,   2 * 1625 },  /* 13.0 Mhz */
+    {         0,          0 },  /* not used */

xen/arch/arm/platforms/omap5.c line 40

Quoted 10 lines
xen/arch/arm/platforms/omap5.c new file +10 -0
+    { 130 *   8, 130 *   25 },  /* 19.2 Mhz */
+    {   2 * 384,   2 * 1625 },  /* 26.0 Mhz */
+    {   3 * 256,   3 * 1125 },  /* 27.0 Mhz */
+    { 130 *   4, 130 *   25 },  /* 38.4 Mhz */
+};
+
+/*
+ * The realtime counter also called master counter, is a free-running
+ * counter, which is related to real time. It produces the count used
+ * by the CPU local timer peripherals in teh MPU cluster. The timer counts

teh -> the

Ian.