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 Support GPIO, IOMUX, and USB on i.MX51.



details:   https://anonhg.NetBSD.org/src/rev/f65b4ea2db49
branches:  trunk
changeset: 759142:f65b4ea2db49
user:      bsh <bsh%NetBSD.org@localhost>
date:      Tue Nov 30 13:05:27 2010 +0000

description:
Support GPIO, IOMUX, and USB on i.MX51.

diffstat:

 sys/arch/arm/imx/files.imx51   |   20 +-
 sys/arch/arm/imx/imx51_axi.c   |    8 +-
 sys/arch/arm/imx/imx51_gpio.c  |  114 +++++++++++
 sys/arch/arm/imx/imx51_iomux.c |  180 +++++++++++++++++
 sys/arch/arm/imx/imx51_usb.c   |   89 ++++++++
 sys/arch/arm/imx/imx51reg.h    |   98 +++++++-
 sys/arch/arm/imx/imx51var.h    |   16 +-
 sys/arch/arm/imx/imxgpio.c     |  422 +++++++++++++++++++++++++++++++++++++++++
 sys/arch/arm/imx/imxgpioreg.h  |    7 +-
 sys/arch/arm/imx/imxgpiovar.h  |   53 +++++
 sys/arch/arm/imx/imxkppreg.h   |    4 +-
 sys/arch/arm/imx/imxusb.c      |  402 +++++++++++++++++++++++++++++++++++++++
 sys/arch/arm/imx/imxusbreg.h   |  113 ++++++++++
 sys/arch/arm/imx/imxusbvar.h   |   51 ++++
 14 files changed, 1539 insertions(+), 38 deletions(-)

diffs (truncated from 1741 to 300 lines):

diff -r 696c270444fe -r f65b4ea2db49 sys/arch/arm/imx/files.imx51
--- a/sys/arch/arm/imx/files.imx51      Tue Nov 30 12:42:48 2010 +0000
+++ b/sys/arch/arm/imx/files.imx51      Tue Nov 30 13:05:27 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.imx51,v 1.1 2010/11/13 07:11:02 bsh Exp $
+#      $NetBSD: files.imx51,v 1.2 2010/11/30 13:05:27 bsh Exp $
 #
 # Configuration info for the Freescale i.MX51
 #
@@ -46,14 +46,15 @@
 defparam opt_imx51clk.h IMX51_IPGCLK_FREQ
 
 # iMX GPIO
-# device       imxgpio: gpiobus
-# attach       imxgpio at ahb
-# file arch/arm/imx/imx31_gpio.c               imxgpio         needs-flag
+device imxgpio: gpiobus
+attach imxgpio at axi
+file   arch/arm/imx/imxgpio.c          imxgpio         needs-flag
+file   arch/arm/imx/imx51_gpio.c       imxgpio
 
 # iMX IOMUX
 device imxiomux : bus_space_generic
 attach imxiomux at axi
-file   arch/arm/imx/imx31_iomux.c              imxiomux
+file   arch/arm/imx/imx51_iomux.c              imxiomux
 
 # LCD controller
 # device       lcd : bus_dma_generic, wsemuldisplaydev, rasops16, rasops8, rasops4, rasops_rotation
@@ -73,8 +74,13 @@
 file   arch/arm/imx/imx51_uart.c               imxuart
 defflag        opt_imxuart.h                           IMXUARTCONSOLE
 
-# attach       ohci at ahb with ohci_ahb : bus_dma_generic
-# file arch/arm/imx/ochi_axi.c                 ohci_axi
+# USB controller
+# attach of this driver need to be specified in paltform configuration
+device imxusbc { unit, irq } : bus_dma_generic
+file   arch/arm/imx/imx51_usb.c                        imxusbc
+
+attach ehci at imxusbc with imxehci
+file   arch/arm/imx/imxusb.c                   imxehci
 
 # attach       wdc at ahb with wdc_ahb : bus_dma_generic
 # file arch/arm/imx/wdc_axi.c                  wdc_axi
