Skip to contentSkip to conversation

lib: utils/serial: Update Shakti UART based on latest implementation

PATCH New Anup Patel 5 participants 7 messages Jul 8, 2022 – Jul 21, 2022

lore
Share & tools
lore

Anup Patel

author
#0 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

---
Changes since v2:
- Updated patch subject and description
- Minor fix in shakti_uart_getc()

---
 lib/utils/serial/shakti-uart.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/utils/serial/shakti-uart.c +3 -3
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@
 #define REG_RX_THRES	0x20
 
 #define UART_TX_FULL  0x2
+#define UART_RX_NOT_EMPTY 0x4
 #define UART_RX_FULL  0x8
 
 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)
+	if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)
 		return readb(uart_base + REG_RX);
 	return -1;
 }
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

? 2022-07-08???? 17:22 +0530?Anup Patel???

Quoted 8 lines

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

look good to me

Quoted 41 lines

---
Changes since v2:
?- Updated patch subject and description
?- Minor fix in shakti_uart_getc()
---
?lib/utils/serial/shakti-uart.c | 6 +++---
?1 file changed, 3 insertions(+), 3 deletions(-)

lib/utils/serial/shakti-uart.c +0 -0
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@

?#define REG_RX_THRES???0x20
?
?#define UART_TX_FULL? 0x2
+#define UART_RX_NOT_EMPTY 0x4
?#define UART_RX_FULL? 0x8
?
?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)
+???????if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY) ????????????????return readb(uart_base + REG_RX); ????????return -1;
?}

Signature · 1 line
2.34.1
#2 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

In reply to Anup Patel
Quoted 6 lines · Anup Patel

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

This part of the description is referencing a comment that was *introduced* by an earlier version of this patch; there is no comment in the source being removed and so this part of the commit message is inaccurate.

I?m also rather concerned about reusing an existing compatible string for an incompatible device, it seems like even if you?re dropping support for an old UART the new one should have its own compatible with the version suffix bumped. They have versions in them for a reason.

Jess

Quoted 47 lines

---
Changes since v2:
- Updated patch subject and description
- Minor fix in shakti_uart_getc()
---
lib/utils/serial/shakti-uart.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
lib/utils/serial/shakti-uart.c +3 -3
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@
 #define REG_RX_THRES	0x20
 
 #define UART_TX_FULL  0x2
+#define UART_RX_NOT_EMPTY 0x4
 #define UART_RX_FULL  0x8
 
 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)
+	if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)
 		return readb(uart_base + REG_RX);
 	return -1;
 }
Signature · 7 lines
2.34.1


-- 
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
#3 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

Quoted 14 lines · Jessica Clarke
Quoted 6 lines · Anup Patel

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

This part of the description is referencing a comment that was *introduced* by an earlier version of this patch; there is no comment in the source being removed and so this part of the commit message is inaccurate.

Quoted 4 lines

I?m also rather concerned about reusing an existing compatible string for an incompatible device, it seems like even if you?re dropping support for an old UART the new one should have its own compatible with the version suffix bumped. They have versions in them for a reason.

My understanding is that they (Shakti folks) never used the old version of UART on any actual silicon. It seems they are already using the newer UART everywhere and they just forgot to change the code here.

@Prasanna Thandabani Is the above understanding correct ?

Regards,
Anup

Quoted 51 lines

Jess

Quoted 47 lines

---
Changes since v2:
- Updated patch subject and description
- Minor fix in shakti_uart_getc()
---
lib/utils/serial/shakti-uart.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
lib/utils/serial/shakti-uart.c +3 -4
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@
 #define REG_RX_THRES  0x20
 
 #define UART_TX_FULL  0x2
+#define UART_RX_NOT_EMPTY 0x4
 #define UART_RX_FULL  0x8
 
 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)
+     if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)
              return readb(uart_base + REG_RX);
      return -1;
 }
--

2.34.1

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

