Skip to contentSkip to conversation

dm: serial: fix uart stop bits

PATCH New Álvaro Fernández Rojas 2 participants 9 messages May 18, 2017 – May 31, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: serial: fix uart stop bits

I missed this when I added support for BMIPS UART driver and it's needed to achieve a real 115200 8N1 setup.

---
 drivers/serial/serial_bcm6345.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/serial/serial_bcm6345.c +2 -0
index db270e3..14c1bf2 100644
@@ -141,6 +141,8 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate)
 			UART_CTL_RXTIMEOUT_5 |
 			/* set 8 bits/symbol */
 			UART_CTL_BITSPERSYM_8 |
+			/* set 1 stop bit */
+			UART_CTL_STOPBITS_1 |
 			/* set parity to even */
 			UART_CTL_RXPAREVEN_MASK |
 			UART_CTL_TXPAREVEN_MASK);
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 dm: serial: bcm6345: fix uart stop bits

I missed this when I added support for BMIPS UART driver and it's needed to achieve a real 115200 8N1 setup.

---
v2: fix commit title (missed bcm6345)

 drivers/serial/serial_bcm6345.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/serial/serial_bcm6345.c +2 -0
index db270e3..14c1bf2 100644
@@ -141,6 +141,8 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate)
 			UART_CTL_RXTIMEOUT_5 |
 			/* set 8 bits/symbol */
 			UART_CTL_BITSPERSYM_8 |
+			/* set 1 stop bit */
+			UART_CTL_STOPBITS_1 |
 			/* set parity to even */
 			UART_CTL_RXPAREVEN_MASK |
 			UART_CTL_TXPAREVEN_MASK);
Signature · 1 line
2.1.4
#2 lore raw

PATCH v3 1/2 dm: serial: bcm6345: fix uart stop bits

I missed this when I added support for BMIPS UART driver and it's needed to achieve a real 115200 8N1 setup.

---
v3: no changes, added another fix on a separate patch.
v2: fix commit title (missed bcm6345)

 drivers/serial/serial_bcm6345.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/serial/serial_bcm6345.c +2 -0
index db270e3..14c1bf2 100644
@@ -141,6 +141,8 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate)
 			UART_CTL_RXTIMEOUT_5 |
 			/* set 8 bits/symbol */
 			UART_CTL_BITSPERSYM_8 |
+			/* set 1 stop bit */
+			UART_CTL_STOPBITS_1 |
 			/* set parity to even */
 			UART_CTL_RXPAREVEN_MASK |
 			UART_CTL_TXPAREVEN_MASK);
Signature · 1 line
2.1.4
#3 lore raw

PATCH v3 2/2 dm: serial: bcm6345: fix baud rate clock calculation

It's currently bugged and doesn't work for even cases. Right shift bits instead of dividing and fix even cases.

---
 drivers/serial/serial_bcm6345.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/serial/serial_bcm6345.c +4 -6
index 14c1bf2..9638952 100644
@@ -157,11 +157,9 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate)
 			UART_FIFO_CFG_TX_4);
 
 	/* set baud rate */
-	val = (clk / baudrate) / 16;
-	if (val & 0x1)
-		val = val;
-	else
-		val = val / 2 - 1;
+	val = ((clk / baudrate) >> 5);
+	if (!(val & 0x1))
+		val -= 1;
 	writel_be(val, base + UART_BAUD_REG);
 
 	/* clear interrupts */
@@ -243,7 +241,7 @@ static int bcm6345_serial_probe(struct udevice *dev)
 	ret = clk_get_by_index(dev, 0, &clk);
 	if (ret < 0)
 		return ret;
-	priv->uartclk = clk_get_rate(&clk) / 2;
+	priv->uartclk = clk_get_rate(&clk);
 	clk_free(&clk);
 
 	/* initialize serial */
Signature · 1 line
2.1.4
#4 lore raw

PATCH v3 2/2 dm: serial: bcm6345: fix baud rate clock calculation

Am 18.05.2017 um 23:09 schrieb Álvaro Fernández Rojas:

Quoted 8 lines

It's currently bugged and doesn't work for even cases. Right shift bits instead of dividing and fix even cases.

---
 drivers/serial/serial_bcm6345.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

applied to u-boot-mips, thanks.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170520/c7e23eaf/attachment.sig>

#5 lore raw

PATCH v3 2/2 dm: serial: bcm6345: fix baud rate clock calculation

Hi Daniel,
It looks like this is not the correct way to calculate it either.I will send a proper patch later today.I'm very sorry for the inconvenience. Regards,Álvaro.

On Sat, May 20, 2017 at 6:04 PM +0200, "Daniel Schwierzeck" <[email protected]> wrote:

Am 18.05.2017 um 23:09 schrieb Álvaro Fernández Rojas:

Quoted 8 lines

It's currently bugged and doesn't work for even cases. Right shift bits instead of dividing and fix even cases.

Signed-off-by Álvaro Fernández Rojas
---
 drivers/serial/serial_bcm6345.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

applied to u-boot-mips, thanks.

#6 lore raw

PATCH v4 1/1 dm: serial: bcm6345: fix baud rate clock calculation

It's currently bugged and doesn't work for even cases. Right shift bits instead of dividing and fix even cases.

---
v4: really fix baud rate calculation
v3: fix baud rate calculation

 drivers/serial/serial_bcm6345.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/serial/serial_bcm6345.c +4 -4
index 14c1bf2..0843b48 100644
@@ -157,11 +157,11 @@ static int bcm6345_serial_init(void __iomem *base, ulong clk, u32 baudrate)
 			UART_FIFO_CFG_TX_4);
 
 	/* set baud rate */
-	val = (clk / baudrate) / 16;
+	val = ((clk / baudrate) >> 4);
 	if (val & 0x1)
-		val = val;
+		val = (val >> 1);
 	else
-		val = val / 2 - 1;
+		val = (val >> 1) - 1;
 	writel_be(val, base + UART_BAUD_REG);
 
 	/* clear interrupts */
@@ -243,7 +243,7 @@ static int bcm6345_serial_probe(struct udevice *dev)
 	ret = clk_get_by_index(dev, 0, &clk);
 	if (ret < 0)
 		return ret;
-	priv->uartclk = clk_get_rate(&clk) / 2;
+	priv->uartclk = clk_get_rate(&clk);
 	clk_free(&clk);
 
 	/* initialize serial */
Signature · 1 line
2.1.4
#7 lore raw

PATCH v4 1/1 dm: serial: bcm6345: fix baud rate clock calculation

Am 22.05.2017 um 20:01 schrieb Álvaro Fernández Rojas:

Quoted 11 lines

It's currently bugged and doesn't work for even cases. Right shift bits instead of dividing and fix even cases.

---
v4: really fix baud rate calculation
v3: fix baud rate calculation

 drivers/serial/serial_bcm6345.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

applied to u-boot-mips/next and replaced the previously applied v3 patch, thanks.

Signature · 9 lines
- Daniel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170531/fc4ff360/attachment.sig>
#8 lore raw

PATCH v3 1/2 dm: serial: bcm6345: fix uart stop bits

In reply to Álvaro Fernández Rojas

Am 18.05.2017 um 23:09 schrieb Álvaro Fernández Rojas:

Quoted 11 lines

I missed this when I added support for BMIPS UART driver and it's needed to achieve a real 115200 8N1 setup.

---
v3: no changes, added another fix on a separate patch.
v2: fix commit title (missed bcm6345)

 drivers/serial/serial_bcm6345.c | 2 ++
 1 file changed, 2 insertions(+)

applied to u-boot-mips, thanks.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170520/830bfb25/attachment.sig>