All of lore.kernel.org
 help / color / mirror / Atom feed
From: Walter Goossens <waltergoossens-CmkmPbn3yAE@public.gmane.org>
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: nios2-dev-1eJk0qcHJCcaeqlQEoCUNoJY59XmG8rH@public.gmane.org
Subject: [PATCH] Add devicetree support to altera_jtaguart
Date: Wed, 12 Jan 2011 23:17:31 +0100	[thread overview]
Message-ID: <4D2E287B.7000005@home.nl> (raw)

[-- Attachment #1: Type: text/plain, Size: 113 bytes --]

This patch adds devicetree support to the altera_jtaguart driver.
Tested on hardware on the nios2 architecture.


[-- Attachment #2: altera_jtaguart_fdt.patch --]
[-- Type: text/plain, Size: 2705 bytes --]

diff --git a/drivers/serial/altera_jtaguart.c b/drivers/serial/altera_jtaguart.c
index f9b49b5..b71ba92 100644
--- a/drivers/serial/altera_jtaguart.c
+++ b/drivers/serial/altera_jtaguart.c
@@ -431,21 +431,44 @@ static int __devinit altera_jtaguart_probe(struct platform_device *pdev)
 {
 	struct altera_jtaguart_platform_uart *platp = pdev->dev.platform_data;
 	struct uart_port *port;
-	int i;
-
-	for (i = 0; i < ALTERA_JTAGUART_MAXPORTS && platp[i].mapbase; i++) {
-		port = &altera_jtaguart_ports[i].port;
-
-		port->line = i;
-		port->type = PORT_ALTERA_JTAGUART;
-		port->mapbase = platp[i].mapbase;
-		port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE);
-		port->iotype = SERIAL_IO_MEM;
-		port->irq = platp[i].irq;
-		port->ops = &altera_jtaguart_ops;
-		port->flags = ASYNC_BOOT_AUTOCONF;
-
-		uart_add_one_port(&altera_jtaguart_driver, port);
+	if(platp) {
+		int i;
+		for (i = 0; i < ALTERA_JTAGUART_MAXPORTS && platp[i].mapbase; i++) {
+			port = &altera_jtaguart_ports[i].port;
+
+			port->line = i;
+			port->type = PORT_ALTERA_JTAGUART;
+			port->mapbase = platp[i].mapbase;
+			port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE);
+			port->iotype = SERIAL_IO_MEM;
+			port->irq = platp[i].irq;
+			port->ops = &altera_jtaguart_ops;
+			port->flags = ASYNC_BOOT_AUTOCONF;
+
+			uart_add_one_port(&altera_jtaguart_driver, port);
+		}
+#ifdef CONFIG_OF
+	} else {
+		struct resource *res_irq;
+		struct resource *res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		if(res_mem)
+		{
+			res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+			if(res_irq)
+			{
+				port = &altera_jtaguart_ports[0].port;
+				port->line = 0;
+				port->type = PORT_ALTERA_JTAGUART;
+				port->mapbase = res_mem->start;
+				port->membase = ioremap(port->mapbase, ALTERA_JTAGUART_SIZE);
+				port->iotype = SERIAL_IO_MEM;
+				port->irq = res_irq->start;
+				port->ops = &altera_jtaguart_ops;
+				port->flags = ASYNC_BOOT_AUTOCONF;
+				uart_add_one_port(&altera_jtaguart_driver, port);
+			}
+		}
+#endif
 	}
 
 	return 0;
@@ -464,6 +487,15 @@ static int __devexit altera_jtaguart_remove(struct platform_device *pdev)
 
 	return 0;
 }
+#ifdef CONFIG_OF
+static struct of_device_id altera_jtaguart_match[] = {
+	{ 
+		.compatible = "altera,altera_juart",
+	},
+	{},
+}
+MODULE_DEVICE_TABLE(of, altera_jtaguart_match);
+#endif /* CONFIG_OF */
 
 static struct platform_driver altera_jtaguart_platform_driver = {
 	.probe	= altera_jtaguart_probe,
@@ -471,6 +503,9 @@ static struct platform_driver altera_jtaguart_platform_driver = {
 	.driver	= {
 		.name	= DRV_NAME,
 		.owner	= THIS_MODULE,
+#ifdef CONFIG_OF
+		.of_match_table = altera_jtaguart_match,
+#endif
 	},
 };
 

[-- Attachment #3: Type: text/plain, Size: 192 bytes --]

_______________________________________________
devicetree-discuss mailing list
devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
https://lists.ozlabs.org/listinfo/devicetree-discuss

             reply	other threads:[~2011-01-12 22:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-12 22:17 Walter Goossens [this message]
     [not found] ` <4D2E287B.7000005-CmkmPbn3yAE@public.gmane.org>
2011-01-12 23:06   ` [PATCH] Add devicetree support to altera_jtaguart Grant Likely
     [not found]     ` <20110112230607.GA31712-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2011-01-13  1:18       ` [PATCHv2] " Walter Goossens
     [not found]         ` <4D2E52FF.5060102-CmkmPbn3yAE@public.gmane.org>
2011-01-18 16:35           ` [Nios2-dev] " Tobias Klauser
2011-01-23 13:17             ` [PATCH v3] " Walter Goossens
     [not found]               ` <4D3C2A67.6030408-CmkmPbn3yAE@public.gmane.org>
2011-01-24 12:28                 ` Tobias Klauser
2011-01-13  1:25       ` [PATCH] " Walter Goossens

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=4D2E287B.7000005@home.nl \
    --to=waltergoossens-cmkmpbn3yae@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=nios2-dev-1eJk0qcHJCcaeqlQEoCUNoJY59XmG8rH@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.