CVS commit: src/sys/arch/arm/ti

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_wdt.c

Log Message:
Add TI OMAP watchdog timer driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov 29 20:54:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_wdt.c

Log Message:
Add TI OMAP watchdog timer driver.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_wdt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.11 src/sys/arch/arm/ti/am3_prcm.c:1.12
--- src/sys/arch/arm/ti/am3_prcm.c:1.11	Wed Nov 27 23:02:54 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Fri Nov 29 20:54:00 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.12 2019/11/29 20:54:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -169,6 +169,8 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"),
 
+	AM3_PRCM_HWMOD_WKUP("wd_timer2", 0xd4, "FIXED_32K"),
+
 	AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"),

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.20 src/sys/arch/arm/ti/files.ti:1.21
--- src/sys/arch/arm/ti/files.ti:1.20	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/files.ti	Fri Nov 29 20:54:00 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.20 2019/11/03 22:59:06 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.21 2019/11/29 20:54:00 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_cpufreq.c	soc_ti
@@ -131,6 +131,11 @@ device	omapnand: nandbus
 attach	omapnand at fdt
 file	arch/arm/ti/omap2_nand.c	omapnand
 
+# Watchdog timer
+device	tiwdt: sysmon_wdog
+attach	tiwdt at fdt with ti_wdt
+file	arch/arm/ti/ti_wdt.c		ti_wdt
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_AM33XX: SOC_TI

Added files:

Index: src/sys/arch/arm/ti/ti_wdt.c
diff -u /dev/null src/sys/arch/arm/ti/ti_wdt.c:1.1
--- /dev/null	Fri Nov 29 20:54:00 2019
+++ src/sys/arch/arm/ti/ti_wdt.c	Fri Nov 29 20:54:00 2019
@@ -0,0 +1,259 @@
+/* $NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * 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 
+__KERNEL_RCSID(0, "$NetBSD: ti_wdt.c,v 1.1 2019/11/29 20:54:00 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+#define	WDT_WDSC		0x10
+#define	 WDSC_SOFTRESET		__BIT(1)
+#define	WDT_WDST		0x14
+#define	WDT_WISR		0x18
+#define	WDT_WIER		0x1c
+#define	WDT_WCLR		0x24
+#define	 WCLR_PRE		__BIT(5)
+#define	 WCLR_PTV		__BITS(4,2)
+#define	WDT_WCRR		0x28
+#define	WDT_WLDR		0x2c
+#define	WDT_WTGR		0x30
+#define	WDT_WWPS		0x34
+#define	 WWPS_W_PEND_WDLY	__BIT(5)
+#define	 WWPS_W_PEND_WSPR	__BIT(4)
+#define	 WWPS_W_PEND_WTGR	__BIT(3)
+#define	 WWPS_W_PEND_WLDR	__BIT(2)
+#define	 WWPS_W_PEND_WCRR	__BIT(1)
+#define	 WWPS_W_PEND_WCLR	__BIT(0)
+#define	 WWPS_W_PEND_MASK	__BITS(5,0)
+#define	WDT_WDLY		0x44
+#define	WDT_WSPR		0x48
+#define	WDT_WIRQSTATRAW		0x54
+#define	WDT_WIRQSTAT		0x58
+#define	WDT_WIRQENSET		0x5c
+#define	WDT_WIRQENCLR		0x60
+#define	 WIRQ_EVENT_DLY		__BIT(1)
+#define	 WIRQ_EVENT_OVF		__BIT(0)
+
+#define	

CVS commit: src/sys/arch/arm/ti

2019-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Nov 28 23:57:09 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Support 1-bit mode and force all xfers to bounce to workaround a transfer error 
issue for now


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_sdhc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Nov 28 23:57:09 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Support 1-bit mode and force all xfers to bounce to workaround a transfer error 
issue for now


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_sdhc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.4 src/sys/arch/arm/ti/ti_sdhc.c:1.5
--- src/sys/arch/arm/ti/ti_sdhc.c:1.4	Wed Nov 27 23:03:24 2019
+++ src/sys/arch/arm/ti/ti_sdhc.c	Thu Nov 28 23:57:09 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.5 2019/11/28 23:57:09 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.5 2019/11/28 23:57:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -428,15 +428,21 @@ static int
 ti_sdhc_bus_width(struct sdhc_softc *sc, int width)
 {
 	struct ti_sdhc_softc *hmsc = (struct ti_sdhc_softc *)sc;
-	uint32_t con;
+	uint32_t con, hctl;
 
 	con = bus_space_read_4(hmsc->sc_bst, hmsc->sc_bsh, MMCHS_CON);
+	hctl = SDHC_READ(hmsc, SDHC_HOST_CTL);
 	if (width == 8) {
 		con |= CON_DW8;
+	} else if (width == 4) {
+		con &= ~CON_DW8;
+		hctl |= SDHC_4BIT_MODE;
 	} else {
 		con &= ~CON_DW8;
+		hctl &= ~SDHC_4BIT_MODE;
 	}
 	bus_space_write_4(hmsc->sc_bst, hmsc->sc_bsh, MMCHS_CON, con);
+	SDHC_WRITE(hmsc, SDHC_HOST_CTL, hctl);
 
 	return 0;
 }
@@ -487,6 +493,13 @@ ti_sdhc_edma_init(struct ti_sdhc_softc *
 		error);
 		return error;
 	}
+	error = bus_dmamap_load(sc->sc.sc_dmat, sc->sc_edma_dmamap,
+	sc->sc_edma_bbuf, MAXPHYS, NULL, BUS_DMA_WAITOK);
+	if (error) {
+		device_printf(sc->sc.sc_dev, "couldn't load dmamap: %d\n",
+		error);
+		return error;
+	}
 
 	return error;
 }
@@ -496,24 +509,23 @@ ti_sdhc_edma_xfer_data(struct sdhc_softc
 {
 	struct ti_sdhc_softc *sc = device_private(sdhc_sc->sc_dev);
 	const bus_dmamap_t map = cmd->c_dmamap;
-	int seg, error;
 	bool bounce;
+	int error;
 
-	for (bounce = false, seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) {
-		if ((cmd->c_dmamap->dm_segs[seg].ds_addr & 0x1f) != 0) {
+#if notyet
+	bounce = false;
+	for (int seg = 0; seg < cmd->c_dmamap->dm_nsegs; seg++) {
+		if ((cmd->c_dmamap->dm_segs[seg].ds_addr & 0x1f) != 0 ||
+		(cmd->c_dmamap->dm_segs[seg].ds_len & 3) != 0) {
 			bounce = true;
 			break;
 		}
 	}
+#else
+	bounce = true;
+#endif
 
 	if (bounce) {
-		error = bus_dmamap_load(sc->sc.sc_dmat, sc->sc_edma_dmamap,
-		sc->sc_edma_bbuf, MAXPHYS, NULL, BUS_DMA_WAITOK);
-		if (error) {
-			device_printf(sc->sc.sc_dev,
-			"[bounce] bus_dmamap_load failed: %d\n", error);
-			return error;
-		}
 		if (ISSET(cmd->c_flags, SCF_CMD_READ)) {
 			bus_dmamap_sync(sc->sc.sc_dmat, sc->sc_edma_dmamap, 0,
 			MAXPHYS, BUS_DMASYNC_PREREAD);
@@ -536,7 +548,6 @@ ti_sdhc_edma_xfer_data(struct sdhc_softc
 			bus_dmamap_sync(sc->sc.sc_dmat, sc->sc_edma_dmamap, 0,
 			MAXPHYS, BUS_DMASYNC_POSTWRITE);
 		}
-		bus_dmamap_unload(sc->sc.sc_dmat, sc->sc_edma_dmamap);
 		if (ISSET(cmd->c_flags, SCF_CMD_READ) && error == 0) {
 			memcpy(cmd->c_data, sc->sc_edma_bbuf, cmd->c_datalen);
 		}



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:03:24 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Fix inverted ti,needs-special-hs-handling property logic and enable EDMA support


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_sdhc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.3 src/sys/arch/arm/ti/ti_sdhc.c:1.4
--- src/sys/arch/arm/ti/ti_sdhc.c:1.3	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/ti_sdhc.c	Wed Nov 27 23:03:24 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.4 2019/11/27 23:03:24 jmcneill Exp $");
 
 #include 
 #include 
@@ -180,7 +180,6 @@ ti_sdhc_attach(device_t parent, device_t
 	sc->sc_addr = addr;
 	sc->sc_bst = faa->faa_bst;
 
-#if notyet
 	/* XXX use fdtbus_dma API */
 	int len;
 	const u_int *dmas = fdtbus_get_prop(phandle, "dmas", );
@@ -198,10 +197,6 @@ ti_sdhc_attach(device_t parent, device_t
 		sc->sc_edma_chan[EDMA_CHAN_RX] = -1;
 		break;
 	}
-#else
-	sc->sc_edma_chan[EDMA_CHAN_TX] = -1;
-	sc->sc_edma_chan[EDMA_CHAN_RX] = -1;
-#endif
 
 	if (bus_space_map(sc->sc_bst, addr, size, 0, >sc_bsh) != 0) {
 		aprint_error(": couldn't map registers\n");
@@ -219,7 +214,7 @@ ti_sdhc_attach(device_t parent, device_t
 		sc->sc.sc_flags |= SDHC_FLAG_8BIT_MODE;
 	if (of_hasprop(phandle, "ti,needs-special-reset"))
 		sc->sc.sc_flags |= SDHC_FLAG_WAIT_RESET;
-	if (of_hasprop(phandle, "ti,needs-special-hs-handling"))
+	if (!of_hasprop(phandle, "ti,needs-special-hs-handling"))
 		sc->sc.sc_flags |= SDHC_FLAG_NO_HS_BIT;
 	if (of_hasprop(phandle, "ti,dual-volt"))
 		sc->sc.sc_caps = SDHC_VOLTAGE_SUPP_3_0V;



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:03:24 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c

Log Message:
Fix inverted ti,needs-special-hs-handling property logic and enable EDMA support


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_sdhc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:02:54 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
Fix mmc and timer indexes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/am3_prcm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.10 src/sys/arch/arm/ti/am3_prcm.c:1.11
--- src/sys/arch/arm/ti/am3_prcm.c:1.10	Mon Nov  4 09:37:51 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Wed Nov 27 23:02:54 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.11 2019/11/27 23:02:54 jmcneill Exp $");
 
 #include 
 #include 
@@ -161,7 +161,7 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("gpio3", 0xb0, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("gpio4", 0xb4, "PERIPH_CLK"),
 
-	AM3_PRCM_HWMOD_WKUP("timer0", 0x10, "FIXED_32K"),
+	AM3_PRCM_HWMOD_WKUP("timer1", 0x10, "FIXED_32K"),
 	AM3_PRCM_HWMOD_PER("timer2", 0x80, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer3", 0x84, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer4", 0x88, "FIXED_24MHZ"),
@@ -169,9 +169,9 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"),
 	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"),
 
-	AM3_PRCM_HWMOD_PER("mmc0", 0x3c, "MMC_CLK"),
-	AM3_PRCM_HWMOD_PER("mmc1", 0xf4, "MMC_CLK"),
-	AM3_PRCM_HWMOD_PER("mmc2", 0xf8, "MMC_CLK"),
+	AM3_PRCM_HWMOD_PER("mmc1", 0x3c, "MMC_CLK"),
+	AM3_PRCM_HWMOD_PER("mmc2", 0xf4, "MMC_CLK"),
+	AM3_PRCM_HWMOD_PER("mmc3", 0xf8, "MMC_CLK"),
 
 	AM3_PRCM_HWMOD_PER("tpcc", 0xbc, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("tptc0", 0x24, "PERIPH_CLK"),



CVS commit: src/sys/arch/arm/ti

2019-11-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 27 23:02:54 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
Fix mmc and timer indexes.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/am3_prcm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 09:37:05 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c

Log Message:
Fix KERNHIST build (and simplify)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/if_cpsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Nov 24 09:37:05 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c

Log Message:
Fix KERNHIST build (and simplify)


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/if_cpsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/if_cpsw.c
diff -u src/sys/arch/arm/ti/if_cpsw.c:1.8 src/sys/arch/arm/ti/if_cpsw.c:1.9
--- src/sys/arch/arm/ti/if_cpsw.c:1.8	Sun Nov  3 10:09:04 2019
+++ src/sys/arch/arm/ti/if_cpsw.c	Sun Nov 24 09:37:05 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.8 2019/11/03 10:09:04 jmcneill Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.9 2019/11/24 09:37:05 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.8 2019/11/03 10:09:04 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.9 2019/11/24 09:37:05 skrll Exp $");
 
 #include 
 #include 
@@ -174,19 +174,14 @@ static int cpsw_ale_update_addresses(str
 CFATTACH_DECL_NEW(cpsw, sizeof(struct cpsw_softc),
 cpsw_match, cpsw_attach, cpsw_detach, NULL);
 
-#undef KERNHIST
 #include 
 KERNHIST_DEFINE(cpswhist);
 
-#ifdef KERNHIST
-#define KERNHIST_CALLED_5(NAME, i, j, k, l) \
-do { \
-	_kernhist_call = atomic_inc_uint_nv(&_kernhist_cnt); \
-	KERNHIST_LOG(NAME, "called! %x %x %x %x", i, j, k, l); \
-} while (/*CONSTCOND*/ 0)
-#else
-#define KERNHIST_CALLED_5(NAME, i, j, k, l)
-#endif
+#define CPSWHIST_CALLARGS(A,B,C,D)	do {	\
+	KERNHIST_CALLARGS(cpswhist, "%jx %jx %jx %jx",			\
+		(uintptr_t)(A), (uintptr_t)(B), (uintptr_t)(C), (uintptr_t)(D));\
+	} while (0)
+
 
 static inline u_int
 cpsw_txdesc_adjust(u_int x, int y)
@@ -219,7 +214,7 @@ cpsw_set_txdesc_next(struct cpsw_softc *
 	const bus_size_t o = sizeof(struct cpsw_cpdma_bd) * i + 0;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, n, 0);
+	CPSWHIST_CALLARGS(sc, i, n, 0);
 
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh_txdescs, o, n);
 }
@@ -230,7 +225,7 @@ cpsw_set_rxdesc_next(struct cpsw_softc *
 	const bus_size_t o = sizeof(struct cpsw_cpdma_bd) * i + 0;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, n, 0);
+	CPSWHIST_CALLARGS(sc, i, n, 0);
 
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, n);
 }
@@ -244,7 +239,7 @@ cpsw_get_txdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 
 	bus_space_read_region_4(sc->sc_bst, sc->sc_bsh_txdescs, o, dp, c);
 	KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
@@ -260,7 +255,7 @@ cpsw_set_txdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 	KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
 	dp[0], dp[1], dp[2], dp[3]);
 
@@ -276,7 +271,7 @@ cpsw_get_rxdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 
 	bus_space_read_region_4(sc->sc_bst, sc->sc_bsh_rxdescs, o, dp, c);
 
@@ -293,7 +288,7 @@ cpsw_set_rxdesc(struct cpsw_softc * cons
 	const bus_size_t c = __arraycount(bdp->word);
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, i, bdp, 0);
+	CPSWHIST_CALLARGS(sc, i, bdp, 0);
 	KERNHIST_LOG(cpswhist, "%08x %08x %08x %08x\n",
 	dp[0], dp[1], dp[2], dp[3]);
 
@@ -607,7 +602,7 @@ cpsw_start(struct ifnet *ifp)
 	u_int mlen;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
+	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
 	if (__predict_false((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) !=
 	IFF_RUNNING)) {
@@ -1140,7 +1135,7 @@ cpsw_rxintr(void *arg)
 	u_int len, off;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
+	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
 	for (;;) {
 		KASSERT(sc->sc_rxhead < CPSW_NRXDESCS);
@@ -1225,7 +1220,7 @@ cpsw_txintr(void *arg)
 	u_int cpi;
 
 	KERNHIST_FUNC(__func__);
-	KERNHIST_CALLED_5(cpswhist, sc, 0, 0, 0);
+	CPSWHIST_CALLARGS(sc, 0, 0, 0);
 
 	KASSERT(sc->sc_txrun);
 



CVS commit: src/sys/arch/arm/ti

2019-11-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov  4 09:38:39 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_lcdc.c

Log Message:
Select closest rate to desired pixel clock


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_lcdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov  4 09:38:39 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_lcdc.c

Log Message:
Select closest rate to desired pixel clock


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_lcdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_lcdc.c
diff -u src/sys/arch/arm/ti/ti_lcdc.c:1.2 src/sys/arch/arm/ti/ti_lcdc.c:1.3
--- src/sys/arch/arm/ti/ti_lcdc.c:1.2	Sun Nov  3 23:31:49 2019
+++ src/sys/arch/arm/ti/ti_lcdc.c	Mon Nov  4 09:38:38 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.2 2019/11/03 23:31:49 jmcneill Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.3 2019/11/04 09:38:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.2 2019/11/03 23:31:49 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.3 2019/11/04 09:38:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -159,8 +159,8 @@ tilcdc_mode_set(struct drm_crtc *crtc, s
 {
 	struct tilcdc_crtc *mixer_crtc = to_tilcdc_crtc(crtc);
 	struct tilcdc_softc * const sc = mixer_crtc->sc;
+	int clk_div, div, diff, best_diff;
 	uint32_t val;
-	u_int clk_div;
 
 	const u_int hspw = adjusted_mode->crtc_hsync_end - adjusted_mode->crtc_hsync_start;
 	const u_int hbp = adjusted_mode->crtc_htotal - adjusted_mode->crtc_hsync_end;
@@ -170,9 +170,16 @@ tilcdc_mode_set(struct drm_crtc *crtc, s
 	const u_int vfp = adjusted_mode->crtc_vsync_start - adjusted_mode->crtc_vdisplay;
 
 	const u_int rate = clk_get_rate(sc->sc_clk);
-	for (clk_div = 2; clk_div < 255; clk_div++) {
-		if (rate / clk_div <= (int)adjusted_mode->crtc_clock * 1000)
-			break;
+
+	clk_div = 255;
+	best_diff = -1;
+	for (div = 2; div < 255; div++) {
+		const int pixel_clock = (rate / div) / 1000;
+		diff = abs(adjusted_mode->crtc_clock - pixel_clock);
+		if (best_diff == -1 || diff < best_diff) {
+			best_diff = diff;
+			clk_div = div;
+		}
 	}
 	if (clk_div == 255) {
 		device_printf(sc->sc_dev, "couldn't configure pixel clock (%u)\n",



CVS commit: src/sys/arch/arm/ti

2019-11-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov  4 09:37:51 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
Use 297MHz for display clock


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/ti/am3_prcm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Nov  4 09:37:51 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
Use 297MHz for display clock


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/ti/am3_prcm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.9 src/sys/arch/arm/ti/am3_prcm.c:1.10
--- src/sys/arch/arm/ti/am3_prcm.c:1.9	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Mon Nov  4 09:37:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.9 2019/11/03 22:59:06 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.9 2019/11/03 22:59:06 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.10 2019/11/04 09:37:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -52,7 +52,6 @@ __KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v
 #define	AM3_PRCM_CLKCTRL_MODULEMODE		__BITS(1,0)
 #define	AM3_PRCM_CLKCTRL_MODULEMODE_ENABLE	0x2
 
-/* WKUP */
 #define	AM3_PRCM_CM_IDLEST_DPLL_DISP	(AM3_PRCM_CM_WKUP + 0x48)
 #define	 AM3_PRCM_CM_IDLEST_DPLL_DISP_ST_MN_BYPASS	__BIT(8)
 #define	 AM3_PRCM_CM_IDLEST_DPLL_DISP_ST_DPLL_CLK	__BIT(0)
@@ -64,6 +63,8 @@ __KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v
 #define	  AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN_MN_BYPASS	4
 #define	  AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN_LOCK		7
 
+#define	DPLL_DISP_RATE29700
+
 static int am3_prcm_match(device_t, cfdata_t, void *);
 static void am3_prcm_attach(device_t, device_t, void *);
 
@@ -100,8 +101,8 @@ am3_prcm_hwmod_enable_display(struct ti_
 			delay(10);
 		}
 
-		/* Set DPLL frequency to 270 MHz */
-		val = __SHIFTIN(270, AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_MULT);
+		/* Set DPLL frequency to DPLL_DISP_RATE (297 MHz) */
+		val = __SHIFTIN(DPLL_DISP_RATE / 100, AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_MULT);
 		val |= __SHIFTIN(24 - 1, AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_DIV);
 		PRCM_WRITE(sc, AM3_PRCM_CM_CLKSEL_DPLL_DISP, val);
 
@@ -141,7 +142,7 @@ static struct ti_prcm_clk am3_prcm_clks[
 	TI_PRCM_FIXED("FIXED_24MHZ", 2400),
 	TI_PRCM_FIXED("FIXED_48MHZ", 4800),
 	TI_PRCM_FIXED("FIXED_96MHZ", 9600),
-	TI_PRCM_FIXED("DISPLAY_CLK", 27000),
+	TI_PRCM_FIXED("DISPLAY_CLK", DPLL_DISP_RATE),
 	TI_PRCM_FIXED_FACTOR("PERIPH_CLK", 1, 1, "FIXED_48MHZ"),
 	TI_PRCM_FIXED_FACTOR("MMC_CLK", 1, 1, "FIXED_96MHZ"),
 



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 23:31:49 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_lcdc.c

Log Message:
Comment out mode fixup (not needed it seems)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_lcdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 23:31:49 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_lcdc.c

Log Message:
Comment out mode fixup (not needed it seems)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_lcdc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_lcdc.c
diff -u src/sys/arch/arm/ti/ti_lcdc.c:1.1 src/sys/arch/arm/ti/ti_lcdc.c:1.2
--- src/sys/arch/arm/ti/ti_lcdc.c:1.1	Sun Nov  3 22:59:06 2019
+++ src/sys/arch/arm/ti/ti_lcdc.c	Sun Nov  3 23:31:49 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_lcdc.c,v 1.1 2019/11/03 22:59:06 jmcneill Exp $ */
+/* $NetBSD: ti_lcdc.c,v 1.2 2019/11/03 23:31:49 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared D. McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.1 2019/11/03 22:59:06 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_lcdc.c,v 1.2 2019/11/03 23:31:49 jmcneill Exp $");
 
 #include 
 #include 
@@ -138,6 +138,7 @@ static bool
 tilcdc_mode_fixup(struct drm_crtc *crtc,
 const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode)
 {
+#if 0
 	adjusted_mode->hskew = mode->hsync_end - mode->hsync_start;
 	adjusted_mode->flags |= DRM_MODE_FLAG_HSKEW;
 
@@ -146,7 +147,7 @@ tilcdc_mode_fixup(struct drm_crtc *crtc,
 		adjusted_mode->flags |= DRM_MODE_FLAG_PHSYNC;
 	else
 		adjusted_mode->flags |= DRM_MODE_FLAG_NHSYNC;
-		
+#endif
 
 	return true;
 }



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 22:59:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_fb.c ti_lcdc.c ti_lcdc.h ti_lcdcreg.h

Log Message:
Add support for AM335x display controller (LCDC).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_fb.c \
src/sys/arch/arm/ti/ti_lcdc.c src/sys/arch/arm/ti/ti_lcdc.h \
src/sys/arch/arm/ti/ti_lcdcreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.8 src/sys/arch/arm/ti/am3_prcm.c:1.9
--- src/sys/arch/arm/ti/am3_prcm.c:1.8	Wed Oct 30 21:40:04 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Sun Nov  3 22:59:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.8 2019/10/30 21:40:04 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.9 2019/11/03 22:59:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.8 2019/10/30 21:40:04 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.9 2019/11/03 22:59:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -52,6 +52,18 @@ __KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v
 #define	AM3_PRCM_CLKCTRL_MODULEMODE		__BITS(1,0)
 #define	AM3_PRCM_CLKCTRL_MODULEMODE_ENABLE	0x2
 
+/* WKUP */
+#define	AM3_PRCM_CM_IDLEST_DPLL_DISP	(AM3_PRCM_CM_WKUP + 0x48)
+#define	 AM3_PRCM_CM_IDLEST_DPLL_DISP_ST_MN_BYPASS	__BIT(8)
+#define	 AM3_PRCM_CM_IDLEST_DPLL_DISP_ST_DPLL_CLK	__BIT(0)
+#define	AM3_PRCM_CM_CLKSEL_DPLL_DISP	(AM3_PRCM_CM_WKUP + 0x54)
+#define	 AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_MULT		__BITS(18,8)
+#define	 AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_DIV		__BITS(6,0)
+#define	AM3_PRCM_CM_CLKMODE_DPLL_DISP	(AM3_PRCM_CM_WKUP + 0x98)
+#define	 AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN		__BITS(2,0)
+#define	  AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN_MN_BYPASS	4
+#define	  AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN_LOCK		7
+
 static int am3_prcm_match(device_t, cfdata_t, void *);
 static void am3_prcm_attach(device_t, device_t, void *);
 
@@ -70,8 +82,48 @@ am3_prcm_hwmod_enable(struct ti_prcm_sof
 	return 0;
 }
 
+static int
+am3_prcm_hwmod_enable_display(struct ti_prcm_softc *sc, struct ti_prcm_clk *tc, int enable)
+{
+	uint32_t val;
+	int retry;
+
+	if (enable) {
+		/* Put the DPLL in MN bypass mode */
+		PRCM_WRITE(sc, AM3_PRCM_CM_CLKMODE_DPLL_DISP,
+		__SHIFTIN(AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN_MN_BYPASS,
+			  AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN));
+		for (retry = 1; retry > 0; retry--) {
+			val = PRCM_READ(sc, AM3_PRCM_CM_IDLEST_DPLL_DISP);
+			if ((val & AM3_PRCM_CM_IDLEST_DPLL_DISP_ST_MN_BYPASS) != 0)
+break;
+			delay(10);
+		}
+
+		/* Set DPLL frequency to 270 MHz */
+		val = __SHIFTIN(270, AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_MULT);
+		val |= __SHIFTIN(24 - 1, AM3_PRCM_CM_CLKSEL_DPLL_DISP_DPLL_DIV);
+		PRCM_WRITE(sc, AM3_PRCM_CM_CLKSEL_DPLL_DISP, val);
+
+		/* Disable MN bypass mode */
+		PRCM_WRITE(sc, AM3_PRCM_CM_CLKMODE_DPLL_DISP,
+		__SHIFTIN(AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN_LOCK,
+			  AM3_PRCM_CM_CLKMODE_DPLL_DISP_DPLL_EN));
+		for (retry = 1; retry > 0; retry--) {
+			val = PRCM_READ(sc, AM3_PRCM_CM_IDLEST_DPLL_DISP);
+			if ((val & AM3_PRCM_CM_IDLEST_DPLL_DISP_ST_DPLL_CLK) != 0)
+break;
+			delay(10);
+		}
+	}
+
+	return am3_prcm_hwmod_enable(sc, tc, enable);
+}
+
 #define	AM3_PRCM_HWMOD_PER(_name, _reg, _parent)	\
 	TI_PRCM_HWMOD((_name), AM3_PRCM_CM_PER + (_reg), (_parent), am3_prcm_hwmod_enable)
+#define	AM3_PRCM_HWMOD_PER_DISP(_name, _reg, _parent)	\
+	TI_PRCM_HWMOD((_name), AM3_PRCM_CM_PER + (_reg), (_parent), am3_prcm_hwmod_enable_display)
 #define	AM3_PRCM_HWMOD_WKUP(_name, _reg, _parent)	\
 	TI_PRCM_HWMOD((_name), AM3_PRCM_CM_WKUP + (_reg), (_parent), am3_prcm_hwmod_enable)
 
@@ -89,6 +141,7 @@ static struct ti_prcm_clk am3_prcm_clks[
 	TI_PRCM_FIXED("FIXED_24MHZ", 2400),
 	TI_PRCM_FIXED("FIXED_48MHZ", 4800),
 	TI_PRCM_FIXED("FIXED_96MHZ", 9600),
+	TI_PRCM_FIXED("DISPLAY_CLK", 27000),
 	TI_PRCM_FIXED_FACTOR("PERIPH_CLK", 1, 1, "FIXED_48MHZ"),
 	TI_PRCM_FIXED_FACTOR("MMC_CLK", 1, 1, "FIXED_96MHZ"),
 
@@ -127,6 +180,8 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("usb_otg_hs", 0x1c, "PERIPH_CLK"),
 
 	AM3_PRCM_HWMOD_PER("rng", 0x90, "PERIPH_CLK"),
+
+	AM3_PRCM_HWMOD_PER_DISP("lcdc", 0x18, "DISPLAY_CLK"),
 };
 
 static int

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.19 src/sys/arch/arm/ti/files.ti:1.20
--- src/sys/arch/arm/ti/files.ti:1.19	Fri Nov  1 11:53:35 2019
+++ src/sys/arch/arm/ti/files.ti	Sun Nov  3 22:59:06 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.19 2019/11/01 11:53:35 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.20 2019/11/03 22:59:06 

CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 22:59:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_fb.c ti_lcdc.c ti_lcdc.h ti_lcdcreg.h

Log Message:
Add support for AM335x display controller (LCDC).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_fb.c \
src/sys/arch/arm/ti/ti_lcdc.c src/sys/arch/arm/ti/ti_lcdc.h \
src/sys/arch/arm/ti/ti_lcdcreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 13:45:57 UTC 2019

Modified Files:
src/sys/arch/arm/ti: omap2_nand.c

Log Message:
Also match ti,omap2-onenand


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/omap2_nand.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 13:45:57 UTC 2019

Modified Files:
src/sys/arch/arm/ti: omap2_nand.c

Log Message:
Also match ti,omap2-onenand


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/omap2_nand.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/omap2_nand.c
diff -u src/sys/arch/arm/ti/omap2_nand.c:1.1 src/sys/arch/arm/ti/omap2_nand.c:1.2
--- src/sys/arch/arm/ti/omap2_nand.c:1.1	Fri Nov  1 11:53:35 2019
+++ src/sys/arch/arm/ti/omap2_nand.c	Sun Nov  3 13:45:57 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: omap2_nand.c,v 1.1 2019/11/01 11:53:35 jmcneill Exp $	*/
+/*	$NetBSD: omap2_nand.c,v 1.2 2019/11/03 13:45:57 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: omap2_nand.c,v 1.1 2019/11/01 11:53:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2_nand.c,v 1.2 2019/11/03 13:45:57 jmcneill Exp $");
 
 /* TODO move to opt_* */
 #undef OMAP2_NAND_HARDWARE_ECC
@@ -126,6 +126,7 @@ struct omap2_nand_softc {
 
 static const char * compatible[] = {
 	"ti,omap2-nand",
+	"ti,omap2-onenand",
 	NULL
 };
 



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 11:34:40 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_gpio.c

Log Message:
Add support for GPIO interrupts and fix reading the state of output pins.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_gpio.c
diff -u src/sys/arch/arm/ti/ti_gpio.c:1.2 src/sys/arch/arm/ti/ti_gpio.c:1.3
--- src/sys/arch/arm/ti/ti_gpio.c:1.2	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/ti_gpio.c	Sun Nov  3 11:34:40 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_gpio.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $ */
+/* $NetBSD: ti_gpio.c,v 1.3 2019/11/03 11:34:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.3 2019/11/03 11:34:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -44,27 +44,87 @@ __KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 
 
 #include 
 
-#define	GPIO_OE0x34
-#define	GPIO_DATAIN			0x38
-#define	GPIO_CLEARDATAOUT		0x90
-#define	GPIO_SETDATAOUT			0x94
+#define	TI_GPIO_NPINS			32
+
+enum ti_gpio_type {
+	TI_GPIO_OMAP3,
+	TI_GPIO_OMAP4,
+	TI_NGPIO
+};
+
+enum {
+	GPIO_IRQSTATUS1,
+	GPIO_IRQENABLE1,	/* OMAP3 */
+	GPIO_IRQENABLE1_SET,	/* OMAP4 */
+	GPIO_IRQENABLE1_CLR,	/* OMAP4 */
+	GPIO_OE,
+	GPIO_DATAIN,
+	GPIO_DATAOUT,
+	GPIO_LEVELDETECT0,
+	GPIO_LEVELDETECT1,
+	GPIO_RISINGDETECT,
+	GPIO_FALLINGDETECT,
+	GPIO_CLEARDATAOUT,
+	GPIO_SETDATAOUT,
+	GPIO_NREG
+};
+
+static const u_int ti_gpio_regmap[TI_NGPIO][GPIO_NREG] = {
+	[TI_GPIO_OMAP3] = {
+		[GPIO_IRQSTATUS1]	= 0x18,
+		[GPIO_IRQENABLE1]	= 0x1c,
+		[GPIO_OE]		= 0x34,
+		[GPIO_DATAIN]		= 0x38,
+		[GPIO_DATAOUT]		= 0x3c,
+		[GPIO_LEVELDETECT0]	= 0x40,
+		[GPIO_LEVELDETECT1]	= 0x44,
+		[GPIO_RISINGDETECT]	= 0x48,
+		[GPIO_FALLINGDETECT]	= 0x4c,
+		[GPIO_CLEARDATAOUT]	= 0x90,
+		[GPIO_SETDATAOUT]	= 0x94,
+	},
+	[TI_GPIO_OMAP4] = {
+		[GPIO_IRQSTATUS1]	= 0x2c,
+		[GPIO_IRQENABLE1_SET]	= 0x34,
+		[GPIO_IRQENABLE1_CLR]	= 0x38,
+		[GPIO_OE]		= 0x134,
+		[GPIO_DATAIN]		= 0x138,
+		[GPIO_DATAOUT]		= 0x13c,
+		[GPIO_LEVELDETECT0]	= 0x140,
+		[GPIO_LEVELDETECT1]	= 0x144,
+		[GPIO_RISINGDETECT]	= 0x148,
+		[GPIO_FALLINGDETECT]	= 0x14c,
+		[GPIO_CLEARDATAOUT]	= 0x190,
+		[GPIO_SETDATAOUT]	= 0x194,
+	},
+};
 
 static const struct of_compat_data compat_data[] = {
-	/* compatible			reg offset */
-	{ "ti,omap3-gpio",		0x0 },
-	{ "ti,omap4-gpio",		0x100 },
+	{ "ti,omap3-gpio",		TI_GPIO_OMAP3 },
+	{ "ti,omap4-gpio",		TI_GPIO_OMAP4 },
 	{ NULL }
 };
 
+struct ti_gpio_intr {
+	u_int intr_pin;
+	int (*intr_func)(void *);
+	void *intr_arg;
+	bool intr_mpsafe;
+};
+
 struct ti_gpio_softc {
 	device_t sc_dev;
 	bus_space_tag_t sc_bst;
 	bus_space_handle_t sc_bsh;
 	kmutex_t sc_lock;
-	bus_size_t sc_regoff;
+	enum ti_gpio_type sc_type;
+	const char *sc_modname;
+	void *sc_ih;
 
 	struct gpio_chipset_tag sc_gp;
-	gpio_pin_t sc_pins[32];
+	gpio_pin_t sc_pins[TI_GPIO_NPINS];
+	bool sc_pinout[TI_GPIO_NPINS];
+	struct ti_gpio_intr sc_intr[TI_GPIO_NPINS];
 	device_t sc_gpiodev;
 };
 
@@ -76,9 +136,9 @@ struct ti_gpio_pin {
 };
 
 #define RD4(sc, reg) 		\
-bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg) + (sc)->sc_regoff)
+bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, ti_gpio_regmap[(sc)->sc_type][(reg)])
 #define WR4(sc, reg, val) 	\
-bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg) + (sc)->sc_regoff, (val))
+bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, ti_gpio_regmap[(sc)->sc_type][(reg)], (val))
 
 static int	ti_gpio_match(device_t, cfdata_t, void *);
 static void	ti_gpio_attach(device_t, device_t, void *);
@@ -100,6 +160,8 @@ ti_gpio_ctl(struct ti_gpio_softc *sc, u_
 		oe &= ~__BIT(pin);
 	WR4(sc, GPIO_OE, oe);
 
+	sc->sc_pinout[pin] = (flags & GPIO_PIN_OUTPUT) != 0;
+
 	return 0;
 }
 
@@ -162,7 +224,10 @@ ti_gpio_read(device_t dev, void *priv, b
 	const uint32_t data_mask = __BIT(pin->pin_nr);
 
 	/* No lock required for reads */
-	data = RD4(sc, GPIO_DATAIN);
+	if (sc->sc_pinout[pin->pin_nr])
+		data = RD4(sc, GPIO_DATAOUT);
+	else
+		data = RD4(sc, GPIO_DATAIN);
 	val = __SHIFTOUT(data, data_mask);
 	if (!raw && pin->pin_actlo)
 		val = !val;
@@ -195,6 +260,126 @@ static struct fdtbus_gpio_controller_fun
 	.write = ti_gpio_write,
 };
 
+static void
+ti_gpio_intr_disestablish(device_t dev, void *ih)
+{
+	struct ti_gpio_softc * const sc = device_private(dev);
+	struct ti_gpio_intr *intr = ih;
+	const u_int pin = intr->intr_pin;
+	const uint32_t pin_mask = __BIT(pin);
+	uint32_t val;
+
+	/* Disable interrupts */
+	if (sc->sc_type == TI_GPIO_OMAP3) {
+		val = RD4(sc, GPIO_IRQENABLE1);
+		WR4(sc, GPIO_IRQENABLE1, val & ~pin_mask);
+	} else {
+		WR4(sc, GPIO_IRQENABLE1_CLR, pin_mask);
+	}
+
+	intr->intr_func = NULL;
+	intr->intr_arg 

CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 11:34:40 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_gpio.c

Log Message:
Add support for GPIO interrupts and fix reading the state of output pins.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 10:09:04 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c
Added Files:
src/sys/arch/arm/ti: if_cpswreg.h

Log Message:
Cleanup and remove dependency on arch/arm/omap


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/if_cpsw.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/if_cpswreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/if_cpsw.c
diff -u src/sys/arch/arm/ti/if_cpsw.c:1.7 src/sys/arch/arm/ti/if_cpsw.c:1.8
--- src/sys/arch/arm/ti/if_cpsw.c:1.7	Sun Oct 27 23:25:38 2019
+++ src/sys/arch/arm/ti/if_cpsw.c	Sun Nov  3 10:09:04 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.7 2019/10/27 23:25:38 jmcneill Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.8 2019/11/03 10:09:04 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.7 2019/10/27 23:25:38 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.8 2019/11/03 10:09:04 jmcneill Exp $");
 
 #include 
 #include 
@@ -73,14 +73,11 @@ __KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 
 #include 
 #include 
 
-#if 0
-#include 
-#else
 #include 
-#endif
-#include 
-#include 
-#include 
+
+#include 
+
+#define FDT_INTR_FLAGS	0
 
 #define CPSW_TXFRAGS	16
 
@@ -470,22 +467,10 @@ cpsw_attach(device_t parent, device_t se
 		memcpy(sc->sc_enaddr, macaddr, ETHER_ADDR_LEN);
 	}
 
-#if 0
-	sc->sc_rxthih = intr_establish(oa->obio_intrbase + CPSW_INTROFF_RXTH,
-	IPL_VM, IST_LEVEL, cpsw_rxthintr, sc);
-	sc->sc_rxih = intr_establish(oa->obio_intrbase + CPSW_INTROFF_RX,
-	IPL_VM, IST_LEVEL, cpsw_rxintr, sc);
-	sc->sc_txih = intr_establish(oa->obio_intrbase + CPSW_INTROFF_TX,
-	IPL_VM, IST_LEVEL, cpsw_txintr, sc);
-	sc->sc_miscih = intr_establish(oa->obio_intrbase + CPSW_INTROFF_MISC,
-	IPL_VM, IST_LEVEL, cpsw_miscintr, sc);
-#else
-#define FDT_INTR_FLAGS 0
 	sc->sc_rxthih = fdtbus_intr_establish(phandle, CPSW_INTROFF_RXTH, IPL_VM, FDT_INTR_FLAGS, cpsw_rxthintr, sc);
 	sc->sc_rxih = fdtbus_intr_establish(phandle, CPSW_INTROFF_RX, IPL_VM, FDT_INTR_FLAGS, cpsw_rxintr, sc);
 	sc->sc_txih = fdtbus_intr_establish(phandle, CPSW_INTROFF_TX, IPL_VM, FDT_INTR_FLAGS, cpsw_txintr, sc);
 	sc->sc_miscih = fdtbus_intr_establish(phandle, CPSW_INTROFF_MISC, IPL_VM, FDT_INTR_FLAGS, cpsw_miscintr, sc);
-#endif
 
 	sc->sc_bst = faa->faa_bst;
 	sc->sc_bss = size;
@@ -590,19 +575,6 @@ cpsw_attach(device_t parent, device_t se
 		ifmedia_set(>mii_media, IFM_ETHER | IFM_MANUAL);
 	} else {
 		sc->sc_phy_has_1000t = cpsw_phy_has_1000t(sc);
-		if (sc->sc_phy_has_1000t) {
-#if 0
-			aprint_normal_dev(sc->sc_dev, "1000baseT PHY found. "
-			"Setting RGMII Mode\n");
-			/*
-			 * Select the Interface RGMII Mode in the Control
-			 * Module
-			 */
-			sitara_cm_reg_write_4(CPSW_GMII_SEL,
-			GMIISEL_GMII2_SEL(RGMII_MODE) |
-			GMIISEL_GMII1_SEL(RGMII_MODE));
-#endif
-		}
 
 		ifmedia_set(>mii_media, IFM_ETHER | IFM_AUTO);
 	}

Added files:

Index: src/sys/arch/arm/ti/if_cpswreg.h
diff -u /dev/null src/sys/arch/arm/ti/if_cpswreg.h:1.1
--- /dev/null	Sun Nov  3 10:09:04 2019
+++ src/sys/arch/arm/ti/if_cpswreg.h	Sun Nov  3 10:09:04 2019
@@ -0,0 +1,238 @@
+/*-
+ * Copyright (c) 2012 Damjan Marion 
+ * 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 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 AUTHOR 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef	_IF_CPSWREG_H
+#define	_IF_CPSWREG_H
+
+#define CPSW_ETH_PORTS			2
+#define CPSW_CPPI_PORTS			1
+
+#define CPSW_SS_OFFSET			0x
+#define CPSW_SS_IDVER			(CPSW_SS_OFFSET + 0x00)
+#define CPSW_SS_SOFT_RESET		(CPSW_SS_OFFSET + 0x08)

CVS commit: src/sys/arch/arm/ti

2019-11-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov  3 10:09:04 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c
Added Files:
src/sys/arch/arm/ti: if_cpswreg.h

Log Message:
Cleanup and remove dependency on arch/arm/omap


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/if_cpsw.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/if_cpswreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov  1 11:53:35 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti omap3_cm.c
Added Files:
src/sys/arch/arm/ti: omap2_gpmcreg.h omap2_nand.c ti_gpmc.c

Log Message:
Add NAND flash support.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/omap2_gpmcreg.h \
src/sys/arch/arm/ti/omap2_nand.c src/sys/arch/arm/ti/ti_gpmc.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/omap3_cm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov  1 11:53:35 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti omap3_cm.c
Added Files:
src/sys/arch/arm/ti: omap2_gpmcreg.h omap2_nand.c ti_gpmc.c

Log Message:
Add NAND flash support.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/omap2_gpmcreg.h \
src/sys/arch/arm/ti/omap2_nand.c src/sys/arch/arm/ti/ti_gpmc.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/omap3_cm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.18 src/sys/arch/arm/ti/files.ti:1.19
--- src/sys/arch/arm/ti/files.ti:1.18	Thu Oct 31 17:08:54 2019
+++ src/sys/arch/arm/ti/files.ti	Fri Nov  1 11:53:35 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.18 2019/10/31 17:08:54 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.19 2019/11/01 11:53:35 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_cpufreq.c	soc_ti
@@ -112,6 +112,16 @@ device	omapfb: rasops16, rasops8, wsemul
 attach	omapfb at fdt with omap3_dss
 file	arch/arm/ti/omap3_dss.c		omap3_dss
 
+# Memory controller
+device	tigpmc { } : fdt
+attach	tigpmc at fdt with ti_gpmc
+file	arch/arm/ti/ti_gpmc.c		ti_gpmc
+
+# NAND flash controller
+device	omapnand: nandbus
+attach	omapnand at fdt
+file	arch/arm/ti/omap2_nand.c	omapnand
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_AM33XX: SOC_TI

Index: src/sys/arch/arm/ti/omap3_cm.c
diff -u src/sys/arch/arm/ti/omap3_cm.c:1.3 src/sys/arch/arm/ti/omap3_cm.c:1.4
--- src/sys/arch/arm/ti/omap3_cm.c:1.3	Thu Oct 31 01:05:06 2019
+++ src/sys/arch/arm/ti/omap3_cm.c	Fri Nov  1 11:53:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_cm.c,v 1.3 2019/10/31 01:05:06 jmcneill Exp $ */
+/* $NetBSD: omap3_cm.c,v 1.4 2019/11/01 11:53:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v 1.3 2019/10/31 01:05:06 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v 1.4 2019/11/01 11:53:35 jmcneill Exp $");
 
 #include 
 #include 
@@ -55,6 +55,12 @@ static int omap3_cm_match(device_t, cfda
 static void omap3_cm_attach(device_t, device_t, void *);
 
 static int
+omap3_cm_hwmod_nopenable(struct ti_prcm_softc *sc, struct ti_prcm_clk *tc, int enable)
+{
+	return 0;
+}
+
+static int
 omap3_cm_hwmod_enable(struct ti_prcm_softc *sc, struct ti_prcm_clk *tc, int enable)
 {
 	uint32_t val;
@@ -92,6 +98,8 @@ omap3_cm_hwmod_enable(struct ti_prcm_sof
 	TI_PRCM_HWMOD_MASK((_name), CM_PER_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
 #define	OMAP3_CM_HWMOD_USBHOST(_name, _bit, _parent, _flags)	\
 	TI_PRCM_HWMOD_MASK((_name), CM_USBHOST_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
+#define	OMAP3_CM_HWMOD_NOP(_name, _parent)			\
+	TI_PRCM_HWMOD_MASK((_name), 0, 0, (_parent), omap3_cm_hwmod_nopenable, 0)
 
 static const char * const compatible[] = {
 	"ti,omap3-cm",
@@ -154,6 +162,8 @@ static struct ti_prcm_clk omap3_cm_clks[
 	OMAP3_CM_HWMOD_PER("gpio6", 17, "PERIPH_CLK", 0),
 
 	OMAP3_CM_HWMOD_USBHOST("usb_host_hs", 0, "PERIPH_CLK", 0),
+
+	OMAP3_CM_HWMOD_NOP("gpmc", "PERIPH_CLK"),
 };
 
 static void

Added files:

Index: src/sys/arch/arm/ti/omap2_gpmcreg.h
diff -u /dev/null src/sys/arch/arm/ti/omap2_gpmcreg.h:1.1
--- /dev/null	Fri Nov  1 11:53:35 2019
+++ src/sys/arch/arm/ti/omap2_gpmcreg.h	Fri Nov  1 11:53:35 2019
@@ -0,0 +1,236 @@
+/*	$NetBSD: omap2_gpmcreg.h,v 1.1 2019/11/01 11:53:35 jmcneill Exp $	*/
+/*
+ * Copyright (c) 2007 Microsoft
+ * 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. All advertising materials mentioning features or use of this software
+ *must display the following acknowledgement:
+ *	This product includes software developed by Microsoft
+ *
+ * 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 OR CONTRIBUTERS 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 

CVS commit: src/sys/arch/arm/ti

2019-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov  1 09:49:22 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_iic.c

Log Message:
Enable IRQ status bits for omap3 type and set speed properly


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_iic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_iic.c
diff -u src/sys/arch/arm/ti/ti_iic.c:1.3 src/sys/arch/arm/ti/ti_iic.c:1.4
--- src/sys/arch/arm/ti/ti_iic.c:1.3	Thu Oct 31 10:21:29 2019
+++ src/sys/arch/arm/ti/ti_iic.c	Fri Nov  1 09:49:21 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_iic.c,v 1.3 2019/10/31 10:21:29 jmcneill Exp $ */
+/* $NetBSD: ti_iic.c,v 1.4 2019/11/01 09:49:21 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.3 2019/10/31 10:21:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.4 2019/11/01 09:49:21 jmcneill Exp $");
 
 #include 
 #include 
@@ -176,6 +176,7 @@ struct ti_iic_softc {
 	kmutex_t		sc_mtx;
 	kcondvar_t		sc_cv;
 	ti_i2cop_t		sc_op;
+	int			sc_opflags;
 	int			sc_buflen;
 	int			sc_bufidx;
 	char			*sc_buf;
@@ -308,14 +309,16 @@ ti_iic_intr(void *arg)
 	uint32_t stat;
 
 	mutex_enter(>sc_mtx);
-	DPRINTF(("ti_iic_intr\n"));
-	stat = I2C_READ_REG(sc, I2C_IRQSTATUS);
-	DPRINTF(("ti_iic_intr pre handle sc->sc_op eq %#x\n", sc->sc_op));
-	ti_iic_handle_intr(sc, stat);
-	I2C_WRITE_REG(sc, I2C_IRQSTATUS, stat);
-	if (sc->sc_op == TI_I2CERROR || sc->sc_op == TI_I2CDONE) {
-		DPRINTF(("ti_iic_intr post handle sc->sc_op %#x\n", sc->sc_op));
-		cv_broadcast(>sc_cv);
+	DPRINTF(("ti_iic_intr opflags=%#x\n", sc->sc_opflags));
+	if ((sc->sc_opflags & I2C_F_POLL) == 0) {
+		stat = I2C_READ_REG(sc, I2C_IRQSTATUS);
+		DPRINTF(("ti_iic_intr pre handle sc->sc_op eq %#x\n", sc->sc_op));
+		ti_iic_handle_intr(sc, stat);
+		I2C_WRITE_REG(sc, I2C_IRQSTATUS, stat);
+		if (sc->sc_op == TI_I2CERROR || sc->sc_op == TI_I2CDONE) {
+			DPRINTF(("ti_iic_intr post handle sc->sc_op %#x\n", sc->sc_op));
+			cv_broadcast(>sc_cv);
+		}
 	}
 	mutex_exit(>sc_mtx);
 	DPRINTF(("ti_iic_intr status 0x%x\n", stat));
@@ -423,9 +426,14 @@ ti_iic_reset(struct ti_iic_softc *sc)
 
 
 	/* XXX standard speed only */
-	psc = 3;
-	scll = 53;
-	sclh = 55;
+	if (sc->sc_type == TI_IIC_OMAP3) {
+		psc = (9600 / 1920) - 1;
+		scll = sclh = (1920 / (2 * 10)) - 6;
+	} else {
+		psc = 3;
+		scll = 53;
+		sclh = 55;
+	}
 
 	/* Clocks */
 	I2C_WRITE_REG(sc, I2C_PSC, psc);
@@ -481,6 +489,7 @@ ti_iic_op(struct ti_iic_softc *sc, i2c_a
 
 	mutex_enter(>sc_mtx);
 	sc->sc_op = op;
+	sc->sc_opflags = flags;
 	sc->sc_buf = buf;
 	sc->sc_buflen = buflen;
 	sc->sc_bufidx = 0;
@@ -491,7 +500,7 @@ ti_iic_op(struct ti_iic_softc *sc, i2c_a
 	I2C_WRITE_REG(sc, I2C_SA, (addr & I2C_SA_MASK));
 	DPRINTF(("SA 0x%x len %d\n", I2C_READ_REG(sc, I2C_SA), I2C_READ_REG(sc, I2C_CNT)));
 
-	if ((flags & I2C_F_POLL) == 0) {
+	if ((flags & I2C_F_POLL) == 0 || sc->sc_type == TI_IIC_OMAP3) {
 		/* clear any pending interrupt */
 		I2C_WRITE_REG(sc, I2C_IRQSTATUS,
 		I2C_READ_REG(sc, I2C_IRQSTATUS));



CVS commit: src/sys/arch/arm/ti

2019-11-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Nov  1 09:49:22 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_iic.c

Log Message:
Enable IRQ status bits for omap3 type and set speed properly


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_iic.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-31 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 31 10:21:29 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_iic.c ti_iicreg.h

Log Message:
Handle different register layout on OMAP3


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_iic.c \
src/sys/arch/arm/ti/ti_iicreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_iic.c
diff -u src/sys/arch/arm/ti/ti_iic.c:1.2 src/sys/arch/arm/ti/ti_iic.c:1.3
--- src/sys/arch/arm/ti/ti_iic.c:1.2	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/ti_iic.c	Thu Oct 31 10:21:29 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_iic.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $ */
+/* $NetBSD: ti_iic.c,v 1.3 2019/10/31 10:21:29 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
@@ -50,7 +50,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1.3 2019/10/31 10:21:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -81,10 +81,75 @@ __KERNEL_RCSID(0, "$NetBSD: ti_iic.c,v 1
 #define DPRINTF(args)
 #endif
 
+enum ti_iic_type {
+	TI_IIC_OMAP3,
+	TI_IIC_OMAP4,
+	TI_NTYPES
+};
+
+enum {
+	I2C_SYSC,
+	I2C_IRQSTATUS_RAW,
+	I2C_IRQSTATUS,
+	I2C_IRQENABLE,		/* OMAP3 */
+	I2C_IRQENABLE_SET,	/* OMAP4 */
+	I2C_IRQENABLE_CLR,	/* OMAP4 */
+	I2C_SYSS,
+	I2C_BUF,
+	I2C_CNT,
+	I2C_DATA,
+	I2C_CON,
+	I2C_OA,
+	I2C_SA,
+	I2C_PSC,
+	I2C_SCLL,
+	I2C_SCLH,
+	I2C_BUFSTAT,
+	TI_NREGS
+};
+
+static const u_int ti_iic_regmap[TI_NTYPES][TI_NREGS] = {
+	[TI_IIC_OMAP3] = {
+		[I2C_SYSC] = 0x20,
+		[I2C_IRQSTATUS_RAW] = 0x08,
+		[I2C_IRQSTATUS] = 0x08,
+		[I2C_IRQENABLE] = 0x04,
+		[I2C_SYSS] = 0x10,
+		[I2C_BUF] = 0x14,
+		[I2C_CNT] = 0x18,
+		[I2C_DATA] = 0x1c,
+		[I2C_CON] = 0x24,
+		[I2C_OA] = 0x28,
+		[I2C_SA] = 0x2c,
+		[I2C_PSC] = 0x30,
+		[I2C_SCLL] = 0x34,
+		[I2C_SCLH] = 0x38,
+		[I2C_BUFSTAT] = 0x40,
+	},
+	[TI_IIC_OMAP4] = {
+		[I2C_SYSC] = 0x10,
+		[I2C_IRQSTATUS_RAW] = 0x24,
+		[I2C_IRQSTATUS] = 0x28,
+		[I2C_IRQENABLE_SET] = 0x2c,
+		[I2C_IRQENABLE_CLR] = 0x30,
+		[I2C_SYSS] = 0x90,
+		[I2C_BUF] = 0x94,
+		[I2C_CNT] = 0x98,
+		[I2C_DATA] = 0x9c,
+		[I2C_CON] = 0xa4,
+		[I2C_OA] = 0xa8,
+		[I2C_SA] = 0xac,
+		[I2C_PSC] = 0xb0,
+		[I2C_SCLL] = 0xb4,
+		[I2C_SCLH] = 0xb8,
+		[I2C_BUFSTAT] = 0xc0,
+	},
+};
+
 static const struct of_compat_data compat_data[] = {
-	/* compatible		reg shift */
-	{ "ti,omap3-i2c",	2 },
-	{ "ti,omap4-i2c",	0 },
+	/* compatible		type */
+	{ "ti,omap3-i2c",	TI_IIC_OMAP3 },
+	{ "ti,omap4-i2c",	TI_IIC_OMAP4 },
 	{ NULL }
 };
 
@@ -105,7 +170,7 @@ struct ti_iic_softc {
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 
-	u_int			sc_reg_shift;
+	enum ti_iic_type	sc_type;
 
 	void			*sc_ih;
 	kmutex_t		sc_mtx;
@@ -122,13 +187,13 @@ struct ti_iic_softc {
 };
 
 #define I2C_READ_REG(sc, reg)		\
-	bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, (reg) << (sc)->sc_reg_shift)
+	bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, ti_iic_regmap[(sc)->sc_type][(reg)])
 #define I2C_READ_DATA(sc)		\
-	bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, OMAP2_I2C_DATA << (sc)->sc_reg_shift);
+	bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, ti_iic_regmap[(sc)->sc_type][I2C_DATA])
 #define I2C_WRITE_REG(sc, reg, val)	\
-	bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, (reg) << (sc)->sc_reg_shift, (val))
+	bus_space_write_2((sc)->sc_iot, (sc)->sc_ioh, ti_iic_regmap[(sc)->sc_type][(reg)], (val))
 #define I2C_WRITE_DATA(sc, val)		\
-	bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, OMAP2_I2C_DATA << (sc)->sc_reg_shift, (val))
+	bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, ti_iic_regmap[(sc)->sc_type][I2C_DATA], (val))
 
 static int	ti_iic_match(device_t, cfdata_t, void *);
 static void	ti_iic_attach(device_t, device_t, void *);
@@ -174,11 +239,11 @@ ti_iic_attach(device_t parent, device_t 
 	struct ti_iic_softc *sc = device_private(self);
 	struct fdt_attach_args * const faa = opaque;
 	const int phandle = faa->faa_phandle;
-	int scheme, major, minor, fifodepth, fifo;
+	int fifodepth, fifo;
+	const char *modname;
 	char intrstr[128];
 	bus_addr_t addr;
 	bus_size_t size;
-	uint16_t rev;
 
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
 		aprint_error(": couldn't get registers\n");
@@ -208,7 +273,7 @@ ti_iic_attach(device_t parent, device_t 
 		aprint_error(": couldn't map registers\n");
 		return;
 	}
-	sc->sc_reg_shift = of_search_compatible(phandle, compat_data)->data;
+	sc->sc_type = of_search_compatible(phandle, compat_data)->data;
 
 	sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0,
 	ti_iic_intr, sc);
@@ -217,23 +282,17 @@ ti_iic_attach(device_t parent, device_t 
 		return;
 	}
 
-	scheme = I2C_REVNB_HI_SCHEME(I2C_READ_REG(sc, OMAP2_I2C_REVNB_HI));
-	rev = I2C_READ_REG(sc, OMAP2_I2C_REVNB_LO);
-	if (scheme == 0) {
-		major = I2C_REV_SCHEME_0_MAJOR(rev);
-		minor = I2C_REV_SCHEME_0_MINOR(rev);
-	} else {
-		

CVS commit: src/sys/arch/arm/ti

2019-10-31 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 31 10:21:29 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_iic.c ti_iicreg.h

Log Message:
Handle different register layout on OMAP3


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_iic.c \
src/sys/arch/arm/ti/ti_iicreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 31 01:05:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: omap3_cm.c

Log Message:
Remove DPLL5 init ported from old omap code, it is not required


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/omap3_cm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/omap3_cm.c
diff -u src/sys/arch/arm/ti/omap3_cm.c:1.2 src/sys/arch/arm/ti/omap3_cm.c:1.3
--- src/sys/arch/arm/ti/omap3_cm.c:1.2	Wed Oct 30 21:41:40 2019
+++ src/sys/arch/arm/ti/omap3_cm.c	Thu Oct 31 01:05:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_cm.c,v 1.2 2019/10/30 21:41:40 jmcneill Exp $ */
+/* $NetBSD: omap3_cm.c,v 1.3 2019/10/31 01:05:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v 1.2 2019/10/30 21:41:40 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v 1.3 2019/10/31 01:05:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -43,7 +43,6 @@ __KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v
 #define	CM_CORE1_BASE		0x0a00
 #define	CM_CORE3_BASE		0x0a08
 #define	CM_WKUP_BASE		0x0c00
-#define	CM_CLK_CTRL_REG_BASE	0x0d00
 #define	CM_PER_BASE		0x1000
 #define	CM_USBHOST_BASE		0x1400
 
@@ -52,12 +51,6 @@ __KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v
 #define	CM_AUTOIDLE		0x30
 #define	CM_CLKSEL		0x40
 
-#define	CM_CLKEN2_PLL		0x04
-#define	CM_IDLEST2_CKGEN	0x24
-#define	CM_AUTOIDLE2_PLL	0x34
-#define	CM_CLKSEL4_PLL		0x4c
-#define	CM_CLKSEL5_PLL		0x50
-
 static int omap3_cm_match(device_t, cfdata_t, void *);
 static void omap3_cm_attach(device_t, device_t, void *);
 
@@ -173,15 +166,6 @@ omap3_cm_initclocks(struct ti_prcm_softc
 	val |= __BIT(0);	/* CLKSEL_GPT2  0x1: source is SYS_CLK */
 	val |= __BIT(1);	/* CLKSEL_GPT3  0x1: source is SYS_CLK */
 	PRCM_WRITE(sc, CM_PER_BASE + CM_CLKSEL, val);
-
-	/* Enable DPLL5  */
-	const u_int m = 443, n = 11, m2 = 4;
-	PRCM_WRITE(sc, CM_CLK_CTRL_REG_BASE + CM_CLKEN2_PLL, (0x4 << 4) | 0x7);
-	PRCM_WRITE(sc, CM_CLK_CTRL_REG_BASE + CM_CLKSEL4_PLL, (m << 8) | n);
-	PRCM_WRITE(sc, CM_CLK_CTRL_REG_BASE + CM_CLKSEL5_PLL, m2);
-	PRCM_WRITE(sc, CM_CLK_CTRL_REG_BASE + CM_AUTOIDLE2_PLL, 1);
-	while ((PRCM_READ(sc, CM_CLK_CTRL_REG_BASE + CM_IDLEST2_CKGEN) & 1) == 0)
-		delay(100);
 }
 
 static int



CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 31 01:05:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: omap3_cm.c

Log Message:
Remove DPLL5 init ported from old omap code, it is not required


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/omap3_cm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 30 22:21:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: omap3_platform.c

Log Message:
Fix PRM_RSTCTRL_RST_DPLL3 definition, now reset works.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/omap3_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/omap3_platform.c
diff -u src/sys/arch/arm/ti/omap3_platform.c:1.1 src/sys/arch/arm/ti/omap3_platform.c:1.2
--- src/sys/arch/arm/ti/omap3_platform.c:1.1	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/omap3_platform.c	Wed Oct 30 22:21:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_platform.c,v 1.1 2019/10/29 22:19:13 jmcneill Exp $ */
+/* $NetBSD: omap3_platform.c,v 1.2 2019/10/30 22:21:06 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: omap3_platform.c,v 1.1 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_platform.c,v 1.2 2019/10/30 22:21:06 jmcneill Exp $");
 
 #include 
 #include 
@@ -71,7 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: omap3_platfo
 #define	OMAP3_PRCM_BASE		0x48306000
 #define	OMAP3_PRCM_GR_BASE	(OMAP3_PRCM_BASE + 0x1200)
 #define	 PRM_RSTCTRL		(OMAP3_PRCM_GR_BASE + 0x50)
-#define	  PRM_RSTCTRL_RST_DPLL3	__BIT(1)
+#define	  PRM_RSTCTRL_RST_DPLL3	__BIT(2)
 
 #define	OMAP3_32KTIMER_BASE	0x4832
 #define	 REG_32KSYNCNT_CR	(OMAP3_32KTIMER_BASE + 0x10)



CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 30 22:21:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: omap3_platform.c

Log Message:
Fix PRM_RSTCTRL_RST_DPLL3 definition, now reset works.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/omap3_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 30 21:41:40 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti omap3_cm.c ti_prcm.h
Added Files:
src/sys/arch/arm/ti: ti_ehci.c ti_usb.c ti_usbtll.c

Log Message:
Add OMAP3 USB support.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/omap3_cm.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_ehci.c \
src/sys/arch/arm/ti/ti_usb.c src/sys/arch/arm/ti/ti_usbtll.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_prcm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.16 src/sys/arch/arm/ti/files.ti:1.17
--- src/sys/arch/arm/ti/files.ti:1.16	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/files.ti	Wed Oct 30 21:41:40 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.16 2019/10/29 22:19:13 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.17 2019/10/30 21:41:40 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_cpufreq.c	soc_ti
@@ -88,6 +88,17 @@ device	tiotg { } : fdt
 attach	tiotg at fdt with ti_otg
 file	arch/arm/ti/ti_otg.c		ti_otg
 
+device	tiusb { } : fdt
+attach	tiusb at fdt with ti_usb
+file	arch/arm/ti/ti_usb.c		ti_usb
+
+device	tiusbtll
+attach	tiusbtll at fdt with ti_usbtll
+file	arch/arm/ti/ti_usbtll.c		ti_usbtll
+
+attach	ehci at fdt with ti_ehci
+file	arch/arm/ti/ti_ehci.c		ti_ehci
+
 attach	motg at fdt with ti_motg
 file	arch/arm/ti/ti_motg.c		ti_motg
 

Index: src/sys/arch/arm/ti/omap3_cm.c
diff -u src/sys/arch/arm/ti/omap3_cm.c:1.1 src/sys/arch/arm/ti/omap3_cm.c:1.2
--- src/sys/arch/arm/ti/omap3_cm.c:1.1	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/omap3_cm.c	Wed Oct 30 21:41:40 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_cm.c,v 1.1 2019/10/29 22:19:13 jmcneill Exp $ */
+/* $NetBSD: omap3_cm.c,v 1.2 2019/10/30 21:41:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v 1.1 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v 1.2 2019/10/30 21:41:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -43,11 +43,20 @@ __KERNEL_RCSID(1, "$NetBSD: omap3_cm.c,v
 #define	CM_CORE1_BASE		0x0a00
 #define	CM_CORE3_BASE		0x0a08
 #define	CM_WKUP_BASE		0x0c00
+#define	CM_CLK_CTRL_REG_BASE	0x0d00
 #define	CM_PER_BASE		0x1000
 #define	CM_USBHOST_BASE		0x1400
 
 #define	CM_FCLKEN		0x00
 #define	CM_ICLKEN		0x10
+#define	CM_AUTOIDLE		0x30
+#define	CM_CLKSEL		0x40
+
+#define	CM_CLKEN2_PLL		0x04
+#define	CM_IDLEST2_CKGEN	0x24
+#define	CM_AUTOIDLE2_PLL	0x34
+#define	CM_CLKSEL4_PLL		0x4c
+#define	CM_CLKSEL5_PLL		0x50
 
 static int omap3_cm_match(device_t, cfdata_t, void *);
 static void omap3_cm_attach(device_t, device_t, void *);
@@ -71,19 +80,25 @@ omap3_cm_hwmod_enable(struct ti_prcm_sof
 		val &= ~tc->u.hwmod.mask;
 	PRCM_WRITE(sc, tc->u.hwmod.reg + CM_ICLKEN, val);
 
+	if (tc->u.hwmod.flags & TI_HWMOD_DISABLE_AUTOIDLE) {
+		val = PRCM_READ(sc, tc->u.hwmod.reg + CM_AUTOIDLE);
+		val &= ~tc->u.hwmod.mask;
+		PRCM_WRITE(sc, tc->u.hwmod.reg + CM_AUTOIDLE, val);
+	}
+
 	return 0;
 }
 
-#define	OMAP3_CM_HWMOD_CORE1(_name, _bit, _parent)	\
-	TI_PRCM_HWMOD_MASK((_name), CM_CORE1_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable)
-#define	OMAP3_CM_HWMOD_CORE3(_name, _bit, _parent)	\
-	TI_PRCM_HWMOD_MASK((_name), CM_CORE3_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable)
-#define	OMAP3_CM_HWMOD_WKUP(_name, _bit, _parent)	\
-	TI_PRCM_HWMOD_MASK((_name), CM_WKUP_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable)
-#define	OMAP3_CM_HWMOD_PER(_name, _bit, _parent)	\
-	TI_PRCM_HWMOD_MASK((_name), CM_PER_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable)
-#define	OMAP3_CM_HWMOD_USBHOST(_name, _mask, _parent)	\
-	TI_PRCM_HWMOD_MASK((_name), CM_USBHOST_BASE, (_mask), (_parent), omap3_cm_hwmod_enable)
+#define	OMAP3_CM_HWMOD_CORE1(_name, _bit, _parent, _flags)	\
+	TI_PRCM_HWMOD_MASK((_name), CM_CORE1_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
+#define	OMAP3_CM_HWMOD_CORE3(_name, _bit, _parent, _flags)	\
+	TI_PRCM_HWMOD_MASK((_name), CM_CORE3_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
+#define	OMAP3_CM_HWMOD_WKUP(_name, _bit, _parent, _flags)	\
+	TI_PRCM_HWMOD_MASK((_name), CM_WKUP_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
+#define	OMAP3_CM_HWMOD_PER(_name, _bit, _parent, _flags)	\
+	TI_PRCM_HWMOD_MASK((_name), CM_PER_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
+#define	OMAP3_CM_HWMOD_USBHOST(_name, _bit, _parent, _flags)	\
+	TI_PRCM_HWMOD_MASK((_name), CM_USBHOST_BASE, __BIT(_bit), (_parent), omap3_cm_hwmod_enable, (_flags))
 
 static const char * const compatible[] = {
 	"ti,omap3-cm",
@@ -96,59 +111,79 @@ CFATTACH_DECL_NEW(omap3_cm, sizeof(struc
 static struct ti_prcm_clk omap3_cm_clks[] = {
 	/* XXX until we get a proper clock 

CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 30 21:41:40 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti omap3_cm.c ti_prcm.h
Added Files:
src/sys/arch/arm/ti: ti_ehci.c ti_usb.c ti_usbtll.c

Log Message:
Add OMAP3 USB support.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/omap3_cm.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_ehci.c \
src/sys/arch/arm/ti/ti_usb.c src/sys/arch/arm/ti/ti_usbtll.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_prcm.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 30 21:40:04 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c ti_omaptimer.c

Log Message:
Use the hwmod clk to get the timer rate and explicitly enable the
timecounter timer.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_omaptimer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.7 src/sys/arch/arm/ti/am3_prcm.c:1.8
--- src/sys/arch/arm/ti/am3_prcm.c:1.7	Mon Oct 28 23:57:59 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Wed Oct 30 21:40:04 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.7 2019/10/28 23:57:59 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.8 2019/10/30 21:40:04 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.7 2019/10/28 23:57:59 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.8 2019/10/30 21:40:04 jmcneill Exp $");
 
 #include 
 #include 
@@ -86,6 +86,7 @@ CFATTACH_DECL_NEW(am3_prcm, sizeof(struc
 static struct ti_prcm_clk am3_prcm_clks[] = {
 	/* XXX until we get a proper clock tree */
 	TI_PRCM_FIXED("FIXED_32K", 32768),
+	TI_PRCM_FIXED("FIXED_24MHZ", 2400),
 	TI_PRCM_FIXED("FIXED_48MHZ", 4800),
 	TI_PRCM_FIXED("FIXED_96MHZ", 9600),
 	TI_PRCM_FIXED_FACTOR("PERIPH_CLK", 1, 1, "FIXED_48MHZ"),
@@ -107,12 +108,12 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("gpio4", 0xb4, "PERIPH_CLK"),
 
 	AM3_PRCM_HWMOD_WKUP("timer0", 0x10, "FIXED_32K"),
-	AM3_PRCM_HWMOD_PER("timer2", 0x80, "PERIPH_CLK"),
-	AM3_PRCM_HWMOD_PER("timer3", 0x84, "PERIPH_CLK"),
-	AM3_PRCM_HWMOD_PER("timer4", 0x88, "PERIPH_CLK"),
-	AM3_PRCM_HWMOD_PER("timer5", 0xec, "PERIPH_CLK"),
-	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "PERIPH_CLK"),
-	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("timer2", 0x80, "FIXED_24MHZ"),
+	AM3_PRCM_HWMOD_PER("timer3", 0x84, "FIXED_24MHZ"),
+	AM3_PRCM_HWMOD_PER("timer4", 0x88, "FIXED_24MHZ"),
+	AM3_PRCM_HWMOD_PER("timer5", 0xec, "FIXED_24MHZ"),
+	AM3_PRCM_HWMOD_PER("timer6", 0xf0, "FIXED_24MHZ"),
+	AM3_PRCM_HWMOD_PER("timer7", 0x7c, "FIXED_24MHZ"),
 
 	AM3_PRCM_HWMOD_PER("mmc0", 0x3c, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc1", 0xf4, "MMC_CLK"),

Index: src/sys/arch/arm/ti/ti_omaptimer.c
diff -u src/sys/arch/arm/ti/ti_omaptimer.c:1.3 src/sys/arch/arm/ti/ti_omaptimer.c:1.4
--- src/sys/arch/arm/ti/ti_omaptimer.c:1.3	Tue Oct 29 22:19:13 2019
+++ src/sys/arch/arm/ti/ti_omaptimer.c	Wed Oct 30 21:40:04 2019
@@ -1,7 +1,7 @@
-/*	$NetBSD: ti_omaptimer.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $	*/
+/*	$NetBSD: ti_omaptimer.c,v 1.4 2019/10/30 21:40:04 jmcneill Exp $	*/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.3 2019/10/29 22:19:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.4 2019/10/30 21:40:04 jmcneill Exp $");
 
 #include 
 #include 
@@ -125,6 +125,16 @@ omaptimer_get_timecount(struct timecount
 	return RD4(sc, TIMER_TCRR);
 }
 
+static void
+omaptimer_enable(struct omaptimer_softc *sc, uint32_t value)
+{
+	/* Configure the timer */
+	WR4(sc, TIMER_TLDR, value);
+	WR4(sc, TIMER_TCRR, value);
+	WR4(sc, TIMER_TIER, 0);
+	WR4(sc, TIMER_TCLR, TCLR_ST | TCLR_AR);
+}
+
 static int
 omaptimer_match(device_t parent, cfdata_t match, void *aux)
 {
@@ -141,8 +151,10 @@ omaptimer_attach(device_t parent, device
 	const int phandle = faa->faa_phandle;
 	struct timecounter *tc = >sc_tc;
 	const char *modname;
+	struct clk *hwmod;
 	bus_addr_t addr;
 	bus_size_t size;
+	u_int rate;
 
 	if (fdtbus_get_reg(phandle, 0, , ) != 0) {
 		aprint_error(": couldn't get registers\n");
@@ -159,7 +171,8 @@ omaptimer_attach(device_t parent, device
 		return;
 	}
 
-	if (ti_prcm_enable_hwmod(phandle, 0) != 0) {
+	hwmod = ti_prcm_get_hwmod(phandle, 0);
+	if (hwmod == NULL || clk_enable(hwmod) != 0) {
 		aprint_error(": couldn't enable module\n");
 		return;
 	}
@@ -171,22 +184,23 @@ omaptimer_attach(device_t parent, device
 	aprint_naive("\n");
 	aprint_normal(": Timer (%s)\n", modname);
 
+	rate = clk_get_rate(hwmod);
+
 	if (strcmp(modname, "timer2") == 0) {
+		omaptimer_enable(sc, 0);
+
 		/* Install timecounter */
 		tc->tc_get_timecount = omaptimer_get_timecount;
 		tc->tc_counter_mask = ~0u;
-		tc->tc_frequency = 2400;
+		tc->tc_frequency = rate;
 		tc->tc_name = modname;
 		tc->tc_quality = 200;
 		tc->tc_priv = sc;
 		tc_init(tc);
+
 	} else if (strcmp(modname, "timer3") == 0) {
-		/* Configure the timer */
-		const uint32_t value = (0x - ((2400UL / hz) - 1));
-		WR4(sc, TIMER_TLDR, value);
-		WR4(sc, TIMER_TCRR, value);
-		WR4(sc, TIMER_TIER, 0);
-		WR4(sc, TIMER_TCLR, TCLR_ST | TCLR_AR);
+		const uint32_t value = (0x - ((rate / hz) - 1));
+		omaptimer_enable(sc, value);
 
 		/* Use this 

CVS commit: src/sys/arch/arm/ti

2019-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct 30 21:40:04 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c ti_omaptimer.c

Log Message:
Use the hwmod clk to get the timer rate and explicitly enable the
timecounter timer.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/ti_omaptimer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 29 22:19:13 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti ti_com.c ti_dpll_clock.c ti_gpio.c
ti_iic.c ti_omapintc.c ti_omaptimer.c ti_prcm.c ti_prcm.h ti_rng.c
ti_sdhc.c
Added Files:
src/sys/arch/arm/ti: omap3_cm.c omap3_platform.c omap3_prm.c

Log Message:
Add support for TI OMAP3.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/omap3_cm.c \
src/sys/arch/arm/ti/omap3_platform.c src/sys/arch/arm/ti/omap3_prm.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/ti_com.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_dpll_clock.c \
src/sys/arch/arm/ti/ti_gpio.c src/sys/arch/arm/ti/ti_iic.c \
src/sys/arch/arm/ti/ti_omapintc.c src/sys/arch/arm/ti/ti_rng.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_omaptimer.c \
src/sys/arch/arm/ti/ti_prcm.c src/sys/arch/arm/ti/ti_prcm.h \
src/sys/arch/arm/ti/ti_sdhc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-29 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 29 22:19:13 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti ti_com.c ti_dpll_clock.c ti_gpio.c
ti_iic.c ti_omapintc.c ti_omaptimer.c ti_prcm.c ti_prcm.h ti_rng.c
ti_sdhc.c
Added Files:
src/sys/arch/arm/ti: omap3_cm.c omap3_platform.c omap3_prm.c

Log Message:
Add support for TI OMAP3.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/omap3_cm.c \
src/sys/arch/arm/ti/omap3_platform.c src/sys/arch/arm/ti/omap3_prm.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/ti_com.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_dpll_clock.c \
src/sys/arch/arm/ti/ti_gpio.c src/sys/arch/arm/ti/ti_iic.c \
src/sys/arch/arm/ti/ti_omapintc.c src/sys/arch/arm/ti/ti_rng.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/ti_omaptimer.c \
src/sys/arch/arm/ti/ti_prcm.c src/sys/arch/arm/ti/ti_prcm.h \
src/sys/arch/arm/ti/ti_sdhc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.15 src/sys/arch/arm/ti/files.ti:1.16
--- src/sys/arch/arm/ti/files.ti:1.15	Tue Oct 29 10:54:10 2019
+++ src/sys/arch/arm/ti/files.ti	Tue Oct 29 22:19:13 2019
@@ -1,8 +1,9 @@
-#	$NetBSD: files.ti,v 1.15 2019/10/29 10:54:10 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.16 2019/10/29 22:19:13 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_cpufreq.c	soc_ti
 file	arch/arm/ti/am3_platform.c	soc_am33xx
+file	arch/arm/ti/omap3_platform.c	soc_omap3
 
 # Interrupt controller
 device	omapintc: pic, pic_splfuncs
@@ -23,6 +24,16 @@ device	am3prcm { } : fdt, ti_prcm
 attach	am3prcm at fdt with am3_prcm
 file	arch/arm/ti/am3_prcm.c		am3_prcm
 
+# CM (OMAP3)
+device	omap3cm { } : fdt, ti_prcm
+attach	omap3cm at fdt with omap3_cm
+file	arch/arm/ti/omap3_cm.c		omap3_cm
+
+# PRM (OMAP3)
+device	omap3prm { } : fdt
+attach	omap3prm at fdt with omap3_prm
+file	arch/arm/ti/omap3_prm.c		omap3_prm
+
 # Clocks
 device	timuxclk
 attach	timuxclk at fdt with ti_mux_clock
@@ -88,3 +99,4 @@ file	arch/arm/ti/ti_rng.c		ti_rng
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_AM33XX: SOC_TI
+defflag	opt_soc.h			SOC_OMAP3: SOC_TI

Index: src/sys/arch/arm/ti/ti_com.c
diff -u src/sys/arch/arm/ti/ti_com.c:1.7 src/sys/arch/arm/ti/ti_com.c:1.8
--- src/sys/arch/arm/ti/ti_com.c:1.7	Sun Oct 27 12:14:51 2019
+++ src/sys/arch/arm/ti/ti_com.c	Tue Oct 29 22:19:13 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_com.c,v 1.7 2019/10/27 12:14:51 jmcneill Exp $ */
+/* $NetBSD: ti_com.c,v 1.8 2019/10/29 22:19:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.7 2019/10/27 12:14:51 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.8 2019/10/29 22:19:13 jmcneill Exp $");
 
 #include 
 #include 
@@ -105,7 +105,7 @@ ti_com_attach(device_t parent, device_t 
 		return;
 	}
 
-	if (ti_prcm_enable_hwmod(OF_parent(phandle), 0) != 0) {
+	if (ti_prcm_enable_hwmod(phandle, 0) != 0) {
 		aprint_error(": couldn't enable module\n");
 		return;
 	}

Index: src/sys/arch/arm/ti/ti_dpll_clock.c
diff -u src/sys/arch/arm/ti/ti_dpll_clock.c:1.1 src/sys/arch/arm/ti/ti_dpll_clock.c:1.2
--- src/sys/arch/arm/ti/ti_dpll_clock.c:1.1	Mon Oct 28 21:16:47 2019
+++ src/sys/arch/arm/ti/ti_dpll_clock.c	Tue Oct 29 22:19:13 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_dpll_clock.c,v 1.1 2019/10/28 21:16:47 jmcneill Exp $ */
+/* $NetBSD: ti_dpll_clock.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_dpll_clock.c,v 1.1 2019/10/28 21:16:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_dpll_clock.c,v 1.2 2019/10/29 22:19:13 jmcneill Exp $");
 
 #include 
 #include 
@@ -39,24 +39,25 @@ __KERNEL_RCSID(0, "$NetBSD: ti_dpll_cloc
 
 #include 
 
-/* CM_IDLEST_DPLL_MPU */
-#define	ST_MN_BYPASS		__BIT(8)
-#define	ST_DPLL_CLK		__BIT(0)
-
-/* CM_CLKSEL_DPLL_MPU */
-#define	DPLL_BYP_CLKSEL		__BIT(23)
 #define	DPLL_MULT		__BITS(18,8)
 #define	DPLL_DIV		__BITS(6,0)
 
-/* CM_CLKMODE_DPLL_MPU */
-#define	DPLL_EN			__BITS(2,0)
-#define	 DPLL_EN_NM_BYPASS	4
-#define	 DPLL_EN_LOCK		7
-
-static const char * const compatible[] = {
-	"ti,am3-dpll-clock",
-	NULL
-};
+#define	AM3_ST_MN_BYPASS	__BIT(8)
+#define	AM3_ST_DPLL_CLK		__BIT(0)
+
+#define	AM3_DPLL_EN		__BITS(2,0)
+#define	 AM3_DPLL_EN_NM_BYPASS	4
+#define	 AM3_DPLL_EN_LOCK	7
+
+#define	OMAP3_ST_MPU_CLK	__BIT(0)
+
+#define	OMAP3_EN_MPU_DPLL	__BITS(2,0)
+#define	 OMAP3_EN_MPU_DPLL_BYPASS	5
+#define	 OMAP3_EN_MPU_DPLL_LOCK		7
+
+#define	OMAP3_CORE_DPLL_CLKOUT_DIV __BITS(31,27)
+#define	OMAP3_CORE_DPLL_MULT	__BITS(26,16)
+#define	OMAP3_CORE_DPLL_DIV	__BITS(14,8)
 
 static int	ti_dpll_clock_match(device_t, cfdata_t, void *);
 static void	

CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 23:58:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_rng.c ti_rngreg.h

Log Message:
Add support for hardware RNG.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_rng.c \
src/sys/arch/arm/ti/ti_rngreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.6 src/sys/arch/arm/ti/am3_prcm.c:1.7
--- src/sys/arch/arm/ti/am3_prcm.c:1.6	Mon Oct 28 22:21:35 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Mon Oct 28 23:57:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.6 2019/10/28 22:21:35 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.7 2019/10/28 23:57:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.6 2019/10/28 22:21:35 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.7 2019/10/28 23:57:59 jmcneill Exp $");
 
 #include 
 #include 
@@ -124,6 +124,8 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("tptc2", 0x100, "PERIPH_CLK"),
 
 	AM3_PRCM_HWMOD_PER("usb_otg_hs", 0x1c, "PERIPH_CLK"),
+
+	AM3_PRCM_HWMOD_PER("rng", 0x90, "PERIPH_CLK"),
 };
 
 static int

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.13 src/sys/arch/arm/ti/files.ti:1.14
--- src/sys/arch/arm/ti/files.ti:1.13	Mon Oct 28 22:21:35 2019
+++ src/sys/arch/arm/ti/files.ti	Mon Oct 28 23:57:59 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.13 2019/10/28 22:21:35 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.14 2019/10/28 23:57:59 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -80,6 +80,11 @@ file	arch/arm/ti/ti_otg.c		ti_otg
 attach	motg at fdt with ti_motg
 file	arch/arm/ti/ti_motg.c		ti_motg
 
+# RNG
+device	tirng
+attach	tirng at fdt with ti_rng
+file	arch/arm/ti/ti_rng.c		ti_rng
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_TI_AM335X: SOC_TI

Added files:

Index: src/sys/arch/arm/ti/ti_rng.c
diff -u /dev/null src/sys/arch/arm/ti/ti_rng.c:1.1
--- /dev/null	Mon Oct 28 23:58:00 2019
+++ src/sys/arch/arm/ti/ti_rng.c	Mon Oct 28 23:57:59 2019
@@ -0,0 +1,151 @@
+/* $NetBSD: ti_rng.c,v 1.1 2019/10/28 23:57:59 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2015 Jared D. McNeill 
+ * 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. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * 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 
+__KERNEL_RCSID(0, "$NetBSD: ti_rng.c,v 1.1 2019/10/28 23:57:59 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static const char * const compatible[] = {
+	"ti,omap4-rng",
+	NULL
+};
+
+struct ti_rng_softc {
+	device_t sc_dev;
+	bus_space_tag_t sc_iot;
+	bus_space_handle_t sc_ioh;
+
+	kmutex_t sc_lock;
+	krndsource_t sc_rndsource;
+};
+
+static int	ti_rng_match(device_t, cfdata_t, void *);
+static void	ti_rng_attach(device_t, device_t, void *);
+static void	ti_rng_callback(size_t, void *);
+
+CFATTACH_DECL_NEW(ti_rng, sizeof(struct ti_rng_softc),
+ti_rng_match, ti_rng_attach, NULL, NULL);
+
+#define RD4(sc, reg) \
+	bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg))
+#define WR4(sc, reg, val) \
+	bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, (reg), (val))
+
+static int
+ti_rng_match(device_t parent, cfdata_t match, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+ti_rng_attach(device_t parent, device_t self, void *aux)
+{
+	struct ti_rng_softc *sc = 

CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 23:58:00 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_rng.c ti_rngreg.h

Log Message:
Add support for hardware RNG.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_rng.c \
src/sys/arch/arm/ti/ti_rngreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 22:21:35 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_gpio.c

Log Message:
Add support for GPIO controller.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.5 src/sys/arch/arm/ti/am3_prcm.c:1.6
--- src/sys/arch/arm/ti/am3_prcm.c:1.5	Mon Oct 28 21:16:10 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Mon Oct 28 22:21:35 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.5 2019/10/28 21:16:10 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.6 2019/10/28 22:21:35 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.5 2019/10/28 21:16:10 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.6 2019/10/28 22:21:35 jmcneill Exp $");
 
 #include 
 #include 
@@ -101,6 +101,11 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("i2c2", 0x48, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("i2c3", 0x44, "PERIPH_CLK"),
 
+	AM3_PRCM_HWMOD_WKUP("gpio1", 0x8, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("gpio2", 0xac, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("gpio3", 0xb0, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("gpio4", 0xb4, "PERIPH_CLK"),
+
 	AM3_PRCM_HWMOD_WKUP("timer0", 0x10, "FIXED_32K"),
 	AM3_PRCM_HWMOD_PER("timer2", 0x80, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("timer3", 0x84, "PERIPH_CLK"),

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.12 src/sys/arch/arm/ti/files.ti:1.13
--- src/sys/arch/arm/ti/files.ti:1.12	Mon Oct 28 21:16:47 2019
+++ src/sys/arch/arm/ti/files.ti	Mon Oct 28 22:21:35 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.12 2019/10/28 21:16:47 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.13 2019/10/28 22:21:35 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -45,6 +45,11 @@ device	omaptimer
 attach  omaptimer at fdt
 file	arch/arm/ti/ti_omaptimer.c	omaptimer
 
+# GPIO
+device	tigpio: gpiobus
+attach	tigpio at fdt with ti_gpio
+file	arch/arm/ti/ti_gpio.c		ti_gpio
+
 # I2C
 device	tiiic: i2cbus, i2cexec
 attach	tiiic at fdt with ti_iic

Added files:

Index: src/sys/arch/arm/ti/ti_gpio.c
diff -u /dev/null src/sys/arch/arm/ti/ti_gpio.c:1.1
--- /dev/null	Mon Oct 28 22:21:35 2019
+++ src/sys/arch/arm/ti/ti_gpio.c	Mon Oct 28 22:21:35 2019
@@ -0,0 +1,302 @@
+/* $NetBSD: ti_gpio.c,v 1.1 2019/10/28 22:21:35 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * 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 
+__KERNEL_RCSID(0, "$NetBSD: ti_gpio.c,v 1.1 2019/10/28 22:21:35 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+
+#define	GPIO_OE0x134
+#define	GPIO_DATAIN			0x138
+#define	GPIO_CLEARDATAOUT		0x190
+#define	GPIO_SETDATAOUT			0x194
+
+static const char * const compatible[] = {
+	"ti,omap4-gpio",
+	NULL
+};
+
+struct ti_gpio_softc {
+	device_t sc_dev;
+	bus_space_tag_t sc_bst;
+	bus_space_handle_t sc_bsh;
+	kmutex_t sc_lock;
+
+	struct gpio_chipset_tag sc_gp;
+	gpio_pin_t sc_pins[32];
+	device_t sc_gpiodev;
+};
+
+struct ti_gpio_pin {
+	struct ti_gpio_softc *pin_sc;
+	u_int pin_nr;
+	int pin_flags;
+	bool pin_actlo;
+};
+
+#define RD4(sc, reg) 		\
+bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define WR4(sc, reg, val) 	\
+

CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 22:21:35 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_gpio.c

Log Message:
Add support for GPIO controller.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_gpio.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 21:16:47 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti
Added Files:
src/sys/arch/arm/ti: ti_cpufreq.c ti_div_clock.c ti_dpll_clock.c
ti_mux_clock.c

Log Message:
Add AM335x DVFS support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_cpufreq.c \
src/sys/arch/arm/ti/ti_div_clock.c src/sys/arch/arm/ti/ti_dpll_clock.c \
src/sys/arch/arm/ti/ti_mux_clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 21:16:47 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti
Added Files:
src/sys/arch/arm/ti: ti_cpufreq.c ti_div_clock.c ti_dpll_clock.c
ti_mux_clock.c

Log Message:
Add AM335x DVFS support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_cpufreq.c \
src/sys/arch/arm/ti/ti_div_clock.c src/sys/arch/arm/ti/ti_dpll_clock.c \
src/sys/arch/arm/ti/ti_mux_clock.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.11 src/sys/arch/arm/ti/files.ti:1.12
--- src/sys/arch/arm/ti/files.ti:1.11	Sun Oct 27 19:11:07 2019
+++ src/sys/arch/arm/ti/files.ti	Mon Oct 28 21:16:47 2019
@@ -1,7 +1,8 @@
-#	$NetBSD: files.ti,v 1.11 2019/10/27 19:11:07 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.12 2019/10/28 21:16:47 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
+file	arch/arm/ti/ti_cpufreq.c	soc_ti
 
 # Interrupt controller
 device	omapintc: pic, pic_splfuncs
@@ -18,10 +19,23 @@ define	ti_prcm
 file	arch/arm/ti/ti_prcm.c		ti_prcm
 
 # PRCM (AM3xxx)
-device	am3prcm: ti_prcm
+device	am3prcm { } : fdt, ti_prcm
 attach	am3prcm at fdt with am3_prcm
 file	arch/arm/ti/am3_prcm.c		am3_prcm
 
+# Clocks
+device	timuxclk
+attach	timuxclk at fdt with ti_mux_clock
+file	arch/arm/ti/ti_mux_clock.c	ti_mux_clock
+
+device	tidivclk
+attach	tidivclk at fdt with ti_div_clock
+file	arch/arm/ti/ti_div_clock.c	ti_div_clock
+
+device	tidpllclk
+attach	tidpllclk at fdt with ti_dpll_clock
+file	arch/arm/ti/ti_dpll_clock.c	ti_dpll_clock
+
 # UART
 attach	com at fdt with ti_com: ti_prcm
 file	arch/arm/ti/ti_com.c		ti_com needs-flag

Added files:

Index: src/sys/arch/arm/ti/ti_cpufreq.c
diff -u /dev/null src/sys/arch/arm/ti/ti_cpufreq.c:1.1
--- /dev/null	Mon Oct 28 21:16:47 2019
+++ src/sys/arch/arm/ti/ti_cpufreq.c	Mon Oct 28 21:16:47 2019
@@ -0,0 +1,113 @@
+/* $NetBSD: ti_cpufreq.c,v 1.1 2019/10/28 21:16:47 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * 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 "opt_soc.h"
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: ti_cpufreq.c,v 1.1 2019/10/28 21:16:47 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+static bool		ti_opp_probed = false;
+static bool		(*ti_opp_supportedfn)(const int, const int);
+static struct syscon	*ti_opp_syscon;
+
+#ifdef SOC_TI_AM335X
+
+#define	AM33XX_REV_OFFSET	0x0600
+#define	AM33XX_REV_MASK		0xf000
+#define	AM33XX_EFUSE_OFFSET	0x07fc
+#define	AM33XX_EFUSE_MASK	0x1fff
+#define	AM33XX_EFUSE_DEFAULT	0x1e2f
+
+static const char * const am33xx_compatible[] = { "ti,am33xx", NULL };
+
+static bool
+am33xx_opp_supported(const int opp_table, const int opp_node)
+{
+	const u_int *supported_hw;
+	uint32_t efuse, rev;
+	int len;
+
+	syscon_lock(ti_opp_syscon);
+	rev = __SHIFTOUT(syscon_read_4(ti_opp_syscon, AM33XX_REV_OFFSET), AM33XX_REV_MASK);
+	efuse = __SHIFTOUT(syscon_read_4(ti_opp_syscon, AM33XX_EFUSE_OFFSET), AM33XX_EFUSE_MASK);
+	syscon_unlock(ti_opp_syscon);
+
+	if (efuse == 0)
+		efuse = AM33XX_EFUSE_DEFAULT;
+	efuse = ~efuse;
+
+	supported_hw = fdtbus_get_prop(opp_node, "opp-supported-hw", );
+	if (len != 8)
+		return false;
+
+	if ((rev & be32toh(supported_hw[0])) == 0)
+		return false;
+
+	if ((efuse & be32toh(supported_hw[1])) == 0)
+		return false;
+
+	return true;
+}
+#endif
+
+static void
+ti_opp_probe(const int opp_table)
+{
+	if (ti_opp_probed)
+		return;
+	ti_opp_probed = true;
+
+	ti_opp_syscon = 

CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 21:16:10 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
enumerate devices under child "clocks" node


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/am3_prcm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.4 src/sys/arch/arm/ti/am3_prcm.c:1.5
--- src/sys/arch/arm/ti/am3_prcm.c:1.4	Sun Oct 27 19:11:07 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Mon Oct 28 21:16:10 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.4 2019/10/27 19:11:07 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.5 2019/10/28 21:16:10 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.4 2019/10/27 19:11:07 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.5 2019/10/28 21:16:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -134,6 +134,7 @@ am3_prcm_attach(device_t parent, device_
 {
 	struct ti_prcm_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
+	int clocks;
 
 	sc->sc_dev = self;
 	sc->sc_phandle = faa->faa_phandle;
@@ -147,4 +148,8 @@ am3_prcm_attach(device_t parent, device_
 
 	aprint_naive("\n");
 	aprint_normal(": AM3xxx PRCM\n");
+
+	clocks = of_find_firstchild_byname(sc->sc_phandle, "clocks");
+	if (clocks > 0)
+		fdt_add_bus(self, clocks, faa);
 }



CVS commit: src/sys/arch/arm/ti

2019-10-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 28 21:16:10 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c

Log Message:
enumerate devices under child "clocks" node


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/am3_prcm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 23:25:38 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c

Log Message:
Get mac address from DT


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/if_cpsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/if_cpsw.c
diff -u src/sys/arch/arm/ti/if_cpsw.c:1.6 src/sys/arch/arm/ti/if_cpsw.c:1.7
--- src/sys/arch/arm/ti/if_cpsw.c:1.6	Wed May 29 06:17:27 2019
+++ src/sys/arch/arm/ti/if_cpsw.c	Sun Oct 27 23:25:38 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.6 2019/05/29 06:17:27 msaitoh Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.7 2019/10/27 23:25:38 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.6 2019/05/29 06:17:27 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.7 2019/10/27 23:25:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -398,14 +398,14 @@ cpsw_attach(device_t parent, device_t se
 {
 	struct fdt_attach_args * const faa = aux;
 	struct cpsw_softc * const sc = device_private(self);
-	prop_dictionary_t dict = device_properties(self);
 	struct ethercom * const ec = >sc_ec;
 	struct ifnet * const ifp = >ec_if;
 	struct mii_data * const mii = >sc_mii;
 	const int phandle = faa->faa_phandle;
+	const uint8_t *macaddr;
 	bus_addr_t addr;
 	bus_size_t size;
-	int error;
+	int error, slave, len;
 	u_int i;
 
 	KERNHIST_INIT(cpswhist, 4096);
@@ -423,8 +423,14 @@ cpsw_attach(device_t parent, device_t se
 	callout_init(>sc_tick_ch, 0);
 	callout_setfunc(>sc_tick_ch, cpsw_tick, sc);
 
-	prop_data_t eaprop = prop_dictionary_get(dict, "mac-address");
-	if (eaprop == NULL) {
+	macaddr = NULL;
+	slave = of_find_firstchild_byname(phandle, "slave");
+	if (slave > 0) {
+		macaddr = fdtbus_get_prop(slave, "mac-address", );
+		if (len != ETHER_ADDR_LEN)
+			macaddr = NULL;
+	}
+	if (macaddr == NULL) {
 #if 0
 		/* grab mac_id0 from AM335x control module */
 		uint32_t reg_lo, reg_hi;
@@ -461,10 +467,7 @@ cpsw_attach(device_t parent, device_t se
 #endif
 		}
 	} else {
-		KASSERT(prop_object_type(eaprop) == PROP_TYPE_DATA);
-		KASSERT(prop_data_size(eaprop) == ETHER_ADDR_LEN);
-		memcpy(sc->sc_enaddr, prop_data_data_nocopy(eaprop),
-		ETHER_ADDR_LEN);
+		memcpy(sc->sc_enaddr, macaddr, ETHER_ADDR_LEN);
 	}
 
 #if 0



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 23:25:38 UTC 2019

Modified Files:
src/sys/arch/arm/ti: if_cpsw.c

Log Message:
Get mac address from DT


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/if_cpsw.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 21:26:04 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_platform.c

Log Message:
Fix early putchar, add reset func


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_platform.c
diff -u src/sys/arch/arm/ti/ti_platform.c:1.8 src/sys/arch/arm/ti/ti_platform.c:1.9
--- src/sys/arch/arm/ti/ti_platform.c:1.8	Sun Oct 27 17:58:42 2019
+++ src/sys/arch/arm/ti/ti_platform.c	Sun Oct 27 21:26:04 2019
@@ -1,9 +1,9 @@
-/* $NetBSD: ti_platform.c,v 1.8 2019/10/27 17:58:42 jmcneill Exp $ */
+/* $NetBSD: ti_platform.c,v 1.9 2019/10/27 21:26:04 jmcneill Exp $ */
 
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.8 2019/10/27 17:58:42 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.9 2019/10/27 21:26:04 jmcneill Exp $");
 
 #include 
 
@@ -26,7 +26,7 @@ void
 am33xx_platform_early_putchar(char c)
 {
 #ifdef CONSADDR
-#define CONSADDR_VA ((CONSADDR - 0x44c0) + 0xe4c0)
+#define CONSADDR_VA ((CONSADDR - 0x44c0) + (KERNEL_IO_VBASE | 0x04c0))
 	volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ?
 	(volatile uint32_t *)CONSADDR_VA :
 	(volatile uint32_t *)CONSADDR;
@@ -130,12 +130,21 @@ am33xx_platform_delay(u_int n)
 	}
 }
 
+static void
+am33xx_platform_reset(void)
+{
+	volatile uint32_t *resetaddr = (volatile uint32_t *)(KERNEL_IO_VBASE | 0x04e00f00);
+
+	*resetaddr = 1;
+}
+
 static const struct arm_platform am33xx_platform = {
 	.ap_devmap = am33xx_platform_devmap,
 	.ap_init_attach_args = am33xx_platform_init_attach_args,
 	.ap_bootstrap = am33xx_platform_bootstrap,
 	.ap_uart_freq = am33xx_platform_uart_freq,
 	.ap_delay = am33xx_platform_delay,
+	.ap_reset = am33xx_platform_reset,
 };
 
 ARM_PLATFORM(am33xx, "ti,am33xx", _platform);



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 21:26:04 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_platform.c

Log Message:
Fix early putchar, add reset func


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/ti_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 19:11:07 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_iic.c ti_iicreg.h

Log Message:
Add I2C support.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_iic.c \
src/sys/arch/arm/ti/ti_iicreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 19:11:07 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_iic.c ti_iicreg.h

Log Message:
Add I2C support.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_iic.c \
src/sys/arch/arm/ti/ti_iicreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.3 src/sys/arch/arm/ti/am3_prcm.c:1.4
--- src/sys/arch/arm/ti/am3_prcm.c:1.3	Sun Oct 27 16:31:26 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Sun Oct 27 19:11:07 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.3 2019/10/27 16:31:26 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.4 2019/10/27 19:11:07 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.3 2019/10/27 16:31:26 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.4 2019/10/27 19:11:07 jmcneill Exp $");
 
 #include 
 #include 
@@ -97,6 +97,10 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("uart4", 0x78, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("uart5", 0x38, "PERIPH_CLK"),
 
+	AM3_PRCM_HWMOD_WKUP("i2c1", 0xb8, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("i2c2", 0x48, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("i2c3", 0x44, "PERIPH_CLK"),
+
 	AM3_PRCM_HWMOD_WKUP("timer0", 0x10, "FIXED_32K"),
 	AM3_PRCM_HWMOD_PER("timer2", 0x80, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("timer3", 0x84, "PERIPH_CLK"),

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.10 src/sys/arch/arm/ti/files.ti:1.11
--- src/sys/arch/arm/ti/files.ti:1.10	Sun Oct 27 16:31:26 2019
+++ src/sys/arch/arm/ti/files.ti	Sun Oct 27 19:11:07 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.10 2019/10/27 16:31:26 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.11 2019/10/27 19:11:07 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -31,6 +31,11 @@ device	omaptimer
 attach  omaptimer at fdt
 file	arch/arm/ti/ti_omaptimer.c	omaptimer
 
+# I2C
+device	tiiic: i2cbus, i2cexec
+attach	tiiic at fdt with ti_iic
+file	arch/arm/ti/ti_iic.c		ti_iic
+
 # Ethernet
 device  cpsw: ether, ifnet, arp, mii, mii_phy
 attach  cpsw at fdt

Added files:

Index: src/sys/arch/arm/ti/ti_iic.c
diff -u /dev/null src/sys/arch/arm/ti/ti_iic.c:1.1
--- /dev/null	Sun Oct 27 19:11:07 2019
+++ src/sys/arch/arm/ti/ti_iic.c	Sun Oct 27 19:11:07 2019
@@ -0,0 +1,629 @@
+/* $NetBSD: ti_iic.c,v 1.1 2019/10/27 19:11:07 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 2013 Manuel Bouyer.  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.
+ */
+
+/*-
+ * Copyright (c) 2012 Jared D. McNeill 
+ * 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. The name of the author may not be used to endorse or promote products
+ *derived from this software without specific prior written permission.
+ *
+ * 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 

CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 17:59:21 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_omaptimer.c

Log Message:
Use Timer2 for timecounter, and enable hw module.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_omaptimer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_omaptimer.c
diff -u src/sys/arch/arm/ti/ti_omaptimer.c:1.1 src/sys/arch/arm/ti/ti_omaptimer.c:1.2
--- src/sys/arch/arm/ti/ti_omaptimer.c:1.1	Thu Oct 26 01:16:32 2017
+++ src/sys/arch/arm/ti/ti_omaptimer.c	Sun Oct 27 17:59:21 2019
@@ -1,7 +1,7 @@
-/*	$NetBSD: ti_omaptimer.c,v 1.1 2017/10/26 01:16:32 jakllsch Exp $	*/
+/*	$NetBSD: ti_omaptimer.c,v 1.2 2019/10/27 17:59:21 jmcneill Exp $	*/
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.1 2017/10/26 01:16:32 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_omaptimer.c,v 1.2 2019/10/27 17:59:21 jmcneill Exp $");
 
 #include 
 #include 
@@ -15,6 +15,23 @@ __KERNEL_RCSID(0, "$NetBSD: ti_omaptimer
 
 #include 
 
+#include 
+
+#define	TIMER_IRQENABLE_SET	0x2c
+#define	TIMER_IRQENABLE_CLR	0x30
+#define	 MAT_EN_FLAG		__BIT(0)
+#define	 OVF_EN_FLAG		__BIT(1)
+#define	 TCAR_EN_FLAG		__BIT(2)
+#define	TIMER_TCLR		0x38
+#define	 TCLR_ST		__BIT(0)
+#define	 TCLR_AR		__BIT(1)
+#define	TIMER_TCRR		0x3c
+#define	TIMER_TLDR		0x40
+
+/* XXX */
+#define	IS_TIMER2(addr)	((addr) == 0x4804)
+#define	IS_TIMER3(addr)	((addr) == 0x48042000)
+
 static const char * const compatible[] = {
 	"ti,am335x-timer-1ms",
 	"ti,am335x-timer",
@@ -61,12 +78,16 @@ omaptimer_cpu_initclocks(void)
 	
 	aprint_normal_dev(sc->sc_dev, "interrupting on %s\n", intrstr);
 
-	uint32_t value;
-	value = (0x - ((2400UL / hz) - 1));
-	bus_space_write_4(sc->sc_bst, sc->sc_bsh, 0x40, value);
-	bus_space_write_4(sc->sc_bst, sc->sc_bsh, 0x3c, value);
-	bus_space_write_4(sc->sc_bst, sc->sc_bsh, 0x2c, 2);
-	bus_space_write_4(sc->sc_bst, sc->sc_bsh, 0x38, 3);
+	/* Enable interrupts */
+	bus_space_write_4(sc->sc_bst, sc->sc_bsh, TIMER_IRQENABLE_SET, OVF_EN_FLAG);
+}
+
+static u_int
+omaptimer_get_timecount(struct timecounter *tc)
+{
+	struct omaptimer_softc * const sc = tc->tc_priv;
+
+	return bus_space_read_4(sc->sc_bst, sc->sc_bsh, TIMER_TCRR);
 }
 
 static int
@@ -83,6 +104,7 @@ omaptimer_attach(device_t parent, device
 	struct omaptimer_softc * const sc = device_private(self);
 	struct fdt_attach_args * const faa = aux;
 	const int phandle = faa->faa_phandle;
+	struct timecounter *tc = >sc_tc;
 	bus_addr_t addr;
 	bus_size_t size;
 
@@ -107,13 +129,37 @@ omaptimer_attach(device_t parent, device
 		return;
 	}
 
+	if (ti_prcm_enable_hwmod(OF_parent(phandle), 0) != 0) {
+		aprint_error(": couldn't enable module\n");
+		return;
+	}
+
 	aprint_naive("\n");
 	aprint_normal(": Timer\n");
 
-	/* Use this as the OS timer in UP configurations */
-	if (!arm_has_mpext_p && addr == 0x48042000) { /* TIMER3 */
-		timer_softc = sc;
-		arm_fdt_timer_register(omaptimer_cpu_initclocks);
+	if (IS_TIMER2(addr)) {
+		/* Install timecounter */
+		tc->tc_get_timecount = omaptimer_get_timecount;
+		tc->tc_counter_mask = ~0u;
+		tc->tc_frequency = 2400;
+		tc->tc_name = "Timer2";
+		tc->tc_quality = 200;
+		tc->tc_priv = sc;
+		tc_init(tc);
+	} else if (IS_TIMER3(addr)) {
+		/* Configure the timer */
+		const uint32_t value = (0x - ((2400UL / hz) - 1));
+		bus_space_write_4(sc->sc_bst, sc->sc_bsh, TIMER_TLDR, value);
+		bus_space_write_4(sc->sc_bst, sc->sc_bsh, TIMER_TCRR, value);
+		bus_space_write_4(sc->sc_bst, sc->sc_bsh, TIMER_IRQENABLE_CLR, 
+		MAT_EN_FLAG | OVF_EN_FLAG | TCAR_EN_FLAG);
+		bus_space_write_4(sc->sc_bst, sc->sc_bsh, TIMER_TCLR, TCLR_ST | TCLR_AR);
+
+		/* Use this as the OS timer in UP configurations */
+		if (!arm_has_mpext_p) {
+			timer_softc = sc;
+			arm_fdt_timer_register(omaptimer_cpu_initclocks);
+		}
 	}
 }
 



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 17:59:21 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_omaptimer.c

Log Message:
Use Timer2 for timecounter, and enable hw module.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_omaptimer.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 17:58:42 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_platform.c

Log Message:
Place devmap above KERNEL_IO_VBASE


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/ti_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 17:58:42 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_platform.c

Log Message:
Place devmap above KERNEL_IO_VBASE


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/ti_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_platform.c
diff -u src/sys/arch/arm/ti/ti_platform.c:1.7 src/sys/arch/arm/ti/ti_platform.c:1.8
--- src/sys/arch/arm/ti/ti_platform.c:1.7	Sat Oct 26 15:58:15 2019
+++ src/sys/arch/arm/ti/ti_platform.c	Sun Oct 27 17:58:42 2019
@@ -1,9 +1,9 @@
-/* $NetBSD: ti_platform.c,v 1.7 2019/10/26 15:58:15 jmcneill Exp $ */
+/* $NetBSD: ti_platform.c,v 1.8 2019/10/27 17:58:42 jmcneill Exp $ */
 
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.7 2019/10/26 15:58:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.8 2019/10/27 17:58:42 jmcneill Exp $");
 
 #include 
 
@@ -14,6 +14,8 @@ __KERNEL_RCSID(0, "$NetBSD: ti_platform.
 
 #include 
 
+#include 
+
 extern struct bus_space armv7_generic_bs_tag;
 extern struct bus_space armv7_generic_a4x_bs_tag;
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
@@ -41,9 +43,9 @@ static const struct pmap_devmap *
 am33xx_platform_devmap(void)
 {
 	static const struct pmap_devmap devmap[] = {
-		DEVMAP_ENTRY(0xe4c0, 0x44c0, 0x0040),
-		DEVMAP_ENTRY(0xe800, 0x4800, 0x0100),
-		DEVMAP_ENTRY(0xea00, 0x4a00, 0x0100),
+		DEVMAP_ENTRY(KERNEL_IO_VBASE | 0x04c0, 0x44c0, 0x0040),
+		DEVMAP_ENTRY(KERNEL_IO_VBASE | 0x0800, 0x4800, 0x0100),
+		DEVMAP_ENTRY(KERNEL_IO_VBASE | 0x0a00, 0x4a00, 0x0100),
 		DEVMAP_ENTRY_END
 	};
 
@@ -120,10 +122,10 @@ am33xx_platform_delay(u_int n)
 	prev = bus_space_read_4(bst, bsh, 0x3c);
 	while (ticks > 0) {
 		cur = bus_space_read_4(bst, bsh, 0x3c);
-		if (cur > prev)
+		if (cur >= prev)
 			ticks -= (cur - prev);
 		else
-			ticks -= (UINT32_MAX - prev + 1 - cur);
+			ticks -= (UINT32_MAX - cur + prev);
 		prev = cur;
 	}
 }
@@ -136,12 +138,4 @@ static const struct arm_platform am33xx_
 	.ap_delay = am33xx_platform_delay,
 };
 
-void dummysetstatclockrate(int);
-void
-dummysetstatclockrate(int newhz)
-{
-}
-__weak_alias(setstatclockrate, dummysetstatclockrate);
-
 ARM_PLATFORM(am33xx, "ti,am33xx", _platform);
-



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 17:21:23 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c ti_sdhcreg.h

Log Message:
Disable autoidle


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_sdhc.c \
src/sys/arch/arm/ti/ti_sdhcreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 17:21:23 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_sdhc.c ti_sdhcreg.h

Log Message:
Disable autoidle


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/ti_sdhc.c \
src/sys/arch/arm/ti/ti_sdhcreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_sdhc.c
diff -u src/sys/arch/arm/ti/ti_sdhc.c:1.1 src/sys/arch/arm/ti/ti_sdhc.c:1.2
--- src/sys/arch/arm/ti/ti_sdhc.c:1.1	Sun Oct 27 15:43:46 2019
+++ src/sys/arch/arm/ti/ti_sdhc.c	Sun Oct 27 17:21:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhc.c,v 1.1 2019/10/27 15:43:46 jmcneill Exp $	*/
+/*	$NetBSD: ti_sdhc.c,v 1.2 2019/10/27 17:21:23 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.1 2019/10/27 15:43:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.2 2019/10/27 17:21:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -297,8 +297,12 @@ no_dma:
 		aprint_error_dev(dev, "Soft reset timeout\n");
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, MMCHS_SYSCONFIG,
 	SYSCONFIG_ENAWAKEUP |
+#if notyet
 	SYSCONFIG_AUTOIDLE |
 	SYSCONFIG_SIDLEMODE_AUTO |
+#else
+	SYSCONFIG_SIDLEMODE_IGNORE |
+#endif
 	SYSCONFIG_CLOCKACTIVITY_FCLK |
 	SYSCONFIG_CLOCKACTIVITY_ICLK);
 
Index: src/sys/arch/arm/ti/ti_sdhcreg.h
diff -u src/sys/arch/arm/ti/ti_sdhcreg.h:1.1 src/sys/arch/arm/ti/ti_sdhcreg.h:1.2
--- src/sys/arch/arm/ti/ti_sdhcreg.h:1.1	Sun Oct 27 15:43:46 2019
+++ src/sys/arch/arm/ti/ti_sdhcreg.h	Sun Oct 27 17:21:23 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: ti_sdhcreg.h,v 1.1 2019/10/27 15:43:46 jmcneill Exp $	*/
+/*	$NetBSD: ti_sdhcreg.h,v 1.2 2019/10/27 17:21:23 jmcneill Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -61,6 +61,7 @@
 #  define SYSCONFIG_CLOCKACTIVITY_ICLK	(1 << 8)
 #  define SYSCONFIG_SIDLEMODE_MASK	(3 << 3)
 #  define SYSCONFIG_SIDLEMODE_AUTO	(2 << 3)
+#  define SYSCONFIG_SIDLEMODE_IGNORE	(1 << 3)
 #  define SYSCONFIG_ENAWAKEUP		(1 << 2)
 #  define SYSCONFIG_SOFTRESET		(1 << 1)
 #  define SYSCONFIG_AUTOIDLE		(1 << 0)



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 16:31:26 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_motg.c ti_otg.c ti_otgreg.h

Log Message:
Add USB support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_motg.c \
src/sys/arch/arm/ti/ti_otg.c src/sys/arch/arm/ti/ti_otgreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.2 src/sys/arch/arm/ti/am3_prcm.c:1.3
--- src/sys/arch/arm/ti/am3_prcm.c:1.2	Sun Oct 27 12:14:51 2019
+++ src/sys/arch/arm/ti/am3_prcm.c	Sun Oct 27 16:31:26 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.2 2019/10/27 12:14:51 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.3 2019/10/27 16:31:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.2 2019/10/27 12:14:51 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.3 2019/10/27 16:31:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -113,6 +113,8 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("tptc0", 0x24, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("tptc1", 0xfc, "PERIPH_CLK"),
 	AM3_PRCM_HWMOD_PER("tptc2", 0x100, "PERIPH_CLK"),
+
+	AM3_PRCM_HWMOD_PER("usb_otg_hs", 0x1c, "PERIPH_CLK"),
 };
 
 static int

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.9 src/sys/arch/arm/ti/files.ti:1.10
--- src/sys/arch/arm/ti/files.ti:1.9	Sun Oct 27 15:43:46 2019
+++ src/sys/arch/arm/ti/files.ti	Sun Oct 27 16:31:26 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.9 2019/10/27 15:43:46 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.10 2019/10/27 16:31:26 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -48,6 +48,14 @@ file	arch/arm/ti/ti_tptc.c		ti_tptc
 attach	sdhc at fdt with ti_sdhc: ti_edma, ti_prcm
 file	arch/arm/ti/ti_sdhc.c		ti_sdhc
 
+# USB
+device	tiotg { } : fdt
+attach	tiotg at fdt with ti_otg
+file	arch/arm/ti/ti_otg.c		ti_otg
+
+attach	motg at fdt with ti_motg
+file	arch/arm/ti/ti_motg.c		ti_motg
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_TI_AM335X: SOC_TI

Added files:

Index: src/sys/arch/arm/ti/ti_motg.c
diff -u /dev/null src/sys/arch/arm/ti/ti_motg.c:1.1
--- /dev/null	Sun Oct 27 16:31:26 2019
+++ src/sys/arch/arm/ti/ti_motg.c	Sun Oct 27 16:31:26 2019
@@ -0,0 +1,237 @@
+/* $NetBSD: ti_motg.c,v 1.1 2019/10/27 16:31:26 jmcneill Exp $ */
+/*
+ * Copyright (c) 2013 Manuel Bouyer.  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 
+__KERNEL_RCSID(0, "$NetBSD: ti_motg.c,v 1.1 2019/10/27 16:31:26 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#ifdef USB_DEBUG
+#ifndef MOTG_DEBUG
+#define motgdebug 0
+#else
+extern int motgdebug;
+#endif /* MOTG_DEBUG */
+#endif /* USB_DEBUG */
+
+#define	DPRINTF(FMT,A,B,C,D)	USBHIST_LOGN(motgdebug,1,FMT,A,B,C,D)
+#define	MOTGHIST_FUNC()		USBHIST_FUNC()
+#define	MOTGHIST_CALLED(name)	USBHIST_CALLED(motgdebug)
+
+static const char * compatible [] = {
+	"ti,musb-am33xx",
+	NULL
+};
+
+/*
+ * motg device attachement and driver,
+ * for the per-port part of the controller: TI-specific part, phy and
+ * MI Mentor OTG.
+ */
+
+struct ti_motg_softc {
+	struct motg_softc	sc_motg;
+	bus_space_tag_t		sc_ctrliot;
+	bus_space_handle_t	

CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 16:31:26 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti
Added Files:
src/sys/arch/arm/ti: ti_motg.c ti_otg.c ti_otgreg.h

Log Message:
Add USB support.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/ti/am3_prcm.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_motg.c \
src/sys/arch/arm/ti/ti_otg.c src/sys/arch/arm/ti/ti_otgreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 15:43:46 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti
Added Files:
src/sys/arch/arm/ti: ti_sdhc.c ti_sdhcreg.h

Log Message:
Add MMCHS support.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_sdhc.c \
src/sys/arch/arm/ti/ti_sdhcreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 15:43:46 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti
Added Files:
src/sys/arch/arm/ti: ti_sdhc.c ti_sdhcreg.h

Log Message:
Add MMCHS support.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_sdhc.c \
src/sys/arch/arm/ti/ti_sdhcreg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.8 src/sys/arch/arm/ti/files.ti:1.9
--- src/sys/arch/arm/ti/files.ti:1.8	Sun Oct 27 12:14:51 2019
+++ src/sys/arch/arm/ti/files.ti	Sun Oct 27 15:43:46 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.8 2019/10/27 12:14:51 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.9 2019/10/27 15:43:46 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -44,6 +44,10 @@ device	titptc
 attach	titptc at fdt with ti_tptc
 file	arch/arm/ti/ti_tptc.c		ti_tptc
 
+# MMCHS
+attach	sdhc at fdt with ti_sdhc: ti_edma, ti_prcm
+file	arch/arm/ti/ti_sdhc.c		ti_sdhc
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_TI_AM335X: SOC_TI

Added files:

Index: src/sys/arch/arm/ti/ti_sdhc.c
diff -u /dev/null src/sys/arch/arm/ti/ti_sdhc.c:1.1
--- /dev/null	Sun Oct 27 15:43:46 2019
+++ src/sys/arch/arm/ti/ti_sdhc.c	Sun Oct 27 15:43:46 2019
@@ -0,0 +1,672 @@
+/*	$NetBSD: ti_sdhc.c,v 1.1 2019/10/27 15:43:46 jmcneill Exp $	*/
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * 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 
+__KERNEL_RCSID(0, "$NetBSD: ti_sdhc.c,v 1.1 2019/10/27 15:43:46 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#define EDMA_MAX_PARAMS		32
+
+#ifdef TISDHC_DEBUG
+int tisdhcdebug = 1;
+#define DPRINTF(n,s)do { if ((n) <= tisdhcdebug) device_printf s; } while (0)
+#else
+#define DPRINTF(n,s)do {} while (0)
+#endif
+
+
+#define CLKD(kz)	(sc->sc.sc_clkbase / (kz))
+
+#define SDHC_READ(sc, reg) \
+	bus_space_read_4((sc)->sc_bst, (sc)->sc_sdhc_bsh, (reg))
+#define SDHC_WRITE(sc, reg, val) \
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_sdhc_bsh, (reg), (val))
+
+struct ti_sdhc_config {
+	bus_size_t		regoff;
+	uint32_t		flags;
+};
+
+static const struct ti_sdhc_config omap2_hsmmc_config = {
+};
+
+static const struct ti_sdhc_config omap3_pre_es3_hsmmc_config = {
+	.flags = SDHC_FLAG_SINGLE_ONLY
+};
+
+static const struct ti_sdhc_config omap4_hsmmc_config = {
+	.regoff = 0x100
+};
+
+static const struct of_compat_data compat_data[] = {
+	{ "ti,omap2-hsmmc",		(uintptr_t)_hsmmc_config },
+	{ "ti,omap3-hsmmc",		(uintptr_t)_hsmmc_config },
+	{ "ti,omap3-pre-es3-hsmmc",	(uintptr_t)_pre_es3_hsmmc_config },
+	{ "ti,omap4-hsmmc",		(uintptr_t)_hsmmc_config },
+	{ NULL }
+};
+
+enum {
+	EDMA_CHAN_TX,
+	EDMA_CHAN_RX,
+	EDMA_NCHAN
+};
+
+struct ti_sdhc_softc {
+	struct sdhc_softc	sc;
+	int			sc_phandle;
+	bus_addr_t		sc_addr;
+	bus_space_tag_t		sc_bst;
+	bus_space_handle_t	sc_bsh;
+	bus_space_handle_t	sc_hl_bsh;
+	bus_space_handle_t	sc_sdhc_bsh;
+	struct sdhc_host	*sc_hosts[1];
+	void 			*sc_ih;		/* interrupt vectoring */
+
+	int			sc_edma_chan[EDMA_NCHAN];
+	struct edma_channel	*sc_edma_tx;
+	struct edma_channel	*sc_edma_rx;
+	uint16_t		sc_edma_param_tx[EDMA_MAX_PARAMS];
+	uint16_t		

CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 12:14:51 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti ti_com.c ti_prcm.c ti_prcm.h
Added Files:
src/sys/arch/arm/ti: ti_edma.c ti_edma.h ti_tptc.c

Log Message:
Add EDMA TPCC and TPTC drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/am3_prcm.c \
src/sys/arch/arm/ti/ti_prcm.c src/sys/arch/arm/ti/ti_prcm.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_com.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_edma.c \
src/sys/arch/arm/ti/ti_edma.h src/sys/arch/arm/ti/ti_tptc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/am3_prcm.c
diff -u src/sys/arch/arm/ti/am3_prcm.c:1.1 src/sys/arch/arm/ti/am3_prcm.c:1.2
--- src/sys/arch/arm/ti/am3_prcm.c:1.1	Thu Oct 26 23:28:15 2017
+++ src/sys/arch/arm/ti/am3_prcm.c	Sun Oct 27 12:14:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: am3_prcm.c,v 1.1 2017/10/26 23:28:15 jmcneill Exp $ */
+/* $NetBSD: am3_prcm.c,v 1.2 2019/10/27 12:14:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.1 2017/10/26 23:28:15 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: am3_prcm.c,v 1.2 2019/10/27 12:14:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -108,6 +108,11 @@ static struct ti_prcm_clk am3_prcm_clks[
 	AM3_PRCM_HWMOD_PER("mmc0", 0x3c, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc1", 0xf4, "MMC_CLK"),
 	AM3_PRCM_HWMOD_PER("mmc2", 0xf8, "MMC_CLK"),
+
+	AM3_PRCM_HWMOD_PER("tpcc", 0xbc, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("tptc0", 0x24, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("tptc1", 0xfc, "PERIPH_CLK"),
+	AM3_PRCM_HWMOD_PER("tptc2", 0x100, "PERIPH_CLK"),
 };
 
 static int
Index: src/sys/arch/arm/ti/ti_prcm.c
diff -u src/sys/arch/arm/ti/ti_prcm.c:1.1 src/sys/arch/arm/ti/ti_prcm.c:1.2
--- src/sys/arch/arm/ti/ti_prcm.c:1.1	Thu Oct 26 23:28:15 2017
+++ src/sys/arch/arm/ti/ti_prcm.c	Sun Oct 27 12:14:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_prcm.c,v 1.1 2017/10/26 23:28:15 jmcneill Exp $ */
+/* $NetBSD: ti_prcm.c,v 1.2 2019/10/27 12:14:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_prcm.c,v 1.1 2017/10/26 23:28:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_prcm.c,v 1.2 2019/10/27 12:14:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -255,3 +255,15 @@ ti_prcm_get_hwmod(const int phandle, u_i
 
 	return NULL;
 }
+
+int
+ti_prcm_enable_hwmod(const int phandle, u_int index)
+{
+	struct clk *clk;
+
+	clk = ti_prcm_get_hwmod(phandle, index);
+	if (clk == NULL)
+		return ENOENT;
+
+	return clk_enable(clk);
+}
Index: src/sys/arch/arm/ti/ti_prcm.h
diff -u src/sys/arch/arm/ti/ti_prcm.h:1.1 src/sys/arch/arm/ti/ti_prcm.h:1.2
--- src/sys/arch/arm/ti/ti_prcm.h:1.1	Thu Oct 26 23:28:15 2017
+++ src/sys/arch/arm/ti/ti_prcm.h	Sun Oct 27 12:14:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_prcm.h,v 1.1 2017/10/26 23:28:15 jmcneill Exp $ */
+/* $NetBSD: ti_prcm.h,v 1.2 2019/10/27 12:14:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -165,5 +165,6 @@ struct ti_prcm_softc {
 #endif /* !TI_PRCM_PRIVATE */
 
 struct clk *	ti_prcm_get_hwmod(const int, u_int);
+int		ti_prcm_enable_hwmod(const int, u_int);
 
 #endif /* !_ARM_TI_PRCM_H */

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.7 src/sys/arch/arm/ti/files.ti:1.8
--- src/sys/arch/arm/ti/files.ti:1.7	Sun Oct 27 11:33:56 2019
+++ src/sys/arch/arm/ti/files.ti	Sun Oct 27 12:14:51 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.7 2019/10/27 11:33:56 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.8 2019/10/27 12:14:51 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -36,6 +36,14 @@ device  cpsw: ether, ifnet, arp, mii, mi
 attach  cpsw at fdt
 filearch/arm/ti/if_cpsw.c		cpsw
 
+# EDMA
+device	tiedma
+attach	tiedma at fdt with ti_edma
+file	arch/arm/ti/ti_edma.c		ti_edma
+device	titptc
+attach	titptc at fdt with ti_tptc
+file	arch/arm/ti/ti_tptc.c		ti_tptc
+
 # SOC parameters
 defflag	opt_soc.h			SOC_TI
 defflag	opt_soc.h			SOC_TI_AM335X: SOC_TI

Index: src/sys/arch/arm/ti/ti_com.c
diff -u src/sys/arch/arm/ti/ti_com.c:1.6 src/sys/arch/arm/ti/ti_com.c:1.7
--- src/sys/arch/arm/ti/ti_com.c:1.6	Sun Oct 27 11:33:56 2019
+++ src/sys/arch/arm/ti/ti_com.c	Sun Oct 27 12:14:51 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_com.c,v 1.6 2019/10/27 11:33:56 jmcneill Exp $ */
+/* $NetBSD: ti_com.c,v 1.7 2019/10/27 12:14:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.6 2019/10/27 11:33:56 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.7 2019/10/27 12:14:51 jmcneill Exp $");
 
 #include 
 #include 
@@ -79,7 +79,6 @@ ti_com_attach(device_t parent, device_t 
 	

CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 12:14:51 UTC 2019

Modified Files:
src/sys/arch/arm/ti: am3_prcm.c files.ti ti_com.c ti_prcm.c ti_prcm.h
Added Files:
src/sys/arch/arm/ti: ti_edma.c ti_edma.h ti_tptc.c

Log Message:
Add EDMA TPCC and TPTC drivers.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/ti/am3_prcm.c \
src/sys/arch/arm/ti/ti_prcm.c src/sys/arch/arm/ti/ti_prcm.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_com.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_edma.c \
src/sys/arch/arm/ti/ti_edma.h src/sys/arch/arm/ti/ti_tptc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 11:33:56 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti ti_com.c

Log Message:
Make com work again


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/ti_com.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.6 src/sys/arch/arm/ti/files.ti:1.7
--- src/sys/arch/arm/ti/files.ti:1.6	Sat Oct 26 15:58:55 2019
+++ src/sys/arch/arm/ti/files.ti	Sun Oct 27 11:33:56 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.6 2019/10/26 15:58:55 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.7 2019/10/27 11:33:56 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -23,10 +23,8 @@ attach	am3prcm at fdt with am3_prcm
 file	arch/arm/ti/am3_prcm.c		am3_prcm
 
 # UART
-ifdef soc_ti
 attach	com at fdt with ti_com: ti_prcm
 file	arch/arm/ti/ti_com.c		ti_com needs-flag
-endif
 
 # Timer
 device	omaptimer

Index: src/sys/arch/arm/ti/ti_com.c
diff -u src/sys/arch/arm/ti/ti_com.c:1.5 src/sys/arch/arm/ti/ti_com.c:1.6
--- src/sys/arch/arm/ti/ti_com.c:1.5	Fri Oct 18 06:58:06 2019
+++ src/sys/arch/arm/ti/ti_com.c	Sun Oct 27 11:33:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_com.c,v 1.5 2019/10/18 06:58:06 skrll Exp $ */
+/* $NetBSD: ti_com.c,v 1.6 2019/10/27 11:33:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.5 2019/10/18 06:58:06 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.6 2019/10/27 11:33:56 jmcneill Exp $");
 
 #include 
 #include 
@@ -106,7 +106,7 @@ ti_com_attach(device_t parent, device_t 
 		return;
 	}
 
-	hwmod = ti_prcm_get_hwmod(phandle, 0);
+	hwmod = ti_prcm_get_hwmod(OF_parent(phandle), 0);
 	KASSERT(hwmod != NULL);
 	if (clk_enable(hwmod) != 0) {
 		aprint_error(": couldn't enable module\n");



CVS commit: src/sys/arch/arm/ti

2019-10-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 27 11:33:56 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti ti_com.c

Log Message:
Make com work again


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/ti_com.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 26 15:58:55 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti
Added Files:
src/sys/arch/arm/ti: ti_sysc.c

Log Message:
Add bus driver for TI sysc interconncet.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_sysc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/files.ti
diff -u src/sys/arch/arm/ti/files.ti:1.5 src/sys/arch/arm/ti/files.ti:1.6
--- src/sys/arch/arm/ti/files.ti:1.5	Sat Oct 26 14:57:27 2019
+++ src/sys/arch/arm/ti/files.ti	Sat Oct 26 15:58:55 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: files.ti,v 1.5 2019/10/26 14:57:27 jmcneill Exp $
+#	$NetBSD: files.ti,v 1.6 2019/10/26 15:58:55 jmcneill Exp $
 #
 
 file	arch/arm/ti/ti_platform.c	soc_ti
@@ -6,7 +6,12 @@ file	arch/arm/ti/ti_platform.c	soc_ti
 # Interrupt controller
 device	omapintc: pic, pic_splfuncs
 attach  omapintc at fdt
-file	arch/arm/ti/ti_omapintc.c omapintc
+file	arch/arm/ti/ti_omapintc.c	omapintc
+
+# sysc interconnect
+device	tisysc { } : fdt, ti_prcm
+attach	tisysc at fdt with ti_sysc
+file	arch/arm/ti/ti_sysc.c		ti_sysc
 
 # PRCM
 define	ti_prcm

Added files:

Index: src/sys/arch/arm/ti/ti_sysc.c
diff -u /dev/null src/sys/arch/arm/ti/ti_sysc.c:1.1
--- /dev/null	Sat Oct 26 15:58:55 2019
+++ src/sys/arch/arm/ti/ti_sysc.c	Sat Oct 26 15:58:55 2019
@@ -0,0 +1,72 @@
+/* $NetBSD: ti_sysc.c,v 1.1 2019/10/26 15:58:55 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2019 Jared McNeill 
+ * 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 
+__KERNEL_RCSID(0, "$NetBSD: ti_sysc.c,v 1.1 2019/10/26 15:58:55 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+static int	ti_sysc_match(device_t, cfdata_t, void *);
+static void	ti_sysc_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(ti_sysc, 0, ti_sysc_match, ti_sysc_attach, NULL, NULL);
+
+static const char * compatible[] = {
+	"ti,sysc",
+	NULL
+};
+
+static int
+ti_sysc_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+
+	return of_match_compatible(faa->faa_phandle, compatible);
+}
+
+static void
+ti_sysc_attach(device_t parent, device_t self, void *aux)
+{
+	struct fdt_attach_args * const faa = aux;
+	const int phandle = faa->faa_phandle;
+
+	aprint_naive("\n");
+	aprint_normal("\n");
+
+	fdt_add_bus(self, phandle, faa);
+}



CVS commit: src/sys/arch/arm/ti

2019-10-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 26 15:58:15 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_platform.c

Log Message:
Fix am33xx_platform_early_putchar for pre-MMU output


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_platform.c
diff -u src/sys/arch/arm/ti/ti_platform.c:1.6 src/sys/arch/arm/ti/ti_platform.c:1.7
--- src/sys/arch/arm/ti/ti_platform.c:1.6	Tue Oct 30 16:41:52 2018
+++ src/sys/arch/arm/ti/ti_platform.c	Sat Oct 26 15:58:15 2019
@@ -1,9 +1,9 @@
-/* $NetBSD: ti_platform.c,v 1.6 2018/10/30 16:41:52 skrll Exp $ */
+/* $NetBSD: ti_platform.c,v 1.7 2019/10/26 15:58:15 jmcneill Exp $ */
 
 #include "opt_console.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.6 2018/10/30 16:41:52 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ti_platform.c,v 1.7 2019/10/26 15:58:15 jmcneill Exp $");
 
 #include 
 
@@ -25,7 +25,9 @@ am33xx_platform_early_putchar(char c)
 {
 #ifdef CONSADDR
 #define CONSADDR_VA ((CONSADDR - 0x44c0) + 0xe4c0)
-	volatile uint32_t *uartaddr = (volatile uint32_t *)CONSADDR_VA;
+	volatile uint32_t *uartaddr = cpu_earlydevice_va_p() ?
+	(volatile uint32_t *)CONSADDR_VA :
+	(volatile uint32_t *)CONSADDR;
 
 	while ((le32toh(uartaddr[com_lsr]) & LSR_TXRDY) == 0)
 		;



CVS commit: src/sys/arch/arm/ti

2019-10-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 26 15:58:55 UTC 2019

Modified Files:
src/sys/arch/arm/ti: files.ti
Added Files:
src/sys/arch/arm/ti: ti_sysc.c

Log Message:
Add bus driver for TI sysc interconncet.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/ti/files.ti
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/ti/ti_sysc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 26 15:58:15 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_platform.c

Log Message:
Fix am33xx_platform_early_putchar for pre-MMU output


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/ti/ti_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct 18 06:58:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_com.c

Log Message:
Use PRIxBUSADDR


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_com.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/ti

2019-10-18 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct 18 06:58:06 UTC 2019

Modified Files:
src/sys/arch/arm/ti: ti_com.c

Log Message:
Use PRIxBUSADDR


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/ti/ti_com.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/ti/ti_com.c
diff -u src/sys/arch/arm/ti/ti_com.c:1.4 src/sys/arch/arm/ti/ti_com.c:1.5
--- src/sys/arch/arm/ti/ti_com.c:1.4	Sat Dec  8 17:46:10 2018
+++ src/sys/arch/arm/ti/ti_com.c	Fri Oct 18 06:58:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ti_com.c,v 1.4 2018/12/08 17:46:10 thorpej Exp $ */
+/* $NetBSD: ti_com.c,v 1.5 2019/10/18 06:58:06 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.4 2018/12/08 17:46:10 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: ti_com.c,v 1.5 2019/10/18 06:58:06 skrll Exp $");
 
 #include 
 #include 
@@ -102,7 +102,7 @@ ti_com_attach(device_t parent, device_t 
 
 	error = bus_space_map(bst, addr, size, 0, );
 	if (error) {
-		aprint_error(": couldn't map %#llx: %d", (uint64_t)addr, error);
+		aprint_error(": couldn't map %#" PRIxBUSADDR ": %d", addr, error);
 		return;
 	}