aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2007-10-01 22:16:04 -0400
committerJosh Boyer <jwboyer@linux.vnet.ibm.com>2007-10-03 08:23:15 -0400
commit852e1ea748e83eba7fdb1cc198f271837b16137b (patch)
treef3a2b65e469c76acf3a7d2adb5c1ac69e446a060 /drivers
parent435706b385d1f5422e44ee86b5dec0a2150eca02 (diff)
[POWERPC] Uartlite: Add of-platform-bus binding
Add of_platform bus binding so this driver can be used with arch/powerpc Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/uartlite.c96
1 files changed, 92 insertions, 4 deletions
diff --git a/drivers/serial/uartlite.c b/drivers/serial/uartlite.c
index ed13b9fac1af..0904c2a62fc4 100644
--- a/drivers/serial/uartlite.c
+++ b/drivers/serial/uartlite.c
@@ -1,7 +1,8 @@
1/* 1/*
2 * uartlite.c: Serial driver for Xilinx uartlite serial controller 2 * uartlite.c: Serial driver for Xilinx uartlite serial controller
3 * 3 *
4 * Peter Korsgaard <jacmet@sunsite.dk> 4 * Copyright (C) 2006 Peter Korsgaard <jacmet@sunsite.dk>
5 * Copyright (C) 2007 Secret Lab Technologies Ltd.
5 * 6 *
6 * This file is licensed under the terms of the GNU General Public License 7 * This file is licensed under the terms of the GNU General Public License
7 * version 2. This program is licensed "as is" without any warranty of any 8 * version 2. This program is licensed "as is" without any warranty of any
@@ -17,6 +18,10 @@
17#include <linux/delay.h> 18#include <linux/delay.h>
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <asm/io.h> 20#include <asm/io.h>
21#if defined(CONFIG_OF)
22#include <linux/of_device.h>
23#include <linux/of_platform.h>
24#endif
20 25
21#define ULITE_NAME "ttyUL" 26#define ULITE_NAME "ttyUL"
22#define ULITE_MAJOR 204 27#define ULITE_MAJOR 204
@@ -382,8 +387,10 @@ static int __init ulite_console_setup(struct console *co, char *options)
382 port = &ulite_ports[co->index]; 387 port = &ulite_ports[co->index];
383 388
384 /* not initialized yet? */ 389 /* not initialized yet? */
385 if (!port->membase) 390 if (!port->membase) {
391 pr_debug("console on ttyUL%i not initialized\n", co->index);
386 return -ENODEV; 392 return -ENODEV;
393 }
387 394
388 if (options) 395 if (options)
389 uart_parse_options(options, &baud, &parity, &bits, &flow); 396 uart_parse_options(options, &baud, &parity, &bits, &flow);
@@ -542,6 +549,72 @@ static struct platform_driver ulite_platform_driver = {
542}; 549};
543 550
544/* --------------------------------------------------------------------- 551/* ---------------------------------------------------------------------
552 * OF bus bindings
553 */
554#if defined(CONFIG_OF)
555static int __devinit
556ulite_of_probe(struct of_device *op, const struct of_device_id *match)
557{
558 struct resource res;
559 const unsigned int *id;
560 int irq, rc;
561
562 dev_dbg(&op->dev, "%s(%p, %p)\n", __FUNCTION__, op, match);
563
564 rc = of_address_to_resource(op->node, 0, &res);
565 if (rc) {
566 dev_err(&op->dev, "invalide address\n");
567 return rc;
568 }
569
570 irq = irq_of_parse_and_map(op->node, 0);
571
572 id = of_get_property(op->node, "port-number", NULL);
573
574 return ulite_assign(&op->dev, id ? *id : -1, res.start, irq);
575}
576
577static int __devexit ulite_of_remove(struct of_device *op)
578{
579 return ulite_release(&op->dev);
580}
581
582/* Match table for of_platform binding */
583static struct of_device_id __devinit ulite_of_match[] = {
584 { .type = "serial", .compatible = "xilinx,uartlite", },
585 {},
586};
587MODULE_DEVICE_TABLE(of, ulite_of_match);
588
589static struct of_platform_driver ulite_of_driver = {
590 .owner = THIS_MODULE,
591 .name = "uartlite",
592 .match_table = ulite_of_match,
593 .probe = ulite_of_probe,
594 .remove = __devexit_p(ulite_of_remove),
595 .driver = {
596 .name = "uartlite",
597 },
598};
599
600/* Registration helpers to keep the number of #ifdefs to a minimum */
601static inline int __init ulite_of_register(void)
602{
603 pr_debug("uartlite: calling of_register_platform_driver()\n");
604 return of_register_platform_driver(&ulite_of_driver);
605}
606
607static inline void __exit ulite_of_unregister(void)
608{
609 of_unregister_platform_driver(&ulite_of_driver);
610}
611#else /* CONFIG_OF */
612/* CONFIG_OF not enabled; do nothing helpers */
613static inline int __init ulite_of_register(void) { return 0; }
614static inline void __exit ulite_of_unregister(void) { }
615#endif /* CONFIG_OF */
616
617/* ---------------------------------------------------------------------
545 * Module setup/teardown 618 * Module setup/teardown
546 */ 619 */
547 620
@@ -549,20 +622,35 @@ int __init ulite_init(void)
549{ 622{
550 int ret; 623 int ret;
551 624
625 pr_debug("uartlite: calling uart_register_driver()\n");
552 ret = uart_register_driver(&ulite_uart_driver); 626 ret = uart_register_driver(&ulite_uart_driver);
553 if (ret) 627 if (ret)
554 return ret; 628 goto err_uart;
629
630 ret = ulite_of_register();
631 if (ret)
632 goto err_of;
555 633
634 pr_debug("uartlite: calling platform_driver_register()\n");
556 ret = platform_driver_register(&ulite_platform_driver); 635 ret = platform_driver_register(&ulite_platform_driver);
557 if (ret) 636 if (ret)
558 uart_unregister_driver(&ulite_uart_driver); 637 goto err_plat;
638
639 return 0;
559 640
641err_plat:
642 ulite_of_unregister();
643err_of:
644 uart_unregister_driver(&ulite_uart_driver);
645err_uart:
646 printk(KERN_ERR "registering uartlite driver failed: err=%i", ret);
560 return ret; 647 return ret;
561} 648}
562 649
563void __exit ulite_exit(void) 650void __exit ulite_exit(void)
564{ 651{
565 platform_driver_unregister(&ulite_platform_driver); 652 platform_driver_unregister(&ulite_platform_driver);
653 ulite_of_unregister();
566 uart_unregister_driver(&ulite_uart_driver); 654 uart_unregister_driver(&ulite_uart_driver);
567} 655}
568 656