imx31_uart.c revision 1.3
11.1Sbsh/*
21.1Sbsh * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
31.1Sbsh * Written by Hiroyuki Bessho for Genetec Corporation.
41.1Sbsh *
51.1Sbsh * Redistribution and use in source and binary forms, with or without
61.1Sbsh * modification, are permitted provided that the following conditions
71.1Sbsh * are met:
81.1Sbsh * 1. Redistributions of source code must retain the above copyright
91.1Sbsh *    notice, this list of conditions and the following disclaimer.
101.1Sbsh * 2. Redistributions in binary form must reproduce the above copyright
111.1Sbsh *    notice, this list of conditions and the following disclaimer in the
121.1Sbsh *    documentation and/or other materials provided with the distribution.
131.1Sbsh *
141.1Sbsh * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
151.1Sbsh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
161.1Sbsh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
171.1Sbsh * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
181.1Sbsh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
191.1Sbsh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
201.1Sbsh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
211.1Sbsh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
221.1Sbsh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
231.1Sbsh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
241.1Sbsh * POSSIBILITY OF SUCH DAMAGE.
251.1Sbsh *
261.1Sbsh */
271.1Sbsh
281.1Sbsh#include "opt_imxuart.h"
291.1Sbsh#include <sys/param.h>
301.1Sbsh#include <sys/bus.h>
311.1Sbsh#include <sys/device.h>
321.1Sbsh#include <arm/imx/imx31reg.h>
331.1Sbsh#include <arm/imx/imx31var.h>
341.1Sbsh#include <arm/imx/imxuartreg.h>
351.1Sbsh#include <arm/imx/imxuartvar.h>
361.1Sbsh
371.3Shkenkenstatic int imx31_uart_match(device_t, struct cfdata *, void *);
381.3Shkenkenstatic void imx31_uart_attach(device_t, device_t, void *);
391.3Shkenken
401.3ShkenkenCFATTACH_DECL_NEW(imx31_uart, sizeof(struct imxuart_softc),
411.3Shkenken    imx31_uart_match, imx31_uart_attach, NULL, NULL);
421.1Sbsh
431.1Sbshint
441.3Shkenkenimx31_uart_match(device_t parent, struct cfdata *cf, void *aux)
451.1Sbsh{
461.1Sbsh	struct aips_attach_args * const aipsa = aux;
471.1Sbsh
481.1Sbsh	switch (aipsa->aipsa_addr) {
491.1Sbsh	case UART1_BASE:
501.1Sbsh	case UART2_BASE:
511.1Sbsh	case UART3_BASE:
521.1Sbsh	case UART4_BASE:
531.1Sbsh	case UART5_BASE:
541.1Sbsh		return 1;
551.1Sbsh	}
561.1Sbsh
571.1Sbsh	return 0;
581.1Sbsh}
591.1Sbsh
601.1Sbshvoid
611.3Shkenkenimx31_uart_attach(device_t parent, device_t self, void *aux)
621.1Sbsh{
631.1Sbsh	struct aips_attach_args * aa = aux;
641.1Sbsh
651.3Shkenken	imxuart_attach_common(parent, self,
661.1Sbsh	    aa->aipsa_memt, aa->aipsa_addr, aa->aipsa_size, aa->aipsa_intr, 0);
671.1Sbsh}
681.1Sbsh
69