Skip to contentSkip to conversation

Initial DT support for MSM8660

PATCH Superseded David Brown 2 participants 10 messages Aug 12, 2011 – Aug 16, 2011

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Initial DT support for MSM8660

This series adds initial support for booting the MSM8660 via devicetree. The target boots with a serial console, and no platform data.

In order to test this with a devicetree boot, it is necessary to include patches allowing the devicetree to be appended to the kernel, and merge ATAG values into the DT.

Once these patches reach mainline, I intend to remove the non-DT boot for this target.

David Brown (4):
msm_serial: Use relative resources for iomem
msm_serial: Add devicetree support
ARM: msm: Add devicetree support for msm8660-surf
ARM: msm: Describe MSM 8660 SURF FPGA registers in DT

 .../devicetree/bindings/tty/serial/msm_serial.txt  |   18 ++++
 arch/arm/boot/dts/msm8660-surf.dts                 |   29 ++++++
 arch/arm/mach-msm/board-msm8x60.c                  |   98 ++++++++++++++++++--
 drivers/tty/serial/msm_serial.c                    |   30 ++++--
 4 files changed, 158 insertions(+), 17 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/tty/serial/msm_serial.txt
 create mode 100644 arch/arm/boot/dts/msm8660-surf.dts
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#1 lore raw

PATCH 1/4 msm_serial: Use relative resources for iomem

Device tree iomem resources are only accessible by index, and not by name. The msm_serial devices always have either 1 or 2 iomem resources, that are always in the same order. Convert the platform_get_resource_byname into just platform_get_resource to facilitate device tree conversion.

---
 drivers/tty/serial/msm_serial.c |   16 ++++++----------
 1 files changed, 6 insertions(+), 10 deletions(-)
drivers/tty/serial/msm_serial.c +6 -10
index e6ba838..d9863b2 100644
@@ -589,9 +589,8 @@ static void msm_release_port(struct uart_port *port)
 		iowrite32(GSBI_PROTOCOL_IDLE, msm_port->gsbi_base +
 			  GSBI_CONTROL);
 
-		gsbi_resource = platform_get_resource_byname(pdev,
-							     IORESOURCE_MEM,
-							     "gsbi_resource");
+		gsbi_resource = platform_get_resource(pdev,
+							IORESOURCE_MEM, 1);
 
 		if (unlikely(!gsbi_resource))
 			return;
@@ -612,8 +611,7 @@ static int msm_request_port(struct uart_port *port)
 	resource_size_t size;
 	int ret;
 
-	uart_resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						     "uart_resource");
+	uart_resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (unlikely(!uart_resource))
 		return -ENXIO;
 
@@ -628,8 +626,7 @@ static int msm_request_port(struct uart_port *port)
 		goto fail_release_port;
 	}
 
