uart_cpu_ia64.c revision 127215
176259Sgreen/* 276259Sgreen * Copyright (c) 2003, 2004 Marcel Moolenaar 376259Sgreen * All rights reserved. 476259Sgreen * 576259Sgreen * Redistribution and use in source and binary forms, with or without 676259Sgreen * modification, are permitted provided that the following conditions 776259Sgreen * are met: 876259Sgreen * 976259Sgreen * 1. Redistributions of source code must retain the above copyright 1076259Sgreen * notice, this list of conditions and the following disclaimer. 1176259Sgreen * 2. Redistributions in binary form must reproduce the above copyright 1276259Sgreen * notice, this list of conditions and the following disclaimer in the 1376259Sgreen * documentation and/or other materials provided with the distribution. 1476259Sgreen * 1576259Sgreen * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1676259Sgreen * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1776259Sgreen * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1876259Sgreen * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1976259Sgreen * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2076259Sgreen * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2176259Sgreen * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2276259Sgreen * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2376259Sgreen * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2476259Sgreen * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2576259Sgreen */ 2676259Sgreen 2776259Sgreen#include <sys/cdefs.h> 2876259Sgreen__FBSDID("$FreeBSD: head/sys/dev/uart/uart_cpu_ia64.c 127215 2004-03-20 02:14:02Z marcel $"); 2976259Sgreen 3076259Sgreen#include <sys/param.h> 3176259Sgreen#include <sys/systm.h> 3276259Sgreen#include <sys/bus.h> 3376259Sgreen 3476259Sgreen#include <machine/bootinfo.h> 3576259Sgreen#include <machine/bus.h> 3676259Sgreen#include <machine/dig64.h> 3776259Sgreen#include <machine/vmparam.h> 3876259Sgreen 3976259Sgreen#include <dev/uart/uart.h> 4076259Sgreen#include <dev/uart/uart_cpu.h> 4176259Sgreen 4276259Sgreenbus_space_tag_t uart_bus_space_io = IA64_BUS_SPACE_IO; 4376259Sgreenbus_space_tag_t uart_bus_space_mem = IA64_BUS_SPACE_MEM; 4476259Sgreen 4576259Sgreenstatic int dig64_to_uart_parity[] = { 4676259Sgreen UART_PARITY_NONE, UART_PARITY_NONE, UART_PARITY_EVEN, 4776259Sgreen UART_PARITY_ODD, UART_PARITY_MARK, UART_PARITY_SPACE 4876259Sgreen}; 4976259Sgreen 5076259Sgreenint 5176259Sgreenuart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) 5276259Sgreen{ 5376259Sgreen 5476259Sgreen return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); 5576259Sgreen} 5676259Sgreen 5776259Sgreenint 5876259Sgreenuart_cpu_getdev(int devtype, struct uart_devinfo *di) 5976259Sgreen{ 6076259Sgreen struct dig64_hcdp_table *tbl; 6176259Sgreen struct dig64_hcdp_entry *ent; 6276259Sgreen bus_addr_t addr; 6376259Sgreen unsigned int i; 6476259Sgreen 6576259Sgreen /* 6676259Sgreen * Use the DIG64 HCDP table if present. 6776259Sgreen */ 6876259Sgreen if (bootinfo.bi_hcdp != 0) { 6976259Sgreen tbl = (void*)IA64_PHYS_TO_RR7(bootinfo.bi_hcdp); 7076259Sgreen for (i = 0; i < tbl->entries; i++) { 7176259Sgreen ent = tbl->entry + i; 7276259Sgreen 7376259Sgreen if (devtype == UART_DEV_CONSOLE && 7476259Sgreen ent->type != DIG64_HCDP_CONSOLE) 7576259Sgreen continue; 7676259Sgreen 7776259Sgreen if (devtype == UART_DEV_DBGPORT && 7876259Sgreen ent->type != DIG64_HCDP_DBGPORT) 79 continue; 80 81 addr = ent->address.addr_high; 82 addr = (addr << 32) + ent->address.addr_low; 83 di->ops = uart_ns8250_ops; 84 di->bas.chan = 0; 85 di->bas.bst = (ent->address.addr_space == 0) 86 ? uart_bus_space_mem : uart_bus_space_io; 87 if (bus_space_map(di->bas.bst, addr, 8, 0, 88 &di->bas.bsh) != 0) 89 continue; 90 di->bas.regshft = 0; 91 di->bas.rclk = ent->pclock << 4; 92 /* We don't deal with 64-bit baud rates. */ 93 di->baudrate = ent->baud_low; 94 di->databits = ent->databits; 95 di->stopbits = ent->stopbits; 96 di->parity = (ent->parity >= 6) ? UART_PARITY_NONE 97 : dig64_to_uart_parity[ent->parity]; 98 return (0); 99 } 100 101 /* FALLTHROUGH */ 102 } 103 104 /* Check the environment. */ 105 return (uart_getenv(devtype, di)); 106} 107