Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/imx UART driver for i.MX31 and 51.



details:   https://anonhg.NetBSD.org/src/rev/d7933e8ca7a5
branches:  trunk
changeset: 758687:d7933e8ca7a5
user:      bsh <bsh%NetBSD.org@localhost>
date:      Sat Nov 13 06:12:17 2010 +0000

description:
UART driver for i.MX31 and 51.

diffstat:

 sys/arch/arm/imx/imx31_uart.c |    63 +
 sys/arch/arm/imx/imx51_uart.c |    61 +
 sys/arch/arm/imx/imxuart.c    |  2900 +++++++++++++++++++++++++++++++++++-----
 sys/arch/arm/imx/imxuartreg.h |   358 ++--
 sys/arch/arm/imx/imxuartvar.h |    77 +-
 5 files changed, 2855 insertions(+), 604 deletions(-)

diffs (truncated from 3668 to 300 lines):

diff -r 69b5901945f5 -r d7933e8ca7a5 sys/arch/arm/imx/imx31_uart.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/imx/imx31_uart.c     Sat Nov 13 06:12:17 2010 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "opt_imxuart.h"
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <arm/imx/imx31reg.h>
+#include <arm/imx/imx31var.h>
+#include <arm/imx/imxuartreg.h>
+#include <arm/imx/imxuartvar.h>
+
+
+int
+imxuart_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+       struct aips_attach_args * const aipsa = aux;
+
+       switch (aipsa->aipsa_addr) {
+       case UART1_BASE:
+       case UART2_BASE:
+       case UART3_BASE:
+       case UART4_BASE:
+       case UART5_BASE:
+               return 1;
+       }
+
+       return 0;
+}
+
+void
+imxuart_attach(struct device *parent, struct device *self, void *aux)
+{
+       struct aips_attach_args * aa = aux;
+
+       imxuart_attach_common(parent, self, 
+           aa->aipsa_memt, aa->aipsa_addr, aa->aipsa_size, aa->aipsa_intr, 0);
+}
+
diff -r 69b5901945f5 -r d7933e8ca7a5 sys/arch/arm/imx/imx51_uart.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/imx/imx51_uart.c     Sat Nov 13 06:12:17 2010 +0000
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include "opt_imxuart.h"
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <arm/imx/imx51reg.h>
+#include <arm/imx/imx51var.h>
+#include <arm/imx/imxuartreg.h>
+#include <arm/imx/imxuartvar.h>
+
+
+int
+imxuart_match(struct device *parent, struct cfdata *cf, void *aux)
+{
+       struct axi_attach_args * const aa = aux;
+
+       switch (aa->aa_addr) {
+       case UART1_BASE:
+       case UART2_BASE:
+       case UART3_BASE:
+               return 1;
+       }
+
+       return 0;
+}
+
+void
+imxuart_attach(struct device *parent, struct device *self, void *aux)
+{
+       struct axi_attach_args * aa = aux;
+
+       imxuart_attach_common(parent, self, 
+           aa->aa_iot, aa->aa_addr, aa->aa_size, aa->aa_irq, 0);
+}
+
diff -r 69b5901945f5 -r d7933e8ca7a5 sys/arch/arm/imx/imxuart.c
--- a/sys/arch/arm/imx/imxuart.c        Sat Nov 13 06:09:34 2010 +0000
+++ b/sys/arch/arm/imx/imxuart.c        Sat Nov 13 06:12:17 2010 +0000
@@ -1,451 +1,2537 @@
-/* $Id: imxuart.c,v 1.4 2010/11/13 05:00:31 bsh Exp $ */
-#include <sys/types.h>
+/* $NetBSD: imxuart.c,v 1.5 2010/11/13 06:12:17 bsh Exp $ */
+
+/*
+ * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
+ * Written by Hiroyuki Bessho for Genetec Corporation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GENETEC CORPORATION
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+/*
+ * derived from sys/dev/ic/com.c
+ */
+
+/*-
+ * Copyright (c) 1998, 1999, 2004, 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)com.c       7.5 (Berkeley) 5/16/91
+ */
+
+/*
+ * driver for UART in i.MX SoC.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: imxuart.c,v 1.5 2010/11/13 06:12:17 bsh Exp $");
+
+#include "opt_imxuart.h"
+#include "opt_ddb.h"
+#include "opt_kgdb.h"
+#include "opt_lockdebug.h"
+#include "opt_multiprocessor.h"
+#include "opt_ntp.h"
+#include "opt_imxuart.h"
+#include "opt_imx.h"
+
+#include "rnd.h"
+#if NRND > 0 && defined(RND_COM)
+#include <sys/rnd.h>
+#endif
+
+#ifndef        IMXUART_TOLERANCE
+#define        IMXUART_TOLERANCE       30      /* baud rate tolerance, in 0.1% units */
+#endif
+
+#ifndef        IMXUART_FREQDIV
+#define        IMXUART_FREQDIV         2       /* XXX */
+#endif
+
+#ifndef        IMXUART_FREQ
+#define        IMXUART_FREQ    (56900000)
+#endif
+
+/*
+ * Override cnmagic(9) macro before including <sys/systm.h>.
+ * We need to know if cn_check_magic triggered debugger, so set a flag.
+ * Callers of cn_check_magic must declare int cn_trapped = 0;
+ * XXX: this is *ugly*!
+ */
+#define        cn_trap()                               \
+       do {                                    \
+               console_debugger();             \
+               cn_trapped = 1;                 \
+       } while (/* CONSTCOND */ 0)
+
+#include <sys/param.h>
 #include <sys/systm.h>
-#include <sys/device.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/poll.h>
+#include <sys/tty.h>
+#include <sys/proc.h>
+#include <sys/user.h>
 #include <sys/conf.h>
-
-#include <arm/armreg.h>
-
-#include <sys/tty.h>
-#include <sys/termios.h>
-#include <dev/cons.h>
-
-#include <machine/bus.h>
-#include <arm/imx/imx31var.h>
+#include <sys/file.h>
+#include <sys/uio.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/device.h>



Home | Main Index | Thread Index | Old Index