-	gsbi_resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						     "gsbi_resource");
+	gsbi_resource = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 	/* Is this a GSBI-based port? */
 	if (gsbi_resource) {
 		size = resource_size(gsbi_resource);
@@ -875,7 +872,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
 	port->dev = &pdev->dev;
 	msm_port = UART_TO_MSM(port);
 
-	if (platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsbi_resource"))
+	if (platform_get_resource(pdev, IORESOURCE_MEM, 1))
 		msm_port->is_uartdm = 1;
 	else
 		msm_port->is_uartdm = 0;
@@ -899,8 +896,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
 	printk(KERN_INFO "uartclk = %d\n", port->uartclk);
 
 
-	resource = platform_get_resource_byname(pdev, IORESOURCE_MEM,
-						     "uart_resource");
+	resource = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (unlikely(!resource))
 		return -ENXIO;
 	port->mapbase = resource->start;
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#2 lore raw

PATCH 2/4 msm_serial: Add devicetree support

In reply to David Brown

Add devicetree support to the msm_serial driver. Clocks are still queried by direct name from the driver until device tree clock support is implemented.

---
 .../devicetree/bindings/tty/serial/msm_serial.txt  |   18 ++++++++++++++++++
 drivers/tty/serial/msm_serial.c                    |   14 ++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/tty/serial/msm_serial.txt
Documentation/devicetree/bindings/tty/serial/msm_serial.txt new file +18 -0
new file mode 100644
index 0000000..071459c
@@ -0,0 +1,18 @@
+* Qualcomm MSM UART
+
+Required properties:
+- compatible :
+	- "qcom,msm-uart"
+- reg : offset and length of the register set for the device
+	for the hsuart operating in compatible mode, there should be a
+	second pair describing the gsbi registers.
+- interrupts : should contain the uart interrupt.
+
+Example:
+
+	uart at 19c400000 {
+		compatible = "qcom,msm-hsuart", "qcom,msm-uart";
+		reg = <0x19c40000 0x1000">,
+		      <0x19c00000 0x1000">;
+		interrupts = <195>;
+	};
drivers/tty/serial/msm_serial.c +14 -0
index d9863b2..d5a6db6 100644
@@ -19,6 +19,7 @@
 # define SUPPORT_SYSRQ
 #endif
 
+#include <linux/atomic.h>
 #include <linux/hrtimer.h>
 #include <linux/module.h>
 #include <linux/io.h>
@@ -33,6 +34,8 @@
 #include <linux/clk.h>
 #include <linux/platform_device.h>
 #include <linux/delay.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
 
 #include "msm_serial.h"
 
@@ -856,6 +859,8 @@ static struct uart_driver msm_uart_driver = {
 	.cons = MSM_CONSOLE,
 };
 
+static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
+
 static int __init msm_serial_probe(struct platform_device *pdev)
 {
 	struct msm_port *msm_port;
@@ -863,6 +868,9 @@ static int __init msm_serial_probe(struct platform_device *pdev)
 	struct uart_port *port;
 	int irq;
 
+	if (pdev->id == -1)
+		pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
+
 	if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
 		return -ENXIO;
 
@@ -920,11 +928,17 @@ static int __devexit msm_serial_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static struct of_device_id msm_match_table[] = {
+	{ .compatible = "qcom,msm-hsuart-lite" },
+	{}
+};
+
 static struct platform_driver msm_platform_driver = {
 	.remove = msm_serial_remove,
 	.driver = {
 		.name = "msm_serial",
 		.owner = THIS_MODULE,
+		.of_match_table = msm_match_table,
 	},
 };
 
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#8 lore raw

PATCH 3/4 ARM: msm: Add devicetree support for msm8660-surf

In reply to David Brown

Adds support for booting via device tree with a simple serial console.

---
 arch/arm/boot/dts/msm8660-surf.dts |   24 +++++++++++++++
 arch/arm/mach-msm/board-msm8x60.c  |   58 +++++++++++++++++++++++++++++++----
 2 files changed, 75 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/boot/dts/msm8660-surf.dts
arch/arm/boot/dts/msm8660-surf.dts new file +24 -0
new file mode 100644
index 0000000..308d867
@@ -0,0 +1,24 @@
+/dts-v1/;
+
+/include/ "skeleton.dtsi"
+
+/ {
+	model = "Qualcomm MSM8660 SURF";
+	compatible = "qcom,msm8660-surf", "qcom,msm8660";
+	interrupt-parent = <&intc>;
+
+	intc: interrupt-controller at 02080000 {
+		compatible = "qcom,msm-8660-qgic";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		reg = < 0x02080000 0x1000 >,
+		      < 0x02081000 0x1000 >;
+	};
+
+	serial at 19c400000 {
+		compatible = "qcom,msm-hsuart-lite";
+		reg = <0x19c40000 0x1000>,
+		      <0x19c00000 0x1000>;
+		interrupts = <195>;
+	};
+};
arch/arm/mach-msm/board-msm8x60.c +51 -7

82 lines not on this page · raw message

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#9 lore raw

PATCH 4/4 ARM: msm: Describe MSM 8660 SURF FPGA registers in DT

In reply to David Brown

The MSM 8660 SURF development board contains a register-accessible FPGA. By default, this FPGA configures the first UART in output-only mode. On this target, reconfigure this FPGA to enable the UART to be bidirectional.

---
 arch/arm/boot/dts/msm8660-surf.dts |    5 +++
 arch/arm/mach-msm/board-msm8x60.c  |   48 +++++++++++++++++++++++++++++++++---
 2 files changed, 49 insertions(+), 4 deletions(-)
arch/arm/boot/dts/msm8660-surf.dts +5 -0
index 308d867..13a91f7 100644
@@ -21,4 +21,9 @@
 		      <0x19c00000 0x1000>;
 		interrupts = <195>;
 	};
+
+	qcom,fpga at 1d000000 {
+		compatible = "qcom,msm8660-surf-fpga";
+		reg = < 0x1d000000 0x1000 >;
+	};
 };
arch/arm/mach-msm/board-msm8x60.c +44 -4

62 lines not on this page · raw message

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#3 lore raw

Re: [PATCH 2/4] msm_serial: Add devicetree support

In reply to David Brown
Quoted 20 lines · On Friday 12 August 2011 16:00:06 David Brown wrote:
Documentation/devicetree/bindings/tty/serial/msm_serial.txt new file +16 -0
+Required properties:
+- compatible :
+       - "qcom,msm-uart"
+- reg : offset and length of the register set for the device
+       for the hsuart operating in compatible mode, there should be a
+       second pair describing the gsbi registers.
+- interrupts : should contain the uart interrupt.
+
+Example:
+
+       uart at 19c400000 {
+               compatible = "qcom,msm-hsuart", "qcom,msm-uart";
+               reg = <0x19c40000 0x1000">,
+                     <0x19c00000 0x1000">;
+               interrupts = <195>;
+       };

Documentation/devicetree/bindings/tty/serial/msm_serial.txt static int __devexit msm_serial_remove(struct platform_device *pdev) · line 935

Quoted 8 lines
Documentation/devicetree/bindings/tty/serial/msm_serial.txt new file +5 -0
@@ -920,11 +928,17 @@ static int __devexit msm_serial_remove(struct platform_device *pdev)
        return 0;
 }
 
