Skip to contentSkip to conversation

ARM: PL011: add support for extended FIFO-size of PL011-r1p5

PATCH Superseded Jongsung Kim 4 participants 18 messages Apr 12, 2013 – May 22, 2013

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: PL011: add support for extended FIFO-size of PL011-r1p5

The latest r1p5-revision of the ARM PL011 UART has 32-byte FIFOs, while all earlier ones have 16-byte FIFOs. This patch suggests a way to set the FIFO-size correctly & flexibly by using a function(vendor_data::get_fifosize) rather than using the vendor_data::fifosize variable. The function takes the UARTPeriphID, and returns the correct size.

 drivers/tty/serial/amba-pl011.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)
(quoted diff) +0 -0

b/drivers/tty/serial/amba-pl011.c
index 3ea5408..22af0c8 100644

drivers/tty/serial/amba-pl011.c +0 -0
@@ -72,32 +72,44 @@
 /* There is by now at least one vendor with differing details, so handle it

*/
struct vendor_data {
unsigned int ifls;
- unsigned int fifosize;
unsigned int lcrh_tx;
unsigned int lcrh_rx;
bool oversampling;
bool dma_threshold;
bool cts_event_workaround;
+
+ unsigned int (*get_fifosize)(unsigned int periphid);
};

+static unsigned int get_fifosize_arm(unsigned int periphid) +{
+ unsigned int rev = (periphid >> 20) & 0xf;
+ return rev < 3 ? 16 : 32;
+}
+
static struct vendor_data vendor_arm = {
.ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8,
- .fifosize = 16,
.lcrh_tx = UART011_LCRH,
.lcrh_rx = UART011_LCRH,
.oversampling = false,
.dma_threshold = false,
.cts_event_workaround = false,
+ .get_fifosize = get_fifosize_arm,
};

+static unsigned int get_fifosize_st(unsigned int periphid) +{
+ return 64;
+}
+
static struct vendor_data vendor_st = {
.ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF,
- .fifosize = 64,
.lcrh_tx = ST_UART011_LCRH_TX,
.lcrh_rx = ST_UART011_LCRH_RX,
.oversampling = true,
.dma_threshold = true,
.cts_event_workaround = true,
+ .get_fifosize = get_fifosize_st,
};

static struct uart_amba_port *amba_ports[UART_NR];
@@ -2010,7 +2022,7 @@ static int pl011_probe(struct amba_device *dev, const struct amba_id *id)
uap->lcrh_rx = vendor->lcrh_rx;
uap->lcrh_tx = vendor->lcrh_tx;
uap->old_cr = 0;
- uap->fifosize = vendor->fifosize;
+ uap->fifosize = vendor->get_fifosize(dev->periphid);
uap->port.dev = &dev->dev;
uap->port.mapbase = dev->res.start;
uap->port.membase = base;

#1 lore raw

Review

