mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-27 14:43:58 +08:00
57c8a661d9
Move remaining definitions and declarations from include/linux/bootmem.h into include/linux/memblock.h and remove the redundant header. The includes were replaced with the semantic patch below and then semi-automated removal of duplicated '#include <linux/memblock.h> @@ @@ - #include <linux/bootmem.h> + #include <linux/memblock.h> [sfr@canb.auug.org.au: dma-direct: fix up for the removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181002185342.133d1680@canb.auug.org.au [sfr@canb.auug.org.au: powerpc: fix up for removal of linux/bootmem.h] Link: http://lkml.kernel.org/r/20181005161406.73ef8727@canb.auug.org.au [sfr@canb.auug.org.au: x86/kaslr, ACPI/NUMA: fix for linux/bootmem.h removal] Link: http://lkml.kernel.org/r/20181008190341.5e396491@canb.auug.org.au Link: http://lkml.kernel.org/r/1536927045-23536-30-git-send-email-rppt@linux.vnet.ibm.com Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> Acked-by: Michal Hocko <mhocko@suse.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Chris Zankel <chris@zankel.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: Greentime Hu <green.hu@gmail.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Cc: Ingo Molnar <mingo@redhat.com> Cc: "James E.J. Bottomley" <jejb@parisc-linux.org> Cc: Jonas Bonn <jonas@southpole.se> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Ley Foon Tan <lftan@altera.com> Cc: Mark Salter <msalter@redhat.com> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Matt Turner <mattst88@gmail.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Simek <monstr@monstr.eu> Cc: Palmer Dabbelt <palmer@sifive.com> Cc: Paul Burton <paul.burton@mips.com> Cc: Richard Kuo <rkuo@codeaurora.org> Cc: Richard Weinberger <richard@nod.at> Cc: Rich Felker <dalias@libc.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Serge Semin <fancer.lancer@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Tony Luck <tony.luck@intel.com> Cc: Vineet Gupta <vgupta@synopsys.com> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
158 lines
3.9 KiB
C
158 lines
3.9 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Driver for CPM (SCC/SMC) serial ports; CPM2 definitions
|
|
*
|
|
* 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>
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/tty.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/serial.h>
|
|
#include <linux/console.h>
|
|
#include <linux/sysrq.h>
|
|
#include <linux/device.h>
|
|
#include <linux/memblock.h>
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <asm/io.h>
|
|
#include <asm/irq.h>
|
|
#include <asm/fs_pd.h>
|
|
#include <asm/prom.h>
|
|
|
|
#include <linux/serial_core.h>
|
|
#include <linux/kernel.h>
|
|
|
|
#include "cpm_uart.h"
|
|
|
|
/**************************************************************/
|
|
|
|
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;
|
|
resource_size_t 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 = resource_size(&res);
|
|
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);
|
|
}
|
|
|
|
/*
|
|
* 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
|
|
*/
|
|
int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
|
|
{
|
|
int dpmemsz, memsz;
|
|
u8 __iomem *dp_mem;
|
|
unsigned long dp_offset;
|
|
u8 *mem_addr;
|
|
dma_addr_t dma_addr = 0;
|
|
|
|
pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
|
|
|
|
dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
|
|
dp_offset = cpm_dpalloc(dpmemsz, 8);
|
|
if (IS_ERR_VALUE(dp_offset)) {
|
|
printk(KERN_ERR
|
|
"cpm_uart_cpm.c: could not allocate buffer descriptors\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
dp_mem = cpm_dpram_addr(dp_offset);
|
|
|
|
memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
|
|
L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
|
|
if (is_con) {
|
|
mem_addr = kzalloc(memsz, GFP_NOWAIT);
|
|
dma_addr = virt_to_bus(mem_addr);
|
|
}
|
|
else
|
|
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
|
|
GFP_KERNEL);
|
|
|
|
if (mem_addr == NULL) {
|
|
cpm_dpfree(dp_offset);
|
|
printk(KERN_ERR
|
|
"cpm_uart_cpm.c: could not allocate coherent memory\n");
|
|
return -ENOMEM;
|
|
}
|
|
|
|
pinfo->dp_addr = dp_offset;
|
|
pinfo->mem_addr = mem_addr;
|
|
pinfo->dma_addr = dma_addr;
|
|
pinfo->mem_size = memsz;
|
|
|
|
pinfo->rx_buf = mem_addr;
|
|
pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
|
|
* pinfo->rx_fifosize);
|
|
|
|
pinfo->rx_bd_base = (cbd_t __iomem *)dp_mem;
|
|
pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
|
|
|
|
return 0;
|
|
}
|
|
|
|
void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
|
|
{
|
|
dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
|
|
pinfo->rx_fifosize) +
|
|
L1_CACHE_ALIGN(pinfo->tx_nrfifos *
|
|
pinfo->tx_fifosize), (void __force *)pinfo->mem_addr,
|
|
pinfo->dma_addr);
|
|
|
|
cpm_dpfree(pinfo->dp_addr);
|
|
}
|