+static struct of_device_id msm_match_table[] = {
+       { .compatible = "qcom,msm-hsuart-lite" },
+       {}
+};
+

Hi David,

It looks like you changed the value for the "compatible" property in the process of making the patch, but did not update all places.

Should it be qcom,msm-hsuart-lite or qcom,msm-hsuart?

Arnd

#4 lore raw

Re: [PATCH 2/4] msm_serial: Add devicetree support

Quoted 32 lines · Arnd Bergmann
Quoted 20 lines · On Friday 12 August 2011 16:00:06 David Brown wrote:
Documentation/devicetree/bindings/tty/serial/msm_serial.txt new file +16 -0
+Required properties:
+- compatible :
+       - "qcom,msm-uart"
+- reg : offset and length of the register set for the device
+       for the hsuart operating in compatible mode, there should be a
+       second pair describing the gsbi registers.
+- interrupts : should contain the uart interrupt.
+
+Example:
+
+       uart at 19c400000 {
+               compatible = "qcom,msm-hsuart", "qcom,msm-uart";
+               reg = <0x19c40000 0x1000">,
+                     <0x19c00000 0x1000">;
+               interrupts = <195>;
+       };

Documentation/devicetree/bindings/tty/serial/msm_serial.txt static int __devexit msm_serial_remove(struct platform_device *pdev) · line 935

Quoted 8 lines
Documentation/devicetree/bindings/tty/serial/msm_serial.txt new file +5 -0
@@ -920,11 +928,17 @@ static int __devexit msm_serial_remove(struct platform_device *pdev)
        return 0;
 }
 
+static struct of_device_id msm_match_table[] = {
+       { .compatible = "qcom,msm-hsuart-lite" },
+       {}
+};
+

Hi David,

Quoted 4 lines

It looks like you changed the value for the "compatible" property in the process of making the patch, but did not update all places.

Should it be qcom,msm-hsuart-lite or qcom,msm-hsuart?

I guess I got the documentation to be different than the code. Sadily, I think the documentation is probably what I want instead of the code.

I'm not sure actually what is best to use here. I'm thinking that the 'lite' identifier should perhaps go away. MSM's have two UARTS on them, an older "simple" PIO type of UART, and a newer one that can do DMA (called the hsuart for high-speed). The hsuart can also be used in a non-DMA driver in a mostly compatible way with the old UART.

For non-high-speed applications, the user will probably just want to use the non-DMA driver. My question is then: if the device tree describes it as

	compatible = "qcom,msm-hsuart", "qcom,msm-uart";

and one driver matches qcom,msm-hsuart and another matches qcom,msm-uart, which driver will get used. Ideally, it would use the earliest one in the list.

If that's the case, I'll get rid of the -lite suffix and just make the non-DMA driver compatible with the plain "qcom,msm-uart".

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#5 lore raw

