Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/marvell Add UART and PCIe controller for Marvell SoC.



details:   https://anonhg.NetBSD.org/src/rev/45e955ae2548
branches:  trunk
changeset: 756332:45e955ae2548
user:      kiyohara <kiyohara%NetBSD.org@localhost>
date:      Tue Jul 13 11:16:02 2010 +0000

description:
Add UART and PCIe controller for Marvell SoC.
  However not define attribute *_mbus in our tree yet.

diffstat:

 sys/dev/marvell/com_mv.c        |  159 ++++++++
 sys/dev/marvell/files.discovery |   14 +-
 sys/dev/marvell/mvpex.c         |  738 ++++++++++++++++++++++++++++++++++++++++
 sys/dev/marvell/mvpexreg.h      |  144 +++++++
 sys/dev/marvell/mvpexvar.h      |   77 ++++
 5 files changed, 1125 insertions(+), 7 deletions(-)

diffs (truncated from 1172 to 300 lines):

diff -r 265a5d0d7f4d -r 45e955ae2548 sys/dev/marvell/com_mv.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/marvell/com_mv.c  Tue Jul 13 11:16:02 2010 +0000
@@ -0,0 +1,159 @@
+/*     $NetBSD: com_mv.c,v 1.1 2010/07/13 11:16:02 kiyohara Exp $      */
+/*
+ * Copyright (c) 2007, 2010 KIYOHARA Takashi
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: com_mv.c,v 1.1 2010/07/13 11:16:02 kiyohara Exp $");
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/termios.h>
+
+#include <dev/marvell/gtvar.h>
+#include <dev/marvell/marvellreg.h>
+#include <dev/marvell/marvellvar.h>
+
+#include <dev/ic/comvar.h>
+
+#include <prop/proplib.h>
+
+#define MVUART_SIZE            0x20
+
+
+static int mvuart_match(device_t, struct cfdata *, void *);
+static void mvuart_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(mvuart_gt, sizeof(struct com_softc),
+    mvuart_match, mvuart_attach, NULL, NULL);
+CFATTACH_DECL_NEW(mvuart_mbus, sizeof(struct com_softc),
+    mvuart_match, mvuart_attach, NULL, NULL);
+
+#ifdef COM_REGMAP
+#define MVUART_INIT_REGS(regs, tag, hdl, addr, size)           \
+       do {                                                    \
+               int i;                                          \
+                                                               \
+               regs.cr_iot = tag;                              \
+               regs.cr_ioh = hdl;                              \
+               regs.cr_iobase = addr;                          \
+               regs.cr_nports = size;                          \
+               for (i = 0; i < __arraycount(regs.cr_map); i++) \
+                       regs.cr_map[i] = com_std_map[i] << 2;   \
+       } while (0)
+#else
+#define MVUART_INIT_REGS(regs, tag, hdl, addr, size) \
+       COM_INIT_REGS(regs, tag, hdl, addr)
+#endif
+
+
+/* ARGSUSED */
+static int
+mvuart_match(device_t parent, struct cfdata *match, void *aux)
+{
+       struct marvell_attach_args *mva = aux;
+       bus_space_handle_t ioh;
+
+       switch (mva->mva_model) {
+#if 0
+       case MARVELL_DISCOVERY_V:       /* Do we have ?? */
+       case MARVELL_DISCOVERY_VI:      /* Do we have ?? */
+#endif
+       case MARVELL_ORION_1_88F1181:
+       case MARVELL_ORION_1_88F5082:
+       case MARVELL_ORION_1_88F5180N:
+       case MARVELL_ORION_1_88F5181:
+       case MARVELL_ORION_1_88F5182:
+       case MARVELL_ORION_1_88F6082:
+       case MARVELL_ORION_1_88W8660:
+       case MARVELL_ORION_2_88F1281:
+       case MARVELL_ORION_2_88F5281:
+               break;
+
+       default:
+               return 0;
+       }
+
+       if (com_is_console(mva->mva_iot, mva->mva_addr + mva->mva_offset, NULL))
+               return 1;
+
+       if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset,
+           mva->mva_size, &ioh))
+               return 0;
+       if (!comprobe1(mva->mva_iot, ioh))
+               return 0;
+       mva->mva_size = MVUART_SIZE;
+       return 1;
+}
+
+/* ARGSUSED */
+static void
+mvuart_attach(device_t parent, device_t self, void *aux)
+{
+       struct com_softc *sc = device_private(self);
+       struct marvell_attach_args *mva = aux;
+       bus_space_tag_t iot;
+       bus_space_handle_t ioh;
+       prop_dictionary_t dict = device_properties(self);
+
+       sc->sc_dev = self;
+
+       if (!prop_dictionary_get_uint32(dict, "frequency", &sc->sc_frequency)) {
+               aprint_error(": no frequency property\n");
+               return;
+       }
+
+       iot = mva->mva_iot;
+       if (!com_is_console(iot, mva->mva_addr + mva->mva_offset, &ioh)) {
+               if (bus_space_subregion(iot, mva->mva_ioh, mva->mva_offset,
+                   mva->mva_size, &ioh)) {
+                       aprint_error(": can't map registers\n");
+                       return;
+               }
+       }
+       MVUART_INIT_REGS(sc->sc_regs,
+           iot, ioh, mva->mva_addr + mva->mva_offset, mva->mva_size);
+
+       com_attach_subr(sc);
+
+       marvell_intr_establish(mva->mva_irq, IPL_SERIAL, comintr, sc);
+}
+
+#ifdef COM_REGMAP
+int mvuart_cnattach(bus_space_tag_t, bus_addr_t, int, uint32_t, int);
+
+int
+mvuart_cnattach(bus_space_tag_t iot, bus_addr_t addr, int baud,
+               uint32_t sysfreq, int mode)
+{
+       struct com_regs regs;
+
+       MVUART_INIT_REGS(regs, iot, 0x0, addr, MVUART_SIZE);
+
+       return comcnattach1(&regs, baud, sysfreq, COM_TYPE_16550_NOERS, mode);
+}
+#endif /* COM_REGMAP */
diff -r 265a5d0d7f4d -r 45e955ae2548 sys/dev/marvell/files.discovery
--- a/sys/dev/marvell/files.discovery   Tue Jul 13 11:12:19 2010 +0000
+++ b/sys/dev/marvell/files.discovery   Tue Jul 13 11:16:02 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.discovery,v 1.14 2010/07/11 08:34:57 kiyohara Exp $
+#      $NetBSD: files.discovery,v 1.15 2010/07/13 11:16:02 kiyohara Exp $
 #
 # Config file and device description for machine-independent support for
 # the Marvell (formerly Galileo Technology) Discovery system controllers.