diff -r 696c270444fe -r f65b4ea2db49 sys/arch/arm/imx/imx51_axi.c
--- a/sys/arch/arm/imx/imx51_axi.c      Tue Nov 30 12:42:48 2010 +0000
+++ b/sys/arch/arm/imx/imx51_axi.c      Tue Nov 30 13:05:27 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx51_axi.c,v 1.1 2010/11/13 07:11:02 bsh Exp $        */
+/*     $NetBSD: imx51_axi.c,v 1.2 2010/11/30 13:05:27 bsh Exp $        */
 
 /*-
  * Copyright (c) 2010 SHIMIZU Ryo <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx51_axi.c,v 1.1 2010/11/13 07:11:02 bsh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx51_axi.c,v 1.2 2010/11/30 13:05:27 bsh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -101,9 +101,11 @@
        aa = aux;
 
        if ((strcmp(cf->cf_name, "tzic") != 0) &&
-           (strcmp(cf->cf_name, "imxuart") != 0))
+           (strcmp(cf->cf_name, "imxuart") != 0) &&
+           (strcmp(cf->cf_name, "imxgpio") != 0))
                return 0;
 
+       aa->aa_name = cf->cf_name;
        aa->aa_addr = cf->cf_loc[AXICF_ADDR];
        aa->aa_size = cf->cf_loc[AXICF_SIZE];
        aa->aa_irq = cf->cf_loc[AXICF_IRQ];
diff -r 696c270444fe -r f65b4ea2db49 sys/arch/arm/imx/imx51_gpio.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/imx/imx51_gpio.c     Tue Nov 30 13:05:27 2010 +0000
@@ -0,0 +1,114 @@
+/*     $NetBSD: imx51_gpio.c,v 1.1 2010/11/30 13:05:27 bsh Exp $ */
+
+/* derived from imx31_gpio.c */
+/*-
+ * Copyright (c) 2007 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas
+ *
+ * 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.
+ */
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: imx51_gpio.c,v 1.1 2010/11/30 13:05:27 bsh Exp $");
+
+#include "locators.h"
+#include "gpio.h"
+
+#include <sys/param.h>
+#include <sys/evcnt.h>
+#include <sys/atomic.h>
+
+#include <machine/intr.h>
+
+#include <arm/cpu.h>
+#include <arm/armreg.h>
+#include <arm/cpufunc.h>
+
+#include <machine/bus.h>
+
+#include <arm/imx/imx51reg.h>
+#include <arm/imx/imx51var.h>
+#include <arm/pic/picvar.h>
+
+#include <arm/imx/imxgpioreg.h>
+#include <arm/imx/imxgpiovar.h>
+
+#if NGPIO > 0
+#include <sys/gpio.h>
+#include <dev/gpio/gpiovar.h>
+#endif
+
+const int imxgpio_ngroups = GPIO_NGROUPS;
+
+int
+imxgpio_match(device_t parent, cfdata_t cfdata, void *aux)
+{
+       struct axi_attach_args *aa = aux;
+
+       switch(aa->aa_addr) {
+       case GPIO1_BASE:
+       case GPIO2_BASE:
+       case GPIO3_BASE:
+       case GPIO4_BASE:
+               return 1;
+       }
+
+       return 0;
+}
+
+void
+imxgpio_attach(device_t parent, device_t self, void *aux)
+{
+       struct axi_attach_args * const aa = aux;
+       bus_space_handle_t ioh;
+       int error;
+
+       if (aa->aa_irq == AXICF_IRQ_DEFAULT &&
+           aa->aa_irqbase != AXICF_IRQBASE_DEFAULT) {
+               aprint_error_dev(self, "missing intr in config\n");
+               return;
+       }
+       if (aa->aa_irq != AXICF_IRQ_DEFAULT &&
+           aa->aa_irqbase == AXICF_IRQBASE_DEFAULT) {
+               aprint_error_dev(self, "missing irqbase in config\n");
+               return;
+       }
+               
+       if (aa->aa_size == AXICF_SIZE_DEFAULT)
+               aa->aa_size = GPIO_SIZE;
+
+       error = bus_space_map(aa->aa_iot, aa->aa_addr, aa->aa_size,
+           0, &ioh);
+
+       if (error) {
+               aprint_error(": failed to map register %#lx@%#lx: %d\n",
+                   aa->aa_size, aa->aa_addr, error);
+               return;
+       }
+
+       imxgpio_attach_common(self, aa->aa_iot, ioh,
+           (aa->aa_addr - GPIO1_BASE) / 0x4000,
+           aa->aa_irq, aa->aa_irqbase);
+}
+
diff -r 696c270444fe -r f65b4ea2db49 sys/arch/arm/imx/imx51_iomux.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/arm/imx/imx51_iomux.c    Tue Nov 30 13:05:27 2010 +0000
@@ -0,0 +1,180 @@
+/*     $NetBSD: imx51_iomux.c,v 1.1 2010/11/30 13:05:27 bsh Exp $      */
+
+/*
+ * Copyright (c) 2009, 2010  Genetec Corporation.  All rights reserved.
+ * Written by Hashimoto Kenichi 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 <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: imx51_iomux.c,v 1.1 2010/11/30 13:05:27 bsh Exp $");
+
+#define        _INTR_PRIVATE
+
+#include "locators.h"
+
+#include <sys/param.h>
+#include <sys/evcnt.h>
+#include <sys/atomic.h>
+#include <sys/device.h>
+
+#include <uvm/uvm_extern.h>
+
+#include <machine/intr.h>
+
+#include <arm/cpu.h>
+#include <arm/armreg.h>
+#include <arm/cpufunc.h>
+
+#include <machine/bus.h>
+
+#include <arm/imx/imx51reg.h>
+#include <arm/imx/imx51var.h>
+
+struct iomux_softc {
+       struct device iomux_dev;
+       bus_space_tag_t iomux_memt;
+       bus_space_handle_t iomux_memh;
+};
+
+extern struct cfdriver imxiomux_cd;
+
+#define        IOMUX_READ(iomux, reg) \
+       bus_space_read_4((iomux)->iomux_memt, (iomux)->iomux_memh, (reg))
+#define        IOMUX_WRITE(iomux, reg, val) \
+       bus_space_write_4((iomux)->iomux_memt, (iomux)->iomux_memh, (reg), (val))
+
+static int iomux_match(device_t, cfdata_t, void *);
+static void iomux_attach(device_t, device_t, void *);
+
+static struct iomux_softc *iomuxsc = NULL;
+
+CFATTACH_DECL(imxiomux,
+             sizeof(struct iomux_softc),
+             iomux_match, iomux_attach,
+             NULL, NULL);
+
+int
+iomux_match(device_t parent, cfdata_t cfdata, void *aux)
+{
+       struct axi_attach_args *axia = aux;
+
+       if (axia->aa_addr != IOMUXC_BASE)
+               return 0;
+
+       return 1;
+}
+
+void
+iomux_attach(device_t parent, device_t self, void *aux)
+{
+       struct axi_attach_args * const axia = aux;
+       struct iomux_softc * const iomux = device_private(self);
+       int error;
+
+       if (axia->aa_size == AXICF_SIZE_DEFAULT)
+               axia->aa_size = IOMUXC_SIZE;
+
+       iomux->iomux_memt = axia->aa_iot;
+       error = bus_space_map(axia->aa_iot, axia->aa_addr, axia->aa_size,
+                             0, &iomux->iomux_memh);
+
+       if (error) {
+               aprint_error(": failed to map register %#lx@%#lx: %d\n",



Home | Main Index | Thread Index | Old Index