uart_bus_at91usart.c revision 158531
1155324Simp/*- 2155324Simp * Copyright (c) 2005 Olivier Houchard. All rights reserved. 3155324Simp * 4155324Simp * Redistribution and use in source and binary forms, with or without 5155324Simp * modification, are permitted provided that the following conditions 6155324Simp * are met: 7155324Simp * 1. Redistributions of source code must retain the above copyright 8155324Simp * notice, this list of conditions and the following disclaimer. 9155324Simp * 2. Redistributions in binary form must reproduce the above copyright 10155324Simp * notice, this list of conditions and the following disclaimer in the 11155324Simp * documentation and/or other materials provided with the distribution. 12155324Simp * 13155324Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14155324Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15155324Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16155324Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17155324Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18155324Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19155324Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20155324Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21155324Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22155324Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23155324Simp */ 24155324Simp 25155324Simp#include "opt_uart.h" 26155324Simp 27155324Simp#include <sys/cdefs.h> 28155324Simp__FBSDID("$FreeBSD: head/sys/arm/at91/uart_bus_at91usart.c 158531 2006-05-13 23:41:16Z cognet $"); 29155324Simp 30155324Simp#include <sys/param.h> 31155324Simp#include <sys/systm.h> 32155324Simp#include <sys/bus.h> 33155324Simp#include <sys/conf.h> 34155324Simp#include <sys/kernel.h> 35155324Simp#include <sys/module.h> 36155324Simp#include <machine/bus.h> 37155324Simp#include <sys/rman.h> 38155324Simp#include <machine/resource.h> 39155324Simp 40155324Simp#include <dev/pci/pcivar.h> 41155324Simp 42155324Simp#include <dev/uart/uart.h> 43155324Simp#include <dev/uart/uart_bus.h> 44155324Simp#include <dev/uart/uart_cpu.h> 45155324Simp 46155324Simp#include <arm/at91/at91rm92reg.h> 47155324Simp 48155324Simp#include "uart_if.h" 49155324Simp 50155324Simpstatic int usart_at91rm92_probe(device_t dev); 51155324Simp 52155324Simpextern struct uart_class at91_usart_class; 53155324Simp 54155324Simpstatic device_method_t usart_at91rm92_methods[] = { 55155324Simp /* Device interface */ 56155324Simp DEVMETHOD(device_probe, usart_at91rm92_probe), 57155324Simp DEVMETHOD(device_attach, uart_bus_attach), 58155324Simp DEVMETHOD(device_detach, uart_bus_detach), 59155324Simp { 0, 0 } 60155324Simp}; 61155324Simp 62155324Simpstatic driver_t usart_at91rm92_driver = { 63155324Simp uart_driver_name, 64155324Simp usart_at91rm92_methods, 65155324Simp sizeof(struct uart_softc), 66155324Simp}; 67155324Simp 68155324Simpextern SLIST_HEAD(uart_devinfo_list, uart_devinfo) uart_sysdevs; 69155324Simp 70155324Simpstatic int 71155324Simpusart_at91rm92_probe(device_t dev) 72155324Simp{ 73155324Simp struct uart_softc *sc; 74155324Simp 75155324Simp sc = device_get_softc(dev); 76155324Simp switch (device_get_unit(dev)) 77155324Simp { 78155324Simp case 0: 79158531Scognet#ifdef SKYEYE_WORKAROUNDS 80158531Scognet device_set_desc(dev, "USART0"); 81158531Scognet#else 82155324Simp device_set_desc(dev, "DBGU"); 83158531Scognet#endif 84155324Simp /* 85155324Simp * Setting sc_sysdev makes this device a 'system device' and 86155324Simp * indirectly makes it the system console. 87155324Simp */ 88155324Simp sc->sc_sysdev = SLIST_FIRST(&uart_sysdevs); 89155324Simp bcopy(&sc->sc_sysdev->bas, &sc->sc_bas, sizeof(sc->sc_bas)); 90155324Simp break; 91155324Simp case 1: 92155324Simp device_set_desc(dev, "USART0"); 93155324Simp break; 94155324Simp case 2: 95155324Simp device_set_desc(dev, "USART1"); 96155324Simp break; 97155324Simp case 3: 98155324Simp device_set_desc(dev, "USART2"); 99155324Simp break; 100155324Simp case 4: 101155324Simp device_set_desc(dev, "USART3"); 102155324Simp break; 103155324Simp } 104155324Simp sc->sc_class = &at91_usart_class; 105158531Scognet return (uart_bus_probe(dev, 0, 0, 0, device_get_unit(dev))); 106155324Simp} 107155324Simp 108155324Simp 109155324SimpDRIVER_MODULE(uart, atmelarm, usart_at91rm92_driver, uart_devclass, 0, 0); 110