driver core: add devname module aliases to allow module on-demand auto-loading
[pandora-kernel.git] / drivers / serial / mpc52xx_uart.c
index cb07938..84a35f6 100644 (file)
  * kind, whether express or implied.
  */
 
-/* Platform device Usage :
- *
- * Since PSCs can have multiple function, the correct driver for each one
- * is selected by calling mpc52xx_match_psc_function(...). The function
- * handled by this driver is "uart".
- *
- * The driver init all necessary registers to place the PSC in uart mode without
- * DCD. However, the pin multiplexing aren't changed and should be set either
- * by the bootloader or in the platform init code.
- *
- * The idx field must be equal to the PSC index (e.g. 0 for PSC1, 1 for PSC2,
- * and so on). So the PSC1 is mapped to /dev/ttyPSC0, PSC2 to /dev/ttyPSC1 and
- * so on. But be warned, it's an ABSOLUTE REQUIREMENT ! This is needed mainly
- * fpr the console code : without this 1:1 mapping, at early boot time, when we
- * are parsing the kernel args console=ttyPSC?, we wouldn't know which PSC it
- * will be mapped to.
- */
-
-/* OF Platform device Usage :
- *
- * This driver is only used for PSCs configured in uart mode.  The device
- * tree will have a node for each PSC with "mpc52xx-psc-uart" in the compatible
- * list.
- *
- * By default, PSC devices are enumerated in the order they are found.  However
- * a particular PSC number can be forces by adding 'device_no = <port#>'
- * to the device node.
- *
- * The driver init all necessary registers to place the PSC in uart mode without
- * DCD. However, the pin multiplexing aren't changed and should be set either
- * by the bootloader or in the platform init code.
- */
-
 #undef DEBUG
 
 #include <linux/device.h>
@@ -430,34 +397,10 @@ static unsigned long mpc512x_getuartclk(void *p)
        return mpc5xxx_get_bus_frequency(p);
 }
 
-#define DEFAULT_FIFO_SIZE 16
-
-static unsigned int __init get_fifo_size(struct device_node *np,
-                                        char *fifo_name)
-{
-       const unsigned int *fp;
-
-       fp = of_get_property(np, fifo_name, NULL);
-       if (fp)
-               return *fp;
-
-       pr_warning("no %s property in %s node, defaulting to %d\n",
-                  fifo_name, np->full_name, DEFAULT_FIFO_SIZE);
-
-       return DEFAULT_FIFO_SIZE;
-}
-
-#define FIFOC(_base) ((struct mpc512x_psc_fifo __iomem *) \
-                   ((u32)(_base) + sizeof(struct mpc52xx_psc)))
-
 /* Init PSC FIFO Controller */
 static int __init mpc512x_psc_fifoc_init(void)
 {
        struct device_node *np;
-       void __iomem *psc;
-       unsigned int tx_fifo_size;
-       unsigned int rx_fifo_size;
-       int fifobase = 0; /* current fifo address in 32 bit words */
 
        np = of_find_compatible_node(NULL, NULL,
                                     "fsl,mpc5121-psc-fifo");
@@ -480,51 +423,6 @@ static int __init mpc512x_psc_fifoc_init(void)
                return -ENODEV;
        }
 
-       for_each_compatible_node(np, NULL, "fsl,mpc5121-psc-uart") {
-               tx_fifo_size = get_fifo_size(np, "fsl,tx-fifo-size");
-               rx_fifo_size = get_fifo_size(np, "fsl,rx-fifo-size");
-
-               /* size in register is in 4 byte units */
-               tx_fifo_size /= 4;
-               rx_fifo_size /= 4;
-               if (!tx_fifo_size)
-                       tx_fifo_size = 1;
-               if (!rx_fifo_size)
-                       rx_fifo_size = 1;
-
-               psc = of_iomap(np, 0);
-               if (!psc) {
-                       pr_err("%s: Can't map %s device\n",
-                               __func__, np->full_name);
-                       continue;
-               }
-
-               /* FIFO space is 4KiB, check if requested size is available */
-               if ((fifobase + tx_fifo_size + rx_fifo_size) > 0x1000) {
-                       pr_err("%s: no fifo space available for %s\n",
-                               __func__, np->full_name);
-                       iounmap(psc);
-                       /*
-                        * chances are that another device requests less
-                        * fifo space, so we continue.
-                        */
-                       continue;
-               }
-               /* set tx and rx fifo size registers */
-               out_be32(&FIFOC(psc)->txsz, (fifobase << 16) | tx_fifo_size);
-               fifobase += tx_fifo_size;
-               out_be32(&FIFOC(psc)->rxsz, (fifobase << 16) | rx_fifo_size);
-               fifobase += rx_fifo_size;
-
-               /* reset and enable the slices */
-               out_be32(&FIFOC(psc)->txcmd, 0x80);
-               out_be32(&FIFOC(psc)->txcmd, 0x01);
-               out_be32(&FIFOC(psc)->rxcmd, 0x80);
-               out_be32(&FIFOC(psc)->rxcmd, 0x01);
-
-               iounmap(psc);
-       }
-
        return 0;
 }
 
@@ -1464,15 +1362,16 @@ mpc52xx_uart_of_enumerate(void)
 MODULE_DEVICE_TABLE(of, mpc52xx_uart_of_match);
 
 static struct of_platform_driver mpc52xx_uart_of_driver = {
-       .match_table    = mpc52xx_uart_of_match,
        .probe          = mpc52xx_uart_of_probe,
        .remove         = mpc52xx_uart_of_remove,
 #ifdef CONFIG_PM
        .suspend        = mpc52xx_uart_of_suspend,
        .resume         = mpc52xx_uart_of_resume,
 #endif
-       .driver         = {
-               .name   = "mpc52xx-psc-uart",
+       .driver = {
+               .name = "mpc52xx-psc-uart",
+               .owner = THIS_MODULE,
+               .of_match_table = mpc52xx_uart_of_match,
        },
 };
 
@@ -1500,7 +1399,7 @@ mpc52xx_uart_init(void)
        /*
         * Map the PSC FIFO Controller and init if on MPC512x.
         */
-       if (psc_ops->fifoc_init) {
+       if (psc_ops && psc_ops->fifoc_init) {
                ret = psc_ops->fifoc_init();
                if (ret)
                        return ret;