Quoted 4 lines · Jongsung Kim
(quoted diff) +4 -0
+static unsigned int get_fifosize_arm(unsigned int periphid)
+{
+	unsigned int rev = (periphid >> 20) & 0xf;
+	return rev < 3 ? 16 : 32;

Don't we have a macro to get the revision given the amba device? amba_rev().

#2 lore raw
In reply to Jongsung Kim
Quoted 6 lines · Jongsung Kim

The latest r1p5-revision of the ARM PL011 UART has 32-byte FIFOs, while all earlier ones have 16-byte FIFOs. This patch suggests a way to set the FIFO-size correctly & flexibly by using a function(vendor_data::get_fifosize) rather than using the vendor_data::fifosize variable. The function takes the UARTPeriphID, and returns the correct size.

This change (now part of 3.10-rc1) breaks the serial port on the BCM2835 ARM SoC (part of the Raspberry Pi). Sorry for not noticing this earlier; a combination of my vacation and laziness I guess.

For reference, the AMBA periphid of the UART device there is 0x00341011. The nibble "3" is the revision being tested in:

Review

Quoted 5 lines
(quoted diff) +5 -0
+static unsigned int get_fifosize_arm(unsigned int periphid)
+{
+	unsigned int rev = (periphid >> 20) & 0xf;
+	return rev < 3 ? 16 : 32;
+}

Should that be <= not <, or is there just something more wrong in the patch or bcm2835 HW? I wonder how r1p5 maps to 3 in the test above.

#3 lore raw

Stephen Warren <[email protected]> :

Quoted 2 lines

For reference, the AMBA periphid of the UART device there is 0x00341011. The nibble "3" is the revision being tested in:

The UART device has periphid 0x00341011, and is compatible with the original PL011 prior to r1p5. Not with r1p5. It could be a possible way to specify the compatible periphid (such as 0x00241011) instead of just 0x0 when initializing the amba_device for the UART.

Quoted 10 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+static unsigned int get_fifosize_arm(unsigned int periphid)
+{
+	unsigned int rev = (periphid >> 20) & 0xf;
+	return rev < 3 ? 16 : 32;
+}

Should that be <= not <, or is there just something more wrong in the patch or bcm2835 HW? I wonder how r1p5 maps to 3 in the test above.

From the PL011-r1p5 TRM, bits[7:4] of the UARTPeriphID2 register are

read as:

r1p0 - 0x0
r1p1 - 0x1
r1p3 - 0x2
r1p4 - 0x2
r1p5 - 0x3.

Doesn't the BCM2835 UART have anything different from the ARM PL011? What about the UARTPCellID registers? They are set to 0xb105f00d with the ARM PL011.

#4 lore raw
Quoted 14 lines · Jongsung Kim

Stephen Warren <[email protected]> :

Quoted 2 lines

For reference, the AMBA periphid of the UART device there is 0x00341011. The nibble "3" is the revision being tested in:

The UART device has periphid 0x00341011, and is compatible with the original PL011 prior to r1p5. Not with r1p5. It could be a possible way to specify the compatible periphid (such as 0x00241011) instead of just 0x0 when initializing the amba_device for the UART.

Quoted 5 lines
Quoted 5 lines
(quoted diff) +5 -0
+static unsigned int get_fifosize_arm(unsigned int periphid)
+{
+	unsigned int rev = (periphid >> 20) & 0xf;
+	return rev < 3 ? 16 : 32;
+}

...

Quoted 3 lines

Doesn't the BCM2835 UART have anything different from the ARM PL011? What about the UARTPCellID registers? They are set to 0xb105f00d with the ARM PL011.

Looking at BCM2835-ARM-Peripherals.pdf (i.e. the public documentation for the BCM2835 chip), I see:

=====
The UART provides:
* Separate 16x8 transmit and 16x12 receive FIFO memory.
...
For the in-depth UART overview, please, refer to the ARM PrimeCell UART (PL011) Revision: r1p5 Technical Reference Manual.
=====

That seems to imply that not all r1p5 PL011s actually have a depth-32 FIFO. Perhaps this is a configurable property of the IP block, not something that all r1p5 have?

I can't check the UARTPCellID registers right now.

#5 lore raw
Quoted 31 lines · Stephen Warren
Quoted 14 lines · Jongsung Kim

Stephen Warren <[email protected]> :

Quoted 2 lines

For reference, the AMBA periphid of the UART device there is 0x00341011. The nibble "3" is the revision being tested in:

The UART device has periphid 0x00341011, and is compatible with the original PL011 prior to r1p5. Not with r1p5. It could be a possible way to specify the compatible periphid (such as 0x00241011) instead of just 0x0 when initializing the amba_device for the UART.

Quoted 5 lines
Quoted 5 lines
(quoted diff) +5 -0
+static unsigned int get_fifosize_arm(unsigned int periphid)
+{
+	unsigned int rev = (periphid >> 20) & 0xf;
+	return rev < 3 ? 16 : 32;
+}

...

Quoted 3 lines

Doesn't the BCM2835 UART have anything different from the ARM PL011? What about the UARTPCellID registers? They are set to 0xb105f00d with the ARM PL011.

Looking at BCM2835-ARM-Peripherals.pdf (i.e. the public documentation for the BCM2835 chip), I see:

=====
The UART provides:
* Separate 16x8 transmit and 16x12 receive FIFO memory.
...
For the in-depth UART overview, please, refer to the ARM PrimeCell UART (PL011) Revision: r1p5 Technical Reference Manual.
=====

Quoted 5 lines

That seems to imply that not all r1p5 PL011s actually have a depth-32 FIFO. Perhaps this is a configurable property of the IP block, not something that all r1p5 have?

I can't check the UARTPCellID registers right now.

The PCellID value is a marker for primecells, and is common to all primecells which implement the ID scheme. It's the other ID registers you want. :)

#6 lore raw
In reply to Stephen Warren

Stephen Warren <[email protected]> :

Quoted 11 lines

Looking at BCM2835-ARM-Peripherals.pdf (i.e. the public documentation for the BCM2835 chip), I see:

=====
The UART provides:
* Separate 16x8 transmit and 16x12 receive FIFO memory.
...
For the in-depth UART overview, please, refer to the ARM PrimeCell UART (PL011) Revision: r1p5 Technical Reference Manual.
=====

Quoted 1 line

That seems to imply that not all r1p5 PL011s actually have a depth-32

FIFO.

Quoted 1 line

Perhaps this is a configurable property of the IP block, not something

that

Quoted 1 line

all r1p5 have?

All r1p5 have 32-byte FIFO depth and it's not configurable. From the PL011 TRM:

r1p4-r1p5 Contains the following differences in functionality:
* The receive and transmit FIFOs are increased to a depth of
32.
* The Revision field in the UARTPeriphID2 Register on page
3-24

		  bits [7:4] now reads back as 0x3.
#7 lore raw
Quoted 16 lines · Jongsung Kim

Stephen Warren <[email protected]> :

Quoted 11 lines

Looking at BCM2835-ARM-Peripherals.pdf (i.e. the public documentation for the BCM2835 chip), I see:

=====
The UART provides:
* Separate 16x8 transmit and 16x12 receive FIFO memory.
...
For the in-depth UART overview, please, refer to the ARM PrimeCell UART (PL011) Revision: r1p5 Technical Reference Manual.
=====

Quoted 3 lines

That seems to imply that not all r1p5 PL011s actually have a depth-32 FIFO. Perhaps this is a configurable property of the IP block, not something that all r1p5 have?

Quoted 7 lines

All r1p5 have 32-byte FIFO depth and it's not configurable. From the PL011 TRM:

r1p4-r1p5 Contains the following differences in functionality:
* The receive and transmit FIFOs are increased to a depth of 32.
* The Revision field in the UARTPeriphID2 Register on page 3-24 bits [7:4] now reads back as 0x3.

Well, that certainly isn't true in practice. I think we should revert this commit until we can determine what the problem is.

I validated that the periphid register in HW contains the r1p5 revision (3), and the pcellid register does indeed contain the expected 0xb105f00d value. However, if I run the following hacky code in U-Boot to determine the FIFO depth, it comes out as 16, which explains the symptoms I'm seeing:

void find_fifo_depth(void)

{
	volatile u8 *uart = 0x20201000;
	int depth = 0;

	/* Wait for TX FIFO empty */
	while (!(uart[0x18] & 0x80))
		;

	/* Disable UART */
	uart[0x30] &= ~1;

	/* Push chars into TX FIFO until full */
	for (;;) {
		uart[0] = 'A' + depth;
		depth++;
		/* Done if FIFO full */
		if (uart[0x18] & 0x20)
			break;
		if (depth > 64) {
			depth = -1;
			break;
		}
	}

	/* Re-enable UART */
	uart[0x30] |= 1;

	printf("FIFO depth: %d\n", depth);
}
#8 lore raw
Quoted 8 lines · Stephen Warren

Well, that certainly isn't true in practice. I think we should revert this commit until we can determine what the problem is.

I validated that the periphid register in HW contains the r1p5 revision (3), and the pcellid register does indeed contain the expected 0xb105f00d value. However, if I run the following hacky code in U-Boot to determine the FIFO depth, it comes out as 16, which explains the symptoms I'm seeing:

We could do that, just like we do in 8250.c to check the FIFO depth. There's not much harm in doing that at boot time, it just needs to be done carefully so that it doesn't disrupt any existing use of the UART.

#9 lore raw
In reply to Stephen Warren

Stephen Warren <[email protected]> :

Quoted 1 line
Quoted 1 line

All r1p5 have 32-byte FIFO depth and it's not configurable. From the

PL011

Quoted 4 lines
Quoted 4 lines

TRM:

r1p4-r1p5 Contains the following differences in functionality:
* The receive and transmit FIFOs are increased to a depth of

32.

Quoted 1 line
Quoted 1 line

* The Revision field in the UARTPeriphID2 Register on page

3-24

Quoted 4 lines
Quoted 1 line
		  bits [7:4] now reads back as 0x3.

Well, that certainly isn't true in practice. I think we should revert this commit until we can determine what the problem is.

I asked to the ARM support about this. Waiting for reply..

#10 lore raw
In reply to Stephen Warren

Jongsung Kim <[email protected]> :

Quoted 7 lines

Stephen Warren <[email protected]> :

Quoted 6 lines
Quoted 6 lines

All r1p5 have 32-byte FIFO depth and it's not configurable. From the PL011
TRM:

r1p4-r1p5 Contains the following differences in functionality:
* The receive and transmit FIFOs are increased to a depth of

32.

Quoted 1 line
Quoted 1 line
Quoted 1 line

* The Revision field in the UARTPeriphID2 Register on page

3-24

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
		  bits [7:4] now reads back as 0x3.

Well, that certainly isn't true in practice. I think we should revert this commit until we can determine what the problem is.

I asked to the ARM support about this. Waiting for reply..

ARM support said they doesn't have information about BCM2835 UART. Does anyone have a communication channel to Broadcom? It takes time for me to get contact point to Broadcom.. (I'm trying)

