Path: blob/master/arch/mips/netlogic/xlr/platform.c
10821 views
/*1* Copyright 2011, Netlogic Microsystems.2* Copyright 2004, Matt Porter <[email protected]>3*4* This file is licensed under the terms of the GNU General Public5* License version 2. This program is licensed "as is" without any6* warranty of any kind, whether express or implied.7*/89#include <linux/device.h>10#include <linux/platform_device.h>11#include <linux/kernel.h>12#include <linux/init.h>13#include <linux/resource.h>14#include <linux/serial_8250.h>15#include <linux/serial_reg.h>1617#include <asm/netlogic/xlr/iomap.h>18#include <asm/netlogic/xlr/pic.h>19#include <asm/netlogic/xlr/xlr.h>2021unsigned int nlm_xlr_uart_in(struct uart_port *p, int offset)22{23nlm_reg_t *mmio;24unsigned int value;2526/* XLR uart does not need any mapping of regs */27mmio = (nlm_reg_t *)(p->membase + (offset << p->regshift));28value = netlogic_read_reg(mmio, 0);2930/* See XLR/XLS errata */31if (offset == UART_MSR)32value ^= 0xF0;33else if (offset == UART_MCR)34value ^= 0x3;3536return value;37}3839void nlm_xlr_uart_out(struct uart_port *p, int offset, int value)40{41nlm_reg_t *mmio;4243/* XLR uart does not need any mapping of regs */44mmio = (nlm_reg_t *)(p->membase + (offset << p->regshift));4546/* See XLR/XLS errata */47if (offset == UART_MSR)48value ^= 0xF0;49else if (offset == UART_MCR)50value ^= 0x3;5152netlogic_write_reg(mmio, 0, value);53}5455#define PORT(_irq) \56{ \57.irq = _irq, \58.regshift = 2, \59.iotype = UPIO_MEM32, \60.flags = (UPF_SKIP_TEST | \61UPF_FIXED_TYPE | UPF_BOOT_AUTOCONF),\62.uartclk = PIC_CLKS_PER_SEC, \63.type = PORT_16550A, \64.serial_in = nlm_xlr_uart_in, \65.serial_out = nlm_xlr_uart_out, \66}6768static struct plat_serial8250_port xlr_uart_data[] = {69PORT(PIC_UART_0_IRQ),70PORT(PIC_UART_1_IRQ),71{},72};7374static struct platform_device uart_device = {75.name = "serial8250",76.id = PLAT8250_DEV_PLATFORM,77.dev = {78.platform_data = xlr_uart_data,79},80};8182static int __init nlm_uart_init(void)83{84nlm_reg_t *mmio;8586mmio = netlogic_io_mmio(NETLOGIC_IO_UART_0_OFFSET);87xlr_uart_data[0].membase = (void __iomem *)mmio;88xlr_uart_data[0].mapbase = CPHYSADDR((unsigned long)mmio);8990mmio = netlogic_io_mmio(NETLOGIC_IO_UART_1_OFFSET);91xlr_uart_data[1].membase = (void __iomem *)mmio;92xlr_uart_data[1].mapbase = CPHYSADDR((unsigned long)mmio);9394return platform_device_register(&uart_device);95}9697arch_initcall(nlm_uart_init);9899100