* [RFC 0/2] serial: OF alias support
@ 2011-11-08 13:35 Michal Simek
2011-11-08 13:35 ` [RFC 1/2] serial: Add OF alias support for uartlite Michal Simek
0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2011-11-08 13:35 UTC (permalink / raw)
To: devicetree-discuss
Cc: grant.likely, john.williams, michal.simek, linux-kernel,
linux-serial, jacmet, arnd
Hi,
I am sending two patches for uartlite and uart16550/8250
serial drivers.
Our aim is to be able to probe serial drivers based
on order in alias node. We are using of_alias_get_id function
to get correct ID.
These patches are based on the latest Linaro git tree
(git://git.linaro.org/kernel/linux-linaro-3.1.git).
"Merge branch 'devicetree/arm-linaro-3.1' of git://git.secretlab.ca/git/linux-2.6 into linaro-3.1"
(sha1: af1bdb79ca64ceadc7b44b11929b384eff66ce59)
Thanks for you comments,
Michal
Michal Simek (2):
serial: Add OF alias support for uartlite
serial: 8250: Add OF alias support
drivers/tty/serial/8250.c | 7 +++++++
drivers/tty/serial/of_serial.c | 15 +++++++++++++++
drivers/tty/serial/uartlite.c | 26 ++++++++++++++++++++++----
3 files changed, 44 insertions(+), 4 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [RFC 1/2] serial: Add OF alias support for uartlite
2011-11-08 13:35 [RFC 0/2] serial: OF alias support Michal Simek
@ 2011-11-08 13:35 ` Michal Simek
[not found] ` <1320759307-24877-2-git-send-email-monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Michal Simek @ 2011-11-08 13:35 UTC (permalink / raw)
To: devicetree-discuss
Cc: grant.likely, john.williams, michal.simek, linux-kernel,
linux-serial, jacmet, arnd
Signed-off-by: John Williams <john.williams@petalogix.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
---
drivers/tty/serial/uartlite.c | 26 ++++++++++++++++++++++----
1 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/uartlite.c b/drivers/tty/serial/uartlite.c
index 0aed022..71ba422 100644
--- a/drivers/tty/serial/uartlite.c
+++ b/drivers/tty/serial/uartlite.c
@@ -573,13 +573,31 @@ MODULE_DEVICE_TABLE(of, ulite_of_match);
static int __devinit ulite_probe(struct platform_device *pdev)
{
struct resource *res, *res2;
+ unsigned int *idp;
int id = pdev->id;
+
#ifdef CONFIG_OF
- const __be32 *prop;
+ /* Look for a serialN alias */
+ id = of_alias_get_id(pdev->dev.of_node, "serial");
+ if (id < 0) {
+ dev_warn(&pdev->dev, "failed to get alias id, errno %d\n", id);
+ /* Fall back to old port-number property */
+ idp = of_get_property(pdev->dev.of_node, "port-number", NULL);
+ if (idp < 0) {
+ dev_warn(&pdev->dev,
+ "failed to get port-number, errno %d\n", idp);
+ id = -1;
+ } else
+ id = be32_to_cpup(idp);
+ }
- prop = of_get_property(pdev->dev.of_node, "port-number", NULL);
- if (prop)
- id = be32_to_cpup(prop);
+ /* We can't register ids which are greater than number of uartlites */
+ if (id >= ULITE_NR_UARTS) {
+ dev_warn(&op->dev,
+ "Extern number of allocated uartlite entries "
+ "ULITE_NR_UARTS, id %d\n", id);
+ return -ENODEV;
+ }
#endif
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [RFC 2/2] serial: 8250: Add OF alias support
[not found] ` <1320759307-24877-2-git-send-email-monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
@ 2011-11-08 13:35 ` Michal Simek
0 siblings, 0 replies; 3+ messages in thread
From: Michal Simek @ 2011-11-08 13:35 UTC (permalink / raw)
To: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
michal.simek-g5w7nrANp4BDPfheJLI6IQ,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
john.williams-g5w7nrANp4BDPfheJLI6IQ
Follow alias number for OF driven boards.
For example:
aliases {
serial2 = &RS232_Uart_1;
} ;
Setup port->line number in of_platform_serial_probe from alias node.
Fixing serial8250_find_match_or_unused function is more complicated
because it is key function which check which port is available.
This was probably done for any ancient ISA support where all ports are
registered first in serial8250_register_ports (serial8250_isa_init_ports).
and then, if they are usused, unregistered and registered with
proper setting. Not sure if this is needed.
If port entry matches, it is used. If not, code looks first at entry
at port->line number to be able to assign ttySX number according
port->line setup from of_platform_serial_probe. If this port is used
code looks for the first free entry as before.
The only one change is to check entry on port->line first.
This patch requires more testing because there are several usage of
standard 8250 compatible driver.
Signed-off-by: Michal Simek <monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
---
drivers/tty/serial/8250.c | 7 +++++++
drivers/tty/serial/of_serial.c | 15 +++++++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index 7f50999..ade3c77 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -3212,6 +3212,13 @@ static struct uart_8250_port *serial8250_find_match_or_unused(struct uart_port *
if (uart_match_port(&serial8250_ports[i].port, port))
return &serial8250_ports[i];
+ /* Look at setup port->line port first. If is available, use it */
+ if (port->line >= 0 && port->line < nr_uarts)
+ if (serial8250_ports[port->line].port.type == PORT_UNKNOWN &&
+ serial8250_ports[port->line].port.iobase == 0) {
+ return &serial8250_ports[port->line];
+ }
+
/*
* We didn't find a matching entry, so look for the first
* free entry. We look for one which hasn't been previously
diff --git a/drivers/tty/serial/of_serial.c b/drivers/tty/serial/of_serial.c
index 24aa67c..486f2bd 100644
--- a/drivers/tty/serial/of_serial.c
+++ b/drivers/tty/serial/of_serial.c
@@ -98,6 +98,7 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
struct uart_port port;
int port_type;
int ret;
+ int id;
match = of_match_device(of_platform_serial_table, &ofdev->dev);
if (!match)
@@ -115,6 +116,20 @@ static int __devinit of_platform_serial_probe(struct platform_device *ofdev)
if (ret)
goto out;
+ id = of_alias_get_id(ofdev->dev.of_node, "serial");
+ if (id < 0) {
+ dev_warn(&ofdev->dev, "FAILED to find out alias id\n");
+ } else {
+ if (id < CONFIG_SERIAL_8250_RUNTIME_UARTS)
+ port.line = id;
+ else {
+ dev_warn(&ofdev->dev,
+ "FAILED to register serial driver with id %d\n",
+ id);
+ goto out;
+ }
+ }
+
switch (port_type) {
#ifdef CONFIG_SERIAL_8250
case PORT_8250 ... PORT_MAX_8250:
--
1.7.5.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-11-08 13:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-08 13:35 [RFC 0/2] serial: OF alias support Michal Simek
2011-11-08 13:35 ` [RFC 1/2] serial: Add OF alias support for uartlite Michal Simek
[not found] ` <1320759307-24877-2-git-send-email-monstr-pSz03upnqPeHXe+LvDLADg@public.gmane.org>
2011-11-08 13:35 ` [RFC 2/2] serial: 8250: Add OF alias support Michal Simek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).