#4 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

Yes Anup,

That's right. The current UART is being used everywhere, and we have realised the gap in OpenSBI V1.1 release ( realised that we didn't update the OpenSBI Repo). Hence the patch.

Please let me know if more information would help.

Thanks
Prasanna
----Resending on Plain Text Mode----

Quoted 81 lines · Anup Patel
Quoted 14 lines · Jessica Clarke
Quoted 6 lines · Anup Patel

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

This part of the description is referencing a comment that was *introduced* by an earlier version of this patch; there is no comment in the source being removed and so this part of the commit message is inaccurate.

Quoted 4 lines

I?m also rather concerned about reusing an existing compatible string for an incompatible device, it seems like even if you?re dropping support for an old UART the new one should have its own compatible with the version suffix bumped. They have versions in them for a reason.

My understanding is that they (Shakti folks) never used the old version of UART on any actual silicon. It seems they are already using the newer UART everywhere and they just forgot to change the code here.

@Prasanna Thandabani Is the above understanding correct ?

Regards,
Anup

Quoted 51 lines

Jess

Quoted 47 lines

---
Changes since v2:
- Updated patch subject and description
- Minor fix in shakti_uart_getc()
---
lib/utils/serial/shakti-uart.c | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
lib/utils/serial/shakti-uart.c +3 -4
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@
 #define REG_RX_THRES  0x20
 
 #define UART_TX_FULL  0x2
+#define UART_RX_NOT_EMPTY 0x4
 #define UART_RX_FULL  0x8
 
 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)
+     if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)
              return readb(uart_base + REG_RX);
      return -1;
 }
--

2.34.1

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

Applied
#5 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

In reply to Anup Patel
Quoted 9 lines · Anup Patel

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

@Prasanna, Please make sure that Shakti UART compatible string is documented in the upstream Linux kernel. This time it's okay since there is no HW with the old version of Shakti UART but subsequent changes to Shakti UART should require a new compatible string.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 40 lines

---
Changes since v2:
- Updated patch subject and description
- Minor fix in shakti_uart_getc()

---
 lib/utils/serial/shakti-uart.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/utils/serial/shakti-uart.c +3 -4
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@
 #define REG_RX_THRES   0x20
 
 #define UART_TX_FULL  0x2
+#define UART_RX_NOT_EMPTY 0x4
 #define UART_RX_FULL  0x8
 
 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)
+       if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)
                return readb(uart_base + REG_RX);
        return -1;
 }
--

2.34.1

#6 lore raw

PATCH v3 1/1 lib: utils/serial: Update Shakti UART based on latest implementation

Sure Anup,

That's the ideal way for a longer run. Thanks for applying the patch.

Thanks
PT

Quoted 62 lines · Anup Patel
Quoted 9 lines · Anup Patel

From: Prasanna T <[email protected]>

The age old version of Shakti UART was upgraded long back, but we missed updating the driver in OpenSBI. The old version of UART is not supported anymore, hence removed the inline comment which is also outdated now.

@Prasanna, Please make sure that Shakti UART compatible string is documented in the upstream Linux kernel. This time it's okay since there is no HW with the old version of Shakti UART but subsequent changes to Shakti UART should require a new compatible string.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 40 lines

---
Changes since v2:
- Updated patch subject and description
- Minor fix in shakti_uart_getc()

---
 lib/utils/serial/shakti-uart.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/utils/serial/shakti-uart.c +3 -4
index 5f2fe75..3556935 100644
@@ -19,21 +19,21 @@
 #define REG_RX_THRES   0x20
 
 #define UART_TX_FULL  0x2
+#define UART_RX_NOT_EMPTY 0x4
 #define UART_RX_FULL  0x8
 
 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)
+       if (readb(uart_base + REG_STATUS) & UART_RX_NOT_EMPTY)
                return readb(uart_base + REG_RX);
        return -1;
 }
--

2.34.1