Re: [PATCH 2/4] msm_serial: Add devicetree support

Quoted 11 lines · On Saturday 13 August 2011 12:46:45 David Brown wrote:

I'm not sure actually what is best to use here. I'm thinking that the 'lite' identifier should perhaps go away. MSM's have two UARTS on them, an older "simple" PIO type of UART, and a newer one that can do DMA (called the hsuart for high-speed). The hsuart can also be used in a non-DMA driver in a mostly compatible way with the old UART.

For non-high-speed applications, the user will probably just want to use the non-DMA driver. My question is then: if the device tree describes it as

Quoted 8 lines
        compatible = "qcom,msm-hsuart", "qcom,msm-uart";

and one driver matches qcom,msm-hsuart and another matches qcom,msm-uart, which driver will get used. Ideally, it would use the earliest one in the list.

If that's the case, I'll get rid of the -lite suffix and just make the non-DMA driver compatible with the plain "qcom,msm-uart".

I believe that unfortunately the answer is that the first driver that matches anything will get used. There are two possible ways that I can see to make it do what you want anyway:

1. In the probe function for the slow driver, you return an error when the device you get passed matches "qcom,msm-hsuart", possibly dependent on whether the other driver also got built.

2. You register one platform driver that handles both names and gives the device to just one of the two drivers. This would probably require linking the two drivers into the same module, or having the non-DMA speed driver just act as a library.

Arnd

#6 lore raw

Re: [PATCH 2/4] msm_serial: Add devicetree support

Quoted 25 lines · Arnd Bergmann
Quoted 11 lines · On Saturday 13 August 2011 12:46:45 David Brown wrote:

I'm not sure actually what is best to use here. I'm thinking that the 'lite' identifier should perhaps go away. MSM's have two UARTS on them, an older "simple" PIO type of UART, and a newer one that can do DMA (called the hsuart for high-speed). The hsuart can also be used in a non-DMA driver in a mostly compatible way with the old UART.

For non-high-speed applications, the user will probably just want to use the non-DMA driver. My question is then: if the device tree describes it as

Quoted 8 lines
        compatible = "qcom,msm-hsuart", "qcom,msm-uart";

and one driver matches qcom,msm-hsuart and another matches qcom,msm-uart, which driver will get used. Ideally, it would use the earliest one in the list.

If that's the case, I'll get rid of the -lite suffix and just make the non-DMA driver compatible with the plain "qcom,msm-uart".

I believe that unfortunately the answer is that the first driver that matches anything will get used. There are two possible ways that I can see to make it do what you want anyway:

Quoted 8 lines

1. In the probe function for the slow driver, you return an error when the device you get passed matches "qcom,msm-hsuart", possibly dependent on whether the other driver also got built.

2. You register one platform driver that handles both names and gives the device to just one of the two drivers. This would probably require linking the two drivers into the same module, or having the non-DMA speed driver just act as a library.

How about if I just keep it simple for now. Since there isn't actually a driver for the DMA version, this driver will handle both UART blocks, so I'll just do the plain thing in the DT.

In the future, when a DMA-capable driver exists, we can figure out how to determine which driver should be used. At this point, I'm not even sure what the correct answer will be, since a given configuration may want to use non-DMA for one msm-hsuart device, and the DMA driver for another. It's kind of board/use specific, but beyond just describing what the hardware is.

I've just sent new patches with this fixed up.

David

Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
#7 lore raw

Re: [PATCH 2/4] msm_serial: Add devicetree support

Quoted 3 lines · On Tuesday 16 August 2011 10:57:02 David Brown wrote:

How about if I just keep it simple for now. Since there isn't actually a driver for the DMA version, this driver will handle both UART blocks, so I'll just do the plain thing in the DT.

Sounds good to me.

Quoted 6 lines

In the future, when a DMA-capable driver exists, we can figure out how to determine which driver should be used. At this point, I'm not even sure what the correct answer will be, since a given configuration may want to use non-DMA for one msm-hsuart device, and the DMA driver for another. It's kind of board/use specific, but beyond just describing what the hardware is.

In order to be absolutely future-proof, you could mandate that you always list two "compatible" values, one for the generic version and one for the specific implementation (high-speed or low-speed). It's a simple change from what you have now and it allows to change the drivers to bind to just the specific name in case you want to handle them separately in the future, without having to change the device tree files.

Arnd