@@ -29,13 +29,13 @@
 
 # PCI Interface
 device gtpci: pcibus
-file   dev/marvell/gtpci.c             gtpci & gtpci_gt needs-flag
+file   dev/marvell/gtpci.c             gtpci & (gtpci_gt|gtpci_mbus) needs-flag
 attach gtpci at gt with gtpci_gt
 
 # PCI Express Interface
-#device        mvpex: pcibus
-#file  dev/marvell/mvpex.c             mvpex & (mvpex_gt|mvpex_mbus) needs-flag
-#attach        mvpex at gt with mvpex_gt
+device mvpex: pcibus
+file   dev/marvell/mvpex.c             mvpex & (mvpex_gt|mvpex_mbus) needs-flag
+attach mvpex at gt with mvpex_gt
 
 # Fast ethernet
 define gfec { [port = -1], [irq = -1] }
@@ -82,8 +82,8 @@
 attach gttwsi at gt with gttwsi_gt
 
 # UART Interface
-#attach        com at gt with mvuart_gt
-#file  dev/marvell/com_mv.c            mvuart_gt | mvuart_mbus
+attach com at gt with mvuart_gt
+file   dev/marvell/com_mv.c            mvuart_gt | mvuart_mbus
 
 # IDMA Controller and XOR Engine
 device gtidmac: dmover_service
diff -r 265a5d0d7f4d -r 45e955ae2548 sys/dev/marvell/mvpex.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/marvell/mvpex.c   Tue Jul 13 11:16:02 2010 +0000
@@ -0,0 +1,738 @@
+/*     $NetBSD: mvpex.c,v 1.1 2010/07/13 11:16:02 kiyohara Exp $       */
+/*
+ * Copyright (c) 2008 KIYOHARA Takashi
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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: mvpex.c,v 1.1 2010/07/13 11:16:02 kiyohara Exp $");
+
+#include "opt_pci.h"
+#include "pci.h"
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/device.h>
+#include <sys/errno.h>
+#include <sys/extent.h>
+#include <sys/evcnt.h>
+#include <sys/malloc.h>
+#include <sys/systm.h>
+
+#include <prop/proplib.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+#include <dev/pci/pciconf.h>
+
+#include <dev/marvell/mvpexreg.h>
+#include <dev/marvell/mvpexvar.h>
+#include <dev/marvell/marvellreg.h>
+#include <dev/marvell/marvellvar.h>
+
+#include <machine/pci_machdep.h>
+
+#include "locators.h"
+
+
+static int mvpex_match(device_t, struct cfdata *, void *);
+static void mvpex_attach(device_t, device_t, void *);
+
+static int mvpex_intr(void *);
+
+static void mvpex_init(struct mvpex_softc *);
+#if 0  /* shall move to pchb(4)? */
+static void mvpex_barinit(struct mvpex_softc *);
+static int mvpex_wininit(struct mvpex_softc *, int, int, int, int, uint32_t *,
+                        uint32_t *);
+#else
+static void mvpex_wininit(struct mvpex_softc *);
+#endif
+#if NPCI > 0
+static void mvpex_pci_config(struct mvpex_softc *, bus_space_tag_t,
+                            bus_space_tag_t, bus_dma_tag_t, pci_chipset_tag_t,
+                            u_long, u_long, u_long, u_long, int);
+#endif
+
+CFATTACH_DECL_NEW(mvpex_gt, sizeof(struct mvpex_softc),
+    mvpex_match, mvpex_attach, NULL, NULL);
+CFATTACH_DECL_NEW(mvpex_mbus, sizeof(struct mvpex_softc),
+    mvpex_match, mvpex_attach, NULL, NULL);
+
+
+/* ARGSUSED */
+static int
+mvpex_match(device_t parent, struct cfdata *match, void *aux)
+{
+       struct marvell_attach_args *mva = aux;
+
+       switch (mva->mva_model) {
+#if 0
+       case MARVELL_DISCOVERY_V:
+       case MARVELL_DISCOVERY_VI:
+#endif
+       case MARVELL_ORION_1_88F1181:



Home | Main Index | Thread Index | Old Index