xref: /netbsd-src/sys/arch/arm/imx/imx51_uart.c (revision 4f4d98d9641451b54ed55023f2edd9dd3954ca25)
15a80dc5fSbsh /*
25a80dc5fSbsh  * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
35a80dc5fSbsh  * Written by Hiroyuki Bessho for Genetec Corporation.
45a80dc5fSbsh  *
55a80dc5fSbsh  * Redistribution and use in source and binary forms, with or without
65a80dc5fSbsh  * modification, are permitted provided that the following conditions
75a80dc5fSbsh  * are met:
85a80dc5fSbsh  * 1. Redistributions of source code must retain the above copyright
95a80dc5fSbsh  *    notice, this list of conditions and the following disclaimer.
105a80dc5fSbsh  * 2. Redistributions in binary form must reproduce the above copyright
115a80dc5fSbsh  *    notice, this list of conditions and the following disclaimer in the
125a80dc5fSbsh  *    documentation and/or other materials provided with the distribution.
135a80dc5fSbsh  *
145a80dc5fSbsh  * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
155a80dc5fSbsh  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
165a80dc5fSbsh  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
175a80dc5fSbsh  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
185a80dc5fSbsh  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
195a80dc5fSbsh  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
205a80dc5fSbsh  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
215a80dc5fSbsh  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
225a80dc5fSbsh  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
235a80dc5fSbsh  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
245a80dc5fSbsh  * POSSIBILITY OF SUCH DAMAGE.
255a80dc5fSbsh  *
265a80dc5fSbsh  */
275a80dc5fSbsh 
282868f5bcShkenken #include <sys/cdefs.h>
29*4f4d98d9Shkenken __KERNEL_RCSID(0, "$NetBSD: imx51_uart.c,v 1.4 2017/09/08 05:29:12 hkenken Exp $");
302868f5bcShkenken 
312868f5bcShkenken #include "opt_imx.h"
325a80dc5fSbsh #include "opt_imxuart.h"
332868f5bcShkenken 
345a80dc5fSbsh #include <sys/param.h>
355a80dc5fSbsh #include <sys/bus.h>
365a80dc5fSbsh #include <sys/device.h>
375a80dc5fSbsh #include <arm/imx/imx51reg.h>
385a80dc5fSbsh #include <arm/imx/imx51var.h>
395a80dc5fSbsh #include <arm/imx/imxuartreg.h>
405a80dc5fSbsh #include <arm/imx/imxuartvar.h>
415a80dc5fSbsh 
42*4f4d98d9Shkenken static int imx51_uart_match(device_t, struct cfdata *, void *);
43*4f4d98d9Shkenken static void imx51_uart_attach(device_t, device_t, void *);
44*4f4d98d9Shkenken 
45*4f4d98d9Shkenken CFATTACH_DECL_NEW(imx51_uart, sizeof(struct imxuart_softc),
46*4f4d98d9Shkenken     imx51_uart_match, imx51_uart_attach, NULL, NULL);
47*4f4d98d9Shkenken 
485a80dc5fSbsh int
imx51_uart_match(device_t parent,struct cfdata * cf,void * aux)49*4f4d98d9Shkenken imx51_uart_match(device_t parent, struct cfdata *cf, void *aux)
505a80dc5fSbsh {
515a80dc5fSbsh 	struct axi_attach_args * const aa = aux;
525a80dc5fSbsh 
535a80dc5fSbsh 	switch (aa->aa_addr) {
545a80dc5fSbsh 	case UART1_BASE:
555a80dc5fSbsh 	case UART2_BASE:
565a80dc5fSbsh 	case UART3_BASE:
575a80dc5fSbsh 		return 1;
585a80dc5fSbsh 	}
595a80dc5fSbsh 
605a80dc5fSbsh 	return 0;
615a80dc5fSbsh }
625a80dc5fSbsh 
635a80dc5fSbsh void
imx51_uart_attach(device_t parent,device_t self,void * aux)64*4f4d98d9Shkenken imx51_uart_attach(device_t parent, device_t self, void *aux)
655a80dc5fSbsh {
665a80dc5fSbsh 	struct axi_attach_args * aa = aux;
675a80dc5fSbsh 
685a80dc5fSbsh 	imxuart_attach_common(parent, self,
695a80dc5fSbsh 	    aa->aa_iot, aa->aa_addr, aa->aa_size, aa->aa_irq, 0);
705a80dc5fSbsh }
715a80dc5fSbsh 
72