~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/tty/serial/apbuart.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
553
553
/* OF Platform Driver                                                       */
554
554
/* ======================================================================== */
555
555
 
556
 
static int __devinit apbuart_probe(struct platform_device *op,
557
 
                                   const struct of_device_id *match)
 
556
static int __devinit apbuart_probe(struct platform_device *op)
558
557
{
559
 
        int i = -1;
 
558
        int i;
560
559
        struct uart_port *port = NULL;
561
560
 
562
 
        i = 0;
563
561
        for (i = 0; i < grlib_apbuart_port_nr; i++) {
564
562
                if (op->dev.of_node == grlib_apbuart_nodes[i])
565
563
                        break;
567
565
 
568
566
        port = &grlib_apbuart_ports[i];
569
567
        port->dev = &op->dev;
 
568
        port->irq = op->archdata.irqs[0];
570
569
 
571
570
        uart_add_one_port(&grlib_apbuart_driver, (struct uart_port *) port);
572
571
 
587
586
        {},
588
587
};
589
588
 
590
 
static struct of_platform_driver grlib_apbuart_of_driver = {
 
589
static struct platform_driver grlib_apbuart_of_driver = {
591
590
        .probe = apbuart_probe,
592
591
        .driver = {
593
592
                .owner = THIS_MODULE,
599
598
 
600
599
static int grlib_apbuart_configure(void)
601
600
{
602
 
        struct device_node *np, *rp;
603
 
        const u32 *prop;
604
 
        int freq_khz, line = 0;
605
 
 
606
 
        /* Get bus frequency */
607
 
        rp = of_find_node_by_path("/");
608
 
        if (!rp)
609
 
                return -ENODEV;
610
 
        rp = of_get_next_child(rp, NULL);
611
 
        if (!rp)
612
 
                return -ENODEV;
613
 
        prop = of_get_property(rp, "clock-frequency", NULL);
614
 
        if (!prop)
615
 
                return -ENODEV;
616
 
        freq_khz = *prop;
 
601
        struct device_node *np;
 
602
        int line = 0;
617
603
 
618
604
        for_each_matching_node(np, apbuart_match) {
619
 
                const int *irqs, *ampopts;
 
605
                const int *ampopts;
 
606
                const u32 *freq_hz;
620
607
                const struct amba_prom_registers *regs;
621
608
                struct uart_port *port;
622
609
                unsigned long addr;
624
611
                ampopts = of_get_property(np, "ampopts", NULL);
625
612
                if (ampopts && (*ampopts == 0))
626
613
                        continue; /* Ignore if used by another OS instance */
627
 
 
628
 
                irqs = of_get_property(np, "interrupts", NULL);
629
614
                regs = of_get_property(np, "reg", NULL);
 
615
                /* Frequency of APB Bus is frequency of UART */
 
616
                freq_hz = of_get_property(np, "freq", NULL);
630
617
 
631
 
                if (!irqs || !regs)
 
618
                if (!regs || !freq_hz || (*freq_hz == 0))
632
619
                        continue;
633
620
 
634
621
                grlib_apbuart_nodes[line] = np;
639
626
 
640
627
                port->mapbase = addr;
641
628
                port->membase = ioremap(addr, sizeof(struct grlib_apbuart_regs_map));
642
 
                port->irq = *irqs;
 
629
                port->irq = 0;
643
630
                port->iotype = UPIO_MEM;
644
631
                port->ops = &grlib_apbuart_ops;
645
632
                port->flags = UPF_BOOT_AUTOCONF;
646
633
                port->line = line;
647
 
                port->uartclk = freq_khz * 1000;
 
634
                port->uartclk = *freq_hz;
648
635
                port->fifosize = apbuart_scan_fifo_size((struct uart_port *) port, line);
649
636
                line++;
650
637
 
676
663
                return ret;
677
664
        }
678
665
 
679
 
        ret = of_register_platform_driver(&grlib_apbuart_of_driver);
 
666
        ret = platform_driver_register(&grlib_apbuart_of_driver);
680
667
        if (ret) {
681
668
                printk(KERN_ERR
682
 
                       "%s: of_register_platform_driver failed (%i)\n",
 
669
                       "%s: platform_driver_register failed (%i)\n",
683
670
                       __FILE__, ret);
684
671
                uart_unregister_driver(&grlib_apbuart_driver);
685
672
                return ret;
697
684
                                     &grlib_apbuart_ports[i]);
698
685
 
699
686
        uart_unregister_driver(&grlib_apbuart_driver);
700
 
        of_unregister_platform_driver(&grlib_apbuart_of_driver);
 
687
        platform_driver_unregister(&grlib_apbuart_of_driver);
701
688
}
702
689
 
703
690
module_init(grlib_apbuart_init);