public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: John Linn <john.linn@xilinx•com>
To: linuxppc-dev@ozlabs•org
Cc: John Linn <john.linn@xilinx•com>
Subject: [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart 16550.
Date: Thu, 20 Mar 2008 07:43:51 -0700	[thread overview]
Message-ID: <20080320144402.3063517C005D@mail148-sin.bigfish.com> (raw)
In-Reply-To: <12060242324116-git-send-email-john.linn@xilinx.com>

The Xilinx 16550 uart core is not a standard 16550, because it uses
word-based addressing rather than byte-based addressing.  As a result,
it is not compatible with the open firmware 'ns16550' compatible
binding.  This code introduces new bindings, which pass the correct
register base and regshift properties to the uart driver to enable
this core to be used.  Doing this cleanly required some refactoring of
the existing code.

Signed-off-by: Stephen Neuendorffer <stephen.neuendorffer@xilinx•com>
Signed-off-by: John Linn <john.linn@xilinx•com>
---
 drivers/serial/of_serial.c |   47 ++++++++++++++++++++++++++++++-------------
 1 files changed, 33 insertions(+), 14 deletions(-)

diff --git a/drivers/serial/of_serial.c b/drivers/serial/of_serial.c
index 2efb892..910c94f 100644
--- a/drivers/serial/of_serial.c
+++ b/drivers/serial/of_serial.c
@@ -20,13 +20,15 @@
 struct of_serial_info {
 	int type;
 	int line;
+	int regshift;
+	int regoffset;
 };
 
 /*
  * Fill a struct uart_port for a given device node
  */
 static int __devinit of_platform_serial_setup(struct of_device *ofdev,
-					int type, struct uart_port *port)
+					struct of_serial_info *info, struct uart_port *port)
 {
 	struct resource resource;
 	struct device_node *np = ofdev->node;
@@ -48,17 +50,16 @@ static int __devinit of_platform_serial_setup(struct of_device *ofdev,
 	}
 
 	spin_lock_init(&port->lock);
-	port->mapbase = resource.start;
+	port->mapbase = resource.start + info->regoffset;
 	port->irq = irq_of_parse_and_map(np, 0);
 	port->iotype = UPIO_MEM;
-	port->type = type;
+	port->type = info->type;
+	port->regshift = info->regshift;
 	port->uartclk = *clk;
 	port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP
 		| UPF_FIXED_PORT;
 	port->dev = &ofdev->dev;
-	/* If current-speed was set, then try not to change it. */
-	if (spd)
-		port->custom_divisor = *clk / (16 * (*spd));
+	port->custom_divisor = *clk / (16 * (*spd));
 
 	return 0;
 }