However, ARM support also said:

"If the Broadcom part definitely has 16-deep FIFOs, it cannot be based on a PL011 r1p5, so I might guess that Broadcom have just referenced the latest version of the documentation on our website, but have actually implemented an earlier version."

#11 lore raw
Quoted 22 lines · Jongsung Kim

Jongsung Kim <[email protected]> :

Quoted 7 lines

Stephen Warren <[email protected]> :

Quoted 6 lines
Quoted 6 lines

All r1p5 have 32-byte FIFO depth and it's not configurable. From the PL011
TRM:

r1p4-r1p5 Contains the following differences in functionality:
* The receive and transmit FIFOs are increased to a depth of

32.

Quoted 1 line
Quoted 1 line
Quoted 1 line

* The Revision field in the UARTPeriphID2 Register on page

3-24

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
		  bits [7:4] now reads back as 0x3.

Well, that certainly isn't true in practice. I think we should revert this commit until we can determine what the problem is.

I asked to the ARM support about this. Waiting for reply..

ARM support said they doesn't have information about BCM2835 UART. Does anyone have a communication channel to Broadcom? It takes time for me to get contact point to Broadcom.. (I'm trying)

Quoted 6 lines

However, ARM support also said:

"If the Broadcom part definitely has 16-deep FIFOs, it cannot be based on a PL011 r1p5, so I might guess that Broadcom have just referenced the latest version of the documentation on our website, but have actually implemented an earlier version."

