]> 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 7ebce263ad405349026b2e6133006f6775d990bd..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>
 #ifdef CONFIG_PPC_CPM_NEW_BINDING
 void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
 {
-       cpm_cpm2_t __iomem *cp = cpm2_map(im_cpm);
+       cpm_command(port->command, cmd);
+}
 
-       out_be32(&cp->cp_cpcr, port->command | cmd | CPM_CR_FLG);
-       while (in_be32(&cp->cp_cpcr) & CPM_CR_FLG)
-               ;
+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;
 
-       cpm2_unmap(cp);
+       /* 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)
 {
@@ -171,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;
@@ -227,7 +273,7 @@ void scc4_lineif(struct uart_cpm_port *pinfo)
 #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
@@ -235,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;
@@ -278,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;
@@ -289,7 +335,7 @@ 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);