@@ -81,8 +82,9 @@ static int __devinit of_platform_serial_probe(struct of_device *ofdev,
 	if (info == NULL)
 		return -ENOMEM;
 
-	port_type = (unsigned long)id->data;
-	ret = of_platform_serial_setup(ofdev, port_type, &port);
+	memcpy(info, id->data, sizeof(struct of_serial_info));
+	port_type = info->type;
+	ret = of_platform_serial_setup(ofdev, info, &port);
 	if (ret)
 		goto out;
 
@@ -100,7 +102,6 @@ static int __devinit of_platform_serial_probe(struct of_device *ofdev,
 	if (ret < 0)
 		goto out;
 
-	info->type = port_type;
 	info->line = ret;
 	ofdev->dev.driver_data = info;
 	return 0;
@@ -128,15 +129,33 @@ static int of_platform_serial_remove(struct of_device *ofdev)
 	return 0;
 }
 
+static struct of_serial_info __devinitdata ns8250_info = { .type = PORT_8250 };
+static struct of_serial_info __devinitdata ns16450_info = { .type = PORT_16450 };
+static struct of_serial_info __devinitdata ns16550_info = { .type = PORT_16550 };
+static struct of_serial_info __devinitdata ns16750_info = { .type = PORT_16750 };
+static struct of_serial_info __devinitdata xilinx_16550_info = {
+	.type = PORT_16550,
+	.regshift = 2,
+	.regoffset = 3,
+};
+static struct of_serial_info __devinitdata unknown_info = { .type = PORT_UNKNOWN };
+
 /*
  * A few common types, add more as needed.
  */
 static struct of_device_id __devinitdata of_platform_serial_table[] = {
-	{ .type = "serial", .compatible = "ns8250",   .data = (void *)PORT_8250, },
-	{ .type = "serial", .compatible = "ns16450",  .data = (void *)PORT_16450, },
-	{ .type = "serial", .compatible = "ns16550",  .data = (void *)PORT_16550, },
-	{ .type = "serial", .compatible = "ns16750",  .data = (void *)PORT_16750, },
-	{ .type = "serial",			      .data = (void *)PORT_UNKNOWN, },
+	{ .type = "serial", .compatible = "ns8250",   .data = &ns8250_info, },
+	{ .type = "serial", .compatible = "ns16450",  .data = &ns16450_info, },
+	{ .type = "serial", .compatible = "ns16550",  .data = &ns16550_info, },
+	{ .type = "serial", .compatible = "ns16750",  .data = &ns16750_info, },
+	{ .type = "serial", .compatible = "xlnx,opb-uart16550-1.00.c", .data = &xilinx_16550_info, },
+	{ .type = "serial", .compatible = "xlnx,opb-uart16550-1.00.d", .data = &xilinx_16550_info, },
+	{ .type = "serial", .compatible = "xlnx,opb-uart16550-1.00.e", .data = &xilinx_16550_info, },
+	{ .type = "serial", .compatible = "xlnx,plb-uart16550-1.00.c", .data = &xilinx_16550_info, },
+	{ .type = "serial", .compatible = "xlnx,xps-uart16550-1.00.a", .data = &xilinx_16550_info, },
+	{ .type = "serial", .compatible = "xlnx,xps-uart16550-2.00.a", .data = &xilinx_16550_info, },
+	{ .type = "serial", .compatible = "xlnx,xps-uart16550-2.00.b", .data = &xilinx_16550_info, },
+	{ .type = "serial",			      .data = &unknown_info, },
 	{ /* end of list */ },
 };
 
-- 
1.5.2.1

       reply	other threads:[~2008-03-20 14:44 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <12060242324116-git-send-email-john.linn@xilinx.com>
2008-03-20 14:43 ` John Linn [this message]
2008-03-21  0:19   ` [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart 16550 Grant Likely
2008-03-21  9:21     ` Paul Mackerras
2008-03-21 11:39       ` Segher Boessenkool
2008-03-21 16:08         ` [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart16550 Stephen Neuendorffer
2008-03-21 16:48           ` Segher Boessenkool
2008-03-22 14:50       ` [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart 16550 Grant Likely
2008-03-22 16:06         ` Sergei Shtylyov
2008-03-24 14:09         ` Sergei Shtylyov
2008-03-24 14:27           ` Grant Likely
2008-03-24 16:15             ` Sergei Shtylyov
2008-03-24 16:48               ` Grant Likely
2008-03-24 17:03               ` Sergei Shtylyov
2008-03-25 22:48                 ` John Linn
2008-03-21 13:00     ` Sergei Shtylyov
2008-03-21 15:37       ` Segher Boessenkool
2008-03-21 15:54         ` Sergei Shtylyov
2008-03-21 16:45           ` Segher Boessenkool
2008-03-21 16:50             ` [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart16550 Stephen Neuendorffer
2008-03-21 17:01             ` [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart 16550 Sergei Shtylyov
2008-03-22 15:06       ` Grant Likely
2008-03-22 16:40         ` Sergei Shtylyov
2008-03-21 16:14     ` [PATCH 2/3] [POWERPC] Xilinx: of_serial support for Xilinx uart16550 Stephen Neuendorffer
     [not found] ` <1206024232655-git-send-email-john.linn@xilinx.com>
2008-03-20 14:43   ` [PATCH 3/3] [POWERPC] Xilinx: boot support for Xilinx uart 16550 John Linn
2008-03-20 14:54     ` Grant Likely
2008-03-20 16:15       ` John Linn
2008-03-20 21:18         ` Grant Likely
     [not found]       ` <20080320175601.5D86217C8055@mail127-sin.bigfish.com>
2008-03-20 21:07         ` Grant Likely
2008-03-20 22:04     ` Grant Likely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080320144402.3063517C005D@mail148-sin.bigfish.com \
    --to=john.linn@xilinx$(echo .)com \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox