Source-Changes-HG archive

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

[src/trunk]: src/sys/arch - get rid of private bus space in ingenic_com.c



details:   https://anonhg.NetBSD.org/src/rev/d59865617aa4
branches:  trunk
changeset: 339318:d59865617aa4
user:      macallan <macallan%NetBSD.org@localhost>
date:      Sat Jul 11 19:00:04 2015 +0000

description:
- get rid of private bus space in ingenic_com.c
- move com to apbus
- attach the other UARTs

diffstat:

 sys/arch/evbmips/conf/CI20          |  29 +++++++++----
 sys/arch/evbmips/ingenic/machdep.c  |   5 +-
 sys/arch/mips/conf/files.ingenic    |  18 ++++++--
 sys/arch/mips/ingenic/apbus.c       |  13 ++++-
 sys/arch/mips/ingenic/ingenic_com.c |  79 +++++++++++++++++-------------------
 5 files changed, 83 insertions(+), 61 deletions(-)

diffs (truncated from 350 to 300 lines):

diff -r 587faf417408 -r d59865617aa4 sys/arch/evbmips/conf/CI20
--- a/sys/arch/evbmips/conf/CI20        Sat Jul 11 18:54:03 2015 +0000
+++ b/sys/arch/evbmips/conf/CI20        Sat Jul 11 19:00:04 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: CI20,v 1.13 2015/04/06 14:12:28 martin Exp $
+#      $NetBSD: CI20,v 1.14 2015/07/11 19:00:04 macallan Exp $
 #
 # MIPS Creator CI20
 #
@@ -7,7 +7,7 @@
 
 #options       INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "CI20-$Revision: 1.13 $"
+#ident                 "CI20-$Revision: 1.14 $"
 
 maxusers       32
 
@@ -43,7 +43,7 @@
 
 # Debugging options
 options        DIAGNOSTIC      # extra kernel sanity checking
-options        DEBUG           # extra kernel debugging support
+#options       DEBUG           # extra kernel debugging support
 #options       KMEMSTATS       # kernel memory statistics (vmstat -m)
 #options       USERCONF        # userconf(4) support
 #options       SYSCTL_INCLUDE_DESCR    # Include sysctl descriptions in kernel
@@ -134,15 +134,19 @@
 
 config         netbsd  root on sd0a type ffs
 #config                netbsd  root on axe0 type nfs
+#config                netbsd  root on dme0 type nfs
 
 mainbus0       at root
 #options       MULTIPROCESSOR
+
 cpu0           at mainbus?
 #wdog0         at mainbus?
-com*           at mainbus?
 apbus0         at mainbus?
 
-# On-board USB
+# On-chip UARTs
+com*           at apbus?
+
+# On-chip USB
 dwctwo*        at apbus?
 #options       DWC2_DEBUG
 usb*           at dwctwo?
@@ -150,17 +154,18 @@
 ohci*          at apbus?
 usb*           at ohci?
 
-# this one doesn't work yet
+# this one doesn't work right just yet
 #ehci*         at apbus?
+#options       INGENIC_EHCI_DEBUG
+#options       EHCI_DEBUG
+#options       USBVERBOSE
+#options       USBHIST
 #usb*          at ehci?
 
 # onboard ethernet
 dme*           at apbus?
 
 # I2C/SMBus
-# Work in progress - can't do transfers over 15 bytes per direction,
-# no interrupts etc.
-# Good enough for talking to an RTC though, so it's enabled.
 jziic*                 at apbus?
 #options       JZIIC_DEBUG     # spammy
 iic*           at jziic?
@@ -182,6 +187,12 @@
 #jzgpio*       at apbus? addr ?
 #gpio*         at jzgpio?
 
+# MSC / SDMMC - unfinished
+#jzmmc*                at apbus?
+#options       JZMMC_DEBUG
+#sdmmc*                at jzmmc?
+#ld*           at sdmmc?
+
 # USB stuff
 uhub*          at usb?
 uhub*          at uhub? port ?
diff -r 587faf417408 -r d59865617aa4 sys/arch/evbmips/ingenic/machdep.c
--- a/sys/arch/evbmips/ingenic/machdep.c        Sat Jul 11 18:54:03 2015 +0000
+++ b/sys/arch/evbmips/ingenic/machdep.c        Sat Jul 11 19:00:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.8 2015/06/30 02:39:03 matt Exp $ */
+/*     $NetBSD: machdep.c,v 1.9 2015/07/11 19:00:04 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.8 2015/06/30 02:39:03 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.9 2015/07/11 19:00:04 macallan Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -242,6 +242,7 @@
         * Everything related to console initialization is done
         * in mach_init().
         */
+       apbus_init();
        ingenic_com_cnattach();
 }
 
diff -r 587faf417408 -r d59865617aa4 sys/arch/mips/conf/files.ingenic
--- a/sys/arch/mips/conf/files.ingenic  Sat Jul 11 18:54:03 2015 +0000
+++ b/sys/arch/mips/conf/files.ingenic  Sat Jul 11 19:00:04 2015 +0000
@@ -1,18 +1,19 @@
-#      $NetBSD: files.ingenic,v 1.5 2015/04/04 12:28:52 macallan Exp $
+#      $NetBSD: files.ingenic,v 1.6 2015/07/11 19:00:04 macallan Exp $
 
 include "dev/scsipi/files.scsipi"              # SCSI devices
 include "dev/ata/files.ata"                    # ATA devices
 include "dev/usb/files.usb"                    # USB devices
 
-# On-chip UART device
-attach com at mainbus with com_mainbus
-file   arch/mips/ingenic/ingenic_com.c com_mainbus
-
 # Ingenic system bus
 device apbus { [addr=-1] }
 attach apbus at mainbus
 file   arch/mips/ingenic/apbus.c               apbus
 
+# On-chip UART device
+attach com at apbus with ingenic_com
+file   arch/mips/ingenic/ingenic_com.c ingenic_com
+options        COM_REGMAP
+
 # USB
 attach dwctwo at apbus with ingenic_dwctwo
 file   arch/mips/ingenic/ingenic_dwctwo.c      ingenic_dwctwo  needs-flag
@@ -22,6 +23,7 @@
 
 attach ehci at apbus with ingenic_ehci
 file   arch/mips/ingenic/ingenic_ehci.c        ingenic_ehci    needs-flag
+defflag        opt_ingenic.h   INGENIC_EHCI_DEBUG
 
 # Ethernet
 attach dme at apbus with ingenic_dme
@@ -32,3 +34,9 @@
 attach         jziic at apbus
 file   arch/mips/ingenic/jziic.c       jziic
 defflag        opt_ingenic.h   JZIIC_DEBUG
+
+# SDMMC
+device         jzmmc : sdmmcbus
+attach         jzmmc at apbus
+file   arch/mips/ingenic/jzmmc.c       jzmmc
+defflag        opt_ingenic.h   JZMMC_DEBUG
diff -r 587faf417408 -r d59865617aa4 sys/arch/mips/ingenic/apbus.c
--- a/sys/arch/mips/ingenic/apbus.c     Sat Jul 11 18:54:03 2015 +0000
+++ b/sys/arch/mips/ingenic/apbus.c     Sat Jul 11 19:00:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apbus.c,v 1.15 2015/05/18 15:07:52 macallan Exp $ */
+/*     $NetBSD: apbus.c,v 1.16 2015/07/11 19:00:04 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -29,7 +29,7 @@
 /* catch-all for on-chip peripherals */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.15 2015/05/18 15:07:52 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apbus.c,v 1.16 2015/07/11 19:00:04 macallan Exp $");
 
 #include "locators.h"
 #define        _MIPS_BUS_DMA_PRIVATE