This all seems rather academic. Irrespective of what the cause of the problem is, the commit actively breaks a previously working configuration. I still believe we should revert it first, then find out exactly what's going on later. Should I sent the revert commit?

#12 lore raw

PATCH 1/1 ARM: bcm2835: override the HW UART periphid

Stephen Warren reported the recent commit 78506f2 (add support for extended FIFO-size of PL011-r1p5) breaks the serial port on the BCM2835 ARM SoC.

A UART compatible with the ARM PL011-r1p5 should have 32-deep FIFOs. The BCM2835 UART just looks like an ARM PL011-r1p5, but has 16-deep FIFOs just like PL011-r1p4 or earlier revisions. As a workaround for this compatibility issue, this patch overrides the HW UART periphid register values with the actually compatible UART periphid 0x00241011 (r1p3 or r1p4).

---
 arch/arm/boot/dts/bcm2835.dtsi |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/arm/boot/dts/bcm2835.dtsi +1 -0
index f0052dc..1e12aef 100644
@@ -44,6 +44,7 @@
 			reg = <0x7e201000 0x1000>;
 			interrupts = <2 25>;
 			clock-frequency = <3000000>;
+			arm,primecell-periphid = <0x00241011>;
 		};
 
 		gpio: gpio {
Signature · 1 line
1.7.1
#13 lore raw

RE: [PATCH] ARM: bcm2835: override the HW UART periphid

Jongsung Kim <[email protected]> :

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/boot/dts/bcm2835.dtsi

arch/arm/boot/dts/bcm2835.dtsi line 50

Quoted 11 lines

index f0052dc..1e12aef 100644

arch/arm/boot/dts/bcm2835.dtsi +1 -0
@@ -44,6 +44,7 @@
 			reg = <0x7e201000 0x1000>;
 			interrupts = <2 25>;
 			clock-frequency = <3000000>;
+			arm,primecell-periphid = <0x00241011>;
 		};
 
 		gpio: gpio {

Stephen, how do you think about this kind of approach instead?

#14 lore raw

Re: [PATCH] ARM: bcm2835: override the HW UART periphid

Have checked with the designer of the UART block and he confirmed that the 2835 PL011 contains a 16 deep fifo not 32 deep...

Hardware guys, they can never just leave it alone!!!

Gordon

Quoted 22 lines · Jongsung Kim

Jongsung Kim <[email protected]> :

Review

Quoted 1 line
(quoted diff) +0 -0

b/arch/arm/boot/dts/bcm2835.dtsi

arch/arm/boot/dts/bcm2835.dtsi line 50

Quoted 11 lines

index f0052dc..1e12aef 100644

arch/arm/boot/dts/bcm2835.dtsi +1 -0
@@ -44,6 +44,7 @@
                      reg = <0x7e201000 0x1000>;
                      interrupts = <2 25>;
                      clock-frequency = <3000000>;
+                     arm,primecell-periphid = <0x00241011>;
              };
 
              gpio: gpio {

Stephen, how do you think about this kind of approach instead?

_______________________________________________
linux-rpi-kernel mailing list
linux-rpi-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rpi-kernel

#15 lore raw

Re: [PATCH] ARM: bcm2835: override the HW UART periphid

In reply to Jongsung Kim
Quoted 11 lines · Jongsung Kim

Stephen Warren reported the recent commit 78506f2 (add support for extended FIFO-size of PL011-r1p5) breaks the serial port on the BCM2835 ARM SoC.

A UART compatible with the ARM PL011-r1p5 should have 32-deep FIFOs. The BCM2835 UART just looks like an ARM PL011-r1p5, but has 16-deep FIFOs just like PL011-r1p4 or earlier revisions. As a workaround for this compatibility issue, this patch overrides the HW UART periphid register values with the actually compatible UART periphid 0x00241011 (r1p3 or r1p4).

Quoted 2 lines

I know this will work, because I tried out the same thing last week.

However, I'm not convinced that it's the correct approach. What other changes exist between r1p4 and r1p5; can you check in the TRM? Faking the periphid would prevent the driver from taking account of any other changes. Should we instead add a DT property solely to override the FIFO size, and then set that for bcm2835? I guess if there really aren't any other SW-visible changes in r1p5, this approach is fine.

#16 lore raw

Re: [PATCH] ARM: bcm2835: override the HW UART periphid

Quoted 12 lines · Stephen Warren
Quoted 11 lines · Jongsung Kim

Stephen Warren reported the recent commit 78506f2 (add support for extended FIFO-size of PL011-r1p5) breaks the serial port on the BCM2835 ARM SoC.

A UART compatible with the ARM PL011-r1p5 should have 32-deep FIFOs. The BCM2835 UART just looks like an ARM PL011-r1p5, but has 16-deep FIFOs just like PL011-r1p4 or earlier revisions. As a workaround for this compatibility issue, this patch overrides the HW UART periphid register values with the actually compatible UART periphid 0x00241011 (r1p3 or r1p4).

Quoted 7 lines
Quoted 2 lines

I know this will work, because I tried out the same thing last week.

However, I'm not convinced that it's the correct approach. What other changes exist between r1p4 and r1p5; can you check in the TRM?

Looking at the TRM, it seems this is really the only change, according to the changelog in the documentation (although it's a little difficult to tell since the document seems to have a bunch of changes that presumably don't affect behaviour). So, faking the periphid seems OK.

Let's apply for 3.10.

#17 lore raw

RE: [PATCH] ARM: bcm2835: override the HW UART periphid

Stephen Warren <[email protected]> :

Quoted 3 lines

Looking at the TRM, it seems this is really the only change, according to the changelog in the documentation (although it's a little difficult to tell since the document seems to have a bunch of changes that

presumably

Quoted 5 lines

don't affect behaviour). So, faking the periphid seems OK.

Let's apply for 3.10.

Thank you, Stephen.