uart_cpu_at91usart.c revision 238403
121308Sache/*- 221308Sache * Copyright (c) 2003 Marcel Moolenaar 321308Sache * Copyright (c) 2006 M. Warner Losh 421308Sache * All rights reserved. 521308Sache * 621308Sache * Redistribution and use in source and binary forms, with or without 721308Sache * modification, are permitted provided that the following conditions 821308Sache * are met: 921308Sache * 1021308Sache * 1. Redistributions of source code must retain the above copyright 1158310Sache * notice, this list of conditions and the following disclaimer. 1221308Sache * 2. Redistributions in binary form must reproduce the above copyright 1321308Sache * notice, this list of conditions and the following disclaimer in the 1421308Sache * documentation and/or other materials provided with the distribution. 1521308Sache * 1621308Sache * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1721308Sache * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1821308Sache * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1921308Sache * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 2021308Sache * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2121308Sache * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2258310Sache * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2321308Sache * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2421308Sache * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2521308Sache * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2621308Sache * SUCH DAMAGE. 2721308Sache */ 2821308Sache 2921308Sache#include "opt_uart.h" 3021308Sache 3121308Sache#include <sys/cdefs.h> 3221308Sache__FBSDID("$FreeBSD: head/sys/arm/at91/uart_cpu_at91rm9200usart.c 238403 2012-07-12 19:11:37Z imp $"); 3321308Sache 3421308Sache#include <sys/param.h> 3521308Sache#include <sys/systm.h> 3621308Sache#include <sys/bus.h> 3721308Sache#include <sys/cons.h> 3821308Sache#include <sys/lock.h> 3921308Sache#include <sys/mutex.h> 4021308Sache#include <machine/bus.h> 4121308Sache 4221308Sache#include <dev/uart/uart.h> 4321308Sache#include <dev/uart/uart_bus.h> 4421308Sache#include <dev/uart/uart_cpu.h> 4521308Sache 4621308Sache#include <arm/at91/at91rm92reg.h> 4721308Sache#include <arm/at91/at91var.h> 4821308Sache 4921308Sachebus_space_tag_t uart_bus_space_io; 5058310Sachebus_space_tag_t uart_bus_space_mem; 51119610Sache 5258310Sacheextern struct uart_class at91_usart_class; 5321308Sacheextern struct bus_space at91_bs_tag; 5421308Sache 5521308Sacheint 5621308Sacheuart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2) 5721308Sache{ 5821308Sache return ((b1->bsh == b2->bsh && b1->bst == b2->bst) ? 1 : 0); 5921308Sache} 6021308Sache 6121308Sacheint 6221308Sacheuart_cpu_getdev(int devtype, struct uart_devinfo *di) 6321308Sache{ 6421308Sache struct uart_class *class; 6521308Sache 6621308Sache class = &at91_usart_class; 6721308Sache if (class->uc_rclk == 0 && at91_master_clock != 0) 6821308Sache class->uc_rclk = at91_master_clock; 6921308Sache di->ops = uart_getops(class); 7021308Sache di->bas.chan = 0; 7121308Sache di->bas.bst = &at91_bs_tag; 7221308Sache /* 7321308Sache * XXX: Not pretty, but will work because we map the needed addresses 7421308Sache * early. At least we probed this so that the console will work on 7521308Sache * all flavors of Atmel we can detect. 7621308Sache */ 7721308Sache di->bas.bsh = soc_info.dbgu_base; 7821308Sache di->baudrate = 115200; 7921308Sache di->bas.regshft = 0; 8021308Sache di->bas.rclk = 0; 8121308Sache di->databits = 8; 8221308Sache di->stopbits = 1; 8321308Sache di->parity = UART_PARITY_NONE; 8421308Sache uart_bus_space_io = &at91_bs_tag; 8521308Sache uart_bus_space_mem = NULL; 8621308Sache /* Check the environment for overrides */ 8721308Sache uart_getenv(devtype, di, class); 8875406Sache return (0); 8921308Sache} 9021308Sache