@@ -72,6 +72,11 @@
 } apbus_dev_t;
 
 static const apbus_dev_t apbus_devs[] = {
+       { "com",        JZ_UART0,       51, CLK_UART0, 0, 0},
+       { "com",        JZ_UART1,       50, CLK_UART1, 0, 0},
+       { "com",        JZ_UART2,       49, CLK_UART2, 0, 0},
+       { "com",        JZ_UART3,       48, CLK_UART3, 0, 0},
+       { "com",        JZ_UART4,       34, 0, CLK_UART4, 0},
        { "dwctwo",     JZ_DWC2_BASE,   21, CLK_OTG0 | CLK_UHC, CLK_OTG1, 0},
        { "ohci",       JZ_OHCI_BASE,    5, CLK_UHC, 0, 0},
        { "ehci",       JZ_EHCI_BASE,   20, CLK_UHC, 0, 0},
@@ -181,7 +186,7 @@
        gpio_as_dev1(4, 12);
        gpio_as_dev1(4, 13);
        /* these can be DDC2 or SMB4 */
-#if 1
+#if 0
        /* DDC2 devices show up at SMB4 */
        gpio_as_dev1(5, 24);
        gpio_as_dev1(5, 25);
@@ -219,7 +224,7 @@
        gpio_as_dev0(1, 30);
        gpio_as_dev0(1, 31);
 
-#ifdef INGENIC_DEBUG
+#ifndef INGENIC_DEBUG
        printf("JZ_CLKGR0 %08x\n", readreg(JZ_CLKGR0));
        printf("JZ_CLKGR1 %08x\n", readreg(JZ_CLKGR1));
        printf("JZ_SPCR0  %08x\n", readreg(JZ_SPCR0));
diff -r 587faf417408 -r d59865617aa4 sys/arch/mips/ingenic/ingenic_com.c
--- a/sys/arch/mips/ingenic/ingenic_com.c       Sat Jul 11 18:54:03 2015 +0000
+++ b/sys/arch/mips/ingenic/ingenic_com.c       Sat Jul 11 19:00:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ingenic_com.c,v 1.4 2015/03/07 15:35:33 macallan Exp $ */
+/*     $NetBSD: ingenic_com.c,v 1.5 2015/07/11 19:00:04 macallan Exp $ */
 
 /*-
  * Copyright (c) 2014 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.4 2015/03/07 15:35:33 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ingenic_com.c,v 1.5 2015/07/11 19:00:04 macallan Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -45,10 +45,15 @@
 
 #include <mips/cpuregs.h>
 
+#include <mips/ingenic/ingenic_var.h>
 #include <mips/ingenic/ingenic_regs.h>
 
 #include "opt_com.h"
 
+#ifndef COM_REGMAP
+#error We need COM_REGMAP
+#endif
+
 volatile int32_t *com0addr = (int32_t *)MIPS_PHYS_TO_KSEG1(JZ_UART0);
 
 void   ingenic_putchar_init(void);
@@ -60,9 +65,6 @@
 #endif
 
 
-static struct mips_bus_space   ingenic_com_mbst;
-static int     mbst_valid = 0;
-static void    ingenic_com_bus_mem_init(bus_space_tag_t, void *);
 void           ingenic_com_cnattach(void);
 
 static int     ingenic_com_match(device_t, cfdata_t , void *);
@@ -70,12 +72,17 @@
 
 struct ingenic_com_softc {
        struct com_softc sc_com;
+       bus_space_tag_t sc_tag;
+       bus_space_handle_t sc_regh;
 };
 
-CFATTACH_DECL_NEW(com_mainbus, sizeof(struct ingenic_com_softc),
+CFATTACH_DECL_NEW(ingenic_com, sizeof(struct ingenic_com_softc),
     ingenic_com_match, ingenic_com_attach, NULL, NULL);
 
-bus_space_handle_t regh = 0;
+static bus_space_handle_t regh = 0;
+static bus_addr_t cons_com = 0;
+static struct com_regs regs;
+extern bus_space_tag_t apbus_memt;
 
 void
 ingenic_putchar_init(void)
@@ -138,31 +145,20 @@
                ingenic_putchar(c);
 }
 
-static void
-ingenic_com_bus_init(void)
-{
-       if (mbst_valid) return;
-       ingenic_com_bus_mem_init(&ingenic_com_mbst, NULL);
-       mbst_valid = 1;
-}
-
 void
 ingenic_com_cnattach(void)
 {
-       struct com_regs regs;
+       int i;
        
-       ingenic_com_bus_init();
-       bus_space_map(&ingenic_com_mbst, 0, 0x1000, 0, &regh);
-
+       bus_space_map(apbus_memt, JZ_UART0, 0x100, 0, &regh);
+       cons_com = JZ_UART0;
        memset(&regs, 0, sizeof(regs));
-       COM_INIT_REGS(regs, &ingenic_com_mbst, regh, 0);
+       COM_INIT_REGS(regs, apbus_memt, regh, JZ_UART0);
+       for (i = 0; i < 16; i++) {
+               regs.cr_map[i] = regs.cr_map[i] << 2;
+       }
+       regs.cr_nports = 32;
 



Home | Main Index | Thread Index | Old Index