Skip to contentSkip to conversation

Changes specific to Shakti uart

PATCH New Prasanna T 2 participants 2 messages Jul 1, 2022

lore
Share & tools
lore

Prasanna T

author
#0 lore raw

PATCH 1/1 Changes specific to Shakti uart

---
 include/sbi_utils/serial/shakti-uart.h | 4 ++++
 lib/utils/fdt/fdt_helper.c             | 2 +-
 lib/utils/serial/shakti-uart.c         | 7 ++++---
 3 files changed, 9 insertions(+), 4 deletions(-)
include/sbi_utils/serial/shakti-uart.h +4 -0
index bcb019e..08043be 100644
@@ -9,6 +9,10 @@
 
 #include <sbi/sbi_types.h>
 
+void shakti_uart_putc(char ch);
+
+int shakti_uart_getc(void);
+
 int shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate);
 
 #endif
lib/utils/fdt/fdt_helper.c +1 -1
index 2bdb1ef..40597e7 100644
@@ -31,7 +31,7 @@
 #define DEFAULT_GAISLER_UART_REG_IO_WIDTH	4
 
 #define DEFAULT_SHAKTI_UART_FREQ		50000000
-#define DEFAULT_SHAKTI_UART_BAUD		115200
+#define DEFAULT_SHAKTI_UART_BAUD		19200
 
 const struct fdt_match *fdt_match_node(void *fdt, int nodeoff,
 				       const struct fdt_match *match_table)
lib/utils/serial/shakti-uart.c +4 -3
index 5f2fe75..d3fd5f1 100644
@@ -20,20 +20,21 @@
 
 #define UART_TX_FULL  0x2
 #define UART_RX_FULL  0x8
+#define UART_RX_NOT_EMPTY 0x4
 
 static volatile char *uart_base;
 
 static void shakti_uart_putc(char ch)
 {
-	while((readw(uart_base + REG_STATUS) & UART_TX_FULL))
+	while((readb(uart_base + REG_STATUS) & UART_TX_FULL))
 		;
 	writeb(ch, uart_base + REG_TX);
 }
 
 static int shakti_uart_getc(void)
 {
-	u16 status = readw(uart_base + REG_STATUS);
-	if (status & UART_RX_FULL)
+	u16 status = readb(uart_base + REG_STATUS);
+	if (status & UART_RX_NOT_EMPTY) // MASKING 3rd bit for UARTv2. If UARTv1 use MASK UART_RX_FULL.
 		return readb(uart_base + REG_RX);
 	return -1;
 }
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 Changes specific to Shakti uart

Quoted 1 line · Prasanna T

No commit message and a vague subject.

Quoted 11 lines

---

include/sbi_utils/serial/shakti-uart.h | 4 ++++
lib/utils/fdt/fdt_helper.c             | 2 +-
lib/utils/serial/shakti-uart.c         | 7 ++++---
3 files changed, 9 insertions(+), 4 deletions(-)
include/sbi_utils/serial/shakti-uart.h +0 -0
index bcb019e..08043be 100644

include/sbi_utils/serial/shakti-uart.h line 15

Quoted 7 lines
include/sbi_utils/serial/shakti-uart.h +4 -0
@@ -9,6 +9,10 @@
 
 #include <sbi/sbi_types.h>
 
+void shakti_uart_putc(char ch);
+
+int shakti_uart_getc(void);
+

These are wrong to add.

lib/utils/fdt/fdt_helper.c line 34

Quoted 13 lines
include/sbi_utils/serial/shakti-uart.h +0 -0
 int shakti_uart_init(unsigned long base, u32 in_freq, u32 baudrate);
 
 #endif
lib/utils/fdt/fdt_helper.c +1 -1
index 2bdb1ef..40597e7 100644
@@ -31,7 +31,7 @@
 #define DEFAULT_GAISLER_UART_REG_IO_WIDTH	4
 
 #define DEFAULT_SHAKTI_UART_FREQ		50000000
-#define DEFAULT_SHAKTI_UART_BAUD		115200
+#define DEFAULT_SHAKTI_UART_BAUD		19200

Why change this?

lib/utils/serial/shakti-uart.c line 23

Quoted 11 lines
lib/utils/fdt/fdt_helper.c +0 -0
 const struct fdt_match *fdt_match_node(void *fdt, int nodeoff,
 				       const struct fdt_match *match_table)
lib/utils/serial/shakti-uart.c +1 -0
index 5f2fe75..d3fd5f1 100644
@@ -20,20 +20,21 @@
 
 #define UART_TX_FULL  0x2
 #define UART_RX_FULL  0x8
+#define UART_RX_NOT_EMPTY 0x4

Keep these sorted by their value.

lib/utils/serial/shakti-uart.c line 29

Quoted 6 lines
lib/utils/serial/shakti-uart.c +1 -1
 static volatile char *uart_base;
 
 static void shakti_uart_putc(char ch)
 {
-	while((readw(uart_base + REG_STATUS) & UART_TX_FULL))
+	while((readb(uart_base + REG_STATUS) & UART_TX_FULL))

Why does this need changing? Was it always broken or did something change?

lib/utils/serial/shakti-uart.c line 36

Quoted 9 lines
lib/utils/serial/shakti-uart.c +1 -2
 		;
 	writeb(ch, uart_base + REG_TX);
 }
 
 static int shakti_uart_getc(void)
 {
-	u16 status = readw(uart_base + REG_STATUS);
-	if (status & UART_RX_FULL)
+	u16 status = readb(uart_base + REG_STATUS);

As with putc.

lib/utils/serial/shakti-uart.c line 37

Quoted 1 line
lib/utils/serial/shakti-uart.c +1 -0
+	if (status & UART_RX_NOT_EMPTY) // MASKING 3rd bit for UARTv2. If UARTv1 use MASK UART_RX_FULL.

So this seems to explain the changes, UARTv2 needs a different driver, so don?t break UARTv1, extend this driver to support both simultaneously?

Jess

Quoted 11 lines
lib/utils/serial/shakti-uart.c +0 -0
 		return readb(uart_base + REG_RX);
 	return -1;
 }
Signature · 7 lines
2.17.1


-- 
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi