]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/serial/cpm_uart/cpm_uart_cpm2.c
cpm_uart: fix whitespace issues
[linux-2.6-omap-h63xx.git] / drivers / serial / cpm_uart / cpm_uart_cpm2.c
index 7b61d805ebe98b317138e3c2a562ee1496c29789..e53524c6463cc1010531927788cb81ac65b15a89 100644 (file)
@@ -5,11 +5,11 @@
  *
  *  Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
  *              Pantelis Antoniou (panto@intracom.gr) (CPM1)
- * 
+ *
  *  Copyright (C) 2004 Freescale Semiconductor, Inc.
  *            (C) 2004 Intracom, S.A.
  *            (C) 2006 MontaVista Software, Inc.
- *             Vitaly Bordug <vbordug@ru.mvista.com>
+ *             Vitaly Bordug <vbordug@ru.mvista.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -41,6 +41,9 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/fs_pd.h>
+#ifdef CONFIG_PPC_CPM_NEW_BINDING
+#include <asm/prom.h>
+#endif
 
 #include <linux/serial_core.h>
 #include <linux/kernel.h>
 
 /**************************************************************/
 
-void cpm_line_cr_cmd(int line, int cmd)
+#ifdef CONFIG_PPC_CPM_NEW_BINDING
+void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
+{
+       cpm_command(port->command, cmd);
+}
+
+void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
+                               struct device_node *np)
+{
+       void __iomem *pram;
+       unsigned long offset;
+       struct resource res;
+       unsigned long len;
+
+       /* Don't remap parameter RAM if it has already been initialized
+        * during console setup.
+        */
+       if (IS_SMC(port) && port->smcup)
+               return port->smcup;
+       else if (!IS_SMC(port) && port->sccup)
+               return port->sccup;
+
+       if (of_address_to_resource(np, 1, &res))
+               return NULL;
+
+       len = 1 + res.end - res.start;
+       pram = ioremap(res.start, len);
+       if (!pram)
+               return NULL;
+
+       if (!IS_SMC(port))
+               return pram;
+
+       if (len != 2) {
+               printk(KERN_WARNING "cpm_uart[%d]: device tree references "
+                       "SMC pram, using boot loader/wrapper pram mapping. "
+                       "Please fix your device tree to reference the pram "
+                       "base register instead.\n",
+                       port->port.line);
+               return pram;
+       }
+
+       offset = cpm_dpalloc(PROFF_SMC_SIZE, 64);
+       out_be16(pram, offset);
+       iounmap(pram);
+       return cpm_muram_addr(offset);
+}
+
+void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
+{
+       if (!IS_SMC(port))
+               iounmap(pram);
+}
+
+#else
+void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
 {
        ulong val;
+       int line = port - cpm_uart_ports;
        volatile cpm_cpm2_t *cp = cpm2_map(im_cpm);
 
 
@@ -158,9 +217,9 @@ void scc2_lineif(struct uart_cpm_port *pinfo)
         * really has to get out of the driver so boards can
         * be supported in a sane fashion.
         */
+       volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
 #ifndef CONFIG_STX_GP3
        volatile iop_cpm2_t *io = cpm2_map(im_ioport);
-       volatile cpmux_t *cpmux = cpm2_map(im_cpmux);
 
        io->iop_pparb |= 0x008b0000;
        io->iop_pdirb |= 0x00880000;
@@ -211,9 +270,10 @@ void scc4_lineif(struct uart_cpm_port *pinfo)
        cpm2_unmap(cpmux);
        cpm2_unmap(io);
 }
+#endif
 
 /*
- * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 
+ * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
  * receive buffer descriptors from dual port ram, and a character
  * buffer area from host mem. If we are allocating for the console we need
  * to do it from bootmem
@@ -221,7 +281,7 @@ void scc4_lineif(struct uart_cpm_port *pinfo)
 int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
 {
        int dpmemsz, memsz;
-       u8 *dp_mem;
+       u8 __iomem *dp_mem;
        unsigned long dp_offset;
        u8 *mem_addr;
        dma_addr_t dma_addr = 0;
@@ -264,7 +324,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
        pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
                                                       * pinfo->rx_fifosize);
 
-       pinfo->rx_bd_base = (volatile cbd_t *)dp_mem;
+       pinfo->rx_bd_base = (cbd_t __iomem *)dp_mem;
        pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
 
        return 0;
@@ -275,12 +335,13 @@ void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
        dma_free_coherent(NULL, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
                                               pinfo->rx_fifosize) +
                          L1_CACHE_ALIGN(pinfo->tx_nrfifos *
-                                        pinfo->tx_fifosize), pinfo->mem_addr,
+                                        pinfo->tx_fifosize), (void __force *)pinfo->mem_addr,
                          pinfo->dma_addr);
 
        cpm_dpfree(pinfo->dp_addr);
 }
 
+#ifndef CONFIG_PPC_CPM_NEW_BINDING
 /* Setup any dynamic params in the uart desc */
 int cpm_uart_init_portdesc(void)
 {
@@ -386,3 +447,4 @@ int cpm_uart_init_portdesc(void)
 
        return 0;
 }
+#endif